呼叫时错误
试图打开一些文件时,应用程序会导致一些I/O错误。该应用程序很大,有数十个子例程&模块和跳过其中一个没有解决问题,因为另一个会导致类似的问题。我参加了其中一个子例程,添加了一些行(以获取额外的信息),重新编译并重新运行。结果是环境变量似乎缺失或错误。例如,当我尝试使用呼叫get_environment_variable('pwd',pwd',pwd)
并打印出PWD的值(定义为contrafe> targine(len = 128)),我得到了错误
fortran运行时错误:记录的结尾
。我也尝试了CWD,但结果相同。似乎代码中的某些内容正在改变这些环境变量或使它们无法访问,但是我无法将其手指放在什么或如何查明原始问题上。
An app is causing some I/O errors when trying to open some files. The app is pretty large with dozens of subroutines & modules and skipping one of them doesn't fix the problem because another one will cause a similar one. I took one of the subroutines, added some lines (for extra info), recompiled and rerun it. The results is that the environmental variables seem to be missing or fault. For example, when I try to get the current directory with call get_environment_variable('PWD',pwd)
and print out the value of pwd (defined as character(len=128)
), I'm getting the error Fortran runtime error: End of record
. I also tried with cwd but same result. It seems like something in the code is altering these environmental variables or making them inaccessible, but I cannot put my fingers on what is it or how to pinpoint the original issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
内存损坏可能会导致代码中任何地方的意外后果。除非您提供问题的“最低可再现例子”,否则将不可能给出正确的答案。
但是,关于您的错误消息:编译器告诉您您正在阅读的字符变量
pwd
太短(很容易是数百个字符)。我建议您首先查询该字符变量的
长度
,然后使用分配
字符串存储它并使用status
检查一切都正确Memory corruption could cause unintended consequences anywhere in the code. It will be impossible to give a right answer unless you provide a "minimum reproducible example" of your problem.
Regarding your error message though: the compiler is telling you that the character variable you're reading
PWD
in is too short (could be easily hundreds of characters).I suggest you first query the
LENGTH
of that character variable, then use anallocatable
string to store it and useSTATUS
to check that everything went right