#!/bin/bash
# --------------------------------------------------------------------------- #
# matrix.base : Core of setting up matrix of regression test (v2).            #
#                                                                             #
# Remarks:                                                                    #
# - This code uses three temporary files,                                     #
#    matrix.head: This file can pre-exist with batch queue data etc. to be    #
#                 set in matrix.go. If not, the head will start as a bash     #
#                 script.                                                     #
#    matrix.body: All options, separated out to allow for switch filtering.   #
#    matrix.tail: Ending identification.                                      #
# - This script generates the file "matrix" that can then be executed         #
#   interactively and/or in batch, and can be edited by hand as needed.       #
# - Version 2 is set up to minimize compilations, using the sort_switch and   #
#   comp_switch utilities.                                                    #
#                                                                             #
#                                                      Hendrik L. Tolman      #
#                                                      August 2013            #
#                                                      December 2013          #
#                                                                             #
#    Copyright 2013 National Weather Service (NWS),                           #
#       National Oceanic and Atmospheric Administration.  All rights          #
#       reserved.  WAVEWATCH III is a trademark of the NWS.                   #
#       No unauthorized use without permission.                               #
#                                                                             #
# --------------------------------------------------------------------------- #
# 1. Set up
# 1.a Check environment parameters needed to be set up in calling script.

  for par in mpi np nr nth rtst ww3 shrd dist omp \
             prop1D prop2D time fetch hur1mg \
             multi01 multi02 multi03 multi04 multi05 \
             hybd shwtr unstr pdlib smcgr rtd mudice infgrv \
             uost assim calendar confignc oasis \
             esmf ufs ufscoarse rstrt_b4b nth_b4b npl_b4b grib \
             multi06 multi07 multi08 multi09
  do
    eval " value=\$$par"
#   echo "$par = $value"
    if [ -z "$value" ]
    then
       echo "error matrix.base: parameter $par not set ..."
       exit 1
    fi
  done

# 1.b Check on existence of matrix.head  - - - - - - - - - - - - - - - - - - -

  if [ ! -f matrix.head ]
  then
    echo "#!/bin/sh"  > matrix.head
  fi

  rm -f matrix.body
  rm -f matrix.tail

# 1.c Output to ID script  - - - - - - - - - - - - - - - - - - - - - - - - - -

  echo "  echo ' '"                                                            >> matrix.head
  echo "  echo '             **********************************************'"  >> matrix.head
  echo "  echo '           ***  WAVEWATCH III matrix of regression tests  ***'">> matrix.head
  echo "  echo '             **********************************************'"  >> matrix.head
  echo "  echo ' '"                                                            >> matrix.head

  echo "  echo '    Tests for single CPU codes                       : $shrd'" >> matrix.head
  echo "  echo '    Tests for multiple CPU codes (MPI)               : $dist'" >> matrix.head
  echo "  echo '    Tests for multiple CPU codes (OMP)               : $omp'"  >> matrix.head
  echo "  echo '    Tests for threaded multiple CPU codes (MPI/OMPH) : $hybd'" >> matrix.head
  echo "  echo ' '"                                                            >> matrix.head

  echo "  echo '      1D pure propagation tests          : $prop1D'"           >> matrix.head
  echo "  echo '      2D pure propagation tests          : $prop2D'"           >> matrix.head
  echo "  echo '      Growth curves (time)               : $time'"             >> matrix.head
  echo "  echo '      Growth curves (fetch)              : $fetch'"            >> matrix.head
  echo "  echo '      Shallow water tests                : $shwtr'"            >> matrix.head
  echo "  echo '      Unstructured grid tests            : $unstr'"            >> matrix.head
  echo "  echo '      SMC grid tests                     : $smcgr'"            >> matrix.head
  echo "  echo '      Rotated pole tests                 : $rtd'"              >> matrix.head
  echo "  echo '      Hurricane with one moving grid     : $hur1mg'"           >> matrix.head
  echo "  echo '      Mud/Ice and wave interaction tests : $mudice'"           >> matrix.head
  echo "  echo '      Second harmonic generation tests   : $infgrv'"           >> matrix.head
  echo "  echo '      Multi 01 (wet and dry)             : $multi01'"          >> matrix.head
  echo "  echo '      Multi 02 (basic nesting)           : $multi02'"          >> matrix.head
  echo "  echo '      Multi 03 (nesting and overlap)     : $multi03'"          >> matrix.head
  echo "  echo '      Multi 04 (swell on mount/current)  : $multi04'"          >> matrix.head
  echo "  echo '      Multi 05 (hurricane 3 moving grds) : $multi05'"          >> matrix.head
  echo "  echo '      Multi 06 (curv. + reg. grds)       : $multi06'"          >> matrix.head
  echo "  echo '      Multi 07 (unstr. + reg. grds)      : $multi07'"          >> matrix.head
  echo "  echo '      Multi 08 (with ice)                : $multi08'"          >> matrix.head
  echo "  echo '      Multi 09 (SMC multi grid)          : $multi09'"          >> matrix.head
  echo "  echo '      Assim Update of the restart file   : $assim'"            >> matrix.head
  echo "  echo '      OASIS coupling                     : $oasis'"            >> matrix.head
  echo "  echo '      Calendar type                      : $calendar'"         >> matrix.head
  echo "  echo '      ESMF Coupling                      : $esmf'"             >> matrix.head
  echo "  echo '      The Unified Forecast System        : $ufs'"              >> matrix.head
  echo "  echo '      grib file field output             : $grib'"             >> matrix.head
  echo "  echo '      Restart Reproducibility            : $rstrt_b4b'"        >> matrix.head
  echo "  echo '      MPI task Reproducibility           : $npl_b4b'"          >> matrix.head
  echo "  echo '      Thread Reproducibility             : $nth_b4b'"          >> matrix.head
  echo "  echo '      Configurable netCDF generation     : $confignc'"         >> matrix.head
  echo "  echo ' '"                                                            >> matrix.head
  if [ -n "$filter" ]
  then
    echo "  echo '      Filter for tests                 : $filter'"           >> matrix.head
    echo "  echo ' '"                                                          >> matrix.head
  fi

# --------------------------------------------------------------------------- #
# 2.  Here come all tests, sorted by identical switch files                   #
# --------------------------------------------------------------------------- #

