我有这段代码:
PROGRAM xfit
! driver for routine fit
USE nrtype; USE nrutil
USE nr
USE ran_state, ONLY : ran_seed
IMPLICIT NONE
INTEGER(I4B), PARAMETER :: NPT=100
REAL(SP), PARAMETER :: SPREAD=0.5_sp
INTEGER(I4B) :: mwt
REAL(SP) :: a,b,chi2,q,siga,sigb
REAL(SP), DIMENSION(NPT) :: harvest,sig,x,y
call ran_seed(sequence=731)
x(:)=arth(0.1_sp,0.1_sp,NPT)
call gasdev(harvest)
y(:)=-2.0_sp*x(:)+1.0_sp+SPREAD*harvest
sig(:)=SPREAD
do mwt=0,1
if (mwt == 0) then
write(*,'(//1x,a)') 'Ignoring standard deviation'
call fit(x,y,a,b,siga,sigb,chi2,q)
else
write(*,'(//1x,a)') 'Including standard deviation'
call fit(x,y,a,b,siga,sigb,chi2,q,sig)
end if
write(*,'(1x,t5,a,f9.6,t24,a,f9.6)') 'A = ',a,'Uncertainty: ',&
siga
write(*,'(1x,t5,a,f9.6,t24,a,f9.6)') 'B = ',b,'Uncertainty: ',&
sigb
write(*,'(1x,t5,a,4x,f10.6)') 'Chi-squared: ',chi2
write(*,'(1x,t5,a,f10.6)') 'Goodness-of-fit: ',q
end do
END PROGRAM xfit
但是当我编译它时,我得到以下错误
USE ran_state, ONLY : ran_seed
1
Fatal Error: Can't open module file 'ran_state.mod' for reading at (1):
No such file or directory
你能告诉我如何解决它吗?
答案 0 :(得分:1)
当我这样构建时,我发现了同样的错误:
gfortran test.f90 -o test.exe
使用modulename
1
致命错误:无法打开模块文件' modulename.mod'阅读 (1):没有这样的文件或目录
说modulename.mod位于/ usr / local / include
以及/ usr / local / lib
中的一些依赖项
您可以使用以下内容消除错误:
gfortran test.f90 -o test.exe -I/usr/local/include -L/usr/local/lib
答案 1 :(得分:0)
它告诉您需要首先构建模块ran_state。如果您编译包含ran_state的模块,那么您将获得一个.mod文件。如果您随后构建了程序,则不应再出现该错误。