C
C     **********************************************************
C     **                                                      **
C     **  Ｋ年度,Ｘ歳,Ｔ年の被保険者より発生する              **
C     **            老齢年金(在職)の新規裁定者のデ−タを作成  **
C     **                                                      **
C     **********************************************************
C
C
      SUBROUTINE      SAITEZAI(X,T)
C
C
      IMPLICIT INTEGER (A-Z)
      INCLUDE 'seps.inc'
      INCLUDE 'siml.inc'
C
C
      COMMON /K/ K
      COMMON /S/ S,S2
C
      COMMON /DSITPR/XR,XXR,XRB,IT,TN,TA,TZ,PRO,PROS,PSLR
C
      REAL*8 TN,TA,TZ(4),PRO,PROS,PSLR
C
      REAL*8 BK,BK2,BK3
      REAL*8 TMG,TMF,TMO,TMGP
      REAL*8 RIS(0:10),TMRIS,TMRIS2
      REAL*8 TMRP(0:10), TMRPS, TML
C
C-----------------------------------------------------
C     老齢（在職）新法（旧老齢相当）（Ｉ＝２）
C                 新法（旧通老相当）（Ｉ＝４）
C-----------------------------------------------------
C
      TMO=Z(X,T,0,0)
      CALL DSITK(X,T,2,BK,BK2,BK3)
C
C  -----------------------------------------------------
C     低在老の裁定
C  -----------------------------------------------------
C
      I=0
      IF( ((X.EQ.XR .AND. X.LT.65) .OR.
     &     (X.GT.XR .AND. X.LT.65 .AND. X.LE.XRB .AND. XRB.GT.60))
     &    .AND. IT.NE.3 .AND. IT.NE.4                             ) I=2
      IF((((X.EQ.XR .AND. X.LT.65) .OR.
     &     (X.GT.XR .AND. X.LT.65 .AND. X.LE.XRB .AND. XRB.GT.60))
     &    .AND. (IT.EQ.3 .OR. IT.EQ.4) .AND. 1.0D0-1.0D-6.LE.TMO ) .OR.
     &   (X.GT.XRB .AND. X.LT.65 .AND.
     &    1.0D0-1.0D-6.LE.TMO .AND. TMO.LT.2.0D0-1.0D-6          )) I=4
C
      IF(I.EQ.2 .OR. I.EQ.4) THEN
C
        RIS(0)=1.0D0
        DO 1000 XX=1,10
          RIS(XX)=0.0D0
 1000   CONTINUE
C
        IF(XR.GE.60) THEN
          DO 1100 XX=1,5
            IF(XXR.GT.65-XX) THEN
              RIS(XX)=RISS(K,65-XX,XXR,S,1)
            ELSE
              RIS(XX)=0.0D0
            END IF
 1100     CONTINUE
          DO 1110 XX=1,5
            RIS(0)=RIS(0)-RIS(XX)
 1110     CONTINUE
          TMRIS=0.0D0
          DO 1120 XX=0,5
            IF(65-XX.GE.X) THEN
              TMRIS=TMRIS+RIS(XX)
            ELSE
              RIS(XX)=0.0D0
            END IF
 1120     CONTINUE
          TMRIS2=0.0D0
          DO 1130 XX=0,5
            IF(TMRIS.GE.1.0D-6) THEN
              RIS(XX)=RIS(XX)/TMRIS
            ELSE
              IF(XX.EQ.0) THEN
                RIS(XX)=1.0D0
              ELSE 
                RIS(XX)=0.0D0
              END IF
            END IF
            TMRIS2=TMRIS2+RIS(XX)
 1130     CONTINUE
          IF(TMRIS2-1.0D0.GT.1.0D-6) THEN
            WRITE(6,*) '繰上げ請求率エラー',TMRIS2
            STOP
          END IF
        END IF
C
        IF(XRB.GT.60 .AND. X.GT.60 .AND. X.LE.XRB .AND. T.GT.0) THEN
          GD(X,T)=GD(X-1,T-1)*(1.0D0-Q2(K,X))
        ELSE
          GD(X,T)=0.0D0
        END IF
