1 |
roquet |
1.1 |
function varid = ncdefVar(ncid,varname,xtype,dimlist); |
2 |
|
|
% add a variable in a netcdf file. |
3 |
|
|
|
4 |
|
|
global useNativeMatlabNetcdf; |
5 |
|
|
if isempty(useNativeMatlabNetcdf); useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); end; |
6 |
|
|
|
7 |
|
|
if useNativeMatlabNetcdf; |
8 |
|
|
if isempty(dimlist), error('nddefVar error: no dimencions allocated'); end |
9 |
|
|
iDim=[]; |
10 |
|
|
for ii=1:length(dimlist), |
11 |
|
|
iDim(ii)=netcdf.inqDimID(ncid,dimlist{ii}); |
12 |
|
|
end |
13 |
|
|
netcdf.defVar(ncid,varname,xtype,iDim); |
14 |
|
|
else;%try to use old mex stuff |
15 |
|
|
% inverse the order of list dimensions |
16 |
|
|
dimlist=fliplr(dimlist); |
17 |
|
|
ncvar(varname,xtype,dimlist,ncid); |
18 |
|
|
end; |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|