Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Run Fortran Applications from the Command Line

For programs run from the command line, the operating system searches directories listed in the PATH environment variable to find the requested executable file.

The program can also be run by specifying the complete path of the executable file. On Windows, any DLLs you are using must be in the same directory as the executable or in one specified in the path.

Multithreaded Programs

If the program is multithreaded, each thread starts on whichever processor is available at the time. On a computer with one processor, the threads all run in parallel, but not simultaneously; the single processor switches among them. On a computer with multiple processors, the threads can run simultaneously.

Use the -fpscomp filesfromcmd Option

If you specify the -fpscomp option with keyword filesfromcmd, the command line that executes the program can include additional file names to satisfy OPEN statements in the program for which the file name field (FILE specifier) has been left blank. The first file name on the command line is used for the first OPEN statement executed, the second file name for the second OPEN statement, and so on.

Each file name on the command line must be separated from the names around it by one or more spaces, or tab characters. You can enclose each name in quotation marks ("<filename>"), but this is not required unless the argument contains spaces or tabs. A null argument consists of an empty set of quotation marks with no file name enclosed ("").

The following example runs the program MYPROG.EXE from the command line:

MYPROG "" OUTPUT.DAT

Because the first file name argument is null, the first OPEN statement with a blank file name field produces the following message:

File name missing or blank - please enter file name
UNIT number  ?

The number is the unit number specified in the OPEN statement. The file name OUTPUT.DAT is used for the second OPEN statement executed. If additional OPEN statements with blank file name fields are executed, you will be prompted to add more file names.

Instead of using the -fpscomp option with keyword filesfromcmd, you can:

  • Call the GETARG library routine to return the specified command-line argument. To execute the program in the Microsoft Visual Studio IDE, provide the command-line arguments to be passed to the program using Project > Properties. Choose the Debugging category and enter the arguments in the Command Arguments text box.

  • On Windows, call the GetOpenFileName Windows API routine to request the file name using a dialog box.

See Also