#!/bin/bash
#SBATCH -o ./output/%x.%j.%N.out
#SBATCH -e ./output/%x.%j.%N.err
#SBATCH -D ./
#SBATCH -J mcr_mpmd
#SBATCH --get-user-env
#SBATCH --export=NONE
#SBATCH --clusters=serial
#SBATCH --partition=serial_std
#SBATCH --ntasks=8
#SBATCH --cpus-per-task=1
#SBATCH --time=0:10:00
   
#===============================================================================
# USER-DEFINED INPUT
#===============================================================================
WORKDIR=MY_WORKING_DIR        # Edit here -> set path name to working directory
APPNAME=./bin/mcr_run.exe     # Edit here -> name MCR compiled executable
MCRMODULE=MATLAB-MCR-MODULE   # Edit here -> set MCR module
MPIMODULE=intel-mpi           # Edit here if necessary
   
SIZE_MATRIX_A="[2000 1000]"
SIZE_MATRIX_B="[1000 8000]"
   
#===============================================================================
# SET MODULES AND ENVIRONMENT VARIABLES
#===============================================================================
module load slurm_setup
   
# Load Matlab Compiler Runtime.
module rm matlab
module load $MPIMODULE
module load $MCRMODULE
   
# Set MCR cache path to SCRATCH. Don't use HOME directory!
export MCR_CACHE_ROOT=${SCRATCH}/MCR_MPMD_JOBID${SLURM_JOB_ID}
# Set general temp. path (some MATLAB releases want to have TMP).
export TMP=$SCRATCH
   
#===============================================================================
# RUN APPLICATION
#===============================================================================
cd $WORKDIR
mpiexec $APPNAME "${SIZE_MATRIX_A}" "${SIZE_MATRIX_B}"