Hi There,
its me again. This time I stuck with Fortran's polymorphism. What I try
to implement is a function whose return value type is not fixed at
compile time. In other words, it should return ether a real or integer
which is already explicit.
Just a toy example which, unfortunately, does not what I want:
function get_value(key) result( value )
integer, intent(in) :: key
class(*), allocatable :: value
select case(key)
case(1) ! should return integer
allocate( value, source = 1 )
return
case(2) ! should return real
allocate( value, source = 2.0 )
return
end select
end function get_value
My issue is, the function's result is of implicit polymorphic type.
However, I want the result being explicit of intrinsic type integer or
real.
Could you think of any solution archiving such functionality?
Cheers and thanks in advance,
Stefan
|