C
C     **************************************************
C     **                                              **
C     **        フ  ァ  イ  ル  Ｏ  Ｐ  Ｅ  Ｎ        **
C     **                                              **
C     **************************************************
C
C
      SUBROUTINE      FOPN
C
      IMPLICIT INTEGER(A-Z)
      INCLUDE 'seps.inc'
C
      CHARACTER CNAME*4, CWNAME*4, CECON*4
      CHARACTER CYR*2
      CHARACTER CSEID*3
      CHARACTER OFLNAME*100
      CHARACTER CVER*2
C
C-----------------------------------------------------------
C     試算番号の設定
C-----------------------------------------------------------
C
      WRITE(CVER, '(I2.2)') KVER
      WRITE(CNAME ,1000) INAME
      WRITE(CWNAME,1000) IWNAME
      WRITE(CECON ,1000) IECON
C
      WRITE(CYR, '(I2.2)') KIJUN+12
C
 1000 FORMAT(I4.4)
C
      IF(PSEID.EQ.0) CSEID='kou'
      IF(PSEID.EQ.1) CSEID='kok'
      IF(PSEID.EQ.2) CSEID='jnr'
      IF(PSEID.EQ.3) CSEID='tob'
      IF(PSEID.EQ.4) CSEID='ren'
      IF(PSEID.EQ.5) CSEID='sig'
      IF(PSEID.EQ.6) CSEID='nou'
      IF(PSEID.EQ.7) CSEID='oku'
C
      IF(PSEID.EQ.7) GO TO 2100
C
C-----------------------------------------------------------
C     基礎率ファイル
C-----------------------------------------------------------
C  ---------------------------------------------------------
C     基礎率ファイル(全体) 
C  ---------------------------------------------------------
C
      KISORFILE(PSEID)
     &    ='/rev31/emp/data/u-rev/kisor/kisor_'//CSEID//
     &                                          '31-'//CVER//'.csv'
      OPEN(10,FILE=KISORFILE(PSEID),STATUS='OLD')
C
C  ---------------------------------------------------------
C     報酬用基礎率ファイル
C  ---------------------------------------------------------
C
      HOUFILE
     &  ='/rev31/emp/data/u-rev/kisor/hou_'//CSEID//'31-'//CVER//'.csv'
C
      OPEN(11,FILE=HOUFILE,STATUS='OLD')
C
C  ---------------------------------------------------------
C     支給率
C  ---------------------------------------------------------
C
      SIKFILE
     & ='/rev31/emp/data/u-rev/kisor/sikur_'//CSEID//'31-'//CVER//'.csv'
C
      OPEN(12,FILE=SIKFILE,STATUS='OLD')
C
C  ---------------------------------------------------------
C     有遺族率ファイル
C  ---------------------------------------------------------
C
      YUIZOFILE='/rev31/emp/data/u-rev/kisor/yuizor_'//CSEID//
     &                                          '31-'//CVER//'.csv'
      OPEN(14,FILE=YUIZOFILE,STATUS='OLD')
C
C  ---------------------------------------------------------
C     死亡率ファイル
C  ---------------------------------------------------------
C
      IF(SEIMEI.EQ.1) THEN
        QXFILE='/rev31/emp/data/u-sinj/QX-M29.csv'
      ELSE IF(SEIMEI.EQ.2) THEN
        QXFILE='/rev31/emp/data/u-sinj/QX-H29.csv'
      ELSE IF(SEIMEI.EQ.3) THEN
        QXFILE='/rev31/emp/data/u-sinj/QX-L29.csv'
      END IF
C
      OPEN(25,FILE=QXFILE,STATUS='OLD')
C
C--------------------------------
C     基礎数ファイル(被保険者 全体)
C--------------------------------
C
      HIHOFILE(PSEID,1)='/rev31/emp/data/u-rev/kisos/'//CSEID//
     &                                    '/hk28-1.csv'
      HIHOFILE(PSEID,2)='/rev31/emp/data/u-rev/kisos/'//CSEID//
     &                                    '/hk28-2.csv'
      IF(PSEID.EQ.0) THEN
        HIHOFILE(PSEID,3)='/rev31/emp/data/u-rev/kisos/'//CSEID//
     &                                    '/hk28-3.csv'
      END IF
      OPEN(30,FILE=HIHOFILE(PSEID,1),STATUS='OLD')
      OPEN(31,FILE=HIHOFILE(PSEID,2),STATUS='OLD')
      IF(PSEID.EQ.0) OPEN(32,FILE=HIHOFILE(PSEID,3),STATUS='OLD')
C
C--------------------------------
C     基礎数ファイル(受給者)
C--------------------------------
C
      JUKFILE(0,1) ='/rev31/emp/data/u-rev/kisos/kou/jk'
     &                                  //CYR//'-1-kas.csv'
      JUKFILE(0,2) ='/rev31/emp/data/u-rev/kisos/kou/jk'
     &                                  //CYR//'-2-kas.csv'
      JUKFILE(0,3) ='/rev31/emp/data/u-rev/kisos/kou/jk'
     &                                  //CYR//'-3-kas.csv'
      JUKFILE(1,1)='/rev31/emp/data/u-rev/kisos/kok/jk'
     &                                  //CYR//'-1-kas.csv'
      JUKFILE(1,2)='/rev31/emp/data/u-rev/kisos/kok/jk'
     &                                  //CYR//'-2-kas.csv'
      JUKFILE(4,1)='/rev31/emp/data/u-rev/kisos/ren/jk'
     &                                  //CYR//'-1-kas.csv'
      JUKFILE(4,2)='/rev31/emp/data/u-rev/kisos/ren/jk'
     &                                  //CYR//'-2-kas.csv'
      JUKFILE(5,1)='/rev31/emp/data/u-rev/kisos/sig/jk'
     &                                  //CYR//'-1-kas.csv'
      JUKFILE(5,2)='/rev31/emp/data/u-rev/kisos/sig/jk'
     &                                  //CYR//'-2-kas.csv'
C
      OPEN(35,FILE=JUKFILE(PSEID,1),STATUS='OLD')
      OPEN(36,FILE=JUKFILE(PSEID,2),STATUS='OLD')
      IF(PSEID.EQ.0) OPEN(37,FILE=JUKFILE(PSEID,3),STATUS='OLD')
C
C--------------------------------
C     外枠ファイル
C--------------------------------
C
      WAKUFILE(0)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-01.csv'
      WAKUFILE(8)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-02.csv'
      WAKUFILE(10)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-30.csv'
      WAKUFILE(11)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-31.csv'
      WAKUFILE(12)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-32.csv'
      WAKUFILE(13)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-36.csv'
      WAKUFILE(14)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-49.csv'
      WAKUFILE(15)='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-50.csv'
      WAKUFILE(1) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-03.csv'
      WAKUFILE(2) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-06.csv'
      WAKUFILE(3) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-07.csv'
      WAKUFILE(4) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-04.csv'
      WAKUFILE(5) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-05.csv'
      WAKUFILE(6) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-08.csv'
      OPEN(70,FILE=WAKUFILE(PSEID),STATUS='OLD')
      IF(PSEID.EQ.0) OPEN(71,FILE=WAKUFILE( 8),STATUS='OLD')
      IF(PSEID.EQ.0) OPEN(73,FILE=WAKUFILE(10),STATUS='OLD')
C
      IF(PSEID.EQ.0) THEN
        OPEN(75,FILE=WAKUFILE(11),STATUS='OLD')
        OPEN(76,FILE=WAKUFILE(12),STATUS='OLD')
        OPEN(77,FILE=WAKUFILE(13),STATUS='OLD')
        IF(FLG_PART.GE.3) THEN
          OPEN(78,FILE=WAKUFILE(14),STATUS='OLD')
          OPEN(79,FILE=WAKUFILE(15),STATUS='OLD')
        END IF
      END IF
C
      WAKUFILE(9) ='/rev31/wakuc/rslt/ver_3/rslt'
     &                           //CWNAME//'/waku'//CWNAME//'-26.csv'
      OPEN(72,FILE=WAKUFILE(9),STATUS='OLD')
C
 2100 CONTINUE
C
C-------------------------------------------
C     経済的要素ファイル
C-------------------------------------------
C
      ECONFILE='/rev31/emp/data/u-rev/econ/econ-'//CECON//'.csv'
      OPEN(20,FILE=ECONFILE,STATUS='OLD')
