	program orb6master
c
c	This program reads data from orb6.master and
c	generates html files containing all orbits.
c
	character*1 junk,keep,note,ref2,agrade
	character*7 ref1
	character*10 wds
	character*18 gif
	character*165 header
	character*147 data
c
	open(10,file='orb6.master',status='UNKNOWN')
	open(11,file='/data/Orbits/Orb6/orb6master.header',status='UNKNOWN')
	open(12,file='orb6master.html',status='UNKNOWN')
c
c	read and discard header lines from orbit catalog master file
c
	do 100 n=1,4
  100	read(10,901) junk
  901	format(a1)
	norbits=0
c
c	read and write header lines for orb6master.html
c
  200	read(11,903,end=300) header
  903	format(a165)
  	write(12,903) header
	go to 200
c
c	read star name and orbital elements
c
  300	read(10,904,end=700) data,grade,note,keep,ref1,ref2,gif,wds
  904	format(a147,t169,f3.1,1x,a1,1x,a1,1x,a7,a1,1x,a18,t23,a10)
	if (wds .ne. '          ') go to 310
	write(12,909)
  909	format('<br>')
  	go to 300
  310	igrade=nint(grade)
	if (grade .lt. 1.49) igrade=1
	if (grade .gt. 4.51) igrade=5
	if (grade .gt. 6.51) igrade=6
	if (grade .gt. 7.51) igrade=8
	if (grade .gt. 8.51) igrade=9
	agrade=' '
	if (igrade .eq. 1) agrade='1'
	if (igrade .eq. 2) agrade='2'
	if (igrade .eq. 3) agrade='3'
	if (igrade .eq. 4) agrade='4'
	if (igrade .eq. 5) agrade='5'
	if (igrade .eq. 6) agrade='-'
	if (igrade .eq. 7) agrade='-'
	if (igrade .eq. 8) agrade='I'
	if (igrade .eq. 9) agrade='A'
c
c	write lines for orb6orbits.html
c
	if ((note .ne. 'n') .and. (gif .ne. '                  '))
     $     write(12,905) data,ref1,ref2,ref1,ref2,
     $     agrade,keep,note,gif
  905	format(a147,' <a href="wdsref.html#',a7,a1,'">',a7,a1,'</a>',
     $     1x,a1,1x,a1,1x,a1,' <a href=GIF/',a18,'>P</a>')
c
  	if ((note .eq. 'n') .and. (gif .ne. '                  ')) 
     $     write(12,906) data,ref1,ref2,ref1,ref2,
     $     agrade,keep,wds,gif
  906	format(a147,' <a href="wdsref.html#',a7,a1,'">',a7,a1,'</a>',
     $     1x,a1,1x,a1,' <a href="orb6notes.html#',a10,
     $     '">N</a> <a href=GIF/',a18,'>P</a>')
c
	if ((note .ne. 'n') .and. (gif .eq. '                  '))
     $     write(12,907) data,ref1,ref2,ref1,ref2,
     $     agrade,keep,note
  907	format(a147,' <a href="wdsref.html#',a7,a1,'">',a7,a1,'</a>',
     $     1x,a1,1x,a1,1x,a1)
c
  	if ((note .eq. 'n') .and. (gif .eq. '                  ')) 
     $     write(12,908) data,ref1,ref2,ref1,ref2,
     $     agrade,keep,wds
  908	format(a147,' <a href="wdsref.html#',a7,a1,'">',a7,a1,'</a>',
     $     1x,a1,1x,a1,' <a href="orb6notes.html#',a10,
     $     '">N</a>')
c
	go to 300
c
  700	write(12,911)
  911	format('</pre>')
c
  999	stop
	end
