Complete submission script (for PBS Pro)

#!/bin/sh
#
# --- Memory management of Flux ---
# Flux memory is a bit tricky to handle,
# so please provide an initial memory (in GB) using the env var MEM.
#
# When using PBS, one can also use the option -v of qsub as:
#        qsub [args] -v MEM=32gb path2ThisScript.sh
# for example.
#
# Use fixed values for the GUI-memories
export JVM_MEMORY=100        # In MBytes
export MEMSIZC3=52428800     # In Bytes
# Set the ratio of the memory Flux can use (as a division of two integers).
RATIO="4 / 10" # Flux master has 40% of the memory, leaving 60% of MEM to the solver
# Deduce the numerical memory (in Bytes)
export MEMSIZN3=$((($MEM*1024*1024*1024*$RATIO)-$MEMSIZC3-($JVM_MEMORY*1024*1024)))
#
# Check the value of the core memory
if [[$MEMSIZN3 -lt 0]] ; then
    echo "Error: Not enough memory. Please assign a greater memory size.
        (MEMSIZN3=$MEMSIZN3)" >&2; exit 3
fi
echo Core Memory is of `awk '{print $1/1024/1024/1024}' <<<$MEMSIZN3` GB
#
# --- Core management ---
#
# Flux cannot be ran through mpiexec directly, it is done internally in Flux.
#
# Therefore, before the distribution, the master Flux should be set to use only one core setting:
export FLUX_NCORES = 1
# This is optional, if FLUX_CORES is not defined, Flux uses all the cores available on the mother node.
#
# To use the distribution in Flux, the nodefile must be specified using FLUX_NODEFILE env. var.
#
export FLUX_NODEFILE = $PBS_NODEFILE
#
echo Node file is at $FLUX_NODEFILE
echo Total number of cores = `wc -1 $FLUX_NODEFILE`
#
# --- Options ---
#
# This allows multiple instances of Flux
export SYNC_SOCKET=0
#
# --- Making the command line ---
#
# Specify the path to use executable of Flux
PATH_TO_FLUX_EXECUTABLE=/opt/altair/Flux2018.1/altair/flux/Flux/Bin/prg/lin64/flux
# Specify the python script to execute
YOUR_PYTHON_SCRIPT=~/tmp/pythonScript.py
# Get the application of the python extracting its header
FLUX_APP=$(head -n 1 $YOUR_PYTHON_SCRIPT | cut -d ! -f 2 | awk '{$1=$1;print}' | cut -d ' ' -f 1)
# Launch Flux
$PATH_TO_FLUX_EXECUTABLE -application $FLUX_APP -runPyInSilentModeAndExit $YOUR_PYTHON_SCRIPT -batch