Well, following up on the yorelchr's recent thread on stack overflow, here is my version, that I would like to have solved better than I have now.
The following codelines are part of a longer program that I tried to boil down on the essentials:
If I use the read statement version 1 everything is fine - except that the read takes some time - whereas version 2 gives me a stack overflow error.
This routine is my data input routine and is executed only once per program run. However, as the data are saved in a linked list, this part of the prog is executed as often as tiles are available. I simply hate to increase memory allocation, as there might be bigger files to read in the future and then my prog would fail again.
So what to do ?
Norbert
The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
The following codelines are part of a longer program that I tried to boil down on the essentials:
Code:
type metatile
.
.
integer*1, dimension (:), pointer :: pTexPixels ! pointer to array of pixels for texture
.
.
type (metatile), pointer :: pNext
type (metatile), pointer :: pLast
end type metatile
.
type (metatile), pointer :: ppMetaTileHead, ppMetaTileTemp, ppMetaTileTail
.
.
(allocating memory for ppMetaTileTail )
.
.
iByteNumber = 3 * iiTexWidth * iiTexHeight
! typically value of iiTexWidth and iiTexHeight are 1024 or 2048 each.
allocate (ppMTilesTail.pTexPixels (iByteNumber), stat = irslt)
if (irslt .ne. 0) then
(errormessage)
endif
.
.
open (unit = IO_BMP, file = cFile, form ='BINARY', status = 'OLD', iostat = irslt)
.
.
! (Version 1)
! if (irslt .eq. 0) read (IO_BMP, iostat = irslt) (ppMTilesTail.pTexPixels (j), j = 1, iByteNumber)
! (Version 2)
if (irslt .eq. 0) read (IO_BMP, iostat = irslt) ppMTilesTail.pTexPixels
.
.
if (irslt .ne. 0) then
(errormessage)
If I use the read statement version 1 everything is fine - except that the read takes some time - whereas version 2 gives me a stack overflow error.
This routine is my data input routine and is executed only once per program run. However, as the data are saved in a linked list, this part of the prog is executed as often as tiles are available. I simply hate to increase memory allocation, as there might be bigger files to read in the future and then my prog would fail again.
So what to do ?
Norbert
The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.