/*************************************
*                                    *
*    外枠システム  readdata.c        *
*  （入力ファイル読み込み）          *
*      共済部分は除く                *
*                                    *
*************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "set.h"
#include "cntl.h"
#include "file_open.h"


void readdata(void)
{

 /* 変数定義 */
    int     ii               ;
    int     jj               ;
    int     kk               ;
    previous_buffer0 = -1000 ;
    char    filename[250]    ; 
    char    pathname[250]    ; 


/*  出力先のディレクトリを作成  */
    sprintf(pathname, "/rev26/wakuc/rslt/ver_5/" ) ;
    mkdir( pathname, 0755 );
    sprintf(pathname, "/rev26/wakuc/rslt/ver_5/rslt%04d", BANGO ) ;
    mkdir( pathname, 0755 );


/*  エラー出力用ファイルを開く  */
    sprintf(filename, "/rev26/wakuc/rslt/ver_5/rslt%04d/waku%04d-err.csv" , BANGO, BANGO);
    if ((fp_err = fopen(filename, "w")) == NULL) {
        fprintf(stderr, "出力用ファイルを開けません\n");
        exit (2);
    }


/* 人口関係 */

  /* （１）推計人口  */

      switch ( JIN ) {
          case 11: /* 出生率中位推計 */
              if ( QX == 1 ) { /* 死亡率中位推計 */
                sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fm-dm.csv");
                sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fm-dm.csv");
              }
              else if ( QX == 2 ) { /* 死亡率高位推計 */
                sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fm-dh.csv");
                sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fm-dh.csv");
              }
              else if ( QX == 3 ) { /* 死亡率低位推計 */
                sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fm-dl.csv");
                sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fm-dl.csv");
              }
              break ;
          case 12: /* 出生率高位推計、死亡率中位推計 */
              sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fh-dm.csv");
              sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fh-dm.csv");
              break ;
          case 13: /* 出生率低位推計、死亡率中位推計 */
              sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fl-dm.csv");
              sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fl-dm.csv");
              break ;

      }

      if ((fp_jinkom = fopen(filename_m, "r")) == NULL) {
          fprintf(stderr, "男性人口推計ファイルを開けません!\n");
          exit (2);
      }
      if ((fp_jinkof = fopen(filename_f, "r")) == NULL) {
          fprintf(stderr, "女性人口推計ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkom ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkom, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "男性人口ファイルエラー\n");
              exit (2);
          }
          sojinko_c[nendo-STARTY][1] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      /*  女性読み込み  */
      karayomi( fp_jinkof ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkof, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性人口ファイルエラー\n");
              exit (2);
          }
          sojinko_c[nendo-STARTY][2] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

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


  /* （２）推計人口のうち標準人口  */

          switch ( KYOREQBK ) {
              case 11: /* 出生率中位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fm-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fm-dm.csv");
                  break ;
              case 12: /* 出生率高位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fh-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fh-dm.csv");
                  break ;
              case 13: /* 出生率低位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fl-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fl-dm.csv");
                  break ;
          }


      if ((fp_jinkom = fopen(filename_m, "r")) == NULL) {
          fprintf(stderr, "男性人口推計ファイルを開けません!\n");
          exit (2);
      }
      if ((fp_jinkof = fopen(filename_f, "r")) == NULL) {
          fprintf(stderr, "女性人口推計ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkom ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkom, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "男性人口ファイルエラー\n");
              exit (2);
          }
          stk_sojinko_c[nendo-STARTY][1] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              stk_jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      karayomi( fp_jinkof ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkof, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性人口ファイルエラー\n");
              exit (2);
          }
          stk_sojinko_c[nendo-STARTY][2] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              stk_jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

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


          switch ( KYOREQBR ) {
              case 11: /* 出生率中位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fm-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fm-dm.csv");
                  break ;
              case 12: /* 出生率高位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fh-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fh-dm.csv");
                  break ;
              case 13: /* 出生率低位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fl-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fl-dm.csv");
                  break ;
          }


      if ((fp_jinkom = fopen(filename_m, "r")) == NULL) {
          fprintf(stderr, "男性人口推計（標準R）ファイルを開けません!\n");
          exit (2);
      }
      if ((fp_jinkof = fopen(filename_f, "r")) == NULL) {
          fprintf(stderr, "女性人口推計（標準R）ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkom ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkom, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "男性人口（標準R）ファイルエラー\n");
              exit (2);
          }
          str_sojinko_c[nendo-STARTY][1] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              str_jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      karayomi( fp_jinkof ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkof, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性人口（標準R）ファイルエラー\n");
              exit (2);
          }
          str_sojinko_c[nendo-STARTY][2] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              str_jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      fclose(fp_jinkom);
      fclose(fp_jinkof);


          switch ( KYOREQBS ) {
              case 11: /* 出生率中位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fm-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fm-dm.csv");
                  break ;
              case 12: /* 出生率高位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fh-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fh-dm.csv");
                  break ;
              case 13: /* 出生率低位推計・死亡率中位推計 */
                  sprintf(filename_m, "/rev26/wakuc/data/sinj/jinko24/popm-fl-dm.csv");
                  sprintf(filename_f, "/rev26/wakuc/data/sinj/jinko24/popf-fl-dm.csv");
                  break ;
          }


      if ((fp_jinkom = fopen(filename_m, "r")) == NULL) {
          fprintf(stderr, "男性人口推計（標準S）ファイルを開けません!\n");
          exit (2);
      }
      if ((fp_jinkof = fopen(filename_f, "r")) == NULL) {
          fprintf(stderr, "女性人口推計（標準S）ファイルを開けません!\n");
          exit (2);
      }


      karayomi( fp_jinkom ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkom, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "男性人口ファイルエラー\n");
              exit (2);
          }
          sts_sojinko_c[nendo-STARTY][1] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              sts_jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }


      karayomi( fp_jinkof ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkof, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性人口ファイルエラー\n");
              exit (2);
          }
          sts_sojinko_c[nendo-STARTY][2] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              sts_jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      fclose(fp_jinkom);
      fclose(fp_jinkof);


  /* （３）実績人口 */

      sprintf(filename_m, "/rev26/wakuc/data/sinj/popm-jisseki26.csv");
      sprintf(filename_f, "/rev26/wakuc/data/sinj/popf-jisseki26.csv");

      if ((fp_jinkom = fopen(filename_m, "r")) == NULL) {
          fprintf(stderr, "実績男性人口ファイルを開けません!\n");
          exit (2);
      }
      if ((fp_jinkof = fopen(filename_f, "r")) == NULL) {
          fprintf(stderr, "実績女性人口ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkom ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkom, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "男性実績人口ファイルエラー\n");
              exit (2);
          }
          sojinko_c[nendo-STARTY][1] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
              stk_jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
              sts_jinko_c[nendo-STARTY][1][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      karayomi( fp_jinkof ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkof, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性実績人口ファイルエラー\n");
              exit (2);
          }
          sojinko_c[nendo-STARTY][2] = buffer[2];
          for ( nenrei=0; nenrei<=120; nenrei++) {
              jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
              stk_jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
              sts_jinko_c[nendo-STARTY][2][nenrei] = buffer[nenrei+3];
          }
          previous_buffer0 = buffer[0] ;
      }

      fclose(fp_jinkom);
      fclose(fp_jinkof);



  /* （４）人口割合 */

      sprintf(filename, "/rev26/wakuc/data/sinj/jinko24/wari-2010.csv");

      if ((fp_jinkow = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "人口割合ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkow ) ;
      while (( read_csv( buffer, fp_jinkow, &data_number ) != EOF ) ) {
          nenrei = (int)(buffer[0]) ;
          if (( nenrei < 0 ) || ( nenrei > 120 )) {
              fprintf(stderr, "人口割合ファイルエラー\n");
              exit (2);
          }
          jinko_wari[1][nenrei] = buffer[1];
          jinko_wari[2][nenrei] = buffer[2];
      }

      fclose(fp_jinkow);

      sprintf(filename, "/rev26/wakuc/data/sinj/jinko24/syus-2010.csv");

      if ((fp_jinkow = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "人口割合Sファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkow ) ;
      while (( read_csv( buffer, fp_jinkow, &data_number ) != EOF ) ) {
          nenrei = (int)(buffer[0]) ;
          if (( nenrei < 15 ) || ( nenrei > 49 )) {
              fprintf(stderr, "人口割合Sファイルエラー\n");
              exit (2);
          }

          switch ( JIN ) {
              case 11: /* 出生率中位推計 */
                  jinko_syus[nenrei] = buffer[1];
                  break ;
              case 12: /* 出生率高位推計 */
                  jinko_syus[nenrei] = buffer[2];
                  break ;
              case 13: /* 出生率低位推計 */
                  jinko_syus[nenrei] = buffer[3];
                  break ;
          }
      }

      fclose(fp_jinkow);





  /* （５）女性有配偶者割合（推計） */

      switch ( YUHAIGX ) {
          case 1: 
              sprintf(filename, "/rev26/wakuc/data/sinj/jinko24/yuhaigr_suikei-25-1.csv");
              break ;
      }

      if ((fp_jinkoy = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "女性有配偶割合（推計）ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkoy ) ;
      karayomi( fp_jinkoy ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkoy, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性有配偶（推計）ファイルエラー\n");
              exit (2);
          }
          sei = (int)(buffer[1]) ;
          if ( sei != 2 ) {
              fprintf(stderr, "女性有配偶（推計）ファイルエラー\n");
              exit (2);
          }
          for ( nenrei=15; nenrei<=100; nenrei++) {
              yuhaigr_c[nendo-STARTY][nenrei] = buffer[nenrei-12] / 100.0 ;
          }
          previous_buffer0 = buffer[0] ;
      }

      fclose(fp_jinkoy);


  /* （６）女性有配偶者割合（実績） */

      sprintf(filename, "/rev26/wakuc/data/sinj/jinko24/yuhaigr_jisseki24.csv");

      if ((fp_jinkoy = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "女性有配偶割合（実績）ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkoy ) ;
      karayomi( fp_jinkoy ) ;
      previous_buffer0 = -1000 ;
      while (( read_csv( buffer, fp_jinkoy, &data_number ) != EOF ) && (buffer[0] > previous_buffer0 )) {
          nendo = (int)(buffer[0]) ;
          if (( nendo < STARTY ) || ( nendo > ENDY )) {
              fprintf(stderr, "女性有配偶（実績）ファイルエラー\n");
              exit (2);
          }
          sei = (int)(buffer[1]) ;
          if ( sei != 2 ) {
              fprintf(stderr, "女性有配偶（実績）ファイルエラー\n");
              exit (2);
          }
          for ( nenrei=15; nenrei<=100; nenrei++) {
              yuhaigr_c[nendo-STARTY][nenrei] = buffer[nenrei-12] / 100.0 ;
          }
          previous_buffer0 = buffer[0] ;
      }

      fclose(fp_jinkoy);


  /* （７）共済推計用、実績の総人口（生産年齢人口）  */

      sprintf(filename, "/rev26/wakuc/data/sinj/jissekiseisan26.csv") ;

      if ((fp_jinkoy = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "実績総人口ファイルを開けません!\n");
          exit (2);
      }

      karayomi( fp_jinkoy ) ;
      while ( read_csv( buffer, fp_jinkoy, &data_number ) != EOF ) {
          nendo = (int) (buffer[0]) ;
          seisanj_j_c[nendo-STARTY][0] = buffer[1] * 1000 ;
          seisanj_j_c[nendo-STARTY][1] = buffer[2] * 1000 ;
          seisanj_j_c[nendo-STARTY][2] = buffer[3] * 1000 ;
          seisanj_j_m[nendo-STARTY][0] = buffer[4] * 1000 ;
          seisanj_j_m[nendo-STARTY][1] = buffer[5] * 1000 ;
          seisanj_j_m[nendo-STARTY][2] = buffer[6] * 1000 ;

          sojinko_j_c[nendo-STARTY][0] = buffer[8] * 1000 ;
          sojinko_j_c[nendo-STARTY][1] = buffer[9] * 1000 ;
          sojinko_j_c[nendo-STARTY][2] = buffer[10] * 1000 ;
          sojinko_j_m[nendo-STARTY][0] = buffer[11] * 1000 ;
          sojinko_j_m[nendo-STARTY][1] = buffer[12] * 1000 ;
          sojinko_j_m[nendo-STARTY][2] = buffer[13] * 1000 ;
      }

      fclose( fp_jinkoy ) ;



/* 労働力関係 */

  /* （１）労働力率（進まないケース） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      switch ( ROUDR ) {
          case 1: 
          case 2: 
              sprintf(filename, "/rev26/wakuc/data/roud/roudou26-1-a.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "労働力率ファイルを開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            roudr_a_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }


  /* （２）労働力率  */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      switch ( ROUDR ) {
          case 1: /* 進むケース */
              sprintf(filename, "/rev26/wakuc/data/roud/roudou26-1-c.csv");
              break ;
          case 2: /* 進まないケース */
              sprintf(filename, "/rev26/wakuc/data/roud/roudou26-1-a.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "労働力率ファイル（ケース毎）を開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            roudr_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }

  /* （３）就業者割合（進まないケース） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      switch ( ROUDR ) {
          case 1: 
          case 2: 
              sprintf(filename, "/rev26/wakuc/data/roud/syuwari26-1-a.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "就業者割合ファイルを開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            syuwari_a_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }

  /* （４）就業者割合 */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      switch ( ROUDR ) {
          case 1: /* 進むケース */
              sprintf(filename, "/rev26/wakuc/data/roud/syuwari26-1-c.csv");
              break ;
          case 2: /* 進まないケース */
              sprintf(filename, "/rev26/wakuc/data/roud/syuwari26-1-a.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "就業者割合ファイル（ケース毎）を開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            syuwari_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }


  /* （５）就業率（進まないケース） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      switch ( ROUDR ) {
          case 1: 
          case 2: 
              sprintf(filename, "/rev26/wakuc/data/roud/syugyor26-1-a.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "就業率ファイルを開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            syugyor_a_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }

  /* （６）就業率 */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      switch ( ROUDR ) {
          case 1: /* 進むケース */
              sprintf(filename, "/rev26/wakuc/data/roud/syugyor26-1-c.csv");
              break ;
          case 2: /* 進まないケース */
              sprintf(filename, "/rev26/wakuc/data/roud/syugyor26-1-a.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "就業率ファイル（ケース毎）を開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            syugyor_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }


  /* （７）年度末労働力率（実績） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      sprintf(filename, "/rev26/wakuc/data/roud/roudou26-mj.csv");
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "年度末労働力率ファイルを開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1999, ROUDYR );
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            roudr_m[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
            roudr_a_m[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }

  /* （８）年度末就業者割合（実績） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      sprintf(filename, "/rev26/wakuc/data/roud/syuwari26-mj.csv");
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "年度末労働力率ファイルを開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1999, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            syuwari_m[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
            syuwari_a_m[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }

  /* （９）年度末就業率（実績） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      sprintf(filename, "/rev26/wakuc/data/roud/syugyor26-mj.csv");
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "年度末労働力率ファイルを開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1999, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            syugyor_m[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
            syugyor_a_m[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }


  /* （10）雇用者割合（実績） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

      sprintf(filename, "/rev26/wakuc/data/roud/koyour26.csv");

      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "雇用者割合ファイル（実績）を開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR );
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            koyour_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
            koyour_a_c[nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }

  /* （11）年齢別短時間雇用者割合（実績） */

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            TEMP[nendo-STARTY][sei][nenrei] = 0.0 ;
          }
        }
      }

        sprintf(filename, "/rev26/wakuc/data/roud/tankor26.csv");

      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
         fprintf(stderr, "年齢別短時間雇用者割合ファイル（実績）を開けません!\n");
         exit (2);
      }
      read_roud( fp_roudritu, 1996, ROUDYR ); 
      fclose( fp_roudritu );

      for ( nendo=1996; nendo<=ROUDYR; nendo++ ) {
        for ( sei=1; sei<=4; sei++ ) {
          for ( nenrei=15; nenrei<=100; nenrei++ ) {
            tankor_c[2][nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
            tankor_c[3][nendo-STARTY][sei][nenrei] = TEMP[nendo-STARTY][sei][nenrei] ;
            tankor_c[1][nendo-STARTY][sei][nenrei] = 1.0 - TEMP[nendo-STARTY][sei][nenrei] ;
          }
        }
      }


  /* （12）諸設定値 */

      switch ( ROUDR ) {
          case 1: 
          case 2: 
              sprintf(filename, "/rev26/wakuc/data/roud/syosettei26-1.csv");
              break ;
      }
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "諸設定値ファイルを開けません!\n");
          exit (2);
      }

          karayomi( fp_roudritu );

      for ( ii=1; ii<=3; ii++ ) {
          karayomi( fp_roudritu );
          karayomi( fp_roudritu );
          for ( jj=1996; jj<=ROUDYR; jj++ ) {
              read_csv( buffer, fp_roudritu, &data_number );
              nendo = (int)buffer[0] ;
              kk = (int)buffer[1] ;
              if ( ( kk == 1 ) && ( ROUDR == 2 ) ) {  
                  tankor_all_c[2][nendo-STARTY] = buffer[2] ; 
                  heikinh_c[1][nendo-STARTY] = buffer[3] ;    
                  heikinh_c[3][nendo-STARTY] = buffer[4] ;    
                  heikinh_c[8][nendo-STARTY] = buffer[5] ;    
                  heikinh_c[2][nendo-STARTY] = buffer[6] ;    
                  tankor_all_c[4][nendo-STARTY] = buffer[9] + buffer[10] ; 
                  tankor_all_c[5][nendo-STARTY] = buffer[11] ; 
                  tankor_all_c[6][nendo-STARTY] = buffer[7] + buffer[8]  ; 
                  kounenteki_c[1][nendo-STARTY] = buffer[12] ; 
                  kounenteki_c[2][nendo-STARTY] = buffer[13] ; 
                  kounenteki_c[4][nendo-STARTY] = buffer[14] ; 
                  kounenteki_c[5][nendo-STARTY] = buffer[15] ; 
                  kounenteki_c[6][nendo-STARTY] = buffer[16] ; 
              }
              else if ( ( kk == 3 ) && ( ROUDR == 1 ) )  {  
                  tankor_all_c[2][nendo-STARTY] = buffer[2] ; 
                  heikinh_c[1][nendo-STARTY] = buffer[3] ;    
                  heikinh_c[3][nendo-STARTY] = buffer[4] ;    
                  heikinh_c[8][nendo-STARTY] = buffer[5] ;    
                  heikinh_c[2][nendo-STARTY] = buffer[6] ;    
                  tankor_all_c[4][nendo-STARTY] = buffer[9] + buffer[10] ; 
                  tankor_all_c[5][nendo-STARTY] = buffer[11] ; 
                  tankor_all_c[6][nendo-STARTY] = buffer[7] + buffer[8]  ; 
                  kounenteki_c[1][nendo-STARTY] = buffer[12] ; 
                  kounenteki_c[2][nendo-STARTY] = buffer[13] ; 
                  kounenteki_c[4][nendo-STARTY] = buffer[14] ; 
                  kounenteki_c[5][nendo-STARTY] = buffer[15] ; 
                  kounenteki_c[6][nendo-STARTY] = buffer[16] ; 
              }
          }
      }

      fclose( fp_roudritu ) ;



/*  被保険者数過去実績  */

    /*  平成８年度  */
    if ( KIJUN >= 1996 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H08map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成８年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 1996 );
         fclose( fp_map );
    }

    /*  平成９年度  */
    if ( KIJUN >= 1997 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H09map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成９年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 1997 );
         fclose( fp_map );
    }

    /*  平成10年度  */
    if ( KIJUN >= 1998 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H10map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成10年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 1998 );
         fclose( fp_map );
    }

    /*  平成11年度  */
    if ( KIJUN >= 1999 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H11map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成11年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 1999 );
         fclose( fp_map );
    }

    /*  平成12年度  */
    if ( KIJUN >= 2000 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H12map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成12年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2000 );
         fclose( fp_map );
    }

    /*  平成13年度  */
    if ( KIJUN >= 2001 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H13map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成13年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2001 );
         fclose( fp_map );
    }

    /*  平成14年度  */
    if ( KIJUN >= 2002 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H14map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成14年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2002 );
         fclose( fp_map );
    }

    /*  平成15年度  */
    if ( KIJUN >= 2003 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H15map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成15年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2003 );
         fclose( fp_map );
    }

    /*  平成16年度  */
    if ( KIJUN >= 2004 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H16map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成16年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2004 );
         fclose( fp_map );
    }

    /*  平成17年度  */
    if ( KIJUN >= 2005 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H17map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成17年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2005 );
         fclose( fp_map );
    }

    /*  平成18年度  */
    if ( KIJUN >= 2006 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H18map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成18年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2006 );
         fclose( fp_map );
    }

    /*  平成19年度  */
    if ( KIJUN >= 2007 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H19map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成19年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2007 );
         fclose( fp_map );
    }

    /*  平成20年度  */
    if ( KIJUN >= 2008 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H20map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成20年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2008 );
         fclose( fp_map );
    }

    /*  平成21年度  */
    if ( KIJUN >= 2009 )  {
         sprintf(filename, "/rev26/wakuc/data/map/H21map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成21年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2009 );
         fclose( fp_map );
    }

    /*  平成22年度  */
    if ( KIJUN >= 2010 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H22map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成22年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2010 );
         fclose( fp_map );
    }

    /*  平成23年度  */
    if ( KIJUN >= 2011 ) {
         sprintf(filename, "/rev26/wakuc/data/map/H23map.csv");
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成23年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2011 );
         fclose( fp_map );
    }

    /*  平成24年度  */
    if ( KIJUN >= 2012 ) {
         if ( MODE == 4 ) { 
             sprintf(filename, "/rev26/wakuc/data/map/H24map-op.csv");
         }
         else {
             sprintf(filename, "/rev26/wakuc/data/map/H24map.csv");
         }
         if ((fp_map = fopen(filename, "r")) == NULL) {
             fprintf(stderr, "平成24年度被保険者数を開けません!\n");
             exit (2);
         }
         read_map( fp_map, 2012 );
         fclose( fp_map );
    }



/*  １号女性の有配偶率  */

      sprintf(filename, "/rev26/wakuc/data/prev/ichiyuhaigr26.csv");
      if ((fp_roudritu = fopen(filename, "r")) == NULL) {
          fprintf(stderr, "１号有配偶率ファイルを開けません!\n");
          exit (2);
      }

        karayomi( fp_roudritu );

        for ( ii=20; ii<=69; ii++) {
            read_csv( buffer, fp_roudritu, &data_number );
            nenrei = (int)buffer[0];
            ichiyuhaigr[nenrei] = buffer[5] / 100.0 ;
        }

        fclose( fp_roudritu );


/*  上限年齢  */
    if ( MODE == 4 ) {
        sprintf(filename, "/rev26/wakuc/data/prev/ichisanxend26.csv");
        if ((fp_roudritu = fopen(filename, "r")) == NULL) {
            fprintf(stderr, "上限年齢ファイルを開けません!\n");
            exit (2);
        }

            karayomi( fp_roudritu );

          for ( ii=2000; ii<=2050; ii++) {
              read_csv( buffer, fp_roudritu, &data_number );
              nendo = (int)buffer[0];
              xend[8][nendo-STARTY] = (int)buffer[1] ;
          }

          fclose( fp_roudritu );

          for ( nendo=STARTY; nendo<=1999; nendo++ ) {
              xend[8][nendo-STARTY] = xend[8][2000-STARTY] ;
          }

          for ( nendo=2051; nendo<=KE+1; nendo++ ) {
              xend[8][nendo-STARTY] = xend[8][nendo-1-STARTY] ;
          }
    }
    else { 
        for ( nendo=KS; nendo<=KE+1; nendo++ ) {
            xend[8][nendo-STARTY] = 60 ; 
        }
    }



}



