#!/bin/bash

set +x

module load PrgEnv-intel/8.1.0
module load intel/19.1.3.304
module load python/3.8.6

workdir=/lfs/h1/owp/ptmp/Zhengtao.Cui/rfc_upload_monitoring

rfc_ingestion_dir=/lfs/h1/owp/nwm/noscrub/Zhengtao.Cui/test/packages/nwm.v3.0.0/ush/rfc_ingestion

#rfc_pixml_dir=/lfs/h1/owp/nwc/noscrub/Zhengtao.Cui/rfc_reservoir 
rfc_pixml_dir=/lfs/h1/ops/prod/dcom/RFC_data/Reservoir

rfc_timeseries_dir=/lfs/h1/ops/prod/com/nwm/v2.2

if [ ! -e $workdir ]; then mkdir -p $workdir; fi

cd $workdir

$rfc_ingestion_dir/get_RFC_list_by_date_on_FTP.py -i $rfc_pixml_dir \
   -t $rfc_timeseries_dir -s $rfc_ingestion_dir/RFC_Reservoir_Locations_for_Forecast_Ingest_into_NWM_All_RFCs.csv > rfc_monitoring.log 2>&1


#email
outfile=rfc_upload_monitor$(date +%d_%m_%Y).txt
echo "RFC monitoring result: O --- missing, X --- data available" | cat - "./$outfile" | mail -s "`date +%Y%m%d` : RFC upload monitoring (WCOSS2)" -a ./$outfile -r 'Zhengtao.Cui@noaa.gov' Zhengtao.Cui@noaa.gov,brian.cosgrove@noaa.gov