Integer changes mid-execution
Jerry DeLisle
jvdelisle@verizon.net
Wed Nov 4 09:56:00 GMT 2009
On 11/03/2009 05:21 AM, Nishita Desai wrote:
> On Tue, Nov 3, 2009 at 17:19, N.M. Maclaren<nmm1@cam.ac.uk> wrote:
>> On Nov 3 2009, Nishita Desai wrote:
>>>
>>> What happens is that suddenly at the end of the third iteration,
>>> NPART changes value. Here is a gdb transcript:
>>>
>> Somewhere in the code you are executing, you are overwriting NPART.
>> That is usually due to a subscript being larger than the size of an
>> array, but there are many other possible causes.
>
> Thanks for your reply Nick. You were right, that was the case.
> However, I don't understand why this should happen. I can understand
> if P(I,NPART) points to some garbage value, or that I shall get a
> segmentation fault. But why is the array index variable overwritten?
If memory is being overwritten beyond the extent of an array you likely will hit
other variables that are stored in adjacent locations.
Try -fbounds-check when you compile. It may give you some interesting results.
Jerry
More information about the Fortran
mailing list