Reynold Greenlaw writes:
> call Output_Str( "My name is Reynold" )
> call Output_StrInt( "My age is", 21 )
> call Output_StrReal( "My shoe size is",9.5 )
> They cry out for a common interface such as:
> interface Output
> module procedure Output_Str
> module procedure Output_StrInt
> module procedure Output_StrReal
> end interface
Looks fine to me. Only thing I'm not quite sure of is whether or not
they are sufficiently unique - I never remember all those rules. Nag
f95 seems happy anyway, though that's not a guarantee. Its possible
this might be your real problem - I'll let someone who remembers all
those disambiguation rules (and any subtle differences in them between
f90 and f95) answer for that because it will take me too long to
puzzle it out myself.
Try taking out the first one (the one that just has a string). Its
the only one I'm unsure of. The other two I'm sure would be ok
from that perspective (unless you did something like make the
second argument optional, which I assume you didn't).
> but this can't be done because the length of the string arguments to my
> output subroutines are known only at run-time
Huh? What does that have to do with anything? String length isn't
used in disambiguation at all (basically because it isn't generally
known til run-time). How did you conclude this was relevant? Are you
getting an error message from some compiler? Perhaps like the message
in your title? If so, perhaps you should be giving us the actual
data, namely a sample file and the compiler error message, rather than
your conclusion.
> Petros Dafniotis posted nearly the same problem (20 Jan 2000: "Question on
> character valued functions") which was resolved by Richard Maine. Great, but
> I'm still stuck!
No, that wasn't even vaguely related to the above (unless I'm more
confused than usual). That had nothing to do with generics. And it
was an issue only for functions, not subroutines. Your problem
involves subroutines, not functions. And your problem seems to be
about generaics.
> function output_str(string)
> character*(*) :: string
> end function output_str
>
> and this didn't work for me.
If you confuse subroutines and functions, certainly not much will
work.
I think we need to see more specifics on the problem. Unless its
possibly the disambiguation rules, in which case you need someone who
remembers them exactly.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|