title: Can we avoid creating a local variable if an optional argument is not PRESENT?
body: <p>I am having a problem with the <code>PRESENT</code> statement with Fortran 95. Currently I am using Silverfrost's Plato and their FTN95 compiler (in "Release Win32" mode). What I wanted to do is to create a subroutine <code>SUB(a,b)</code>, where <code>b</code> is an optional variable. So far so good, but the problem arises when I try to give a new value to <code>b</code> with <code>if (.NOT. present(b)) b=0</code>. This is the code:</p>
  
  <pre><code>module MOD
  contains
    subroutine SUB(a,b)
    implicit none
    integer :: a
    integer,optional :: b
    if (.NOT. present(b)) b=0
    print*, a,b
    end subroutine SUB
  end module MOD
  
  program TEST
  use MOD
  implicit none
  
  integer :: i=2, j=1
  
  call SUB(i,j)
  call SUB(i)
  call SUB(j)
  
  end program TEST
  </code></pre>
  
  <p>Is there an elegant way out of this situation, or do I really need to create another variable, <code>b_aux</code> for instance, and then use the following code?:</p>
  
  <pre><code>if (present(b)) then
    b_aux=b
    else
      b_aux=0
  endif
  </code></pre>