Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an executable that in turn runs an input file in fortran

Status
Not open for further replies.

Frankpendegrass

Programmer
Jun 25, 2009
3
GB
Hi. I need to write a fortran program that calls an EXE, call it "runner.exe" that in turn runs an input file, call it "run.inp". Thing is, I would normally run "runner.exe" manually, and type in "run.inp" and "runner.exe" gives outputs. But now, I have 100's of input files and I can't affod to do it manually anymore so I need to automate the process, that is, have a program that calls "runner.exe" and "runner.exe" calls all the 100's of input files. How do I do that ?
I have tried [ Call system ('runner.exe') ] and all that does is actually run "runner.exe" but remember, "runner.exe" is in turn waiting for me to type in an input file. So how do I automate the process ?
Note: "runner.exe" was written by someone else and lets assume I don't have the code.
Many thanks.
 
1. Read all your files, which you want to process in an array. If you don't know how, maybe look at the program get_files.f90 here:

2. Then copy every file, which name you have in the above array into the input file and then run runner - i.e. something like this:
Code:
call system ('copy file_n run.inp')
call system ('runner.exe')
(But first try with one file if the copying and running with the above 2 commands works.)
 
If you usually type by hand in run.inp, why can't you do the same in fortran?

Just generate run.inp and call runner.exe

If runner.exe is stable enough and doesn't get stuck, you might as well use the batch command "start" to prevent calling the next runner.exe too early.

You also ought to use the flush command to prevent that windows cashes your data.

DO i=1,100,1
OPEN(FILE=1,...etc.
WRITE the file *.inp
CLOSE(1)
FLUSH(1)
CALL SYSTEM('START /WAIT runner.exe')
END DO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top