# File to provide interfaces to both the result reader and to the
# output translators for the CATIA V5 <--> ICEMCFD Gateway
#

# Initialize the gateway -- read in guibase files, setup guibase globals
# and find BWidget package

proc ICC_gateway_initialize {{is_batch 0}} {
    global guibase_dir_list ICC_gateway has_blt guibase_dir
    global botform_geo
    
    set botform_geo -0-0
    if ![info exists has_blt] {
	if {[info commands blt::table] == "" &&
	    [info proc blt_table] == ""} {
	    set has_blt 0
	} else {
	    set has_blt 1
	}
    }
    
    if {!$is_batch} {
	
	# Now initialize BWidget
	
	set bwl [package require BWidget 1.3]
	if ![regexp "can't find package" $bwl] {
	    set ICC_gateway(BWidget) 1
	} else {
	    set ICC_gateway(BWidget) 0
	    
	    # last ditch gultch on this -- try for a specific directory
	    
	    foreach gd $guibase_dir_list {
		set bwd [glob -nocomplain $gd/\{bw,BW\}idget* \
			     $gd/../\{bw,BW\}idget*]
		foreach sd $bwd {
		    lappend auto_path $sd
		}
	    }
	    
	    set bwl [package require BWidget 1.3]
	    if ![regexp "can't find package" $bwl] {
		set ICC_gateway(BWidget) 1
	    }
	}
    }
    
    catch {unset guibase_dir}
    foreach f {
	toplevel
	bocofile
	bltemu
	bubble
	checkbox
	choose_one
	cursors
	dialog
	exec_cmds
	family_boco
	fileselect
	forms
	formutil
	help
	misc
	my-dialog
	my-tkerror
	pathentry
	settings
	sizes
	my-tkerror
	readers
	run_application
    } {
	set found 0
	foreach gd $guibase_dir_list {
	    if [file exists $gd/$f.tcl] {
		
		# this is necessary to prevent evaluation of $gd 2 times
		# because of windows the \ in file name.  Could also use
		# file nativename, but there is a version issue with this
		
		set ICC_gateway(tempfile) $gd/$f.tcl
		set stat [catch {uplevel \#0 \
				     {source $ICC_gateway(tempfile)}} msg]
		if !$stat {
		    set found 1
		    
		    if ![info exists guibase_dir] {
			set guibase_dir $gd
		    }
		    break
		} else {
		    # puts "$gd/$f.tcl - $msg"
		}
	    }
	}
	if !$found {
	    error "File $f.tcl not found in \"$guibase_dir_list\""
	}
    }
    
    if {!$is_batch} {
	compute_sizes
    }
    
    # do this after source all of the guibase files
    
    proc mess {args} {
	global ICC_gateway
	if $ICC_gateway(rf_debug) {
	    puts "[lindex $args 0]"
	}
    }
    
    set ICC_gateway(initialized) 1
}

proc busy {on} {}

# Find result reader

proc ICC_gateway_reader {reader line} {
    global ICC_gateway batch_mode

    set batch_mode 1
    if ![info exists ICC_gateway(initialized)] {
	ICC_gateway_initialize
    }
    
    if ![info exists ICC_gateway(unstruct)] { set ICC_gateway(unstruct) 1 }
    if ![info exists ICC_gateway(reader)] { set ICC_gateway(reader) $reader }
    if ![info exists ICC_gateway(files)] { set ICC_gateway(files) "" }
    if ![info exists ICC_gateway(prec)] { set ICC_gateway(prec)  1 }
    if ![info exists ICC_gateway(tstep)] { set ICC_gateway(tstep) 0 }
    if ![info exists ICC_gateway(args)] { set ICC_gateway(args)  "" }

    set key [v3readers_available]
    set rlist ""
    foreach a $key {
        set stats [lindex $a 1]
        lappend rlist [lindex $stats 0]
    }

    if {$reader == "" || $reader == "__noreader__"} {
	set batch_mode 0
	#set buts {Accept cancel}
	set d [form_init .backimp "CATIAV5 Gateway Solver Reader"]
	if {$d != ""} {

	    form_label $d.backl "Reader:" {0 0}
	    futil_menuentry $d.back ICC_gateway(reader) "list $rlist" {0 1}
	    form_finish +300+300
	}
	if ![form_wait .backimp] { return [list 1 ""] }
    } else {
	set ICC_gateway(reader) $reader
    }

    set desc [v3reader_backenddesc_for $ICC_gateway(reader)]
    # puts "desc = $desc, reader = $ICC_gateway(reader)"
    if {$desc == ""} { return "" }

    # see if we need to set the line
    
    if {$line == "" || $line == "__noline__"} {
	set batch_mode 0
	set line ""
	set setup_proc [lindex $desc 0]_setup_input
	set ICC_gateway(backend) [v3reader_backend_for $ICC_gateway(reader)]
	# puts "setup_proc = $setup_proc"
	set status [catch {set line [$setup_proc $ICC_gateway(backend) \
					 "unknown" ""]} msg]
	if $status { error $msg }
	if {$line == ""} { set status 1 }
    } else {
	set status 0
    }
    return [list $status $line]    
}

