Error: C stack usage is too close to the limit in Windows environment

你。 提交于 2019-12-11 00:35:30

问题


I'm doing geostatistical interpolations in R on a 5600 x 5700 matrix and, despite having available memory, I'm getting the error "C stack usage is too close to the limit."

There are a few SO questions related to this issue including this one and this one. These sources and others I've seen online suggest changing the stack size often resolves this issue. Some suggested this change: R_CStackLimit = (uintptr_t)-1 in the file "Rinterface.h". However I am on Windows 7 (x64), using R 2.15.3 (x64) via the Rpy2 module (v 2.3.6 x64 by way of Christoph Gohlke) in Python 2.7, and "Rinterface.h" isn't to be found. How can I otherwise change my effective stack limit for R?

The code that I am running for the interpolation is as follows (except I have it wrapped in a function):

  d <- read.table(wd,header=TRUE,sep=',')
  d <- na.omit(d)
  coordinates(d) <- ~ longdd+latdd ## convert simple data frame into a spatial data frame object
  proj4string(d) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
  stations <- spTransform(d, CRS(utm19))
  names(stations@data)[1] <- "stations"

  grids <- readGDAL("dem.asc")
  names(grids) <- "dem"
  grids$dsea <- readGDAL("dsea.asc")$band1
  proj4string(grids) <- CRS(utm19)
  ov <- overlay(grids, stations)
  stations$dem = ov$dem
  stations$dsea = ov$dsea

  stations <- stations[!is.na(stations$dsea),]

  vgm <- vgm(model="Sph",range=25000)

  v <- variogram(air_temp_max_c~dem+dsea,stations) 
  vgm_max_r<-fit.variogram(v, model=vgm)
  temp_uk <- krige(air_temp_max_c~dem+dsea, locations=stations, newdata=grids, model=vgm_max_r)
  write.asciigrid(temp_uk[1],outmax)
  max_cv <- krige.cv(air_temp_max_c~dem+dsea, locations=stations, vgm_max_r)

  max_cv <-data.frame(max_cv)
  max_cv["date"] <- dt
  max_cv["gs"] <- gs
  max_cv["parameter"] <- "air_temp_max_c"
  write.table(max_cv,file=<outFile>,sep=",",row.names=F)

回答1:


you can use #include "Rinterface.h" and put file Rinterface.h in the same file as your C or R code.

The "Rinterface.h" is available at: https://svn.r-project.org/R/trunk/src/include/Rinterface.h



来源:https://stackoverflow.com/questions/16880854/error-c-stack-usage-is-too-close-to-the-limit-in-windows-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!