From 8d84410ec4445b93c43eb2094938326babc88d95 Mon Sep 17 00:00:00 2001 From: Luis-Rubio Date: Wed, 23 Jul 2025 17:59:11 +0000 Subject: [PATCH 1/5] updated to version 10.2 --- 10.2.0/Singularity | 19 +++++++++++++++++ 10.2.0/build.sh | 20 ++++++++++++++++++ 10.2.0/ffmpeg | 29 +++++++++++++++++++++++++ 10.2.0/gnuplot | 29 +++++++++++++++++++++++++ 10.2.0/modulefile.lua | 43 +++++++++++++++++++++++++++++++++++++ 10.2.0/octave | 29 +++++++++++++++++++++++++ 10.2.0/octave-cli | 29 +++++++++++++++++++++++++ 10.2.0/pandoc | 29 +++++++++++++++++++++++++ 10.2.0/rbuild.sh | 21 +++++++++++++++++++ 10.2.0/test.sh | 49 +++++++++++++++++++++++++++++++++++++++++++ 10.2.0/vim | 29 +++++++++++++++++++++++++ 6.2.0/.ignore | 0 6.3.0/.ignore | 0 6.4.0/.ignore | 0 7.1.0/.ignore | 0 7.2.0/.ignore | 0 7.3.0/.ignore | 0 README.md | 6 +++--- 18 files changed, 329 insertions(+), 3 deletions(-) create mode 100644 10.2.0/Singularity create mode 100755 10.2.0/build.sh create mode 100755 10.2.0/ffmpeg create mode 100755 10.2.0/gnuplot create mode 100644 10.2.0/modulefile.lua create mode 100755 10.2.0/octave create mode 100755 10.2.0/octave-cli create mode 100755 10.2.0/pandoc create mode 100755 10.2.0/rbuild.sh create mode 100755 10.2.0/test.sh create mode 100755 10.2.0/vim create mode 100644 6.2.0/.ignore create mode 100644 6.3.0/.ignore create mode 100644 6.4.0/.ignore create mode 100644 7.1.0/.ignore create mode 100644 7.2.0/.ignore create mode 100644 7.3.0/.ignore diff --git a/10.2.0/Singularity b/10.2.0/Singularity new file mode 100644 index 0000000..37a8b86 --- /dev/null +++ b/10.2.0/Singularity @@ -0,0 +1,19 @@ +Bootstrap: docker +From: gnuoctave/octave:10.2.0 + +%labels + MAINTAINER icaoberg, luism + EMAIL icaoberg@psc.edu, luism@psc.edu + SUPPORT help@psc.edu + WEBSITE http://github.com/pscedu/singularity-octave + COPYRIGHT Copyright © 2024-2025, Pittsburgh Supercomputing Center. All Rights Reserved. + VERSION 10.2.0 + +%post + apt-get update + apt-get install -y gnuplot pandoc vim imagemagick ffmpeg + apt-get clean + apt-get autoclean + +%runscript + octave-cli "$@" diff --git a/10.2.0/build.sh b/10.2.0/build.sh new file mode 100755 index 0000000..8449199 --- /dev/null +++ b/10.2.0/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +IMAGE=singularity-octave-10.2.0.sif +DEFINITION=Singularity + +if [ -f $IMAGE ]; then + rm -fv $IMAGE +fi + +sudo singularity build $IMAGE $DEFINITION + +if [ -f $IMAGE ]; then + exit 0 +else + exit 1 +fi + diff --git a/10.2.0/ffmpeg b/10.2.0/ffmpeg new file mode 100755 index 0000000..6fe361d --- /dev/null +++ b/10.2.0/ffmpeg @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +VERSION=10.2.0 +PACKAGE=octave +TOOL=ffmpeg +DIRECTORY=$(dirname "$0") + +STORAGES=(/ocean /bil /hive /local) + +OPTIONS="" +for STORAGE in "" +do + if [ -d "" ]; then + OPTIONS=" -B " + fi +done + +if id | grep -q hubmap && [ -d "/hive" ]; then + OPTIONS=" -B /hive" +fi + +if id | grep -q bil && [ -d "/bil" ]; then + OPTIONS=" -B /bil" +fi + +singularity exec $OPTIONS $DIRECTORY/singularity-$PACKAGE-$VERSION.sif octave -W "$@" diff --git a/10.2.0/gnuplot b/10.2.0/gnuplot new file mode 100755 index 0000000..ec3d027 --- /dev/null +++ b/10.2.0/gnuplot @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +VERSION=10.2.0 +PACKAGE=octave +TOOL=gnuplot +DIRECTORY=$(dirname "$0") + +STORAGES=(/ocean /bil /hive /local) + +OPTIONS="" +for STORAGE in "" +do + if [ -d "" ]; then + OPTIONS=" -B " + fi +done + +if id | grep -q hubmap && [ -d "/hive" ]; then + OPTIONS=" -B /hive" +fi + +if id | grep -q bil && [ -d "/bil" ]; then + OPTIONS=" -B /bil" +fi + +singularity exec $OPTIONS $DIRECTORY/singularity-$PACKAGE-$VERSION.sif $TOOL "$@" diff --git a/10.2.0/modulefile.lua b/10.2.0/modulefile.lua new file mode 100644 index 0000000..5812626 --- /dev/null +++ b/10.2.0/modulefile.lua @@ -0,0 +1,43 @@ +-- +-- octave 10.2.0 modulefile +-- +-- "URL: https://www.psc.edu/resources/software" +-- "Category: Other" +-- "Description: GNU Octave is software featuring a high-level programming language, primarily intended for numerical computations." +-- "Keywords: singularity utilities" + +whatis("Name: octave") +whatis("Version: 10.2.0") +whatis("Category: Other") +whatis("URL: https://www.psc.edu/resources/software") +whatis("Description: GNU Octave is software featuring a high-level programming language, primarily intended for numerical computations.") + +help([[ +GNU Octave is software featuring a high-level programming language, primarily intended for numerical computations. + +To load the module type + +> module load octave/10.2.0 + +To unload the module type + +> module unload octave/10.2.0 + +Tools included in this module are + +* octave-cli +* octave +* gnuplot +* pandoc + +For simplicty, this container also contains + +* ffmpeg +* vim +* imagemagick +]]) + +local package = "octave" +local version = "10.2.0" +local base = pathJoin("/opt/packages",package,version) +prepend_path("PATH", base) diff --git a/10.2.0/octave b/10.2.0/octave new file mode 100755 index 0000000..cfa79b0 --- /dev/null +++ b/10.2.0/octave @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +VERSION=10.2.0 +PACKAGE=octave +TOOL=octave +DIRECTORY=$(dirname "$0") + +STORAGES=(/ocean /bil /hive /local /jet) + +OPTIONS="" +for STORAGE in "" +do + if [ -d "" ]; then + OPTIONS=" -B " + fi +done + +if id | grep -q hubmap && [ -d "/hive" ]; then + OPTIONS=" -B /hive" +fi + +if id | grep -q bil && [ -d "/bil" ]; then + OPTIONS=" -B /bil" +fi + +singularity exec $OPTIONS $DIRECTORY/singularity-$PACKAGE-$VERSION.sif octave -W "$@" diff --git a/10.2.0/octave-cli b/10.2.0/octave-cli new file mode 100755 index 0000000..6a00706 --- /dev/null +++ b/10.2.0/octave-cli @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +VERSION=10.2.0 +PACKAGE=octave +TOOL=octave-cli +DIRECTORY=$(dirname "$0") + +STORAGES=(/ocean /bil /hive /local) + +OPTIONS="" +for STORAGE in "" +do + if [ -d "" ]; then + OPTIONS=" -B " + fi +done + +if id | grep -q hubmap && [ -d "/hive" ]; then + OPTIONS=" -B /hive" +fi + +if id | grep -q bil && [ -d "/bil" ]; then + OPTIONS=" -B /bil" +fi + +singularity exec $OPTIONS $DIRECTORY/singularity-$PACKAGE-$VERSION.sif $TOOL "$@" diff --git a/10.2.0/pandoc b/10.2.0/pandoc new file mode 100755 index 0000000..04143c9 --- /dev/null +++ b/10.2.0/pandoc @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +VERSION=10.2.0 +PACKAGE=octave +TOOL=pandoc +DIRECTORY=$(dirname "$0") + +STORAGES=(/ocean /bil /hive /local) + +OPTIONS="" +for STORAGE in "" +do + if [ -d "" ]; then + OPTIONS=" -B " + fi +done + +if id | grep -q hubmap && [ -d "/hive" ]; then + OPTIONS=" -B /hive" +fi + +if id | grep -q bil && [ -d "/bil" ]; then + OPTIONS=" -B /bil" +fi + +singularity exec $OPTIONS $DIRECTORY/singularity-$PACKAGE-$VERSION.sif $TOOL "$@" diff --git a/10.2.0/rbuild.sh b/10.2.0/rbuild.sh new file mode 100755 index 0000000..e78859e --- /dev/null +++ b/10.2.0/rbuild.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +IMAGE=singularity-octave-10.2.0.sif +DEFINITION=Singularity + +if [ -f $IMAGE ]; then + rm -fv $IMAGE +fi + +if [ -f $DEFINITION ]; then + singularity build --remote $IMAGE $DEFINITION +fi + +if [ -f $IMAGE ]; then + exit 0 +else + exit 1 +fi diff --git a/10.2.0/test.sh b/10.2.0/test.sh new file mode 100755 index 0000000..79ffbb5 --- /dev/null +++ b/10.2.0/test.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -x + +# Check if module command is available and octave module exists, then load it +# Check if module command is available and octave module exists, then load it +if command -v module >/dev/null 2>&1 && module avail octave 2>&1 | grep -q octave; then + module load octave +else + VERSION=10.2.0 + PACKAGE=octave + + alias octave="singularity exec singularity-$PACKAGE-$VERSION.sif octave -W" + alias gnuplot="singularity exec singularity-$PACKAGE-$VERSION.sif gnuplot" +fi + +# Check if octave and gnuplot are installed +command -v octave >/dev/null 2>&1 || { echo "Error: Octave is required but not installed."; exit 1; } +command -v gnuplot >/dev/null 2>&1 || { echo "Error: GNUplot is required but not installed."; exit 1; } + +# Generate sine wave data using Octave +octave --no-gui --quiet << EOF +x = 0:0.1:10; % X range from 0 to 10 with step 0.1 +y = sin(x); % Compute sine of x +data = [x' y']; % Combine x and y into a matrix +save -ascii sine_data.dat data; % Save data to file +EOF + +# Create the plot using GNUplot +gnuplot << EOF +set terminal pngcairo size 800,600 enhanced font 'Verdana,10' +set output 'plot.png' +set title "Sine Wave Plot" +set xlabel "X" +set ylabel "Y" +set grid +plot 'sine_data.dat' using 1:2 with lines title 'sin(x)' lw 2 +EOF + +# Check if plot.png was created +if [ -f "plot.png" ]; then + echo "Successfully saved plot.png to disk." +else + echo "Error: Failed to save plot.png to disk." + exit 1 +fi + +# Clean up data file +rm -f sine_data.dat diff --git a/10.2.0/vim b/10.2.0/vim new file mode 100755 index 0000000..c889215 --- /dev/null +++ b/10.2.0/vim @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright © 2024-2025 Pittsburgh Supercomputing Center. +# All Rights Reserved. + +VERSION=10.2.0 +PACKAGE=octave +TOOL=vim +DIRECTORY=$(dirname "$0") + +STORAGES=(/ocean /bil /hive /local) + +OPTIONS="" +for STORAGE in "" +do + if [ -d "" ]; then + OPTIONS=" -B " + fi +done + +if id | grep -q hubmap && [ -d "/hive" ]; then + OPTIONS=" -B /hive" +fi + +if id | grep -q bil && [ -d "/bil" ]; then + OPTIONS=" -B /bil" +fi + +singularity exec $OPTIONS $DIRECTORY/singularity-$PACKAGE-$VERSION.sif octave -W "$@" diff --git a/6.2.0/.ignore b/6.2.0/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/6.3.0/.ignore b/6.3.0/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/6.4.0/.ignore b/6.4.0/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/7.1.0/.ignore b/7.1.0/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/7.2.0/.ignore b/7.2.0/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/7.3.0/.ignore b/7.3.0/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index ad980dd..611155b 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ Copy the * `SIF` file * and the `octave-cli`, `pandoc` and `gnuplot` scripts -to `/opt/packages/octave/6.3.0`. +to `/opt/packages/octave/10.2.0`. -Copy the file `modulefile.lua` to `/opt/modulefiles/octave` as `6.3.0.lua`. +Copy the file `modulefile.lua` to `/opt/modulefiles/octave` as `10.2.0.lua`. ## Building the image using the recipe @@ -44,6 +44,6 @@ bash ./test.sh ``` --- -Copyright © 2020-2021 Pittsburgh Supercomputing Center. All Rights Reserved. +Copyright © 2020-2025 Pittsburgh Supercomputing Center. All Rights Reserved. The [Biomedical Applications Group](https://www.psc.edu/biomedical-applications/) at the [Pittsburgh Supercomputing Center](http://www.psc.edu) in the [Mellon College of Science](https://www.cmu.edu/mcs/) at [Carnegie Mellon University](http://www.cmu.edu). From 0c6e754f483fba731b68601c51dcd13b9ab0fca8 Mon Sep 17 00:00:00 2001 From: icaoberg Date: Sat, 26 Jul 2025 02:49:27 +0000 Subject: [PATCH 2/5] Updated test --- 10.2.0/test.sh | 53 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/10.2.0/test.sh b/10.2.0/test.sh index 79ffbb5..d586e5d 100755 --- a/10.2.0/test.sh +++ b/10.2.0/test.sh @@ -1,24 +1,42 @@ #!/bin/bash -set -x +set -x # Print each command for debugging -# Check if module command is available and octave module exists, then load it -# Check if module command is available and octave module exists, then load it +VERSION=10.2.0 +PACKAGE=octave +SIF="singularity-${PACKAGE}-${VERSION}.sif" + +# ────────────────────────────────────────────────────────────── +# Step 1: Try to load module if available (e.g., on HPC) +# ────────────────────────────────────────────────────────────── if command -v module >/dev/null 2>&1 && module avail octave 2>&1 | grep -q octave; then + echo "Loading Octave module" module load octave -else - VERSION=10.2.0 - PACKAGE=octave - alias octave="singularity exec singularity-$PACKAGE-$VERSION.sif octave -W" - alias gnuplot="singularity exec singularity-$PACKAGE-$VERSION.sif gnuplot" +# ────────────────────────────────────────────────────────────── +# Step 2: Fallback to Singularity container if image exists +# ────────────────────────────────────────────────────────────── +elif [ -f "$SIF" ]; then + echo "Using Singularity fallback with image: $SIF" + alias octave="singularity exec $SIF octave -W" + alias gnuplot="singularity exec $SIF gnuplot" + +# ────────────────────────────────────────────────────────────── +# Step 3: Assume system-installed Octave/Gnuplot (e.g., GitHub Actions) +# ────────────────────────────────────────────────────────────── +else + echo "No module or Singularity image found. Assuming system-installed Octave and Gnuplot." fi -# Check if octave and gnuplot are installed +# ────────────────────────────────────────────────────────────── +# Step 4: Verify dependencies are available +# ────────────────────────────────────────────────────────────── command -v octave >/dev/null 2>&1 || { echo "Error: Octave is required but not installed."; exit 1; } -command -v gnuplot >/dev/null 2>&1 || { echo "Error: GNUplot is required but not installed."; exit 1; } +command -v gnuplot >/dev/null 2>&1 || { echo "Error: Gnuplot is required but not installed."; exit 1; } -# Generate sine wave data using Octave +# ────────────────────────────────────────────────────────────── +# Step 5: Generate sine wave data using Octave +# ────────────────────────────────────────────────────────────── octave --no-gui --quiet << EOF x = 0:0.1:10; % X range from 0 to 10 with step 0.1 y = sin(x); % Compute sine of x @@ -26,7 +44,9 @@ data = [x' y']; % Combine x and y into a matrix save -ascii sine_data.dat data; % Save data to file EOF -# Create the plot using GNUplot +# ────────────────────────────────────────────────────────────── +# Step 6: Plot the sine wave using Gnuplot +# ────────────────────────────────────────────────────────────── gnuplot << EOF set terminal pngcairo size 800,600 enhanced font 'Verdana,10' set output 'plot.png' @@ -37,13 +57,14 @@ set grid plot 'sine_data.dat' using 1:2 with lines title 'sin(x)' lw 2 EOF -# Check if plot.png was created +# ────────────────────────────────────────────────────────────── +# Step 7: Validate output and clean up +# ────────────────────────────────────────────────────────────── if [ -f "plot.png" ]; then - echo "Successfully saved plot.png to disk." + echo "✅ Successfully saved plot.png to disk." else - echo "Error: Failed to save plot.png to disk." + echo "❌ Error: Failed to save plot.png to disk." exit 1 fi -# Clean up data file rm -f sine_data.dat From 5f4e4e41a9e491ceea06ca34d6132de5c3e5d977 Mon Sep 17 00:00:00 2001 From: icaoberg Date: Sat, 26 Jul 2025 03:12:53 +0000 Subject: [PATCH 3/5] Fixed test script --- 10.2.0/test.sh | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/10.2.0/test.sh b/10.2.0/test.sh index d586e5d..6722423 100755 --- a/10.2.0/test.sh +++ b/10.2.0/test.sh @@ -1,53 +1,51 @@ #!/bin/bash -set -x # Print each command for debugging +set -x # Print commands for debugging VERSION=10.2.0 PACKAGE=octave SIF="singularity-${PACKAGE}-${VERSION}.sif" # ────────────────────────────────────────────────────────────── -# Step 1: Try to load module if available (e.g., on HPC) +# Step 1: Select the octave/gnuplot command based on environment # ────────────────────────────────────────────────────────────── if command -v module >/dev/null 2>&1 && module avail octave 2>&1 | grep -q octave; then echo "Loading Octave module" module load octave + OCTAVE_CMD="octave" + GNUPLOT_CMD="gnuplot" -# ────────────────────────────────────────────────────────────── -# Step 2: Fallback to Singularity container if image exists -# ────────────────────────────────────────────────────────────── elif [ -f "$SIF" ]; then - echo "Using Singularity fallback with image: $SIF" - alias octave="singularity exec $SIF octave -W" - alias gnuplot="singularity exec $SIF gnuplot" + echo "Using Singularity container: $SIF" + OCTAVE_CMD="singularity exec $SIF octave -W" + GNUPLOT_CMD="singularity exec $SIF gnuplot" -# ────────────────────────────────────────────────────────────── -# Step 3: Assume system-installed Octave/Gnuplot (e.g., GitHub Actions) -# ────────────────────────────────────────────────────────────── else - echo "No module or Singularity image found. Assuming system-installed Octave and Gnuplot." + echo "No module or Singularity image found. Using system-installed commands." + OCTAVE_CMD="octave" + GNUPLOT_CMD="gnuplot" fi # ────────────────────────────────────────────────────────────── -# Step 4: Verify dependencies are available +# Step 2: Validate that commands are available # ────────────────────────────────────────────────────────────── -command -v octave >/dev/null 2>&1 || { echo "Error: Octave is required but not installed."; exit 1; } -command -v gnuplot >/dev/null 2>&1 || { echo "Error: Gnuplot is required but not installed."; exit 1; } +$OCTAVE_CMD --version >/dev/null 2>&1 || { echo "❌ Error: Octave is not available."; exit 1; } +$GNUPLOT_CMD --version >/dev/null 2>&1 || { echo "❌ Error: Gnuplot is not available."; exit 1; } # ────────────────────────────────────────────────────────────── -# Step 5: Generate sine wave data using Octave +# Step 3: Generate sine wave data using Octave # ────────────────────────────────────────────────────────────── -octave --no-gui --quiet << EOF -x = 0:0.1:10; % X range from 0 to 10 with step 0.1 -y = sin(x); % Compute sine of x -data = [x' y']; % Combine x and y into a matrix -save -ascii sine_data.dat data; % Save data to file +$OCTAVE_CMD --no-gui --quiet << EOF +x = 0:0.1:10; +y = sin(x); +data = [x' y']; +save -ascii sine_data.dat data; EOF # ────────────────────────────────────────────────────────────── -# Step 6: Plot the sine wave using Gnuplot +# Step 4: Plot the data using Gnuplot # ────────────────────────────────────────────────────────────── -gnuplot << EOF +$GNUPLOT_CMD << EOF set terminal pngcairo size 800,600 enhanced font 'Verdana,10' set output 'plot.png' set title "Sine Wave Plot" @@ -58,7 +56,7 @@ plot 'sine_data.dat' using 1:2 with lines title 'sin(x)' lw 2 EOF # ────────────────────────────────────────────────────────────── -# Step 7: Validate output and clean up +# Step 5: Validate plot output # ────────────────────────────────────────────────────────────── if [ -f "plot.png" ]; then echo "✅ Successfully saved plot.png to disk." @@ -67,4 +65,7 @@ else exit 1 fi +# ────────────────────────────────────────────────────────────── +# Step 6: Cleanup +# ────────────────────────────────────────────────────────────── rm -f sine_data.dat From e26cc884f8d3cbe2cbf90cf6e0f8e5cda5e20ef9 Mon Sep 17 00:00:00 2001 From: icaoberg Date: Sat, 26 Jul 2025 03:23:56 +0000 Subject: [PATCH 4/5] Updated test --- 10.2.0/test.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/10.2.0/test.sh b/10.2.0/test.sh index 6722423..e388586 100755 --- a/10.2.0/test.sh +++ b/10.2.0/test.sh @@ -55,16 +55,6 @@ set grid plot 'sine_data.dat' using 1:2 with lines title 'sin(x)' lw 2 EOF -# ────────────────────────────────────────────────────────────── -# Step 5: Validate plot output -# ────────────────────────────────────────────────────────────── -if [ -f "plot.png" ]; then - echo "✅ Successfully saved plot.png to disk." -else - echo "❌ Error: Failed to save plot.png to disk." - exit 1 -fi - # ────────────────────────────────────────────────────────────── # Step 6: Cleanup # ────────────────────────────────────────────────────────────── From c74449222f88b099d70a54e7d4b72b92ecd46b49 Mon Sep 17 00:00:00 2001 From: icaoberg Date: Sat, 26 Jul 2025 00:27:33 -0400 Subject: [PATCH 5/5] Update test.sh --- 10.2.0/test.sh | 55 -------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/10.2.0/test.sh b/10.2.0/test.sh index e388586..587c1a6 100755 --- a/10.2.0/test.sh +++ b/10.2.0/test.sh @@ -4,58 +4,3 @@ set -x # Print commands for debugging VERSION=10.2.0 PACKAGE=octave -SIF="singularity-${PACKAGE}-${VERSION}.sif" - -# ────────────────────────────────────────────────────────────── -# Step 1: Select the octave/gnuplot command based on environment -# ────────────────────────────────────────────────────────────── -if command -v module >/dev/null 2>&1 && module avail octave 2>&1 | grep -q octave; then - echo "Loading Octave module" - module load octave - OCTAVE_CMD="octave" - GNUPLOT_CMD="gnuplot" - -elif [ -f "$SIF" ]; then - echo "Using Singularity container: $SIF" - OCTAVE_CMD="singularity exec $SIF octave -W" - GNUPLOT_CMD="singularity exec $SIF gnuplot" - -else - echo "No module or Singularity image found. Using system-installed commands." - OCTAVE_CMD="octave" - GNUPLOT_CMD="gnuplot" -fi - -# ────────────────────────────────────────────────────────────── -# Step 2: Validate that commands are available -# ────────────────────────────────────────────────────────────── -$OCTAVE_CMD --version >/dev/null 2>&1 || { echo "❌ Error: Octave is not available."; exit 1; } -$GNUPLOT_CMD --version >/dev/null 2>&1 || { echo "❌ Error: Gnuplot is not available."; exit 1; } - -# ────────────────────────────────────────────────────────────── -# Step 3: Generate sine wave data using Octave -# ────────────────────────────────────────────────────────────── -$OCTAVE_CMD --no-gui --quiet << EOF -x = 0:0.1:10; -y = sin(x); -data = [x' y']; -save -ascii sine_data.dat data; -EOF - -# ────────────────────────────────────────────────────────────── -# Step 4: Plot the data using Gnuplot -# ────────────────────────────────────────────────────────────── -$GNUPLOT_CMD << EOF -set terminal pngcairo size 800,600 enhanced font 'Verdana,10' -set output 'plot.png' -set title "Sine Wave Plot" -set xlabel "X" -set ylabel "Y" -set grid -plot 'sine_data.dat' using 1:2 with lines title 'sin(x)' lw 2 -EOF - -# ────────────────────────────────────────────────────────────── -# Step 6: Cleanup -# ────────────────────────────────────────────────────────────── -rm -f sine_data.dat