title: Fortran 90 Presence Of Optional Arguments
body: <p>I do not understand the behavior of the present() intrinsic function with pgf90 7.2.  I wrote a 20 line sample program to test this, but the results still make no sense to me.  Observe:</p>
  
  <pre><code>
  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
  </code></pre>
  
  <p>if I: call testopt(1,2,(any variable)) from my main program, it prints: "present check: T F".  However if I: call testopt(1,2,(any variable)) from a subprogram it prints: "present check: T T".  I expected to see "present check: F F" in either case, because I am only calling the subroutine with the 3 non-optional arguments, and neither of the optional ones.  I cannot fathom why it would behave this way, and this is causing a major bug in a program I am working on.  I appreciate any insight.  Thanks.</p>