Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran90: present() function doesn't work in subroutines

  1. Jun 11, 2012 #1
    I am using Gfortran 4.4.3 on Ubuntu 10.04 operating system.
    Can someone explain why the following code works correctly (a):-

    program testpresent
    real :: a,b,c
    call test_present(a,b,c)
    contains
    subroutine test_present(x1,x2,x3,x4,x5,x6)
    real, intent(inout), optional :: x1,x2,x3,x4,x5,x6
    write(6,*) present(x1),present(x2),present(x3),present(x4),present(x5),present(x6)
    return
    end subroutine test_present
    end program

    works correctly (T T T F F F) while (b):-

    program testpresent
    real :: a,b,c
    call test_present(a,b,c)
    end program

    subroutine test_present(x1,x2,x3,x4,x5,x6)
    real, intent(inout), optional :: x1,x2,x3,x4,x5,x6
    write(6,*) present(x1),present(x2),present(x3),present(x4),present(x5),present(x6)
    end subroutine test_present

    does not. There is nothing in the documentation that says (b) is wrong, and it compiles without error messages.
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted