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
C
      DO 1000 X=15,85
        DO 1010 T=0,70
C
          IF(X.LT.70) THEN
            AP(K,S2)   =AP(K,S2)   +G(X,T)
            APDUM(K,S2)=APDUM(K,S2)+G(X,T)
          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)
            END IF
          END IF
C
C
C         65〜69歳被保険者数(AP65)
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)
C
          END IF
C
C         70〜歳被保険者数(AP70)
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)
C
          END IF
C
C      最終標準報酬
C
          TMP=0.0D0
          TMR=0.0D0
          IF(S2.EQ.2 .AND. 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
            TMP=G(X,T)*BB(X,T)
          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(X.GE.15 .AND. X.LE.75) THEN
            AX(K,X,S) =AX(K,X,S)+G(X,T)*BB(X,T)
            GX(K,X,S) =GX(K,X,S)+G(X,T)
            IF(X.LT.70) THEN
              AX(K,14,S)=AX(K,14,S)+G(X,T)*BB(X,T)
              GX(K,14,S)=GX(K,14,S)+G(X,T)
            END IF
          END IF
C
C         産休免除導入前年度の調整
C
          IF(FLG_SANKYU.EQ.1 .AND. K.EQ.SANKYUYR-1 .AND.
     &       S2.EQ.2 .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
C         60歳以上の報酬
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) THEN
            IF(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
            END IF
          END IF
C
C         高在老前年の調整
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
 1010   CONTINUE
C
C       パート導入の調整用計算
C
C       適用拡大２段階目（４月施行）前年の調整(人数)
        IF(FLG_PART.GE.2 .AND. PSEID.EQ.0 .AND. S.LE.2 .AND.
     &     K.EQ.PARTYR2-1                                   ) THEN
          APDUM(K,S2)  = APDUM(K,S2)+(LPT2(K,S,X)-LPT1(K,S,X))
          IF(X.GE.65 .AND. X.LE.69) THEN
            AP65DUM(K,S2)= AP65DUM(K,S2)+(LPT2(K,S,X)-LPT1(K,S,X))
          ELSE IF (X.GE.70) THEN
            AP70DUM(K,S2)= AP70DUM(K,S2)+(LPT2(K,S,X)-LPT1(K,S,X))
          END IF
        END IF
C
        IF(FLG_PART.GE.1 .AND. PSEID.EQ.0 .AND. S.LE.2 .AND.
     &     (K.EQ.PARTYR1-1 .OR. K.EQ.PARTYR1)               )THEN
          IF(S.EQ.2 .AND. X.LE.45) THEN
            TMP=LPT1(K,S,X)*BNPT(K,X,S)*AD(K)*(1.0D0-IKUCOE(K))
            TMR=LPT1(K,S,X)*BNPT(K,X,S)*AD(K)*IKUCOE(K)
          ELSE
            TMP=LPT1(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
          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
C
          IF(K.EQ.PARTYR1) 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
          END IF
C
        ELSE IF(FLG_PART.GE.2 .AND. PSEID.EQ.0 .AND. S.LE.2 .AND.
     &          (K.EQ.PARTYR2-1 .OR. K.EQ.PARTYR2)               )THEN
          IF(K.EQ.PARTYR2-1) THEN
            TMQ=DMPT2(X,S)*AD(K)
          ELSE
            TMQ=BNPT(K,X,S)*AD(K)
          END IF
          IF(S.EQ.2 .AND. X.LE.45) THEN
            TMP=(LPT2(K,S,X)-LPT1(K,S,X))*TMQ*(1.0D0-IKUCOE(K))
            TMR=(LPT2(K,S,X)-LPT1(K,S,X))*TMQ*IKUCOE(K)
          ELSE
            TMP=(LPT2(K,S,X)-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
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
          END IF
        END IF
C
 1000 CONTINUE
C
C
      RETURN
C
      END
C
