ece-esm.sh.tmpl 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902
  1. # librunscript defines some helper functions
  2. . ${start_dir}/librunscript.sh
  3. # =============================================================================
  4. # *** BEGIN User configuration
  5. # =============================================================================
  6. # -----------------------------------------------------------------------------
  7. # *** General configuration
  8. # -----------------------------------------------------------------------------
  9. # Component configuration (for syntax of the $config variable, see librunscript.sh)
  10. #
  11. # Currently maintained:
  12. # config="ifs amip oasis" # "GCM forced-SST" : IFS + AMIP
  13. # config="ifs amip oasis lpjg:fdbck" # "Veg" : forced-GCM + LPJ-Guess
  14. # config="ifs amip oasis tm5:chem,o3fb,ch4fb,aerfb" # "AerChem" : forced-GCM + TM5
  15. #
  16. # config="ifs nemo lim3 rnfmapper xios:detached oasis" # "GCM" : IFS+NEMO
  17. # config="ifs nemo lim3 rnfmapper xios:detached oasis lpjg:fdbck" # "Veg" : GCM+LPJ-Guess
  18. # config="ifs nemo lim3 rnfmapper xios:detached oasis pisces lpjg:fdbck tm5:co2,co2fb" # "C-cycle" : GCM+LPJG+TM5
  19. # config="ifs nemo lim3 rnfmapper xios:detached oasis tm5:chem,o3fb,ch4fb,aerfb" # "AerChem" : GCM+TM5
  20. #
  21. # config="ifs nemo pisces lim3 rnfmapper xios:detached oasis" # "GCM" : IFS+NEMO+PISCES
  22. #
  23. config="ifs nemo lim3 rnfmapper xios:detached oasis"
  24. # minimum sanity
  25. has_config amip nemo && error "Cannot have both nemo and amip in config!!"
  26. ! has_config ifs && error "The ESM script requires ifs in config"
  27. # Experiment name (exactly 4 letters!)
  28. export exp_name=[[[MOD:GENERAL:EXP_NAME]]]
  29. # Simulation start and end date. Use any (reasonable) syntax you want.
  30. run_start_date="[[[MOD:GENERAL:RUN_START_DATE]]]"
  31. run_end_date="[[[MOD:GENERAL:RUN_END_DATE]]]"
  32. # Set $force_run_from_scratch to 'true' if you want to force this run to start
  33. # from scratch, possibly ignoring any restart files present in the run
  34. # directory. Leave set to 'false' otherwise.
  35. # NOTE: If set to 'true' the run directory $run_dir is cleaned!
  36. force_run_from_scratch=[[[MOD:GENERAL:FORCE_RUN_FROM_SCRATCH]]]
  37. special_restart=false
  38. special_restart_from=ECE3
  39. special_restart_date="1995-01-01"
  40. # Resolution (TM5 resolution is set at compilation)
  41. ifs_grid=[[[MOD:IFS:GRID]]]
  42. nem_grid=[[[MOD:NEM:GRID]]]
  43. # Restart frequency. Use any (reasonable) number and time unit you want.
  44. # For runs without restart, leave this variable empty
  45. rst_freq="[[[MOD:GENERAL:RST_FREQ]]]"
  46. # Number of restart legs to be run in one go
  47. run_num_legs=[[[MOD:GENERAL:RUN_NUM_LEGS]]]
  48. # Coupling frequencies
  49. has_config ifs tm5 && cpl_freq_atm_ctm_hrs=[[[MOD:OASIS:CPL_FREQ_ATM_CHE_HRS]]]
  50. has_config ifs lpjg && cpl_freq_atm_lpjg_hrs=[[[MOD:OASIS:CPL_FREQ_ATM_LPJG_HRS]]]
  51. # Don't change the coupling frequency because UPDCLIE (where SST and SIC
  52. # are updated) is called every 24 hours (hardcoded in ifs-36r4/src/ifs/utility/updtim.F90)
  53. has_config amip && cpl_freq_amip_sec=86400
  54. # Directories
  55. #start_dir=${PWD}
  56. ctrl_file_dir=${start_dir}/ctrl
  57. output_control_files_dir=${start_dir}/[[[MOD:GENERAL:OUTPUT_CONTROL_FILES_DIR]]]
  58. # Architecture
  59. build_arch=[[[PLT:ACTIVE:BUILD_ARCH]]]
  60. use_machinefile=[[[PLT:ACTIVE:USE_MACHINEFILE]]]
  61. # This file is used to store information about restarts
  62. ece_info_file="ece.info"
  63. # -----------------------------------------------------------------------------
  64. # *** Read platform dependent configuration
  65. # -----------------------------------------------------------------------------
  66. . ${start_dir}/ecconf.cfg
  67. configure
  68. # -----------------------------------------------------------------------------
  69. # *** Time step settings
  70. # -----------------------------------------------------------------------------
  71. if has_config ifs
  72. then
  73. case "${ifs_grid}" in
  74. T159L*) ifs_time_step_sec=3600 ;;
  75. T255L*) ifs_time_step_sec=2700 ;;
  76. T511L*) ifs_time_step_sec=900 ;;
  77. *) error "Can't set time steps for unknown horizontal grid: ${ifs_grid}"
  78. ;;
  79. esac
  80. fi
  81. if has_config nemo
  82. then
  83. case "${nem_grid}" in
  84. ORCA1L*) nem_time_step_sec=2700; lim_time_step_sec=2700 ;;
  85. ORCA025L*) nem_time_step_sec=900 ; lim_time_step_sec=900 ;;
  86. *) error "Can't set time steps for unknown horizontal grid: ${nem_grid}"
  87. ;;
  88. esac
  89. fi
  90. if has_config ifs nemo
  91. then
  92. case "${ifs_grid}--${nem_grid}" in
  93. T159L*--ORCA1L*)
  94. ifs_time_step_sec=3600; nem_time_step_sec=2700; lim_time_step_sec=2700; cpl_freq_atm_oce_sec=10800
  95. ;;
  96. T255L*--ORCA1L*)
  97. ifs_time_step_sec=2700; nem_time_step_sec=2700; lim_time_step_sec=2700; cpl_freq_atm_oce_sec=2700
  98. ;;
  99. T511L*--ORCA025L*)
  100. ifs_time_step_sec=900 ; nem_time_step_sec=900 ; lim_time_step_sec=900 ; cpl_freq_atm_oce_sec=2700
  101. ;;
  102. *) error "Can't set time steps for unknown combination of horizontal grids: ${ifs_grid}-${nem_grid}"
  103. ;;
  104. esac
  105. fi
  106. # -----------------------------------------------------------------------------
  107. # *** IFS configuration
  108. # -----------------------------------------------------------------------------
  109. ifs_version=36r4
  110. ifs_di_freq=$(( 24 * 3600 / ifs_time_step_sec ))
  111. ifs_ddh_freq=$(( 120 * 3600 / ifs_time_step_sec ))
  112. export ifs_res_hor=$(echo ${ifs_grid} | sed 's:T\([0-9]\+\)L\([0-9]\+\):\1:')
  113. ifs_res_ver=$(echo ${ifs_grid} | sed 's:T\([0-9]\+\)L\([0-9]\+\):\2:')
  114. ifs_numproc=[[[MOD:IFS:NUMPROC]]]
  115. ifs_exe_file=${ecearth_src_dir}/ifs-${ifs_version}/bin/ifsmaster-${build_arch}
  116. ifs_lastout=false
  117. ifs_cmip5=[[[MOD:IFS:CMIP5]]]
  118. ifs_cmip5_rcp=[[[MOD:IFS:CMIP5_RCP]]]
  119. export ifs_cmip_fixyear=[[[MOD:IFS:CMIP_FIXYEAR]]]
  120. export ifs_cmip_fixyear_ch4=[[[MOD:IFS:CMIP_FIXYEAR_CH4]]]
  121. # Repeat trap from ifs/suecrad.F90 for early catch
  122. if ! has_config tm5:ch4fb && (( $ifs_cmip_fixyear != $ifs_cmip_fixyear_ch4 ))
  123. then
  124. error 'CH4 in IFS is not provided by TM5, NCMIPFIXYR_CH4 should be set equal to NCMIPFIXYR'
  125. fi
  126. ifs_cmip6=[[[MOD:IFS:CMIP6]]]
  127. ifs_mac2sp=[[[MOD:IFS:CMIP6]]]
  128. ifs_cmip6piaer=[[[MOD:IFS:CMIP6]]]
  129. ifs_cmip6_scenario=[[[MOD:IFS:CMIP6_SCENARIO]]]
  130. # Enable optional COVID-19 scenarios, will enforce ifs_cmip6_scenario=SSP2-4.5
  131. ifs_covid19=FALSE
  132. # Choose one scenario : Base TwoYearBlip ModerateGreen StrongGreen FossilFuel
  133. ifs_covid19scen=Base
  134. # Basic sanity checks
  135. if [ ${ifs_covid19} == TRUE ] ; then
  136. [ ${ifs_cmip6_scenario} != SSP2-4.5 ] && echo "*WARNING* with ifs_covid19=TRUE IFS uses ifs_cmip6_scenario=SSP2-4.5 not ${ifs_cmip6_scenario}"
  137. has_config any lpjg pisces tm5 && error "ifs_covid19=TRUE is not supported with LPJ-GUESS, PISCES nor TM5"
  138. fi
  139. lcmip6_strataer_simp=FALSE
  140. lcmip6_strataer_full=[[[MOD:IFS:CMIP6]]]
  141. lcmip6_strataer_bckgd=FALSE
  142. export ifs_A4xCO2=[[[MOD:IFS:CMIP6_A4xCO2]]]
  143. export ifs_1PCTCO2=[[[MOD:IFS:CMIP6_1PCTCO2]]]
  144. export bgc_1PCTCO2=[[[MOD:IFS:CMIP6_1PCTCO2_BGC]]]
  145. # Time-varying orbital forcing (Qiong Zhang, SU-2013-09)
  146. # https://dev.ec-earth.org/projects/ecearth3/wiki/Orbital_forcing_in_EC-Earth_3
  147. #
  148. # ifs_orb_switch=false, no orbital calculations applied
  149. # ifs_orb_switch=true, use orbital calculations according to ifs_orb_mode
  150. # ifs_orb_mode="fixed_year", or "variable_year", or "fixed_parameters"
  151. # fixed_year: calculate the orbital parameters at ifs_orb_iyear, e.g.,1850
  152. # variable_year: calculate orbital parameters annually start from ifs_orb_iyear
  153. # fixed_parameters: prescribe orbital parameters for given year
  154. case "${ifs_grid}" in
  155. T159*) ifs_orb_switch=true ;;
  156. *) ifs_orb_switch=false ;;
  157. esac
  158. ifs_orb_mode="variable_year"
  159. ifs_orb_iyear=$(date -u -d "${run_start_date}" +%Y)
  160. # Relaxation of soil moisture (Wilhelm May, LU; October 2017)
  161. #
  162. # LRXSM: Parameter indicating the levels to be nudged
  163. #
  164. # LRXSM = 0: no nudging
  165. # LRXSM = 12: 4xdaily data and 3 levels (excluding level 1)
  166. # LRXSM = 13: 4xdaily data and 4 levels
  167. #
  168. # LRXSMTx: time scale of the relaxation for level X (in hours)
  169. #
  170. # LRXSMTx = 0: actual values relpaced by external ones
  171. # LRXSMTx = 24: 1 day
  172. # LRXSMTx = 120: 5 days
  173. #
  174. # LRXSMS: indicates when the relaxation is done
  175. #
  176. # LRXSMS = 0: before the time step
  177. # LRXSMS = 1: after the time step
  178. #
  179. has_config soilnudg && ifs_lrxsm=13 || ifs_lrxsm=0
  180. ifs_lrxsmt1=96
  181. ifs_lrxsmt2=72
  182. ifs_lrxsmt3=48
  183. ifs_lrxsmt4=24
  184. ifs_lrxsms=1
  185. # IFS tuning parameters
  186. variant=
  187. has_config tm5:chem && variant=-AerChem
  188. ifs_tuning_parameter_file=${ctrl_file_dir}/ifs-tuning-parameters-${ifs_grid}${variant}.sh
  189. if [ -f ${ifs_tuning_parameter_file} ]
  190. then
  191. source ${ifs_tuning_parameter_file}
  192. else
  193. error "Sorry, ${ifs_tuning_parameter_file} not found, exiting."
  194. fi
  195. # Select source of vegetation data:
  196. # ifs climatology from IFS
  197. # era20c vegetation from an off-line LPJ-Guess run forced with ERA20C
  198. # (currently available only for T255 and T159)
  199. # cmip6 vegetation from an EC-Earth3-Veg (interactive LPJ-Guess) run
  200. # (currently available only for T255)
  201. # custom_exp vegetation from any EC-Earth3-Veg run exp
  202. # (must contain same variables as era20c & cmip6 and located in icmcl_exp folder)
  203. # none don't create an ICMCL file with vegetation data (this is set
  204. # automatically if LPJG is used with feedback)
  205. #
  206. ifs_veg_source="cmip6"
  207. has_config lpjg:fdbck && ifs_veg_source="none"
  208. case ${ifs_veg_source} in
  209. "ifs" )
  210. # Use Lambert-Beer to compute effective vegetation cover
  211. n_compute_eff_veg_fraction=2
  212. ;;
  213. "era20c" )
  214. # LPJG vegetation is provided as effective cover
  215. # Don't use Lambert-Beer
  216. n_compute_eff_veg_fraction=0
  217. case "${ifs_grid}" in
  218. T159L*) veg_version=v29 ;;
  219. T255L*) veg_version=v16 ;;
  220. *) error "Vegetation from off-line LPJ-Guess not available for ${ifs_grid}" ;;
  221. esac
  222. ;;
  223. "cmip6" )
  224. # LPJG vegetation is provided as effective cover
  225. # Don't use Lambert-Beer
  226. n_compute_eff_veg_fraction=0
  227. case "${ifs_grid}" in
  228. T255L*) veg_version=v32 ;;
  229. *) error "Vegetation from CMIP6 EC-Earth3-Veg not available for ${ifs_grid}" ;;
  230. esac
  231. ;;
  232. "custom_"* )
  233. # LPJG vegetation is provided as effective cover
  234. # Don't use Lambert-Beer
  235. n_compute_eff_veg_fraction=0
  236. veg_version=${ifs_veg_source:7}
  237. if [ ! -d ${ini_data_dir}/ifs/${ifs_grid}/icmcl_${veg_version} ]
  238. then
  239. error "requested IFS_VEG_SOURCE = ${ifs_veg_source} but not found in ${ini_data_dir}/ifs/${ifs_grid}/icmcl_${veg_version}"
  240. fi
  241. ;;
  242. "none" )
  243. # LPJG with feedback
  244. n_compute_eff_veg_fraction=0
  245. ! has_config lpjg:fdbck && error "IFS requires an offline source of vegetation"
  246. ;;
  247. * )
  248. error "Vegetation from ${ifs_veg_source} not implemented"
  249. ;;
  250. esac
  251. # use DMI land ice physics and varying snow albedo
  252. case "${ifs_grid}" in
  253. T159*) ifs_landice=true ;;
  254. *) ifs_landice=false ;;
  255. esac
  256. # -----------------------------------------------------------------------------
  257. # *** NEMO/LIM configuration
  258. # -----------------------------------------------------------------------------
  259. # This is only needed if the experiment is started from an existing set of NEMO
  260. # restart files
  261. nem_restart_file_path=${start_dir}/nemo-rst
  262. nem_restart_offset=0
  263. nem_res_hor=$(echo ${nem_grid} | sed 's:ORCA\([0-9]\+\)L[0-9]\+:\1:')
  264. nem_config=${nem_grid}
  265. has_config lim3 && nem_config=${nem_config}_LIM3
  266. if has_config pisces tm5:co2
  267. then
  268. nem_config=${nem_config}_CarbonCycle
  269. elif has_config pisces
  270. then
  271. nem_config=${nem_config}_PISCES
  272. fi
  273. # TODO - nemo standalone configs are not accounted for in this script, but this would set the required nem_config
  274. ! has_config ifs && nem_config=${nem_config}_standalone
  275. nem_exe_file=${ecearth_src_dir}/nemo-3.6/CONFIG/${nem_config}/BLD/bin/nemo.exe
  276. nem_numproc=[[[MOD:NEM:NUMPROC]]]
  277. # Thermal conductivity of snow, see comment in ctrl/namelist.lim3.ref.sh
  278. case "${ifs_grid}" in
  279. T159L* ) nem_rn_cdsn=0.25 ;;
  280. * ) nem_rn_cdsn=0.27 ;;
  281. esac
  282. # -----------------------------------------------------------------------------
  283. # *** Runoff mapper configuration
  284. # -----------------------------------------------------------------------------
  285. rnf_exe_file=${ecearth_src_dir}/runoff-mapper/bin/runoff-mapper.exe
  286. rnf_numproc=1
  287. # -----------------------------------------------------------------------------
  288. # *** LPJ-GUESS configuration
  289. # -----------------------------------------------------------------------------
  290. lpjg_time_step_sec=[[[MOD:LPJG:TIME_STEP_SEC]]]
  291. lpjg_numproc=[[[MOD:LPJG:NUMPROC]]]
  292. has_config lpjg && lpjg_on=1
  293. has_config lpjg:fdbck && lpjg_fdbck=1
  294. has_config tm5:co2 && lpjg_fdbck_tm5=1 || lpjg_fdbck_tm5=0
  295. export lpjg_fixNdepafter=[[[MOD:LPJG:LPJG_FIXNDEPAFTER]]]
  296. export lpjg_fixLUafter=[[[MOD:LPJG:LPJG_FIXLUAFTER]]]
  297. info '!!!! CMIP FIX YEAR SETTINGS:'
  298. info "ifs_cmip_fixyear: $ifs_cmip_fixyear"
  299. info "lpjg_fixNDepAfter: $lpjg_fixNdepafter"
  300. info "lpjg_fixLUAfter: $lpjg_fixLUafter"
  301. info '!!!!'
  302. lpjg_res=T${ifs_res_hor}
  303. lpjg_exe_file=${ecearth_src_dir}/lpjg/build/guess_${lpjg_res}
  304. # -----------------------------------------------------------------------------
  305. # *** AMIP-reader configuration
  306. # -----------------------------------------------------------------------------
  307. amip_exe_file=${ecearth_src_dir}/amip-forcing/bin/amip-forcing.exe
  308. amip_numproc=1
  309. # -----------------------------------------------------------------------------
  310. # *** TM5 configuration
  311. # -----------------------------------------------------------------------------
  312. if $(has_config tm5)
  313. then
  314. # With TM5, NPRTRV is set to 1 in the namelist. To avoid some out-of-bound
  315. # arrays in IFS, we must limit the number of cores for IFS
  316. if (( ifs_numproc > (ifs_res_hor+1) ))
  317. then
  318. error "too much cores requested for IFS, max is $((ifs_res_hor+1))"
  319. fi
  320. # TM5 settings
  321. has_config tm5:co2 && tmversion="co2" || tmversion="cb05"
  322. has_config tm5:co2 && export tm5_co2=1 || export tm5_co2=0
  323. export tm5_exch_nlevs=[[[MOD:TM5:NLEVS]]]
  324. tm5_time_step_sec=[[[MOD:TM5:TIME_STEP_SEC]]]
  325. export tm5_numproc_x=[[[MOD:TM5:NUMPROC_X]]]
  326. export tm5_numproc_y=[[[MOD:TM5:NUMPROC_Y]]]
  327. tm5_numproc=$(( tm5_numproc_x * tm5_numproc_y ))
  328. export tm5_emiss_fixyear=[[[MOD:TM5:EMISS_FIXYEAR]]]
  329. # limited number of levels for feedback (aerosols, currently set to lmax_conv in TM5)
  330. case ${tm5_exch_nlevs} in
  331. 34) export tm5_exch_nlevs_cutoff=23 ;;
  332. 10) export tm5_exch_nlevs_cutoff=10 ;;
  333. 4) export tm5_exch_nlevs_cutoff=4 ;;
  334. *) error "not supported number of levels for TM5"
  335. esac
  336. # executable
  337. tm5_exe_file=${ecearth_src_dir}/tm5mp/build-${tmversion}-ml${tm5_exch_nlevs}/appl-tm5-${tmversion}.x
  338. # path to initial conditions, modify as needed
  339. tm5_restart_file_path=${ini_data_dir}/tm5/restart/${tmversion}-ml${tm5_exch_nlevs}
  340. # fields sent back to IFS
  341. has_config tm5:o3fb && tm5_to_ifs=O3 || tm5_to_ifs=
  342. has_config tm5:ch4fb && tm5_to_ifs=${tm5_to_ifs},CH4
  343. has_config tm5:aerfb && tm5_to_ifs=${tm5_to_ifs},"\
  344. N2,SU2,BC2,OC2,N3,SU3,BC3,OC3,SS3,DU3,\
  345. N4,SU4,BC4,OC4,SS4,DU4,N5,BC5,OC5,N6,DU6,N7,DU7,\
  346. NO3,MSA,\
  347. 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,\
  348. 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,\
  349. 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"
  350. has_config tm5:co2fb && tm5_to_ifs=${tm5_to_ifs},CO2
  351. export tm5_to_ifs=$(echo ${tm5_to_ifs} | sed "s/^,//")
  352. # coupled to LPJ-Guess and/or PISCES?
  353. has_config tm5:co2 lpjg && export cpl_tm_guess=T || export cpl_tm_guess=F
  354. has_config tm5:co2 pisces && export cpl_tm_pisces=T || export cpl_tm_pisces=F
  355. fi
  356. # -----------------------------------------------------------------------------
  357. # *** OASIS configuration
  358. # -----------------------------------------------------------------------------
  359. # Restart files for the coupling fields (note 8 character limit in OASIS)
  360. # rstas.nc : atmosphere single-category fields
  361. # rstam.nc : atmosphere multi-category fields
  362. # rstos.nc : ocean single-category fields
  363. # rstom.nc : ocean multi-category fields
  364. oas_rst_ifs_nemo="rstas.nc rstos.nc"
  365. oas_rst_ifs_lpjg="vegin.nc lpjgv.nc"
  366. # Met fields from IFS to TM (always required)
  367. oas_rst_ifs_tm5="r_hum.nc r_g2d.nc r_udr.nc r_div.nc r_vor.nc \
  368. r_ddr.nc r_tmp.nc r_dmf.nc r_s2d.nc r_umf.nc"
  369. has_config tm5:chem && \
  370. oas_rst_ifs_tm5=${oas_rst_ifs_tm5}' r_cc_.nc r_clw.nc r_cco.nc r_ciw.nc r_ccu.nc'
  371. has_config tm5:o3fb || has_config tm5:ch4fb && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' o3ch4.nc'
  372. has_config tm5:aerfb && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' C???????'
  373. # C-cycle configuration
  374. has_config tm5:co2 lpjg && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' l_co2.nc rlpjg.nc'
  375. has_config tm5:co2 pisces && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' o_co2.nc pisce.nc'
  376. has_config tm5:co2fb && oas_rst_ifs_tm5=$oas_rst_ifs_tm5' co2mx.nc'
  377. # final list of files depends on the activated components - this is used in save_ic as well
  378. #oas_rst_files="${oas_rst_ifs_nemo} ${oas_rst_ifs_tm5} vegin.nc lpjgv.nc"
  379. oas_rst_files=""
  380. has_config ifs nemo && oas_rst_files+=" ${oas_rst_ifs_nemo}"
  381. has_config ifs lpjg && oas_rst_files+=" ${oas_rst_ifs_lpjg}"
  382. has_config ifs tm5 && oas_rst_files+=" ${oas_rst_ifs_tm5}"
  383. # Decide whether the OASIS weight files for interpolation should be linked from
  384. # the setup directory (true) or not (false). In the latter case, the weights
  385. # are re-computed at the start of the run.
  386. oas_link_weights=true
  387. # Flux correction for runoff (not calving) sent from Oasis to ocean.
  388. # 1.07945 is computed to compensate for a P-E=-0.016 mm/day (valid for std res)
  389. case "${ifs_grid}" in
  390. T159L* ) has_config nemo && oas_mb_fluxcorr=1.08652 ;;
  391. * ) has_config nemo && oas_mb_fluxcorr=1.07945 ;;
  392. esac
  393. # -----------------------------------------------------------------------------
  394. # *** XIOS configuration
  395. # -----------------------------------------------------------------------------
  396. xio_exe_file=${ecearth_src_dir}/xios-2.5/bin/xios_server.exe
  397. xio_numproc=[[[MOD:XIO:NUMPROC]]]
  398. # -----------------------------------------------------------------------------
  399. # *** Extra initial conditions saved during the run
  400. # -----------------------------------------------------------------------------
  401. if has_config save_ic
  402. then
  403. source ./libsave_ic.sh
  404. declare -a save_ic_date save_ic_date1 save_ic_sec save_ic_day save_ic_ppt_file save_ic_nemo_ts
  405. oas_rst_files="${oas_rst_ifs_nemo} ${oas_rst_ifs_tm5} vegin.nc lpjgv.nc"
  406. fi
  407. # -----------------------------------------------------------------------------
  408. # *** Carbon cycle configuration
  409. # -----------------------------------------------------------------------------
  410. # set to true to write co2 fluxes sent to TM5
  411. ccycle_debug_fluxes=true
  412. # =============================================================================
  413. # *** END of User configuration
  414. # =============================================================================
  415. # =============================================================================
  416. # *** This is where the code begins ...
  417. # =============================================================================
  418. # -----------------------------------------------------------------------------
  419. # *** Create the run dir if necessary and go there
  420. # Everything is done from here.
  421. # -----------------------------------------------------------------------------
  422. if [ ! -d ${run_dir} ]
  423. then
  424. mkdir -p ${run_dir}
  425. if $special_restart
  426. then
  427. force_run_from_scratch=false
  428. rsync -av --delete ${run_dir}/../${special_restart_from}/ --exclude log --exclude output --exclude restart --exclude="${special_restart_from}_*" --exclude="srf*" --exclude="restart_*" --exclude="debug.*" --exclude="output.*" ${run_dir}
  429. cp -f ${nem_exe_file} ${run_dir}
  430. cp -f ${ifs_exe_file} ${run_dir}
  431. cp -f ${rnf_exe_file} ${run_dir}
  432. cp -f ${xio_exe_file} ${run_dir}
  433. special_year=${special_restart_date:0:4}
  434. sed -i "/$special_year/q" ${run_dir}/ece.info
  435. . ${run_dir}/ece.info
  436. special_restart_leg=$(printf %03d $((leg_number+1)))
  437. special_restart_leg_oasis=$(printf %03d $((leg_number+2)))
  438. # PUT HERE THE INSTRUCTIONS TO COPY THE restart files
  439. rsync -av ${run_dir}/../../archive/${special_restart_from}/restart/ifs/${special_restart_leg}/ ${run_dir}
  440. rsync -av ${run_dir}/../../archive/${special_restart_from}/restart/oasis/${special_restart_leg_oasis}/ ${run_dir}
  441. cd ${run_dir}/../../archive/${special_restart_from}/restart/nemo/${special_restart_leg}
  442. for f in *.nc; do
  443. nf=${exp_name}${f:4}
  444. cp $f ${run_dir}/$nf
  445. done
  446. cd -
  447. cd ${run_dir}
  448. for f in ${exp_name}_????????_restart_???_????.nc; do
  449. nf=${f:14}
  450. ln -s $f $nf
  451. done
  452. cd -
  453. rm -f ${run_dir}/ICMCL${special_restart_from}INIT
  454. mv ${run_dir}/ICMGG${special_restart_from}INIUA ${run_dir}/ICMGG${exp_name}INIUA
  455. mv ${run_dir}/ICMGG${special_restart_from}INIT ${run_dir}/ICMGG${exp_name}INIT
  456. mv ${run_dir}/ICMSH${special_restart_from}INIT ${run_dir}/ICMSH${exp_name}INIT
  457. fi
  458. else
  459. force_run_from_scratch=false
  460. special_restart=false
  461. fi
  462. cd ${run_dir}
  463. # -----------------------------------------------------------------------------
  464. # *** Determine the time span of this run and whether it's a restart leg
  465. # -----------------------------------------------------------------------------
  466. # Regularise the format of the start and end date of the simulation
  467. run_start_date=$(date -uR -d "${run_start_date}")
  468. run_end_date=$(date -uR -d "${run_end_date}")
  469. # -----------------------------------------------------------------------------
  470. # *** Set path to grib_set
  471. # -----------------------------------------------------------------------------
  472. grib_set=${GRIB_BIN_PATH}${GRIB_BIN_PATH:+/}grib_set
  473. # Loop over the number of legs
  474. for (( ; run_num_legs>0 ; run_num_legs-- ))
  475. do
  476. # Check for restart information file and set the current leg start date
  477. # Ignore restart information file if force_run_from_scratch is true
  478. if ${force_run_from_scratch} || ! [ -r ${ece_info_file} ]
  479. then
  480. leg_is_restart=false
  481. leg_start_date=${run_start_date}
  482. leg_number=1
  483. else
  484. leg_is_restart=true
  485. . ./${ece_info_file}
  486. leg_start_date=${leg_end_date}
  487. leg_number=$((leg_number+1))
  488. fi
  489. # Compute the end date of the current leg
  490. if [ -n "${rst_freq}" ]
  491. then
  492. leg_end_date=$(date -uR -d "${leg_start_date} + ${rst_freq}")
  493. else
  494. leg_end_date=${run_end_date}
  495. fi
  496. # Check if legs are integer multiples of full years if LPJG is used
  497. if has_config lpjg
  498. then
  499. if [[ $(date +%m%d%T -u -d "${leg_start_date}") != "010100:00:00" || \
  500. $(date +%m%d%T -u -d "${leg_start_date} + ${rst_freq}") != "010100:00:00" ]]
  501. then
  502. error "LPJ-GUESS runs must start on Jan 1 and end on Dec 31. Multi-year legs are allowed."
  503. fi
  504. fi
  505. if [ $(date -u -d "${leg_end_date}" +%s) -ge $(date -u -d "${run_end_date}" +%s) ]
  506. then
  507. leg_end_date=${run_end_date}
  508. ifs_lastout=true
  509. fi
  510. # Some time variables needed later
  511. leg_length_sec=$(( $(date -u -d "${leg_end_date}" +%s) - $(date -u -d "${leg_start_date}" +%s) ))
  512. leg_start_sec=$(( $(date -u -d "${leg_start_date}" +%s) - $(date -u -d "${run_start_date}" +%s) ))
  513. leg_end_sec=$(( $(date -u -d "${leg_end_date}" +%s) - $(date -u -d "${run_start_date}" +%s) ))
  514. leg_start_date_yyyymmdd=$(date -u -d "${leg_start_date}" +%Y%m%d)
  515. leg_start_date_yyyy=$(date -u -d "${leg_start_date}" +%Y)
  516. leg_end_date_yyyy=$(date -u -d "${leg_end_date}" +%Y)
  517. # Check whether there's actually time left to simulate - exit otherwise
  518. if [ ${leg_length_sec} -le 0 ]
  519. then
  520. info "Leg start date equal to or after end of simulation."
  521. info "Nothing left to do. Exiting."
  522. exit 0
  523. fi
  524. # Initial conditions saved during the run
  525. do_save_ic=false
  526. has_config save_ic && save_ic_get_config
  527. # if you do not use an option with save_ic, you must define 'do_save_ic' and
  528. # 'save_ic_date_offset' here or in ../libsave_ic.sh/save_ic_get_config()
  529. ${do_save_ic} && save_ic_define_vars
  530. # -------------------------------------------------------------------------
  531. # *** Prepare the run directory for a run from scratch
  532. # -------------------------------------------------------------------------
  533. if ! $leg_is_restart
  534. then
  535. # ---------------------------------------------------------------------
  536. # *** Check if run dir is empty. If not, and if we are allowed to do so
  537. # by ${force_run_from_scratch}, remove everything
  538. # ---------------------------------------------------------------------
  539. if $(ls * >& /dev/null)
  540. then
  541. if ${force_run_from_scratch}
  542. then
  543. rm -fr ${run_dir}/*
  544. else
  545. error "Run directory not empty and \$force_run_from_scratch not set."
  546. fi
  547. fi
  548. # ---------------------------------------------------------------------
  549. # *** Copy executables of model components
  550. # *** Additionally, create symlinks to the original place for reference
  551. # ---------------------------------------------------------------------
  552. cp ${ifs_exe_file} .
  553. ln -s ${ifs_exe_file} $(basename ${ifs_exe_file}).lnk
  554. if $(has_config amip)
  555. then
  556. cp ${amip_exe_file} .
  557. ln -s ${amip_exe_file} $(basename ${amip_exe_file}).lnk
  558. fi
  559. if $(has_config nemo)
  560. then
  561. cp ${nem_exe_file} .
  562. ln -s ${nem_exe_file} $(basename ${nem_exe_file}).lnk
  563. cp ${rnf_exe_file} .
  564. ln -s ${rnf_exe_file} $(basename ${rnf_exe_file}).lnk
  565. cp ${xio_exe_file} .
  566. ln -s ${xio_exe_file} $(basename ${xio_exe_file}).lnk
  567. fi
  568. if $(has_config lpjg)
  569. then
  570. cp ${lpjg_exe_file} .
  571. ln -s ${lpjg_exe_file} $(basename ${lpjg_exe_file}).lnk
  572. fi
  573. if $(has_config tm5)
  574. then
  575. cp ${tm5_exe_file} .
  576. ln -s ${tm5_exe_file} $(basename ${tm5_exe_file}).lnk
  577. fi
  578. # ---------------------------------------------------------------------
  579. # *** Files needed for IFS (linked)
  580. # ---------------------------------------------------------------------
  581. # Initial data
  582. ln -s \
  583. ${ini_data_dir}/ifs/${ifs_grid}/${leg_start_date_yyyymmdd}/ICMGGECE3INIUA \
  584. ICMGG${exp_name}INIUA
  585. ln -s \
  586. ${ini_data_dir}/ifs/${ifs_grid}/${leg_start_date_yyyymmdd}/ICMSHECE3INIT \
  587. ICMSH${exp_name}INIT
  588. rm -f ICMGG${exp_name}INIT
  589. cp ${ini_data_dir}/ifs/${ifs_grid}/${leg_start_date_yyyymmdd}/ICMGGECE3INIT \
  590. ICMGG${exp_name}INIT
  591. # add bare_soil_albedo to ICMGG*INIT
  592. tempfile=tmp.$$
  593. ${grib_set} -s dataDate=$(date -u -d "$run_start_date" +%Y%m%d) \
  594. ${ini_data_dir}/ifs/${ifs_grid}/climate/bare_soil_albedos.grb \
  595. ${tempfile}
  596. cat ${tempfile} >> ICMGG${exp_name}INIT
  597. rm -f ${tempfile}
  598. # add land ice mask if needed
  599. if ${ifs_landice}
  600. then
  601. tempfile=tmp.$$
  602. cdo divc,10 -setcode,82 -selcode,141 ICMGG${exp_name}INIT ${tempfile}
  603. ${grib_set} -s gridType=reduced_gg ${tempfile} ${tempfile}
  604. cat ${tempfile} >> ICMGG${exp_name}INIT
  605. rm -f ${tempfile}
  606. fi
  607. # Other stuff
  608. ln -s ${ini_data_dir}/ifs/rtables/* .
  609. # Output control (ppt files)
  610. if [ ! -f ${output_control_files_dir}/pptdddddd0600 ] && [ ! -f ${output_control_files_dir}/pptdddddd0300 ];then
  611. echo "Error from ece-esm.sh: Neither the file pptdddddd0600 or pptdddddd0300 exists in the directory:"
  612. echo " " ${output_control_files_dir}
  613. exit -1
  614. fi
  615. mkdir postins
  616. cp ${output_control_files_dir}/ppt* postins/
  617. if [ -f postins/pptdddddd0600 ];then
  618. ln -s pptdddddd0600 postins/pptdddddd0000
  619. ln -s pptdddddd0600 postins/pptdddddd1200
  620. ln -s pptdddddd0600 postins/pptdddddd1800
  621. fi
  622. if [ -f postins/pptdddddd0300 ];then
  623. ln -s pptdddddd0300 postins/pptdddddd0900
  624. ln -s pptdddddd0300 postins/pptdddddd1500
  625. ln -s pptdddddd0300 postins/pptdddddd2100
  626. if [ ! -f postins/pptdddddd0600 ];then
  627. ln -s pptdddddd0300 postins/pptdddddd0000
  628. ln -s pptdddddd0300 postins/pptdddddd0600
  629. ln -s pptdddddd0300 postins/pptdddddd1200
  630. ln -s pptdddddd0300 postins/pptdddddd1800
  631. fi
  632. fi
  633. /bin/ls -1 postins/* > dirlist
  634. # ---------------------------------------------------------------------
  635. # *** Files needed for LPJ-GUESS
  636. # ---------------------------------------------------------------------
  637. if $(has_config lpjg)
  638. then
  639. # Check for valid grid
  640. if [ $lpjg_res != "T255" -a $lpjg_res != "T159" ]
  641. then
  642. error "LPJG-gridlist doesn't exist for ifs-grid: ${ifs_grid}"
  643. fi
  644. # Initial data - saved state for LPJ-GUESS (.bin format)
  645. lpjgstartdir=$(printf "lpjg_state_%04d" $leg_start_date_yyyy)
  646. ln -sf ${ini_data_dir}/lpjg/ini_state/${lpjg_res}/${lpjgstartdir} ${run_dir}/${lpjgstartdir}
  647. # Control files (i.e. .ins, landuse, N deposition, soil type files etc.)
  648. cp -f ${ecearth_src_dir}/lpjg/data/ins/*.ins .
  649. # activate the new litterfall scheme for C4MIP - for the coupled model this is done when both pisces and lpjg are activated
  650. has_config pisces lpjg && echo -e "!override for EC-Earth-CC in runscript\nifpftlitterfall 1\ncalc_phen_after_restart 0" >> global.ins
  651. mkdir -p ${run_dir}/landuse
  652. fi
  653. # ---------------------------------------------------------------------
  654. # *** Files needed for NEMO (linked)
  655. # ---------------------------------------------------------------------
  656. if $(has_config nemo)
  657. then
  658. # Link initialisation files for matching ORCA grid
  659. for f in \
  660. bathy_meter.nc coordinates.nc \
  661. ahmcoef.nc \
  662. K1rowdrg.nc M2rowdrg.nc mask_itf.nc \
  663. decay_scale_bot.nc decay_scale_cri.nc \
  664. mixing_power_bot.nc mixing_power_cri.nc mixing_power_pyc.nc \
  665. runoff_depth.nc subbasins.nc
  666. do
  667. [ -f ${ini_data_dir}/nemo/initial/${nem_grid}/$f ] && ln -s ${ini_data_dir}/nemo/initial/${nem_grid}/$f
  668. done
  669. # Copying the time independent NEMO files for the matching ORCA grid in order to facilitate cmorisation:
  670. for f in \
  671. bathy_meter.nc subbasins.nc
  672. do
  673. mkdir -p output/nemo/ofx-data
  674. [ -f ${ini_data_dir}/nemo/initial/${nem_grid}/$f ] && cp -f ${ini_data_dir}/nemo/initial/${nem_grid}/$f output/nemo/ofx-data/
  675. done
  676. # Link geothermal heating file (independent of grid) and matching weight file
  677. ln -s ${ini_data_dir}/nemo/initial/Goutorbe_ghflux.nc
  678. ln -s ${ini_data_dir}/nemo/initial/weights_Goutorbe1_2_orca${nem_res_hor}_bilinear.nc
  679. # Link the salinity climatology file (needed for diagnostics)
  680. ln -s ${ini_data_dir}/nemo/climatology/${nem_grid}/sali_ref_clim_monthly.nc
  681. # Link either restart files or climatology files for the initial state
  682. if $(has_config nemo:start_from_restart)
  683. then
  684. # When linking restart files, we accept three options:
  685. # (1) Merged files for ocean and ice, i.e.
  686. # restart_oce.nc and restart_ice.nc
  687. # (2) One-file-per-MPI-rank, i.e.
  688. # restart_oce_????.nc and restart_ice_????.nc
  689. # No check is done whether the number of restart files agrees
  690. # with the number of MPI ranks for NEMO!
  691. # (3) One-file-per-MPI-rank with a prefix, i.e.
  692. # <exp_name>_<time_step>_restart_oce_????.nc (similar for the ice)
  693. # The prefix is ignored.
  694. # The code assumes that one of the options can be applied! If more
  695. # options are applicable, the first is chosen. If none of the
  696. # options apply, NEMO will crash with missing restart file.
  697. if ls -U ${nem_restart_file_path}/restart_[oi]ce.nc > /dev/null 2>&1
  698. then
  699. ln -s ${nem_restart_file_path}/restart_[oi]ce.nc ./
  700. elif ls -U ${nem_restart_file_path}/restart_[oi]ce_????.nc > /dev/null 2>&1
  701. then
  702. ln -s ${nem_restart_file_path}/restart_[oi]ce_????.nc ./
  703. else
  704. for f in ${nem_restart_file_path}/????_????????_restart_[oi]ce_????.nc
  705. do
  706. ln -s $f $(echo $f | sed 's/.*_\(restart_[oi]ce_....\.nc\)/\1/')
  707. done
  708. fi
  709. else
  710. # Temperature and salinity files for initialisation
  711. ln -s ${ini_data_dir}/nemo/climatology/absolute_salinity_WOA13_decav_Reg1L75_clim.nc
  712. ln -s ${ini_data_dir}/nemo/climatology/conservative_temperature_WOA13_decav_Reg1L75_clim.nc
  713. ln -s ${ini_data_dir}/nemo/climatology/weights_WOA13d1_2_orca${nem_res_hor}_bilinear.nc
  714. # Grid dependent runoff files
  715. case ${nem_grid} in
  716. ORCA1*) ln -s ${ini_data_dir}/nemo/climatology/runoff-icb_DaiTrenberth_Depoorter_ORCA1_JD.nc ;;
  717. ORCA025*) ln -s ${ini_data_dir}/nemo/climatology/ORCA_R025_runoff_v1.1.nc ;;
  718. esac
  719. fi
  720. # for ocean_nudging
  721. if $(has_config nemo:ocenudg) ; then
  722. ln -s ${ini_data_dir}/nemo/oce_nudg/resto.nc
  723. fi
  724. # XIOS files
  725. . ${ctrl_file_dir}/iodef.xml.sh > iodef.xml
  726. ln -s ${ctrl_file_dir}/context_nemo.xml
  727. ln -s ${ctrl_file_dir}/domain_def_nemo.xml
  728. ln -s ${ctrl_file_dir}/axis_def_nemo.xml
  729. ln -s ${ctrl_file_dir}/grids_def_nemo.xml
  730. ln -s ${ctrl_file_dir}/field_def_nemo-lim.xml
  731. ln -s ${ctrl_file_dir}/field_def_nemo-opa.xml
  732. ln -s ${ctrl_file_dir}/field_def_nemo-pisces.xml
  733. ln -s ${ctrl_file_dir}/field_def_nemo-inerttrc.xml
  734. ln -s ${output_control_files_dir}/file_def_nemo-lim3.xml file_def_nemo-lim.xml
  735. ln -s ${output_control_files_dir}/file_def_nemo-opa.xml
  736. ln -s ${output_control_files_dir}/file_def_nemo-pisces.xml
  737. if [ -f ${ini_data_dir}/xios/ORCA${nem_res_hor}/coordinates_xios.nc ]
  738. then
  739. cp ${ini_data_dir}/xios/ORCA${nem_res_hor}/coordinates_xios.nc ./
  740. else
  741. info "File 'coordinates_xios.nc' not found. NEMO can not be run with land domain removal!"
  742. fi
  743. # Files needed for TOP/PISCES
  744. if $(has_config pisces)
  745. then
  746. ln -fs ${ini_data_dir}/nemo/pisces/dust_INCA_ORCA_R1.nc
  747. ln -fs ${ini_data_dir}/nemo/pisces/ndeposition_Duce_ORCA_R1.nc
  748. ln -fs ${ini_data_dir}/nemo/pisces/pmarge_etopo_ORCA_R1.nc
  749. ln -fs ${ini_data_dir}/nemo/pisces/river_global_news_ORCA_R1.nc
  750. ln -fs ${ini_data_dir}/nemo/pisces/Solubility_T62_Mahowald_ORCA_R1.nc
  751. ln -fs ${ini_data_dir}/nemo/pisces/par_fraction_gewex_clim90s00s_ORCA_R1.nc
  752. ln -fs ${ini_data_dir}/nemo/pisces/DIC_GLODAP_annual_ORCA_R1.nc
  753. ln -fs ${ini_data_dir}/nemo/pisces/Alkalini_GLODAP_annual_ORCA_R1.nc
  754. ln -fs ${ini_data_dir}/nemo/pisces/O2_WOA2009_monthly_ORCA_R1.nc
  755. ln -fs ${ini_data_dir}/nemo/pisces/PO4_WOA2009_monthly_ORCA_R1.nc
  756. ln -fs ${ini_data_dir}/nemo/pisces/Si_WOA2009_monthly_ORCA_R1.nc
  757. ln -fs ${ini_data_dir}/nemo/pisces/DOC_PISCES_monthly_ORCA_R1.nc
  758. ln -fs ${ini_data_dir}/nemo/pisces/Fer_PISCES_monthly_ORCA_R1.nc
  759. ln -fs ${ini_data_dir}/nemo/pisces/NO3_WOA2009_monthly_ORCA_R1.nc
  760. # create co2 concentration file atcco2.txt if required
  761. if { [ $ifs_cmip_fixyear -gt 0 ] || [[ "${ifs_A4xCO2}" = "TRUE" ]]; } && [[ "${bgc_1PCTCO2}" = "FALSE" ]]
  762. then
  763. rm -f atcco2.txt
  764. elif [[ "${bgc_1PCTCO2}" = "TRUE" ]]
  765. then
  766. cp -f ${ini_data_dir}/nemo/pisces/mole-fraction-of-carbon-dioxide-in-air_1pctCO2_1849-2016.txt atcco2.txt
  767. else
  768. # determine scenario-name and co2-file middle-fix
  769. case $(echo ${ifs_cmip6_scenario} | tr '[:upper:]' '[:lower:]') in
  770. hist*) pis_scen="ssp585"; pis_sco2_mfix="REMIND-MAGPIE-ssp585-1-2-1";;
  771. ssp2-4.5*) pis_scen="ssp245"; pis_sco2_mfix="MESSAGE-GLOBIOM-ssp245-1-2-1";;
  772. ssp5-3.4*) pis_scen="ssp534os"; pis_sco2_mfix="REMIND-MAGPIE-ssp534-over-1-2-1";;
  773. ssp5-8.5*) pis_scen="ssp585"; pis_sco2_mfix="REMIND-MAGPIE-ssp585-1-2-1";;
  774. *) error "Scenario ${ifs_cmip6_scenario} not defined for PISCES" ;;
  775. esac
  776. # concatenate historic and scenario (2015+) co2 concentration file
  777. pis_sco2_pfix="${ini_data_dir}/nemo/pisces/mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations"
  778. cat ${pis_sco2_pfix}_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_1849-2014.txt ${pis_sco2_pfix}_ScenarioMIP_UoM-${pis_sco2_mfix}_gr1-GMNHSH_2015-2500.txt > atcco2.txt
  779. fi
  780. fi
  781. #linking surface boundary conditions for CFCs (even if CFCs are not included)
  782. ln -fs ${ini_data_dir}/nemo/cfc/CFCs_CDIAC_extension_1637_2019.dat CFCs_CDIAC.dat
  783. if $(has_config pisces:start_from_restart)
  784. then
  785. # Same three options as for nemo:start_from_restart
  786. if ls -U ${nem_restart_file_path}/restart_trc.nc > /dev/null 2>&1
  787. then
  788. ln -s ${nem_restart_file_path}/restart_trc.nc ./
  789. elif ls -U ${nem_restart_file_path}/restart_trc_????.nc > /dev/null 2>&1
  790. then
  791. ln -s ${nem_restart_file_path}/restart_trc_????.nc ./
  792. else
  793. for f in ${nem_restart_file_path}/????_????????_restart_trc_????.nc
  794. do
  795. ln -s $f $(echo $f | sed 's/.*_\(restart_trc_....\.nc\)/\1/')
  796. done
  797. fi
  798. fi
  799. fi
  800. # ---------------------------------------------------------------------
  801. # *** Files needed for the Runoff mapper (linked)
  802. # ---------------------------------------------------------------------
  803. has_config rnfmapper && \
  804. ln -s ${ini_data_dir}/runoff-mapper/runoff_maps.nc
  805. # -------------------------------------------------------------------------
  806. # *** File and dir needed for TM5
  807. # -------------------------------------------------------------------------
  808. if $(has_config tm5)
  809. then
  810. tm5_istart=[[[MOD:TM5:ISTART]]]
  811. case ${tm5_istart} in
  812. 33|32) ln -s \
  813. ${tm5_restart_file_path}/TM5_restart_${leg_start_date_yyyymmdd}_0000_glb300x200.nc
  814. ;;
  815. 31) ln -s ${tm5_restart_file_path}/tm5_save.hdf
  816. ;;
  817. 5) ln -s ${tm5_restart_file_path}/tm5_mmix.hdf
  818. ;;
  819. 2|9)
  820. ;;
  821. *) error "Unsupported initial fields option (TM5): ${tm5_istart}"
  822. ;;
  823. esac
  824. # spectral info
  825. ln -s ${ini_data_dir}/tm5/TM5_INPUT/T${ifs_res_hor}_info.txt
  826. # Profiling dir for TM5
  827. mkdir -p ${run_dir}/tm5_profile
  828. fi
  829. # ---------------------------------------------------------------------
  830. # *** Files needed for OASIS (linked)
  831. # ---------------------------------------------------------------------
  832. # Name table file
  833. ln -s ${ini_data_dir}/oasis/cf_name_table.txt
  834. # -- Get grid definition and weight files for IFS/NEMO or IFS/AMIP coupling
  835. has_config nemo && \
  836. oas_grid_dir=${ini_data_dir}/oasis/T${ifs_res_hor}-ORCA${nem_res_hor} && \
  837. mycp='cp'
  838. has_config amip && \
  839. oas_grid_dir=${ini_data_dir}/oasis/AMIP && \
  840. mycp='cdo -f nc copy' # to enforce nc format, needed for 'cdo merge' to work (have nc4c with Primavera files)
  841. # Grid definition files
  842. if $(has_config tm5)
  843. then
  844. ${mycp} ${oas_grid_dir}/areas.nc gcm_areas.nc
  845. ${mycp} ${oas_grid_dir}/grids.nc gcm_grids.nc
  846. ${mycp} ${oas_grid_dir}/masks.nc gcm_masks.nc
  847. else
  848. ln -s ${oas_grid_dir}/areas.nc
  849. ln -s ${oas_grid_dir}/grids.nc
  850. ln -s ${oas_grid_dir}/masks.nc
  851. fi
  852. # Weight files
  853. case ${ifs_res_hor} in
  854. 159) oas_agrd=080
  855. ;;
  856. 255) oas_agrd=128
  857. ;;
  858. 511) oas_agrd=256
  859. ;;
  860. 799) oas_agrd=400
  861. ;;
  862. *) error "Unsupported horizontal resolution (IFS): ${ifs_res_hor}"
  863. ;;
  864. esac
  865. if $(has_config nemo)
  866. then
  867. case ${nem_res_hor} in
  868. 1) oas_ogrd=O1t0
  869. ;;
  870. 025) oas_ogrd=Ot25
  871. ;;
  872. *) error "Unsupported horizontal resolution (NEMO): ${nem_res_hor}"
  873. ;;
  874. esac
  875. fi
  876. if ${oas_link_weights}
  877. then
  878. for f in ${oas_grid_dir}/rmp_????_to_????_GAUSWGT.nc
  879. do
  880. ln -s $f
  881. done
  882. fi
  883. if $(has_config ifs nemo)
  884. then
  885. for f in ${oas_rst_ifs_nemo}
  886. do
  887. cp ${oas_grid_dir}/rst/$f .
  888. done
  889. fi
  890. # -- Get grid definition, weight and restart files for TM5 coupling
  891. if $(has_config tm5)
  892. then
  893. oas_grid_dir=${ini_data_dir}/oasis/T${ifs_res_hor}-TM5-LPJG
  894. cp ${oas_grid_dir}/tm5_areas.nc .
  895. cp ${oas_grid_dir}/tm5_grids.nc .
  896. cp ${oas_grid_dir}/tm5_masks.nc .
  897. if ${oas_link_weights}
  898. then
  899. for f in ${oas_grid_dir}/rmp_????_to_????_*.nc
  900. do
  901. ln -s $f
  902. done
  903. fi
  904. # -- Get restart files for TM5-IFS/LPJG/PISCES
  905. for f in ${oas_rst_ifs_tm5}
  906. do
  907. cp ${oas_grid_dir}/rst/${tm5_exch_nlevs}-levels/$f .
  908. done
  909. # -- Merge grid definition files
  910. cdo merge gcm_areas.nc tm5_areas.nc areas.nc
  911. cdo merge gcm_grids.nc tm5_grids.nc grids.nc
  912. cdo merge gcm_masks.nc tm5_masks.nc masks.nc
  913. fi
  914. else # i.e. $leg_is_restart == true
  915. # ---------------------------------------------------------------------
  916. # *** Remove all leftover output files from previous legs
  917. # ---------------------------------------------------------------------
  918. # IFS files
  919. rm -f ICM{SH,GG}${exp_name}+??????
  920. # NEMO files
  921. rm -f ${exp_name}_??_????????_????????_{grid_U,grid_V,grid_W,grid_T,icemod,SBC,scalar,SBC_scalar,diad_T}.nc
  922. # TM5 restart file type
  923. tm5_istart=33
  924. if [ $tm5_istart -eq 31 ] && $(has_config tm5)
  925. then
  926. ln -sf save_${leg_start_date_yyyymmdd}00_glb300x200.hdf tm5_save.hdf
  927. fi
  928. fi # ! $leg_is_restart
  929. #--------------------------------------------------------------------------
  930. # *** Surface restoring and ocean nudging options
  931. #--------------------------------------------------------------------------
  932. if $(has_config nemo:ocenudg) ; then
  933. ln -fs ${ini_data_dir}/nemo/oce_nudg/temp_sal*.nc ./
  934. fi
  935. if $(has_config nemo:surfresto) ; then
  936. ln -fs ${ini_data_dir}/nemo/surface_restoring/sss_restore_data*.nc ./
  937. ln -fs ${ini_data_dir}/nemo/surface_restoring/sst_restore_data*.nc ./
  938. ln -fs ${ini_data_dir}/nemo/surface_restoring/mask_restore*.nc ./
  939. fi
  940. # -------------------------------------------------------------------------
  941. # *** Remove land grid-points
  942. # -------------------------------------------------------------------------
  943. if $(has_config nemo:elpin)
  944. then
  945. if [ ! -f coordinates_xios.nc ]
  946. then
  947. error "ELpIN requested, but file 'coordinates_xios.nc' was not found"
  948. fi
  949. jpns=($(${ecearth_src_dir}/util/ELPiN/ELPiNv2.cmd ${nem_numproc}))
  950. info "nemo domain decompostion from ELpIN: ${jpns[@]}"
  951. nem_numproc=${jpns[0]}
  952. nem_jpni=${jpns[1]}
  953. nem_jpnj=${jpns[2]}
  954. elif has_config nemo
  955. then
  956. info "nemo original domain decomposition (not using ELPiN)"
  957. fi
  958. # -------------------------------------------------------------------------
  959. # *** Initial conditions saved during the run
  960. # -------------------------------------------------------------------------
  961. ${do_save_ic} && save_ic_prepare_output
  962. # -------------------------------------------------------------------------
  963. # *** Create some control files
  964. # -------------------------------------------------------------------------
  965. # Create TM5 runtime rcfile
  966. tm5_start_date=$(date -u -d "${leg_start_date}" +%F\ %T)
  967. tm5_end_date=$(date -u -d "${leg_end_date}" +%F\ %T)
  968. if $(has_config tm5)
  969. then
  970. cp -f ${ctrl_file_dir}/tm5-config-run.rc ${run_dir}
  971. ${ecearth_src_dir}/tm5mp/setup_tm5 --no-compile \
  972. --time-start="${tm5_start_date}" --time-final="${tm5_end_date}" \
  973. --istart=${tm5_istart} ${run_dir}/tm5-config-run.rc
  974. fi
  975. # IFS frequency output for namelist
  976. if [ -f postins/pptdddddd0300 ]
  977. then
  978. ifs_output_freq=$(( 3 * 3600 / ifs_time_step_sec ))
  979. elif [ -f postins/pptdddddd0600 ]
  980. then
  981. ifs_output_freq=$(( 6 * 3600 / ifs_time_step_sec ))
  982. else
  983. error "IFS output frequency undefined."
  984. fi
  985. # IFS, NEMO, LIM, AMIP namelist and OASIS namcouple files
  986. has_config ifs && . ${ctrl_file_dir}/namelist.ifs.sh > fort.4
  987. has_config nemo && . ${ctrl_file_dir}/namelist.nemo.ref.sh > namelist_ref
  988. has_config ifs nemo && . ${ctrl_file_dir}/namelist.nemo-${nem_grid}-coupled.cfg.sh > namelist_cfg
  989. has_config lim3 && . ${ctrl_file_dir}/namelist.lim3.ref.sh > namelist_ice_ref
  990. has_config lim3 && . ${ctrl_file_dir}/namelist.lim3-${nem_grid}.cfg.sh > namelist_ice_cfg
  991. has_config rnfmapper && . ${ctrl_file_dir}/namelist.runoffmapper.sh > namelist.runoffmapper
  992. has_config amip && . ${ctrl_file_dir}/namelist.amip.sh > namelist.amip
  993. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.top.ref.sh > namelist_top_ref
  994. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.top.cfg.sh > namelist_top_cfg
  995. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.pisces.ref.sh > namelist_pisces_ref
  996. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.pisces.cfg.sh > namelist_pisces_cfg
  997. has_config nemo && . ${ctrl_file_dir}/namelist.nemo.age.ref.sh > namelist_age_ref
  998. has_config nemo && . ${ctrl_file_dir}/namelist.nemo.age.cfg.sh > namelist_age_cfg
  999. #include CFCs namelist even if CFCs are not included
  1000. has_config nemo && . ${ctrl_file_dir}/namelist.nemo.cfc.ref.sh > namelist_cfc_ref
  1001. has_config nemo && . ${ctrl_file_dir}/namelist.nemo.cfc.cfg.sh > namelist_cfc_cfg
  1002. # C-cycle - overwrite coupled nemo namelist
  1003. has_config pisces tm5:co2 && \
  1004. . ${ctrl_file_dir}/namelist.nemo-${nem_grid}-carboncycle.cfg.sh > namelist_cfg
  1005. lucia=[[[MOD:OASIS:LUCIA]]]
  1006. . ${ctrl_file_dir}/namcouple.sh > namcouple
  1007. # -------------------------------------------------------------------------
  1008. # *** LPJ-GUESS initial data
  1009. # -------------------------------------------------------------------------
  1010. if $(has_config lpjg)
  1011. then
  1012. # LPJG runtime rcfile - update with leg dates
  1013. . ${ctrl_file_dir}/namelist.lpjg.sh > lpjg_steps.rc
  1014. # determine lpjg scenario-name and co2-file middle-fix
  1015. case $(echo ${ifs_cmip6_scenario} | tr '[:upper:]' '[:lower:]') in
  1016. hist*) lpjg_scen="ssp370"; lu_src="AIM" ; lpjg_sco2_mfix="AIM-ssp370-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  1017. ssp1-1.9*) lpjg_scen="ssp119"; lu_src="IMAGE" ; lpjg_sco2_mfix="IMAGE-ssp119-1-2-1" ; lu_file_posfix="2019_03_13.txt";;
  1018. ssp1-2.6*) lpjg_scen="ssp126"; lu_src="IMAGE" ; lpjg_sco2_mfix="IMAGE-ssp126-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  1019. 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";;
  1020. ssp3-7.0*) lpjg_scen="ssp370"; lu_src="AIM" ; lpjg_sco2_mfix="AIM-ssp370-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  1021. ssp4-3.4*) lpjg_scen="ssp434"; lu_src="GCAM" ; lpjg_sco2_mfix="GCAM4-ssp434-1-2-1" ; lu_file_posfix="2018_10_08.txt";;
  1022. ssp5-3.4*) lpjg_scen="ssp534os"; lu_src="MAGPIE"; lpjg_sco2_mfix="REMIND-MAGPIE-ssp534-over-1-2-1" ; lu_file_posfix="2019_05_10.txt";;
  1023. 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";;
  1024. *) error "Scenario ${ifs_cmip6_scenario} not defined for LPJ-GUESS" ;;
  1025. esac
  1026. lpjg_scenario_new="historical + $lpjg_sco2_mfix"
  1027. lpjg_scenario_info=${run_dir}/lpjg_scenario.info
  1028. if [ -f $lpjg_scenario_info ]
  1029. then
  1030. source $lpjg_scenario_info
  1031. if [ "$lpjg_scenario_new" = "$lpjg_scenario" ]
  1032. then
  1033. lpjg_copy_rte=false
  1034. else
  1035. lpjg_copy_rte=true
  1036. fi
  1037. else
  1038. lpjg_copy_rte=true
  1039. fi
  1040. # copy RTE only if necessary (at beginning of a run or when scenario changes)
  1041. if $lpjg_copy_rte
  1042. then
  1043. # write info about installed scenarios to file
  1044. echo "lpjg_scenario=\"historical + $lpjg_sco2_mfix\"" > $lpjg_scenario_info
  1045. # set file prefixes depending on scenario
  1046. lu_file_prefix="1850_2100_luh2_Hist_ScenarioMIP_UofMD"
  1047. lu_file_midfix="2_1_f"
  1048. lu_path="${ini_data_dir}/lpjg/landuse/${lpjg_res}/${lpjg_scen}"
  1049. # copy and reference-link landuse, gross transitions, crops, n-fertilisation
  1050. for inp in lu gross crop nfert
  1051. do
  1052. if [ $inp == "crop" -o $inp == "nfert" ]
  1053. then
  1054. lu_src_file="${lu_path}/${inp}_rfirr_${lu_file_prefix}_${lu_src}_${lpjg_scen}_${lu_file_midfix}_${lpjg_res}_${lu_file_posfix}"
  1055. else
  1056. lu_src_file="${lu_path}/${inp}_${lu_file_prefix}_${lu_src}_${lpjg_scen}_${lu_file_midfix}_${lpjg_res}_${lu_file_posfix}"
  1057. fi
  1058. cp -f $lu_src_file ${run_dir}/landuse/${inp}_luh2.txt
  1059. ln -fs $lu_src_file ${run_dir}/landuse/${inp}_luh2.txt.lnk
  1060. done
  1061. # nitrogen deposition files
  1062. mkdir -p ${run_dir}/ndep
  1063. for inp in drynhx2 drynoy2 wetnhx2 wetnoy2
  1064. do
  1065. ndep_src_file="${ini_data_dir}/lpjg/ndep/${lpjg_res}/${lpjg_scen}/${lpjg_scen}_${lpjg_res}_${inp}.nc"
  1066. cp -f $ndep_src_file ${run_dir}/ndep/${inp}.nc
  1067. ln -fs $ndep_src_file ${run_dir}/ndep/${inp}.nc.lnk
  1068. done
  1069. # concatenate historic and scenario (2015+) co2 concentration file
  1070. # hist co2 file
  1071. 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"
  1072. # scenario co2 file
  1073. 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"
  1074. # combined file
  1075. lpjg_co2_file="${run_dir}/mole_fraction_of_carbon_dioxide_in_air_input4MIPs_lpjg.nc"
  1076. rm -f $lpjg_co2_file
  1077. cdo mergetime $lpjg_hco2_file $lpjg_sco2_file $lpjg_co2_file
  1078. fi
  1079. # Populate or update LPJG run directories
  1080. for (( n=1; n<=${lpjg_numproc}; n++ ))
  1081. do
  1082. # if run from scratch or number of procs has been extended
  1083. if ! $leg_is_restart || [ ! -d ${run_dir}/run${n} ]
  1084. then
  1085. # Make output directories
  1086. mkdir -p ${run_dir}/run${n}/output
  1087. # Copy *.ins, lpjg_steps.rc and OASIS-MCT restart files
  1088. cp ${run_dir}/*.ins ${run_dir}/run${n}
  1089. # Copy output control files
  1090. cp ${output_control_files_dir}/lpjg_cmip6_output.ins ${run_dir}/run${n}
  1091. ln -s ${output_control_files_dir}/lpjg_cmip6_output.ins ${run_dir}/run${n}/lpjg_cmip6_output.ins.lnk
  1092. cp ${ini_data_dir}/lpjg/oasismct/ghg*.txt ${run_dir}/run${n}
  1093. cp ${ini_data_dir}/lpjg/oasismct/${lpjg_res}/ece_gridlist_${lpjg_res}.txt ${run_dir}/run${n}/ece_gridlist.txt
  1094. ln -s ${ini_data_dir}/lpjg/oasismct/${lpjg_res}/ece_gridlist_${lpjg_res}.txt ${run_dir}/run${n}/ece_gridlist.txt.lnk
  1095. # Data only needed by master
  1096. if [ $n == 1 ]
  1097. then
  1098. cp ${ini_data_dir}/lpjg/oasismct/${lpjg_res}/*.nc ${run_dir}
  1099. cp ${ini_data_dir}/lpjg/oasismct/lpjgv.txt ${run_dir}/run${n}
  1100. fi
  1101. fi
  1102. # Refresh output-dirs after they hav been removed at end of the last leg
  1103. mkdir -p ${run_dir}/run${n}/output/CMIP6
  1104. mkdir -p ${run_dir}/run${n}/output/CRESCENDO
  1105. done
  1106. if $leg_is_restart
  1107. then
  1108. lpjg_restart_dir="restart/lpjg/$(printf %03d $((leg_number-1)))"
  1109. lpjg_rst_state="${lpjg_restart_dir}/lpjg_state_${leg_start_date_yyyy}"
  1110. if [ -d "$lpjg_rst_state" ]
  1111. then
  1112. ln -sf $lpjg_rst_state
  1113. else
  1114. echo "lpjg restart dir $lpjg_rst_state not available"
  1115. exit -1
  1116. fi
  1117. # get oasis restart files
  1118. oasis_restart_dir="restart/oasis/$(printf %03d $((leg_number)))"
  1119. cp -f ${oasis_restart_dir}/*.nc ${run_dir}/
  1120. fi
  1121. fi
  1122. # -------------------------------------------------------------------------
  1123. # *** Create ICMCL file with vegetation fields
  1124. # not needed if LPJG is used with feedback
  1125. # -------------------------------------------------------------------------
  1126. tempfile=tmp.$$
  1127. case ${ifs_veg_source} in
  1128. "ifs" )
  1129. # Vegetation from IFS (climatology)
  1130. icmclfile=${ini_data_dir}/ifs/${ifs_grid}/climate/ICMCL_ONLY_VEG_PD
  1131. # Create data for december, the year before the leg starts
  1132. ${grib_set} \
  1133. -s dataDate=$(printf "%04d" $((leg_start_date_yyyy-1)))1215 \
  1134. ${icmclfile}-12 ICMCL${exp_name}INIT
  1135. # Create data for all month in the years of the leg
  1136. for (( y=${leg_start_date_yyyy} ; y<=${leg_end_date_yyyy} ; y++ ))
  1137. do
  1138. yy=$(printf "%04d" $y)
  1139. for m in {1..12}
  1140. do
  1141. mm=$(printf "%02d" $m)
  1142. ${grib_set} -s dataDate=${yy}${mm}15 ${icmclfile}-${mm} ${tempfile}
  1143. cat ${tempfile} >> ICMCL${exp_name}INIT
  1144. done
  1145. done
  1146. # Create data for january, the year after the leg ends
  1147. ${grib_set} \
  1148. -s dataDate=$(printf "%04d" $((leg_end_date_yyyy+1)))0115 \
  1149. ${icmclfile}-01 ${tempfile}
  1150. cat ${tempfile} >> ICMCL${exp_name}INIT
  1151. ;;
  1152. "era20c"|"cmip6"|"custom_"* )
  1153. # Vegetation from a LPJG run (off-line or EC-Earth3-Veg)
  1154. rm -f ICMCL${exp_name}INIT
  1155. # Create data for all years of the leg, including one year
  1156. # before and one year after
  1157. for (( yr=leg_start_date_yyyy-1 ; yr<=leg_end_date_yyyy+1 ; yr+=1 ))
  1158. do
  1159. case ${ifs_veg_source} in
  1160. 'era20c' )
  1161. # no scenario needed with era20c
  1162. icmcl_scenario="" ;;
  1163. 'custom_'* )
  1164. # no scenario implemented yet with custom_dir
  1165. icmcl_scenario="" ;;
  1166. 'cmip6' )
  1167. # select scenario, use SSP3-7.0 as default
  1168. # if not otherwise specified
  1169. icmcl_scenario="historical"
  1170. if ( [ $ifs_cmip_fixyear -le 0 ] && [ $yr -ge 2015 ] ) || \
  1171. [ $ifs_cmip_fixyear -ge 2015 ]
  1172. then
  1173. [[ ${ifs_cmip6_scenario} =~ ^SSP ]] \
  1174. && icmcl_scenario=${ifs_cmip6_scenario} \
  1175. || if [ ${ifs_covid19^^} == TRUE ]
  1176. then
  1177. icmcl_scenario='SSP2-4.5'
  1178. else
  1179. icmcl_scenario='SSP3-7.0'
  1180. fi
  1181. fi ;;
  1182. esac
  1183. if [ $ifs_cmip_fixyear -le 0 ] || [[ ${ifs_veg_source} == custom_* ]]
  1184. then
  1185. cat ${ini_data_dir}/ifs/${ifs_grid}/icmcl_${veg_version}/${icmcl_scenario}/icmcl_$yr.grb >> ICMCL${exp_name}INIT
  1186. else
  1187. # Fixed year forcing, requires cdo! (only when not using ifs_veg_source=custom_exp*)
  1188. # If cdo is not available at runtime you need to fix proper
  1189. # icmcl files beforehand and use them here
  1190. cdo setyear,$yr ${ini_data_dir}/ifs/${ifs_grid}/icmcl_${veg_version}/${icmcl_scenario}/icmcl_${ifs_cmip_fixyear}.grb ${tempfile}
  1191. cat ${tempfile} >> ICMCL${exp_name}INIT
  1192. fi
  1193. done
  1194. ;;
  1195. "none" )
  1196. info "no ICMCL file is created"
  1197. ;;
  1198. * )
  1199. error "Vegetation from ${ifs_veg_source} not implemented"
  1200. ;;
  1201. esac
  1202. # Clean up
  1203. rm -f ${tempfile}
  1204. # -------------------------------------------------------------------------
  1205. # *** Link the appropriate NEMO restart files of the previous leg
  1206. # -------------------------------------------------------------------------
  1207. if $leg_is_restart && $(has_config nemo) && ! $special_restart
  1208. then
  1209. ns=$(printf %08d $(( leg_start_sec / nem_time_step_sec - nem_restart_offset )))
  1210. for (( n=0 ; n<nem_numproc ; n++ ))
  1211. do
  1212. np=$(printf %04d ${n})
  1213. ln -fs ${exp_name}_${ns}_restart_oce_${np}.nc restart_oce_${np}.nc
  1214. ln -fs ${exp_name}_${ns}_restart_ice_${np}.nc restart_ice_${np}.nc
  1215. has_config pisces && \
  1216. ln -fs ${exp_name}_${ns}_restart_trc_${np}.nc restart_trc_${np}.nc
  1217. done
  1218. # Make sure there are no global restart files
  1219. # If links are found, they will be removed. We are cautious and do
  1220. # _not_ remove real files! However, if real global restart files are
  1221. # present, NEMO/LIM will stop because time stamps will not match.
  1222. [ -h restart_oce.nc ] && rm restart_oce.nc
  1223. [ -h restart_ice.nc ] && rm restart_ice.nc
  1224. [ -h restart_trc.nc ] && rm restart_trc.nc
  1225. fi
  1226. # -------------------------------------------------------------------------
  1227. # *** Remove some OASIS files of the previous leg
  1228. # -------------------------------------------------------------------------
  1229. if $leg_is_restart
  1230. then
  1231. rm -f anaisout_*
  1232. fi
  1233. # -------------------------------------------------------------------------
  1234. # *** Remove any ccycle debug output files
  1235. # -------------------------------------------------------------------------
  1236. if ${ccycle_debug_fluxes} && $leg_is_restart && $(has_config tm5:co2)
  1237. then
  1238. if $(has_config lpjg)
  1239. then
  1240. rm -f GUE_{CNAT,CANT,CNPP}_*.nc run1/GUE_{CNAT,CANT,CNPP}_*.nc
  1241. rm -f TM5_Land{CNAT,CANT,CNPP}_*.nc
  1242. fi
  1243. if $(has_config pisces)
  1244. then
  1245. rm -f O_CO2FLX_*.nc
  1246. rm -f TM5_OceCFLX_*.nc
  1247. fi
  1248. fi
  1249. # -------------------------------------------------------------------------
  1250. # *** Check consistency of OASIS restarts and IFS rcf with ece_info_file
  1251. # -------------------------------------------------------------------------
  1252. if $leg_is_restart
  1253. then
  1254. info "Check OASIS restarts and IFS rcf before launch"
  1255. leg_nb_3d=$(printf %03d $((leg_number)))
  1256. for oasis_restart_file in restart/oasis/${leg_nb_3d}/*
  1257. do
  1258. [ ! -f "${oasis_restart_file}" ] && break
  1259. if ! diff -q $(basename ${oasis_restart_file}) ${oasis_restart_file} >/dev/null
  1260. then
  1261. echo "*WARNING* Overwriting OASIS restart (${oasis_restart_file})"
  1262. cp -f ${oasis_restart_file} .
  1263. fi
  1264. done
  1265. rcf_restart_file=restart/ifs/${leg_nb_3d}/rcf
  1266. if [ -f "${rcf_restart_file}" ]
  1267. then
  1268. if ! diff -q rcf ${rcf_restart_file} >/dev/null
  1269. then
  1270. echo "*WARNING* Overwriting IFS rcf file (${rcf_restart_file})"
  1271. cp -f ${rcf_restart_file} .
  1272. fi
  1273. fi
  1274. fi
  1275. # -------------------------------------------------------------------------
  1276. # *** Start the run
  1277. # -------------------------------------------------------------------------
  1278. export DR_HOOK_IGNORE_SIGNALS='-1'
  1279. export CPLNG='active'
  1280. # Use the launch function from the platform configuration file
  1281. has_config nemo && \
  1282. cmd="${xio_numproc} ${xio_exe_file} -- \
  1283. ${nem_numproc} ${nem_exe_file} -- \
  1284. ${ifs_numproc} ${ifs_exe_file} -v ecmwf -e ${exp_name}" || \
  1285. cmd="${ifs_numproc} ${ifs_exe_file} -v ecmwf -e ${exp_name}"
  1286. has_config lpjg && cmd=${cmd}" -- ${lpjg_numproc} ${lpjg_exe_file} guess.ins -parallel"
  1287. has_config tm5 && cmd=${cmd}" -- ${tm5_numproc} ${tm5_exe_file} tm5-run.rc"
  1288. has_config amip && cmd=${cmd}" -- ${amip_numproc} ${amip_exe_file}"
  1289. has_config nemo && cmd=${cmd}" -- ${rnf_numproc} ${rnf_exe_file}"
  1290. t1=$(date +%s)
  1291. launch $cmd
  1292. t2=$(date +%s)
  1293. tr=$(date -d "0 -$t1 sec + $t2 sec" +%T)
  1294. # -------------------------------------------------------------------------
  1295. # *** Check for signs of success
  1296. # Note the tests provide no guarantee that things went fine! They are
  1297. # just based on the IFS, NEMO and TM5 log files. More tests (e.g. checking
  1298. # restart files) could be implemented.
  1299. # -------------------------------------------------------------------------
  1300. # Checking for IFS success
  1301. if [ -f ifs.stat ]
  1302. then
  1303. if [ "$(awk 'END{print $3}' ifs.stat)" == "CNT0" ]
  1304. then
  1305. info "Leg successfully completed according to IFS log file 'ifs.stat'."
  1306. else
  1307. error "Leg not completed according to IFS log file 'ifs.stat'."
  1308. fi
  1309. else
  1310. error "IFS log file 'ifs.stat' not found after run."
  1311. fi
  1312. # Check for NEMO success
  1313. if $(has_config nemo)
  1314. then
  1315. if [ -f ocean.output ]
  1316. then
  1317. 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)" ]
  1318. then
  1319. info "Leg successfully completed according to NEMO log file 'ocean.output'."
  1320. else
  1321. error "Leg not completed according to NEMO log file 'ocean.output'."
  1322. fi
  1323. else
  1324. error "NEMO log file 'ocean.output' not found after run."
  1325. fi
  1326. fi
  1327. # Check for TM5 success
  1328. if $(has_config tm5)
  1329. then
  1330. if [ -f tm5.ok ]
  1331. then
  1332. info "Leg successfully completed according to existing TM5 file 'tm5.ok'."
  1333. else
  1334. error "Leg not completed according to non-existing TM5 file 'tm5.ok'."
  1335. fi
  1336. fi
  1337. # -------------------------------------------------------------------------
  1338. # *** Post-process initial conditions saved during the run if requested
  1339. # -------------------------------------------------------------------------
  1340. ${do_save_ic} && save_ic_postproc
  1341. # -------------------------------------------------------------------------
  1342. # *** Move IFS output files to archive directory
  1343. # -------------------------------------------------------------------------
  1344. outdir="${archive_dir}/output/ifs/$(printf %03d $((leg_number)))"
  1345. mkdir -p ${outdir}
  1346. prv_leg=$(printf %03d $((leg_number-1)))
  1347. # This takes care of a special IFS feature: The output for the last time
  1348. # step of each leg is written at the first time step of the new leg. The
  1349. # following code makes sure that the output is appended to the appropriate
  1350. # file. Since GRIB files are just streams, its done with a simple cat
  1351. # command.
  1352. for f in ICMSH${exp_name}+?????? ICMGG${exp_name}+??????
  1353. do
  1354. if [ -f output/ifs/${prv_leg}/${f} ]
  1355. then
  1356. cat ${f} >> output/ifs/${prv_leg}/${f}
  1357. rm -f ${f}
  1358. else
  1359. mv ${f} ${outdir}
  1360. fi
  1361. done
  1362. # -------------------------------------------------------------------------
  1363. # *** Move NEMO output files to archive directory
  1364. # -------------------------------------------------------------------------
  1365. if $(has_config nemo)
  1366. then
  1367. outdir="${archive_dir}/output/nemo/$(printf %03d $((leg_number)))"
  1368. mkdir -p ${outdir}
  1369. for v in grid_U grid_V grid_W grid_T icemod SBC scalar SBC_scalar diad_T ptrc_T bioscalar \
  1370. grid_T_2D grid_U_2D grid_V_2D grid_W_2D grid_T_3D grid_U_3D grid_V_3D grid_W_3D \
  1371. grid_T_SFC grid_1point grid_T_3D_ncatice vert_sum \
  1372. grid_ptr_W_3basin_3D grid_ptr_T_3basin_2D grid_ptr_T_2D \
  1373. zoom_700_sum zoom_300_sum zoom_2000_sum
  1374. do
  1375. for f in ${exp_name}_*_????????_????????_*${v}.nc
  1376. do
  1377. test -f $f && mv $f $outdir/
  1378. done
  1379. done
  1380. fi
  1381. # -------------------------------------------------------------------------
  1382. # *** Move LPJ-GUESS output files to archive directory
  1383. # -------------------------------------------------------------------------
  1384. if $(has_config lpjg)
  1385. then
  1386. outdir="output/lpjg/$(printf %03d $((leg_number)))"
  1387. if [ -d ${outdir} ]
  1388. then
  1389. rm -rf ${outdir}
  1390. fi
  1391. mkdir -p ${outdir}
  1392. # LPJG run directories
  1393. # concatenate *.out (or compressed *.out.gz) files from each run* into output dir
  1394. flist=$(cd ${run_dir}/run1/output && find *.out.gz -type f 2>/dev/null || true)
  1395. if [ "$flist" = "" ]
  1396. then
  1397. lpjg_compress_output=false
  1398. flist=$(cd ${run_dir}/run1/output && find *.out -type f 2>/dev/null)
  1399. else
  1400. lpjg_compress_output=true
  1401. fi
  1402. mkdir ${outdir}/CMIP6
  1403. for (( n=1; n<=${lpjg_numproc}; n++ ))
  1404. do
  1405. for ofile in $flist
  1406. do
  1407. if $lpjg_compress_output
  1408. then
  1409. [ $n == 1 ] && gzip -c ${run_dir}/run${n}/output/`basename ${ofile} .gz`.hdr > ${outdir}/$ofile
  1410. cat ${run_dir}/run${n}/output/${ofile} >> ${outdir}/$ofile
  1411. else
  1412. if (( n == 1 ))
  1413. then
  1414. cat ${run_dir}/run${n}/output/${ofile} > ${outdir}/$ofile
  1415. else
  1416. awk '(FNR!=1){print $0}' ${run_dir}/run${n}/output/${ofile} >> ${outdir}/$ofile
  1417. fi
  1418. fi
  1419. done
  1420. rm -rf ${run_dir}/run${n}/output
  1421. done
  1422. # move monthly file if available
  1423. if [ -f ${run_dir}/LPJ-GUESS_monthlyoutput.txt ]
  1424. then
  1425. mv ${run_dir}/LPJ-GUESS_monthlyoutput.txt ${outdir}
  1426. fi
  1427. fi
  1428. # -------------------------------------------------------------------------
  1429. # *** Move TM5 output files to archive directory
  1430. # -------------------------------------------------------------------------
  1431. if $(has_config tm5)
  1432. then
  1433. outdir="output/tm5/$(printf %03d $((leg_number)))"
  1434. mkdir -p ${outdir}
  1435. set +e
  1436. mv budget_??????????_??????????_global.hdf ${outdir}
  1437. mv j_statistics_??????????_??????????.hdf ${outdir}
  1438. mv mmix_??????????_??????????_glb???x???.hdf ${outdir}
  1439. mv aerocom?_TM5_*_????????_daily.nc ${outdir}
  1440. mv aerocom?_TM5_*_??????_monthly.nc ${outdir}
  1441. mv AOD_????_??_??.nc ${outdir}
  1442. mv -f TM5MP_${exp_name}_griddef.nc ${outdir}
  1443. mv TM5MP_${exp_name}_TP_????_??_??.nc ${outdir}
  1444. mv TM5MP_${exp_name}_vmr3_????_??_??.nc ${outdir}
  1445. mv general_TM5_${exp_name}_??????????_hourly.nc ${outdir}
  1446. mv general_TM5_${exp_name}_??????_monthly.nc ${outdir}
  1447. mv *EC-Earth3-*_${exp_name}_*.nc ${outdir}
  1448. set -e
  1449. # move profiling files if any
  1450. if [ "$(ls -A ${run_dir}/tm5_profile)" ]
  1451. then
  1452. outdir="output/tm5/profile_$(printf %03d $((leg_number)))"
  1453. mkdir -p ${outdir}
  1454. for f in ${run_dir}/tm5_profile/*
  1455. do
  1456. test -f ${f} && mv $f ${outdir}
  1457. done
  1458. fi
  1459. fi
  1460. # -------------------------------------------------------------------------
  1461. # *** Move IFS restart files to archive directory
  1462. # -------------------------------------------------------------------------
  1463. if $leg_is_restart
  1464. then
  1465. outdir="${archive_dir}/restart/ifs/$(printf %03d $((leg_number)))"
  1466. mkdir -p ${outdir}
  1467. # Figure out the time part of the restart files (cf. CTIME on rcf files)
  1468. # NOTE: Assuming that restarts are at full days (time=0000) only!
  1469. nd="$(printf %06d $((leg_start_sec/(24*3600))))0000"
  1470. mv srf${nd}.???? ${outdir}
  1471. fi
  1472. # -------------------------------------------------------------------------
  1473. # *** Move ccycle debug output files to archive directory
  1474. # -------------------------------------------------------------------------
  1475. if ${ccycle_debug_fluxes} && $(has_config tm5:co2)
  1476. then
  1477. outdir="output/tm5/$(printf %03d $((leg_number)))"
  1478. mkdir -p ${outdir}
  1479. if $(has_config lpjg)
  1480. then
  1481. for f in CNAT CANT CNPP ; do
  1482. mv TM5_Land${f}_*.nc ${outdir}
  1483. rm -f GUE_${f}_*.nc run1/GUE_${f}_*.nc
  1484. #gf=`ls -1 GUE_${f}_*.nc | head -n 1`
  1485. #cdo mergetime ${gf} run1/${gf} ${outdir}/${gf}
  1486. done
  1487. fi
  1488. if $(has_config pisces)
  1489. then
  1490. mv TM5_OceCFLX_*.nc ${outdir}
  1491. rm -f O_CO2FLX_*.nc
  1492. #mv O_CO2FLX_*.nc ${outdir}
  1493. fi
  1494. fi
  1495. # -------------------------------------------------------------------------
  1496. # *** Move LPJ-GUESS restart files to archive directory
  1497. # -------------------------------------------------------------------------
  1498. if $(has_config lpjg)
  1499. then
  1500. outdir="restart/lpjg/$(printf %03d $((leg_number)))"
  1501. if [ -d ${outdir} ]
  1502. then
  1503. rm -rf ${outdir}
  1504. fi
  1505. mkdir -p ${outdir}
  1506. state_dir="./lpjg_state_$(printf %04d $((leg_end_date_yyyy)))"
  1507. mv ${state_dir} ${outdir}
  1508. # LPJG writes into run1 dir, so mv to main rundir
  1509. mv -f run1/lpjgv.nc .
  1510. has_config tm5:co2 lpjg && mv -f run1/rlpjg.nc .
  1511. # remove restart link
  1512. if $leg_is_restart
  1513. then
  1514. old_state_dir="./lpjg_state_$(printf %04d $((leg_start_date_yyyy)))"
  1515. if [ -L $old_state_dir ]
  1516. then
  1517. rm -f "$old_state_dir"
  1518. fi
  1519. fi
  1520. fi
  1521. # -------------------------------------------------------------------------
  1522. # *** Move NEMO restart files to archive directory
  1523. # -------------------------------------------------------------------------
  1524. if $leg_is_restart && $(has_config nemo)
  1525. then
  1526. outdir="${archive_dir}/restart/nemo/$(printf %03d $((leg_number)))"
  1527. mkdir -p ${outdir}
  1528. ns=$(printf %08d $(( leg_start_sec / nem_time_step_sec - nem_restart_offset )))
  1529. for f in oce ice
  1530. do
  1531. mv ${exp_name}_${ns}_restart_${f}_????.nc ${outdir}
  1532. done
  1533. if has_config pisces
  1534. then
  1535. mv ${exp_name}_${ns}_restart_trc_????.nc ${outdir}
  1536. fi
  1537. fi
  1538. # -------------------------------------------------------------------------
  1539. # *** Move TM5 restart file to archive directory
  1540. # -------------------------------------------------------------------------
  1541. if $leg_is_restart && $(has_config tm5)
  1542. then
  1543. outdir="restart/tm5/$(printf %03d $((leg_number)))"
  1544. mkdir -p ${outdir}
  1545. case ${tm5_istart} in
  1546. 33|32) f=TM5_restart_${leg_start_date_yyyymmdd}_0000_glb300x200.nc
  1547. ;;
  1548. 31) f=save_${leg_start_date_yyyymmdd}00_glb300x200.hdf
  1549. ;;
  1550. esac
  1551. mv $f ${outdir}
  1552. fi
  1553. # -------------------------------------------------------------------------
  1554. # *** Copy OASIS restart files to archive directory
  1555. # NOTE: These files are copied and not moved as they are used in the
  1556. # next leg!
  1557. # Note also that the OASIS restart files present at the end of
  1558. # the leg correspond to the start of the next leg!
  1559. # -------------------------------------------------------------------------
  1560. outdir="${archive_dir}/restart/oasis/$(printf %03d $((leg_number+1)))"
  1561. mkdir -p ${outdir}
  1562. for f in ${oas_rst_files}
  1563. do
  1564. test -f ${f} && cp ${f} ${outdir}
  1565. done
  1566. # -------------------------------------------------------------------------
  1567. # *** Copy rcf files to the archive directory (of the next leg!)
  1568. # -------------------------------------------------------------------------
  1569. outdir="${archive_dir}/restart/ifs/$(printf %03d $((leg_number+1)))"
  1570. mkdir -p ${outdir}
  1571. for f in rcf
  1572. do
  1573. test -f ${f} && cp ${f} ${outdir}
  1574. done
  1575. # -------------------------------------------------------------------------
  1576. # *** Move log files to archive directory
  1577. # -------------------------------------------------------------------------
  1578. outdir="${archive_dir}/log/$(printf %03d $((leg_number)))"
  1579. mkdir -p ${outdir}
  1580. for f in \
  1581. ifs.log ifs.stat fort.4 ocean.output \
  1582. time.step solver.stat guess.log run1/guess0.log \
  1583. amip.log namelist.amip \
  1584. nout.000000 debug.root.?? \
  1585. ctm.tm5.log.0
  1586. do
  1587. test -f ${f} && mv ${f} ${outdir}
  1588. done
  1589. has_config pisces && cp ocean.carbon ${outdir}
  1590. for f in ctm.tm5.log.*
  1591. do
  1592. if [[ -f ${f} ]]
  1593. then
  1594. [[ -s ${f} ]] && mv ${f} ${outdir} || \rm -f ${f}
  1595. fi
  1596. done
  1597. # -------------------------------------------------------------------------
  1598. # *** Write the restart control file
  1599. # -------------------------------------------------------------------------
  1600. # Compute CPMIP performance
  1601. sypd="$(cpmip_sypd $leg_length_sec $(($t2 - $t1)))"
  1602. ncores=0
  1603. has_config nemo && (( ncores+=${nem_numproc} )) || :
  1604. has_config ifs && (( ncores+=${ifs_numproc} )) || :
  1605. has_config xios && (( ncores+=${xio_numproc} )) || :
  1606. has_config rnfmapper && (( ncores+=${rnf_numproc} )) || :
  1607. has_config lpjg && (( ncores+=${lpjg_numproc} )) || :
  1608. has_config tm5 && (( ncores+=${tm5_numproc} )) || :
  1609. has_config amip && (( ncores+=${amip_numproc} )) || :
  1610. chpsy="$(cpmip_chpsy $leg_length_sec $(($t2 - $t1)) $ncores)"
  1611. echo "#" | tee -a ${ece_info_file}
  1612. echo "# Finished leg at `date '+%F %T'` after ${tr} (hh:mm:ss)" \
  1613. | tee -a ${ece_info_file}
  1614. echo "# CPMIP performance: $sypd SYPD $chpsy CHPSY"| tee -a ${ece_info_file}
  1615. echo "leg_number=${leg_number}" | tee -a ${ece_info_file}
  1616. echo "leg_start_date=\"${leg_start_date}\"" | tee -a ${ece_info_file}
  1617. echo "leg_end_date=\"${leg_end_date}\"" | tee -a ${ece_info_file}
  1618. # Need to reset force_run_from_scratch in order to avoid destroying the next leg
  1619. force_run_from_scratch=false
  1620. special_restart=false
  1621. done # loop over legs
  1622. # -----------------------------------------------------------------------------
  1623. # *** Platform dependent finalising of the run
  1624. # -----------------------------------------------------------------------------
  1625. finalise
  1626. exit 0