        DIMENSION LPOS(9)
        CHARACTER*1 LEFT(40),TEST(3,10),DATA(130),BLANK,COMMENT(72)
        CHARACTER*80 FILE
        CHARACTER*20 FILELIST,OUTFILE
        CHARACTER*1 RIGHT(40)
        DATA TEST/'F','I','L','I','M','A','O','B','S','O','B','J',
     D  'D','A','T','T','I','M','E','X','P','C','E','N','G','R','A',
     D  'C','O','M'/,BLANK/' '/
        DATA LPOS/1,21,31,51,71,81,91,101,116/
        WRITE (*,*) ' file with list of files?'
        READ (*,5000) FILELIST
        WRITE (*,*) ' output log file?'
        READ (*,5000) OUTFILE
 5000   FORMAT (A20)
        OPEN (UNIT=1,FILE=FILELIST,STATUS='OLD')
        OPEN (UNIT=8,FILE=OUTFILE)
    1   READ (1,5001,END=100) FILE
 5001   FORMAT (A80)
        OPEN (UNIT=2,FILE=FILE,STATUS='OLD',ACCESS='DIRECT',
     O    RECL=80)
        DO 2 K=1,130
    2   DATA(K)=BLANK
        NCOMMENT=0
        I=1
    3   READ (2,REC=I) LEFT,RIGHT
        DO 6 J=1,10
        IF (LEFT(1).NE.TEST(1,J)) GOTO 5
        IF (LEFT(2).NE.TEST(2,J)) GOTO 5
        IF (LEFT(3).NE.TEST(3,J)) GOTO 5
        IF ((J.EQ.1).AND.LEFT(4).NE.'E') GOTO 5
C --  handle the numerical data for exposure time differently
        IF (J.EQ.7) GOTO 50
C -----------------------------------------------------------
C --    comments, if present, are added to the end of the ordinary line
        IF (J.EQ.10) GOTO 60
        DO 4 K=6,40
        IF (LEFT(K).EQ.'''') GOTO 7
    4   CONTINUE
        GOTO 5
    7   L=LPOS(J)
        K=K+1
    8   DATA(L)=LEFT(K)
        K=K+1
        L=L+1
        IF (LEFT(K).EQ.'''') GOTO 6
        IF (L.LT.LPOS(J+1)) GOTO 8
    5   IF (LEFT(1).EQ.'E'.AND.LEFT(2).EQ.'N'.AND.LEFT(3).EQ.'D')
     I       GOTO 10
        GOTO 6
   50   DO 55 K=10,40
          IF (LEFT(K).NE.BLANK) GOTO 56
   55     CONTINUE
          GOTO 6
   56     DO 57 KK=K,40
          IF (LEFT(KK).EQ.BLANK) GOTO 58
   57     CONTINUE
          GOTO 6
   58     LENGTH=KK-K+1
          L=LPOS(J+1)-LENGTH-1
          DO 59 KK=1,LENGTH
C---          WRITE (*,*) LEFT(K+KK-1)
   59     DATA(L+KK)=LEFT(K+KK-1)
        GOTO 6
   60   DO 65 KK=10,40  
        IF (LEFT(KK).NE.BLANK) GOTO 66
   65   CONTINUE
        GOTO 6
   66   NCOMMENT=40-KK+1
        DO 68 K=1,NCOMMENT
        COMMENT(K)=LEFT(K+KK-1)
   68   CONTINUE
        DO 70 L=1,40
        IF (RIGHT(41-L).NE.BLANK) GOTO 75
   70   CONTINUE
        GOTO 6 
   75   LL=41-L
        DO 78 L=1,LL
        COMMENT(40+L)=RIGHT(L)
   78   CONTINUE
        NCOMMENT=40+LL
    6   CONTINUE
        I=I+1
        IF (I.LT.48) GOTO 3
   10   CLOSE (2)
        WRITE (*,7010) FILE,DATA
        WRITE (8,7010) FILE,DATA,(COMMENT(L),L=1,NCOMMENT)
 7010   FORMAT (A8,'  ',202A1)
        GOTO 1
  100   CLOSE (1)
        STOP
        END
