Caldtg='/data/public/HYCOM/shian/Caldtg.ksh'

tmpdtg=`date -d "-1 days" +%Y%m%d`12
tmpdtg2=`date -d "-1 days" +%Y%m%d`12
yy=`echo ${tmpdtg2} | cut -c 1-4`
dd=`echo ${tmpdtg2} | cut -c 5-6`
opath=/data/public/HYCOM/shian/${yy}/${dd}

while [ ${tmpdtg} -le ${tmpdtg2} ]
do
file=${opath}/hycom_glby_930_${tmpdtg}_t012
panosize=`ls -l ${file}_ts3z.nc |cut -d ' ' -f 5`
if [[ ! -f ${file}_ts3z.nc ]] || [[ ${panosize} -le 3000000000 ]];then
   echo "rm and download"
   y4=`echo ${tmpdtg} | cut -c1-4`
   rm -rf ${file}_ts3z.nc
   wget -P ${opath}/ ftp://ftp.hycom.org/datasets/GLBy0.08/expt_93.0/data/forecasts/hycom_glby_930_${tmpdtg}_t012_ts3z.nc
else
   echo "ts t012 ok"
fi

file=${opath}/hycom_glby_930_${tmpdtg}_t012
panosize=`ls -l ${file}_uv3z.nc |cut -d ' ' -f 5`
if [[ ! -f ${file}_uv3z.nc ]] || [[ ${panosize} -le 3000000000 ]];then
   echo "rm and download"
   y4=`echo ${tmpdtg} | cut -c1-4`
   rm -rf ${file}_uv3z.nc
   wget -P ${opath}/ ftp://ftp.hycom.org/datasets/GLBy0.08/expt_93.0/data/forecasts/hycom_glby_930_${tmpdtg}_t012_uv3z.nc
else
   echo "uv t012 ok"
fi

file=${opath}/hycom_glby_930_${tmpdtg}_t012
panosize=`ls -l ${file}_ssh.nc |cut -d ' ' -f 5`
if [[ ! -f ${file}_ssh.nc ]] || [[ ${panosize} -le 30000000 ]];then
   echo "rm and download"
   y4=`echo ${tmpdtg} | cut -c1-4`
   rm -rf ${file}_ssh.nc
   wget -P ${opath}/ ftp://ftp.hycom.org/datasets/GLBy0.08/expt_93.0/data/forecasts/hycom_glby_930_${tmpdtg}_t012_ssh.nc
else
   echo "ssh t012 ok"
fi


  tmpdtg=`${Caldtg} ${tmpdtg} 24`
done


