- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am experiencing a strange problem - my program has started behaving as though it is using Fortran 66 DO loops (executes once regardless) without any provocation.
I went to make some minor modifications to a program using a long-standing workspace set-up that has not been (consciously) changed in a long time. Here is the sequence of events:
- I made a few minor changes.
- Got good results but needed to use the debugger to sort some things out.
- The first few times through, everything worked as expected. Located problems, fixed them, re-ran the debugger, etc.
- At one point, I started getting an array bounds error in another (untouched) part of the code.
- I checked it out through the debugger and discovered that it was executing the first cycle of a DO loop for which the start and stop counters were both zero (e.g. do i = i1, i2 where i1=0 and i2=0). This is reminiscent of the old days when Fortran 66 forced one cycle regardless of the values.
- I verified that the F66 semantics switch (/f66) was off. I even went so far as to add "/nof66", to which I got the following error message: "df: error: Negation of '/nof66' switch not allowed"
- I then created a whole new Project and Workspace from scratch, added the code files, set up the Compile and Link options, etc.
- It compiled and ran successfully a couple of times, and then, without any significant change, reverted to the F66 behavior!
I am baffled. Any ideas?
Thanks,
Steve
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look at the Disassembly window?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This symptom is most often a case of memory corruption - some other part of the program writing on a memory location it shouldn't be. One common way this can happen, especially in CVF, is if you are calling non-Fortran routines and get the calling convention wrong, so that the stack is corrupted.
Given the other things you mentioned, it seems likely that some code in your application is writing where it shouldn't. Unfortunately, this can be hard to track down. First thing to do is to verify all calling sequences and turn on bounds checking. Might not hurt to turn on /warn:declarations (IMPLICIT NONE) to make sure all your variables are properly declared.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While I agree that such random behaviour indicates memory corruption somewhere, I have to note that, in f77 onwards...
I checked it out through the debugger and discovered that it was executing the first cycle of a DO loop for which the start and stop counters were both zero (e.g. do i = i1, i2 where i1=0 and i2=0). This is reminiscent of the old days when Fortran 66 forced one cycle regardless of the values.
... do i=0,0 should loop once. OTOH, do i=1,0 should not loop at all. I don't know if it was a typo in posting, or the code was always broken...
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav is correct, of course. 0,0 should loop once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmmmm .... You are right of course, Jugoslav. i=0,0 should loop once.
Now I have to figure out why it hadn't caused a problem earlier ... The random nature of it is still bothersome. I will go back and follow some of your suggestions, Steve, to try to get to the bottom of it.
Thanks for your help guys.
Steve H.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page