GNU Scientific Library on cluster
Intro: 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 |
|
|
The GSL website http://www.gnu.org/software/gsl/
How to use GSL on cluster
Step 1: Please read "how to setup your working environment" and do the following:
a. Include the sentence of "module load gsl/default" in the module-loading blocks in your .bashrc file
b. Type ". .bashrc" in your terminal, and then type "module list or type "which blastall" in your terminal again, you shall be able to see:
[testy@n137 ~]$ . .bashrc
[testy@n137 ~]$ module list
Currently Loaded Modulefiles:
1) gsl/default
If you see the above output on terminal, it means your environment has been setup correctly.
c. check your gnu c/c++ compiling path.
[testy@n137 namd]$ which gcc
/usr/bin/gcc
[testy@n137 namd]$ which g++
/usr/bin/g++
check your LD_LIBRARY_PATH path.
[testy@n137 namd]$ echo $LD_LIBRARY_PATH
/shr/home/source/gsl/lib
This indicates your environment has been setup correctly and you can begin to work and submit your job. (Your MUST setup the LD_LIBRARY_PATH correctly).
Step 2. Compiling and running your program
The example testGSL.c and the Makefile can be downloaded to your working directory.
[testy@n137 ~]$ cd /shr/home/testy/your_working_dir
[testy@n137 ~]$ make -f testGSL.mak
gcc -I/source/gsl/include -o testGSL.o -c testGSL.c
gcc -L/source/gsl/lib testGSL.o -lgsl -lgslcblas -lm -Wall -o testGSL
run your program .
[testy@n137 ~]$ ./testGSL
plain ==================
result = 1.391775
sigma = 0.003746
exact = 1.393204
error = -0.001429 = 0.4 sigma
miser ==================
result = 1.393587
sigma = 0.000913
exact = 1.393204
error = 0.000383 = 0.4 sigma
vegas warm-up ==================
result = 1.390760
sigma = 0.003309
exact = 1.393204
error = -0.002444 = 0.7 sigma
converging...
result = 1.393244 sigma = 0.000111 chisq/dof = 4.4
result = 1.393238 sigma = 0.000083 chisq/dof = 0.7
vegas final ==================
result = 1.393238
sigma = 0.000083
exact = 1.393204
error = 0.000034 = 0.4 sigma
Time elapsed: 7.010000
After you finish the testing, PLEASE read how to submit jobs in cluster to run your compiled program, DONOT run it directly on n62 or n63.
|