Index: gs2-extensions/parallel-building/trunk/src/bin/script/parallel_terrier_fileindex.pl
===================================================================
--- gs2-extensions/parallel-building/trunk/src/bin/script/parallel_terrier_fileindex.pl	(revision 26187)
+++ gs2-extensions/parallel-building/trunk/src/bin/script/parallel_terrier_fileindex.pl	(revision 26242)
@@ -66,5 +66,5 @@
   if ($debug)
   {
-    print STDERR '[debug] ' . $message;
+    print STDERR '[SDEBUG] ' . $message;
   }
 }
@@ -100,106 +100,105 @@
 sub main
 {
-    print '[' . time() . '] Parallel FileIndexer Started: ' . localtime() . "\n";
-
-    # 1. Initialization
-    my $class_name = 'org.terrier.applications.FileIndexer';
-    my $worker_count = 0;
-    my $terrier_home = '';
-    my $collection_path = '';
-    my $batch_size = 0;
-    my $debug = 0;
-    # - parse arguments
-    my $argument;
-    for (my $i = 0; $i < scalar(@ARGV); $i++)
-    {
-      $argument = $ARGV[$i];
-      if ('-workers' eq $argument)
-      {
-        $i++;
-        $worker_count = $ARGV[$i];
-      }
-      elsif ('-terrier' eq $argument)
-      {
-        $i++;
-        $terrier_home = $ARGV[$i];
-      }
-      elsif ('-collection' eq $argument)
-      {
-        $i++;
-        $collection_path = $ARGV[$i];
-      }
-      elsif ('-batchsize' eq $argument)
-      {
-        $i++;
-        $batch_size = $ARGV[$i];
-      }
-      elsif ('-debug' eq $argument)
-      {
-        $debug = 1;
-      }
-      else
-      {
-        &printUsage('Unrecognized argument: ' . $argument);
-      }
-    }
-    print 'Worker Count: ' . $worker_count . "\n";
-    print 'Terrier Home: ' . $terrier_home . "\n";
-    print 'Collection:   ' . $collection_path . "\n";
-    print 'Batch Size:   ' . $batch_size . "\n";
-    print 'Debug:        ' . $debug . "\n";
-    # - check arguments
-    if ($worker_count !~ /^\d+$/)
-    {
-      &printUsage('Worker count must be an integer');
-    }
-    if ('' eq $terrier_home || !-d $terrier_home)
-    {
-      &printUsage('Terrier home path given doesn\'t exist or isn\'t a directory');
-    }
-    if ('' eq $collection_path || !-d $collection_path)
-    {
-      &printUsage('Collection path given doesn\'t exist or isn\'t a directory');
-    }
-    if ($batch_size !~ /^\d+$/)
-    {
-      &printUsage('Batch size count must be an integer');
-    }
-    if (0 == $worker_count || 0 == $batch_size)
-    {
-      print STDOUT "Warning! Zero workers or a batch size of zero causes a serial index.\n";
-      $batch_size = 0;
-    }
-    # - derived variables
-    my $anyclass_exe = &fileCat($terrier_home, 'bin', 'anyclass.sh');
-
-
-    # 2. Remove any existing index
-    print STDOUT " * Removing any old index\n";
-    my $var_path = &fileCat($terrier_home, 'var');
-    opendir(DH, $var_path) or die('Error! Failed to open var path for reading: ' . $!);
-    my @old_files = readdir(DH);
-    closedir(DH);
-    my $old_file;
-    foreach $old_file (@old_files)
-    {
-      if ($old_file =~ /^manifest-\d+.spec/)
-      {
-        my $old_path = &fileCat($var_path, $old_file);
-        &debugPrint($debug, 'deleting ' . $old_path . "\n");
-        unlink($old_path);
-      }
-    }
-    my $index_path = &fileCat($var_path, 'index');
-    my $delete_command = 'rm -rf "' . $index_path . '"';
-    &debugPrint($debug, 'command: ' . $delete_command . "\n");
-    `$delete_command`;
-    my $assoc_path = &fileCat($var_path, 'share', 'images', 'assoc');
-    $delete_command  = 'rm -rf "' . $assoc_path . '"';
-    &debugPrint($debug, 'command: ' . $delete_command . "\n");
-    `$delete_command`;
-    print STDOUT ' - cleanup complete!' . "\n";
-
-    # 3. Prepare the collection for parallel indexing
-    print STDOUT " * Prepare collection for indexing\n";
+  print '[SCRIPT:' . time() . "] Starting Parallel FileIndexer\n";
+
+  # 1. Initialization
+  my $class_name = 'org.terrier.applications.FileIndexer';
+  my $worker_count = 0;
+  my $terrier_home = '';
+  my $collection_path = '';
+  my $batch_size = 0;
+  my $debug = 0;
+  # - parse arguments
+  my $argument;
+  for (my $i = 0; $i < scalar(@ARGV); $i++)
+  {
+    $argument = $ARGV[$i];
+    if ('-workers' eq $argument)
+    {
+      $i++;
+      $worker_count = $ARGV[$i];
+    }
+    elsif ('-terrier' eq $argument)
+    {
+      $i++;
+      $terrier_home = $ARGV[$i];
+    }
+    elsif ('-collection' eq $argument)
+    {
+      $i++;
+      $collection_path = $ARGV[$i];
+    }
+    elsif ('-batchsize' eq $argument)
+    {
+      $i++;
+      $batch_size = $ARGV[$i];
+    }
+    elsif ('-debug' eq $argument)
+    {
+      $debug = 1;
+    }
+    else
+    {
+      &printUsage('Unrecognized argument: ' . $argument);
+    }
+  }
+  print '[SCRIPT] Worker Count: ' . $worker_count . "\n";
+  print '[SCRIPT] Terrier Home: ' . $terrier_home . "\n";
+  print '[SCRIPT] Collection:   ' . $collection_path . "\n";
+  print '[SCRIPT] Batch Size:   ' . $batch_size . "\n";
+  print '[SCRIPT] Debug:        ' . $debug . "\n";
+
+  # - check arguments
+  if ($worker_count !~ /^\d+$/)
+  {
+    &printUsage('Worker count must be an integer');
+  }
+  if ('' eq $terrier_home || !-d $terrier_home)
+  {
+    &printUsage('Terrier home path given doesn\'t exist or isn\'t a directory');
+  }
+  if ('' eq $collection_path || !-d $collection_path)
+  {
+    &printUsage('Collection path given doesn\'t exist or isn\'t a directory');
+  }
+  if ($batch_size !~ /^\d+$/)
+  {
+    &printUsage('Batch size count must be an integer');
+  }
+  if (0 == $worker_count || 0 == $batch_size)
+  {
+    print STDOUT "Warning! Zero workers or a batch size of zero causes a serial index.\n";
+    $batch_size = 0;
+  }
+  # - derived variables
+  my $anyclass_exe = &fileCat($terrier_home, 'bin', 'anyclass.sh');
+
+  # 2. Remove any existing index
+  print STDOUT "[SCRIPT] Removing old index files...\n";
+  my $var_path = &fileCat($terrier_home, 'var');
+  opendir(DH, $var_path) or die('Error! Failed to open var path for reading: ' . $!);
+  my @old_files = readdir(DH);
+  closedir(DH);
+  my $old_file;
+  foreach $old_file (@old_files)
+  {
+    if ($old_file =~ /^manifest-\d+.spec/)
+    {
+      my $old_path = &fileCat($var_path, $old_file);
+      &debugPrint($debug, 'deleting ' . $old_path . "\n");
+      unlink($old_path);
+    }
+  }
+  my $index_path = &fileCat($var_path, 'index');
+  my $delete_command = 'rm -rf "' . $index_path . '"';
+  &debugPrint($debug, 'command: ' . $delete_command . "\n");
+  `$delete_command`;
+  my $assoc_path = &fileCat($terrier_home, 'share', 'images', 'assoc');
+  $delete_command  = 'rm -rf "' . $assoc_path . '"';
+  &debugPrint($debug, 'command: ' . $delete_command . "\n");
+  `$delete_command`;
+
+  # 3. Prepare the collection for parallel indexing
+  print STDOUT "[SCRIPT] Prepare collection for indexing...\n";
     my $prepare_command = $anyclass_exe . ' ' . $class_name . ' -prepare -path "' . $collection_path . '"';
     if (0 < $batch_size)
@@ -221,6 +220,5 @@
       }
     }
