[UP]


Manual Reference Pages  - get_environment_variable (3)

NAME

get_environment_variable(3f) - [FORTRAN:INTRINSIC:SYSTEM ENVIRONMENT] Get an environmental variable

CONTENTS

Syntax
Description
Arguments
Return Value
Example
Standard
Class

SYNTAX

call get_environment_variable(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)

DESCRIPTION

Get the VALUE of the environmental variable NAME.

Note that get_environment_variable need not be thread-safe. It is the responsibility of the user to ensure that the environment is not being updated concurrently.

ARGUMENTS

NAME - (Optional) Shall be a scalar of type CHARACTER and of default kind.
VALUE - (Optional) Shall be a scalar of type CHARACTER and of default kind.
LENGTH - (Optional) Shall be a scalar of type INTEGER and of default kind.
STATUS - (Optional) Shall be a scalar of type INTEGER and of default kind.
TRIM_NAME
  - (Optional) Shall be a scalar of type LOGICAL and of default kind.

RETURN VALUE

Stores the value of NAME in VALUE. If VALUE is not large enough to hold the data, it is truncated. If NAME is not set, VALUE will be filled with blanks.

Argument LENGTH contains the length needed for storing the environment variable NAME or zero if it is not present.

STATUS is -1 if VALUE is present but too short for the environment variable; it is 1 if the environment variable does not exist and 2 if the processor does not support environment variables; in all other cases STATUS is zero.

If TRIM_NAME is present with the value .FALSE., the trailing blanks in NAME are significant; otherwise they are not part of the environment variable name.

EXAMPLE

Sample program:

   program demo_getenv
     character(len=:),allocatable :: var
     character(len=:),allocatable :: homedir
     integer :: howbig
     var=’HOME’
     ! get length required to hold value
     call get_environment_variable(var, length=howbig)
     ! make string to hold value of sufficient size
     allocate(character(len=howbig) :: homedir)
     ! get value
     call get_environment_variable(var, homedir)
     ! print environment variable name value
     write (*,’(a,"=""",a,"""")’)var,trim(homedir)
   end program demo_getenv

Typical Results:

   HOME="/home/urbanjs/V600"

STANDARD

[[Fortran 2003]] and later

CLASS

Subroutine


get_environment_variable (3) March 18, 2019
Generated by manServer 1.08 from a04bdb04-317d-4f2a-b9dc-b3203e90bb1c using man macros.