Finally I was able to pinpoint this nasty bug - but at a completely different location than flagged by this errormessage (see my previous posting).
Here is the first part of the routine in Question:
subroutine EG_Plants()
use EG_Data
implicit none
include <windows.ins>,nolist
INTERFACE
integer function EG_KillPLant(pPlantActual)
type (Plants), pointer :: pPlantActual
end function EG_KillPlant
integer function EG_NewPlant (pMother, cMode)
type (Plants), pointer :: pMother
character(*), intent(in) :: cMode
end function EG_NewPlant
END INTERFACE
integer EG_NewPlant
integer EG_KillPlant
character*20 cBuffer
integer iRslt
integer EG_Pause
type (Plants), pointer :: pPlantNext
type (Plants), pointer :: pPlantActual ! Zeiger auf aktuelle Pflanze.
iRslt = 0
iRslt = iRslt ! Vermeiden der Warnung
if (iiTSeed .eq. iiNTage) then
nullify (ppPlantCurrent)
iRslt = EG_NewPlant (ppPlantCurrent, 'AUSSAAT') ! ppPlantCurrent wird bei der Aussaat eigentlich nicht gebraucht!
return
endif
if (iiNPlants .le. 0) return
pPlantNext => ppPlantHead
! Lebenslauf der Pflanzen
do
if (.not. associated(pPlantNext)) exit
pPlantActual => pPlantNext
nullify (pPlantNext)
if (associated (pPlantActual%pNext)) pPlantNext => pPlantActual%pNext
! Keimung und ggf. Vertrocknen der Samen
if (pPlantActual%lSeedFlag) then ! Wenn dieses Teil noch Samen ist ...
if (ttPlanSquares(pPlantActual%iPlanX, pPlantActual%iPlanY)%iWater .gt. 0) then ! ... und es gibt Wasser
pPlantActual%iWater = min (iiMaxValue, pPlantActual%iWater + 1) ! dann Wasser um 1 erhöhen
if (pPlantActual%iWater .gt. pPlantActual%iSeedWater) then ! Wenn die gespeicherte Wassermenge die zum Keimen erforderliche Menge übersteigt, dann keimen
pPlantActual%lSeedFlag = .false.
pPlantActual%iAge = 0
pPlantActual%iWater = 0
pPlantActual%iTNextSpread = iiNTage + pPlantActual%iSpreadMinAge
iiNSeeds = iiNSeeds - 1
endif
else
pPlantActual%iAge = pPlantActual%iAge + 1 ! Restlebensdauer als Samen um 1 verringert
if (pPlantActual%iAge .ge. pPlantActual%iSeedSurvivalActual) then
iRslt = EG_KillPlant(pPlantActual) ! Wenn vertrocknet, dann löschen
cycle ! < - this was the line flagged by the errormessage
endif
endif
else ! Ist kein Samen mehr, sondern gekeimte Pflanze
! Alter, Tod wenn maximalalter überschritten
! pPlantActual%iAge = ppPlantCurrent%iAge + 1 ! < - This was the faulty codeline
pPlantActual%iAge = pPlantActual%iAge + 1 ! < - This is the proper codeline.
if (pPlantActual%iAge .gt. pPlantActual%iPlantMaxAgeActual) then
iRslt = EG_KillPlant(pPlantActual) ! Wenn überaltert, dann löschen
cycle
endif
Second part will follow with my next reply.
I indicated where the error was flagged and the codeline that proved faulty in reality, that is, where this dangling pointer occurred. Note: the loop was processed three times after the flagged line was processed for the last time before the error occurred.
I am happy with my program running - but somebody might be interested to look into this matter.