IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 12, 2015, 12:53:36 PM (11 years ago)
Author:
eugene
Message:

merging changes from ipp-pv3-20140717 (via branches/eam_branches/ipp-pv3-20140717-merge)

Location:
trunk/ippScripts/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts

  • trunk/ippScripts/scripts/sc_prepare_warp.pl

    r37154 r37833  
    11#! /usr/bin/env perl
     2
     3# generate the input & output files lists and commands for a single warpRun
    24
    35use Carp;
     
    1618use Pod::Usage qw( pod2usage );
    1719
    18 
    1920# Hard coded values
    20 # my $remote_root   = '/scratch3/watersc1/'; 
    21 my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 $remote_root = '/scratch3/watersc1/';
    23 my $threads       = 2;                      # How many threads are we going to use?
    24 my $job_cost      = 110 / 60 / 60;          # Estimate of how long a job runs, in hours.
    25 my $proc_per_node = 24;                     # processors per node
    26 my $min_nodes     = 1;                      # smallest allocation to ask for
    27 my $max_nodes     = 1000;                   # largest allocation to ask for
    28 my $min_time      = 1;                      # shortest allocation to ask for
    29 my $max_time      = 8;                      # longest allocation to ask for
    30 my $remote_hostname= "LANL/Mustang";         # Name of the remote node.
    31 my @return_component_list = ("DBINFO.EXP", "PSWARP.CONFIG", "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.VARIANCE", "PSWARP.OUTPUT.SOURCES","PSPHOT.PSF.SKY.SAVE","LOG.EXP");
     21# my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     22my $remote_root     = '/scratch3/watersc1/';
     23my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
     24my $threads_req     = 4;                      # How many threads are we going to use?
     25
     26my $fail_state = "prep_fail";
     27
    3228# Look for programs we need
    3329my $missing_tools;
    34 
    3530my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    3631my $warptool    = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     
    4136}
    4237
    43 my ($remote_id,$warp_id,,$camera,$dbname,$verbose,$path_base,$no_update);
     38my ($remote_id,$warp_id,$camera,$dbname,$verbose,$path_base,$no_update);
    4439GetOptions(
    4540    'remote_id=s'    => \$remote_id,
     41    'warp_id=s'      => \$warp_id,
    4642    'camera|c=s'     => \$camera,
    4743    'dbname|d=s'     => \$dbname,
     
    5248
    5349pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    54 pod2usage( -msg => "Required options: --remote_id --camera --dbname --path_base", -exitval => 3) unless
     50pod2usage( -msg => "Required options: --remote_id -warp_id --camera --dbname --path_base", -exitval => 3) unless
    5551    defined($remote_id) and
     52    defined($warp_id) and
    5653    defined($camera) and
    5754    defined($path_base) and
    5855    defined($dbname);
    59 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id);
     56
     57my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $warp_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    6058
    6159my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6260
    63 #
    64 # Step 1: Get a list of the components that make up this remoteRun
    65 
    66 # SHould this call listrun to ensure we're in state new?
    67 my $rt_cmd = "$remotetool -listcomponent -remote_id $remote_id";
    68 $rt_cmd   .= " -dbname $dbname " if defined($dbname);
    69 
    70 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    71     run(command => $rt_cmd, verbose => $verbose);
    72 unless ($success) {
    73     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    74     &my_die("Unable to run remotetool to determine stage parameters.",
    75             $remote_id,$error_code);
    76 }
    77 my $compData = $mdcParser->parse(join "", @$stdout_buf) or
    78     &my_die("Unable to determine component information.",
    79             $remote_id,$PS_EXIT_PROG_ERROR);
    80 my $compData2= parse_md_list($compData);
    81 
    82 #
    83 # Step 1b: Open output files
    84 my $uri_command = $path_base . ".cmd";
     61my @return_component_list = ("DBINFO.EXP", "PSWARP.CONFIG", "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.VARIANCE", "PSWARP.OUTPUT.SOURCES","PSPHOT.PSF.SKY.SAVE","LOG.EXP");
     62
     63# STEP 0: Open output files
    8564my $uri_transfer= $path_base . ".transfer";
    8665my $uri_check   = $path_base . ".check";
     
    8968my $uri_return  = $path_base . ".return";
    9069
    91 my $disk_command = $ipprc->file_resolve($uri_command,1);
    9270my $disk_transfer= $ipprc->file_resolve($uri_transfer,1);
    9371my $disk_check   = $ipprc->file_resolve($uri_check,1);
     
    9674my $disk_return  = $ipprc->file_resolve($uri_return,1);
    9775
    98 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it.
    99 
    100 open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id,$PS_EXIT_SYS_ERROR);
    101 open(CHECK,    ">$disk_check")  || &my_die("Couldn't open file? $disk_check",$remote_id,$PS_EXIT_SYS_ERROR);
    102 open(CONFIG,   ">$disk_config")  || &my_die("Couldn't open file? $disk_config",$remote_id,$PS_EXIT_SYS_ERROR);
    103 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id,$PS_EXIT_SYS_ERROR);
    104 open(RETURN,   ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $PS_EXIT_SYS_ERROR);
    105 
    106 
    107 #
    108 # Step 2: Iterate over all componenets in this remote run.
     76my (undef, $remote_config) = &uri_convert($uri_config); # Needs to be done after we've created it.
     77
     78open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     79open(CHECK,    ">$disk_check")     || &my_die("Couldn't open file? $disk_check",   $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     80open(CONFIG,   ">$disk_config")    || &my_die("Couldn't open file? $disk_config",  $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     81open(GENERATE, ">$disk_generate")  || &my_die("Couldn't open file? $disk_generate",$remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     82open(RETURN,   ">$disk_return")    || &my_die("Couldn't open file? $disk_return",  $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     83
    10984my $job_index = 0;
    110 my @pre_commands = ();
    111 my @main_commands = ();
    112 my @post_commands = ();
    113 
    114 my %file_filter = ();
    115 
    116 foreach my $compEntry (@$compData2) {
    117     my $warp_id = $compEntry->{stage_id};
    118 
    119 # Get exposure level information from the warpRun we're working from.
     85
     86# STEP 1: Get exposure level information from the warpRun we're working from.
     87my ($warpData);
     88{
    12089    # This actually returns all the individual warp/skyfiles that comprise this run.  Because consistency.
    12190    my $command = "$warptool -towarped -warp_id $warp_id ";
    12291    $command   .= " -dbname $dbname " if defined($dbname);
    123     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    124         run(command => $command, verbose => 0);
     92
     93    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     94        run(command => $command, verbose => $verbose);
    12595    unless ($success) {
    126         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    127         &my_die("Unable to run warptool -pendingimfile ",
    128                 $warp_id,$error_code);
    129     }
    130     my $warpData = $mdcParser->parse(join "", @$stdout_buf) or
    131         &my_die("Unable to determine warp component information.",
    132                 $warp_id,$PS_EXIT_PROG_ERROR);
    133     my $warpData2= parse_md_list($warpData);
    134 
    135 #
    136 # Step 3: Iterate over the sub-components
    137     foreach my $warpEntry ( @{ $warpData2 } ) {
    138         my $workdir = $warpEntry->{workdir};
    139         my $exp_tag = $warpEntry->{exp_tag};
    140         my $skycell_id = $warpEntry->{skycell_id};
    141         my $tess_id = $warpEntry->{tess_id};
    142         my $reduction = 'DEFAULT' unless defined $warpEntry->{reduction};
    143         my $recipe_pswarp = $ipprc->reduction($reduction, 'WARP_PSWARP'); # Recipe to use                                                                         
    144         my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.wrp.${warp_id}.${skycell_id}";
    145         print "$ipp_outroot\n";
    146         my $remote_outroot = uri_local_to_remote($ipp_outroot);
    147 
    148         my $reg_command = "$warptool -scmap -warp_id $warp_id -skycell_id ${skycell_id}";
    149         $reg_command   .= " -dbname $dbname " if defined($dbname);
    150        
    151         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    152             run(command => $reg_command, verbose => 0);
    153         unless ($success) {
    154             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    155             &my_die("Unable to run warptool -pendingimfile: $reg_command ",
    156                     $warp_id,$error_code);
    157         }
    158    
    159         my $inpData = $mdcParser->parse(join "", @$stdout_buf) or
    160             &my_die("Unable to determine warp component information.",
    161                     $warp_id, $PS_EXIT_PROG_ERROR);
    162         my $inpData2=parse_md_list($inpData);
    163        
    164         my $pre_cmd_ims = "ls -1 ";
    165         my $pre_cmd_masks= "ls -1 ";
    166         my $pre_cmd_vars = "ls -1 ";
    167         my $pre_cmd_astrom = "";
    168 
    169         foreach my $imfile (@{ $inpData2 }) {
    170             my $image = $ipprc->filename("PPIMAGE.CHIP", $imfile->{chip_path_base}, $imfile->{class_id});
    171             my $mask  = $ipprc->filename("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id});
    172             my $var   = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $imfile->{chip_path_base}, $imfile->{class_id});
    173 
    174             my $astrom= $ipprc->filename("PSASTRO.OUTPUT", $imfile->{cam_path_base});
    175            
    176             my $remote_image = uri_local_to_remote($image);
    177             my $remote_mask  = uri_local_to_remote($mask);
    178             my $remote_var   = uri_local_to_remote($var);
    179             my $remote_astrom= uri_local_to_remote($astrom);
    180 
    181             $pre_cmd_ims     .= " $remote_image ";
    182             $pre_cmd_masks   .= " $remote_mask  ";
    183             $pre_cmd_vars    .= " $remote_var   ";
    184             $pre_cmd_astrom   = "echo $remote_astrom > ${remote_outroot}.astrom ";
    185         }
    186         $pre_cmd_ims   .= "  > ${remote_outroot}.imlist ";
    187         $pre_cmd_masks .= "  > ${remote_outroot}.masklist ";
    188         $pre_cmd_vars  .= "  > ${remote_outroot}.varlist ";
    189 
    190         my $skycell_command = " dvoImageExtract -D CATDIR /turquoise/usr/projects/ps1/watersc1/tess/${tess_id} $skycell_id -o ${remote_outroot}.skyfile ";
    191 
    192         my $pswarp_command  = " pswarp -list ${remote_outroot}.imlist ";
    193         $pswarp_command    .= " -masklist ${remote_outroot}.masklist -variancelist ${remote_outroot}.varlist ";
    194         $pswarp_command    .= " -astromlist ${remote_outroot}.astrom ";
    195         $pswarp_command    .= " ${remote_outroot} ${remote_outroot}.skyfile ";
    196         $pswarp_command    .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE ";
    197         $pswarp_command    .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF ";
    198         $pswarp_command    .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF ";
    199         $pswarp_command    .= " -F SOURCE.PLOT.MOMENTS SOURCE.PLOT.SKY.MOMENTS ";
    200         $pswarp_command    .= " -F SOURCE.PLOT.PSFMODEL SOURCE.PLOT.SKY.PSFMODEL ";
    201         $pswarp_command    .= " -F SOURCE.PLOT.APRESID SOURCE.PLOT.SKY.APRESID ";
    202         $pswarp_command    .= " -recipe PSWARP $recipe_pswarp ";
    203         $pswarp_command    .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log ";
    204         $pswarp_command    .= " -threads 4 "; # -image_id ${image_id} -source_id ${source_id} ";
    205         $pswarp_command    .= " -recipe PPSTATS WARPSTATS ";
    206         $pswarp_command    .= " -dumpconfig ${remote_outroot}.pswarp.mdc -stats ${remote_outroot}.stats ";
    207 
    208 #       print "$pswarp_command \n";
    209        
    210         my $post_cmd_echo = " echo -n \"warptool  -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id ";
    211         $post_cmd_echo   .= " -path_base $remote_outroot -uri UNKNOWN ";
    212         $post_cmd_echo   .=  " -dbname $dbname " if defined $dbname;
    213         $post_cmd_echo   .= " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 \" > ${remote_outroot}.dbinfo ";
    214        
    215         my $post_cmd_SfM  = " ppStatsFromMetadata ${remote_outroot}.stats - WARP_SKYCELL >> ${remote_outroot}.dbinfo ";
    216 
    217         print CONFIG "${pre_cmd_ims} && ${pre_cmd_masks} && ${pre_cmd_vars} && ${pre_cmd_astrom} && ${skycell_command} && ${pswarp_command} && ${post_cmd_echo} && ${post_cmd_SfM} ";
    218         $job_index++;
    219 
    220         # Determine which output files need to be returned
    221         foreach my $component(@return_component_list) {
    222             my $filename = $ipprc->filename($component,$ipp_outroot,$skycell_id);
    223             my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename);
    224             my $remote_outroot_dir = dirname($ipp_disk);
    225             print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    226         }
    227 
    228         print CONFIG "\n";
    229 #       die();
     96        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     97        &my_die("Unable to run warptool -pendingimfile ", $remote_id, $warp_id, $error_code, $fail_state);
     98    }
     99
     100    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     101        &my_die("Unable to determine warp component information.", $remote_id, $warp_id, $PS_EXIT_PROG_ERROR, $fail_state);
     102    $warpData = parse_md_list($MDlist);
     103}
     104
     105# STEP 2: Iterate over the sub-components
     106{
     107    foreach my $warpEntry ( @{ $warpData } ) {
     108        my $workdir = $warpEntry->{workdir};
     109        my $exp_tag = $warpEntry->{exp_tag};
     110        my $skycell_id = $warpEntry->{skycell_id};
     111        my $tess_id = $warpEntry->{tess_id};
     112
     113        my $reduction = $warpEntry->{reduction};
     114        $reduction = 'DEFAULT' unless defined $warpEntry->{reduction};
     115
     116        my $recipe_pswarp = $ipprc->reduction($reduction, 'WARP_PSWARP'); # Recipe to use
     117        if ($recipe_pswarp eq "") {
     118            &my_die("Unable to determine PSWARP recipe for $reduction", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     119        }
     120
     121        my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.wrp.${warp_id}.${skycell_id}";
     122        print "$ipp_outroot\n";
     123        my $remote_outroot = &uri_local_to_remote($ipp_outroot);
     124
     125        my $command = "$warptool -scmap -warp_id $warp_id -skycell_id ${skycell_id}";
     126        $command   .= " -dbname $dbname " if defined($dbname);
     127
     128        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     129            run(command => $command, verbose => $verbose);
     130        unless ($success) {
     131            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     132            &my_die("Unable to run warptool -pendingimfile: $command ", $remote_id, $warp_id, $error_code, $fail_state);
     133        }
     134
     135        my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     136            &my_die("Unable to determine warp component information.", $remote_id, $warp_id, $PS_EXIT_PROG_ERROR, $fail_state);
     137        my $inData = parse_md_list($MDlist);
     138
     139        my $pre_cmd_ims = "ls -1 ";
     140        my $pre_cmd_masks= "ls -1 ";
     141        my $pre_cmd_vars = "ls -1 ";
     142        my $pre_cmd_astrom = "";
     143
     144        foreach my $imfile (@{ $inData }) {
     145            my $image = $ipprc->filename("PPIMAGE.CHIP", $imfile->{chip_path_base}, $imfile->{class_id});
     146            my $mask  = $ipprc->filename("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id});
     147            my $var   = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $imfile->{chip_path_base}, $imfile->{class_id});
     148
     149            my $astrom= $ipprc->filename("PSASTRO.OUTPUT", $imfile->{cam_path_base});
     150
     151            my $remote_image = &uri_local_to_remote($image);
     152            my $remote_mask  = &uri_local_to_remote($mask);
     153            my $remote_var   = &uri_local_to_remote($var);
     154            my $remote_astrom= &uri_local_to_remote($astrom);
     155
     156            $pre_cmd_ims     .= " $remote_image ";
     157            $pre_cmd_masks   .= " $remote_mask  ";
     158            $pre_cmd_vars    .= " $remote_var   ";
     159            $pre_cmd_astrom   = "echo $remote_astrom > ${remote_outroot}.astrom ";
     160        }
     161        $pre_cmd_ims   .= "  > ${remote_outroot}.imlist ";
     162        $pre_cmd_masks .= "  > ${remote_outroot}.masklist ";
     163        $pre_cmd_vars  .= "  > ${remote_outroot}.varlist ";
     164
     165        my $skycell_command = " dvoImageExtract -D CATDIR /turquoise/usr/projects/ps1/watersc1/tess/${tess_id} $skycell_id -o ${remote_outroot}.skyfile ";
     166
     167        my $pswarp_command  = " pswarp -list ${remote_outroot}.imlist ";
     168        $pswarp_command    .= " -masklist ${remote_outroot}.masklist -variancelist ${remote_outroot}.varlist ";
     169        $pswarp_command    .= " -astromlist ${remote_outroot}.astrom ";
     170        $pswarp_command    .= " ${remote_outroot} ${remote_outroot}.skyfile ";
     171        $pswarp_command    .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE ";
     172        $pswarp_command    .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF ";
     173        $pswarp_command    .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF ";
     174        $pswarp_command    .= " -F SOURCE.PLOT.MOMENTS SOURCE.PLOT.SKY.MOMENTS ";
     175        $pswarp_command    .= " -F SOURCE.PLOT.PSFMODEL SOURCE.PLOT.SKY.PSFMODEL ";
     176        $pswarp_command    .= " -F SOURCE.PLOT.APRESID SOURCE.PLOT.SKY.APRESID ";
     177        $pswarp_command    .= " -recipe PSWARP $recipe_pswarp ";
     178        $pswarp_command    .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log ";
     179        $pswarp_command    .= " -threads $threads_req "; # -image_id ${image_id} -source_id ${source_id} ";
     180        $pswarp_command    .= " -recipe PPSTATS WARPSTATS ";
     181        $pswarp_command    .= " -dumpconfig ${remote_outroot}.pswarp.mdc -stats ${remote_outroot}.stats ";
     182
     183#       print "$pswarp_command \n";
     184
     185        my $post_cmd_echo = " echo -n \"warptool  -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id ";
     186        $post_cmd_echo   .=  " -dbname $dbname " if defined $dbname;
     187        $post_cmd_echo   .= " -uri ${ipp_outroot}.fits ";
     188        $post_cmd_echo   .= " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 \" > ${remote_outroot}.dbinfo ";
     189
     190        my $post_cmd_SfM  = " ppStatsFromMetadata ${remote_outroot}.stats - WARP_SKYCELL >> ${remote_outroot}.dbinfo ";
     191
     192        print CONFIG "${pre_cmd_ims} && ${pre_cmd_masks} && ${pre_cmd_vars} && ${pre_cmd_astrom} && ${skycell_command} && ${pswarp_command} && ${post_cmd_echo} && ${post_cmd_SfM} ";
     193        $job_index++;
     194
     195        # Determine which output files need to be returned
     196        foreach my $component(@return_component_list) {
     197            my $filename = $ipprc->filename($component,$ipp_outroot,$skycell_id);
     198            my ($ipp_disk, $remote_disk) = &uri_to_outputs_for_return( $filename);
     199            my $remote_outroot_dir = dirname($ipp_disk);
     200            print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
     201        }
     202        print CONFIG "\n";
     203#       die();
    230204    }
    231205}
     
    236210close(GENERATE);
    237211
    238 #
    239 # Construct the moab command last, so we can use the job_index counter to estimate resources.  Somehow.
    240 my $proc_need = $job_index * $threads;       # how many total processors do we need?
    241 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes?
    242 my $time_need = $job_index * $job_cost;      # How many seconds will this take?
    243 
    244 my $fill_factor = 0.8;  # This is the factor of how much of the time allocation we'd like to fill
    245 my ($time_req,$node_req);
    246 if ($node_need * $job_cost < $fill_factor * $min_nodes * $min_time) {
    247     $time_req = $min_time;
    248     $node_req = $min_nodes;
    249 }
    250 elsif ($node_need * $job_cost > $fill_factor * $max_nodes * $max_time) {
    251     $time_req = $max_time;
    252     $node_req = $max_nodes;
    253     print STDERR "You've requested the construction of a bundle that appears to need $node_need nodes and $job_cost time per job.  This exceeds the max limits ($max_nodes, $max_time).  Using those max values instead.  Good luck.\n";
    254 }
    255 else {
    256     $time_req = int(($node_need * $job_cost) / ($fill_factor * $max_nodes)) + 1;
    257     $node_req = int(($node_need * $job_cost) / ($fill_factor * $time_req)) + 1;
    258 }
    259 $time_req += 1; # Safety addition.
    260 
    261 open(COMMAND,  ">$disk_command") || &my_die("Couldn't open file? $disk_command",$remote_id,$PS_EXIT_SYS_ERROR);
    262 print COMMAND "#!/bin/tcsh\n";
    263 print COMMAND "##### Moab controll lines\n";
    264 print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
    265 print COMMAND "#MSUB -j oe\n";
    266 print COMMAND "#MSUB -V\n";
    267 print COMMAND "#MSUB -o ${remote_root}warp.${remote_id}.out\n";
    268 print COMMAND "date\n";
    269 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";
    270 print COMMAND "${remote_root}/stask_chip.py $remote_config " . 'hosts.${SLURM_JOB_ID} 1' . "\n";
    271 print COMMAND "date\n";
    272 close(COMMAND);
    273 
    274212unless($no_update) {
    275     my $command = "remotetool -updaterun -remote_id $remote_id ";
    276     $command .= " -set_state pending ";
     213    my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $warp_id ";
     214    $command .= " -set_jobs $job_index";
     215    $command .= " -set_path_base $path_base";
     216    $command .= " -set_state prep_done";
    277217    $command .= " -dbname $dbname " if defined $dbname;
    278218
    279219    system($command);
    280220}
    281 
     221exit (0);
    282222
    283223## Common SC routines
     
    287227    my $ipp_disk= $ipprc->file_resolve( $neb_uri );
    288228    my $remote_disk = $ipp_disk;
    289    
     229
    290230    unless(defined($ipp_disk)) {
    291         my_die();
     231        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
    292232    }
    293233
     
    303243    my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1);
    304244    my $remote_disk = $ipp_disk;
    305    
     245
    306246    unless(defined($ipp_disk)) {
    307         my_die();
     247        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
    308248    }
    309249
     
    317257sub uri_to_outputs { # (ipp_disk,remote_disk) = uri_to_output(neb_uri); Appends to TRANSFER and CHECK filehandles
    318258    my $neb_uri = shift;
    319     my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    320    
    321     unless (exists($file_filter{$neb_uri})) {
    322         $file_filter{$neb_uri} = 1;
    323         print TRANSFER "$ipp_disk\n";
    324         print CHECK    "$remote_disk\n";
    325     }
     259    my ($ipp_disk, $remote_disk) = &uri_convert( $neb_uri );
     260
     261    print TRANSFER "$ipp_disk\n";
     262    print CHECK    "$remote_disk\n";
    326263    return($ipp_disk,$remote_disk);
    327264}
     
    329266sub uri_to_outputs_for_return { # (ipp_disk,remote_disk) = uri_to_outputs_for_return(neb_uri); create ipp_disk, append to RETURN and GENERATE
    330267    my $neb_uri = shift;
    331     my ($ipp_disk, $remote_disk) = uri_convert_and_create( $neb_uri );
    332     unless (exists($file_filter{$neb_uri})) {
    333         $file_filter{$neb_uri} = 1;
    334         print RETURN "$ipp_disk\n";
    335         print GENERATE "$remote_disk\n";
    336     }
     268    my ($ipp_disk, $remote_disk) = &uri_convert_and_create( $neb_uri );
     269
     270    print RETURN "$ipp_disk\n";
     271    print GENERATE "$remote_disk\n";
    337272    return($ipp_disk,$remote_disk);
    338273}
     
    348283    return($remote_uri);
    349284}
    350  
     285
    351286sub uri_remote_to_local { #(local_neb_uri) = uri_remote_to_local(remote_uri);
    352287    # This needs to replace the remote root directory with the nebulous tag.
     
    354289    $remote_uri =~ s%${remote_root}%%;
    355290    my $local_uri  = "neb:///" . $remote_uri;
    356    
     291
    357292    return($local_uri);
    358293}
     
    361296sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status);
    362297    my $msg = shift;
    363     my $id  = shift;
     298    my $remote_id  = shift;
     299    my $stage_id  = shift;
    364300    my $exit_code = shift;
    365301    my $exit_state = shift;
     
    368304
    369305    carp($msg);
    370    
    371     if (defined $id and not $no_update) {
    372         my $command = "remotetool -updaterun -remote_id $id";
    373         $command .= " -fault $exit_code " if defined $exit_code;
     306
     307    if (defined $remote_id and defined $stage_id and not $no_update) {
     308        my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id";
    374309        $command .= " -set_state $exit_state " if defined $exit_state;
    375310        $command .= " -dbname $dbname " if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.