Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28459 Discussions

Fortran write to Visual Studio's output window?

AONym
New Contributor II
776 Views

I'm looking for a way to have a Fortran pgm write to Visual Studio's output window.

I can do so now using  the subroutine `OutputDebugString` in library `IFWINA`.

Is there a simpler way to do this? I have tried `WRITE(*, format)`, but this doesn't produce anything in Visual Studio's output window.

Visual Studio 2022 (17.6.0), Intel Fortran compiler 2023.0.0, Windows 11.

0 Kudos
1 Solution
FortranFan
Honored Contributor II
756 Views

OutputDebugStringA is - from what I recall - what Microsoft itself recommends:

https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa

 

How much simpler can it get once you realize the Fortran language has no business recognizing anything like the Visual Studio output window?

View solution in original post

0 Kudos
3 Replies
FortranFan
Honored Contributor II
757 Views

OutputDebugStringA is - from what I recall - what Microsoft itself recommends:

https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa

 

How much simpler can it get once you realize the Fortran language has no business recognizing anything like the Visual Studio output window?

0 Kudos
JohnNichols
Valued Contributor III
717 Views

I had a small chuckle at your comment.  The debug window is useful for looking at information that you do not want on the main screen as your program progresses, Fortran is there to do the formula translation, the rest is just fluff to get the data in and the results out.  

It is nice when you have a program that generates 0.5 million FE bricks tell you on  a different screen that brick 15 is now working when it has not been since last night.  Of course I do not use the debug screen in Fortran, just the main console, but it is a god send in C#. 

O! for the days of Fortran II and a good PDP, we could all go back to a simpler life, no facebook, no windows and no C# or Python.  

Ulrich_M_
New Contributor I
707 Views

I just route all print output by default to the output window by starting an "external tool" that consists of the following batch file

 

@Echo off
SETLOCAL
set SAVESTAMP=%DATE:~4%
set SAVESTAMP=%SAVESTAMP:/=-%@%TIME::=-%
set SAVESTAMP=c:\mfortran\output%SAVESTAMP: =%.txt
%1\x64\Release\mfortran.exe | mtee.exe %SAVESTAMP%

with the "$(ProjectDir)" as argument and the "Use Output Window" option checked. I this way, the output appears within the IDE (no console window), and I have a copy of the text output in a txt file that I can inspect later or during a run with another text editor.

0 Kudos
Reply