Search code examples
rfortrangfortrancranfortran95

Warning: GNU Extension


When I submit my package to CRAN, it does not pass the automatic incoming checks with a following warning:

* checking whether package 'EpiILM' can be installed ... WARNING
  Found the following significant warnings:
  Warning: GNU Extension: Different type kinds at (1)

and corresponding log file says

  Epimcmc.f95:440.25:

        psi= min(1.0,exp(ratio))
                     1
 Warning: GNU Extension: Different type kinds at (1)

When I tested my package using R CMD CHECK and R CMD CHECK --as-cran, both result no warnings or notes. I am using an R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch" on my MacOS and codes are written in Fortran 95.

Any suggestions?


Solution

  • Your code is too short to diagnose exactly, but it can be probably inferred safely what the not-shown part of the code is.

    Your ratio is of different kind than default one, probably `double precision.

    But 1.0 is the default kind (aka. single precision).

    Mixing different kinds in min() is not allowed in Fortran, but you do this in:

      min(1.0,exp(ratio))
    

    To fix the problem, use literals of the same kind as ratio is. So if it is a double precision, you can use:

      min(1.0d0, exp(ratio))
    

    and if it is some real(rk) you can use

      min(1.0_rk, exp(ratio))
    

    The real(.., kind=rk) function can also be used.


    The warning says that the GNU Fortran compiler recognizes it is not allowed in Fortran, but allows it as a non-standard extension. Whether using this extension is allowed by the CRAN coding standards is a different question. Probably no, if it got rejected.