TABLE OF CONTENTS


::pwtk::findExecutable

SYNOPSIS

proc ::pwtk::findExecutable {program {abort 1}} {

PURPOSE

Find the executable of a given Quantum-ESPRESSO (QE) program, using the following set of rules:

  1. First, the value of the associated program's variable is queried (i.e., QEprog(PW), QEprog(PH), QEprog(PP) as set by the ::pwtk::prog calls). If the variable exists, it is checked that it points to an executable.
  2. If (1) fails, the value of $QEdir(BIN_DIR)/$program is tried.
  3. If even (2) fails, the plain $program is tried, and if it fails, an error is thrown if $abort != 0

This command is typically used internally by PWTK.

ARGUMENTS

SOURCE

    variable state

    if { ! $state(bin_query) } {
        # querying of binaries is disabled, use $program varbatim
        return $program
    }
    
    set head  [headname [file rootname $program] .x]
            
    # A. query the value of QEprog(PW), QEprog(PH), QEprog(PP)... variables
    
    set HEAD  [string toupper $head]
    set prog  [auto_execok [::pwtk::getVar_ QEprog($HEAD)]]
    if { $prog ne {} } {
        return $prog
    }
            
    # B. if (a) fails try as $QEdir(BIN_DIR)/$program, $QEdir(BIN_DIR)/$head.x, or $QEdir(BIN_DIR)/$head
    
    foreach name [list $program $head.x $head] {
        set prog [auto_execok [file join [::pwtk::getVar_ QEdir(BIN_DIR)] $name]]
        if { $prog ne {} } {
            return $prog
        }
    }
    
    # C. if ((a) && (b)) fail try as plain $program, $head.x, or $head
    
    foreach name [list $program $head.x $head] {
        set prog [auto_execok $name]
        if { $prog ne {} } {
            return $prog
        }
    }

    if { $prog eq {} } {
        ::pwtk::error "can't find a usable \"$program\" executable" $abort
    }

    return $program
}