PROGRAM g01aefe ! G01AEF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : g01aef, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: xmax, xmin INTEGER :: iclass, ifail, j, k, n ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: cb(:), x(:) INTEGER, ALLOCATABLE :: ifreq(:) ! .. Executable Statements .. WRITE (nout,*) 'G01AEF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Read in the problem size READ (nin,*) n, iclass, k ALLOCATE (x(n),cb(k),ifreq(k)) ! Read in data READ (nin,*) x(1:n) WRITE (nout,99997) 'Number of cases', n WRITE (nout,99997) 'Number of classes', k ! Get the class boundaries IF (iclass/=1) THEN WRITE (nout,*) 'Routine-supplied class boundaries' ELSE READ (nin,*) cb(1:(k-1)) WRITE (nout,*) 'User-supplied class boundaries' END IF WRITE (nout,*) ! Construct the frequency table ifail = 0 CALL g01aef(n,k,x,iclass,cb,ifreq,xmin,xmax,ifail) ! Display results WRITE (nout,*) '*** Frequency distribution ***' WRITE (nout,*) WRITE (nout,*) ' Class Frequency' WRITE (nout,*) WRITE (nout,99999) ' Up to ', cb(1), ifreq(1) k = k - 1 IF (k>1) THEN WRITE (nout,99998) (cb(j-1),' to ',cb(j),ifreq(j),j=2,k) END IF WRITE (nout,99996) cb(k), ' and over ', ifreq(k+1) WRITE (nout,*) WRITE (nout,99995) 'Total frequency = ', n WRITE (nout,99994) 'Minimum = ', xmin WRITE (nout,99994) 'Maximum = ', xmax 99999 FORMAT (1X,A,F8.2,I11) 99998 FORMAT (1X,F8.2,A,F8.2,I11) 99997 FORMAT (1X,A,I4) 99996 FORMAT (1X,F8.2,A,I9) 99995 FORMAT (1X,A,I6) 99994 FORMAT (1X,A,F9.2) END PROGRAM g01aefe