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

Home » Public Forums » archive » Running fortran exectuable using IDL spawn fails
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
Running fortran exectuable using IDL spawn fails [message #93508] Tue, 09 August 2016 05:05 Go to next message
Susanne is currently offline  Susanne
Messages: 3
Registered: August 2016
Junior Member
I cannot get a simple Fortran code to execute in my Windows 7 command prompt using the IDL 8.5.1 spawn command. I've googled for solutions, and found one that suggested to cd into the path of the exe file. I tried that and it didn't help.

I was able to re-create the result using this very simple Fortran code (test.f):

c This is a test code
write(*,*) "--- Hello World ---"
stop
end

Using "gfortran -o test test.f, I make the executable test.exe without any warnings. When I run the resulting executable manually in my command prompt, I get the expected "Hello World" output in the command prompt. When however, I run test.exe using a spawn command in IDL, after changing into the directory where the .exe resides, ...

cd, path
spawn, 'test.exe & pause'

... I only get "Press any key to continue" in the command prompt, but the expected "Hello World" output is missing. Why is the .exe file not running? I've tried simpler spawn commands, e.g., spawn, 'dir & pause', and those produce the expected result. But running the exe file with IDL spawn does not produce the expected output. Hoping that someone can give me a clue what is missing here.
Re: Running fortran exectuable using IDL spawn fails [message #93509 is a reply to message #93508] Tue, 09 August 2016 05:40 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, August 9, 2016 at 2:05:14 PM UTC+2, Susanne wrote:
> I cannot get a simple Fortran code to execute in my Windows 7 command prompt using the IDL 8.5.1 spawn command. I've googled for solutions, and found one that suggested to cd into the path of the exe file. I tried that and it didn't help.
>
> I was able to re-create the result using this very simple Fortran code (test.f):
>
> c This is a test code
> write(*,*) "--- Hello World ---"
> stop
> end
>
> Using "gfortran -o test test.f, I make the executable test.exe without any warnings. When I run the resulting executable manually in my command prompt, I get the expected "Hello World" output in the command prompt. When however, I run test.exe using a spawn command in IDL, after changing into the directory where the .exe resides, ...
>
> cd, path
> spawn, 'test.exe & pause'
>
> ... I only get "Press any key to continue" in the command prompt, but the expected "Hello World" output is missing. Why is the .exe file not running? I've tried simpler spawn commands, e.g., spawn, 'dir & pause', and those produce the expected result. But running the exe file with IDL spawn does not produce the expected output. Hoping that someone can give me a clue what is missing here.

Not sure, but try something like this:

cd, path
spawn, 'test.exe', result, errResult
print, result
print, errResult

what do you get?

Cheers,
Helder
Re: Running fortran exectuable using IDL spawn fails [message #93510 is a reply to message #93508] Tue, 09 August 2016 07:17 Go to previous messageGo to next message
Susanne is currently offline  Susanne
Messages: 3
Registered: August 2016
Junior Member
IDL> print, result
Press any key to continue . . .
IDL> print, err_result

IDL> print, exit_status
0
Re: Running fortran exectuable using IDL spawn fails [message #93511 is a reply to message #93510] Tue, 09 August 2016 07:34 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, August 9, 2016 at 4:17:26 PM UTC+2, susanne...@gmail.com wrote:
> IDL> print, result
> Press any key to continue . . .
> IDL> print, err_result
>
> IDL> print, exit_status
> 0

Strange... the only other idea I have at the moment is to try this code:

c This is a test code
write(6,*) "--- Hello World ---"
stop
end

Just in case the Windows messes up the stdout...

Other than that, I don't know.

A workaround would be to redirect your output in Windows to a text file:
spawn, 'test.exe > myOutput.txt', result, errResult
and then check the contents of myOutput.txt.

Good luck!

Cheers,
Helder
Re: Running fortran exectuable using IDL spawn fails [message #93516 is a reply to message #93508] Wed, 10 August 2016 03:03 Go to previous message
Susanne is currently offline  Susanne
Messages: 3
Registered: August 2016
Junior Member
The write(6,*) "--- Hello World ---" solved it - thanks!!!!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Odd behavior with NaNs
Next Topic: Mapping issue with mapcontinents, /usa and /canada ......

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

Current Time: Wed Oct 08 13:31:32 PDT 2025

Total time taken to generate the page: 0.00619 seconds