1 |
function s=gcmfaces(varargin); |
function s=gcmfaces(varargin); |
2 |
%object: create an empty gcmfaces object |
%object: create an empty gcmfaces object |
3 |
%optional input: cell array containing each face data that |
%input: fld cell array containing each face data |
4 |
% will be used to fill the gcmfaces object |
% OR nFaces number of faces (empty faces in output) |
5 |
%pre-requisite : the grid (global mygrid variable) must have been |
% OR (none; results in empty face data, with nFaces=mygrid.nFaces) |
6 |
% defined using grid_load or grid_load_native |
%output: gcmfaces object |
7 |
% providing the blue print for new gcmfaces objects |
|
8 |
%note: this routine used to have several inputs of various types; |
|
9 |
% now only the first input is used, and only if it is a cell array. |
%object: create an empty gcmfaces object |
10 |
|
%input: fld cell array containing each face data |
11 |
|
% OR nFaces,fld (to add consistency check) |
12 |
|
% OR nFaces number of faces (empty faces in output) |
13 |
|
% OR (none) (empty faces in output) |
14 |
|
%output: gcmfaces object formatted/filled accordingly |
15 |
|
|
16 |
|
|
17 |
global mygrid; |
global mygrid; |
18 |
|
|
19 |
nFaces=mygrid.nFaces; |
if nargin==2; |
20 |
|
nFaces=varargin{1}; |
21 |
|
fld=varargin{2}; |
22 |
|
if ~iscell(fld)|length(fld)~=nFaces; |
23 |
|
error('inconsistent spec. of nFaces,fld'); |
24 |
|
end; |
25 |
|
elseif nargin==1; |
26 |
|
tmp1=varargin{1}; |
27 |
|
if iscell(tmp1); |
28 |
|
fld=tmp1; |
29 |
|
nFaces=length(fld); |
30 |
|
else; |
31 |
|
nFaces=varargin{1}; |
32 |
|
fld=[]; |
33 |
|
end; |
34 |
|
elseif isfield(mygrid,'nFaces'); |
35 |
|
nFaces=mygrid.nFaces; |
36 |
|
fld=[]; |
37 |
|
else; |
38 |
|
error('nFaces needs to be specified'); |
39 |
|
end; |
40 |
|
|
41 |
if nFaces==1; gridType='ll'; |
if nFaces==1; gridType='ll'; |
42 |
elseif nFaces==4; gridType='llpc'; |
elseif nFaces==4; gridType='llpc'; |
47 |
|
|
48 |
nFacesMax=6; |
nFacesMax=6; |
49 |
|
|
|
if nargin>1; fld=varargin{1}; else; fld=[]; end; |
|
|
|
|
50 |
if iscell(fld); |
if iscell(fld); |
51 |
s.nFaces=length(fld); |
s.nFaces=length(fld); |
52 |
s.gridType=gridType; |
s.gridType=gridType; |
53 |
for iF=1:s.nFaces; |
for iF=1:s.nFaces; |
54 |
eval(['s.f' num2str(iF) '=fld{iF};']); |
eval(['s.f' num2str(iF) '=fld{iF};']); |
55 |
end; |
end; |
56 |
for iF=s.nFaces+1:nFacesMax; |
for iF=s.nFaces+1:nFacesMax; |
57 |
eval(['s.f' num2str(iF) '=[];']); |
eval(['s.f' num2str(iF) '=[];']); |
58 |
end; |
end; |
59 |
else; |
else; |
60 |
s.nFaces=nFaces; |
s.nFaces=nFaces; |
61 |
s.gridType=gridType; |
s.gridType=gridType; |