# parse result of reader

proc ICC_reader_line {line outfile} {
    global ICC_gateway
    
    # puts "line = $line, outfile = $outfile"
    set stat [lindex $line 0]
    if !$stat {
	set arglist [lindex $line 1]
	set ns [llength $arglist]
	for {set i 0} {$i < $ns} {incr i} {
	    set ICC_gateway([lindex $arglist $i]) [lindex $arglist [incr i]]
	}
    }
    set ofile [open $outfile w]
    puts $ofile $ICC_gateway(startup_files)
    puts $ofile $ICC_gateway(backend)
    puts $ofile $ICC_gateway(other_result_files)
    puts $ofile $stat
}

# ---- Import scripts

proc ICC_gateway_initimport {match_file} {
    global guibase_dir_list guibase_dir ICC_gateway
    
    catch {unset guibase_dir}
    foreach f {
	readers
    } {
	set found 0
	foreach gd $guibase_dir_list {
	    if [file exists $gd/$f.tcl] {
		
		# this is necessary to prevent evaluation of $gd 2 times
		# because of windows the \ in file name.  Could also use
		# file nativename, but there is a version issue with this
		
		set ICC_gateway(tempfile) $gd/$f.tcl
		set stat [catch {uplevel \#0 \
				     {source $ICC_gateway(tempfile)}} msg]
		if !$stat {
		    set found 1
		    
		    if ![info exists guibase_dir] {
			set guibase_dir $gd
		    }
		    break
		} else {
		    puts "$gd/$f.tcl - $msg"
		}
	    }
	}
	if !$found {
	    error "File $f.tcl not found in \"$guibase_dir_list\""
	}
    }
    
    v3reader_match_init $match_file
    set ICC_gateway(importinit) 1
}

proc ICC_gateway_matchresult {solvekey variable_list info reqtype tempfile} {
    global ICC_gateway
    
    if {![info exists ICC_gateway(importinit)] ||
	!$ICC_gateway(importinit)} {
	ICC_gateway_initimport ""
    }
    
    set ret [v3reader_varlist_match $solvekey $variable_list $info $reqtype]
    if {$tempfile != ""} {
	set fp [open $tempfile w]
	foreach desc $ret {
	    # fixed name has no spaces in it, but matched name might
	    # below fixes format of line
	    puts $fp "[lindex $desc 0] \{[lindex $desc 1]\}"
	}
	close $fp
    }
    return $ret
}

# hooky implementation of this function.  Can do better

proc v3p_domain_types {file} {
    set ext [file extension $file]
    if {$ext == "domain" || $ext == "uns"} {
	return "ok"
    }
    return "bad"
}

# Output translator top-level proc

proc ICC_gateway_output {solver args} {
    global file_name batch_mode auto_path famboco_obj ICC_gateway
    
    # no objects here, just use ICC_famboco_obj as clearing house
    # for all family object commands
    
    set famboco_obj "ICC_famboco_obj"
    
    # see if the empty string specified as all of the extra
    # arguments
    
    set batch_mode 0
    if {[llength $args] > 0} {
	for {set i 0} {$i < [llength $args]} {incr i} {
	    if {[lindex $args $i] != ""} {
		set batch_mode 1
		break
	    }
	}
	if !$batch_mode { set args "" }
    }
    
    # Select solver if none given
    
    if {$solver == "" || $solver == "__nosol__"} {
	set ret [ICC_gateway_select]
    } else {
	set ret [ICC_gateway_setsolver $solver 1]
    }
    if !$ret {
	error "Problem in Selecting/Setting Solver."
    }
    
    # Delay cleanup until this point so that internal determination
    # of changing solver can cause boco flag to be set to 0
    # With Demo, won't occur
    
    set bocoflag $ICC_gateway(boco_flag)
    if {$bocoflag == 0} {
	ICC_gateway_cleanboco
    }
    
    if {$file_name(family_boco) == "" || \
	    ![file exists $file_name(family_boco)] || \
	    $bocoflag != 2} {
	
	if {$file_name(family_boco) == ""} {
	    set file_name(family_boco) [pwd]/temp.fbc
	}
	if !$ICC_gateway(BWidget) {
	    error "Could not find a suitable BWidget package."
	}
	ICC_init_fam_visible
	if ![geo_famboco_edit] { return 0 }
	ic_boco_save $file_name(family_boco)
    }
    return [ICC_gateway_solutioninput $args]
}

