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

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

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


Revision 1.3 - (hide annotations) (download)
Mon Feb 8 13:19:21 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.2: +14 -7 lines
- add DIM=0 option to operate on dimensions 1 and 2 jointly

1 gforget 1.3 function r = sum(p,varargin);
2     % SUM(p,varargin)
3     %
4 gforget 1.2 %overloaded gcmfaces sum function :
5     % 1) if single gcmfaces argument, then returns the global sum over all faces
6     % 2) if more than one argument, then simply calls double sum function for
7     % each face data, passing over the other arguments
8 gforget 1.1
9     if nargin==1;
10     tmp1=[];
11     for iFace=1:p.nFaces;
12     iF=num2str(iFace);
13     eval(['tmp1=[tmp1;p.f' iF '(:)];']);
14     end;
15     r=sum(tmp1);
16     return;
17     end;
18    
19 gforget 1.3 if varargin{1}>0;
20     r=p;
21     for iFace=1:r.nFaces;
22     iF=num2str(iFace);
23     eval(['r.f' iF '=sum(p.f' iF ',varargin{:});']);
24     end;
25     else;
26     tmp1=convert2gcmfaces(p);
27     [n1,n2,n3,n4]=size(tmp1);
28     tmp1=reshape(tmp1,n1*n2,n3,n4);
29     r=sum(tmp1,1);
30 gforget 1.1 end;
31    

  ViewVC Help
Powered by ViewVC 1.1.22