Passing Array Data
When you pass an IDL array into a CALL_EXTERNAL routine, that routine gets a pointer to the first memory location in the array. In order to perform any processing on the array, an external routine needs more information—such as the array's size and number of dimensions. With CALL_EXTERNAL, you will need to pass this information explicitly as additional arguments to the routine.
In order to handle multi-dimensional arrays, C needs to know the size of the array at compile time. In most cases, this means that you will need to treat multi-dimensional arrays passed in from IDL as one dimensional arrays. However, you can still build your own indices to access an array as if it had more than one dimension in C. For example, the IDL array index:
could be represented in a CALL_EXTERNAL routine as:
The following routine, found in sum_2d_array.c, calculates the sum of a subsection of a two dimensional array. This is implemented as a function with a natural C interface, and a second glue routine that implements the IDL portable convention, using the one with the natural interface to do the actual work:
The IDL system routine interface provides much more support for the manipulation of IDL array variables. See Adding System Routines for more information.