u9.c File Reference

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

Include dependency graph for u9.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Test setting and getting of array values

Definition at line 5 of file u9.c.

References NMD_FREE, NMD_MALLOC, NMDCreateObject(), NMDDestroyObject(), NMDGetArrayValue(), NMDIntarray, NMDRealarray, and NMDSetArrayValue().

00005                                {
00006   NMD_metadata nmd; NMDErrorCode ierr; 
00007   NMDTruth flg; NMDDataType t;
00008   int *ii,*iir,len; double *rr;
00009   PetscFunctionBegin;
00010   PetscInitialize(&argc,&argv,0,0);
00011 
00012   ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr);
00013 
00014   NMD_MALLOC(ii,5,int,"int array");
00015   NMD_MALLOC(rr,2,double,"double array");
00016   ii[2] = 15; rr[1] = 37.2;
00017 
00018   ierr = NMDSetArrayValue
00019     (nmd,"ctg","i array",NMDIntarray,&ii,5); NMD_ERR_RETURN(ierr);
00020   ierr = NMDSetArrayValue
00021     (nmd,"ctg","r array",NMDRealarray,&rr,2); NMD_ERR_RETURN(ierr);
00022 
00023   ierr = NMDGetArrayValue
00024     (nmd,"ctg","r array",NULL,NULL,&len,&flg); NMD_ERR_RETURN(ierr);
00025   if (!flg) NMD_ERR_REPORT("Could not get r array info");
00026   if (len!=2) NMD_ERR_REPORTi("r array length mismatch",len);
00027 
00028   ierr = NMDGetArrayValue
00029     (nmd,"ctg","i array",&t,(void*)&iir,NULL,&flg); NMD_ERR_RETURN(ierr);
00030   if (!flg) NMD_ERR_REPORT("Could not get i array");
00031   if (t!=NMDIntarray) NMD_ERR_REPORTi("i array type mismatch",(int)t);
00032   if (iir[2]!=15) NMD_ERR_REPORTi("i array value problem",iir[2]);
00033 
00034   NMD_FREE(ii); NMD_FREE(rr);
00035   ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr);
00036 
00037   PetscFinalize();
00038   PetscFunctionReturn(0);
00039 }

Here is the call graph for this function:


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