Malcolm Cohen wrote:
> Pierre Hugonnet said:
> The question is whether you want the convenience of kind-generic interfaces
> to your old library. If you do, you need to do some work to create it. If
> you have source code this need not be very much work - tools are available to
> generate interface blocks, and it is then very easy to put generic names
> to put onto the generated interface blocks (the difficult bit might be
> inventing the names!).
>
> [...]
> > According to my experience it is not so easy. The key point being
> > the correspondance between the kinds used in the library and the
> > kinds used in a calling program. It turns out in fact that you
> > always need to assume that you are using the default REAL and
> > DOUBLE PRECISION kinds, even hidden by the SELECTED_REAL_KIND mechanism.
>
> No, "in fact", you do not.
>
> It is trivially easy to have generic interfaces based on real kinds
> for your library, and then it is all done for you.
>
> > Using SELECTED_REAL_KIND without any (implicit) reference to
> > REAL or DOUBLE PRECISION is almost impossible.
>
> I could not disagree more. There are libraries out there designed for
> Fortran 90 which use these facilities without any explicit (default) REAL or
> DOUBLE PRECISION declarations in sight.
>
> [I said]
> > > If you restrict yourself to (default) REAL and DOUBLE PRECISION it is trivial
> > > to do it portably. If you don't so restrict yourself then
> > > (a) using just REAL and DOUBLE PRECISION does not work (duh!)
> > > (b) portability (of the library code itself) necessarily goes out the window
> > > if you want to use machines with different numbers of real kinds.
> > >
> >
> > That's why I say that SELECTED_REAL_KIND doesn't bring any advantage
> > in terms of portability: if you want to be portable, you are
> > forced to use REAL and DOUBLE PRECISION.
>
> Huh? Did you read what I said at all?
>
> Since REAL gives you 1 precision (single), and DOUBLE PRECISION gives you
> a second precision (double), to handle quad precision you need a third way.
> You cannot do it with just REAL and DOUBLEPRECISION at all!!!
>
> Fortunately, with SELECTED_REAL_KIND you can do quad precision in a relatively
> portable way (at least to those machines that give you quad precision).
Even to quad precision, it can be done
portably. However, a generic interface to quad
precision would not be available.
> Cheers,
> ...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
> ([log in to unmask])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|