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

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

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

revision 1.1 by gforget, Wed Feb 10 14:43:47 2010 UTC revision 1.5 by gforget, Tue Jan 12 14:37:03 2016 UTC
# Line 1  Line 1 
1  function s=gcmfaces(varargin);  function s=gcmfaces(varargin);
2    %object:    create an empty gcmfaces object
3    %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  if nargin==0; fld=5; gridType='llc';  
9  elseif nargin==1; fld=varargin{1}; gridType='llc';  %object:    create an empty gcmfaces object
10  elseif nargin==2; fld=varargin{1}; gridType=varargin{2};  %input:     fld cell array containing each face data
11  else; error('wrong gcmfaces definition'); end;  %      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;
18    
19    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        nFaces=1;
39        fld=[];
40        warning('nFaces set to 1 by default');
41    end;
42    
43    if nFaces==1; gridType='ll';
44    elseif nFaces==4; gridType='llpc';
45    elseif nFaces==5; gridType='llc';
46    elseif nFaces==6; gridType='cube';
47    else; error('wrong gcmfaces definition');
48    end;
49    
50  nFacesMax=6;  nFacesMax=6;
51    
52  if iscell(fld);  if iscell(fld);
53     s.nFaces=length(fld);      s.nFaces=length(fld);
54     s.gridType=gridType;      s.gridType=gridType;
55     for iF=1:s.nFaces;      for iF=1:s.nFaces;
56        eval(['s.f' num2str(iF) '=fld{iF};']);          eval(['s.f' num2str(iF) '=fld{iF};']);
57     end;      end;
58     for iF=s.nFaces+1:nFacesMax;        for iF=s.nFaces+1:nFacesMax;
59        eval(['s.f' num2str(iF) '=[];']);          eval(['s.f' num2str(iF) '=[];']);
60     end;      end;
 elseif isreal(fld);  
    s.nFaces=fld;  
    s.gridType=gridType;  
    for iF=1:nFacesMax;  
       eval(['s.f' num2str(iF) '=[];']);  
    end;  
61  else;  else;
62     error('wrong gcmfaces definition');      s.nFaces=nFaces;
63        s.gridType=gridType;
64        for iF=1:nFacesMax;
65            eval(['s.f' num2str(iF) '=[];']);
66        end;
67  end;  end;
68    
69  s = class(s,'gcmfaces');  s = class(s,'gcmfaces');

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.22