source: Roms_tools/Preprocessing_tools/zlevs.m @ 2

Last change on this file since 2 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 2.3 KB
Line 
1function 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%
44cff1=1./sinh(theta_s);
45cff2=0.5/tanh(0.5*theta_s);
46if type=='w'
47  sc=((0:N)-N)/N;
48  N=N+1;
49else
50  sc=((1:N)-N-0.5)/N;
51end
52Cs=(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%   
60hinv=1./h;
61cff=hc*(sc-Cs);
62cff1=Cs;
63cff2=sc+1;
64z=zeros(N,M,L);
65for k=1:N
66  z0=cff(k)+cff1(k)*h;
67  z(k,:,:)=z0+zeta.*(1.+z0.*hinv);
68end
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
82return
83
Note: See TracBrowser for help on using the repository browser.