# ICON
#
# ------------------------------------------
# Copyright (C) 2004-2026, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: BSD-3-Clause
# ------------------------------------------

# ----------------------------------------------------------------------------
#
# ICON-ART Regional LAM
#
#-----------------------------------------------------------------------------
#
# This simulation performs the selected chemical tracers using an online emission module.
#
#=============================================================================

INDIR=${basedir}/../../TESTSUITE
OUTDIR=${basedir}/experiments/horeka_art_lam_oem_base
ICONFOLDER=${basedir}
ARTFOLDER=${basedir}/externals/art
EXP=LAM_OEM
lart=.True.

FILETYPE=5
restart=.False.
read_restart_namelists=.False.

# Create output directory and go to this directory

if [ ! -d $OUTDIR ]; then
    mkdir -p $OUTDIR
fi

cd $OUTDIR


# ----------------------------------------------------------------------
# SETTINGS: directories
# ----------------------------------------------------------------------

this_folder=$(pwd)

ARTFOLDER=${ICONFOLDER}/externals/art
RADFOLDER=${ICONFOLDER}/externals/ecrad/data

ln -sfn ${ARTFOLDER}/runctrl_examples/oem_testcase_files/icbc/ICON-ART-UNSTRUCTURED_DOM01_20220818T00.nc ${ARTFOLDER}/runctrl_examples/oem_testcase_files/ART_ICE_iconR19B09-grid_.nc

# ----------------------------------------------------------------------------
# create ICON master namelist
# ----------------------------------------------------------------------------

cat > icon_master.namelist << EOF
! master_nml: ----------------------------------------------------------------
&master_nml
 lrestart                   =                     .FALSE.        ! .TRUE.=current experiment is resumed
/

! master_model_nml: repeated for each model ----------------------------------
&master_model_nml
 model_type                  =                          1         ! identifies which component to run (atmosphere,ocean,...)
 model_name                  =                      "ATMO"        ! character string for naming this component.
 model_namelist_filename     =              "NAMELIST_NWP"        ! file name containing the model namelists
 model_min_rank              =                          1         ! start MPI rank for this model
 model_max_rank              =                      65536         ! end MPI rank for this model
 model_inc_rank              =                          1         ! stride of MPI ranks
/

! time_nml: specification of date and time------------------------------------
&time_nml
 ini_datetime_string         =      "2022-08-18T00:00:00Z"        ! initial date and time of the simulation
 end_datetime_string         =      "2022-08-18T01:00:00Z"        ! end date and time of the simulation 10T00
/
EOF

# ----------------------------------------------------------------------
# model namelists
# ----------------------------------------------------------------------

cat > NAMELIST_NWP << EOF
! parallel_nml: MPI parallelization -------------------------------------------
&parallel_nml
 nproma                      =                          8
 !nblocks_c                   =                          1
 !nproma_sub                  =                          800         ! loop chunk length
 p_test_run                  =                     .FALSE.        ! .TRUE. means verification run for MPI parallelization
 num_io_procs                =                          1         ! number of I/O processors
 num_restart_procs           =                          0         ! number of restart processors
 num_prefetch_proc           =                          1         ! number of processors for LBC prefetching
 iorder_sendrecv             =                          3         ! sequence of MPI send/receive calls
/


! run_nml: general switches ---------------------------------------------------
&run_nml
 ltestcase                   =                     .FALSE.        ! real case run
 num_lev                     =                         60         ! number of full levels (atm.) for each domain
 lvert_nest                  =                     .FALSE.        ! no vertical nesting
 dtime                       =                         5            ! timestep in seconds
 ldynamics                   =                      .TRUE.        ! compute adiabatic dynamic tendencies
 ltransport                  =                      .TRUE.        ! compute large-scale tracer transport
 ntracer                     =                          0         ! number of advected tracers
 iforcing                    =                          3         ! forcing of dynamics and transport by parameterized processes
 msg_level                   =                          10         ! detailed report during integration
 ltimer                      =                      .TRUE.        ! timer for monitoring the runtime of specific routines
 timers_level                =                         10         ! performance timer granularity
 check_uuid_gracefully       =                      .TRUE.        ! give only warnings for non-matching uuids
 output                      =                        "nml"       ! main switch for enabling/disabling components of the model output
 lart                        =                      .TRUE.        ! main switch for ART
 debug_check_level           =                         10
