> I'm running into the following problem and I was wondering if someone
> might know what is causing it. I am trying to create a simple xy plot.
> I am using the following lines to create my data object.
>
> float *xdra, *ydra;
> ...
> ... allocate memory and read values into xdra and ydra ...
> ...
>
> NhlRLClear(rlist);
> NhlRLSetFloatArray(rlist,NhlNcaXArray,xdra,NhlNumber(xdra));
> NhlRLSetFloatArray(rlist,NhlNcaYArray,ydra,NhlNumber(ydra));
> NhlCreate(&dataid,"xyData",NhlcoordArraysClass,
> NhlDEFAULT_APP,rlist);
NhlNumber can not determine how big of an array you allocate dynamically.
It can only be used to determine the number of elements in a static or
stack declared array. All NhlNumber is, is a C macro that takes the size
of an array, and divides it by the size of an element of that array.
You can find it defined in $(NCARG_ROOT)/include/ncarg/hlu/hlu.h but
the definition looks like this:
#define NhlNumber(arr) ((unsigned int) (sizeof(arr) / sizeof(arr[0])))
> This however fails to produce the appropriate plot. (i.e. It would only
> plot the first two points and not plot the rest)
Because NhlNumber returned 1.
> HOWEVER when I declare xdra and ydra explicitly like
>
>
> float xdra[10], ydra[10];
>
> and read the 10 points into the array then the plot works
> fine.
>
> There shouldn't be a difference whether I declare it as a pointer and
> then allocate the memory for it as opposed to hardwiring the size
> from the begining should there?????
There is no difference to the NhlRLSetFloatArray function, but there is
a big difference to NhlNumber. If you are allocating the memory dynamically,
you will need to keep track of how many elements you allocated and set that
explicitly - you can't use NhlNumber.
jeff
-- Jeff W. Boote <boote@ucar.edu> *************************************** Scientific Computing Division * There are more things in heaven and * National Center for Atmospheric Research * earth, Horatio, Than are dreamt of * Boulder * in your philosophy. Hamlet * ***************************************
This archive was generated by hypermail 2b29 : Wed Jun 28 2000 - 09:45:35 MDT