Chapter 3.2 : The job script

1
#!/bin/bash


Commençons par le prefix de notre programme (si on considère que nous lancerons nos jobs depuis les sources) :
1
PREFIX=${PWD}


On affiche sur quelle machine on tourne :
1
echo "Used machine is $(uname -a)"


On définit un dossier build unique pour que plusieurs jobs ne se marchent pas dessus :
1
2
3
4
5
6
7
BUILD_DIR="${PREFIX}/build_cmake_$(uname -n)"

if [ -d ${BUILD_DIR} ]
then
    	echo "Remove existing directory $BUILD_DIR"
        rm -fr ${BUILD_DIR}
fi


Créons notre dossier de compilation :
1
2
mkdir -p ${BUILD_DIR}
echo "BUILD_DIR = '${BUILD_DIR}'"


Définition notre image Apptainer :
1
CONTAINER_IMAGE="./introduction_cpp_algorithms_alpine_light_latest.sif"


On appelle le script d'installation que nous définirons dans la section secApptainerInstallSingularity :
1
apptainer run --bind $PREFIX:/source --bind ${BUILD_DIR}:/build ${CONTAINER_IMAGE} /source/compile_example.sh


The full configuration :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
PREFIX=${PWD}

echo "Used machine is $(uname -a)"
BUILD_DIR="${PREFIX}/build_cmake_$(uname -n)"

if [ -d ${BUILD_DIR} ]
then
    	echo "Remove existing directory $BUILD_DIR"
        rm -fr ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR}
echo "BUILD_DIR = '${BUILD_DIR}'"
CONTAINER_IMAGE="./introduction_cpp_algorithms_alpine_light_latest.sif"

apptainer run --bind $PREFIX:/source --bind ${BUILD_DIR}:/build ${CONTAINER_IMAGE} /source/compile_example.sh
The file is avalaible here.