(j3.2006) derived types with type parameters are different

Robert Corbett Robert.Corbett
Mon Jul 28 22:48:00 EDT 2008


Here are updated versions of my second and third programs with the
fixes Bill Long suggested.

-------------------------------------------------------------------

       MODULE M1
         INTERFACE S
           SUBROUTINE S1(X, M)
             TYPE T(N)
               INTEGER, LEN :: N
               SEQUENCE
               REAL A(N+N)
             END TYPE
             TYPE(T(M)) :: X
           END SUBROUTINE
         END INTERFACE
         TYPE T(N)
           INTEGER, LEN :: N
           SEQUENCE
           REAL A(N+N)
         END TYPE
         TYPE(T(2)) :: X
       END

       MODULE M2
         INTERFACE S
           SUBROUTINE S2(X, M)
             TYPE T(N)
               INTEGER, LEN :: N
               SEQUENCE
               REAL A(2*N)
             END TYPE
             TYPE(T(M)) :: X
           END SUBROUTINE
         END INTERFACE
         TYPE T(N)
           INTEGER, LEN :: N
           SEQUENCE
           REAL A(2*N)
         END TYPE
         TYPE(T(2)) :: X
       END

       SUBROUTINE S1(X, M)
         TYPE T(N)
           INTEGER, LEN :: N
           SEQUENCE
           REAL A(N+N)
         END TYPE
         TYPE(T(M)) :: X
         PRINT *, 'CALLED S1'
       END

       SUBROUTINE S2(X, M)
         TYPE T(N)
           INTEGER, LEN :: N
           SEQUENCE
           REAL A(2*N)
         END TYPE
         TYPE(T(M)) :: X
         PRINT *, 'CALLED S2'
       END

       PROGRAM MAIN
         USE M1, ONLY: S, X
         USE M2, ONLY: S, Y=>X
         CALL S(X, 2)
         CALL S(Y, 2)
       END

-----------------------------------------------------------------------

       MODULE M1
         TYPE T(N)
           INTEGER, LEN :: N
           SEQUENCE
             REAL A(N+N)
         END TYPE
         TYPE(T(2)) :: X
       END

       MODULE M2
         TYPE T(N)
           INTEGER, LEN :: N
           SEQUENCE
             REAL A(2*N)
         END TYPE
         TYPE(T(2)) :: X
       END

       PROGRAM MAIN
         USE M1, ONLY: X
         USE M2, ONLY: Y=>X
         X%A = 0.0
         Y = X
         PRINT *, X, Y
       END

----------------------------------------------------------------------------



More information about the J3 mailing list