Fortran代码产生运行时错误';不支持操作';尝试打开文本文件时
我正在尝试运行一段用f95编写的fortran代码。我在Ubuntu中使用gfortran编译了它 代码中有一个要在文本文件中读取的命令。当我运行它时,它会给我以下错误:Fortran代码产生运行时错误';不支持操作';尝试打开文本文件时,fortran,runtime-error,fortran95,Fortran,Runtime Error,Fortran95,我正在尝试运行一段用f95编写的fortran代码。我在Ubuntu中使用gfortran编译了它 代码中有一个要在文本文件中读取的命令。当我运行它时,它会给我以下错误: Fortran runtime error: Cannot open file 'input_parameters.txt': Operation not supported 这是我们尝试读取文本文件之前的代码: program LSmodel implicit none !this is a for
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)
我正在运行Ubuntu18.04.2 LTS。更新-我已经找到(我相信)这段代码不起作用的原因,尽管我不知道为什么
文件夹在网络驱动器中,而不是在我的本地计算机上。一旦我将文件夹移动到本地计算机上,我就不再收到此错误 您应该添加编译程序的方式,也许还应该添加运行程序的方式。另外,为了以防万一,文件存在于执行程序的目录中?另外,为了澄清
隐式无!这是fortran语言,意味着所有以i,j,k,l,m,n开头的变量都是整数。
是错误的。隐式无表示编译器不会从变量的第一个字母隐式推断类型。因此,如果未声明变量,则会引发错误。我无法使用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 mycolfolderName
的input_parameters.txt,您的代码编译并运行得很好。您尝试运行它的目录中的“ls-l input_parameters.txt”的输出可能也很有用