INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

run a fortran with a different variable each time without compiling

run a fortran with a different variable each time without compiling

run a fortran with a different variable each time without compiling

(OP)
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

RE: run a fortran with a different variable each time without compiling

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.

RE: run a fortran with a different variable each time without compiling

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close