1 | function z = zlevs(h,zeta,theta_s,theta_b,hc,N,type); |
---|
2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3 | % |
---|
4 | % function z = zlevs(h,zeta,theta_s,theta_b,hc,N,type); |
---|
5 | % |
---|
6 | % this function compute the depth of rho or w points for ROMS |
---|
7 | % |
---|
8 | % On Input: |
---|
9 | % |
---|
10 | % type 'r': rho point 'w': w point |
---|
11 | % |
---|
12 | % On Output: |
---|
13 | % |
---|
14 | % z Depths (m) of RHO- or W-points (3D matrix). |
---|
15 | % |
---|
16 | % Further Information: |
---|
17 | % http://www.brest.ird.fr/Roms_tools/ |
---|
18 | % |
---|
19 | % This file is part of ROMSTOOLS |
---|
20 | % |
---|
21 | % ROMSTOOLS is free software; you can redistribute it and/or modify |
---|
22 | % it under the terms of the GNU General Public License as published |
---|
23 | % by the Free Software Foundation; either version 2 of the License, |
---|
24 | % or (at your option) any later version. |
---|
25 | % |
---|
26 | % ROMSTOOLS is distributed in the hope that it will be useful, but |
---|
27 | % WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
29 | % GNU General Public License for more details. |
---|
30 | % |
---|
31 | % You should have received a copy of the GNU General Public License |
---|
32 | % along with this program; if not, write to the Free Software |
---|
33 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
34 | % MA 02111-1307 USA |
---|
35 | % |
---|
36 | % Copyright (c) 2002-2006 by Pierrick Penven |
---|
37 | % e-mail:Pierrick.Penven@ird.fr |
---|
38 | % |
---|
39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
40 | [M,L]=size(h); |
---|
41 | % |
---|
42 | % Set S-Curves in domain [-1 < sc < 0] at vertical W- and RHO-points. |
---|
43 | % |
---|
44 | cff1=1./sinh(theta_s); |
---|
45 | cff2=0.5/tanh(0.5*theta_s); |
---|
46 | if type=='w' |
---|
47 | sc=((0:N)-N)/N; |
---|
48 | N=N+1; |
---|
49 | else |
---|
50 | sc=((1:N)-N-0.5)/N; |
---|
51 | end |
---|
52 | Cs=(1.-theta_b)*cff1*sinh(theta_s*sc)... |
---|
53 | +theta_b*(cff2*tanh(theta_s*(sc+0.5))-0.5); |
---|
54 | % |
---|
55 | % Create S-coordinate system: based on model topography h(i,j), |
---|
56 | % fast-time-averaged free-surface field and vertical coordinate |
---|
57 | % transformation metrics compute evolving depths of of the three- |
---|
58 | % dimensional model grid. |
---|
59 | % |
---|
60 | hinv=1./h; |
---|
61 | cff=hc*(sc-Cs); |
---|
62 | cff1=Cs; |
---|
63 | cff2=sc+1; |
---|
64 | z=zeros(N,M,L); |
---|
65 | for k=1:N |
---|
66 | z0=cff(k)+cff1(k)*h; |
---|
67 | z(k,:,:)=z0+zeta.*(1.+z0.*hinv); |
---|
68 | end |
---|
69 | |
---|
70 | %if type=='w' |
---|
71 | % hmin=min(min(h)); |
---|
72 | % hmax=max(max(h)); |
---|
73 | % for k=N:-1:1 |
---|
74 | % cff1=sc(k)*hc+(hmin-hc)*Cs(k); |
---|
75 | % cff2=sc(k)*hc+(0.5*(hmin+hmax)-hc)*Cs(k); |
---|
76 | % cff3=sc(k)*hc+(hmax-hc)*Cs(k); |
---|
77 | % disp([num2str(k,6),' | ',num2str(sc(k),6),' | ',num2str(Cs(k)),' | ',... |
---|
78 | % num2str(cff1),' | ',num2str(cff2),' | ',num2str(cff3)]) |
---|
79 | % end |
---|
80 | %end |
---|
81 | |
---|
82 | return |
---|
83 | |
---|