Does gfortran have c or cpp like automatic stdout buffer? If yes how to enable it?
I was playing around with strace and found that gfortran doesn’t seem to buffer anything. Single character write is directly called for each character if fortran program calls write(*,*)
character by character.
write(1, "W", 1) = 1
write(1, "X", 1) = 1
write(1, "Y", 1) = 1
write(1, "Z", 1) = 1
write(1, " \n", 2) = 2
write(1, "1", 1) = 1
write(1, "2", 1) = 1
write(1, "3", 1) = 1
write(1, "4", 1) = 1
write(1, "M", 1) = 1
write(1, "N", 1) = 1
This makes printing something to terminal significatly slower (even the terminal starts using too much CPU)
VScode integrated terminal is consuming more CPU than the program itself. ( same with terminal emulators written in compiled languages).
Is there some way to enable it or is this absent in gfortran?
example code :
program test
implicit none
INTEGER::i
do while(.true.)
do i=49,90
WRITE(*,"(A)",advance="no")achar(i)
enddo
print*,""
enddo
end program test
C equivalent in this reply