- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Forum Members,
I am using the Intel Fortran Compiler Version 11.1, the code I am working with uses extensively memory allocation. What I am trying to do is run the code in a loop. Te problem is that this code allocates memory but some of the arrays are not deallocated. It has a fortran STOP in the end which frees the memory, when the code finishes. However if I put a loop around it the code tries to allocate arrays which are already allocated. One can check this issue quite conveniently whith the following command:
If (allocated(array(size))) deallocate (array)
allocate(array)
This is however quite difficult to implement because I have about 800 places where the allocation is done.
In principle if the arrays are allocated inside a subroutine and they are not declared with “SAVE” after the RETURN statement in the end, they are deleted. However there are many places with SAVE statement in my code.
My question is how can I check precisely where this double allocation is taking place. The code tells me just that I have double allocation error, but where exactly and which array is causing the problem is not mentioned. I hope that this can be solved with compiler flags. I have also license for the Visual Fortran compiler, in case necessary I am able to switch to it.
I would appreciate any ideas how to overcome this problem.
Thank you in advance
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code tells me just that I have double allocation error, but where exactly and which array is causing the problem is not mentioned.If you compiled with /traceback, you already know "where exactly" in terms of routine and source line number. In an EXE compiled in "release" mode, variable names do not get stored, so if you have multiple variables in a single ALLOCATE statement the run-time cannot tell you the name of the individual variable which caused the problem. Nor am I sure that knowing the name of the variable would help you much, since that variable may have been allocated and deallocated a number of times already. Even if you break up the ALLOCATE statement into multiple statements each of which allocates one variable, locate the one that caused an error and "fix" that particular instance by writing IF(.NOT.ALLOCATED(varname))ALLOCATE(varname(..)), there is no immunity from further errors arising from one of the other variables. Some compilers enable producing a log file of allocations and deallocations, but with your 800 places where allocation is done perusing the log file may take "forever". Ultimately, planning and managing allocations that one chooses to do with ALLOCATE/DEALLOCATE is something the programmer has to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page