[J3] Generic interface for IEEE_SELECTED_REAL_KIND?
Bill Long
longb at cray.com
Wed Jan 2 16:09:41 EST 2019
> On Jan 2, 2019, at 2:28 PM, Steven G. Kargl via J3 <j3 at mailman.j3-fortran.org> wrote:
>
> 18-007r1, 17.10 starts with
>
> "For all of the procedures defined in the modules,
> the arguments shown are the names that shall be used
> for argument keywords if the keyword form is used for
> the actual arguments.”
Which is regarding how to write the syntax for a reference that uses keyword arguments, as in
IEEE_SELECTED_REAL_KIND (P=6, R=30, RADIX=2)
>
> IEEE_SELECTED_RERAL_KIND is listed in Table 17.2 as
> a module procedure available the from IEEE_ARITHMETIC
> module. If a Fortran processor has 2 or more INTEGER
> kinds (say, INTEGER(1) and INTEGER(2)), it is impossible
> to write a generic interface for IEEE_SELECTED_REAL_KIND
> that can be contained within the module. Is there a
> J3 paper that discusses this issue?
This is unrelated to the use of keyword arguments. I agree that writing a generic interface to cover all the combinations of KINDS for the integer arguments is very tedious, but why is it “impossible”? There is a proposal for F202X for templates that would make writing this sort of module procedure trivial, not needing a generic interface. In fact, writing the IEEE modules in Fortran would be significantly simplified if templates could be used.
I believe the common implementation for something like IEEE_SELECTED_REAL_KIND is to treat it like an ordinary intrinsic if there is a visible USE of the module, and the compiler just replaces the reference with the result if the actual arguments are constants. If they are not constants, then the compiler can generate a call to function that has all 64-bit integer arguments, including casts to that size as needed for arguments that are present. Such “compiler magic” is not directly discussed in the standard.
Cheers,
Bill
>
> --
> Steve
Bill Long longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
More information about the J3
mailing list