TABLE OF CONTENTS


::pwtk::restart_fromIO

SYNOPSIS

proc ::pwtk::restart_fromIO {engine args} {

USAGE

    restart_fromIO engine [OPTIONS] HEAD ?FILE.in? ?FILE.out?

 more specifically:
 
   restart_fromIO pw.x|cp.x  ?-true_restart 0|1?  ?-clear 0|1?  ?-cell?  HEAD  ?FILE.in?  ?FILE.out?

PURPOSE

Restart calculation from the I/O files, where:

This command restarts a calculation from the specified input and output files, i.e., input data are read from the input file, whereas CELL_PARAMETERS and ATOMIC_POSITIONS are loaded from the output file; CELL_PARAMETERS are loaded only if found in the output file.

OPTIONS

ARGUMENTS

SIDE EFFECTS

None. Data loading and calculation is performed within input_pushpop { ... }

RETURN VALUE

The name of the new output file.

SOURCE

    # check the engine argument
    engine_

    # parse options
    set nargmin 1
    set nargmax 3
    set usage "engine ?-true_restart 0|1?  ?-clear 0|1?  head  ?file.in?  ?file.out?"
    set options {
        {true_restart.arg  0  "perform true restart with restart_mode = 'restart'"}
        {clear.arg         1  "use just the input variables from the specified input file"}
        {cell                 "enforce the use of CELL_PARAMETERS from the pw.x output file"}
    }
    parseOpt_
    checkOTypeStrict_ -true_restart $opt(true_restart) boolean
    checkOTypeStrict_ -clear        $opt(clear) boolean

    
    # assign head, inp, out
    lassign $args head inp out
    ifset inp $head.in 
    ifset out [::pwtk::headname $inp].out 

    # check if $inp & $out exist; if not try with $type.$inp & $type.$out
    set calc [::pwtk::input::namelistGetVarValue CONTROL -nocase calculation trim]
    if { ! [file exists $inp] && [file exists $calc.$inp] } {
        set head $calc.[regsub "^$calc\." $head {}]
        set inp  $calc.$inp
    }
    if { ! [file exists $out] && [file exists $calc.$out] } { set out $calc.$out }    
    
    # do the job    
    input_pushpop {        
        ::pwtk::print [procName] "Loading input data from $inp"
        switch -nocase -- $engine {
            pw - pw.x { ::pwtk::pwi::load_fromPWI $inp $opt(clear) }
            cp - cp.x { ::pwtk::cpi::load_fromCPI $inp $opt(clear) }
        }
        if { [regexp ^vc- $calc] || $opt(cell) } {
            ::pwtk::print [procName] "Loading CELL_PARAMETERS & ATOMIC_POSITIONS from '$out'\n"
            ::pwtk::pwi::CELL_PARAMETERS_and_ATOMIC_POSITIONS_fromPWO $out
        } else {
            ::pwtk::print [procName] "Loading ATOMIC_POSITIONS from '$out'\n"
            ::pwtk::pwi::ATOMIC_POSITIONS_fromPWO $out
        }
        if { $opt(true_restart) } {
            re$runCmd $head
        } else {
            CONTROL " restart_mode = "
            $runCmd -append $head
        }
    }
    return $head.out
}