/*************************************
*                                    *
*    外枠システム  setjinko.c        *
*  （人口設定）                      *
*                                    *
*************************************/

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


void setjinko(void) {

int    TMP ;
double TMQ ;
double TMR ;


  for ( nendo=FJINKOY; nendo<=KE; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( nenrei=1; nenrei<=120; nenrei++ ) {
        if ( jinko_c[nendo-1-STARTY][sei][nenrei-1] > 0.0 ) {
          jinko_c[nendo+1-STARTY][sei][nenrei]
            = raund( jinko_c[nendo-STARTY][sei][nenrei-1]
                   * jinko_c[nendo-STARTY][sei][nenrei]
                   / jinko_c[nendo-1-STARTY][sei][nenrei-1] , 0 ) ;
        }
        else {
          jinko_c[nendo+1-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( stk_jinko_c[nendo-1-STARTY][sei][nenrei-1] > 0.0 ) {
          stk_jinko_c[nendo+1-STARTY][sei][nenrei]
            = raund ( stk_jinko_c[nendo-STARTY][sei][nenrei-1]
                    * stk_jinko_c[nendo-STARTY][sei][nenrei]
                    / stk_jinko_c[nendo-1-STARTY][sei][nenrei-1] , 0 );
        }
        else {
          stk_jinko_c[nendo+1-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( str_jinko_c[nendo-1-STARTY][sei][nenrei-1] > 0.0 ) {
          str_jinko_c[nendo+1-STARTY][sei][nenrei]
            = raund ( str_jinko_c[nendo-STARTY][sei][nenrei-1]
                    * str_jinko_c[nendo-STARTY][sei][nenrei]
                    / str_jinko_c[nendo-1-STARTY][sei][nenrei-1] , 0 );
        }
        else {
          str_jinko_c[nendo+1-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( sts_jinko_c[nendo-1-STARTY][sei][nenrei-1] > 0.0 ) {
          sts_jinko_c[nendo+1-STARTY][sei][nenrei]
            = raund ( sts_jinko_c[nendo-STARTY][sei][nenrei-1]
                    * sts_jinko_c[nendo-STARTY][sei][nenrei]
                    / sts_jinko_c[nendo-1-STARTY][sei][nenrei-1] , 0 );
        }
        else {
          sts_jinko_c[nendo+1-STARTY][sei][nenrei] = 0.0 ;
        }
      }
    }
    TMQ = 0.0 ; TMR = 0.0 ;
    for ( nenrei=15; nenrei<=49; nenrei++ ) {
      TMQ += jinko_c[nendo+1-STARTY][2][nenrei] * jinko_syus[nenrei] ;
      TMR += jinko_c[nendo-STARTY][2][nenrei] * jinko_syus[nenrei] ;
    }
    if ( TMR > 0.0 ) {
      for ( sei=1; sei<=2; sei++ ) {
        jinko_c[nendo+1-STARTY][sei][0]
          = raund( jinko_c[nendo-STARTY][sei][0] * TMQ / TMR , 0 );
      }
    }
    TMQ = 0.0 ; TMR = 0.0 ;
    for ( nenrei=15; nenrei<=49; nenrei++ ) {
      TMQ += stk_jinko_c[nendo+1-STARTY][2][nenrei] * jinko_syus[nenrei] ;
      TMR += stk_jinko_c[nendo-STARTY][2][nenrei] * jinko_syus[nenrei] ;
    }
    if ( TMR > 0.0 ) {
      for ( sei=1; sei<=2; sei++ ) {
        stk_jinko_c[nendo+1-STARTY][sei][0]
           = raund( stk_jinko_c[nendo-STARTY][sei][0] * TMQ / TMR , 0 );
      }
    }
    TMQ = 0.0 ; TMR = 0.0 ;
    for ( nenrei=15; nenrei<=49; nenrei++ ) {
      TMQ += str_jinko_c[nendo+1-STARTY][2][nenrei] * jinko_syus[nenrei] ;
      TMR += str_jinko_c[nendo-STARTY][2][nenrei] * jinko_syus[nenrei] ;
    }
    if ( TMR > 0.0 ) {
      for ( sei=1; sei<=2; sei++ ) {
        str_jinko_c[nendo+1-STARTY][sei][0]
           = raund( str_jinko_c[nendo-STARTY][sei][0] * TMQ / TMR , 0 );
      }
    }
    TMQ = 0.0 ; TMR = 0.0 ;
    for ( nenrei=15; nenrei<=49; nenrei++ ) {
      TMQ += sts_jinko_c[nendo+1-STARTY][2][nenrei] * jinko_syus[nenrei] ;
      TMR += sts_jinko_c[nendo-STARTY][2][nenrei] * jinko_syus[nenrei] ;
    }
    if ( TMR > 0.0 ) {
      for ( sei=1; sei<=2; sei++ ) {
        sts_jinko_c[nendo+1-STARTY][sei][0]
           = raund( sts_jinko_c[nendo-STARTY][sei][0] * TMQ / TMR , 0 );
      }
    }
  }



  for ( nendo=STARTY+1; nendo<=KE+1; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( nenrei=106; nenrei<=120; nenrei++ ) {
        if ( jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            jinko_c[nendo-STARTY][sei][105] += jinko_c[nendo-STARTY][sei][nenrei] ;
            jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( stk_jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            stk_jinko_c[nendo-STARTY][sei][105] += stk_jinko_c[nendo-STARTY][sei][nenrei] ;
            stk_jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( str_jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            str_jinko_c[nendo-STARTY][sei][105] += str_jinko_c[nendo-STARTY][sei][nenrei] ;
            str_jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( sts_jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            sts_jinko_c[nendo-STARTY][sei][105] += sts_jinko_c[nendo-STARTY][sei][nenrei] ;
            sts_jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
      }
    }
  }



  for ( nendo=STARTY+1; nendo<=KE; nendo++ ) {
    for ( nenrei=0; nenrei<=105; nenrei++) {
      for ( sei=1; sei<=2; sei++){
         if ( nenrei+SJINKOY-nendo > 0 ) {  
             TMP = 0;
             TMP = nenrei + SJINKOY - nendo; 
             if ( TMP < 106 ) {
               if (( nenrei > 0 ) && ( nenrei < 105 )) {
                   jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
                   stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( stk_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + stk_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
                   str_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( str_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + str_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
                   sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( sts_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + sts_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
               }
               else if ( nenrei==0 ) {     
                   jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( jinko_c[nendo-STARTY][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP] )
                     + jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
                   stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( stk_jinko_c[nendo-STARTY][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP] )
                     + stk_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
                   str_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( str_jinko_c[nendo-STARTY][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP] )
                     + str_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
                   sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( sts_jinko_c[nendo-STARTY][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP] )
                     + sts_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][TMP] ) / 2.0;
               }
               else if ( nenrei==105 ) {     
                   jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][TMP-1] ) / 2.0;
                   stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( stk_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + stk_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][TMP-1] ) / 2.0;
                   str_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( str_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + str_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][TMP-1] ) / 2.0;
                   sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( sts_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + sts_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][TMP] 
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][TMP-1] )
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][TMP-1] ) / 2.0;
               }
             }
             else { 
               if (( nenrei > 0 ) && ( nenrei < 105 )) {
                   jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][105] ) / 2.0;
                   stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( stk_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + stk_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][105] ) / 2.0;
                   str_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( str_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + str_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][105] ) / 2.0;
                   sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( sts_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + sts_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei+1] * jinko_wari[sei][105] ) / 2.0;
               }
               else if ( nenrei==105 ) {     
                   jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][105] ) / 2.0;
                   stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( stk_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + stk_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + stk_jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][105] ) / 2.0;
                   str_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( str_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + str_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + str_jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][105] ) / 2.0;
                   sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                     ( sts_jinko_c[nendo-STARTY][sei][nenrei-1] * ( 1.0 - jinko_wari[sei][105] )
                     + sts_jinko_c[nendo-STARTY][sei][nenrei] * jinko_wari[sei][105] 
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * ( 1.0 - jinko_wari[sei][105] )
                     + sts_jinko_c[nendo-STARTY+1][sei][nenrei] * jinko_wari[sei][105] ) / 2.0;
               }
             }

         }
         else { 
             if (( nenrei > 0 ) && ( nenrei < 105 )) {
                 jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + jinko_c[nendo-STARTY][sei][nenrei] 
                   + jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
                 stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( stk_jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + stk_jinko_c[nendo-STARTY][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
                 str_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( str_jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + str_jinko_c[nendo-STARTY][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
                 sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( sts_jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + sts_jinko_c[nendo-STARTY][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
             }
             else if ( nenrei==0 ) {     
                 jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( jinko_c[nendo-STARTY][sei][nenrei] 
                   + jinko_c[nendo-STARTY][sei][nenrei] 
                   + jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
                 stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( stk_jinko_c[nendo-STARTY][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
                 str_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( str_jinko_c[nendo-STARTY][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
                 sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( sts_jinko_c[nendo-STARTY][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY+1][sei][nenrei+1] ) / 4.0;
             }
             else if ( nenrei==105 ) {     
                 jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + jinko_c[nendo-STARTY][sei][nenrei] 
                   + jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + jinko_c[nendo-STARTY+1][sei][nenrei] ) / 4.0;
                 stk_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( stk_jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + stk_jinko_c[nendo-STARTY][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + stk_jinko_c[nendo-STARTY+1][sei][nenrei] ) / 4.0;
                 str_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( str_jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + str_jinko_c[nendo-STARTY][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + str_jinko_c[nendo-STARTY+1][sei][nenrei] ) / 4.0;
                 sts_jinko_m[nendo-STARTY][sei][nenrei] = 
                   ( sts_jinko_c[nendo-STARTY][sei][nenrei-1] 
                   + sts_jinko_c[nendo-STARTY][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY+1][sei][nenrei] 
                   + sts_jinko_c[nendo-STARTY+1][sei][nenrei] ) / 4.0;
             }
         }
         jinko_c[nendo-STARTY][0][nenrei]
           = jinko_c[nendo-STARTY][1][nenrei] + jinko_c[nendo-STARTY][2][nenrei] ; 
         jinko_m[nendo-STARTY][0][nenrei]
           = jinko_m[nendo-STARTY][1][nenrei] + jinko_m[nendo-STARTY][2][nenrei] ; 
         stk_jinko_c[nendo-STARTY][0][nenrei]
           = stk_jinko_c[nendo-STARTY][1][nenrei] + stk_jinko_c[nendo-STARTY][2][nenrei] ; 
         stk_jinko_m[nendo-STARTY][0][nenrei]
           = stk_jinko_m[nendo-STARTY][1][nenrei] + stk_jinko_m[nendo-STARTY][2][nenrei] ; 
         str_jinko_c[nendo-STARTY][0][nenrei]
           = str_jinko_c[nendo-STARTY][1][nenrei] + str_jinko_c[nendo-STARTY][2][nenrei] ; 
         str_jinko_m[nendo-STARTY][0][nenrei]
           = str_jinko_m[nendo-STARTY][1][nenrei] + str_jinko_m[nendo-STARTY][2][nenrei] ; 
         sts_jinko_c[nendo-STARTY][0][nenrei]
           = sts_jinko_c[nendo-STARTY][1][nenrei] + sts_jinko_c[nendo-STARTY][2][nenrei] ; 
         sts_jinko_m[nendo-STARTY][0][nenrei]
           = sts_jinko_m[nendo-STARTY][1][nenrei] + sts_jinko_m[nendo-STARTY][2][nenrei] ; 

      }
    }
  }


  for ( nendo=STARTY+1; nendo<=KE+1; nendo++ ) {
    for ( sei=1; sei<=2; sei++ ) {
      for ( nenrei=101; nenrei<=120; nenrei++ ) {
        if ( jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            jinko_c[nendo-STARTY][sei][100] += jinko_c[nendo-STARTY][sei][nenrei] ;
            jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( jinko_m[nendo-STARTY][sei][nenrei] > 0.0 ) {
            jinko_m[nendo-STARTY][sei][100] += jinko_m[nendo-STARTY][sei][nenrei] ;
            jinko_m[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( stk_jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            stk_jinko_c[nendo-STARTY][sei][100] += stk_jinko_c[nendo-STARTY][sei][nenrei] ;
            stk_jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( stk_jinko_m[nendo-STARTY][sei][nenrei] > 0.0 ) {
            stk_jinko_m[nendo-STARTY][sei][100] += stk_jinko_m[nendo-STARTY][sei][nenrei] ;
            stk_jinko_m[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( str_jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            str_jinko_c[nendo-STARTY][sei][100] += str_jinko_c[nendo-STARTY][sei][nenrei] ;
            str_jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( str_jinko_m[nendo-STARTY][sei][nenrei] > 0.0 ) {
            str_jinko_m[nendo-STARTY][sei][100] += str_jinko_m[nendo-STARTY][sei][nenrei] ;
            str_jinko_m[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( sts_jinko_c[nendo-STARTY][sei][nenrei] > 0.0 ) {
            sts_jinko_c[nendo-STARTY][sei][100] += sts_jinko_c[nendo-STARTY][sei][nenrei] ;
            sts_jinko_c[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
        if ( sts_jinko_m[nendo-STARTY][sei][nenrei] > 0.0 ) {
            sts_jinko_m[nendo-STARTY][sei][100] += sts_jinko_m[nendo-STARTY][sei][nenrei] ;
            sts_jinko_m[nendo-STARTY][sei][nenrei] = 0.0 ;
        }
      }
    }
  }



/*  女性有配偶、無配偶別人口  */

  /*  年度中有配偶率の延長  */
  for ( nendo=YUHAIGY+1; nendo<=KE+1; nendo++ ) {
    for ( nenrei=0; nenrei<=100; nenrei++) {
      yuhaigr_c[nendo-STARTY][nenrei] = yuhaigr_c[nendo-1-STARTY][nenrei] ;
    }
  }

  for ( nendo=STARTY+1; nendo<=KE+1; nendo++ ) {
    for ( nenrei=0; nenrei<=100; nenrei++) {
      /*  年度末有配偶率  */
        yuhaigr_m[nendo-STARTY][nenrei] =
          ( yuhaigr_c[nendo-STARTY][nenrei] + yuhaigr_c[nendo+1-STARTY][nenrei] ) / 2.0 ;
      /*  有配偶、無配偶別人口  */
        jinko_c[nendo-STARTY][3][nenrei] =
          jinko_c[nendo-STARTY][2][nenrei] * yuhaigr_c[nendo-STARTY][nenrei] ;
        jinko_c[nendo-STARTY][4][nenrei] =
          jinko_c[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_c[nendo-STARTY][nenrei] ) ;
        jinko_m[nendo-STARTY][3][nenrei] =
          jinko_m[nendo-STARTY][2][nenrei] * yuhaigr_m[nendo-STARTY][nenrei] ;
        jinko_m[nendo-STARTY][4][nenrei] =
          jinko_m[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_m[nendo-STARTY][nenrei] ) ;
        stk_jinko_c[nendo-STARTY][3][nenrei] =
          stk_jinko_c[nendo-STARTY][2][nenrei] * yuhaigr_c[nendo-STARTY][nenrei] ;
        stk_jinko_c[nendo-STARTY][4][nenrei] =
          stk_jinko_c[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_c[nendo-STARTY][nenrei] ) ;
        stk_jinko_m[nendo-STARTY][3][nenrei] =
          stk_jinko_m[nendo-STARTY][2][nenrei] * yuhaigr_m[nendo-STARTY][nenrei] ;
        stk_jinko_m[nendo-STARTY][4][nenrei] =
          stk_jinko_m[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_m[nendo-STARTY][nenrei] ) ;
        str_jinko_c[nendo-STARTY][3][nenrei] =
          str_jinko_c[nendo-STARTY][2][nenrei] * yuhaigr_c[nendo-STARTY][nenrei] ;
        str_jinko_c[nendo-STARTY][4][nenrei] =
          str_jinko_c[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_c[nendo-STARTY][nenrei] ) ;
        str_jinko_m[nendo-STARTY][3][nenrei] =
          str_jinko_m[nendo-STARTY][2][nenrei] * yuhaigr_m[nendo-STARTY][nenrei] ;
        str_jinko_m[nendo-STARTY][4][nenrei] =
          str_jinko_m[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_m[nendo-STARTY][nenrei] ) ;
        sts_jinko_c[nendo-STARTY][3][nenrei] =
          sts_jinko_c[nendo-STARTY][2][nenrei] * yuhaigr_c[nendo-STARTY][nenrei] ;
        sts_jinko_c[nendo-STARTY][4][nenrei] =
          sts_jinko_c[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_c[nendo-STARTY][nenrei] ) ;
        sts_jinko_m[nendo-STARTY][3][nenrei] =
          sts_jinko_m[nendo-STARTY][2][nenrei] * yuhaigr_m[nendo-STARTY][nenrei] ;
        sts_jinko_m[nendo-STARTY][4][nenrei] =
          sts_jinko_m[nendo-STARTY][2][nenrei] * (1.0 - yuhaigr_m[nendo-STARTY][nenrei] ) ;
    }
  }

/*  総人口、生産年齢人口  */

  for ( nendo=STARTY+1; nendo<=KE; nendo++ ) {
    sojinko_c[nendo-STARTY][0] = sojinko_c[nendo-STARTY][1] + sojinko_c[nendo-STARTY][2] ;
    stk_sojinko_c[nendo-STARTY][0] = stk_sojinko_c[nendo-STARTY][1] + stk_sojinko_c[nendo-STARTY][2] ;
    str_sojinko_c[nendo-STARTY][0] = str_sojinko_c[nendo-STARTY][1] + str_sojinko_c[nendo-STARTY][2] ;
    sts_sojinko_c[nendo-STARTY][0] = sts_sojinko_c[nendo-STARTY][1] + sts_sojinko_c[nendo-STARTY][2] ;
    for ( nenrei=0; nenrei<=100; nenrei++) {
      for ( sei=1; sei<=4; sei++){
        sojinko_m[nendo-STARTY][sei] += jinko_m[nendo-STARTY][sei][nenrei] ;
        stk_sojinko_m[nendo-STARTY][sei] += stk_jinko_m[nendo-STARTY][sei][nenrei] ;
        str_sojinko_m[nendo-STARTY][sei] += str_jinko_m[nendo-STARTY][sei][nenrei] ;
        sts_sojinko_m[nendo-STARTY][sei] += sts_jinko_m[nendo-STARTY][sei][nenrei] ;
        if ( sei<=2 ) {
          sojinko_m[nendo-STARTY][0] += jinko_m[nendo-STARTY][sei][nenrei] ;
          stk_sojinko_m[nendo-STARTY][0] += stk_jinko_m[nendo-STARTY][sei][nenrei] ;
          str_sojinko_m[nendo-STARTY][0] += str_jinko_m[nendo-STARTY][sei][nenrei] ;
          sts_sojinko_m[nendo-STARTY][0] += sts_jinko_m[nendo-STARTY][sei][nenrei] ;
        }
        if (( nenrei >= 15 ) && ( nenrei <= 64 )) {
          seisanj_c[nendo-STARTY][sei] += jinko_c[nendo-STARTY][sei][nenrei] ;
          seisanj_m[nendo-STARTY][sei] += jinko_m[nendo-STARTY][sei][nenrei] ;
          stk_seisanj_c[nendo-STARTY][sei] += stk_jinko_c[nendo-STARTY][sei][nenrei] ;
          stk_seisanj_m[nendo-STARTY][sei] += stk_jinko_m[nendo-STARTY][sei][nenrei] ;
          str_seisanj_c[nendo-STARTY][sei] += str_jinko_c[nendo-STARTY][sei][nenrei] ;
          str_seisanj_m[nendo-STARTY][sei] += str_jinko_m[nendo-STARTY][sei][nenrei] ;
          sts_seisanj_c[nendo-STARTY][sei] += sts_jinko_c[nendo-STARTY][sei][nenrei] ;
          sts_seisanj_m[nendo-STARTY][sei] += sts_jinko_m[nendo-STARTY][sei][nenrei] ;
          if ( sei<=2 ) {
            seisanj_c[nendo-STARTY][0] += jinko_c[nendo-STARTY][sei][nenrei] ;
            seisanj_m[nendo-STARTY][0] += jinko_m[nendo-STARTY][sei][nenrei] ;
            stk_seisanj_c[nendo-STARTY][0] += stk_jinko_c[nendo-STARTY][sei][nenrei] ;
            stk_seisanj_m[nendo-STARTY][0] += stk_jinko_m[nendo-STARTY][sei][nenrei] ;
            str_seisanj_c[nendo-STARTY][0] += str_jinko_c[nendo-STARTY][sei][nenrei] ;
            str_seisanj_m[nendo-STARTY][0] += str_jinko_m[nendo-STARTY][sei][nenrei] ;
            sts_seisanj_c[nendo-STARTY][0] += sts_jinko_c[nendo-STARTY][sei][nenrei] ;
            sts_seisanj_m[nendo-STARTY][0] += sts_jinko_m[nendo-STARTY][sei][nenrei] ;
          }
        }
      }
    }
  }


}

