Index: trunk/ippScripts/scripts/lap_science.pl
===================================================================
--- trunk/ippScripts/scripts/lap_science.pl	(revision 37073)
+++ trunk/ippScripts/scripts/lap_science.pl	(revision 37117)
@@ -34,5 +34,6 @@
 my $qstack_threshold     = 0.05; # Only make a quickstack if more than 5% of the exposures require it.
 my $minimum_stack_inputs = 2;    # We can avoid magicking stack inputs if we have more than this number.
-my $do_updates_pv2       = 1;    # Do updates using the calls needed for PV2.  
+my $maximum_stack_inputs = 25;   # This is the place-holder guess on how big a stack we should process locally
+my $do_updates_pv2       = 0;    # Do updates using the calls needed for PV2.  
 
 GetOptions(
@@ -1037,4 +1038,7 @@
     my $data_group = "${label}.${proj_cell}.final.${lap_id}";
 
+
+    ##
+    ## Queue the "shallow" stacks that will run at los alamos.
     my $command = "$stacktool ";
     $command .= " -pretend " if defined $debug;
@@ -1043,5 +1047,5 @@
 #    $command .= " -select_label $label "; # Removed to allow exposure sharing to work
     $command .= " -set_label ${label} -set_workdir $workdir -set_data_group $data_group ";
-    $command .= " -min_num ${minimum_stack_inputs} -set_reduction THREEPI_STACK_1DG -set_dist_group $exposure->{dist_group} ";
+    $command .= " -min_num ${minimum_stack_inputs} -max_num ${maximum_stack_inputs} -set_reduction THREEPI_STACK_1DG -set_dist_group $exposure->{dist_group} ";
     $command .= " $warps ";
 
@@ -1054,5 +1058,28 @@
     my $stacks_made = $mdcParser->parse_list(join "", @$stdout_buf) or
 	&my_die("unable to parse metadata from stacktool -definebyquery", $lap_id, "");    
-    
+
+    ##
+    ## Queue the "deep" stacks that will run locally.
+    my $deep_minimum = $maximum_stack_inputs + 1;
+    $command = "$stacktool ";
+    $command .= " -pretend " if defined $debug;
+    $command .= " -dbname $dbname " if defined $dbname;
+    $command .= " -definebyquery -select_skycell_id ${proj_cell}.% -select_filter $filter ";
+#    $command .= " -select_label $label "; # Removed to allow exposure sharing to work
+    $command .= " -set_label ${label}.local -set_workdir $workdir -set_data_group $data_group ";
+    $command .= " -min_num ${deep_minimum} -set_reduction THREEPI_STACK_1DG -set_dist_group $exposure->{dist_group} ";
+    $command .= " $warps ";
+
+    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run(command => $command, verbose => $verbose);
+    unless ($success) {
+	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+	&my_die("Unable to perform stacktool -definebyquery: $error_code", $lap_id);
+    }
+    $stacks_made .= $mdcParser->parse_list(join "", @$stdout_buf) or
+	&my_die("unable to parse metadata from stacktool -definebyquery", $lap_id, "");    
+
+
+    ## Determine the sass_id so we can record it in the database.
     $command = "$stacktool ";
     $command .= " -dbname $dbname " if defined $dbname;
