#!/bin/ksh

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

rm -f rrodf1_1000.m1x.unix
rm -f rrodf2_1000.m1x.unix
rm -f r1t_24hrs.m1x.unix

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

ftp satepsanone.nesdis.noaa.gov <<EOD
cd atovsdev/rrodf
get rrodf1_1000.m1x rrodf1_1000.m1x.unix 
get rrodf2_1000.m1x rrodf2_1000.m1x.unix
get r1t_24hrs.m1x r1t_24hrs.m1x.unix

cd ../m1x

get rodf1_24hrs.m1x rodf1_24hrs.m1x.unix
get rodf2_24hrs.m1x rodf2_24hrs.m1x.unix
get r1t_24hrs.m1x r1t_24hrs.m1x.unix
bye
EOD



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

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.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


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

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

#    $byteswap/swaprrodf1000.x

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

