Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Problem With A Subroutine With Class and Pointer attribute

$
0
0

I have a larger program that passes a data type into a deallocation subroutine that is a pointer, but the compilation fails saying the data type does not match.

Here is a simplified version of the code:

      MODULE DATATYPE
      TYPE EX1
          INTEGER,DIMENSION(:),ALLOCATABLE:: A
      END TYPE
      !
      TYPE, EXTENDS(EX1)::EX
          INTEGER:: B
      END TYPE
      !
      CONTAINS
      !
      SUBROUTINE SUB(STRUCT)
      CLASS(EX1),POINTER:: STRUCT
      !
      SELECT TYPE(STRUCT)
      TYPE IS (EX)
          DEALLOCATE(STRUCT)
      END SELECT
      !
      END SUBROUTINE
      END MODULE
      
      PROGRAM MAIN
      USE DATATYPE
      TYPE(EX),POINTER:: STRUCT
      !
      ALLOCATE(STRUCT)
      CALL SUB(STRUCT)
 
      END PROGRAM

The compiler error I get is:

Error    1     error #6633: The type of the actual argument differs from the type of the dummy argument.   [STRUCT]   

 

The code works fine if I drop the POINTER attribute where I say CLASS(EX1),POINTER:: STRUCT

Is this a compiler error or is there no way to have the POINTER attribute with CLASS.

 

Thanks in advance as always!


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>