DO-loop and WRITE strange behaviour
pedro albarran
pedro.albarran@uc3m.es
Sun Jul 3 11:53:00 GMT 2005
Dear all,
I have noticed a rare error when compiling a simple code with gfortran.
Consider the following code in which a WRITE command is included within
a DO-loop
---------------------------
PROGRAM SIMPLE
IMPLICIT NONE
INTEGER i
OPEN(1,FILE='out.txt')
DO i=1,1000
WRITE(1,*) i
END DO
END PROGRAM SIMPLE
-------------------------------
the output includes some strange jumps: after the number "585" you won't
see 586 but "631". At the end, you will find the number "1000", with
only 955 lines were written.
Some additional comments:
1) if you do the loop from "i=1,631", no jump occurs
2) it seems that the problems come from combining DO and WRITE; for
instance, if you fill-in an array with the same loop, it is fine.
Moreover, this is specific to gfortran: compiling with g95 or Visual
Fortran, everything is ok. Any ideas?
I have tried to look in the mailing list but I was not successful. Also,
sorry for not using GCC bugzilla, but I wasn't sure how to do it.
Best regards,
Pedro.
More information about the Fortran
mailing list