#!/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
# 
cd /work/users/longtt/proj_VNU/FROM_RD/PERSIANN
year="2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015"
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 dd in $date ; do
        echo PERSIANN-CDR_v01r01_${y}${mo}${dd}_c20140523.nc 
        multiget -l ftp://data.ncdc.noaa.gov/cdr/persiann/files/${y}/PERSIANN-CDR_v01r01_${y}${mo}${dd}_c20140523.nc 
    done
        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
