#!/bin/bash
#####################################################################
# 
# rt_check_missing.bash 
#
# Purpose:
# This shell script identifies missing RT SP3 files
# resulting from failed BERNESE runs.
#
#
# History:  
#       Created by: Ming Chen 2026/05/5
#                   ming.chen@noaa.gov
# 
# Usage: rt_check_missing.bash 
# 
#
#####################################################################
#


pkghome=/home/mchen36/wrk/RT_COSMIC2_REL1.2
cd $pkghome
source set_env.bash

if [ -z "${podgen_home}" ]; then 
   echo "env is not set up, source the set_env.bash file first .."
   exit
fi

podgen=${podgen_home}

sdate="2026-07-15 00:00:00"
edate="2026-07-15 15:00:00"
sdate=`date -u -d "6 hours ago" +"%Y-%m-%d %H:%M:00"`
edate=`date -u -d "2 hours ago" +"%Y-%m-%d %H:%M:00"`

# Convert dates to Unix epoch seconds
current_sec=$(date -d "$sdate" +%s)
end_sec=$(date -d "$edate" +%s)

while (( current_sec < end_sec )); do
    # Format and display the current interval
    mydate=`date -d "@$current_sec" "+%Y-%m-%dT%H:%M:%S"`
    echo "$mydate"
    python update_yaml.py -t "$mydate" -i rt_cosmic2_reproc.yaml -o check_missing.yaml -v
    ((current_sec += 1800))
done
