User's Guide: Usage:Compilation

Next:Examples Previous:Usage


Compilation

Compiling with the Non-MPI version of SPRNG

SPRNG 5.0 consists of one library for six random number generators. The library libsprng.a generates streams from the Combine Multiple Recursive Generator, the 48 bit Linear Congruential Generator, the 64 bit Linear Congruential Generator, the modified Lagged Fibonacci Generator, the multiplicative Lagged Fibbonacci Generator, and the Prime Modulus Linear Congruential Generator. In SPRNG version 5.0 implementation, the user can generate streams only from all six generators in one program.

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 library, and liblib.a is the SPRNG library from which the user desires to generate random numbers.

If the size of a pointer is 8 bytes, automake/autoconf should detect this properly and define SPRNG_POINTER appropriately. However, if this is not detected properly, 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).

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:

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

where CXX is the C++ compiler and F77 is the FORTRAN compiler. FORTRAN users may also wish to read the note on preprocessor directives. It is also often neccessary for FORTRAN users to include the standard c++ library when compiling with SPRNG, so including -lstdc++ may be necessary as well.

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.cpp -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. In many systems, there is a separate MPI compiler which automatically includes the MPI libraries. If this is the case, the following syntax may be used:

MPICXX -Isrcdir filename.c -Llibdir -llib
MPIF77 -Isrcdir filename.F -Llibdir -llib

where MPICXX is the MPI C++ compiler and MPIF77 is the MPI FORTRAN compiler.


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