      subroutine getgrp (nr, nob, nof)

c  collect a group of associated records from within an event
c  this could be:
c   1.   epicentre record (+ secondary epicentre record)
c   2.   epicentre comment (+ continuation comments)
c   3.   primary phase (+ later phase(s)) (+ phase comment(s))

      include 'basics.inc'

      include 'hold.inc'

c      character*4 chival

      character*2 recs2
      

      ninset = 0
      nob = moveon (nr, ninset)
      nof = nob
      
c      if (recs(nof)(1:2) .eq. ' 1') then
      
      if (recs2(nof,1,2) .eq. ' 1') then
      
c this is an epicentre group

c        if (recs(nof)(3:4) .eq. ' 2') nof = moveon(nr, ninset)
        
        if (recs2(nof,3,4) .eq. ' 2') nof = moveon(nr, ninset)        
        
c      else if (recs(nof)(1:2) .eq. ' 3') then

      else if (recs2(nof,1,2) .eq. ' 3') then
      
c this is a comment group

c        do while (recs(nof)(3:4) .eq. ' 4')
        
        do while (recs2(nof,3,4) .eq. ' 4')
        
          nof = moveon(nr, ninset)
          
        end do
        

c      else if (recs(nof)(1:2) .eq. ' 5'
c     2        .or. recs(nof)(1:2) .eq. '15') then
     
      else if (recs2(nof,1,2) .eq. ' 5'
     2        .or. recs2(nof,1,2) .eq. '15') then

c this is a phase group

c        do while (recs(nof)(3:4) .eq. ' 6'
c     2          .or. recs(nof)(3:4) .eq. ' 7')
     
        do while (recs2(nof,3,4) .eq. ' 6'
     2          .or. recs2(nof,3,4) .eq. ' 7')
          
          nof = moveon(nr, ninset)
          
        end do

      else
      
c        call abort ('Getgrp: Unexpected record type '//recs(nof)(1:2))
        
        call abort ('Getgrp: Unexpected record type '//recs2(nof,1,2))
        
      end if
      
      return
      end
