I see a lot online on using the flush
function in Fortran to flush output. I am wondering, specifically for Fortran 90, and specifically for stdout, what form this should take as a one-liner to put into my code?
My guess is flush(*)
.
flush()
is not a function, but either a non-standard intrinsic subroutine, and hence invoked in a call statement
call flush(unit_number)
or a standard statement in Fortran 2003, hence invoked as a statement
flush(unit_number)
Commonly, standard output is pre-connected to unit 6, but to be sure you can use the standard constant output_unit
from module iso_fortran_env
(see Standard input and output units in Fortran 90?)
That again requires Fortran 2003.
Note that almost any compiler nowadays supports these features. But if you really specifically need the 26 years old Fortran 90, then you must consult your compiler's manual, which unit numbers it uses for the pre-connected files. Very likely it will be 6 for standard output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With