[J3] sequence type equality

Robert Corbett rpcorbett at att.net
Wed Oct 14 21:29:37 EDT 2020


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
> 
> 
> 
> 



More information about the J3 mailing list