/[MITgcm]/MITgcm_contrib/gael/matlab_class/@gcmfaces/gcmfaces.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/@gcmfaces/gcmfaces.m

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


Revision 1.4 - (hide annotations) (download)
Tue Jul 31 19:08:43 2012 UTC (12 years, 11 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q
Changes since 1.3: +42 -18 lines
- review the variou options of input params.

1 gforget 1.1 function s=gcmfaces(varargin);
2 gforget 1.3 %object: create an empty gcmfaces object
3 gforget 1.4 %input: fld cell array containing each face data
4     % OR nFaces number of faces (empty faces in output)
5     % OR (none; results in empty face data, with nFaces=mygrid.nFaces)
6     %output: gcmfaces object
7    
8    
9     %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 gforget 1.1
17 gforget 1.2 global mygrid;
18    
19 gforget 1.4 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 gforget 1.2
41     if nFaces==1; gridType='ll';
42     elseif nFaces==4; gridType='llpc';
43     elseif nFaces==5; gridType='llc';
44     elseif nFaces==6; gridType='cube';
45     else; error('wrong gcmfaces definition');
46     end;
47 gforget 1.1
48     nFacesMax=6;
49    
50     if iscell(fld);
51 gforget 1.4 s.nFaces=length(fld);
52     s.gridType=gridType;
53     for iF=1:s.nFaces;
54     eval(['s.f' num2str(iF) '=fld{iF};']);
55     end;
56     for iF=s.nFaces+1:nFacesMax;
57     eval(['s.f' num2str(iF) '=[];']);
58     end;
59 gforget 1.1 else;
60 gforget 1.2 s.nFaces=nFaces;
61     s.gridType=gridType;
62     for iF=1:nFacesMax;
63     eval(['s.f' num2str(iF) '=[];']);
64     end;
65 gforget 1.1 end;
66    
67     s = class(s,'gcmfaces');
68    

  ViewVC Help
Powered by ViewVC 1.1.22