Manual Reference Pages  - get_command (3fortran)

NAME

GET_COMMAND(3) - [SYSTEM:COMMAND LINE] Get the entire command line invocation

SYNOPSIS

call get_command([command] [,length] [,status] [,errmsg])

         subroutine get_command( command ,length ,status, errmsg )

character(len=*),intent(out),optional :: command integer(kind=**),intent(out),optional :: length integer(kind=**),intent(out),optional :: status character(len=*),intent(inout),optional :: errmsg

CHARACTERISTICS

o a kind designated as ** may be any supported kind for the type meeting the conditions described herein.
o COMMAND and ERRMSG are scalar character variables of default kind.
o LENGTH and STATUS are scalar integer with a decimal exponent range of at least four.

DESCRIPTION

GET_COMMAND(3) retrieves the entire command line that was used to invoke the program.

Note that what is typed on the command line is often processed by a shell. The shell typically processes special characters and white space before passing it to the program. The processing can typically be turned off by turning off globbing or quoting the command line arguments and/or changing the default field separators, but this should rarely be necessary.

RESULT

o COMMAND : If COMMAND is present, the entire command line that was used to invoke the program is stored into it. If the command cannot be determined, COMMAND is assigned all blanks.
o LENGTH : If LENGTH is present, it is assigned the length of the command line. It is system-dependent as to whether trailing blanks will be counted. : If the command length cannot be determined, a length of 0 is assigned.
o STATUS : 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.
o ERRMSG : It is assigned a processor-dependent explanatory message if the command retrieval fails. Otherwise, it is unchanged.

EXAMPLES

Sample program:

    program demo_get_command
    implicit none
    integer                      :: command_line_length
    character(len=:),allocatable :: command_line
       ! get command line length
       call get_command(length=command_line_length)
       ! allocate string big enough to hold command line
       allocate(character(len=command_line_length) :: command_line)
       ! get command line as a string
       call get_command(command=command_line)
       ! trim leading spaces just in case
       command_line=adjustl(command_line)
       write(*,’("OUTPUT:",a)’)command_line
    end program demo_get_command

Results:

         # note that shell expansion removes some of the whitespace
         # without quotes
         ./test_get_command  arguments    on command   line to   echo

OUTPUT:./test_get_command arguments on command line to echo

# using the bash shell with single quotes ./test_get_command ’arguments *><‘~[]!{}?"#146;| ’

OUTPUT:./test_get_command arguments *><‘~[]!{}?"’|

STANDARD

Fortran 2003

SEE ALSO

GET_COMMAND_ARGUMENT(3), COMMAND_ARGUMENT_COUNT(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 get_command (3fortran) April 28, 2024
Generated by manServer 1.08 from 34c2a697-cac2-4180-83fc-f27c6d2bd93e using man macros.