User's Guide: Usage:Compilation

Next:Examples Previous:Usage


Compilation

Compiling with the Non-MPI version of SPRNG

SPRNG currently consists of five libraries for random number generation. The library libcmrg.a generates streams from the Combine Multiple Recursive Generator, liblcg.a from the 48 bit Linear Congruential Generator, liblcg64.a from the 64 bit Linear Congruential Generator, liblfg.a from the modified Lagged Fibonacci Generator, and libpmlcg.a from the Prime Modulus Linear Congruential Generator. (The last one is not automatically installed.) In the current implementation, the user can generate streams only from one of these libraries in a given program. However, the user can easily change between different generators in different runs by just changing the library linked to, and does not need to recompile the code.

In order to use a library, the programmer needs to link the code to the desired library. This is generally done by using the following linking option: -Llibdir -llib where libdir is the path to the SPRNG libraries, and liblib.a is the particular SPRNG library from which the user desires to generate random numbers. We have provided examples for compilation on different platforms.

If the size of a pointer is 8 bytes, then either the macro SPRNG_POINTER=8 should be defined before including the header file, or this should be done through a compiler option (typically -DSPRNG_POINTER=8). Please take a look at the make.PLAT file of your platform for the correct setting.

In order to compile programs, the user must also indicate the location of the SPRNG header files. This is generally done by passing the -Isrcdir option to the compiler, where srcdir is the path to the SPRNG SRC directory.

The compilation syntax may therefore be one of the following on most compilers:

CC -Isrcdir filename.c -Llibdir -llib
F77 -Isrcdir filename.F -Llibdir -llib

where CC is the C compiler and F77 is the FORTRAN compiler. FORTRAN users may also wish to read the note on preprocessor directives.

We have also provided examples for compilation on different platforms.

Compiling with the MPI version of SPRNG

If the MPI version of SPRNG has been installed, then the user will have to link to the MPI libraries too, in addition to the SPRNG libraries mentioned above. Thus the following syntax for the compilation may be used on most compilers:

CC -Isrcdir filename.c -Llibdir -llib -Lmpidir -lmpilib
F77 -Isrcdir filename.F -Llibdir -llib -Lmpidir -lmpilib

where mpidir is the path to the MPI library and libmpilib.a is the name of the MPI library. The MPI library must be linked after the SPRNG library. We have provided examples for compilation on different platforms.


[Quick 
Start] [User's 
Guide] [Reference 
Manual] [Quick 
Reference] [Next: 
Examples]