C
        DO 2000 XX=0,5
          IF(X.LT.60 .AND. XX.GE.1) GO TO 2000
C
          TMG=RIS(XX)*(G(X,T)-GD(X,T))
          IF(XRB.GT.60 .AND. X.LT.XRB .AND. X.NE.65-XX) TMG=0.0D0
C
          IF(XRB.GT.60 .AND. X.LT.XRB) THEN
            GD(X,T)=GD(X,T)+TMG
          END IF
C
          RN(X,XX,I)=RN(X,XX,I)+TMG
          HNN(X,XX,I,1)=HNN(X,XX,I,1)+TMG*TZ(1)
          HNN(X,XX,I,2)=HNN(X,XX,I,2)+TMG*TZ(2)
          PSHNN(X,XX,I)=PSHNN(X,XX,I)+TMG*PSLR
C
          FN(X,XX,I,1)=FN(X,XX,I,1)+TMG*BK
          FNHIK(X,XX,I,1)=FNHIK(X,XX,I,1)+TMG*BK2
          FNMIN(X,XX,I,1)=FNMIN(X,XX,I,1)+TMG*BK3
C
          TMF=TMG*FL*FLT(MAX(-74,K-X))*BD(K,2)*TN
          FN(X,XX,I,2)=FN(X,XX,I,2)+TMF
          TMO=TMG*FL1*BD(K,14)*MIN(TA/CAN(MAX(-74,K-X)),1.0D0)
          IF(FLG_SIGO.EQ.1) THEN
            TMO=TMO*MAX(CAN(MAX(-74,K-X)),40.0D0)/40.0D0
          END IF
          FN(X,XX,I,14)=FN(X,XX,I,14)+TMO
C
          IF((KEY.EQ.4  .OR. KEY.EQ.5  .OR. KEY.EQ.7  .OR.
     &        KEY.EQ.8  .OR. KEY.EQ.12 .OR. KEY.EQ.13 .OR.
     &        KEY.EQ.14 .OR. KEY.EQ.22 .OR. KEY.EQ.23    )
     &       .AND. PSLSI2.EQ.1 .AND. K.GE.PSLY)           GO TO 2010
C
          IF(S.GE.4)                                      GO TO 2010
C
          IF(I.EQ.2 .OR. (I.EQ.4 .AND. IT.EQ.3)) THEN
            FN(X,XX,I,4) =FN(X,XX,I,4) +TMG*ADT(1)*BD(K,4)*PSLR
            FN(X,XX,I,23)=FN(X,XX,I,23)
     &                    +TMG*SADT(MAX(-74,K-X))*BD(K,23)*PSLR
            FN(X,XX,I,5) =FN(X,XX,I,5) +TMG*ADT(2)*BD(K,5)*PSLR
            FN(X,XX,I,6)=FN(X,XX,I,6)
     &                  +TMG*CADT(K-NINT(NS(K,X)))*BD(K,6)*PSLR
          END IF
C
 2010     CONTINUE
C
C
          IF(DAIK14.EQ.0) THEN
            TMF=TMG*((W(X,T,0,1,1)+W(X,T,0,2,1))*MIN(8.0D-3,PRO)
     &               +W(X,T,0,3,1)*MIN(7.5D-3,PRO)
     &               +W(X,T,0,4,1)*PROS)
          ELSE IF(DAIK14.EQ.1) THEN
            TMF=TMG*(W(X,T,0,0,1)*PRO+W(X,T,0,4,1)*PROS)
          ELSE IF(DAIK14.EQ.2) THEN
            TMF=TMG*(W(X,T,0,0,1)*7.5D-3+W(X,T,0,4,1)*5.77D-3)
          ELSE IF(DAIK14.EQ.3) THEN
            TMF=TMG*(W(X,T,0,0,1)*PRO+W(X,T,0,4,1)*PROS)
          END IF
          IF(((DAIK14.EQ.0 .OR. DAIK14.EQ.1) .AND. K.GE.0) .OR.
     &       ((DAIK14.EQ.2 .OR. DAIK14.EQ.3) .AND. K.GE.KIJUN+1)) THEN
            TMF=TMF*HIKRATE
          END IF
          KAKORN(X,XX,I,1)=KAKORN(X,XX,I,1)+TMF
 2000   CONTINUE
      END IF
