      real      x, y, z, xold, yold, cd, xx
      integer   i, ncorners, ilab
      character ifile*80, temp*70
c
      open(unit=2,file='loop_geometry.ps',status='unknown')
      write(2,*) '%!'
      cd = ( 72.0 * 1000 )/ ( 25.4 * 60000.0 )
      write(2,*) cd,cd,' scale'
c
c Thompson grid coordinates
c
      write(2,*) '7400 7200 translate' 
c
      do while(.true.) 
        call tin('Name of loop file ?',ifile)
        if(ifile.eq.'none'.or.ifile.eq.'NONE') goto 100 
        open(unit=1,file=ifile,status='unknown')
        do i = 1, 15
          read(1,'(a)') temp
        end do
        read(temp(23:),*) ncorners
        read(1,'(a)') temp
        write(2,*) 'newpath'
        do i = 1, ncorners
          read(1,*) j, x, y, z
          if(i.eq.1) then
            write(2,*) x, y,' moveto'
           else
            write(2,*) x, y,' lineto'
          end if
        end do 
        write(2,*) 'closepath stroke'
        close(unit=1)
      end do
100   call tin('Name of profile file ?',ifile)
      open(unit=1,file=ifile,status='unknown')
      i = 1
      write(2,*) 'newpath'
      do while(.true.)
        read(1,*,end=200) j, ilab, x, y, z
        write(2,*) x, y+20, ' moveto'
        write(2,*) x, y-20, ' lineto'
        if(i.ne.1) then
          write(2,*) xold, yold, ' moveto'
          write(2,*) x, y, ' lineto'
        end if
        xold = x 
        yold = y 
        if(mod(ilab,500).eq.0.or.ilab.eq.0) then
          write(2,*) 'stroke'

          write(2,*) 'newpath'
        endif
        i = i + 1
      end do
200   write(2,*) 'stroke'
      write(2,*) 'showpage'
      close(unit=1)
      stop
      end
