program Renumber

  ! Renumber the object decks after diff71

  character(153) :: Line
  integer :: nA = 0, nB = 0, nAmax = huge(0)

  call getarg ( 1, line )
  if ( line /= '' ) read ( line, * ) nAmax

  do while ( nA < nAmax )
    read ( *, '(a)', end=9 ) line
    if ( line(77:77) == '<' ) then
      nA = nA + 1
      write ( *, '(a,i4.4,a)' ) line(1:71), na, ' <'
    else if ( line(77:77) == '>' ) then
      nB = nB + 1
      write ( *, '(t72,a,i4.4)' ) line(72:151), nb
    else
      nA = nA + 1
      nB = nB + 1
      write ( *, '(a,i4.4,a,i4.4)' ) line(1:71), na, line(76:151), nb
    end if
  end do

9 stop

end program Renumber
