/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/ncputvar.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/ncputvar.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Mon Apr 11 20:48:54 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
Changes since 1.1: +6 -4 lines
interface for old/new Matlab netcdf toolbox

1 gforget 1.1 function []=ncputvar(nc,VARname,VARvalue,varargin);
2    
3     global useNativeMatlabNetcdf; if isempty(useNativeMatlabNetcdf); useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); end;
4    
5 roquet 1.2 if useNativeMatlabNetcdf
6 gforget 1.1
7     %get variable id:
8     vv = netcdf.inqVarID(nc,VARname);
9     %flip order of dimensions:
10     bb=length(size(VARvalue)); VARvalue=permute(VARvalue,[bb:-1:1]);
11     if nargin>3;
12     %get and flip position vectors:
13     VARpos=fliplr(varargin);
14     %convert VARpos to start,count:
15     start=[]; count=[];
16     for ii=1:length(VARpos);
17     start=[start VARpos{ii}(1)-1];
18     count=[count VARpos{ii}(end)-VARpos{ii}(1)+1];
19     end;
20     %write to file:
21     netcdf.putVar(nc,vv,start,count,VARvalue);
22     else;
23     %write to file:
24     netcdf.putVar(nc,vv,VARvalue);
25     end;
26    
27    
28     else;%try to use old mex stuff
29 roquet 1.2
30     if nargin>3;
31     nc{VARname}(varargin{:})=VARvalue;
32 gforget 1.1 else;
33 roquet 1.2 nc{VARname}(:)=VARvalue;
34 gforget 1.1 end;
35 roquet 1.2
36 gforget 1.1 end;

  ViewVC Help
Powered by ViewVC 1.1.22