ece-esm.sh.tmpl 78 KB

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