Difference between revisions of "Development/GSL"

From bwHPC Wiki
Jump to: navigation, search
(Documentation)
m (S Richling moved page GSL to Development/GSL: Umzug in Development-Bereich)
 
(30 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
{{Softwarepage|numlib/gsl}}
  +
 
{| width=600px class="wikitable"
 
{| width=600px class="wikitable"
 
|-
 
|-
Line 5: Line 7:
 
| module load
 
| module load
 
| numlib/gsl
 
| numlib/gsl
|-
 
| Availability
 
| [[bwUniCluster_2.0]] | [[BwForCluster_JUSTUS_2]]
 
 
|-
 
|-
 
| License
 
| License
Line 13: Line 12:
 
|-
 
|-
 
|Citing
 
|Citing
| <small><small><pre>M. Galassi et al., GNU Scientific Library Reference Manual (3rd Ed.), ISBN 0954612078.</pre></small></small>
+
| <pre>M. Galassi et al., GNU Scientific Library Reference Manual (3rd Ed.), ISBN 0954612078.</pre>
 
|-
 
|-
 
| Links
 
| Links
Line 33: Line 32:
 
<br>
 
<br>
 
<br>
 
<br>
  +
== How to use GSL ==
   
  +
A man page is available and can be accessed by typing
= Availability =
 
 
GSL is available on selected bwHPC-Clusters. A complete list of versions currently installed on the bwHPC-Clusters can be obtained from the [https://www.bwhpc.de/software.html Cluster Information System (CIS)].
 
 
In order to check which versions of GSL are installed on the compute cluster, run the following command:
 
<pre>
 
$ module avail numlib/gsl
 
</pre>
 
 
= Documentation =
 
 
A documentation for GSL is available [https://www.gnu.org/software/gsl/doc/html/index.html online].
 
 
The help page of the GSL module provides more version specific information:
 
<pre>
 
$ module help numlib/gsl
 
 
----------- Module Specific Help for 'numlib/gsl/2.6' ----------
 
This module sets the path and environment variables for GSL-2.6.
 
 
The library has been compiled with GNU compiler 8.3 using the following optimization flags:
 
 
-O3 -funroll-loops -march=native -mtune=native
 
 
Online-Documentation: $GSL_WWW
 
 
Local-Documentation: $GSL_DOC_DIR
 
 
Code Examples: $GSL_EXA_DIR
 
 
Tips for compiling and linking:
 
 
After having loaded the environment module, you can use several environment variables to
 
compile and link your application with the GSL library.
 
 
Your source code should contain preprocessor include statements with a gsl/prefix, such as
 
 
#include <gsl/gsl_math.h>
 
 
A typical compilation command for a source file example.c with the GNU C compiler gcc is
 
 
gcc -Wall -I\$GSL_INC_DIR -c example.c
 
 
The GSL_INC_DIR environment variable points to the location of the include path for the GSL header files.
 
 
The following command can be used to link the application with the GSL library:
 
 
gcc -L\$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm
 
 
The GSL_LIB_DIR environment variable points to the location of the GSL library.
 
 
In case of problems, submit a trouble ticket at 'https://bw-support.scc.kit.edu'.
 
 
The full version is: numlib/gsl/2.6
 
</pre>
 
 
Furthermore, a man page is available and can be accessed by typing:
 
 
<pre>
 
<pre>
 
$ man gsl
 
$ man gsl
 
</pre>
 
</pre>
   
= Usage =
+
=== Includes ===
   
  +
Your source code should contain preprocessor include statements with a gsl/prefix such as
== Loading the module ==
 
  +
<source lang="c">#include <gsl/gsl_math.h></source>
   
  +
=== Compile ===
You can load the default version of GSL with the following command:
 
<pre>
 
$ module load numlib/gsl
 
</pre>
 
   
  +
A typical compilation command for a source file 'example.c' using the Intel C compiler icc is
The module will try to load all modules it needs to function (e.g., compiler, mpi, ...). If loading the module fails, check if you have already loaded one of those modules, but not in the version required by GSL.
 
  +
<pre> $ icc -Wall -I$GSL_INC_DIR -c example.c </pre>
  +
The <span style="background:#edeae2;margin:2px;padding:1px;border:1px dotted #808080">$GSL_INC_DIR</span> environment variable points to the location of the include path for the GSL header files.
   
  +
=== Link ===
If you wish to load another (older) version of GSL, you can do so using
 
<pre>
 
$ module load numlib/gsl/<version>
 
</pre>
 
with <version> specifying the desired version.
 
   
  +
The following command can be used to link the application with the GSL libraries:
= How To Use the Library =
 
== Includes ==
 
Your source code should contain preprocessor include statements with a gsl/ prefix, such as
 
<source lang="c">#include <gsl/gsl_math.h></source>
 
== Compile ==
 
A typical compilation command for a source file example.c with the
 
Intel C compiler icc is
 
<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 include path for the gsl header files.
 
<br>
 
== Link ==
 
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 <span style="background:#edeae2;margin:2px;padding:1px;border:1px dotted #808080">$GSL_LIB_DIR</span> 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.
of the gsl libraries.
 
<br>
 
Also make sure to have the GSL-module loaded before running applications build
 
with this library.
 
<br><br>
 
= Examples =
 
 
Consider the following GSL task and create source code file 'gsl-test.c':
 
 
<source lang="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;
 
}
 
</source>
 
 
The code can be compiled and executed with the following commands:
 
 
<pre>
 
$ module load numlib/gsl/2.6-intel-19.1.2
 
$ icc -Wall -I$GSL_INC_DIR -c gsl-test.c
 
$ icc -L$GSL_LIB_DIR -o example gsl-test.o -lgsl -lgslcblas -lm
 
$ ./example
 
J0(5) = -1.775967713143382642e-01
 
</pre>
 
   
 
= Useful links =
 
= Useful links =
Line 164: Line 62:
 
* [https://de.wikipedia.org/wiki/GNU_Scientific_Library Wikipedia article (german)]
 
* [https://de.wikipedia.org/wiki/GNU_Scientific_Library Wikipedia article (german)]
 
* [https://en.wikipedia.org/wiki/GNU_Scientific_Library Wikipedia article (english)]
 
* [https://en.wikipedia.org/wiki/GNU_Scientific_Library Wikipedia article (english)]
----
 
[[Category: Numerical libraries]][[Category:BwUniCluster]][[Category:BwUniCluster_2.0]][[Category:BwForCluster_Chemistry]][[Category:BwForCluster_JUSTUS_2]]
 

Latest revision as of 00:03, 15 March 2023

The main documentation is available via module help numlib/gsl on the cluster. Most software modules for applications provide working example batch scripts.


Description Content
module load numlib/gsl
License GNU General Public License (GPL)
Citing
M. Galassi et al., GNU Scientific Library Reference Manual (3rd Ed.), ISBN 0954612078.
Links Homepage | Documentation
Graphical Interface No


1 Description

The GNU Scientific Library (GSL) is a software library for numerical computations in applied mathematics and science. GSL is written in C, but bindings exist for other programming languages as well. 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:

• 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

1.1 How to use GSL

A man page is available and can be accessed by typing

$ man gsl

1.1.1 Includes

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

#include <gsl/gsl_math.h>

1.1.2 Compile

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

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

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

1.1.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_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.

2 Useful links