TABLE OF CONTENTS


::pwtk::run_fromPWO

SYNOPSIS

proc ::pwtk::run_fromPWO {engine args} {

USAGE

   run_fromPWO engine [options] pwoFile

 more specifically:

   run_fromPWO engine ?-fix_first n?  ?-fix_last n?  ?-fix indexList?  ?-fix_string fixString? \
                      ?-head headName?   ?-cell?  pwoFile

PURPOSE

Load the structure from the PWO file and make a pw.x or cp.x calculation, depending on the 'engine' specs, i.e.:

OPTIONS

ARGUMENTS

RETURN VALUE

The name of the pw.x output file, i.e., type.head.out, where type is the value of the CONTROL's "calculation" variable (scf, relax, mv-relax...) and head is the rootname of either the pwo-file or the argument of the -head option.

SIDE EFFECTS

"prefix", "outdir_postfix", and "nat" are set to appropriate values.

SOURCE

    # check the engine argument
    engine_

    # parse options

    set narg 1
    set usage "engine ?-fix_first n?  ?-fix_last n?  ?-fix indexList?  ?-fix_string fixString?  ?-head headName?  ?-cell? pwoFile"
    set options {
        {fix_first.arg  {}  "fix the first Nfirst atoms, i.e., atoms from 1 to Nfirst"}
        {fix_last.arg   {}  "fix the last Nlast atoms, i.e., atoms from N-Nlast+1 to N"}
        {fix.arg        {}  "list of atoms to fix"}
        {fix_string.arg {0 0 0} "fix string"}
        {head.arg       {} "head-name for the pw.x|cp.x I/O files"}
        {cell              "load also CELL_PARAMETERS from the PWO file (default = only coordinates)"}
    }
    parseOpt_
    checkOType_ -fix_first $opt(fix_first) {number posint}      "positive integer"
    checkOType_ -fix_last  $opt(fix_last)  {number posint}      "positive integer"
    checkOType_ -fix_last  $opt(fix)       {numberlist posint}  "list of positive integer numbers"
    checkOType_ -fix_last  $opt(fix_string) {numberlist binary} "list of binary integers (0|1)"
    
    # load PWO file
    
    set pwoFile $args
    ::pwtk::fileMustExist $pwoFile "pw.x output"

    # head-name of I/O files
    
    set head [file tail [::pwtk::headname $pwoFile .out]]
    if { $opt(head) != "" } {
        set head $opt(head)
    }

    # load the structure from the PWO file
        
    if { $opt(cell) } {
        ::pwtk::print [procName] "Loading CELL_PARAMETERS & ATOMIC_POSITIONS from PWO file: $pwoFile\n"
        ::pwtk::pwi::CELL_PARAMETERS_and_ATOMIC_POSITIONS_fromPWO $optalat $pwoFile
    } else {
        ::pwtk::print [procName] "Loading ATOMIC_POSITIONS from PWO file: $pwoFile\n"
        ::pwtk::pwi::ATOMIC_POSITIONS_fromPWO $pwoFile
    }

    # fix atoms
        
    if { $opt(fix_first) != {} } {
        ::pwtk::pwi::fixAtoms1st $opt(fix_first) $opt(fix_string)
    }
    if { $opt(fix_last) != {} } {
        ::pwtk::pwi::fixAtomsLast $opt(fix_last) $opt(fix_string)
    }
    if { $opt(fix) != {} } {
        ::pwtk::pwi::fixAtoms $opt(fix) $opt(fix_string)
    }

    # determine the rootname for I/O files
    
    set type [::pwtk::input::namelistGetVarValue CONTROL -nocase calculation trim]
    ::pwtk::ifset type scf        
    set prefix [regsub "^$type\." $head {}]; # scf.|relax.|vc-relax. stripped
    set head $type.$prefix

    # run the calculation

    outdir_postfix $prefix
    CONTROL " prefix = '$prefix' "    
    $runCmd $head
    
    return $head.out
}