我搜索了很多,但没有找到任何答案。这是我的代码的一部分。
program simulation
use random, only: random_normal
use omp_lib
real(8),parameter:: r_critical=0.4,dt=10.**(-3)
real,parameter:: Estar=8.86
real,parameter::A=236.
real(8),dimension(0:4):: a0
real(8) lens,rs,ss,cs,zs,is,js,ks,ls,ms
real(8):: lens0,rs0,ss0,cs0,zs0
real(8) Edef, Esh, Eld, AH, cm12
real,dimension(5):: shape_para
integer,dimension(5):: ii
integer::stat
integer :: N
real :: x
integer :: counts
real,dimension(0:28,0:20,0:18,0:18,0:24)::nuc
real(8) deltal,deltar,deltaz,deltac,deltas
! read the data--len,r,s,c,z,U
open(1,iostat=stat,FILE="236.txt")
if(stat==0) then
write(*,*) 'READING SUCCESSFUL'
end if
nuc(:,:,:,:,:)=100.
do
read(1,*,end=100) cm12, ii(1:5), shape_para(1:5),Esh,Eld,Edef,AH
nuc(ii(1),ii(2),ii(5),ii(4),ii(3))=Edef
enddo
100 continue
write(*,*) 'END READING DATA'
lens0=1.665;rs0=0.585;zs0=0.320;cs0=0.570;ss0=-0.158
write(*,*) 'START POINT',translen(lens0),transr(rs0,lens0),transz(zs0),transc(cs0,lens0),transs(ss0)
open(2,asynchronous='yes',file='output.txt')
call omp_set_num_threads(24)
!$omp parallel do &
!$omp default(none) &
!$omp private(N,lens,rs,zs,cs,ss,deltal,deltar,deltaz,deltac,deltas,counts,a0,AH) &
!$omp shared(nuc,lens0,rs0,zs0,cs0,ss0)
do N=1,10000
lens=lens0;rs=rs0;zs=zs0;cs=cs0;ss=ss0
counts=0
do while (rs > r_critical) !j > j-critical
deltal=interpoFl(nuc,lens,rs,ss,cs,zs)*dt + sqrt(2*sqrt((Estar-interpoU(nuc,lens,rs,ss,cs,zs))*8/A)*dt)*random_normal()
deltar=interpoFr(nuc,lens,rs,ss,cs,zs)*dt + sqrt(2*sqrt((Estar-interpoU(nuc,lens,rs,ss,cs,zs))*8/A)*dt)*random_normal()
deltas=interpoFs(nuc,lens,rs,ss,cs,zs)*dt + sqrt(2*sqrt((Estar-interpoU(nuc,lens,rs,ss,cs,zs))*8/A)*dt)*random_normal()
deltac=interpoFc(nuc,lens,rs,ss,cs,zs)*dt + sqrt(2*sqrt((Estar-interpoU(nuc,lens,rs,ss,cs,zs))*8/A)*dt)*random_normal()
deltaz=interpoFz(nuc,lens,rs,ss,cs,zs)*dt + sqrt(2*sqrt((Estar-interpoU(nuc,lens,rs,ss,cs,zs))*8/A)*dt)*random_normal()
if(not_exist(lens+deltal,rs+deltar,ss+deltas,cs+deltac,zs+deltaz)) cycle
if(Estar<interpoU(nuc,lens+deltal,rs+deltar,ss+deltas,cs+deltac,zs+deltaz)) cycle
lens=lens+deltal;rs=rs+deltar;ss=ss+deltas;cs=cs+deltac;zs=zs+deltaz
counts=counts+1
if(counts>100000) exit
end do
call cal_shape_a0(lens,rs,ss,cs,zs,a0(0:4))
call CalCenterofMass(lens,zs,a0(0:4),AH)
write(2,'(f10.2)') AH
end do
contains
...
end program
编译没有问题,但是当我使用./a.out来执行程序时,它会给我分段错误(核心转储),没有其他消息。我使用gdb来查找故障发生的位置。然后我发现打开文件行有问题。
open(1,iostat=stat,FILE="236.txt")
所以我不知道为什么。它可以在顺序操作时正确执行,但在使用openmp时错误。有谁知道它为什么?