【发布时间】:2020-02-18 05:17:30
【问题描述】:
我正在尝试运行一段用 f95 编写的 fortran 代码。我在 Ubuntu 中使用 gfortran 编译过它。
在代码中有一个读取文本文件的命令。当我运行它时,它给了我以下错误:
Fortran runtime error: Cannot open file 'input_parameters.txt': Operation not supported
这是我们尝试读取文本文件之前的代码:
program LSmodel
implicit none !this is a fortran thing that means that all variables that start with i,j,k,l,m,n are integers.
real :: sec,ran,gasdev ! random generator variables
real :: x,y,z,u,v,w,ut,vt,wt,t,dt ! simulation variables
real :: wg ! seed parametes
real :: Um,sigma_u,sigma_v,sigma_w,uw ! wind statistics variables
real :: dvaru_dz,dvarv_dz,dvarw_dz,duw_dz ! wind statistics variables
real :: dissip_m,TL ! vector over the range of ustars
real :: zs,zg,zmax ! release height & boundaries
real :: Ainv,C0inv ! inverse parameters
real :: C0,A,b,au,av,aw,dt_on_TL ! LS model parameters
real :: dz_max,dt_max ! time step limit
real :: CT,beta ! Crossing Trajectories correction
real :: C_chi,chi,TKE,T_chi,omega ! DI parameters
real :: a_ln,b_ln,sigma_chi,dissip_s ! DI parameters
real :: rhop,rho,r,g,gt,Re,AIP,Cd,nu ! IP parameters
real :: up,vp,wp,upt,vpt,wpt,vr,dt_ip,alpha ! IP parameters
real :: keepseed, maxheight
integer :: seed ! random generator variables, keepseed decides whether to keep the same seed or not for comparison of simulation
integer :: pnum, traj_exit ! simulation parameters. traj_exit counts the number of particles that have exited from the topo f the wind flow.
integer :: i,j,jj,n,ii ! counting parameters
integer :: n_ip,IP=1 ! IP parameters
character(len=80) :: filename, wgchar, foldername
real, allocatable,dimension(:) :: z_vec,Um_vec,sigma_u_vec,sigma_v_vec,sigma_w_vec,uw_vec
real, allocatable,dimension(:) :: dvaru_dz_vec,dvarv_dz_vec,dvarw_dz_vec,duw_dz_vec,dissip_m_vec
! input
open (23,file='input_parameters.txt') !opening a file for the input parameters....
read (23, *) x,C0,wg,zs,zg,beta,dt_on_TL,y,sigma_chi,C_chi,r,rhop,alpha,rho,nu, keepseed, foldername
close(23)
我正在运行 Ubuntu 18.04.2 LTS。
【问题讨论】:
-
你应该添加你编译程序的方式,也许你是如何运行它的。另外以防万一,该文件存在于执行程序的目录中?
-
另外,为了澄清
implicit none !this is a fortran thing that means that all variables that start with i,j,k,l,m,n are integers.是错误的。隐式无意味着编译器不会从变量的第一个字母隐式推断类型。因此,如果未声明变量,则会引发错误。 -
我无法使用 gfortran 9.2.1 重现此错误。你的代码编译并运行良好,输入参数为
1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 myCoolFolderName。 -
“ls -l input_parameters.txt”在您尝试运行它的目录中的输出可能也很有用
标签: fortran runtime-error fortran95