#!/bin/ksh -x
#
#

# VARIAVEIS

cd ${Eta_scr}
hh=`echo ${Run_Date} | cut -c9-10`
FctCont=000000
cont=0
OK="False"

typeset -Z6 Fct FctCont

while [ "${OK}" != "True" ] ; do

 if [ "${FInitBC}" == "cfsr" ] ; then
  dir_CFSR=${data_grib}/${Run_Date}
  arqin=`${Eta_home}/util/caldate.3.0 ${Run_Date} + ${FctCont}h ${dir_CFSR}/'yymmddhh0000.ETAwrk'`
  arqout=`${Eta_home}/util/caldate.3.0 ${Run_Date} + ${FctCont}h ${Eta_run}/'cfsr_YYYYMMDDHH.'${FctCont}'.ETAwrk'`
 fi

 if [ -s ${arqin} ] ; then
  echo "ARQ1"$arqin >> ${Eta_run}/cond$Run_Date  
  cp ${arqin} ${arqout}
 fi

 if ((${cont}>=100)); then
  echo "cont1"=$cont
  exit 
 fi

 if [ -s ${arqin} ] ; then
  cont=0
  
 if [ "${FctCont}" == "${Fct}" ] ; then
   OK="True"
   cp ${dir_CFSR}/gdsinfo.ETAwrk ${Eta_run}/
   exit
  fi  
  
  let FctCont=${FctCont}+${InitBC}
 else
  sleep 15
  let cont=$cont+1  
 fi

done

