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

One option with respect to MATLAB would be to use the C Matrix API in combination with compilers that support Fortran-C interoperability. According to the MATLAB documentation the kinds are:

MATLAB C API C type Fortran kind
mwSize size_t c_size_t
mwIndex size_t c_size_t
mwSignedIndex ptrdiff_t c_ptrdiff_t

The downside of using the C route is you cannot rely upon on the MATLAB mex command to perform the compilation and linking of Fortran routines correctly. Instead you have to provide the compiled object files directly to the mex C driver. Edit: another peril is that size_t is an unsigned type in C, but is read as an signed type in Fortran. This means in Fortran you can only use have of the range of size_t (on a 64-bit platform, this can take values betweeen 0 and 18,446,744,073,709,551,615)

I don’t know what it would take to nudge Mathworks to improve standard Fortran interoperability, instead of relying upon extensions like INTEGER*8. I guess there is not much user demand. An example of calling Fortran through the C MEX API can be found in the thread below:

3 Likes