TABLE OF CONTENTS


::pwtk::nebi::fprint_old

SYNOPSIS

proc ::pwtk::nebi::fprint_old {{file {}}} {

PURPOSE

Print the content of neb.x input data in old pw.x format (for QE-4.x) either to file or to stdout if the file was not specified.

ARGUMENTS

SOURCE

    ::pwtk::input::pushpop {

        # to make old format work, we need this:
        CONTROL { calculation = 'neb' }
    
        # shift the PATH variables to IONS namelist   
        foreach var [::pwtk::input::namelistVars_ PATH] {
            if { $::pwtk::input::namelist(PATH,var=$var) != "" } {
                IONS " $var = $::pwtk::input::namelist(PATH,var=$var) "
            }
        }
        ::pwtk::input::namelistClear PATH
        
        set first_image 0
        set tot_charge  0
        foreach line [split [get] \n] {
            
            if { [regexp {(BEGIN|END)} $line] } {
                # strip the BEGIN & END keywords
                continue
            }

            if { [regexp FIRST_IMAGE $line] } {
                set first_image 1
                continue
            }

            if { $first_image && [regexp ATOMIC_POSITIONS $line] } {
                append output $line\nfirst_image\n
                set first_image 0
                continue
            }

            if { ! $first_image && [regexp ATOMIC_POSITIONS $line] } {
                # skip ATOMIC_POSITIONS for further images
                continue
            }

            if { [regexp {(INTERMEDIATE_IMAGE|LAST_IMAGE)} $line] } {
                append output [string tolower $line]\n
                continue
            }

            if { [regexp TOTAL_CHARGE $line] } {
                # skip TOTAL_CHARGE keyword-line
                set tot_charge 1
                continue
            } elseif { $tot_charge } {
                # skip TOTAL_CHARGE value
                set tot_charge 0
                continue
            }
            
            append output $line\n    
        }

        if { $file == {} } {
            # print to stdout
            puts stdout $output
        } else {
            if { [::pwtk::backup_io] } {
                ::pwtk::file_backup $file
            }
            ::pwtk::writeFile $file $output
        }
    }
}