我正在使用R librare NCDF,其中R版本为3.0.2。我试图一遍又一遍地打开和关闭一些NetCDF(我可以解释原因,但是这个问题不需要)。
sapply(1:14000, function(whatever) {
print(whatever)
sapply(prediction.cdfs, function(cdf) {
print(file.path(cdf.dir, cdf))
nc = open.ncdf(file.path(cdf.dir, cdf))
close.ncdf(nc)
})
})
一遍又一遍地关闭后,它最终会因此错误而失败:
[1] 3329
[1] "/opt/devel/cdfs/file_one.cdf"
[1] "/opt/devel/cdfs/file_two.cdf"
[1] "/opt/devel/cdfs/file_three.cdf"
[1] "/opt/devel/cdfs/file_four.cdf"
[1] "/opt/devel/cdfs/file_five.cdf"
Error in open.ncdf(file.path(cdf.dir, cdf)) :
NAs in foreign function call (arg 1)
有人知道发生了什么事吗?本质上,错误似乎是随机的。吠叫有关外国功能调用的时间是可变的。我正在寻找解释或仅处理工作?
谢谢
我相信问题是从我的分析中的上一个步骤中的未关闭连接到相同文件。我正在Linux系统上运行此操作,因此我在使用
运行循环时跟踪了打开的文件连接watch ls -l /proc/${PID}/fd
连接打开并关闭恰到好处,但是我看到了以前的分析中摆出了一些旧的连接。我关闭了它们,一切都很好!!!