source: trunk/src/core/RpResult.cc @ 66

Last change on this file since 66 was 66, checked in by mmc, 19 years ago

Cleaned up the app-fermi example so that it works the same way
across all of the various languages.

Added rpResult() function for reporting results. All programs
should all this to save out the XML before they exit. Also added
the fortran version rp_result().

File size: 1.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  FUNCTION: rpResult
4 *
5 *  Clients call this function at the end of their simulation, to
6 *  pass the simulation result back to the Rappture GUI.  It writes
7 *  out the given XML object to a runXXX.xml file, and then writes
8 *  out the name of that file to stdout.
9 * ======================================================================
10 *  AUTHOR:  Michael McLennan, Purdue University
11 *  Copyright (c) 2004-2005
12 *  Purdue Research Foundation, West Lafayette, IN
13 * ======================================================================
14 */
15#include <stdlib.h>
16#include <time.h>
17
18void
19rpResult(PyObject* lib) {
20    char outputFile[100];
21    char* xtext;
22    FILE* fp;
23    time_t t;
24
25    xtext = rpXml(lib);
26
27    // create output filename
28    snprintf(outputFile, 50, "run%d.xml", (int)time(&t));
29
30    // write out the result file
31    fp = fopen(outputFile, "w");
32    if(!fp) {
33        fprintf(stderr,"can't save results (err=%d)\n", errno);
34        return;
35    }
36    int fsize = fwrite(xtext, strlen(xtext), sizeof(char), fp);
37    fclose(fp);
38
39    // tell Rappture the file name
40    printf("=RAPPTURE-RUN=>%s\n", outputFile);
41}
Note: See TracBrowser for help on using the repository browser.