Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29072 Discussions

help with running a fortran job from the command line

Tom15
Beginner
1,203 Views

Apologies, but I have a really simple question.

Also, probably I have not selected the right forum,  - if not i would be grateful for advice on alternative forums

I have a legacy fortran77 program that I need to run.  It is self contained except for taking data from an input file and sending results to an output file.  I want to compile and run the program from the command line that is part of Intel\Composer XE 2015>. I can successfully run a version of the program without the input and output files so I think my problem is not knowing the string for including the input and output files in the command line.

I would be grateful if anyone can tell me the correct structure of the command that achieves that.

0 Kudos
3 Replies
Arjen_Markus
Honored Contributor II
1,157 Views

There are various possibilities:

  • Use command-line arguments to indicate the names of the input and output files. Even though you say your program is FORTRAN 77, that does not mean you cannot use the newer intrinsic routines, get_command_argument or command_argument_count.
  • Use redirection on the command-line, in which case you can read from standard input (read(*,...)) and write to standard output (write(*,...)):
prompt> runprogram < input > output
  • Use a fixed input file to read the file names from.

 

0 Kudos
Igor_V_Intel
Employee
1,141 Views

You need to check the code of the program and find OPEN statements, e.g. OPEN(UNIT=8, FILE='projectA/data.test')

If there is the array of chars to hold the path then find a way it is defined and set in the program.


0 Kudos
jimdempseyatthecove
Honored Contributor III
1,138 Views

When you (or someone available to you) ran this program before, what did you (they) type in?

Be aware that file name arguments, and what your program does with those arguments prior to using them in an OPEN statement, generally rely on what is referred to as "relative addressing".  This means (particularly with older programs), the program doesn't know where it resides on the system and it doesn't know where the data files are located but it assumes that they are either together or on a path relative to where the program is located.

 

Really old programs were developed (coded) without the concept of a file system structure. IOW there was no provision for a path to the file (or where the program resides). 

When a program opens a file without providing a path to the file (your progam may not be coded to permit paths to files), the file placement is assumed to be in what is called "the current directory".

C:\Program Files (x86)\IntelSWTools>cd \test
C:\test>yourProgramName arg1 arg2 arg3

Where the args are anything that the program expects on the command line. These may be file names (with or without paths), options, numerical values (e.g. array sizes), title, or the meaning of number 42.

While your old program may be written without the capacity of file paths, when your program location differs from your data files locations, you would set the current directory to that of your data files, and then specify a qualified path to your program:

C:\Program Files (x86)\IntelSWTools>cd \path\of\files
C:\path\of\files>\Development\Project\Blueberry\YourProgramName arg1 arg2 arg3

Without documentation, it is hard to ascertain what are the expected (required) arguments.

Personally, (sans documentation) I would look at the code. If that didn't resolve the issue (and if I could compile the program), I'd step through it with the debugger.

Note, your program may not expect or require any command line arguments. Instead, it may require pre-assigned file names such as INDATA and OUTDATA. Whatever is required is what you use.

 

There is not much else we can help you with.

 

Jim Dempsey

0 Kudos
Reply