/

! art_nml: Aerosols and Reactive Trace gases extension-------------------------------------------------
&art_nml
 lart_chem                  =                        .TRUE.       ! enables chemistry
 lart_pntSrc                =                        .FALSE.       ! enables point sources
 lart_aerosol               =                       .FALSE.       ! main switch for the treatment of atmospheric aerosol
 lart_chemtracer            =                        .TRUE.       ! main switch for the treatment of chemical tracer
 lart_diag_out              =                        .TRUE.       ! If this switch is set to .TRUE., diagnostic
                                                                  ! ... output elds are available. Set it to
                                                                  ! ... .FALSE. when facing memory problems.
 iart_init_gas              =                            5
 cart_cheminit_file         = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/icbc/ICON-ART-UNSTRUCTURED_DOM01_20220818T00.nc"
 iart_seasalt               =                            0        ! enable seasalt
 cart_chemtracer_xml        = '${ARTFOLDER}/runctrl_examples/oem_testcase_files/xml/vprm_ensemble_co2_186_2022.xml'       ! path to xml file for passive tracers
 cart_pntSrc_xml            = '${ARTFOLDER}/runctrl_examples/oem_testcase_files/xml/boundaries_run.xml'
 cart_input_folder          = '${ARTFOLDER}/runctrl_examples/oem_testcase_files'       ! absolute Path to ART source code
 cart_io_suffix             = '.nc'
/

! oem_nml: online emission module ---------------------------------------------
&oemctrl_nml
 gridded_emissions_nc        =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/oem_gridded_emissions_HR_22_LPS_2.nc'
 vertical_profile_nc         =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/vertical_profiles_HR_ZH.nc'
 hour_of_day_nc              =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/hourofday.nc'
 day_of_week_nc              =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/dayofweek.nc'
 month_of_year_nc            =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/monthofyear.nc'
 hour_of_year_nc             =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/hourofyear_Hagenholz.nc'
 ens_reg_nc                  =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/vprm/Regions_new.nc'
 ens_lambda_nc               =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/lambda_2022081800_priorcycle1.nc'
 vegetation_indices_nc       =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/vprm/VPRM_indices_ICON_ZH_22_23_new.nc'
 boundary_lambda_nc          =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/oae/bg_lambda_2022081800_priorcycle1.nc'
 boundary_regions_nc         =   '${ARTFOLDER}/runctrl_examples/oem_testcase_files/boundary_mask_ZH_beov3_ic_order.nc'
 vprm_par                    =  452.0801019142973, 356.9982743495175, 444.35135030708693, 483.71014017898636,  6.820000E+02,  549.8142194931744, 545.613483159301, 0.0E+00
 vprm_lambda                 = -0.1976385733575807, -0.16249650220700065, -0.15183296864822501, -0.12614291858843657, -1.141000E-01, -0.10418834453782252, -0.13114180960813507, 0.0E+00
 vprm_alpha                  =  0.3002548628277834, 0.22150160044981743, 0.20130383953759856, 0.238064533552737,  4.900000E-03,  0.19239326299324863, 0.405695555089534, 0.0E+00
 vprm_beta                   = 0.6884293574708447, 1.0916535677003347, 1.7074258216614222, 0.18946623368956772,  0.000000E+00,  0.17642838146641998, 0.41774465249044423, 0.0E+00
 vprm_tmin                   =  0.0,  0.0,  0.0,  2.0,  2.0,  5.0,  2.0, 0.0
 vprm_tmax                   = 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0
 vprm_topt                   = 20.0, 20.0, 20.0, 20.0, 20.0, 22.0, 18.0, 0.0
 vprm_tlow                   =  4.0,  0.0,  2.0,  4.0,  0.0,  0.0,  0.0, 0.0
 lcut_area                   =   .FALSE.
 lon_cut_start               =   5.0
 lon_cut_end                 =   15.0
 lat_cut_start               =   45.0
 lat_cut_end                 =   55.0
