TABLE OF CONTENTS
::pwtk::input::namelistAtmSymb2Ityp
SYNOPSIS
proc ::pwtk::input::namelistAtmSymb2Ityp {nmlName varName} { # # USAGE: # ::pwtk::input::namelistAtmSymb2Ityp namelistName VarName
PURPOSE
Transform "ntyp"-type variable by relacing the atomic-label with atomic-index, e.g., "starting_magnetization(Fe)" will be transformed to "starting_magnetization(1)", where 1 is the index of Fe species.
Beware that such a transformation should be done only during the HERE ...
RETURN VALUE
- either: $varName
- or: "$arrayName(atomic-index)" instead of "$arrayName(atomic-label)"
SOURCE
global ::pwtk::ntyp_variables if { [info exists ::pwtk::ntyp_variables($nmlName)] \ && "$::pwtk::ntyp_variables($nmlName)" } { ## BEWARE: for arrays "varName = arrayName(value)" set arrayName [lindex [split $varName \(] 0] set elemName [lindex [split $varName \(\)] 1] if { $elemName == "" } { # variable is not array return $varName } set usedSpecies [::pwtk::pwi::getAtomicLabels] set allSpecies [::pwtk::pwi::getAllAtomicLabels] set ind [lsearch $usedSpecies $elemName] if { $ind == -1 } { if { [lsearch $allSpecies $elemName] > -1 } { # we have variable(AtomicLabel), but the atomic label is # not used; filter it out, i.e., return nothing return "" } else { # perhaps we have variable(atomicLabel) and # atomicLabel is not even defined; note that Fortran # arrays use numeric indices, whereas atomicLabel is a # string, hence filter out variable(atomicLabel) is # atomicLabel is not a numeric index. # # BEWARE: Fortran indices can be "1,2" or "-1:5,-3:+4" ! # set parsed [regsub -all {[,:+-]} $elemName {}] if { ! [string is integer $parsed] } { return "" } } } elseif { $ind > -1 } { incr ind return $arrayName\($ind\) } } return $varName }