Use GSL on the Cluster¶
- 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 gslin your
- After loading the module in your
PBSscript, you must add to the
PBSscript 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
#PBSdirectives are standard, requesting just 1 minute of walltime and 1 node with 2 cores. More on
#PBSdirectives can be found in the PBS guide
$PBS_O_WORKDIRis simply a variable that represents the directory you submit the PBS script from. Make sure the
.cfile 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
module loadlines load gcc (compiler) and gsl.
gccline links the GSL library and compiles the C program into an executable called
./gslExampleruns the program
Part 2: Submit Job and Check Status¶
- Make sure you're in the directory that contains the
PBSscript and the
- Submit as normal, with
qsub <pbs script name>. In this case
- 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
PBSscript, you should see a couple of newly generated files, including
gslExampleis the executable file created
gsl.outcontains the results of the job
vim 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.