#!/usr/bin/bash

if [[ $# -eq 1 ]] ; then
   ymd=$1
   ymd2=$1
   ymd3=$1
else
   ymd=`date --date='15 day ago' +%Y-%m-%d`
   ymd2=`date --date='30 day ago' +%Y-%m-%d`
   ymd3=`date --date='5 day ago' +%Y-%m-%d`
fi
#
#======================================================================================
#
#---clean up n20/atms raw,dynamic, and output data
#
#======================================================================================
#
#satId="n20"
#sensorId="atms"
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/ExternalData/rdr/${satId}_${sensorId}/                    -name ${ymd} -print0  | xargs -0 rm -rf
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/ff_colloc/${satId}_${sensorId}/   -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fmsdr/${satId}_${sensorId}/       -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fwd_analys/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/ims_colloc/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/nwp_analys/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/tdr/${satId}_${sensorId}/         -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/sdr/${satId}_${sensorId}/         -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/swe_climo/${satId}_${sensorId}/   -name ${ymd3} -print0 | xargs -0 rm -rf
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/dep/${satId}_${sensorId}/             -name ${ymd} -print0  | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/edr/${satId}_${sensorId}/             -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/grid/${satId}_${sensorId}/            -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/nc/${satId}_${sensorId}/              -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/figs/${satId}_${sensorId}/            -name ${ymd2} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/sfr/${satId}_${sensorId}/            -name ${ymd2} -print0 | xargs -0 rm -rf
##
##---clean up control and input data
###
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/ControlData/ -type f -mtime +10 -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/InputsData/  -type f -mtime +10 -print0 | xargs -0 rm -rf
#
#echo "${ymd} n20/atms related data have been cleaned"
#
#======================================================================================
#
#---clean up metopC raw,dynamic, and output data
#
#======================================================================================
#
satId="metopB"
sensorId1="amsua"
sensorId2="mhs"
#find /data/data548/pub/yklee/mirs_metopB/data/ExternalData/rdr/${satId}_${sensorId1}_${sensorId2}/     -name ${ymd} -print0  | xargs -0 rm -rf

find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/ff_colloc/${satId}_${sensorId1}_${sensorId2}/   -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/fmsdr/${satId}_${sensorId1}_${sensorId2}/       -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/fmsdrchopp/${satId}_${sensorId1}_${sensorId2}/  -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/fwd_analys/${satId}_${sensorId1}_${sensorId2}/  -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/ims_colloc/${satId}_${sensorId1}_${sensorId2}/  -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/nwp_analys/${satId}_${sensorId1}_${sensorId2}/  -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/tdr/${satId}_${sensorId1}/         -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/tdr/${satId}_${sensorId2}/         -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/sdr/${satId}_${sensorId1}/         -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/sdr/${satId}_${sensorId2}/         -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/DynamicData/swe_climo/${satId}_${sensorId1}_${sensorId2}/   -name ${ymd3} -print0 | xargs -0 rm -rf

find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/Outputs/dep/${satId}_${sensorId1}_${sensorId2}/             -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/Outputs/edr/${satId}_${sensorId1}_${sensorId2}/             -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/Outputs/grid/${satId}_${sensorId1}_${sensorId2}/            -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/Outputs/nc/${satId}_${sensorId1}_${sensorId2}/              -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/Outputs/figs/${satId}_${sensorId1}_${sensorId2}/            -name ${ymd3} -print0 | xargs -0 rm -rf
find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/Outputs/sfr/${satId}_${sensorId1}_${sensorId2}/             -name ${ymd3} -print0 | xargs -0 rm -rf

#find /data/data548/pub/yklee/mirs_metopB/data/TestbedData/PerfsMonitoring/${satId}_${sensorId1}_${sensorId2}/         -name ${ymd3} -print0 | xargs -0 rm -rf *png

echo "${ymd} metopB_amsua_mhs related data have been cleaned"
#
#======================================================================================
#
#---clean up metopC GFS data
#
#======================================================================================
#
#
#---clean up GFS data
#
#find /data/data411/pub/sliu/ExternalData/gfs_0p50/gfs.*pgrb2* -mtime +5 -exec rm {} \; 
#find /data/data411/pub/sliu/ExternalData/gridNWP_sfr/atms/ -type d -mtime +5 -exec rm -rf {} \;
#find /data/data248/pub/external_data/gridNWP_sfr/amsua/    -type d -mtime +5 -exec rm -rf {} \;
#find /data/data248/pub/external_data/gridNWP_sfr    -type d -mtime +5 -exec rm -rf {} \;
#
#======================================================================================
#
#---clean up gpm raw,dynamic, and output data
#
#======================================================================================
#
#find /data/data248/pub/sliu/mirs_data/ExternalData/rdr/gpm_gmi/  -name ${ymd} -print0 | xargs -0 rm -rf
#find /data/data248/pub/sliu/mirs_data/ExternalData/rdr/npp_atms/ -name ${ymd3} -print0 | xargs -0 rm -rf

#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fmsdr/gpm_gmi/      -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fmsdrchopp/gpm_gmi/ -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fwd_analys/gpm_gmi/ -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/ims_colloc/gpm_gmi/ -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/nwp_analys/gpm_gmi/ -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/tdr/gpm_gmi/        -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/sdr/gpm_gmi/        -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/swe_climo/gpm_gmi/  -name ${ymd3} -print0 | xargs -0 rm -rf
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/dep/gpm_gmi/ -name ${ymd} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/edr/gpm_gmi/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/grid/gpm_gmi/ -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/nc/gpm_gmi/   -name ${ymd3} -print0 | xargs -0 rm -rf
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/figs/gpm_gmi/ -name ${ymd2} -print0 | xargs -0 rm -rf
##
##---clean up ims data
#
#find /data/data248/pub/sliu/mirs_data/ExternalData/ims_analys/ -type f -mtime +10 -print0 | xargs -0 rm -rf
#
#---clean up control and input data
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/ControlData/ -type f -mtime +10 -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/InputsData/  -type f -mtime +10 -print0 | xargs -0 rm -rf

#
#---clean up gprof and st4 data
#
##find /data/data248/pub/sliu/mirs_utilities_data/ExternalData/gpm_gprof/ -name ${ymd2} -print0 | xargs -0 rm -rf
##find /data/data248/pub/sliu/mirs_utilities_data/ExternalData/st4/ -name ${ymd2} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_utilities_data/Outputs/gprof_dep -name ${ymd3} -print0 | xargs -0 rm -rf
#
#echo "${ymd} gpm related data have been cleaned"
#
#======================================================================================
#
#---clean up npp/atms raw,dynamic, and output data
#
#======================================================================================
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/ff_colloc/npp_atms/      -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fmsdr/npp_atms/          -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/fwd_analys/npp_atms/     -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/nwp_analys/npp_atms/     -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/tdr/npp_atms/            -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/sdr/npp_atms/            -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/swe_climo/npp_atms/      -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/DynamicData/regress_retr/npp_atms/   -name ${ymd3} -print0 | xargs -0 rm -rf
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/dep/npp_atms/ -name ${ymd} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/edr/npp_atms/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/grid/npp_atms/ -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/nc/npp_atms/   -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/TestbedData/Outputs/sfr/npp_atms/            -name ${ymd2} -print0 | xargs -0 rm -rf
#
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/Outputs/figs/npp_atms/ -name ${ymd2} -print0 | xargs -0 rm -rf
##
##---clean up control and input data
##
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/ControlData/ -type f -mtime +10 -print0 | xargs -0 rm -rf
#find /data/data412/pub/sliu/mirs_oper_v11r6/data/InputsData/  -type f -mtime +10 -print0 | xargs -0 rm -rf
#
#echo "${ymd} npp/atms related data have been cleaned"
##
##---tc_multi
##
#satId="n20"
#sensorId="atms"
#find /data/data412/pub/sliu/mirs_oper_v11r3/data/ExternalData/rdr/${satId}_${sensorId}/                    -name ${ymd} -print0  | xargs -0 rm -rf

#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/ff_colloc/${satId}_${sensorId}/   -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/fmsdr/${satId}_${sensorId}/       -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/fwd_analys/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/ims_colloc/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/nwp_analys/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/tdr/${satId}_${sensorId}/         -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/sdr/${satId}_${sensorId}/         -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/swe_climo/${satId}_${sensorId}/   -name ${ymd3} -print0 | xargs -0 rm -rf
#
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/dep/${satId}_${sensorId}/             -name ${ymd} -print0  | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/edr/${satId}_${sensorId}/             -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/grid/${satId}_${sensorId}/            -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/nc/${satId}_${sensorId}/              -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/figs/${satId}_${sensorId}/            -name ${ymd2} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/sfr/${satId}_${sensorId}/            -name ${ymd2} -print0 | xargs -0 rm -rf
##
##---clean up control and input data
##
#find /data/data247/pub/sliu/mirs_tc_multi/data/ControlData/ -type f -mtime +10 -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/InputsData/  -type f -mtime +10 -print0 | xargs -0 rm -rf
#
#echo "${ymd} ${satId}/${sensorId} related data have been cleaned"
##
#---tc_multi
#
#satId="npp"
#sensorId="atms"
##find /data/data412/pub/sliu/mirs_oper_v11r3/data/ExternalData/rdr/${satId}_${sensorId}/                    -name ${ymd} -print0  | xargs -0 rm -rf
#
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/ff_colloc/${satId}_${sensorId}/   -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/fmsdr/${satId}_${sensorId}/       -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/fwd_analys/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/ims_colloc/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/nwp_analys/${satId}_${sensorId}/  -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/tdr/${satId}_${sensorId}/         -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/sdr/${satId}_${sensorId}/         -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/DynamicData/swe_climo/${satId}_${sensorId}/   -name ${ymd3} -print0 | xargs -0 rm -rf
#
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/dep/${satId}_${sensorId}/             -name ${ymd} -print0  | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/edr/${satId}_${sensorId}/             -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/grid/${satId}_${sensorId}/            -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/nc/${satId}_${sensorId}/              -name ${ymd3} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/figs/${satId}_${sensorId}/            -name ${ymd2} -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/TestbedData/Outputs/sfr/${satId}_${sensorId}/            -name ${ymd2} -print0 | xargs -0 rm -rf
##
##---clean up control and input data
##
#find /data/data247/pub/sliu/mirs_tc_multi/data/ControlData/ -type f -mtime +10 -print0 | xargs -0 rm -rf
#find /data/data247/pub/sliu/mirs_tc_multi/data/InputsData/  -type f -mtime +10 -print0 | xargs -0 rm -rf
#
#echo "${ymd} ${satId}/${sensorId} related data have been cleaned"