void read_roud( FILE *fp, int ynendo1, int ynendo2 ) {

    int  ii;
    int  jj;
    double  buffer[DATA_MAX] ;
    int     data_number      ;

        karayomi( fp );

    for ( jj=1; jj<=4; jj++ ) {
        karayomi( fp );
        karayomi( fp );
        for ( ii=ynendo1; ii<=ynendo2; ii++ ) {
            read_csv( buffer, fp, &data_number );
            nendo = (int)buffer[0] ;
            sei = (int)buffer[1] ;
            for ( nenrei=15; nenrei<=100; nenrei++ ) {
                TEMP[nendo-STARTY][sei][nenrei] = buffer[nenrei-12] / 100.0 ;
            }
        }
    }


}



void read_map(FILE *fp, int nendo) {

    int  ii;
    double  buffer[DATA_MAX] ;
    int     data_number      ;

    for (ii=1; ii<=3; ii++) {
        karayomi( fp );
    }

    for (ii=15; ii<=89; ii++) {
        read_csv( buffer, fp, &data_number );
        nenrei = (int)buffer[0];
        qkou12syu[nendo-STARTY][1][nenrei] = buffer[1];    
        kou3syu[nendo-STARTY][1][nenrei] = buffer[2];      
        kyosai[1][nendo-STARTY][1][nenrei] = buffer[3];    
        kyosai[4][nendo-STARTY][1][nenrei] = buffer[4];    
        kyosai[6][nendo-STARTY][1][nenrei] = buffer[5];    
        kyosai[5][nendo-STARTY][1][nenrei] = buffer[6];    
        kyosai[2][nendo-STARTY][1][nenrei] = buffer[7];    
        kyosai[3][nendo-STARTY][1][nenrei] = buffer[8];    
        kyosai[7][nendo-STARTY][1][nenrei] = buffer[9];    
        qkou12syu3[nendo-STARTY][1][nenrei] = buffer[11];  
        kou3syu3[nendo-STARTY][1][nenrei] = buffer[12];    
        kyosai3[1][nendo-STARTY][1][nenrei] = buffer[13];  
        kyosai3[4][nendo-STARTY][1][nenrei] = buffer[14];  
        kyosai3[6][nendo-STARTY][1][nenrei] = buffer[15];  
        kyosai3[5][nendo-STARTY][1][nenrei] = buffer[16];  
        kyosai3[2][nendo-STARTY][1][nenrei] = buffer[17];  
        kyosai3[3][nendo-STARTY][1][nenrei] = buffer[18];  
        kyosai3[7][nendo-STARTY][1][nenrei] = buffer[19];  
        ichigouip[nendo-STARTY][1][nenrei] = buffer[20];   
        ichigouni[nendo-STARTY][1][nenrei] = buffer[21];   
        kikin[nendo-STARTY][1][nenrei] = buffer[22];       
    }

    for (ii=1; ii<=2; ii++) {
        karayomi( fp );
    }

    for (ii=15; ii<=89; ii++) {
        read_csv( buffer, fp, &data_number );
        nenrei = (int)buffer[0];
        qkou12syu[nendo-STARTY][2][nenrei] = buffer[1];    
        kou3syu[nendo-STARTY][2][nenrei] = buffer[2];      
        kyosai[1][nendo-STARTY][2][nenrei] = buffer[3];    
        kyosai[4][nendo-STARTY][2][nenrei] = buffer[4];    
        kyosai[6][nendo-STARTY][2][nenrei] = buffer[5];    
        kyosai[5][nendo-STARTY][2][nenrei] = buffer[6];    
        kyosai[2][nendo-STARTY][2][nenrei] = buffer[7];    
        kyosai[3][nendo-STARTY][2][nenrei] = buffer[8];    
        kyosai[7][nendo-STARTY][2][nenrei] = buffer[9];    
        qkou12syu3[nendo-STARTY][2][nenrei] = buffer[11];  
        kou3syu3[nendo-STARTY][2][nenrei] = buffer[12];    
        kyosai3[1][nendo-STARTY][2][nenrei] = buffer[13];  
        kyosai3[4][nendo-STARTY][2][nenrei] = buffer[14];  
        kyosai3[6][nendo-STARTY][2][nenrei] = buffer[15];  
        kyosai3[5][nendo-STARTY][2][nenrei] = buffer[16];  
        kyosai3[2][nendo-STARTY][2][nenrei] = buffer[17];  
        kyosai3[3][nendo-STARTY][2][nenrei] = buffer[18];  
        kyosai3[7][nendo-STARTY][2][nenrei] = buffer[19];  
        ichigouip[nendo-STARTY][2][nenrei] = buffer[20];   
        ichigouni[nendo-STARTY][2][nenrei] = buffer[21];   
        kikin[nendo-STARTY][2][nenrei] = buffer[22];       
    }

    for ( nenrei=15; nenrei<=89; nenrei++ ) {
        qkou12syu[nendo-STARTY][0][nenrei]
          = qkou12syu[nendo-STARTY][1][nenrei] + qkou12syu[nendo-STARTY][2][nenrei] ;
        kou3syu[nendo-STARTY][0][nenrei]
          = kou3syu[nendo-STARTY][1][nenrei] + kou3syu[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++ ) {
          kyosai[seido][nendo-STARTY][0][nenrei]
            = kyosai[seido][nendo-STARTY][1][nenrei] + kyosai[seido][nendo-STARTY][2][nenrei] ;
          kyosai3[seido][nendo-STARTY][0][nenrei]
            = kyosai3[seido][nendo-STARTY][1][nenrei] + kyosai3[seido][nendo-STARTY][2][nenrei] ;
        }
        ichigouip[nendo-STARTY][0][nenrei]
          = ichigouip[nendo-STARTY][1][nenrei] + ichigouip[nendo-STARTY][2][nenrei] ;
        ichigouni[nendo-STARTY][0][nenrei]
          = ichigouni[nendo-STARTY][1][nenrei] + ichigouni[nendo-STARTY][2][nenrei] ;
        kikin[nendo-STARTY][0][nenrei]
          = kikin[nendo-STARTY][1][nenrei] + kikin[nendo-STARTY][2][nenrei] ;
    }

}

