Quick Reference:Default Interface

Previous:Simple Interface


Quick Reference for the Default Interface

Header files and Macros

C: Include the header file sprng.h.
FORTRAN: Include the header file sprng_f.h.

Define the following macro before including a SPRNG header file:
CHECK_POINTERS to obtain the interface with pointer checking.
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 in the MPI version.

sprng_f.h defines the macro SPRNG_POINTER to be a FORTRAN integer large enough to hold a C pointer. 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.

SPRNG Functions

The C call is given first, followed by the FORTRAN call.

int *init_sprng(int streamnum, int nstreams, int seed, int param)
SPRNG_POINTER init_sprng(integer streamnum, integer nstreams, integer seed, integer param)

Initialize a random number stream with seed seed and parameter param. streamnum is the stream number and must be in [0,nstreams-1]. nstreams is the number of different streams that will be initialized (on all the processors). init_sprng returns the stream ID.

double sprng(int *stream)
real*8 sprng(SPRNG_POINTER stream)

The next random number in [0,1) from the stream with ID stream is returned.

int isprng(int *stream)
integer isprng(SPRNG_POINTER stream)

The next random number in [0,231) from the stream with ID stream is returned.

int print_sprng(int *stream)
integer print_sprng(SPRNG_POINTER stream)

Print information about a stream with ID 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 with ID 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)

Return an ID after recreating the stream that had been packed into buffer.

int free_sprng(int *stream)
integer free_sprng(SPRNG_POINTER stream)

Free memory used to store the state of the stream with ID stream. Return the number of streams available on the process.

int spawn_sprng(int *stream, int nspawned, int ***newstreams)
integer spawn_sprng(SPRNG_POINTER stream, integer nspawned, SPRNG_POINTER fnewstreams)

Spawn nspawned new streams from an exiting one with ID stream. fnewstreams is an array of size at least nspawned in which the ID's of the new streams are stored. In C, SPRNG allocates memory and makes *newstreams point to this array. The number of streams successfully spawned is returned.


[Quick 
Start] [User's 
Guide] [Reference 
Manual] [Quick 
Reference]