#!/bin/ksh +x
#**************************#
#                          #
#     Reinforcement_Do     #
#                          #
#**************************#
#
if [ "${1}" = "-h" ]
then
  echo " "
  echo " Do Calculations for the Points which Mixed Waves Energy have"
  echo " Reinforcements to Plot the Reinforcement Graphic"
  echo " "
  echo "   Usage:"
  echo " "
  echo "   ./Reinforcement_Do cs [Mmax]"
  echo " "
  echo " Default:"
  echo " cs = br ; Mmax = 126"
  echo " "
  echo " cs : br for Barotropic Mode"
  echo " Mmax : Rhomb+1 (even), Rhomb is the zonal wave truncation (Rhomb odd number)"
  echo "        is the total number of zonal waves plus the zonal mean (+1)"
  echo " "
  echo " Obs:"
  echo "    Barotropic Mixed Waves 3 and 1 are the Best for Suitable Graphic"
  echo "    Mixed Rossby-Gravity: mx : l=Mmax+17, isi=2, ln=0"
  echo "    Wave Numbers for Reinforcement: s1=3 and s2=1"
  echo "    Note that s=k-1 ; s=0,1,2,... ; k=1,2,3,..."
  echo " "
  exit
fi
#
cs=${1}
if [ "${cs}" != "br" ]
then
  cs="br"
fi
#
if [ -z "${2}" ]
then
  Mmax=126
else
  Mmax=${2}
fi
#
dircfg='../../../Config/'
. ${dircfg}Config_Dir
. ${dircfg}Reference_Case
#
vr="mx"
# Barotropic Mode
typeset -Z3 hh
hh=001
#
typeset -Z3 kmx
let kmx=${Kmax}
typeset -Z4 mmx1
let mmx1=${Mmax}-1
#
# Namelist
#
Trunc=RB${mmx1}L${kmx}
ext=${vr}_1_${Trunc}_${csvm}_h${hh}
dgs=Eps_Hn_${ext}.dgs
out=../../output/Reinforcement_Do_${ext}.out
#
rm -f ${out}
rm -f ./nml/Reinforcement_Do.nml
#
set -x
#
cat << eot > ./nml/Reinforcement_Do.nml
 &Reinforcementnml
  eps_hn='${dgs}'
 /
eot
#
# Running
time ../../bin/Reinforcement_Do.bin > ${out}
#
rm -f ./nml/Reinforcement_Do.nml
#
