1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
namespace eval ::helpdoc {}
# Purpose: definition of QE modules that PWgui knows about
proc ::helpdoc::core_modules {} {
variable mod_def_mappings
# this is the list of "core" mod_def_mappings, i.e., modules (QE
# programs) which the PWgui knows
set mod_def_mappings {
pw PW/Doc INPUT_PW
neb NEB/Doc INPUT_NEB
ph PHonon/Doc INPUT_PH
pp PP/Doc INPUT_PP
projwfc PP/Doc INPUT_PROJWFC
bands PP/Doc INPUT_BANDS
dos PP/Doc INPUT_DOS
atomic atomic/Doc INPUT_LD1
hp HP/Doc INPUT_HP
}
}
###
# Purpose: print the usage message for utility programs that requires "$0 module" execution
proc ::helpdoc::prog_module_usage {} {
global argv0
puts stderr "
Usage: $argv0 module
Where module is one of:
[::helpdoc::get_supported_modules]
"
exit 1
}
# Purpose: get a list of all modules that PWgui supports
proc ::helpdoc::get_supported_modules {} {
variable mod_def_mappings
if { ! [info exists mod_def_mappings] } {
core_modules
}
set modules ""
foreach {mod subdir def_prefix} $mod_def_mappings {
lappend modules $mod
}
return $modules
}
##
# Purpose: get the pathname of INPUT_XX.def file from the module name
proc ::helpdoc::get_def_filename {module {must_exists 1}} {
variable mod_def_mappings
global topdir
if { ! [info exists topdir] } {
puts stderr "variable \"topdir\" does not exist; define it before calling get_def_filename"
exit 1
}
if { ! [info exists mod_def_mappings] } {
core_modules
}
set deffile ""
foreach {mod subdir def_prefix} $mod_def_mappings {
if { $mod == $module } {
set deffile [file join $topdir $subdir $def_prefix.def]
}
}
if { $must_exists == 1 && "$deffile" eq {} } {
puts stderr "\[failed\]
module \"$module\" is not defined by \"mod_def_mappings\" variable,
list of defined modules:
[get_supported_modules]
"
exit 1
}
return $deffile
}
##
# Purpose: get the pathname of PWgui's module file from the module name
proc ::helpdoc::get_gui_module_filename {module {must_exists 1}} {
variable mod_def_mappings
global moduledir
if { ! [info exists moduledir] } {
puts stderr "variable \"moduledir\" does not exist; define it before calling get_def_filename"
exit 1
}
if { ! [info exists mod_def_mappings] } {
core_modules
}
set modfile ""
foreach {mod subdir def_prefix} $mod_def_mappings {
if { $mod == $module } {
set modfile [file join $moduledir $mod $mod.tcl]
}
}
if { $must_exists == 1 && "$modfile" eq {} } {
puts stderr "\[failed\]
module \"$module\" is not defined by \"mod_def_mappings\" variable,
list of defined modules:
[get_supported_modules]
"
exit 1
}
return $modfile
}
|