From 71c86c57fc6bb885a3b296b9624f359216e21b51 Mon Sep 17 00:00:00 2001
From: David Goz <david.goz@inaf.it>
Date: Fri, 21 Jun 2024 15:35:22 +0200
Subject: [PATCH] sbatch pleadi serial added

---
 .gitignore                                    |   4 +-
 jacobi/serial/not_opt/Makefile                |   1 +
 jacobi/serial/not_opt/script/input_parameters |  21 +---
 jacobi/serial/not_opt/script/run_pleiadi.sh   | 104 ++++++++++++++++++
 4 files changed, 111 insertions(+), 19 deletions(-)
 create mode 100755 jacobi/serial/not_opt/script/run_pleiadi.sh

diff --git a/.gitignore b/.gitignore
index 7b3ba82..24bea9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
 # put here the files which are not going to be committed
 *.txt
 *~
-*.bin
\ No newline at end of file
+*.bin
+*.err
+*.out
\ No newline at end of file
diff --git a/jacobi/serial/not_opt/Makefile b/jacobi/serial/not_opt/Makefile
index 01dd641..191f891 100644
--- a/jacobi/serial/not_opt/Makefile
+++ b/jacobi/serial/not_opt/Makefile
@@ -60,3 +60,4 @@ clean:
 	rm -f cachegrind.out.*
 	rm -f callgrind.*
 	rm -f *bin
+	rm -rf jacobi_serial_*
diff --git a/jacobi/serial/not_opt/script/input_parameters b/jacobi/serial/not_opt/script/input_parameters
index 8d6804a..06ef59f 100644
--- a/jacobi/serial/not_opt/script/input_parameters
+++ b/jacobi/serial/not_opt/script/input_parameters
@@ -1,23 +1,8 @@
 ##########################################################################
-####################### paramfile ########################################
 
-# set the template of the paramfile
-TEMPLATE="paramfile_template.txt"
-# set the name of the paramfile used for each run
-PARAMFILE="paramfile_JUWELS.txt"
+# set the grid size
 
-##########################################################################
-####################### run parameters ###################################
-
-# Delete output files (Yes if 1)
-DELETE_OUTPUT_FILES=0
-# Output directory
-OUTPUTDIR="./TEST/"
-# number of particles
-N=(65536)
-# MPI tasks
-MPI=(1 2)
-# OMP threads
-THREADS=(1 2 4)
+GRID_SIZE_X=128
+GRID_SIZE_Y=128
 
 ##########################################################################
diff --git a/jacobi/serial/not_opt/script/run_pleiadi.sh b/jacobi/serial/not_opt/script/run_pleiadi.sh
new file mode 100755
index 0000000..148ba18
--- /dev/null
+++ b/jacobi/serial/not_opt/script/run_pleiadi.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+######################### RESOURSE ALLOCATION #####################################
+##SBATCH --account=????????
+
+#SBATCH --partition=pleiadi
+#SBATCH --job-name="Jabobi"
+#SBATCH --nodes=1
+#SBATCH --ntasks-per-node=1
+#SBATCH --cpus-per-task=1
+#SBATCH --output=Jacobi-serial-no-opt-%j.out
+#SBATCH --error=Jacobi-serial-no-opt.%j.err
+#SBATCH --time=00:03:00
+###################################################################################
+
+################################## MODULES ########################################
+export MODULE_VERSION=5.0.1
+source /opt/cluster/spack/share/spack/setup-env.sh
+
+# module purge
+module purge
+# load GCC
+module load default-gcc-11.2.0
+###################################################################################
+
+# input parameters
+source input_parameters
+
+WORKDIR=${PWD}
+# compile the application
+cd .. && make serial
+if [[ "$?" != "0" ]]
+then
+    echo "Cannot compile the application ...aborting..."
+    exit 1
+fi
+
+# get the executable
+EXEC=$(find $(realpath ./) -maxdepth 1 -executable -name "jacobi_*" -type f -print)
+if [[ "$?" != "0" ]]
+then
+    echo "Cannot find the executable ...aborting..."
+    exit 2
+fi
+
+
+# run 
+time ${EXEC} ${GRID_SIZE_X} ${GRID_SIZE_Y} |& tee ${EXEC}_output.txt
+
+cd ${WORKDIR}
+
+exit 0
+
+# # return to ./script and source input parameters and function
+# cd - && source input_parameters && source write_paramfile.sh
+
+# # loop over particles
+# for PART in "${N[@]}"
+# do
+#     # loop over MPI tasks
+#     for TASK in "${MPI[@]}"
+#     do
+# 	# loop over OMP threads
+# 	for THR in "${THREADS[@]}"
+# 	do
+# 	    # write the paramfile
+# 	    write_paramfile ${TEMPLATE}      ${PARAMFILE}       \
+# 			    ${DELETE_OUTPUT_FILES} ${OUTPUTDIR} \
+# 			    ${THR} ${PART}
+
+# 	    # check the status
+# 	    if [[ "$?" != "0" ]]
+# 	    then
+# 		echo "Error while writing ${PARAMFILE} ...aborting..."
+# 		exit 3
+# 	    fi
+
+# 	    # move the paramfile and move to the parent directory where the executable resides
+# 	    mv ${PARAMFILE} ../ && cd ..
+	    
+# 	    # run the application
+# 	    srun --ntasks ${TASK} ${EXEC} ${PARAMFILE} >& $SLURM_JOB_ID.log
+
+# 	    # check exit status
+# 	    if [[ "$?" != "0" ]]
+# 	    then
+# 		echo "####################################################################"
+# 		echo "ERROR while running the app using: ${TASK} MPI tasks and ${GPU} GPUs"
+# 		echo "####################################################################"
+# 	    fi
+
+# 	    # delete the paramfile and return to the previous directory
+# 	    rm -f ${PARAMFILE} && cd -
+# 	done # loop over THR
+#     done # loop over TASKS
+# done # looop over particles
+
+# # make clean
+# cd .. && make clean
+
+
+
+# Everything is OK!
+# exit 0
-- 
GitLab