compilation.sh 19 KB

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