C
C  -----------------------------------------------------
C     高在老(65歳、70歳)の裁定及び裁定替え
C       高在老の65歳、70歳時の給付の発生
C  -----------------------------------------------------
      IF((XEND.GT.65 .AND. X.EQ.65) .OR.
     &   (XEND.GT.70 .AND. X.EQ.70)     ) THEN
        IF(IT.EQ.1 .OR. IT.EQ.2) I=2
        IF(IT.EQ.3 .OR. IT.EQ.4) I=4
C
        IF(FLG_PART.GE.1 .AND. PSEID.EQ.0 .AND. S.LE.2. .AND.
     &     K.GE.PARTYR1                                      ) THEN
          TML=L(K,S,X)+LPT(K,S,X)
        ELSE
          TML=L(K,S,X)
        END IF
        TMRPS=0.0D0
        DO 3090 XX=0,10
          TMRP(XX)=(R(X-1,XX,2)+R(X-1,XX,4)+R(X-1,XX,6)+R(X-1,XX,8))
     &             *(1.0D0-Q2(K,X))
          TMRPS=TMRPS+TMRP(XX)
 3090   CONTINUE
C
        RIS(0)=1.0D0
        DO 3100 XX=1,10
          IF(TML.GT.1.0D-6 .AND. TML.GE.TMRPS) THEN
            RIS(XX)=TMRP(XX)/TML
          ELSE
            IF(TMRPS.GT.1.0D-6) THEN
              RIS(XX)=TMRP(XX)/TMRPS
            ELSE
              RIS(XX)=0.0D0
            END IF
          END IF
          RIS(0)=RIS(0)-RIS(XX)
 3100   CONTINUE
C
        DO 3200 XX=0,10
C
          TMG=RIS(XX)*G(X,T)
          TMGP=0.0D0
          IF(FLG_PART.GE.1 .AND. S.LE.2 .AND. PSEID.EQ.0 .AND. 
     &       K.GE.PARTYR1 .AND. X-K.GT.XRB-PARTYR1            ) THEN
            IF(LPT(K,S,X).GT.1.0D-6) THEN
              TMGP=RIS(XX)*GPT(X,T)*LPT1(K,S,X)/LPT(K,S,X)
     &             *RT(PARTYR1,XRB)
            END IF
          END IF
          IF(FLG_PART.GE.2 .AND. S.LE.2 .AND. PSEID.EQ.0 .AND. 
     &       K.GE.PARTYR2 .AND. X-K.GT.XRB-PARTYR2            ) THEN
            IF(LPT(K,S,X).GT.1.0D-6) THEN
              TMGP=TMGP
     &            +RIS(XX)*GPT(X,T)*(LPT2(K,S,X)-LPT1(K,S,X))/LPT(K,S,X)
     &             *RT(PARTYR2,XRB)
            END IF
          END IF
          RN(X,XX,I)=RN(X,XX,I)+TMG
          HNN(X,XX,I,1)=HNN(X,XX,I,1)+TMG*TZ(1)
          HNN(X,XX,I,2)=HNN(X,XX,I,2)+TMG*TZ(2)
          PSHNN(X,XX,I)=PSHNN(X,XX,I)+TMG*PSLR
C
          FN(X,XX,I,1)=FN(X,XX,I,1)+TMG*BK
          FNHIK(X,XX,I,1)=FNHIK(X,XX,I,1)+TMG*BK2
          FNMIN(X,XX,I,1)=FNMIN(X,XX,I,1)+TMG*BK3
C
          TMF=TMG*FL*FLT(MAX(-74,K-X))*BD(K,2)*TN
          FN(X,XX,I,2)=FN(X,XX,I,2)+TMF
          TMO=TMG*FL1*BD(K,14)*MIN(TA/CAN(MAX(-74,K-X)),1.0D0)
          IF(FLG_SIGO.EQ.1) THEN
            TMO=TMO*MAX(CAN(MAX(-74,K-X)),40.0D0)/40.0D0
          END IF
          FN(X,XX,I,14)=FN(X,XX,I,14)+TMO
          TMF=MAX(TMF-TMO,0.0D0)
          FN(X,XX,I,3)=FN(X,XX,I,3)+TMF
