Can floating point literals be adapted by the compiler to double precision variable?

I think Fortran has been designed to write applications, and it’s quite easy to use the same code and switch precision (say from double to single) by changing a single line. The design maybe can be improved, but it’s not bad in my opinion. At the very least it’s a great starting point.

But to write libraries that support multiple precisions at once is not easy and these are the current approaches:

  • duplicate the code
  • use some macro preprocessor
  • create a module that works with any precision, and it gets copied to the user application, and the user sets the required precision, but you can only use one precision at a time, not both

I think it would be helpful to make the precision “generic”, here is the proposal for this: Allow an intent(out) argument to adopt the same kind as an input(in) argument · Issue #128 · j3-fortran/fortran_proposals · GitHub