NCL问题:warning:_NclOpenFile:Can not open file

NCL官网上关于addfiles有这么一段儿:

Users who aggregate many NetCDF files together in a single call to the
addfiles function should be aware that there are limits on the number
of files that can be simultaneously open. Many is, of course, a
relative term. OPeNDAP-enabled NCL is restricted by the OPeNDAP NetCDF
client library to 64 open files when accessing files either locally or
over the network. Otherwise, typical Unix/Linux systems usually allow
1024 open files, although this value can vary for older or less-common
sytems, and it can also be tweaked when building the OS kernel. Note
that the actual number of open files possible may be somewhat less
than the limit because of file descriptors used internally. However,
NCL can optionally close files after each access, in effect removing
this limitation. This is accomplished by invoking the setfileoption
procedure to set the option SuppressClose to False. This is only an
issue for NetCDF, because, in general, for other file formats
supported by NCL, files are closed after each access.

翻译成人话:在调用addfiles函数批量处理NetCDF文件的话,不能一次性打开太多文件。在本地或通过网络访问文件时启用OPeNDAP的NCL被OPeNDAP NetCDF客户端库限制打开64个文件。一般的Unix/Linux系统通常允许1024个打开的文件(较老的或不太常见的系统除外),而且在设置内核时也可以进行调整。当然内部使用的文件描述符,实际可能打开的文件数量可能比限制少一些。不过NCL可以在每次访问之后选择性地关闭文件,实际上消除了这个限制。这是通过调用setfileoption过程来实现的,该过程将选项SuppressClose设置为False。这只是NetCDF的问题,对于NCL支持的其他文件格式,文件在每次访问之后都会被关闭。

简而言之,直接设置:
在addfiles读取文件前一行加

setfileoption("nc","SuppressClose",False)

每次打开文件写入变量后就关闭文件

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值