R dyn.load(“路径/文件名.so”)中出错:无法加载共享对象

R dyn.load(“路径/文件名.so”)中出错:无法加载共享对象,r,dll,fortran,R,Dll,Fortran,我有几个编译过的Fortran子程序要在R中使用。当我试图调用这个特定的子程序时,它会产生以下错误: Error in dyn.load("path/file_name.so") : unable to load shared object '/complete_path/file_name.so': libgfortran.so.4: cannot open shared object file: No such file or directory 虽然其他子例

我有几个编译过的Fortran子程序要在R中使用。当我试图调用这个特定的子程序时,它会产生以下错误:

Error in dyn.load("path/file_name.so") : 
  unable to load shared object '/complete_path/file_name.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
虽然其他子例程加载得很好,但下面是子例程:

subroutine box_center(m,n,o,a,b,ps,box,filter)
    implicit none
    integer, intent(in) :: m,n,o
    integer :: x,y,t,mone,none,a,b
    double precision, intent(inout) :: ps(m,n,o),box(a,b)
    double precision, intent(out) :: filter(m,n,o)

    mone=m - 3
    none=n - 3
    do 20,t=1,time 
      do 10, x=4,mone
       do 5, y=4,none
        box = reshape((/ps(x-3,y-3,t)  ,ps(x-3,y-2,t),ps(x-3,y-1,t) &
                        , ps(x-3,y,t)  ,ps(x-3,y+1,t),ps(x-3,y+2,t) &
                , ps(x-3,y+3,t) & 
                                , ps(x-2,y-3,t),ps(x-2,y-2,t),ps(x-2,y-1,t) &
                        , ps(x-2,y,t)  ,ps(x-2,y+1,t),ps(x-2,y+2,t) &
                , ps(x-2,y+3,t) & 
                                , ps(x-1,y-3,t),ps(x-1,y-2,t),ps(x-1,y-1,t) &
                        , ps(x-1,y,t)  ,ps(x-1,y+1,t),ps(x-1,y+2,t) &
                , ps(x-1,y+3,t) & 
                    , ps(x,y-3,t),ps(x,y-2,t),ps(x,y-1,t) &
                        , ps(x,y,t)  ,ps(x,y+1,t),ps(x,y+2,t) &
                , ps(x,y+3,t) & 
                                , ps(x+1,y-3,t),ps(x+1,y-2,t),ps(x+1,y-1,t) &
                        , ps(x+1,y,t)  ,ps(x+1,y+1,t),ps(x+1,y+2,t) &
                , ps(x+1,y+3,t) & 
                                , ps(x+2,y-3,t),ps(x+2,y-2,t),ps(x+2,y-1,t) &
                        , ps(x+2,y,t)  ,ps(x+2,y+1,t),ps(x+2,y+2,t) &
                , ps(x+2,y+3,t) & 
                                , ps(x+3,y-3,t),ps(x+3,y-2,t),ps(x+3,y-1,t) &
                        , ps(x+3,y,t)  ,ps(x+3,y+1,t),ps(x+3,y+2,t) &
                , ps(x+3,y+3,t)/), (/a,b/))


           if(minval(box) .EQ. box(4,4)) then                       
                filter(x,y,t) = 1.00
              else
                filter(x,y,t) = 0.00
             end if 


5          end do 
10         end do   
20  end do  
    end subroutine box_center
所有子程序均采用相同的程序进行编译:

gfortran -c -ffree-form file_name.f 
R CMD SHLIB file_name.f

还有一点需要注意:当我使用本地机器时,这个特定的子程序可以很好地加载,它会在HPC上产生错误。

也许像我这样的初学者会发现它很有用,而不是删除问题

在远程计算机上编译Fortran子程序是解决方案,而不是在本地计算机上