Changes between Version 4 and Version 5 of FAQ_WrapperScriptBasics


Ignore:
Timestamp:
Jul 20, 2006 9:17:08 PM (15 years ago)
Author:
dkearney
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQ_WrapperScriptBasics

    v4 v5  
    2727All wrapper scripts follow the same basic format:
    2828
    29   1. open a rappture library object by sending it an xml file
    30   2. "get" inputs that the user specified, from the rappture object
    31   3. create an input file for your science code
    32   4. call your science code
    33   5. parse the output files from the science code
    34   6. "put" the interesting output back into the rappture library object
    35   7. call the result function to tell rappture graphical user interface that the wrapper script is complete.
     29  1. Open a Rappture library object by sending it an xml file
     30  2. "get" inputs that the user specified, from the Rappture object
     31  3. Create an input file for your science code
     32  4. Call your science code
     33  5. Parse the output files from the science code
     34  6. "put" the interesting output back into the Rappture library object
     35  7. Call the result function to tell Rappture graphical user interface that the wrapper script is complete.
    3636
    3737Generally wrapper scripts are written in a scripting language such as Tcl, Python, or Perl. This is because with scripting languages usually make it easy to do string manipulation, external application calls, and creation of files. While these activities can be done in languages like C/C++ or Fortran, its just easier and more convenient to use a scripting language. If you don't know a scripting language, then this is an excellent time to learn one. Tcl, Python and Perl are all pretty easy to learn and understand, especially if you already know another programming language.
     38
     39|| Step || Explanation || Tcl Example Code || Python Example Code ||
     40|| 1 || Here we open the Rappture library with the first command line argument, argument 0 ||'''set opt [Rappture::library [lindex $argv 0]]''' || '''lib = Rappture.library(sys.argv[1])''' ||
     41|| 2 || Pay attention to all lines that use the "get" function. They are grabbing information from the Rappture library || '''$opt get input.(structure).(p_node).current''' || ?? ||
     42|| 3 || Look for the appending of information to a variable, and the writing of variables to files || '''append deck ...''' [[BR]] '''set deckfile "pdr[pid]"''' [[BR]] '''set fid [open $deckfile w]''' [[BR]] '''puts $fid $deck '''[[BR]] '''close $fid''' || ?? ||
     43|| 4 || Look for the Rappture::exec call. That is how to execute external programs in Tcl || '''set status [catch {Rappture::exec $program $deckfile} out]''' || ?? ||
     44|| 5 || Generally the code right after the Rappture::exec function call deals with parsing the output || ?? || ?? ||
     45|| 6 || Anywhere you see the "put" function being used, you know we are trying to put information back into the Rappture library. || '''$opt put output.log $out''' || ?? ||
     46|| 7 || This line tells the rappture graphical user interface that the wrapper script has completed and that it can start rendering plots. Sometimes in old tcl scripts you see a line like this: [[BR]] puts "=RAPPTURE-RUN=>$oname" [[BR]] This is the old way to end a program and should not be used. || '''Rappture::result $opt $status''' || ?? ||
    3847
    3948== Hands On Example ==