-2
我有一些值寫在文件4,我需要再次閱讀他們的新計算,但我收到分段故障錯誤,而我正在運行代碼,這個問題發生在讀命令「讀(4,*)NNrow( I),Niz(I),NNbin(I),Nfi(I),NfiStdDev(I),NfiAvr(I),NMagbin(I),Nzup(I)「 我該如何解決這個問題?如何解決「分段故障」錯誤?
do j=1,nmax
if (zb(iz,im,j).ne.0) then
call Romberg (dix,dDistCa,zb(iz,im,j),zup(iz)) !COMOVING DISTANCE
Vmax=dix*S !COMOVINF VOLUME
fi=fi+1/Vmax !LUMINOSITY FUNCTION
write(2,'(i5,2x,f9.4,2x,f8.5,2x,3f14.10)')j,magbin,zbin,S,Vmax,dix
endif
enddo
if (Nbin.ge.n_thresh) then
Nrow=Nrow+1
write(4,'(3i7,2x,f25.8,2x,2f20.8,2x,f9.4,2x,f8.5)')Nrow,iz,Nbin,fi,fiStdDev,fiAvr,magbin,zup(iz)
endif
enddo loopmag
rewind(4)
close(4)
write(*,*)Nrow
open(4,file='luminosity_func_I.asc')
allocate (fiStdDev2(Nrow),stat=ok)
allocate (fi_expected(Nrow),stat=ok)
allocate (DFI(Nrow),stat=ok)
allocate (CHISQ(Nrow),stat=ok)
! Ln10=2.3025
A=0.4*2.3025
do I=1,Nrow ! NDATA=NMAX
write(*,*)I
read (4,*) NNrow(I),Niz(I),NNbin(I),Nfi(I),NfiStdDev(I),NfiAvr(I),NMagbin(I),Nzup(I)
fiStdDev2(I)=1/NfiStdDev(I)*NfiStdDev(I)
write(*,*)fiStdDev2(I)
fi_expected(I)=A*fi_star*10**(0.4*(alpha+1)*(M_star-NMagbin(I)))*exp(-10**(0.4*(M_star-NMagbin(I))))
DFI(I)=fi_expected(I)-NFI(I)
CHISQ(I)=DFI(I)*DFI(I)*fiStdDev2(I)
END DO
不,不,不。不要再次發佈相同的問題。 [錯誤發生「段錯誤」](http://stackoverflow.com/questions/19400039/errors-with-segmentation-fault-occurred) –