/*************************************
*                                    *
*    外枠システム  simlpart.c        *
*  （パート適用拡大者数の推計）      *
*                                    *
*************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "set.h"
#include "cntl.h"
#include "file_open.h"

void simlpart(void) 
{


/*  変数定義  */
    char    filename[250]    ; 
    int     pkubun  ; 
    int     ykubun  ;  
    int     ii      ;
    int     TMR     ;
    double  TMP     ; 
    double  TMQ     ; 
    double  TMS     ; 
    double  TMT     ; 
    int     XEND ;




  if(PART >=1){
    switch ( PARTK1 ) { 
        case 6: /* 125万人ベース */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-1.csv");
            break ;
        case 7: /*325万人ベース  */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-2.csv");
            break ;
        case 8: /*1050万人ベース  */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-3-1.csv");
            break ;
    }

  /*  ファイルを開く  */
    if ((fp_part = fopen(filename, "r")) == NULL) {
        fprintf(stderr, "パート入力ファイル（１段階）を開けません!\n");
        exit (2); /* 終了 */
    }

 
        karayomi( fp_part );  
    for ( kubun=1; kubun<=11; kubun++ ) {
        read_csv( buffer, fp_part, &data_number );
        ii = (int) buffer[0] ; 
        kbetu_partkiso[1][ii][1][1] = (double) buffer[1] ; 
        kbetu_partkiso[1][ii][2][1] = (double) buffer[2] ; 
        kbetu_partkiso[1][ii][3][1] = (double) buffer[3] ;
        kbetu_partkiso[2][ii][1][1] = (double) buffer[4] ; 
        kbetu_partkiso[2][ii][2][1] = (double) buffer[5] ; 
        kbetu_partkiso[2][ii][3][1] = (double) buffer[6] ; 
    }

        fclose(fp_part);


    switch ( PARTK2 ) { 
        case 1: /* 125万人ベース */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-1.csv");
            break ;
        case 2: /* 325万人ベース */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-2.csv");
            break ;
        case 3: /* 1050万人ベース */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-3-1.csv");
            break ;

    }

  /*  ファイルを開く  */
    if ((fp_part = fopen(filename, "r")) == NULL) {
        fprintf(stderr, "パート入力ファイル（２段階）を開けません!\n");
        exit (2); /* 終了 */
    }

        karayomi( fp_part );  
    for ( kubun=1; kubun<=11; kubun++ ) {
        read_csv( buffer, fp_part, &data_number );
        ii = (int) buffer[0] ; 
        kbetu_partkiso[1][ii][1][2] = (double) buffer[1] ; 
        kbetu_partkiso[1][ii][2][2] = (double) buffer[2] ; 
        kbetu_partkiso[1][ii][3][2] = (double) buffer[3] ;
        kbetu_partkiso[2][ii][1][2] = (double) buffer[4] ; 
        kbetu_partkiso[2][ii][2][2] = (double) buffer[5] ; 
        kbetu_partkiso[2][ii][3][2] = (double) buffer[6] ; 
    }

    /*  ファイルクローズ  */
        fclose(fp_part);

        PARTJJ = 1995 ; 
        PARTKK = 1996 ; 
		PARTLL = 1997 ; 

    for ( nendo=KS; nendo<=KE+1; nendo++ ) {
      for ( sei=0; sei<=4; sei++ ) {
        for ( nenrei=15; nenrei<=120; nenrei++ ) {
            tmae[1][nendo-STARTY][sei][nenrei] = kou12syu[nendo-STARTY][sei][nenrei] ;
            tmae[2][nendo-STARTY][sei][nenrei] = kou3syu[nendo-STARTY][sei][nenrei] ;
            tmae[3][nendo-STARTY][sei][nenrei] = kyosai[1][nendo-STARTY][sei][nenrei] ;
            tmae[4][nendo-STARTY][sei][nenrei] = kyosai[2][nendo-STARTY][sei][nenrei] ;
            tmae[5][nendo-STARTY][sei][nenrei] = kyosai[3][nendo-STARTY][sei][nenrei] ;
            tmae[6][nendo-STARTY][sei][nenrei] = kounen[nendo-STARTY][sei][nenrei] ;
            tmae[9][nendo-STARTY][sei][nenrei] = ichigouip[nendo-STARTY][sei][nenrei] ;
            tmae[10][nendo-STARTY][sei][nenrei] = ichigou[nendo-STARTY][sei][nenrei] ;
            tmae[11][nendo-STARTY][sei][nenrei] = kou12syu3[nendo-STARTY][sei][nenrei] ;
            tmae[12][nendo-STARTY][sei][nenrei] = kou3syu3[nendo-STARTY][sei][nenrei] ;
            tmae[13][nendo-STARTY][sei][nenrei] = kyosai3[1][nendo-STARTY][sei][nenrei] ;
            tmae[14][nendo-STARTY][sei][nenrei] = kyosai3[2][nendo-STARTY][sei][nenrei] ;
            tmae[15][nendo-STARTY][sei][nenrei] = kyosai3[3][nendo-STARTY][sei][nenrei] ;
            tmae[16][nendo-STARTY][sei][nenrei] = kyosai3[4][nendo-STARTY][sei][nenrei] ;
            tmae[17][nendo-STARTY][sei][nenrei] = kyosai3[5][nendo-STARTY][sei][nenrei] ;
            tmae[18][nendo-STARTY][sei][nenrei] = kyosai3[7][nendo-STARTY][sei][nenrei] ;
            tmae[19][nendo-STARTY][sei][nenrei] = kyosai3[6][nendo-STARTY][sei][nenrei] ;
            tmae[20][nendo-STARTY][sei][nenrei] = sangou[nendo-STARTY][sei][nenrei] ;
            tmae[21][nendo-STARTY][sei][nenrei] = kounen3[nendo-STARTY][sei][nenrei] ; 
        }
      }
    }



    for ( nendo=PARTKYR; nendo<=KE; nendo++ ) {
        for ( sei=1; sei<=2; sei++ ) {
            for ( kubun=1; kubun<=15; kubun++ ) {
                TMR = kubun * 5 + 12 ; 
                kbetu_tankoj[nendo-STARTY][sei][kubun] = 0.0 ;
                for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
					if(MODE ==3 || MODE ==6){
                    	kbetu_tankoj[nendo-STARTY][sei][kubun] += (koyouj_m[3][nendo-STARTY][sei][nenrei]+koyouj_m[4][nendo-STARTY][sei][nenrei]+koyouj_m[5][nendo-STARTY][sei][nenrei]) ;
					}
					else {
						kbetu_tankoj[nendo-STARTY][sei][kubun] += (koyouj_m[4][nendo-STARTY][sei][nenrei]+koyouj_m[5][nendo-STARTY][sei][nenrei]) ;
					}
                }
            }
        }
    }



   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( kubun=1; kubun<=15; kubun++ ) {
        for ( pkubun=1; pkubun<=3; pkubun++ ) { 
          for ( ykubun=1; ykubun<=2; ykubun++ ) {

            if ( kbetu_tankoj[PARTKYR-STARTY][sei][kubun] > 0.0 ) {
                kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun]
                 = kbetu_partkiso[sei][kubun][pkubun][ykubun]
                   * kbetu_tankoj[nendo-STARTY][sei][kubun] / kbetu_tankoj[PARTKYR-STARTY][sei][kubun] ;
            }
            else {  /*  エラー  */
              fprintf(stderr, "パート推計で%d年度の性%d年齢区分%dの短雇がマイナス!\n", PARTKYR, sei, kubun );
              printf("パート推計で%d年度の性%d年齢区分%dの短雇がマイナス!\n", PARTKYR, sei, kubun );
              kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] = 0.0 ;
            }

          }
        }

        for ( ykubun=0; ykubun<=2; ykubun++ ) {
          if (( kubun >= 2 ) && ( kubun <= 9 )) { 
              kbetu_partnin[nendo-STARTY][sei][kubun][1][ykubun]
                += kbetu_partnin[nendo-STARTY][sei][kubun][3][ykubun] ;
              kbetu_partnin[nendo-STARTY][sei][kubun][3][ykubun] = 0.0 ;
          }
          kbetu_partnin[nendo-STARTY][sei][kubun][0][ykubun]
            = kbetu_partnin[nendo-STARTY][sei][kubun][1][ykubun] 
            + kbetu_partnin[nendo-STARTY][sei][kubun][2][ykubun] 
            + kbetu_partnin[nendo-STARTY][sei][kubun][3][ykubun] ;
        }
      }
    }
   }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( kubun=2; kubun<=9; kubun++ ) {
          TMR = kubun * 5 + 12 ; 
          for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
              kbetu_partgen[nendo-STARTY][sei][kubun][1] += ichigouip[nendo-STARTY][sei][nenrei] ;
                kbetu_partgen[nendo-STARTY][sei][kubun][2] += sangou[nendo-STARTY][sei][nenrei] ;
          }
      }

      for ( kubun=10; kubun<=11; kubun++ ) {
          TMR = kubun * 5 + 12 ; 
          for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
              kbetu_partgen[nendo-STARTY][sei][kubun][1] += ichigouni[nendo-STARTY][sei][nenrei] ;
          }
      }
    }
   }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {

      for ( kubun=2; kubun<=9; kubun++ ) {
        for ( pkubun=1; pkubun<=3; pkubun++ ) {
          for ( ykubun=1; ykubun<=2; ykubun++ ) {

            if ( kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] <= 0.0 ) { 
              kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] = 0.0 ;
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][pkubun][ykubun] = 1.0 ;
              }
            }
            else if ( kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun]
                       <= kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] ) { 
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][pkubun][ykubun] = 
                 ( kbetu_partgen[nendo-STARTY][sei][kubun][pkubun]
                    - kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] ) 
                 / kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] ;
              }
            }
            else if ( nendo < KE ) { 
              printf("パート %d年度の性%d、年齢区分%d、パート区分%d、猶予区分%d が減算しきれない\n",
                      nendo, sei, kubun, pkubun, ykubun ) ;
              fprintf(fp_err, "パート %d年度の性%d、年齢区分%d、パート区分%d、猶予区分%d が減算しきれない\n",
                      nendo, sei, kubun, pkubun, ykubun ) ;

              kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] =
                kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] ;
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][pkubun][ykubun] = 0.0 ;
              }
            }
          }
        }
      }

      for ( kubun=10; kubun<=11; kubun++ ) {
        for ( ykubun=1; ykubun<=2; ykubun++ ) {  
            if ( kbetu_partgen[nendo-STARTY][sei][kubun][1] <= 0.0 ) { 
              kbetu_partnin[nendo-STARTY][sei][kubun][1][ykubun] = 0.0 ;
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][1][ykubun] = 1.0 ;
              }
            }
            else if ( kbetu_partnin[nendo-STARTY][sei][kubun][1][ykubun]
                       <= kbetu_partgen[nendo-STARTY][sei][kubun][1] ) {
              TMR = kubun * 5 + 12 ;
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][1][ykubun] = 
                 ( kbetu_partgen[nendo-STARTY][sei][kubun][1]
                    - kbetu_partnin[nendo-STARTY][sei][kubun][1][ykubun] ) 
                 / kbetu_partgen[nendo-STARTY][sei][kubun][1] ;
              }
            }
            else if ( nendo < KE ) { 
              printf("パート %d年度の性%d、年齢区分%d、パート区分1、猶予区分%dが減算しきれない\n",
                      nendo, sei, kubun, ykubun ) ;
              fprintf(fp_err, "パート %d年度の性%d、年齢区分%d、パート区分1、猶予区分%dが減算しきれない\n",
                      nendo, sei, kubun, ykubun ) ;

              kbetu_partnin[nendo-STARTY][sei][kubun][1][ykubun]
               = kbetu_partgen[nendo-STARTY][sei][kubun][1] ;
              TMR = kubun * 5 + 12 ;
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][1][ykubun] = 0.0 ;
              }
            }
        }
      }

    }
   }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {

    if(MODE == 3 || MODE == 6){
		for ( nenrei=15; nenrei<=19; nenrei++ ) {
        	for ( ykubun=1; ykubun<=2; ykubun++ ) {
         	 for ( sei=1; sei<=2; sei++ ) {
            	partnin[nendo-STARTY][sei][nenrei][3][ykubun]
              	= kbetu_partnin[nendo-STARTY][sei][1][3][ykubun]
              	* (koyouj_m[3][nendo-STARTY][sei][nenrei]+koyouj_m[4][nendo-STARTY][sei][nenrei]+koyouj_m[5][nendo-STARTY][sei][nenrei]) / kbetu_tankoj[nendo-STARTY][sei][1] ;
          	}
          	partnin[nendo-STARTY][3][nenrei][3][ykubun]
           		= partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                	* (koyouj_m[3][nendo-STARTY][3][nenrei]+koyouj_m[4][nendo-STARTY][3][nenrei]+koyouj_m[5][nendo-STARTY][3][nenrei]) / (koyouj_m[3][nendo-STARTY][2][nenrei]+koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
          	partnin[nendo-STARTY][4][nenrei][3][ykubun]
           		= partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                	* (koyouj_m[3][nendo-STARTY][4][nenrei]+koyouj_m[4][nendo-STARTY][4][nenrei]+koyouj_m[5][nendo-STARTY][4][nenrei]) / (koyouj_m[3][nendo-STARTY][2][nenrei]+koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
          	/*  男女計  */
          partnin[nendo-STARTY][0][nenrei][3][ykubun]
          	  = partnin[nendo-STARTY][1][nenrei][3][ykubun] + partnin[nendo-STARTY][2][nenrei][3][ykubun] ;
       	 }
      	}
	}
	else {
		for ( nenrei=15; nenrei<=19; nenrei++ ) {
           for ( ykubun=1; ykubun<=2; ykubun++ ) {
         	 for ( sei=1; sei<=2; sei++ ) {
            	partnin[nendo-STARTY][sei][nenrei][3][ykubun]
              	= kbetu_partnin[nendo-STARTY][sei][1][3][ykubun]
              	* (koyouj_m[4][nendo-STARTY][sei][nenrei]+koyouj_m[5][nendo-STARTY][sei][nenrei]) / kbetu_tankoj[nendo-STARTY][sei][1] ;
          	}
          	partnin[nendo-STARTY][3][nenrei][3][ykubun]
           		= partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                	* (koyouj_m[4][nendo-STARTY][3][nenrei]+koyouj_m[5][nendo-STARTY][3][nenrei]) / (koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
          	partnin[nendo-STARTY][4][nenrei][3][ykubun]
           		= partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                	* (koyouj_m[4][nendo-STARTY][4][nenrei]+koyouj_m[5][nendo-STARTY][4][nenrei]) / (koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
          	/*  男女計  */
          partnin[nendo-STARTY][0][nenrei][3][ykubun]
          	  = partnin[nendo-STARTY][1][nenrei][3][ykubun] + partnin[nendo-STARTY][2][nenrei][3][ykubun] ;
       	 }
      	}
	}	

      for ( kubun=2; kubun<=9; kubun++ ) {
        TMR = kubun * 5 + 12 ; 
        for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {

            for ( ykubun=1; ykubun<=2; ykubun++ ) {
              for ( sei=1; sei<=2; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][1][ykubun] =
                   ichigouip[nendo-STARTY][sei][nenrei] 
                     * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][1][ykubun] ) ;
              }
              for ( sei=3; sei<=4; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][1][ykubun] =
                   ichigouip[nendo-STARTY][sei][nenrei] 
                     * ( 1.0 - partgenwari[nendo-STARTY][2][nenrei][1][ykubun] ) ;
              }
              /*  男女計  */
              partnin[nendo-STARTY][0][nenrei][1][ykubun]
                = partnin[nendo-STARTY][1][nenrei][1][ykubun] + partnin[nendo-STARTY][2][nenrei][1][ykubun] ; 
            }
            if ( nendo >= PARTYR1-1 ) { 
                /* １段階 */
                if ( nendo < PARTYR2 ) {
                  if ( nendo == PARTYR1-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      ichigouip[PARTJJ-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][1][1] ;
                      ichigouni[PARTJJ-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTJJ-STARTY][sei][nenrei]
                        = ichigouip[PARTJJ-STARTY][sei][nenrei] + ichigouni[PARTJJ-STARTY][sei][nenrei] ;
                    }
                    for ( sei=3; sei<=4; sei++ ) {
                      ichigouip[PARTJJ-STARTY][sei][nenrei] 
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][1][1] ;
                      ichigouni[PARTJJ-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTJJ-STARTY][sei][nenrei]
                        = ichigouip[PARTJJ-STARTY][sei][nenrei] + ichigouni[PARTJJ-STARTY][sei][nenrei] ;
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      ichigouip[PARTKK-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][1][2] ;
                      ichigouni[PARTKK-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTKK-STARTY][sei][nenrei]
                        = ichigouip[PARTKK-STARTY][sei][nenrei] + ichigouni[PARTKK-STARTY][sei][nenrei] ;
                    }
                    for ( sei=3; sei<=4; sei++ ) {
                      ichigouip[PARTKK-STARTY][sei][nenrei] 
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][1][2] ;
                      ichigouni[PARTKK-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTKK-STARTY][sei][nenrei]
                        = ichigouip[PARTKK-STARTY][sei][nenrei] + ichigouni[PARTKK-STARTY][sei][nenrei] ;
                    }
                    for ( sei=1; sei<=2; sei++ ) {
                      ichigouip[nendo-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][1][1] ;
                      ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[nendo-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                    }
                    for ( sei=3; sei<=4; sei++ ) {
                      ichigouip[nendo-STARTY][sei][nenrei] 
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][1][1] ;
                      ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[nendo-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                    }
                  }
                  else {
                  	for ( sei=1; sei<=2; sei++ ) {
                    	ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][1][1] ;
                  	}
                  	for ( sei=3; sei<=4; sei++ ) {
                    	ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][1][1] ;
                  	}
                  }
                }
                else if( nendo >= PARTYR2 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][1][2] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][1][2] ;
                  }
                }
                /*  男女計  */
                ichigouip[nendo-STARTY][0][nenrei]
                  = ichigouip[nendo-STARTY][1][nenrei] + ichigouip[nendo-STARTY][2][nenrei] ;
                if ( nendo == PARTYR1-1 ) {
                  ichigouip[PARTJJ-STARTY][0][nenrei]
                    = ichigouip[PARTJJ-STARTY][1][nenrei] + ichigouip[PARTJJ-STARTY][2][nenrei] ;
                  ichigouni[PARTJJ-STARTY][0][nenrei]
                    = ichigouni[PARTJJ-STARTY][1][nenrei] + ichigouni[PARTJJ-STARTY][2][nenrei] ;
                  ichigou[PARTJJ-STARTY][0][nenrei]
                    = ichigou[PARTJJ-STARTY][1][nenrei] + ichigou[PARTJJ-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR2-1 ) {
                  ichigouip[PARTKK-STARTY][0][nenrei]
                    = ichigouip[PARTKK-STARTY][1][nenrei] + ichigouip[PARTKK-STARTY][2][nenrei] ;
                  ichigouni[PARTKK-STARTY][0][nenrei]
                    = ichigouni[PARTKK-STARTY][1][nenrei] + ichigouni[PARTKK-STARTY][2][nenrei] ;
                  ichigou[PARTKK-STARTY][0][nenrei]
                    = ichigou[PARTKK-STARTY][1][nenrei] + ichigou[PARTKK-STARTY][2][nenrei] ;
                }
            }
         
            for ( ykubun=1; ykubun<=2; ykubun++ ) {
              for ( sei=1; sei<=2; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][2][ykubun]
                  = ( qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei]
                      + kyosai3[4][nendo-STARTY][sei][nenrei] + kyosai3[5][nendo-STARTY][sei][nenrei]
                      + kyosai3[6][nendo-STARTY][sei][nenrei] + kyosai3[7][nendo-STARTY][sei][nenrei] )
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][2][ykubun] )  ;
                partnin[nendo-STARTY][sei][nenrei][8][ykubun] = partnin[nendo-STARTY][sei][nenrei][2][ykubun] ;
              }
              partnin[nendo-STARTY][3][nenrei][2][ykubun] = partnin[nendo-STARTY][2][nenrei][2][ykubun] ;
              partnin[nendo-STARTY][3][nenrei][8][ykubun] = partnin[nendo-STARTY][2][nenrei][8][ykubun] ;
              partnin[nendo-STARTY][4][nenrei][2][ykubun] = 0.0 ;
              partnin[nendo-STARTY][4][nenrei][8][ykubun] = 0.0 ;
              /*  男女計  */
              partnin[nendo-STARTY][0][nenrei][2][ykubun]
                = partnin[nendo-STARTY][1][nenrei][2][ykubun] + partnin[nendo-STARTY][2][nenrei][2][ykubun] ;
              partnin[nendo-STARTY][0][nenrei][8][ykubun]
                = partnin[nendo-STARTY][1][nenrei][8][ykubun] + partnin[nendo-STARTY][2][nenrei][8][ykubun] ;
            }

            if ( nendo >= PARTYR1-1 ) { 
                if ( nendo < PARTYR2 ) {
                  if ( nendo == PARTYR1-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      qkou12syu3[PARTJJ-STARTY][sei][nenrei]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      kou3syu3[PARTJJ-STARTY][sei][nenrei]
                        = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      for ( seido=4; seido<=7; seido++ ) {
                        kyosai3[seido][PARTJJ-STARTY][sei][nenrei]
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      }
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      qkou12syu3[PARTKK-STARTY][sei][nenrei]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                      kou3syu3[PARTKK-STARTY][sei][nenrei]
                        = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                      for ( seido=4; seido<=7; seido++ ) {
                        kyosai3[seido][PARTKK-STARTY][sei][nenrei]
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                      }
                    }
					for ( sei=1; sei<=2; sei++ ) {
                      qkou12syu3[nendo-STARTY][sei][nenrei]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      kou3syu3[nendo-STARTY][sei][nenrei]
                        = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      for ( seido=4; seido<=7; seido++ ) {
                        kyosai3[seido][nendo-STARTY][sei][nenrei]
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      }
                    }
                  }                  
                  else {
                  	for ( sei=1; sei<=2; sei++ ) {
                    	qkou12syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                    	kou3syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                    	for ( seido=4; seido<=7; seido++ ) {
                      	kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                    	}
                  	}
                  }
                }
                else if ( nendo >= PARTYR2 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    qkou12syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                    kou3syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                    for ( seido=4; seido<=7; seido++ ) {
                      kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                    }
                  }
                }
                qkou12syu3[nendo-STARTY][3][nenrei] = qkou12syu3[nendo-STARTY][2][nenrei] ;
                kou3syu3[nendo-STARTY][3][nenrei] = kou3syu3[nendo-STARTY][2][nenrei] ;
                for ( seido=4; seido<=7; seido++ ) {
                  kyosai3[seido][nendo-STARTY][3][nenrei] = kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  qkou12syu3[PARTJJ-STARTY][3][nenrei] = qkou12syu3[PARTJJ-STARTY][2][nenrei] ;
                  kou3syu3[PARTJJ-STARTY][3][nenrei] = kou3syu3[PARTJJ-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][3][nenrei] = kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  qkou12syu3[PARTKK-STARTY][3][nenrei] = qkou12syu3[PARTKK-STARTY][2][nenrei] ;
                  kou3syu3[PARTKK-STARTY][3][nenrei] = kou3syu3[PARTKK-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][3][nenrei] = kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }
                qkou12syu3[nendo-STARTY][0][nenrei]
                  = qkou12syu3[nendo-STARTY][1][nenrei] + qkou12syu3[nendo-STARTY][2][nenrei] ;
                kou3syu3[nendo-STARTY][0][nenrei]
                  = kou3syu3[nendo-STARTY][1][nenrei] + kou3syu3[nendo-STARTY][2][nenrei] ;
                for ( seido=4; seido<=7; seido++ ) {
                  kyosai3[seido][nendo-STARTY][0][nenrei]
                    = kyosai3[seido][nendo-STARTY][1][nenrei] + kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  qkou12syu3[PARTJJ-STARTY][0][nenrei]
                    = qkou12syu3[PARTJJ-STARTY][1][nenrei] + qkou12syu3[PARTJJ-STARTY][2][nenrei] ;
                  kou3syu3[PARTJJ-STARTY][0][nenrei]
                    = kou3syu3[PARTJJ-STARTY][1][nenrei] + kou3syu3[PARTJJ-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][0][nenrei]
                      = kyosai3[seido][PARTJJ-STARTY][1][nenrei] + kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  qkou12syu3[PARTKK-STARTY][0][nenrei]
                    = qkou12syu3[PARTKK-STARTY][1][nenrei] + qkou12syu3[PARTKK-STARTY][2][nenrei] ;
                  kou3syu3[PARTKK-STARTY][0][nenrei]
                    = kou3syu3[PARTKK-STARTY][1][nenrei] + kou3syu3[PARTKK-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][0][nenrei]
                      = kyosai3[seido][PARTKK-STARTY][1][nenrei] + kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }
            }

            for ( ykubun=0; ykubun<=2; ykubun++ ) {
              for ( sei=1; sei<=2; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][2][ykubun]
                  += ( kyosai3[1][nendo-STARTY][sei][nenrei] + kyosai3[2][nendo-STARTY][sei][nenrei]
                       + kyosai3[3][nendo-STARTY][sei][nenrei] )
                     * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][2][ykubun] )  ; 
                partnin[nendo-STARTY][sei][nenrei][5][ykubun] = kyosai3[1][nendo-STARTY][sei][nenrei]
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][2][ykubun] )  ; /* 国共済 */
                partnin[nendo-STARTY][sei][nenrei][6][ykubun] = kyosai3[2][nendo-STARTY][sei][nenrei]
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][2][ykubun] )  ; /* 地共済 */
                partnin[nendo-STARTY][sei][nenrei][7][ykubun] = kyosai3[3][nendo-STARTY][sei][nenrei]
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][2][ykubun] )  ; /* 私学共済 */
              }
              partnin[nendo-STARTY][3][nenrei][2][ykubun] = partnin[nendo-STARTY][2][nenrei][2][ykubun] ;
              partnin[nendo-STARTY][4][nenrei][2][ykubun] = 0.0 ;
              for ( pkubun=5; pkubun<=7; pkubun++ ) {
                partnin[nendo-STARTY][3][nenrei][pkubun][ykubun]
                  = partnin[nendo-STARTY][2][nenrei][pkubun][ykubun] ;
                partnin[nendo-STARTY][4][nenrei][pkubun][ykubun] = 0.0 ;
              }
              partnin[nendo-STARTY][0][nenrei][2][ykubun]
                = partnin[nendo-STARTY][1][nenrei][2][ykubun] + partnin[nendo-STARTY][2][nenrei][2][ykubun] ;
              for ( pkubun=5; pkubun<=7; pkubun++ ) {
                partnin[nendo-STARTY][0][nenrei][pkubun][ykubun]
                  = partnin[nendo-STARTY][1][nenrei][pkubun][ykubun] + partnin[nendo-STARTY][2][nenrei][pkubun][ykubun] ;
              }
            }
            if ( nendo >= PARTYR1-1 ) {
                if ( nendo < PARTYR2 ) {
                  if ( nendo == PARTYR1-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      for ( seido=1; seido<=3; seido++ ) {
                        kyosai3[seido][PARTJJ-STARTY][sei][nenrei] 
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      }
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      for ( seido=1; seido<=3; seido++ ) {
                        kyosai3[seido][PARTKK-STARTY][sei][nenrei] 
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                      }
                    }
                    for ( sei=1; sei<=2; sei++ ) {
                      for ( seido=1; seido<=3; seido++ ) {
                        kyosai3[seido][nendo-STARTY][sei][nenrei] 
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                      }
                    }
                  }
                  else {
                  	for ( sei=1; sei<=2; sei++ ) {
                    	for ( seido=1; seido<=3; seido++ ) {
                      	kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][1] ;
                    	}
                  	}
                  }
                }
                else if ( nendo >= PARTYR2 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    for ( seido=1; seido<=3; seido++ ) {
                      kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][2][2] ;
                    }
                  }
                }
                for ( seido=1; seido<=3; seido++ ) {
                  kyosai3[seido][nendo-STARTY][3][nenrei] = kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][3][nenrei] = kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][3][nenrei] = kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }
                /*  男女計  */
                for ( seido=1; seido<=3; seido++ ) {
                  kyosai3[seido][nendo-STARTY][0][nenrei]
                    = kyosai3[seido][nendo-STARTY][1][nenrei] + kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][0][nenrei]
                      = kyosai3[seido][PARTJJ-STARTY][1][nenrei] + kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][0][nenrei]
                      = kyosai3[seido][PARTKK-STARTY][1][nenrei] + kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }

            }

        }
      }
      
      for ( kubun=10; kubun<=11; kubun++ ) {
        TMR = kubun * 5 + 12 ; 
        for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {

          for ( ykubun=1; ykubun<=2; ykubun++ ) {
            for ( sei=1; sei<=2; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][1][ykubun] = ichigouni[nendo-STARTY][sei][nenrei] 
                * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][1][ykubun] ) ;
            }
            for ( sei=3; sei<=4; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][1][ykubun] = ichigouni[nendo-STARTY][sei][nenrei] 
                * ( 1.0 - partgenwari[nendo-STARTY][2][nenrei][1][ykubun] ) ;
            }
            /*  男女計  */
            partnin[nendo-STARTY][0][nenrei][1][ykubun]
              = partnin[nendo-STARTY][1][nenrei][1][ykubun] + partnin[nendo-STARTY][2][nenrei][1][ykubun] ; 
          }
          if ( nendo >= PARTYR1-1 ) {
            if ( nendo < PARTYR2 ) {
                if ( nendo == PARTYR1-1 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouni[PARTJJ-STARTY][sei][nenrei]
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][1][1] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouni[PARTJJ-STARTY][sei][nenrei] 
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][1][1] ;
                  }
                }
                else if ( nendo == PARTYR2-1 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouni[PARTKK-STARTY][sei][nenrei]
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][1][2] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouni[PARTKK-STARTY][sei][nenrei] 
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][1][2] ;
                  }
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouni[nendo-STARTY][sei][nenrei]
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][1][1] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouni[nendo-STARTY][sei][nenrei] 
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][1][1] ;
                  }
                }
                
                else {
                	for ( sei=1; sei<=2; sei++ ) {
                  		ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][1][1] ;
                	}
                	for ( sei=3; sei<=4; sei++ ) {
                  		ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][1][1] ;
                	}
                }
            }
            else if ( nendo >= PARTYR2 ) {
                for ( sei=1; sei<=2; sei++ ) {
                  ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][1][2] ;
                }
                for ( sei=3; sei<=4; sei++ ) {
                  ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][1][2] ;
                }
            }
            ichigouni[nendo-STARTY][0][nenrei]
              = ichigouni[nendo-STARTY][1][nenrei] + ichigouni[nendo-STARTY][2][nenrei] ;
            if ( nendo == PARTYR1-1 ) {
              ichigouni[PARTJJ-STARTY][0][nenrei]
                = ichigouni[PARTJJ-STARTY][1][nenrei] + ichigouni[PARTJJ-STARTY][2][nenrei] ;
            }
            if ( nendo == PARTYR2-1) {
              ichigouni[PARTKK-STARTY][0][nenrei]
                = ichigouni[PARTKK-STARTY][1][nenrei] + ichigouni[PARTKK-STARTY][2][nenrei] ;
            }
          }



        if( MODE == 3 || MODE == 6){ 
		 for ( ykubun=0; ykubun<=2; ykubun++ ) {
            for ( sei=1; sei<=2; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][3][ykubun]
                = kbetu_partnin[nendo-STARTY][sei][kubun][3][ykubun]
                * (koyouj_m[3][nendo-STARTY][sei][nenrei]+koyouj_m[4][nendo-STARTY][sei][nenrei]+koyouj_m[5][nendo-STARTY][sei][nenrei]) / kbetu_tankoj[nendo-STARTY][sei][kubun] ;
            }
            partnin[nendo-STARTY][3][nenrei][3][ykubun]
              = partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                  * (koyouj_m[3][nendo-STARTY][3][nenrei]+koyouj_m[4][nendo-STARTY][3][nenrei]+koyouj_m[5][nendo-STARTY][3][nenrei]) / (koyouj_m[3][nendo-STARTY][2][nenrei]+koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
            partnin[nendo-STARTY][4][nenrei][3][ykubun]
              = partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                  * (koyouj_m[3][nendo-STARTY][4][nenrei]+koyouj_m[4][nendo-STARTY][4][nenrei]+koyouj_m[5][nendo-STARTY][4][nenrei]) / (koyouj_m[3][nendo-STARTY][2][nenrei]+koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
            /*  男女計  */
            partnin[nendo-STARTY][0][nenrei][3][ykubun]
              = partnin[nendo-STARTY][1][nenrei][3][ykubun] + partnin[nendo-STARTY][2][nenrei][3][ykubun] ;
          }
		}
		else {
		 for ( ykubun=0; ykubun<=2; ykubun++ ) {
            for ( sei=1; sei<=2; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][3][ykubun]
                = kbetu_partnin[nendo-STARTY][sei][kubun][3][ykubun]
                * (koyouj_m[4][nendo-STARTY][sei][nenrei]+koyouj_m[5][nendo-STARTY][sei][nenrei]) / kbetu_tankoj[nendo-STARTY][sei][kubun] ;
            }
            partnin[nendo-STARTY][3][nenrei][3][ykubun]
              = partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                  * (koyouj_m[4][nendo-STARTY][3][nenrei]+koyouj_m[5][nendo-STARTY][3][nenrei]) / (koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
            partnin[nendo-STARTY][4][nenrei][3][ykubun]
              = partnin[nendo-STARTY][2][nenrei][3][ykubun] 
                  * (koyouj_m[4][nendo-STARTY][4][nenrei]+koyouj_m[5][nendo-STARTY][4][nenrei]) / (koyouj_m[4][nendo-STARTY][2][nenrei]+koyouj_m[5][nendo-STARTY][2][nenrei]) ;
            /*  男女計  */
            partnin[nendo-STARTY][0][nenrei][3][ykubun]
              = partnin[nendo-STARTY][1][nenrei][3][ykubun] + partnin[nendo-STARTY][2][nenrei][3][ykubun] ;
          }
		}

          if ( ( MODE == 5 || MODE == 6) && ( nendo >= PARTYR1-1 ) ) {
            XEND = xend[8][nendo-STARTY] ;
            if ( XEND < 60 ) { XEND = 60 ; }

            if ( nenrei < XEND ) {
                for ( sei=1; sei<=4; sei++ ) {
                  if ( ichigouip[nendo-STARTY][sei][nenrei] + sangou[nendo-STARTY][sei][nenrei] > 0.0 ) {
                    partgenwari[nendo-STARTY][sei][nenrei][3][1]
                      = 1.0 - partnin[nendo-STARTY][sei][nenrei][3][1]
                         / ( ichigouip[nendo-STARTY][sei][nenrei] + sangou[nendo-STARTY][sei][nenrei] ) ;
                    partgenwari[nendo-STARTY][sei][nenrei][3][2]
                      = 1.0 - partnin[nendo-STARTY][sei][nenrei][3][2]
                         / ( ichigouip[nendo-STARTY][sei][nenrei] + sangou[nendo-STARTY][sei][nenrei] ) ;
                  }
                  else {
                    partgenwari[nendo-STARTY][sei][nenrei][3][1] = 1.0 ;
                    partgenwari[nendo-STARTY][sei][nenrei][3][2] = 1.0 ;
                  }
                  if ( ( partgenwari[nendo-STARTY][sei][nenrei][3][1] > 0 )
                         && ( partgenwari[nendo-STARTY][sei][nenrei][3][1] < 1.0 ) ) { 
                      partnin[nendo-STARTY][sei][nenrei][1][1]
                        += ichigouip[nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][2][1]
                        = sangou[nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][5][1]
                        = kyosai3[1][nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][6][1]
                        = kyosai3[2][nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][7][1]
                        = kyosai3[3][nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][8][1]
                        = ( qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei] )
                            * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][3][1] = 0.0 ;

                  }
                  else if ( partgenwari[nendo-STARTY][sei][nenrei][3][1] < 0 ) { 
                      partgenwari[nendo-STARTY][sei][nenrei][3][1] = 0.0 ;
                      partnin[nendo-STARTY][sei][nenrei][1][1] = ichigouip[nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][2][1] = sangou[nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][5][1] = kyosai3[1][nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][6][1] = kyosai3[2][nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][7][1] = kyosai3[3][nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][8][1]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][1][0] = partnin[nendo-STARTY][sei][nenrei][1][1] ;
                      partnin[nendo-STARTY][sei][nenrei][2][0] = partnin[nendo-STARTY][sei][nenrei][2][1] ;
                      partnin[nendo-STARTY][sei][nenrei][5][0] = partnin[nendo-STARTY][sei][nenrei][5][1] ;
                      partnin[nendo-STARTY][sei][nenrei][6][0] = partnin[nendo-STARTY][sei][nenrei][6][1] ;
                      partnin[nendo-STARTY][sei][nenrei][7][0] = partnin[nendo-STARTY][sei][nenrei][7][1] ;
                      partnin[nendo-STARTY][sei][nenrei][8][0] = partnin[nendo-STARTY][sei][nenrei][8][1] ;
                  }
                  if ( ( partgenwari[nendo-STARTY][sei][nenrei][3][2] > 0 )
                         && ( partgenwari[nendo-STARTY][sei][nenrei][3][2] < 1.0 ) ) { 
                      partnin[nendo-STARTY][sei][nenrei][1][2]
                        += ichigouip[nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][2][2]
                         = sangou[nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][5][2]
                        = kyosai3[1][nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][6][2]
                        = kyosai3[2][nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][7][2]
                        = kyosai3[3][nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][8][2]
                        = ( qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei] )
                            * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][3][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][3][2] = 0.0 ;
                  }
                  else if ( partgenwari[nendo-STARTY][sei][nenrei][3][2] < 0 ) { 
                      partgenwari[nendo-STARTY][sei][nenrei][3][2] = 0.0 ;
                      partnin[nendo-STARTY][sei][nenrei][1][2] = ichigouip[nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][2][2] = sangou[nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][5][2] = kyosai3[1][nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][6][2] = kyosai3[2][nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][7][2] = kyosai3[3][nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][8][2]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei] ;
                  }
                  if ( nendo == PARTYR1-1 ) {
                    ichigouip[PARTJJ-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    ichigouni[PARTJJ-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ; 
                    ichigou[PARTJJ-STARTY][sei][nenrei]
                      = ichigouip[PARTJJ-STARTY][sei][nenrei] + ichigouni[PARTJJ-STARTY][sei][nenrei] ;
                    qkou12syu3[PARTJJ-STARTY][sei][nenrei]
                      = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    kou3syu3[PARTJJ-STARTY][sei][nenrei] 
                      = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    for ( seido=1; seido<=7; seido++ ) {
                      kyosai3[seido][PARTJJ-STARTY][sei][nenrei]
                        = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    }
                  }
				  else if ( nendo <= PARTYR2-1 ) {
                    ichigouip[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ; 
                    ichigou[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                    qkou12syu3[nendo-STARTY][sei][nenrei]
                      = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    kou3syu3[nendo-STARTY][sei][nenrei] 
                      = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    for ( seido=1; seido<=7; seido++ ) {
                      kyosai3[seido][nendo-STARTY][sei][nenrei]
                        = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][1] ;
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    ichigouip[PARTKK-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    ichigouni[PARTKK-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ; 
                    ichigou[PARTKK-STARTY][sei][nenrei]
                      = ichigouip[PARTKK-STARTY][sei][nenrei] + ichigouni[PARTKK-STARTY][sei][nenrei] ;
                    qkou12syu3[PARTKK-STARTY][sei][nenrei]
                      = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    kou3syu3[PARTKK-STARTY][sei][nenrei] 
                      = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    for ( seido=1; seido<=7; seido++ ) {
                      kyosai3[seido][PARTKK-STARTY][sei][nenrei]
                        = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    }
                  }
				  else {
                    ichigouip[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ; 
                    ichigou[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                    qkou12syu3[nendo-STARTY][sei][nenrei]
                      = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    kou3syu3[nendo-STARTY][sei][nenrei] 
                      = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    for ( seido=1; seido<=7; seido++ ) {
                      kyosai3[seido][nendo-STARTY][sei][nenrei]
                        = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][3][2] ;
                    }
                  }




                }
            }

            ichigouip[nendo-STARTY][2][nenrei]
              = ichigouip[nendo-STARTY][3][nenrei] + ichigouip[nendo-STARTY][4][nenrei] ;
            qkou12syu3[nendo-STARTY][2][nenrei] = qkou12syu3[nendo-STARTY][3][nenrei] ;
            kou3syu3[nendo-STARTY][2][nenrei] = kou3syu3[nendo-STARTY][3][nenrei] ;
            for ( seido=1; seido<=7; seido++ ) {
              kyosai3[seido][nendo-STARTY][2][nenrei] = kyosai3[seido][nendo-STARTY][3][nenrei] ; 
            }
            for ( ii=1; ii<=8; ii++ ) {
              partnin[nendo-STARTY][2][nenrei][ii][0]
                = partnin[nendo-STARTY][3][nenrei][ii][0] + partnin[nendo-STARTY][4][nenrei][ii][0] ;
              partnin[nendo-STARTY][2][nenrei][ii][1]
                = partnin[nendo-STARTY][3][nenrei][ii][1] + partnin[nendo-STARTY][4][nenrei][ii][1] ;
              partnin[nendo-STARTY][2][nenrei][ii][2]
                = partnin[nendo-STARTY][3][nenrei][ii][2] + partnin[nendo-STARTY][4][nenrei][ii][2] ;
            }
            if ( nendo == PARTYR1-1 ) {
              ichigouip[PARTJJ-STARTY][2][nenrei]
                = ichigouip[PARTJJ-STARTY][3][nenrei] + ichigouip[PARTJJ-STARTY][4][nenrei] ;
              ichigouni[PARTJJ-STARTY][2][nenrei]
                = ichigouni[PARTJJ-STARTY][3][nenrei] + ichigouni[PARTJJ-STARTY][4][nenrei] ;
              ichigou[PARTJJ-STARTY][2][nenrei]
                = ichigou[PARTJJ-STARTY][3][nenrei] + ichigou[PARTJJ-STARTY][4][nenrei] ;
              qkou12syu3[PARTJJ-STARTY][2][nenrei] = qkou12syu3[PARTJJ-STARTY][3][nenrei] ;
              kou3syu3[PARTJJ-STARTY][2][nenrei] = kou3syu3[PARTJJ-STARTY][3][nenrei] ;
              for ( seido=1; seido<=7; seido++ ) {
                kyosai3[seido][PARTJJ-STARTY][2][nenrei] = kyosai3[seido][PARTJJ-STARTY][3][nenrei] ; 
              }
            }
            if ( nendo == PARTYR2-1 ) {
              ichigouip[PARTKK-STARTY][2][nenrei]
                = ichigouip[PARTKK-STARTY][3][nenrei] + ichigouip[PARTKK-STARTY][4][nenrei] ;
              ichigouni[PARTKK-STARTY][2][nenrei]
                = ichigouni[PARTKK-STARTY][3][nenrei] + ichigouni[PARTKK-STARTY][4][nenrei] ;
              ichigou[PARTKK-STARTY][2][nenrei]
                = ichigou[PARTKK-STARTY][3][nenrei] + ichigou[PARTKK-STARTY][4][nenrei] ;
              qkou12syu3[PARTKK-STARTY][2][nenrei] = qkou12syu3[PARTKK-STARTY][3][nenrei] ;
              kou3syu3[PARTKK-STARTY][2][nenrei] = kou3syu3[PARTKK-STARTY][3][nenrei] ;
              for ( seido=1; seido<=7; seido++ ) {
                kyosai3[seido][PARTKK-STARTY][2][nenrei] = kyosai3[seido][PARTKK-STARTY][3][nenrei] ; 
              }
            }
            ichigouip[nendo-STARTY][0][nenrei]
              = ichigouip[nendo-STARTY][1][nenrei] + ichigouip[nendo-STARTY][2][nenrei] ;
            qkou12syu3[nendo-STARTY][0][nenrei]
              = qkou12syu3[nendo-STARTY][1][nenrei] + qkou12syu3[nendo-STARTY][2][nenrei] ;
            kou3syu3[nendo-STARTY][0][nenrei]
              = kou3syu3[nendo-STARTY][1][nenrei] + kou3syu3[nendo-STARTY][2][nenrei] ;
            for ( seido=1; seido<=7; seido++ ) {
              kyosai3[seido][nendo-STARTY][0][nenrei]
                = kyosai3[seido][nendo-STARTY][1][nenrei] + kyosai3[seido][nendo-STARTY][2][nenrei] ;
            }
            for ( ii=1; ii<=8; ii++ ) {
              partnin[nendo-STARTY][0][nenrei][ii][0]
                = partnin[nendo-STARTY][1][nenrei][ii][0] + partnin[nendo-STARTY][2][nenrei][ii][0] ;
              partnin[nendo-STARTY][0][nenrei][ii][1]
                = partnin[nendo-STARTY][1][nenrei][ii][1] + partnin[nendo-STARTY][2][nenrei][ii][1] ;
              partnin[nendo-STARTY][0][nenrei][ii][2]
                = partnin[nendo-STARTY][1][nenrei][ii][2] + partnin[nendo-STARTY][2][nenrei][ii][2] ;
            }
            if ( nendo == PARTYR1-1 ) {
              ichigouip[PARTJJ-STARTY][0][nenrei]
                = ichigouip[PARTJJ-STARTY][1][nenrei] + ichigouip[PARTJJ-STARTY][2][nenrei] ;
              ichigouni[PARTJJ-STARTY][0][nenrei]
                = ichigouni[PARTJJ-STARTY][1][nenrei] + ichigouni[PARTJJ-STARTY][2][nenrei] ;
              ichigou[PARTJJ-STARTY][0][nenrei]
                = ichigou[PARTJJ-STARTY][1][nenrei] + ichigou[PARTJJ-STARTY][2][nenrei] ;
              qkou12syu3[PARTJJ-STARTY][0][nenrei]
                = qkou12syu3[PARTJJ-STARTY][1][nenrei] + qkou12syu3[PARTJJ-STARTY][2][nenrei] ;
              kou3syu3[PARTJJ-STARTY][0][nenrei]
                = kou3syu3[PARTJJ-STARTY][1][nenrei] + kou3syu3[PARTJJ-STARTY][2][nenrei] ;
              for ( seido=1; seido<=7; seido++ ) {
                kyosai3[seido][PARTJJ-STARTY][0][nenrei]
                  = kyosai3[seido][PARTJJ-STARTY][1][nenrei] + kyosai3[seido][PARTJJ-STARTY][2][nenrei] ; 
              }
            }
            if ( nendo == PARTYR2-1 ) {
              ichigouip[PARTKK-STARTY][0][nenrei]
                = ichigouip[PARTKK-STARTY][1][nenrei] + ichigouip[PARTKK-STARTY][2][nenrei] ;
              ichigouni[PARTKK-STARTY][0][nenrei]
                = ichigouni[PARTKK-STARTY][1][nenrei] + ichigouni[PARTKK-STARTY][2][nenrei] ;
              ichigou[PARTKK-STARTY][0][nenrei]
                = ichigou[PARTKK-STARTY][1][nenrei] + ichigou[PARTKK-STARTY][2][nenrei] ;
              qkou12syu3[PARTKK-STARTY][0][nenrei]
                = qkou12syu3[PARTKK-STARTY][1][nenrei] + qkou12syu3[PARTKK-STARTY][2][nenrei] ;
              kou3syu3[PARTKK-STARTY][0][nenrei]
                = kou3syu3[PARTKK-STARTY][1][nenrei] + kou3syu3[PARTKK-STARTY][2][nenrei] ;
              for ( seido=1; seido<=7; seido++ ) {
                kyosai3[seido][PARTKK-STARTY][0][nenrei]
                  = kyosai3[seido][PARTKK-STARTY][1][nenrei] + kyosai3[seido][PARTKK-STARTY][2][nenrei] ; 
              }
            }
          }

        }
      }

  }


/*合計値を作成*/
   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {
     		for ( pkubun=1; pkubun<=3; pkubun++ ) {
       	    	partnin[nendo-STARTY][sei][nenrei][0][1] += partnin[nendo-STARTY][sei][nenrei][pkubun][1] ;
       	    	partnin[nendo-STARTY][sei][nenrei][0][2] += partnin[nendo-STARTY][sei][nenrei][pkubun][2] ;
          	}
      }
    }
   }
  for ( nendo=PARTYR1; nendo<=KE; nendo++ ) {
    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {
        	for ( pkubun=0; pkubun<=3; pkubun++ ) {
          		if ( nendo < PARTYR2 ) {
            		partnin[nendo-STARTY][sei][nenrei][pkubun][0] += partnin[nendo-STARTY][sei][nenrei][pkubun][1] ;
          		}
          	}
      }
    }
  }

    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {
        for ( pkubun=0; pkubun<=3; pkubun++ ) {
        	for ( ykubun=0; ykubun<=2; ykubun++ ) {
				partnin[PARTJJ-STARTY][sei][nenrei][pkubun][ykubun] = partnin[PARTYR1-1-STARTY][sei][nenrei][pkubun][ykubun];
      		}
      	}
      }
    }
	
  	for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
   	 for ( sei=0; sei<=4; sei++ ) {
    	  for ( nenrei=15; nenrei<=79; nenrei++ ) {
            partnin[nendo-STARTY][sei][nenrei][14][2] = partnin[nendo-STARTY][sei][nenrei][0][1] ;
          }
     }
    }
    

  }

  for ( nendo=2016; nendo<=KE; nendo++ ) {
   if ( PART == 0 ){
   } 
   else {
    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {

          if ( nendo < PARTYR2 ) {
           if ( nendo >= PARTYR1 ){
            koyouj_m[7][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][1] ;
            koyouj_m[10][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][1] ;
            koyouj_c[7][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][1]+partnin[nendo-STARTY][sei][nenrei][0][1]) / 2.0 ;
            koyouj_c[10][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][1]+partnin[nendo-STARTY][sei][nenrei][0][1]) / 2.0 ;
            
            
            soroudh_m[8][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][1] * 100.0 ;
            soroudh_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][1] * 100.0 ;
			soroudh_c[8][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][1]+partnin[nendo-STARTY][sei][nenrei][0][1] ) * 50.0 ;
            soroudh_c[9][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][1]+partnin[nendo-STARTY][sei][nenrei][0][1] ) * 50.0 ;
            
          }
          else if ( nendo == PARTYR2 ) {
            koyouj_m[7][nendo-STARTY][sei][nenrei]  += partnin[nendo-STARTY][sei][nenrei][0][2] ;
            koyouj_m[10][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][2] ;
            koyouj_c[7][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][2]+partnin[nendo-STARTY][sei][nenrei][0][2]) / 2.0 ;
            koyouj_c[10][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][2]+partnin[nendo-STARTY][sei][nenrei][0][2]) / 2.0 ;
           
            
            soroudh_m[8][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][2] * 100.0 ;
            soroudh_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][2] * 100.0 ;
            soroudh_c[8][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][2]+partnin[nendo-STARTY][sei][nenrei][0][2] ) * 50.0 ;
            soroudh_c[9][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][0][2]+partnin[nendo-STARTY][sei][nenrei][0][2] ) * 50.0 ;
          }
          else if ( nendo > PARTYR2 ) {
            koyouj_m[7][nendo-STARTY][sei][nenrei]  += partnin[nendo-STARTY][sei][nenrei][0][2] ;
            koyouj_m[10][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][2] ;
            koyouj_c[7][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][0][2] + partnin[nendo-STARTY][sei][nenrei][0][2] ) / 2.0 ;
            koyouj_c[10][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][0][2] + partnin[nendo-STARTY][sei][nenrei][0][2] ) / 2.0 ;
            soroudh_m[8][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][2] * 100.0 ;
            soroudh_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][0][2] * 100.0 ;
            soroudh_c[8][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][0][2] + partnin[nendo-STARTY][sei][nenrei][0][2] ) * 50.0 ;
            soroudh_c[9][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][0][2] + partnin[nendo-STARTY][sei][nenrei][0][2] ) * 50.0 ;
          }

         }
	 }
	}
  }
 }

 if ( PART >=1){
  for ( nendo=PARTJJ; nendo<=KE; nendo++ ) {
    if ( ( nendo<= PARTKK ) || ( nendo>=PARTYR1 ) ) {
      XEND = xend[8][nendo-STARTY] ;
      if ( XEND < 60 ) { XEND = 60 ; }
      for ( sei=0; sei<=4; sei++ ) {

        for ( nenrei=15; nenrei<=100; nenrei++ ) {
          ichigou[nendo-STARTY][sei][nenrei] =
            ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
        }
        for ( nenrei=20; nenrei<=XEND-1; nenrei++ ) {

          qkounen3[nendo-STARTY][sei][nenrei]
            = qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei] ;
          kou12syu3[nendo-STARTY][sei][nenrei] = qkou12syu3[nendo-STARTY][sei][nenrei] ;
          kounen3[nendo-STARTY][sei][nenrei] = qkounen3[nendo-STARTY][sei][nenrei] ;

          for ( seido=4; seido<=7; seido++ ) {
            kou12syu3[nendo-STARTY][sei][nenrei] += kyosai3[seido][nendo-STARTY][sei][nenrei] ;
            kounen3[nendo-STARTY][sei][nenrei] += kyosai3[seido][nendo-STARTY][sei][nenrei] ;
          }
          sangou[nendo-STARTY][sei][nenrei] = kounen3[nendo-STARTY][sei][nenrei] ;
          for ( seido=1; seido<=3; seido++ ) { 
            sangou[nendo-STARTY][sei][nenrei] += kyosai3[seido][nendo-STARTY][sei][nenrei] ;
          }
        }
      }
    }
  }
 }

  if ( MODE == 3 || MODE == 6) {
      simlpart_4(); 
  }
  



}

