TABLE OF CONTENTS
::pwtk::remedy
SYNOPSIS
proc ::pwtk::remedy {prog {mode {}} {script {}}} {
USAGE
The allowed forms are: remedy PROG remedy PROG { SCRIPT } \___ these two are synonymous remedy PROG set { SCRIPT } / remedy PROG append { SCRIPT } remedy PROG get remedy PROG exec remedy PROG clear Where: * remedy PROG -- query if the remedy mode is active for the PROG executable * remedy PROG get -- get the remedy script * remedy PROG { SCRIPT } -- set the remedy script * remedy PROG set { SCRIPT } -- set the remedy script * remedy PROG append { SCRIPT } -- append to remedy script * remedy PROG exec -- execute a remedy script * remedy PROG clear -- clear the remedy script (i.e. turn remedy off)
DESCRIPTION
A simple one-attempt remedy mode (for a more elaborate remedy-mode for pw.x, see: ::pwtk::runPW_remedy). If a given PROG QE calculation fails, it will be retried by first executing a "remedy" script and then repeating the calculation. The "remedy" script is executed in the pushpop mode. Hence, after the remedy completion, the PWTK state is the same as before the remedy invocation. The remedy logic is as follows:
if calculation failed { input_pushpop { eval remedyScript repeat the failed calculation } }
ARGUMENTS
- PROG -- the canonical name of the QE executable (e.g. pw.x, ph.x)
- MODE -- one of: get, set, append, clear
- SCRIPT -- remedy script
RETURN VALUE
- remedy get ... returns the remedy script (or empty string if remedy is inactive)
- otherwise: 0 or 1 (1 = remedy is active; 0 = remedy is inactive)
SOURCE
variable state if { $mode eq "" } { # query mode ifempty state(remedy,$prog) { return 0 } else { return 1 } } switch -exact -- $mode { get { ifexist state(remedy,$prog) { return $state(remedy,$prog) } else { return {} } } set { set state(remedy,$prog) $script\n return 1 } append { append state(remedy,$prog) $script\n return 1 } exec { ifnotempty state(remedy,$prog) { eval $state(remedy,$prog) return 1 } else { return 0 } } clear { unset state(remedy,$prog) return 0 } default { if { $script eq {} } { # it is: remedy PROG { SCRIPT } # hence the "MODE" argument is the "SCRIPT" set state(remedy,$prog) $mode\n return 1 } else { # wrong usage ::pwtk::error "wrong mode \"$mode\", must be one of set, append, clear" 1 } } } # should not come here return 0 }