Running fortran exectuable using IDL spawn fails [message #93508] |
Tue, 09 August 2016 05:05  |
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   |
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 #93511 is a reply to message #93510] |
Tue, 09 August 2016 07:34   |
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
|
|
|
|