I agree that the program appears to be conforming, and so does the NAG
compiler.
The dummy arguments of the three subroutines in question are clearly not
"TKR compatible" (TKR = Type Kind Rank), as although the types are
compatible (in one direction) the Kinds are different. So the subroutines
form an unambiguous generic set according to the rules in (Fortran 2008)
"12.4.3.4.5 Restrictions on generic declarations".
Cheers,
-----Original Message-----
From: Anton Shterenlikht
Sent: Thursday, August 17, 2017 10:18 PM
To: [log in to unmask]
Subject: [COMP-FORTRAN-90] generic resolution, kind type parameters
Is this program conforming?
I think yes.
module m
implicit none
type amphibian
end type amphibian
type, extends( amphibian ) :: anura( k, nl )
integer, kind :: k=-10
integer, len :: nl=30
end type anura
type, extends( anura ) :: bufonidae
character( len= nl ) :: genus
end type bufonidae
type, extends( anura ) :: hylidae
character( len= nl ) :: genus
end type hylidae
interface s
module procedure s1
module procedure s2
module procedure s3
end interface s
contains
subroutine s1( a )
class( anura ) :: a
write (*,*) "Order: Anura, nothing else known"
end subroutine s1
subroutine s2( a )
class( bufonidae( k=111, nl=* ) ) :: a
write (*,*) a % genus
end subroutine s2
subroutine s3( a )
class( hylidae( k=3456, nl=* ) ) :: a
write (*,*) a % genus
end subroutine s3
end module m
program x
use m
implicit none
type( anura ) :: x1
type( bufonidae( k=111 ) ) :: x2
type( hylidae( k=3456 ) ) :: x3
x2 % genus = "Didynamipus sjostedti"
x3 % genus = "Cyclorana platycephala"
call s( x1 )
call s( x2 )
call s( x3 )
end program x
One compiler give the expected output:
Order: Anura, nothing else known
Didynamipus sjostedti
Cyclorana platycephala
Another compiler outputs only the first line,
i.e. no output from calls to subroutine s with
arguments x2 or x3.
Thanks
Anton
|