Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26736 Discussions

Write to screen in the same line - Debug vs Release Mode

Peter_F_5
Beginner
135 Views

I am trying Fortran to output to screen without making paragraphs - i.e. output several times but in a row. The code below outputs correctly to screen if I compile the program and run it from the command line. However, it does not output to screen if I am using the debug feature of Visual Studio. Is there any work around or a better solution to this?

program test
   implicit none
   integer :: ind
   do ind = 1,20
      write(*,'(1x,i0)',advance='no') ind
      !Some other stuff here
   end do
end program
0 Kudos
2 Replies
Steve_Lionel
Black Belt Retired Employee
135 Views

That's very interesting, and I can reproduce the behavior. While if one runs the program not under the debugger, you see the output, if you step through the program with the debugger output never appears, even at the end of the program.

I did find a workaround. Change the WRITE(*) to WRITE(6) and add, after the WRITE:

flush(6)

If you change the project property Fortran > Language > Enable F2003 Semantics to Yes, you don't have to change the WRITE, though to be formally correct you should change the program to:

program test
   use, intrinsic :: ISO_FORTRAN_ENV
   implicit none
   integer :: ind
   do ind = 1,20
      write(*,'(1x,i0)',advance='no') ind
      flush(OUTPUT_UNIT)
      !Some other stuff here
   end do
end program

I recommend that you report this problem to Intel using https://supporttickets.intel.com/

Peter_F_5
Beginner
135 Views

Hi Steve, 

That worked perfectly. I will report the problem to Intel in any case.

Thanks,
Peter

Reply