
# ICEM CFD solver interface routine for the manager.
#
# Copyright (c) 1993-1995 ICEM Systems.

proc sctetra_write_input {} {
    global confname file_name sctetra_output_path icem_powermesh
    global file_name env

    set domain [domain_select $file_name(domains_dir) "Select an unstructured domain." unstruct 0]
    if {$domain == {}} return

    set outfile $file_name(transfer_dir)/sctetra

    set scale 0
    set x 1.0
    set y 1.0
    set z 1.0
    set fortran_unit 8
    set env(F_UFMTENDIAN) $fortran_unit
    set double 1

    if {![dialog .sctetra "SC-Tetra" \
          "Please edit the following SC-Tetra options." {
               {outfile -type path -title "Output file" -help "Output File"}
	       {scale -opt {{"Yes" 1} {"No" 0}} -title "Scaling"}
               {x -type string -active {$scale} -title "x scaling factor" }
               {y -type string -active {$scale} -title "y scaling factor" }
               {z -type string -active {$scale} -title "z scaling factor" }
	       {double -opt {{Single 0} {Double 1}} -title Precision -help "Precision"}
           }]} return
  
    if {![file exists $domain]} {
        errormsg "Domain file $domain doesn't exist"
        return
    }

    set command "\"$sctetra_output_path\" -dom \"$domain\""
    if $double {set command "$command -double"}
    if $scale   {set command "$command -scale $x,$y,$z"}
    set command "$command \"$outfile\""

    runxcom ICEM-CFD/SC-Tetra-Interface $command "" 1 0
}
