C
C     **************************************************
C     **                                              **
C     **           被保険者及び待期者の集計           **
C     **                                              **
C     **************************************************
C
C
      SUBROUTINE   SHKEHIHO
C
C
      IMPLICIT INTEGER (A-Z)
      INCLUDE 'seps.inc'
      INCLUDE 'shke.inc'
C
      COMMON /K/ K
      COMMON /S/ S,S2
C
C
      REAL*8 TMP,TMQ,TMR,TMS
C
      DO 1000 X=15,85
        DO 1010 T=0,70
C
          GEE(K,S2,X,T)      = G(X,T)
          GEEPT(K,S2,X,T)    = GPT(X,T)
C
          IF(X.LT.70) THEN
            AP(K,S2)   =AP(K,S2)   +G(X,T)
            APDUM(K,S2)=APDUM(K,S2)+G(X,T)
            IF(PSEID.EQ.0 .AND. S.LE.2 .AND. K.GE.PARTYR1)THEN
              APPART(K,S2) =APPART(K,S2)+GPT(X,T)
              APPARTDUM(K,S2) =APPARTDUM(K,S2)+GPT(X,T)
            END IF
          ELSE IF(X.GE.70) THEN
            IF(XEND.GT.70) THEN
              AP(K,S2)   =AP(K,S2)   +G(X,T)
              APDUM(K,S2)=APDUM(K,S2)+G(X,T)
              IF(PSEID.EQ.0 .AND. S.LE.2 .AND. K.GE.PARTYR1)THEN
                APPART(K,S2) =APPART(K,S2)+GPT(X,T)
                APPARTDUM(K,S2) =APPARTDUM(K,S2)+GPT(X,T)
              END IF
            END IF
          END IF
C
          IF(X.GE.65 .AND. X.LE.69) THEN
            AP65(K,S2)   =AP65(K,S2)   +G(X,T)
            AP65DUM(K,S2)=AP65DUM(K,S2)+G(X,T)
            IF(PSEID.EQ.0 .AND. S.LE.2 .AND. K.GE.PARTYR1)THEN
              APPART65(K,S2)   =APPART65(K,S2)   +GPT(X,T)
              APPART65DUM(K,S2)=APPART65DUM(K,S2)+GPT(X,T)
            END IF
          END IF
C
          IF(XEND.GT.70 .AND. X.GE.70) THEN
            AP70(K,S2)   =AP70(K,S2)   +G(X,T)
            AP70DUM(K,S2)=AP70DUM(K,S2)+G(X,T)
            IF(PSEID.EQ.0 .AND. S.LE.2 .AND. K.GE.PARTYR1)THEN
              APPART70(K,S2)   =APPART70(K,S2)   +GPT(X,T)
              APPART70DUM(K,S2)=APPART70DUM(K,S2)+GPT(X,T)
            END IF
          END IF
C
          IF(XEND.GT.75 .AND. X.GE.75) THEN
            AP75(K,S2)   =AP75(K,S2)   +G(X,T)
            AP75DUM(K,S2)=AP75DUM(K,S2)+G(X,T)
            IF(PSEID.EQ.0 .AND. S.LE.2 .AND. K.GE.PARTYR1)THEN
              APPART75(K,S2)   =APPART75(K,S2)   +GPT(X,T)
              APPART75DUM(K,S2)=APPART75DUM(K,S2)+GPT(X,T)
            END IF
          END IF
