R session aborted. R encountered a fatal error. RandomFields package.

I am trying to generate random fields on a square grid of size NXN using the 'RandomFields' package in R 4.1.0 with RStudio-1.5.192. Specifically, I am using the function 'RMgencauchy,' which takes two parameters: alpha and beta as inputs to obtain the the random fields. The code works for larger grid sizes for a particular combination of alpha and beta, for instance with N=100, alpha=1 and beta=1 the code works. However, for a different combination of alpha and beta with a grid of the same size, the R session gets terminated Here is a MWE:

################### my code ###############################################
rm(list=ls())               
library(RandomFields)       
library(pracma)
library(PracTools) 
library(corTools)

meanv = 5
al = 1
bet = 0.2 #when 'bet' value is changed to 1, the code is executed without any issues
model <- RMgencauchy(var=1, alpha=al, beta=bet)+RMtrend(mean=5)

N = 100
step <- 1  
x.seq <- seq(-((N-1)/2)*step, ((N-1)/2)*step, step) 
y.seq <- seq(-((N-1)/2)*step, ((N-1)/2)*step, step)   
 
f <- RFsimulate(model, x = x.seq, y.seq,z = NULL, grid=TRUE,spConform=FALSE) #1000

I think, the memory should not be an issue as these are relatively small sizes and I am running this code a computer with 256 GB RAM. I have a similar issue when I try to increase N beyond 700 even with alpha=1 and beta=1. The default value of 'memory.limit()' is 261819, I could increase up to 1e13 using 'memory.limit(1e13).' However, this did not resolve the issue. I am not sure what the problem exactly is. Thanks.

The code runs fine up till an internall call to a RandomFields.dll

  result <- .Call(C_EvaluateModel, as.double(n), as.integer(reg))

looking at C_EvaluateModel gives :

$name
[1] "EvaluateModel"

$address
<pointer: 0x0000013b3ebb6570>
attr(,"class")
[1] "RegisteredNativeSymbol"

$dll
DLL name: RandomFields
Filename: C:/Users/NirGraham/Documents/R/R-4.0.5/library/RandomFields/libs/x64/RandomFields.dll
Dynamic lookup: FALSE

$numParameters
[1] 2

attr(,"class")
[1] "CallRoutine"      "NativeSymbolInfo"

so its a failure n a compiled dll.
Your best bet is to contact a contributor or maintainer of the package and ask for support / report the issue.
CRAN - Package RandomFields (r-project.org)

Thank you @nirgrahamuk. I do not completely understand what the issue here is to be able to report it to the package developers. It would be helpful for me if you could explain more what this dll error is. And also, did you have any similar issue when the parameters were set as 'al=1' and 'bet=1'? This combination was executed perfectly without any errors.

I think you have plenty to raise an issue, because the code you made as an example, consistently crashes out your RStudio , and does mine too....
the stuff about the callroutine, is internal , and a user wouldnt be expected to know about it, its just an example of me chasing it down to the package to the point where its not even R code that has been written that is suspect, its probable some c/c++ code compiled into a DLL that is triggering RStudio to explode.

I tried with bet=1 as per your suggestion, and the code ran and didnt crash me. I tried 0.2 (and 0.5) for bet, and Rstudio was terminated. Which should never happen...

Got it. Thank you @nirgrahamuk for the explanation. I will report this to the package developers.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.