C
C     ************************************************
C     **                                            **
C     **      Ｋ年度、Ｘ歳、被保険者期間Ｔ年の      **
C     **      被保険者データ(期間、報酬)を作成      **
C     **                                            **
C     ************************************************
C
C
      SUBROUTINE      SIMLBZW(X,T)
C
      IMPLICIT INTEGER (A-Z)
      INCLUDE 'seps.inc'
      INCLUDE 'siml.inc'
C
C
      COMMON /K/ K
      COMMON /S/ S,S2
C
      REAL*8 TM(0:4)
      REAL*8 BB0,BBNP0,BBPT0
      REAL*8 Z0(0:1),ZE0(0:1)
      REAL*8 W0,WE0
      REAL*8 CHS,CH9,CHT
      REAL*8 TMP,TMQ
      REAL*8 BBDUM,BBNPDUM,BBPTDUM
      REAL*8 BB0DUM,BBNP0DUM,BBPT0DUM,BNDUM,BNPTDUM
C
C-----------------------------------------------------
C     最終年額報酬の設定(BB)
C-----------------------------------------------------
      BB0=BB(X-1,T-1)
      IF(K.GT.PARTYR1 .AND. PSEID.EQ.0 .AND. S.LE.2) THEN
        BBNP0=BBNP(X-1,T-1)
        BBPT0=BBPT(X-1,T-1)
      ELSE
        BBNP0=BB0
      END IF
C
      IF(K.GE.PARTYR1 .AND. PSEID.EQ.0 .AND. S.LE.2) THEN
        IF(G(X,T)-GPT(X,T).GT.1.0D-6) THEN
          IF(X.NE.15) THEN
            BBNP(X,T)=(BN(K,X,S)*AD(K)*(GN(X,T)-GNPT(X,T))
     &                 +BBNP0*BR(K,X,S)/BR(K-1,X-1,S)*(1.0D0+H(K))
     &                   *(GZ(X,T)-GZPT(X,T)))
     &                /(G(X,T)-GPT(X,T))
          ELSE
            BBNP(X,T)=BN(K,X,S)*AD(K)
          END IF
        ELSE
          BBNP(X,T)=0.0D0
        END IF
C
        IF(GPT(X,T).GT.1.0D-6) THEN
          IF(X.NE.15) THEN
            BBPT(X,T)=(BNPT(K,X,S)*AD(K)*GNPT(X,T)
     &                 +BBPT0*(1.0D0+H(K))*GZPT(X,T))
     &                /GPT(X,T)
          ELSE
            BBPT(X,T)=BNPT(K,X,S)*AD(K)
          END IF
        ELSE
          BBPT(X,T)=0.0D0
        END IF
C
        IF(X.EQ.XEND) THEN
          BBNP(X,T)=BBNP0*BR(K,X,S)/BR(K-1,X-1,S)*(1.0D0+H(K))
          BBPT(X,T)=BBPT0*(1.0D0+H(K))
        END IF
C
        IF(G(X,T).GT.1.0D-6) THEN
          BB(X,T)=(BBNP(X,T)*(G(X,T)-GPT(X,T))+BBPT(X,T)*GPT(X,T))
     &            /G(X,T)
        ELSE
          BB(X,T)=0.0D0
        END IF
      ELSE
        IF(G(X,T).GT.1.0D-6) THEN
          IF(X.NE.15) THEN
            BB(X,T)=(BN(K,X,S)*AD(K)*GN(X,T)
     &       +BB0*BR(K,X,S)/BR(K-1,X-1,S)*(1.0D0+H(K))*GZ(X,T))/G(X,T)
          ELSE
            BB(X,T)=BN(K,X,S)*AD(K)
          END IF
        ELSE
          BB(X,T)=0.0D0
        END IF
        IF(X.EQ.XEND) BB(X,T)=BB0*BR(K,X,S)/BR(K-1,X-1,S)*(1.0D0+H(K))
      END IF
C
C-----------------------------------------------------
C     被保険者期間年数の設定(Z,ZE,PSZ,PSZE)
C-----------------------------------------------------
      DX=60
      IF(FLG_SIGO.EQ.1) THEN
        DX=20+MAX(NINT(CAN(MAX(K-X,-74))),40)
      END IF