proc ICC_gateway_cleanboco {} {
    global file_name ICC_gateway
    catch {cmd_rm $file_name(family_boco)}
    set ICC_gateway(boco_flag) 0
}

# Select a solver

proc ICC_gateway_select {} {
    global ICC_gateway solution solver_info env

    if ![info exists ICC_gateway(initialized)] {
	ICC_gateway_initialize
    }
       
    if [winfo exists .famboco] {
        return [famboco_set_solver .famboco.main]
    }

    get_solver_info

    if ![info exists solution(solver)] {
	set solution(solver) "Generic"
    }
    
    set ch [choose_one "Select a solver." [lsort [array names solver_info]] \
                $solution(solver)]
    if {$ch == ""} { return 0 }

    return [ICC_gateway_setsolver $ch 1]
}

# Set selected solver

proc ICC_gateway_setsolver {soln getbc} {
    global solution env famboco_edit

    set solveinfo [ICC_solver_info $soln]
    set ch [lindex $solveinfo 0]
    if {$ch == ""} {
        mess "Solver \"$soln\" is unknown\n"
        return 0
    }
    mess "Current solver is $ch\n"

    set si [lindex $solveinfo 1]
    set sol [lindex $si 1]
    set tdir [lindex $si 4]
    set proc ${sol}_write_input

    if ![file exists $tdir/$sol.tcl] {
        if [file exists ./$sol.tcl] {
            set tdir .
        } else {
            error "GUI file for $sol doesn't exist in either . or $tdir"
        }
    }
    uplevel #0 source [list $tdir/$sol.tcl]
    if $getbc {
        puts "F $tdir/$sol.bcinfo"
        if [file exists $tdir/$sol.bcinfo] {
            famboco_load_bcinfo $tdir/$sol.bcinfo
        } elseif [file exists ./$sol.bcinfo] {
            famboco_load_bcinfo ./$sol.bcinfo
        } else {
            famboco_load_bcinfo ""
        }
    }

    set solution(solver) $ch
    set famboco_edit(solver) $ch
    return 1
}

# 

proc ICC_solver_info {sol} {
    global solver_info

    set sol [string trim $sol]
    if {$sol == "Generic"} { set sol "" }
    if {$sol == ""} {
        return [list "" ""]
    }

    if [info exists solver_info($sol)] {
	return [list $sol $solver_info($sol)]
    }

    # see if solver internal name specified
    
    set allargs [array names solver_info]
    foreach extn $allargs {
	set si $solver_info($extn)
	set curn [string trim [lindex $si 1]]
	if {$curn == $sol} {
	    return [list $extn $si]
	}
    }
    return [list "" ""]
}

# ---------------------- Hack until new family_boco.tcl installed
proc famboco_to_schema {file} {
    global famboco_info gateway_categories gateway_bcs gateway_pars
    
    set fp [open $file w]
    set allargs [array names famboco_info]
    
    catch {unset gateway_categories}
    catch {unset gateway_bcs}
    catch {unset gateway_pars}
    
    # first the categories
    
    foreach a $allargs {
	if {[regexp {args,(\w*)} $a dummy name]} {
	    set category __nocategory__
	    if {[info exists famboco_info(category,$name)]} {
		set category $famboco_info(category,$name)
		if {$category == ""} {
		    set category __nocategory__
		}
	    }
	    lappend gateway_categories($category) $name
	}
    }
    
    set md "Meshing directives"
    foreach a $allargs {
	if {[regexp {args,(\w*)} $a dummy name]} {
	    set arglist $famboco_info($a)
	    
	    if [info exists famboco_info(category,$name)] {
		set category $famboco_info(category,$name)
	    } else {
		set category ""
	    }
	    
	    if {$category != $md} {
		set idx 0
		set curbc ""
		foreach arg $arglist {
		    set odinf [famboco_schema_order [lrange $arg 1 end] $idx]
		    lappend curbc $odinf
		    incr idx
		}
		
		set gateway_bcs($name) $curbc
		puts $fp "\"$name\" [llength $curbc]"
		foreach l $curbc {
		    puts $fp $l
		}
	    }
	}
    }
    close $fp
}

proc famboco_schema_order {curarg defidx} {
    foreach {n v} $curarg {
	set $n $v
    }
    
    if {![info exists type]} {
	set type string
    }
    
    if {![info exists default]} {
	set default _nodefault_
    }
    
    if {![info exists title]} {
	set title _notitle_
    }
    
    if {![info exists name]} {
	set name _noname_
    }
    
    if {![info exists pos]} {
	set pos $defidx
    }
    
    if {![info exists collapse]} {
	set collapse 0
    }

    return "$pos \"$name\" $type $collapse \"$title\" \"$default\""
}
# --------------------------- end hack ---------------------------

# create scheme file for choosen solver

proc ICC_gateway_solverscheme {solver schemefile} {
    get_solver_info
    if ![ICC_gateway_setsolver $solver 1] {
	return 0
    }
    famboco_to_schema $schemefile
    
    return 1
}

# invoke translator procedure

proc ICC_gateway_solutioninput {batch_args} {
    global solution env file_name batch_mode
    
    if {$solution(solver) == ""} {
	error "No solver set"
    }

    if { ! [ info exists file_name(family_boco) ] || \
                $file_name(family_boco) == "" || \
                ! [ file exists $file_name(family_boco) ] } {
# need to save family_boco.
	ic_boco_save $file_name(family_boco)
    }
    
    set soln $solution(solver)
    set solveinfo [ICC_solver_info $soln]
    set extn [lindex $solveinfo 0]
    if {$extn == ""} {
	error "Solver \"$soln\" is unknown"
    }
    
    set si [lindex $solveinfo 1]
    set sol [lindex $si 1]
    set program [lindex $si 2]
    set tdir [lindex $si 4]
    set proc ${sol}_write_input
    if {[info procs $proc] == ""} {
	if ![file exists $tdir/$sol.tcl] {
	    error "GUI file for $solver doesn't exist"
	}
	uplevel #0 source [list $tdir/$sol.tcl]
    }
    
    # Now we have to do tricks to get the old solver files to work
    global place current_solver ${sol}_output_path icem_powermesh confname
    global solver s2u_path superdomain_path merge_unstr_path icem_fluent
    
    set solver $solution(solver)
    set current_solver $sol
    if ![string compare $tdir $env(ICEM_ACN)/icemcfd/output-interfaces] {
	set prog [get_program icemcfd/output-interfaces $program]
    } else {
	set prog $tdir/$program
    }
    set ${sol}_output_path $prog
	
    if [catch {set s2u_path [get_program icemcfd str_to_unstr]} res] {
	mess "Warning: $res\n" red
    }
    if [catch {set superdomain_path [get_program icemcfd supdomain]} res] {
	mess "Warning: $res\n" red
    }
    if [catch {set merge_unstr_path [get_program icemcfd merge_unstr]} res] {
	mess "Warning: $res\n" red
    }
    set icem_powermesh 0
    set icem_fluent 0
    set place $file_name(project_dir)
    set confname [file tail [file dirname $file_name(project_dir)]]
    if {($confname == "icemcfd") || ($confname == "mulcad") || \
            ($confname == "") || ($confname == ".")} {
        set confname [file tail $file_name(project_dir)]
    }

    busy 1
    set res [eval $proc $batch_args]
    busy 0
    mess "Done with translation.\n"
    return [list 1 $res]
}

proc ICC_gateway_solutioninput_batch {soln batch_args} {
    global solution file_name
    
    if { ! [ info exists file_name(family_boco) ] || \
                $file_name(family_boco) == "" || \
                ! [ file exists $file_name(family_boco) ] } {
	error "No family boco file"
    }
    
    get_solver_info
    set solveinfo [ICC_solver_info $soln]
    set solver [lindex $solveinfo 0]
    if {$solver == ""} {
	error "Solver \"$soln\" is unknown"
    }
    
    set solution(solver) $solver
    set si [lindex $solveinfo 1]
    set sol [lindex $si 1]
    
    set solvbatcharg gateway_${sol}_batchargs
    if {[info proc $solvbatcharg] == ""} {
	error "Must use tk gui method for solver \"$solver\""
    }

    set batch_args [$solvbatcharg $batch_args]
    set ret [ICC_gateway_solutioninput $batch_args]
}

