只需查看以下简单代码:
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
不应被评估,在这种情况下为空。