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

Home » Public Forums » archive » Re: IDL -> C : How to save data from IDL?
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
Re: IDL -> C : How to save data from IDL? [message #62433] Wed, 10 September 2008 04:23 Go to next message
Joost Aan de Brugh is currently offline  Joost Aan de Brugh
Messages: 16
Registered: July 2008
Junior Member
On Sep 10, 12:41 pm, "hotplainr...@gmail.com" <hotplainr...@gmail.com>
wrote:
> Hi guys,
>
> I have managed to get CUDA interfacing to IDL and so far its all good.
> However, whenever I get problems in C or CUDA, I can't run a debugger
> because it doesn't recognise IDL. So I want to separate the C code
> from IDL and this means I have to be able to load data from within C.
>
> How do I save data that is IDL for C to use?
>
> I'm thinking of
>
> running IDL program -> C program which writes the data into a file
>
> Thanks
> Zaki


Hello Zaki,

If you use a file:
Maybe it is the best to use conventional file formats like NetCDF and
HDF. They are the most portable.

You can probably also use Call_External (see IDL Help on
Call_External).
I used it for Fortran. IO hope that it works similar for C
You need a shared object file and a method name.
The method name is probably something like your defined name plus an
underscore
You can see what that name is with "nm <shared object file>" in Linux.
(I do not know for Windows)

You define a method with arguments argc and argv.
In Fortran, argv is a list of integers which are the memory addresses
of your arguments (void-pointers). You should be able to write data
into these addresses.
Probably, this only works better with C than with Fortran.
But if you use this, watch out, because you should always write the
same size as allocated by IDL. Note that non-long integers in IDL are
only 2 bytes long and if you memcpy a 4-byte C int there, you write 2
bytes into unknown territory, ruining other data or causing a
segmentation fault. (Of course, the former is worse). The other way
round is also dangerous. For example, if you write a 4-byte C-float
into an address where you have a 8-byte IDL Double, you will get
idiotic values in IDL.

Best regards,
Joost Aan de Brugh
Re: IDL -> C : How to save data from IDL? [message #62519 is a reply to message #62433] Thu, 11 September 2008 02:49 Go to previous message
hotplainrice@gmail.co is currently offline  hotplainrice@gmail.co
Messages: 15
Registered: July 2008
Junior Member
On Sep 10, 9:23 pm, Joost Aan de Brugh <joost...@gmail.com> wrote:
> On Sep 10, 12:41 pm, "hotplainr...@gmail.com" <hotplainr...@gmail.com>
> wrote:
>
>> Hi guys,
>
>> I have managed to get CUDA interfacing to IDL and so far its all good.
>> However, whenever I get problems in C or CUDA, I can't run a debugger
>> because it doesn't recognise IDL. So I want to separate the C code
>> from IDL and this means I have to be able to load data from within C.
>
>> How do I save data that is IDL for C to use?
>
>> I'm thinking of
>
>> running IDL program -> C program which writes the data into a file
>
>> Thanks
>> Zaki
>
> Hello Zaki,
>
> If you use a file:
> Maybe it is the best to use conventional file formats like NetCDF and
> HDF. They are the most portable.
>
> You can probably also use Call_External (see IDL Help on
> Call_External).
> I used it for Fortran. IO hope that it works similar for C
> You need a shared object file and a method name.
> The method name is probably something like your defined name plus an
> underscore
> You can see what that name is with "nm <shared object file>" in Linux.
> (I do not know for Windows)
>
> You define a method with arguments argc and argv.
> In Fortran, argv is a list of integers which are the memory addresses
> of your arguments (void-pointers). You should be able to write data
> into these addresses.
> Probably, this only works better with C than with Fortran.
> But if you use this, watch out, because you should always write the
> same size as allocated by IDL. Note that non-long integers in IDL are
> only 2 bytes long and if you memcpy a 4-byte C int there, you write 2
> bytes into unknown territory, ruining other data or causing a
> segmentation fault. (Of course, the former is worse). The other way
> round is also dangerous. For example, if you write a 4-byte C-float
> into an address where you have a 8-byte IDL Double, you will get
> idiotic values in IDL.
>
> Best regards,
> Joost Aan de Brugh

Thanks Joost for the reply, I'll look into it soon.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Some questions about "axis"
Next Topic: IDL calls C calls IDL?

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

Current Time: Thu Oct 09 14:48:31 PDT 2025

Total time taken to generate the page: 1.32822 seconds