我不理解使用pgf90 7.2的present()内在函数的行为.我写了一个20行的示例程序来测试这个,但结果对我来说仍然没有意义.注意:
subroutine testopt(one,two,three,four,five)
implicit none
integer, intent(in) :: one,two
integer, intent(out) :: three
integer, intent(in), optional :: four
integer, intent(out), optional :: five
three = one + two
print *,"present check: ",present(four),present(five)
if (present(four) .and. present(five)) then
five = four*four
end if
end subroutine testopt
Run Code Online (Sandbox Code Playgroud)
如果我:从我的主程序调用testopt(1,2,(任何变量)),它打印:"present check:T F".但是如果我:从子程序中调用testopt(1,2,(任何变量)),它会打印:"present check:T T".我希望在任何一种情况下都能看到"当前检查:F F",因为我只使用3个非可选参数调用子程序,而不是任何可选参数.我无法理解为什么它会以这种方式运行,这导致我正在处理的程序中的一个主要错误.我很欣赏任何见解.谢谢.