我用fortran 90编写了这段代码,我认为这段代码没有任何问题。
PROGRAM xfitexy
! driver for routine fitexy
USE nrtype
USE nr
USE ran_state, ONLY : ran_seed
IMPLICIT NONE
INTEGER(I4B), PARAMETER :: NPT=30
REAL(SP) :: a,b,chi2,harvest,q,sa,sb,siga,sigb
REAL(SP), DIMENSION(NPT) :: x,y,dx,dy,dz
INTEGER(I4B) :: i
call ran_seed(sequence=1411)
dz(:)=0.0
do i=1,NPT
call ran1(harvest)
dx(i)=0.1_sp+harvest
call ran1(harvest)
dy(i)=0.1_sp+harvest
call gasdev(harvest)
x(i)=10.0_sp+10.0_sp*harvest
call gasdev(harvest)
y(i)=2.0_sp*x(i)-5.0_sp+dy(i)*harvest
call gasdev(harvest)
x(i)=x(i)+dx(i)*harvest
end do
write(*,*) 'Values of a,b,siga,sigb,chi2,q:'
write(*,*) 'Fit with x and y errors gives:'
call fitexy(x,y,dx,dy,a,b,siga,sigb,chi2,q)
write(*,'(1x,6f12.6)') a,b,siga,sigb,chi2,q
write(*,*)
write(*,*) 'Setting x errors to zero gives:'
call fitexy(x,y,dz,dy,a,b,siga,sigb,chi2,q)
write(*,'(1x,6f12.6)') a,b,siga,sigb,chi2,q
write(*,*) '...to be compared with fit result:'
call fit(x,y,a,b,siga,sigb,chi2,q,dy)
sa=sqrt(siga**2+sigb**2*(a/b)**2)/b
sb=sigb/b**2
write(*,'(1x,6f12.6)') -a/b,1./b,sa,sb,chi2,q
END PROGRAM xfitexy当我编译它时,我得到了以下错误:
USE nrtype; USE nrutil 1
Fatal Error: Can't open module file 'nrtype.mod' for reading at (1): No such file or directory 你能告诉我怎么解决这个问题吗?非常感谢
发布于 2013-05-25 11:40:20
我可能错了,但我猜你是从别的地方抄袭了这个程序。不要误会我的意思,仿真是开始学习任何代码的好方法,因为它会导致像这样的学习错误。USE命令指示编译器查找另一个称为模块的文件,该文件包含多个子程序(函数或子例程),这些子程序必须存储在与正在编译的程序相同的文件中。名为nrtype.f90、nr.f90和ran_state.f90的模块必须与xfitxy程序在同一文件中,以便编译器可以将它们转换为nrtype.mod、nr.mod和ran_state.mod文件,以便与主程序一起编译到单个程序中。
https://stackoverflow.com/questions/16635019
复制相似问题