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

proc csp_write_input {} {
    global confname file_name csp_output_path icem_powermesh

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

    set outfile $file_name(transfer_dir)/csp
    set project $file_name(project_dir)
    set ascii 1

    if {![dialog .csp "CSP" \
          "Please edit the following CSP options." {
               {bocofile -type path -title "Boco file" \
                   -help "Boundary condition file"}
	       {project -type string -title "Project name"}
	       {ascii -opt {{"ASCII" 1} {"BINARY" 0}} \
			-title "ASCII or BINARY file"}
	       {outfile -type path -title "Output file"} 
           }]} return

   
    if {![file exists $domain]} {
        errormsg "Domain file $domain doesn't exist"
        return
    }

    if {![file exists $bocofile]} {
        errormsg "File $bocofile doesn't exist"
        return
    }

    set command "\"$csp_output_path\" -dom \"$domain\" -b \"$bocofile\" -project \"$project\""
    if $ascii {set command "$command -ascii"}
    set command "$command \"$outfile\""

    runcom $command ""
}
