NMD
Functions
u11.c File Reference
#include <stdlib.h>
#include "nmd.h"
Include dependency graph for u11.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 with internal copy

Definition at line 5 of file u11.c.

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

                               {
  NMD_metadata nmd; NMDErrorCode ierr; 
  NMDTruth flg; NMDDataType t;
  int *ii,*iir;
  PetscFunctionBegin;
  PetscInitialize(&argc,&argv,0,0);

  ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr);

  NMD_MALLOC(ii,5,int,"int array");
  ii[2] = 15;

  ierr = NMDCopyArrayValue
    (nmd,"ctg","i array",NMDIntarray,&ii,5); NMD_ERR_RETURN(ierr);

  NMD_FREE(ii);

  ierr = NMDGetArrayValue
    (nmd,"ctg","i array",&t,(void*)&iir,NULL,&flg); NMD_ERR_RETURN(ierr);
  if (!flg) NMD_ERR_REPORT("Could not get i array");
  if (t!=NMDIntarray) NMD_ERR_REPORTi("i array type mismatch",(int)t);
  if (iir[2]!=15) NMD_ERR_REPORTi("i array value problem",iir[2]);

  ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr);

  PetscFinalize();
  PetscFunctionReturn(0);
}

Here is the call graph for this function: