#!/bin/csh -f

cd /home/matlab/hw_dynamic/JMA
set d2=`date --date="2 days ago" +%d`
set y2=`date --date="2 days ago" +%Y`
set m2=`date --date="2 days ago" +%m` 
set URL="https://ds.data.jma.go.jp/tcc/tcc/products/clisys/anim/GIF/tp/anom/${y2}/${m2}/${d2}/5day/OlrPsiWaf_tp200hPa_${y2}${m2}${d2}.gif"
wget ${URL} -O OlrPsiWaf_tp200hPa_${y2}${m2}${d2}.gif

set fecha=`date +%Y%m%d`
set hora=`date +%H`

set URL='http://www.bom.gov.au/climate/mjo/graphics/rmm.phase.Last40days.gif.ps'
cd /home/matlab/hw_dynamic/MJO_REPO
cd bom/RMM_40_days

if ( -e "${fecha}" ) then
    echo "${fecha} exist"
else 
    echo "${fecha} does not exist"
    wget ${URL} -O ${fecha}
endif

set URL='http://www.bom.gov.au/climate/mjo/graphics/rmm.phase.Last90days.gif.ps'
cd ../RMM_90_days

if ( -e "${fecha}" ) then
    echo "${fecha} exist"
else 
    echo "${fecha} does not exist"
    wget ${URL} -O ${fecha}
endif

#set URL='https://www.cpc.ncep.noaa.gov/products/precip/CWlink/MJO/diagram_40days_forecast_GEFS_member.gif'
set URL='https://www.cpc.ncep.noaa.gov/products/precip/CWlink/MJO/ensplume_full.gif'
cd ../../ncpe

if ( -e "${fecha}" ) then
    echo "${fecha} exist"
else 
    echo "${fecha} does not exist"
    wget ${URL} -O ${fecha}
endif

# 45 15,16,17,21,22,23 * * * /hw_dynamic/MJO_REPO/mjo_repo.csh

