[J3] [EXTERNAL] sequence type equality
Clune, Thomas L. (GSFC-6101)
thomas.l.clune at nasa.gov
Wed Oct 14 16:28:59 EDT 2020
Bob,
Almost a correct program - just an extra comma in the PRINT statement on line 43.
The code compiled with 2 compilers and was rejected by a 3rd due to invalid assignments of different structure types.
- Tom
On Oct 14, 2020, at 4:07 PM, Robert Corbett via J3 <j3 at mailman.j3-fortran.org<mailto: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
T
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201014/079d7a76/attachment-0002.htm>
More information about the J3
mailing list