TABLE OF CONTENTS


::pwtk::nebi::fixAtoms_inPATH

SYNOPSIS

proc ::pwtk::nebi::fixAtoms_inPATH {pathFile_or_pathContent} {

PURPOSE

Revamp the content of the neb.x PATH file such that the fixAtoms if_pos(*) fields correspond to the currently stored neb.x input POSITIONS data.

BEWARE

This routine leaves the pathFile intact, but instead returns the content of the revamped PATH file.

ARGUMENT

RETURN VALUE

The content of the revamped PATH file.

SOURCE

    if { [file exists $pathFile_or_pathContent] } {
        set pathContent [::pwtk::readFile $pathFile_or_pathContent]
    } else {
        set pathContent $pathFile_or_pathContent
    }

    ::pwtk::nebi::positions2data_ data

    # read path file & fix atoms according to the current NEBI data

    set im 0
    foreach line [split $pathContent \n] {
        if { [lindex $line 0] eq "Image:" } {
            set im [lindex $line 1]
        }
        if { $im == 1 } {
            if { [llength $line] == 9 } {
                incr nat
                ::pwtk::ifset data(ix,1,$nat) 1
                ::pwtk::ifset data(iy,1,$nat) 1
                ::pwtk::ifset data(iz,1,$nat) 1

                # fmt  = "(3(2X,F18.12),3(2X,F18.12),3(2X,I1))"
                set line [format {  %18.12f  %18.12f  %18.12f  %18.12f  %18.12f  %18.12f  %1d  %1d  %1d} {*}[lrange $line 0 5] $data(ix,1,$nat) $data(iy,1,$nat) $data(iz,1,$nat)]
            }
        }
        append new_path $line\n
    }
    ::pwtk::ifnotexist new_path {
        ::pwtk::error "expected a PATH file or a PATH content, but got:\n$pathFile_or_pathContent" 1
    }

    return $new_path
}