/[MITgcm]/MITgcm_contrib/mlosch/interp_llc/hfac.m
ViewVC logotype

Annotation of /MITgcm_contrib/mlosch/interp_llc/hfac.m

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


Revision 1.1 - (hide annotations) (download)
Thu May 3 21:07:21 2007 UTC (17 years ago) by mlosch
Branch: MAIN
CVS Tags: HEAD
initial checkin of topography and hydrography interpolation scripts for
the llc-grid, based on old matlab scripts by Alistair Adcroft
Let's hope, they are useful.

1 mlosch 1.1 function [hfacC,ddz] = hfac(dz,H,hfacmin,dzmin)
2     %
3     % Create hfacC(i,j,k) and dz(i,j,k) from dz(k), H(i,j)
4     % using MITgcmUV model parameters hfacmin and dzmin
5     %
6     % e.g.
7     % [hfacC,ddz] = hfac(dz,H,hfacmin,dzmin)
8     % e.g. To create a "p-mask" from above
9     % pmask=zeros(size(hfacC)); pmask( find(hfacC>0) )=1;
10    
11     [nx,ny,nt]=size(H);
12     nz=prod(size(dz));
13     N=[nx ny nt nz];
14    
15     zf=[0 -cumsum(dz)];
16    
17     hfacC=zeros(N);
18     ddz=zeros(N);
19     for k=1:nz,
20     hFacLim=max([ hfacmin min([1 dzmin/dz(k)]) ]);
21     if hFacLim == 1
22     report('Level k=%3i dz(k)=%8.2f Full cell\n',k,dz(k))
23     else
24     report('Level k=%3i dz(k)=%8.2f Lopping with min[hfacC(:,k)*dz(k)]=%8.2f\n',k,dz(k),hFacLim*dz(k))
25     end
26     ddd=(zf(k)-H)/dz(k);
27     ddd(find(ddd > 1)) = 1;
28     %ddd(find(ddd < 0)) = 0;
29     %ddd(find(ddd < hFacLim/2 & ddd ~= 0)) = 0;
30     ddd(find(ddd < hFacLim/2)) = 0; % This should do the job of the above 2 lines
31     ddd(find(ddd >= hFacLim/2 & ddd < hFacLim)) = hFacLim;
32     hfacC(:,:,:,k)=ddd;
33     ddz(:,:,:,k)=ddd*dz(k);
34     end
35    
36     hfacC=squeeze(hfacC);
37     ddz=squeeze(ddz);

  ViewVC Help
Powered by ViewVC 1.1.22