nsc-tetralith.cfg.tmpl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # Platform dependent configuration functions for the 'tetralith' machine
  2. # (tetralith.nsc.liu.se)
  3. function configure()
  4. {
  5. # This function should configure all settings/modules needed to
  6. # later prepare the EC-Earth run directory and set variables used
  7. # in the run script
  8. # Configure paths for building/running EC-Earth
  9. ecearth_src_dir=[[[PLT:ACTIVE:ECEARTH_SRC_DIR]]]
  10. run_dir=[[[PLT:ACTIVE:RUN_DIR]]]
  11. ini_data_dir=[[[PLT:ACTIVE:INI_DATA_DIR]]]
  12. # File for standard output.
  13. # NOTE: This will be modified for restart jobs!
  14. stdout_file=${start_dir}/out/$(basename ${SLURM_JOB_NAME}).out
  15. # Resubmit this job for automatic restarts? [true/false]
  16. # Also, add options for the resubmit command here.
  17. resubmit_job=[[[PLT:ACTIVE:RESUBMIT_JOB]]]
  18. resubmit_opt="[[[PLT:ACTIVE:RESUBMIT_OPT]]]"
  19. # In order to use a specific number of cores per node for LPJG:
  20. # - Set use_machinefile=true
  21. # - Set lpjg_ppn to the required value
  22. # - Adapt the number of nodes for your job!
  23. # Note that executables are not mixed on a node, when use_machinefile is
  24. # true. This means that every executable uses at least one node!
  25. use_machinefile=false
  26. lpjg_ppn=4
  27. # Configure grib api paths
  28. export GRIB_DEFINITION_PATH=[[[PLT:ACTIVE:ECEARTH_SRC_DIR]]]/util/grib_table_126:[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_DEFINITION_SUBDIR]]]
  29. export GRIB_SAMPLES_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_SAMPLES_SUBDIR]]]
  30. export GRIB_BIN_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_BIN_SUBDIR]]]
  31. # Configure number of processors per node
  32. proc_per_node=[[[PLT:ACTIVE:PROC_PER_NODE]]]
  33. # Configure and load modules
  34. pre_load_modules_cmd="[[[PLT:ACTIVE:PRE_LOAD_MODULES_CMD]]]"
  35. module_list="[[[PLT:ACTIVE:MODULE_LIST]]]"
  36. module () {
  37. eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
  38. }
  39. if [ -n "${module_list}" ]
  40. then
  41. set +u
  42. module purge
  43. for m in "${module_list}"
  44. do
  45. module add $m
  46. done
  47. set -u
  48. fi
  49. # Add directories to the shared library search path
  50. if [ -n "[[[PLT:ACTIVE:ADD_TO_LD_LIBRARY_PATH]]]" ]
  51. then
  52. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"[[[PLT:ACTIVE:ADD_TO_LD_LIBRARY_PATH]]]"
  53. fi
  54. # Set tetralith specific environment
  55. unset I_MPI_PMI_LIBRARY
  56. export I_MPI_FABRICS=shm:tmi
  57. export TMI_CONFIG=${I_MPI_ROOT}/intel64/etc/tmi.conf
  58. export LD_LIBRARY_PATH=${I_MPI_ROOT}/intel64/lib
  59. ulimit -s unlimited
  60. }
  61. function configure_python()
  62. {
  63. # specific for python+eccodes setup - used for OSM pre- and post-processing
  64. unset GRIB_DEFINITION_PATH
  65. unset GRIB_SAMPLES_PATH
  66. unset GRIB_BIN_PATH
  67. export GRIB_BIN_PATH=/software/sse/manual/eccodes/2.10.0/nsc1-ENABLE-AEC-intel-2018a-eb/bin
  68. export GRIB_DEFINITION_PATH=${HOME}/esm/osm/sources/util/grib_table_126:/software/sse/manual/eccodes/2.10.0/nsc1-ENABLE-AEC-intel-2018a-eb/share/eccodes/definitions
  69. export GRIB_SAMPLES_PATH=/software/sse/manual/eccodes/2.10.0/nsc1-ENABLE-AEC-intel-2018a-eb/share/eccodes/ifs_samples/grib1
  70. }
  71. function launch()
  72. {
  73. cmd="mpiexec.hydra -bootstrap slurm -genvall -prepend-rank -ordered-output"
  74. if $use_machinefile
  75. then
  76. cmd+=" -machinefile mfile"
  77. rm -f mfile
  78. nodelist=($(hostlist -e $SLURM_NODELIST))
  79. assigned_nodes=0
  80. fi
  81. while (( "$#" ))
  82. do
  83. nranks=$1
  84. executable=./$(basename $2)
  85. shift
  86. shift
  87. cmd+=" -n $nranks $executable"
  88. while (( "$#" )) && [ "$1" != "--" ]
  89. do
  90. cmd+=" $1"
  91. shift
  92. done
  93. shift || true
  94. (( "$#" )) && cmd+=" :"
  95. if $use_machinefile
  96. then
  97. case "$executable" in
  98. ./guess_*) ppn=$lpjg_ppn ;;
  99. *) ppn=$proc_per_node ;;
  100. esac
  101. while (( $nranks > 0 ))
  102. do
  103. (( n = ppn<nranks?ppn:nranks ))
  104. echo "${nodelist[assigned_nodes]}:${n}" >> mfile
  105. (( assigned_nodes += 1 ))
  106. (( nranks -= n )) || true
  107. done
  108. fi
  109. done
  110. [ -z "${OMP_NUM_THREADS-}" ] && export OMP_NUM_THREADS=1
  111. $cmd
  112. }
  113. function finalise()
  114. {
  115. # This function should execute of any post run functionality, e.g.
  116. # platform dependent cleaning or a resubmit
  117. if ${resubmit_job} && [ $(date -d "${leg_end_date}" +%s) -lt $(date -d "${run_end_date}" +%s) ]
  118. then
  119. info "Resubmitting job for leg $((leg_number+1))"
  120. # Need to go to start_dir to find the run script
  121. cd ${start_dir}
  122. # Submit command
  123. # Note: This does not work if you specify a job name with sbatch -J jobname!
  124. sbatch -N ${SLURM_JOB_NUM_NODES} \
  125. -o ${run_dir}/$(basename ${stdout_file}).$(printf %03d $((leg_number+1))) \
  126. -e ${run_dir}/$(basename ${stdout_file}).$(printf %03d $((leg_number+1))) \
  127. -d ${SLURM_JOB_ID} \
  128. ${resubmit_opt} \
  129. ./${SLURM_JOB_NAME}
  130. fi
  131. }