#!/bin/ksh
# Execute: concatenate_hoursoneday.ksh 20130803 20130805 00 24 BOIA_SC 
date_ini=$1
date_fin=$2
hour_ini=$3
hour_fin=$4
station=$5

dir_func=/scratchin/grupos/oceano/rosio.camayo/validation/functions
dir_data=/scratchout/grupos/oceano/rosio.camayo/validation/validate_pesq/d-input/d-mod_vs_obs/
file_out=$dir_data/extreme_events/mod_obs_${station}_${date_ini}_${date_fin}_${hour_ini}_${hour_fin}
rm -f $file_out

date_atual=$date_ini
while [[ $date_atual -le $date_fin ]] ; do

hour_atual=$hour_ini
while [[ $hour_atual -le $hour_fin ]] ; do

cat $dir_data/${station}/${date_atual}00/mod_obs_${station}_${date_atual}00_${hour_atual} >> $file_out

(( hour_atual= hour_atual + 1 ))
if (( $hour_atual < 10 ));then
hour_atual=0${hour_atual}
fi
done

date_atual=$(${dir_func}/faz_data ${date_atual}00 24 | cut -b 1-8)
done

