Skip to content

Commit 227d878

Browse files
committed
Correct usage documentation, see issue #36
1 parent 0e254fe commit 227d878

2 files changed

Lines changed: 71 additions & 43 deletions

File tree

docs/installation.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ For FMU users
1010
**A normal user will not need to install anything!**
1111

1212
The stable and bleeding release of the scripts is distributed
13-
within Equinor, either through
14-
/project/res or Komodo. The front-end to run is the ``fmuconfig`` script:
13+
within Equinor through Komodo. The front-end to run is the ``fmuconfig`` script:
1514

1615
.. code-block:: console
1716

docs/usage.rst

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,106 @@
22
Usage
33
=====
44

5+
Folder structure
6+
----------------
7+
8+
A recommended folder structure in Equinor is (assuming the revision folder is 21.2.0
9+
in this example):
10+
11+
.. code-block:: bash
12+
13+
21.2.0/fmuconfig/input
14+
/bin
15+
/output
16+
17+
The ``input`` has a file ``global_master_config.yml`` a possibly a few include files,
18+
and these are edited by users.
19+
20+
The ``bin`` has shell scripts that process the input to a set of YAML and/or IPL
21+
which is stored at ``output``. The files in output shall never be edited by hand.
22+
23+
524
Run from script
625
---------------
726

8-
The fmu.config module is accessed through a script, which is run like this::
27+
The ``fmu.config`` module is accessed through a script, and assuming the file structure
28+
above, is to be run like this:
929

10-
fmuconfig global_master_config.yml <options...>
30+
.. code-block:: shell
1131
12-
The global master config *shall* be placed at ``rNNN/share/config`` or
13-
``rNNN/share/config/input``, where *rNNN* is
14-
the revision number.
32+
# go to fmuconfig/bin
33+
fmuconfig ../input/global_master_config.yml <options...>
1534
16-
Here is an example of a shell script that runs `fmuconfig` from the rms/bin folder:
35+
Here is an example of a shell script that runs `fmuconfig` from the ``bin`` folder:
1736

1837
.. code-block:: bash
1938
2039
#!/bin/bash
21-
#
22-
# Run the global configuration for RMS, both making IPL and YAML versions
23-
# from a common global config
24-
#
25-
source /project/res/SDP_bashrc
26-
source /project/res/komodo/stable/enable
2740
28-
MASTER="../../share/config/input/global_master_config.yml"
29-
DEST="../input/global_variables"
30-
TMPL="../../ert/input/templates"
31-
ROOTIPL="global_variables"
32-
ROOTYML="global_variables_rms"
41+
MASTER="../../fmuconfig/input/global_master_config.yml" # all updates here
42+
OUTFOLDER="../../fmuconfig/output" # location of result files
43+
ROOTNAME="global_variables" # root name of result files
3344
34-
# run command for IPL version
35-
fmuconfig $MASTER --rootname $ROOTIPL --mode ipl --destination $DEST \
36-
--template $TMPL --tool rms
45+
# clean up (be careful with syntax)
46+
rm -f ${OUTFOLDER}/ROOTNAME*
3747
38-
# run command for YAML version
39-
fmuconfig $MASTER --rootname $ROOTYML --mode yml --destination $DEST \
40-
--template $TMPL --tool rms
48+
# run command for creating YAML version (+ ert tmpl version; yml.tmpl)
49+
fmuconfig $MASTER --rootname $ROOTNAME --mode yml --destination $OUTFOLDER \
50+
--template $OUTFOLDER
51+
52+
# optional!
53+
# run command for creating IPL version if needed (+ ert tmpl version; ipl.tmpl)
54+
fmuconfig $MASTER --rootname $ROOTNAME --mode ipl --destination $OUTFOLDER \
55+
--template $OUTFOLDER --tool rms
4156
4257
4358
Run from python inside or outside RMS
4459
-------------------------------------
4560

46-
The config can also be ran from a python script, e.g. inside RMS. In that case you
61+
In RMS there are two options to run global variables:
62+
63+
* Run shell script above using system command (recommended)
64+
* Run from RMS python
65+
66+
For shell script for RMS, use a system command job as this:
67+
68+
.. code-block:: shell
69+
70+
cd ../../fmuconfig/bin; run_external sh global_variables_update.sh
71+
72+
The config can also be run from a python script inside RMS. In that case you
4773
need to initiate the Class instance and run a few methods. Here is an example:
4874

4975
.. code-block:: python
5076
77+
"""Run global config in RMS python."""
78+
from pathlib import Path
5179
import fmu.config
5280
53-
cfg = fmu.config.ConfigParserFMU()
54-
55-
global_master = '../../share/config/input/global_master_config.yml'
56-
path_ipl = '../input/global_variables'
57-
path_ipl_tmpl = '../../ert/input/templates'
58-
root_ipl = 'global_variables'
5981
60-
root_yml = 'global_variables_rms' # to avoid name conflict
82+
MASTER = "../../fmuconfig/input/global_master_config.yml"
83+
OUTPUT = "../../fmuconfig/output"
84+
ROOT = "global_variables"
6185
62-
cfg.parse(global_master)
86+
def cleanup():
87+
for file in Path(OUTPUT).glob(ROOT + "*"):
88+
file.unlink()
89+
print(f"Removed old {file}")
6390
64-
# make IPL
65-
cfg.to_ipl(rootname=root_ipl, destination=path_ipl, template=path_ipl_tmpl,
66-
tool='rms')
67-
cfg.to_yaml(rootname=root_yml, destination=path_ipl, template=path_ipl_tmpl,
68-
tool='rms')
6991
70-
print('\n\nGlobal IPL and YML are updated')
92+
def main():
93+
cfg = fmu.config.ConfigParserFMU()
94+
cfg.parse(MASTER)
7195
96+
# make IPL, optional!
97+
cfg.to_ipl(rootname=ROOT, destination=OUTPUT, template=OUTPUT, tool="rms")
7298
99+
# YAML
100+
cfg.to_yaml(rootname=ROOT, destination=OUTPUT, template=OUTPUT)
73101
102+
print("\n\nGlobal IPL and YML are updated")
74103
75-
Learn by examples!
76-
------------------
77104
78-
Learn the format by studying the following examples.
105+
if __name__ == "__main__":
106+
cleanup()
107+
main()

0 commit comments

Comments
 (0)