#!/bin/ksh

#PBS -N testRpost
#PBS -o /lfs/h2/emc/ptmp/manuel.pondeca/faaupgrade/test_rtma2p5_2dvar/logs/rtma_post.out
#PBS -e /lfs/h2/emc/ptmp/manuel.pondeca/faaupgrade/test_rtma2p5_2dvar/logs/rtma_post.out
#PBS -l select=1:ncpus=64:mpiprocs=64:mem=200GB
#PBS -l walltime=00:20:00
#PBS -q "dev"
#PBS -A RTMA-DEV

set -ax

cd $PBS_O_WORKDIR

echo "Master Host: $PBS_O_HOST"
echo "Nodes:"; cat $PBS_NODEFILE
echo "PBS_O_WORKDIR= $PBS_O_WORKDIR"

export ntasks=64
export ppn=64
export threads=1

export LANG=en_US

export MP_EAGER_LIMIT=165536
export MP_COREFILE_FORMAT=lite
export MP_EUIDEVELOP=min
export MP_EUIDEVICE=sn_all
export MP_EUILIB=us
export MP_MPILIB=mpich2

export MP_LABELIO=yes
export MP_SINGLE_THREAD=yes
export MP_USE_BULK_XFER=yes
export MP_SHARED_MEMORY=yes

export MPICH_ALLTOALL_THROTTLE=0
export MP_COLLECTIVE_OFFLOAD=no
export KMP_STACKSIZE=1024m

export MP_TASK_AFFINITY=core:2
export OMP_NUM_THREADS=1

export configfile=/lfs/h2/emc/ptmp/$USER/faaupgrade/config/rtma/test/rtma2p5/rtma2p5_envir.sh
export RUN_ENVIR=dev
source $configfile
export FIX${NET}=$FIXdir1
export PARMrtma=$HOMErtma/parm
export pcom=$COMOUT
export DATA=$DATAPOST
cd $DATA

export job=POST
export jlogfile=$jlogfile_post
export pgmout=stdout_post
export KEEPDATA=YES

export SENDTOC=NO
export SENDPCOM=NO
export SENDDBN=NO
export SENDDBN_NTC=NO


if [[ $thismachine == 'IBM' ]] ; then
  sh $utilscript/setup.sh
fi

if [[ $thismachine == 'IBM' ]] ; then
. /usrx/local/Modules/3.2.9/init/ksh
   module purge
   module load ibmpe
   module load lsf
   module load ics/14.0.2
   module load prod_util
   module load grib_util/v1.0.5
elif [[ $thismachine == 'DELL' ]] ; then
. /usrx/local/prod/lmod/lmod/init/ksh
   module purge
   module load ips/18.0.1.163
   module load impi/18.0.1
   module load lsf/10.1
   module load prod_util/1.1.0
   module load grib_util/1.0.6
elif [[ $thismachine == 'CRAY' ]] ; then
. /usr/share/lmod/lmod/init/ksh
   module purge
   moduledir=$HOMErtma/modulefiles/RTMA
   module use ${moduledir}
   source $HOMErtma/versions/run.ver
   module load v${vernum}_for_${thismachine}.post
fi

module list

$HOMErtma/jobs/JRTMA_POST