C
C
          TMP=0.0D0
          TMR=0.0D0
          IF(X.LE.45) THEN
            TMP=G(X,T)*BB(X,T)*(1.0D0-IKUCOE(K))
            TMR=G(X,T)*BB(X,T)*IKUCOE(K)
          ELSE IF(
     &      (                    FLG_HIHO70.EQ.0.AND.X.LT.70).OR.
     &      (K.LE.HIHO70YR-1.AND.FLG_HIHO70.GE.1.AND.X.LT.70).OR.
     &      (K.GE.HIHO70YR  .AND.FLG_HIHO70.EQ.1.AND.X.LT.75)
     &    )THEN
            TMP=G(X,T)*BB(X,T)
          ELSE IF(K.EQ.HIHO70YR-1 .AND.
     &            (FLG_HIHO70.GE.1 .AND. X.GE.70 .AND. X.LT.75)) THEN
            TMS=G(X,T)*BB(X,T) * 5.0D0 / 6.0D0
          END IF
          IF(X.LT.65) THEN
            A(K,S2)   =A(K,S2)   +TMP
            ADUM(K,S2)=ADUM(K,S2)+TMP
            AIKU(K,S2)=AIKU(K,S2)+TMR
            AIKUDUM(K,S2)=AIKUDUM(K,S2)+TMR
          ELSE IF(X.GE.65 .AND. X.LT.70) THEN
            IF(XEND.GT.65) THEN
              A(K,S2)   =A(K,S2)   +TMP
              ADUM(K,S2)=ADUM(K,S2)+TMP
            END IF
          ELSE
            IF(XEND.GT.70) THEN
              A(K,S2)   =A(K,S2)   +TMP
              ADUM(K,S2)=ADUM(K,S2)+TMP
            END IF
          END IF
C
          IF(FLG_SANKYU.EQ.1 .AND. K.EQ.SANKYUYR-1 .AND. X.LE.45) THEN
            TMQ=G(X,T)*BB(X,T)*(IKUCOE(K+1)-IKUCOE(K))
            ADUM(K,S2)=ADUM(K,S2)-TMQ
            AIKUDUM(K,S2)=AIKUDUM(K,S2)+TMQ
          END IF
C
          IF(X.LT.70) THEN
            IF(X.GE.60) THEN
              A60(K,S2)=A60(K,S2)+TMP
              A60DUM(K,S2)=A60DUM(K,S2)+TMP
            END IF
            IF(X.GE.65) THEN
              A65(K,S2)=A65(K,S2)+TMP
              A65DUM(K,S2)=A65DUM(K,S2)+TMP
            END IF
          ELSE IF(X.GE.70 .AND. XEND.GT.70) THEN
            A60(K,S2)=A60(K,S2)+TMP
            A65(K,S2)=A65(K,S2)+TMP
            A70(K,S2)=A70(K,S2)+TMP
            A60DUM(K,S2)=A60DUM(K,S2)+TMP
            A65DUM(K,S2)=A65DUM(K,S2)+TMP
            A70DUM(K,S2)=A70DUM(K,S2)+TMP
            IF(X.GE.75 .AND. XEND.GT.75) THEN
              A75(K,S2)=A75(K,S2)+TMP
              A75DUM(K,S2)=A75DUM(K,S2)+TMP
            END IF
          END IF
C
          IF(K.EQ.KOZAEXYR-1 .AND. X.GE.70) THEN
            IF(XEND.LE.70) THEN
              A60DUM(K,S2)=A60DUM(K,S2)+TMP
              A65DUM(K,S2)=A65DUM(K,S2)+TMP
              A70DUM(K,S2)=A70DUM(K,S2)+TMP
            END IF
          END IF
C
          IF(K.EQ.HIHO70YR-1 .AND. FLG_HIHO70.GE.1 .AND. X.GE.70) THEN
            ADUM(K,S2)=ADUM(K,S2)+TMS
            A60DUM(K,S2)=A60DUM(K,S2)+TMS
            A65DUM(K,S2)=A65DUM(K,S2)+TMS
            A70DUM(K,S2)=A70DUM(K,S2)+TMS
            IF(X.GE.75 .AND. XEND.GT.75)THEN
              A75DUM(K,S2)=A75DUM(K,S2)+TMS
            END IF
          END IF
C
 1010   CONTINUE