void simlpart_4(void) 
{


/*  変数定義  */
    char    filename[250]    ; 
    int     pkubun  ;  
    int     ykubun  ;  
    int     ii      ;
    int     TMR     ;
    double  TMP     ; 
    double  TMQ     ; 
    double  TMS     ; 
    double  TMT     ; 
    int     XEND ;



  if(PART >=1){
    switch ( PARTK1 ) { 
        case 8:
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-3-2.csv");
            break ;
    }

  /*  ファイルを開く  */
    if ((fp_part = fopen(filename, "r")) == NULL) {
        fprintf(stderr, "パート入力ファイル（１段階）を開けません!\n");
        exit (2); /* 終了 */
    }


        karayomi( fp_part );  
    for ( kubun=1; kubun<=11; kubun++ ) {
        read_csv( buffer, fp_part, &data_number );
        ii = (int) buffer[0] ; 
        kbetu_partkiso[1][ii][18][1] = (double) buffer[1] ; 
        kbetu_partkiso[1][ii][19][1] = (double) buffer[2] ; 
        kbetu_partkiso[1][ii][20][1] = (double) buffer[3] ; 
        kbetu_partkiso[2][ii][18][1] = (double) buffer[4] ; 
        kbetu_partkiso[2][ii][19][1] = (double) buffer[5] ; 
        kbetu_partkiso[2][ii][20][1] = (double) buffer[6] ; 
    }

        fclose(fp_part);


    switch ( PARTK2 ) { 
        case 3: /* 1050万人ベース */
            sprintf(filename, "/rev31/wakuc/data/part/partnin31-3-2.csv");
            break ;

    }

  /*  ファイルを開く  */
    if ((fp_part = fopen(filename, "r")) == NULL) {
        fprintf(stderr, "パート入力ファイル（２段階）を開けません!\n");
        exit (2); /* 終了 */
    }


        karayomi( fp_part );  
    for ( kubun=1; kubun<=11; kubun++ ) {
        read_csv( buffer, fp_part, &data_number );
        ii = (int) buffer[0] ; 
        kbetu_partkiso[1][ii][18][2] = (double) buffer[1] ; 
        kbetu_partkiso[1][ii][19][2] = (double) buffer[2] ; 
        kbetu_partkiso[1][ii][20][2] = (double) buffer[3] ; 
        kbetu_partkiso[2][ii][18][2] = (double) buffer[4] ; 
        kbetu_partkiso[2][ii][19][2] = (double) buffer[5] ; 
        kbetu_partkiso[2][ii][20][2] = (double) buffer[6] ;
    }

        fclose(fp_part);

        PARTJJ = 1995 ; 
        PARTKK = 1996 ; 


    for ( nendo=PARTKYR; nendo<=KE; nendo++ ) {
        for ( sei=1; sei<=2; sei++ ) {
            for ( kubun=1; kubun<=15; kubun++ ) {
                TMR = kubun * 5 + 12 ; 
                kbetu_tankoj[nendo-STARTY][sei][kubun] = 0.0 ;
                for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                    kbetu_tankoj[nendo-STARTY][sei][kubun] += (koyouj_m[1][nendo-STARTY][sei][nenrei]+koyouj_m[2][nendo-STARTY][sei][nenrei]+koyouj_m[6][nendo-STARTY][sei][nenrei]) ;
                }
            }
        }
    }



   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( kubun=1; kubun<=15; kubun++ ) {
        for ( pkubun=18; pkubun<=20; pkubun++ ) { 
          for ( ykubun=1; ykubun<=2; ykubun++ ) {

            if ( kbetu_tankoj[PARTKYR-STARTY][sei][kubun] > 0.0 ) {
                kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun]
                 = kbetu_partkiso[sei][kubun][pkubun][ykubun]
                   * kbetu_tankoj[nendo-STARTY][sei][kubun] / kbetu_tankoj[PARTKYR-STARTY][sei][kubun] ;
            }
            else { 
              fprintf(stderr, "パート推計で%d年度の性%d年齢区分%dの短雇がマイナス!\n", PARTKYR, sei, kubun );
              printf("パート推計で%d年度の性%d年齢区分%dの短雇がマイナス!\n", PARTKYR, sei, kubun );
              kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] = 0.0 ;
            }

          }
        }

        for ( ykubun=0; ykubun<=2; ykubun++ ) {
          if (( kubun >= 2 ) && ( kubun <= 9 )) { 
              kbetu_partnin[nendo-STARTY][sei][kubun][18][ykubun]
                += kbetu_partnin[nendo-STARTY][sei][kubun][20][ykubun] ;
              kbetu_partnin[nendo-STARTY][sei][kubun][20][ykubun] = 0.0 ;
          }
          kbetu_partnin[nendo-STARTY][sei][kubun][17][ykubun]
            = kbetu_partnin[nendo-STARTY][sei][kubun][18][ykubun] 
            + kbetu_partnin[nendo-STARTY][sei][kubun][19][ykubun] 
            + kbetu_partnin[nendo-STARTY][sei][kubun][20][ykubun] ;
        }
      }
    }
   }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( kubun=2; kubun<=9; kubun++ ) {
          TMR = kubun * 5 + 12 ; 
          for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {

              kbetu_partgen[nendo-STARTY][sei][kubun][18] += ichigouip[nendo-STARTY][sei][nenrei] ;

                kbetu_partgen[nendo-STARTY][sei][kubun][19] += sangou[nendo-STARTY][sei][nenrei] ;
          }
      }
      for ( kubun=10; kubun<=11; kubun++ ) {
          TMR = kubun * 5 + 12 ;
          for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
              kbetu_partgen[nendo-STARTY][sei][kubun][18] += ichigouni[nendo-STARTY][sei][nenrei] ;
          }
      }
    }
   }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( kubun=2; kubun<=9; kubun++ ) {
        for ( pkubun=18; pkubun<=20; pkubun++ ) {
          for ( ykubun=1; ykubun<=2; ykubun++ ) {
            if ( kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] <= 0.0 ) { 
              kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] = 0.0 ;
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][pkubun][ykubun] = 1.0 ;
              }
            }
            else if ( kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun]
                       <= kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] ) { 
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][pkubun][ykubun] = 
                 ( kbetu_partgen[nendo-STARTY][sei][kubun][pkubun]
                    - kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] ) 
                 / kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] ;
              }
            }
            else if ( nendo < KE ) { 
              printf("パート %d年度の性%d、年齢区分%d、パート区分%d、猶予区分%d が減算しきれない\n",
                      nendo, sei, kubun, pkubun, ykubun ) ;
              fprintf(fp_err, "パート %d年度の性%d、年齢区分%d、パート区分%d、猶予区分%d が減算しきれない\n",
                      nendo, sei, kubun, pkubun, ykubun ) ;
              kbetu_partnin[nendo-STARTY][sei][kubun][pkubun][ykubun] =
                kbetu_partgen[nendo-STARTY][sei][kubun][pkubun] ;
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][pkubun][ykubun] = 0.0 ;
              }
            }
          }
        }
      }

      for ( kubun=10; kubun<=11; kubun++ ) {
        for ( ykubun=1; ykubun<=2; ykubun++ ) {  
            if ( kbetu_partgen[nendo-STARTY][sei][kubun][18] <= 0.0 ) { 
              kbetu_partnin[nendo-STARTY][sei][kubun][18][ykubun] = 0.0 ;
              TMR = kubun * 5 + 12 ; 
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][18][ykubun] = 1.0 ;
              }
            }
            else if ( kbetu_partnin[nendo-STARTY][sei][kubun][18][ykubun]
                       <= kbetu_partgen[nendo-STARTY][sei][kubun][18] ) {
              TMR = kubun * 5 + 12 ;
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][18][ykubun] = 
                 ( kbetu_partgen[nendo-STARTY][sei][kubun][18]
                    - kbetu_partnin[nendo-STARTY][sei][kubun][18][ykubun] ) 
                 / kbetu_partgen[nendo-STARTY][sei][kubun][18] ;
              }
            }
            else if ( nendo < KE ) { 
              printf("パート %d年度の性%d、年齢区分%d、パート区分1、猶予区分%dが減算しきれない\n",
                      nendo, sei, kubun, ykubun ) ;
              fprintf(fp_err, "パート %d年度の性%d、年齢区分%d、パート区分1、猶予区分%dが減算しきれない\n",
                      nendo, sei, kubun, ykubun ) ;
              kbetu_partnin[nendo-STARTY][sei][kubun][18][ykubun]
               = kbetu_partgen[nendo-STARTY][sei][kubun][18] ;
              TMR = kubun * 5 + 12 ;
              for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {
                partgenwari[nendo-STARTY][sei][nenrei][18][ykubun] = 0.0 ;
              }
            }
        }
      }

    }
   }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {

      for ( nenrei=15; nenrei<=19; nenrei++ ) {
        for ( ykubun=1; ykubun<=2; ykubun++ ) {
          for ( sei=1; sei<=2; sei++ ) {
            partnin[nendo-STARTY][sei][nenrei][20][ykubun]
              = kbetu_partnin[nendo-STARTY][sei][1][20][ykubun]
              * (koyouj_m[1][nendo-STARTY][sei][nenrei]+koyouj_m[2][nendo-STARTY][sei][nenrei]+koyouj_m[6][nendo-STARTY][sei][nenrei]) / kbetu_tankoj[nendo-STARTY][sei][1] ;
          }
          partnin[nendo-STARTY][3][nenrei][20][ykubun]
            = partnin[nendo-STARTY][2][nenrei][20][ykubun] 
                * (koyouj_m[1][nendo-STARTY][3][nenrei]+koyouj_m[2][nendo-STARTY][3][nenrei]+koyouj_m[6][nendo-STARTY][3][nenrei]) / (koyouj_m[1][nendo-STARTY][2][nenrei]+koyouj_m[2][nendo-STARTY][2][nenrei]+koyouj_m[6][nendo-STARTY][2][nenrei]) ;
          partnin[nendo-STARTY][4][nenrei][20][ykubun]
            = partnin[nendo-STARTY][2][nenrei][20][ykubun] 
                * (koyouj_m[1][nendo-STARTY][4][nenrei]+koyouj_m[2][nendo-STARTY][4][nenrei]+koyouj_m[6][nendo-STARTY][4][nenrei]) / (koyouj_m[1][nendo-STARTY][2][nenrei]+koyouj_m[2][nendo-STARTY][2][nenrei]+koyouj_m[6][nendo-STARTY][2][nenrei]) ;
          /*  男女計  */
          partnin[nendo-STARTY][0][nenrei][20][ykubun]
            = partnin[nendo-STARTY][1][nenrei][20][ykubun] + partnin[nendo-STARTY][2][nenrei][20][ykubun] ;
        }
      }

      for ( kubun=2; kubun<=9; kubun++ ) {
        TMR = kubun * 5 + 12 ; 
        for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {

            for ( ykubun=1; ykubun<=2; ykubun++ ) {
              for ( sei=1; sei<=2; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][18][ykubun] =
                   ichigouip[nendo-STARTY][sei][nenrei] 
                     * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][18][ykubun] ) ;
              }
              for ( sei=3; sei<=4; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][18][ykubun] =
                   ichigouip[nendo-STARTY][sei][nenrei] 
                     * ( 1.0 - partgenwari[nendo-STARTY][2][nenrei][18][ykubun] ) ;
              }
              /*  男女計  */
              partnin[nendo-STARTY][0][nenrei][18][ykubun]
                = partnin[nendo-STARTY][1][nenrei][18][ykubun] + partnin[nendo-STARTY][2][nenrei][18][ykubun] ; 
            }
            if ( nendo >= PARTYR1-1 ) { 
   
                if ( nendo < PARTYR2 ) {
                  if ( nendo == PARTYR1-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      ichigouip[PARTJJ-STARTY][sei][nenrei]
                        = ichigouip[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][18][1] ;
                      ichigouni[PARTJJ-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTJJ-STARTY][sei][nenrei]
                        = ichigouip[PARTJJ-STARTY][sei][nenrei] + ichigouni[PARTJJ-STARTY][sei][nenrei] ;
                    }
                    for ( sei=3; sei<=4; sei++ ) {
                      ichigouip[PARTJJ-STARTY][sei][nenrei] 
                        = ichigouip[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][18][1] ;
                      ichigouni[PARTJJ-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTJJ-STARTY][sei][nenrei]
                        = ichigouip[PARTJJ-STARTY][sei][nenrei] + ichigouni[PARTJJ-STARTY][sei][nenrei] ;
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      ichigouip[PARTKK-STARTY][sei][nenrei]
                        = ichigouip[PARTKK-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][18][2] ;
                      ichigouni[PARTKK-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTKK-STARTY][sei][nenrei]
                        = ichigouip[PARTKK-STARTY][sei][nenrei] + ichigouni[PARTKK-STARTY][sei][nenrei] ;
                    }
                    for ( sei=3; sei<=4; sei++ ) {
                      ichigouip[PARTKK-STARTY][sei][nenrei] 
                        = ichigouip[PARTKK-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][18][2] ;
                      ichigouni[PARTKK-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[PARTKK-STARTY][sei][nenrei]
                        = ichigouip[PARTKK-STARTY][sei][nenrei] + ichigouni[PARTKK-STARTY][sei][nenrei] ;
                    }
                    for ( sei=1; sei<=2; sei++ ) {
                      ichigouip[nendo-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][18][1] ;
                      ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[nendo-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                    }
                    for ( sei=3; sei<=4; sei++ ) {
                      ichigouip[nendo-STARTY][sei][nenrei] 
                        = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][18][1] ;
                      ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ;
                      ichigou[nendo-STARTY][sei][nenrei]
                        = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                    }
                  }
                  else {
                  	for ( sei=1; sei<=2; sei++ ) {
                    	ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][18][1] ;
                  	}
                  	for ( sei=3; sei<=4; sei++ ) {
                    	ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][18][1] ;
                  	}
                  }
                }
                else if( nendo >= PARTYR2 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][18][2] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouip[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][18][2] ;
                  }
                }
                /*  男女計  */
                ichigouip[nendo-STARTY][0][nenrei]
                  = ichigouip[nendo-STARTY][1][nenrei] + ichigouip[nendo-STARTY][2][nenrei] ;
                if ( nendo == PARTYR1-1 ) {
                  ichigouip[PARTJJ-STARTY][0][nenrei]
                    = ichigouip[PARTJJ-STARTY][1][nenrei] + ichigouip[PARTJJ-STARTY][2][nenrei] ;
                  ichigouni[PARTJJ-STARTY][0][nenrei]
                    = ichigouni[PARTJJ-STARTY][1][nenrei] + ichigouni[PARTJJ-STARTY][2][nenrei] ;
                  ichigou[PARTJJ-STARTY][0][nenrei]
                    = ichigou[PARTJJ-STARTY][1][nenrei] + ichigou[PARTJJ-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR2-1 ) {
                  ichigouip[PARTKK-STARTY][0][nenrei]
                    = ichigouip[PARTKK-STARTY][1][nenrei] + ichigouip[PARTKK-STARTY][2][nenrei] ;
                  ichigouni[PARTKK-STARTY][0][nenrei]
                    = ichigouni[PARTKK-STARTY][1][nenrei] + ichigouni[PARTKK-STARTY][2][nenrei] ;
                  ichigou[PARTKK-STARTY][0][nenrei]
                    = ichigou[PARTKK-STARTY][1][nenrei] + ichigou[PARTKK-STARTY][2][nenrei] ;
                }
            }
         
            for ( ykubun=1; ykubun<=2; ykubun++ ) {
              for ( sei=1; sei<=2; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][19][ykubun]
                  = ( qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei]
                      + kyosai3[4][nendo-STARTY][sei][nenrei] + kyosai3[5][nendo-STARTY][sei][nenrei]
                      + kyosai3[6][nendo-STARTY][sei][nenrei] + kyosai3[7][nendo-STARTY][sei][nenrei] )
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][19][ykubun] )  ;
                partnin[nendo-STARTY][sei][nenrei][25][ykubun] = partnin[nendo-STARTY][sei][nenrei][19][ykubun] ;
              }
              partnin[nendo-STARTY][3][nenrei][19][ykubun] = partnin[nendo-STARTY][2][nenrei][19][ykubun] ;
              partnin[nendo-STARTY][3][nenrei][25][ykubun] = partnin[nendo-STARTY][2][nenrei][25][ykubun] ;
              partnin[nendo-STARTY][4][nenrei][19][ykubun] = 0.0 ;
              partnin[nendo-STARTY][4][nenrei][25][ykubun] = 0.0 ;
              /*  男女計  */
              partnin[nendo-STARTY][0][nenrei][19][ykubun]
                = partnin[nendo-STARTY][1][nenrei][19][ykubun] + partnin[nendo-STARTY][2][nenrei][19][ykubun] ;
              partnin[nendo-STARTY][0][nenrei][25][ykubun]
                = partnin[nendo-STARTY][1][nenrei][25][ykubun] + partnin[nendo-STARTY][2][nenrei][25][ykubun] ;
            }

            if ( nendo >= PARTYR1-1 ) { 
                if ( nendo < PARTYR2 ) {
                  if ( nendo == PARTYR1-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      qkou12syu3[PARTJJ-STARTY][sei][nenrei]
                        = qkou12syu3[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      kou3syu3[PARTJJ-STARTY][sei][nenrei]
                        = kou3syu3[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      for ( seido=4; seido<=7; seido++ ) {
                        kyosai3[seido][PARTJJ-STARTY][sei][nenrei]
                          = kyosai3[seido][PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      }
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      qkou12syu3[PARTKK-STARTY][sei][nenrei]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                      kou3syu3[PARTKK-STARTY][sei][nenrei]
                        = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                      for ( seido=4; seido<=7; seido++ ) {
                        kyosai3[seido][PARTKK-STARTY][sei][nenrei]
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                      }
                    }
					for ( sei=1; sei<=2; sei++ ) {
                      qkou12syu3[nendo-STARTY][sei][nenrei]
                        = qkou12syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      kou3syu3[nendo-STARTY][sei][nenrei]
                        = kou3syu3[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      for ( seido=4; seido<=7; seido++ ) {
                        kyosai3[seido][nendo-STARTY][sei][nenrei]
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      }
                    }
                  }                  
                  else {
                  	for ( sei=1; sei<=2; sei++ ) {
                    	qkou12syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                    	kou3syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                    	for ( seido=4; seido<=7; seido++ ) {
                      	kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                    	}
                  	}
                  }
                }
                else if ( nendo >= PARTYR2 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    qkou12syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                    kou3syu3[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                    for ( seido=4; seido<=7; seido++ ) {
                      kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                    }
                  }
                }
                qkou12syu3[nendo-STARTY][3][nenrei] = qkou12syu3[nendo-STARTY][2][nenrei] ;
                kou3syu3[nendo-STARTY][3][nenrei] = kou3syu3[nendo-STARTY][2][nenrei] ;
                for ( seido=4; seido<=7; seido++ ) {
                  kyosai3[seido][nendo-STARTY][3][nenrei] = kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  qkou12syu3[PARTJJ-STARTY][3][nenrei] = qkou12syu3[PARTJJ-STARTY][2][nenrei] ;
                  kou3syu3[PARTJJ-STARTY][3][nenrei] = kou3syu3[PARTJJ-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][3][nenrei] = kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  qkou12syu3[PARTKK-STARTY][3][nenrei] = qkou12syu3[PARTKK-STARTY][2][nenrei] ;
                  kou3syu3[PARTKK-STARTY][3][nenrei] = kou3syu3[PARTKK-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][3][nenrei] = kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }
                /*  男女計  */
                qkou12syu3[nendo-STARTY][0][nenrei]
                  = qkou12syu3[nendo-STARTY][1][nenrei] + qkou12syu3[nendo-STARTY][2][nenrei] ;
                kou3syu3[nendo-STARTY][0][nenrei]
                  = kou3syu3[nendo-STARTY][1][nenrei] + kou3syu3[nendo-STARTY][2][nenrei] ;
                for ( seido=4; seido<=7; seido++ ) {
                  kyosai3[seido][nendo-STARTY][0][nenrei]
                    = kyosai3[seido][nendo-STARTY][1][nenrei] + kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  qkou12syu3[PARTJJ-STARTY][0][nenrei]
                    = qkou12syu3[PARTJJ-STARTY][1][nenrei] + qkou12syu3[PARTJJ-STARTY][2][nenrei] ;
                  kou3syu3[PARTJJ-STARTY][0][nenrei]
                    = kou3syu3[PARTJJ-STARTY][1][nenrei] + kou3syu3[PARTJJ-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][0][nenrei]
                      = kyosai3[seido][PARTJJ-STARTY][1][nenrei] + kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  qkou12syu3[PARTKK-STARTY][0][nenrei]
                    = qkou12syu3[PARTKK-STARTY][1][nenrei] + qkou12syu3[PARTKK-STARTY][2][nenrei] ;
                  kou3syu3[PARTKK-STARTY][0][nenrei]
                    = kou3syu3[PARTKK-STARTY][1][nenrei] + kou3syu3[PARTKK-STARTY][2][nenrei] ;
                  for ( seido=4; seido<=7; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][0][nenrei]
                      = kyosai3[seido][PARTKK-STARTY][1][nenrei] + kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }
            }

            for ( ykubun=0; ykubun<=2; ykubun++ ) {
              for ( sei=1; sei<=2; sei++ ) {
                partnin[nendo-STARTY][sei][nenrei][19][ykubun]
                  += ( kyosai3[1][nendo-STARTY][sei][nenrei] + kyosai3[2][nendo-STARTY][sei][nenrei]
                       + kyosai3[3][nendo-STARTY][sei][nenrei] )
                     * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][19][ykubun] )  ; 
                partnin[nendo-STARTY][sei][nenrei][22][ykubun] = kyosai3[1][nendo-STARTY][sei][nenrei]
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][19][ykubun] )  ; /* 国共済 */
                partnin[nendo-STARTY][sei][nenrei][23][ykubun] = kyosai3[2][nendo-STARTY][sei][nenrei]
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][19][ykubun] )  ; /* 地共済 */
                partnin[nendo-STARTY][sei][nenrei][24][ykubun] = kyosai3[3][nendo-STARTY][sei][nenrei]
                  * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][19][ykubun] )  ; /* 私学共済 */
              }
              partnin[nendo-STARTY][3][nenrei][19][ykubun] = partnin[nendo-STARTY][2][nenrei][19][ykubun] ;
              partnin[nendo-STARTY][4][nenrei][19][ykubun] = 0.0 ;
              for ( pkubun=22; pkubun<=24; pkubun++ ) {
                partnin[nendo-STARTY][3][nenrei][pkubun][ykubun]
                  = partnin[nendo-STARTY][2][nenrei][pkubun][ykubun] ;
                partnin[nendo-STARTY][4][nenrei][pkubun][ykubun] = 0.0 ;
              }
              /*  男女計  */
              partnin[nendo-STARTY][0][nenrei][19][ykubun]
                = partnin[nendo-STARTY][1][nenrei][19][ykubun] + partnin[nendo-STARTY][2][nenrei][19][ykubun] ;
              for ( pkubun=22; pkubun<=24; pkubun++ ) {
                partnin[nendo-STARTY][0][nenrei][pkubun][ykubun]
                  = partnin[nendo-STARTY][1][nenrei][pkubun][ykubun] + partnin[nendo-STARTY][2][nenrei][pkubun][ykubun] ;
              }
            }
            if ( nendo >= PARTYR1-1 ) {
                if ( nendo < PARTYR2 ) {
                  if ( nendo == PARTYR1-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      for ( seido=1; seido<=3; seido++ ) {
                        kyosai3[seido][PARTJJ-STARTY][sei][nenrei] 
                          = kyosai3[seido][PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      }
                    }
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    for ( sei=1; sei<=2; sei++ ) {
                      for ( seido=1; seido<=3; seido++ ) {
                        kyosai3[seido][PARTKK-STARTY][sei][nenrei] 
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                      }
                    }
                    for ( sei=1; sei<=2; sei++ ) {
                      for ( seido=1; seido<=3; seido++ ) {
                        kyosai3[seido][nendo-STARTY][sei][nenrei] 
                          = kyosai3[seido][nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                      }
                    }
                  }
                  else {
                  	for ( sei=1; sei<=2; sei++ ) {
                    	for ( seido=1; seido<=3; seido++ ) {
                      	kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][1] ;
                    	}
                  	}
                  }
                }
                else if ( nendo >= PARTYR2 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    for ( seido=1; seido<=3; seido++ ) {
                      kyosai3[seido][nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][19][2] ;
                    }
                  }
                }
                for ( seido=1; seido<=3; seido++ ) {
                  kyosai3[seido][nendo-STARTY][3][nenrei] = kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][3][nenrei] = kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][3][nenrei] = kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }
                /*  男女計  */
                for ( seido=1; seido<=3; seido++ ) {
                  kyosai3[seido][nendo-STARTY][0][nenrei]
                    = kyosai3[seido][nendo-STARTY][1][nenrei] + kyosai3[seido][nendo-STARTY][2][nenrei] ;
                }
                if ( nendo == PARTYR1-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTJJ-STARTY][0][nenrei]
                      = kyosai3[seido][PARTJJ-STARTY][1][nenrei] + kyosai3[seido][PARTJJ-STARTY][2][nenrei] ;
                  }
                }
                if ( nendo == PARTYR2-1 ) {
                  for ( seido=1; seido<=3; seido++ ) {
                    kyosai3[seido][PARTKK-STARTY][0][nenrei]
                      = kyosai3[seido][PARTKK-STARTY][1][nenrei] + kyosai3[seido][PARTKK-STARTY][2][nenrei] ;
                  }
                }

            }

        }
      }
      
      for ( kubun=10; kubun<=11; kubun++ ) {
        TMR = kubun * 5 + 12 ; 
        for ( nenrei=TMR-2; nenrei<=TMR+2; nenrei++ ) {

          for ( ykubun=1; ykubun<=2; ykubun++ ) {
            for ( sei=1; sei<=2; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][18][ykubun] = ichigouni[nendo-STARTY][sei][nenrei] 
                * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][18][ykubun] ) ;
            }
            for ( sei=3; sei<=4; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][18][ykubun] = ichigouni[nendo-STARTY][sei][nenrei] 
                * ( 1.0 - partgenwari[nendo-STARTY][2][nenrei][18][ykubun] ) ;
            }
            /*  男女計  */
            partnin[nendo-STARTY][0][nenrei][18][ykubun]
              = partnin[nendo-STARTY][1][nenrei][18][ykubun] + partnin[nendo-STARTY][2][nenrei][18][ykubun] ; 
          }
          if ( nendo >= PARTYR1-1 ) {
            if ( nendo < PARTYR2 ) {
                if ( nendo == PARTYR1-1 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouni[PARTJJ-STARTY][sei][nenrei]
                      = ichigouni[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][18][1] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouni[PARTJJ-STARTY][sei][nenrei] 
                      = ichigouni[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][18][1] ;
                  }
                }
                else if ( nendo == PARTYR2-1 ) {
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouni[PARTKK-STARTY][sei][nenrei]
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][18][2] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouni[PARTKK-STARTY][sei][nenrei] 
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][18][2] ;
                  }
                  for ( sei=1; sei<=2; sei++ ) {
                    ichigouni[nendo-STARTY][sei][nenrei]
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][18][1] ;
                  }
                  for ( sei=3; sei<=4; sei++ ) {
                    ichigouni[nendo-STARTY][sei][nenrei] 
                      = ichigouni[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][2][nenrei][18][1] ;
                  }
                }
                
                else {
                	for ( sei=1; sei<=2; sei++ ) {
                  		ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][18][1] ;
                	}
                	for ( sei=3; sei<=4; sei++ ) {
                  		ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][18][1] ;
                	}
                }
            }
            else if ( nendo >= PARTYR2 ) {
                for ( sei=1; sei<=2; sei++ ) {
                  ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][sei][nenrei][18][2] ;
                }
                for ( sei=3; sei<=4; sei++ ) {
                  ichigouni[nendo-STARTY][sei][nenrei] *= partgenwari[nendo-STARTY][2][nenrei][18][2] ;
                }
            }
            /*  男女計  */
            ichigouni[nendo-STARTY][0][nenrei]
              = ichigouni[nendo-STARTY][1][nenrei] + ichigouni[nendo-STARTY][2][nenrei] ;
            if ( nendo == PARTYR1-1 ) {
              ichigouni[PARTJJ-STARTY][0][nenrei]
                = ichigouni[PARTJJ-STARTY][1][nenrei] + ichigouni[PARTJJ-STARTY][2][nenrei] ;
            }
            if ( nendo == PARTYR2-1) {
              ichigouni[PARTKK-STARTY][0][nenrei]
                = ichigouni[PARTKK-STARTY][1][nenrei] + ichigouni[PARTKK-STARTY][2][nenrei] ;
            }
          }


          for ( ykubun=0; ykubun<=2; ykubun++ ) {
            for ( sei=1; sei<=2; sei++ ) {
              partnin[nendo-STARTY][sei][nenrei][20][ykubun]
                = kbetu_partnin[nendo-STARTY][sei][kubun][20][ykubun]
                * (koyouj_m[1][nendo-STARTY][sei][nenrei]+koyouj_m[2][nendo-STARTY][sei][nenrei]+koyouj_m[6][nendo-STARTY][sei][nenrei]) / kbetu_tankoj[nendo-STARTY][sei][kubun] ;
            }
            partnin[nendo-STARTY][3][nenrei][20][ykubun]
              = partnin[nendo-STARTY][2][nenrei][20][ykubun] 
                  * (koyouj_m[1][nendo-STARTY][3][nenrei]+koyouj_m[2][nendo-STARTY][3][nenrei]+koyouj_m[6][nendo-STARTY][3][nenrei]) / (koyouj_m[1][nendo-STARTY][2][nenrei]+koyouj_m[2][nendo-STARTY][2][nenrei]+koyouj_m[6][nendo-STARTY][2][nenrei]) ;
            partnin[nendo-STARTY][4][nenrei][20][ykubun]
              = partnin[nendo-STARTY][2][nenrei][20][ykubun] 
                  * (koyouj_m[1][nendo-STARTY][4][nenrei]+koyouj_m[2][nendo-STARTY][4][nenrei]+koyouj_m[6][nendo-STARTY][4][nenrei]) / (koyouj_m[1][nendo-STARTY][2][nenrei]+koyouj_m[2][nendo-STARTY][2][nenrei]+koyouj_m[6][nendo-STARTY][2][nenrei]) ;
            /*  男女計  */
            partnin[nendo-STARTY][0][nenrei][20][ykubun]
              = partnin[nendo-STARTY][1][nenrei][20][ykubun] + partnin[nendo-STARTY][2][nenrei][20][ykubun] ;
          }
          if ( (MODE == 6) && ( nendo >= PARTYR1-1 ) ) {
            XEND = xend[8][nendo-STARTY] ;
            if ( XEND < 60 ) { XEND = 60 ; }

            if ( nenrei < XEND ) {
                for ( sei=1; sei<=4; sei++ ) {
                  if ( ichigouip[nendo-STARTY][sei][nenrei] > 0.0 ) {
                    partgenwari[nendo-STARTY][sei][nenrei][20][1]
                      = 1.0 - partnin[nendo-STARTY][sei][nenrei][20][1]
                         / ( ichigouip[nendo-STARTY][sei][nenrei] ) ;
                    partgenwari[nendo-STARTY][sei][nenrei][20][2]
                      = 1.0 - partnin[nendo-STARTY][sei][nenrei][20][2]
                         / ( ichigouip[nendo-STARTY][sei][nenrei]  ) ;
                  }
                  else {
                    partgenwari[nendo-STARTY][sei][nenrei][20][1] = 1.0 ;
                    partgenwari[nendo-STARTY][sei][nenrei][20][2] = 1.0 ;
                  }
                  if ( ( partgenwari[nendo-STARTY][sei][nenrei][20][1] > 0 )
                         && ( partgenwari[nendo-STARTY][sei][nenrei][20][1] < 1.0 ) ) { 
                      partnin[nendo-STARTY][sei][nenrei][18][1]
                        += ichigouip[nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][20][1] ) ;
                      partnin[nendo-STARTY][sei][nenrei][20][1] = 0.0 ;

                  }
                  else if ( partgenwari[nendo-STARTY][sei][nenrei][20][1] < 0 ) { 
                      partgenwari[nendo-STARTY][sei][nenrei][20][1] = 0.0 ;
                      partnin[nendo-STARTY][sei][nenrei][18][1] = ichigouip[nendo-STARTY][sei][nenrei] ;
                      partnin[nendo-STARTY][sei][nenrei][18][0] = partnin[nendo-STARTY][sei][nenrei][18][1] ;
                  }
                  if ( ( partgenwari[nendo-STARTY][sei][nenrei][20][2] > 0 )
                         && ( partgenwari[nendo-STARTY][sei][nenrei][20][2] < 1.0 ) ) { 
                      partnin[nendo-STARTY][sei][nenrei][18][2]
                        += ichigouip[nendo-STARTY][sei][nenrei] * ( 1.0 - partgenwari[nendo-STARTY][sei][nenrei][20][2] ) ;
                      partnin[nendo-STARTY][sei][nenrei][20][2] = 0.0 ;
                  }
                  else if ( partgenwari[nendo-STARTY][sei][nenrei][20][2] < 0 ) { 
                      partgenwari[nendo-STARTY][sei][nenrei][20][2] = 0.0 ;
                      partnin[nendo-STARTY][sei][nenrei][18][2] = ichigouip[nendo-STARTY][sei][nenrei] ;
                  }
                  if ( nendo == PARTYR1-1 ) {
                    ichigouip[PARTJJ-STARTY][sei][nenrei]
                      = ichigouip[PARTJJ-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][20][1] ;
                    ichigouni[PARTJJ-STARTY][sei][nenrei] = ichigouni[PARTJJ-STARTY][sei][nenrei] ; 
                    ichigou[PARTJJ-STARTY][sei][nenrei]
                      = ichigouip[PARTJJ-STARTY][sei][nenrei] + ichigouni[PARTJJ-STARTY][sei][nenrei] ;
                  }
				  else if ( nendo <= PARTYR2-1 ) {
                    ichigouip[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][20][1] ;
                    ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ; 
                    ichigou[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                  }
                  else if ( nendo == PARTYR2-1 ) {
                    ichigouip[PARTKK-STARTY][sei][nenrei]
                      = ichigouip[PARTKK-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][20][2] ;
                    ichigouni[PARTKK-STARTY][sei][nenrei] = ichigouni[PARTKK-STARTY][sei][nenrei] ; 
                    ichigou[PARTKK-STARTY][sei][nenrei]
                      = ichigouip[PARTKK-STARTY][sei][nenrei] + ichigouni[PARTKK-STARTY][sei][nenrei] ;
                  }
				  else {
                    ichigouip[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] * partgenwari[nendo-STARTY][sei][nenrei][20][2] ;
                    ichigouni[nendo-STARTY][sei][nenrei] = ichigouni[nendo-STARTY][sei][nenrei] ; 
                    ichigou[nendo-STARTY][sei][nenrei]
                      = ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
                  }




                }
            }

            ichigouip[nendo-STARTY][2][nenrei]
              = ichigouip[nendo-STARTY][3][nenrei] + ichigouip[nendo-STARTY][4][nenrei] ;
            for ( ii=18; ii<=25; ii++ ) {
              partnin[nendo-STARTY][2][nenrei][ii][0]
                = partnin[nendo-STARTY][3][nenrei][ii][0] + partnin[nendo-STARTY][4][nenrei][ii][0] ;
              partnin[nendo-STARTY][2][nenrei][ii][1]
                = partnin[nendo-STARTY][3][nenrei][ii][1] + partnin[nendo-STARTY][4][nenrei][ii][1] ;
              partnin[nendo-STARTY][2][nenrei][ii][2]
                = partnin[nendo-STARTY][3][nenrei][ii][2] + partnin[nendo-STARTY][4][nenrei][ii][2] ;
            }
            if ( nendo == PARTYR1-1 ) {
              ichigouip[PARTJJ-STARTY][2][nenrei]
                = ichigouip[PARTJJ-STARTY][3][nenrei] + ichigouip[PARTJJ-STARTY][4][nenrei] ;
              ichigouni[PARTJJ-STARTY][2][nenrei]
                = ichigouni[PARTJJ-STARTY][3][nenrei] + ichigouni[PARTJJ-STARTY][4][nenrei] ;
              ichigou[PARTJJ-STARTY][2][nenrei]
                = ichigou[PARTJJ-STARTY][3][nenrei] + ichigou[PARTJJ-STARTY][4][nenrei] ;
            }
            if ( nendo == PARTYR2-1 ) {
              ichigouip[PARTKK-STARTY][2][nenrei]
                = ichigouip[PARTKK-STARTY][3][nenrei] + ichigouip[PARTKK-STARTY][4][nenrei] ;
              ichigouni[PARTKK-STARTY][2][nenrei]
                = ichigouni[PARTKK-STARTY][3][nenrei] + ichigouni[PARTKK-STARTY][4][nenrei] ;
              ichigou[PARTKK-STARTY][2][nenrei]
                = ichigou[PARTKK-STARTY][3][nenrei] + ichigou[PARTKK-STARTY][4][nenrei] ;
            }
            ichigouip[nendo-STARTY][0][nenrei]
              = ichigouip[nendo-STARTY][1][nenrei] + ichigouip[nendo-STARTY][2][nenrei] ;
            for ( ii=18; ii<=25; ii++ ) {
              partnin[nendo-STARTY][0][nenrei][ii][0]
                = partnin[nendo-STARTY][1][nenrei][ii][0] + partnin[nendo-STARTY][2][nenrei][ii][0] ;
              partnin[nendo-STARTY][0][nenrei][ii][1]
                = partnin[nendo-STARTY][1][nenrei][ii][1] + partnin[nendo-STARTY][2][nenrei][ii][1] ;
              partnin[nendo-STARTY][0][nenrei][ii][2]
                = partnin[nendo-STARTY][1][nenrei][ii][2] + partnin[nendo-STARTY][2][nenrei][ii][2] ;
            }
            if ( nendo == PARTYR1-1 ) {
              ichigouip[PARTJJ-STARTY][0][nenrei]
                = ichigouip[PARTJJ-STARTY][1][nenrei] + ichigouip[PARTJJ-STARTY][2][nenrei] ;
              ichigouni[PARTJJ-STARTY][0][nenrei]
                = ichigouni[PARTJJ-STARTY][1][nenrei] + ichigouni[PARTJJ-STARTY][2][nenrei] ;
              ichigou[PARTJJ-STARTY][0][nenrei]
                = ichigou[PARTJJ-STARTY][1][nenrei] + ichigou[PARTJJ-STARTY][2][nenrei] ;
            }
            if ( nendo == PARTYR2-1 ) {
              ichigouip[PARTKK-STARTY][0][nenrei]
                = ichigouip[PARTKK-STARTY][1][nenrei] + ichigouip[PARTKK-STARTY][2][nenrei] ;
              ichigouni[PARTKK-STARTY][0][nenrei]
                = ichigouni[PARTKK-STARTY][1][nenrei] + ichigouni[PARTKK-STARTY][2][nenrei] ;
              ichigou[PARTKK-STARTY][0][nenrei]
                = ichigou[PARTKK-STARTY][1][nenrei] + ichigou[PARTKK-STARTY][2][nenrei] ;
            }
          }

         
        }
      }

  }


   for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {
     		for ( pkubun=18; pkubun<=20; pkubun++ ) {
       	    	partnin[nendo-STARTY][sei][nenrei][17][1] += partnin[nendo-STARTY][sei][nenrei][pkubun][1] ;
       	    	partnin[nendo-STARTY][sei][nenrei][17][2] += partnin[nendo-STARTY][sei][nenrei][pkubun][2] ;
          	}
      }
    }
   }
  for ( nendo=PARTYR1; nendo<=KE; nendo++ ) {
    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {
        	for ( pkubun=17; pkubun<=20; pkubun++ ) {
          		if ( nendo < PARTYR2 ) {
            		partnin[nendo-STARTY][sei][nenrei][pkubun][0] += partnin[nendo-STARTY][sei][nenrei][pkubun][1] ;
          		}
          	}
      }
    }
  }

    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {
        for ( pkubun=17; pkubun<=20; pkubun++ ) {
        	for ( ykubun=0; ykubun<=2; ykubun++ ) {
				partnin[PARTJJ-STARTY][sei][nenrei][pkubun][ykubun] = partnin[PARTYR1-1-STARTY][sei][nenrei][pkubun][ykubun];
      		}
      	}
      }
    }
	
  	for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
   	 for ( sei=0; sei<=4; sei++ ) {
    	  for ( nenrei=15; nenrei<=79; nenrei++ ) {
            partnin[nendo-STARTY][sei][nenrei][11][2] = partnin[nendo-STARTY][sei][nenrei][17][1] ;
          }
     }
    }
    
  	for ( nendo=PARTYR1-1; nendo<=KE; nendo++ ) {
   	 for ( sei=0; sei<=4; sei++ ) {
    	  for ( nenrei=15; nenrei<=79; nenrei++ ) {
        	for ( ykubun=0; ykubun<=2; ykubun++ ) {
            partnin[nendo-STARTY][sei][nenrei][0][ykubun] += partnin[nendo-STARTY][sei][nenrei][17][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][1][ykubun] += partnin[nendo-STARTY][sei][nenrei][18][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][2][ykubun] += partnin[nendo-STARTY][sei][nenrei][19][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][3][ykubun] += partnin[nendo-STARTY][sei][nenrei][20][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][5][ykubun] += partnin[nendo-STARTY][sei][nenrei][22][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][6][ykubun] += partnin[nendo-STARTY][sei][nenrei][23][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][7][ykubun] += partnin[nendo-STARTY][sei][nenrei][24][ykubun] ;
			partnin[nendo-STARTY][sei][nenrei][8][ykubun] += partnin[nendo-STARTY][sei][nenrei][25][ykubun] ;
			}
          }
     }
    }
	
	 nendo = PARTJJ;
	 for ( sei=0; sei<=4; sei++ ) {
	    for ( nenrei=15; nenrei<=79; nenrei++ ) {
    	  for ( ykubun=0; ykubun<=2; ykubun++ ) {
          partnin[nendo-STARTY][sei][nenrei][0][ykubun] += partnin[nendo-STARTY][sei][nenrei][17][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][1][ykubun] += partnin[nendo-STARTY][sei][nenrei][18][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][2][ykubun] += partnin[nendo-STARTY][sei][nenrei][19][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][3][ykubun] += partnin[nendo-STARTY][sei][nenrei][20][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][5][ykubun] += partnin[nendo-STARTY][sei][nenrei][22][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][6][ykubun] += partnin[nendo-STARTY][sei][nenrei][23][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][7][ykubun] += partnin[nendo-STARTY][sei][nenrei][24][ykubun] ;
    			partnin[nendo-STARTY][sei][nenrei][8][ykubun] += partnin[nendo-STARTY][sei][nenrei][25][ykubun] ;
  			}
      }
    }
  }

  for ( nendo=2016; nendo<=KE; nendo++ ) {
   if ( PART == 0 ){

   } 
   else {
    for ( sei=0; sei<=4; sei++ ) {
      for ( nenrei=15; nenrei<=79; nenrei++ ) {

          if ( nendo < PARTYR2 ) {
           if ( nendo >= PARTYR1 ){
            koyouj_m[7][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][1] ;
            koyouj_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][1] ;
            koyouj_c[7][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][1]+partnin[nendo-STARTY][sei][nenrei][17][1]) / 2.0 ;
            koyouj_c[9][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][1]+partnin[nendo-STARTY][sei][nenrei][17][1]) / 2.0 ;
            
            
            soroudh_m[7][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][1] * 120.0 ;
            soroudh_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][1] * 120.0 ;
			soroudh_c[7][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][1]+partnin[nendo-STARTY][sei][nenrei][17][1] ) * 60.0 ;
            soroudh_c[9][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][1]+partnin[nendo-STARTY][sei][nenrei][17][1] ) * 60.0 ;
            
          }
          else if ( nendo == PARTYR2 ) {
            koyouj_m[7][nendo-STARTY][sei][nenrei]  += partnin[nendo-STARTY][sei][nenrei][17][2] ;
            koyouj_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][2] ;
            koyouj_c[7][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][2]+partnin[nendo-STARTY][sei][nenrei][17][2]) / 2.0 ;
            koyouj_c[9][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][2]+partnin[nendo-STARTY][sei][nenrei][17][2]) / 2.0 ;
           
            
            soroudh_m[7][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][2] * 120.0 ;
            soroudh_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][2] * 120.0 ;
            soroudh_c[7][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][2]+partnin[nendo-STARTY][sei][nenrei][17][2] ) * 50.0 ;
            soroudh_c[9][nendo-STARTY][sei][nenrei]
              		+= (partnin[nendo-1-STARTY][sei][nenrei][17][2]+partnin[nendo-STARTY][sei][nenrei][17][2] ) * 50.0 ;
          }
          else if ( nendo > PARTYR2 ) {
            koyouj_m[7][nendo-STARTY][sei][nenrei]  += partnin[nendo-STARTY][sei][nenrei][17][2] ;
            koyouj_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][2] ;
            koyouj_c[7][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][17][2] + partnin[nendo-STARTY][sei][nenrei][17][2] ) / 2.0 ;
            koyouj_c[9][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][17][2] + partnin[nendo-STARTY][sei][nenrei][17][2] ) / 2.0 ;
            soroudh_m[7][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][2] * 120.0 ;
            soroudh_m[9][nendo-STARTY][sei][nenrei] += partnin[nendo-STARTY][sei][nenrei][17][2] * 120.0 ;
            soroudh_c[7][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][17][2] + partnin[nendo-STARTY][sei][nenrei][17][2] ) * 60.0 ;
            soroudh_c[9][nendo-STARTY][sei][nenrei]
              += ( partnin[nendo-1-STARTY][sei][nenrei][17][2] + partnin[nendo-STARTY][sei][nenrei][17][2] ) * 60.0 ;
          }

         }
	 }
	}
  }
 }

 if ( PART >=1){
  for ( nendo=PARTJJ; nendo<=KE; nendo++ ) {
    if ( ( nendo<= PARTKK ) || ( nendo>=PARTYR1 ) ) {
      XEND = xend[8][nendo-STARTY] ;
      if ( XEND < 60 ) { XEND = 60 ; }
      for ( sei=0; sei<=4; sei++ ) {
        for ( nenrei=15; nenrei<=100; nenrei++ ) {
          ichigou[nendo-STARTY][sei][nenrei] =
            ichigouip[nendo-STARTY][sei][nenrei] + ichigouni[nendo-STARTY][sei][nenrei] ;
        }
        for ( nenrei=20; nenrei<=XEND-1; nenrei++ ) {
          qkounen3[nendo-STARTY][sei][nenrei]
            = qkou12syu3[nendo-STARTY][sei][nenrei] + kou3syu3[nendo-STARTY][sei][nenrei] ;
          kou12syu3[nendo-STARTY][sei][nenrei] = qkou12syu3[nendo-STARTY][sei][nenrei] ;
          kounen3[nendo-STARTY][sei][nenrei] = qkounen3[nendo-STARTY][sei][nenrei] ;
          for ( seido=4; seido<=7; seido++ ) {
            kou12syu3[nendo-STARTY][sei][nenrei] += kyosai3[seido][nendo-STARTY][sei][nenrei] ;
            kounen3[nendo-STARTY][sei][nenrei] += kyosai3[seido][nendo-STARTY][sei][nenrei] ;
          }
          sangou[nendo-STARTY][sei][nenrei] = kounen3[nendo-STARTY][sei][nenrei] ;
          for ( seido=1; seido<=3; seido++ ) { 
            sangou[nendo-STARTY][sei][nenrei] += kyosai3[seido][nendo-STARTY][sei][nenrei] ;
          }
        }
      }
    }
  }
 }


}

