system_getenv(3f) - [M_system:ENVIRONMENT] get environment variable from Fortran by calling get_environment_variable(3f) (LICENSE:PD)
Synopsis
Description
Options
Examples
Author
License
function system_getenv(name,default)
character(len=:),allocatable :: system_getenv character(len=*),intent(in) :: name character(len=*),intent(in),optional :: default
The system_getenv() function gets the value of an environment variable.
name Return the value of the specified environment variable or blank if the variable is not defined. default If the value returned would be blank this value will be used instead.
Sample setting an environment variable from Fortran:
program demo_system_getenv use M_system, only : system_getenv use M_system, only : ge=>system_getenv implicit none character(len=:),allocatable :: TMPDIRwrite(*,("USER : ",a))system_getenv(USER) write(*,("LOGNAME : ",a))system_getenv(LOGNAME) write(*,("USERNAME : ",a))system_getenv(USERNAME)
! look first for USER then LOGNAME then USERNAME write(*, *)ge(USER, ge(LOGNAME, ge(USERNAME, UNKNOWN)))
TMPDIR= ge(TMPDIR, ge(TMP, ge(TEMPDIR, ge(TEMP, /tmp)))) write(*,*)favorite scratch area is ,TMPDIR
end program demo_system_getenv
John S. Urban
Public Domain
Nemo Release 3.1 | system_getenv (3m_system) | March 07, 2025 |