strange memory leak
mattias alveteg
Mattias.Alveteg@chemeng.lth.se
Wed Oct 18 13:37:00 GMT 2006
Hi,
If the problem described below is already known, please ignore this
message:
I got runtime error messages when running some code, compiled with
GFortran 4.2.0 (2006-10-15) containing the following code (inside a
module)
subroutine EvaluateStateError(states1,error)
implicit none
real(rk),dimension(:,:),intent(in) :: states1
real(rk),intent(out) :: error
integer :: i(1),j(1)
real(rk) :: Diff(size(states1,1),size(states1,2))
error = maxval(abs(diff))
i=maxloc(abs(diff),dim=1)
j=maxloc(abs(diff),dim=2)
...
Changing the last 3 lines to this:
diff=abs(diff)
error = maxval(diff)
i=maxloc(diff,dim=1)
j=maxloc(diff,dim=2)
made the runtime error disappear. My guess is that some temporary
variable is created (since abs(diff) appears three times) and that
the compiler for some reasons tries to free that memory twice.
Since I found a workaround this has a rather low priority for me, but
please let me know if the problem is interesting enough that I should
try to isolate it (it'll take a few weeks before I have time to do that)
greetings
Mattias
More information about the Fortran
mailing list