C
          IF((KEY.EQ.4  .OR. KEY.EQ.5  .OR. KEY.EQ.7  .OR.
     &        KEY.EQ.8  .OR. KEY.EQ.12 .OR. KEY.EQ.13 .OR.
     &        KEY.EQ.14 .OR. KEY.EQ.22 .OR. KEY.EQ.23    )
     &       .AND. PSLSI2.EQ.1 .AND. K.GE.PSLY)           GO TO 3210
C
          IF(S.GE.4)                                      GO TO 3210
C
          IF(I.EQ.2 .OR. (I.EQ.4 .AND. IT.EQ.3)) THEN
            FN(X,XX,I,4) =FN(X,XX,I,4)+(TMG-TMGP)*ADT(1)*BD(K,4)*PSLR
            FN(X,XX,I,23)=FN(X,XX,I,23)
     &                   +(TMG-TMGP)*SADT(MAX(-74,K-X))*BD(K,23)*PSLR
            FN(X,XX,I,5) =FN(X,XX,I,5)+(TMG-TMGP)*ADT(2)*BD(K,5)*PSLR
            FN(X,XX,I,6) =FN(X,XX,I,6)+(TMG-TMGP)
     &                       *CADT(K-NINT(NS(K,X)))*BD(K,6)*PSLR
          END IF
C
 3210     CONTINUE
C
C
          IF(DAIK14.EQ.0) THEN
            TMF=TMG*((W(X,T,0,1,1)+W(X,T,0,2,1))*MIN(8.0D-3,PRO)
     &               +W(X,T,0,3,1)*MIN(7.5D-3,PRO)+W(X,T,0,4,1)*PROS)
          ELSE IF(DAIK14.EQ.1) THEN
            TMF=TMG*(W(X,T,0,0,1)*PRO+W(X,T,0,4,1)*PROS)
          ELSE IF(DAIK14.EQ.2) THEN
            TMF=TMG*(W(X,T,0,0,1)*7.5D-3+W(X,T,0,4,1)*5.77D-3)
          ELSE IF(DAIK14.EQ.3) THEN
            TMF=TMG*(W(X,T,0,0,1)*PRO+W(X,T,0,4,1)*PROS)
          END IF
          IF(((DAIK14.EQ.0 .OR. DAIK14.EQ.1).AND. K.GE.0) .OR.
     &       ((DAIK14.EQ.2 .OR. DAIK14.EQ.3).AND. K.GE.KIJUN+1)) THEN
            TMF=TMF*HIKRATE
          END IF
          KAKORN(X,XX,I,1)=KAKORN(X,XX,I,1)+TMF
 3200   CONTINUE
      END IF
C
C
      RETURN
C
      END
C
C
C     **********************************************************
C     **                                                      **
C     **  Ｋ年度,Ｘ歳,Ｔ年待期者より発生する                  **
C     **            老齢年金(退職)の新規裁定者のデ−タを作成  **
C     **                                                      **
C     **********************************************************
C
C
      SUBROUTINE      SAITETAI(X,T)
C
C
      IMPLICIT INTEGER (A-Z)
      INCLUDE 'seps.inc'
      INCLUDE 'siml.inc'
C
C
      COMMON /K/ K
      COMMON /S/ S,S2
C
      COMMON /DSITPR/XR,XXR,XRB,IT,TN,TA,TZ,PRO,PROS,PSLR
C
      REAL*8 TN,TA,TZ(4),PRO,PROS,PSLR
C
      REAL*8 BK,BK2,BK3
      REAL*8 TMG,TMF,TMO,TMG2(0:10)
      REAL*8 RIS(0:10),TMRIS,TMRIS2
      REAL*8 GED
      REAL*8 TMRP(0:10), TMRPS, TMLP
C
      TMO=ZE(X,T,0,0)
      CALL DSITK(X,T,1,BK,BK2,BK3)
C
C
      IF(TMO.GE.SENLL-1.0D-6 .AND. IT.NE.2 .AND.
     &   X.GE.XRB .AND. X.LT.XXR .AND. XXR.GT.60) THEN
C
        TMG=GE(X,T)
C
        RSENN(X)=RSENN(X)+TMG
        HNSENN(X,1)=HNSENN(X,1)+TMG*TZ(1)
        HNSENN(X,2)=HNSENN(X,2)+TMG*TZ(2)
        PSHNSENN(X)=PSHNSENN(X)+TMG*PSLR
C
        FSENN(X,1) =FSENN(X,1)+TMG*BK
        FSENNHIK(X,1)=FSENNHIK(X,1)+TMG*BK2
        FSENNMIN(X,1)=FSENNMIN(X,1)+TMG*BK3
C
        TMF=TMG*FL*FLT(MAX(-74,K-X))*BD(K,2)*TN
        FSENN(X,2) =FSENN(X,2)+TMF
        TMO=TMG*FL1*BD(K,14)*MIN(TA/CAN(MAX(-74,K-X)),1.0D0)
        IF(FLG_SIGO.EQ.1) THEN
          TMO=TMO*MAX(CAN(MAX(-74,K-X)),40.0D0)/40.0D0
        END IF
        FSENN(X,14)=FSENN(X,14)+TMO
        TMF=MAX(TMF-TMO,0.0D0)
        FSENN(X,3) =FSENN(X,3)+TMF
C
        IF((KEY.EQ. 4 .OR. KEY.EQ. 5 .OR. KEY.EQ. 7 .OR.
     &      KEY.EQ. 8 .OR. KEY.EQ.12 .OR. KEY.EQ.13 .OR.
     &      KEY.EQ.14 .OR. KEY.EQ.22 .OR. KEY.EQ.23    )
     &     .AND. PSLSI2.EQ.1 .AND. K.GE.PSLY)           GO TO 4000
C
        IF(S.GE.4)                                      GO TO 4000
C
        FSENN(X,4) =FSENN(X,4) +TMG*ADT(1)*BD(K,4)*PSLR
        FSENN(X,23)=FSENN(X,23)+TMG*SADT(MAX(-74,K-X))*BD(K,23)*PSLR
        FSENN(X,5) =FSENN(X,5) +TMG*ADT(2)*BD(K,5)*PSLR
        FSENN(X,6)=FSENN(X,6)
     &             +TMG*CADT(K-NINT(NS(K,X)))*BD(K,6)*PSLR
C
 4000   CONTINUE
C
C
        IF(DAIK14.EQ.0) THEN
        TMF=TMG*((WE(X,T,0,1,1)+WE(X,T,0,2,1))*MIN(8.0D-3,PRO)
     &           +WE(X,T,0,3,1)*MIN(7.5D-3,PRO)
     &           +WE(X,T,0,4,1)*PROS)
        ELSE IF(DAIK14.EQ.1) THEN
          TMF=TMG*(WE(X,T,0,0,1)*PRO+WE(X,T,0,4,1)*PROS)
        ELSE IF(DAIK14.EQ.2) THEN
          TMF=TMG*(WE(X,T,0,0,1)*7.5D-3+WE(X,T,0,4,1)*5.77D-3)
        ELSE IF(DAIK14.EQ.3) THEN
          TMF=TMG*(WE(X,T,0,0,1)*PRO+WE(X,T,0,4,1)*PROS)
        END IF
        IF(((DAIK14.EQ.0 .OR. DAIK14.EQ.1) .AND. K.GE.0) .OR.
     &     ((DAIK14.EQ.2 .OR. DAIK14.EQ.3) .AND. K.GE.KIJUN+1)) THEN
          TMF=TMF*HIKRATE
        END IF
        KAKORSNN(X,1)=KAKORSNN(X,1)+TMF
C
        GE(X,T)=0.0D0
        CALL SUBC4(ZE,14,115,X,X,0,100,T,T,0,1,0,1,0,9,0,9)
        CALL SUBC5(WE,14,115,X,X,0,100,T,T,0,0,0,0,0,7,0,7,0,3,0,3)
