GET_ENVIRONMENT_VARIABLE

8.103 GET_ENVIRONMENT_VARIABLE — Get an environmental variable

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 with a call to the GET_ENVIRONMENT_VARIABLE intrinsic.

Standard:
Fortran 2003 and later
Class:
Subroutine
Syntax:
CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)
Arguments:
NAME 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:
PROGRAM test_getenv
  CHARACTER(len=255) :: homedir
  CALL get_environment_variable("HOME", homedir)
  WRITE (*,*) TRIM(homedir)
END PROGRAM

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gfortran/GET_005fENVIRONMENT_005fVARIABLE.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部