#!/bin/bash

#BSUB -oo _SREFDIR_/run/sref_gefs2sref.log
#BSUB -eo _SREFDIR_/run/sref_gefs2sref.log
#BSUB -J SREF_gefs2sref
##BSUB -n 31
#BSUB -n 54
#BSUB -x
#BSUB -R span[ptile=16]
##BSUB -R "rusage[mem=2000]
#BSUB -W 01:30
#BSUB -P SREF-T2O
#BSUB -q "dev"

set -aeux

trap 'echo "SREF error GEFS2SREF" >> /gpfs/dell2/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref' INT TERM ERR
echo "SREF started GEFS2SREF" >> /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 EnvVars/1.0.2 settarg/7.7 prod_envir/1.0.2
module load impi/18.0.1
module load CFP/2.0.1
module list

export OMP_NUM_THREADS=1
export MP_EUIDEVICE=sn_all
export MP_EUILIB=us
export MP_MPILIB=mpich2
export MP_TASK_AFFINITY=core: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_

_SREFDIR_/jobs/JSREF_GEFS2SREF

echo "SREF finished GEFS2SREF" >> /gpfs/dell2/ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

# If want to submit a next job here
#bsub < _SREFDIR_/run/SREF_BIAS.bsub
#echo "SREF waiting BIAS" >> /ptmp/$LOGNAME/tmpnwprd/jlogfile_sref

