Purpose
Returns the value of the specified
environment variable.
Argument type and attributes
- NAME
- An INTENT(IN) CHARACTER scalar.
It is a character string that identifies the name of the operating-system
environment variable. The string is case-significant.
- VALUE (optional)
- An INTENT(OUT) CHARACTER scalar.
It is assigned the value of the environment variable, or a string
of blanks if the environment variable has no value or does not exist.
- LENGTH (optional)
- An INTENT(OUT) INTEGER scalar.
It is assigned the significant length of the value, or 0 if the environment
variable has no value or does not exist.
- STATUS (optional)
- An INTENT(OUT) INTEGER scalar.
It is assigned a status value.
STATUS has
one of the following values:
- 0, if either the environment variable exists and its value is
successfully assigned to VALUE or the environment
variable exists but has no value
- 1, if the environment variable does not exist
- -1, if the length of the VALUE argument
is less than the significant length of the value of the environment
variable
- 3, if other error conditions occur
- TRIM_NAME (optional)
- An INTENT(IN) LOGICAL scalar. TRIM_NAME 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.
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