1 | function [n3dvars,varcell,L,M,N]=get_3dvars(nc) |
---|
2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3 | % |
---|
4 | % get_3dvars: Get the all prognostic variable names (u,v,zeta,..) |
---|
5 | % and sizes from a netcdf file |
---|
6 | % |
---|
7 | % |
---|
8 | % Further Information: |
---|
9 | % http://www.brest.ird.fr/Roms_tools/ |
---|
10 | % |
---|
11 | % This file is part of ROMSTOOLS |
---|
12 | % |
---|
13 | % ROMSTOOLS is free software; you can redistribute it and/or modify |
---|
14 | % it under the terms of the GNU General Public License as published |
---|
15 | % by the Free Software Foundation; either version 2 of the License, |
---|
16 | % or (at your option) any later version. |
---|
17 | % |
---|
18 | % ROMSTOOLS is distributed in the hope that it will be useful, but |
---|
19 | % WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | % GNU General Public License for more details. |
---|
22 | % |
---|
23 | % You should have received a copy of the GNU General Public License |
---|
24 | % along with this program; if not, write to the Free Software |
---|
25 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
26 | % MA 02111-1307 USA |
---|
27 | % |
---|
28 | % Copyright (c) 2006 by Pierrick Penven |
---|
29 | % e-mail:Pierrick.Penven@ird.fr |
---|
30 | % |
---|
31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
32 | |
---|
33 | Vars = var(nc); |
---|
34 | Varnames = [ncnames(Vars)]; |
---|
35 | nvar=length(Vars); |
---|
36 | ndims=0*(1:nvar); |
---|
37 | ligne=' '; |
---|
38 | varstr=repmat(ligne,nvar,1); |
---|
39 | n3dvars=0; |
---|
40 | for i=1:nvar |
---|
41 | vname=char(Varnames(i)); |
---|
42 | myvar=nc{vname}; |
---|
43 | ndims(i)=length(dim(myvar)); |
---|
44 | if ndims(i)>=3 |
---|
45 | n3dvars=n3dvars+1; |
---|
46 | varstr(n3dvars,1:length(vname))=vname; |
---|
47 | a=size(myvar); |
---|
48 | if ndims(i)==4 |
---|
49 | L(n3dvars)=a(4); |
---|
50 | M(n3dvars)=a(3); |
---|
51 | N(n3dvars)=a(2); |
---|
52 | else |
---|
53 | L(n3dvars)=a(3); |
---|
54 | M(n3dvars)=a(2); |
---|
55 | N(n3dvars)=1; |
---|
56 | end |
---|
57 | end |
---|
58 | end |
---|
59 | varstr=varstr(1:n3dvars,:); |
---|
60 | varcell=cellstr(varstr); |
---|