ece-nemo.sh.tmpl 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. #!/usr/bin/env bash
  2. set -xuve
  3. cd %CURRENT_ROOTDIR%
  4. # librunscript defines some helper functions
  5. source ./librunscript.sh
  6. # =============================================================================
  7. # *** BEGIN User configuration
  8. # =============================================================================
  9. # -----------------------------------------------------------------------------
  10. # *** General configuration
  11. # -----------------------------------------------------------------------------
  12. # Component configuration
  13. # (for syntax of the $config variable, see librunscript.sh)
  14. # get config from autosubmit variables
  15. [[ "%OCEAN_ini%" = *[!\ ]* ]] && start_from_restart=":start_from_restart" || start_from_restart=""
  16. [ "%OCE_NUDG%" = TRUE ] && ocenudg=":ocenudg" || ocenudg=""
  17. [ "%SURF_RESTO%" = TRUE ] && surfresto=":surfresto" || surfresto=""
  18. [ "%PISCES%" = TRUE ] && pisces="pisces" || pisces=""
  19. [ "%NEMO_remove_land%" = TRUE ] && elpin=":elpin" || elpin=""
  20. if [[ "%SAVE_IC%" = FALSE ]] || [[ "%SAVE_IC%" = "" ]] || [[ "%SAVE_IC%" = "%%SAVE_IC%%" ]]; then save_ic="" ; else save_ic="save_ic:%SAVE_IC%" ; fi
  21. config="nemo${start_from_restart}${ocenudg}${surfresto}${elpin} ${pisces} lim3 xios:detached ${save_ic}"
  22. # Experiment name (exactly 4 letters!)
  23. exp_name=[[[MOD:GENERAL:EXP_NAME]]]
  24. # Simulation start and end date. Use any (reasonable) syntax you want.
  25. run_start_date="[[[MOD:GENERAL:RUN_START_DATE]]]"
  26. run_end_date="[[[MOD:GENERAL:RUN_END_DATE]]]"
  27. # Simulation member. Use any (reasonable) syntax you want.
  28. member="%MEMBER%"
  29. # Set $force_run_from_scratch to 'true' if you want to force this run to start
  30. # from scratch, possibly ignoring any restart files present in the run
  31. # directory. Leave set to 'false' otherwise.
  32. # NOTE: If set to 'true' the run directory $run_dir is cleaned!
  33. force_run_from_scratch=[[[MOD:GENERAL:FORCE_RUN_FROM_SCRATCH]]]
  34. # Resolution
  35. nem_grid=[[[MOD:NEM:GRID]]]
  36. # Restart frequency. Use any (reasonable) number and time unit you want.
  37. # For runs without restart, leave this variable empty
  38. rst_freq="[[[MOD:GENERAL:RST_FREQ]]]"
  39. # Number of restart legs to be run in one go
  40. run_num_legs=[[[MOD:GENERAL:RUN_NUM_LEGS]]]
  41. # Directories
  42. start_dir=${PWD}
  43. ctrl_file_dir=${start_dir}/ctrl
  44. output_control_files_dir=${start_dir}/[[[MOD:GENERAL:OUTPUT_CONTROL_FILES_DIR]]]
  45. # Architecture
  46. build_arch=[[[PLT:ACTIVE:BUILD_ARCH]]]
  47. # This file is used to store information about restarts
  48. ece_info_file="ece.info"
  49. # -----------------------------------------------------------------------------
  50. # *** Read platform dependent configuration
  51. # -----------------------------------------------------------------------------
  52. source ./ecconf.cfg
  53. configure
  54. # -----------------------------------------------------------------------------
  55. # *** Time step settings
  56. # -----------------------------------------------------------------------------
  57. case "${nem_grid}" in
  58. ORCA1L*) nem_time_step_sec=2700; lim_time_step_sec=2700 ;;
  59. ORCA025L*) nem_time_step_sec=900 ; lim_time_step_sec=900 ;;
  60. *) error "Can't set time steps for unknown horizontal grid: ${nem_grid}"
  61. ;;
  62. esac
  63. # -----------------------------------------------------------------------------
  64. # *** NEMO/LIM configuration
  65. # -----------------------------------------------------------------------------
  66. # This is only needed if the experiment is started from an existing set of NEMO
  67. # restart files
  68. nem_restart_file_path=${ini_data_dir}
  69. nem_restart_offset=0
  70. nem_res_hor=$(echo ${nem_grid} | sed 's:ORCA\([0-9]\+\)L[0-9]\+:\1:')
  71. # Pick correct NEMO configuration, which is one of:
  72. # NEMO standalone, NEMO+PISCES-standaone, PISCES-offline
  73. nem_config_name=${nem_grid}_LIM3_standalone
  74. has_config pisces && nem_config_name=${nem_grid}_LIM3_PISCES_standalone
  75. has_config pisces:offline && nem_config_name=${nem_grid}_OFF_PISCES
  76. nem_exe_file=${ecearth_src_dir}/nemo-3.6/CONFIG/${nem_config_name}/BLD/bin/nemo.exe
  77. nem_numproc=[[[MOD:NEM:NUMPROC]]]
  78. # -----------------------------------------------------------------------------
  79. # *** XIOS configuration
  80. # -----------------------------------------------------------------------------
  81. xio_exe_file=${ecearth_src_dir}/xios-2.5/bin/xios_server.exe
  82. xio_numproc=[[[MOD:XIO:NUMPROC]]]
  83. # -----------------------------------------------------------------------------
  84. # *** Extra initial conditions saved during the run
  85. # -----------------------------------------------------------------------------
  86. if has_config save_ic
  87. then
  88. source ./libsave_ic.sh
  89. declare -a save_ic_date save_ic_date1 save_ic_sec save_ic_day save_ic_ppt_file save_ic_nemo_ts
  90. fi
  91. # =============================================================================
  92. # *** END of User configuration
  93. # =============================================================================
  94. # =============================================================================
  95. # *** This is where the code begins ...
  96. # =============================================================================
  97. # -----------------------------------------------------------------------------
  98. # *** Create the run dir if necessary and go there
  99. # Everything is done from here.
  100. # -----------------------------------------------------------------------------
  101. if [ ! -d ${run_dir} ]
  102. then
  103. mkdir -p ${run_dir}
  104. fi
  105. cd ${run_dir}
  106. # -----------------------------------------------------------------------------
  107. # *** Determine the time span of this run and whether it's a restart leg
  108. # -----------------------------------------------------------------------------
  109. # Regularise the format of the start and end date of the simulation
  110. run_start_date=$(absolute_date_noleap "${run_start_date}")
  111. run_end_date=$(absolute_date_noleap "${run_end_date}")
  112. # Loop over the number of legs
  113. for (( ; run_num_legs>0 ; run_num_legs-- ))
  114. do
  115. # Check for restart information file and set the current leg start date
  116. # Ignore restart information file if force_run_from_scratch is true
  117. if ${force_run_from_scratch} || ! [ -r ${ece_info_file} ]
  118. then
  119. leg_is_restart=false
  120. leg_start_date=${run_start_date}
  121. leg_number=1
  122. else
  123. leg_is_restart=true
  124. . ./${ece_info_file}
  125. leg_start_date=${leg_end_date}
  126. leg_number=$((leg_number+1))
  127. fi
  128. # Compute the end date of the current leg
  129. if [ -n "${rst_freq}" ]
  130. then
  131. leg_end_date=$(absolute_date_noleap "${leg_start_date} + ${rst_freq}")
  132. else
  133. leg_end_date=${run_end_date}
  134. fi
  135. if [ $(date -d "${leg_end_date}" +%s) -gt $(date -d "${run_end_date}" +%s) ]
  136. then
  137. leg_end_date=${run_end_date}
  138. fi
  139. # Some time variables needed later
  140. leg_length_sec=$(( $(date -d "${leg_end_date}" +%s) - $(date -d "${leg_start_date}" +%s) ))
  141. leg_start_sec=$(( $(date -d "${leg_start_date}" +%s) - $(date -d "${run_start_date}" +%s) ))
  142. leg_end_sec=$(( $(date -d "${leg_end_date}" +%s) - $(date -d "${run_start_date}" +%s) ))
  143. leg_start_date_yyyymmdd=$(date -u -d "${leg_start_date}" +%Y%m%d)
  144. leg_start_date_yyyy=$(date -u -d "${leg_start_date}" +%Y)
  145. leg_end_date_yyyy=$(date -u -d "${leg_end_date}" +%Y)
  146. # Correct for leap days because NEMO standalone uses no-leap calendar
  147. leg_length_sec=$(( leg_length_sec - $(leap_days "${leg_start_date}" "${leg_end_date}")*24*3600 ))
  148. leg_start_sec=$(( leg_start_sec - $(leap_days "${run_start_date}" "${leg_start_date}")*24*3600 ))
  149. leg_end_sec=$(( leg_end_sec - $(leap_days "${run_start_date}" "${leg_end_date}")*24*3600 ))
  150. # Check whether there's actually time left to simulate - exit otherwise
  151. if [ ${leg_length_sec} -le 0 ]
  152. then
  153. info "Leg start date equal to or after end of simulation."
  154. info "Nothing left to do. Exiting."
  155. exit 0
  156. fi
  157. # Initial conditions saved during the run
  158. do_save_ic=false
  159. save_ic_custom=false
  160. has_config save_ic && save_ic_get_config
  161. # if you do not use an option with save_ic, you must define 'do_save_ic' and
  162. # 'save_ic_date_offset' here or in ../libsave_ic.sh/save_ic_get_config()
  163. # with AS runtime, no need to edit the script, set SAVE_IC_OFFSET (and optionally SAVE_IC_COND)
  164. if $save_ic_custom
  165. then
  166. [[ "%SAVE_IC_COND%" = "" ]] || [[ "%SAVE_IC_COND%" = "%%SAVE_IC_COND%%" ]] \
  167. && save_ic_cond=true || save_ic_cond='%SAVE_IC_COND%'
  168. if eval $save_ic_cond ; then do_save_ic=true ; else do_save_ic=false ; fi
  169. save_ic_date_offset=( %SAVE_IC_OFFSET% )
  170. fi
  171. ${do_save_ic} && save_ic_define_vars
  172. # -------------------------------------------------------------------------
  173. # *** Prepare the run directory for a run from scratch
  174. # -------------------------------------------------------------------------
  175. if ! $leg_is_restart
  176. then
  177. # ---------------------------------------------------------------------
  178. # *** Check if run dir is empty. If not, and if we are allowed to do so
  179. # by ${force_run_from_scratch}, remove everything
  180. # ---------------------------------------------------------------------
  181. if $(ls * >& /dev/null)
  182. then
  183. if ${force_run_from_scratch}
  184. then
  185. rm -fr ${run_dir}/*
  186. else
  187. error "Run directory not empty and \$force_run_from_scratch not set."
  188. fi
  189. fi
  190. # ---------------------------------------------------------------------
  191. # *** Copy executables of model components
  192. # *** Additionally, create symlinks to the original place for reference
  193. # ---------------------------------------------------------------------
  194. cp ${nem_exe_file} .
  195. ln -s ${nem_exe_file} $(basename ${nem_exe_file}).lnk
  196. cp ${xio_exe_file} .
  197. ln -s ${xio_exe_file} $(basename ${xio_exe_file}).lnk
  198. # ---------------------------------------------------------------------
  199. # *** Files needed for NEMO (linked)
  200. # ---------------------------------------------------------------------
  201. # Link initialisation files for matching ORCA grid
  202. for f in \
  203. bathy_meter.nc coordinates.nc \
  204. ahmcoef.nc \
  205. K1rowdrg.nc M2rowdrg.nc mask_itf.nc \
  206. decay_scale_bot.nc decay_scale_cri.nc \
  207. mixing_power_bot.nc mixing_power_cri.nc mixing_power_pyc.nc \
  208. runoff_depth.nc subbasins.nc
  209. do
  210. [ -f ${ini_data_dir}/nemo/initial/${nem_grid}/$f ] && ln -s ${ini_data_dir}/nemo/initial/${nem_grid}/$f
  211. done
  212. # Link geothermal heating file (independent of grid) and matching weight file
  213. ln -s ${ini_data_dir}/nemo/initial/Goutorbe_ghflux.nc
  214. ln -s ${ini_data_dir}/nemo/initial/weights_Goutorbe1_2_orca${nem_res_hor}_bilinear.nc
  215. # Link the salinity climatology file (needed for diagnostics)
  216. ln -s ${ini_data_dir}/nemo/climatology/${nem_grid}/sali_ref_clim_monthly.nc
  217. # Link either restart files or climatology files for the initial state
  218. if $(has_config nemo:start_from_restart)
  219. then
  220. # When linking restart files, we accept three options:
  221. # (1) Merged files for ocean and ice, i.e.
  222. # restart_oce.nc and restart_ice.nc
  223. # (2) One-file-per-MPI-rank, i.e.
  224. # restart_oce_????.nc and restart_ice_????.nc
  225. # No check is done whether the number of restart files agrees
  226. # with the number of MPI ranks for NEMO!
  227. # (3) One-file-per-MPI-rank with a prefix, i.e.
  228. # <exp_name>_<time_step>_restart_oce_????.nc (similar for the ice)
  229. # The prefix is ignored.
  230. # The code assumes that one of the options can be applied! If more
  231. # options are applicable, the first is chosen. If none of the
  232. # options apply, NEMO will crash with missing restart file.
  233. if ls -U ${nem_restart_file_path}/restart_[oi]ce.nc > /dev/null 2>&1
  234. then
  235. ln -s ${nem_restart_file_path}/restart_[oi]ce.nc ./
  236. elif ls -U ${nem_restart_file_path}/restart_[oi]ce_????.nc > /dev/null 2>&1
  237. then
  238. ln -s ${nem_restart_file_path}/restart_[oi]ce_????.nc ./
  239. else
  240. for f in ${nem_restart_file_path}/????_????????_restart_[oi]ce_????.nc
  241. do
  242. ln -s $f $(echo $f | sed 's/.*_\(restart_[oi]ce_....\.nc\)/\1/')
  243. done
  244. fi
  245. else
  246. # Temperature and salinity files for initialisation
  247. ln -s ${ini_data_dir}/nemo/climatology/absolute_salinity_WOA13_decav_Reg1L75_clim.nc
  248. ln -s ${ini_data_dir}/nemo/climatology/conservative_temperature_WOA13_decav_Reg1L75_clim.nc
  249. ln -s ${ini_data_dir}/nemo/climatology/weights_WOA13d1_2_orca${nem_res_hor}_bilinear.nc
  250. fi
  251. # Grid dependent runoff files
  252. case ${nem_grid} in
  253. ORCA1*) ln -s ${ini_data_dir}/nemo/climatology/runoff-icb_DaiTrenberth_Depoorter_ORCA1_JD.nc ;;
  254. ORCA025*) ln -s ${ini_data_dir}/nemo/climatology/ORCA_R025_runoff_v1.1.nc ;;
  255. esac
  256. #for ocean_nudging
  257. if $(has_config nemo:ocenudg) ; then
  258. ln -fs ${ini_data_dir}/nemo/oce_nudg/resto.nc ./
  259. fi
  260. # Write fake file for previous fresh water budget adjustment (nn_fwb==2 in namelist)
  261. echo " 0 0.0000000000000000E+00 0.0000000000000000E+00" > EMPave_old.dat
  262. # Link NEMO CoreII forcing files (only set supported out-of-the-box)
  263. for v in u_10 v_10 t_10 q_10 ncar_precip ncar_rad
  264. do
  265. f="${ini_data_dir}/nemo/forcing/CoreII/${v}.15JUNE2009_fill.nc"
  266. [ -f "$f" ] && ln -s $f
  267. done
  268. # Link CoreII weight files for corresponding grid
  269. ln -s ${ini_data_dir}/nemo/forcing/CoreII/weights_coreII_2_orca${nem_res_hor}_bilinear.nc
  270. ln -s ${ini_data_dir}/nemo/forcing/CoreII/weights_coreII_2_orca${nem_res_hor}_bicubic.nc
  271. # XIOS files
  272. . ${ctrl_file_dir}/iodef.xml.sh > iodef.xml
  273. ln -s ${ctrl_file_dir}/context_nemo.xml
  274. ln -s ${ctrl_file_dir}/domain_def_nemo.xml
  275. ln -s ${ctrl_file_dir}/axis_def_nemo.xml
  276. ln -s ${ctrl_file_dir}/grids_def_nemo.xml
  277. ln -s ${ctrl_file_dir}/field_def_nemo-lim.xml
  278. ln -s ${ctrl_file_dir}/field_def_nemo-opa.xml
  279. ln -s ${ctrl_file_dir}/field_def_nemo-pisces.xml
  280. ln -s ${ctrl_file_dir}/field_def_nemo-inerttrc.xml
  281. ln -s ${output_control_files_dir}/file_def_nemo-lim3.xml file_def_nemo-lim.xml
  282. ln -s ${output_control_files_dir}/file_def_nemo-opa.xml
  283. ln -s ${output_control_files_dir}/file_def_nemo-pisces.xml
  284. if [ -f ${ini_data_dir}/xios/ORCA${nem_res_hor}/coordinates_xios.nc ]
  285. then
  286. cp ${ini_data_dir}/xios/ORCA${nem_res_hor}/coordinates_xios.nc ./
  287. else
  288. info "File 'coordinates_xios.nc' not found. NEMO can not be run with land domain removal!"
  289. fi
  290. # ---------------------------------------------------------------------
  291. # *** Files needed for TOP/PISCES (linked)
  292. # ---------------------------------------------------------------------
  293. if $(has_config pisces)
  294. then
  295. ln -fs ${ini_data_dir}/pisces/dust_INCA_ORCA_R1.nc
  296. ln -fs ${ini_data_dir}/pisces/ndeposition_Duce_ORCA_R1.nc
  297. ln -fs ${ini_data_dir}/pisces/pmarge_etopo_ORCA_R1.nc
  298. ln -fs ${ini_data_dir}/pisces/river_global_news_ORCA_R1.nc
  299. ln -fs ${ini_data_dir}/pisces/Solubility_T62_Mahowald_ORCA_R1.nc
  300. ln -fs ${ini_data_dir}/pisces/par_fraction_gewex_clim90s00s_ORCA_R1.nc
  301. ln -fs ${ini_data_dir}/pisces/DIC_GLODAP_annual_ORCA_R1.nc
  302. ln -fs ${ini_data_dir}/pisces/Alkalini_GLODAP_annual_ORCA_R1.nc
  303. ln -fs ${ini_data_dir}/pisces/O2_WOA2009_monthly_ORCA_R1.nc
  304. ln -fs ${ini_data_dir}/pisces/PO4_WOA2009_monthly_ORCA_R1.nc
  305. ln -fs ${ini_data_dir}/pisces/Si_WOA2009_monthly_ORCA_R1.nc
  306. ln -fs ${ini_data_dir}/pisces/DOC_PISCES_monthly_ORCA_R1.nc
  307. ln -fs ${ini_data_dir}/pisces/Fer_PISCES_monthly_ORCA_R1.nc
  308. ln -fs ${ini_data_dir}/pisces/NO3_WOA2009_monthly_ORCA_R1.nc
  309. fi
  310. else # i.e. $leg_is_restart == true
  311. # ---------------------------------------------------------------------
  312. # *** Remove all leftover output files from previous legs
  313. # ---------------------------------------------------------------------
  314. # NEMO output files
  315. rm -f ${exp_name}_??_????????_????????_{grid_U,grid_V,grid_W,grid_T,icemod,SBC,scalar,SBC_scalar,diad_T}.nc
  316. restart_dir="restart/nemo/$(printf %03d $((leg_number)))"
  317. [ -f ${restart_dir}/EMPave_old.dat ] && cp ${restart_dir}/EMPave_old.dat .
  318. fi # ! $leg_is_restart
  319. #--------------------------------------------------------------------------
  320. # *** Surface restoring and ocean nudging options
  321. #--------------------------------------------------------------------------
  322. #for ocean_nudging
  323. if $(has_config nemo:ocenudg) ; then
  324. ln -fs ${ini_data_dir}/nemo/oce_nudg/temp_sal_*.nc ./
  325. fi
  326. #for surface restoring
  327. if $(has_config nemo:surfresto) ; then
  328. ln -fs ${ini_data_dir}/nemo/surface_restoring/sss_restore_data*.nc ./
  329. ln -fs ${ini_data_dir}/nemo/surface_restoring/sst_restore_data*.nc ./
  330. ln -fs ${ini_data_dir}/nemo/surface_restoring/mask_restore*.nc ./
  331. fi
  332. # -------------------------------------------------------------------------
  333. # *** Remove land grid-points
  334. # -------------------------------------------------------------------------
  335. if $(has_config nemo:elpin)
  336. then
  337. if [ ! -f coordinates_xios.nc ]
  338. then
  339. error "ELpIN requested, but file 'coordinates_xios.nc' was not found"
  340. fi
  341. jpns=($(${ecearth_src_dir}/util/ELPiN/ELPiNv2.cmd ${nem_numproc}))
  342. info "nemo domain decompostion from ELpIN: ${jpns[@]}"
  343. nem_numproc=${jpns[0]}
  344. nem_jpni=${jpns[1]}
  345. nem_jpnj=${jpns[2]}
  346. else
  347. info "nemo original domain decomposition (not using ELPiN)"
  348. fi
  349. # -------------------------------------------------------------------------
  350. # *** Initial conditions saved during the run
  351. # -------------------------------------------------------------------------
  352. ${do_save_ic} && save_ic_prepare_output
  353. # -------------------------------------------------------------------------
  354. # *** Create some control files
  355. # -------------------------------------------------------------------------
  356. # NEMO and LIM namelists
  357. . ${ctrl_file_dir}/namelist.nemo.ref.sh > namelist_ref
  358. . ${ctrl_file_dir}/namelist.nemo-${nem_grid}-standalone.cfg.sh > namelist_cfg
  359. . ${ctrl_file_dir}/namelist.lim3.ref.sh > namelist_ice_ref
  360. . ${ctrl_file_dir}/namelist.lim3-${nem_grid}.cfg.sh > namelist_ice_cfg
  361. # NEMO/TOP+PISCES namelists
  362. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.top.ref.sh > namelist_top_ref
  363. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.top.cfg.sh > namelist_top_cfg
  364. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.pisces.ref.sh > namelist_pisces_ref
  365. has_config pisces && . ${ctrl_file_dir}/namelist.nemo.pisces.cfg.sh > namelist_pisces_cfg
  366. # -------------------------------------------------------------------------
  367. # *** Link the appropriate NEMO restart files of the previous leg
  368. # -------------------------------------------------------------------------
  369. if $leg_is_restart
  370. then
  371. ns=$(printf %08d $(( leg_start_sec / nem_time_step_sec - nem_restart_offset )))
  372. for (( n=0 ; n<nem_numproc ; n++ ))
  373. do
  374. np=$(printf %04d ${n})
  375. ln -fs ${exp_name}_${ns}_restart_oce_${np}.nc restart_oce_${np}.nc
  376. ln -fs ${exp_name}_${ns}_restart_ice_${np}.nc restart_ice_${np}.nc
  377. has_config pisces && \
  378. ln -fs ${exp_name}_${ns}_restart_trc_${np}.nc restart_trc_${np}.nc
  379. done
  380. # Make sure there are no global restart files
  381. # If links are found, they will be removed. We are cautious and do
  382. # _not_ remove real files! However, if real global restart files are
  383. # present, NEMO/LIM will stop because time stamps will not match.
  384. [ -h restart_oce.nc ] && rm restart_oce.nc
  385. [ -h restart_ice.nc ] && rm restart_ice.nc
  386. fi
  387. # -------------------------------------------------------------------------
  388. # *** Start the run
  389. # -------------------------------------------------------------------------
  390. # Use the launch function from the platform configuration file
  391. t1=$(date +%s)
  392. launch \
  393. ${xio_numproc} ${xio_exe_file} -- \
  394. ${nem_numproc} ${nem_exe_file}
  395. t2=$(date +%s)
  396. tr=$(date -d "0 -$t1 sec + $t2 sec" +%T)
  397. # -------------------------------------------------------------------------
  398. # *** Check for signs of success
  399. # Note the tests provide no guarantee that things went fine! They are
  400. # just based on the IFS and NEMO log files. More tests (e.g. checking
  401. # restart files) could be implemented.
  402. # -------------------------------------------------------------------------
  403. # Check for NEMO success
  404. if [ -f ocean.output ]
  405. then
  406. if [ "$(sed -n '/New day/h; ${g;s:.*\([0-9/]\{10\}\).*:\1:;p;}' ocean.output)" == "$(date -u -d "$(absolute_date_noleap "${leg_end_date} - 1 day")" +%Y/%m/%d)" ]
  407. then
  408. info "Leg successfully completed according to NEMO log file 'ocean.output'."
  409. else
  410. error "Leg not completed according to NEMO log file 'ocean.output'."
  411. fi
  412. else
  413. error "NEMO log file 'ocean.output' not found after run."
  414. fi
  415. # -------------------------------------------------------------------------
  416. # *** Post-process initial conditions saved during the run if requested
  417. # -------------------------------------------------------------------------
  418. ${do_save_ic} && save_ic_postproc
  419. # -------------------------------------------------------------------------
  420. # *** Move NEMO output files to archive directory
  421. # -------------------------------------------------------------------------
  422. outdir="output/nemo/$(printf %03d $((leg_number)))"
  423. mkdir -p ${outdir}
  424. for v in grid_U grid_V grid_W grid_T icemod SBC scalar SBC_scalar diad_T \
  425. grid_T_2D grid_U_2D grid_V_2D grid_W_2D grid_T_3D grid_U_3D grid_V_3D grid_W_3D \
  426. grid_1point grid_T_3D_ncatice vert_sum \
  427. grid_ptr_W_3basin_3D grid_ptr_T_3basin_2D grid_ptr_T_2D \
  428. zoom_700_sum zoom_300_sum zoom_2000_sum
  429. do
  430. for f in ${exp_name}_*_????????_????????_*${v}.nc
  431. do
  432. test -f $f && mv $f $outdir/
  433. done
  434. done
  435. # -------------------------------------------------------------------------
  436. # *** Move NEMO restart files to archive directory
  437. # -------------------------------------------------------------------------
  438. if $leg_is_restart
  439. then
  440. outdir="restart/nemo/$(printf %03d $((leg_number)))"
  441. mkdir -p ${outdir}
  442. ns=$(printf %08d $(( leg_start_sec / nem_time_step_sec - nem_restart_offset )))
  443. for f in oce ice trc
  444. do
  445. test -f ${exp_name}_${ns}_restart_${f}_0000.nc && \
  446. mv ${exp_name}_${ns}_restart_${f}_????.nc ${outdir}
  447. done
  448. cp EMPave_old.dat ${outdir}/EMPave_old.dat
  449. fi
  450. cp EMPave.dat EMPave_old.dat
  451. # -------------------------------------------------------------------------
  452. # *** Move log files to archive directory
  453. # -------------------------------------------------------------------------
  454. outdir="log/$(printf %03d $((leg_number)))"
  455. mkdir -p ${outdir}
  456. for f in \
  457. ocean.output time.step solver.stat
  458. do
  459. test -f ${f} && mv ${f} ${outdir}
  460. done
  461. # -------------------------------------------------------------------------
  462. # *** Write the restart control file
  463. # -------------------------------------------------------------------------
  464. # Compute CPMIP performance
  465. sypd="$(cpmip_sypd $leg_length_sec $(($t2 - $t1)))"
  466. chpsy="$(cpmip_chpsy $leg_length_sec $(($t2 - $t1)) $(($nem_numproc + $xio_numproc)))"
  467. echo "#" | tee -a ${ece_info_file}
  468. echo "# Finished leg at `date '+%F %T'` after ${tr} (hh:mm:ss)" \
  469. | tee -a ${ece_info_file}
  470. echo "# CPMIP performance: $sypd SYPD $chpsy CHPSY"| tee -a ${ece_info_file}
  471. echo "leg_number=${leg_number}" | tee -a ${ece_info_file}
  472. echo "leg_start_date=\"${leg_start_date}\"" | tee -a ${ece_info_file}
  473. echo "leg_end_date=\"${leg_end_date}\"" | tee -a ${ece_info_file}
  474. # Need to reset force_run_from_scratch in order to avoid destroying the next leg
  475. force_run_from_scratch=false
  476. done # loop over legs
  477. # -----------------------------------------------------------------------------
  478. # *** Platform dependent finalising of the run
  479. # -----------------------------------------------------------------------------
  480. finalise