# switch_PR1[_MPI] cases, pure propagation, (mostly) no sources

  if [ "$shrd" = 'y' ]
  then

    if [ "$prop1D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1 -w work_PR1 $ww3 ww3_tp1.1" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1 $ww3 ww3_tp1.2" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1 $ww3 ww3_tp1.3" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1 $ww3 ww3_tp1.4" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1 $ww3 ww3_tp1.5" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1 $ww3 ww3_tp1.6" >> matrix.body
    fi

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_curv -g curv  $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_a    -g a     $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_b    -g b     $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst        -w work_PR1               $ww3 ww3_tp2.12" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 ww3_tp2.13" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_TRPL -g TRPL  $ww3 ww3_tp2.13" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 ww3_tp2.5" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1 -w work_PR1               $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_a -m grdset_a $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_b -m grdset_b $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_c -m grdset_c $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_d -m grdset_d $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_a -m grdset_a $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_b -m grdset_b $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_c -m grdset_c $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_d -m grdset_d $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_e -m grdset_e $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_a -m grdset_a $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_b -m grdset_b $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_f -m grdset_f $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR1 -w work_PR1_g -m grdset_g $ww3 mww3_test_04" >> matrix.body
    fi
  
  fi

  if [ "$dist" = 'y' ]
  then

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_curv_MPI -g curv -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_a_MPI    -g a    -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_b_MPI    -g b    -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s MPI     -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.12" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.13" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_TRPL_MPI -g TRPL -f -p $mpi -n $np $ww3 ww3_tp2.13" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI                 -f -p $mpi -n $np $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_d2 -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR1_MPI -w work_PR1_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi
  
  fi

  if [ "$prop2D" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR1_MPI -w work_REF_PR1_MPI -i input_REF -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
  fi

  if [ "$prop2D" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR1 -w work_REF_PR1 -i input_REF $ww3 ww3_tp2.5" >> matrix.body
  fi

# switch_PR2_UNO[_MPI] cases, pure propagation, (mostly) no sources

  if [ "$shrd" = 'y' ]
  then

    if [ "$prop1D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO $ww3 ww3_tp1.1" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO $ww3 ww3_tp1.2" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO $ww3 ww3_tp1.3" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO $ww3 ww3_tp1.4" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO $ww3 ww3_tp1.5" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO $ww3 ww3_tp1.6" >> matrix.body
    fi

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO              $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO              $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO              $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO              $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_curv -g curv $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO              $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_a    -g a    $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_b    -g b    $ww3 ww3_tp2.9" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO               $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_a -m grdset_a $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_b -m grdset_b $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_c -m grdset_c $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_d -m grdset_d $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_a -m grdset_a $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_b -m grdset_b $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_c -m grdset_c $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_d -m grdset_d $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_e -m grdset_e $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_a -m grdset_a $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_b -m grdset_b $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_f -m grdset_f $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UNO -w work_PR2_UNO_g -m grdset_g $ww3 mww3_test_04" >> matrix.body
    fi

  fi

  if [ "$dist" = 'y' ]
  then

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_curv_MPI -g curv -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_a_MPI    -g a    -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_b_MPI    -g b    -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI                 -f -p $mpi -n $np $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_d2 -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UNO_MPI  -w work_PR2_UNO_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi

  fi

  if [ "$prop2D" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR2_UNO_MPI  -w work_REF_PR2_UNO_MPI -i input_REF -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
  fi

  if [ "$prop2D" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR2_UNO -w work_REF_PR2_UNO  -i input_REF $ww3 ww3_tp2.5" >> matrix.body
  fi

# switch_PR2_UQ[_MPI] cases, pure propagation, (mostly) no sources

  if [ "$shrd" = 'y' ]
  then

    if [ "$prop1D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ $ww3 ww3_tp1.1" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ $ww3 ww3_tp1.2" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ $ww3 ww3_tp1.3" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ $ww3 ww3_tp1.4" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ $ww3 ww3_tp1.5" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ $ww3 ww3_tp1.6" >> matrix.body
    fi

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ              $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ              $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ              $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ              $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_curv -g curv $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ              $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_a    -g a    $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_b    -g b    $ww3 ww3_tp2.9" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ               $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_a -m grdset_a $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_b -m grdset_b $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_c -m grdset_c $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_d -m grdset_d $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_a -m grdset_a $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_b -m grdset_b $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_c -m grdset_c $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_d -m grdset_d $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_e -m grdset_e $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_a -m grdset_a $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_b -m grdset_b $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_f -m grdset_f $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UQ -w work_PR2_UQ_g -m grdset_g $ww3 mww3_test_04" >> matrix.body
    fi

  fi

  if [ "$dist" = 'y' ]
  then

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_MPI               -f -p $mpi -n $np $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_MPI               -f -p $mpi -n $np $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_MPI               -f -p $mpi -n $np $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_MPI               -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_curv_MPI -g curv  -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_MPI               -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_a_MPI    -g a     -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI   -w work_PR2_UQ_b_MPI    -g b     -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI                 -f -p $mpi -n $np $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_d2 -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR2_UQ_MPI -w work_PR2_UQ_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi

  fi

  if [ "$prop2D" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR2_UQ_MPI  -w work_REF_PR2_UQ_MPI -i input_REF -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
  fi

  if [ "$prop2D" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR2_UQ -w work_REF_PR2_UQ  -i input_REF $ww3 ww3_tp2.5" >> matrix.body
  fi

# switch_PR3_UNO[_MPI] cases, pure propagation, (mostly) no sources

  if [ "$shrd" = 'y' ]
  then

    if [ "$prop1D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO $ww3 ww3_tp1.1" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO $ww3 ww3_tp1.2" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO $ww3 ww3_tp1.3" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO $ww3 ww3_tp1.4" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO $ww3 ww3_tp1.5" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO $ww3 ww3_tp1.6" >> matrix.body
    fi

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO              $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO              $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO              $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO              $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_curv -g curv $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO              $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_a    -g a    $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_b    -g b    $ww3 ww3_tp2.9" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO               $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_a -m grdset_a $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_b -m grdset_b $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_c -m grdset_c $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_d -m grdset_d $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_a -m grdset_a $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_b -m grdset_b $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_c -m grdset_c $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_d -m grdset_d $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_e -m grdset_e $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_a -m grdset_a $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_b -m grdset_b $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_f -m grdset_f $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO -w work_PR3_UNO_g -m grdset_g $ww3 mww3_test_04" >> matrix.body
    fi

    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_a_c -m grdset_a  -g curv $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_b_c -m grdset_b  -g curv $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_c_c -m grdset_c  -g curv $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_d_c -m grdset_d  -g curv $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_a_c -m grdset_a $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_b_c -m grdset_b $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_c_c -m grdset_c $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_d_c -m grdset_d $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_e_c -m grdset_e $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_a_c -m grdset_a $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_b_c -m grdset_b $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_f_c -m grdset_f $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_g_c -m grdset_g $ww3 mww3_test_04" >> matrix.body
    fi
    if [ "$multi06" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_SCRIP -w work_PR3_UNO_d   -m grdset_d $ww3 mww3_test_06" >> matrix.body
    fi

  fi

  if [ "$dist" = 'y' ]
  then

    if [ "$prop2D" = 'y' ] && [ "$dist" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.1" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.2" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.3" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_curv_MPI -g curv -f -p $mpi -n $np $ww3 ww3_tp2.4" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_a_MPI    -g a    -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_b_MPI    -g b    -f -p $mpi -n $np $ww3 ww3_tp2.9" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI                 -f -p $mpi -n $np $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_d2 -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI  -w work_PR3_UNO_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi

    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_a_c  -m grdset_a -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_b_c  -m grdset_b -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_c_c  -m grdset_c -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_d_c  -m grdset_d -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_a_c  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_b_c  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_c_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_d_c  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_d2_c -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_e_c  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_b_c  -m grdset_b -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_c_c  -m grdset_c -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_d_c  -m grdset_d -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UNO_MPI_SCRIP -w work_PR3_UNO_MPI_e_c  -m grdset_e -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi

  fi

  if [ "$prop2D" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR3_UNO_MPI  -w work_REF_PR3_UNO_MPI -i input_REF -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
  fi

  if [ "$prop2D" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR3_UNO -w work_REF_PR3_UNO  -i input_REF $ww3 ww3_tp2.5" >> matrix.body
  fi

# switch_PR3_UQ[_MPI] cases, pure propagation, (mostly) no sources

  if [ "$shrd" = 'y' ]
  then

    if [ "$prop1D" = 'y' ] && [ "$shrd" = 'y' ]
    then
      echo "$rtst              -w work_PR3_UQ    $ww3 ww3_tp1.7"  >> matrix.body
      echo "$rtst              -w work_PR3_UQ    $ww3 ww3_tp1.8"  >> matrix.body
      echo "$rtst -i input_BJ  -w work_BJ_PR3_UQ $ww3 ww3_tp1.8"  >> matrix.body
      echo "$rtst              -w work_PR3_UQ    $ww3 ww3_tp1.9"  >> matrix.body
      echo "$rtst           -N -w work_PR3_UQ    $ww3 ww3_tp1.11" >> matrix.body
      echo "$rtst -i input2 -N -w work_PR3_UQ    $ww3 ww3_tp1.11" >> matrix.body
    fi

    if [ "$unstr" = 'y' ]
    then
      echo "$rtst -s ST0 -w work_ST0 $ww3 ww3_tp2.6" >> matrix.body
      echo "$rtst -s ST0 -w work_ST0 $ww3 ww3_tp2.7" >> matrix.body
      echo "$rtst -s ST4 -w work_ST4 $ww3 ww3_tp2.6" >> matrix.body
    fi

    if [ "$prop1D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ $ww3 ww3_tp1.1" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ $ww3 ww3_tp1.2" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ $ww3 ww3_tp1.3" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ $ww3 ww3_tp1.4" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ $ww3 ww3_tp1.5" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ $ww3 ww3_tp1.6" >> matrix.body
    fi

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ                 $ww3 ww3_tp2.1"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ                 $ww3 ww3_tp2.2"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ                 $ww3 ww3_tp2.3"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ                 $ww3 ww3_tp2.4"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ_curv -g curv    $ww3 ww3_tp2.4"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ                 $ww3 ww3_tp2.5"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ_a    -g a       $ww3 ww3_tp2.9"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ_b    -g b       $ww3 ww3_tp2.9"  >> matrix.body
      echo "$rtst                        -w work_PR3_UQ                 $ww3 ww3_tp2.8"  >> matrix.body
      echo "$rtst -s PR3_UQ              -w work_PR3_UQ                 $ww3 ww3_tp2.13" >> matrix.body
      echo "$rtst                        -w work_PR3_UQ                 $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst                        -w work_5km -g 5km             $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst           -i input_rho -w work_PR3_UQ_RHO             $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst -s ST4    -i input_rho -w work_ST4FLX5                $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst -s ST6    -i input_rho -w work_ST6FLX5                $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst           -s TIDE      -w work_TIDE                   $ww3 ww3_tp2.18" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ               $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_a -m grdset_a $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_b -m grdset_b $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_c -m grdset_c $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_d -m grdset_d $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_a -m grdset_a $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_b -m grdset_b $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_c -m grdset_c $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_d -m grdset_d $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_e -m grdset_e $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_a -m grdset_a $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_b -m grdset_b $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_f -m grdset_f $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ -w work_PR3_UQ_g -m grdset_g $ww3 mww3_test_04" >> matrix.body
    fi

    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_a_c -m grdset_a  -g curv  $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_b_c -m grdset_b  -g curv  $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_c_c -m grdset_c  -g curv  $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_d_c -m grdset_d  -g curv  $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_a_c -m grdset_a           $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_b_c -m grdset_b           $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_c_c -m grdset_c           $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_d_c -m grdset_d           $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_e_c -m grdset_e           $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_a_c -m grdset_a           $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_b_c -m grdset_b           $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_f_c -m grdset_f           $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_g_c -m grdset_g           $ww3 mww3_test_04" >> matrix.body
    fi
    if [ "$multi06" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_SCRIP -w work_PR3_UQ_d   -m grdset_d           $ww3 mww3_test_06" >> matrix.body
    fi
    if [ "$multi07" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst                 -w work_PR3_UQ     -m grdset             $ww3 mww3_test_07" >> matrix.body
    fi

  fi

  if [ "$dist" = 'y' ]
  then

    if [ "$prop2D" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s MPI                     -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp1.9"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.1"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.2"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.3"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.4"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_curv_MPI -g curv     -f -p $mpi -n $np $ww3 ww3_tp2.4"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.5"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_a_MPI    -g a        -f -p $mpi -n $np $ww3 ww3_tp2.9"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_b_MPI    -g b        -f -p $mpi -n $np $ww3 ww3_tp2.9"  >> matrix.body
      echo "$rtst -s PR3_UQ_MPI              -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.13" >> matrix.body
      echo "$rtst -s MPI                     -w work_PR3_UQ_MPI                  -f -p $mpi -n $np $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst -s MPI                     -w work_MPI_5km         -g 5km      -f -p $mpi -n $np $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst -s MPI        -i input_rho -w work_PR3_UQ_RHO_MPI              -f -p $mpi -n $np $ww3 ww3_tp2.15" >> matrix.body
      echo "$rtst -s TIDE_MPI                -w work_TIDE_MPI                    -f -p $mpi -n $np $ww3 ww3_tp2.18" >> matrix.body
    fi

    if [ "$multi01" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI                 -f -p $mpi -n $np $ww3 mww3_test_01" >> matrix.body
    fi
    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_a  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_d2 -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_b  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_d  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI -w work_PR3_UQ_MPI_e  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi

    if [ "$multi02" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_a_c -m grdset_a -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_b_c -m grdset_b -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_c_c -m grdset_c -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_d_c -m grdset_d -g curv -f -p $mpi -n $np $ww3 mww3_test_02" >> matrix.body
    fi
    if [ "$multi03" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_a_c  -m grdset_a  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_b_c  -m grdset_b  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_c_c  -m grdset_c  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_d_c  -m grdset_d  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_d2_c -m grdset_d2 -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP -w work_PR3_UQ_MPI_e_c  -m grdset_e  -f -p $mpi -n $np $ww3 mww3_test_03" >> matrix.body
    fi
    if [ "$multi04" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP   -w work_PR3_UQ_MPI_b_c    -m grdset_b -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP   -w work_PR3_UQ_MPI_c_c    -m grdset_c -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP   -w work_PR3_UQ_MPI_d_c    -m grdset_d -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIP   -w work_PR3_UQ_MPI_e_c    -m grdset_e -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
      echo "$rtst -s PR3_UQ_MPI_SCRIPNC -w work_PR3_UQ_MPI_NC_b_c -m grdset_b -f -p $mpi -n $np $ww3 mww3_test_04" >> matrix.body
    fi

    if [ "$multi08" = 'y' ]
    then
      echo ' ' >> matrix.body
      echo "$rtst -s ST4_PR3_UQ_MPI -w work_ST4_PR3_UQ_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_08" >> matrix.body
      echo "$rtst -i i_lowres_multi -w work_lowres         -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_08" >> matrix.body
    fi

  fi

  if [ "$prop2D" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR3_UQ_MPI  -w work_REF_PR3_UQ_MPI -i input_REF -f -p $mpi -n $np $ww3 ww3_tp2.5" >> matrix.body
  fi

  if [ "$prop2D" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s PR3_UQ -w work_REF_PR3_UQ  -i input_REF $ww3 ww3_tp2.5" >> matrix.body
  fi

# time limited growth, no switch sharing here

  if [ "$time" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s ST1      -w work_ST1                     $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST1_RWND -w work_ST1_RWND                $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST2      -w work_ST2                     $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST3      -w work_ST3                     $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST4      -w work_ST4                     $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST4      -w work_ST4_T700 -g ST4_T700 -N $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST4_WRT  -w work_ST4_WRT                 $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST4_GMD  -w work_ST4_GMD                 $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST4_TSA  -w work_ST4_TSA                 $ww3 ww3_ts1" >> matrix.body
    echo "$rtst -s ST6      -w work_ST6                     $ww3 ww3_ts1" >> matrix.body
    echo "$rtst             -w work_NL5 -i input_nl5_matrix $ww3 ww3_ts1" >> matrix.body
  fi

# fetch limited growth, no switch sharing here

  if [ "$fetch" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s ST1_PR1     -w work_ST1_PR1     $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST1_PR2_UQ  -w work_ST1_PR2_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST1_PR2_UNO -w work_ST1_PR2_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST1_PR3_UQ  -w work_ST1_PR3_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST1_PR3_UNO -w work_ST1_PR3_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST2_PR1     -w work_ST2_PR1     $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST2_PR2_UQ  -w work_ST2_PR2_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST2_PR2_UNO -w work_ST2_PR2_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST2_PR3_UQ  -w work_ST2_PR3_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST2_PR3_UNO -w work_ST2_PR3_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST3_PR1     -w work_ST3_PR1     $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST3_PR2_UQ  -w work_ST3_PR2_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST3_PR2_UNO -w work_ST3_PR2_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST3_PR3_UQ  -w work_ST3_PR3_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST3_PR3_UNO -w work_ST3_PR3_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST4_PR1     -w work_ST4_PR1     $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST4_PR2_UQ  -w work_ST4_PR2_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST4_PR2_UNO -w work_ST4_PR2_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST4_PR3_UQ  -w work_ST4_PR3_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST4_PR3_UNO -w work_ST4_PR3_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST6_PR1     -w work_ST6_PR1     $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST6_PR2_UQ  -w work_ST6_PR2_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST6_PR2_UNO -w work_ST6_PR2_UNO $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST6_PR3_UQ  -w work_ST6_PR3_UQ  $ww3 ww3_ts2" >> matrix.body
    echo "$rtst -s ST6_PR3_UNO -w work_ST6_PR3_UNO $ww3 ww3_ts2" >> matrix.body
  fi

# ww3_st3, no switch sharing here, but run only if you do not run MPI or OpenMP

  if [ "$hur1mg" = 'y' ] && [ "$shrd" = 'y' ] && [ "$dist" != 'y' ]  && [ "$omp" != 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s ST1_PR1      -w work_ST1_PR1     $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST1_PR2_UQ   -w work_ST1_PR2_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST1_PR2_UNO  -w work_ST1_PR2_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST1_PR3_UQ   -w work_ST1_PR3_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST1_PR3_UNO  -w work_ST1_PR3_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST2_PR1      -w work_ST2_PR1     $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST2_PR2_UQ   -w work_ST2_PR2_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST2_PR2_UNO  -w work_ST2_PR2_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST2_PR3_UQ   -w work_ST2_PR3_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST2_PR3_UNO  -w work_ST2_PR3_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST3_PR1      -w work_ST3_PR1     $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST3_PR2_UQ   -w work_ST3_PR2_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST3_PR2_UNO  -w work_ST3_PR2_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST3_PR3_UQ   -w work_ST3_PR3_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST3_PR3_UNO  -w work_ST3_PR3_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR1      -w work_ST4_PR1     $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR1_FLD1 -w work_ST4_FLD1    $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR1_FLD2 -w work_ST4_FLD2    $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR2_UQ   -w work_ST4_PR2_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR2_UNO  -w work_ST4_PR2_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR3_UQ   -w work_ST4_PR3_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST4_PR3_UNO  -w work_ST4_PR3_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST6_PR1      -w work_ST6_PR1     $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST6_PR2_UQ   -w work_ST6_PR2_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST6_PR2_UNO  -w work_ST6_PR2_UNO $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST6_PR3_UQ   -w work_ST6_PR3_UQ  $ww3 ww3_ts3" >> matrix.body
    echo "$rtst -s ST6_PR3_UNO  -w work_ST6_PR3_UNO $ww3 ww3_ts3" >> matrix.body
  fi

# Moving grid cases for MPI, ww3_ts3 and mww3_test_05 share switches


  if [ "$dist" = 'y' ]
  then

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

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR1_MPI     -w work_ST1_PR1_MPI                 -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR1_MPI     -w work_ST1_PR1_MPI     -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UQ_MPI  -w work_ST1_PR2_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UQ_MPI  -w work_ST1_PR2_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UNO_MPI -w work_ST1_PR2_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UNO_MPI -w work_ST1_PR2_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UQ_MPI  -w work_ST1_PR3_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UQ_MPI  -w work_ST1_PR3_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UNO_MPI -w work_ST1_PR3_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UNO_MPI -w work_ST1_PR3_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR1_MPI     -w work_ST2_PR1_MPI                 -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR1_MPI     -w work_ST2_PR1_MPI     -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UQ_MPI  -w work_ST2_PR2_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UQ_MPI  -w work_ST2_PR2_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UNO_MPI -w work_ST2_PR2_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UNO_MPI -w work_ST2_PR2_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UQ_MPI  -w work_ST2_PR3_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UQ_MPI  -w work_ST2_PR3_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UNO_MPI -w work_ST2_PR3_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UNO_MPI -w work_ST2_PR3_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR1_MPI     -w work_ST3_PR1_MPI                 -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR1_MPI     -w work_ST3_PR1_MPI     -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UQ_MPI  -w work_ST3_PR2_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UQ_MPI  -w work_ST3_PR2_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UNO_MPI -w work_ST3_PR2_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UNO_MPI -w work_ST3_PR2_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UQ_MPI  -w work_ST3_PR3_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UQ_MPI  -w work_ST3_PR3_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UNO_MPI -w work_ST3_PR3_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UNO_MPI -w work_ST3_PR3_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR1_FLD1_MPI -w work_ST4_FLD1_MPI               -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
      echo "$rtst -s ST4_PR1_FLD2_MPI -w work_ST4_FLD2_MPI               -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
      echo "$rtst -s ST4_PR1_MPI     -w work_ST4_PR1_MPI                 -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR1_MPI     -w work_ST4_PR1_MPI     -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UQ_MPI  -w work_ST4_PR2_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UQ_MPI  -w work_ST4_PR2_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UNO_MPI -w work_ST4_PR2_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UNO_MPI -w work_ST4_PR2_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UQ_MPI  -w work_ST4_PR3_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UQ_MPI  -w work_ST4_PR3_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UNO_MPI -w work_ST4_PR3_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UNO_MPI -w work_ST4_PR3_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR1_MPI     -w work_ST6_PR1_MPI                 -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR1_MPI     -w work_ST6_PR1_MPI     -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UQ_MPI  -w work_ST6_PR2_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UQ_MPI  -w work_ST6_PR2_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UNO_MPI -w work_ST6_PR2_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UNO_MPI -w work_ST6_PR2_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UQ_MPI  -w work_ST6_PR3_UQ_MPI              -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UQ_MPI  -w work_ST6_PR3_UQ_MPI  -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UNO_MPI -w work_ST6_PR3_UNO_MPI             -f -p $mpi -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UNO_MPI -w work_ST6_PR3_UNO_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_05" >> matrix.body
    fi

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

  fi

# Moving grid cases for MPI-OPENMP Hybrid, ww3_ts3 and mww3_test_05 share switches


  if [ "$hybd" = 'y' ]
  then

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

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR1_MPI_OMPH     -w work_ST1_PR1_MPI_OMPH                 -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR1_MPI_OMPH     -w work_ST1_PR1_MPI_OMPH     -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UQ_MPI_OMPH  -w work_ST1_PR2_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UQ_MPI_OMPH  -w work_ST1_PR2_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UNO_MPI_OMPH -w work_ST1_PR2_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UNO_MPI_OMPH -w work_ST1_PR2_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UQ_MPI_OMPH  -w work_ST1_PR3_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UQ_MPI_OMPH  -w work_ST1_PR3_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UNO_MPI_OMPH -w work_ST1_PR3_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UNO_MPI_OMPH -w work_ST1_PR3_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR1_MPI_OMPH     -w work_ST2_PR1_MPI_OMPH                 -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR1_MPI_OMPH     -w work_ST2_PR1_MPI_OMPH     -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UQ_MPI_OMPH  -w work_ST2_PR2_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UQ_MPI_OMPH  -w work_ST2_PR2_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UNO_MPI_OMPH -w work_ST2_PR2_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UNO_MPI_OMPH -w work_ST2_PR2_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UQ_MPI_OMPH  -w work_ST2_PR3_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UQ_MPI_OMPH  -w work_ST2_PR3_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UNO_MPI_OMPH -w work_ST2_PR3_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UNO_MPI_OMPH -w work_ST2_PR3_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR1_MPI_OMPH     -w work_ST3_PR1_MPI_OMPH                 -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR1_MPI_OMPH     -w work_ST3_PR1_MPI_OMPH     -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UQ_MPI_OMPH  -w work_ST3_PR2_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UQ_MPI_OMPH  -w work_ST3_PR2_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UNO_MPI_OMPH -w work_ST3_PR2_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UNO_MPI_OMPH -w work_ST3_PR2_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UQ_MPI_OMPH  -w work_ST3_PR3_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UQ_MPI_OMPH  -w work_ST3_PR3_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UNO_MPI_OMPH -w work_ST3_PR3_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UNO_MPI_OMPH -w work_ST3_PR3_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR1_MPI_OMPH     -w work_ST4_PR1_MPI_OMPH                 -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR1_MPI_OMPH     -w work_ST4_PR1_MPI_OMPH     -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UQ_MPI_OMPH  -w work_ST4_PR2_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UQ_MPI_OMPH  -w work_ST4_PR2_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UNO_MPI_OMPH -w work_ST4_PR2_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UNO_MPI_OMPH -w work_ST4_PR2_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UQ_MPI_OMPH  -w work_ST4_PR3_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UQ_MPI_OMPH  -w work_ST4_PR3_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UNO_MPI_OMPH -w work_ST4_PR3_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UNO_MPI_OMPH -w work_ST4_PR3_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR1_MPI_OMPH     -w work_ST6_PR1_MPI_OMPH                 -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR1_MPI_OMPH     -w work_ST6_PR1_MPI_OMPH     -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UQ_MPI_OMPH  -w work_ST6_PR2_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UQ_MPI_OMPH  -w work_ST6_PR2_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UNO_MPI_OMPH -w work_ST6_PR2_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UNO_MPI_OMPH -w work_ST6_PR2_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UQ_MPI_OMPH  -w work_ST6_PR3_UQ_MPI_OMPH              -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UQ_MPI_OMPH  -w work_ST6_PR3_UQ_MPI_OMPH  -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UNO_MPI_OMPH -w work_ST6_PR3_UNO_MPI_OMPH             -f -p $mpi -n $nr -t $nth $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UNO_MPI_OMPH -w work_ST6_PR3_UNO_MPI_OMPH -m grdset_a -f -p $mpi -n $nr -t $nth $ww3 mww3_test_05" >> matrix.body
    fi

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

  fi
# Moving grid cases for OpenMP, ww3_ts3 and mww3_test_05 share switches


  if [ "$omp" = 'y' ]
  then

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

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR1_OMP     -w work_ST1_PR1_OMP                 -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR1_OMP     -w work_ST1_PR1_OMP     -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UQ_OMP  -w work_ST1_PR2_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UQ_OMP  -w work_ST1_PR2_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UNO_OMP -w work_ST1_PR2_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR2_UNO_OMP -w work_ST1_PR2_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UQ_OMP  -w work_ST1_PR3_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UQ_OMP  -w work_ST1_PR3_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UNO_OMP -w work_ST1_PR3_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST1_PR3_UNO_OMP -w work_ST1_PR3_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR1_OMP     -w work_ST2_PR1_OMP                 -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR1_OMP     -w work_ST2_PR1_OMP     -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UQ_OMP  -w work_ST2_PR2_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UQ_OMP  -w work_ST2_PR2_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UNO_OMP -w work_ST2_PR2_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR2_UNO_OMP -w work_ST2_PR2_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UQ_OMP  -w work_ST2_PR3_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UQ_OMP  -w work_ST2_PR3_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UNO_OMP -w work_ST2_PR3_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST2_PR3_UNO_OMP -w work_ST2_PR3_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR1_OMP     -w work_ST3_PR1_OMP                 -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR1_OMP     -w work_ST3_PR1_OMP     -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UQ_OMP  -w work_ST3_PR2_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UQ_OMP  -w work_ST3_PR2_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UNO_OMP -w work_ST3_PR2_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR2_UNO_OMP -w work_ST3_PR2_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UQ_OMP  -w work_ST3_PR3_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UQ_OMP  -w work_ST3_PR3_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UNO_OMP -w work_ST3_PR3_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST3_PR3_UNO_OMP -w work_ST3_PR3_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR1_OMP     -w work_ST4_PR1_OMP                 -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR1_OMP     -w work_ST4_PR1_OMP     -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UQ_OMP  -w work_ST4_PR2_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UQ_OMP  -w work_ST4_PR2_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UNO_OMP -w work_ST4_PR2_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR2_UNO_OMP -w work_ST4_PR2_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UQ_OMP  -w work_ST4_PR3_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UQ_OMP  -w work_ST4_PR3_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UNO_OMP -w work_ST4_PR3_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST4_PR3_UNO_OMP -w work_ST4_PR3_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR1_OMP     -w work_ST6_PR1_OMP                 -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR1_OMP     -w work_ST6_PR1_OMP     -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UQ_OMP  -w work_ST6_PR2_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UQ_OMP  -w work_ST6_PR2_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UNO_OMP -w work_ST6_PR2_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR2_UNO_OMP -w work_ST6_PR2_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UQ_OMP  -w work_ST6_PR3_UQ_OMP              -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UQ_OMP  -w work_ST6_PR3_UQ_OMP  -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi

    if [ "$hur1mg" = 'y' ] || [ "$multi05" = 'y' ] ; then 
      echo ' ' >> matrix.body ; fi
    if [ "$hur1mg" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UNO_OMP -w work_ST6_PR3_UNO_OMP             -f -O -n $np $ww3 ww3_ts3" >> matrix.body
    fi
    if [ "$multi05" = 'y' ]
    then
      echo "$rtst -s ST6_PR3_UNO_OMP -w work_ST6_PR3_UNO_OMP -m grdset_a -f -O -n $np $ww3 mww3_test_05" >> matrix.body
    fi
# - - - - - - - - - - - - 

  fi

# Second harmonic test case

  if [ "$infgrv" = 'y' ] && [ "$shrd" = 'y' ] 
  then
    echo ' ' >> matrix.body
    echo "$rtst $ww3 -w work_IG1 ww3_tig1.1" >> matrix.body
  fi

# SMC grid cases, MPI only if requested

  if [ "$smcgr" = 'y' ] && [ "$shrd" = 'y' ] && [ "$dist" != 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst $ww3 -w work_SHRD_SMC ww3_tp2.10" >> matrix.body
    echo "$rtst -w work_SHRD $ww3 ww3_tp2.16" >> matrix.body
  fi

  if [ "$smcgr" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI -w work_MPI -f -p $mpi -n $np $ww3 ww3_tp2.10" >> matrix.body
    echo "$rtst -s MPI -w work_MPI -f -p $mpi -n $np $ww3 ww3_tp2.16" >> matrix.body
  fi

  if [ "$smcgr" = 'y' ] && [ "$hybd" = 'y' ]; then
    echo "$rtst -s MPI_OMPH -w work_MPI_OMPH -f -p $mpi -n $nr -t $nth $ww3 ww3_tp2.10" >> matrix.body
    echo "$rtst -s MPI_OMPH -w work_MPI_OMPH -f -p $mpi -n $nr -t $nth $ww3 ww3_tp2.16" >> matrix.body
  fi

  if [ "$multi09" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI -w work_MPI -m grdset_a -f -p $mpi -n $np $ww3 mww3_test_09" >> matrix.body
  fi

# Rotated pole grid cases, (ww3_tp2.11 MPI only if requested)

  if [ "$rtd" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst $ww3 ww3_tr1" >> matrix.body
    echo "$rtst -i input_std -w work_std $ww3 ww3_tr1" >> matrix.body
    echo "$rtst -i input_bndin -w work_bndin $ww3 ww3_tr1" >> matrix.body
  fi

  if [ "$rtd" = 'y' ] && [ "$shrd" = 'y' ] && [ "$dist" != 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst $ww3 -w work_SHRD_RTD ww3_tp2.11" >> matrix.body
  fi

  if [ "$rtd" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI -w work_MPI -f -p $mpi -n $np $ww3 ww3_tp2.11" >> matrix.body
  fi

# mud/ice cases

  if [ "$mudice" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s BT8           -w work_BT8                                        $ww3 ww3_tbt1.1" >> matrix.body
    echo "$rtst -s BT8           -w work_BT8                                        $ww3 ww3_tbt2.1" >> matrix.body
    echo "$rtst -s BT9           -w work_BT9                                        $ww3 ww3_tbt1.1" >> matrix.body
    echo "$rtst -s BT9           -w work_BT9                                        $ww3 ww3_tbt2.1" >> matrix.body
    echo "$rtst -g 100m          -w work_100m_IC1              -i input_IC1_156x3   $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 350m          -w work_350m_IC1              -i input_IC1_156x3   $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_1000m_IC1             -i input_IC1_156x3   $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 2500m         -w work_2500m_IC1             -i input_IC1_156x3   $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 5km           -w work_5km_IC1               -i input_IC1         $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 10km          -w work_10km_IC1              -i input_IC1         $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 20km          -w work_20km_IC1              -i input_IC1         $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst                  -w work_IC1                   -i input_IC1         $ww3 ww3_tic2.1" >> matrix.body
    echo "$rtst                  -w work_IC2IS2                                     $ww3 ww3_tic2.2" >> matrix.body
    echo "$rtst -g 1000m         -w work_1000m_IC2_nrl         -i input_IC2_nrl     $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst                  -w work_IC2_nondisp_SMPL      -i input_IC2_nondisp $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m_nondisp -w work_1000m_nondisp_IC2_ifr -i input_IC2_ifr     $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m_nondisp -w work_1000m_nondisp_IC2_nrl -i input_IC2_nrl     $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 350m          -w work_350m_IC3              -i input_IC3         $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_1000m_IC3             -i input_IC3         $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 2500m         -w work_2500m_IC3             -i input_IC3         $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst                  -w work_IC3_nondisp           -i input_IC3_nondisp $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g CGICE_CHENG   -w work_IC3_CGICE_CHENG       -i input_IC3NL       $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC4_M1                -i input_IC4_M1      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC4_M2                -i input_IC4_M2      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC4_M3                -i input_IC4_M3      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC4_M4                -i input_IC4_M4      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC4_M5                -i input_IC4_M5      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst                  -w work_IC4_M6                -i input_IC4_M6      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 206H          -w work_IC4_M6H               -i input_IC4_M6      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 206L          -w work_IC4_M6L               -i input_IC4_M6      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst                  -w work_IC4_M7                -i input_IC4_M7      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC5_M1                -i input_IC5_M1      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC5_M2                -i input_IC5_M2      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -g 1000m         -w work_IC5_M3                -i input_IC5_M3      $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst                  -w work_IC3_A0.5k             -i input_IC3_A0.5k   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_A1.0k             -i input_IC3_A1.0k   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_A2.5k             -i input_IC3_A2.5k   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_B0.5k             -i input_IC3_B0.5k   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_B1.0k             -i input_IC3_B1.0k   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_B2.5k             -i input_IC3_B2.5k   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_CHENG             -i input_IC3_CHENG   $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_V1_h              -i input_IC3_V1_h    $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst                  -w work_IC3_V1_G              -i input_IC3_V1_G    $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst -s PR1_REFRX     -w work_IC3_0.5k_PR1          -i input_IC3_0.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR1_REFRX     -w work_IC3_2.5k_PR1          -i input_IC3_2.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR1_REFRX     -w work_IC3_CHENG             -i input_IC3_CHENG   $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR2_UQ_REFRX  -w work_IC3_0.5k_PR2_UQ       -i input_IC3_0.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR2_UQ_REFRX  -w work_IC3_2.5k_PR2_UQ       -i input_IC3_2.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR2_UQ_REFRX  -w work_IC3_V1_h              -i input_IC3_V1_h    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR2_UNO_REFRX -w work_IC3_0.5k_PR2_UNO      -i input_IC3_0.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR2_UNO_REFRX -w work_IC3_2.5k_PR2_UNO      -i input_IC3_2.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR2_UNO_REFRX -w work_IC3_V1_G              -i input_IC3_V1_G    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR3_UQ_REFRX  -w work_IC3_0.5k_PR3_UQ       -i input_IC3_0.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR3_UQ_REFRX  -w work_IC3_2.5k_PR3_UQ       -i input_IC3_2.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR3_UNO_REFRX -w work_IC3_0.5k_PR3_UNO      -i input_IC3_0.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s PR3_UNO_REFRX -w work_IC3_2.5k_PR3_UNO      -i input_IC3_2.5k    $ww3 ww3_tic1.3" >> matrix.body
    echo "$rtst -s IC0IS2        -w work_IC0IS2_1000      -g 1000m                  $ww3 ww3_tic1.4" >> matrix.body
    echo "$rtst -s IC1IS2        -w work_IC1IS2_1000      -g 1000m                  $ww3 ww3_tic1.4" >> matrix.body
    echo "$rtst -s IC2IS2        -w work_IC2IS2_IC2b      -g IC2b_1000m             $ww3 ww3_tic1.4" >> matrix.body
    echo "$rtst -s IC2IS2        -w work_IC2IS2_IC2d      -g IC2d_1000m             $ww3 ww3_tic1.4" >> matrix.body
    echo "$rtst -s IC2IS2        -w work_IC2IS2scat       -g scat                   $ww3 ww3_tic2.3" >> matrix.body    
    echo "$rtst -s IC2IS2        -w work_IC2IS2creep      -g creepOnly              $ww3 ww3_tic2.3" >> matrix.body
    echo "$rtst -s IC2IS2        -w work_IC2IS2dissip     -g dissipOnly             $ww3 ww3_tic2.3" >> matrix.body
  fi

  if [ "$mudice" = 'y' ] && [ "$dist" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s BT8_MPI -w work_BT8_MPI  -f -p $mpi -n $np $ww3 ww3_tbt1.1" >> matrix.body
    echo "$rtst -s BT8_MPI -w work_BT8_MPI  -f -p $mpi -n $np $ww3 ww3_tbt2.1" >> matrix.body
    echo "$rtst -s BT9_MPI -w work_BT9_MPI  -f -p $mpi -n $np $ww3 ww3_tbt1.1" >> matrix.body
    echo "$rtst -s BT9_MPI -w work_BT9_MPI  -f -p $mpi -n $np $ww3 ww3_tbt2.1" >> matrix.body
    echo "$rtst -s MPI -g CGICE_CHENG   -w work_IC3_CGICE_CHENG_MPI   -i input_IC3NL -f -p $mpi -n $np $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -s MPI -g CGOW_CHENG    -w work_IC3_CGOW_CHENG_MPI    -i input_IC3NL -f -p $mpi -n $np $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -s MPI -g CGOW_NOCHENG  -w work_IC3_CGOW_NOCHENG_MPI  -i input_IC3NL -f -p $mpi -n $np $ww3 ww3_tic1.1" >> matrix.body
    echo "$rtst -s MPI -w work_IC3_A0.5k_MPI -i input_IC3_A0.5k -f -p $mpi -n $np $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst -s MPI -w work_IC3_A1.0k_MPI -i input_IC3_A1.0k -f -p $mpi -n $np $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst -s MPI -w work_IC3_A2.5k_MPI -i input_IC3_A2.5k -f -p $mpi -n $np $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst -s MPI -w work_IC3_B0.5k_MPI -i input_IC3_B0.5k -f -p $mpi -n $np $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst -s MPI -w work_IC3_B1.0k_MPI -i input_IC3_B1.0k -f -p $mpi -n $np $ww3 ww3_tic1.2" >> matrix.body
    echo "$rtst -s MPI -w work_IC3_B2.5k_MPI -i input_IC3_B2.5k -f -p $mpi -n $np $ww3 ww3_tic1.2" >> matrix.body
  fi


 # unstructured grid with PDLIB for domain decomposition and implicit solver
 if [ "$pdlib" = 'y' ] && [ "$dist" = 'y' ]
 then
   echo ' ' >> matrix.body
   echo "$rtst -s MPI -s NO_PDLIB -w work_a     -g a        -f -p $mpi -n $np $ww3 ww3_tp2.17"     >> matrix.body
   echo "$rtst -s MPI -s NO_PDLIB -w work_ma    -m grdset_a -f -p $mpi -n $np $ww3 ww3_tp2.17"     >> matrix.body
   echo "$rtst -s MPI -s PDLIB    -w work_b     -g b        -f -p $mpi -n $np $ww3 ww3_tp2.17"     >> matrix.body
   echo "$rtst -s MPI -s PDLIB    -w work_c     -g c        -f -p $mpi -n $np $ww3 ww3_tp2.17"     >> matrix.body
   echo "$rtst -s MPI -s PDLIB    -w work_pdlib -g pdlib    -f -p $mpi -n $np $ww3 ww3_tp2.6"      >> matrix.body 
   echo "$rtst -s MPI -s PDLIB    -w work_mb    -m grdset_b -f -p $mpi -n $np $ww3 ww3_tp2.17"     >> matrix.body
   echo "$rtst -s MPI -s PDLIB    -w work_mc    -m grdset_c -f -p $mpi -n $np $ww3 ww3_tp2.17"     >> matrix.body
     if [ "$rstrt_b4b" = 'y' ]
     then
        echo "mkdir -p ww3_tp2.17/work_ma1"                                                        >> matrix.body
        echo "cp ww3_tp2.17/work_ma/restart001.inla ww3_tp2.17/work_ma1/restart.inla"              >> matrix.body
        echo "$rtst -s MPI -s NO_PDLIB -w work_ma1 -m grdset_a1 -f -p $mpi -n $np $ww3 ww3_tp2.17" >> matrix.body
        echo "./bin/test.comp ww3_tp2.17 work_ma work_ma1"                                         >> matrix.body
        echo "mkdir -p ww3_tp2.17/work_mc1"                                                        >> matrix.body
        echo "cp ww3_tp2.17/work_mc/restart001.inlc ww3_tp2.17/work_mc1/restart.inlc"              >> matrix.body
        echo "$rtst -s MPI -s PDLIB    -w work_mc1 -m grdset_c1 -f -p $mpi -n $np $ww3 ww3_tp2.17" >> matrix.body
        echo "./bin/test.comp ww3_tp2.17 work_mc work_mc1"                                         >> matrix.body
     fi
 fi

 # unstructured grid with PDLIB for domain decomposition and implicit solver, Neumann Bnd, depth breaking & triad interaction ST
 if [ "$pdlib" = 'y' ] && [ "$dist" = 'y' ] 
 then
   echo ' ' >> matrix.body
   echo "$rtst -s MPI -s PDLIB -w work_1A_a -f -g a -p $mpi -n $np -o netcdf -i input_Case1A $ww3 ww3_tp2.19" >> matrix.body
   echo "$rtst -s MPI -s PDLIB -w work_1B_a -f -g a -p $mpi -n $np -o netcdf -i input_Case1B $ww3 ww3_tp2.19" >> matrix.body
   echo "$rtst -s MPI -s PDLIB -w work_1C_a -f -g a -p $mpi -n $np -o netcdf -i input_Case1C $ww3 ww3_tp2.19" >> matrix.body
 fi


 #Unresolved Obstacles Source Term (UOST) 
 if [ "$uost" = 'y' ] 
 then
   echo ' ' >> matrix.body
   if [ "$dist" = 'y' ]
   then 
     echo "$rtst -s MPI -w work_rg_shel_MPI  -i input_rg_shel            -f -p $mpi -n $np $ww3 ww3_ts4" >> matrix.body
     echo "$rtst -s MPI -w work_rg_multi_MPI -i input_rg_multi -m grdset -f -p $mpi -n $np $ww3 ww3_ts4" >> matrix.body
     echo "$rtst -s MPI -w work_ug_MPI       -i input_ug                 -f -p $mpi -n $np $ww3 ww3_ts4" >> matrix.body
   else 
     echo "$rtst        -w work_rg_shel      -i input_rg_shel                              $ww3 ww3_ts4" >> matrix.body
     echo "$rtst        -w work_rg_multi     -i input_rg_multi -m grdset                   $ww3 ww3_ts4" >> matrix.body
     echo "$rtst        -w work_ug           -i input_ug                                   $ww3 ww3_ts4" >> matrix.body
   fi
 fi

 # Global unstructured grid and Unresolved Obstacles Source Term (UOST) 
 if [ "$uost" = 'y' ] && [ "$dist" = 'y' ]
 then
   echo ' ' >> matrix.body
   echo "$rtst -s MPI -s NO_PDLIB -w work_a  -g a        -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
   echo "$rtst -s MPI -s NO_PDLIB -w work_ma -m grdset_a -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
   if [ "$pdlib" = 'y' ]
   then
     echo "$rtst -s MPI -s PDLIB -w work_b  -g b        -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
     echo "$rtst -s MPI -s PDLIB_METIS -w work_b_metis -g b -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
     echo "$rtst -s MPI -s PDLIB -w work_mb -m grdset_b -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
   fi
 fi

 #Test of updating the restart spectra 
 if [ "$assim" = 'y' ]
 then
   echo ' ' >> matrix.body
   echo "$rtst -s ST4 -w work_UPD0F_O    -i input_UPD0F_O    $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD0F_U    -i input_UPD0F_U    $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD2_O     -i input_UPD2_O     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD2_U     -i input_UPD2_U     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD2_U_cap -i input_UPD2_U_cap $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD3_O     -i input_UPD3_O     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD3_U     -i input_UPD3_U     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD3_U_cap -i input_UPD3_U_cap $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD5_O     -i input_UPD5_O     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD5_U     -i input_UPD5_U     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD5_U_cap -i input_UPD5_U_cap $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD6_O     -i input_UPD6_O     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD6_U     -i input_UPD6_U     $ww3 ww3_ta1" >> matrix.body
   echo "$rtst -s ST4 -w work_UPD6_U_cap -i input_UPD6_U_cap $ww3 ww3_ta1" >> matrix.body
  fi

 #Test of atmosphere, ocean, and ice coupling using OASIS 
 if [ "$oasis" = 'y' ] && [ "$dist" = 'y' ]
 then
   echo ' ' >> matrix.body
   echo "$rtst -s OASACM  -i input_oasacm  -w work_OASACM  -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
   echo "$rtst -s OASACM2 -i input_oasacm2 -w work_OASACM2 -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
   halfnp=$(($np / 2))
   echo "$rtst -s OASACM3 -i input_oasacm3 -w work_OASACM3          -f -p $mpi -n $halfnp $ww3 ww3_tp2.14" >> matrix.body
   echo "mkdir -p ww3_tp2.14/work_OASACM4"                                                                 >> matrix.body
   echo "ln -sf ../work_OASACM3/restart001.ww3 ww3_tp2.14/work_OASACM4/restart.ww3"                        >> matrix.body
   echo "$rtst -s OASACM4 -i input_oasacm4 -w work_OASACM4 -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
   echo "mkdir -p ww3_tp2.14/work_OASACM5"                                                                 >> matrix.body
   echo "ln -sf ../work_OASACM4/restart001.ww3 ww3_tp2.14/work_OASACM5/restart.ww3"                        >> matrix.body
   echo "$rtst -s OASACM5 -i input_oasacm5 -w work_OASACM5 -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
   echo "$rtst -s OASACM6 -i input_oasacm6 -w work_OASACM6 -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
   echo "$rtst -s OASOCM  -i input_oasocm  -w work_OASOCM  -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
   echo "$rtst -s OASICM  -i input_oasicm  -w work_OASICM  -C OASIS -f -p $mpi -n $np     $ww3 ww3_tp2.14" >> matrix.body
 fi

 #Test of UFS applications with ww3_multi and grib2 output
  if [ "$ufs" = 'y' ] && [ "$grib" = 'y' ]
  then
     # (light grid for single core/laptop check)
     if [ "$ufscoarse" = 'y' ]
     then
       echo ' ' >> matrix.body
       echo "$rtst -s MPI -w work_c -m grdset_c -f -p $mpi -n $np $ww3 ww3_ufs1.1"                         >> matrix.body
        if [ "$npl_b4b" = 'y' ]
        then
           halfnp=$(($np / 2))
           echo "$rtst -s MPI -w work_c_npl -m grdset_c -f -p $mpi -n $halfnp $ww3 ww3_ufs1.1"             >> matrix.body
           echo "./bin/test.comp ww3_ufs1.1 work_c work_c_npl"                                             >> matrix.body
        fi
        if [ "$nth_b4b" = 'y' ]
        then
           echo "$rtst -s MPI_OMPH -w work_c_nth -m grdset_c -f -p $mpi -n $nr -t $nth $ww3 ww3_ufs1.1"    >> matrix.body
           echo "./bin/test.comp ww3_ufs1.1 work_c work_c_nth"                                             >> matrix.body
        fi
        if [ "$rstrt_b4b" = 'y' ]
        then
           echo "mkdir -p ww3_ufs1.1/work_d"                                                               >> matrix.body
           echo "cp ww3_ufs1.1/work_c/20210401.030000.restart.glo_5deg ww3_ufs1.1/work_d/restart.glo_5deg" >> matrix.body
           echo "$rtst -s MPI -w work_d -m grdset_d -f -p $mpi -n $np $ww3 ww3_ufs1.1"                     >> matrix.body
           echo "./bin/test.comp ww3_ufs1.1 work_c work_d"                                                 >> matrix.body
        fi
     else
      echo ' ' >> matrix.body
      echo "$rtst -s MPI_OMPH -w work_a -m grdset_a -f -p $mpi -n $npl -t $nth1 $ww3 ww3_ufs1.1"           >> matrix.body
      if [ "$npl_b4b" = 'y' ]
      then
          echo "$rtst -s MPI_OMPH -w work_a_npl -m grdset_a -f -p $mpi -n $npl1 -t $nth1 $ww3 ww3_ufs1.1"  >> matrix.body
          echo "./bin/test.comp ww3_ufs1.1 work_a work_a_npl"                                              >> matrix.body
      fi
      if [ "$nth_b4b" = 'y' ]
      then
          echo "$rtst -s MPI_OMPH -w work_a_nth -m grdset_a -f -p $mpi -n $npl -t $nth $ww3 ww3_ufs1.1"    >> matrix.body
          echo "./bin/test.comp ww3_ufs1.1 work_a work_a_nth"                                              >> matrix.body
      fi
      if [ "$rstrt_b4b" = 'y' ]
      then
          echo "mkdir -p ww3_ufs1.1/work_b"                                                                >> matrix.body
          echo "cp ww3_ufs1.1/work_a/20210401.030000.restart.glo_1deg ww3_ufs1.1/work_b/restart.glo_1deg"  >> matrix.body
          echo "$rtst -s MPI_OMPH -w work_b -m grdset_b -f -p $mpi -n $npl -t $nth1 $ww3 ww3_ufs1.1"       >> matrix.body
          echo "./bin/test.comp ww3_ufs1.1 work_a work_b"                                                  >> matrix.body
      fi
     fi

 # Global unstr case
 # Domain Decomposition Explicit
  fi
     echo "$rtst -s MPI -s PDLIB -i input_unstr -w work_unstr_a -g a -f -p $mpi -n $np $ww3 ww3_ufs1.1"   >> matrix.body
 # Domain Decomposition Block Explicit
     echo "$rtst -s MPI -s PDLIB -i input_unstr -w work_unstr_b -g b -f -p $mpi -n $np $ww3 ww3_ufs1.1"   >> matrix.body
 # Domain Decomposition Implicit
     echo "$rtst -s MPI -s PDLIB -i input_unstr -w work_unstr_c -g c -f -p $mpi -n $np $ww3 ww3_ufs1.1"   >> matrix.body

 #Test of UFS applications with ww3_multi_esmf and grib2 output
  if [ "$ufs" = 'y' ] && [ "$esmf" = 'y' ] && [ "$grib" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI -w work_a_esmf -m grdset_a -C ESMF -f -p $mpi -n $npl   $ww3 ww3_ufs1.1"            >> matrix.body
    if [ "$rstrt_b4b" = 'y' ]
    then
      echo "mkdir -p ww3_ufs1.1/work_b_esmf"                                                               >> matrix.body
      echo "cp ww3_ufs1.1/work_a_esmf/20210401.030000.restart.glo_1deg ww3_ufs1.1/work_b_esmf/restart.glo_1deg"     >> matrix.body
      echo "$rtst -s MPI -w work_b_esmf -m grdset_b -C ESMF -f -p $mpi -n $npl $ww3 ww3_ufs1.1"            >> matrix.body
      echo "./bin/test.comp ww3_ufs1.1 work_a_esmf work_b_esmf"                                            >> matrix.body
    fi
  fi

 #GFSv16 setup with ww3_multi and grib2 output
  if [ "$ufs" = 'y' ] && [ "$grib" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI_OMPH -w work_a -m grdset_a -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.2"            >> matrix.body
    if [ "$rstrt_b4b" = 'y' ]
    then
       echo "mkdir -p ww3_ufs1.2/work_b"                                                                   >> matrix.body
       echo "cp ww3_ufs1.2/work_a/20210401.030000.restart.gnh_10m ww3_ufs1.2/work_b/restart.gnh_10m"       >> matrix.body
       echo "cp ww3_ufs1.2/work_a/20210401.030000.restart.gsh_15m ww3_ufs1.2/work_b/restart.gsh_15m"       >> matrix.body
       echo "cp ww3_ufs1.2/work_a/20210401.030000.restart.aoc_9km ww3_ufs1.2/work_b/restart.aoc_9km"       >> matrix.body
       echo "$rtst -s MPI_OMPH -w work_b -m grdset_b -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.2"         >> matrix.body
       echo "./bin/test.comp ww3_ufs1.2 work_a work_b"                                                     >> matrix.body
    fi
  fi

 #GFSv16 setup with ww3_multi_esmf and grib2 output
  if [ "$ufs" = 'y' ] && [ "$esmf" = 'y' ] && [ "$grib" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI_OMPH -w work_a_esmf -m grdset_a -C ESMF -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.2"     >> matrix.body
    if [ "$rstrt_b4b" = 'y' ]
    then
       echo "mkdir -p ww3_ufs1.2/work_b_esmf"                                                                    >> matrix.body
       echo "cp ww3_ufs1.2/work_a_esmf/20210401.030000.restart.gnh_10m ww3_ufs1.2/work_b_esmf/restart.gnh_10m"   >> matrix.body
       echo "cp ww3_ufs1.2/work_a_esmf/20210401.030000.restart.gsh_15m ww3_ufs1.2/work_b_esmf/restart.gsh_15m"   >> matrix.body
       echo "cp ww3_ufs1.2/work_a_esmf/20210401.030000.restart.aoc_9km ww3_ufs1.2/work_b_esmf/restart.aoc_9km"   >> matrix.body
       echo "$rtst -s MPI_OMPH -w work_b_esmf -m grdset_b  -C ESMF -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.2" >> matrix.body
       echo "./bin/test.comp ww3_ufs1.2 work_a_esmf work_b_esmf"                                                 >> matrix.body
    fi
  fi

 #Test gint for restarts 
  if [ "$ufs" = 'y' ] && [ "$grib" = 'y' ]
  then
    echo ' ' >> matrix.body    
    echo "$rtst -s MPI_OMPH -w work_c -m grdset_c -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.2"            >> matrix.body
    echo "mkdir -p ww3_ufs1.2/work_l"                                                                      >> matrix.body
    echo "cp ww3_ufs1.2/work_c/restart.hafsl ww3_ufs1.2/work_l/restart.hafsl"                              >> matrix.body
    echo "$rtst -s MPI_OMPH -w work_l -m grdset_l -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.2"            >> matrix.body
  fi 


 #GEFSv12 setup with ww3_multi and grib2 output
  if [ "$ufs" = 'y' ] && [ "$grib" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -s MPI_OMPH -w work_a -m grdset_a -f -p $mpi -n $npl  -t $nth1 $ww3 ww3_ufs1.3"                  >> matrix.body
  fi


  # 365_day and 360_day calendars, no switch sharing here
  if [ "$calendar" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -g STD  -w work_STD  $ww3 ww3_tc1" >> matrix.body
    echo "$rtst -g C360 -w work_C360 $ww3 ww3_tc1" >> matrix.body
    echo "$rtst -g C365 -w work_C365 $ww3 ww3_tc1" >> matrix.body
  fi

  # Configurable netCDF metadata in ww3_ounf
  if [ "$confignc" = 'y' ] && [ "$shrd" = 'y' ]
  then
    echo ' ' >> matrix.body
    echo "$rtst -N $ww3 ww3_tnc1" >> matrix.body
  fi

# --------------------------------------------------------------------------- #
# 3.  End of script output                                                    #
# --------------------------------------------------------------------------- #

  echo "  echo ' '"                                                                > matrix.tail
  echo "  echo '       *****************************************************'"    >> matrix.tail
  echo "  echo '     ***  end of WAVEWATCH III matrix of regression tests  ***'"  >> matrix.tail
  echo "  echo '       *****************************************************'"    >> matrix.tail
  echo "  echo ' '"                                                               >> matrix.tail

# --------------------------------------------------------------------------- #
# 4.  Put it together and clean up                                            #
# --------------------------------------------------------------------------- #

  mv matrix.head matrix

  if [ -z "$filter" ]
  then
    cat matrix.body >> matrix
    rm -f matrix.body
  else
    for filt in $filter
    do
      mv matrix.body matrix.head
      grep $filt matrix.head > matrix.body
      rm -f matrix.head
    done
    cat matrix.body >> matrix
    rm -f matrix.body
  fi

  cat matrix.tail >> matrix
  rm -f matrix.tail

  echo "file matrix prepared ...."

# --------------------------------------------------------------------------- #
# End to matrix.base                                                          #
# --------------------------------------------------------------------------- #