environ_var⚓︎
Descriptive description.
CmgRunEnvironment
⚓︎
A context manager class to run CMG simulators with correct environmental variables.
__enter__()
⚓︎
Method that is run when class is initiated by a 'with'-statement
Changelog
- ST 25/10-18
__exit__(exc_typ, exc_val, exc_trb)
⚓︎
Method that is run when 'with'-statement closes. Here, we reset environment variables and Process context to what is was set to before the 'with'-statement. Input here in this method are required to work in 'with'-statement.
Changelog
- ST 25/10-18
__init__(root, simulator, version, license)
⚓︎
We initialize the context manager by setting up correct paths and environment variable names that we set in enter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
str
|
Root folder where CMG simulator(s) are installed. |
required |
simulator
|
str
|
Simulator name. |
required |
version
|
str
|
Version of the simulator. |
required |
license
|
str
|
License server name. |
required |
Changelog
- ST 25/10-18
Notes
'version' is the release version of CMG, e.g., 2017.101.G.
EclipseRunEnvironment
⚓︎
A context manager class to run eclipse simulators with correct environmental variables.
__enter__()
⚓︎
Method that is run when class is initiated by a 'with'-statement
Changelog
- KF 30/10-19
__exit__(exc_typ, exc_val, exc_trb)
⚓︎
Method that is run when 'with'-statement closes. Here, we reset environment variables and Process context to what is was set to before the 'with'-statement. Input here in this method are required to work in 'with'-statement.
Changelog
- ST 25/10-18
__init__(filename)
⚓︎
input filename: eclipse run file, needed to check for errors (string)
Changelog
- KF 30/10-19
FlowRockRunEnvironment
⚓︎
A context manager class to run flowRock simulators with correct environmental variables.
__enter__()
⚓︎
Method that is run when class is initiated by a 'with'-statement
Changelog
- KF 30/10-19
__exit__(exc_typ, exc_val, exc_trb)
⚓︎
Method that is run when 'with'-statement closes. Here, we reset environment variables and Process context to what is was set to before the 'with'-statement. Input here in this method are required to work in 'with'-statement.
Changelog
- ST 25/10-18
__init__(filename)
⚓︎
- filename: dummy run file
Changelog
- KF 30/10-19
OPMRunEnvironment
⚓︎
A context manager class to run OPM simulators with correct environmental variables.
__enter__()
⚓︎
Method that is run when class is initiated by a 'with'-statement
Changelog
- KF 30/10-19
__exit__(exc_typ, exc_val, exc_trb)
⚓︎
Method that is run when 'with'-statement closes. Here, we reset environment variables and Process context to what it was set to before the 'with'-statement. Input here in this method are required to work in 'with'-statement.
Changelog
- ST 25/10-18
__init__(filename, suffix, matchstring)
⚓︎
- filename: OPM run file, needed to check for errors (string)
- suffix: What file to search for complete sign
- matchstring: what is the complete sign
Changelog
- KF 30/10-19
OpenBlasSingleThread
⚓︎
A context manager class to set OpenBLAS multi threading environment variable to 1 (i.e., single threaded). The class is used in a 'with'-statement to ensure that everything inside the statement is run single threaded, and outside the statement is run using whatever the environment variable was set before the 'with'-statement. The environment variable setting threading in OpenBLAS is OMP_NUM_THREADS.
Examples:
>>> from system_tools.environ_var import OpenBlasSingleThread
... import ctypes
... import multiprocessing as mp
...
... def justdoit():
... # Load OpenBLAS library and print number of threads
... openblas_lib = ctypes.cdll.LoadLibrary('/scratch/openblas/lib/libopenblas.so')
... print(openblas_lib.openblas_get_num_threads())
...
... if __name__ == "__main__":
... # Load OpenBLAS library and print number of threads before the with-statement
... openblas_lib = ctypes.cdll.LoadLibrary('/scratch/openblas/lib/libopenblas.so')
... print(openblas_lib.openblas_get_num_threads())
...
... # Run a Process inside the with-statement with the OpenBlasSingleThread class.
... with OpenBlasSingleThread ():
... p = mp.Process (target=justdoit)
... p.start ()
... p.join ()
...
... # Load OpenBLAS library and print number of threads before the with-statement
... openblas_lib = ctypes.cdll.LoadLibrary('/scratch/openblas/lib/libopenblas.so')
... print(openblas_lib.openblas_get_num_threads())
__enter__()
⚓︎
Method that is run when class is initiated by a 'with'-statement
Changelog
- ST 31/10-17
__exit__(exc_typ, exc_val, exc_trb)
⚓︎
Method that is run when 'with'-statement closes. Here, we reset OMP_NUM_THREADS and Process context to what is was set to before the 'with'-statement. Input here in this method are required to work in 'with'-statement.
Changelog
- ST 31/10-17
__init__()
⚓︎
Init. the class with no inputs. Use this to initialize internal variables for storing number of threads an the Process context manager before the change to single thread.
Attributes:
Name | Type | Description |
---|---|---|
num_threads |
String with number of OpenBLAS threads before change to single threaded (it is the content of OMP_NUM_THREADS) |
|
ctx |
The context variable from Process (default is 'fork' context, but we want to use 'spawn') |
Changelog
- ST 31/10-17