-    print STDOUT ' - generated ' . $manifest_count . ' manifest files' . "\n";
-    print STDOUT ' - preparation complete!' . "\n";
+    print STDOUT '[SCRIPT] => generated ' . $manifest_count . " manifest files\n";
     if (0 >= $manifest_count)
     {
@@ -231,5 +229,5 @@
     if (1 == $manifest_count)
     {
-      print STDOUT ' * Index collection with serial processing' . "\n";
+      print STDOUT "[SCRIPT] Index collection using serial processing\n";
       my $manifest_path = &fileCat($var_path, 'manifest-000.spec');
       my $index_command = $anyclass_exe . ' ' . $class_name . ' -index -path "' . $manifest_path . '" -prefix 000';
@@ -240,15 +238,15 @@
     else
     {
-      print STDOUT ' * Index collection with parallel processing (' . $worker_count . ' workers)' . "\n";
-      my $mpi_flags = '--show-progress --timestamp-output --verbose --report-bindings --tag-output';
+      print STDOUT '[SCRIPT] Index collection using parallel processing (' . $worker_count . " workers)";
+      my $mpi_flags = '--show-progress --verbose ';
       my $mpi_conf_path = &fileCat($terrier_home, 'mpi.conf');
       if (-f $mpi_conf_path)
       {
-        print STDOUT ' - parallel processing on cluster' . "\n";
+        print STDOUT "(cluster)\n";
         $mpi_flags .= ' -nolocal -machinefile "' . $mpi_conf_path . '"';
       }
       else
       {
-        print STDOUT ' - parallel processing on multicore computer' . "\n";
+        print STDOUT "(multicore)\n";
       }
       my $mpi_command = 'mpirun ' . $mpi_flags . ' -np ' . ($worker_count + 1) . ' mpiterrierfileindexer "' . $ENV{'GSDLHOME'} . '" "' . $terrier_home . '" ' . $manifest_count;
@@ -256,17 +254,15 @@
       `$mpi_command`;
     }
-    print STDOUT ' - indexing complete!' . "\n";
 
     # 5. Merge the indexes
     # - if we performed a serial process above, then this will just rename the
     #   index files
-    print STDOUT ' * Merging Indexes' . "\n"; 
+    print STDOUT "[SCRIPT] Merging Indexes\n";
     my $merge_command = $anyclass_exe . ' ' . $class_name . ' -merge';
     &debugPrint($debug, 'command: ' . $merge_command . "\n");
     `$merge_command`;
-    print STDOUT ' - merging complete!' . "\n";
 
     # Complete!
-    print '[' . time() . '] Parallel FileIndexer Complete: ' . localtime() . "\n";
+    print '[SCRIPT:' . time() . "] Complete!\n\n";
   }
 
