TABLE OF CONTENTS


::pwtk::findExecutable

SYNOPSIS

proc ::pwtk::findExecutable {program} {

PURPOSE

Return the full pathname of a given Quantum-ESPRESSO program. (for internal use only).

The program is located by the following set of rules:

SOURCE

    variable remote_exec
    variable state

    if { ! $state(bin_query) } {
        # querying of binaries is disabled, use $program varbatim
        return $program
    }
    
    set head  [regsub {\.x$} [file rootname $program] {}]
    set prog  ""
            
    # A. query the value of PW, PH, PP, PROJWFC, ... variables ...
    switch -exact -- $head {
        pw -
        cp -
        neb -
        ph -
        dynmat -
        matdyn -
        q2r - 
        pp - 
        dos - 
        band - 
        projwfc - 
        molecularpdos - 
        hp - 
        turbo_davidson -
        turbo_lanczos - 
        turbo_eels - 
        turbo_spectrum {
            # hardcode-supported programs
                            
            set HEAD  [string toupper $head]
            set prog  [auto_execok [::pwtk::getVar_ QEprog($HEAD)]]
            
            if { [remote_mode_] && $remote_exec(rfull) } {
                set prog [remote_execok_ [remote_query_ "::pwtk::getVar_ QEprog($HEAD)"]]
            }       
        }
    }

    # B. if (a) fails try as $QEdir(BIN_DIR)/$program or $QEdir(BIN_DIR)/$head.x

    foreach name [list $program $head.x] {
        if { $prog == "" } {
            set prog [auto_execok [file join [::pwtk::getVar_ QEdir(BIN_DIR)] $name]]
            
            if { [remote_mode_] && $remote_exec(rfull) } {
                set prog [remote_execok_ [file join [remote_query_ {::pwtk::getVar_ QEdir(BIN_DIR)}] $name]]
            }
        }       
    }
    
    # C. if ((a) && (b)) fail try as plain $program or $head.x
    
    foreach name [list $program $head.x] {
        if { $prog == "" } {
            set prog [auto_execok $name]
            
            if { [remote_mode_] && $remote_exec(rfull) } {
                set prog [remote_execok_ $name]    
            }
        }
    }

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

    return $prog
}