1

I am writing a Fortran program that is to invoke a previously written program. Essentially, my program will create an input file and invoke the external program. The input file will then be read by the external program which will compute a set of data and generate and output file. My program will then read this output file.

I am able to invoke the external program using CALL EXECUTE_COMMAND_LINE("FILENAME"). However, the external program requests an input file name.

How do I pass the input file name to a program invoked within Fortran?

francescalus
  • 30,576
  • 16
  • 61
  • 96
mknight
  • 41
  • 1
  • 4
  • 2
    What about `CALL EXECUTE_COMMAND_LINE("FILENAME "//file_name) `? – Vladimir F Героям слава Mar 18 '16 at 22:58
  • Does the external program take the file's name as a command line argument or read from its standard input (or some other mechanism)? – francescalus Mar 18 '16 at 23:49
  • Try: call execute_command_line("echo '"//INPUTFILENAME//"' | FILENAME"). This works if the external program reads the input from the command line. (It passes echo 'INPUTFILENAME' | FILENAME) to the command line) If the external program requests the input filename as an argument, do what @Vladimir suggests. – StefanS Mar 21 '16 at 08:05
  • Passing the input through echo doesn't work if the thing I'm printing has quotes in it, and it doesn't work if I don't have the thing to be copied in a single string, eg if I'm printing as I iterate. – Joshua Cheek Oct 01 '16 at 23:58

0 Answers0