TABLE OF CONTENTS


::pwtk::phi::load_fromPHI

SYNOPSIS

proc ::pwtk::phi::load_fromPHI {phi {clear_existing 1}} {

PURPOSE

Load the input data from existing ph.x input file.

If clear_existing == 1, then the current input will be cleared, but otherwise the data will be simply added to the existing data.

ARGUMENTS

SOURCE

    ::pwtk::fileMustExist $phi "ph.x input"

    if { [::pwtk::is_true $clear_existing] } {
        # clear the current ph.x input data ...
        ::pwtk::phi::clear
    }
    
    set fid [open $phi r]

    # check if the first line is the title line
    set line    [::pwtk::getNonEmptyLine $fid]
    set word1st [::pwtk::firstWord $line]
    
    if { [string match -nocase &INPUTPH $word1st] } {
        # it's an INPUTPH namelist, rewind $fid
        seek $fid 0 start
    } else {
        ::pwtk::input::card PH.titleLine $line
    }

    # ph.x input file must contain the INPUTPH namelist

    if { [catch {set nml [::pwtk::readNml $fid INPUTPH]}] } {
        ::pwtk::error "input file \"$phi\" does not appear to be a ph.x input file" 1
    }    
    eval $nml
    
    # read the rest of the ph.x input file
    while { ! [eof $fid] } {
        ::pwtk::input::cardAppend PH.affixCards [gets $fid]
    }
    close $fid
}