/


! diffusion_nml: horizontal (numerical) diffusion ----------------------------
&diffusion_nml
 lhdiff_vn                   =                      .TRUE.        ! diffusion on the horizontal wind field
 lhdiff_temp                 =                      .TRUE.        ! diffusion on the temperature field
 lhdiff_w                    =                      .TRUE.        ! diffusion on the vertical wind field
 hdiff_order                 =                          5         ! order of nabla operator for diffusion
 itype_vn_diffu              =                          1         ! reconstruction method used for Smagorinsky diffusion
 itype_t_diffu               =                          2         ! discretization of temperature diffusion
 hdiff_efdt_ratio            =                         24.0       ! ratio of e-folding time to time step
 hdiff_smag_fac              =                          0.025     ! scaling factor for Smagorinsky diffusion
/

! dynamics_nml: dynamical core -----------------------------------------------
&dynamics_nml
 iequations                  =                          3         ! type of equations and prognostic variables
 lcoriolis                   =                      .TRUE.        ! Coriolis force
/

! extpar_nml: external data --------------------------------------------------
&extpar_nml
 itopo                       =                          1         ! topography (0:analytical)
 extpar_filename             = '${ARTFOLDER}/runctrl_examples/oem_testcase_files/grid/extpar_ZH_beov3_J_merged.nc'        ! filename of external parameter input file
 n_iter_smooth_topo          =                        5         ! iterations of topography smoother
 hgtdiff_max_smooth_topo     =                          500.        ! see Namelist doc
 heightdiff_threshold        =                         900.
 itype_vegetation_cycle      =                          3         ! gdm orig. 1 tweaks the annual cycle of LAI
 itype_lwemiss               =                          2
/

! initicon_nml: specify read-in of initial state ------------------------------
&initicon_nml
 init_mode                   =                        7         ! 7: start from DWD fg with subsequent vertical remapping
 lread_ana                   =                    .FALSE.         ! no analysis data will be read
 dwdfg_filename              =          "${ARTFOLDER}/runctrl_examples/oem_testcase_files/icbc/ICON-ART-UNSTRUCTURED_DOM01_20220818T00.nc"        ! initial data filename
 ana_varnames_map_file       = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/mapping/map_file_ZH.ana"        ! dictionary mapping internal names onto GRIB2 shortNames
 ltile_coldstart             =                      .TRUE.        ! coldstart for surface tiles
 ltile_init                  =                     .FALSE.        ! set it to .TRUE. if FG data originate from run without tiles
/

! grid_nml: horizontal grid --------------------------------------------------
&grid_nml
 dynamics_grid_filename      = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/grid/icon_Zurich_R19B9_beo_v3_DOM01.nc"  ! array of the grid filenames for the dycore
 radiation_grid_filename     = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/grid/icon_Zurich_R19B9_beo_v3_DOM01.parent.nc" ! array of the grid filenames for the radiation model
 dynamics_parent_grid_id     =                          0         ! array of the indexes of the parent grid filenames
 lredgrid_phys               =                      .TRUE.        ! .true.=radiation is calculated on a reduced grid
 lfeedback                   =                      .TRUE.        ! specifies if feedback to parent grid is performed
 l_limited_area              =                      .TRUE.        ! .TRUE. performs limited area run
 ifeedback_type              =                          2         ! feedback type (incremental/relaxation-based)
 start_time                  =                          0.        ! Time when a nested domain starts to be active [s]
/

! gridref_nml: grid refinement settings --------------------------------------
&gridref_nml
 denom_diffu_v               =                        150.        ! denominator for lateral boundary diffusion of velocity
/

! interpol_nml: settings for internal interpolation methods ------------------
&interpol_nml
 nudge_zone_width            =                          10         ! width of lateral boundary nudging zone
 support_baryctr_intp        =                     .FALSE.        ! barycentric interpolation support for output
 nudge_max_coeff             =                       0.069
 nudge_efold_width           =                        2.0
/


! io_nml: general switches for model I/O -------------------------------------
&io_nml
 itype_pres_msl              =                          5         ! method for computation of mean sea level pressure
 itype_rh                    =                          1         ! method for computation of relative humidity
 lmask_boundary              =                      .TRUE.        ! mask out interpolation zone in output
/

! limarea_nml: settings for limited area mode ---------------------------------
&limarea_nml
 itype_latbc                 =                          1         ! 1: time-dependent lateral boundary conditions
 dtime_latbc                 =                        3600         ! time difference between 2 consecutive boundary data
 nlev_latbc                  =                         60         ! Number of vertical levels in boundary data
 latbc_boundary_grid         = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/grid/lateral_boundary.grid.nc"       ! Grid file defining the lateral boundary
 latbc_path                  = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/icbc" ! Absolute path to boundary data
 latbc_varnames_map_file     = "${ARTFOLDER}/runctrl_examples/oem_testcase_files/grid/map_file_ZH.latbc"
 latbc_filename              = "ICON-ART-UNSTRUCTURED_DOM01_<y><m><d>T<h>_lbc.nc" ! boundary data input filename
 init_latbc_from_fg          =                     .FALSE.        ! .TRUE.: take lbc for initial time from first guess
/

! lnd_nml: land scheme switches -----------------------------------------------
&lnd_nml
 ntiles                      =                          3         ! number of tiles
 nlev_snow                   =                          3         ! number of snow layers
 lmulti_snow                 =                      .FALSE.       ! .TRUE. for use of multi-layer snow model
 idiag_snowfrac              =                         20         ! type of snow-fraction diagnosis
 lsnowtile                   =                       .TRUE.       ! .TRUE.=consider snow-covered and snow-free separately
 itype_root                  =                          2         ! root density distribution
 itype_heatcond              =                          3         ! type of soil heat conductivity
 itype_lndtbl                =                          4         ! table for associating surface parameters
 itype_evsl                  =                          4         ! type of bare soil evaporation
 itype_root                  =                          2         ! root density distribution
 cwimax_ml                   =                      5.e-4         ! scaling parameter for max. interception storage
 c_soil                      =                       1.25         ! surface area density of the evaporative soil surface
 c_soil_urb                  =                        0.5         ! same for urban areas
 lseaice                     =                      .FALSE.        ! .TRUE. for use of sea-ice model
 llake                       =                      .TRUE.        ! .TRUE. for use of lake model
 itype_canopy                =                          2         ! Jan Peter scheme gdm orig. default 1
 itype_snowevap              =                          3         ! gdm: orig.: 2 Snow evap. in vegetated areas with add. variables for snow age and max. snow height
 itype_trvg                  =                          3         ! BATS scheme with add. prog. var. for integrated plant transpiration since sunrise
 sstice_mode                 =                          2         ! 2: SST is updated on a daily basis by climatological increments
/

! nonhydrostatic_nml: nonhydrostatic model -----------------------------------
&nonhydrostatic_nml
 iadv_rhotheta               =                          2         ! advection method for rho and rhotheta
 ivctype                     =                          2         ! type of vertical coordinate
 itime_scheme                =                          4         ! time integration scheme
 ndyn_substeps               =                          5         ! number of dynamics steps per fast-physics step
 exner_expol                 =                          0.333     ! temporal extrapolation of Exner function
 vwind_offctr                =                          0.2       ! off-centering in vertical wind solver
 damp_height                 =                      8000.0       ! height at which Rayleigh damping of vertical wind starts 12250.0
 rayleigh_coeff              =                          5.0       ! Rayleigh damping coefficient
 divdamp_order               =                         24         ! order of divergence damping
 divdamp_type                =                         32          ! type of divergence damping
 divdamp_fac                 =                          0.004     ! scaling factor for divergence damping
 igradp_method               =                          3         ! discretization of horizontal pressure gradient
 l_zdiffu_t                  =                      .TRUE.        ! specifies computation of Smagorinsky temperature diffusion
 thslp_zdiffu                =                          0.02      ! slope threshold (temperature diffusion)
 thhgtd_zdiffu               =                        125.0       ! threshold of height difference (temperature diffusion)
 htop_moist_proc             =                      22500.0       ! max. height for moist physics
 hbot_qvsubstep              =                      22500.0       ! height above which QV is advected with substepping scheme
/

! nwp_phy_nml: switches for the physics schemes ------------------------------
&nwp_phy_nml
 inwp_gscp                   =                          2         ! cloud microphysics and precipitation
 inwp_convection             =                          1         ! convection
 lshallowconv_only           =                      .TRUE.        ! only shallow convection
 lgrayzone_deepconv          =                      .FALSE.       !
 inwp_radiation              =                          4         ! radiation
 inwp_cldcover               =                          1         ! cloud cover scheme for radiation
 inwp_turb                   =                          1         ! vertical diffusion and transfer
 inwp_satad                  =                          1         ! saturation adjustment
 inwp_sso                    =                          1         ! subgrid scale orographic drag
 inwp_gwd                    =                          0         ! non-orographic gravity wave drag
 inwp_surface                =                          1         ! surface scheme
 latm_above_top              =                      .TRUE.        ! take into account atmosphere above model top for radiation computation
 ldetrain_conv_prec          =                      .TRUE.
 efdt_min_raylfric           =                       7200.        ! minimum e-folding time of Rayleigh friction
 itype_z0                    =                          2         ! type of roughness length data
 icapdcycl                   =                          3         ! apply CAPE modification to improve diurnalcycle over tropical land
 icpl_aero_conv              =                          1         ! coupling between autoconversion and Tegen aerosol climatology
 icpl_aero_gscp              =                          0         ! coupling between autoconversion and Tegen aerosol climatology
 mu_rain                     =                         0.5        ! shap parameter in gamma distribution for rain
 rain_n0_factor              =                         0.1        ! tuning factor for intercept parameter of raindrop size distr.
 dt_rad                      =                         600.       ! time step for radiation in s
 dt_conv                     =                          90.       ! time step for convection in s (domain specific)
 dt_sso                      =                          360.       ! time step for SSO parameterization
 dt_gwd                      =                          120.       ! time step for gravity wave drag parameterization
/

! nwp_tuning_nml: additional tuning parameters ----------------------------------
&nwp_tuning_nml
 tune_v0snow                 =                        25
 tune_rcucov                 =                        0.075
 tune_rhebc_land             =                        0.825
 itune_albedo                =                          1         ! reduced albedo (w.r.t. MODIS data) over Sahara
 tune_gkwake                 =                        0.25
 tune_gfrcrit                =                        0.333
 tune_gkdrag                 =                        0.0
 tune_minsnowfrac            =                        0.3
 tune_box_liq                =                        0.04
 tune_box_liq_asy            =                        4
 tune_gust_factor            =                        7.0
 tune_zvz0i                  =                        1.25        ! new tuning since June 2018 ! gdm non in guenther
 tune_sgsclifac              =                        1.0         ! new tuning becoming operational in July 2019 ! gdm non in guenther
 icpl_turb_clc               =                        2
 max_calibfac_clcl           =                        2.0
/


! output_nml: specifies an output stream --------------------------------------
&output_nml
 filetype                    =                          4         ! output format: 2=GRIB2, 4=NETCDFv2
 dom                         =                          1         ! write domain 1 only
 output_bounds               =        0., 100000000., 3600.        ! start, end, increment
 steps_per_file              =                          1         ! number of steps per file
 mode                        =                          1         ! 1: forecast mode (relative t-axis), 2: climate mode (absolute t-axis)
 include_last                =                      .TRUE.
 output_filename             =                    'ICON-ART-UNSTR'
 filename_format             =   '${this_folder}/<output_filename>_<datetime>' ! file name base
 steps_per_file_inclfirst    =                    .FALSE.
 output_grid                =                      .TRUE.
 remap                       =                          0         ! 1: remap to lat-lon grid
 reg_lon_def                 =                8.05,0.005,8.95       !
 reg_lat_def                 =               47.18,0.005,47.62       !
 ml_varlist                  =  'group:PBL_VARS',
                                'group:ATMO_ML_VARS',
                                'group:precip_vars',
                                'group:land_vars',
                                'group:nh_prog_vars',
                                'group:ART_CHEMISTRY',
                                'z_mc', 'z_ifc',
                                'topography_c',
                                'group:ART_PASSIVE',
                                'group:ART_AEROSOL'
