EC02.sh 79 KB

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