comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Passing Data Through CALL_EXTERNAL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Passing Data Through CALL_EXTERNAL [message #3818] Fri, 17 March 1995 12:59 Go to next message
djk is currently offline  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 Go to previous message
djk is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Reading USGS DEMs
Next Topic: IDL Ignoring CTRL-C under SunOS

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:51:01 PDT 2025

Total time taken to generate the page: 0.00494 seconds