Skip to content
Snippets Groups Projects
Commit 9cce352d authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

corrige un bug de l'implementation de la toolbox netcdf native, lorsqu'il n'y...

corrige un bug de l'implementation de la toolbox netcdf native, lorsqu'il n'y avait pas d'echantillon, la dimension DAYD_EXT etait crée à 0, unlimited, mais pas en premier dans le fichier, ainsi que les variables. Sous R2011b, la toolbox netcdf plantait à la lecture.
parent 6829c1f9
No related branches found
No related tags found
No related merge requests found
......@@ -141,7 +141,8 @@ for id = 0:nvars-1
% are 0. In that case, set data to empty
% ------------------------------------------------------------------
catch ME
warning('netcdf_native:read', '%s: %s', varName, ME.message);
fprintf('Notice: netcdf_native:read: %s set to empty\n', varName);
% fprintf('Notice: netcdf_native:read: %s: %s\n', varName, ME.message);
s.data__ = [];
end
......
......@@ -88,7 +88,12 @@ for i=1:numel(ncd_keys)
if isempty(dimlen)
t = get(get(self.dynaload, 'VARIABLES'), key__);
if isfield(t, 'data__')
netcdf.defDim(self.nc_id, key__, numel(t.data__));
% if empty data, don't create unlimited (0) dimension
% ---------------------------------------------------
if numel(t.data__)
netcdf.defDim(self.nc_id, key__, numel(t.data__));
end
end
else
try
......@@ -210,9 +215,11 @@ for i=1:numel(ncv_keys)
% dimids = [circshift(dimids(1:ind),[0 1]), dimids(ind+1:end)];
% end
% leave comment these lines, it's right case
% ------------------------------------------
catch ME
fprintf('\nNotice: netcdf.%s, dimension %s don''t exist or is empty',...
ME.stack(2).name, s.dimension__{ind});
% fprintf('\nNotice: netcdf.%s, dimension %s don''t exist or is empty',...
% ME.stack(2).name, s.dimension__{ind});
% Leave define mode and go to next variable (key__)
% -------------------------------------------------
......@@ -391,7 +398,12 @@ for i=1:numel(ncv_keys)
% Write data to variable.
% -----------------------
try
netcdf.putVar(self.nc_id, varid, value);
% don't create empty variable
% ---------------------------
if ~isempty(value)
netcdf.putVar(self.nc_id, varid, value);
end
catch exception
fprintf('write variable error: %s', s.key__');
s %#ok<NOPRT>
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment