I am trying to use some of the 2D functions (e.g. Sum2D etc.) in the
Adv. Analysis Library.
The following piece of code is supposed to allocate memory for a 2D
array, fill that array with random numbers and determine the sum of the
elements. I can get an error: "Array argument too small..."
If you use pointers the problem persists no matter how many points the
2D array has.
HOWEVER, if you do not use pointers and declare an array, i.e.
dArray[][], then it works if the number of points is small, e.g. 10.
Any help would be appreciated.
#include
#include
#define NPTS 240
void main ()
{
int i, j;
double sum;
double **dArray;
// Allocate memory for the 2D array
dArray
= malloc(NPTS*sizeof(double));
for (i=0; i dArray[i] = malloc(NPTS*sizeof(double));
// Put some random numbers in the array
for (i=0; i {
for (j=0; j dArray[i][j] = rand();
}
// Use Advanced Analysis to sum the array elements. You get an error:
// Error: Array argument too small (1920) bytes. Argument must contain
at least 460800 bytes
Sum2D (dArray, NPTS, NPTS, ∑);
// Other Advanced Analysis 2D functions have the same the problem.
// If you use pointers the problem persists no matter what NPTS is
// HOWEVER, if you use arrays, i.e. dArray[][], then it works if NPTS
is small, e.g. 10
free(dArray);
}
Thanks
Haris Riris
hriris@pop900.gsfc.nasa.gov
NASA/GSFC, mail code 924