C
      HIHONEN = 70
      IF(K.GE.HIHO70YR .AND. FLG_HIHO70.EQ.1) THEN
        HIHONEN = 75
      END IF
C
      DO 1000 J=0,6
        DO 1010 I=0,1
          Z0(I)=Z(X-1,T-1,I,J)
          IF(T.EQ.TEND-1 .AND. Z0(I).LE.1.0D-6) Z0(I)=Z(X-1,T,I,J)
C
          ZE0(I)=ZE(X-1,T,I,J)
C
          TM(1)=GN(X,T) *ZE0(I)+GZ(X,T) *Z0(I)
          TM(2)=GEZ(X,T)*ZE0(I)+Y(X,T,1)*Z0(I)
C
          IF(X.LE.HIHONEN .AND. (J.EQ.0 .OR. J.EQ.4 .OR.
     &         (S.EQ.1 .AND. X.GE.40 .AND. J.EQ.5) .OR.
     &         (S.GE.2 .AND. X.GE.35 .AND. J.EQ.5) .OR.
     &         (X.GE.20.AND. X.LE.DX .AND. J.EQ.6)    )    ) THEN
C
            IF(I.EQ.0 .OR. (S.EQ.3 .AND. I.EQ.1)) THEN
C
              IF((S.EQ.1 .AND. X.EQ.40  .AND. J.EQ.5) .OR.
     &           (S.GE.2 .AND. X.EQ.35  .AND. J.EQ.5) .OR.
     &           ((X.EQ.20 .OR. X.EQ.DX).AND. J.EQ.6) .OR.
     &           X.EQ.HIHONEN                              ) THEN
                TM(0)=GZ(X,T)/2.0D0+GN(X,T)/2.0D0
              ELSE
                TM(0)=GZ(X,T)      +GN(X,T)/2.0D0
                IF(PSEID.EQ.0 .AND. FLG_PART.GE.1 .AND. S.LE.2
     &             .AND. K.EQ.PARTYR2 .AND. LPT(K,S,X).GE.1.0D-6) THEN
                  TM(0)=TM(0)+LPT1(K,S,X)*GPT(X,T)/LPT(K,S,X)/2.0D0
                END IF
              END IF
C
              TM(1)=TM(1)+TM(0)
C
              IF((S.EQ.1 .AND. X.EQ.40 .AND. J.EQ.5) .OR.
     &           (S.GE.2 .AND. X.EQ.35 .AND. J.EQ.5) .OR.
     &           (             X.EQ.20 .AND. J.EQ.6)    ) THEN
                TM(0)=0.0D0
              ELSE
                TM(0)=Y(X,T,1)/2.0D0
              END IF
C
              TM(2)=TM(2)+TM(0)
C
            END IF
          END IF
C
          Z(X,T,I,J) =0.0D0
          ZE(X,T,I,J)=0.0D0
C
          IF(G(X,T) .GT.1.0D-6) Z(X,T,I,J) =TM(1)/G(X,T)
          IF(GE(X,T).GT.1.0D-6) ZE(X,T,I,J)=TM(2)/GE(X,T)
 1010   CONTINUE
 1000 CONTINUE
C
C-----------------------------------------------------
C     標準報酬累計の設定(W,WE)
C-----------------------------------------------------
      DO 2000 II=0,3
C
        IF(II.EQ.0) THEN
          IF(X.LE.67) THEN
            CHS=1.0D0+HH(K)
          ELSE
            CHS=1.0D0+CI(K)
          END IF
          CH9=1.0D0+H(K)
C
          IF(CHT_FLG.EQ.1) THEN
            KK=MIN(K,KE-3)
            CHT=DIR(K)*(1.0D0+CI0(KK-1+2))*(1.0D0+CI0(KK-1+3))
C
            IF(X.LE.64) THEN
              CHT=CHT/(1.0D0+HH(KK+1))/(1.0D0+HH(KK+2))/(1.0D0+HH(KK+3))
            ELSE IF(X.EQ.65) THEN
              CHT=CHT/(1.0D0+HH(KK+1))/(1.0D0+HH(KK+2))/(1.0D0+CI(KK+3))
            ELSE IF(X.EQ.66) THEN
              CHT=CHT/(1.0D0+HH(KK+1))/(1.0D0+CI(KK+2))/(1.0D0+CI(KK+3))
            ELSE
              CHT=CHT/(1.0D0+CI(KK+1))/(1.0D0+CI(KK+2))/(1.0D0+CI(KK+3))
            END IF
