#!/bin/ksh

byteswap=/data/smcd/nprovs/source/byteswap
dailyfiles=/data/data065/nprovs/data/matchup/DailyFiles_incoming
cd $dailyfiles

rm -f rrodf1000.m1.unix
rm -f rrodf1000.oa11.unix
rm -f rrodf1_1000.d19.unix
rm -f rrodf1_1000.m1x.unix
rm -f rrodf2_1000.d19.unix
rm -f rrodf2_1000.m1x.unix

# Process the Oper Metop-B ATOVS RRODF first for daily NPROVS matchups

#ftp satepsanone.espc.nesdis.noaa.gov <<EOD
#cd /pub/atovsdev/rrodf
#get rrodf1000.m1 rrodf1000.m1.unix
#get rrodf1000.oa11 rrodf1000.oa11.unix
#get rrodf1_1000.d19 rrodf1_1000.d19.unix
#get rrodf1_1000.m1x rrodf1_1000.m1x.unix
#get rrodf2_1000.d19 rrodf2_1000.d19.unix
#get rrodf2_1000.m1x rrodf2_1000.m1x.unix
#bye
#EOD

wget -4 --wait=5 -O rrodf1000.m1.unix http://satepsanone.nesdis.noaa.gov/pub/atovsdev/rrodf/rrodf1000.m1

wget -4 --wait=5 -O rrodf1000.oa11.unix http://satepsanone.nesdis.noaa.gov/pub/atovsdev/rrodf/rrod1000.oa11

wget -4 --wait=5 -O rrodf1_1000.d19.unix http://satepsanone.nesdis.noaa.gov/pub/atovsdev/rrodf/rrodf1_1000.d19

wget -4 --wait=5 -O rrodf1_1000.m1x.unix http://satepsanone.nesdis.noaa.gov/pub/atovsdev/rrodf/rrodf1_1000.m1x

wget -4 --wait=5 -O rrodf2_1000.d19.unix http://satepsanone.nesdis.noaa.gov/pub/atovsdev/rrodf/rrodf2_1000.d19

wget -4 --wait=5 -O rrodf2_1000.m1x.unix http://satepsanone.nesdis.noaa.gov/pub/atovsdev/rrodf/rrodf2_1000.m1x



# Byte-swap the words in the UNIX files so they can be read properly
# in a Linux environment.

if test -e $dailyfiles/rrodf1000.m1.unix
then
   rm -f $dailyfiles/rrodf1000.m1
   rm -f $dailyfiles/fort.*

   ln -s $dailyfiles/rrodf1000.m1.unix    fort.20
   ln -s $dailyfiles/rrodf1000.m1         fort.21

   $byteswap/swaprrodf1000.x

   rm -f fort.*
   chmod 664 $dailyfiles/rrodf1000.m1
   rm -f $dailyfiles/rrodf1000.m1.unix
fi


if test -e $dailyfiles/rrodf1000.oa11.unix
then
   rm -f $dailyfiles/rrodf1000.oa11
   rm -f $dailyfiles/fort.*

   ln -s $dailyfiles/rrodf1000.oa11.unix    fort.20
   ln -s $dailyfiles/rrodf1000.oa11         fort.21

   $byteswap/swaprrodf1000.x

   rm -f fort.*
   chmod 664 $dailyfiles/rrodf1000.oa11
   rm -f $dailyfiles/rrodf1000.oa11.unix
fi


if test -e $dailyfiles/rrodf1_1000.d19.unix
then
   rm -f $dailyfiles/rrodf1_1000.d19
   rm -f $dailyfiles/fort.*

   ln -s $dailyfiles/rrodf1_1000.d19.unix    fort.20
   ln -s $dailyfiles/rrodf1_1000.d19         fort.21

   $byteswap/swaprrodf1000.x

   rm -f fort.*
   chmod 664 $dailyfiles/rrodf1_1000.d19
   rm -f $dailyfiles/rrodf1_1000.d19.unix
fi


if test -e $dailyfiles/rrodf1_1000.m1x.unix
then
   rm -f $dailyfiles/rrodf1_1000.m1x
   rm -f $dailyfiles/fort.*

   ln -s $dailyfiles/rrodf1_1000.m1x.unix    fort.20
   ln -s $dailyfiles/rrodf1_1000.m1x         fort.21

   $byteswap/swaprrodf1000.x

   rm -f fort.*
   chmod 664 $dailyfiles/rrodf1_1000.m1x
   rm -f $dailyfiles/rrodf1_1000.m1x.unix
fi


if test -e $dailyfiles/rrodf2_1000.d19.unix
then
   rm -f $dailyfiles/rrodf2_1000.d19
   rm -f $dailyfiles/fort.*

   ln -s $dailyfiles/rrodf2_1000.d19.unix    fort.20
   ln -s $dailyfiles/rrodf2_1000.d19         fort.21

   $byteswap/swaprrodf1000.x

   rm -f fort.*
   chmod 664 $dailyfiles/rrodf2_1000.d19
   rm -f $dailyfiles/rrodf2_1000.d19.unix
fi


#if test -e $dailyfiles/rrodf2_1000.m1x.unix
#then
#   rm -f $dailyfiles/rrodf2_1000.m1x
#   rm -f $dailyfiles/fort.*

#   ln -s $dailyfiles/rrodf2_1000.m1x.unix    fort.20
#   ln -s $dailyfiles/rrodf2_1000.m1x         fort.21

#   $byteswap/swaprrodf1000.x

#   rm -f fort.*
#   chmod 664 $dailyfiles/rrodf2_1000.m1x
#   rm -f $dailyfiles/rrodf2_1000.m1x.unix
#fi

