This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Distinguishing by KINDs


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]