Hello,
at this point there always is an implementation dependency, since the
kind numbers returned by selected_int_kind are not determined by the
standard. This does not mean there is no portable way to handle this
situation. One would be to do
interface typetest
include 'typestuff.finc'
end interface
and have a symbolic link to the compiler dependent file e.g.,
typestuff.finc -> typestuff_g95.finc
which in turn contains all needed lines.
Another would be to define distinguishable types
type my_int_4
integer(kind1) :: i
end type
type my_int_9
integer(kind2) :: i
end type
and base generic resolution on these. You may need to overload
operations. Performance may then be a problem.
Regards
Gus Gassmann wrote:
> I am experimenting with different types and have created the following
> little program:
> module testmod
> integer, parameter :: kind1=selected_int_kind(4)
> integer, parameter :: kind2=selected_int_kind(9)
> interface typetest
> module procedure type1, type2
> end interface
> contains
> subroutine type1(a)
> integer (kind=kind1) :: a
> print *,' printed from type1: A=',a
> end subroutine type1
> subroutine type2(a)
> integer (kind=kind2) :: a
> print *,' printed from type2: A=',a
> end subroutine type2
> end module testmod
> program test
> use testmod
> integer (kind=1) :: a1 = 1
> integer (kind=2) :: a2 = 2
> call typetest(a1)
> call typetest(a2)
> end program test
> On systems that do not implement two-byte integers, this will result
> in an ambiguous situation because the compiler cannot distinguish
> between the two interfaces. For my purposes the solution would be to
> take one of the two routines out, but this is obviously not portable.
> Is there a way to force the compiler to "do the right thing"?