Welcome to Intel® Software Network Quick Login | Join | Help |
Search in Intel® Software Network Forums
in Go

ALLOCATABLE arrays being used as arguments in a SUBROUTINE

Last post 05-18-2008, 5:40 AM by Steve Lionel. 3 replies.
Sort Posts: Previous Next
 05-17-2008, 8:17 AM 30254986  

ALLOCATABLE arrays being used as arguments in a SUBROUTINE

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?

 
 05-17-2008, 1:54 PM 30254988 in reply to 30254986  

Re: ALLOCATABLE arrays being used as arguments in a SUBROUTINE

Hi Joerg,

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

Gib
 
 05-18-2008, 2:58 AM 30254998 in reply to 30254988  

Re: ALLOCATABLE arrays being used as arguments in a SUBROUTINE

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 the extra work caused by the new installation and testing. So, I didn't try so far.

Joerg

 
 05-18-2008, 5:40 AM 30254999 in reply to 30254998  

Re: ALLOCATABLE arrays being used as arguments in a SUBROUTINE

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.

Steve

Doctor Fortran: intel.com/software/drfortran
 
View as RSS news feed in XML

Shortcuts


Tags For This Post

...

Community Tags

...