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

Home » Public Forums » archive » Re: Calling IDL from Fortran called by 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: Calling IDL from Fortran called by IDL [message #28181] Tue, 27 November 2001 08:01 Go to next message
Mark Rivers is currently offline  Mark Rivers
Messages: 49
Registered: February 2000
Member
Kevin A. Park <kpark@prism-cs.com> wrote in message
news:3c02c150$0$35565$272ea4a1@news.execpc.com...
> Hi,
>
> I have an IDL GUI which sits on top of a calculation engine which
> is written in Fortran 90. Currently IDL accesses the calculation engine
> by calling C wrapper functions via CALL_EXTERNAL. These C wrappers then
> call Fortran routines. The system runs both on Solaris and Windows
> platforms. I am currently using IDL 5.4, but will upgrade to IDL 5.5
> soon.
>
> Some of the calculations in the Fortran take a long time, so what I
> would like to do is have IDL create a progress bar which can be updated
> from the Fortran. Having waded through the IDL External Development
> Guide, I have a few questions.

I have done something like this in the past. Here is the general method.

- IDL calls your external C wrapper routines

- The external C routines launch a new thread and pass this thread
the address of an IDL variable into which some progress information
can be written.

- The external C routine returns to IDL immediately, leaving the new
thread running to do the time-intensive work. The new thread
writes progress information to the IDL variable, which the
IDL code is peridically checking and using to update a progress
meter, display new results or whatever.

The last time I did this was on VMS (!) for a real-time scanning x-ray
microscope display. The "real-time" thread was interupt driven
FORTRAN code that communicated with IDL via the addresses of IDL
variables that were passed to it when a new scan was begun.

The same general ideas should still work. You don't need IDL to
be multi-threaded, you just need to be able to launch a new
thread in your external code.

Mark Rivers
Re: Calling IDL from Fortran called by IDL [message #28188 is a reply to message #28181] Tue, 27 November 2001 04:13 Go to previous messageGo to next message
Pasi Hakala is currently offline  Pasi Hakala
Messages: 3
Registered: November 2001
Junior Member
"Kevin A. Park" wrote:
>
> Hi,
>
> I have an IDL GUI which sits on top of a calculation engine which
> is written in Fortran 90. Currently IDL accesses the calculation engine
> by calling C wrapper functions via CALL_EXTERNAL. These C wrappers then
> call Fortran routines. The system runs both on Solaris and Windows
> platforms. I am currently using IDL 5.4, but will upgrade to IDL 5.5
> soon.
>
> Some of the calculations in the Fortran take a long time, so what I
> would like to do is have IDL create a progress bar which can be updated
> from the Fortran. Having waded through the IDL External Development
> Guide, I have a few questions............
>
How about a simple and stupid IDL-widget process that checks a "status
file"
(created and updated by the fortran routine) periodically?

Cheers, Pasi
Re: Calling IDL from Fortran called by IDL [message #28191 is a reply to message #28188] Tue, 27 November 2001 02:02 Go to previous messageGo to next message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
Kevin A. Park wrote:

> Hi,
>
> I have an IDL GUI which sits on top of a calculation engine which
> is written in Fortran 90. Currently IDL accesses the calculation engine
> by calling C wrapper functions via CALL_EXTERNAL. These C wrappers then
> call Fortran routines. The system runs both on Solaris and Windows
> platforms. I am currently using IDL 5.4, but will upgrade to IDL 5.5
> soon.
>
> Some of the calculations in the Fortran take a long time, so what I
> would like to do is have IDL create a progress bar which can be updated
> from the Fortran.

I'm pretty sure that you are on to a non-starter here. I don't think this
will be possible until IDL is multi-threaded. Even if you can somehow get
your FORTRAN to update a widget, how that widget is rendered on the display
won't change until the windowing event loop is reentered when your external
code returns to IDL.

What you want to do is normally achieved by having the work done in a work
thread, and letting the main thread get on with handling events in the
display. From my limited knowlege of Java I think it's true for Java also.

--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
Re: Calling IDL from Fortran called by IDL [message #28248 is a reply to message #28181] Tue, 27 November 2001 18:38 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Mark Rivers" <rivers@cars.uchicago.edu> writes:

> Kevin A. Park <kpark@prism-cs.com> wrote in message
> news:3c02c150$0$35565$272ea4a1@news.execpc.com...
>> Hi,
>>
>> I have an IDL GUI which sits on top of a calculation engine which
>> is written in Fortran 90. Currently IDL accesses the calculation engine
>> by calling C wrapper functions via CALL_EXTERNAL. These C wrappers then
>> call Fortran routines. The system runs both on Solaris and Windows
>> platforms. I am currently using IDL 5.4, but will upgrade to IDL 5.5
>> soon.
>>
>> Some of the calculations in the Fortran take a long time, so what I
>> would like to do is have IDL create a progress bar which can be updated
>> from the Fortran. Having waded through the IDL External Development
>> Guide, I have a few questions.
>
...
> - The external C routine returns to IDL immediately, leaving the new
> thread running to do the time-intensive work. The new thread
> writes progress information to the IDL variable, which the
> IDL code is peridically checking and using to update a progress
> meter, display new results or whatever.
...

Oooh, but be careful, because if you allow your IDL variable to be
released, say by reassigning it, then your external C routine will
probably end up overwriting some part of memory you didn't want it to.

I would say that the easy compromise is to declare a system variable,
because I believe those are fixed in memory (ie, can't be
unallocated). System variables can be declared via IDL commands, or
within your DLM.

Also, one always needs to worry that things like malloc() and printf()
may not be threadsafe on one's platform. If your work thread and the
IDL thread clash, then *pow*, that will hurt.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 5.4 on Solaris? Please test
Next Topic: Re: New All-Time Records on IDL Newsgroup

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

Current Time: Wed Oct 08 14:32:57 PDT 2025

Total time taken to generate the page: 0.00678 seconds