0

我在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  

你能告诉我如何解决它非常感谢

4

1 回答 1

1

我可能错了,但我猜你是从其他来源复制了这个程序。不要误会我的意思,仿真是开始学习任何代码的好方法,因为它会导致这样的学习错误。USE 命令指示编译器查找另一个称为模块的文件,该模块包含多个子程序(函数或子例程),这些子程序(函数或子例程)必须与正在编译的程序存储在同一文件中。标题为 nrtype.f90、nr.f90 和 ran_state.f90 的模块必须与 xfitxy 程序位于同一文件中,以便编译器可以将它们转换为 nrtype.mod、nr.mod 和 ran_state.mod 文件以编译为单个程序与主程序。

于 2013-05-25T03:40:19.613 回答