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

Home » Public Forums » archive » Re: giving input to fortran program using spawn in 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: giving input to fortran program using spawn in IDL [message #62679] Fri, 26 September 2008 01:41
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
On Sep 24, 6:05 pm, ramm...@gmail.com wrote:
> Dear all,
>
>       I have some programs written in fortran-77. I want to run them
> in
> the IDL editor. I tried using spawn command. Which is good only if I
> am not worry about input to fortran from IDL itself. The result from
> spawn can be split according our fortran program.
>
>       But I am creating some data from IDL, which is required for
> fortran
> as input. I search on the web and tried myself. But I could not make
> it.

Hi I dealt with this issue a couple of months ago. I too wanted to
transfer an array data from IDL to Fortran for processing and pass it
back.
I simply wrote an outfile from IDL, which fortran uses as an input
parameter file.And it worked well for me.
Here is what i did:

forprint,result,text='data.prt',/silent,/nocomment ;The variable
result contains the array that are the inputs of fortran and
these ;are stored in a file data.prt.

spawn,['./fortran.f'],/noshell, result ;Here the variable result
contains the output from fortran. I used the no shell keyword
to ;increase the speed.


Hope it was useful,

regards,
vino
Re: giving input to fortran program using spawn in IDL [message #62690 is a reply to message #62679] Wed, 24 September 2008 20:00 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Jean H <jghasban@DELTHIS.ucalgary.ANDTHIS.ca> writes:

>> If you are using Unix or Mac OS X, you can use the various redirection
>> capabilities of those operating systems. For example, put the inputs
>> in a text file, and then,
>> SPAWN, 'my_fortran_program < inputfile.txt', output_results
...
> Now, with this method, how does one pass an array, not just strings?
> (I have a large image in mind)

My first idea would be to use a separate binary file that you can read
with unformatted I/O. Or, in a pinch you can just use formatted I/O.
Avoiding premature optimization and all that.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: cbmarkwardt+usenet@gmail.com
------------------------------------------------------------ --------------
Re: giving input to fortran program using spawn in IDL [message #62691 is a reply to message #62690] Wed, 24 September 2008 12:07 Go to previous message
jeffnettles4870 is currently offline  jeffnettles4870
Messages: 111
Registered: October 2006
Senior Member
On Sep 24, 12:17 pm, Craig Markwardt
<craigm...@REMOVEcow.physics.wisc.edu> wrote:
> ramm...@gmail.com writes:
>> Dear all,
>
>>       I have some programs written in fortran-77. I want to run them
>> in
>> the IDL editor. I tried using spawn command. Which is good only if I
>> am not worry about input to fortran from IDL itself. The result from
>> spawn can be split according our fortran program.
>
>>       But I am creating some data from IDL, which is required for
>> fortran
>> as input. I search on the web and tried myself. But I could not make
>> it.
>
> If you are using Unix or Mac OS X, you can use the various redirection
> capabilities of those operating systems.  For example, put the inputs
> in a text file, and then,
>    SPAWN, 'my_fortran_program < inputfile.txt', output_results
>
> If you need dynamic control, you will want to use the UNIT keyword for
> SPAWN, which provides a file unit you can write to.  I.e. you would
> PRINTF your inputs to that file unit.  That can be very subtle
> however, so it's better to use the above construction if you can.
>
> If you have windows, I'm less well informed.
>
> Good luck,
> Craig
>
> --
> ------------------------------------------------------------ --------------
> Craig B. Markwardt, Ph.D.      EMAIL: cbmarkwardt+use...@gmail.com
> ------------------------------------------------------------ --------------

Windows supports that kind of redirection as well.
Re: giving input to fortran program using spawn in IDL [message #62692 is a reply to message #62691] Wed, 24 September 2008 09:38 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> If you are using Unix or Mac OS X, you can use the various redirection
> capabilities of those operating systems. For example, put the inputs
> in a text file, and then,
> SPAWN, 'my_fortran_program < inputfile.txt', output_results
>
> If you have windows, I'm less well informed.
>
> Good luck,
> Craig

It does work well under windows too... I have used it a couple of weeks ago.

Now, with this method, how does one pass an array, not just strings? (I
have a large image in mind)

Jean
Re: giving input to fortran program using spawn in IDL [message #62693 is a reply to message #62692] Wed, 24 September 2008 09:17 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
rammaur@gmail.com writes:

> Dear all,
>
> I have some programs written in fortran-77. I want to run them
> in
> the IDL editor. I tried using spawn command. Which is good only if I
> am not worry about input to fortran from IDL itself. The result from
> spawn can be split according our fortran program.
>
> But I am creating some data from IDL, which is required for
> fortran
> as input. I search on the web and tried myself. But I could not make
> it.

If you are using Unix or Mac OS X, you can use the various redirection
capabilities of those operating systems. For example, put the inputs
in a text file, and then,
SPAWN, 'my_fortran_program < inputfile.txt', output_results

If you need dynamic control, you will want to use the UNIT keyword for
SPAWN, which provides a file unit you can write to. I.e. you would
PRINTF your inputs to that file unit. That can be very subtle
however, so it's better to use the above construction if you can.

If you have windows, I'm less well informed.

Good luck,
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: cbmarkwardt+usenet@gmail.com
------------------------------------------------------------ --------------
Re: giving input to fortran program using spawn in IDL [message #62695 is a reply to message #62693] Wed, 24 September 2008 09:07 Go to previous message
jelliott.ittvis is currently offline  jelliott.ittvis
Messages: 7
Registered: September 2008
Junior Member
Check out the CALL_EXTERNAL function. You can pass parameters from
IDL to routines in fortran

On Sep 24, 7:05 am, ramm...@gmail.com wrote:
> Dear all,
>
>       I have some programs written in fortran-77. I want to run them
> in
> the IDL editor. I tried using spawn command. Which is good only if I
> am not worry about input to fortran from IDL itself. The result from
> spawn can be split according our fortran program.
>
>       But I am creating some data from IDL, which is required for
> fortran
> as input. I search on the web and tried myself. But I could not make
> it.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Possible to display .h5 ad .hdf together
Next Topic: Re: Possible to display .h5 ad .hdf together

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

Current Time: Wed Oct 08 19:55:35 PDT 2025

Total time taken to generate the page: 0.00503 seconds