#!/bin/bash

#BSUB -oo _SREFDIR_/run/sref_prep__MODEL___MEMBER_.log
#BSUB -eo _SREFDIR_/run/sref_prep__MODEL___MEMBER_.log
#BSUB -J SREF_PREP__MODEL___MEMBER_
#BSUB -n 28
#BSUB -x
#BSUB -R span[ptile=28]
#BSUB -W 03:00
#BSUB -q "dev"
#BSUB -P SREF-T2O

set -eux

trap 'echo "SREF error _MODEL_ _MEMBER_ PREP" >> /gpfs/dell2/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref' INT TERM ERR
echo "SREF started _MODEL_ _MEMBER_ PREP" >> /gpfs/dell2/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

. /usrx/local/prod/lmod/lmod/init/bash
module load lsf/10.1
module load ips/18.0.1.163
module load prod_util/1.1.0
module load grib_util/1.1.0
module load NetCDF/4.5.0
module load impi/18.0.1
module load CFP/2.0.1

export OMP_NUM_THREADS=1

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

export CONFIG_FILE=_SREFDIR_/parm/sref_para_config_dell

export PDY=_PDY_
export cyc=_CYC_
export FLENGTH=_FLENGTH_
export INCR=_INCR_
export MODEL=_MODEL_
export MEMBER=_MEMBER_
export IOFORM=_IOFORM_
export RES=_RES_
export MACHINE=_MACHINE_
export N_TASK=$LSB_DJOB_NUMPROC


_SREFDIR_/jobs/JSREF_WRF_PREP

echo "SREF finished _MODEL_ _MEMBER_ PREP" >> /gpfs/dell2/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

bsub < _SREFDIR_/run/SREF_REAL__MODEL___MEMBER_.bsub
echo "SREF waiting _MODEL_ _MEMBER_ REAL" >> /gpfs/dell2/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

