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.
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.