C
      ELSE IF(X.GE.XR) THEN
C
C-----------------------------------------------------
C     年功年金以外の裁定
C-----------------------------------------------------
C
        IF(IT.EQ.1 .OR. IT.EQ.2) I=1
        IF(IT.EQ.3 .OR. IT.EQ.4) I=3
C
        DO 4050 XX=0,10
          TMG2(XX)=0.0D0
          RIS(XX)=0.0D0
 4050   CONTINUE
C
        IF(Y(X,T,1).GT.1.0D-6) THEN
          IF(FLG_PART.GE.1 .AND. PSEID.EQ.0 .AND. S.LE.2. .AND.
     &       K.GT.PARTYR1                                      ) THEN
            TMLP=L(K-1,S,X-1)+LPT(K-1,S,X-1)
          ELSE
            TMLP=L(K-1,S,X-1)
          END IF
          TMRPS=0.0D0
          DO 4051 XX=0,10
            TMRP(XX)=R(X-1,XX,2)+R(X-1,XX,4)+R(X-1,XX,6)+R(X-1,XX,8)
            TMRPS=TMRPS+TMRP(XX)
 4051     CONTINUE
C
          GED=0.0D0
          IF(XR.LT.60 .OR. TMLP.LE.1.0D-6) THEN
            TMG2(0)=Y(X,T,1)
            GED=TMG2(0)
          ELSE IF(X.GT.XRB) THEN
            IF(TMRPS.GE.TMLP) THEN
              DO 4052 XX=0,10
                RIS(XX)=TMRP(XX)/TMRPS
                TMG2(XX)=Y(X,T,1)*RIS(XX)
 4052         CONTINUE
            ELSE
              IF(X.GT.65) THEN
                DO 4053 XX=0,10
                  RIS(XX)=TMRP(XX)/TMLP
                  TMG2(XX)=Y(X,T,1)*RIS(XX)
 4053           CONTINUE
                TMG2(MIN(10,X-60))=TMG2(MIN(10,X-60))
     &                             + Y(X,T,1)*(TMLP-TMRPS)/TMLP
              ELSE
                DO 4054 XX=0,10
                  RIS(XX)=TMRP(XX)/TMLP
                  TMG2(XX)=Y(X,T,1)*RIS(XX)
 4054           CONTINUE
                TMG2(0)=TMG2(0)+Y(X,T,1)*(TMLP-TMRPS)/TMLP
              END IF
            END IF
            GED=0.0D0
            DO 4055 XX=0,10
              GED=GED+TMG2(XX)
 4055       CONTINUE
            IF(ABS(GED-Y(X,T,1)).GT.1.0D-6) THEN
              WRITE(6,*) '在老転び裁定エラー１(SAITEITAI)X,T,Y,GED:',
     &                    X, T, Y(X,T,1), GED
              STOP
            END IF
C
          ELSE IF(X.LE.XRB .AND. XRB.GT.60) THEN
            IF(TMRPS-TMLP.GT.1.0D-6) THEN
              WRITE(6,*) '在老転び裁定想定外 TMRPS,TMLP:', TMRPS, TMLP
              STOP
            END IF
            RIS(0)=1.0D0
            TMRIS =1.0D0
            DO 4060 XX=1,5
              IF(65-XX.LT.X) THEN
                RIS(XX)=TMRP(XX)/TMLP
                RIS(0)=RIS(0)-RIS(XX)
              ELSE
                RIS(XX)=RISS(K,65-XX,XXR,S,0)
                TMRIS=TMRIS-RIS(XX)
              END IF
 4060       CONTINUE
            TMRIS2=RIS(0)
            RIS(0)=TMRIS
            DO 4061 XX=0,65-X
              RIS(XX)=RIS(XX) * TMRIS2
 4061       CONTINUE
            GED=0.0D0
            DO 4063 XX=1,5
              IF(65-XX.LT.X) TMG2(XX)=Y(X,T,1)*RIS(XX)
              GED=GED+TMG2(XX)
 4063       CONTINUE
            IF(Y(X,T,1)-GED.LE.-1.0D-8) THEN
              WRITE(6,*) '在老転び裁定エラー２(SAITEITAI) X,T,Y,GED:',
     &                    X, T, Y(X,T,1), GED
              STOP
            END IF
          END IF
