/[MITgcm]/MITgcm/verification/obcs_ctrl/input_ad/VERT_FSFB2.m
ViewVC logotype

Contents of /MITgcm/verification/obcs_ctrl/input_ad/VERT_FSFB2.m

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


Revision 1.1 - (show annotations) (download)
Wed Apr 20 19:18:25 2011 UTC (12 years, 11 months ago) by mmazloff
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62w, checkpoint62z, checkpoint62y, checkpoint62x, HEAD
Verification experiment using obcs controls

1 function [c2, Psi, G, N2, Pmid] = VERT_FSFB2(N2,Pmid)
2 %function [c2, Psi, G, N2, Pmid] = VERT_FSFB2(N2,Pmid)
3 %
4 % VERT_FSFB.m
5 %
6 % Gabriel A. Vecchi - May 12, 1998
7 %%%%%%%%%%%%%%%%
8 %
9 % Solves the discretized wave projection problem
10 % given the vertical profiles of Temperature, Salinity, Pressure
11 % and the depth inteval length.
12 %
13 % Uses the seawater function sw_bfrq to calculate N2.
14 %%%%%%%%%%%%%%%%
15 %
16 % Arguments:
17 % T = temperature vector at same depths as salinity and pressure.
18 % S = salinity vector at same depths as temperature and pressure.
19 % P = pressure vector at same depths as temperature and salinity.
20 % Dz = length of depth interval in meters.
21 %%%%%%%%%%%%%%%%
22 %
23 % Returns:
24 % c2 = vector of square of the wavespeed.
25 % Psi = matrix of eigenvectors (horizontal velocity structure functions).
26 % G = matrix of integral of eigenvectors (vertical velocity structure functions).
27 % N2 = Brunt-Vaisla frequency calculated at the midpoint pressures.
28 % Pmid = midpoint pressures.
29 %%%%%%%%%%%%%%%%
30
31 % Find N2 - get a M-1 sized vector, at the equator.
32 %[N2,crap,Pmid] = sw_bfrq(S,T,P,0);
33
34 for i = 1:length(N2)
35 if N2(i) < 0
36 N2(i) = min(abs(N2));
37 end;
38 end;
39
40 % bdc: needs equally-spaced depths!
41 Dz= median(diff(Pmid));
42
43 % add a point for the surface
44 M = length(N2)+1;
45
46 % Fill in D - the differential operator matrix.
47 % Surface (repeat N2 from midpoint depth)
48 D(1,1) = -2/N2(1);
49 D(1,2) = 2/N2(1);
50 % Interior
51 for i = 2 : M-1,
52 D(i,i-1) = 1/N2(i-1);
53 D(i,i) = -1/N2(i-1)-1/N2(i);
54 D(i,i+1) = 1/N2(i);
55 end
56 % Bottom
57 D(M,M-1) = 2/N2(M-1);
58 D(M,M) = -2/N2(M-1);
59 D=-D./(Dz*Dz);
60 %bdc: no need for A?
61 % A = eye(M);
62
63 % Calculate generalized eigenvalue problem
64 % bdc: eigs gets top M-1
65 %[Psi,lambda] = eigs(D,[],M-1);
66 % use eig:
67 [Psi,lambda] = eig(D);
68
69 % Calculate square of the wavespeed.
70 c2 = sum(lambda);
71 c2=1./c2;
72
73 Psi = fliplr(Psi);
74 c2 = fliplr(c2);
75 for i=1:size(Psi,2)
76 Psi(:,i) = Psi(:,i)/Psi(1,i);
77 end
78
79 % normalize?
80 G = INTEGRATOR(M,Dz)*Psi;
81
82 function [INT] = INTEGRATOR(M,Del)
83 %function [INT] = INTEGRATOR(M,Del)
84 %
85 % INTEGRATOR.m
86 %
87 % Gabriel A. Vecchi - June 7, 1998
88 %%%%%%%%%%%%%%%%
89 % Generates and integration matrix.
90 % Integrates from first point to each point.
91 %%%%%%%%%%%%%%%%
92
93 INT = tril(ones(M));
94 INT = INT - 0.5*(eye(M));
95 INT(:,1) = INT(:,1) - 0.5;
96 INT = INT*Del;
97
98

  ViewVC Help
Powered by ViewVC 1.1.22