Fortran Wiki
execute_command_line

Description

Starts execution of a another program if the processor supports command-line execution.

If wait is present and has the value false, the execution of the command is asynchronous if the system supports it; otherwise, the command is executed synchronously.

The three last arguments allow the user to get status information. After synchronous execution, exitstat contains the integer exit code of the command, as returned by system. cmdstat is set to zero if the command line was executed (whatever its exit status was). cmdmsg is assigned an error message if an error has occurred.

Standard

Fortran 2008 and later

Class

Subroutine?

Syntax

call execute_command_line(command [, wait, exitstat, cmdstat, cmdmsg])

Arguments

  • command - Shall be a default character scalar.
  • wait - (Optional) Shall be a default logical scalar.
  • exitstat - (Optional) Shall be an integer of the default kind.
  • cmdstat - (Optional) Shall be an integer of the default kind.
  • cmdmsg - (Optional) Shall be an character scalar of he default kind.

Example

program test_exec
  integer :: i

  call execute_command_line ("external_prog.exe", exitstat=i)
  print *, "Exit status of external_prog.exe was ", i

  call execute_command_line ("reindex_files.exe", wait=.false.)
  print *, "Now reindexing files in the background"
end program test_exec