Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28630 Discussions

ALLOCATABLE arrays being used as arguments in a SUBROUTINE

joerg_kuthe
Novice
293 Views

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?

0 Kudos
3 Replies
gib
New Contributor II
293 Views
Hi Joerg,

If I were you I'd try to simplify the code down to the simplest case that reproduces the problem.

Gib
0 Kudos
joerg_kuthe
Novice
293 Views

Thanks for your advice, but this doesn't help me in this case.

I hoped that someone has had a similar problem and found a solution.
For example, telling me that I could get rid of that problem by updating to v10.1.
I am reluctant to this because I am afraid of running into other troubles and theextra work caused by the new installation and testing. So, I didn't try so far.

Joerg

0 Kudos
Steven_L_Intel1
Employee
293 Views
First of all, you can install 10.1 without removing your 9.1, so there is no risk. You can select which compiler you want to use in Visual Studio with Tools > Options > Intel Fortran > Compiler (with 10.1 installed).

You left out some critical parts - such as whether the allocatable variables are arguments to the outer routine. I'll guess they are not. I have seen various issues with local allocatable variables in the past, and if your program happens to run into one of these (I have no way to know for sure), you should find 10.1 an improvement.
0 Kudos
Reply