This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Distinguishing by KINDs
- From: Erik Edelmann <eedelman at acclab dot helsinki dot fi>
- To: Salvatore Filippone <sfilippone at uniroma2 dot it>
- Cc: fortran at gcc dot gnu dot org
- Date: Thu, 30 Sep 2004 14:43:12 +0300
- Subject: Re: Distinguishing by KINDs
- References: <1096537954.1250.12.camel@euler>
Den 30.09 kl 11:52:35 skrev sfilippone@uniroma2.it:
> Hi there,
> on i686-linux, snapshot 20040926, I got the following:
>
> [sfilippo@euler sfilippo]$ gfortran -c bug.f90
> In file bug.f90:3
>
> module procedure i1trysub,i2trysub,i4trysub
> 1
> Error: Ambiguous interfaces 'i4trysub' and 'i2trysub' in generic
> interface 'trysub' at (1)
>
> The example is a trimmed-down version from one where the type KINDs
> where distinguished via SELECTED_INT_KIND, and the values 1 2 4 are the
> ones that ultimately were used. Bug or error? (Couldn't find anything
> related in the bug database).
> Thanks
>
> [sfilippo@euler sfilippo]$ more bug.f90
> module vecutil
> interface trysub
> module procedure i1trysub,i2trysub,i4trysub
> end interface
> contains
> subroutine i1trysub(a)
> integer(kind(1)), dimension(:) :: a
> end subroutine i1trysub
>
> subroutine i2trysub(a)
> integer(kind(2)), dimension(:) :: a
> end subroutine i2trysub
>
> subroutine i4trysub(a)
> integer(kind(4)), dimension(:) :: a
> end subroutine i4trysub
> end module vecutil
Bug in your code.
The intrinsic function kind() returns the kind of its argument,
and 1, 2, and 4 are all of the same kind (default kind for
integers). Try
module vecutil
interface trysub
module procedure i1trysub,i2trysub,i4trysub
end interface
contains
subroutine i1trysub(a)
integer(kind=1), dimension(:) :: a
! ^^^^^^
end subroutine i1trysub
subroutine i2trysub(a)
integer(kind=2), dimension(:) :: a
! ^^^^^^
end subroutine i2trysub
subroutine i4trysub(a)
integer(kind=4), dimension(:) :: a
! ^^^^^^
end subroutine i4trysub
end module vecutil
and see if it helps.
regards,
Erik