Hi
On Mon, 19 Jan 1998, Laurent Hill wrote:
> program typefield1
> type T1
> integer :: v
> end type T1
> type T2
> type(T1) :: t1 ! what is T1 here ?
> end type T2
> type(T2) :: v
> v%t1%v=10
> print *, v%t1%v
> end program typefield1
>
> Is this legal ?
Dont know for certain, though I see no reason why not, and I can tell
you it compiles on SGI,DEC,IBM,CRAY systems with expected results and
no warnings, and compiles with F if you move the type definitions into
a module. Which proves nothing ...
> My interpretation would be that it isn't, since in the scope of
> the definition of T2, T1 refers to the field T1, not to the type.
Types and variables occupy different namespaces surely? Using ladebug
...
(ladebug) whatis t1
type t1
integer*4 V
end type
(ladebug) whatis t2
type t2
T1 T1
end type
> If it is legal, then is the following example also legal ?
> (it is rejected by the sun compiler)
>
> subroutine typefield2
> type T1
> integer :: v
> end type T1
> call inner
> contains
> subroutine inner
> type(T1)::t1
> t1%v=10
> print *, t1%v
> end subroutine inner
> end subroutine typefield2
DEC thinks this is OK. SGI and CRAY f90 say:
cf90-920 mfef90: ERROR INNER, File = tt.f90, Line = 8, Column = 15
"T1" is host associated, therefore it must not be redeclared with the type(T1) attribute.
f90: MIPSpro Fortran 90 Version 7.2 (f19) Mon Jan 19, 1998 10:56:52
f90: 12 source lines
f90: 1 Error(s), 0 Warning(s), 0 Other message(s), 0 ANSI(s)
IBM compiler says:
"tt.f90", line 8.10: 1514-077 (S) Identifier t1 appearing as a derived type name is defined in this scoping unit with conflicting attributes.
Curious ...
Kev
--
\\\|///
\\ - - //
( @ @ )
+-----------------oOOo-(_)-oOOo---------------------+
| Kevin Maguire Daresbury Laboratory |
| [log in to unmask] Warrington |
| Tel: (01925) 603221 Cheshire |
| Fax: (01925) 603634 United Kingdom |
+-------------------------Oooo----------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|