Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

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

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
Highlighted
Black Belt

That's very interesting, and

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/

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner

Hi Steve, 

Hi Steve, 

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

Thanks,
Peter

0 Kudos