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

Home » Public Forums » archive » "Share data with external processes"
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
"Share data with external processes" [message #7762] Thu, 16 January 1997 00:00 Go to next message
Ken Stone is currently offline  Ken Stone
Messages: 8
Registered: December 1996
Junior Member
Hello,

Does anyone know of a fast way to transfer a large array (say
fltarr(2000)) from another process? My first thought was to write the
data to a file, and then read it back into IDL. But time is of
a critical nature in this case. Then I found CALL_EXTERNAL, but it
seems to only return a scalar (Is that true?). LINKIMAGE now looks
like the way to go. Has anyone had any luck using LINKIMAGE to pass
around arrays like this? What _is_ the best way to "share data with
external processes"? (I put that in quotes because it's in the RSI
advertisement for IDL. :-))

Thanks,

Ken
Re: "Share data with external processes" [message #7766 is a reply to message #7762] Thu, 16 January 1997 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Ken Stone <k.a.stone@larc.nasa.gov> writes:

> Does anyone know of a fast way to transfer a large array (say
> fltarr(2000)) from another process? My first thought was to write the
> data to a file, and then read it back into IDL. But time is of
> a critical nature in this case. Then I found CALL_EXTERNAL, but it
> seems to only return a scalar (Is that true?).

Well, this is *literally* true, but it's not what you mean.
CALL_EXTERNAL accepts parameters just like any other IDL
procedure or function and these parameters can be passed by
reference or by value to the C program. Your large array will
be one of these parameters. You can think of it as sort of an
output parameter to a normal IDL procedure.

The only real caveat to using CALL_EXTERNAL to pass data is
that the variable must be created and sized on the IDL side.
You can fill it on the C side, but don't change its data type or
size. Your code will look something like this:

dataArray = FLTARR(2000)
junk = CALL_ETERNAL('fill_it.so', 'fillarray', dataArray)
PLOT, dataArray

The first two parameters to CALL_EXTERNAL are the name of the
shared object library you have to create and the entry point name
into that library (i.e, the function in the library you are calling).

The only difficult part of using CALL_EXTERNAL (and it is not
*always* difficult) is getting the shared object module made
correctly. This is compiler and operating system specific. RSI
provides lots of example Make files to help with this, but if
you have a wierd compiler you are sometimes on your own.

> LINKIMAGE now looks
> like the way to go. Has anyone had any luck using LINKIMAGE to pass
> around arrays like this? What _is_ the best way to "share data with
> external processes"? (I put that in quotes because it's in the RSI
> advertisement for IDL. :-))

LINKIMAGE is harder to use than CALL_EXTERNAL and requires that
you know significantly more about how IDL works internally. I would
say you pretty much have to be an expert C programmer to work with
LINKIMAGE, while even someone like me can usually get CALL_EXTERNAL
to work. ;-)

Good luck!

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
Re: "Share data with external processes" [message #7768 is a reply to message #7762] Thu, 16 January 1997 00:00 Go to previous messageGo to next message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <32DE6333.63EA@larc.nasa.gov>, Ken Stone <k.a.stone@larc.nasa.gov> writes:
|> Hello,
|>
|> Does anyone know of a fast way to transfer a large array (say
|> fltarr(2000)) from another process? My first thought was to write the
|> data to a file, and then read it back into IDL. But time is of
|> a critical nature in this case. Then I found CALL_EXTERNAL, but it
|> seems to only return a scalar (Is that true?). LINKIMAGE now looks
|> like the way to go. Has anyone had any luck using LINKIMAGE to pass
|> around arrays like this? What _is_ the best way to "share data with
|> external processes"? (I put that in quotes because it's in the RSI
|> advertisement for IDL. :-))
|>
|> Thanks,
|>
|> Ken
|>

As long as you allocate the arrays to store the result before the call,
you can use call_external to transfer large amounts of data
back and forth as well, i.e.:

transfer = fltarr(2000)
dummy = call_external(....,...,transfer)
plot,transfer

You should perhaps take a look at the IDL RPC (remote procedure call)
library as well - one advantage is that you can actually run your
external routines on a different machine, so you could in effect have
parallel processing as well! I've used this once to make IDL (run as
an RPC server process) visualize data while calculations were made by
a program on another machine.

I believe you can have IDL running as either a master or slave process,
though I've never tried the former.

Stein Vidar
Re: "Share data with external processes" [message #7872 is a reply to message #7762] Mon, 20 January 1997 00:00 Go to previous message
djackson is currently offline  djackson
Messages: 31
Registered: June 1993
Member
> Ken Stone <k.a.stone@larc.nasa.gov> writes:
>
>> Does anyone know of a fast way to transfer a large array (say
>> fltarr(2000)) from another process? My first thought was to write the
>> data to a file, and then read it back into IDL. But time is of
>> a critical nature in this case. Then I found CALL_EXTERNAL, but it
>> seems to only return a scalar (Is that true?).

If you're doing this on a Unix system, I have some experience I might
share. In one of my programs, I use 'spawn' to start the other process
with the 'unit=' option (and '/noshell' might be useful, too) which then
works as a bidirectional pipe. You can write to it and read from it, just
as if you were at the command line.

I really can't comment on whether this would be faster than other methods,
or if it even could work in your situation, but I thought I'd drop it into
the hat!

Cheers,
-Dick

Dick Jackson djackson@ibd.nrc.ca Institute for Biodiagnostics
Opinions are mine alone. National Research Council Canada, Winnipeg
"And I told him my dream was to live for all time
In some perfect refrain, like the man who wrote 'Danny Boy'."
- Joe Jackson, from the album _Night_Music_, 1994.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Revolutionary Software
Next Topic: IDL FAQ

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

Current Time: Wed Oct 08 20:02:29 PDT 2025

Total time taken to generate the page: 0.03845 seconds