compilation.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. #!/usr/bin/env bash
  2. # remote_setup.sh:
  3. # Extracts the sources from the Autosubmit project bundle and compiles EC-Earth
  4. set -xuve
  5. #
  6. # Architecture
  7. #
  8. HPCARCH=%HPCARCH%
  9. CURRENT_ROOTDIR=%CURRENT_ROOTDIR%
  10. PROJECT_DESTINATION=%PROJECT_DESTINATION%
  11. PROJECT_DIR=${CURRENT_ROOTDIR}/${PROJECT_DESTINATION}
  12. TEMPLATE_NAME=%TEMPLATE_NAME%
  13. IFS_resolution=%IFS_resolution%
  14. MAKE_NUMPROC=%NUMPROC%
  15. PROJDIR=%PROJDIR%
  16. BSC_OUTCLASS=%BSC_OUTCLASS%
  17. CMIP6_OUTCLASS=%CMIP6_OUTCLASS%
  18. PRODUCTION_EXP=%PRODUCTION_EXP%
  19. PRECOMPILED_VERSION=%PRECOMPILED_VERSION%
  20. TM5_NLEVS=%TM5_NLEVS%
  21. # ==================================================
  22. # functions
  23. # ==================================================
  24. function get_configuration_nemo (){
  25. NEMO_resolution=%NEMO_resolution%
  26. if [[ -z ${NEMO_resolution-} ]] ; then
  27. echo "ERROR: nemo is requested but NEMO_resolution is not defined!"
  28. exit 1
  29. fi
  30. # Select correct nemo_config
  31. has_config pisces:offline ifs && echo "ERROR: cannot have pisces:offline and ifs in config!" && exit 1
  32. # this code adheres to the conventions in ece-esm.sh
  33. nem_grid=%NEMO_resolution%
  34. nem_config=${nem_grid}
  35. has_config lim3 && nem_config=${nem_config}_LIM3
  36. has_config pisces:offline && nem_config=${nem_config}_OFF
  37. if $(has_config pisces tm5:co2) ; then
  38. nem_config=${nem_config}_CarbonCycle
  39. elif $(has_config pisces) ; then
  40. nem_config=${nem_config}_PISCES
  41. fi
  42. # TODO - nemo standalone configs are not accounted for in this script, but this would set the required nem_config
  43. ! has_config ifs && nem_config=${nem_config}_standalone
  44. NEMO_CONFIG=${nem_config}
  45. }
  46. function compile_nemo(){
  47. ########################
  48. # NEMO compilation key #
  49. ########################
  50. # Configuration to be compiled
  51. nemo_config_to_compile=$1
  52. new_nemo_compilation_keys=" key_init_alloc_zero ${extra_nemo_compilation_keys-}"
  53. fcm_file=$(ls ${SOURCE_FOLDER}/nemo-3.6/CONFIG/${nemo_config_to_compile}/*.fcm)
  54. for key in ${new_nemo_compilation_keys}; do
  55. if [[ $(grep ${key} ${fcm_file}) == "" ]] ; then
  56. echo adding ${key}
  57. sed -i -e 1's/$/'" "${key}' &/' ${fcm_file}
  58. fi
  59. done
  60. for elem in ${remove_nemo_compilation_keys}; do
  61. sed -i "s/ $elem//" $fcm_file
  62. echo "Removing $elem from compilation keys"
  63. done
  64. cd ${SOURCE_FOLDER}/nemo-3.6/CONFIG
  65. # remove old nemo executable to make sure compilation did not fail
  66. # workaround for the issue that make_nemo does not return an exit code on failure
  67. rm -f ${SOURCE_FOLDER}/nemo*/CONFIG/${nemo_config_to_compile}/BLD/bin/*.exe
  68. if ${MODEL_CLEAN} ; then ./makenemo -m ecconf -n ${nemo_config_to_compile} -j ${MAKE_NUMPROC} clean ; fi
  69. ./makenemo -m ecconf -n ${nemo_config_to_compile} -j ${MAKE_NUMPROC}
  70. [ -f ${SOURCE_FOLDER}/nemo*/CONFIG/${nemo_config_to_compile}/BLD/bin/*.exe ] || exit 1
  71. }
  72. function compile_tm5(){
  73. local tm5_version=$1
  74. export TM5_NLEVS=$2
  75. if [[ ${tm5_version} == "co2" ]] ; then
  76. ecconf_args+=" -o MODEL:TM5:CO2_ONLY=True"
  77. elif [[ ${tm5_version} == "cb05" ]] ; then
  78. ecconf_args+=" -o MODEL:TM5:CO2_ONLY=False" ;
  79. fi
  80. ecconf_args+=" -o MODEL:TM5:NLEVS="${TM5_NLEVS}
  81. export tm5_exch_nlevs=${TM5_NLEVS}
  82. cd ${SOURCE_FOLDER}
  83. util/ec-conf/ec-conf3 --platform ${architecture} ${ecconf_args} config-build.xml
  84. tm5_exe_file=${SOURCE_FOLDER}/tm5mp/build-${tm5_version}-ml${tm5_exch_nlevs}/appl-tm5-${tm5_version}.x
  85. cd ${SOURCE_FOLDER}/tm5mp/
  86. if [ ! -f ${SOURCE_FOLDER}/tm5mp/setup_tm5 ] ; then
  87. ln -sf ${SOURCE_FOLDER}/tm5mp/bin/pycasso_setup_tm5 ${SOURCE_FOLDER}/tm5mp/setup_tm5
  88. chmod 755 setup_tm5
  89. fi
  90. if ${MODEL_CLEAN} ; then
  91. ./setup_tm5 -c -n -v -j ${MAKE_NUMPROC} ecconfig-ecearth3.rc
  92. else
  93. ./setup_tm5 -v -j ${MAKE_NUMPROC} ecconfig-ecearth3.rc
  94. fi
  95. [ -f ${tm5_exe_file} ] || exit 1
  96. }
  97. function compile_lpjg(){
  98. ifs_res=$1
  99. lpjg_res=T$(echo ${ifs_res} | sed 's:T\([0-9]\+\)L\([0-9]\+\):\1:')
  100. if [ $lpjg_res != "T255" -a $lpjg_res != "T159" ]
  101. then
  102. echo "LPJG not supported for ifs-grid: ${ifs_res}"
  103. exit 1
  104. else
  105. ecconf_args+=" -o MODEL:LPJG:GRID=$lpjg_res "
  106. fi
  107. cd ${SOURCE_FOLDER}
  108. util/ec-conf/ec-conf3 --platform ${architecture} ${ecconf_args} config-build.xml
  109. cd ${SOURCE_FOLDER}/lpjg/build
  110. if ${MODEL_CLEAN} ; then
  111. rm -f CMakeCache.txt ;
  112. fi
  113. cmake ..
  114. if ${MODEL_CLEAN} ; then
  115. make clean ;
  116. fi
  117. make -j ${MAKE_NUMPROC}
  118. [ -f ${SOURCE_FOLDER}/lpjg/build/guess_${lpjg_res} ] || exit 1
  119. cd ${SOURCE_FOLDER}/lpjg/offline
  120. if ${MODEL_CLEAN} ; then
  121. make clean
  122. fi
  123. make
  124. [ -f ${SOURCE_FOLDER}/lpjg/offline/lpjg_forcing_ifs_${lpjg_res} ] || exit 1
  125. }
  126. # define which runtime we are using
  127. use_autosubmit=true
  128. [[ use_autosubmit && ${PROJECT_DESTINATION} == 'ecearth3' ]] && use_autosubmit_simple=true || use_autosubmit_simple=false
  129. #when using the simplified AS runtime we use the same ECEARTH_SRC_DIR definition
  130. #as in the full auto-ecearth AS runtime, to avoid having to change it in config-build and config-run
  131. #TODO set PROJECT_DIR from ECEARTH_SRC_DIR, requires writing this script as an ec-conf template
  132. if $use_autosubmit_simple ; then
  133. SOURCE_FOLDER=${CURRENT_ROOTDIR}/auto-ecearth3/sources/sources
  134. else
  135. SOURCE_FOLDER=${PROJECT_DIR}/sources/sources
  136. fi
  137. # Variables that could be used from config-build.xml should be exported
  138. export exp_name=%EXPID%
  139. # these variables are to be used for development, allowing to retain any local
  140. # changes to the sources and compile the model more quickly
  141. # EXTRACT : extract files from uploaded .tar.gz file and copy runtime files (default:true)
  142. # CLEAN : do 'make clean' for all model components (default:true)
  143. [ "%MODEL_EXTRACT%" = FALSE ] && MODEL_EXTRACT=false || MODEL_EXTRACT=true
  144. [ "%MODEL_CLEAN%" = FALSE ] && MODEL_CLEAN=false || MODEL_CLEAN=true
  145. #
  146. # get model config from AS variables (for compilation only)
  147. #
  148. #ifs
  149. [[ "$TEMPLATE_NAME" = ecearth3* || "$TEMPLATE_NAME" = ifs3* ]] && ifs="ifs" || ifs=""
  150. [[ "$TEMPLATE_NAME" = ifs3* ]] && amip="amip" || amip=""
  151. #nemo
  152. if [[ "$TEMPLATE_NAME" = ecearth3* || "$TEMPLATE_NAME" = nemo3* ]]; then nemo="nemo"; lim3="lim3"; xios="xios:detached"; else nemo=""; lim3=""; xios=""; fi
  153. [[ "$TEMPLATE_NAME" = ecearth3* ]] && rnfmapper="rnfmapper" || rnfmapper=""
  154. [[ "%NEMO_remove_land%" = TRUE && ! -z $nemo ]] && elpin=":elpin" || elpin=""
  155. [[ "%PISCES%" = TRUE ]] && { if [[ "%PISCES_OFF%" = TRUE ]] ; then pisces="pisces:offline" ; lim3="" ; else pisces="pisces" ; fi } || pisces=""
  156. #others
  157. [[ "$TEMPLATE_NAME" = lsm* || "%LPJG%" = TRUE ]] && lpjg=%LPJG_CONFIG% || lpjg=""
  158. [[ "$TEMPLATE_NAME" = lsm* || "%OSM%" = TRUE ]] && osm="osm" || osm=""
  159. [[ "%TM5%" = TRUE ]] && tm5=%TM5_CONFIG% || tm5=""
  160. export config="${ifs} ${amip} ${nemo}${elpin} ${pisces} ${lim3} ${rnfmapper} ${xios} oasis ${lpjg} ${osm} ${tm5}"
  161. #####################################################################################
  162. # To re-define the components you want to build
  163. #####################################################################################
  164. # you can set here the components you want to build by uncommenting a line such as these
  165. #config="ifs amip nemo pisces lim3 rnfmapper xios oasis lpjg ${tm5}" # for all components (esm runtime)
  166. #config="osm oasis lpjg" # for lsm configuration
  167. #####################################################################################
  168. # 3.3.3.1 - To compile all components #
  169. #####################################################################################
  170. # Uncomment these lines to compile all components and all nemo resolutions and LPJG/TM5 versions
  171. #config=compile_all
  172. #PRECOMPILED_VERSION="NONE"
  173. #PRODUCTION_EXP=TRUE
  174. #
  175. [[ -z ${PRECOMPILED_VERSION-} ]] && PRECOMPILED_VERSION="NONE"
  176. #
  177. # Loading of modules
  178. #
  179. set +xuve
  180. export ecconf_args=""
  181. if [ ${HPCARCH} == 'ecmwf-xc40' ]
  182. then
  183. export architecture=ecmwf-cca-intel-mpi
  184. prgenvswitchto intel
  185. module load cray-hdf5-parallel/1.8.14
  186. module load cray-netcdf-hdf5parallel/4.3.3.1
  187. module unload eccodes
  188. module load grib_api/1.27.0
  189. module load python3/3.8.8-01
  190. # for tm5
  191. if has_config any compile_all tm5 ; then
  192. module load udunits
  193. module load hdf
  194. fi
  195. # for lpjg
  196. if has_config any compile_all lpjg ; then
  197. module load cmake
  198. fi
  199. rm -f ${CURRENT_ROOTDIR}/${PROJECT_DESTINATION}/sources/util/grib_table_126/define_table_126.sh
  200. export ecconf_args+=" -o PLT:ACTIVE:ECEARTH_SRC_DIR=${SCRATCH}/${exp_name}/auto-ecearth3/sources/sources" ;
  201. elif [ ${HPCARCH} == 'nord3v2' ]
  202. then
  203. export SCRATCH=/gpfs/scratch/`id -gn`/${USER}
  204. export architecture=bsc-nord3-intel-intelmpi
  205. module purge
  206. module load gcc intel impi/2021.4 mkl/2021.4 netcdf-c/4.4.1.1_hdf5-1.10.8 hdf5 perl netcdf-fortran/4.4.4
  207. elif [ ${HPCARCH} == 'marenostrum4' ] ; then
  208. export SCRATCH=/gpfs/scratch/`id -gn`/${USER}
  209. export architecture=bsc-marenostrum4-intel-intelmpi
  210. module purge
  211. module load intel/2017.4
  212. module load impi/2018.4
  213. module load perl/5.26
  214. module load mkl/2018.4 # required by python/3.6.1
  215. module load python/3.6.1
  216. # for lpjg
  217. if has_config any lpjg compile_all ; then
  218. module load cmake
  219. module load grib/1.14.0
  220. fi
  221. if [[ ${PRODUCTION_EXP-} == "TRUE" ]] ; then
  222. ecconf_args+='-o PLT:ACTIVE:OASIS_ADD_FFLAGS="-132" -o PLT:ACTIVE:NEMO_ADD_FFLAGS="-fpe0" '
  223. fi
  224. else
  225. error "Unsupported ec-conf architechture: ${HPCARCH}"
  226. exit 0
  227. fi
  228. module list
  229. set -xuve
  230. #
  231. # Extract Model Sources and copy runtime, only if MODEL_EXTRACT=TRUE
  232. #
  233. if ${MODEL_EXTRACT} ; then
  234. #
  235. # Extract Model Sources
  236. #
  237. cd ${CURRENT_ROOTDIR}
  238. if [ -f ${PROJECT_DESTINATION}.tar.gz ]; then
  239. tar -xvf ${PROJECT_DESTINATION}.tar.gz
  240. rm ${PROJECT_DESTINATION}.tar.gz
  241. # move sources into auto-ecearth3/sources to make it consistent with ECEARTH_SRC_DIR
  242. if $use_autosubmit_simple
  243. then
  244. mkdir -p ${CURRENT_ROOTDIR}/auto-ecearth3
  245. mv ${PROJECT_DESTINATION} ${CURRENT_ROOTDIR}/auto-ecearth3/sources
  246. ln -sf ${CURRENT_ROOTDIR}/auto-ecearth3 ${PROJECT_DESTINATION}
  247. fi
  248. fi
  249. #
  250. # Copy runtime
  251. #
  252. cd ${CURRENT_ROOTDIR}
  253. ln -sf ${PROJECT_DESTINATION}/sources/runtime/autosubmit/ecconf.cfg .
  254. for ctrlfile in `( ls ${PROJECT_DESTINATION}/sources/runtime/classic/lib*.sh )`
  255. do
  256. ln -sf ${ctrlfile} .
  257. done
  258. ln -sf ${PROJECT_DESTINATION}/sources/runtime/classic/ctrl/ .
  259. fi # $MODEL_EXTRACT
  260. #
  261. # librunscript defines some helper functions
  262. #
  263. source ${CURRENT_ROOTDIR}/librunscript.sh
  264. # check for extra nemo compilation keys
  265. extra_nemo_compilation_keys=""
  266. remove_nemo_compilation_keys=""
  267. # check for extra compilation keys for chosen BSC_OUTCLASS
  268. if [[ -n "${BSC_OUTCLASS-}" && -d ${PROJECT_DESTINATION}/outclass/${BSC_OUTCLASS}/ ]]; then
  269. [ -f ${PROJECT_DESTINATION}/outclass/${BSC_OUTCLASS}/outclass_extra_nemo_compilation_keys.fcm ] && extra_nemo_compilation_keys+=" "$(cat ${PROJECT_DESTINATION}/outclass/${BSC_OUTCLASS}/outclass_extra_nemo_compilation_keys.fcm)
  270. fi
  271. # check the experiment configuration and remove the keys "key_diaar5 key_diahth" if the experiment is a coupled or nemo HR experiment
  272. if [[ -n "${BSC_OUTCLASS-}" && -d ${PROJECT_DESTINATION}/outclass/${BSC_OUTCLASS}/ ]]; then
  273. if has_config nemo && [ "${BSC_OUTCLASS}" == "reduced" ] && [ "%NEMO_resolution%" == "ORCA025L75" ]; then
  274. remove_nemo_compilation_keys="key_diaar5 key_diahth"
  275. echo "Removing compilation keys for NEMO HR"
  276. else
  277. echo "NOT removing compilation keys"
  278. fi
  279. fi
  280. # check if the experiment has an historical outclass and pisces is activated (requires key_cfc)
  281. has_config pisces && [[ "%CMOR_EXP%" = "historical" || "%CMOR_EXP%" = "esm-hist" ]] && extra_nemo_compilation_keys+=" key_cfc "
  282. # make sure we are not using precompiled binaries or compiling all binaries if special keys are necessary
  283. # or maybe ignore the keys if we are compiling all?
  284. if [[ "${extra_nemo_compilation_keys}" != "" ]] ; then
  285. has_config compile_all && [[ "${PRECOMPILED_VERSION-}" = "NONE" ]] && DO_EXIT="TRUE"
  286. if [[ "${PRECOMPILED_VERSION-}" != "NONE" || "${DO_EXIT-}" == "TRUE" ]] ; then
  287. echo "PRECOMPILED_VERSION or compile_all not compatible with pisces historical runs or BSC_OUTCLASS with extra compilation keys"
  288. exit 1
  289. fi
  290. fi
  291. # report if no outclass was chosen
  292. if [[ "${BSC_OUTCLASS-}" == "" ]] && [[ "${CMIP6_OUTCLASS-}" == "" ]] ; then
  293. echo "WARNING: you are using the outclass from ec-earth portal"
  294. fi
  295. if [[ "${PRECOMPILED_VERSION-}" == "NONE" ]] ; then
  296. cd ${SOURCE_FOLDER}
  297. util/ec-conf/ec-conf3 --platform ${architecture} ${ecconf_args} config-build.xml
  298. #
  299. # Check bin and lib directory (git-svn issue with empty folders)
  300. #
  301. cd ${SOURCE_FOLDER}
  302. if [ ! -d ifs-36r4/bin ]; then
  303. mkdir ifs-36r4/bin
  304. mkdir ifs-36r4/lib
  305. fi
  306. if [ ! -d runoff-mapper/bin ] ; then
  307. mkdir runoff-mapper/bin
  308. mkdir runoff-mapper/lib
  309. fi
  310. if [ ! -d amip-forcing/bin ] ; then
  311. mkdir amip-forcing/bin
  312. mkdir amip-forcing/lib
  313. fi
  314. if [ ! -d lpjg/build ] ; then
  315. mkdir lpjg/build
  316. fi
  317. #
  318. # Compilation of Model Sources
  319. #
  320. # 1) OASIS
  321. if $(has_config any oasis compile_all) ; then
  322. cd ${SOURCE_FOLDER}/oasis3-mct/util/make_dir
  323. if ${MODEL_CLEAN} ; then
  324. make realclean -f TopMakefileOasis3 BUILD_ARCH=ecconf ;
  325. fi
  326. make -f TopMakefileOasis3 -j ${MAKE_NUMPROC} BUILD_ARCH=ecconf
  327. # build lucia with the ifort compiler - modify this if you use another compiler
  328. cd ${SOURCE_FOLDER}/oasis3-mct/util/lucia
  329. F90=ifort ./lucia -c
  330. [ -f ${SOURCE_FOLDER}/oasis3-mct/util/lucia/lucia.exe ] || exit 1
  331. fi
  332. # 2) XIOS
  333. if $(has_config any xios compile_all) ; then
  334. cd ${SOURCE_FOLDER}/xios-2.5
  335. if ${MODEL_CLEAN} ; then
  336. ./make_xios --arch ecconf --use_oasis oasis3_mct --netcdf_lib netcdf4_par --job ${MAKE_NUMPROC} --full
  337. else
  338. ./make_xios --arch ecconf --use_oasis oasis3_mct --netcdf_lib netcdf4_par --job ${MAKE_NUMPROC}
  339. fi
  340. [ -f ${SOURCE_FOLDER}/xios-2.5/bin/xios_server.exe ] || exit 1
  341. fi
  342. # 3) Runoff-Mapper
  343. if $(has_config any rnfmapper compile_all) ; then
  344. cd ${SOURCE_FOLDER}/runoff-mapper/src
  345. if ${MODEL_CLEAN} ; then
  346. make clean ;
  347. fi
  348. make
  349. [ -f ${SOURCE_FOLDER}/runoff-mapper/bin/runoff-mapper.exe ] || exit 1
  350. fi
  351. # 4) NEMO
  352. if $(has_config any compile_all nemo) ; then
  353. NEMO_resolution=%NEMO_resolution%
  354. if [[ -z ${NEMO_resolution-} ]] ; then
  355. echo "ERROR: nemo is requested but NEMO_resolution is not defined!"
  356. exit 1
  357. fi
  358. has_config pisces && [[ "%CMOR_EXP%" = "historical" || "%CMOR_EXP%" = "esm-hist" ]] && new_nemo_compilation_keys+=" key_cfc "
  359. # Select correct nemo_config
  360. has_config pisces:offline ifs && echo "ERROR: cannot have pisces:offline and ifs in config!" && exit 1
  361. # Determine proper NEMO configuration
  362. get_configuration_nemo
  363. # compilation step
  364. if $(has_config compile_all) ; then
  365. for NEMO_CONFIG in ORCA025L75_LIM3 ORCA025L75_LIM3_standalone ORCA1L75_LIM3 ORCA1L75_LIM3_CarbonCycle ORCA1L75_LIM3_PISCES ORCA1L75_LIM3_PISCES_standalone ORCA1L75_LIM3_standalone ORCA1L75_OFF_PISCES_standalone ; do
  366. compile_nemo $NEMO_CONFIG
  367. done
  368. else
  369. compile_nemo $NEMO_CONFIG
  370. fi
  371. fi
  372. # 5) IFS
  373. if $(has_config any ifs compile_all) ; then
  374. set +xuve
  375. . ${SOURCE_FOLDER}/util/grib_table_126/define_table_126.sh
  376. set -xuve
  377. cd ${SOURCE_FOLDER}/ifs-36r4
  378. if ${MODEL_CLEAN} ; then
  379. make clean BUILD_ARCH=ecconf
  380. make realclean BUILD_ARCH=ecconf
  381. make dep-clean BUILD_ARCH=ecconf
  382. fi
  383. make -j ${MAKE_NUMPROC} BUILD_ARCH=ecconf lib
  384. make BUILD_ARCH=ecconf master
  385. [ -f ${SOURCE_FOLDER}/ifs*/bin/ifsmaster* ] || exit 1
  386. fi
  387. # 6) Amip
  388. if $(has_config any amip compile_all); then
  389. cd ${SOURCE_FOLDER}/amip-forcing/src
  390. if ${MODEL_CLEAN} ; then
  391. make clean
  392. fi
  393. make
  394. [ -f ${SOURCE_FOLDER}/amip*/bin/amip* ] || exit 1
  395. fi
  396. # 7) LPJG component
  397. if $(has_config any lpjg compile_all); then
  398. if $(has_config compile_all) ; then
  399. compile_lpjg "T255L91"
  400. compile_lpjg "T159L91"
  401. elif $(has_config lpjg) ; then
  402. compile_lpjg $IFS_resolution
  403. fi
  404. fi
  405. # 8) TM5
  406. if $(has_config any tm5 compile_all); then
  407. if $(has_config compile_all) ; then
  408. compile_tm5 "co2" 10
  409. compile_tm5 "cb05" 34
  410. elif $(has_config tm5) ; then
  411. tmversion="cb05"
  412. has_config tm5:co2 && tmversion="co2"
  413. compile_tm5 ${tmversion} ${TM5_NLEVS}
  414. fi
  415. fi
  416. # 9) ELPiN
  417. if $(has_config any elpin compile_all) ; then
  418. cd ${SOURCE_FOLDER}/util/ELPiN/
  419. make clean
  420. make
  421. fi
  422. # 10) OSM
  423. if $(has_config any osm compile_all) ; then
  424. cd ${SOURCE_FOLDER}/ifs-36r4/src/surf/offline/
  425. if [ ${HPCARCH} == 'marenostrum4' ] ; then
  426. export PATH=/gpfs/projects/bsc32/share/fcm-2017.10.0/bin:$PATH
  427. else
  428. # this works on CCA...
  429. module load fcm
  430. fi
  431. if ${MODEL_CLEAN} ; then
  432. fcm make -vvv -j ${MAKE_NUMPROC} --new
  433. else
  434. fcm make -vvv -j ${MAKE_NUMPROC}
  435. fi
  436. [ -f ${SOURCE_FOLDER}/ifs*/src/surf/offline/osm/build/bin/master1s.exe ] || exit 1
  437. fi
  438. echo "Finished compiling"
  439. set +xuve
  440. #
  441. # workaround for intelremotemond process started when compiling with
  442. # intel compilers (maybe only on MN3 ?)
  443. #
  444. set +e
  445. if [ ${HPCARCH} == 'nord3v2' ] ; then
  446. (! pidof intelremotemond) || killall -u ${USER} intelremotemond ;
  447. fi
  448. else
  449. echo "Your experiment will use a precompiled binary version:" ${PRECOMPILED_VERSION-}
  450. # create links to the binaries
  451. cd ${PROJECT_DIR}/sources
  452. path_to_precompiled=/gpfs/projects/bsc32/models/ecearth/${PRECOMPILED_VERSION-}/make/MN4-intel-opt/sources/sources
  453. # Get defined configurations
  454. arrComponents=()
  455. if $(has_config nemo) ; then
  456. get_configuration_nemo
  457. arrComponents+=(nemo)
  458. nemo_exe_file=${path_to_precompiled}/nemo-3.6/CONFIG/${NEMO_CONFIG}/BLD/bin/nemo.exe
  459. nemo_dst_dir=./sources/nemo-3.6/CONFIG/${NEMO_CONFIG}/BLD/bin/
  460. fi
  461. if $(has_config ifs) ; then
  462. arrComponents+=(ifs)
  463. ifs_exe_file=${path_to_precompiled}/ifs-36r4/bin/ifsmaster-ecconf
  464. ifs_dst_dir=./sources/ifs-36r4/bin/
  465. fi
  466. if $(has_config xios) ; then
  467. arrComponents+=(xios)
  468. xios_exe_file=${path_to_precompiled}/xios-2.5/bin/xios_server.exe
  469. xios_dst_dir=./sources/xios-2.5/bin/
  470. fi
  471. if $(has_config osm) ; then
  472. arrComponents+=(osm)
  473. osm_exe_file=${path_to_precompiled}/ifs-36r4/src/surf/offline/osm/build/bin/master1s_cpl.exe
  474. osm_dst_dir=./sources/ifs-36r4/src/surf/offline/osm/build/bin/
  475. fi
  476. if $(has_config elpin) ; then
  477. arrComponents+=(elpin)
  478. elpin_exe_file=${path_to_precompiled}/util/ELPiN/bin/mpp_domain_decomposition.exe
  479. elpin_dst_dir=./sources/util/ELPiN/bin/
  480. fi
  481. if $(has_config lpjg) ; then
  482. arrComponents+=(lpjg)
  483. lpjg_exe_file=${path_to_precompiled}/lpjg/build/guess_T$(echo ${IFS_resolution} | sed 's:T\([0-9]\+\)L\([0-9]\+\):\1:')
  484. lpjg_dst_dir=./sources/lpjg/build/
  485. fi
  486. if $(has_config tm5) ; then
  487. arrComponents+=(tm5)
  488. tmversion="cb05"
  489. has_config tm5:co2 && tmversion="co2"
  490. tm5_exe_file=${path_to_precompiled}/tm5mp/build-${tmversion}-ml${TM5_NLEVS}/appl-tm5-${tmversion}.x
  491. tm5_dst_dir=./sources/tm5mp/build-${tmversion}-ml${TM5_NLEVS}/
  492. fi
  493. if $(has_config rnfmapper) ; then
  494. arrComponents+=(runoff_mapper)
  495. runoff_mapper_exe_file=${path_to_precompiled}/runoff-mapper/bin/runoff-mapper.exe
  496. runoff_mapper_dst_dir=./sources/runoff-mapper/bin/
  497. fi
  498. if $(has_config amip) ; then
  499. arrComponents+=(amip)
  500. amip_exe_file=${path_to_precompiled}/amip-forcing/bin/amip-forcing.exe
  501. amip_dst_dir=./sources/amip-forcing/bin/
  502. fi
  503. for component in ${arrComponents[@]} ; do
  504. exe=${component}_exe_file
  505. dst=${component}_dst_dir
  506. # we copy only the binary
  507. if [[ ! -d ${!dst} ]] ; then
  508. mkdir -p ${!dst}
  509. fi
  510. cp -f ${!exe} ${!dst}
  511. # get the enclosing folder of the target binaries folder that was just copied
  512. ln -sf ${!exe} ${!dst}/$(basename ${!exe}).lnk
  513. done
  514. fi