C---------------------------------------------------------------C
C  FUNCTION GH1D INTEGRATES WITH RESPECT TO NORMAL DENSITY      C
C  VARIABLES:                                                   C
C    IMC = 12 FOR 2-SIDED MCA                                   C
C        = 21     1-SIDED MCB                                   C
C        = 31     1-SIDED MCC  (SAME AS 1-SIDED MCB)            C
C        = 32     2-SIDED MCC                                   C
C    K   = NUMBER OF TREATMENTS (PASSED ONTO INSIDE INTEGRAL)   C
C    D   = CRITICAL VALUE       (PASSED ONTO INSIDE INTEGRAL)   C
C    S   = CHI/SQRT(NU) VARIABLE(PASSED ONTO INSIDE INTEGRAL)   C
C  LAST REVISION: 05-28-88 BY WCS FOR VECTOR PROCESSING         C
C---------------------------------------------------------------C
      DOUBLEPRECISION FUNCTION GH1D(IMC,K,D,S)
      IMPLICIT DOUBLE PRECISION(A-H,O-Z)
C6    IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION A(100),B(100),C(100)
      DIMENSION PH(48),WH(48),WHLN(48),ZH(48)
      DIMENSION XN(96),VCDFN(96)
      DIMENSION VFMC(48)
      COMMON/LIST2/A,B,C
      COMMON/LIST6/PH,WH,ZH,WHLN
      COMMON/LIST8/ZERO,ZSR,ZLOG,ZLN
      COMMON/LIST9/SR2,PI,SRPI,PIB2
C
      KM1=K-1
      F= 0.0D0
      M=48
      DO 100 I=1,M
        VFMC(I)=1.0D0
 100  CONTINUE
      DTS=D*S
      DO 400 J=1,KM1
        IF (IMC.EQ.21) GOTO 210
        IF (IMC.EQ.12) GOTO 120
          DO 320 I=1,M
            AZH=A(J)*ZH(I)
            XN(I)=-(AZH+DTS)*C(J)
            XN(I+M)=-(AZH-DTS)*C(J)
 320      CONTINUE
          GOTO 250
 120      M=48
          DO 122 I=1,M
            AZH=A(J)*ZH(I)
            XN(I)=-AZH*C(J)
            XN(I+M)=-(AZH-DTS)*C(J)
 122      CONTINUE
          GOTO 250
C
 210      M=M
          DO 230 I=1,M
            AZH=A(J)*ZH(I)
            XN(I)=-(AZH+DTS)*C(J)
 230      CONTINUE
          GOTO 250
C       ----------------------------------------------------
C       NCDFV COMPUTES THE UPPER TAIL AREA OF A N(O,1) CURVE
C       ----------------------------------------------------
 250    CALL NCDFV(M,XN,VCDFN)
C       ---------------------------------
C       COMPUTE VALUES OF INTEGRAND: VMCC
C       --------------------------------- 
 280    IF (IMC.EQ.21) GOTO 340
          DO 300 I=1,M
            VFMC(I)=VFMC(I)*(VCDFN(I)-VCDFN(I+M))
 300      CONTINUE
          GOTO 400
 340      DO 350 I=1,M
            VFMC(I)=VFMC(I)*VCDFN(I)
 350      CONTINUE
C
  400 CONTINUE
C         ----------------------
C         COMPUTE SUM OF WH*VMCC
C         ----------------------
  450 DO 500 I=1,M
        F=F+VFMC(I)*WH(I)
  500 CONTINUE     
      IF (IMC.EQ.12) F=DFLOAT(K)*F
C
      GH1D=F/SRPI
C
      RETURN
      END
