      SUBROUTINE GETREC (REC, IUNIT, ISTAT)
C--GETREC READS A BUFFER OF ASCII RECORDS, THE RETURNS THEM ONE AT A TIME

      SAVE NSIZE	! NUMBER OF RECORDS IN BUFFER (PRESENTLY 500 MAX)
      CHARACTER*(*) REC	! RECORD TO BE "READ"
      INTEGER IUNIT	! INPUT UNIT NUMBER
      INTEGER ISTAT	! 0 FOR NORMAL RETURN OF A RECORD
C                         1 END OF FILE REACHED, NO MORE RECORDS
      SAVE NREC
      DATA NREC /0/	! CURRENT POSITION OF LAST RECORD RETURNED IN BUFFER
      CHARACTER*138 BUF(500) ! CHARACTER BUFFER

C--READ IN A NEW BUFFER IF ITS EMPTY
      IF (NREC.EQ.0 .OR. NREC.EQ.NSIZE) THEN
        NREC=0
        READ (IUNIT, END=9) NSIZE, (BUF(I),I=1,NSIZE)
      END IF

      ISTAT=0
C--GRAB THE NEXT RECORD FROM THE BUFFER
      NREC = NREC +1
      REC = BUF(NREC)
      RETURN

C--END OF FILE
9     ISTAT=1
      RETURN
      END
