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

Home » Public Forums » archive » Creating an IDL array within C?
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
Creating an IDL array within C? [message #62172] Fri, 29 August 2008 06:40 Go to next message
hotplainrice@gmail.co is currently offline  hotplainrice@gmail.co
Messages: 15
Registered: July 2008
Junior Member
Hi guys,

Another problem for everyone. Yay!

Firstly, I'm working on translating code from IDL to C for CUDA
purposes by re-writing it as a system routine.

so the issue:

Within IDL, the user can do this

IDL> help, data6
DATA6 UNDEFINED = <Undefined>

and call an arbitrary function that will have it created.

thisfunc, data6, wv

Within thisfunc.pro
pro thisfunc, data6, wv
data6 = fltarr(5,6)

How do I do this in C?
Is it even possible or do I have to ensure that data6 exists before I
call my system routine?

Regards
Zaki
Re: Creating an IDL array within C? [message #62225 is a reply to message #62172] Sat, 30 August 2008 09:52 Go to previous messageGo to next message
MC is currently offline  MC
Messages: 50
Registered: September 1996
Member
On Aug 30, 1:40 am, "hotplainr...@gmail.com" <hotplainr...@gmail.com>
wrote:
> Hi guys,
>
> Another problem for everyone. Yay!
>
> Firstly, I'm working on translating code from IDL to C for CUDA
> purposes by re-writing it as a system routine.
>
> so the issue:
>
> Within IDL, the user can do this
>
> IDL> help, data6
> DATA6           UNDEFINED = <Undefined>
>
> and call an arbitrary function that will have it created.
>
> thisfunc, data6, wv
>
> Within thisfunc.pro
> pro thisfunc, data6, wv
>    data6 = fltarr(5,6)
>
> How do I do this in C?
> Is it even possible or do I have to ensure that data6 exists before I
> call my system routine?
>
> Regards
> Zaki

When you create the function prototype you declare the variable, even
if it has no value at that time.
In your case 'data6' could be a pointer variable for an as yet unsized
or variable sized array
-at least that's how I remember ANSI C should work e.g.

<myheader.h>

int thisfunc(float *data6, int wv ....);

Cheers
Re: Creating an IDL array within C? [message #62305 is a reply to message #62225] Mon, 01 September 2008 20:21 Go to previous message
Karl[1] is currently offline  Karl[1]
Messages: 79
Registered: October 2005
Member
On Aug 30, 10:52 am, MC <Morefl...@gmail.com> wrote:
> On Aug 30, 1:40 am, "hotplainr...@gmail.com" <hotplainr...@gmail.com>
> wrote:
>
>
>
>> Hi guys,
>
>> Another problem for everyone. Yay!
>
>> Firstly, I'm working on translating code from IDL to C for CUDA
>> purposes by re-writing it as a system routine.
>
>> so the issue:
>
>> Within IDL, the user can do this
>
>> IDL> help, data6
>> DATA6           UNDEFINED = <Undefined>
>
>> and call an arbitrary function that will have it created.
>
>> thisfunc, data6, wv
>
>> Within thisfunc.pro
>> pro thisfunc, data6, wv
>>    data6 = fltarr(5,6)
>
>> How do I do this in C?
>> Is it even possible or do I have to ensure that data6 exists before I
>> call my system routine?
>
>> Regards
>> Zaki
>
> When you create the function prototype you declare the variable, even
> if it has no value at that time.
> In your case 'data6' could be a pointer variable for an as yet unsized
> or variable sized array
> -at least that's how I remember ANSI C should work e.g.
>
> <myheader.h>
>
> int thisfunc(float *data6, int wv ....);
>
> Cheers

No, that's not even close. The OP is asking how to create an IDL
array in a C routine.

It is a lot easier to allocate the array in IDL and pass it to the C
function if you can. But sometimes you don't know the size of the
array until after you are actually in the C code.

Here is the general idea:

Suppose you want to return an IDL variable containing an array [5,6]
of floats. (The dimensions COULD be determined at run time.)
The variable is to be passed to the caller in argv[0].

IDL_MEMINT dim[2];
IDL_VPTR vpVar;
dim[0] = 5;
dim[1] = 6;
float *fp;
fp = (float*) IDL_MakeTempArray(IDL_TYP_FLOAT, 2, dim,
IDL_ARR_INI_NOP, &vpVar);

/* code to fill in array pointed to by fp */

if (argc >= 1)
IDL_VarCopy(vpVar, argv[0]);


See the IDL External Programming Guide for more info.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: 3D phase diagram drawing
Next Topic: Re: 3D phase diagram drawing

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

Current Time: Wed Oct 08 18:40:40 PDT 2025

Total time taken to generate the page: 0.00601 seconds