Skip to content

Instantly share code, notes, and snippets.

@samuelsaari
Last active September 7, 2022 08:33
Show Gist options
  • Save samuelsaari/9ac0a232ae5b869f0d1635fc561f6cdb to your computer and use it in GitHub Desktop.
Save samuelsaari/9ac0a232ae5b869f0d1635fc561f6cdb to your computer and use it in GitHub Desktop.
Batch job specification for stepFlexmix parallel wrapper
#!/bin/bash -l
#SBATCH --job-name=r_multicore_flh
#SBATCH --account=project_2003758
#SBATCH --output=x_output_all_%j.R
#SBATCH --error=x_errors_%j.R
#SBATCH --partition=large # small # test # hugemem_longrun # hugemem
#SBATCH --time=00:09:59 # 2-23:58:00 # 00:14:54 # 6-23:49:00 # 2-23:49:00
#SBATCH --nodes=12 #nr_of_classses
#SBATCH --ntasks-per-node=10 #nrep
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=4GB
############################################
# Parallel wrapper test for stepFlexmix
# Miika Maki
# Batch job specifications
##########################################3#
# Load r-env-singularity
module load r-env-singularity
# Clean up .Renviron file in home directory
if test -f ~/.Renviron; then
sed -i '/TMPDIR/d' ~/.Renviron
sed -i '/OMP_NUM_THREADS/d' ~/.Renviron # unnecessary?
fi
# Specify a temp folder path
echo "TMPDIR=/scratch/project_2003758" >> ~/.Renviron
# Match thread and core numbers
export SINGULARITYENV_OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
# Thread affinity control
export SINGULARITYENV_OMP_PLACES=cores
export SINGULARITYENV_OMP_PROC_BIND=close
## working directory
mkdir /scratch/project_2003758/makimiik/out_${SLURM_JOB_ID}
cd /scratch/project_2003758/makimiik/out_${SLURM_JOB_ID}
srun singularity_wrapper exec RMPISNOW --no-save --quiet < /users/makimiik/flh/z1det_MVE.R 2>&1 | tee x1det_MVE_${SLURM_JOB_ID}.R
############################ RMPISNOW or R
# moving and copying files to the job-specific folder
## errors and outputs
cp -p -v /users/makimiik/flh/x_errors_${SLURM_JOB_ID}.R .
cp -p -v /users/makimiik/flh/x_output_all_${SLURM_JOB_ID}.R .
cp -p -v /users/makimiik/flh/x1det_MVE_output_${SLURM_JOB_ID}.R .
# copy of scripts
cp -p -v /users/makimiik/flh/z1det_MVE.R .
# copy of this file
cp -p -v /users/makimiik/flh/a1det_batch_MVE.sh .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment