Re: Really wierd bug
From: Rich Townsend (rhdt_at_barVOIDtol.udel.edu)
Date: 08/18/04
- Next message: Jugoslav Dujic: "Re: Binary operations in FORTRAN"
- Previous message: Paul Van Delst: "Re: Arrays in Fortran 77"
- Next in thread: Jugoslav Dujic: "Re: Really wierd bug"
- Maybe reply: Jugoslav Dujic: "Re: Really wierd bug"
- Maybe reply: Rich Townsend: "Re: Really wierd bug"
- Maybe reply: John Mansell: "Re: Really wierd bug"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 18 Aug 2004 11:32:21 -0400
justabeginner wrote:
> Hi. I've written a simple program that optimises mathematical
> functions based on the principles of a genetic algorithm.
>
> The variables are population size, mutation rate, generations to
> create, etc.
>
> It works 99% of the time, and only fails once the population size is
> set to 70. Otherwise, it works for population sizes of 15, 69, 71,
> 100, 150, etc. I don't know what so special about 70 but I'm thinking
> it has to be a compiler bug because it works fine for other population
> sizes as indicated above.
>
> The error I get is:
> "forrtl: severe (161): Program Exception - Array Bounds Exceeded".
>
> My compiler is Compaq Visual Fortran 1997-1999. It has nothing to do
> with allocating the array sizes because I've defined the arrays as
> allocatable in size and the program allocates space depending on the
> population size.
>
> I've attached the program below for those who are interested in taking
> a look. I've located the offending line causing the error; just search
> for and jump to keyword 'ERROR'. It is between 2 print statements.
<snip program>
Hi --
I've tried compiling your code using the Lahey lf95 compiler. Firstly,
you have a bug on line 326 -- an extra comma after '(1,*)'.
Secondly, your program does indeed contain an array bounds error -- this
is not a compiler bug. Running with a population size of 70, I get the
following error (with array-bounds checking enabled):
The subscript or substring population is out of the specified range
(reference value: 2,0,1, specification value: 1:13,1:70,1:2).
Error occurs at or near line 222 of MAIN__
You have correctly identified the offending line as:
population(i+1,j,2) = population(i+1,select2,1)
The problem is occuring because, for some reason, your subscript select2
has the value zero. I suggest you find out what is causing this.
Other points worth noting: the variables gencount, generations and
prev_fit are not declared anywhere in the code. This may well be a
mistake, since implicit typing rules will mean that both gencount and
generations are declared as REAL rather than INTEGER. To avoid making
mistakes like this, you should put an 'implicit none' at the top of each
program/subroutine/function.
Finally, I've tried running your code using undefined variable checking.
This produces the runtime error:
The variable (population(10,1,1)) has an undefined value.
Error occurs at or near line 90 of MAIN__
I suggest that you make sure the population array is properly
initialized before you reference it.
cheers,
Rich
-- Dr Richard H D Townsend Bartol Research Institute University of Delaware [ Delete VOID for valid email address ]
- Next message: Jugoslav Dujic: "Re: Binary operations in FORTRAN"
- Previous message: Paul Van Delst: "Re: Arrays in Fortran 77"
- Next in thread: Jugoslav Dujic: "Re: Really wierd bug"
- Maybe reply: Jugoslav Dujic: "Re: Really wierd bug"
- Maybe reply: Rich Townsend: "Re: Really wierd bug"
- Maybe reply: John Mansell: "Re: Really wierd bug"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|