#
# Fam desc : 0 family 1 id number 2 all valid dims as list (0, 1, 2, 3)
#

proc ICC_init_fam_visible {} {
    global fam_visible ICC_gateway
    
    catch {unset fam_visible}
    foreach famdesc $ICC_gateway(famdesc) {
	set fam_visible([lindex $famdesc 0]) 1
    }
}

# Find specified family id

proc ICC_findfam {fam} {
    global ICC_gateway
    
    foreach famdesc $ICC_gateway(famdesc) {
	if {$fam == [lindex $famdesc 0]} { return $famdesc }
    }
    return ""
}

# save the family boco file

proc ICC_save_family_boco {file comment} {
    global whoami
    
    set whoami $comment
    famboco_save $file
}

# backstop so we can find all callbacks that use family boco object

proc ICC_famboco_obj {args} {
    error "Called famboco_obj with $args"
}

proc ICC_dummy {args} {}

# Replacements for family boco loading in med

# Top level to edit boundary condition values

proc geo_famboco_edit {} {
    global solution famboco_info famboco_data
    global fam_visible file_name solution
    
    ICC_init_fam_visible
    if ![ic_boco_is_loaded] {
	if {[info exists file_name(family_boco)] && \
		[file_is_family_boco $file_name(family_boco)]} {
		mess "Loading family boco file $file_name(family_boco)\n"
		ic_boco_load $file_name(family_boco)
	        set file_name(family_boco_loaded) 1
	}
    }

    if {"" == $solution(solver)} {
	set solution(solver) Generic
    }

    return [famboco_edit $solution(solver) ICC_dummy]
}

# Load specified family boco file

proc ic_boco_load {file} {
    famboco_load $file
}

# Return current solver

proc ic_boco_solver {} {
    global solution
    return $solution(solver)
}

# Save Boundary conditions into specified file

proc ic_boco_save {file} {
    set comment "ICEMCFD CatiaV5 Gateway [cmd_date]"
    ICC_save_family_boco $file $comment
    mess "Saved family boco data to $file\n"
}

#  interface procs in med

proc ic_write_file {name text} {
    set fp [open $name w]
    puts -nonewline $fp $text
    close $fp
}

proc cmd_date {} {
    return [clock format [clock seconds]]
}

proc runcom {cmd { catfile "" } } {
    
    mess "Running: $cmd\n"
    busy 1
    set msg [eval exec $cmd]
    mess $msg\n blue
    busy 0
    mess Done\n
}

proc ic_run_application_exec {dir progdir progname arguments } {
    set olddir [pwd]
    if [catch {cd $dir} res] {
        mess "Can't change directory: $res\n"
    }
    if {$progdir == ""} {
        set app $progname
    } else {
        set app [get_program $progdir $progname]
    }
    catch {
        run_application_exec "$app $arguments"
    } res
    cd $olddir
    return $res
}

proc domain_select {dir message type mult {useboco 1} {usetopo 1}} {
    global file_name
    
    # do not, in fact, select any domain files.  Just return all
    # domain files produced
    
    return $file_name(domain)
}

proc file_is_family_boco {file} {
    return [expr [file isfile $file] && \
		([string match *family_boco* $file] || \
		     [string match *.fbc $file])]
}

proc ic_uns_is_loaded {} {
    return 0
}

proc create_trivial_famboco {} {
    return ""
}

