subroutinerun_command
subroutine run_command(command, stat)
Run command and wait for it. Without cmdstat, a program can stop with an error if the command
is not found, which some shells report with status 127.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| command | character(len=*) | in | the command | |
| stat | integer | out | nonzero on failure |
Source
Show the code
subroutine run_command(command, stat)
character(len=*), intent(in) :: command !! the command
integer, intent(out) :: stat !! nonzero on failure
integer :: exit_status, command_status
exit_status = 0
call execute_command_line(command, exitstat=exit_status, cmdstat=command_status)
stat = merge(exit_status, command_status, command_status == 0)
end subroutine run_command