ece-esm.sh.tmpl 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  1. #!/usr/bin/env bash
  2. set -ue
  3. # librunscript defines some helper functions
  4. source ./librunscript.sh
  5. # =============================================================================
  6. # *** BEGIN User configuration
  7. # =============================================================================
  8. # -----------------------------------------------------------------------------
  9. # *** General configuration
  10. # -----------------------------------------------------------------------------
  11. # Component configuration (for syntax of the $config variable, see librunscript.sh)
  12. #
  13. # Currently maintained:
  14. # config="ifs amip" # "GCM forced-SST" : IFS + AMIP
  15. # config="ifs amip lpjg:fdbck tm5:co2" # "C-cycle" : forced-GCM + LPJ-Guess + TM5
  16. # config="ifs amip lpjg:fdbck" # "Veg" : forced-GCM + LPJ-Guess
  17. # config="ifs amip tm5:chem,o3,ch4,aero" # "AerChem" : forced-GCM + TM5
  18. #
  19. # config="ifs nemo lim3 rnfmapper xios:detached oasis" # "GCM" : IFS+NEMO
  20. # config="ifs nemo lim3 rnfmapper xios:detached oasis lpjg:fdbck tm5:co2" # "C-cycle" : GCM+LPJG+TM5
  21. # config="ifs nemo lim3 rnfmapper xios:detached oasis lpjg:fdbck" # "Veg" : GCM+LPJ-Guess
  22. # config="ifs nemo lim3 rnfmapper xios:detached oasis tm5:chem,o3,ch4,aero" # "AerChem" : GCM+TM5
  23. config="ifs nemo lim3 rnfmapper xios:detached oasis lpjg:fdbck tm5:co2"
  24. # minimum sanity
  25. has_config amip nemo && error "Cannot have both nemo and amip in config!!"
  26. # Experiment name (exactly 4 letters!)
  27. export exp_name=[[[MOD:GENERAL:EXP_NAME]]]
  28. # Simulation start and end date. Use any (reasonable) syntax you want.
  29. run_start_date="[[[MOD:GENERAL:RUN_START_DATE]]]"
  30. run_end_date="[[[MOD:GENERAL:RUN_END_DATE]]]"
  31. # Set $force_run_from_scratch to 'true' if you want to force this run to start
  32. # from scratch, possibly ignoring any restart files present in the run
  33. # directory. Leave set to 'false' otherwise.
  34. # NOTE: If set to 'true' the run directory $run_dir is cleaned!
  35. force_run_from_scratch=[[[MOD:GENERAL:FORCE_RUN_FROM_SCRATCH]]]
  36. # Resolution (TM5 resolution is set at compilation)
  37. ifs_grid=[[[MOD:IFS:GRID]]]
  38. nem_grid=[[[MOD:NEM:GRID]]]
  39. # Restart frequency. Use any (reasonable) number and time unit you want.
  40. # For runs without restart, leave this variable empty
  41. rst_freq="[[[MOD:GENERAL:RST_FREQ]]]"
  42. # Number of restart legs to be run in one go
  43. run_num_legs=[[[MOD:GENERAL:RUN_NUM_LEGS]]]
  44. # Coupling frequencies
  45. has_config ifs tm5 && cpl_freq_atm_ctm_hrs=[[[MOD:OASIS:CPL_FREQ_ATM_CHE_HRS]]]
  46. has_config ifs lpjg && cpl_freq_atm_lpjg_hrs=[[[MOD:OASIS:CPL_FREQ_ATM_LPJG_HRS]]]
  47. # Don't change the coupling frequency because UPDCLIE (where SST and SIC
  48. # are updated) is called every 24 hours (hardcoded in ifs-36r4/src/ifs/utility/updtim.F90)
  49. has_config amip && cpl_freq_amip_sec=86400
  50. # Directories
  51. start_dir=${PWD}
  52. ctrl_file_dir=${start_dir}/ctrl
  53. output_control_files_dir=${start_dir}/[[[MOD:GENERAL:OUTPUT_CONTROL_FILES_DIR]]]
  54. # Architecture
  55. build_arch=[[[PLT:ACTIVE:BUILD_ARCH]]]
  56. # This file is used to store information about restarts
  57. ece_info_file="ece.info"
  58. # -----------------------------------------------------------------------------
  59. # *** Read platform dependent configuration
  60. # -----------------------------------------------------------------------------
  61. source ./ecconf.cfg
  62. configure
  63. # -----------------------------------------------------------------------------
  64. # *** Time step settings
  65. # -----------------------------------------------------------------------------
  66. if has_config ifs
  67. then
  68. case "${ifs_grid}" in
  69. T159L*) ifs_time_step_sec=3600 ;;
  70. T255L*) ifs_time_step_sec=2700 ;;
  71. T511L*) ifs_time_step_sec=900 ;;
  72. *) error "Can't set time steps for unknown horizontal grid: ${ifs_grid}"
  73. ;;
  74. esac
  75. fi
  76. if has_config nemo
  77. then
  78. case "${nem_grid}" in
  79. ORCA1L*) nem_time_step_sec=2700; lim_time_step_sec=2700 ;;
  80. ORCA025L*) nem_time_step_sec=900 ; lim_time_step_sec=900 ;;
  81. *) error "Can't set time steps for unknown horizontal grid: ${nem_grid}"
  82. ;;
  83. esac
  84. fi
  85. if has_config ifs nemo
  86. then
  87. case "${ifs_grid}--${nem_grid}" in
  88. T159L*--ORCA1L*)
  89. ifs_time_step_sec=3600; nem_time_step_sec=2700; lim_time_step_sec=2700; cpl_freq_atm_oce_sec=10800
  90. ;;
  91. T255L*--ORCA1L*)
  92. ifs_time_step_sec=2700; nem_time_step_sec=2700; lim_time_step_sec=2700; cpl_freq_atm_oce_sec=2700
  93. ;;
  94. T511L*--ORCA025L*)
  95. ifs_time_step_sec=900 ; nem_time_step_sec=900 ; lim_time_step_sec=900 ; cpl_freq_atm_oce_sec=2700
  96. ;;
  97. *) error "Can't set time steps for unknown combination of horizontal grids: ${ifs_grid}-${nem_grid}"
  98. ;;
  99. esac
  100. fi
  101. # -----------------------------------------------------------------------------
  102. # *** IFS configuration
  103. # -----------------------------------------------------------------------------
  104. ifs_version=36r4
  105. ifs_di_freq=$(( 24 * 3600 / ifs_time_step_sec ))
  106. ifs_ddh_freq=$(( 120 * 3600 / ifs_time_step_sec ))
  107. export ifs_res_hor=$(echo ${ifs_grid} | sed 's:T\([0-9]\+\)L\([0-9]\+\):\1:')
  108. ifs_res_ver=$(echo ${ifs_grid} | sed 's:T\([0-9]\+\)L\([0-9]\+\):\2:')
  109. ifs_numproc=[[[MOD:IFS:NUMPROC]]]
  110. ifs_exe_file=${ecearth_src_dir}/ifs-${ifs_version}/bin/ifsmaster-${build_arch}
  111. ifs_lastout=false
  112. ifs_cmip5=[[[MOD:IFS:CMIP5]]]
  113. ifs_cmip5_rcp=[[[MOD:IFS:CMIP5_RCP]]]
  114. ifs_cmip_fixyear=[[[MOD:IFS:CMIP_FIXYEAR]]]
  115. ifs_cmip6=[[[MOD:IFS:CMIP6]]]
  116. ifs_mac2sp=[[[MOD:IFS:CMIP6]]]
  117. ifs_cmip6piaer=[[[MOD:IFS:CMIP6]]]
  118. ifs_cmip6_scenario=[[[MOD:IFS:CMIP6_SCENARIO]]]
  119. lcmip6_strataer_simp=FALSE
  120. lcmip6_strataer_full=[[[MOD:IFS:CMIP6]]]
  121. lcmip6_strataer_bckgd=FALSE
  122. ifs_A4xCO2=[[[MOD:IFS:CMIP6_A4xCO2]]]
  123. ifs_1PCTCO2=[[[MOD:IFS:CMIP6_1PCTCO2]]]
  124. # Time-varying orbital forcing (Qiong Zhang, SU-2013-09)
  125. # https://dev.ec-earth.org/projects/ecearth3/wiki/Orbital_forcing_in_EC-Earth_3
  126. #
  127. # ifs_orb_switch=FALSE, no orbital calculations applied
  128. # ifs_orb_switch=TRUE, use orbital calculations according to ifs_orb_mode
  129. # ifs_orb_mode="fixed_year", or "variable_year", or "fixed_parameters"
  130. # fixed_year: calculate the orbital parameters at ifs_orb_iyear, e.g.,1850
  131. # variable_year: calculate orbital parameters annually start from ifs_orb_iyear
  132. # fixed_parameters: prescribe orbital parameters for given year
  133. ifs_orb_switch=FALSE
  134. ifs_orb_mode="variable_year"
  135. ifs_orb_iyear=$(date -u -d "${run_start_date}" +%Y)
  136. # IFS tuning parameters
  137. ifs_tuning_parameter_file=${ctrl_file_dir}/ifs-tuning-parameters-${ifs_grid}.sh
  138. if [ -f ${ifs_tuning_parameter_file} ]
  139. then
  140. source ${ifs_tuning_parameter_file}
  141. else
  142. error "Sorry, ${ifs_tuning_parameter_file} not found, exiting."
  143. fi
  144. # Select source of vegetation data:
  145. # ifs climatology from IFS
  146. # era20c vegetation from an off-line LPJ-Guess run forced with ERA20C
  147. # (currently available only for T255 and T159)
  148. # cmip6 vegetation from an EC-Earth3-Veg (interactive LPJ-Guess) run
  149. # (currently available only for T255)
  150. # none don't create an ICMCL file with vegetation data (this is set
  151. # automatically if LPJG is used with feedback)
  152. #
  153. ifs_veg_source="cmip6"
  154. has_config lpjg:fdbck && ifs_veg_source="none"
  155. case ${ifs_veg_source} in
  156. "ifs" )
  157. # Use Lambert-Beer to compute effective vegetation cover
  158. n_compute_eff_veg_fraction=2
  159. ;;
  160. "era20c" )
  161. # LPJG vegetation is provided as effective cover
  162. # Don't use Lambert-Beer
  163. n_compute_eff_veg_fraction=0
  164. case "${ifs_grid}" in
  165. T159L*) veg_version=v29 ;;
  166. T255L*) veg_version=v16 ;;
  167. *) error "Vegetation from off-line LPJ-Guess not available for ${ifs_grid}" ;;
  168. esac
  169. ;;
  170. "cmip6" )
  171. # LPJG vegetation is provided as effective cover
  172. # Don't use Lambert-Beer
  173. n_compute_eff_veg_fraction=0
  174. case "${ifs_grid}" in
  175. T255L*) veg_version=v32 ;;
  176. *) error "Vegetation from CMIP6 EC-Earth3-Veg not available for ${ifs_grid}" ;;
  177. esac
  178. ;;
  179. "none" )
  180. # LPJG with feedback
  181. n_compute_eff_veg_fraction=0
  182. ! has_config lpjg:fdbck && error "IFS requires an offline source of vegetation"
  183. ;;
  184. * )
  185. error "Vegetation from ${ifs_veg_source} not implemented"
  186. ;;
  187. esac
  188. # use DMI land ice physics and varying snow albedo
  189. ifs_landice=false
  190. # -----------------------------------------------------------------------------
  191. # *** NEMO/LIM configuration
  192. # -----------------------------------------------------------------------------
  193. # This is only needed if the experiment is started from an existing set of NEMO
  194. # restart files
  195. nem_restart_file_path=${start_dir}/nemo-rst
  196. nem_restart_offset=0
  197. nem_res_hor=$(echo ${nem_grid} | sed 's:ORCA\([0-9]\+\)L[0-9]\+:\1:')
  198. nem_exe_file=${ecearth_src_dir}/nemo-3.6/CONFIG/${nem_grid}_LIM3/BLD/bin/nemo.exe
  199. nem_numproc=[[[MOD:NEM:NUMPROC]]]
  200. # -----------------------------------------------------------------------------
  201. # *** Runoff mapper configuration
  202. # -----------------------------------------------------------------------------
  203. rnf_exe_file=${ecearth_src_dir}/runoff-mapper/bin/runoff-mapper.exe
  204. rnf_numproc=1
  205. # -----------------------------------------------------------------------------
  206. # *** LPJ-GUESS configuration
  207. # -----------------------------------------------------------------------------
  208. lpjg_time_step_sec=[[[MOD:LPJG:TIME_STEP_SEC]]]
  209. lpjg_numproc=[[[MOD:LPJG:NUMPROC]]]
  210. has_config lpjg && lpjg_on=1
  211. has_config lpjg:fdbck && lpjg_fdbck=1
  212. has_config tm5 && lpjg_fdbck_tm5=1 || lpjg_fdbck_tm5=0
  213. export lpjg_fixNdepafter=[[[MOD:LPJG:LPJG_FIXNDEPAFTER]]]
  214. export lpjg_fixLUafter=[[[MOD:LPJG:LPJG_FIXLUAFTER]]]
  215. if [ $ifs_cmip_fixyear -gt 0 ]
  216. then
  217. info '!!!! CMIP FIX YEAR SETTINGS:'
  218. info "ifs_cmip_fixyear: $ifs_cmip_fixyear"
  219. info "lpjg_fixNDepAfter: $lpjg_fixNdepafter"
  220. info "lpjg_fixLUAfter: $lpjg_fixLUafter"
  221. info '!!!!'
  222. fi
  223. lpjg_res=T${ifs_res_hor}
  224. lpjg_exe_file=${ecearth_src_dir}/lpjg/build/guess_${lpjg_res}
  225. # -----------------------------------------------------------------------------
  226. # *** AMIP-reader configuration
  227. # -----------------------------------------------------------------------------
  228. amip_exe_file=${ecearth_src_dir}/amip-forcing/bin/amip-forcing.exe
  229. amip_numproc=1
  230. # -----------------------------------------------------------------------------
  231. # *** TM5 configuration
  232. # -----------------------------------------------------------------------------
  233. if $(has_config tm5)
  234. then
  235. # With TM5, NPRTRV is set to 1 in the namelist. To avoid some out-of-bound
  236. # arrays in IFS, we must limit the number of cores for IFS
  237. if (( ifs_numproc > (ifs_res_hor+1) ))
  238. then
  239. error "too much cores requested for IFS, max is $((ifs_res_hor+1))"
  240. fi
  241. fi
  242. has_config tm5:co2 && export tm5_co2=1 || export tm5_co2=0
  243. tm5_time_step_sec=[[[MOD:TM5:TIME_STEP_SEC]]]
  244. tm5_numproc=$(( [[[MOD:TM5:NUMPROC_X]]] * [[[MOD:TM5:NUMPROC_Y]]] ))
  245. # nb of coupled levels: nb of levels in either TM5 or IFS (must fit what's used at compilation)
  246. export tm5_exch_nlevs=34
  247. # limited number of levels for aerosols,
  248. # currently set to lmax_conv
  249. export tm5_exch_nlevs_cutoff=23
  250. # executable
  251. has_config tm5:co2 && tm5_exe_file=${ecearth_src_dir}/tm5mp/build-co2/appl-tm5-co2.x
  252. has_config tm5:chem && tm5_exe_file=${ecearth_src_dir}/tm5mp/build/appl-tm5.x
  253. # fields sent back to IFS
  254. has_config tm5:o3 && tm5_to_ifs=O3 || tm5_to_ifs=
  255. has_config tm5:ch4 && tm5_to_ifs=${tm5_to_ifs},CH4
  256. has_config tm5:aero && tm5_to_ifs=${tm5_to_ifs},"\
  257. N2,SU2,BC2,OC2,N3,SU3,BC3,OC3,SS3,DU3,\
  258. N4,SU4,BC4,OC4,SS4,DU4,N5,BC5,OC5,N6,DU6,N7,DU7,\
  259. NO3,MSA,\
  260. AOD_01,AOD_02,AOD_03,AOD_04,AOD_05,AOD_06,AOD_07,AOD_08,AOD_09,AOD_10,AOD_11,AOD_12,AOD_13,AOD_14,\
  261. SSA_01,SSA_02,SSA_03,SSA_04,SSA_05,SSA_06,SSA_07,SSA_08,SSA_09,SSA_10,SSA_11,SSA_12,SSA_13,SSA_14,\
  262. ASF_01,ASF_02,ASF_03,ASF_04,ASF_05,ASF_06,ASF_07,ASF_08,ASF_09,ASF_10,ASF_11,ASF_12,ASF_13,ASF_14"
  263. export tm5_to_ifs=$(echo ${tm5_to_ifs} | sed "s/^,//")
  264. # coupled to LPJ-Guess?
  265. has_config tm5:co2 lpjg && export cpl_tm_guess=T || export cpl_tm_guess=F
  266. # -----------------------------------------------------------------------------
  267. # *** OASIS configuration
  268. # -----------------------------------------------------------------------------
  269. # Restart files for the coupling fields (note 8 character limit in OASIS)
  270. # rstas.nc : atmosphere single-category fields
  271. # rstam.nc : atmosphere multi-category fields
  272. # rstos.nc : ocean single-category fields
  273. # rstom.nc : ocean multi-category fields
  274. oas_rst_ifs_nemo="rstas.nc rstos.nc"
  275. oas_rst_ifs_tm5="r_hum.nc r_g2d.nc r_udr.nc r_cc_.nc r_clw.nc r_div.nc \
  276. r_cco.nc r_vor.nc r_ddr.nc r_ciw.nc r_tmp.nc r_dmf.nc \
  277. r_s2d.nc r_ccu.nc r_umf.nc"
  278. has_config tm5:o3 || has_config tm5:ch4 && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' o3ch4.nc'
  279. has_config tm5:aero && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' C???????'
  280. # Decide whether the OASIS weight files for interpolation should be linked from
  281. # the setup directory (true) or not (false). In the latter case, the weights
  282. # are re-computed at the start of the run.
  283. oas_link_weights=true
  284. # Flux correction for runoff (not calving) sent from Oasis to ocean.
  285. # 1.07945 is computed to compensate for a P-E=-0.016 mm/day
  286. has_config nemo && oas_mb_fluxcorr=1.07945
  287. # -----------------------------------------------------------------------------
  288. # *** XIOS configuration
  289. # -----------------------------------------------------------------------------
  290. xio_exe_file=${ecearth_src_dir}/xios-2.5/bin/xios_server.exe
  291. xio_numproc=[[[MOD:XIO:NUMPROC]]]
  292. # -----------------------------------------------------------------------------
  293. # *** Extra initial conditions saved during the run
  294. # -----------------------------------------------------------------------------
  295. if has_config save_ic
  296. then
  297. source ./libsave_ic.sh
  298. declare -a save_ic_date save_ic_date1 save_ic_sec save_ic_day save_ic_ppt_file save_ic_nemo_ts
  299. oas_rst_files=${oas_rst_ifs_nemo}
  300. fi
  301. # =============================================================================
  302. # *** END of User configuration
  303. # =============================================================================
  304. # =============================================================================
  305. # *** This is where the code begins ...
  306. # =============================================================================
  307. # -----------------------------------------------------------------------------
  308. # *** Create the run dir if necessary and go there
  309. # Everything is done from here.
  310. # -----------------------------------------------------------------------------
  311. if [ ! -d ${run_dir} ]
  312. then
  313. mkdir -p ${run_dir}
  314. fi
  315. cd ${run_dir}
  316. # -----------------------------------------------------------------------------
  317. # *** Determine the time span of this run and whether it's a restart leg
  318. # -----------------------------------------------------------------------------
  319. # Regularise the format of the start and end date of the simulation
  320. run_start_date=$(date -uR -d "${run_start_date}")
  321. run_end_date=$(date -uR -d "${run_end_date}")
  322. # -----------------------------------------------------------------------------
  323. # *** Set path to grib_set
  324. # -----------------------------------------------------------------------------
  325. grib_set=${GRIB_BIN_PATH}${GRIB_BIN_PATH:+/}grib_set
  326. # Loop over the number of legs
  327. for (( ; run_num_legs>0 ; run_num_legs-- ))
  328. do
  329. # Check for restart information file and set the current leg start date
  330. # Ignore restart information file if force_run_from_scratch is true
  331. if ${force_run_from_scratch} || ! [ -r ${ece_info_file} ]
  332. then
  333. leg_is_restart=false
  334. leg_start_date=${run_start_date}
  335. leg_number=1
  336. else
  337. leg_is_restart=true
  338. . ./${ece_info_file}
  339. leg_start_date=${leg_end_date}
  340. leg_number=$((leg_number+1))
  341. fi
  342. # Compute the end date of the current leg
  343. if [ -n "${rst_freq}" ]
  344. then
  345. leg_end_date=$(date -uR -d "${leg_start_date} + ${rst_freq}")
  346. else
  347. leg_end_date=${run_end_date}
  348. fi
  349. if [ $(date -u -d "${leg_end_date}" +%s) -ge $(date -u -d "${run_end_date}" +%s) ]
  350. then
  351. leg_end_date=${run_end_date}
  352. ifs_lastout=true
  353. fi
  354. # Some time variables needed later
  355. leg_length_sec=$(( $(date -u -d "${leg_end_date}" +%s) - $(date -u -d "${leg_start_date}" +%s) ))
  356. leg_start_sec=$(( $(date -u -d "${leg_start_date}" +%s) - $(date -u -d "${run_start_date}" +%s) ))
  357. leg_end_sec=$(( $(date -u -d "${leg_end_date}" +%s) - $(date -u -d "${run_start_date}" +%s) ))
  358. leg_start_date_yyyymmdd=$(date -u -d "${leg_start_date}" +%Y%m%d)
  359. leg_start_date_yyyy=$(date -u -d "${leg_start_date}" +%Y)
  360. leg_end_date_yyyy=$(date -u -d "${leg_end_date}" +%Y)
  361. # Check whether there's actually time left to simulate - exit otherwise
  362. if [ ${leg_length_sec} -le 0 ]
  363. then
  364. info "Leg start date equal to or after end of simulation."
  365. info "Nothing left to do. Exiting."
  366. exit 0
  367. fi
  368. # Initial conditions saved during the run
  369. do_save_ic=false
  370. has_config save_ic && save_ic_get_config
  371. # if you do not use an option with save_ic, you must define 'do_save_ic' and
  372. # 'save_ic_date_offset' here or in ../libsave_ic.sh/save_ic_get_config()
  373. ${do_save_ic} && save_ic_define_vars
  374. # -------------------------------------------------------------------------
  375. # *** Prepare the run directory for a run from scratch
  376. # -------------------------------------------------------------------------
  377. if ! $leg_is_restart
  378. then
  379. # ---------------------------------------------------------------------
  380. # *** Check if run dir is empty. If not, and if we are allowed to do so
  381. # by ${force_run_from_scratch}, remove everything
  382. # ---------------------------------------------------------------------
  383. if $(ls * >& /dev/null)
  384. then
  385. if ${force_run_from_scratch}
  386. then
  387. rm -fr ${run_dir}/*
  388. else
  389. error "Run directory not empty and \$force_run_from_scratch not set."
  390. fi
  391. fi
  392. # ---------------------------------------------------------------------
  393. # *** Copy executables of model components
  394. # *** Additionally, create symlinks to the original place for reference
  395. # ---------------------------------------------------------------------
  396. cp ${ifs_exe_file} .
  397. ln -s ${ifs_exe_file} $(basename ${ifs_exe_file}).lnk
  398. if $(has_config amip)
  399. then
  400. cp ${amip_exe_file} .
  401. ln -s ${amip_exe_file} $(basename ${amip_exe_file}).lnk
  402. fi
  403. if $(has_config nemo)
  404. then
  405. cp ${nem_exe_file} .
  406. ln -s ${nem_exe_file} $(basename ${nem_exe_file}).lnk
  407. cp ${rnf_exe_file} .
  408. ln -s ${rnf_exe_file} $(basename ${rnf_exe_file}).lnk
  409. cp ${xio_exe_file} .
  410. ln -s ${xio_exe_file} $(basename ${xio_exe_file}).lnk
  411. fi
  412. if $(has_config lpjg)
  413. then
  414. cp ${lpjg_exe_file} .
  415. ln -s ${lpjg_exe_file} $(basename ${lpjg_exe_file}).lnk
  416. fi
  417. if $(has_config tm5)
  418. then
  419. cp ${tm5_exe_file} .
  420. ln -s ${tm5_exe_file} $(basename ${tm5_exe_file}).lnk
  421. fi
  422. # ---------------------------------------------------------------------
  423. # *** Files needed for IFS (linked)
  424. # ---------------------------------------------------------------------
  425. # Initial data
  426. ln -s \
  427. ${ini_data_dir}/ifs/${ifs_grid}/${leg_start_date_yyyymmdd}/ICMGGECE3INIUA \
  428. ICMGG${exp_name}INIUA
  429. ln -s \
  430. ${ini_data_dir}/ifs/${ifs_grid}/${leg_start_date_yyyymmdd}/ICMSHECE3INIT \
  431. ICMSH${exp_name}INIT
  432. rm -f ICMGG${exp_name}INIT
  433. cp ${ini_data_dir}/ifs/${ifs_grid}/${leg_start_date_yyyymmdd}/ICMGGECE3INIT \
  434. ICMGG${exp_name}INIT
  435. # add bare_soil_albedo to ICMGG*INIT
  436. tempfile=tmp.$$
  437. ${grib_set} -s dataDate=$(date -u -d "$run_start_date" +%Y%m%d) \
  438. ${ini_data_dir}/ifs/${ifs_grid}/climate/bare_soil_albedos.grb \
  439. ${tempfile}
  440. cat ${tempfile} >> ICMGG${exp_name}INIT
  441. rm -f ${tempfile}
  442. # add land ice mask if needed
  443. if ${ifs_landice}
  444. then
  445. tempfile=tmp.$$
  446. cdo divc,10 -setcode,82 -selcode,141 ICMGG${exp_name}INIT ${tempfile}
  447. ${grib_set} -s gridType=reduced_gg ${tempfile} ${tempfile}
  448. cat ${tempfile} >> ICMGG${exp_name}INIT
  449. rm -f ${tempfile}
  450. fi
  451. # Other stuff
  452. ln -s ${ini_data_dir}/ifs/rtables/* .
  453. # Output control (ppt files)
  454. if [ ! -f ${output_control_files_dir}/pptdddddd0600 ] && [ ! -f ${output_control_files_dir}/pptdddddd0300 ];then
  455. echo "Error from ece-esm.sh: Neither the file pptdddddd0600 or pptdddddd0300 exists in the directory:"
  456. echo " " ${output_control_files_dir}
  457. exit -1
  458. fi
  459. mkdir postins
  460. cp ${output_control_files_dir}/ppt* postins/
  461. if [ -f postins/pptdddddd0600 ];then
  462. ln -s pptdddddd0600 postins/pptdddddd0000
  463. ln -s pptdddddd0600 postins/pptdddddd1200
  464. ln -s pptdddddd0600 postins/pptdddddd1800
  465. fi
  466. if [ -f postins/pptdddddd0300 ];then
  467. ln -s pptdddddd0300 postins/pptdddddd0900
  468. ln -s pptdddddd0300 postins/pptdddddd1500
  469. ln -s pptdddddd0300 postins/pptdddddd2100
  470. if [ ! -f postins/pptdddddd0600 ];then
  471. ln -s pptdddddd0300 postins/pptdddddd0000
  472. ln -s pptdddddd0300 postins/pptdddddd0600
  473. ln -s pptdddddd0300 postins/pptdddddd1200
  474. ln -s pptdddddd0300 postins/pptdddddd1800
  475. fi
  476. fi
  477. /bin/ls -1 postins/* > dirlist
  478. # ---------------------------------------------------------------------
  479. # *** Files needed for LPJ-GUESS
  480. # ---------------------------------------------------------------------
  481. if $(has_config lpjg)
  482. then
  483. # Check for valid grid
  484. if [ $lpjg_res != "T255" -a $lpjg_res != "T159" ]
  485. then
  486. error "LPJG-gridlist doesn't exist for ifs-grid: ${ifs_grid}"
  487. fi
  488. # Initial data - saved state for LPJ-GUESS (.bin format)
  489. lpjgstartdir=$(printf "lpjg_state_%04d" $leg_start_date_yyyy)
  490. ln -sf ${ini_data_dir}/lpjg/ini_state/${lpjg_res}/${lpjgstartdir} ${run_dir}/${lpjgstartdir}
  491. # Control files (i.e. .ins, landuse, N deposition, soil type files etc.)
  492. cp -f ${ecearth_src_dir}/lpjg/data/ins/*.ins .
  493. mkdir -p ${run_dir}/landuse
  494. fi
  495. # ---------------------------------------------------------------------
  496. # *** Files needed for NEMO (linked)
  497. # ---------------------------------------------------------------------
  498. if $(has_config nemo)
  499. then
  500. # Link initialisation files for matching ORCA grid
  501. for f in \
  502. bathy_meter.nc coordinates.nc \
  503. ahmcoef.nc \
  504. K1rowdrg.nc M2rowdrg.nc mask_itf.nc \
  505. decay_scale_bot.nc decay_scale_cri.nc \
  506. mixing_power_bot.nc mixing_power_cri.nc mixing_power_pyc.nc \
  507. runoff_depth.nc subbasins.nc
  508. do
  509. [ -f ${ini_data_dir}/nemo/initial/${nem_grid}/$f ] && ln -s ${ini_data_dir}/nemo/initial/${nem_grid}/$f
  510. done
  511. # Link geothermal heating file (independent of grid) and matching weight file
  512. ln -s ${ini_data_dir}/nemo/initial/Goutorbe_ghflux.nc
  513. ln -s ${ini_data_dir}/nemo/initial/weights_Goutorbe1_2_orca${nem_res_hor}_bilinear.nc
  514. # Link the salinity climatology file (needed for diagnostics)
  515. ln -s ${ini_data_dir}/nemo/climatology/${nem_grid}/sali_ref_clim_monthly.nc
  516. # Link either restart files or climatology files for the initial state
  517. if $(has_config nemo:start_from_restart)
  518. then
  519. # When linking restart files, we accept three options:
  520. # (1) Merged files for ocean and ice, i.e.
  521. # restart_oce.nc and restart_ice.nc
  522. # (2) One-file-per-MPI-rank, i.e.
  523. # restart_oce_????.nc and restart_ice_????.nc
  524. # No check is done whether the number of restart files agrees
  525. # with the number of MPI ranks for NEMO!
  526. # (3) One-file-per-MPI-rank with a prefix, i.e.
  527. # <exp_name>_<time_step>_restart_oce_????.nc (similar for the ice)
  528. # The prefix is ignored.
  529. # The code assumes that one of the options can be applied! If more
  530. # options are applicable, the first is chosen. If none of the
  531. # options apply, NEMO will crash with missing restart file.
  532. if ls -U ${nem_restart_file_path}/restart_[oi]ce.nc > /dev/null 2>&1
  533. then
  534. ln -s ${nem_restart_file_path}/restart_[oi]ce.nc ./
  535. elif ls -U ${nem_restart_file_path}/restart_[oi]ce_????.nc > /dev/null 2>&1
  536. then
  537. ln -s ${nem_restart_file_path}/restart_[oi]ce_????.nc ./
  538. else
  539. for f in ${nem_restart_file_path}/????_????????_restart_[oi]ce_????.nc
  540. do
  541. ln -s $f $(echo $f | sed 's/.*_\(restart_[oi]ce_....\.nc\)/\1/')
  542. done
  543. fi
  544. else
  545. # Temperature and salinity files for initialisation
  546. ln -s ${ini_data_dir}/nemo/climatology/absolute_salinity_WOA13_decav_Reg1L75_clim.nc
  547. ln -s ${ini_data_dir}/nemo/climatology/conservative_temperature_WOA13_decav_Reg1L75_clim.nc
  548. ln -s ${ini_data_dir}/nemo/climatology/weights_WOA13d1_2_orca${nem_res_hor}_bilinear.nc
  549. # Grid dependent runoff files
  550. case ${nem_grid} in
  551. ORCA1*) ln -s ${ini_data_dir}/nemo/climatology/runoff-icb_DaiTrenberth_Depoorter_ORCA1_JD.nc ;;
  552. ORCA025*) ln -s ${ini_data_dir}/nemo/climatology/ORCA_R025_runoff_v1.1.nc ;;
  553. esac
  554. fi
  555. # for ocean_nudging
  556. if $(has_config nemo:ocenudg) ; then
  557. ln -s ${ini_data_dir}/nemo/oce_nudg/resto.nc
  558. fi
  559. # XIOS files
  560. . ${ctrl_file_dir}/iodef.xml.sh > iodef.xml
  561. ln -s ${ctrl_file_dir}/context_nemo.xml
  562. ln -s ${ctrl_file_dir}/domain_def_nemo.xml
  563. ln -s ${ctrl_file_dir}/axis_def_nemo.xml
  564. ln -s ${ctrl_file_dir}/grids_def_nemo.xml
  565. ln -s ${ctrl_file_dir}/field_def_nemo-lim.xml
  566. ln -s ${ctrl_file_dir}/field_def_nemo-opa.xml
  567. ln -s ${ctrl_file_dir}/field_def_nemo-pisces.xml
  568. ln -s ${ctrl_file_dir}/field_def_nemo-inerttrc.xml
  569. ln -s ${output_control_files_dir}/file_def_nemo-lim3.xml file_def_nemo-lim.xml
  570. ln -s ${output_control_files_dir}/file_def_nemo-opa.xml
  571. ln -s ${output_control_files_dir}/file_def_nemo-pisces.xml
  572. if [ -f ${ini_data_dir}/xios/ORCA${nem_res_hor}/coordinates_xios.nc ]
  573. then
  574. cp ${ini_data_dir}/xios/ORCA${nem_res_hor}/coordinates_xios.nc ./
  575. else
  576. info "File 'coordinates_xios.nc' not found. NEMO can not be run with land domain removal!"
  577. fi
  578. fi
  579. # ---------------------------------------------------------------------
  580. # *** Files needed for the Runoff mapper (linked)
  581. # ---------------------------------------------------------------------
  582. has_config rnfmapper && \
  583. ln -s ${ini_data_dir}/runoff-mapper/runoff_maps.nc
  584. # -------------------------------------------------------------------------
  585. # *** File and dir needed for TM5
  586. # -------------------------------------------------------------------------
  587. if $(has_config tm5)
  588. then
  589. tm5_istart=[[[MOD:TM5:ISTART]]]
  590. case ${tm5_istart} in
  591. 33|32) ln -s \
  592. ${ini_data_dir}/tm5/restart/TM5_restart_${leg_start_date_yyyymmdd}_0000_glb300x200.nc
  593. ;;
  594. 31) ln -s ${ini_data_dir}/tm5/restart/tm5_save.hdf
  595. ;;
  596. 5) ln -s ${ini_data_dir}/tm5/restart/tm5_mmix.hdf
  597. ;;
  598. 2|9)
  599. ;;
  600. *) error "Unsupported initial fields option (TM5): ${tm5_istart}"
  601. ;;
  602. esac
  603. # Profiling dir for TM5
  604. mkdir -p ${run_dir}/tm5_profile
  605. fi
  606. # ---------------------------------------------------------------------
  607. # *** Files needed for OASIS (linked)
  608. # ---------------------------------------------------------------------
  609. # Name table file
  610. ln -s ${ini_data_dir}/oasis/cf_name_table.txt
  611. # -- Get grid definition and weight files for IFS/NEMO or IFS/AMIP coupling
  612. has_config nemo && \
  613. oas_grid_dir=${ini_data_dir}/oasis/T${ifs_res_hor}-ORCA${nem_res_hor} && \
  614. mycp='cp'
  615. has_config amip && \
  616. oas_grid_dir=${ini_data_dir}/oasis/AMIP && \
  617. mycp='cdo -f nc copy' # to enforce nc format, needed for 'cdo merge' to work (have nc4c with Primavera files)
  618. # Grid definition files
  619. if $(has_config tm5)
  620. then
  621. ${mycp} ${oas_grid_dir}/areas.nc gcm_areas.nc
  622. ${mycp} ${oas_grid_dir}/grids.nc gcm_grids.nc
  623. ${mycp} ${oas_grid_dir}/masks.nc gcm_masks.nc
  624. else
  625. ln -s ${oas_grid_dir}/areas.nc
  626. ln -s ${oas_grid_dir}/grids.nc
  627. ln -s ${oas_grid_dir}/masks.nc
  628. fi
  629. # Weight files
  630. case ${ifs_res_hor} in
  631. 159) oas_agrd=080
  632. ;;
  633. 255) oas_agrd=128
  634. ;;
  635. 511) oas_agrd=256
  636. ;;
  637. 799) oas_agrd=400
  638. ;;
  639. *) error "Unsupported horizontal resolution (IFS): ${ifs_res_hor}"
  640. ;;
  641. esac
  642. if $(has_config nemo)
  643. then
  644. case ${nem_res_hor} in
  645. 1) oas_ogrd=O1t0
  646. ;;
  647. 025) oas_ogrd=Ot25
  648. ;;
  649. *) error "Unsupported horizontal resolution (NEMO): ${nem_res_hor}"
  650. ;;
  651. esac
  652. fi
  653. if ${oas_link_weights}
  654. then
  655. for f in ${oas_grid_dir}/rmp_????_to_????_GAUSWGT.nc
  656. do
  657. ln -s $f
  658. done
  659. fi
  660. if $(has_config ifs nemo)
  661. then
  662. for f in ${oas_rst_ifs_nemo}
  663. do
  664. cp ${oas_grid_dir}/rst/$f .
  665. done
  666. fi
  667. # -- Get grid definition, weight and restart files for IFS/TM5 coupling
  668. if $(has_config tm5)
  669. then
  670. oas_grid_dir=${ini_data_dir}/oasis/T${ifs_res_hor}-TM3x2
  671. cp ${oas_grid_dir}/tm5_areas.nc .
  672. cp ${oas_grid_dir}/tm5_grids.nc .
  673. cp ${oas_grid_dir}/tm5_masks.nc .
  674. if ${oas_link_weights}
  675. then
  676. for f in ${oas_grid_dir}/rmp_????_to_????_*.nc
  677. do
  678. ln -s $f
  679. done
  680. fi
  681. for f in ${oas_rst_ifs_tm5}
  682. do
  683. cp ${oas_grid_dir}/rst/$f .
  684. done
  685. # -- Merge grid definition files
  686. cdo merge gcm_areas.nc tm5_areas.nc areas.nc
  687. cdo merge gcm_grids.nc tm5_grids.nc grids.nc
  688. cdo merge gcm_masks.nc tm5_masks.nc masks.nc
  689. fi
  690. else # i.e. $leg_is_restart == true
  691. # ---------------------------------------------------------------------
  692. # *** Remove all leftover output files from previous legs
  693. # ---------------------------------------------------------------------
  694. # IFS files
  695. rm -f ICM{SH,GG}${exp_name}+??????
  696. # NEMO files
  697. rm -f ${exp_name}_??_????????_????????_{grid_U,grid_V,grid_W,grid_T,icemod,SBC,scalar,SBC_scalar,diad_T}.nc
  698. # TM5 start file type (33 if you have netcdf4 compiled w/ parallel IO, else to 31)
  699. tm5_istart=33
  700. if [ $tm5_istart -eq 31 ] && $(has_config tm5)
  701. then
  702. ln -sf save_${leg_start_date_yyyymmdd}00_glb300x200.hdf tm5_save.hdf
  703. fi
  704. fi # ! $leg_is_restart
  705. #--------------------------------------------------------------------------
  706. # *** Surface restoring and ocean nudging options
  707. #--------------------------------------------------------------------------
  708. if $(has_config nemo:ocenudg) ; then
  709. ln -fs ${ini_data_dir}/nemo/oce_nudg/temperature*.nc ./
  710. ln -fs ${ini_data_dir}/nemo/oce_nudg/salinity*.nc ./
  711. fi
  712. if $(has_config nemo:surfresto) ; then
  713. ln -fs ${ini_data_dir}/nemo/surface_restoring/sss_restore_data*.nc ./
  714. ln -fs ${ini_data_dir}/nemo/surface_restoring/sst_restore_data*.nc ./
  715. ln -fs ${ini_data_dir}/nemo/surface_restoring/mask_restore*.nc ./
  716. fi
  717. # -------------------------------------------------------------------------
  718. # *** Remove land grid-points
  719. # -------------------------------------------------------------------------
  720. if $(has_config nemo:elpin)
  721. then
  722. if [ ! -f coordinates_xios.nc ]
  723. then
  724. error "ELpIN requested, but file 'coordinates_xios.nc' was not found"
  725. fi
  726. jpns=($(${ecearth_src_dir}/util/ELPiN/ELPiNv2.cmd ${nem_numproc}))
  727. info "nemo domain decompostion from ELpIN: ${jpns[@]}"
  728. nem_numproc=${jpns[0]}
  729. nem_jpni=${jpns[1]}
  730. nem_jpnj=${jpns[2]}
  731. elif has_config nemo
  732. then
  733. info "nemo original domain decomposition (not using ELPiN)"
  734. fi
  735. # -------------------------------------------------------------------------
  736. # *** Initial conditions saved during the run
  737. # -------------------------------------------------------------------------
  738. ${do_save_ic} && save_ic_prepare_output
  739. # -------------------------------------------------------------------------
  740. # *** Create some control files
  741. # -------------------------------------------------------------------------
  742. # Create TM5 runtime rcfile
  743. tm5_start_date=$(date -u -d "${leg_start_date}" +%F\ %T)
  744. tm5_end_date=$(date -u -d "${leg_end_date}" +%F\ %T)
  745. has_config tm5 && ${ecearth_src_dir}/tm5mp/setup_tm5 --no-compile \
  746. --time-start="${tm5_start_date}" --time-final="${tm5_end_date}" \
  747. --istart=${tm5_istart} ${ctrl_file_dir}/tm5-config-run.rc
  748. # IFS frequency output for namelist
  749. if [ -f postins/pptdddddd0300 ]
  750. then
  751. ifs_output_freq=$(( 3 * 3600 / ifs_time_step_sec ))
  752. elif [ -f postins/pptdddddd0600 ]
  753. then
  754. ifs_output_freq=$(( 6 * 3600 / ifs_time_step_sec ))
  755. else
  756. error "IFS output frequency undefined."
  757. fi
  758. # IFS, NEMO, LIM, AMIP namelist and OASIS namcouple files
  759. has_config ifs && . ${ctrl_file_dir}/namelist.ifs.sh > fort.4
  760. has_config nemo && . ${ctrl_file_dir}/namelist.nemo.ref.sh > namelist_ref
  761. has_config nemo && . ${ctrl_file_dir}/namelist.nemo-${nem_grid}-coupled.cfg.sh > namelist_cfg
  762. has_config lim3 && . ${ctrl_file_dir}/namelist.lim3.ref.sh > namelist_ice_ref
  763. has_config lim3 && . ${ctrl_file_dir}/namelist.lim3-${nem_grid}.cfg.sh > namelist_ice_cfg
  764. has_config rnfmapper && . ${ctrl_file_dir}/namelist.runoffmapper.sh > namelist.runoffmapper
  765. has_config amip && . ${ctrl_file_dir}/namelist.amip.sh > namelist.amip
  766. . ${ctrl_file_dir}/namcouple.sh > namcouple
  767. # -------------------------------------------------------------------------
  768. # *** LPJ-GUESS initial data
  769. # -------------------------------------------------------------------------
  770. if $(has_config lpjg)
  771. then
  772. # LPJG runtime rcfile - update with leg dates
  773. . ${ctrl_file_dir}/namelist.lpjg.sh > lpjg_steps.rc
  774. # determine lpjg scenario-name and co2-file middle-fix
  775. case $(echo ${ifs_cmip6_scenario} | tr '[:upper:]' '[:lower:]') in
  776. hist*) lpjg_scen="ssp370"; lu_src="AIM" ; lpjg_sco2_mfix="AIM-ssp370-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  777. ssp1-1.9*) lpjg_scen="ssp119"; lu_src="IMAGE" ; lpjg_sco2_mfix="IMAGE-ssp119-1-2-1" ; lu_file_posfix="2019_03_13.txt";;
  778. ssp1-2.6*) lpjg_scen="ssp126"; lu_src="IMAGE" ; lpjg_sco2_mfix="IMAGE-ssp126-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  779. ssp2-4.5*) lpjg_scen="ssp245"; lu_src="MESSAGE"; lpjg_sco2_mfix="MESSAGE-GLOBIOM-ssp245-1-2-1"; lu_file_posfix="2018_10_08.txt";;
  780. ssp3-7.0*) lpjg_scen="ssp370"; lu_src="AIM" ; lpjg_sco2_mfix="AIM-ssp370-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  781. ssp5-8.5*) lpjg_scen="ssp585"; lu_src="MAGPIE" ; lpjg_sco2_mfix="REMIND-MAGPIE-ssp585-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  782. *) error "Scenario ${ifs_cmip6_scenario} not defined for LPJ-GUESS" ;;
  783. esac
  784. lpjg_scenario_new="historical + $lpjg_sco2_mfix"
  785. lpjg_scenario_info=${run_dir}/lpjg_scenario.info
  786. if [ -f $lpjg_scenario_info ]
  787. then
  788. source $lpjg_scenario_info
  789. if [ "$lpjg_scenario_new" = "$lpjg_scenario" ]
  790. then
  791. lpjg_copy_rte=false
  792. else
  793. lpjg_copy_rte=true
  794. fi
  795. else
  796. lpjg_copy_rte=true
  797. fi
  798. # copy RTE only if necessary (at beginning of a run or when scenario changes)
  799. if $lpjg_copy_rte
  800. then
  801. # write info about installed scenarios to file
  802. echo "lpjg_scenario=\"historical + $lpjg_sco2_mfix\"" > $lpjg_scenario_info
  803. # set file prefixes depending on scenario
  804. lu_file_prefix="1850_2100_luh2_Hist_ScenarioMIP_UofMD"
  805. lu_file_midfix="2_1_f"
  806. lu_path="${ini_data_dir}/lpjg/landuse/${lpjg_res}/${lpjg_scen}"
  807. # copy and reference-link landuse, gross transitions, crops, n-fertilisation
  808. for inp in lu gross crop nfert
  809. do
  810. if [ $inp == "crop" -o $inp == "nfert" ]
  811. then
  812. lu_src_file="${lu_path}/${inp}_rfirr_${lu_file_prefix}_${lu_src}_${lpjg_scen}_${lu_file_midfix}_${lpjg_res}_${lu_file_posfix}"
  813. else
  814. lu_src_file="${lu_path}/${inp}_${lu_file_prefix}_${lu_src}_${lpjg_scen}_${lu_file_midfix}_${lpjg_res}_${lu_file_posfix}"
  815. fi
  816. cp -f $lu_src_file ${run_dir}/landuse/${inp}_luh2.txt
  817. ln -fs $lu_src_file ${run_dir}/landuse/${inp}_luh2.txt.lnk
  818. done
  819. # nitrogen deposition files
  820. mkdir -p ${run_dir}/ndep
  821. for inp in drynhx2 drynoy2 wetnhx2 wetnoy2
  822. do
  823. ndep_src_file="${ini_data_dir}/lpjg/ndep/${lpjg_res}/${lpjg_scen}/${lpjg_scen}_${lpjg_res}_${inp}.nc"
  824. cp -f $ndep_src_file ${run_dir}/ndep/${inp}.nc
  825. ln -fs $ndep_src_file ${run_dir}/ndep/${inp}.nc.lnk
  826. done
  827. # concatenate historic and scenario (2015+) co2 concentration file
  828. # hist co2 file
  829. lpjg_hco2_file="${ini_data_dir}/ifs/cmip6-data/mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_0000-2014.nc"
  830. # scenario co2 file
  831. lpjg_sco2_file="${ini_data_dir}/ifs/cmip6-data/mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-${lpjg_sco2_mfix}_gr1-GMNHSH_2015-2500.nc"
  832. # combined file
  833. lpjg_co2_file="${run_dir}/mole_fraction_of_carbon_dioxide_in_air_input4MIPs_lpjg.nc"
  834. rm -f $lpjg_co2_file
  835. cdo mergetime $lpjg_hco2_file $lpjg_sco2_file $lpjg_co2_file
  836. fi
  837. # Populate or update LPJG run directories
  838. for (( n=1; n<=${lpjg_numproc}; n++ ))
  839. do
  840. # if run from scratch or number of procs has been extended
  841. if ! $leg_is_restart || [ ! -d ${run_dir}/run${n} ]
  842. then
  843. # Make output directories
  844. mkdir -p ${run_dir}/run${n}/output
  845. # Copy *.ins, lpjg_steps.rc and OASIS-MCT restart files
  846. cp ${run_dir}/*.ins ${run_dir}/run${n}
  847. # Copy output control files
  848. cp ${output_control_files_dir}/lpjg_cmip6_output.ins ${run_dir}/run${n}
  849. ln -s ${output_control_files_dir}/lpjg_cmip6_output.ins ${run_dir}/run${n}/lpjg_cmip6_output.ins.lnk
  850. cp ${ini_data_dir}/lpjg/oasismct/ghg*.txt ${run_dir}/run${n}
  851. cp ${ini_data_dir}/lpjg/oasismct/${lpjg_res}/ece_gridlist_${lpjg_res}.txt ${run_dir}/run${n}/ece_gridlist.txt
  852. ln -s ${ini_data_dir}/lpjg/oasismct/${lpjg_res}/ece_gridlist_${lpjg_res}.txt ${run_dir}/run${n}/ece_gridlist.txt.lnk
  853. # Data only needed by master
  854. if [ $n == 1 ]
  855. then
  856. cp ${ini_data_dir}/lpjg/oasismct/${lpjg_res}/*.nc ${run_dir}
  857. cp ${ini_data_dir}/lpjg/oasismct/lpjgv.txt ${run_dir}/run${n}
  858. fi
  859. fi
  860. # Refresh output-dirs after they hav been removed at end of the last leg
  861. mkdir -p ${run_dir}/run${n}/output/CMIP6
  862. mkdir -p ${run_dir}/run${n}/output/CRESCENDO
  863. done
  864. if $leg_is_restart
  865. then
  866. lpjg_restart_dir="restart/lpjg/$(printf %03d $((leg_number-1)))"
  867. lpjg_rst_state="${lpjg_restart_dir}/lpjg_state_${leg_start_date_yyyy}"
  868. if [ -d "$lpjg_rst_state" ]
  869. then
  870. ln -sf $lpjg_rst_state
  871. else
  872. echo "lpjg restart dir $lpjg_rst_state not available"
  873. exit -1
  874. fi
  875. # get oasis restart files
  876. oasis_restart_dir="restart/oasis/$(printf %03d $((leg_number)))"
  877. cp -f ${oasis_restart_dir}/*.nc ${run_dir}/
  878. fi
  879. fi
  880. # -------------------------------------------------------------------------
  881. # *** Create ICMCL file with vegetation fields
  882. # not needed if LPJG is used with feedback
  883. # -------------------------------------------------------------------------
  884. tempfile=tmp.$$
  885. case ${ifs_veg_source} in
  886. "ifs" )
  887. # Vegetation from IFS (climatology)
  888. icmclfile=${ini_data_dir}/ifs/${ifs_grid}/climate/ICMCL_ONLY_VEG_PD
  889. # Create data for december, the year before the leg starts
  890. ${grib_set} \
  891. -s dataDate=$(printf "%04d" $((leg_start_date_yyyy-1)))1215 \
  892. ${icmclfile}-12 ICMCL${exp_name}INIT
  893. # Create data for all month in the years of the leg
  894. for (( y=${leg_start_date_yyyy} ; y<=${leg_end_date_yyyy} ; y++ ))
  895. do
  896. yy=$(printf "%04d" $y)
  897. for m in {1..12}
  898. do
  899. mm=$(printf "%02d" $m)
  900. ${grib_set} -s dataDate=${yy}${mm}15 ${icmclfile}-${mm} ${tempfile}
  901. cat ${tempfile} >> ICMCL${exp_name}INIT
  902. done
  903. done
  904. # Create data for january, the year after the leg ends
  905. ${grib_set} \
  906. -s dataDate=$(printf "%04d" $((leg_end_date_yyyy+1)))0115 \
  907. ${icmclfile}-01 ${tempfile}
  908. cat ${tempfile} >> ICMCL${exp_name}INIT
  909. ;;
  910. "era20c"|"cmip6" )
  911. # Vegetation from a LPJG run (off-line or EC-Earth3-Veg)
  912. rm -f ICMCL${exp_name}INIT
  913. # Create data for all years of the leg, including one year
  914. # before and one year after
  915. for (( yr=leg_start_date_yyyy-1 ; yr<=leg_end_date_yyyy+1 ; yr+=1 ))
  916. do
  917. case ${ifs_veg_source} in
  918. 'era20c' )
  919. # no scenario needed with era20c
  920. icmcl_scenario="" ;;
  921. 'cmip6' )
  922. # select scenario, use SSP3-7.0 as default
  923. # if not otherwise specified
  924. icmcl_scenario="historical"
  925. if ( [ $ifs_cmip_fixyear -le 0 ] && [ $yr -ge 2015 ] ) || \
  926. [ $ifs_cmip_fixyear -ge 2015 ]
  927. then
  928. [[ ${ifs_cmip6_scenario} =~ ^SSP ]] \
  929. && icmcl_scenario=${ifs_cmip6_scenario} \
  930. || icmcl_scenario='SSP3-7.0'
  931. fi ;;
  932. esac
  933. if [ $ifs_cmip_fixyear -le 0 ]
  934. then
  935. cat ${ini_data_dir}/ifs/${ifs_grid}/icmcl_${veg_version}/${icmcl_scenario}/icmcl_$yr.grb >> ICMCL${exp_name}INIT
  936. else
  937. # Fixed year forcing, requires cdo!
  938. # If cdo is not available at runtime you need to fix proper
  939. # icmcl files beforehand and use them here
  940. cdo setyear,$yr ${ini_data_dir}/ifs/${ifs_grid}/icmcl_${veg_version}/${icmcl_scenario}/icmcl_${ifs_cmip_fixyear}.grb ${tempfile}
  941. cat ${tempfile} >> ICMCL${exp_name}INIT
  942. fi
  943. done
  944. ;;
  945. "none" )
  946. info "no ICMCL file is created"
  947. ;;
  948. * )
  949. error "Vegetation from ${ifs_veg_source} not implemented"
  950. ;;
  951. esac
  952. # Clean up
  953. rm -f ${tempfile}
  954. # -------------------------------------------------------------------------
  955. # *** Link the appropriate NEMO restart files of the previous leg
  956. # -------------------------------------------------------------------------
  957. if $leg_is_restart && $(has_config nemo)
  958. then
  959. ns=$(printf %08d $(( leg_start_sec / nem_time_step_sec - nem_restart_offset )))
  960. for (( n=0 ; n<nem_numproc ; n++ ))
  961. do
  962. np=$(printf %04d ${n})
  963. ln -fs ${exp_name}_${ns}_restart_oce_${np}.nc restart_oce_${np}.nc
  964. ln -fs ${exp_name}_${ns}_restart_ice_${np}.nc restart_ice_${np}.nc
  965. done
  966. # Make sure there are no global restart files
  967. # If links are found, they will be removed. We are cautious and do
  968. # _not_ remove real files! However, if real global restart files are
  969. # present, NEMO/LIM will stop because time stamps will not match.
  970. [ -h restart_oce.nc ] && rm restart_oce.nc
  971. [ -h restart_ice.nc ] && rm restart_ice.nc
  972. fi
  973. # -------------------------------------------------------------------------
  974. # *** Remove some OASIS files of the previous leg
  975. # -------------------------------------------------------------------------
  976. if $leg_is_restart
  977. then
  978. rm -f anaisout_*
  979. fi
  980. # -------------------------------------------------------------------------
  981. # *** Start the run
  982. # -------------------------------------------------------------------------
  983. export DR_HOOK_IGNORE_SIGNALS='-1'
  984. export CPLNG='active'
  985. # Use the launch function from the platform configuration file
  986. has_config nemo ifs && \
  987. cmd="${xio_numproc} ${xio_exe_file} -- \
  988. ${nem_numproc} ${nem_exe_file} -- \
  989. ${rnf_numproc} ${rnf_exe_file} -- \
  990. ${ifs_numproc} ${ifs_exe_file} -v ecmwf -e ${exp_name}" || \
  991. cmd="${ifs_numproc} ${ifs_exe_file} -v ecmwf -e ${exp_name}"
  992. has_config lpjg && cmd=${cmd}" -- ${lpjg_numproc} ${lpjg_exe_file} guess.ins -parallel"
  993. has_config tm5 && cmd=${cmd}" -- ${tm5_numproc} ${tm5_exe_file} tm5-run.rc"
  994. has_config amip && cmd=${cmd}" -- ${amip_numproc} ${amip_exe_file}"
  995. t1=$(date +%s)
  996. launch $cmd
  997. t2=$(date +%s)
  998. tr=$(date -d "0 -$t1 sec + $t2 sec" +%T)
  999. # -------------------------------------------------------------------------
  1000. # *** Check for signs of success
  1001. # Note the tests provide no guarantee that things went fine! They are
  1002. # just based on the IFS, NEMO and TM5 log files. More tests (e.g. checking
  1003. # restart files) could be implemented.
  1004. # -------------------------------------------------------------------------
  1005. # Checking for IFS success
  1006. if [ -f ifs.stat ]
  1007. then
  1008. if [ "$(awk 'END{print $3}' ifs.stat)" == "CNT0" ]
  1009. then
  1010. info "Leg successfully completed according to IFS log file 'ifs.stat'."
  1011. else
  1012. error "Leg not completed according to IFS log file 'ifs.stat'."
  1013. fi
  1014. else
  1015. error "IFS log file 'ifs.stat' not found after run."
  1016. fi
  1017. # Check for NEMO success
  1018. if $(has_config nemo)
  1019. then
  1020. if [ -f ocean.output ]
  1021. then
  1022. if [ "$(sed -n '/New day/h; ${g;s:.*\([0-9/]\{10\}\).*:\1:;p;}' ocean.output)" == "$(date -u -d "${leg_end_date} - 1 day" +%Y/%m/%d)" ]
  1023. then
  1024. info "Leg successfully completed according to NEMO log file 'ocean.output'."
  1025. else
  1026. error "Leg not completed according to NEMO log file 'ocean.output'."
  1027. fi
  1028. else
  1029. error "NEMO log file 'ocean.output' not found after run."
  1030. fi
  1031. fi
  1032. # Check for TM5 success
  1033. if $(has_config tm5)
  1034. then
  1035. if [ -f tm5.ok ]
  1036. then
  1037. info "Leg successfully completed according to existing TM5 file 'tm5.ok'."
  1038. else
  1039. error "Leg not completed according to non-existing TM5 file 'tm5.ok'."
  1040. fi
  1041. fi
  1042. # -------------------------------------------------------------------------
  1043. # *** Post-process initial conditions saved during the run if requested
  1044. # -------------------------------------------------------------------------
  1045. ${do_save_ic} && save_ic_postproc
  1046. # -------------------------------------------------------------------------
  1047. # *** Move IFS output files to archive directory
  1048. # -------------------------------------------------------------------------
  1049. outdir="output/ifs/$(printf %03d $((leg_number)))"
  1050. mkdir -p ${outdir}
  1051. prv_leg=$(printf %03d $((leg_number-1)))
  1052. # This takes care of a special IFS feature: The output for the last time
  1053. # step of each leg is written at the first time step of the new leg. The
  1054. # following code makes sure that the output is appended to the appropriate
  1055. # file. Since GRIB files are just streams, its done with a simple cat
  1056. # command.
  1057. for f in ICMSH${exp_name}+?????? ICMGG${exp_name}+??????
  1058. do
  1059. if [ -f output/ifs/${prv_leg}/${f} ]
  1060. then
  1061. cat ${f} >> output/ifs/${prv_leg}/${f}
  1062. rm -f ${f}
  1063. else
  1064. mv ${f} ${outdir}
  1065. fi
  1066. done
  1067. # -------------------------------------------------------------------------
  1068. # *** Move NEMO output files to archive directory
  1069. # -------------------------------------------------------------------------
  1070. if $(has_config nemo)
  1071. then
  1072. outdir="output/nemo/$(printf %03d $((leg_number)))"
  1073. mkdir -p ${outdir}
  1074. for v in grid_U grid_V grid_W grid_T icemod SBC scalar SBC_scalar diad_T \
  1075. grid_T_2D grid_U_2D grid_V_2D grid_W_2D grid_T_3D grid_U_3D grid_V_3D grid_W_3D \
  1076. grid_1point grid_T_3D_ncatice vert_sum \
  1077. grid_ptr_W_3basin_3D grid_ptr_T_3basin_2D grid_ptr_T_2D \
  1078. zoom_700_sum zoom_300_sum zoom_2000_sum
  1079. do
  1080. for f in ${exp_name}_*_????????_????????_*${v}.nc
  1081. do
  1082. test -f $f && mv $f $outdir/
  1083. done
  1084. done
  1085. fi
  1086. # -------------------------------------------------------------------------
  1087. # *** Move LPJ-GUESS output files to archive directory
  1088. # -------------------------------------------------------------------------
  1089. if $(has_config lpjg)
  1090. then
  1091. outdir="output/lpjg/$(printf %03d $((leg_number)))"
  1092. if [ -d ${outdir} ]
  1093. then
  1094. rm -rf ${outdir}
  1095. fi
  1096. mkdir -p ${outdir}
  1097. # LPJG run directories
  1098. # concatenate *.out files from each run* into output dir
  1099. flist=$(find ${run_dir}/run1/output -type f | sed "s%${run_dir}/run1/output\/%%")
  1100. mkdir ${outdir}/CMIP6
  1101. for (( n=1; n<=${lpjg_numproc}; n++ ))
  1102. do
  1103. for ofile in $flist
  1104. do
  1105. if (( n == 1 ))
  1106. then
  1107. cat ${run_dir}/run${n}/output/${ofile} > ${outdir}/$ofile
  1108. else
  1109. awk '(FNR!=1){print $0}' ${run_dir}/run${n}/output/${ofile} >> ${outdir}/$ofile
  1110. fi
  1111. done
  1112. rm -rf ${run_dir}/run${n}/output
  1113. done
  1114. # move monthly file if available
  1115. if [ -f ${run_dir}/LPJ-GUESS_monthlyoutput.txt ]
  1116. then
  1117. mv ${run_dir}/LPJ-GUESS_monthlyoutput.txt ${outdir}
  1118. fi
  1119. fi
  1120. # -------------------------------------------------------------------------
  1121. # *** Move TM5 output files to archive directory
  1122. # -------------------------------------------------------------------------
  1123. if $(has_config tm5)
  1124. then
  1125. outdir="output/tm5/$(printf %03d $((leg_number)))"
  1126. mkdir -p ${outdir}
  1127. set +e
  1128. mv budget_??????????_??????????_global.hdf ${outdir}
  1129. mv j_statistics_??????????_??????????.hdf ${outdir}
  1130. mv mmix_??????????_??????????_glb???x???.hdf ${outdir}
  1131. mv aerocom?_TM5_*_????????_daily.nc ${outdir}
  1132. mv aerocom?_TM5_*_??????_monthly.nc ${outdir}
  1133. mv AOD_????_??_??.nc ${outdir}
  1134. mv -f TM5MP_${exp_name}_griddef.nc ${outdir}
  1135. mv TM5MP_${exp_name}_TP_????_??_??.nc ${outdir}
  1136. mv TM5MP_${exp_name}_vmr3_????_??_??.nc ${outdir}
  1137. mv general_TM5_${exp_name}_??????????_hourly.nc ${outdir}
  1138. mv general_TM5_${exp_name}_??????_monthly.nc ${outdir}
  1139. set -e
  1140. # move profiling files if any
  1141. if [ "$(ls -A ${run_dir}/tm5_profile)" ]
  1142. then
  1143. outdir="output/tm5/profile_$(printf %03d $((leg_number)))"
  1144. mkdir -p ${outdir}
  1145. for f in ${run_dir}/tm5_profile/*
  1146. do
  1147. test -f ${f} && mv $f ${outdir}
  1148. done
  1149. fi
  1150. fi
  1151. # -------------------------------------------------------------------------
  1152. # *** Move IFS restart files to archive directory
  1153. # -------------------------------------------------------------------------
  1154. if $leg_is_restart
  1155. then
  1156. outdir="restart/ifs/$(printf %03d $((leg_number)))"
  1157. mkdir -p ${outdir}
  1158. # Figure out the time part of the restart files (cf. CTIME on rcf files)
  1159. # NOTE: Assuming that restarts are at full days (time=0000) only!
  1160. nd="$(printf %06d $((leg_start_sec/(24*3600))))0000"
  1161. mv srf${nd}.???? ${outdir}
  1162. fi
  1163. # -------------------------------------------------------------------------
  1164. # *** Move LPJ-GUESS restart files to archive directory
  1165. # -------------------------------------------------------------------------
  1166. if $(has_config lpjg)
  1167. then
  1168. outdir="restart/lpjg/$(printf %03d $((leg_number)))"
  1169. if [ -d ${outdir} ]
  1170. then
  1171. rm -rf ${outdir}
  1172. fi
  1173. mkdir -p ${outdir}
  1174. state_dir="./lpjg_state_$(printf %04d $((leg_end_date_yyyy)))"
  1175. mv ${state_dir} ${outdir}
  1176. # LPJG writes into run1 dir, so mv to main rundir
  1177. mv -f run1/lpjgv.nc .
  1178. # remove restart link
  1179. if $leg_is_restart
  1180. then
  1181. old_state_dir="./lpjg_state_$(printf %04d $((leg_start_date_yyyy)))"
  1182. if [ -L $old_state_dir ]
  1183. then
  1184. rm -f "$old_state_dir"
  1185. fi
  1186. fi
  1187. fi
  1188. # -------------------------------------------------------------------------
  1189. # *** Move NEMO restart files to archive directory
  1190. # -------------------------------------------------------------------------
  1191. if $leg_is_restart && $(has_config nemo)
  1192. then
  1193. outdir="restart/nemo/$(printf %03d $((leg_number)))"
  1194. mkdir -p ${outdir}
  1195. ns=$(printf %08d $(( leg_start_sec / nem_time_step_sec - nem_restart_offset )))
  1196. for f in oce ice
  1197. do
  1198. mv ${exp_name}_${ns}_restart_${f}_????.nc ${outdir}
  1199. done
  1200. fi
  1201. # -------------------------------------------------------------------------
  1202. # *** Move TM5 restart file to archive directory
  1203. # -------------------------------------------------------------------------
  1204. if $leg_is_restart && $(has_config tm5)
  1205. then
  1206. outdir="restart/tm5"
  1207. mkdir -p ${outdir}
  1208. case ${tm5_istart} in
  1209. 33) f=TM5_restart_${leg_start_date_yyyymmdd}_0000_glb300x200.nc
  1210. ;;
  1211. 31) f=save_${leg_start_date_yyyymmdd}00_glb300x200.hdf
  1212. ;;
  1213. esac
  1214. mv $f ${outdir}
  1215. fi
  1216. # -------------------------------------------------------------------------
  1217. # *** Copy OASIS restart files to archive directory
  1218. # NOTE: These files are copied and not moved as they are used in the
  1219. # next leg!
  1220. # Note also that the OASIS restart files present at the end of
  1221. # the leg correspond to the start of the next leg!
  1222. # -------------------------------------------------------------------------
  1223. outdir="restart/oasis/$(printf %03d $((leg_number+1)))"
  1224. mkdir -p ${outdir}
  1225. for f in ${oas_rst_ifs_nemo} ${oas_rst_ifs_tm5} vegin.nc lpjgv.nc
  1226. do
  1227. test -f ${f} && cp ${f} ${outdir}
  1228. done
  1229. # -------------------------------------------------------------------------
  1230. # *** Copy rcf files to the archive directory (of the next leg!)
  1231. # -------------------------------------------------------------------------
  1232. outdir="restart/ifs/$(printf %03d $((leg_number+1)))"
  1233. mkdir -p ${outdir}
  1234. for f in rcf
  1235. do
  1236. test -f ${f} && cp ${f} ${outdir}
  1237. done
  1238. # -------------------------------------------------------------------------
  1239. # *** Move log files to archive directory
  1240. # -------------------------------------------------------------------------
  1241. outdir="log/$(printf %03d $((leg_number)))"
  1242. mkdir -p ${outdir}
  1243. for f in \
  1244. ifs.log ifs.stat fort.4 ocean.output \
  1245. time.step solver.stat guess.log run1/guess0.log \
  1246. amip.log namelist.amip \
  1247. nout.000000 debug.??.?????? A*_??.nc O*_??.nc \
  1248. ctm.tm5.log.0
  1249. do
  1250. test -f ${f} && mv ${f} ${outdir}
  1251. done
  1252. for f in ctm.tm5.log.*
  1253. do
  1254. test -f ${f} && \rm -f ${f}
  1255. done
  1256. # -------------------------------------------------------------------------
  1257. # *** Write the restart control file
  1258. # -------------------------------------------------------------------------
  1259. # Compute CPMIP performance
  1260. sypd="$(cpmip_sypd $leg_length_sec $(($t2 - $t1)))"
  1261. ncores=0
  1262. has_config nemo && (( ncores+=${nem_numproc} )) || :
  1263. has_config ifs && (( ncores+=${ifs_numproc} )) || :
  1264. has_config xios && (( ncores+=${xio_numproc} )) || :
  1265. has_config rnfmapper && (( ncores+=${rnf_numproc} )) || :
  1266. has_config lpjg && (( ncores+=${lpjg_numproc} )) || :
  1267. has_config tm5 && (( ncores+=${tm5_numproc} )) || :
  1268. has_config amip && (( ncores+=${amip_numproc} )) || :
  1269. chpsy="$(cpmip_chpsy $leg_length_sec $(($t2 - $t1)) $ncores)"
  1270. echo "#" | tee -a ${ece_info_file}
  1271. echo "# Finished leg at `date '+%F %T'` after ${tr} (hh:mm:ss)" \
  1272. | tee -a ${ece_info_file}
  1273. echo "# CPMIP performance: $sypd SYPD $chpsy CHPSY"| tee -a ${ece_info_file}
  1274. echo "leg_number=${leg_number}" | tee -a ${ece_info_file}
  1275. echo "leg_start_date=\"${leg_start_date}\"" | tee -a ${ece_info_file}
  1276. echo "leg_end_date=\"${leg_end_date}\"" | tee -a ${ece_info_file}
  1277. # Need to reset force_run_from_scratch in order to avoid destroying the next leg
  1278. force_run_from_scratch=false
  1279. done # loop over legs
  1280. # -----------------------------------------------------------------------------
  1281. # *** Platform dependent finalising of the run
  1282. # -----------------------------------------------------------------------------
  1283. finalise
  1284. exit 0