5 |
if isempty(useNativeMatlabNetcdf); useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); end; |
if isempty(useNativeMatlabNetcdf); useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); end; |
6 |
|
|
7 |
if useNativeMatlabNetcdf; |
if useNativeMatlabNetcdf; |
8 |
if isempty(dimlist), error('nddefVar error: no dimencions allocated'); end |
if isempty(dimlist), error('ncdefVar error: no dimension allocated'); end |
9 |
iDim=[]; |
iDim=[]; |
10 |
for ii=1:length(dimlist), |
for ii=1:length(dimlist), |
11 |
iDim(ii)=netcdf.inqDimID(ncid,dimlist{ii}); |
iDim(ii)=netcdf.inqDimID(ncid,dimlist{ii}); |
14 |
else;%try to use old mex stuff |
else;%try to use old mex stuff |
15 |
% inverse the order of list dimensions |
% inverse the order of list dimensions |
16 |
dimlist=fliplr(dimlist); |
dimlist=fliplr(dimlist); |
17 |
ncvar(varname,xtype,dimlist,ncid); |
switch length(dimlist) |
18 |
|
case 1, |
19 |
|
eval(sprintf('ncid{''%s''}=nc%s(''%s'');',varname,xtype,dimlist{1})); |
20 |
|
case 2, |
21 |
|
eval(sprintf('ncid{''%s''}=nc%s(''%s'',''%s'');',varname,xtype,dimlist{1},dimlist{2})); |
22 |
|
case 3, |
23 |
|
eval(sprintf('ncid{''%s''}=nc%s(''%s'',''%s'',''%s'');',varname,xtype,dimlist{1},dimlist{2},dimlist{3})); |
24 |
|
otherwise |
25 |
|
error('ncdefVar: number of dimension > 3'); |
26 |
|
end |
27 |
end; |
end; |
28 |
|
|
29 |
|
|
|
|
|
|
|
|