Fortran; Calling an executable that in turn runs an input file

  • Context: Fortran 
  • Thread starter Thread starter Aeroengie
  • Start date Start date
  • Tags Tags
    File Fortran Input
Click For Summary
SUMMARY

This discussion focuses on automating the execution of "runner.exe" from a Fortran program, which requires input files named "run.inp". The user seeks a solution to eliminate manual input for hundreds of files. The proposed solution involves creating a Fortran program that generates a series of text files (in001.txt to in100.txt) containing the input file names and a batch file to execute "runner.exe" with these inputs. The output can be consolidated into a single file, "out.txt", by redirecting the output of each execution.

PREREQUISITES
  • Fortran programming skills
  • Understanding of system calls in Fortran
  • Familiarity with batch file creation
  • Basic knowledge of file I/O operations
NEXT STEPS
  • Learn how to use Fortran's system calls effectively
  • Research batch file scripting for Windows
  • Explore file redirection techniques in command-line interfaces
  • Investigate Fortran's file handling capabilities for dynamic file creation
USEFUL FOR

This discussion is beneficial for Fortran developers, automation engineers, and anyone looking to streamline the execution of external programs with multiple input files.

Aeroengie
Messages
2
Reaction score
0
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 let's assume I don't have the code.
Many thanks.
 
Technology news on Phys.org
Create a program to create a set of files named in001.txt, in002.txt, ... in100.txt. In each text file, include the name of the file you want to use for input. Then the program should write a batch file, with the following lines:

runner <in001.txt
runner <in002.txt
...
runner <in100.txt

I'm not sure what you're doing with the output, but if you want it all in a single file:

delete out.txt
runner <in001.txt >>out.txt
runner <in002.txt >>out.txt
...
runner <in100.txt >>out.txt
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 22 ·
Replies
22
Views
2K