proc get_boco_topo {} {
    global file_name
    
    if {$file_name(family_boco) != ""} {
	set bc $file_name(family_boco)
	
    } elseif {$file_name(mesh_dir) != ""} {
        set bc ""
        set opts [glob -nocomplain $file_name(mesh_dir)/*.fbc]
        if {$opts != ""} {
            set bc [lindex $opts 0]
        }

	if {$bc == ""} {
	    if {[file exists $file_name(mesh_dir)/family_boco.fbc]} {
	        set bc $file_name(mesh_dir)/family_boco.fbc

            } elseif {[file exists $file_name(mesh_dir)/family_boco]} {
                set bc $file_name(mesh_dir)/family_boco

	    } elseif {[file exists $file_name(mesh_dir)/boco]} {
	        set bc $file_name(mesh_dir)/boco
	    
	    } elseif {[file exists $file_name(mesh_dir)/boco_info]} {
	        set bc $file_name(mesh_dir)/boco_info
	
	    } else {
	        set bc $file_name(mesh_dir)/
	    }
	}
    } elseif [ic_uns_is_loaded] {
	set bc [create_trivial_famboco]
    } else {
	set bc ./
    }
    uplevel 1 set bocofile \"$bc\"
    
    # ---------------------
    
    if {$file_name(topo_mulcad_out) != ""} {
	set top $file_name(topo_mulcad_out)
	
    } elseif {$file_name(mesh_dir) != ""} {
	set tdir [file dirname [file dirname $file_name(mesh_dir)]]/topology
	
	if [file exists $file_name(mesh_dir)/topo_mulcad_out] {
	    set top $file_name(mesh_dir)/topo_mulcad_out
	    
	} elseif [file exists $file_name(mesh_dir)/topo_info] {
	    set top $file_name(mesh_dir)/topo_info
	    
	} elseif [file exists $tdir/topo_mulcad_out] {
	    set top $tdir/topo_mulcad_out
	    
	} else {
	    set opts [glob -nocomplain $file_name(mesh_dir)/*.top]
	    if {$opts != ""} {
		set top [lindex $opts 0]
	    } else {
		set top ./
	    }
	}
    } else {
	set top ./
    }
    uplevel 1 set topofile \"$top\"
    
    # ---------------------
    
    if {$file_name(family_topo) != ""} {
	set fto $file_name(family_topo)
	
    } elseif {$file_name(mesh_dir) != ""} {
	if [file exists $file_name(mesh_dir)/family_topo] {
	    set fto $file_name(mesh_dir)/family_topo
	    
	} else {
	    set opts [glob -nocomplain $file_name(mesh_dir)/*.fto]
	    if {$opts != ""} {
		set fto [lindex $opts 0]
	    } else {
		set fto ./
	    }
	}
    } else {
	set fto ./
    }
    uplevel 1 set ftopofile \"$fto\"
}

proc query_question {args} {
    return *okay*
}

# Result reader interfaces

proc sock_client_do {cmd args} {
    return [eval $cmd $args]
}

proc rfile_selection {args} {
    return [file_selection $args]
}

proc rfile_select {message {default ""} {title "File selection"} \
		       {get_dir 0} {new_ok 0} {ok_func ""} {prev_file ""} \
		       {extra_widgets ""} {visible_func ""} {pick_func ""} \
		       {multiple 0} {ok_to_select "ok to select"} \
		       {absolute 1} {warn_overwrite 0}} {
    return [file_select $message $default $title \
		$get_dir $new_ok $ok_func $prev_file \
		$extra_widgets $visible_func  $pick_func \
		$multiple $ok_to_select $absolute $warn_overwrite]
}

proc rfile_select_multiple {message default {title "File selection"} \
			       {ok_func ""} {extra_widgets ""} \
			       {visible_func ""}} {
    return [file_select $message $default $title 0 0 $ok_func "" \
		$extra_widgets $visible_func "" 1]
}

proc rfile_select_entry {w var get_dir new_ok msg tabgeo {act ""} {ok_func ""}\
                {prev_file ""} {extra_widgets ""} {visible_func ""} \
                {pick_func ""} {dir ""} {mfiles 0} {absolute 1} \
                {ok_to_select "ok to select"} {warn_overwrite 0}} {
    global drop_down_arrow
    
    set drop_down_arrow 0
    return [file_select_entry $w $var $get_dir $new_ok $msg $tabgeo \
		$act $ok_func $prev_file $extra_widgets $visible_func \
		$pick_func "" 0]
}

#initialization -- setting values afterwards overrides default values

array set ICC_gateway {
    zonemask ""
    node_weight_files ""
    node_weight_method 0
    rf_debug 1
    startup_files ""
    no_face_data 0
    backend_option "unknown"
    grid_options ""
    boco_names ""
    boco_file ""
    topo_file ""
    user_scalars ""
    user_cscalars ""
    user_vectors ""
    npgcut ""
    result_server ""
    do_edits ""
    other_result_files ""
    grid_steady 1
    startup_files ""
    backend ""
    BWidget 0
    famdesc ""
    boco_flag 0
}	
