Errors using certain Fortran compilers in CRAN checks

According to StackOverflow this error is typical for a double-free, i.e. trying to free a null pointer. Somehow I doubt this error is related to this procedure.

As noted in the R docs, it’s important your types have the same storage width (and representation): Writing R Extensions

My own recommendation would be to just use the C kind specifiers matching whatever R uses and pack those into a module:

module rkinds
   use, intrinsic :: iso_c_binding
   private
   integer, parameter, public :: rint = c_int
   integer, parameter, public :: rdp = c_double
end module

subroutine estimate_bct_ordinal(samsize0,numG,P,CDrawsStore)
use rkinds, only: rint, rdp
implicit none
integer(rint), intent(in) :: P, numG, samsize0
real(rdp), intent(out)  :: CDrawsStore(samsize0,numG,P,P)
real(rdp)               :: CCan(P,P)

! ...
end subroutine estimate_bct_ordinal

On my Mac, and using gfortran, the values of rint and i6 are the same in practice, however the intent w.r.t the goal of interoperating with the canonical R implementation is different.

1 Like