#!/bin/bash
#
# Get_ERA5_nc+process.sh yyyymmddhh nhour
# yyyymmddhh : initial date to start to get data
#       nhour: number of hours of data download
#              frequency 6/6h

# Check input parameter
if (($#<2)) ; then
  echo "      Get_ERA5_nc+process.sh yyyymmddhh nhour"
  echo "      yyyymmddhh : initial date to start to get data"
  echo "      nhour: number of hours of data download"
  echo "      frequency 6/6h"
  exit 1
fi

export yeari=${1}

# VARIAVEIS
Dir_scr=./
Dir_home=`dirname ${Dir_scr}`
Dir_datain=`dirname ${Dir_home}`
ModelDrive=`basename ${Dir_scr}`
Dir_wrk=${Dir_datain}/atmos/${ModelDrive}/${Run_Date}
InitBC=6

LastArq="False"
Variable = ["sea_surface_temperature"]
# PbsSlurm
Dir_out=./era5
VarInd = 0
while [ "${LastArq}" != "True" ] ; do

  if [ ! -d ${Dir_wrk} ] ; then
     mkdir -p  ${Dir_out}/Variable[$VarInd]}
  fi
cd ${out}
python3 ${Dir_scr}/getEra5.py ${yeari:0:4} Variavel[$VarInd]}
done
exit
