GNU Scientific Library (GSL): Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:
|-
|-
| Availability
| Availability
| [[bwUniCluster]] | [[BwForCluster_Chemistry]]
| [[bwUniCluster]]
|-
|-
| License
| License
| [http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)]
|
|-
|-
|Citing
|Citing
| <small><small><pre>The recommended way is to cite the reference manual,
|
e.g. M. Galassi et al, GNU Scientific Library Reference Manual
(3rd Ed.), ISBN 0954612078.</pre></small></small>
|-
|-
| Links
| Links
| [http://www.gnu.org/software/gsl GSL-GNU Scientific Library Homepage] &#124; [http://www.gnu.org/software/gsl/ Online-Documentation]
|
|-
|-
| Graphical Interface
| Graphical Interface
Line 25: Line 27:
= Description =
= Description =
The '''GNU Scientific Library''' (or '''GSL''') is a software library for numerical computations in applied mathematics and science. The GSL is written in the C programming language, but bindings exist for other languages as well.
The '''GNU Scientific Library''' (or '''GSL''') is a software library for numerical computations in applied mathematics and science. The GSL is written in the C programming language, but bindings exist for other languages as well.
<br>
The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers.
<br>
The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite.
<br>
<br>
<u>The complete range of subject areas covered by the library includes</u>
<br>
&bull; Complex Numbers &bull; Roots of Polynomials &bull; Special Functions &bull; Vectors and Matrices &bull; Permutations &bull; Sorting &bull; BLAS Support &bull; Linear Algebra &bull; Eigensystems &bull; Fast Fourier Transforms &bull; Quadrature &bull; Random Numbers &bull; Quasi-Random Sequences &bull; Random Distributions &bull; Statistics &bull; Histograms &bull; N-Tuples &bull; Monte Carlo Integration &bull; Simulated Annealing &bull; Differential Equations &bull; Interpolation &bull; Numerical Differentiation &bull; Chebyshev Approximation &bull; Series Acceleration &bull; Discrete Hankel Transforms &bull; Root-Finding &bull; Minimization &bull; Least-Squares Fitting &bull; Physical Constants &bull; IEEE Floating-Point &bull; Discrete Wavelet Transforms &bull; Basis splines &bull; Running Statistics &bull; Sparse Matrices and Linear Algebra
<br>
<br>
<br>
<br>
Line 34: Line 45:
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/numlib/gsl
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/numlib/gsl
|width=99%
|width=99%
|height=250
|height=220
|border=0
|border=0
}}
}}
Line 49: Line 60:
= Documentation =
= Documentation =
=== Online ===
=== Online ===
[http://www.gnu.org/software/gsl/ Online-Documentation]
* [http://www.gnu.org/software/gsl/ Online-Documentation]
=== Local ===
=== Local ===
* info gsl
* info gsl
Line 79: Line 90:
To see a list of all GSL environments set by the 'module load'-command use 'env | grep GSL'.
To see a list of all GSL environments set by the 'module load'-command use 'env | grep GSL'.
<br>
<br>
Or use the command 'module display numlib/gsl'.
Or use the command 'module show numlib/gsl'.
<pre>
<pre>
$ module show numlib/gsl-------------------------------------------------------------------
$ module show numlib/gsl-------------------------------------------------------------------
Line 106: Line 117:
== Includes ==
== Includes ==
Your source code should contain preprocessor include statements with a gsl/ prefix, such as
Your source code should contain preprocessor include statements with a gsl/ prefix, such as
<pre> #include <gsl/gsl_math.h></pre>
<source lang="c">#include <gsl/gsl_math.h></source>
== Compile ==
== Compile ==
A typical compilation command for a source file example.c with the
A typical compilation command for a source file example.c with the
Intel C compiler icc is
Intel C compiler icc is
<pre> $ icc -Wall -I$GSL_INC_DIR -c example.c </pre>
<pre> $ icc -Wall -I$GSL_INC_DIR -c example.c </pre>
The [[#GSL-Specific Environments|$GSL_INC_DIR environment variable] points to location of
The [[#GSL-Specific Environments|$GSL_INC_DIR environment variable]] points to location of
the include path for the gsl header files.
the include path for the gsl header files.
<br>
<br>
Line 117: Line 128:
The following command can be used to link the application with the gsl libraries.
The following command can be used to link the application with the gsl libraries.
<pre> $ icc -L$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm </pre>
<pre> $ icc -L$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm </pre>
The [[[#GSL-Specific Environments||$GSL_LIB_DIR environment] variable points to the location
The [[#GSL-Specific Environments|$GSL_LIB_DIR environment]] variable points to the location
of the gsl libraries.
of the gsl libraries.
<br>
<br>
Line 137: Line 148:
}
}
</source>
</source>
<small>[https://www.gnu.org/software/gsl/manual/html_node/Special-Functions.html Bessel-Funktions and more]</small>
<br>
== Compile and Link ==
== Compile and Link ==
Load the gsl module for the Intel compiler, compile, link and run the program
Load the GSL module for the Intel compiler, compile, link and run the program
<pre>
<pre>
$ module load numlib/gsl/1.16-intel-13.1
$ module load numlib/gsl/1.16-intel-13.1

Revision as of 14:43, 15 December 2015

Description Content
module load numlib/gsl
Availability bwUniCluster
License GNU General Public License (GPL)
Citing
The recommended way is to cite the reference manual,
e.g. M. Galassi et al, GNU Scientific Library Reference Manual
(3rd Ed.), ISBN 0954612078.
Links GSL-GNU Scientific Library Homepage | Online-Documentation
Graphical Interface No


Description

The GNU Scientific Library (or GSL) is a software library for numerical computations in applied mathematics and science. The GSL is written in the C programming language, but bindings exist for other languages as well.
The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers.
The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite.

The complete range of subject areas covered by the library includes
• Complex Numbers • Roots of Polynomials • Special Functions • Vectors and Matrices • Permutations • Sorting • BLAS Support • Linear Algebra • Eigensystems • Fast Fourier Transforms • Quadrature • Random Numbers • Quasi-Random Sequences • Random Distributions • Statistics • Histograms • N-Tuples • Monte Carlo Integration • Simulated Annealing • Differential Equations • Interpolation • Numerical Differentiation • Chebyshev Approximation • Series Acceleration • Discrete Hankel Transforms • Root-Finding • Minimization • Least-Squares Fitting • Physical Constants • IEEE Floating-Point • Discrete Wavelet Transforms • Basis splines • Running Statistics • Sparse Matrices and Linear Algebra

Versions and Availability

A list of versions currently available on the bwForCluster Chemistry can be obtained from the
Cluster Information System CIS {{#widget:Iframe |url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/numlib/gsl |width=99% |height=220 |border=0 }}
Show a list of available versions using 'module avail numlib/gsl' on any HPC-C5 cluster.

: EXAMPLE bwUniCluster
$ module avail numlib/gsl
------------------------ /opt/bwhpc/common/modulefiles -------------------------
numlib/gsl/1.16-gnu-4.4             numlib/gsl/1.16-intel-14.0
numlib/gsl/1.16-intel-13.1(default)


Documentation

Online

Local

  • info gsl
  • man gsl
  • man gsl-config


Tips for compiling and linking

Loading the module

You can load the default version of the GSL library with the command
'module load numlib/gsl'.
The module will try to load modules it needs to function. If loading the module fails, check if you have already loaded one of those modules with the command 'module list'.
If you wish to load a specific (older) version (if available), you can do so using e.g. ' module load numlib/gsl/'version' to load the version you desires.

$ module avail numlib/gsl
------------------------ /opt/bwhpc/common/modulefiles -------------------------
numlib/gsl/1.16-gnu-4.4             numlib/gsl/1.16-intel-14.0
numlib/gsl/1.16-intel-13.1(default)
$ module load numlib/gsl/1.16-gnu-4.4
$ module list
Currently Loaded Modulefiles:
  1) numlib/gsl/1.16-gnu-4.4


GSL-Specific Environments

To see a list of all GSL environments set by the 'module load'-command use 'env | grep GSL'.
Or use the command 'module show numlib/gsl'.

$ module show numlib/gsl-------------------------------------------------------------------
/opt/bwhpc/common/modulefiles/numlib/gsl/1.16-intel-13.1:
GSL_VERSION = 1.16 
GSL_HOME = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1 
GSL_BIN_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/bin 
GSL_INC_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/include 
GSL_LIB_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib 
GSL_STA_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib 
GSL_SHA_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib 
GSL_MAN_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/man 
GSL_INF_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/info 
GSL_DOC_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/doc 
GSL_EXA_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/doc/examples 
GSL_WWW http://www.gnu.org/software/gsl/ 
PATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/bin:$PATH
MANPATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/man:$MANPATH
INFOPATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/info:$INFOPATH
LD_LIBRARY_PATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib:$LD_LIBRARY_PATH
INCLUDE = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/include:$INCLUDE
[...] 


How To Use the Library

Includes

Your source code should contain preprocessor include statements with a gsl/ prefix, such as

#include <gsl/gsl_math.h>

Compile

A typical compilation command for a source file example.c with the Intel C compiler icc is

 $ icc -Wall -I$GSL_INC_DIR  -c example.c 

The $GSL_INC_DIR environment variable points to location of the include path for the gsl header files.

Link

The following command can be used to link the application with the gsl libraries.

 $ icc -L$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm 

The $GSL_LIB_DIR environment variable points to the location of the gsl libraries.
Also make sure to have the GSL-module loaded before running applications build with this library.

Example C-Source Code

Create source code file 'intro.c'

#include <stdio.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 0;
}

Bessel-Funktions and more

Compile and Link

Load the GSL module for the Intel compiler, compile, link and run the program

$ module load numlib/gsl/1.16-intel-13.1
Loading module dependency 'compiler/intel/13.1'.
$ icc -Wall -I$GSL_INC_DIR  -c intro.c
$ icc -L$GSL_LIB_DIR -o intro intro.o -lgsl -lgslcblas -lm
$ ./intro
J0(5) = -1.775967713143382642e-01