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

ID 767251
Date 7/13/2023
Public

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

Document Table of Contents

SYSTEM

Portability Function: Sends a command to the shell as if it had been typed at the command line.

Module

USE IFPORT

result = SYSTEM (string)

string

(Input) Character*(*). Operating system command.

Results

The result type is INTEGER(4). The result is the exit status of the shell command. If -1, use IERRNO to retrieve the error. Errors can be one of the following:

  • E2BIG: The argument list is too long.

  • ENOENT: The command interpreter cannot be found.

  • ENOEXEC: The command interpreter file has an invalid format and is not executable.

  • ENOMEM: Not enough system resources are available to execute the command.

On Windows* systems, the calling process waits until the command terminates. To insure compatibility and consistent behavior, an image can be invoked directly by using the Windows API CreateProcess( ) in your Fortran code.

Commands run with the SYSTEM routine are run in a separate shell. Defaults set with the SYSTEM function, such as current working directory or environment variables, do not affect the environment the calling program runs in.

The command line character limit for the SYSTEM function is the same limit that your operating system command interpreter accepts.

Example

   USE IFPORT
   INTEGER(4) I, errnum
   I = SYSTEM("dir > file.lst")
   If (I .eq. -1) then
     errnum = ierrno( )
     print *, 'Error ', errnum
   end if
   END

See Also