Quick Reference for the Simple Interface
Header files and MacrosC: Include the header file sprng.h.
FORTRAN: Include the header file sprng_f.h.
Define the following macro before including a SPRNG header file:
SIMPLE_SPRNG to obtain this simple interface.
FLOAT_GEN to obtain single precision numbers when calling sprng, instead of the double precision default.
USE_MPI to get the same seed on all processors with make_sprng_seed, or if user does not plan to call init_sprng, in the MPI version.
sprng_f.h defines the macro SPRNG_POINTER to be a FORTRAN integer large enough to hold a C pointer.
SPRNG FunctionsThe C call is given first, followed by the FORTRAN call.
- int *init_sprng(int rng_type, int seed, int param)
- SPRNG_POINTER init_sprng(integer rng_type, integer seed, integer param)
- Initialize a random number stream with seed seed and parameter param. Return 0 if unsuccessful.
- double sprng()
- real*8 sprng()
- The next random number in [0,1) is returned.
- int isprng()
- integer isprng()
- The next random number in [0,231) is returned.
- int print_sprng()
- integer print_sprng()
- Print information about the random number stream.
- int make_sprng_seed()
- integer make_sprng_seed()
- Produce a seed. Define USE_MPI to get the same seed on all processors with the MPI version.
- int pack_sprng(int *stream, char **buffer)
- integer pack_sprng(SPRNG_POINTER stream, character fbuffer)
- Pack the stream into an array and return the number of bytes of storage required. fbuffer is an array of size MAX_PACKED_LENGTH. In C, SPRNG allocates memory and has the result stored in *buffer.
- int *unpack_sprng(char *buffer)
- SPRNG_POINTER unpack_sprng(character buffer)
- Recreate the stream that had been packed into buffer. Return 0 if unsuccessful.