TABLE OF CONTENTS


::pwtk::queue::QUEUE

SYNOPSIS

proc ::pwtk::queue::QUEUE {queueSystem args} {

PURPOSE

This is a driver for a direct execution of PWTK script with the batch-queuing system. It creates a pwtk script that is then executed directly by batch-queue submission command.

This is a generic command used for the automatic implemantation of specific commands, such as SLURM, LL, LSF, which are created upon "::pwtk::queue::init $queueSystem"

USAGE

::pwtk::queue::QUEUE queueSystem script

::pwtk::queue::QUEUE queueSystem profile script

::pwtk::queue::QUEUE queueSystem profile -option1 value1 -option2 value2 ... script

ARGUMENTS

SOURCE

    variable direct
    variable counter
    variable scriptTail

    # direct mode (i.e. pwtk is executed directly from created batch script)    
    set direct 1
        
    #
    # parse args
    #
    
    set nargs [llength $args]
    set QUEUE [string toupper $queueSystem]    

    if { $nargs == 0 } {
        error "ERROR: an empty script supplied to $QUEUE command\n"
    } elseif { $nargs == 1 } {

        # Usage: $QUEUE script
        # (no parsing of args needed)

    } else {
        if { [string index [lindex $args 0] 0] != "-" } {

            # Usage: $QUEUE profile -option value -option value ... script
            # N.B. $nargs must be odd

            # "odd" check disabled, because we can have $QUEUE profile -option1 -option2 -option3 value3 (i.e. options can have no values)
            #
            #if { $nargs%2 } {
            #    error "ERROR: wrong number of arguments, should be:\n\n$QUEUE profile -option1 value1 -option2 value2 ... script\n\nbut got:   $QUEUE $args\n\n"
            #}
        } else {

            # Usage: $QUEUE -option value -option value script
            # N.B. $nargs must be even
            
            # "even" check disabled, because we can have $QUEUE -option1 -option2 -option3 value3 (i.e. options can have no values)
            #
            #if { $nargs%2 == 0 } {
            #    error "ERROR: wrong number of arguments, should be:\n\n$QUEUE -option1 value1 -option2 value2 ... script\n\nbut got:   $QUEUE $args\n\n"
            #}
        }
        if { $nargs >= 2} {
            #
            # activate the use of user requested profile
            #
            eval ::pwtk::queue::setHead $queueSystem [lrange $args 0 $nargs-2]
        }
    }
    
    set script     [lindex $args end]        
    set scriptHead [file rootname [info script]]
    
    set pwtk_scriptName  [::pwtk::queue::scriptName_ $scriptHead.$queueSystem.pwtk]
    set pwtk_logName     $pwtk_scriptName.log
    #set pwtk_logName     [::pwtk::queue::scriptName_ $scriptHead.$queueSystem.log];
    set queue_scriptName [::pwtk::queue::scriptName_ $scriptHead.$queueSystem.sh]
    
    writeFile $pwtk_scriptName $script
    
    pwtk::printTitle $QUEUE "running PWTK script within the $QUEUE batch queuing system"    
    ::pwtk::print "$QUEUE batch script:  $queue_scriptName"
    ::pwtk::print "batch PWTK script:  $pwtk_scriptName"
    ::pwtk::print "batch PWTK log file:  $pwtk_logName\n"
    ::pwtk::print "$QUEUE batch options used in $queue_scriptName:\n[getHead $queueSystem]"

    ::pwtk::queue::setTail $queueSystem  "pwtk $pwtk_scriptName > $pwtk_logName 2>&1"
    ::pwtk::queue::submit  $queueSystem  $queue_scriptName

    # VERY IMPORTANT: clear the "tail" otherwise the script will be
    # appended for new SLURM command !!!

    ::pwtk::queue::clear $queueSystem tail
    
    set direct 0
    incr counter
}