[0b00607] | 1 | ******************************************** |
---|
[f20342a] | 2 | The compilation job script ``compilejob.ksh`` |
---|
[0b00607] | 3 | ******************************************** |
---|
| 4 | |
---|
[f20342a] | 5 | The compile job is a Korn-shell script which will be created during the installation process for the application modes **remote** and **gateway** from a template called ``compilejob.template`` in the template directory. |
---|
[0b00607] | 6 | |
---|
[f20342a] | 7 | ``Flex_extract`` uses the Python package `genshi <https://genshi.edgewall.org/>`_ to generate |
---|
[0b00607] | 8 | the Korn-shell script from the template files by substituting the individual parameters. |
---|
| 9 | These individual parameters are marked by a doubled ``$`` sign in ``job.temp``. |
---|
| 10 | |
---|
[f20342a] | 11 | The job script has a number of settings for the batch system which are fixed, and it differentiates between the *ecgate* and the *cca/ccb* |
---|
[0b00607] | 12 | server system to load the necessary modules for the environment when submitted to the batch queue. |
---|
| 13 | |
---|
| 14 | The submission is done by the ``ECaccess`` tool from within ``flex_extract`` with the command ``ecaccess-job-submit``. |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | What does the compilation script do? |
---|
| 19 | ------------------------------------ |
---|
| 20 | |
---|
[f20342a] | 21 | #. It sets the necessary batch-system parameters |
---|
[0b00607] | 22 | #. It prepares the job environment at the ECMWF servers by loading the necessary library modules |
---|
[f20342a] | 23 | #. It sets some environment variables for the single session |
---|
[0b00607] | 24 | #. It creates the ``flex_extract`` root directory in the ``$HOME`` path of the user |
---|
[f20342a] | 25 | #. It untars the tarball into the root directory. |
---|
| 26 | #. It compiles the Fortran program using ``Makefile``. |
---|
| 27 | #. At the end, it checks whether the script has returned an error or not, and emails the log file to the user. |
---|
[0b00607] | 28 | |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | Example ``compilejob.ksh`` |
---|
| 34 | -------------------------- |
---|
| 35 | |
---|
| 36 | .. code-block:: bash |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | #!/bin/ksh |
---|
| 40 | |
---|
| 41 | # ON ECGB: |
---|
| 42 | # start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE on gateway server |
---|
| 43 | # start with sbatch NAME_OF_THIS_FILE directly on machine |
---|
| 44 | |
---|
| 45 | #SBATCH --workdir=/scratch/ms/at/km4a |
---|
| 46 | #SBATCH --qos=normal |
---|
| 47 | #SBATCH --job-name=flex_ecmwf |
---|
| 48 | #SBATCH --output=flex_ecmwf.%j.out |
---|
| 49 | #SBATCH --error=flex_ecmwf.%j.out |
---|
| 50 | #SBATCH --mail-type=FAIL |
---|
| 51 | #SBATCH --time=12:00:00 |
---|
| 52 | |
---|
| 53 | ## CRAY specific batch requests |
---|
| 54 | ##PBS -N flex_ecmwf |
---|
| 55 | ##PBS -q ns |
---|
| 56 | ##PBS -S /usr/bin/ksh |
---|
| 57 | ##PBS -o /scratch/ms/at/km4a/flex_ecmwf.${Jobname}.${Job_ID}.out |
---|
| 58 | # job output is in .ecaccess_DO_NOT_REMOVE |
---|
| 59 | ##PBS -j oe |
---|
| 60 | ##PBS -V |
---|
| 61 | ##PBS -l EC_threads_per_task=1 |
---|
| 62 | ##PBS -l EC_memory_per_task=3200MB |
---|
| 63 | |
---|
| 64 | set -x |
---|
| 65 | export VERSION=7.1 |
---|
| 66 | case ${HOST} in |
---|
| 67 | *ecg*) |
---|
| 68 | module unload grib_api |
---|
| 69 | module unload eccodes |
---|
| 70 | module unload python |
---|
| 71 | module unload emos |
---|
| 72 | module load python3 |
---|
| 73 | module load eccodes/2.12.0 |
---|
| 74 | module load emos/455-r64 |
---|
| 75 | export FLEXPART_ROOT_SCRIPTS=${HOME} |
---|
[b1674ed] | 76 | export MAKEFILE=makefile_ecgate |
---|
[0b00607] | 77 | ;; |
---|
| 78 | *cca*) |
---|
| 79 | module unload python |
---|
| 80 | module switch PrgEnv-cray PrgEnv-intel |
---|
| 81 | module load python3 |
---|
| 82 | module load eccodes/2.12.0 |
---|
| 83 | module load emos |
---|
| 84 | echo ${GROUP} |
---|
| 85 | echo ${HOME} |
---|
| 86 | echo ${HOME} | awk -F / '{print $1, $2, $3, $4}' |
---|
| 87 | export GROUP=`echo ${HOME} | awk -F / '{print $4}'` |
---|
| 88 | export SCRATCH=/scratch/ms/${GROUP}/${USER} |
---|
| 89 | export FLEXPART_ROOT_SCRIPTS=${HOME} |
---|
[b1674ed] | 90 | export MAKEFILE=makefile_ecgate |
---|
[0b00607] | 91 | ;; |
---|
| 92 | esac |
---|
| 93 | |
---|
| 94 | mkdir -p ${FLEXPART_ROOT_SCRIPTS}/flex_extract_v${VERSION} |
---|
| 95 | cd ${FLEXPART_ROOT_SCRIPTS}/flex_extract_v${VERSION} # if FLEXPART_ROOT is not set this means cd to the home directory |
---|
| 96 | tar -xvf ${HOME}/flex_extract_v${VERSION}.tar |
---|
[b1674ed] | 97 | cd Source/Fortran |
---|
| 98 | \rm *.o *.mod calc_etadot |
---|
[0b00607] | 99 | make -f ${MAKEFILE} >flexcompile 2>flexcompile |
---|
| 100 | |
---|
[b1674ed] | 101 | ls -l calc_etadot >>flexcompile |
---|
[0b00607] | 102 | if [ $? -eq 0 ]; then |
---|
| 103 | echo 'SUCCESS!' >>flexcompile |
---|
| 104 | mail -s flexcompile.${HOST}.$$ ${USER} <flexcompile |
---|
| 105 | else |
---|
| 106 | echo Environment: >>flexcompile |
---|
| 107 | env >> flexcompile |
---|
| 108 | mail -s "ERROR! flexcompile.${HOST}.$$" ${USER} <flexcompile |
---|
| 109 | fi |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | .. toctree:: |
---|
| 115 | :hidden: |
---|
| 116 | :maxdepth: 2 |
---|