Errors using certain Fortran compilers in CRAN checks

This is a warning from R (search for _R_CHECK_FORTRAN_KIND_DETAILS_),

R CMD check now warns on non-portable uses of Fortran KIND such as INTEGER(KIND=4) and REAL(KIND=8).

To see the failing lines set environment variable R_CHECK_FORTRAN_KIND_DETAILS to a true value.

It looks like it’s just a problem on the Intel Fortran auto-generated modules (a consequence of -warn all or -check all). The module generation can be turned off by the flag -no-gen-interfaces.

Thanks for this. So I assume that ‘flag’ needs to be in the makevars file? Not sure how the line should look like exactly. (After some googling), I tried:

PKG_FFLAGS⁠ = $ ifort -c -nogen-interfaces test_kind.f90

but that seems to be wrong… I am really not familiar with setting flags to be honest…

When R CMD build is launched it creates a Makefile with some default rules and injects your Makevars.

I imagine there is some kind of default rule, which looks roughly like:

%.o: %.f90
    $(FC) $(PKG_FFLAGS) $(FFLAGS) -c $<

Here FC will expand to the compiler name, PKG_FLAGS is meant for portable compiler flags that work across multiple compilers, and FFLAGS is a variable you can set from the environment.

If you were to write the Makefile manually (say if you were compiling Fortran outside of the R world), it might contain,

FC=ifort
FFLAGS=-warn all -no-gen-interface

test_kind.o: test_kind.f90
   $(FC) $(FFLAGS) -c $<