reporting.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "petsc.h"
#include "anamod.h"
#include "nmd.h"

Include dependency graph for reporting.c:

Go to the source code of this file.

Functions

static PetscErrorCode ReportAnamodContent (NMD_metadata nmd, char **rkey, char **rval, int separator)
PetscErrorCode TabReportModules (char **rkey, int separator)
PetscErrorCode TabReportValues (NMD_metadata nmd, char **rkey, char **rval, int separator)


Function Documentation

static PetscErrorCode ReportAnamodContent ( NMD_metadata  nmd,
char **  rkey,
char **  rval,
int  separator 
) [static]

Generate a delimited string of all module names and corresponding values.

  • if the rval parameter is null, no value string is generated
  • separator is a single character

Definition at line 19 of file reporting.c.

References AnaModTraceArrays(), categories, CategoryGetModules(), GetCategories(), modules, QuantityAsString(), and types.

Referenced by TabReportModules(), and TabReportValues().

00020 {
00021   char *key,*val; size_t lkey,lval;
00022   int ncat,icat,nmod,imod;
00023   char **categories,**modules; AnalysisDataType *types;
00024   PetscTruth begun=PETSC_FALSE,trace_arrays; PetscErrorCode ierr;
00025   PetscFunctionBegin;
00026 
00027   ierr = GetCategories(&categories,&ncat); CHKERRQ(ierr);
00028   ierr = AnaModTraceArrays(&trace_arrays); CHKERRQ(ierr);
00029 
00030   lkey = 0; lval = 0;
00031   for (icat=0; icat<ncat; icat++) {
00032     ierr = CategoryGetModules
00033       (categories[icat],&modules,&types,PETSC_NULL,&nmod); CHKERRQ(ierr);
00034     for (imod=0; imod<nmod; imod++) {
00035       PetscTruth f,isarray;
00036       AnalysisDataType type=types[imod];
00037 
00038       lkey += strlen(categories[icat])+strlen(modules[imod])+20;
00039 
00040       if (rval) {
00041         ierr = NMDIsArrayType(type,(NMDTruth*)&isarray); CHKERRQ(ierr);
00042         if (isarray) {
00043           if (trace_arrays) {
00044             int len;
00045             ierr = NMDGetArrayValue
00046               (nmd,categories[icat],modules[imod],
00047                NULL,NULL,&len,(NMDTruth*)&f); CHKERRQ(ierr);
00048             if (f) lval += len*20;
00049           } else
00050             lval += 4*20;
00051         } else
00052           lval += 20;
00053       }
00054     }
00055   }
00056   ierr = PetscMalloc(lkey*sizeof(char),&key); CHKERRQ(ierr);
00057   ierr = PetscMemzero(key,lkey*sizeof(char)); CHKERRQ(ierr);
00058   if (rval) {
00059     ierr = PetscMalloc(lval*sizeof(char),&val); CHKERRQ(ierr);
00060     ierr = PetscMemzero(val,lval*sizeof(char)); CHKERRQ(ierr);
00061   }
00062 
00063   for (icat=0; icat<ncat; icat++) {
00064     ierr = CategoryGetModules
00065       (categories[icat],&modules,&types,PETSC_NULL,&nmod); CHKERRQ(ierr);
00066     for (imod=0; imod<nmod; imod++) {
00067       PetscTruth f=PETSC_FALSE;
00068       AnalysisDataType type=types[imod];
00069 
00070       ierr = PetscStrlen(key,&lkey); CHKERRQ(ierr);
00071       if (rval) {ierr = PetscStrlen(val,&lval); CHKERRQ(ierr);}
00072 
00073       if (begun) {
00074         sprintf(key+lkey++,"%c", separator);
00075         if (rval) sprintf(val+lval++,"%c", separator);
00076       } else begun=PETSC_TRUE;
00077 
00078       sprintf(key+lkey,"%s:%s",categories[icat],modules[imod]);
00079 
00080       ierr = PetscStrlen(key,&lkey); CHKERRQ(ierr);
00081       sprintf(key+lkey,":%s",typenames[types[imod]]);
00082 
00083       if (rval) {
00084         AnalysisItem v; char *stringed; int vlen=0; PetscTruth isarray;
00085         ierr = NMDIsArrayType(type,(NMDTruth*)&isarray); CHKERRQ(ierr);
00086         if (isarray) {
00087           ierr = NMDGetArrayValue
00088             (nmd,categories[icat],modules[imod],
00089              &type,(void*)&v,&vlen,(NMDTruth*)&f); CHKERRQ(ierr);
00090         } else {
00091           ierr = NMDGetValue
00092             (nmd,categories[icat],modules[imod],
00093              NULL,(void*)&v,(NMDTruth*)&f); CHKERRQ(ierr);
00094         }
00095         if (f && (!isarray || trace_arrays) ) {
00096           ierr = QuantityAsString
00097             (&v,types[imod],&stringed); CHKERRQ(ierr);
00098         } else stringed = "";
00099         sprintf(val+lval,"%s",stringed);
00100       }
00101       CHKMEMQ;
00102     }
00103   }
00104   *rkey = key; 
00105   if (rval) *rval = val;
00106 
00107   PetscFunctionReturn(0);
00108 }

Here is the call graph for this function:

PetscErrorCode TabReportModules ( char **  rkey,
int  separator 
)

Generate a string with separator delimiter listing all currently declared modules in the AnaMod system. The user needs to PetscFree() the string after use.

Definition at line 116 of file reporting.c.

References ReportAnamodContent().

00117 {
00118   PetscErrorCode ierr;
00119   PetscFunctionBegin;
00120   ierr = ReportAnamodContent
00121     (PETSC_NULL,rkey,PETSC_NULL,separator); CHKERRQ(ierr);
00122   PetscFunctionReturn(0);
00123 }

Here is the call graph for this function:

PetscErrorCode TabReportValues ( NMD_metadata  nmd,
char **  rkey,
char **  rval,
int  separator 
)

Generate strings with separator delimiter listing all currently declared modules in the AnaMod system and their values. The user needs to PetscFree() the strings after use.

Definition at line 131 of file reporting.c.

References ReportAnamodContent().

00132 {
00133   PetscErrorCode ierr;
00134   PetscFunctionBegin;
00135 #if defined(HAVE_NMD)
00136   printf("\n\n>>>> Please use NMD value reporting<<<<\n\n\n");
00137 #endif
00138   ierr = ReportAnamodContent
00139     (nmd,rkey,rval,separator); CHKERRQ(ierr);
00140   PetscFunctionReturn(0);
00141 }

Here is the call graph for this function:


Generated on Sun Oct 4 04:01:19 2009 for SALSA Analysis Modules by  doxygen 1.5.9