#!/bin/ksh  -x

# VARIAVEIS 

cd ${Eta_run}

export tval=0
typeset -Z6 tval

CInit_Lowercase=`echo ${CInit}|awk '{print tolower($1)}'`
BCond_Lowercase=`echo ${BCond}|awk '{print tolower($1)}'`

echo "for $cyc data will handle data from 00 to $endtime at $int hour intervals"
cp ${Eta_ucl}/InputModelInf.txt_${CInit} ${Eta_run}/InputModelInf.txt
filename=${CInit}_${Run_Date}.${tval}
if [ -s ${data_prep}/${filename} ] ; then
${Eta_dprep_exe}/dg${CInit_Lowercase}.exe << endin 
${filename} 
${data_prep} 
endin
else
  echo " "${filename}" not found."
  exit 1    
fi
if ((${TInitBC}==0)) ; then
 Run_Date=`${Eta_home1}/util/caldate.3.0 ${Run_Date} - ${HInitBC}hr 'yyyymmddhh'`
 let tval=${tval}+${InitBC}+${HInitBC}
 let Fct=${Fct}+${HInitBC}
else
 tval=${InitBC}
fi

cp ${Eta_ucl}/InputModelInf.txt_${BCond} ${Eta_run}/InputModelInf.txt

while ((${tval}<=${Fct})) ; do
   filename=${BCond}_${Run_Date}.${tval}
   if [ -s ${data_prep}/${filename} ] ; then
${Eta_dprep_exe}/dg${BCond}.exe << endin 
${filename} 
${data_prep} 
endin
   else
     echo " "${filename}" not found."
     exit 1    
   fi

   let tval=${tval}+${InitBC}
done

exit 0
