C
C*************************** OPENIO ************************************
C
C  Open the input and output files.
C
C***********************************************************************
C
      SUBROUTINE OPENIO
C
      IMPLICIT NONE
      CHARACTER*1  CHAR
      CHARACTER*150 DIR
      CHARACTER*150 FNI1, FNI2, FNI3
      CHARACTER*150 FNI10,FNI11,FNI12,FNI13,FNI14
      CHARACTER*150 FNI20,FNI21,FNI22,FNI23
      CHARACTER*150 FNI30,FNI31,FNI32
      CHARACTER*150 FNP1, FNP2, FNP3, FNP4
      CHARACTER*150 FNP5, FNP6, FNP7, FNP8
      CHARACTER*150 FNP9, FNP10,FNP11,FNP12
      CHARACTER*150 FNP13,FNP14,FNP15,FNP16
      CHARACTER*150 FNP17,FNP18,FNP19
      CHARACTER*150 FND1, FND2, FND3, FND4
      CHARACTER*150 FND10,FND11,FND12
      CHARACTER*150 FNTERM
      CHARACTER*150 FNO1, FNO2, FNO3, FNO4, FNO5, FNO6
      CHARACTER*150 FNO7, FNO8, FNO9, FNO10,FNO11,FNO12
      CHARACTER*150 FNO13,FNO14,FNO15,FNO16,FNO17,FNO18
      CHARACTER*150 FNO19,FNO20
      CHARACTER*150 FNO30,FNO31,FNO32,FNO33
      CHARACTER*150 FNO36
      CHARACTER*150 FNO40,FNO41,FNO42,FNO43,FNO44
      CHARACTER*150 FNO50,FNO51
      CHARACTER*150 FNO57
      CHARACTER*150 FNO70,FNO71
      CHARACTER*150 FNO80,FNO81
      CHARACTER*150 FNOPT
      INTEGER      I,NCHAR
      INCLUDE     'IOUNITS.H'
C
      OPEN(IFN,FILE='cathy.fnames',STATUS='UNKNOWN')
      READ(IFN,*) DIR
      CHAR = '.'
      I = 1
      DO WHILE (CHAR.NE.' ')
         CHAR = DIR(I:I)
         NCHAR = I
         I = I + 1
      END DO
      NCHAR = NCHAR - 1
      READ(IFN,*) FNI1
      READ(IFN,*) FNI2
      READ(IFN,*) FNI3
      READ(IFN,*) FNI10
      READ(IFN,*) FNI11
      READ(IFN,*) FNI12
      READ(IFN,*) FNI13
      READ(IFN,*) FNI14
      READ(IFN,*) FNI20
      READ(IFN,*) FNI21
      READ(IFN,*) FNI22
      READ(IFN,*) FNI23
      READ(IFN,*) FNI30
      READ(IFN,*) FNI31
      READ(IFN,*) FNI32
      READ(IFN,*) FNP1
      READ(IFN,*) FNP2
      READ(IFN,*) FNP3
      READ(IFN,*) FNP4
      READ(IFN,*) FNP5
      READ(IFN,*) FNP6
      READ(IFN,*) FNP7
      READ(IFN,*) FNP8
      READ(IFN,*) FNP9
      READ(IFN,*) FNP10
      READ(IFN,*) FNP11
      READ(IFN,*) FNP12
      READ(IFN,*) FNP13
      READ(IFN,*) FNP14
      READ(IFN,*) FNP15
      READ(IFN,*) FNP16
      READ(IFN,*) FNP17
      READ(IFN,*) FNP18
      READ(IFN,*) FNP19
      READ(IFN,*) FND1
      READ(IFN,*) FND2
      READ(IFN,*) FND3
      READ(IFN,*) FND4
      READ(IFN,*) FND10
      READ(IFN,*) FND11
      READ(IFN,*) FND12
      READ(IFN,*) FNO1
      READ(IFN,*) FNO2
      READ(IFN,*) FNO3
      READ(IFN,*) FNO4
      READ(IFN,*) FNO5
      READ(IFN,*) FNO6
      READ(IFN,*) FNO7
      READ(IFN,*) FNO8
      READ(IFN,*) FNO9
      READ(IFN,*) FNO10
      READ(IFN,*) FNO11
      READ(IFN,*) FNO12
      READ(IFN,*) FNO13
      READ(IFN,*) FNO14
      READ(IFN,*) FNO15
      READ(IFN,*) FNO16
      READ(IFN,*) FNO17
      READ(IFN,*) FNO18
      READ(IFN,*) FNO19
      READ(IFN,*) FNO20
      READ(IFN,*) FNO30
      READ(IFN,*) FNO31
      READ(IFN,*) FNO32
      READ(IFN,*) FNO33
      READ(IFN,*) FNO36
      READ(IFN,*) FNO40
      READ(IFN,*) FNO41
      READ(IFN,*) FNO42
      READ(IFN,*) FNO43
      READ(IFN,*) FNO44
      READ(IFN,*) FNO50
      READ(IFN,*) FNO51
      READ(IFN,*) FNO57
      READ(IFN,*) FNO70
      READ(IFN,*) FNO71
      READ(IFN,*) FNO80
      READ(IFN,*) FNO81
      READ(IFN,*) FNOPT
C
      FNI1=DIR(1:NCHAR)//'/'//FNI1
      FNI2=DIR(1:NCHAR)//'/'//FNI2
      FNI3=DIR(1:NCHAR)//'/'//FNI3
      FNI10=DIR(1:NCHAR)//'/'//FNI10
      FNI11=DIR(1:NCHAR)//'/'//FNI11
      FNI12=DIR(1:NCHAR)//'/'//FNI12
      FNI13=DIR(1:NCHAR)//'/'//FNI13
      FNI14=DIR(1:NCHAR)//'/'//FNI14
      FNI20=DIR(1:NCHAR)//'/'//FNI20
      FNI21=DIR(1:NCHAR)//'/'//FNI21
      FNI22=DIR(1:NCHAR)//'/'//FNI22
      FNI23=DIR(1:NCHAR)//'/'//FNI23
      FNI30=DIR(1:NCHAR)//'/'//FNI30
      FNI31=DIR(1:NCHAR)//'/'//FNI31
      FNI32=DIR(1:NCHAR)//'/'//FNI32
      FNP1=DIR(1:NCHAR)//'/'//FNP1
      FNP2=DIR(1:NCHAR)//'/'//FNP2
      FNP3=DIR(1:NCHAR)//'/'//FNP3
      FNP4=DIR(1:NCHAR)//'/'//FNP4
      FNP5=DIR(1:NCHAR)//'/'//FNP5
      FNP6=DIR(1:NCHAR)//'/'//FNP6
      FNP7=DIR(1:NCHAR)//'/'//FNP7
      FNP8=DIR(1:NCHAR)//'/'//FNP8
      FNP9=DIR(1:NCHAR)//'/'//FNP9
      FNP10=DIR(1:NCHAR)//'/'//FNP10
      FNP11=DIR(1:NCHAR)//'/'//FNP11
      FNP12=DIR(1:NCHAR)//'/'//FNP12
      FNP13=DIR(1:NCHAR)//'/'//FNP13
      FNP14=DIR(1:NCHAR)//'/'//FNP14
      FNP15=DIR(1:NCHAR)//'/'//FNP15
      FNP16=DIR(1:NCHAR)//'/'//FNP16
      FNP17=DIR(1:NCHAR)//'/'//FNP17
      FNP18=DIR(1:NCHAR)//'/'//FNP18
      FNP19=DIR(1:NCHAR)//'/'//FNP19
      FND1=DIR(1:NCHAR)//'/'//FND1
      FND2=DIR(1:NCHAR)//'/'//FND2
      FND3=DIR(1:NCHAR)//'/'//FND3
      FND4=DIR(1:NCHAR)//'/'//FND4
      FND10=DIR(1:NCHAR)//'/'//FND10
      FND11=DIR(1:NCHAR)//'/'//FND11
      FND12=DIR(1:NCHAR)//'/'//FND12
      IF(FNO1 .NE. '/dev/null') FNO1=DIR(1:NCHAR)//'/'//FNO1
      IF(FNO2 .NE. '/dev/null') FNO2=DIR(1:NCHAR)//'/'//FNO2
      IF(FNO3 .NE. '/dev/null') FNO3=DIR(1:NCHAR)//'/'//FNO3
      IF(FNO4 .NE. '/dev/null') FNO4=DIR(1:NCHAR)//'/'//FNO4
      IF(FNO5 .NE. '/dev/null') FNO5=DIR(1:NCHAR)//'/'//FNO5
      IF(FNO6 .NE. '/dev/null') FNO6=DIR(1:NCHAR)//'/'//FNO6
      IF(FNO7 .NE. '/dev/null') FNO7=DIR(1:NCHAR)//'/'//FNO7
      IF(FNO8 .NE. '/dev/null') FNO8=DIR(1:NCHAR)//'/'//FNO8
      IF(FNO9 .NE. '/dev/null') FNO9=DIR(1:NCHAR)//'/'//FNO9
      IF(FNO10.NE. '/dev/null') FNO10=DIR(1:NCHAR)//'/'//FNO10
      IF(FNO11.NE. '/dev/null') FNO11=DIR(1:NCHAR)//'/'//FNO11
      IF(FNO12.NE. '/dev/null') FNO12=DIR(1:NCHAR)//'/'//FNO12
      IF(FNO13.NE. '/dev/null') FNO13=DIR(1:NCHAR)//'/'//FNO13
      IF(FNO14.NE. '/dev/null') FNO14=DIR(1:NCHAR)//'/'//FNO14
      IF(FNO15.NE. '/dev/null') FNO15=DIR(1:NCHAR)//'/'//FNO15
      IF(FNO16.NE. '/dev/null') FNO16=DIR(1:NCHAR)//'/'//FNO16
      IF(FNO17.NE. '/dev/null') FNO17=DIR(1:NCHAR)//'/'//FNO17
      IF(FNO18.NE. '/dev/null') FNO18=DIR(1:NCHAR)//'/'//FNO18
      IF(FNO19.NE. '/dev/null') FNO19=DIR(1:NCHAR)//'/'//FNO19
      IF(FNO20.NE. '/dev/null') FNO20=DIR(1:NCHAR)//'/'//FNO20
      IF(FNO30.NE. '/dev/null') FNO30=DIR(1:NCHAR)//'/'//FNO30
      IF(FNO31.NE. '/dev/null') FNO31=DIR(1:NCHAR)//'/'//FNO31
      IF(FNO32.NE. '/dev/null') FNO32=DIR(1:NCHAR)//'/'//FNO32
      IF(FNO33.NE. '/dev/null') FNO33=DIR(1:NCHAR)//'/'//FNO33
      IF(FNO36.NE. '/dev/null') FNO36=DIR(1:NCHAR)//'/'//FNO36
      IF(FNO40.NE. '/dev/null') FNO40=DIR(1:NCHAR)//'/'//FNO40
      IF(FNO41.NE. '/dev/null') FNO41=DIR(1:NCHAR)//'/'//FNO41
      IF(FNO42.NE. '/dev/null') FNO42=DIR(1:NCHAR)//'/'//FNO42
      IF(FNO43.NE. '/dev/null') FNO43=DIR(1:NCHAR)//'/'//FNO43
      IF(FNO44.NE. '/dev/null') FNO44=DIR(1:NCHAR)//'/'//FNO44
      IF(FNO50.NE. '/dev/null') FNO50=DIR(1:NCHAR)//'/'//FNO50
      IF(FNO51.NE. '/dev/null') FNO51=DIR(1:NCHAR)//'/'//FNO51
      IF(FNO57.NE. '/dev/null') FNO57=DIR(1:NCHAR)//'/'//FNO57
      IF(FNO70.NE. '/dev/null') FNO70=DIR(1:NCHAR)//'/'//FNO70
      IF(FNO71.NE. '/dev/null') FNO71=DIR(1:NCHAR)//'/'//FNO71
      IF(FNO80.NE. '/dev/null') FNO80=DIR(1:NCHAR)//'/'//FNO80
      IF(FNO81.NE. '/dev/null') FNO81=DIR(1:NCHAR)//'/'//FNO81
      IF(FNOPT.NE. '/dev/null') FNOPT=DIR(1:NCHAR)//'/'//FNOPT