/

! radiation_nml: radiation scheme ---------------------------------------------
&radiation_nml
 ecrad_isolver               =                          2
 irad_o3                     =                          79         ! ozone climatology
 irad_aero                   =                          6         ! aerosols
 albedo_type                 =                          2         ! type of surface albedo
 vmr_co2                     =                    390.e-06
 vmr_ch4                     =                   1800.e-09
 vmr_n2o                     =                   322.0e-09
 vmr_o2                      =                     0.20946
 vmr_cfc11                   =                    240.e-12
 vmr_cfc12                   =                    532.e-12
 direct_albedo_water         =                           3
 albedo_whitecap             =                           1
 ecrad_data_path             =                  '${RADFOLDER}'
/
! sleve_nml: vertical level specification -------------------------------------
&sleve_nml
 min_lay_thckn               =                         20.0       ! layer thickness of lowermost layer
 top_height                  =                      23000.0       ! height of model top
 stretch_fac                 =                          0.65      ! stretching factor to vary distribution of model levels
 decay_scale_1               =                       4000.0       ! decay scale of large-scale topography component
 decay_scale_2               =                       2500.0       ! decay scale of small-scale topography component
 decay_exp                   =                          1.2       ! exponent of decay function
 flat_height                 =                      16000.0       ! height above which the coordinate surfaces are flat
/

! transport_nml: tracer transport ---------------------------------------------
&transport_nml
 ivadv_tracer                =              3, 3, 3, 3, 3, 3      ! tracer specific method to compute vertical advection
 itype_hlimit                =              3, 4, 4, 4, 4, 4      ! type of limiter for horizontal transport
 ihadv_tracer                =             52, 2, 2, 2, 2, 2     ! tracer specific method to compute horizontal advection
 llsq_svd                    =                      .TRUE.        ! use SV decomposition for least squares design matrix
/

! turbdiff_nml: turbulent diffusion -------------------------------------------
&turbdiff_nml
 tkhmin                      =                          0.5      ! scaling factor for minimum vertical diffusion coefficient
 tkmmin                      =                          0.75      ! scaling factor for minimum vertical diffusion coefficient
 pat_len                     =                        750.0       ! effective length scale of thermal surface patterns
 tur_len                     =                        300.0       ! asymptotic maximal turbulent distance
 rat_sea                     =                          0.8       ! controls laminar resistance for sea surface
 ltkesso                     =                        .TRUE.      ! consider TKE-production by sub-grid SSO wakes
 frcsmot                     =                          0.2       ! these 2 switches together apply vertical smoothing of the TKE source terms
 imode_frcsmot               =                            2       ! in the tropics (only), which reduces the moist bias in the tropical lower troposphere
 itype_sher                  =                            2       ! type of shear forcing used in turbulence
 ltkeshs                     =                        .TRUE.      ! include correction term for coarse grids in hor. shear production term
 a_hshr                      =                          2.0       ! length scale factor for separated horizontal shear mode
 icldm_turb                  =                            2       ! mode of cloud water representation in turbulence
 ldiff_qi                    =                        .TRUE.
 q_crit                      =                          2.0       ! critical value for normalized supersaturation
 imode_tkesso                =                            2       ! mode of calculating th SSO source term for TKE production
 rlam_heat                   =                         10.0       ! gdm default seems to be 10 in code but 1 in Namelist_overview.pdf
 alpha1                      =                         0.125
/
EOF

rm -f finish.status

#-----------------
# start the model
#-----------------
ls -l ${MODEL}
check_error $? "${MODEL} does not exist?"
#
ldd ${MODEL}

date
$START $MODEL || exit 1
date

#-----------------------------------------------------------------------------
# Check run status
#-----------------------------------------------------------------------------
#
if [[ -f finish.status ]] ; then
  finish_status=$(echo $(cat finish.status))
else
  echo "Run failed or did not complete properly"
  exit 1
fi

echo "Finish status: ${finish_status}"

#-----------------------------------------------------------------------------
# exit 0
#-----------------------------------------------------------------------------
