I'm using Classic Eclipse 4.2.2 with the Photran plugin and cygwin's gfortran compiler on a Windows 7 Professional machine. If I remove 'call flush(6)' below, the program does not write to console until AFTER reading from std in:
program mult1
implicit none
integer :: i,j,k
!
!
! This program just multiplies two integers
! together.
!
!
write(*,*) 'Enter i,j: '
call flush(6)
read(*,*)i,j
k = i*j
write(*,*) 'The product is ', k
stop
end program mult1
Any thoughts or fixes?
I resolved the issue by preventing ALL buffering. This is not the perfect solution (it would be nice to buffer some outputs and not others), but it solves my problem---namely, not having to call flush(6) every time I write(,).
To prevent all buffering with gfortran (NOTE: It is compiler specific),
In the event that you are USING PHOTRAN (the eclipse plug-in for Fortran), you will have to do the following: