Updated 2021-05-17
Use GSL on the Cluster¶
Overview¶
- This guide will cover how to load and run the GNU Scientific Library
- To use GSL in a C program, you must first load the GSL module with
module load gsl
in yourPBS
script. - After loading the module in your
PBS
script, you must add to thePBS
script the necessary commands for compilation and execution of your C program. - Submit the job with
qsub <.pbs filename>
Walkthrough : Use GSL on the Cluster¶
- This walkthrough will use GSL to calculate the value of a Bessel function with an input of 5.
- This example C program is from the GSL documentation
- C program: gslExample.c
- PBS Script: gsl.pbs
- To follow along, manually copy these files into the same directory in your account on the cluster, or transfer them to your account (again put them in the same folder).
Part 1: The PBS Script¶
#PBS -N gslTest
#PBS -A [Account]
#PBS -l nodes=1:ppn=2
#PBS -l pmem=2gb
#PBS -l walltime=1:00
#PBS -q inferno
#PBS -j oe
#PBS -o gsl.out
cd $PBS_O_WORKDIR
module load gcc
module load gsl
gcc -o gslExample gslExample.c `gsl-config --cflags --libs`
./gslExample
- The
#PBS
directives are standard, requesting just 1 minute of walltime and 1 node with 2 cores. More on#PBS
directives can be found in the PBS guide $PBS_O_WORKDIR
is simply a variable that represents the directory you submit the PBS script from. Make sure the.c
file you want to run is in the same directory you put the PBS script. Otherwise, the C program wont be found when the job is run.- Output Files, such as the resulting executable, will also show up in the same directory as the
PBS
script - The
module load
lines load gcc (compiler) and gsl. - The
gcc
line links the GSL library and compiles the C program into an executable calledgslExample
. ./gslExample
runs the program
Part 2: Submit Job and Check Status¶
- Make sure you're in the directory that contains the
PBS
script and the.c
file - Submit as normal, with
qsub <pbs script name>
. In this caseqsub gsl.pbs
- Check job status with
qstat -u username3 -n
, replacing "username3" with your gtusername - You can delete the job with
qdel 22182721
, replacing the number with the jobid returned after running qsub
Part 3: Collecting Results¶
- In the directory where you submitted the
PBS
script, you should see a couple of newly generated files, includinggslExample
andgsl.out
gslExample
is the executable file createdgsl.out
contains the results of the job- Open
gsl.out
withvim gsl.out
(you can use any text editor). - The output should contain the result of the computation:
Job name: gslTest
Queue: inferno
End PBS Prologue Wed Nov 14 12:59:43 EST 2018
---------------------------------------
J0(5) = -1.775967713143382642e-01
---------------------------------------
Begin PBS Epilogue Wed Nov 14 12:59:44 EST 2018
Job ID: 22899130.shared-sched.pace.gatech.edu
- After the result files are produced, you can move the out file as well as any other files off the cluster. Refer to the file transfer guide for help.
- Congratulations! You successfully used GSL on the cluster.