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

Jim Xia jimxia
Mon Jul 28 22:59:57 EDT 2008


I don't fully understand what your intention is in this thread of 
discussions.  If the goal is to remove type parameter feature for sequence 
type, then I'm afraid to say it's too late.  At least IBM has invested a 
great amount in implementing this feature, and we wouldn't want to see the 
investment go wasted.  To answer your technical questions, IBM's compiler 
accepts 2*N vs. N+N case, regardless KIND or LEN type parameters,  For 
your 3 examples (with syntax fixes of course), we diagnose the first two 
examples because generic name S is ambiguous (we treat N*2 the same as 
N+N, also I assume the 2nd example is testing LEN instead of KIND).  For 
the last example we compiles without a problem.

Again, I don't see much of the point to keep discussing this.  Sequence 
type with type parameter is one of the easiest fraction in the entire 
parameterized derived type feature.  You barely scratched the surface on 
this monstrous feature yet.  If you can not overcome the sequence type, 
then I don't know when or ever you'll be able to get the whole thing done.


Cheers,


Jim Xia

RL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444  Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM

j3-bounces at j3-fortran.org wrote on 07/28/2008 09:59:55 PM:

> Bill Long wrote:
> > 
> > Robert Corbett wrote:
> > 
> >>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
> >> 
> > 
> > 
> > This one compiled and output:
> > 
> > CALLED S1
> > CALLED S2
> 
> So your compiler decides that the attributes of the components
> REAL A(N+N) and REAL A(2*N) are different.  I assume it uses
> some form of lexical matching to decide that the bounds expressions
> are different.  According to my understanding of James Xia's
> description of what IBM's compiler does, if the bounds expressions
> had been N and N+0 instead of N+N and 2*N, IBM's compiler would
> consider the two derived types to be the same type.  What does
> Cray's compiler do in that case?  What if the bounds expressions
> were N+2 and N+02?
> 
> Bob Corbett
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080728/e457ef9c/attachment.html 



More information about the J3 mailing list