I am having a problem with ALLOCATABLE arrays being used as arguments.
The situation:
SUBROUTINE PlotZahnrad(...)
USE qtSFD ! see below
...
TYPE (qtSFD_T_RadPaarung), ALLOCATABLE :: tRadPaar(:), tPaarfolge(:)
LOGICAL, ALLOCATABLE :: laRadGezeichnet(:)
...
DO iRd = iRdS, iRdE
...
CALL qtSFD_S_BestimmeRadpaarungen( tRk, nRaeder, iAnzZahnauswahl, iaZahnauswahl, &
tRadPaar, tPaarfolge, laRadGezeichnet )
...
IF ( ALLOCATED(tRadPaar) ) DEALLOCATE(tRadPaar)
IF ( ALLOCATED(tPaarfolge) ) DEALLOCATE(tPaarfolge)
IF ( ALLOCATED(laRadGezeichnet) ) DEALLOCATE(laRadGezeichnet)
END DO
END SUBROUTINE PlotZahnrad
MODULE qtSFD
TYPE qtSFD_T_RadPaarung
INTEGER(qt_K_SHORT) iRad(2)
CHARACTER(16) cBez(2)
INTEGER iBewertung
LOGICAL lIgnore
INTEGER iFolge
INTEGER iZahnauswahl
INTEGER :: iTreibendesRad = 0
END TYPE qtSFD_T_RadPaarung
...
CONTAINS
SUBROUTINE qtSFD_S_BestimmeRadpaarungen( tRk, nRaeder, iAnzZahnauswahl, iaZahnauswahl, &
tRadPaar, tPaarfolge, laRadGezeichnet )
TYPE (qtSFD_T_Raederkette), INTENT(INOUT) :: tRk
INTEGER, INTENT(IN) ::nRaeder
INTEGER, INTENT(IN) :: iAnzZahnauswahl ! Anzahl Zahnauswahlvorgaben
INTEGER, INTENT(INOUT) :: iaZahnauswahl(iAnzZahnauswahl)
TYPE (qtSFD_T_RadPaarung), INTENT(OUT), ALLOCATABLE :: tRadPaar(:)
TYPE (qtSFD_T_RadPaarung), INTENT(OUT), ALLOCATABLE :: tPaarfolge(:)
LOGICAL, INTENT(OUT), ALLOCATABLE :: laRadGezeichnet(:)
...
END SUBROUTINE qtSFD_S_BestimmeRadpaarungen
END MODULE qtSFD
When PlotZahnrad(...) is being called and the do loop is run only once (iRdS = iRdE) then everything is fine.
However if I call PlotZahnrad(...) and iRdE > iRdS such that the do loop is run at least twice, the program
crashes when calling qtSFD_S_BestimmeRadpaarungen() in the second do loop round (the first one went fine). The
traceback tells me that there is an "access violation". In the debugger, the crash occurs exactly at the head
of the SUBROUTINE qtSFD_S_BestimmeRadpaarungen. It appears to me that there is a problem with the allocatable
array arguments.
So I have checked that the allocatable arrays are in fact de-allocated before the call of
qtSFD_S_BestimmeRadpaarungen(). I have also tried to run without "array boundary checks disabled" or I turned
on "AUTOMATIC variables". All in vain. I wonder what I am doing wrong. Or, is there a bug in the compiler? I am
still using v9.1.032. Does someone has an idea?