C
      OPEN(IIN1,  FILE=FNI1,STATUS='OLD')
      OPEN(IIN2,  FILE=FNI2,STATUS='OLD')
      OPEN(IIN3,  FILE=FNI3,STATUS='OLD')
      OPEN(IIN10,FILE=FNI10,STATUS='OLD')
      OPEN(IIN11,FILE=FNI11,STATUS='OLD')
      OPEN(IIN12,FILE=FNI12,STATUS='OLD')
      OPEN(IIN13,FILE=FNI13,STATUS='OLD')
      OPEN(IIN14,FILE=FNI14,STATUS='OLD')
      OPEN(IIN20,FILE=FNI20,STATUS='OLD')
      OPEN(IIN21,FILE=FNI21,STATUS='OLD')
      OPEN(IIN22,FILE=FNI22,STATUS='OLD')
      OPEN(IIN23,FILE=FNI23,STATUS='OLD')
      OPEN(IIN30,FILE=FNI30,STATUS='OLD')
      OPEN(IIN31,FILE=FNI31,STATUS='OLD')
      OPEN(IIN32,FILE=FNI32,STATUS='OLD')
      OPEN(IINPREPRO1,  FILE=FNP1,STATUS='OLD')
      OPEN(IINPREPRO2,  FILE=FNP2,STATUS='OLD')
      OPEN(IINPREPRO3,  FILE=FNP3,STATUS='OLD')
      OPEN(IINPREPRO4,  FILE=FNP4,STATUS='OLD')
      OPEN(IINPREPRO5,  FILE=FNP5,STATUS='OLD')
      OPEN(IINPREPRO6,  FILE=FNP6,STATUS='OLD')
      OPEN(IINPREPRO7,  FILE=FNP7,STATUS='OLD')
      OPEN(IINPREPRO8,  FILE=FNP8,STATUS='OLD')
      OPEN(IINPREPRO9,  FILE=FNP9,STATUS='OLD')
      OPEN(IINPREPRO10,FILE=FNP10,STATUS='OLD')
      OPEN(IINPREPRO11,FILE=FNP11,STATUS='OLD')
      OPEN(IINPREPRO12,FILE=FNP12,STATUS='OLD')
      OPEN(IINPREPRO13,FILE=FNP13,STATUS='OLD')
      OPEN(IINPREPRO14,FILE=FNP14,STATUS='OLD')
      OPEN(IINPREPRO15,FILE=FNP15,STATUS='OLD')
      OPEN(IINPREPRO16,FILE=FNP16,STATUS='OLD')
      OPEN(IINPREPRO17,FILE=FNP17,STATUS='OLD')
      OPEN(IINPREPRO18,FILE=FNP18,STATUS='OLD')
      OPEN(IINPREPRO19,FILE=FNP19,STATUS='OLD')
      OPEN(IINDEM1,  FILE=FND1,STATUS='OLD')
      OPEN(IINDEM2,  FILE=FND2,STATUS='OLD')
      OPEN(IINDEM3,  FILE=FND3,STATUS='OLD')
      OPEN(IINDEM4,  FILE=FND4,STATUS='OLD')
      OPEN(IINDEM10,FILE=FND10,STATUS='OLD')
      OPEN(IINDEM11,FILE=FND11,STATUS='OLD')
      OPEN(IINDEM12,FILE=FND12,STATUS='OLD')
      OPEN(IOUT1,  FILE=FNO1,STATUS='UNKNOWN')
      OPEN(IOUT2,  FILE=FNO2,STATUS='UNKNOWN')
      OPEN(IOUT3,  FILE=FNO3,STATUS='UNKNOWN')
      OPEN(IOUT4,  FILE=FNO4,STATUS='UNKNOWN')
      OPEN(IOUT5,  FILE=FNO5,STATUS='UNKNOWN')
      OPEN(IOUT6,  FILE=FNO6,STATUS='UNKNOWN')
      OPEN(IOUT7,  FILE=FNO7,STATUS='UNKNOWN')
      OPEN(IOUT8,  FILE=FNO8,STATUS='UNKNOWN')
      OPEN(IOUT9,  FILE=FNO9,STATUS='UNKNOWN')
      OPEN(IOUT10,FILE=FNO10,STATUS='UNKNOWN')
      OPEN(IOUT11,FILE=FNO11,STATUS='UNKNOWN')
      OPEN(IOUT12,FILE=FNO12,STATUS='UNKNOWN')
      OPEN(IOUT13,FILE=FNO13,STATUS='UNKNOWN')
      OPEN(IOUT14,FILE=FNO14,STATUS='UNKNOWN')
      OPEN(IOUT15,FILE=FNO15,STATUS='UNKNOWN')
      OPEN(IOUT16,FILE=FNO16,STATUS='UNKNOWN')
      OPEN(IOUT17,FILE=FNO17,STATUS='UNKNOWN')
      OPEN(IOUT18,FILE=FNO18,STATUS='UNKNOWN')
      OPEN(IOUT19,FILE=FNO19,STATUS='UNKNOWN')
      OPEN(IOUT20,FILE=FNO20,STATUS='UNKNOWN')
      OPEN(IOUT30,FILE=FNO30,STATUS='UNKNOWN')
      OPEN(IOUT31,FILE=FNO31,STATUS='UNKNOWN')
      OPEN(IOUT32,FILE=FNO32,STATUS='UNKNOWN')
      OPEN(IOUT33,FILE=FNO33,STATUS='UNKNOWN')
      OPEN(IOUT36,FILE=FNO36,STATUS='UNKNOWN')
      OPEN(IOUT40,FILE=FNO40,STATUS='UNKNOWN')
      OPEN(IOUT41,FILE=FNO41,STATUS='UNKNOWN')
      OPEN(IOUT42,FILE=FNO42,STATUS='UNKNOWN')
      OPEN(IOUT43,FILE=FNO43,STATUS='UNKNOWN')
      OPEN(IOUT44,FILE=FNO44,STATUS='UNKNOWN')
      OPEN(IOUT50,FILE=FNO50,STATUS='UNKNOWN')
      OPEN(IOUT51,FILE=FNO51,STATUS='UNKNOWN')
      OPEN(IOUT57,FILE=FNO57,STATUS='UNKNOWN')
      OPEN(IOUT70,FILE=FNO70,STATUS='UNKNOWN')
      OPEN(IOUT71,FILE=FNO71,STATUS='UNKNOWN')
      OPEN(IOUT80,FILE=FNO80,STATUS='UNKNOWN')
      OPEN(IOUT81,FILE=FNO81,STATUS='UNKNOWN')
      OPEN(IOUTPT,FILE=FNOPT,STATUS='UNKNOWN')
C
C  if ITERM=6 (in block_data.f), terminal output is assumed;
C  otherwise unit ITERM output is to the file named at the last
C  line of "cathy.fnames"
C
      IF (ITERM .NE. 6) THEN
         READ(IFN,*) FNTERM
         OPEN(ITERM,FILE=FNTERM,STATUS='UNKNOWN')
      END IF
C
      RETURN
      END
