*...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
*    
*     normal.f
*
*     Copyright (C) 1991.
*
*     Marie Davidian and A. Ronald Gallant 
*     P.O. Box 5513, Raleigh NC 27650-5513, USA   
*
*     Permission to use, copy, modify, and distribute this
*     software and its documentation for any purpose and
*     without fee is hereby granted, provided that the
*     above copyright notice appear in all copies and that
*     both that copyright notice and this permission notice
*     appear in supporting documentation.
*
*     This software is provided "as is" without any
*     expressed or implied warranty.
*
*...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
      subroutine normal(x,O,S,f,fwO,fwS)
      implicit real*8 (a-h,o-z) 
      implicit integer*4 (i-n)
      save
      real*8    x,O,S,f,fwO,fwS,pi,top,bot
      real*8    V,fwV,VwS
      parameter (pi=0.3141592653589793D+01)
      V=S**2
      VwS=2.d0*S
      top=dexp(-0.5d0*(x-O)**2/V)
      bot=dsqrt(2.d0*pi*V)
      f=top/bot
      fwO = top*((x-O)/V)/bot
      fwV = top*(0.5d0*(x-O)**2/(V*V))/bot 
     &      + (-top/(bot*bot))*(0.5d0/bot)*(2.d0*pi)
      fwS=fwV*VwS
      return
      end
