#PBS -S /bin/bash
#PBS -N jaxa_wing_body_curv
#PBS -l select=5:ncpus=40:mpiprocs=2:model=sky_ele
#PBS -l walltime=02:00:00
#PBS -j oe
#PBS -W group_list=<your project group ID>
#PBS -q normal

#BENCH reference jaxa_wing_body_curv.data.iter
#BENCH tolerance_abs 1.0e-6
#BENCH tolerance_rel 1.0e-6
#BENCH save_vars cl, cd
#BENCH set short

log_file="run.log"

export F_UFMTENDIAN
cd $PBS_O_WORKDIR

#Load required modules
module purge
module use /swbuild/LAVA/LAVA_modules
module load LAVA

# Define thread pinning executable (recommended usage on NAS: mbind.x)
export MBIND_EXE="/u/scicon/tools/bin/mbind.x"

# Export number of threads (ncpus/2)
export OMP_NUM_THREADS=20

# Create a flow solver directory
mkdir -p solver
cd $PBS_O_WORKDIR/solver

# Symbollically link required files
ln -sf ../connectivity/grid.in.ihc
ln -sf ../connectivity/INTOUT
ln -sf ../connectivity/overlapper
ln -sf ../grid_files/grid.bc.in
ln -sf ../grid_files/grid.b2b
ln -sf ../input_files/solver.yaml

# Run flow solver
mpiexec -npernode 2 ${MBIND_EXE} -t ${OMP_NUM_THREADS} lavacurv.3D.NS1.AVX2 solver.yaml 2>&1 |& tee -a ${log_file}
