Fortran 输出大型数组到 netCDF nf90_enddef
Fortran output large array to netCDF nf90_enddef
你好,关于 Whosebug 的第一个问题。
我已经坚持了 5 天了。我想用 Fortran 写一个 netcdf 文件。
我正在使用 netcdf/3.6.3 我正在尝试输出一个名为 frech 的 43000x 18000 大数组和一些较小的数组(一维数组)。
下面是我的代码示例,它是一个非常大的文件,问题不在于为变量输入值问题在于结束变量的定义:
print*,"nunks is",nunks
print*,"neqns is",neqns
ok=nf90_create('michalek.nc', NF90_CLOBBER, ncid)
print *,"create ok=",ok
ok= nf90_def_dim(ncid,"nunks", nunks, nunks_dimid)
print *,"def nunks dimension ",ok
ok= nf90_def_dim(ncid,"neqns", neqns, neqns_dimid)
print *,"def neqns dimension ",ok
dimids=(/neqns_dimid, nunks_dimid/)
print *,dimids
ok= nf90_def_var(ncid,"frech", NF90_REAL, dimids, frech_varid)
print *,"def frech",ok
ok= nf90_def_var(ncid,"src", NF90_REAL, nunks_dimid, src_varid)
print *,"def src",ok
ok= nf90_def_var(ncid,"csrc", NF90_REAL, nunks_dimid, csrc_varid)
print *,"define csrc",ok
ok= nf90_def_var(ncid,"dat", NF90_REAL, neqns_dimid, dat_varid)
print *,"define dat",ok
ok= nf90_def_var(ncid,"cdat", NF90_REAL, neqns_dimid, cdat_varid)
print *,"define cdat",ok
ok= nf90_enddef(ncid)
print *,"end dif ", ok
ok= nf90_put_var(ncid, frech_varid, frech)
print *, 'frech put in ok=',ok
ok= nf90_put_var(ncid, src_varid, src)
print *, 'src put in ok=',ok
ok= nf90_put_var(ncid, csrc_varid, csrc)
print *, 'csrc put in ok=',ok
ok= nf90_put_var(ncid, dat_varid, dat)
print *, 'dat put in ok=',ok
ok= nf90_put_var(ncid, cdat_varid, cdat)
print *, 'cdat put in ok=',ok
ok= nf90_close(ncid)
print *, 'close?',ok
我理解正确读取文件时ok=0
但是,当我到达结束文件定义 (nf90_enddif) 的阶段时,ok 返回为 =-62,并且未创建 netcdf 文件。我想这是数组太大的问题,但我无法解决这个问题
以上代码的相关输出为:
nunks is 43894
neqns is 18144
create ok= 0
def nunks dimension 0
def neqns dimension 0
2 1
def frech 0
def src 0
define csrc 0
define dat 0
define cdat 0
end dif -62
frech put in ok= -39
src put in ok= -39
csrc put in ok= -39
dat put in ok= -39
cdat put in ok= -39
close? -62
感谢您的帮助!
问候
彼得 :)
这可能是由于netcdf中变量大小的限制,4 giga(见下文)。您可能希望在保存数组之前对其进行切片或移动到 netcdf-4/hdf-5.
Have all netCDF size limits been eliminated?
The netCDF-4 HDF5-based format has no practical limits on the size of a variable.
However, for the classic and 64-bit offset formats there are still limits on sizes of netCDF objects. Each fixed-size variable (except the last, when there are no record variables) and the data for one record's worth of a single record variable (except the last) are limited in size to a little less that 4 GiB, which is twice the size limit in versions earlier than netCDF 3.6.
The maximum number of records remains 232-1.
详情见http://www.unidata.ucar.edu/software/netcdf/docs/faq.html#Large%20File%20Support10
在 NetCDF 经典格式中,当不使用无限维度时,您只能使用 1 个超过 2GiB 的变量。它还必须是数据集中的最后一个变量,并且到开头的偏移量不超过 2GiB。看起来将 frech
移动到末尾应该可行。
在 Argonne-Northwestern 的 Parallel-NetCDF (http://cucis.ece.northwestern.edu/projects/PnetCDF/ ) 中,我们通过创建 CDF-5 文件格式放宽了文件大小限制。花了一段时间,但我认为我们在让 Unidata-NetCDF 识别它方面取得了进展。
如果您控制数据的读取者和写入者,您可能想看看具有更新的 CDF-5 文件格式的 parallel-netcdf 是否适合您。如果您需要与其他人合作,可能要等到它正式成为 Unidata 的 NetCDF 的一部分(让 Unidata 知道它对您有用!)。
你好,关于 Whosebug 的第一个问题。
我已经坚持了 5 天了。我想用 Fortran 写一个 netcdf 文件。
我正在使用 netcdf/3.6.3 我正在尝试输出一个名为 frech 的 43000x 18000 大数组和一些较小的数组(一维数组)。
下面是我的代码示例,它是一个非常大的文件,问题不在于为变量输入值问题在于结束变量的定义:
print*,"nunks is",nunks
print*,"neqns is",neqns
ok=nf90_create('michalek.nc', NF90_CLOBBER, ncid)
print *,"create ok=",ok
ok= nf90_def_dim(ncid,"nunks", nunks, nunks_dimid)
print *,"def nunks dimension ",ok
ok= nf90_def_dim(ncid,"neqns", neqns, neqns_dimid)
print *,"def neqns dimension ",ok
dimids=(/neqns_dimid, nunks_dimid/)
print *,dimids
ok= nf90_def_var(ncid,"frech", NF90_REAL, dimids, frech_varid)
print *,"def frech",ok
ok= nf90_def_var(ncid,"src", NF90_REAL, nunks_dimid, src_varid)
print *,"def src",ok
ok= nf90_def_var(ncid,"csrc", NF90_REAL, nunks_dimid, csrc_varid)
print *,"define csrc",ok
ok= nf90_def_var(ncid,"dat", NF90_REAL, neqns_dimid, dat_varid)
print *,"define dat",ok
ok= nf90_def_var(ncid,"cdat", NF90_REAL, neqns_dimid, cdat_varid)
print *,"define cdat",ok
ok= nf90_enddef(ncid)
print *,"end dif ", ok
ok= nf90_put_var(ncid, frech_varid, frech)
print *, 'frech put in ok=',ok
ok= nf90_put_var(ncid, src_varid, src)
print *, 'src put in ok=',ok
ok= nf90_put_var(ncid, csrc_varid, csrc)
print *, 'csrc put in ok=',ok
ok= nf90_put_var(ncid, dat_varid, dat)
print *, 'dat put in ok=',ok
ok= nf90_put_var(ncid, cdat_varid, cdat)
print *, 'cdat put in ok=',ok
ok= nf90_close(ncid)
print *, 'close?',ok
我理解正确读取文件时ok=0 但是,当我到达结束文件定义 (nf90_enddif) 的阶段时,ok 返回为 =-62,并且未创建 netcdf 文件。我想这是数组太大的问题,但我无法解决这个问题
以上代码的相关输出为:
nunks is 43894
neqns is 18144
create ok= 0
def nunks dimension 0
def neqns dimension 0
2 1
def frech 0
def src 0
define csrc 0
define dat 0
define cdat 0
end dif -62
frech put in ok= -39
src put in ok= -39
csrc put in ok= -39
dat put in ok= -39
cdat put in ok= -39
close? -62
感谢您的帮助!
问候 彼得 :)
这可能是由于netcdf中变量大小的限制,4 giga(见下文)。您可能希望在保存数组之前对其进行切片或移动到 netcdf-4/hdf-5.
Have all netCDF size limits been eliminated?
The netCDF-4 HDF5-based format has no practical limits on the size of a variable.
However, for the classic and 64-bit offset formats there are still limits on sizes of netCDF objects. Each fixed-size variable (except the last, when there are no record variables) and the data for one record's worth of a single record variable (except the last) are limited in size to a little less that 4 GiB, which is twice the size limit in versions earlier than netCDF 3.6.
The maximum number of records remains 232-1.
详情见http://www.unidata.ucar.edu/software/netcdf/docs/faq.html#Large%20File%20Support10
在 NetCDF 经典格式中,当不使用无限维度时,您只能使用 1 个超过 2GiB 的变量。它还必须是数据集中的最后一个变量,并且到开头的偏移量不超过 2GiB。看起来将 frech
移动到末尾应该可行。
在 Argonne-Northwestern 的 Parallel-NetCDF (http://cucis.ece.northwestern.edu/projects/PnetCDF/ ) 中,我们通过创建 CDF-5 文件格式放宽了文件大小限制。花了一段时间,但我认为我们在让 Unidata-NetCDF 识别它方面取得了进展。
如果您控制数据的读取者和写入者,您可能想看看具有更新的 CDF-5 文件格式的 parallel-netcdf 是否适合您。如果您需要与其他人合作,可能要等到它正式成为 Unidata 的 NetCDF 的一部分(让 Unidata 知道它对您有用!)。