set_environment_variable(3f) - [M_system:ENVIRONMENT] call setenv(3c) to set environment variable (LICENSE:PD)
Synopsis
Description
Options
Examples
Author
License
subroutine set_environment_variable(NAME, VALUE, STATUS)
character(len=*) :: NAME character(len=*) :: VALUE integer, optional, intent(out) :: STATUS
The set_environment_variable() procedure adds or changes the value of environment variables.
NAME If name does not already exist in the environment, then string is added to the environment. If name does exist, then the value of name in the environment is changed to value. VALUE Value to assign to environment variable NAME STATUS returns zero on success, or nonzero if an error occurs. A non-zero error usually indicates sufficient memory does not exist to store the variable.
Sample setting an environment variable from Fortran:
program demo_set_environment_variable use M_system, only : set_environment_variable use iso_c_binding implicit none integer :: ierr !x! write(*,(a))no environment variables containing "GRU": call execute_command_line(env|grep GRU) !x! call set_environment_variable(GRU,this is the value,ierr) write(*,(a,i0))now "GRU" should be defined, status=,ierr call execute_command_line(env|grep GRU) !x! call set_environment_variable(GRU2,this is the second value,ierr) write(*,(a,i0))now "GRU" and "GRU2" should be defined, status =,ierr !x! call execute_command_line(env|grep GRU) end program demo_set_environment_variableResults:
no environment variables containing "GRU": now "GRU" should be defined, status=0 GRU=this is the value now "GRU" and "GRU2" should be defined, status =0 GRU2=this is the second value GRU=this is the value
John S. Urban
Public Domain
Nemo Release 3.1 | set_environment_variable (3m_system) | March 07, 2025 |