Difference between revisions of "Data Provenance:Documentation:Generating"

From NAMIC Wiki
Jump to: navigation, search
m (Update from Wiki)
 
 
Line 1: Line 1:
 +
''[http://132.239.132.249:8080/xwiki/bin/view/Morphometry-BIRN/mBIRN_Provenance_Main This is version 1.0, see BIRN xwiki for 2.0+]''
 +
 
== Generating Output ==
 
== Generating Output ==
  

Latest revision as of 22:07, 25 April 2007

Home < Data Provenance:Documentation:Generating

This is version 1.0, see BIRN xwiki for 2.0+

Generating Output

This page details how to get the various fields from the Specification Table (some content moved here) depending on if you're working with a shell script, a tcl program, or a C program.

The field names are always to be output with a following colon and a space, for parsing purposes.

This is organised by the field names, and then by the methods to obtain their values in various scenarios. Shell scripting examples assume use of csh.

A lot of assumptions are made about working on a *nix system.

Field Values

ProgramName:

  • C: set ProgramName argv[0];
  • TCL: define a string: char *ProgramName = "name"
  • Shell: set ProgramName = $argv[0];
  • Java: define a string: System.out.print("ProgramName: progName");

ProgramArguments:

  • C: argv
  • TCL: puts "${argv}"
  • Shell: echo $argv;
  • Java: pass String [] args from main, then iterate:
 for (int i = 0; i < args.length; i++) {
   System.out.print(" " + args[i]);
 }

Version:

Use the CVS keyword Name, inserted into your source code file as $Name$ and it will be replaced with a the version tag when you check out the code with a tag (via cvs -r tag co codemodule). Alternately, you can define it as a user string.

  • C: $Name$
  • TCL: $Name$
  • Shell: '$Name$' (in single quotes to avoid it being treated as an environment variable)
  • Java: System.out.print(" ProgramVersion: $Name$ ");

TimeStamp:

  • C:
 #include <time.h>
 struct tm * timeInfo;
 time_t rawtime;
 // mm/dd/yy-hh-mm-ss-TZ
 // plus one for 3 char time zone
 char timeStr[22];
 time ( &rawtime );
 timeInfo = localtime (&rawtime);
 strftime (timeStr, 22, "%D-%k-%M-%S-%Z", timeInfo);
 fprintf(stdout, "%s", timeStr);
  • TCL: [clock format [clock seconds] -format "%D-%T-%Z"]
  • Shell: date +%D-%k-%M-%S-%Z (system call for linux, redirect output into log file via >> $LogFile)
  • Java:
 Calendar cal = Calendar.getInstance();
 int mo = cal.get(cal.MONTH) + 1;
 System.out.print("TimeStamp: " + mo + "/" + cal.get(cal.DAY_OF_MONTH) + "/" + cal.get(cal.YEAR) + "-" + cal.get(cal.HOUR_OF_DAY) + "-" + cal.get(cal.MINUTE) + "-" + cal.get(cal.SECOND) + "-" + cal.getTimeZone().getDisplayName().replace(' ','_'));

CVS:

Use the CVS keyword Id, inserted into your source code file as $Id$ and it will be replaced with the file name, version, date of change and who changed it. TBD: figure out how to do this with Subversion.

  • C: $Id$
  • TCL: $Id$
  • Shell: '$Id$' (in single quotes to avoid it being treated as an environment variable)
  • Java: System.out.print(" CVS: $Id$ ");

User:

This is the name of the user running this processing step.

  • C:
 #include <stdlib.h>
 fprintf(stdout, " User: %s", getenv("USER"));
  • TCL: $::env(USER)
  • Shell: $USER
  • Java:
 Properties props = System.getProperties();
 System.out.print(" User: " + props.getProperty("user.name"));

Machine:

This is the type of hardware that the processing step is run on, sun, x86, etc.

 Properties props = System.getProperties();
 System.out.print(" User: " + props.getProperty("os.arch"));

Platform:

This is the operating system under which the processing step is being run.

 Properties props = System.getProperties();
 System.out.print(" Platform: " + props.getProperty("os.name"));

PlatformVersion:

The version of the operating system.

 Properties props = System.getProperties();
 System.out.print(" PlatformVersion: " + props.getProperty("os.version"));

CompilerName:

  • C:
  #if defined(__GNUC__)
      return "GCC";
  #endif
  #if defined(_MSC_VER)
      return "MSC";
  #endif
      return "UKNOWN";
  • TCL: N/A (define the Tcl/Tk libraries instead)
  • Shell: N/A
  • Java:
 Properties props = System.getProperties();
 System.out.print(" CompilerName: " + props.getProperty("java.compiler"));

CompilerVersion:

  • C:
  #if defined(__GNUC__)
  #if defined(__GNU_PATCHLEVEL__)
      return (__GNUC__ * 10000 \
              + __GNUC_MINOR__ * 100 \
              + __GNUC_PATCHLEVEL__);
  # else
      return (__GNUC__ * 10000 \
              + __GNUC_MINOR__ * 100);
  # endif
  #endif

  #if defined(_MSC_VER)
      return (_MSC_VER);
  #endif

      return 0;
  • TCL: N/A
  • Shell: N/A
  • Java:
 Properties props = System.getProperties();
 System.out.print(" CompilerVersion: " + props.getProperty("java.version"));

LibName:

This is dependent on the library in question, examples are given for VTK and Tcl and Tk.

LibVersion:

  • C:
  • TCL:
    • VTK: set LibVersion [package require vtk]
    • TCL: $::{tcl_patchLevel}
    • TK: $::{tk_patchLevel}
  • Shell:

Tips

  • If you're running a third party program from inside a script, you can get some information even if the program doesn't respond to a version argument:
  set LF=script.log
  echo "ProgramName: [program] ProgramArguments: [list args to be passed here]" >> $LF
  # if the program responds to version requests
  echo -n "ProgramVersion: "
  ./[program] -v >> $LF
  echo -n "Platform: " >> $LF
  uname -o >> $LF
  echo -n "TimeStamp: " >> $LF
  date +%D-%k-%M-%S-%Z >> $LF
  echo "User: " $USER >> $LF
  echo -n "MachineName: " >> $LF
  uname -m >> $LF
  echo -n "Platform: " >> $LF
  uname -o >> $LF
  echo -n "PlatformVersion: " >> $LF
  uname -r >> $LF
  • Here's a link to a C program that was instrumented to respond to the --all-info flag:

a2mrml from the BIRNDUP project