TABLE OF CONTENTS


1X-data-stack

DESCRIPTION

This example demonstrates the PWTK's data-stacking mechanism. It is an ugly example but it demonstrates which items are included in the data-stacking mechanism.

PWTK "keeps" the following data on the stack:

1. input data for all supported QE programs

2. how to run QE programs, i.e., specs specified with: ::pwtk::nice, ::pwtk::container, ::pwtk::prefix, ::pwtk::serial_prefix, ::pwtk::postfix, ::pwtk::serial_postfix, ::pwtk::input_handle

3. directories, specified with: ::pwtk::bin_dir, ::pwtk::pseudo_dir, ::pwtk::outdir, ::pwtk::outdir_prefix, ::pwtk::outdir_postfix, ::pwtk::wfcdir, ::pwtk::wfcdir_prefix, ::pwtk::wfcdir_postfix

4. pathnames of all supported QE programs, specified with: ::pwtk::prog

5. on|off behavior, specified with: ::pwtk::stopOnError, ::pwtk::restart, ::pwtk::bin_query, ::pwtk::backup_io, plugins (e.g. ::pwtk::environ::environ, ::pwtk::artn::artn, ::pwtk::oscdft::oscdft)

6. run modifiers, specified with: ::pwtk::remedy, ::pwtk::prerun, ::pwtk::postrun, ::pwtk::treatrun

EXAMPLE SOURCE FILE

data-stack.pwtk

SOURCE

# import two auxiliary routines implemented for this example
import data-stack-aux.pwtk

# import the input data for pw.x with ::pwtk::pwi::load_fromPWI
load_fromPWI scf.Cu.in


#
# at this point, we have STATE #0
#

# save the current pw.x input data into pw-0.in with 'pwi_fprint' (a
# shortcut to ::pwtk::pwi::fprint) for latter comparison

pwi_fprint pw-0.in

# save current PWTK state for latter comparison
#
# N.B. 'saveState' is an auxilirary proc from data-stack-aux.pwtk,
#      implemented for the purpose of this example

saveState 0


# let's use 'input_pushpop', which is a shortcut to
# ::pwtk::input::pushpop, and modify some data

input_pushpop {
    # 1. modify pw.x input data
    SYSTEM {
        ecutwfc = 50.0
        ecutrho = 8*50.0
    }
    
    # 2. modify run options
    prefix  mpiexec -np 128
    postfix -npool 4

    # 3. modify directories
    outdir /scratch/QE
    pseudo_dir ~/QE/pw/pseudo

    # 4. modify "behavior"
    bin_query off
    restart on
    stopOnError off
    environ on
    
    # 5. modify QE programs
    prog pw.x ~/bin/pw.x
    prog pp.x ~/bin/pp.x

    # 6. run modifiers
    treatrun runPW rerunPW
    
    #
    # at this point, we have STATE #1
    #

    # for comparison, save the current pw.x input data into pw-1.in
    pwi_fprint pw-1.in

    # for comparison, save the current PWTK state
    saveState 1
    
    printTitle "Difference between the states #0 and #1"
    
    # compare the the pw-0.in and pw-1.in input files
    print "\nDifference between the pw-0.in and pw-1.in input files:\n"
    puts [try_exec -i diff pw-0.in pw-1.in]\n

    # compare the state #0 vs #1
    print "\nDifference between the states #0 and #1:\n"
    compareStates 0 1
    print {}
    
}
# all modification made inside input_pushpop {...} are gone,
# let's check this is so

#
# at this point, we have STATE #2
# (which is identical to STATE #0)
#

# save the pw.x input data into pw-2.in
pwi_fprint pw-2.in

# save the current PWTK state
saveState 2

print "
### AFTER input_pushpop ###

All modification made inside the 'input_pushpop' were removed, i.e.,
the state was reverted from #1 back to #0. Hence, the new state #2 is
identical to state #0.

Let's check this is really so.
"

printTitle "Difference between the states #0 and #2"

print "\nDifference between the pw-0.in and pw-2.in input files:
(N.B. empty printout implies no difference)"
puts [try_exec -i diff pw-0.in pw-2.in]

# compare the states #0 & #2
print "\nDifference between the states #0 and #2:
(N.B. empty printout implies no difference)"
compareStates 0 2