Creating an IDL array within C?

This is a discussion on Creating an IDL array within C? within the Idl-pvwave forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > Idl-pvwave

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-29-2008, 09:40 AM
hotplainrice@gmail.com
Guest
 
Default Creating an IDL array within C?

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
Reply With Quote
  #2  
Old 08-30-2008, 12:52 PM
MC
Guest
 
Default Re: Creating an IDL array within C?

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


Reply With Quote
  #3  
Old 09-01-2008, 11:21 PM
Karl
Guest
 
Default Re: Creating an IDL array within C?

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.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:45 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.