Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

do loop 4

Status
Not open for further replies.

Forscher

Technical User
Feb 2, 2012
14
GB
I am running SilverFox FTN 95 with Plato on a Windows PC with XP Prof.
I have run a program that contains an error, I have isolated the error as this:
&&&&&&&&&&&&&&&&&&&
do loop J=0,N
print*,'J=', J
end do
&&&&&&&&&&&&&&&&&&
This works fine for any value of N up to and including 297. However, for all values of N>297, say 1,000 I get J values printed running from (N-297) to N, i.e. 727,728,729,....1,000.
If it were an array, I could understand, but this loop doesn't require more memory the bigger it is. Or does it?
Has anyone any ideas?
 
That's just weird...certainly the problem is not here, it is somewhere else...this is just a side effect...you may have arrays somewhere else that is stepping on somebody else's memory or something.

Have you compiled your program with run time error debugging flags, array length over-running or anything?

If the problem is really, really hard to solve, I have had to fall back to re-starting to "write" the program, meaning, I start a new file and start copying the code over in meaningful chunks, compile and run and see when the guilty piece of code transfers over...
 
Code:
do [COLOR=red]loop[/color] J=0, N
...
would not work in fortran. It must be
Code:
do J=0, N
...
 
Oh, I am not familiar with "SilverFox FTN 95 with Plato", I thought Forscher at least had the syntax correctly and truly had a memory problem, but if "do loop" is not allowed in SilverFox, like in the regular Fortran, then, that is true that the construct

do loop J=0, N
end do

is not quite correct for what is intended. Actually, it is equivalent to

do loopJ=0, N
end do

In other words, the space is being ignored and the loop variable should turn out to be "loopJ"...you can confirm this by writing that one instead. So, J is not being assigned anything for that matter.
 
Hi,
I do not know about the Silverfox compiler, but the docs of my good old Compaq Compiler give for the do statement the form

[name:] DO [label[, ] ] [loop-control]

with label to be a statement label while loop control is the well known index = start, end, step.
So if by chance Forscher's loop is an integer variable or constant and equals a label number, the results could be very unpredictable.

Norbert
 
Sorry, my mistake. of course I wrote:
Do =1,N
Forscher
 
Now, you went to the other extreme! "Do =1,N"? What happened to J? You know, there is such thing as copy/paste.

Lastly, of course you wrote ... so, are you saying that the word "loop" is not there? do you still have the problem first posted?
 
Yes. sorry again. I am sitting watching TV and using my iPad.
I wrote:
Do J=1,1000
Print*, 'J=', J
End do
Apologies again
Forscher
 
I have some good news for Fortran programmer(s): it's not (Silverfrost) Fortran issue.

By default Windows allocates console window buffer for 300 lines only. You can see last 300 lines of the program output (~297 printed lines + 3 lines of the Plato termination messages).

Change (increase) console window default buffer size (see Windows help - it's so easy;)...
 
Thanks ArkM, you are a star. Before I read your message I had re-typed the program (it's really to small to be justify the name program) on a second, old machine I have downstairs and still got the same problem.
Thanks again
Forscher
 
Ha! Good catch ArkM.

Forscher, in your last post, you used the word "still" ...does that mean that you still do not have a solution to your problem?

To test if ArkM is right, please run your program and re-direct your output from standard output (stdout) to a file, like this:

c:\myfolder\myprogram > outfile.txt

And see what you get.
 
Hi Salgerman,
What I meant was that the behaviour of the program was the same in two PCs.
Here is my new code (cut & pasted).
%%%%%%%%%%%%%%%%%%%
program Jtest
implicit none
integer J
OPEN(unit=9,file='data.txt')
do J=1, 500
write(9,999) J
999 Format(I3)
end do
close(unit=9)
end program Jtest
%%%%%%%%%%%%%%%%%%%
This works fine. All values from 0 to 500 recorded in txt file.
Thanks for your comment. Thanks everyone for your interest.
Incidentally, it is many years since I last used FTN; last time, I had to put the program onto punched cards !!!
Good website this.
Cheers
Forscher

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top