source: flex_extract.git/Documentation/html/_sources/Documentation/Input/templates.rst.txt @ 08c9091

ctbtodev
Last change on this file since 08c9091 was 08c9091, checked in by Anne Philipp <anne.philipp@…>, 4 years ago

updated online docu (rm tabs)

  • Property mode set to 100644
File size: 11.5 KB
Line 
1*********
2Templates
3*********
4
5In ``flex_extract``, the Python package `genshi <https://genshi.edgewall.org/>`_ is used to create specific files from templates. It is the most efficient way to be able to quickly adapt, e. g., the job scripts sent to the ECMWF batch queue system, or the namelist file für the Fortran program, without the need to change the program code.
6
7.. note::
8   Do not change anything in these files unless you understand the effects!
9   
10Each template file has its content framework and keeps so-called placeholder variables in the positions where the values need to be substituted at run time. These placeholders are marked by a leading ``$`` sign. In case of the Korn shell job scripts, where (environment) variables are used, the ``$`` sign needs to be doubled for `escaping`.
11   
12The following templates are used; they can be found in the directory ``flex_extract_vX.X/Templates``:
13
14calc_etadot_nml.template
15-------------------------
16
17    This is the template for a Fortran namelist file called ``fort.4`` read by ``calc_etadot``.
18    It contains all the parameters ``calc_etadot`` needs.
19   
20    .. code-block:: fortran
21 
22        &NAMGEN
23          maxl = $maxl,
24          maxb = $maxb,
25          mlevel = $mlevel,
26          mlevelist = "$mlevelist",
27          mnauf = $mnauf,
28          metapar = $metapar,
29          rlo0 = $rlo0,
30          rlo1 = $rlo1,
31          rla0 = $rla0,
32          rla1 = $rla1,
33          momega = $momega,
34          momegadiff = $momegadiff,
35          mgauss = $mgauss,
36          msmooth = $msmooth,
37          meta = $meta,
38          metadiff = $metadiff,
39          mdpdeta = $mdpdeta
40        /
41
42ECMWF_ENV.template
43------------------
44
45    This template is used to create the ``ECMWF_ENV`` file in the application modes **gateway** and **remote**. It contains the user credentials and gateway server settings for the file transfers.
46
47    .. code-block:: bash
48   
49        ECUID $user_name
50        ECGID $user_group
51        GATEWAY $gateway_name
52        DESTINATION $destination_name
53
54installscript.template
55----------------------
56
57    This template is used to create the job script file called ``compilejob.ksh`` during the installation process for the application modes **remote** and **gateway**.
58
59    At the beginning, some directives for the batch system are set.
60    On the **ecgate** server, the ``SBATCH`` comments are the directives for the SLURM workload manager. A description of the single lines can be found at `SLURM directives <https://confluence.ecmwf.int/display/UDOC/Writing+SLURM+jobs>`_.
61    For the high-performance computers **cca** and **ccb**, the ``PBS`` comments are necessary;  for details see `PBS directives <https://confluence.ecmwf.int/display/UDOC/Batch+environment%3A++PBS>`_.
62
63    The software environment requirements mentioned in :ref:`ref-requirements` are prepared by loading the corresponding modules depending on the ``HOST``. It should not be changed without testing.
64   
65    Afterwards, the installation steps as such are done. They included the generation of the root directory, putting files in place, compiling the Fortran program, and sending a log file by email.
66
67    .. code-block:: ksh
68   
69        #!/bin/ksh
70
71        # ON ECGB:
72        # start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE  on gateway server
73        # start with sbatch NAME_OF_THIS_FILE directly on machine
74
75        #SBATCH --workdir=/scratch/ms/$usergroup/$username
76        #SBATCH --qos=normal
77        #SBATCH --job-name=flex_ecmwf
78        #SBATCH --output=flex_ecmwf.%j.out
79        #SBATCH --error=flex_ecmwf.%j.out
80        #SBATCH --mail-type=FAIL
81        #SBATCH --time=12:00:00
82
83        ## CRAY specific batch requests
84        ##PBS -N flex_ecmwf
85        ##PBS -q ns
86        ##PBS -S /usr/bin/ksh
87        ##PBS -o /scratch/ms/$usergroup/$username/flex_ecmwf.$${Jobname}.$${Job_ID}.out
88        # job output is in .ecaccess_DO_NOT_REMOVE
89        ##PBS -j oe
90        ##PBS -V
91        ##PBS -l EC_threads_per_task=1
92        ##PBS -l EC_memory_per_task=3200MB
93
94        set -x
95        export VERSION=$version_number
96        case $${HOST} in
97          *ecg*)
98          module unload grib_api
99          module unload emos
100          module load python3
101          module load eccodes
102          module load emos/455-r64
103          export FLEXPART_ROOT_SCRIPTS=$fp_root_scripts
104          export MAKEFILE=$makefile
105          ;;
106          *cca*)
107          module switch PrgEnv-cray PrgEnv-intel
108          module load python3
109          module load eccodes
110          module load emos/455-r64
111          echo $${GROUP}
112          echo $${HOME}
113          echo $${HOME} | awk -F / '{print $1, $2, $3, $4}'
114          export GROUP=`echo $${HOME} | awk -F / '{print $4}'`
115          export SCRATCH=/scratch/ms/$${GROUP}/$${USER}
116          export FLEXPART_ROOT_SCRIPTS=$fp_root_scripts
117          export MAKEFILE=$makefile
118          ;;
119        esac
120
121        mkdir -p $${FLEXPART_ROOT_SCRIPTS}/flex_extract_v$${VERSION}
122        cd $${FLEXPART_ROOT_SCRIPTS}/flex_extract_v$${VERSION}   # if FLEXPART_ROOT is not set this means cd to the home directory
123        tar -xvf $${HOME}/flex_extract_v$${VERSION}.tar
124        cd Source/Fortran
125        \rm *.o *.mod $fortran_program
126        make -f $${MAKEFILE} >flexcompile 2>flexcompile
127
128        ls -l $fortran_program >>flexcompile
129        if [ $$? -eq 0 ]; then
130          echo 'SUCCESS!' >>flexcompile
131          mail -s flexcompile.$${HOST}.$$$$ $${USER} <flexcompile
132        else
133          echo Environment: >>flexcompile
134          env >> flexcompile
135          mail -s "ERROR! flexcompile.$${HOST}.$$$$" $${USER} <flexcompile
136        fi
137
138
139submitscript.template
140---------------------
141
142    This template is used to create the actual job script file called ``job.ksh`` for the execution of ``flex_extract`` in the application modes **remote** and **gateway**.
143
144    At the beginning, some directives for the batch system are set.
145    On the **ecgate** server, the ``SBATCH`` comments are the directives for the SLURM workload manager. A description of the single lines can be found at `SLURM directives <https://confluence.ecmwf.int/display/UDOC/Writing+SLURM+jobs>`_.
146    For the high performance computers **cca** and **ccb**, the ``PBS`` comments are necessary;
147    for details see `PBS directives <https://confluence.ecmwf.int/display/UDOC/Batch+environment%3A++PBS>`_.
148
149    The software environment requirements mentioned in :ref:`ref-requirements` are prepared by loading the corresponding modules depending on the ``HOST``. It should not be changed without testing.
150   
151    Afterwards, the run directory and the ``CONTROL`` file are created and ``flex_extract`` is executed. In the end, a log file is send by email.
152   
153    .. code-block:: ksh
154   
155        #!/bin/ksh
156
157        # ON ECGB:
158        # start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE  on gateway server
159        # start with sbatch NAME_OF_THIS_FILE directly on machine
160
161        #SBATCH --workdir=/scratch/ms/at/km4a
162        #SBATCH --qos=normal
163        #SBATCH --job-name=flex_ecmwf
164        #SBATCH --output=flex_ecmwf.%j.out
165        #SBATCH --error=flex_ecmwf.%j.out
166        #SBATCH --mail-type=FAIL
167        #SBATCH --time=12:00:00
168
169        ## CRAY specific batch requests
170        ##PBS -N flex_ecmwf
171        ##PBS -q np
172        ##PBS -S /usr/bin/ksh
173        ## -o /scratch/ms/at/km4a/flex_ecmwf.$${PBS_JOBID}.out
174        ## job output is in .ecaccess_DO_NOT_REMOVE
175        ##PBS -j oe
176        ##PBS -V
177        ##PBS -l EC_threads_per_task=24
178        ##PBS -l EC_memory_per_task=32000MB
179
180        set -x
181        export VERSION=7.1
182        case $${HOST} in
183          *ecg*)
184          module unload grib_api
185          module unload emos
186          module load python3
187          module load eccodes
188          module load emos/455-r64
189          export PATH=${PATH}:${HOME}/flex_extract_v7.1/Source/Python
190          ;;
191          *cca*)
192          module switch PrgEnv-cray PrgEnv-intel
193          module load python3
194          module load eccodes
195          module load emos/455-r64
196          export SCRATCH=${TMPDIR}
197          export PATH=${PATH}:${HOME}/flex_extract_v7.1/Source/Python
198          ;;
199        esac
200
201        cd $${SCRATCH}
202        mkdir -p python$$$$
203        cd python$$$$
204
205        export CONTROL=CONTROL
206
207        cat >$${CONTROL}<<EOF
208        $control_content
209        EOF
210
211
212        submit.py --controlfile=$${CONTROL} --inputdir=./work --outputdir=./work 1> prot 2>&1
213
214        if [ $? -eq 0 ] ; then
215          l=0
216          for muser in `grep -i MAILOPS $${CONTROL}`; do
217              if [ $${l} -gt 0 ] ; then
218                 mail -s flex.$${HOST}.$$$$ $${muser} <prot
219              fi
220              l=$(($${l}+1))
221          done
222        else
223          l=0
224          for muser in `grep -i MAILFAIL $${CONTROL}`; do
225              if [ $${l} -gt 0 ] ; then
226                 mail -s "ERROR! flex.$${HOST}.$$$$" $${muser} <prot
227              fi
228              l=$(($${l}+1))
229          done
230        fi
231       
232
233jobscript.template
234------------------
235
236    This template is used to create the template for the execution job script ``submitscript.template`` for ``flex_extract`` in the installation process. A description of the file can be found under ``submitscript.template``. Several parameters are set in this process, such as the user credentials and the ``flex_extract`` version number.
237       
238    .. code-block:: ksh
239   
240        #!/bin/ksh
241
242        # ON ECGB:
243        # start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE  on gateway server
244        # start with sbatch NAME_OF_THIS_FILE directly on machine
245
246        #SBATCH --workdir=/scratch/ms/$usergroup/$username
247        #SBATCH --qos=normal
248        #SBATCH --job-name=flex_ecmwf
249        #SBATCH --output=flex_ecmwf.%j.out
250        #SBATCH --error=flex_ecmwf.%j.out
251        #SBATCH --mail-type=FAIL
252        #SBATCH --time=12:00:00
253
254        ## CRAY specific batch requests
255        ##PBS -N flex_ecmwf
256        ##PBS -q np
257        ##PBS -S /usr/bin/ksh
258        ## -o /scratch/ms/$usergroup/$username/flex_ecmwf.$$$${PBS_JOBID}.out
259        ## job output is in .ecaccess_DO_NOT_REMOVE
260        ##PBS -j oe
261        ##PBS -V
262        ##PBS -l EC_threads_per_task=24
263        ##PBS -l EC_memory_per_task=32000MB
264
265        set -x
266        export VERSION=$version_number
267        case $$$${HOST} in
268          *ecg*)
269          module unload grib_api
270          module unload emos
271          module load python3
272          module load eccodes
273          module load emos/455-r64
274          export PATH=$$$${PATH}:$fp_root_path
275          ;;
276          *cca*)
277          module switch PrgEnv-cray PrgEnv-intel
278          module load python3
279          module load eccodes
280          module load emos/455-r64
281          export SCRATCH=$$$${TMPDIR}
282          export PATH=$$$${PATH}:$fp_root_path
283          ;;
284        esac
285
286        cd $$$${SCRATCH}
287        mkdir -p python$$$$$$$$
288        cd python$$$$$$$$
289
290        export CONTROL=CONTROL
291
292        cat >$$$${CONTROL}<<EOF
293        $$control_content
294        EOF
295
296
297        submit.py --controlfile=$$$${CONTROL} --inputdir=./work --outputdir=./work 1> prot 2>&1
298
299        if [ $? -eq 0 ] ; then
300          l=0
301          for muser in `grep -i MAILOPS $$$${CONTROL}`; do
302              if [ $$$${l} -gt 0 ] ; then
303                 mail -s flex.$$$${HOST}.$$$$$$$$ $$$${muser} <prot
304              fi
305              l=$(($$$${l}+1))
306          done
307        else
308          l=0
309          for muser in `grep -i MAILFAIL $$$${CONTROL}`; do
310              if [ $$$${l} -gt 0 ] ; then
311                 mail -s "ERROR! flex.$$$${HOST}.$$$$$$$$" $$$${muser} <prot
312              fi
313              l=$(($$$${l}+1))
314          done
315        fi
316
317
318
319   
320
321.. toctree::
322    :hidden:
323    :maxdepth: 2
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG