*...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
*    
*     sizes.f
*
*     Copyright (C) 1991.
*
*     Marie Davidian and A. Ronald Gallant 
*     P.O. Box 5513, Raleigh NC 27650-5513, USA   
*
*     Permission to use, copy, modify, and distribute this
*     software and its documentation for any purpose and
*     without fee is hereby granted, provided that the
*     above copyright notice appear in all copies and that
*     both that copyright notice and this permission notice
*     appear in supporting documentation.
*
*     This software is provided "as is" without any
*     expressed or implied warranty.
*
*...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
      subroutine sizes(isw)
      implicit real*8 (a-h,o-z)
      implicit integer*4 (i-n)
      save

      include "global.f"

      integer*4 isw

      if (isw.eq.1) then

        open(unit=8,file=infile,status='old',form='formatted')

        read(8,8000) name
        read(8,8001) ncases
        read(8,8002) npt,iq
        read(8,8001) lx
        read(8,8001) ltau
        read(8,8001) M
        read(8,8002) Kz,Iz
        read(8,8002) Kx,Ix
        read(8,8001) maxitr
        read(8,8003) ftol
        read(8,8001) iseed
        read(8,8003) sfac
        read(8,8002) ngrd,jt
        read(8,8001) iunit9
        read(8,8001) iCvec
        read(8,8001) muzero
        read(8,8001) verify

*       This routine relies on a subsequent call to values with
*       isw=1 to read the rest of the file and close unit 8.

        return
      end if


      if (isw.eq.2) then

        open(unit=9,file=outfil,status='unknown',form='formatted')

        write(9,9000) name
        write(9,9001) ncases
        write(9,9002) npt,iq
        write(9,9003) lx
        write(9,9004) ltau
        write(9,9005) M
        write(9,9006) Kz,Iz
        write(9,9007) Kx,Ix
        write(9,9008) maxitr
        write(9,9009) ftol
        write(9,9010) iseed
        write(9,9011) sfac
        write(9,9012) ngrd,jt     
        write(9,9013) iunit9
        write(9,9017) iCvec
        write(9,9018) muzero
        write(9,9016) verify

*       This routine relies on a subsequent call to values with
*       isw=2 to write the rest of the file and close unit 9.

        return
      end if


      if (isw.eq.3) then
        write(3,3000) name
        write(3,3001) ncases
        write(3,3002) npt,iq
        write(3,3003) lx
        write(3,3004) ltau
        write(3,3005) M
        write(3,3006) Kz,Iz
        write(3,3007) Kx,Ix
        write(3,3008) maxitr
        write(3,3009) ftol
        write(3,3010) iseed
        write(3,3011) sfac
        write(3,3012) ngrd,jt
        write(3,3013) iunit9
        write(3,3017) iCvec
        write(3,3018) muzero
        write(3,3016) verify
        return
      end if

3000  format(15x,'name    ',a10  )
3001  format(15x,'ncases  ',i5,5x)
3002  format(15x,'npt,iq  ',2i5  )
3003  format(15x,'lx      ',i5,5x)
3004  format(15x,'ltau    ',i5,5x)
3005  format(15x,'M       ',i5,5x)
3006  format(15x,'Kz,Iz   ',2i5  )
3007  format(15x,'Kx,Ix   ',2i5  )
3008  format(15x,'maxitr  ',i5,5x)
3009  format(15x,'ftol    ',d10.1)
3010  format(15x,'iseed   ',i5,5x)
3011  format(15x,'sfac    ',d10.1)
3012  format(15x,'ngrd,jt ',2i5  )
3013  format(15x,'iunit9  ',i5,5x)
3016  format(15x,'verify  ',i5,5x)
3017  format(15x,'iCvec   ',i5,5x)
3018  format(15x,'muzero  ',i5,5x)
8000  format(a10)   
8001  format(i5)
8002  format(2i5)
8003  format(d10.0)
9000  format(a10,  '    name    format(a10  )')
9001  format(i5,5x,'    ncases  format(i5,5x)')
9002  format(2i5,  '    npt,iq  format(2i5  )',
     &' (npt MCarlo if iq=0, npt quad if iq=1)')  
9003  format(i5,5x,'    lx      format(i5,5x)')
9004  format(i5,5x,'    ltau    format(i5,5x)')
9005  format(i5,5x,'    M       format(i5,5x)')
9006  format(2i5,  '    Kz,Iz   format(2i5  )')
9007  format(2i5,  '    Kx,Ix   format(2i5  )')
9008  format(i5,5x,'    maxitr  format(i5,5x)')
9009  format(d10.1,'    ftol    format(d10.1)')
9010  format(i5,5x,'    iseed   format(i5,5x)')
9011  format(d10.1,'    sfac    format(d10.1)')
9012  format(2i5  ,'    ngrd,jt format(2i5  )',
     &' (plot points for joint if jt=1)')
9013  format(i5,5x,'    iunit9  format(i5,5x)',
     &' (0 parmfile, 1 eff, 2 sim, 4 plt)')
9016  format(i5,5x,'    verify  format(i5,5x)',
     &' (verify derivatives if verify=1)')
9017  format(i5,5x,'    iCvec   format(i5,5x)',
     &' (compute Cvec if iCvec=1 & iq=1)')
9018  format(i5,5x,'    muzero  format(i5,5x)',
     &' (impose Ez=0 if muzero=1)')
      end
