cdeck homer0
      subroutine homer0 (com,nfld)
      real com(nfld)
      integer nfld
      include 'maincomo.for'
      include 'homerc.for'
c
c   options
c
c      1   -   ignore missing values
c      2   -   do grid cell home range estimates
c              (default is to not do grid cell estimates)
c      3   -   no polygon minimum area estimate
c      4   -   do not perform jennrich-turner estimate
c      5   -   make two passes through data file to get origins
c              and grid cell size for grid cell estimator
c      6   -   perform dunn home range estimate
c      7   -   print lotus files for grid cell map
c      8   -   print lotus files for polygon
c      9   -   print lotus files for 95% jt all fixes
c     10   -   print lotus files for 95% jt unique fixes
c     11   -   print lotus files for 95% dunn ellipse
c     12   -   perform time series randomization test
c     13   -   print lotus files for all data
c
c   close ioscr2
c
      if (.not.qsw(7)) then
         call rwind2
         qsw(7)=.true.
      endif
      qfirst=.true.
c
c   process argument list
c
      if (nfld.gt.1000) go to 10
      call error ('insufficient space to process cases')
      go to 30
 10   nfld2=nfld/2
      call homer1 (com,nfld2)
      if (qfatal) go to 30
      write (iolp,40) nfld
      call linect (2)
      if (qoptsr(5)) qoptsr(2)=.true.
      if (qoptsr(2)) then
c         set up dynamic storage based  on maximum number of intervals
         nintmax=0
         do 20 i=1,ndic
   20       nintmax=max(nintmax,nint(i))
         if (nintmax.le.1) nintmax=100
         ia=nintmax+1
         ib=ia+nintmax
         ic=ib+nintmax*nintmax
         maxcase=(nfld-ic)/3-1
         write (iolp,50) maxcase
         call linect (2)
         if (qopt(7)) go to 30
c        if option 5, process the first pass of the data
         if (qoptsr(5)) then
            call homr3c (com,nfld)
            qfirst=.true.
            string=' '
            rewind(unit=iocr)
         endif
         call homr3a (com(1),com(ia),com(ib),maxcase,com(ic),nintmax,com
     1   )
      else
         maxcase=nfld/3
         write (unit=iolp,fmt=50) maxcase
         call linect (2)
         call homr3b (com,maxcase,com)
      endif
   30 return
c
   40 format (/' homer entered with field length of ',i5,' words.')
   50 format (/' homer has storage to process ',i5,' cases.')
      end
