NMD
|
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
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().
{ NMD_metadata nmd; NMDErrorCode ierr; int i; PetscFunctionBegin; PetscInitialize(&argc,&argv,0,0); ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr); /* * create a bunch of components */ for (i=0; i<37; i++) { char cname[6]; memset(cname,0,6); sprintf(cname,"cmp%d",i); ierr = NMDSetValue(nmd,"cat",cname,NMDInt,&i); NMD_ERR_RETURN(ierr); } /* * now count the keys & values */ { const char *s1,*s2,*c; int n1,n2; ierr = NMDReportObject(nmd,NMDFalse,&s1,&s2,'\t',0,0); NMD_ERR_RETURN(ierr); c = strtok((char*)s1,"\t"); n1 = 0; while (c) {n1++; c = strtok(NULL,"\t");} c = strtok((char*)s2,"\t"); n2 = 0; while (c) {n2++; c = strtok(NULL,"\t");} if (n1!=n2) printf("Mismatch: %d columns in header, %d in values\n",n1,n2); NMD_FREE(s1); NMD_FREE(s2); } ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr); PetscFinalize(); PetscFunctionReturn(0); }