Passing Data Through CALL_EXTERNAL [message #3818] |
Fri, 17 March 1995 12:59  |
djk
Messages: 2 Registered: March 1995
|
Junior Member |
|
|
I'm having problems passing a 2-D array to a C routine using IDL's
CALL_EXTERNAL procedure. Everything works fine passing scalars and 1-D
arrays but when I pass a 2 dimensional float array, I can not seem to
find the data in the second row of the array. I wrote some test code:
TEST.PRO:
nx = long(2) & ny = long(2)
arr = findgen(nx,ny)
a = call_external('test.so', '_test', arr, nx, ny)
end
TEST.C:
long junk(argc, argv)
int argc;
void *argv[];
{
long *nx,
*ny;
float **arr;
/* Assign passed in arguments */
arr = (float **) argv[0]; /* array */
nx = (long *) argv[1]; /* X dimensions of array */
ny = (long *) argv[2]; /* Y dimensions of array */
printf("Arr[][]...); /* prints: 0, 1, 0, 0 */
}
Unfortunately the IDL documentation does not address 2-D array.
I'm using IDL version 3.6.1 on Sun OS 4.1.3.
Any suggestions as to what I am doing wrong? Thanks,
--
( .
(. ) )
) ( ( David Kendig (Hughes STX)
.________. Operations Manager EGRET/Gamma Ray Observatory
| | __| Code 664, GSFC/NASA
| )) Greenbelt, MD 20771
| | //| (301) 286-7242
`---`-`------'---'
Coffee coffee ... djk@egretop.gsfc.nasa.gov
|
|
|
Re: Passing Data Through CALL_EXTERNAL [message #3936 is a reply to message #3818] |
Wed, 22 March 1995 06:40  |
djk
Messages: 2 Registered: March 1995
|
Junior Member |
|
|
This is just a follow up to my question concerning passing
multi-dimension arrays using call_external. First I want to thank all
those who responded. The answer is rather simple. One just passes
the multi-dimensioned array as a simple array.
Using the example from my original post:
long junk(argc, argv)
int argc;
void *argv[];
{
long *nx,
*ny;
float *arr;
/* Assign passed in arguments */
arr = (float **) argv[0]; /* array */
nx = (long *) argv[1]; /* X dimensions of array */
ny = (long *) argv[2]; /* Y dimensions of array */
z = arr[ix + iy * nx];
}
Thanks again for all the help!
--
( .
(. ) )
) ( ( David Kendig (Hughes STX)
.________. Operations Manager EGRET/Gamma Ray Observatory
| | __| Code 664, GSFC/NASA
| )) Greenbelt, MD 20771
| | //| (301) 286-7242
`---`-`------'---'
Coffee coffee ... djk@egretop.gsfc.nasa.gov
|
|
|