# PetscOptionsGetenv

Gets an environmental variable, broadcasts to all processors in communicator from first.

### Synopsis

    #include "petscsys.h"
    PetscErrorCode PETSC_DLLEXPORT PetscOptionsGetenv(MPI_Comm comm,const char name[],char env[],size_t len,PetscTruth *flag)

Collective on MPI_Comm

### Input Parameters

| comm | - communicator to share variable
| name | - name of environmental variable
| len | - amount of space allocated to hold variable

### Output Parameters

| flag | - if not PETSC_NULL tells if variable found or not
| env | - value of variable

### Notes

You can also "set" the environmental variable by setting the options database value -name "stringvalue" (with name in lower case). If name begins with PETSC_ this is discarded before checking the database. For example, PETSC_VIEWER_SOCKET_PORT would be given as -viewer_socket_port 9000

If comm does not contain the 0th process in the MPIRUN it is likely on many systems that the environmental variable will not be set unless you put it in a universal location like a .chsrc file

Level:advanced
Location:src/sys/src/utils/pdisplay.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages