#!/bin/bash
#     keyword :: canesm_delete_tser
# description :: Delete model time series files.
set -a
. betapath2  # sets path for new package (required until old package is retired)

#  * ........................... Parmsub Parameters ............................

 runid="runid"; year="yyyy"; mon="mm"; run_start_year="yyy";run_start_month="mm";
 tser_uxxx="sc";

  # These variables are set when the job string is created
  previous_year=NotSet
  previous_month=NotSet

  current_year=NotSet
  current_month=NotSet

  next_year=NotSet
  next_month=NotSet

  run_start_year=NotSet
  run_start_month=NotSet
  run_stop_year=NotSet
  run_stop_month=NotSet

 crawork="crawork";
 username="username"; user="USER"; nqsprfx=""; nqsext="_${runid}_${year}_m${mon}";
 lopgm="lopgm"; stime="10800"; memory1="4gb";

#  * ............................ Condef Parameters ............................

 noprint=on
 nextjob=on
 debug=off

#  * ............................. Deck Definition .............................
jobname=del_${tser_uxxx}; time=$stime ; memory=$memory1
.   comjcl.cdk
cat > Execute_Script <<'end_of_script'
# Delete time series files
# RSK, 05 2019

# create file lists to be deleted
data_file_lists $runid $RUNPATH --start=$run_start_year:$run_start_month --stop=$run_stop_year:$run_stop_month
[ -s ${tser_uxxx}_time_series_files ] || { echo "ERROR in deling: could not make ${tser_uxx}_time_series_files" ; exit 1 ; }

# delete archived time series
fdb mdelete -f ${tser_uxxx}_time_series_files

end_of_script

. endjcl.cdk
#end_of_job
