#!/bin/bash

#PBS -N SREF
#PBS -A SREF-DEV
##PBS -j oe
#PBS -o _SREFDIR_/run/sref_gfsprep__MEMBER_.log
#PBS -e _SREFDIR_/run/sref_gfsprep__MEMBER_.log
#PBS -l select=1:ncpus=54:mem=2500MB
#PBS -q dev
#PBS -l walltime=00:30:00
##PBS -l hyper=true
#PBS -l debug=true

set -aeux

trap 'echo "SREF error _MEMBER_ GFSPREP" >> /lfs/h2/emc/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref' INT TERM ERR
echo "SREF started _MEMBER_ GFSPREP" >> /lfs/h2/emc/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

#. /usrx/local/prod/lmod/lmod/init/bash
. /usr/share/lmod/lmod/init/bash
#module purge
module reset
module load PrgEnv-intel/8.1.0
module load envvar/1.0
#module load lsf/10.1
#module load ips/18.0.1.163
module load intel/19.1.3.304
module load libjpeg/9c
module load libpng/1.6.37
module load prod_util/2.0.9
module load prod_envir/2.0.6
module load grib_util/1.2.2
module load netcdf/4.7.4
#module load impi/18.0.1
module load cfp/2.0.4
module load craype/2.7.8
module load cray-pals/1.0.12
module load cray-mpich/8.1.9
module list

#module load settarg/7.7

export OMP_NUM_THREADS=1

export RUN_ENVIR=para
export envir=prod
export job=$$

export CONFIG_FILE=_SREFDIR_/parm/sref_para_config_cray

export PDY=_PDY_
export cyc=_CYC_
#export FLENGTH=_FLENGTH_
#export INCR=_INCR_
export MEMBER=_MEMBER_
export MACHINE=_MACHINE_
#export N_TASK=$LSB_DJOB_NUMPROC

_SREFDIR_/jobs/JSREF_WRF_GFSPREP

echo "SREF finished _MEMBER_ GFSPREP" >> /lfs/h2/emc/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

#qsub _SREFDIR_/run/SREF_POST__MODEL___MEMBER_.qsub
#echo "SREF waiting _MODEL_ _MEMBER_ POST" >> /lfs/h2/emc/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

