      PROGRAM HTEST
      PARAMETER (NWPAWC=20000)
      COMMON/PAWC/H(NWPAWC)
      EXTERNAL HTFUN1,HTFUN2
*.------------------------------------------------------------
      CALL HLIMIT(NWPAWC)
*             Book histograms and declare functions
      CALL HBFUN1(101,'Test of HRNDM1',100,0.,1.,HTFUN1)
      CALL HBFUN1(102,'Test of HRNDM1',100,0.,1.,HTFUN2)
      CALL HBOOK1(1,'HISTOGRAM TITLE',10,0.,1.,1000.)
      CALL HBOOK1(2,'HISTOGRAM TITLE',100,0.,1.,1000.)
*             Fill histograms
      DO 10 I=1,720
         X=HRNDM1(101)
         CALL HFILL(1,X,0.,1.)
 10   CONTINUE
      DO 20 I=1,5000
         X=HRNDM1(102)
         CALL HFILL(2,X,0.,1.)
 20   CONTINUE
*             Save all histograms on file HTEST.HBOOK
      CALL HDELET(101)
      CALL HDELET(102)
      CALL HRPUT(0,'HTEST.HBOOK','N')
      CALL HPRINT(0)
      END

      FUNCTION HTFUN1(X)
*             Constants for gaussians
      DATA C1,C2/1.2,0.5/
      DATA XM1,XM2/0.33,0.87/
      DATA XS1,XS2/0.12,0.1/
*             Calculate the gaussians
      A1=-0.5*((X-XM1)/XS1)**2
      A2=-0.5*((X-XM2)/XS2)**2
      X1=C1
      X2=C2
      IF(ABS(A1).GT.0.0001)X1=C1*EXP(A1)
      IF(ABS(A2).GT.0.0001)X2=C2*EXP(A2)
*             Return function value
      HTFUN1=X1+X2
      END

      FUNCTION HTFUN2(X)
*             Constants for gaussians
      DATA C1,C2/1.,0.5/
      DATA XM1,XM2/0.3,0.7/
      DATA XS1,XS2/0.07,0.12/
*             Calculate the gaussians
      A1=-0.5*((X-XM1)/XS1)**2
      A2=-0.5*((X-XM2)/XS2)**2
      X1=C1
      X2=C2
      IF(ABS(A1).GT.0.0001)X1=C1*EXP(A1)
      IF(ABS(A2).GT.0.0001)X2=C2*EXP(A2)
*             Return function value
      HTFUN2=X1+X2
      END
