[UP]


Manual Reference Pages  - 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
Example
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.

EXAMPLE

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
      !!
      write(*,’(a)’)’no environment variables containing "GRU":’
      call execute_command_line(’env|grep GRU’)
      !!
      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’)
      !!
      call set_environment_variable(’GRU2’,’this is the second value’,ierr)
      write(*,’(a,i0)’)’now "GRU" and "GRU2" should be defined, status =’,ierr
      !!
      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


set_environment_variable (3) July 05, 2020
Generated by manServer 1.08 from ae5b62dd-b469-4d0b-8683-c8e320ea6aa8 using man macros.