C
C-------------------------------------------
C     収支計算システムへの出力ファイル
C-------------------------------------------
C
        SFILE(0)='/rev31/emp/rslt/u-rev/shus/shus.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_kou'
        SFILE(1)='/rev31/emp/rslt/u-rev/shus/shus.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_kok'
        SFILE(4)='/rev31/emp/rslt/u-rev/shus/shus.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_ren'
        SFILE(5)='/rev31/emp/rslt/u-rev/shus/shus.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_sig'
        IF(SEIDN.EQ.0 .OR. SEIDN.EQ.8) THEN
          SFILE(2)='/rev31/emp/rslt/u-rev/shhi/shhi.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_jnr'
          SFILE(3)='/rev31/emp/rslt/u-rev/shhi/shhi.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_tob'
          SFILE(6)='/rev31/emp/rslt/u-rev/shhi/shhi.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_nou'
        ELSE
          SFILE(2)='/rev31/emp/rslt/u-rev/shus/shus.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_jnr'
          SFILE(3)='/rev31/emp/rslt/u-rev/shus/shus.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_tob'
          SFILE(6)='/rev31/emp/rslt/u-rev/shus/shus.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_nou'
          SFILE(7)='/rev31/emp/rslt/u-rev/shus/shus.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_oku'
        END IF
      OPEN(80,FILE=SFILE(PSEID))
C
C-------------------------------------------------
C     収支計算システムへの被保険者の出力ファイル
C-------------------------------------------------
C
      SFILE(0)='/rev31/emp/rslt/u-rev/shus/shusg.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_kou'
      SFILE(1)='/rev31/emp/rslt/u-rev/shus/shusg.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_kok'
      SFILE(4)='/rev31/emp/rslt/u-rev/shus/shusg.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_ren'
      SFILE(5)='/rev31/emp/rslt/u-rev/shus/shusg.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_sig'
      SFILE(2)='/rev31/emp/rslt/u-rev/shhi/shhig.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_jnr'
      SFILE(3)='/rev31/emp/rslt/u-rev/shhi/shhig.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_tob'
      SFILE(6)='/rev31/emp/rslt/u-rev/shhi/shhig.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_nou'
      OPEN(87,FILE=SFILE(PSEID))
C
C-------------------------------------------------
C     基礎年金給付費ファイル(基礎年金システムへ )
C-------------------------------------------------
C
      IF(PSEID.NE.7) THEN
        KFILE(0)='/rev31/emp/rslt/u-rev/kiso/kiso.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_kou'
        KFILE(1)='/rev31/emp/rslt/u-rev/kiso/kiso.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_kok'
        KFILE(4)='/rev31/emp/rslt/u-rev/kiso/kiso.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_ren'
        KFILE(5)='/rev31/emp/rslt/u-rev/kiso/kiso.'
     &        //CNAME//'-'//CECON//'-'//CWNAME//'_sig'
        IF(PSEID.EQ.0 .OR. KONEN.NE.1) THEN
          OPEN(90,FILE=KFILE(PSEID))
        END IF
      END IF
C
C-------------------------------------------------
C     改定率ファイル
C-------------------------------------------------
C
      KAITEAFILE='/rev31/emp/rslt/u-rev/kaite/kaitea-'
     &                                        //CNAME//'-'//CECON//'e'
      KAITEBFILE='/rev31/emp/rslt/u-rev/kaite/kaiteb-'
     &                                        //CNAME//'-'//CECON//'e'
C
      IF(KAITE.EQ.1 .AND.
     &   ((SEIDN.LE.6 .AND. SEIDN.NE.0) .OR.
     &   ((SEIDN.EQ.0 .OR. SEIDN.GE.7) .AND. PSEID.EQ.0))) THEN
        OPEN(22,FILE=KAITEAFILE)
        OPEN(23,FILE=KAITEBFILE)
      END IF
C
C------------------------------------------------
C     足下年報比較用ファイル
C------------------------------------------------
C
      IF(PSEID.NE.7) THEN
        HIKAKUFILE='/rev31/emp/rslt/u-rev/hikaku/hikaku.'
     &                //CNAME//'-'//CECON//'-'//CWNAME
        OPEN(92,FILE=HIKAKUFILE)
        ASHIMOTOFILE='/rev31/emp/rslt/u-rev/ashimoto/ashimoto.'
     &                //CNAME//'-'//CECON//'-'//CWNAME
        OPEN(95,FILE=ASHIMOTOFILE)
        ASHIMOTOFILES='/rev31/emp/rslt/u-rev/ashimoto/ashimotos.'
     &                //CNAME//'-'//CECON//'-'//CWNAME
        OPEN(96,FILE=ASHIMOTOFILES)
      END IF
C
C------------------------------------------------
C     基礎率出力ファイル
C------------------------------------------------
      IF((SEIDN.EQ.8 .AND. PSEID.NE.7) .OR. PSEID.EQ.SEIDN) THEN
        OFLNAME='/rev31/emp/rslt/u-rev/kisor/kisor.'
     &          //CNAME//'-'//CECON//'-'//CWNAME//'_'//CSEID//'.csv'
        OPEN(93,FILE=OFLNAME)
      END IF
C
      RETURN
C
      END
C