SALSA Analysis Modules
Functions
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(), CategoryGetModules(), GetCategories(), and QuantityAsString().

Referenced by TabReportModules(), and TabReportValues().

{
  char *key,*val; size_t lkey,lval;
  int ncat,icat,nmod,imod;
  const char **categories,**modules; AnalysisDataType *types;
  PetscBool begun=PETSC_FALSE,trace_arrays; PetscErrorCode ierr;
  PetscFunctionBegin;

  ierr = GetCategories(&ncat,&categories); CHKERRQ(ierr);
  ierr = AnaModTraceArrays(&trace_arrays); CHKERRQ(ierr);

  lkey = 0; lval = 0;
  for (icat=0; icat<ncat; icat++) {
    ierr = CategoryGetModules
      (categories[icat],&modules,&types,PETSC_NULL,&nmod); CHKERRQ(ierr);
    for (imod=0; imod<nmod; imod++) {
      PetscBool f,isarray;
      AnalysisDataType type=types[imod];

      lkey += strlen(categories[icat])+strlen(modules[imod])+20;

      if (rval) {
        ierr = NMDIsArrayType(type,(NMDTruth*)&isarray); CHKERRQ(ierr);
        if (isarray) {
          if (trace_arrays) {
            int len;
            ierr = NMDGetArrayValue
              (nmd,categories[icat],modules[imod],
               NULL,NULL,&len,(NMDTruth*)&f); CHKERRQ(ierr);
            if (f) lval += len*20;
          } else
            lval += 4*20;
        } else
          lval += 20;
      }
    }
  }
  ierr = PetscMalloc(lkey*sizeof(char),&key); CHKERRQ(ierr);
  ierr = PetscMemzero(key,lkey*sizeof(char)); CHKERRQ(ierr);
  if (rval) {
    ierr = PetscMalloc(lval*sizeof(char),&val); CHKERRQ(ierr);
    ierr = PetscMemzero(val,lval*sizeof(char)); CHKERRQ(ierr);
  }

  for (icat=0; icat<ncat; icat++) {
    ierr = CategoryGetModules
      (categories[icat],&modules,&types,PETSC_NULL,&nmod); CHKERRQ(ierr);
    for (imod=0; imod<nmod; imod++) {
      PetscBool f=PETSC_FALSE;
      AnalysisDataType type=types[imod];

      ierr = PetscStrlen(key,&lkey); CHKERRQ(ierr);
      if (rval) {ierr = PetscStrlen(val,&lval); CHKERRQ(ierr);}

      if (begun) {
        sprintf(key+lkey++,"%c", separator);
        if (rval) sprintf(val+lval++,"%c", separator);
      } else begun=PETSC_TRUE;

      sprintf(key+lkey,"%s:%s",categories[icat],modules[imod]);

      ierr = PetscStrlen(key,&lkey); CHKERRQ(ierr);
      sprintf(key+lkey,":%s",typenames[types[imod]]);

      if (rval) {
        AnalysisItem v; char *stringed; int vlen=0; PetscBool isarray;
        ierr = NMDIsArrayType(type,(NMDTruth*)&isarray); CHKERRQ(ierr);
        if (isarray) {
          ierr = NMDGetArrayValue
            (nmd,categories[icat],modules[imod],
             &type,(void*)&v,&vlen,(NMDTruth*)&f); CHKERRQ(ierr);
        } else {
          ierr = NMDGetValue
            (nmd,categories[icat],modules[imod],
             NULL,(void*)&v,(NMDTruth*)&f); CHKERRQ(ierr);
        }
        if (f && (!isarray || trace_arrays) ) {
          ierr = QuantityAsString
            (&v,types[imod],&stringed); CHKERRQ(ierr);
        } else stringed = "";
        sprintf(val+lval,"%s",stringed);
      }
      CHKMEMQ;
    }
  }
  *rkey = key; 
  if (rval) *rval = val;

  PetscFunctionReturn(0);
}

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().

{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  ierr = ReportAnamodContent
    (PETSC_NULL,rkey,PETSC_NULL,separator); CHKERRQ(ierr);
  PetscFunctionReturn(0);
}

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().

{
  PetscErrorCode ierr;
  PetscFunctionBegin;
#if defined(HAVE_NMD)
  printf("\n\n>>>> Please use NMD value reporting<<<<\n\n\n");
#endif
  ierr = ReportAnamodContent
    (nmd,rkey,rval,separator); CHKERRQ(ierr);
  PetscFunctionReturn(0);
}

Here is the call graph for this function: