    PROGRAM nag_normal_dist_ex01

      ! Example Program Text for nag_normal_dist
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_normal_dist, ONLY : nag_normal_prob, nag_normal_deviate
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i
      REAL (wp) :: dev, prob, x
      ! .. Local Arrays ..
      CHARACTER (1) :: tail(4)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_normal_dist_ex01'

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) ' Tail    X     Probability     Deviate'
      WRITE (nag_std_out,*)

      x = 1.96_wp
      tail = (/ 'L', 'U', 'C', 'S'/)

      DO i = 1, 4

        prob = nag_normal_prob(tail(i),x)
        dev = nag_normal_deviate(tail(i),prob)

        WRITE (nag_std_out,'(3X,A1,F8.2,2F13.4)') tail(i), x, prob, dev
      END DO

    END PROGRAM nag_normal_dist_ex01