C
          ELSE
C
            CHT=0.98D0
            DO 2010 KK=5,K
              CHT=CHT*(1.0D0+HH(KK))/(1.0D0+H(KK))
 2010       CONTINUE
            IF(X.GT.67) THEN
              DO 2011 KK=0,MIN(K-5,X-68)
                CHT=CHT*(1.0D0+CI(K-KK))/(1.0D0+HH(K-KK))
 2011         CONTINUE
            END IF
          END IF
        ELSE IF(II.EQ.1) THEN
          CHS=1.0D0
          CH9=1.0D0+H(K)
          CHT=1.0D0
        ELSE IF(II.EQ.2) THEN
          CHS=1.0D0+CI2(K,MAX(X,67))
          CH9=1.0D0+H(K)
C
          IF(CHT_FLG.EQ.1) THEN
            CHT=JZ_SHK(K)*1.031D0*0.988D0
            DO 2012 KK=5,K
              CHT=CHT*(1.0D0+CI2(KK,MAX(X-K+KK,67)))
 2012       CONTINUE
          ELSE
            CHT=0.917D0*1.031D0*0.988D0
            DO 2013 KK=5,K
              CHT=CHT*(1.0D0+CI2(KK,MAX(X-K+KK,67)))/(1.0D0+H(KK))
 2013       CONTINUE
          END IF
        ELSE IF(II.EQ.3) THEN
          CHS=1.0D0+HH(K)
          CH9=1.0D0+H(K)
          IF(CHT_FLG.EQ.1) THEN
            KK=MIN(K,KE-3)
            CHT=DIR(K)*(1.0D0+CI0(KK-1+2))*(1.0D0+CI0(KK-1+3))
     &               /(1.0D0+HH(KK+1))/(1.0D0+HH(KK+2))/(1.0D0+HH(KK+3))
          ELSE
            CHT=0.98D0
            DO 2014 KK=5,K
              CHT=CHT*(1.0D0+HH(KK))/(1.0D0+H(KK))
 2014       CONTINUE
          END IF
        END IF
C
        IF(K-X.GE.-62) THEN
          CHT=CHT*0.991D0*0.998D0
        ELSE
          CHT=CHT*0.991D0
        END IF
        CHWD(X,T,II) =BB(X,T) /2.0D0*CHT
        IF(FLG_HIHO70.EQ.0 .OR. K.LT.HIHO70YR) THEN
          IF(PSEID.EQ.0) THEN
            IF(KOZAIEX2.EQ.0 .AND. X.GE.HIHONEN) THEN
              CHWD(X,T,II)  =0.0D0
            END IF
          END IF
        END IF
C
        IF(HOUJOU.EQ.1) THEN
          IF(K.EQ.HOUJOUYR) THEN
            CHT=CHT*(1.0D0+(HOUJOUR-1.0D0)*1.0D0/2.0D0)
          ELSE IF(K.GT.HOUJOUYR) THEN
            CHT=CHT*HOUJOUR
          END IF
        END IF
C
        IF((CHT_FLG.EQ.0 .OR. (S.EQ.2 .AND. X.GE.20 .AND. X.LE.44))
     &                                        .AND.  K.GE.JIIKU2YR) THEN
          CHT=CHT*(1.0D0+JIIKU)
        END IF
C
        W(X,T,0,0,II) =0.0D0
        WE(X,T,0,0,II)=0.0D0
C
        DO 2030 J=1,4
C
          W0=W(X-1,T-1,0,J,II)
          IF(T.EQ.TEND-1 .AND. W0.LE.1.0D-6) W0=W(X-1,T,0,J,II)
C
          WE0=WE(X-1,T,0,J,II)
C
          TMP=GN(X,T) *WE0+GZ(X,T) *W0
          TMQ=GEZ(X,T)*WE0+Y(X,T,1)*W0
C
          TM(1)=TMP*CHS
          TM(2)=TMQ*CHS
C
          IF(J.LE.3) GO TO 2060
C
          IF(PSEID.EQ.0) THEN
            IF(KOZAIEX2.EQ.0 .AND. X.GE.HIHONEN) THEN
              IF(FLG_HIHO70.GE.1 .AND.
     &           K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1) THEN
                BNDUM = BN(K,X,S)
                IF(S.LE.2) THEN
                  BNPTDUM = BNPT(K,X,S)
                END IF
              END IF
              BN(K,X,S) = 0.0D0
              IF(S.LE.2) THEN
                BNPT(K,X,S) = 0.0D0
              END IF
            END IF
          END IF
            
          IF(K.GE.PARTYR1 .AND. PSEID.EQ.0 .AND. S.LE.2) THEN
            TM(1)=TM(1)+(BN(K,X,S)*AD(K)*(GN(X,T)-GNPT(X,T))
     &                  +BNPT(K,X,S)*AD(K)*GNPT(X,T))/2.0D0*CHT
C
            IF(FLG_PART.GE.1 .AND. K.EQ.PARTYR2 .AND.
     &         LPT(K,S,X).GE.1.0D-6                   ) THEN
              TM(1)=TM(1)+LPT1(K,S,X)*GPT(X,T)/LPT(K,S,X)
     &                    *BNPT(K,X,S)*AD(K)/2.0D0*CHT
            END IF
C
            IF(X.GT.15) THEN
              IF(PSEID.EQ.0) THEN
                IF(KOZAIEX2.EQ.0 .AND. X.GE.HIHONEN) THEN
                  IF(FLG_HIHO70.GE.1 .AND.
     &               K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1) THEN
                    BBDUM   = BB(X,T)
                    BBNPDUM = BBNP(X,T)
                    BBPTDUM = BBPT(X,T)
                    IF(X.GE.HIHONEN+1) THEN
                      BBNP0DUM     = BBNP0
                      BBPT0DUM     = BBPT0
                    END IF
                  END IF
                  BB(X,T)   = 0.0D0
                  BBNP(X,T) = 0.0D0
                  BBPT(X,T) = 0.0D0
                  IF(X.GE.HIHONEN+1) THEN
                    BBNP0 = 0.0D0
                    BBPT0 = 0.0D0
                  END IF
                END IF
              END IF
              TMP=(BBNP0*CH9+BBNP(X,T))/2.0D0*(GZ(X,T)-GZPT(X,T))
     &           +(BBPT0*CH9+BBPT(X,T))/2.0D0*GZPT(X,T)
              TMQ=( BBNP0*CH9*(Y(X,T,1)-YPT(X,T,1))
     &             +BBPT0*CH9*YPT(X,T,1)           )/2.0D0
              TM(1)=TM(1)+TMP*CHT
              TM(2)=TM(2)+TMQ*CHT
              IF(PSEID.EQ.0 .AND. KOZAIEX2.EQ.0 .AND.
     &           K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1 .AND.
     &           X.GE.HIHONEN.AND. FLG_HIHO70.EQ.1 .AND. X.LT.75) THEN
                BB(X,T)   = BBDUM
                BBNP(X,T) = BBNPDUM
                BBPT(X,T) = BBPTDUM
                IF(X.GE.HIHONEN+1) THEN
                  BBNP0 = BBNP0DUM
                  BBPT0 = BBPT0DUM
                END IF
              END IF
            END IF
          ELSE
            TM(1)=TM(1)+BN(K,X,S)*AD(K)/2.0D0*GN(X,T)*CHT
            IF(X.GT.15) THEN
              IF(PSEID.EQ.0) THEN
                IF(KOZAIEX2.EQ.0 .AND. X.GE.HIHONEN) THEN
                  IF(FLG_HIHO70.GE.1 .AND.
     &               K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1) THEN
                    BBDUM = BB(X,T)
                    IF(X.GE.HIHONEN+1) THEN
                      BB0DUM = BB0
                    END IF
                  END IF
                  BB(X,T) = 0.0D0
                  IF(X.GE.HIHONEN+1) THEN
                    BB0     = 0.0D0
                  END IF
                END IF
              END IF
C
              TMP=(BB0*CH9+BB(X,T))/2.0D0*GZ(X,T)
              TMQ= BB0*CH9         /2.0D0*Y(X,T,1)
C
              TM(1)=TM(1)+TMP*CHT
              TM(2)=TM(2)+TMQ*CHT
C
              IF(PSEID.EQ.0 .AND. KOZAIEX2.EQ.0 .AND.
     &           K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1 .AND.
     &           X.GE.HIHONEN .AND. FLG_HIHO70.EQ.1 .AND. X.LT.75) THEN
                BB(X,T) = BBDUM
                IF(X.GE.HIHONEN+1) THEN
                  BB0 = BB0DUM
                END IF
              END IF
            END IF
          END IF

          IF(PSEID.EQ.0 .AND. KOZAIEX2.EQ.0 .AND.
     &       K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1 .AND.
     &       X.GE.HIHONEN .AND. FLG_HIHO70.EQ.1 .AND. X.LT.75) THEN
            BN(K,S,X) = BNDUM
            IF(S.LE.2) THEN
              BNPT(K,X,S) = BNPTDUM
            END IF
          END IF
C
 2060     CONTINUE
C
C
          W(X,T,0,J,II) =0.0D0
          WE(X,T,0,J,II)=0.0D0
C
          IF(G(X,T) .GT.1.0D-6) W(X,T,0,J,II) =TM(1)/G(X,T)
          IF(GE(X,T).GT.1.0D-6) WE(X,T,0,J,II)=TM(2)/GE(X,T)
C
          IF(J.LE.3) THEN
            W(X,T,0,0,II) =W(X,T,0,0,II) +W(X,T,0,J,II)
            WE(X,T,0,0,II)=WE(X,T,0,0,II)+WE(X,T,0,J,II)
          END IF
C
C
 2030   CONTINUE
 2000 CONTINUE
C
C
      RETURN
C
      END
C
C
C     ************************************************
C     **                                            **
C     **      Ｋ年度、Ｘ歳、被保険者期間０年の      **
C     **      被保険者データ(期間、報酬)を作成      **
C     **                                            **
C     ************************************************
C
C
      SUBROUTINE      SIMLBZW0(X)
C
      IMPLICIT INTEGER (A-Z)
      INCLUDE 'seps.inc'
      INCLUDE 'siml.inc'
C
      COMMON /K/ K
      COMMON /S/ S,S2
C
      REAL*8 TM(0:4)
      REAL*8 ZE0(0:1)
      REAL*8 CHS,CHT
      REAL*8 TMP,TMQ
      REAL*8 BNDUM,BNPTDUM
C
C-----------------------------------------------------
C     最終年額報酬の設定(BB)
C-----------------------------------------------------
      IF(G(X,0).GT.1.0D-6) THEN
        IF(K.GE.PARTYR1 .AND. PSEID.EQ.0 .AND. S.LE.2) THEN
          BB(X,0)  =(BN(K,X,S)*(G(X,0)-GPT(X,0))
     &               +BNPT(K,X,S)*GPT(X,0))*AD(K)/G(X,0)
          BBNP(X,0)= BN(K,X,S)*AD(K)
          BBPT(X,0)= BNPT(K,X,S)*AD(K)
        ELSE
          BB(X,0)=BN(K,X,S)*AD(K)
        END IF
      ELSE
        BB(X,0)=0.0D0
        BBPT(X,0)=0.0D0
      END IF
      IF(X.EQ.XEND) THEN
        BB(X,0)=BN(K,X,S)*AD(K)
        BBPT(X,0)=BNPT(K,X,S)*AD(K)
      END IF
C
C-----------------------------------------------------
C     被保険者期間年数の設定(Z,ZE,PSZ,PSZE)
C-----------------------------------------------------
      DX=60
      IF(FLG_SIGO.EQ.1) THEN
        DX=20+MAX(NINT(CAN(MAX(K-X,-74))),40)
      END IF
C
      HIHONEN = 70
      IF(K.GE.HIHO70YR .AND. FLG_HIHO70.EQ.1) THEN
        HIHONEN = 75
      END IF
C
      DO 3000 J=0,6
        DO 3010 I=0,1
          ZE0(I)=ZE(X-1,0,I,J)
C
          TM(1)=GN(X,0) *ZE0(I)
          TM(2)=GEZ(X,0)*ZE0(I)
