Pierre Hugonnet wrote:
> Phillip Helbig wrote:
> > > Also, in C you have long int (any
> > > platform), in Fortran its integer(kind=8) or integer(kind=4) on 32 bit
> > > machines.
>
> > Use SELECTED_INT_KIND
>
> This doesn't ensure the correspondance between C and Fortran types.
> In fact the SELECTED_***_KIND functions have little practical
> value, unless you write fortran-only code, without any call to
> external libraries such as LAPACK. I gave up with them and I came
> back to REAL and DOUBLE PRECISION (OK, for integers you have to use
> SELECTED_INT_KIND, since there are no other standard way to
> declare long integers).
In my "library" codes, I write a REAL and a DOUBLE PRECISION version, and
glue them together with a generic interface. I don't make any assumptions
such as REAL means 6-7 digits -- I use EPSILON and HUGE.
When calling the library, I use SELECTED_REAL_KIND to set the number of
digits appropriate to the problem, and the compiler chooses automatically
whether to use the REAL or DOUBLE PRECISION version of the library code.
Best regards,
Van Snyder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|