C Library Functions  - get_env (3)

NAME

get_env(3f) - [M_io:QUERY] a function returning the value of an environment variable (LICENSE:PD)

CONTENTS

Syntax
Description
Options
Returns
Example
See Also
Author
License

SYNTAX

function get_env(NAME,DEFAULT) result(VALUE)

    character(len=*),intent(in)          :: NAME
    character(len=*),intent(in),optional :: DEFAULT
    character(len=:),allocatable         :: VALUE

DESCRIPTION

Get the value of an environment variable or optionally return a default value if the returned value would be a blank string.

This is a duplicate of system_getenv(3m_system) used to avoid some interdependencies.

OPTIONS

NAME name of environment variable
DEFAULT
  value to return if environment variable is not set or set to an empty string

RETURNS

VALUE the value of the environment variable or the default

EXAMPLE

Sample program:

      program demo_get_env
      use M_io, only : get_env
      character(len=:),allocatable :: HOME
         HOME=get_env(’HOME’,’UNKNOWN’)
         write(*,’(a)’)HOME,get_env(’PATH’)
         write(*,’(a)’)get_env(’HOME’),get_env(’PATH’)
      end program demo_get_env

SEE ALSO

get_environment_variable(3fortran), system_getenv(3m_system), set_environment_variable(3m_system), system_putenv(3m_system), system_clearenv(3m_system), system_initenv(3m_system), system_readenv(3m_system), system_unsetenv(3m_system)

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 get_env (3) July 22, 2023
Generated by manServer 1.08 from aa1cbcaf-1e94-4a81-a421-3e2164adc9fa using man macros.