使用 ncread 时 NetCDF 崩溃

NetCDF crashes when using ncread

从全新安装 Julia 1.7.2 开始,我使用 using Pkg; Pkg.add("NetCDF") 安装 NetCDF 包。检查安装状态,我得到:

julia> Pkg.status()
       Status `C:\Users\apung\.julia\environments\v1.7\Project.toml`
       [30363a11] NetCDF v0.11.4

我的桌面上有一个名为“dummy.nc”的 NetCDF 文件,其中包括“功率”和“频率”等字段;这在 Panoply 中得到验证:

在 Julia 中,我正在尝试使用

读取文件
using NetCDF; ncread("dummy.nc","frequency")

此时,Julia 终端崩溃并自动关闭。如果我在Atom中运行同样的命令,报错是:

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0xa3556550 -- nc4_open_file at 
C:\Users\apung\.julia\artifactsb6e2ce84250e36811c3019c1ad253c1739c888f\bin\libnetcdf-18.dll 
(unknown line) in expression starting at none:1 nc4_open_file at C:\Users\apung\.julia\artifactsb6e2ce84250e36811c3019c1ad253c1739c888f\bin\libnetcdf-18.dll (unknown line)
NC4_open at C:\Users\apung\.julia\artifactsb6e2ce84250e36811c3019c1ad253c1739c888f\bin\libnetcdf-18.dll (unknown line)
NC_open at C:\Users\apung\.julia\artifactsb6e2ce84250e36811c3019c1ad253c1739c888f\bin\libnetcdf-18.dll  (unknown line)
nc_open at C:\Users\apung\.julia\artifactsb6e2ce84250e36811c3019c1ad253c1739c888f\bin\libnetcdf-18.dll (unknown line)
nc_open at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\netcdf_c.jl:55 [inlined]
nc_open at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\netcdf_helpers.jl:103
#open#51 at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:913
open##kw at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:913 [inlined]
#open#52 at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:999
open at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:999 [inlined]
#ncread#54 at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:1052 [inlined]
ncread at C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:1052
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:583
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:731
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:885
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
repleval at C:\Users\apung\.julia\packages\Atom\BUIFZ\src\repl.jl:198
#258 at C:\Users\apung\.julia\packages\Atom\BUIFZ\src\repl.jl:228
unknown function (ip: 00000000642ce9b3)
with_logstate at .\logging.jl:511
with_logger at .\logging.jl:623 [inlined]
evalrepl at C:\Users\apung\.julia\packages\Atom\BUIFZ\src\repl.jl:216
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:583
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:731
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:885
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:150
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:246
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:231
#run_repl#47 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:364
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:351
#930 at .\client.jl:394
jfptr_YY.930_36349.clone_1 at C:\Users\apung\AppData\Local\Programs\Julia-1.7.2\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:716 [inlined]
invokelatest at .\essentials.jl:714 [inlined]
run_main_repl at .\client.jl:379
exec_options at .\client.jl:309
_start at .\client.jl:495
jfptr__start_21275.clone_1 at C:\Users\apung\AppData\Local\Programs\Julia-1.7.2\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:559
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:701
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:42
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 101204148 (Pool: 101156006; Big: 48142); GC: 63

我该怎么做才能解决这个问题?在此期间,我将继续尝试以前的 NetCDF 软件包版本。

编辑: ver没有问题。 0.7.3、0.8.2、0.9.0、0.10.3。 版本 0.11.4 给出了 HDF 错误:

ERROR: NetCDF error code -101:
        NetCDF: HDF error
Stacktrace:
 [1] check
   @ C:\Users\apung\.julia\packages\NetCDF\CS38M\src\netcdf_helpers.jl:22 [inlined]
 [2] nc_open
   @ C:\Users\apung\.julia\packages\NetCDF\CS38M\src\netcdf_c.jl:55 [inlined]
 [3] nc_open(fname::String, omode::UInt16)
   @ NetCDF C:\Users\apung\.julia\packages\NetCDF\CS38M\src\netcdf_helpers.jl:103
 [4] open(fil::String; mode::UInt16, readdimvar::Bool, add_finalizer::Bool)
   @ NetCDF C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:913
 [5] open(f::NetCDF.var"#55#56"{String}, args::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ NetCDF C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:999
 [6] open
   @ C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:999 [inlined]
 [7] #ncread#54
   @ C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:1052 [inlined]
 [8] ncread(fil::String, vname::String)
   @ NetCDF C:\Users\apung\.julia\packages\NetCDF\CS38M\src\NetCDF.jl:1052
 [9] top-level scope
   @ REPL[4]:1

这是 appears to be 最近在 Windows 上引入的一个已知问题。建议的解决方法是

using Pkg
Pkg.add("NetCDF_jll@400.702.400")

或编辑 Project.toml 文件以包含

[compat]
NetCDF_jll = "=400.702.400"

这应该是一个临时解决方法,一旦提到要解决该问题,您可以将 add 反转为 Pkg.rm,或者如果您添加了以上两行,则将其删除。无论哪种情况,您都应该在后面加上 Pkg.update().