/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_IO/read_nctiles.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_IO/read_nctiles.m

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


Revision 1.1 - (hide annotations) (download)
Thu Jan 30 17:05:12 2014 UTC (11 years, 5 months ago) by gforget
Branch: MAIN
- new nctiles IO : times series per tiles (full faces for now) in netcdf4 format.

1 gforget 1.1 function [fld]=read_nctiles(fileName,fldName,tt,kk);
2     %usage: fld=read_nctiles(fileName); reads full field using fileName as field name
3     %usage: fld=read_nctiles(fileName,fldName); reads full field (all depths, all times)
4     %usage: fld=read_nctiles(fileName,fldName,tt); reads 3D or 2D field, at time index tt (all depths)
5     %usage: fld=read_nctiles(fileName,fldName,tt,kk); reads 3D field, at depth index kk, at time index tt
6    
7     gcmfaces_global;
8    
9     if nargin==1;
10     tmp1=['/' fileName];
11     tmp2=strfind(tmp1,'/');
12     fldName=tmp1(tmp2(end)+1:end);
13     end;
14     if nargin>2; tt=varargin{1}; else; tt=[]; end;
15     if nargin>3; kk=varargin{2}; else; kk=[]; end;
16    
17     fld=NaN*mygrid.XC;
18    
19     for ff=1:mygrid.nFaces;
20    
21     fileIn=sprintf('%s.%03d.nc',fileName,ff);
22     nc=netcdf.open(fileIn,0);
23     vv = netcdf.inqVarID(nc,fldName);
24     [varname,xtype,dimids,natts]=netcdf.inqVar(nc,vv);
25    
26     siz=[size(mygrid.XC{ff}) length(mygrid.RC)];
27    
28     if ~isempty(tt);
29     if length(dimids)==3;
30     start=[0 0 tt-1];
31     count=[siz(1) siz(2) 1];
32     elseif isempty(kk);
33     start=[0 0 0 tt-1];
34     count=[siz(1) siz(2) siz(3) 1];
35     else;
36     start=[0 0 kk-1 tt-1];
37     count=[siz(1) siz(2) 1 1];
38     end;
39    
40     fld{ff}=netcdf.getVar(nc,vv,start,count);
41     else;
42     fld{ff}=netcdf.getVar(nc,vv);
43     end;
44    
45     netcdf.close(nc);
46    
47     end;%for ff=1:mygrid.nFaces;
48    
49    

  ViewVC Help
Powered by ViewVC 1.1.22