C
          GE(X,T)=GE(X,T)-GED
          IF(GE(X,T).LT.-1.0D-6) THEN
            WRITE(6,*) '在老転び裁定エラー３(SAITEITAI) X,T,Y,GE:',
     &                  X, T, Y(X,T,1), GE(X,T)
            STOP
          ELSE IF(GE(X,T).LT.1.0D-6) THEN
            GE(X,T)=0.0D0
          END IF
        END IF
C
C
C       通常の退職の裁定
C
        RIS(0)=1.0D0
        DO 4100 XX=1,10
          RIS(XX)=0.0D0
 4100   CONTINUE
        IF(X.GE.60+K-KIJUN .AND. X.LE.69+K-KIJUN .AND. X.GT.65) THEN
CCC
          DO 4105 XX=0,10
            RIS(XX)=0.0D0
 4105     CONTINUE
CCC
          RIS(MIN(10,X-60))=1.0D0
        ELSE IF(XR.EQ.60 .AND. ((X.GE.XR .AND. X.LE.XRB) .OR.
     &                          (K.EQ.KIJUN+1 .AND. X.LE.XXR)) ) THEN
          DO 4110 XX=1,5
            IF(XX.GT.65-XXR) THEN
              RIS(XX)=RISS(K,65-XX,XXR,S,0)
            END IF
 4110     CONTINUE
          DO 4120 XX=1,5
            RIS(0)=RIS(0)-RIS(XX)
 4120     CONTINUE
          TMRIS=0.0D0
          DO 4130 XX=0,5
            IF(X.LE.65-XX) THEN
              TMRIS=TMRIS+RIS(XX)
            ELSE
              RIS(XX)=0.0D0
            END IF
 4130     CONTINUE
          TMRIS2=0.0D0
          DO 4140 XX=0,5
            IF(TMRIS.GT.1.0D-6) THEN
              RIS(XX)=RIS(XX)/TMRIS
            ELSE
              IF(XX.EQ.0) THEN
                RIS(XX)=1.0D0
              ELSE
                RIS(XX)=0.0D0
              END IF
            END IF
            TMRIS2=TMRIS2+RIS(XX)
 4140     CONTINUE
          IF(TMRIS2-1.0D0.GT.1.0D-6) THEN 
            WRITE(6,*) '繰上げ請求率エラー',TMRIS2
            STOP
          END IF
        END IF
C
        GED=0.0D0
        DO 4200 XX=0,10
          IF(X.LT.60 .AND. XX.GE.1) GO TO 4200
          IF(X.GE.XRB .OR. (X.EQ.65-XX .AND. XX.LE.5)) THEN
            TMG=RIS(XX)*GE(X,T)
            IF(X.GE.60+K-KIJUN .AND. X.LE.69+K-KIJUN .AND. 
     &         PSEID.NE.2 .AND. PSEID.NE.3                ) THEN
              IF(X.EQ.65+K-KIJUN .AND. K.EQ.KIJUN+1       ) THEN
                TMG=TMG/3.0D0
              ELSE
                TMG=TMG/MAX(1.0D0,DBLE(5-K+KIJUN+1))
              END IF
            END IF
          ELSE
            TMG=0.0D0
          END IF
          GED=GED+TMG
          TMG=TMG+TMG2(XX)
C
          RN(X,XX,I)=RN(X,XX,I)+TMG
          HNN(X,XX,I,1)=HNN(X,XX,I,1)+TMG*TZ(1)
          HNN(X,XX,I,2)=HNN(X,XX,I,2)+TMG*TZ(2)
          PSHNN(X,XX,I)=PSHNN(X,XX,I)+TMG*PSLR
C
          FN(X,XX,I,1)=FN(X,XX,I,1)+TMG*BK
          FNHIK(X,XX,I,1)=FNHIK(X,XX,I,1)+TMG*BK2
          FNMIN(X,XX,I,1)=FNMIN(X,XX,I,1)+TMG*BK3
