All of the distributional generators, require a base generator which returns a uniformly distributed value in the semi-open interval (0, 1] and AOCL-RNG library includes several such generators. However, for greater flexibility, the library routines allow the user to register their own base generator function. This user-supplied generator then becomes the base generator for all of the distribution generators.
A user supplied generator comes in the form of two routines, one to initialize
the generator and one to generate a set of uniformly distributed values in the
semi-open interval (0, 1]. These two routines can be named anything, but are
referred to as UINI for the initialization routine and UGEN for the
generation routine. User’s own Base Generator Hooks can be used to register
User-supplied generator. Once registered the generator can be accessed and used
in the same manner as the library supplied base generators.
Refer code snippet provided below to use User-supplied base generator.
C Generate 100 values from the Uniform distribution using
C a user supplied base generator
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,NSKIP,SEED(1),STATE(LSTATE) INTEGER X(N)
DOUBLE PRECISION A,B
C Set the seed SEED(1) = 1234
C Set the distributional parameters
A = 0.0D0
B = 1.0D0
C Initialize the base generator. Here RNGNB0GND is a user
C supplied generator and RNGNB0INI is its initializer
CALL DRANDINITIALIZEUSER(RNGNB0INI,RNGNB0GND,1,0,SEED,
* LSEED,STATE,LSTATE,INFO)
C Generate N variates from the Univariate distribution CALL
DRANDUNIFORM(N,A,B,STATE,X,LDX,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)