#!/usr/bin/perl
# 
# break a big list of star positions into small chunks, and run "marks"
#   on each chunk in turn.
#
# usage: make_marks.pl  starpos.dat


$debug = 1;
$chunk_size = 10;

$infile = $ARGV[0];
$tempfile = "make_marks.tmp";

$numlines = `wc $infile | awk '{ print \$1 }'`;
if ($debug > 0) {
  printf "there are %d lines total in %s \n", $numlines, $infile;
}
for ($i = 0; $i < $numlines; $i += $chunk_size) {
  $start = $i;
  $end = $i + $chunk_size;
  $cmd = "awk '{ if ((NR >= $start) && (NR < $end)) { print \$0 }}' $infile ";
  $cmd .= " > $tempfile ";
  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;

  # now run marks
  $cmd = "marks num=1 row=2 col=3 < $tempfile";
  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;

}


exit 0;

