diff --git a/cluster_basic/Matlab_runtime.sh b/cluster_basic/Matlab_runtime.sh index 33023e9..87af767 100755 --- a/cluster_basic/Matlab_runtime.sh +++ b/cluster_basic/Matlab_runtime.sh @@ -1,28 +1,71 @@ #!/bin/bash +# +print_help() +{ + echo "=================================================================" >&2 + echo " DCSR, University of Lausanne " >&2 + echo " " >&2 + echo "Usage : sh $0 " >&2 + echo " " >&2 + echo "Purpose: shows how to use Matlab runtime environment. " >&2 + echo " " >&2 + echo "To do : nothing, simply run the script. " >&2 + echo " " >&2 + echo "=================================================================" >&2 + exit 1 +} + +# Check command line options +# -------------------------- +if [ "$#" == "1" ]; then + if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + $(print_help) + else + echo; echo "FATAL: only accepted options are -h and --help."; echo + fi + exit 1 +fi +if [ "$#" -ge "2" ]; then + echo; echo "FATAL: only accepts a single option (-h or --help)"; echo + exit 1 +fi + + +# STEP 1: load the Matlab Compiler Runtime module +# Note: this will define the $MCR_PATH environment variable +# ----------------------------------------------------------------- module purge +module load Development/Languages/Matlab_Compiler_Runtime/v96 +echo; echo "STEP 1:" +module list +echo; echo "MCR_PATH = $MCR_PATH" +echo; echo -# STEP 0: define which Matlab script to run (without ".m" at the end!) +# STEP 2: define which Matlab script to run (without ".m" at the end!) # -------------------------------------------------------------------- MATLAB_SCRIPT=Matlab_script +echo "STEP 2: will be running the following script: $MATLAB_SCRIPT.m" +echo; echo -# STEP 1: run the script (no GUI) +# STEP 3: run the script (no GUI) # ------------------------------- -echo "STEP 1: Running the script with Matlab" +echo "STEP 3: Running the script with Matlab" matlab -nodisplay -nosplash -nodesktop\ -r "try, $MATLAB_SCRIPT; catch, disp('Matlab failed to run the script!'), end, quit" +echo; echo - -# STEP 2: compile the code with Matlab mcc +# STEP 4: compile the code with Matlab mcc # ---------------------------------------- -echo "STEP 2: Compiling the code with mcc" +echo "STEP 4: Compiling the code with mcc" mcc -v -m $MATLAB_SCRIPT.m echo; echo -# STEP 3: execute the code with Matlab runtime +# STEP 5: execute the code with Matlab runtime # -------------------------------------------- -echo "STEP 3: Running with Matlab runtime" -sh run_$MATLAB_SCRIPT.sh /software/local/Development/Languages/Matlab_Compiler_Runtime/v96 +echo "STEP 5: Running with Matlab Compiler Runtime" +sh run_$MATLAB_SCRIPT.sh $MCR_PATH +echo; echo