Fortran Wiki
get_command

Description

Retrieve the entire command line that was used to invoke the program.

Standard

Fortran 2003 and later

Class

Subroutine

Syntax

call get_command([command, length, status])

Arguments

  • command - (Optional) shall be of type character and of default kind.
  • length - (Optional) Shall be of type integer and of default kind.
  • status - (Optional) Shall be of type integer and of default kind.

Return value

If command is present, stores the entire command line that was used to invoke the program in command. If length is present, it is assigned the length of the command line. If status is present, it is assigned 0 upon success of the command, -1 if command is too short to store the command line, or a positive value in case of an error.

Example

program test_get_command
  character(len=255) :: cmd
  call get_command(cmd)
  write (*,*) trim(cmd)
end program

See also

get_command_argument, command_argument_count

category: intrinsics