+------------------------Fortran 2003 Draft Standard-------------------------+

GET_ENVIRONMENT_VARIABLE(NAME, VALUE, LENGTH, STATUS, TRIM_NAME)

Purpose

Returns the value of the specified environment variable.

Class

Subroutine

Argument Type and Attributes

NAME
is a character string that identifies the name of the operating-system environment variable. The string is case-significant. It is an INTENT(IN) argument that must be scalar of type default character.

VALUE (optional)
is the value of the environment variable, or a string of blanks if the environment variable has no value or does not exist. It is an INTENT(OUT) argument that must be scalar of type default character.

LENGTH (optional)
is the significant length of the value, or 0 if the environment variable has no value or does not exist. It is an INTENT(OUT) argument that must be scalar of type default integer.

STATUS (optional)
is a status value. It is an INTENT(OUT) argument that must be scalar of type default integer.

STATUS has one of the following values:

TRIM_NAME (optional)
is a logical value that specifies whether to trim trailing blanks in NAME. By default, trailing blanks in NAME are trimmed. If TRIM_NAME exists and has the value .FALSE., trailing blanks in NAME are considered significant. TRIM_NAME is an INTENT(IN) argument that must be scalar of type logical.

Examples

integer num, len, status
character*15 value
call GET_ENVIRONMENT_VARIABLE('HOME', value, len, status)
print*, value
print*, len
print*, status

The following is sample output generated by the above program:

$ a.out
/home/xlfuser       (followed by two spaces)
13
0

+---------------------End of Fortran 2003 Draft Standard---------------------+

IBM Copyright 2003