필터 지우기
필터 지우기

failure to CLOBBER an netcdf4 file

조회 수: 3 (최근 30일)
James
James 2011년 5월 24일
using netcdf4 format I can't seem to overwrite existing files - works ok with classic. I get the following - any ideas?
nc = netcdf.create('tmp.nc','CLOBBER') ??? Error using ==> netcdflib Library failure "Can't add HDF5 file metadata".

채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 26일
James, don't let your function exit prematurely: use try/catch blocks. Or, since you are using a very new version, use onCleanup()

추가 답변 (1개)

John
John 2011년 5월 25일
I cannot reproduce your issue, James, what platform and release are you running.
  댓글 수: 1
James
James 2011년 5월 26일
Hi John,
Linux 64bit, Centos5, MatlabR2011a
I've played a little more with my code and found the following - I guess it comes down to should the netcdf bits be cleaned up automatically if my function exists prematurely or am I stuck with the fact that I'll just have to delete the file manually if this happens. Hope the following makes sense:
% this code works
netcdf.setDefaultFormat('FORMAT_NETCDF4') ;
mode = netcdf.getConstant('CLOBBER') ;
ncid = netcdf.create('tmp.nc',mode) ;
netcdf.close(ncid)
ncid = netcdf.create('tmp.nc',mode) ;
netcdf.close(ncid)
% it successfully overwrites, but in my case
% the call is in a function so if the function
% exits prematurely before the netcdf.close statement
% I get something similar to the following if
% I try to re-call the function:
%first pass
netcdf.setDefaultFormat('FORMAT_NETCDF4') ;
mode = netcdf.getConstant('CLOBBER') ;
ncid = netcdf.create('tmp.nc',mode) ;
% exit before end
% second call:
ncid = netcdf.create('tmp.nc',mode) ;
% should get HDF5 error here

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by