C
          IF(X.LE.HIHONEN .AND. (J.EQ.0 .OR. J.EQ.4 .OR.
     &          (S.EQ.1 .AND. X.GE.40 .AND. J.EQ.5) .OR.
     &          (S.GE.2 .AND. X.GE.35 .AND. J.EQ.5) .OR.
     &          (X.GE.20.AND. X.LE.DX .AND. J.EQ.6))   ) THEN
            TM(0)=0.0D0
            IF(I.EQ.0 .OR. (S.EQ.3 .AND. I.EQ.1)) THEN
              TM(0)=(GNN(X)+GN(X,0))/2.0D0
              IF(PSEID.EQ.0 .AND. FLG_PART.GE.1 .AND. S.LE.2 .AND.
     &          K.EQ.PARTYR2 .AND. LPT(K,S,X).GE.1.0D-6) THEN
                TM(0)=TM(0)+LPT1(K,S,X)*GPT(X,0)/LPT(K,S,X)/2.0D0
              END IF
            END IF
C
            TM(1)=TM(1)+TM(0)
C
          END IF
C
          Z(X,0,I,J) =0.0D0
          ZE(X,0,I,J)=0.0D0
C
          IF(G(X,0) .GT.1.0D-6) Z(X,0,I,J) =TM(1)/G(X,0)
          IF(GE(X,0).GT.1.0D-6) ZE(X,0,I,J)=TM(2)/GE(X,0)
 3010   CONTINUE
 3000 CONTINUE
C
C-----------------------------------------------------
C     標準報酬累計の設定(W,WE)
C-----------------------------------------------------
      DO 4000 II=0,3
        IF(II.EQ.0) THEN
          IF(X.LE.67) THEN
            CHS=1.0D0+HH(K)
          ELSE
            CHS=1.0D0+CI(K)
          END IF
C
          IF(CHT_FLG.EQ.1) THEN
            KK=MIN(K,KE-3)
            CHT=DIR(K)*(1.0D0+CI0(KK-1+2))*(1.0D0+CI0(KK-1+3))
C
            IF(X.LE.64) THEN
              CHT=CHT/(1.0D0+HH(KK+1))/(1.0D0+HH(KK+2))/(1.0D0+HH(KK+3))
            ELSE IF(X.EQ.65) THEN
              CHT=CHT/(1.0D0+HH(KK+1))/(1.0D0+HH(KK+2))/(1.0D0+CI(KK+3))
            ELSE IF(X.EQ.66) THEN
              CHT=CHT/(1.0D0+HH(KK+1))/(1.0D0+CI(KK+2))/(1.0D0+CI(KK+3))
            ELSE
              CHT=CHT/(1.0D0+CI(KK+1))/(1.0D0+CI(KK+2))/(1.0D0+CI(KK+3))
            END IF
C
          ELSE
            CHT=0.98D0
            DO 4010 KK=5,K
              CHT=CHT*(1.0D0+HH(KK))/(1.0D0+H(KK))
 4010       CONTINUE
            IF(X.GT.67) THEN
              DO 4011 KK=0,MIN(K-5,X-68)
                CHT=CHT*(1.0D0+CI(K-KK))/(1.0D0+HH(K-KK))
 4011         CONTINUE
            END IF
          END IF
C
        ELSE IF(II.EQ.1) THEN
          CHS=1.0D0
          CHT=1.0D0
        ELSE IF(II.EQ.2) THEN
          CHS=1.0D0+CI2(K,MAX(X,67))
C
          IF(CHT_FLG.EQ.1) THEN
            CHT=JZ_SHK(K)*1.031D0*0.988D0
            DO 4012 KK=5,K
              CHT=CHT*(1.0D0+CI2(KK,MAX(X-K+KK,67)))
 4012       CONTINUE
          ELSE
            CHT=0.917D0*1.031D0*0.988D0
            DO 4013 KK=5,K
              CHT=CHT*(1.0D0+CI2(KK,MAX(X-K+KK,67)))/(1.0D0+H(KK))
 4013       CONTINUE
          END IF
        ELSE IF(II.EQ.3) THEN
          CHS=1.0D0+HH(K)
          IF(CHT_FLG.EQ.1) THEN
            KK=MIN(K,KE-3)
            CHT=DIR(K)*(1.0D0+CI0(KK-1+2))*(1.0D0+CI0(KK-1+3))
     &               /(1.0D0+HH(KK+1))/(1.0D0+HH(KK+2))/(1.0D0+HH(KK+3))
          ELSE
            CHT=0.98D0
            DO 4014 KK=5,K
              CHT=CHT*(1.0D0+HH(KK))/(1.0D0+H(KK))
 4014       CONTINUE
          END IF
        END IF