C
          TMF=TMG*FL*FLT(MAX(-74,K-X))*BD(K,2)*TN
          FN(X,XX,I,2)=FN(X,XX,I,2)+TMF
          TMO=TMG*FL1*BD(K,14)*MIN(TA/CAN(MAX(-74,K-X)),1.0D0)
          IF(FLG_SIGO.EQ.1) THEN
            TMO=TMO*MAX(CAN(MAX(-74,K-X)),40.0D0)/40.0D0
          END IF
          FN(X,XX,I,14)=FN(X,XX,I,14)+TMO
          TMF=MAX(TMF-TMO,0.0D0)
          FN(X,XX,I,3)=FN(X,XX,I,3)+TMF
C
          IF((KEY.EQ. 4 .OR. KEY.EQ. 5 .OR. KEY.EQ. 7 .OR.
     &        KEY.EQ. 8 .OR. KEY.EQ.12 .OR. KEY.EQ.13 .OR.
     &        KEY.EQ.14 .OR. KEY.EQ.22 .OR. KEY.EQ.23    )
     &       .AND. PSLSI2.EQ.1 .AND. K.GE.PSLY)           GO TO 4210
C
          IF(S.GE.4)                                      GO TO 4210
C
          IF(I.EQ.1 .OR. (I.EQ.3 .AND. IT.EQ.3)) THEN
            FN(X,XX,I,4) =FN(X,XX,I,4)+TMG*ADT(1)*BD(K,4)*PSLR
            FN(X,XX,I,23)=FN(X,XX,I,23)
     &                   +TMG*SADT(MAX(-74,K-X))*BD(K,23)*PSLR
            FN(X,XX,I,5) =FN(X,XX,I,5)+TMG*ADT(2)*BD(K,5)*PSLR
            FN(X,XX,I,6)=FN(X,XX,I,6)
     &                  +TMG*CADT(K-NINT(NS(K,X)))*BD(K,6)*PSLR
          END IF
C
 4210     CONTINUE
C
          IF(DAIK14.EQ.0) THEN
            TMF=TMG*((WE(X,T,0,1,1)+WE(X,T,0,2,1))*MIN(8.0D-3,PRO)
     &               +WE(X,T,0,3,1)*MIN(7.5D-3,PRO)
     &               +WE(X,T,0,4,1)*PROS)
          ELSE IF(DAIK14.EQ.1) THEN
            TMF=TMG*(WE(X,T,0,0,1)*PRO+WE(X,T,0,4,1)*PROS)
          ELSE IF(DAIK14.EQ.2) THEN
            TMF=TMG*(WE(X,T,0,0,1)*7.5D-3+WE(X,T,0,4,1)*5.77D-3)
          ELSE IF(DAIK14.EQ.3) THEN
            TMF=TMG*(WE(X,T,0,0,1)*PRO+WE(X,T,0,4,1)*PROS)
          END IF
          IF(((DAIK14.EQ.0 .OR. DAIK14.EQ.1) .AND. K.GE.0) .OR.
     &       ((DAIK14.EQ.2 .OR. DAIK14.EQ.3) .AND. K.GE.KIJUN+1)) THEN
            TMF=TMF*HIKRATE
          END IF
          KAKORN(X,XX,I,1)=KAKORN(X,XX,I,1)+TMF
 4200   CONTINUE
C
        GE(X,T)=GE(X,T)-GED
        IF(ABS(GE(X,T)).LT.1.0D-6) THEN
          GE(X,T)=0.0D0
          CALL SUBC4(ZE,14,115,X,X,0,100,T,T,0,1,0,1,0,9,0,9)
          CALL SUBC5(WE,14,115,X,X,0,100,T,T,0,0,0,0,0,7,0,7,0,3,0,3)
        ELSE IF(GE(X,T).LE.-1.0D-6) THEN
          WRITE(6,*) '待期者裁定エラー:K=',K,'X=',X,'T=',T
          WRITE(6,*) 'GE=',GE(X,T),'GED=',GED,'Y1=',Y(X,T,1)
C          STOP
        END IF
C
      END IF
C
      RETURN
C
      END
C
