Hi Guys, I've been debugging a code now for several hours and have noticed something wierd (turns it out was the source of my error).
I have been using fortran on and off for several years now, I have a lot of experience with Matlab and thought that I understood programming structure pretty well until today. I was surprised by the output of the following few lines of code:
program testing_loop
!-----------------
INTEGER :: I
!-----------------
DO I=1,10
WRITE(*,*) I
ENDDO
WRITE(*,*) 'Loop has ended'
WRITE(*,*) 'I=', I
end program testing_loop
The output, I was surprised to find, was the numbers 1 through 10 followed by: 'Loop has ended I=11'.
I thought that the loop, having terminated when I=10, would produce the output 'I=10' but for some reasons it has incremented the I counter to 11. The same piece of code in matlab, for example, would give an output of 10 and this is what I expected here.
Is this normal behaviour for fortran? I wasn't aware of this feature until today, I've spent several hours debugging my code and it turns out that it had something to do with this; essentially I had assumed that after the loop the value of 'I' would be 10 and based my next set of calculations on this fact.
I'm happy to have found the bug but wondered if this is normal behaviour for FTN95?