Difference between revisions of "GNU Scientific Library (GSL)"

From bwHPC Wiki
Jump to: navigation, search
Line 1: Line 1:
  +
{| width=600px class="wikitable"
  +
|-
  +
! Description !! Content
  +
|-
  +
| module load
  +
| numlib/gsl
  +
|-
  +
| Availability
  +
| [[bwUniCluster]] | [[BwForCluster_Chemistry]]
  +
|-
  +
| License
  +
|
  +
|-
  +
|Citing
  +
|
  +
|-
  +
| Links
  +
|
  +
|-
  +
| Graphical Interface
  +
| No
  +
|-
  +
|}
  +
<br>
  +
= 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>
 
  +
<br>
'''Online-Documentation:''' http://www.gnu.org/software/gsl/
 
  +
= Versions and Availability =
 
  +
A list of versions currently available on the bwForCluster Chemistry can be obtained from the
'''Local-Documentation:'''
 
  +
<br><big>
 
  +
[https://cis-hpc.uni-konstanz.de/prod.cis/ Cluster Information System CIS] </big>
See 'info gsl', 'man gsl' and 'man gsl-config'.
 
  +
{{#widget:Iframe
 
  +
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/numlib/gsl
'''Tips for compiling and linking:'''
 
  +
|width=99%
 
  +
|height=250
Load the gsl module. After having loaded the gsl environment module, you can use several
 
  +
|border=0
environment variables to compile and link your application with the gsl library.
 
  +
}}
 
  +
<br>
  +
Show a list of available versions using 'module avail numlib/gsl' on any HPC-C5 cluster.
  +
<pre>
  +
: 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)
  +
</pre>
  +
<br>
  +
= Documentation =
  +
=== Online ===
  +
[http://www.gnu.org/software/gsl/ Online-Documentation]
  +
=== Local ===
  +
* info gsl
  +
* man gsl
  +
* man gsl-config
  +
<br>
  +
= Tips for compiling and linking =
  +
== Loading the module ==
  +
You can load the default version of the GSL library with the command<br>
  +
'module load numlib/gsl'.
  +
<br>
  +
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'.
  +
<br>
  +
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.
  +
<pre>
  +
$ 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
  +
</pre>
  +
<br>
  +
= GSL-Specific Environments =
  +
To see a list of all GSL environments set by the 'module load'-command use 'env | grep GSL'.
  +
<br>
  +
Or use the command 'module display numlib/gsl'.
  +
<pre>
  +
$ 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
  +
[...]
  +
</pre>
  +
<br>
  +
= How To Use the Library =
  +
== 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>
 
<pre> #include <gsl/gsl_math.h></pre>
  +
== 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_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>
 
  +
== Link ==
The following command can be used to link the application with the
 
  +
The following command can be used to link the application with the gsl libraries.
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_LIB_DIR environment variable points to the location
 
 
of the gsl libraries.
 
of the gsl libraries.
  +
<br>
 
Also make sure to have the gsl module loaded before running applications build
+
Also make sure to have the GSL-module loaded before running applications build
 
with this library.
 
with this library.
  +
<br><br>
 
'''Example'''
+
= Example C-Source Code =
  +
== Create source code file 'intro.c' ==
 
Create source code file 'intro.c':
 
 
 
<source lang="c">
 
<source lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
Line 51: Line 137:
 
}
 
}
 
</source>
 
</source>
  +
== 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
Line 62: Line 147:
 
J0(5) = -1.775967713143382642e-01
 
J0(5) = -1.775967713143382642e-01
 
</pre>
 
</pre>
  +
 
[[Category: Numerical libraries]][[Category:bwUniCluster]]
 
[[Category: Numerical libraries]][[Category:bwUniCluster]]

Revision as of 14:11, 15 December 2015

Description Content
module load numlib/gsl
Availability bwUniCluster | BwForCluster_Chemistry
License
Citing
Links
Graphical Interface No


1 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.

2 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=250 |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)


3 Documentation

3.1 Online

Online-Documentation

3.2 Local

  • info gsl
  • man gsl
  • man gsl-config


4 Tips for compiling and linking

4.1 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


5 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 display 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
[...] 


6 How To Use the Library

6.1 Includes

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

 #include <gsl/gsl_math.h>

6.2 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-Specific Environments|$GSL_INC_DIR environment variable] points to location of the include path for the gsl header files.

6.3 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-Specific Environments||$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.

7 Example C-Source Code

7.1 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;
}

7.2 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