- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to redirect data files to another(from directory where my executable file and loading data are located) directory.
Is it possible to do it from command line at the same time, when I start the code?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are programmatic methods available for a program to process command line arguments (GETARG) and thuscontrol the location of output files via the OPEN.
If the files are not named in the OPEN, then maybe you can utilize the Intel Fortran specific environment variable control discussed in the Intel Fortran Users Guide in the section titled Assigning Files to Logical Units.
This environment variable methodpermits setting paths to specific files. For example,
export FORT30=/tmp/output
After executing the preceding bash/sh command,when the program executes, allI/O statements to unit 30 will refer to file output in the specified directory, /tmp.
Again, this only works when a file name is not specified in the OPEN statement. You just need knowledge of the unit number to be able to control the path and the name of the file.
If the files are not named in the OPEN, then maybe you can utilize the Intel Fortran specific environment variable control discussed in the Intel Fortran Users Guide in the section titled Assigning Files to Logical Units.
This environment variable methodpermits setting paths to specific files. For example,
export FORT30=/tmp/output
After executing the preceding bash/sh command,when the program executes, allI/O statements to unit 30 will refer to file output in the specified directory, /tmp.
Again, this only works when a file name is not specified in the OPEN statement. You just need knowledge of the unit number to be able to control the path and the name of the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might try experimenting with CHDIR(dir_name) after opening up your input files (assuming CHDIR works on Linux). Prior to issuing CHDIR you might want to issue GETCWD to get (save) original current working director such that you can restore this prior to program exit.
The CHDIR can use a directory specified as an environment variable which you can set just prior to launching the app. Or you can pass in the directory as a command line argument. Your choice.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - lessonfree
How to redirect data files to another(from directory where my executable file and loading data are located) directory.
Is it possible to do it from command line at the same time, when I start the code?
There are two other simple ways to redirect output in addition to those mentioned above.
1) If the entire output is done using default i/o unit you can simply do this:
./myprogram > /mypath/myoutput.txt
2) If the output is done into several files called out1, out2, ... then you can create the following links before executing your program:
ln -s /mypath1/mynewout1 out1
ln -s /mypath2/mynewout2 out2
...
./myprogram
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page