Program g05ncfe ! G05NCF Example Program Text ! Mark 24 Release. NAG Copyright 2012. ! .. Use Statements .. Use nag_library, Only: g05kff, g05ncf ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: lseed = 1, nin = 5, nout = 6 ! .. Local Scalars .. Integer :: genid, i, ifail, j, lstate, n, & nperm, subid ! .. Local Arrays .. Integer, Allocatable :: indx(:), state(:) Integer :: seed(lseed) ! .. Executable Statements .. Write (nout,*) 'G05NCF Example Program Results' Write (nout,*) ! Skip heading in data file Read (nin,*) ! Read in the base generator information and seed Read (nin,*) genid, subid, seed(1) ! Initial call to initialiser to get size of STATE array lstate = 0 Allocate (state(lstate)) ifail = 0 Call g05kff(genid,subid,seed,lseed,state,lstate,ifail) ! Reallocate STATE Deallocate (state) Allocate (state(lstate)) ! Initialize the generator to a repeatable sequence ifail = 0 Call g05kff(genid,subid,seed,lseed,state,lstate,ifail) ! Read in sample size and number of permutations Read (nin,*) n, nperm Allocate (indx(n)) Write (nout,99998) nperm, ' Permutations of first ', n, ' integers' Write (nout,*) ! Permutate NPERM times Do j = 1, nperm ! Set up the index vector Do i = 1, n indx(i) = i End Do ! Call the permutation routine ifail = 0 Call g05ncf(indx,n,state,ifail) ! Display the results Write (nout,99999) indx(1:n) End Do 99999 Format (1X,8I3) 99998 Format (1X,I0,A,I0,A) End Program g05ncfe