EC00.sh 78 KB

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