* G05SGF Example Program Text * Mark 22 Release. NAG Copyright 2006. * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) INTEGER MSTATE, MSEED, N, NMIX PARAMETER (MSTATE=633,MSEED=1,N=5,NMIX=3) * .. Local Scalars .. INTEGER GENID, I, IFAIL, LSEED, LSTATE, SUBID * .. Local Arrays .. DOUBLE PRECISION A(NMIX), WGT(NMIX), X(N) INTEGER SEED(MSEED), STATE(MSTATE) * .. External Subroutines .. EXTERNAL G05KFF, G05SGF * .. Executable Statements .. WRITE (NOUT,*) 'G05SGF Example Program Results' WRITE (NOUT,*) * Set the distribution parameters A and WGT A(1) = 1.0D0 A(2) = 5.0D0 A(3) = 2.0D0 WGT(1) = 0.5D0 WGT(2) = 0.3D0 WGT(3) = 0.2D0 * Initialize the seed to a repeatable sequence 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 20 END IF * Generate the variates IFAIL = 1 CALL G05SGF(N,NMIX,A,WGT,STATE,X,IFAIL) IF (IFAIL.NE.0) THEN WRITE (NOUT,99997) IFAIL GO TO 20 END IF * Display the variates WRITE (NOUT,99999) (X(I),I=1,N) * 20 CONTINUE * 99999 FORMAT (1X,F10.4) 99998 FORMAT (1X,' ** G05KFF returned with IFAIL = ',I5) 99997 FORMAT (1X,' ** G05SGF returned with IFAIL = ',I5) END