* G05KHF Example Program Text * Mark 22 Release. NAG Copyright 2006. * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) INTEGER MSTATE, MSEED, NV, N PARAMETER (MSTATE=633,MSEED=1,NV=5,N=3) * .. Local Scalars .. INTEGER GENID, I, IFAIL, J, LSEED, LSTATE, SUBID * .. Local Arrays .. DOUBLE PRECISION X(NV) INTEGER SEED(MSEED), STATE(MSTATE,N) * .. External Subroutines .. EXTERNAL G05KFF, G05KHF, G05SAF * .. Executable Statements .. WRITE (NOUT,*) 'G05KHF Example Program Results' WRITE (NOUT,*) * Initialize the seed SEED(1) = 1762543 * GENID and SUBID identify the base generator GENID = 1 SUBID = 1 LSTATE = MSTATE LSEED = MSEED * Prepare N streams DO 20 I = 1, N * Initialize the generator to a repeatable sequence IFAIL = 1 CALL G05KFF(GENID,SUBID,SEED,LSEED,STATE(1,I),LSTATE,IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99998) IFAIL GO TO 60 END IF * Prepare the I'th out of N streams IFAIL = 1 CALL G05KHF(N,I,STATE(1,I),IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99997) IFAIL GO TO 60 END IF 20 CONTINUE * Generate a NV variates from a uniform distribution, from each stream DO 40 I = 1, N WRITE (NOUT,*) 'Stream ', I IFAIL = 1 CALL G05SAF(NV,STATE(1,I),X,IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99996) IFAIL GO TO 60 END IF * Display the variates WRITE (NOUT,99999) (X(J),J=1,NV) WRITE (NOUT,*) 40 CONTINUE * 60 CONTINUE * 99999 FORMAT (1X,F10.4) 99998 FORMAT (1X,' ** G05KFF returned with IFAIL = ',I5) 99997 FORMAT (1X,' ** G05KHF returned with IFAIL = ',I5) 99996 FORMAT (1X,' ** G05SAF returned with IFAIL = ',I5) END