Fork me on GitHub

GSL

The GNU Scientific Library (GSL) is a collection of routines for numerical computing. The routines have been written from scratch in C. See here for the types of routines that the GSL provides.

Usage

The GSL library can be loaded by running one of:

module load GSL/2.6-GCC-8.3.0
module load GSL/2.5-GCC-8.2.0-2.31.1

which will also load a particular GCC, or:

module load GSL/2.5-iccifort-2019.1.144-GCC-8.2.0-2.31.1

if you also want to activate or have already activated icc/icpc/ifort 2019.1.

Example

A example program that uses the GSL (taken from the GSL documentation):

#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_sf_bessel.h>

int main (void) {
  double x = 5.0;
  double y = gsl_sf_bessel_J0(x);

  printf("J0(%g) = %.18e\n", x, y);

  return EXIT_SUCCESS;
}

Build this using:

gcc -Wall -lgsl -lgslcblas -o test test.c  # OR
icc -Wall -lgsl -lgslcblas -o test test.c

Then run using:

./test

which should print the following (correct to double-precision accuracy):

J0(5) = -1.775967713143382642e-01

NB generally, you may not need to compile using -lgslcblas depending on which GSL routines you are using.