TABLE OF CONTENTS


::pwtk::pwo::getXSFPrimCoor

SYNOPSIS

proc ::pwtk::pwo::getXSFPrimCoor {flag pwoFile {anim_index ""}} {

DESCRIPTION

Return the XSF-formatted atoms (PRIMCOORD section) from the pw.x output file, i.e.:

      PRIMCOORD
        nat 1
        AtmSymb1 x1 y1 z1
        AtmSymb2 x2 y2 z2
        ...

ARGUMENTS

SOURCE

    set output [::fileutil::tempfile xsf.]
    
    set  pwo2xsf [::pwtk::getExecutable [::pwtk::getVar_ PWO2XSF]]
    if { $pwo2xsf eq {} } {
        ::pwtk::error "cannot find the PWO-to-XSF (aka pwo2xsf.sh) converter" 1
    }

    exec -- $pwo2xsf $flag $pwoFile > $output
    
    set xsf    [split [::pwtk::readFile $output] \n]
    set ind    [lsearch $xsf *PRIMCOOR*]
    set natoms [lindex [lindex $xsf [expr {$ind + 1}]] 0]

    set    coor "PRIMCOORD $anim_index\n"
    append coor "[lindex $xsf [expr {$ind + 1}]]\n"
    append coor "[join  [lrange $xsf [expr {$ind + 2}] [expr {$ind + 2 + $natoms}]] \n]"
    return $coor
}