I am trying to write a simple program, which is expected to be used in generating random numbers between 0~1. The programming is performed on the Linux platform with pgf90 compiler.
If directly generating the numbers in the main program, I can get normal results. However, when putting the generating function into a subroutine, I found that the main program gave different results. It is quite weird, for both programs work normaly in Microsoft Powerstation and can give completely same results.
The two programs are listed as below, I wish somebody experienced in Pgf90 can help me. Thanks in advance.
test1.f90 (can’t work normaly)
IX=65535
IC=125
IM=65536
AM=0.
XS=0.
yfl=0.0
open (1,file=‘test1.txt’,status=‘unknown’)
do i=1,1000
call randu3(ix,ic,im,yfl)
enddo
end
SUBROUTINE RANDU3(IX,IC,IM,YFL)
real yfl
IF(YFL.NE.0.) GOTO 1
AX=real(IX)
AM=real(IM)
AC=real(IC)
YFL=AX/AM
1 YFL=ACYFL
YFL=YFL-real(IFIX(YFL))
write(1,)‘yfl final’,yfl
RETURN
END
test2.f90 (seems to be OK)
IX=65535
IC=125
IM=65536
AM=0.
XS=0.
yfl=0.0
open (2,file=‘test2.txt’,status=‘unknown’)
do i=1,1000
IF(YFL.NE.0.) GOTO 1
AX=real(IX)
AM=real(IM)
AC=real(IC)
YFL=AX/AM
1 YFL=ACYFL
YFL=YFL-real(IFIX(YFL))
write(2,)‘yfl final’,yfl
enddo
end