#! /usr/bin/env bash
##########
##
## See https://github.com/NCAR/CESM_postprocessing/wiki for details
## regarding settings for optimal performance for CESM postprocessing tools.
##
##########

#!/bin/bash

#PBS -N xconform
#PBS -q regular
#PBS -l select=16:ncpus=4:mpiprocs=4
#PBS -l walltime=12:00:00
#PBS -A None

source /etc/profile.d/modules.sh

export MPI_UNBUFFERED_STDIO=true
export TMPDIR=$TMPDIR


if [ ! -e /glade/p/cesm/postprocessing/cesm-env2/bin ]; then
    echo "*************************************************************************************"
    echo "CESM xconform exiting due to non-existant python virtual environment in"
    echo "    /glade/p/cesm/postprocessing/cesm-env2/bin"
    echo "You must first run:"
    echo "$SRCROOT/postprocessing/create_python_env -machine [machine]"
    echo "*************************************************************************************"
    exit
fi


module purge


source /glade/p/cesm/postprocessing/cesm-env2/bin/activate


module load gnu/8.3.0

module load ncarenv

module load ncarcompilers

module load mpt/2.19

module load netcdf/4.6.3

module load nco/4.7.9

module load ncl/6.6.2




today="$(date '+%Y%m%d-%H%M%S')"

mpiexec_mpt dplace -s 1 cesm_conform_generator.py --debug 0  --caseroot /glade/p/cesm/chwg_dev/tilmes/cases/cesm2_ch/fire/b.e21.B1850.1750landuse.f09_g17.CMIP6-piControl.cesm2_ctsm5.1_fire4/postprocess >> /glade/p/cesm/chwg_dev/tilmes/cases/cesm2_ch/fire/b.e21.B1850.1750landuse.f09_g17.CMIP6-piControl.cesm2_ctsm5.1_fire4/postprocess/logs/xconform.log.$today 2>&1

