      subroutine read1 (ngfine,ngcoar,outfor)
c
c     *****************************************************************
c
c     this program reads control parameters and initilizes i/o
c
c     output:
c        ngfine   i   number of groups in inital group structure.
c                     nonpositive value => 175
c        ngcoar   i   number of groups in final structure.
c                     Must be positive and less than ngfine
c                     If default used for ngfine, then can use default
c                        for ngcoar
c        outfor   a   output format for cross sections.  Choices are
c                        'FISPACT'
c                        'RACC'
c                        'REAC'
c                     'x' where x is zero or more blanks => 'REAC'
c
c     temporary
c        filein   a   filename (including path) for cross sections
c                       in initial group structure.
c                     filename should  be enclosed in quotes (').
c                     'x' where x is zero or more blanks => 'cross0'
c        fileot   a   filename (including path) for cross sections
c                       in final group structure. 
c                     filename should  be enclosed in quotes (').
c                     'x' where x is zero or more blanks => 'cross1'
c
c     *****************************************************************
c
      character*8  outfor
      character*64 filein,fileot
      integer      ngfine, ngcoar
c
      include 'limit.h'
      include 'unit.h'
      integer      nerr
      character*8  fispac,racc,reac,hblank
      include 'default.h'
      data         fispac /'FISPACT'/, racc /'RACC'/, reac /'REAC'/
      data         hblank /' '/
c
c     read control parameters
      read (5,*,end=90) ngfine,ngcoar,outfor,filein,fileot
c
c     test values for defaults
      if (ngfine .lt. 1) then
         write (6,601) dng, ngfine
         ngfine = dng
         if (ngcoar .lt. 1) then
            write (6,602) dng, ngcoar
            ngcoar = dng
         endif
      endif
      if (outfor .eq. hblank) then
         write (6,603) dout
         outfor = dout
      endif
      if (filein .eq. hblank) then
         write (6,604) dfin
         filein = dfin
      endif
      if (fileot .eq. hblank) then
         write (6,605) dfot
         fileot = dfot
      endif
c
c     write control parameters
      write (6,600)     ngfine,ngcoar,outfor,filein,fileot
c
c     test values for errors
      nerr = 0
      if (ngfine .gt. ngmax) then
         write (6,611) ngfine, ngmax
         nerr = nerr+1
      endif
      if (ngcoar .lt. 0) then
         write (6,612) ngcoar
         nerr = nerr+1
      endif
      if (ngcoar .gt. ngmax) then
         write (6,613) ngcoar,ngmax
         nerr = nerr+1
      endif
      if (ngcoar .gt. ngfine) then
         write (6,614) ngfine,ngcoar
         nerr = nerr+1
      endif
      if ((outfor .ne. fispac) .and. (outfor .ne. racc) .and.
     1    (outfor .ne. reac)) then
         write (6,615) outfor, fispac,racc,reac
         nerr = nerr+1
      endif
      if (nerr .gt. 0) then
         write (6,616) nerr
         stop 11
      endif
c
c     open files
      iuin = 10
      iuot = 11
      iutemp = 12
      open (unit=iuin,file=filein,status='old',err=91)
      open (unit=iuot,file=fileot,err=92)
      open (unit=iutemp,file='temp.colact',status='temporary')
c
c     return
      return
c
c     errors when opening files
90    write (6,617)
91    write (6,618) filein
      stop 12
92    write (6,619) fileot
      stop 12
c
c     formats
600   format (// ' Input values:' /
     1        '    number of fine   groups  ',5x,i5 /
     2        '    number of coarse groups  ',5x,i5 /
     3        '    output format            ',5x,a8 /
     4        '    filename for fine group  ',5x,a  /
     5        '    filename for coarse group',5x,a  )
601   format (' Default value =',i4,
     1       ' used for ngfine, inputted value = ',i5)
602   format (' Default value =',i4,
     1       ' used for ngcoar, inputted value = ',i5)
603   format (' Default value = ',a,
     1        ' used for outfor as inputted value was blank')
604   format (' Default value = ',a / 5x,
     1        ' used for filein as inputted value was blank')
605   format (' Default value = ',a / 5x,
     1        ' used for fileot as inputted value was blank')
611   format (' PROGRAM ERROR  ngfine = ',i5,
     1        ' must be less than ',i5 /
     2        '      change ngmax in limit.h and recompile')
612   format (' USER INPUT ERROR  ngcoar =',i5,' must be >0')
613   format (' PROGRAM ERROR  ngcoar = ',i5,
     1        ' must be less than ',i5 /
     2        '      change ngmax in limit.h and recompile')
614   format (' USER INPUT ERROR  ngcoar =',i5,
     1        ' must be less than ngfine =',i5)
615   format (' USER INPUT ERROR  value of outfor is invalid, =',a,
     1        ' valid values are: ' /,10x,3(a,2x))
616   format (' ABNORMAL STOP  ',i2,' errors found on input')
617   format (' USER INPUT ERROR  no data on standard input file')
618   format (' FILE ERROR  could not open input file =  ',a)
619   format (' FILE ERROR  could not open output file = ',a)
      end
