[J3] sequence type equality

Robert Corbett rpcorbett at att.net
Thu Oct 15 00:15:17 EDT 2020


To summarize, ifort considered
considered all four types to be
different, even the first two that
are textually identical and that do
not include default initializations.

Crayftn, gfortran, and pgfortran
considered all four types to be
same type, regardless of the
presence or absence of default
initializations.  The Sun/Oracle
compiler also ignores the
presence or absence of default
initializations.

In sum, all five compilers ignore
the presence or absence of
default initializations when
determining if two variables
that have types that are sequence
types have the same type.

Robert Corbett

> On Oct 14, 2020, at 8:02 PM, Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> Thanks to Robert and everyone else.
>  
> Looks like an interp is in order to decide this issue one way or the other. Preferably the good way!
>  
> I will write one.
>  
> Cheers,
> --
> ..............Malcolm Cohen, NAG Oxford/Tokyo.
>  
> From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Robert Corbett via J3
> Sent: Thursday, October 15, 2020 10:30 AM
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Robert Corbett <rpcorbett at att.net>
> Subject: Re: [J3] sequence type equality
>  
> I
> 
> Sent from my iPhone
> 
> > On Oct 14, 2020, at 1:27 PM, Bill Long via J3 <j3 at mailman.j3-fortran.org> wrote:
> > 
> > 
> > 
> >> On Oct 14, 2020, at 3:07 PM, Robert Corbett via J3 <j3 at mailman.j3-fortran.org> wrote:
> >> 
> >> Vipul and Malcolm questioned whether variables that
> >> have sequence types that differ only in that
> >> components have different default initializations
> >> should be considered to have the same type. The
> >> program given below cannot answer that question,
> >> but it can test whether a compiler does consider
> >> them the same or different. If the program compiles
> >> without reporting any type mismatches, it does not
> >> take differing default initializations into account
> >> when determining whether variables of sequence type
> >> have the same type.
> >> 
> >> I do not currently have access to a compiler, so
> >> please excuse any errors in the program.
> >> 
> >> Robert Corbett
> >> 
> >> ------------------------------------------------------------
> >> 
> >> MODULE TYPE0
> >> TYPE T
> >> SEQUENCE
> >> INTEGER :: I
> >> END TYPE T
> >> END
> >> 
> >> MODULE TYPE1
> >> TYPE T
> >> SEQUENCE
> >> INTEGER :: I
> >> END TYPE T
> >> END
> >> 
> >> MODULE TYPE2
> >> TYPE T
> >> SEQUENCE
> >> INTEGER :: I = 2
> >> END TYPE T
> >> END
> >> 
> >> MODULE TYPE3
> >> TYPE T
> >> SEQUENCE
> >> INTEGER :: I = 3
> >> END TYPE T
> >> END
> >> 
> >> PROGRAM MAIN
> >> USE TYPE0, T0 => T
> >> USE TYPE1, T1 => T
> >> USE TYPE2, T2 => T
> >> USE TYPE3, T3 => T
> >> TYPE(T0) V0
> >> TYPE(T1) V1
> >> TYPE(T2) V2
> >> TYPE(T3) V3
> >> V0%I = 0
> >> V1%I = 1
> >> V0 = v1
> >> PRINT *, V0%I
> >> V0 = V2
> >> PRINT, *, V0%I
> >> V2 = V3
> >> PRINT *, V2%I
> >> END
> > 
> > Summary:
> > 
> > Typo in original source. Fixed.
> > 
> > All the trials OK except Intel who complained at compile time.
> > 
> > Relevance: Since the advent of modules 3 decades ago, I’ve never se use of, or relevance of SEQUENCE types. 
> > 
> > Mystery: Why is SEQUENCE not in the Obsolescent list? 
> > 
> >> ftn test.f90
> > 
> > PRINT, *, V0%I
> > ^ 
> > ftn-1725 crayftn: ERROR MAIN, File = test.f90, Line = 43, Column = 14 
> > Unexpected syntax while parsing the PRINT statement : "operand" was expected but found ",".
> > ^ 
> >> emacs test.f90
> >> ftn test.f90
> >> ./a.out
> > 1
> > 2
> > 3
> >> module swap PrgEnv-cray PrgEnv-intel
> >> ifort test.f90
> > test.f90(40): error #6197: An assignment of different structure types is invalid. [V1]
> > V0 = v1
> > -------------^
> > test.f90(42): error #6197: An assignment of different structure types is invalid. [V2]
> > V0 = V2
> > -------------^
> > test.f90(44): error #6197: An assignment of different structure types is invalid. [V3]
> > V2 = V3
> > -------------^
> > compilation aborted for test.f90 (code 1)
> >> module swap PrgEnv-intel PrgEnv-gnu
> >> gfortran test.f90
> >> ./a.out
> > 1
> > 2
> > 3
> >> module swap PrgEnv-gnu PrgEnv-pgi
> >> pgf90 test.f90
> >> ./a.out
> > 1
> > 2
> > 3
> >> 
> > 
> >> 
> > Cheers,
> > Bill
> > 
> >> 
> > 
> > Bill Long longb at hpe.com
> > Engineer/Master , Fortran Technical Support & voice: 651-605-9024
> > Bioinformatics Software Development fax: 651-605-9143
> > Hewlett Packard Enterprise/ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
> > 
> > 
> > 
> > 
> 
> 
> Disclaimer
> 
> The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. Please see our Privacy Notice for information on how we process personal data and for details of how to stop or limit communications from us.
> 
> This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201014/fbb42995/attachment-0001.htm>


More information about the J3 mailing list