/[MITgcm]/MITgcm_contrib/gmaze_pv/subfct/subfct_getdS.m
ViewVC logotype

Contents of /MITgcm_contrib/gmaze_pv/subfct/subfct_getdS.m

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


Revision 1.1 - (show annotations) (download)
Wed Sep 19 15:24:41 2007 UTC (17 years, 10 months ago) by gmaze
Branch: MAIN
CVS Tags: HEAD
General Update

1 % DS = subfct_getdS(LAT,LON)
2 % This function computes the 2D dS surface elements centered
3 % on LON,LAT
4 %
5
6 function varargout = subfct_getdS(Y,X);
7
8 ny = length(Y);
9 nx = length(X);
10
11 if nx == size(X,1)
12 X = X';
13 end
14 if ny == size(Y,1)
15 Y = Y';
16 end
17
18 %%% Compute the DY:
19 % Assuming Y is independant of ix:
20 d = m_lldist([1 1]*X(1),Y);
21 dy = [d(1)/2 (d(2:length(d))+d(1:length(d)-1))/2 d(length(d))/2];
22 dy = meshgrid(dy,X)';
23
24 %%% Compute the DX:
25 clear d
26 for iy = 1 : ny
27 d(:,iy) = m_lldist(X,Y([iy iy]));
28 end
29 dx = [d(1,:)/2 ; ( d(2:size(d,1),:) + d(1:size(d,1)-1,:) )./2 ; d(size(d,1),:)/2];
30 dx = dx';
31
32 %% Compute the horizontal DS surface element:
33 ds = dx.*dy;
34
35 switch nargout
36 case 1
37 varargout(1) = {ds};
38 case 2
39 varargout(1) = {ds};
40 varargout(2) = {dx};
41 case 3
42 varargout(1) = {ds};
43 varargout(2) = {dx};
44 varargout(3) = {dy};
45 end

  ViewVC Help
Powered by ViewVC 1.1.22