* G05TGF Example Program Text * Mark 22 Release. NAG Copyright 2006. * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) INTEGER K, MSEED, MSTATE, N, LR, LDX PARAMETER (K=4,MSEED=1,MSTATE=633,N=20,LR=6007,LDX=N) * .. Local Scalars .. INTEGER GENID, I, IFAIL, J, LSEED, LSTATE, M, SUBID * .. Local Arrays .. DOUBLE PRECISION P(K), R(LR) INTEGER SEED(MSEED), STATE(MSTATE), X(LDX,K) * .. External Subroutines .. EXTERNAL G05KFF, G05TGF * .. Executable Statements .. WRITE (NOUT,*) 'G05TGF Example Program Results' WRITE (NOUT,*) * Set the distribution parameters P and M P(1) = 0.08D0 P(2) = 0.1D0 P(3) = 0.8D0 P(4) = 0.02D0 M = 6000 * Initialize the seed SEED(1) = 1762543 * GENID and SUBID identify the base generator GENID = 1 SUBID = 1 * Initialize the generator to a repeatable sequence LSTATE = MSTATE LSEED = MSEED IFAIL = 1 CALL G05KFF(GENID,SUBID,SEED,LSEED,STATE,LSTATE,IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99998) IFAIL GO TO 40 END IF * Generate the variates * Choose MODE = 2 IFAIL = 1 CALL G05TGF(2,N,M,K,P,R,LR,STATE,X,LDX,IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99997) IFAIL GO TO 40 END IF * Display the variates DO 20 I = 1, N WRITE (NOUT,99999) (X(I,J),J=1,K) 20 CONTINUE * 40 CONTINUE * 99999 FORMAT (1X,10(1X,I12)) 99998 FORMAT (1X,' ** G05KFF returned with IFAIL = ',I5) 99997 FORMAT (1X,' ** G05TGF returned with IFAIL = ',I5) END