New Reply

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

 
Share Thread Thread Tools
Jun11-12, 03:13 PM   #1
 

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


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.
 
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Heat-related deaths in Manhattan projected to rise
>> Dire outlook despite global warming 'pause': study
>> Sea level influenced tropical climate during the last ice age
New Reply

Tags
fortran, present() function, subroutine
Thread Tools


Similar Threads for: Fortran90: present() function doesn't work in subroutines
Thread Forum Replies
How does the Fortran90 function floor not have a main type? Programming & Comp Sci 6
Calculating work when 2 forces are present Introductory Physics Homework 6
Problem with fortran 90 Present() function Programming & Comp Sci 2
I have something that doesn't work out for me Differential Equations 2
Why this doesn't work? General Discussion 9