#!/bin/ksh -x
#
#

# VARIAVEIS
cd ${Eta_scr}



dir_sst=${Eta_home}/data/grib
sst_date=`${Eta_home1}/util/caldate.3.0 ${Run_Date} - 1d 'yyyymmdd'`

echo "SST DATE  " ${sst_date}

ihora=`echo ${Run_Date} |cut -c 9-10`
#ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod

datadir=/data/nccf/com/gfs/prod
server=ftpprd.ncep.noaa.gov
fsst=rtgssthr_grb_0.083
cd ${Eta_run}

  if  [[ ! -s ${dir_sst}/${fsst}_${sst_date}.grib2 ]] ; then
       cd ${dir_sst}
       wget -c http://$server$datadir/sst.${sst_date}/${fsst}.grib2
       mv -v ${fsst}.grib2 ${dir_sst}/${fsst}_${sst_date}.grib2
       ../../util/wgrib2 -s -YY  -d 1 -order we:ns ${dir_sst}/${fsst}_${sst_date}.grib2 -ieee ${dir_sst}/sst_Eta_${sst_date}.bin
       chmod 755 ${dir_sst}/sst_Eta_${sst_date}.bin
       cd ${Eta_scr_out}
  else
       cd ${dir_sst}
        ../../util/wgrib2 -s -YY  -d 1 -order we:ns ${dir_sst}/${fsst}_${sst_date}.grib2 -ieee ${dir_sst}/sst_Eta_${sst_date}.bin
       chmod 755 ${dir_sst}/sst_Eta_${sst_date}.bin
       cd ${Eta_scr_out}      
  fi
