无法通过FORTRAN 77中的相对路径打开文件 [英] Unable to open file by a relative path in FORTRAN 77
问题描述
我编写了FORTRAN 77代码,该代码打开(创建)文件并将一些信息写入其中.如果我像这样打开文件,一切都会很好
I wrote FORTRAN 77 code which opens (creates) a file and writes some information into it. Everything works great if I open the file like
INTEGER U
U=1
OPEN(U, FILE='data.txt')
但是如果我想在指定相对路径的其他目录中创建文件(OS Ubuntu)
But if I want the file to be created in a different dir specifying a relative path (OS Ubuntu)
INTEGER U
U=1
OPEN(U, FILE='../output_files/data.txt')
我的gfortran编译器给我以下错误:
my gfortran compiler gives me the following error:
OPEN(U,FILE='../output_files/data.txt')
1
Error: Invalid value for FILE specification at (1)
在我的情况下,似乎绝对路径正在工作.我花了一些时间在Internet上进行了一些研究,发现我浏览的每本手册都说相对路径也应该起作用.这对我很重要.可以通过某种方式解决此问题吗?
Seems like absolute path is working in my case. I have spent some time doing some research on the Internet and found that every manual I looked into said that relative path should work as well. That's important for me. Is it possible to fix this somehow?
更新
我使用的真实代码是
INTEGER U
U=1
OPEN(U, FILE='output_files/energies_and_first_interaction_coordinates_mum.txt')
错误是
OPEN(U,FILE='output_files/energies_and_first_interaction_coordinates_mum.txt')
1
Error: Invalid value for FILE specification at (1)
推荐答案
多亏了francescalus和L.Scott Johnson,我找到了解决方案.问题是打开文件的命令扩展到行上方72位置(我的文件名太长).
I found the solution, thanks to francescalus and L. Scott Johnson.The problem was that the command to open file was expanded beyond 72 position on the line (the name of my file was to long).
这篇关于无法通过FORTRAN 77中的相对路径打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!