Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

FORTRAN file handling question

Go to Solution
Occasional Contributor

FORTRAN file handling question


I have an interesting problem, but I seems to be complicated to explain so bear with me.

I have a FORTRAN program (to which I cannot access the source and can only execute from a remote directory). This program creates output files as part of its execution. If you run this program using a path from another directory (for example: /var/tmp > /A/B/MyProgram) the output files will be created in the directory the program is called from (in this case /var/tmp).

My question is, is there any way to direct the output to another directory, different to the one I am calling it from?

The problem is that I am calling this program from another program that runs in a directory and I want the output to go into another directory, without having to copy the files after the program runs (there is lots of output > 10GB) an I would like to keep this program as fast as possible.

Thanks for any help you can give.
Honored Contributor [Founder]

Re: FORTRAN file handling question

pretty tricky if you have not got access to source code.
I'd try
1. target directory as a parameter
2. create a link in the target directory pointing to the directory where the program is called from. So no copying of data !!

Let us know if it works.
Occasional Contributor

Re: FORTRAN file handling question

Thanks but there's a potential problem that I didn't explain.

My programs runs many cases so the problem arises that if I link the directories, all of my output directories will just be the last run case, right?
Honored Contributor [Founder]

Re: FORTRAN file handling question

in that case:
1. Run the program from dir A
2. Rename the output file with the rename command, which will just chnage the name (nice and quick)
3. Create the link in the target output directory back to the newly renamed file

You can now run your program again and go throught the same loop.

Have you had any success with supplying the output dir as a parameter.

Another idea may be to cd to the intended output dir and then run your command
along the lines:
cd outputdir
cd -