I am getting a sef fault that I do not understand. Perhaps the best thing is to show you the structure of the code.
integer i real*8 rfblow,rfbhi,drfb,rsmall(NTPMAX),vrelv,mass(NTPMAX) real*16 rsmall16(NTPMAX),ratq,rsmr16 common/c_rsm/rfblow,rfbhi,drfb,rsmall,rsmall16
!$OMP PARALLEL DO SCHEDULE(DYNAMIC) DEFAULT(NONE) !$OMP& PRIVATE(i,rsmr16,vrelv,ratq) !$OMP& SHARED(rsmall16,mass) do i=2,nbod
later in the same loop
write(*,*) 'Here #C0.1',i write(*,*) 'Here #C0.3',rsmr16 write(*,*) 'Here #C0.2',rsmall16(i) write(*,*) 'Here #C0.4',vrelv write(*,*) 'Here #C0.5',mass(i) write(*,*) 'Here #C0.6',ratq call size_qstarrat(i,rsmall16(i),rsmr16,vrelv, & mass(i),ratq)
Then I have the subroutine
subroutine size_qstarrat(id,rtarg,rimp,vrel2,mtr,ratq) integer id real*8 vrel2,mtr,grnd_MT,tglob real*16 rtarg,rimp,dcomet16,ratq real*16 qcap,qstar,qstarcgs,rtargcm real*16 ratm,pdis,ratmlr,ratmf real*16 mtarg,mimp,mnew,rnew c----- c... Executable code write(*,*) 'Here #Q0.1',id write(*,*) 'Here #Q0.2',rimp write(*,*) 'Here #Q0.3',rtarg write(*,*) 'Here #Q0.4',vrel2 write(*,*) 'Here #Q0.5',mtr write(*,*) 'Here #Q0.6',ratq
The output when I run it looks like:
Here #C0.1 6
Here #C0.3 1.337014580143983178473131948054959E-0012
Here #C0.2 7.797292446069711940208707975960478E-0007
Here #C0.4 1.039694216870462E-002
Here #C0.5 1.185758329154166E-006
Here #C0.6 0.000000000000000000000000000000000E+0000
Here #Q0.1 6
Here #Q0.2 1.337014580143983178473131948054959E-0012
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
stryAJtmp 00000000004215A9 size_qstarrat_ 4438 stryAJtmp.f
stryAJtmp 000000000041C432 col_disk_ 1987 stryAJtmp.f
libiomp5.so 00002AC0E7BE4073 Unknown Unknown Unknown
In other words, I get a seg fault when I try to access rtarg in the subroutine. This is rsmall16(i) in the main routine which prints out fine before the call (it is #c0.2). So, for some reason the subroutine is not getting the address correct address for rsmall16(i). Note that rsmall16(i) is part of a common block, but the subroutine does not know about that. I need to keep it that way because I use the subroutine other places when the input is not part of the common block.
I should note that I have several machines with different versions of ifort. The machines with version 11.1 20100414
DO NOT HAVE THIS PROBLEM, but my machines with version 12.1.3 20120212 and 13.0.0 20120731 do.
I am compiling it with:
ifort -mcmodel=medium -i-dynamic -heap-arrays -openmp -fpe0 -traceback -w -recursive -o stryAJtmp stryAJtmp.f -L/usr/local/lib/ -L/home/hal/lib/ -I/home/hal/SWIFT_P/ -L/home/hal/SWIFT_P/ -lswift -lfxdr -lMT_rand_OMP
and my libraires are also compiled with these flags. Also, I have KMP_STACKSIZE=64m and OMP_NUM_THREADS 1
I tried to reproduce the problem with a simple code:
real*16 x(100) common/c_test/x do i=1,100 x(i) = i enddo !$OMP PARALLEL DO SCHEDULE(DYNAMIC) DEFAULT(NONE) !$OMP& PRIVATE(i) !$OMP& SHARED(x) do i=1,100 call sub(x(i)) enddo !$OMP END PARALLEL DO stop end c--- subroutine sub(x) real*16 x write(*,*) x return end
but, unfortunately, this worked fine.
Thanks for any insight that you can give me.