J3/05-240r2 To: J3 From: Dan Nagle Subject: Execute an external program Date: 2005 August 08 The execute a command line proposal was rated A by WG5 at the Delft meeting. This paper attempts to provide edits to implement it. Previous papers assumed execute_command_line would be a part of iso_fortran_env and also assumed that that section would be reorganized to separate the constants and the procedures. However, that reorganization has not occurred, so this paper places execute_command_line in the general list of procedures. It may be subject to a future reorganization if desired. In Section 13.5.8, page 298, add to the list: [298:5+] Add: "EXECUTE_COMMAND_LINE execute an O/S command" In Section 13.7, add to the list of procedures: [315:24+] Add: "13.7.5+ EXECUTE_COMMAND_LINE( COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ] ) *Description.* Execute the command line identified by the string COMMAND. The processor must support synchronous and may support asynchronous execution of the external program. *Class.* Subroutine. *Arguments.* COMMAND shall be of type default character and shall be a scalar. It is an INTENT(IN) argument. It identifies the command line to be executed. The interpretation is processor-dependent. WAIT shall be of type default logical and shall (optional) be a scalar. It is an INTENT(IN) argument. EXITSTAT shall be of type default integer and shall (optional) be a scalar. It is an INTENT(INOUT) argument. It shall not be present if WAIT is present with a value of false. CMDSTAT shall be of type default integer and shall (optional) be a scalar. It is an INTENT(OUT) argument. CMDMSG shall be of type default character and shall (optional) be a scalar. It is an INTENT(INOUT) argument. When present and has the value true, EXECUTE_COMMAND_LINE returns after the indicated command line has completed execution. When present and has the value false and the processor supports asynchronous execution of the external command, EXECUTE_COMMAND_LINE returns after the indicated command line has started execution. In all other cases, the effect is as if WAIT is present with a value of true. If WAIT is present with a value of true, the value of EXITSTAT is the processor-dependent exit status of the command line execution, if available. Otherwise, the value of EXITSTAT is unchanged. CMDSTAT is assigned the value zero if no error occurred during EXECUTE_COMMAND_LINE and assigned a processor-dependent positive value otherwise. If an error occurs and CMDSTAT is not present, execution of the program terminates. If the processor does not support the concept of command lines execution, CMDSTAT is assigned the value 1. CMDMSG is assigned a processor-dependent error message if the value of the variable associated with the CMDSTAT argument indicates an error occurred. Otherwise, the value of CMDMSG is unchanged."