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

Contents of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/ncsave.m

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


Revision 1.1 - (show annotations) (download)
Fri Nov 5 21:41:02 2010 UTC (14 years, 8 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q
- make this work both with the legacy mexnc stuff (as before)
  and with the modern matlab native netcdf implementation.

1 function [] = ncsave(theNetCDFFile, varargin);
2
3 global useNativeMatlabNetcdf; if isempty(useNativeMatlabNetcdf); useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); end;
4
5 if useNativeMatlabNetcdf;
6 nc=netcdf.open(theNetCDFFile,'write');
7 else;%try to use old mex stuff
8 nc=netcdf(theNetCDFFile,'write');
9 end;
10
11 for ii=1:nargin-1;
12 nameCur=inputname(ii+1);
13 if useNativeMatlabNetcdf;
14 vv = netcdf.inqVarID(nc,nameCur); netcdf.putVar(nc,vv,varargin{ii}');
15 else;%try to use old mex stuff
16 nc{nameCur}(:)=varargin{ii};
17 end;
18 end;
19
20
21 if useNativeMatlabNetcdf;
22 netcdf.close(nc);
23 else;%try to use old mex stuff
24 close(nc);
25 end;
26
27
28

  ViewVC Help
Powered by ViewVC 1.1.22