pgf90使用可选逻辑参数时导致分段错误

时间:2018-06-20 15:30:48

标签: fortran pgi

只需查看以下简单代码:

program hello

  call foo()

contains

  subroutine foo(bar)

    logical, intent(in), optional :: bar

    if (present(bar) .and. bar) then
      print *, 'hello'
    end if

  end subroutine foo

end program hello

通过pgf90进行编译时,出现Segmentation fault: 11错误,但是使用gfortran时可以。问题应该出在present(bar) .and. bar,但是如果没有给出bar,则present(bar)将被评估为.false.,并且随后的bar不应被评估,在这种情况下为空。

0 个答案:

没有答案
相关问题