C
C
        IF(FLG_PART.GE.1 .AND. PSEID.EQ.0 .AND. S.LE.2 .AND.
     &     K.EQ.PARTYR2-1                                   ) THEN
          APDUM(K,S2)  = APDUM(K,S2)+LPT1(K,S,X)
          APPARTDUM(K,S2)  = APPARTDUM(K,S2)+LPT1(K,S,X)
          IF(X.GE.65 .AND. X.LE.69) THEN
            AP65DUM(K,S2)= AP65DUM(K,S2)+LPT1(K,S,X)
            APPART65DUM(K,S2)= APPART65DUM(K,S2)+LPT1(K,S,X)
          ELSE IF (X.GE.70) THEN
            AP70DUM(K,S2)= AP70DUM(K,S2)+LPT1(K,S,X)
            APPART70DUM(K,S2)= APPART70DUM(K,S2)+LPT1(K,S,X)
          ELSE IF (X.GE.75) THEN
            AP75DUM(K,S2)= AP75DUM(K,S2)+LPT1(K,S,X)
            APPART75DUM(K,S2)= APPART75DUM(K,S2)+LPT1(K,S,X)
          END IF
        END IF
C
        IF(KIJUN.LT.PARTYR1) THEN
        IF(PSEID.EQ.0 .AND. S.LE.2 .AND. K.EQ.PARTYR1) THEN
          IF(X.LE.45) THEN
            TMP=LPT(K,S,X)*BNPT(K,X,S)*AD(K)*(1.0D0-IKUCOE(K))
            TMR=LPT(K,S,X)*BNPT(K,X,S)*AD(K)*IKUCOE(K)
          ELSE
            TMP=LPT(K,S,X)*BNPT(K,X,S)*AD(K)
            TMR=0.0D0
          END IF
          APART(K,S)      =APART(K,S)   +TMP
          AIKUPART(K,S)   =AIKUPART(K,S)+TMR
          ADUM(K,S)       =ADUM(K,S)-TMP
          AIKUDUM(K,S)    =AIKUDUM(K,S)-TMR
          IF(X.GE.60) THEN
            A60PART(K,S)=A60PART(K,S)+TMP
            A60DUM(K,S)=A60DUM(K,S)-TMP
          END IF
          IF(X.GE.65) THEN
            A65PART(K,S)=A65PART(K,S)+TMP
            A65DUM(K,S)=A65DUM(K,S)-TMP
          END IF
          IF(X.GE.70) THEN
            A70PART(K,S)=A70PART(K,S)+TMP
            A70DUM(K,S)=A70DUM(K,S)-TMP
          END IF
          IF(X.GE.75) THEN
            A75PART(K,S)=A75PART(K,S)+TMP
            A75DUM(K,S)=A75DUM(K,S)-TMP
          END IF
        END IF
        END IF
C
        IF(FLG_PART.GE.1 .AND. PSEID.EQ.0 .AND. S.LE.2 .AND.
     &          (K.EQ.PARTYR2-1 .OR. K.EQ.PARTYR2)               )THEN
          TMQ=DMPT2(K,X,S)*AD(K)
          IF(X.LE.45) THEN
            TMP=LPT1(K,S,X)*TMQ*(1.0D0-IKUCOE(K))
            TMR=LPT1(K,S,X)*TMQ*IKUCOE(K)
          ELSE
            TMP=LPT1(K,S,X)*TMQ
            TMR=0.0D0
          END IF
          APART(K,S)   =APART(K,S)   +TMP
          AIKUPART(K,S)=AIKUPART(K,S)+TMR
          IF(X.GE.60) A60PART(K,S)=A60PART(K,S)+TMP
          IF(X.GE.65) A65PART(K,S)=A65PART(K,S)+TMP
          IF(X.GE.70) A70PART(K,S)=A70PART(K,S)+TMP
          IF(X.GE.75) A75PART(K,S)=A75PART(K,S)+TMP
C
          IF(K.EQ.PARTYR2) THEN
            ADUM(K,S2)=ADUM(K,S2)-TMP
            AIKUDUM(K,S2)=AIKUDUM(K,S2)-TMR
            IF(X.GE.60) A60DUM(K,S)=A60DUM(K,S)-TMP
            IF(X.GE.65) A65DUM(K,S)=A65DUM(K,S)-TMP
            IF(X.GE.70) A70DUM(K,S)=A70DUM(K,S)-TMP
            IF(X.GE.75) A75DUM(K,S)=A75DUM(K,S)-TMP
          END IF
        END IF
C
 1000 CONTINUE
C
C
      RETURN
C
      END
C
