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!

run a fortran with a different variable each time without compiling

Status
Not open for further replies.

eugenia1780

Programmer
Jan 27, 2015
2
Dear all,
I need to run a fortran program many times (I am a windows user, but I can change to linux!)
Suppose that the variable is called "N" and it varies from 0 to Nmax.
I would like to run a program over several points considering a different N each time. I don't want to make a DO withing the fortran because I need a file for each program output.
I was thinking in something like this:

FOR /L %%i IN (1 1 2160) DO program.exe %%i &&copy OUTPUT OUTPUT%%i

where Nmax is 2160
But... I don´t know how to declaire that variable in order that my fortran understands that.

Could you please hava a look?

Eugenia
 
Eugenia:

Actually, it is rather simple to create a loop inside your Fortran program and put together a new filename on the fly that includes N as a unique number so that, at the end, you do get a bunch of output files...no need to jump out to bash to do this.

You would need to go into the do-loop
use the counter as part of a string and do an internal WRITE into a character variable
use character variable to open a new file
do whatever
write to file
close file
go back to top of loop.

Please do not test your program with 2160!...start with 5.
 
Hello!
I used to have a program that made something like that but it was actually tedious when naming files. A lot of DO..but maybe I was making some mistake...
I'll try it. If I do not succeed, I'll write again.

Many thanks.
Cheers

Eugenia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top