/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_overturn.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_overturn.m

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


Revision 1.2 - (hide annotations) (download)
Fri Jun 24 01:55:42 2011 UTC (14 years, 1 month ago) by gforget
Branch: MAIN
Changes since 1.1: +6 -0 lines
- added headers

1 gforget 1.1 function [FLD]=calc_overturn(fldU,fldV,LATS_MASKS);
2 gforget 1.2 %object: compute meridional overturning streamfunction
3     %inputs: fldU and fldV are the fields of grid point transport
4     % LATS_MASKS is the set of quasi longitudinal lines along
5     % which transports will integrated (LATS_MASKS should
6     % have been produced by line_zonal_TUV_MASKS.m)
7     %output: FLD is the streamfunction
8 gforget 1.1
9     global mygrid;
10    
11     %initialize output:
12     n3=max(size(fldU.f1,3),1); n4=max(size(fldV.f1,4),1);
13     FLD=NaN*squeeze(zeros(length(LATS_MASKS),n3+1,n4));
14    
15     %prepare fldU/fldV:
16     fldU(isnan(fldU))=0; fldV(isnan(fldV))=0;
17    
18     dxg=mk3D(mygrid.DXG,fldU); dyg=mk3D(mygrid.DYG,fldU); drf=mk3D(mygrid.DRF,fldU);
19     for k4=1:n4;
20     fldU(:,:,:,k4)=fldU(:,:,:,k4).*dyg.*drf.*mygrid.hFacW*1e-6;
21     fldV(:,:,:,k4)=fldV(:,:,:,k4).*dxg.*drf.*mygrid.hFacS*1e-6;
22     end;
23    
24     %use array format to speed up computation below:
25     fldU=convert2array(fldU); fldV=convert2array(fldV);
26     n1=size(fldU,1); n2=size(fldU,2);
27     fldU=reshape(fldU,n1*n2,n3*n4); fldV=reshape(fldV,n1*n2,n3*n4);
28    
29     for iy=1:length(LATS_MASKS);
30    
31     %get list ofpoints that form a zonal band:
32     mmu=convert2array(LATS_MASKS(iy).mmu);
33     nnu=find(~isnan(mmu)); mmu=mmu(nnu)*ones(1,n3*n4);
34     mmv=convert2array(LATS_MASKS(iy).mmv);
35     nnv=find(~isnan(mmv)); mmv=mmv(nnv)*ones(1,n3*n4);
36    
37     %do the area weighed average along this band:
38     tmpu=sum(fldU(nnu,:).*mmu,1);
39     tmpv=sum(fldV(nnv,:).*mmv,1);
40    
41     %store:
42     FLD(iy,1:n3,:)=-flipdim(cumsum(flipdim(reshape(tmpu+tmpv,n3,n4),1),1),1);
43    
44     end;
45    
46     FLD(:,end,:)=0;
47    
48    

  ViewVC Help
Powered by ViewVC 1.1.22