#!/bin/ksh +x
#
if [ "${1}" = "-h" ]
then
  echo " "
  echo " Reads zonal wind, meridional wind, temperature, specific humidity and"
  echo " geopotential height of the CasoInp with KmaxInp pressure levels and"
  echo " interpolate/extrapolate Vertically to KmaxOut pressure levels of CasoOut"
  echo " into a file with zonal wind, meridional wind and geopotential height"
  echo " for the RainRS case"
  echo " "
  echo " Usage:"
  echo " ./run_RainRS caso [Kmax] [Mmax]"
  echo " "
  echo " Default:"
  echo " caso = CFSV2 ; Mmax = 126"
  echo " "
  echo " caso : five letters case identifier"
  echo " Kmax : number of pressure levels of caso"
  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 " "
  exit
fi
#
caso=${1}
if [ -z "${caso}" ]
then
  caso=MONAN
fi
if [ ${caso} != "MONAN" ]
then
  if [ ${caso} != "ERA_5" ]
  then
    if [ ${caso} != "CFSV2" ]
    then
      if [ ${caso} != "NCEPF" ]
      then
        caso=MONAN
      fi
    fi
  fi
fi
if [ -z "${2}" ]
then
  Kmax=22
else
  Kmax=${2}
fi
if [ -z "${3}" ]
then
  Mmax=126
else
  Mmax=${3}
fi
#
if [ ${caso} = "MONAN" ]
then
#
  ep=1
  while [ ep -le 12 ]
  do
    echo "./Run_GEUVZ ${caso} ${Kmax} ${ep} RainRS no .TRUE. ${Mmax}"
    ./Run_GEUVZ ${caso} ${Kmax} ${ep} RainRS no .TRUE. ${Mmax}
    let ep=ep+1
  done
  ep=16
  while [ ep -le 27 ]
  do
    echo "./Run_GEUVZ ${caso} ${Kmax} ${ep} RainRS no .TRUE. ${Mmax}"
    ./Run_GEUVZ ${caso} ${Kmax} ${ep} RainRS no .TRUE. ${Mmax}
  let ep=ep+1
  done
#
else
#
ep=1
while [ ep -le 15 ]
do
  echo "./Run_GEUVZ ${caso} ${Kmax} ${ep} RainRS no .TRUE. ${Mmax}"
  ./Run_GEUVZ ${caso} ${Kmax} ${ep} RainRS no .TRUE. ${Mmax}
  let ep=ep+1
done
#
fi
#
