# author: Roderick van der Linden & Trinh Tuan Long 
#!/bin/bash
### Job name
#PBS -N Extract_PERSIANN
#PBS -q serial_q 
#PBS -l nodes=1:ppn=1
#PBS -o z.out
#PBS -e z.err
#PBS -V
# 
#year="2001"
#month="01"
year="2010 2009"
month="01 02 03 04 05 06 07 08 09 10 11 12"
date="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31"
for y in $year ; do
  for mo in $month ; do
    for da in ${date} ; do
        multiget -l ftp://data.ncdc.noaa.gov/cdr/persiann/files/${y}/PERSIANN-CDR_v01r01_${y}${mo}${da}_c20140523.nc
#ftp://data.ncdc.noaa.gov/cdr/persiann/files/2002/PERSIANN-CDR_v01r01_20021213_c20140523.nc
#ftp://data.ncdc.noaa.gov/cdr/persiann/files/2002/PERSIANN-CDR_v01r01_20021227_c20140523.nc
        #cdo -r mergetime PERSIANN-CDR_v01r01_${y}${mo}??_?????????.nc PERSIANN-CDR_v01r01_${y}${mo}.nc
        #rm PERSIANN-CDR_v01r01_${y}${mo}??_?????????.nc
        #cdo sellonlatbox,70,140,-15,40 PERSIANN-CDR_v01r01_${y}${mo}.nc temp.nc
        #mv temp.nc PERSIANN-CDR_v01r01_${y}${mo}.nc
    done
  done
done
