An `eye` function that accepts the default integer and another integer kind simultaneously

@zaikunzhang , see the example in this thread.

My suggestion will be to think like a library developer and provide generic facilities which make use of options such as integer_kinds array named constant in ISO_FORTRAN_ENV rather than the individual named constants. You can then use some preprocessor, say fypp, to effectively “loop” over such a named constant array in the generic authoring of your function.

While there is no guarantee for anything, a conforming processor can be expected to support a default integer with a decimal exponent range of at least 5; in addition, it is required to support an integer with a minimum decimal exponent of 18 or greater. Thus a library developer knows the size of integer_kinds array will be at least 1; but on modern processors, the size is likely to be 2 or more.

Then on the caller side, no what option is chosen for integer kind - whether using SELECTED_INT_KIND or ISO_FORTRAN_ENV or ISO_C_BINDING (c_int, etc.), you can expect a generic resolution with one specific interface of your eye function that is based on integer_kinds array element value.

2 Likes