      SUBROUTINE CPYFIL (INFILE,OUFILE,AREA,N,COUNT)
C
C     CPYFIL COPIES RECORDS FROM INFILE TO OUFILE UNTIL AN END-OF-FILE
C     ON INFILE IS ENCOUNTERED. AN END-OF-FILE IS NOT WRITTEN ON OUFILE.
C     RECTYPE IS CALLED PRIOR TO COPYING EACH RECORD. STRING RECORDS ARE
C     COPIED USING CPYSTR. NORMAL RECORDS ARE COPIED USING READ/WRITE.
C     UPON EXIT, INFILE IS POSITIONED IMMEDIATELY AFTER THE END-OF-FILE
C     AND OUFILE IS POSITIONED AFTER THE LAST RECORD WRITTEN.
C
C     THIS ROUTINE DOES NOT OPEN NOR CLOSE ANY FILE, NOR WRITE ANY
C     MATRIX TRAILER
C
      INTEGER        AREA(2),INBLK(15),OUBLK(15),OUFILE,TYPE,EOR,COUNT
      COMMON /BLANK/ IPARAM
C
C     INITIALIZE STRING COMMUNICATION BLOCKS AND DETERMINE RECORD TYPE
C
      INBLK(1) = INFILE
      OUBLK(1) = OUFILE
      COUNT    = 0
   10 CALL RECTYP (INFILE,TYPE)
      IF (TYPE .NE. 0) GO TO 50
C
C     COPY NORMAL RECORD
C
   20 EOR  = 1
      CALL READ (*60,*30,INFILE,AREA,N,0,NWDS)
      EOR  = 0
      NWDS = N
   30 IF (COUNT.NE.0 .OR. IPARAM.NE.-1111) GO TO 40
      CALL FNAME (INFILE,AREA(NWDS+1))
      IF (AREA(NWDS+1).EQ.AREA(1) .AND. AREA(NWDS+2).EQ.AREA(2))
     1   CALL FNAME (OUFILE,AREA)
   40 CALL WRITE (OUFILE,AREA,NWDS,EOR)
      COUNT = COUNT + NWDS
      IF (EOR) 10,20,10
C
C     COPY STRING RECORDS
C
   50 CALL CPYSTR (INBLK,OUBLK,0,0)
      COUNT = COUNT + OUBLK(13)
      GO TO 10
C
C     RETURN WHEN END-OF-FILE IS ENCOUNTERED
C
   60 RETURN
      END
