#!/bin/bash

#SBATCH --nodes=<NODES>
#SBATCH --ntasks=<NTASKS>
#SBATCH -p 7713
#SBATCH -J shld_global
#SBATCH --time=4:00:00
#SBATCH --exclusive
#SBATCH -c <THREADS>

ulimit -s unlimited
ulimit -c unlimited
ulimit -v unlimited
ulimit -n unlimited


exp_dir=${SLURM_SUBMIT_DIR}/global_scalability
cd /work/denis.inpe/spack && source ./load_spack_gnu.sh
cd $exp_dir
module list
echo $LD_LIBRARY_PATH
echo $NETCDF_DIR
echo $HDF5_DIR

echo $SLURM_JOB_NODELIST
# nodeset -e $SLURM_JOB_NODELIST    ???

echo "Entrou no diretório${exp_dir} = "$(pwd)

if [ -n "$SLURM_CPUS_PER_TASK" ]; then
  omp_threads=$SLURM_CPUS_PER_TASK
else
  omp_threads=1
fi
export OMP_NUM_THREADS=$omp_threads

# Roberto - opcoes do MPI para a Rattler - evita o erro ... (ver no email)?
#       -mca btl tcp,self,vader -mca btl_tcp_if_include ib0 \

echo "Running with $SLURM_NTASKS MPI processes"

exec=SHiELD_nh.prod.32bit.x

saida_str=../${exec}_out_<NODES>nodes_<NTASKS>mpi_<THREADS>openmp_<BLOCKSIZE>blocks.txt
mpirun -np $SLURM_NTASKS $(pwd)/$exec > $saida_str

