This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why a parameter changes when transfered to subroutine


bin Fan wrote:

Thank you , the simplified example is :


program temp
implicit NONE
real(kind=8)::distance,redshift=0.5D0
real::hubble
call resh_dis(62.0D0,distance) //if this was call resh_dis(62.0, distance) then everything is right
write(*,*) "redshift:",redshift
write(*,*) "distance:",distance
end


subroutine resh_dis(hubble,distance)
  implicit NONE
  real(kind=8)::hubble,distance
  distance = 1.0D0 /hubble
  return
end subroutine


It works fine for me with 4.1.3 20070525. I also tested 4.2 and 4.3. All work fine.


$ gfc resh.f90
$ ./a.out
 redshift:  0.500000000000000
 distance:  1.612903225806452E-002
$ gfc41 -static resh.f90
$ ./a.out
 redshift:  0.500000000000000
 distance:  1.612903225806452E-002
$ gfc42 -static resh.f90
$ ./a.out
 redshift:  0.500000000000000
 distance:  1.612903225806452E-002

I don't know what to say other than to get a later version of gfortran and try it. 4.1.1 is getting pretty old.

Check here: http://gcc.gnu.org/wiki/GFortran#download

Regards,

Jerry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]