(j3.2006) derived types with type parameters are different
Robert Corbett
Robert.Corbett
Sat Jul 26 04:57:18 EDT 2008
Aleksandar Donev wrote:
> On Friday 25 July 2008 09:44, Bill Long wrote:
>
>> The feature is a pain to implement, so resistance to
>>doing it over a different way will be very high.
>
> But what way does Cray do---you seemed unsure of the actual answer? Can Robert
> please prepare two examples (one KIND, one non-KIND), including the mentioned
> generic interface, and see if Cray and IBM actually do the same thing?
> Aleks
Here are three programs that can be used to test how
bounds expressions affect type equivalence.
Different bounds expressions can be substituted for
those in the derived types.
Bob Corbett
-----------------------------------------------------------------
MODULE M1
INTERFACE S
SUBROUTINE S1(X)
TYPE T(N)
INTEGER, KIND :: N
SEQUENCE
REAL A(N+N)
END TYPE
TYPE(T(2)) :: X
END SUBROUTINE
END INTERFACE
TYPE T(N)
INTEGER, KIND :: N
SEQUENCE
REAL A(N+N)
END TYPE
TYPE(T(2)) :: X
END
MODULE M2
INTERFACE S
SUBROUTINE S2(X)
TYPE T(N)
INTEGER, KIND :: N
SEQUENCE
REAL A(2*N)
END TYPE
TYPE(T(2)) :: X
END SUBROUTINE
END INTERFACE
TYPE T(N)
INTEGER, KIND :: N
SEQUENCE
REAL A(2*N)
END TYPE
TYPE(T(2)) :: X
END
SUBROUTINE S1(X)
TYPE T(N)
INTEGER, KIND :: N
SEQUENCE
REAL A(N+N)
END TYPE
TYPE(T(2)) :: X
PRINT *, 'CALLED S1'
END
SUBROUTINE S2(X)
TYPE T(N)
INTEGER, KIND :: N
SEQUENCE
REAL A(2*N)
END TYPE
TYPE(T(2)) :: X
PRINT *, 'CALLED S2'
END
PROGRAM MAIN
USE M1, ONLY: S, X
USE M2, ONLY: S, Y=>X
CALL S(X)
CALL S(Y)
END
------------------------------------------------------------------------
MODULE M1
INTERFACE S
SUBROUTINE S1(X, M)
TYPE T(N)
INTEGER :: N
SEQUENCE
REAL A(N+N)
END TYPE
TYPE(T(M)) :: X
END SUBROUTINE
END INTERFACE
TYPE T(N)
INTEGER :: 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 :: N
SEQUENCE
REAL A(2*N)
END TYPE
TYPE(T(M)) :: X
END SUBROUTINE
END INTERFACE
TYPE T(N)
INTEGER :: N
SEQUENCE
REAL A(2*N)
END TYPE
TYPE(T(2)) :: X
END
SUBROUTINE S1(X, M)
TYPE T(N)
INTEGER :: N
SEQUENCE
REAL A(N+N)
END TYPE
TYPE(T(M)) :: X
PRINT *, 'CALLED S1'
END
SUBROUTINE S2(X, M)
TYPE T(N)
INTEGER, KIND :: 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 :: N
SEQUENCE
REAL A(N+N)
END TYPE
TYPE(T(2)) :: X
END
MODULE M2
TYPE T(N)
INTEGER :: N
SEQUENCE
REAL A(2*N)
END TYPE
TYPE(T(2)) :: X
END
PROGRAM MAIN
USE M1, ONLY: X
USE M2, ONLY: Y
X%A = 0.0
Y = X
PRINT *, X, Y
END
--------------------------------------------------------------------------------------
More information about the J3
mailing list