MetOffice / opsinputs

JEDI library generating VarObs and Cx files
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Integer literals used for kind values #138

Closed DJDavies2 closed 4 months ago

DJDavies2 commented 1 year ago

Following on from https://github.com/MetOffice/opsinputs/pull/133#discussion_r1033564552.

This applies to all types of variables, not just logicals. Literal kind values (4, 8, etc) are not portable between implementations although in practice values of 4 and 8 corresponding to the number of bytes are very common. More portable is to use named constants (parameters) that might be different for different compilers. This can be done via cpp macros or selected_*_kind. Also more recent standards have standard constants defined in the intrinsic module iso_fortran_env.

For example, OPS's implementation of this is here: https://www-nwp/~opsrc/OPS/view/ops-2022.01.1/doc/OpsMod_Kinds.html. This contains a lot of legacy cruft. Unless there is a problem with one of the compilers I would try just using iso_fortran_env constants.