#!/bin/bash

# ----------------------------------------------------------------------
# RPC Project :
# RPC_download_data_onemonth_CLUFGM : get FGM data from CAA
#                           from CAA data base
#                           for one entire month and 4 S/C
#
# usage: RPC_download_data_onemonth_CLUFGM  year month Mode
# ex   : RPC_download_data_onemonth_CLUFGM  2009 03 SPIN"
#
# P. Robert, LPP, 2012-08-25
#
# ----------------------------------------------------------------------


appli=`basename $0`
appli36=`echo "$appli                                 " | cut -c1-36`
Narg=3

if( (test $# = 1 ) && (test $1 = -h ) ) ; then hh=1 ; else hh=0 ; fi

if test $# != $Narg || test $hh = 1
   then
   echo "$appli : product CLUFGM.rff files 1 month 4 sat"
   echo "$appli   require $Narg argument(s), ex:"
   echo "$appli   year month Mode "
   echo "    ex: $appli 2009 12 SPIN"
   echo ""
   if test $hh = 1 ; then exit 0 ; fi
   echo "$appli36 : *** ERROR ! Command aborted." >&2
   exit 1
fi

datim1=`date +%F'  '%H':'%M':'%S `
julsec1=`date +%s`

year=$1
month=$2
Mode=$3

# Mode test
# ---------

if ((test $Mode != SPIN ) && (test $Mode != 5VPS) && (test $Mode != FULL))
   then
     echo "Mode must be only SPIN, 5VPS or FULL"
     echo "$appli36 : *** ERROR ! Command aborted." >&2
     exit 2
fi

# Run classical command but redirect stdout and log file

log_onemonth=download_data_onemonth_CLUFGM_$Mode"_"$year"_"$month.log

RPC_download_data_onemonth_CLUFGM_nolog $* | tee -a $log_onemonth

# ----------------------------------------------------------------------
