Index: /tags/ipp-mdpv3-20150326/ippScripts/scripts/sc_prepare_run.pl
===================================================================
--- /tags/ipp-mdpv3-20150326/ippScripts/scripts/sc_prepare_run.pl	(revision 38081)
+++ /tags/ipp-mdpv3-20150326/ippScripts/scripts/sc_prepare_run.pl	(revision 38082)
@@ -24,4 +24,5 @@
 # my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
 my $remote_root = '/scratch3/watersc1/';
+$remote_root = '/lus/scratch/mehuber7/';
 my $remote_raw    = "${remote_root}/tmp/";  # Directory to find raw data in.
 
@@ -35,5 +36,5 @@
 $job_cost{"chip"}   = 150 / 60 / 60;
 $job_cost{"warp"}   = 110 / 60 / 60;
-$job_cost{"stack"}  = 1500 / 60 / 60;
+$job_cost{"stack"}  = 2; # 1500 / 60 / 60;
 $job_cost{"staticsky"} = 2; # really?  avg time of 5720s?
 
@@ -47,7 +48,7 @@
 $job_subscription{"staticsky"} = 3;
 
-my $proc_per_node = 24;                     # processors per node
+my $proc_per_node = 20;                     # processors per node
 my $min_nodes     = 1;                      # smallest allocation to ask for
-my $max_nodes     = 1000;                   # largest allocation to ask for
+my $max_nodes     = 10;                     # largest allocation to ask for
 my $min_time      = 1;                      # shortest allocation to ask for
 my $max_time      = 8;                      # longest allocation to ask for
@@ -217,8 +218,11 @@
 
 # Construct the moab command last, so we can use the job_index counter to estimate resources.  Somehow.
+if (($stage eq "stack")||($stage eq "staticsky")) {
+    $threads = $job_subscription{$stage};  # Put this here instead of after the calculation to prevent underutilization
+}
 my $proc_need = $job_index * $threads;       # how many total processors do we need?
 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes?
 my $time_need = $job_index * $job_cost{$stage};      # How many seconds will this take?
-
+print STDERR "## $job_index $threads $proc_need $node_need $time_need\n";
 my $fill_factor = 0.8;  # This is the factor of how much of the time allocation we'd like to fill
 my ($time_req,$node_req);
@@ -226,4 +230,5 @@
     $time_req = $min_time;
     $node_req = $min_nodes;
+    print STDERR "CASE 1\n";
 }
 elsif ($node_need * $job_cost{$stage} > $fill_factor * $max_nodes * $max_time) {
@@ -234,12 +239,18 @@
 else {
     $time_req = int(($node_need * $job_cost{$stage}) / ($fill_factor * $max_nodes)) + 1;
+    if ($time_req < $job_cost{$stage}) {
+        $time_req = $job_cost{$stage} + 1;
+    }
     $node_req = int(($node_need * $job_cost{$stage}) / ($fill_factor * $time_req)) + 1;
-}
-
+    print STDERR "CASE 3\n";
+}
+print STDERR "## $job_index $threads $proc_need $node_need $time_need $time_req $node_req\n";
 # Most jobs only take 1 core, but ensure that we split them appropriately
-$node_req *= $job_subscription{$stage};
+#$node_req *= $job_subscription{$stage};
 
 if (($stage eq "stack")||($stage eq "staticsky")) {
     $time_req += 2;
+    $time_req *= 2;
+    $time_req = 72;
 } else {
     $time_req += 1; # Safety addition.
@@ -248,9 +259,16 @@
 open(COMMAND,  ">$disk_command") || &my_die("Couldn't open file? $disk_command", $remote_id, $PS_EXIT_SYS_ERROR, $fail_state);
 print COMMAND "#!/bin/tcsh\n";
-print COMMAND "##### Moab controll lines\n";
-print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
-print COMMAND "#MSUB -j oe\n";
-print COMMAND "#MSUB -V\n";
-print COMMAND "#MSUB -o ${remote_root}/stask_logs/${stage}.${remote_id}.out\n";
+#print COMMAND "##### Moab controll lines\n";
+#print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
+#print COMMAND "#MSUB -j oe\n";
+#print COMMAND "#MSUB -V\n";
+#print COMMAND "#MSUB -o ${remote_root}/stask_logs/${stage}.${remote_id}.out\n";
+print COMMAND "###### sbatch control lines\n";
+print COMMAND "#SBATCH --time ${time_req}:00:00\n";
+print COMMAND "#SBATCH --nodes ${node_req}\n";
+print COMMAND "#SBATCH --open-mode=append\n";
+print COMMAND "#SBATCH --export=ALL\n";
+print COMMAND "#SBATCH --exclusive\n";
+print COMMAND "#SBATCH -o ${remote_root}/stask_logs/${stage}.${remote_id}.out\n";
 print COMMAND "date\n";
 print COMMAND 'srun -n $SLURM_JOB_NUM_NODES -m cyclic -l /bin/hostname | sort -n | awk \'{printf "%s\n", $2}\' > hosts.${SLURM_JOB_ID}' . "\n";
