I have a subroutine that is called quite a lot during program execution. I try to use as many distributed arrays as possible, and the subroutine is called several times without any problems, but at some point it ends:
malloc.c:3790: _int_malloc: Assertion `(unsigned long)(size) >= (unsigned long)(nb)' failed.
this happens at the beginning of the routine when the first array is allocated.
Instead of using an unallocated array, the subroutine is called several times more often, but ends again, now:
wait: 28674: Memory fault(coredump)
I assume that it ends when called, because I write out some values ββimmediately after declaring the variables without any calculations. Call
do k=1, kreise write(*,*)k call rundheit(n(k),kreis(k,1:n(k),3),kreis(k,1:n(k),2),outrnd) end do
Where "kreise" can have values ββup to 1500. I printed and checked the values ββof the passed parameters before the call in the subroutine and after the call.
The kreise constraint does solve the problem, but the constraint is not a practical solution. I need all the data to evaluate. This is not a turning point.
Some notes in my environment:
My program is a routine compiled by FEM-Simulation software using the Intel Fortran compiler. As far as I know, I have no chance to change the compiler options, and I can not compile my code myself, because it has many dependencies on the routines deployed by the FEM software.
I developed and launched this exact subroutine on another, much smaller and simpler simulation without any problems. The actual βbigβ simulations are also performed without any problems if I do not use this particular subroutine (the difference is mainly in the density of the node and, therefore, the amount of data that are taken into account in the calculation). Another user routine works without a problem. All this subroutine is getting results between some increments, some analyzes and recording some reports without changing the simulation.
I guess the problem has something to do with memory processing, which I don't know about.
Thanks.
UPDATE
I compiled the subroutine with -check all and found that the error occurs before the subroutine. Two arrays, one of them n (), are not connected with each other several times, but the error becomes somehow (more) critical when called. The strange part is that these are some iterations outside the border when an error occurs, for example: here both arrays are (1:72) size, and the call is interrupted somewhere for k = from 135 to 267 (the lowest and highest values ββthat I found during some runs).
The problem is the Kreise integer whose value is set during the loop:
... allocate(n(l)) allocate(pos(l)) ... do kreise = 1,l pos(kreise)=minvalX+(Kreise-1)*IncX if(pos(kreise).gt.maxvalX) exit end do
Where Kreise will always be l + 1. Why?
NOTE: pos(kreise).gt.maxvalX should never be true. Becomeing true is not a problem, although it assumes that l was computed incorrect (large). This output will then save computation time by reducing iterations of several loops.