C
        IF(K-X.GE.-62) THEN
          CHT=CHT*0.991D0*0.998D0
        ELSE
          CHT=CHT*0.991D0
        END IF
        CHWD(X,0,II) =BB(X,0) /2.0D0*CHT
        IF(FLG_HIHO70.EQ.0 .OR. K.LT.HIHO70YR) THEN
          IF(PSEID.EQ.0) THEN
            IF(KOZAIEX2.EQ.0 .AND. X.GE.HIHONEN) THEN
              CHWD(X,0,II)  =0.0D0
            END IF
          END IF
        END IF
C
        IF(HOUJOU.EQ.1) THEN
          IF(K.EQ.HOUJOUYR) THEN
            CHT=CHT*(1.0D0+(HOUJOUR-1.0D0)*1.0D0/2.0D0)
          ELSE IF(K.GT.HOUJOUYR) THEN
            CHT=CHT*HOUJOUR
          END IF
        END IF
C
        W(X,0,0,0,II) =0.0D0
        WE(X,0,0,0,II)=0.0D0
C
        DO 4030 J=1,4
C
          TMP=GN(X,0) *WE(X-1,0,0,J,II)
          TMQ=GEZ(X,0)*WE(X-1,0,0,J,II)
C
          TM(1)=TMP*CHS
          TM(2)=TMQ*CHS
C
          IF(J.LE.3) GO TO 4060
C
          IF(PSEID.EQ.0) THEN
            IF(KOZAIEX2.EQ.0 .AND. X.GE.HIHONEN) THEN
              IF(FLG_HIHO70.GE.1 .AND.
     &           K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1) THEN
                BNDUM = BN(K,X,S)
                IF(S.LE.2) THEN
                  BNPTDUM = BNPT(K,X,S)
                END IF
              END IF
              BN(K,X,S) = 0.0D0
              IF(S.LE.2) THEN
                BNPT(K,X,S) = 0.0D0
              END IF
            END IF
          END IF
C
C
          IF(K.GE.PARTYR1 .AND. PSEID.EQ.0 .AND. S.LE.2) THEN
            TM(1)=TM(1)
     &           +(BN(K,X,S)*(G(X,0)-GPT(X,0))+BNPT(K,X,S)*GPT(X,0))
     &            /2.0D0*AD(K)*CHT
C
            IF(FLG_PART.GE.1 .AND. K.EQ.PARTYR2 .AND.
     &         LPT(K,S,X).GE.1.0D-6                   ) THEN
              TM(1)=TM(1)+LPT1(K,S,X)*GPT(X,0)/LPT(K,S,X)
     &                    *BNPT(K,X,S)*AD(K)/2.0D0*CHT
            END IF
          ELSE
            TM(1)=TM(1)+BN(K,X,S)*AD(K)/2.0D0*G(X,0)*CHT
          END IF
          
          IF(PSEID.EQ.0 .AND. KOZAIEX2.EQ.0 .AND.
     &       K.GE.HIHO70YR-5 .AND. K.LE.HIHO70YR-1 .AND.
     &       X.GE.HIHONEN .AND. FLG_HIHO70.EQ.1 .AND. X.LT.75) THEN
            BN(K,S,X) = BNDUM
            IF(S.LE.2) THEN
              BNPT(K,X,S) = BNPTDUM
            END IF
          END IF
C
 4060     CONTINUE
C
          W(X,0,0,J,II) =0.0D0
          WE(X,0,0,J,II)=0.0D0
C
          IF(G(X,0) .GT.1.0D-6) W(X,0,0,J,II) =TM(1)/G(X,0)
          IF(GE(X,0).GT.1.0D-6) WE(X,0,0,J,II)=TM(2)/GE(X,0)
C
          IF(J.LE.3) THEN
            W(X,0,0,0,II) =W(X,0,0,0,II) +W(X,0,0,J,II)
            WE(X,0,0,0,II)=WE(X,0,0,0,II)+WE(X,0,0,J,II)
          END IF
C
 4030   CONTINUE
 4000 CONTINUE
C
      RETURN
C
      END
C
