#! /bin/sh
#
#+
#
# .. _step2_diff.sh:
#
# =============
# step2_diff.sh
# =============
#
# ------------------------------------------
# launch step2_diff.pro with year argument
# ------------------------------------------
#
# SYNOPSYS
# ========
#
# .. code-block:: bash
#
#    step2_diff.sh -y year
#
# EXAMPLES
# ========
#
# For test on year 1994:
#
# .. code-block:: bash
#
#    ./step2_diff.sh -y 1994
#
# EVOLUTIONS
# ==========
#
# $Id$
#
# - fplod 20100318T074009Z aedon.locean-ipsl.upmc.fr (Darwin)
#
#   * unset
#
# - fplod 2007-08-22T08:50:02Z aedon.locean-ipsl.upmc.fr (Darwin)
#
#   * creation to avoid retall and redefinition of file1 and file2
#
#-
#
system=$(uname)
case "${system}" in
   AIX|IRIX64)
      echo " www : no specific posix checking"
   ;;
   *)
      set -o posix
   ;;
esac
unset system
#
command=$(basename ${0})
#
usage=" Usage : ${command} -y year"
#
while [ ${#} -gt 0 ]
do
   case ${1} in
      -y)
         year=${2}
         shift
      ;;
      *)
         # other choice
         echo "eee : unknown option ${1}"
         echo "${usage}"
         exit 1
      ;;
   esac
   # next flag
   shift
done
unset usage
#
# ++ check year validity
#
# remove previous output file
rm Sigma_5d_${year}_grid_T_ORCA2_diff.nc
#
# build IDL sequence of commands
cat <<EOF > /tmp/${command}${$}.pro
year=getenv('year')
file1= '/usr/work/sur/fvi/OPA/ORCA2/' + '/Sigma_5d_'+year+'_grid_T.nc'
file2=getenv('GEOMAG_OD') + '/Sigma_5d_'+year+'_grid_T_ORCA2.nc'
step2_diff, file1, file2, 'Sigma_5d_'+year+'_grid_T_ORCA2_diff.nc'
EOF
#
unset year
#
# launch IDL with the sequence
${IDL_DIR}/bin/idl < /tmp/${command}${$}.pro
#
# cleanning
#++rm /tmp/${command}${$}.pro
#
# end
exit 0
