(j3.2006) question about IMPORT and derived types
Jim Xia
jimxia
Tue Apr 7 22:44:00 EDT 2009
You certainly haven't tried XL Fortran compiler. We compiled your code
without any problems.
Cheers,
Jim Xia
XL 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
From:
Robert Corbett <Robert.Corbett at sun.com>
To:
fortran standards email list for J3 <j3 at j3-fortran.org>
Date:
04/07/2009 10:15 PM
Subject:
(j3.2006) question about IMPORT and derived types
The following program fails to compile with every compiler I used
to compile it including Sun's:
MODULE MOD
TYPE T1
SEQUENCE
TYPE(T2), POINTER :: P
END TYPE
TYPE T2
SEQUENCE
INTEGER I
END TYPE
END
PROGRAM MAIN
USE MOD, T3 => T1, T4 => T2
TYPE T1
SEQUENCE
TYPE(T2), POINTER :: P
END TYPE
INTERFACE SUBR
SUBROUTINE SUBR1(X)
IMPORT T3
TYPE(T3) X
END SUBROUTINE
SUBROUTINE SUBR2(X)
IMPORT T1
TYPE(T1) X
END SUBROUTINE
END INTERFACE
TYPE T2
SEQUENCE
REAL X
END TYPE
END
SUBROUTINE SUBR1(X)
USE MOD
TYPE(T1) X
END
SUBROUTINE SUBR2(X)
TYPE T1
SEQUENCE
TYPE(T2), POINTER :: P
END TYPE
TYPE T2
SEQUENCE
REAL X
END TYPE
TYPE(T1) X
END
The problem, of course, is the definition of the derived
type T2 following the interface block. Section 12.3.2.1
of the Fortran 2003 standard says regarding the IMPORT
statement
If an entity that is made accessible by this means
is accessed by host association and is defined in
the host scoping unit, it shall be explicitly
declared prior to the interface body.
That clearly requires T1 and T3 to be defined prior to the
interface body, but it does not require T2 to be defined
prior to the interface body. Therefore, the program appears
to be standard conforming. Have I missed something?
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/20090407/02b4e52f/attachment.html
More information about the J3
mailing list