lemaitre3.cfg.tmpl 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # Platform dependent configuration functions for the 'zenobe' machine
  2. #(zenobe.hpc.cenaero.be)
  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. archive_dir=/scratch/ucl/elic/${USER}/ecearth/archive/${exp_name}
  13. # File for standard output.
  14. # NOTE: This will be modified for restart jobs!
  15. stdout_file=${SLURM_SUBMIT_DIR-$PWD}/${SLURM_JOB_NAME-"local"}_${SLURM_JOB_ID-"id"}.log
  16. # Resubmit this job for automatic restarts? [true/false]
  17. # Also, add options for the resubmit command here.
  18. resubmit_job=[[[PLT:ACTIVE:RESUBMIT_JOB]]]
  19. resubmit_opt="[[[PLT:ACTIVE:RESUBMIT_OPT]]]"
  20. # Configure number of processors per node
  21. proc_per_node=[[[PLT:ACTIVE:PROC_PER_NODE]]]
  22. # Configure and load modules
  23. pre_load_modules_cmd="[[[PLT:ACTIVE:PRE_LOAD_MODULES_CMD]]]"
  24. module_list="[[[PLT:ACTIVE:MODULE_LIST]]]"
  25. if [ -n "${pre_load_modules_cmd}" ]
  26. then
  27. ${pre_load_modules_cmd}
  28. fi
  29. module load ${module_list}
  30. # Configure GRIBEX paths
  31. export LOCAL_DEFINITION_TEMPLATES=[[[PLT:ACTIVE:GRIBEX_DEFINITION_PATH]]]/gribtemplates
  32. export ECMWF_LOCAL_TABLE_PATH=[[[PLT:ACTIVE:GRIBEX_DEFINITION_PATH]]]/gribtables
  33. # Configure grib api paths
  34. export GRIB_DEFINITION_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_DEFINITION_SUBDIR]]]
  35. export GRIB_SAMPLES_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_SAMPLES_SUBDIR]]]
  36. export GRIB_BIN_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_BIN_SUBDIR]]]
  37. # Add directories to the shared library search path
  38. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"[[[PLT:ACTIVE:ADD_TO_LD_LIBRARY_PATH]]]"
  39. }
  40. function launch()
  41. {
  42. # Compute and check the node distribution
  43. info "======================="
  44. info "Node/proc distribution:"
  45. info "-----------------------"
  46. info "IFS: ${ifs_numproc}"
  47. info "NEMO: ${nem_numproc}"
  48. info "XIOS: ${xio_numproc}"
  49. info "======================="
  50. cmd="mpirun"
  51. while (( "$#" ))
  52. do
  53. nranks=$1
  54. executable=./$(basename $2)
  55. shift
  56. shift
  57. cmd+=" -n $nranks $executable"
  58. while (( "$#" )) && [ "$1" != "--" ]
  59. do
  60. cmd+=" $1"
  61. shift
  62. done
  63. shift || true
  64. (( "$#" )) && cmd+=" :"
  65. done
  66. #export OMP_NUM_THREADS=1
  67. pwd
  68. echo $cmd
  69. #exit
  70. $cmd
  71. }
  72. function finalise2()
  73. {
  74. # This function should execute of any post run functionality, e.g.
  75. # platform dependent cleaning or a resubmit
  76. if ${resubmit_job} && [ $(date -d "${leg_end_date}" +%s) -lt $(date -d "${run_end_date}" +%s) ]
  77. then
  78. info "Resubmitting job for leg $((leg_number+1))"
  79. # Need to go to start_dir to find the run script
  80. cd ${SLURM_SUBMIT_DIR} # same as $start_dir
  81. cp ./${SLURM_JOB_NAME} ./$(basename ${SLURM_JOB_NAME}).$$
  82. sed "s:force_run_from_scratch=true:force_run_from_scratch=false:" \
  83. <./$(basename ${SLURM_JOB_NAME}).$$ \
  84. >./$(basename ${SLURM_JOB_NAME})
  85. cp -f ./${SLURM_JOB_NAME} ./$(basename ${SLURM_JOB_NAME}).$$
  86. sed "s:special_restart=true:special_restart=false:" \
  87. <./$(basename ${SLURM_JOB_NAME}).$$ \
  88. >./$(basename ${SLURM_JOB_NAME})
  89. \rm -f ./${PBS_JOBNAME}.$$
  90. # Submit command
  91. set -x
  92. qsub ./$(basename ${SLURM_JOB_NAME})
  93. set +x
  94. else
  95. info "Not resubmitting."
  96. fi
  97. }
  98. function finalise()
  99. {
  100. # This function should execute of any post run functionality, e.g.
  101. # platform dependent cleaning or a resubmit
  102. if ${resubmit_job} && [ $(date -d "${leg_end_date}" +%s) -lt $(date -d "${run_end_date}" +%s) ]
  103. then
  104. info "Resubmitting job for leg $((leg_number+1))"
  105. # Need to go to start_dir to find the run script
  106. cd ${start_dir}
  107. # Submit command
  108. # Note: This does not work if you specify a job name with sbatch -J jobname!
  109. sbatch -N ${SLURM_JOB_NUM_NODES} \
  110. -o ${run_dir}/$(basename ${stdout_file}).$(printf %03d $((leg_number+1))) \
  111. -e ${run_dir}/$(basename ${stdout_file}).$(printf %03d $((leg_number+1))) \
  112. -d ${SLURM_JOB_ID} \
  113. ${resubmit_opt} \
  114. ./${SLURM_JOB_NAME}
  115. fi
  116. }