Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

PRE-run file handling

stedwomas
Beginner
348 Views

I am debugging a fortran program and have a file called data1, in the program data1 gets altered and  when i rerun the fortran program it is data1  the same as on the first attempt 

 

what i want to do is have a file called data then copy and rename it at the beginning of the fortran program  to data1 , so  data1 would be altered , but  the next time i run the program data will be   copied to data1 and i can procede

 

an alternate method would be to copy data to data1 in  a "prerun" step similar to the Pre-Build Events before you actually build the fortran program 

 

can this be done using either of the two methods

 

 

0 Kudos
1 Reply
mecej4
Honored Contributor III
324 Views

It seems to me that you could avoid much confusion and simply modify your program such that it opens file "data"  for reading and "data1" for writing -- initially "data1" is empty. The program then reads "data", modifies the input information, and writes to "data1". This arrangement will preserve the input file. If the calculations are deterministic and dependent only on whatever is read from "data", the output file "data1" will remain the same after every run. If you change the contents of "data" and run the program, a new version of "data1" will be produced.

0 Kudos
Reply