访问主程序子目录中的文件 [英] Accessing files in sub directory of main program

查看:66
本文介绍了访问主程序子目录中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包含我的主要可执行文件的文件夹非常混乱,其中包含输入,输出和源文件.我想将其中一些文件移到与我的可执行文件不同的目录中,但仍然可以访问它们.如果我可以创建一个目录,例如./main/outfile,该目录可以保存程序中的所有输出文件,那将是很棒的.在Fortran 77/90中访问这些文件时是否可以包含路径?

The folder containing my main executable is very cluttered with input, output and source files. I would like to move some of these files into a different directory to my executable but still be able to access them. It would be fantastic if I could make a directory, for example ./main/outfile, that holds all the output files from my program. Is it possible to include a path when accessing these files in Fortran 77/90?

如果编译器很重要,我会使用在Ubuntu 11.10上运行的gfortran.

If compilers are of any importance, I use gfortran which is running on Ubuntu 11.10.

推荐答案

对于输入/输出文件,只需在打开文件时指定路径即可.例如:

for input/output files, just specify the path when you are opening the file. For example:

open(unit=3,file='outputdata/data_modified.txt',status='unknown')

将打开outputdata文件夹中的文件.请注意,outputdata文件夹必须事先存在,否则您可能会收到错误消息.

will open a file in the outputdata folder. Note that the outputdata folder has to exist beforehand, or you will likely get an error.

这篇关于访问主程序子目录中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