bsc-nord3.cfg.tmpl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Platform dependent configuration functions for MareNostrum
  2. #(mnX.bsc.es)
  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. # Set some MPI related variables, as recommend by BSC
  9. export I_MPI_DEVICE="rdssm:ofa-v2-mlx4_0-1u"
  10. # SCRATCH is not defined in MN3, define it here
  11. # and also make sure it is defined when compiling
  12. export SCRATCH=/gpfs/scratch/`id -gn`/${USER}
  13. # Configure paths for building/running EC-Earth
  14. ecearth_src_dir=[[[PLT:ACTIVE:ECEARTH_SRC_DIR]]]
  15. run_dir=[[[PLT:ACTIVE:RUN_DIR]]]
  16. ini_data_dir=[[[PLT:ACTIVE:INI_DATA_DIR]]]
  17. # File for standard output.
  18. # NOTE: This will be modified for restart jobs!
  19. stdout_file=${start_dir}/out/$(basename ${LSB_JOBNAME}).out
  20. # Resubmit this job for automatic restarts? [true/false]
  21. # Also, add options for the resubmit command here.
  22. resubmit_job=[[[PLT:ACTIVE:RESUBMIT_JOB]]]
  23. resubmit_opt="[[[PLT:ACTIVE:RESUBMIT_OPT]]]"
  24. # Configure grib api paths
  25. export GRIB_DEFINITION_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_DEFINITION_SUBDIR]]]
  26. export GRIB_SAMPLES_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_SAMPLES_SUBDIR]]]
  27. export GRIB_BIN_PATH=[[[PLT:ACTIVE:GRIBAPI_BASE_DIR]]]/[[[PLT:ACTIVE:GRIBAPI_BIN_SUBDIR]]]
  28. # Configure number of processors per node
  29. proc_per_node=[[[PLT:ACTIVE:PROC_PER_NODE]]]
  30. # Configure and load modules
  31. pre_load_modules_cmd="[[[PLT:ACTIVE:PRE_LOAD_MODULES_CMD]]]"
  32. module_list="[[[PLT:ACTIVE:MODULE_LIST]]]"
  33. if [ -n "${module_list}" ]
  34. then
  35. set +eu
  36. if [ -n "${pre_load_modules_cmd}" ]
  37. then
  38. ${pre_load_modules_cmd}
  39. fi
  40. for m in "${module_list}"
  41. do
  42. module add $m
  43. done
  44. set -eu
  45. fi
  46. # Add directories to the shared library search path
  47. if [ -n "[[[PLT:ACTIVE:ADD_TO_LD_LIBRARY_PATH]]]" ]
  48. then
  49. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"[[[PLT:ACTIVE:ADD_TO_LD_LIBRARY_PATH]]]"
  50. fi
  51. export PATH=/gpfs/apps/MN3/CDO/1.8.2/bin:${PATH}
  52. ulimit -s unlimited
  53. }
  54. function launch()
  55. {
  56. cmd="mpirun"
  57. while (( "$#" ))
  58. do
  59. # Get number of MPI ranks and executable name
  60. nranks=$1
  61. executable=./$(basename $2)
  62. shift
  63. shift
  64. cmd+=" -np $nranks $executable"
  65. # Add any arguments to executable
  66. while (( "$#" )) && [ "$1" != "--" ]
  67. do
  68. cmd+=" $1"
  69. shift
  70. done
  71. shift || true
  72. # Add colon of more executables follow
  73. (( "$#" )) && cmd+=" :"
  74. done
  75. export OMP_NUM_THREADS=1
  76. $cmd
  77. }
  78. function finalise()
  79. {
  80. # This function should execute of any post run functionality, e.g.
  81. # platform dependent cleaning or a resubmit
  82. if ${resubmit_job} && [ $(date -d "${leg_end_date}" +%s) -lt $(date -d "${run_end_date}" +%s) ]
  83. then
  84. info "Resubmitting job for leg $((leg_number+1))"
  85. # Need to go to start_dir to find the run script
  86. cd ${start_dir}
  87. # Submit command
  88. # Note: This does not work if you explicitely specify a job name!
  89. bsub -n ${LSB_DJOB_NUMPROC} \
  90. -w ${LSB_JOBID} \
  91. -oo ${run_dir}/$(basename ${stdout_file}).$(printf %03d $((leg_number+1))) \
  92. ${resubmit_opt} \
  93. ${LSB_JOBNAME}
  94. fi
  95. }