	program  jychead
	character*40 tmp,ch,in_lst,out_all,out_star,filename
	character imtype*16,observer*16,object*16,exp*6,gtilt*8
	character utdate*10,uttime*10,cent_lam*6,grat*8
	print*,'Extracts header information and writes to a log and star file'
	write(6,10)
10	format(1x,'Enter a filelist (input) : ',$)
	read(5,1) in_lst
	write(6,20)
20	format(1x,'Enter a logfile for all  : ',$)
	read(5,1) out_all
        write(6,30)
30      format(1x,'Enter a logfile for star : ',$)
        read(5,1) out_star

1	format(a)

	open(1,file=in_lst,status='old')
	open(2,file=out_all,status='unknown')
	open(8,file=out_star,status='unknown') 

	do i=1,20000
	 read(1,1,end=80) filename
	 open(3,file=filename,status='old',access='direct',recl=80)
	 do k=1,288
	  read(3,rec=k) tmp,ch
	  if( tmp(1:8) .eq. 'END     ') goto 50
	  if( tmp(1:8) .eq. 'IMAGETYP') then
          do j=12,27
            if( tmp(j:j) .eq. '\'') imtype=tmp(12:j-1)
           enddo
          endif

	  if( tmp(1:8) .eq. 'OBSERVER') then
	   do j=12,27
	    if( tmp(j:j) .eq. '\'') observer=tmp(12:j-1)
	   enddo
	  endif
	  if( tmp(1:8) .eq. 'OBJECT  ') then
	   do j=12,27
	    if( tmp(j:j) .eq. '\'') object=tmp(12:j-1)
	   enddo
	  endif
	  if( tmp(1:8) .eq. 'DATE-OBS') utdate=tmp(12:21)
	  if( tmp(1:8) .eq. 'TIME-OBS') uttime=tmp(12:19)
	  if( tmp(1:8) .eq. 'CENTLAM ') cent_lam=tmp(25:30)
	  if( tmp(1:8) .eq. 'EXPTIME ') exp=tmp(25:30)
          if( tmp(1:8) .eq. 'GRATING ') grat=tmp(23:30)
	  if( tmp(1:8) .eq. 'GTILT   ') gtilt=tmp(23:30)
	 enddo
50	 close(3)
	 if( imtype(1:6) .eq. 'object') write(8,60) filename(1:8),imtype,
     1	   observer,object,utdate,uttime,cent_lam,exp,grat,gtilt

	 write(2,60) filename(1:8),imtype,observer,object,utdate,
     1	   uttime,cent_lam,exp,grat,gtilt
	 write(6,60) filename(1:8),imtype,observer,object,utdate,
     1	   uttime,cent_lam,exp,grat,gtilt
60 	 format(a8,1x,a6,2x,a15,1x,a13,1x,a10,2x,a8,a6,2x,a7,a8,a8)
	enddo
80	close(1)
	close(2)
	close(8)
	stop
	end
