C Library Functions - set_environment_variable (3)
NAME
set_environment_variable(3f) - [M_system:ENVIRONMENT] call setenv(3c)
to set environment variable
(LICENSE:PD)
CONTENTS
Synopsis
Description
Options
Examples
Author
License
SYNOPSIS
subroutine set_environment_variable(NAME, VALUE, STATUS)
character(len=*) :: NAME
character(len=*) :: VALUE
integer, optional, intent(out) :: STATUS
DESCRIPTION
The set_environment_variable() procedure adds or changes the value
of environment variables.
OPTIONS
|
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.
|
|
EXAMPLES
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_variable
Results:
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
AUTHOR
John S. Urban
LICENSE
Public Domain
| Nemo Release 3.1 | set_environment_variable (3) | June 29, 2025 |
Generated by manServer 1.08 from ad6efca9-3874-4ca4-896a-a777841c3e8c using man macros.