u18.c File Reference

#include <stdlib.h>
#include "memory.h"
#include "string.h"
#include "nmd.h"

Include dependency graph for u18.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Object reporting

Definition at line 7 of file u18.c.

References NMD_FREE, NMDCreateObject(), NMDDestroyObject(), NMDFalse, NMDInt, NMDReportObject(), and NMDSetValue().

00007                                {
00008   NMD_metadata nmd; NMDErrorCode ierr; 
00009   int i;
00010 
00011   PetscFunctionBegin;
00012   PetscInitialize(&argc,&argv,0,0);
00013 
00014   ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr);
00015 
00016   /*
00017    * create a bunch of components
00018    */
00019   for (i=0; i<37; i++) {
00020     char cname[6];
00021     memset(cname,0,6);
00022     sprintf(cname,"cmp%d",i);
00023     ierr = NMDSetValue(nmd,"cat",cname,NMDInt,&i); NMD_ERR_RETURN(ierr);
00024   }
00025 
00026   /* 
00027    * now count the keys & values
00028    */
00029   {
00030     char *s1,*s2,*c; int n1,n2;
00031     ierr = NMDReportObject(nmd,NMDFalse,&s1,&s2,'\t',NULL,NULL); NMD_ERR_RETURN(ierr);
00032 
00033     c = strtok(s1,"\t"); n1 = 0;
00034     while (c) {n1++; c = strtok(NULL,"\t");}
00035 
00036     c = strtok(s2,"\t"); n2 = 0;
00037     while (c) {n2++; c = strtok(NULL,"\t");}
00038 
00039     if (n1!=n2) printf("Mismatch: %d columns in header, %d in values\n",n1,n2);
00040 
00041     NMD_FREE(s1);
00042     NMD_FREE(s2);
00043   }
00044 
00045   ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr);
00046 
00047   PetscFinalize();
00048   PetscFunctionReturn(0);
00049 }

Here is the call graph for this function:


Generated on Sun Oct 4 03:59:31 2009 for NMD by  doxygen 1.5.9