Intel® Fortran Libraries Reference

Intel® Fortran Libraries Reference Intel® Fortran Libraries Reference

h.eng.cam.ac.uk
from h.eng.cam.ac.uk More from this publisher
12.07.2015 Views

2 Intel Fortran Libraries ReferenceSyntaxresult = 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 insurecompatibility 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 theSYSTEM function, such as current working directory or environment variables, do not affect theenvironment the calling program runs in.The command line character limit for the SYSTEM function is the same limit that your operatingsystem command interpreter accepts.CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIBSee Also: “SYSTEMQQ”ExampleUSE IFPORTINTEGER(4) I, errnumI = SYSTEM("dir > file.lst")If (I .eq. -1) thenerrnum = ierrno( )print *, 'Error ', errnumend ifEND2-478

Descriptions of the Library Routines 2SYSTEMQQPortability Function: Executes a system command by passing a command string to the operatingsystem’s command interpreter.Module: USE IFPORTSyntaxresult = SYSTEMQQ (commandline)commandline(Input) Character*(*). Command to be passed to the operating system.Results:The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..The SYSTEMQQ function lets you pass operating-system commands as well as programs.SYSTEMQQ refers to the COMSPEC and PATH environment variables that locate the commandinterpreter file (usually named COMMAND.COM).On Windows* systems, the calling process waits until the command terminates. To insurecompatibility and consistent behavior, an image can be invoked directly by using the Windows*API CreateProcess( ) in your Fortran code.If the function fails, call “GETLASTERRORQQ” to determine the reason. One of the followingerrors can be returned:• ERR$2BIG – The argument list exceeds 128 bytes, or the space required for the environmentformation exceeds 32K.• ERR$NOINT – The command interpreter cannot be found.• ERR$NOEXEC – The command interpreter file has an invalid format and is not executable.• ERR$NOMEM – Not enough memory is available to execute the command; or the availablememory has been corrupted; or an invalid block exists, indicating that the process making thecall was not allocated properly.The command line character limit for the SYSTEMQQ function is the same limit that youroperating system command interpreter accepts.CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIBSee Also: “SYSTEM”ExampleUSE IFPORTLOGICAL(4) result2-479

2 Intel <strong>Fortran</strong> <strong>Libraries</strong> <strong>Reference</strong>Syntaxresult = 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 insurecompatibility and consistent behavior, an image can be invoked directly by using the Windows*API CreateProcess( ) in your <strong>Fortran</strong> code.Commands run with the SYSTEM routine are run in a separate shell. Defaults set with theSYSTEM function, such as current working directory or environment variables, do not affect theenvironment the calling program runs in.The command line character limit for the SYSTEM function is the same limit that your operatingsystem command interpreter accepts.CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIBSee Also: “SYSTEMQQ”ExampleUSE IFPORTINTEGER(4) I, errnumI = SYSTEM("dir > file.lst")If (I .eq. -1) thenerrnum = ierrno( )print *, 'Error ', errnumend ifEND2-478

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!