#!/bin/sh # -*- mode: Tcl -*- # ---------------------------------------------------------------------- # RAPPTURE SIMULATE # # This program will run a driver.xml file and return a run.xml file. # No graphical user interface will be launched. # # USAGE: simulate.tcl -driver driver.xml # ====================================================================== # AUTHOR: Derrick S. Kearney, Purdue University # Copyright (c) 2004-2014 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ====================================================================== #\ exec tclsh "$0" $* # ---------------------------------------------------------------------- # tclsh executes everything from here on... package require Rappture #package require RapptureGUI proc storeoutput {data} { global _d append _d $data } proc main {argv} { Rappture::getopts argv params { value -driver "" value -tooldir "" value -runfile "" } # keep the wish window from popping up catch {wm withdraw .} set xmlobj [Rappture::library $params(-driver)] set installdir $params(-tooldir) if {$installdir == ""} { # tooldir not provided # try looking inside driver.xml for tooldir set installdir [$xmlobj get "tool.version.application.directory(tool)"] if {$installdir == ""} { # default to the current working directory set installdir [pwd] } } # set tool [Rappture::Tool ::#auto $xmlobj $installdir] set task [Rappture::Task ::#auto $xmlobj $installdir] $task configure -jobstats "" set result "" # execute the job foreach {status result} [eval $task run -output storeoutput] break # if run was successful, check to see if we should rename the file if {$status == 0 && $result != "ABORT"} { global _d if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $_d match result]} { if {[string compare "" $params(-runfile)] != 0} { if {[catch {file rename -force -- $result $params(-runfile)} out]} { puts stderr "while moving $result to $params(-runfile): $out" } } } else { set status 1 puts "Can't find result file in output.\nDid you call Rappture::result in your simulator?" } } else { puts $result } } main $argv exit 0