TABLE OF CONTENTS


::pwtk::pwi::getAtmPos

SYNOPSIS

proc ::pwtk::pwi::getAtmPos {{path_allowed 0}} {

PURPOSE

Get verbatim atomic positions from the pw.x ATOMIC_POSITIONS card, i.e.:

     AtmSy1  x1 y1 z1  [if_pos(1) if_pos(2) if_pos(3)]
     AtmSy2  x2 y2 z2  [if_pos(1) if_pos(2) if_pos(3)]
     ....

For path calculation of very old pw.x (prior to neb.x) and if 'path_allowed' == 1, it returns:

     first_image
     AtmSy1  x1 y1 z1  [if_pos(1) if_pos(2) if_pos(3)]
     AtmSy2  x2 y2 z2  [if_pos(1) if_pos(2) if_pos(3)]
     ...

ARGUMENTS

RETURN VALUE

SOURCE

    set coor [::pwtk::input::cardGetContent ATOMIC_POSITIONS]    
    set nl ""
    set new_coor ""
    
    foreach line [split $coor \n] {
        if { [string match -nocase {*first_image} $line] && ! $path_allowed} {
            ::pwtk::error "::pwtk::pwi::getAtmPos works only for non-path type input" 1
        }

        # purify the empty lines (check for syntax errors as well)

        set len [llength $line]

        # can be:  atmSybm  x y z
        # or:      atmSymb  x y z  if_pos(x) if_pos(y) if_pos(z)
        
        if { $path_allowed && [string match *_image* $line] } {
            append new_coor ${nl}${line}
            set nl "\n"     
        } elseif { $len == 4 || $len == 7 } {
            append new_coor ${nl}${line}
            set nl "\n"
        } elseif { $len > 0 } {
            # it's not an empty line --> SYNTAX error
            ::pwtk::error "syntax error in ATOMIC_POSITIONS card, line = $line" 1
        }
    }
    
    return $new_coor
}