RN segmentation fault on compaq


yshzhang88
11-06-2005, 12:27 AM
Dear all,

Now I am trying the following f90 program, ran(idum), to generate random generator.

FUNCTION ran(idum)
IMPLICIT NONE
INTEGER, PARAMETER :: K4B=selected_int_kind(9)
INTEGER(K4B), INTENT(INOUT) :: idum
REAL :: ran

INTEGER(K4B), PARAMETER :: IA=16807,IM=2147483647,IQ=127773,IR=2836
REAL, SAVE :: am
INTEGER(K4B), SAVE :: ix=-1,iy=-1,k
if (idum <= 0 .or. iy < 0) then
am=nearest(1.0,-1.0)/IM
iy=ior(ieor(888889999,abs(idum)),1)
ix=ieor(777755555,abs(idum))
idum=abs(idum)+1
end if

ix=ieor(ix,ishft(ix,13))
ix=ieor(ix,ishft(ix,-17))
ix=ieor(ix,ishft(ix,5))
k=iy/IQ
iy=IA*(iy-k*IQ)-IR*k
if (iy < 0) iy=iy+IM
ran=am*ior(iand(IM,ieor(ix,iy)),1)
END FUNCTION ran

Unfortunetly, I met a very strange problem. When I complie the program by f90 on compaq machine (64 bit), everything is fine. While when I run the excutable, it generate "segmentation fault" .

forrtl: severe (174): SIGSEGV, segmentation fault occurred
0: __FINI_00_remove_gp_range [0x3ff81a6de38]
1: __FINI_00_remove_gp_range [0x3ff81a77414]
2: __FINI_00_remove_gp_range [0x3ff800d4fc0]
3: ran_ [ran.f90: 12, 0x12000a6f0]
4: main$gcmc_ [cons.f90: 242, 0x120004e80]
5: main [for_main.c: 203, 0x12000a80c]
6: __start [0x120002198]

Did anybody meet such problem before? Any suggestion is welcomes.

Thanks lot.

Jack