*     S22AAF Example Program Text
*     Mark 20 Release. NAG Copyright 2001.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          NLMAX
      PARAMETER        (NLMAX=100)
*     .. Local Scalars ..
      DOUBLE PRECISION X
      INTEGER          IFAIL, M, MODE, N, NL
*     .. Local Arrays ..
      DOUBLE PRECISION P(0:NLMAX)
*     .. External Subroutines ..
      EXTERNAL         S22AAF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'S22AAF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
      READ (NIN,*) MODE, X, M, NL
      WRITE (NOUT,*)
      IFAIL = 0
*
      CALL S22AAF(MODE,X,M,NL,P,IFAIL)
*
      WRITE (NOUT,*) 'MODE      X      M    NL   IFAIL'
      WRITE (NOUT,*)
      WRITE (NOUT,99999) MODE, X, M, NL, IFAIL
      WRITE (NOUT,*)
      IF (MODE.EQ.1) THEN
         IF (M.EQ.0) THEN
            WRITE (NOUT,*) 'Unnormalized Legendre function values'
         ELSE
            WRITE (NOUT,*)
     +        'Unnormalized associated Legendre function values'
         END IF
      ELSE IF (MODE.EQ.2) THEN
         IF (M.EQ.0) THEN
            WRITE (NOUT,*) 'Normalized Legendre function values'
         ELSE
            WRITE (NOUT,*)
     +        'Normalized associated Legendre function values'
         END IF
      END IF
      WRITE (NOUT,*) ' n      P(n)'
      DO 20 N = 0, NL
         WRITE (NOUT,99998) N, P(N)
   20 CONTINUE
*
      STOP
*
99999 FORMAT (1X,I3,4X,F5.1,3I6)
99998 FORMAT (1X,I2,1X,1P,E12.4)
      END
