TABLE OF CONTENTS


::pwtk::xsf::getPrimCoor

SYNOPSIS

proc ::pwtk::xsf::getPrimCoor {xsfFile {purify 0}} {

PURPOSE

Return the primitive atomic positions from XSF file (PRIMCOORD section), i.e.:

        AtmSymb1 x1 y1 z1
        AtmSymb2 x2 y2 z2
        ...

SOURCE

    #variable coor_unit

    set xsfList [split [::pwtk::skipEmptyLines [::tclu::readFile $xsfFile]] \n]
    set ind     [lsearch $xsfList *PRIMCOOR*]
    set nat     [lindex [lindex $xsfList [expr {$ind + 1}]] 0]

    if { $ind > -1 } {
        set coor [join [lrange $xsfList [expr {$ind + 2}] [expr {$ind + $nat + 1}]] \n]
        # temporary_begin: capitalize atmSymb
        foreach line [split $coor \n] {
            set atmSymb [string totitle [lindex $line 0]]
            set coor    [lrange $line 1 3]
            append new_coor "$atmSymb   $coor\n"
        }
        return $new_coor
        # temporary_end
    } else {
        ::pwtk::error "$xsfFile is not an XSF file"
    }
    return ""
}