Difference between revisions of "Utility Scripts"

From WikiROMS
Jump to navigationJump to search
 
(4 intermediate revisions by 2 users not shown)
Line 14: Line 14:
::<span class="green">z</span> = <span class="red">depths</span> &nbsp;(<span class="green">Fname</span>, <span class="green">Gname</span>, <span class="green">igrid</span>, <span class="green">idims</span>, <span class="green">Tindex</span>)
::<span class="green">z</span> = <span class="red">depths</span> &nbsp;(<span class="green">Fname</span>, <span class="green">Gname</span>, <span class="green">igrid</span>, <span class="green">idims</span>, <span class="green">Tindex</span>)
:'''On Input:'''
:'''On Input:'''
::<span class="green">Fname</span>: &nbsp; ROMS NetCDF data file name (string)
::{| class="matlab"
::<span class="green">Gname</span>: &nbsp; ROMS NetCDF grid file name (string)
|-
::<span class="green">igrid</span>: &nbsp;  Staggered grid C-type (integer):
|<span class="green">Fname</span>:
:::<span class="red">igrid=1</span> - density points
|ROMS NetCDF data file name (string)
:::<span class="red">igrid=2</span> - stream-function points
|-
:::<span class="red">igrid=3</span> - u-velocity points
|<span class="green">Gname</span>:
:::<span class="red">igrid=4</span> - v-velocity points
|ROMS NetCDF grid file name (string)
:::<span class="red">igrid=5</span> - w-velocity points
|-
::<span class="green">idims</span>: &nbsp;  Depths dimension order switch (integer):
|<span class="green">igrid</span>:
:::<span class="red">idims=0</span> - (i,j,k) column-major order (Fortran and Matlab order)
|Staggered grid C-type (integer):
:::<span class="red">idims=1</span> - (j,i,k) raw-major (C-language order)
|-
::<span class="green">Tindex</span>: &nbsp;  Time index for free-surface (integer)
|}
:::{|
|-
|<span class="green">igrid=1</span> - density points
|-
|<span class="green">igrid=2</span> - stream-function points
|-
|<span class="green">igrid=3</span> - u-velocity points
|-
|<span class="green">igrid=4</span> - v-velocity points
|-
|<span class="green">igrid=5</span> - w-velocity points
|-
|}
::{| class="matlab"
|-
|<span class="green">idims</span>:
|Depths dimension order switch (integer):
|-
|}
:::{|
|-
|<span class="green">idims=0</span> - (i,j,k) column-major order (Fortran and Matlab order)
|-
|<span class="green">idims=1</span> - (j,i,k) row-major (C-language order)
|-
|}
::{| class="matlab"
|-
|<span class="green">Tindex</span>:
|Time index for free-surface (integer)
|-
|}
:'''On Output:'''
:'''On Output:'''
::<span class="green">z</span>: &nbsp;  Depths (3D array; meters, negative)<section end=depths.m />
::{| class="matlab"
|-
|<span class="green">z</span>:
|Depths (3D array; meters, negative)
|-
|}<section end=depths.m />
 


<section begin=gcircle.m />;<span id="gcircle"></span><span class="blue">gcircle.m</span>
<section begin=gcircle.m />;<span id="gcircle"></span><span class="blue">gcircle.m</span>
:Computes great circle distance and initial bearing between two longitude and latitude points. The Earth is assumed to be an sphere. This approximation is valid for short distances. Longitude is positive to the east and negative to the west.  Latitude is positive to the north and negative to the south. <br />
:Computes great circle distance and initial bearing between two longitude and latitude points. The Earth is assumed to be a sphere. This approximation is valid for short distances. Longitude is positive to the east and negative to the west.  Latitude is positive to the north and negative to the south. <br />
::[<span class="green">dist</span>, <span class="green">bearing</span>] = <span class="red">gcircle</span> &nbsp;(<span class="green">lon1</span>, <span class="green">lat1</span>,<span class="green">lon2</span>, <span class="green">lat2</span>, <span class="green">BEARING</span>)
::[<span class="green">dist</span>, <span class="green">bearing</span>] = <span class="red">gcircle</span> &nbsp;(<span class="green">lon1</span>, <span class="green">lat1</span>,<span class="green">lon2</span>, <span class="green">lat2</span>, <span class="green">BEARING</span>)
:'''On Input:'''
:'''On Input:'''
::<span class="green">lon1</span>: &nbsp; longitude point 1 (decimal degrees)
::{| class="matlab"
::<span class="green">lat1</span>: &nbsp; latitude  point 1 (decimal degrees)
|-
::<span class="green">lon2</span>: &nbsp; longitude point 2 (decimal degrees)
|<span class="green">lon1</span>:
::<span class="green">lat2</span>: &nbsp; latitude  point 2 (decimal degrees)
|longitude point 1 (decimal degrees)
::<span class="green">BEARING</span>: &nbsp; Switch to compute bearing angle (logical)
|-
|<span class="green">lat1</span>:
|latitude  point 1 (decimal degrees)
|-
|<span class="green">lon2</span>:
|longitude point 2 (decimal degrees)
|-
|<span class="green">lat2</span>:
|latitude  point 2 (decimal degrees)
|-
|<span class="green">BEARING</span>:
|Switch to compute bearing angle (logical)
|-
|}
:'''On Output:'''
:'''On Output:'''
::<span class="green">dist</span>: &nbsp;  Great circle distance between point 1 and point 2 (kilometers)
::{| class="matlab"
::<span class="green">bearing</span>: &nbsp;  Azimuth from point 1 to point 2 counterclockwise from true '''EAST''' (decimal degrees)<section end=gcircle.m />
|-
|<span class="green">dist</span>:
|Great circle distance between point 1 and point 2 (kilometers)
|-
|<span class="green">bearing</span>:
|Azimuth from point 1 to point 2 counterclockwise from true '''EAST''' (decimal degrees)
|-
|}<section end=gcircle.m />
 


<section begin=sample_grid.m />;<span id="sample_grid"></span><span class="blue">sample_grid.m</span>
<section begin=sample_grid.m />;<span id="sample_grid"></span><span class="blue">sample_grid.m</span>
Line 46: Line 105:
::[<span class="green">Istr</span>, <span class="green">Iend</span>, <span class="green">Jstr</span>, <span class="green">Jend</span>] = <span class="red">sample_grid</span> &nbsp;(<span class="green">XD</span>, <span class="green">YD</span>,  <span class="green">XR</span>, <span class="green">YR</span>, <span class="green">offset</span>, <span class="green">plt</span>)
::[<span class="green">Istr</span>, <span class="green">Iend</span>, <span class="green">Jstr</span>, <span class="green">Jend</span>] = <span class="red">sample_grid</span> &nbsp;(<span class="green">XD</span>, <span class="green">YD</span>,  <span class="green">XR</span>, <span class="green">YR</span>, <span class="green">offset</span>, <span class="green">plt</span>)
:'''On Input:'''
:'''On Input:'''
::<span class="green">XD</span>: &nbsp; Donor grid X-coordinates (2D array)
::{| class="matlab"
::<span class="green">YD</span>: &nbsp; Donor grid Y-coordinates (2D array)
|-
::<span class="green">XR</span>: &nbsp; Receiver grid X-coordinates (2D array)
|<span class="green">XD</span>:
::<span class="green">YR</span>: &nbsp; Receiver grid Y-coordinates (2D array)
|Donor grid X-coordinates (2D array)
::<span class="green">offset</span>: &nbsp; Number of extra points to used to sample the donor grid so is large enough to contain the target grid  (optional; default 5)
|-
::<span class="green">plt</span>: &nbsp; Switch to plot parent and target grids (logical; optional; default false)
|<span class="green">YD</span>:
|Donor grid Y-coordinates (2D array)
|-
|<span class="green">XR</span>:
|Receiver grid X-coordinates (2D array)
|-
|<span class="green">YR</span>:
|Receiver grid Y-coordinates (2D array)
|-
|<span class="green">offset</span>:
|Number of extra points used to sample the donor grid so it is large enough to contain the target grid  (optional; default 5)
|-
|<span class="green">plt</span>:
|Switch to plot parent and target grids (logical; optional; default false)
|-
|}
:'''On Ouput:'''
:'''On Ouput:'''
::<span class="green">Istr</span>: &nbsp; Donor grid starting I-index for sampling
::{| class="matlab"
::<span class="green">Iend</span>: &nbsp; Donor grid ending  I-index for sampling
|-
::<span class="green">Jstr</span>: &nbsp; Donor grid starting J-index for sampling
|<span class="green">Istr</span>:
::<span class="green">Jend</span>: &nbsp; Donor grid ending  J-index for sampling<section end=sample_grid.m />
|Donor grid starting I-index for sampling
|-
|<span class="green">Iend</span>:
|Donor grid ending &nbsp; I-index for sampling
|-
|<span class="green">Jstr</span>:
|Donor grid starting J-index for sampling
|-
|<span class="green">Jend</span>:
|Donor grid ending &nbsp; J-index for sampling
|-
|}<section end=sample_grid.m />
 


<section begin=set_depth.m />;<span id="set_depth"></span><span class="blue">set_depth.m</span>
<section begin=set_depth.m />;<span id="set_depth"></span><span class="blue">set_depth.m</span>
:Given a batymetry (h), free-surface (zeta) and terrain-following parameters, this function computes the 3D depths for the request C-grid location. If the free-surface is not provided, a zero value is assumed resulting in unperturbed depths.  This function can be used when generating initial conditions or climatology data for an application. Check this [[Vertical_S-coordinate|page]] for details. <br />
:Given a batymetry (h), free-surface (zeta) and terrain-following parameters, this function computes the 3D depths for the requested C-grid location. If the free-surface is not provided, a zero value is assumed resulting in unperturbed depths.  This function can be used when generating initial conditions or climatology data for an application. Check this [[Vertical_S-coordinate|page]] for details. <br />
::<span class="green">z</span> = <span class="red">set_depth</span> &nbsp;(<span class="green">Vtransform</span>, <span class="green">Vstretching</span>, <span class="green">theta_s</span>, <span class="green">theta_b</span>, <span class="green">hc</span>, <span class="green">N</span>, <span class="green">igrid</span>, <span class="green">h</span>, <span class="green">zeta</span>, <span class="green">report</span>)
::<span class="green">z</span> = <span class="red">set_depth</span> &nbsp;(<span class="green">Vtransform</span>, <span class="green">Vstretching</span>, <span class="green">theta_s</span>, <span class="green">theta_b</span>, <span class="green">hc</span>, <span class="green">N</span>, <span class="green">igrid</span>, <span class="green">h</span>, <span class="green">zeta</span>, <span class="green">report</span>)
:'''On Input:'''
:'''On Input:'''
::<span class="green">Vtransform</span>: &nbsp;  Vertical transformation equation (integer)
::{| class="matlab"
:::<span class="red">Vtransform = 1</span>, &nbsp; original transformation
|-
|<span class="green">Vtransform</span>:
|Vertical transformation equation (integer)
|-
|}
:::{| class="matlab"
|-
|<span class="green">Vtransform = 1</span>
|original transformation
|-
|}
:::: z(x,y,s,t) = Zo(x,y,s) + zeta(x,y,t) * [1+Zo(x,y,s)/h(x,y)]
:::: z(x,y,s,t) = Zo(x,y,s) + zeta(x,y,t) * [1+Zo(x,y,s)/h(x,y)]
:::: Zo(x,y,s) = hc * s + [h(x,y) - hc] * C(s)
:::: Zo(x,y,s) = hc * s + [h(x,y) - hc] * C(s)
:::<span class="red">Vtransform = 2</span>, &nbsp; new transformation
:::{| class="matlab"
|-
|<span class="green">Vtransform = 2</span>
|new transformation
|-
|}
:::: z(x,y,s,t) = zeta(x,y,t) + [zeta(x,y,t) + h(x,y)] * Zo(x,y,s)
:::: z(x,y,s,t) = zeta(x,y,t) + [zeta(x,y,t) + h(x,y)] * Zo(x,y,s)
:::: Zo(x,y,s) = [hc * s(k)+h(x,y) * C(k)] / [hc + h(x,y)]
:::: Zo(x,y,s) = [hc * s(k)+h(x,y) * C(k)] / [hc + h(x,y)]
::<span class="green">Vstretching</span>: &nbsp;  Vertical stretching function (integer):
::{| class="matlab"
:::<span class="red">Vstretching = 1</span>, &nbsp;  original (Song and Haidvogel, 1994)
|-
:::<span class="red">Vstretching = 2</span>, &nbsp;  A. Shchepetkin (UCLA-ROMS, 2005)
|<span class="green">Vstretching</span>:
:::<span class="red">Vstretching = 3</span>, &nbsp;  R. Geyer BBL refinement
|Vertical stretching function (integer):
:::<span class="red">Vstretching = 4</span>, &nbsp;  A. Shchepetkin (UCLA-ROMS, 2010)
|-
::<span class="green">theta_s</span>: &nbsp;  S-coordinate surface control parameter (scalar)
|}
::<span class="green">theta_b</span>: &nbsp;  S-coordinate bottom control parameter (scalar)
:::{| class="matlab"
::<span class="green">hc</span>: &nbsp;  Width (meter) of surface or bottom boundary layer in which higher vertical resolution is required during stretching (scalar)
|-
::<span class="green">N/span>: &nbsp;  Number of vertical levels (scalar)
|<span class="green">Vstretching = 1</span>
::<span class="green">igrid</span>: &nbsp;  Staggered grid C-type (integer):
|original (Song and Haidvogel, 1994)
:::<span class="red">igrid=1</span>, &nbsp; density points
|-
:::<span class="red">igrid=2</span>, &nbsp; stream-function points
|<span class="green">Vstretching = 2</span>
:::<span class="red">igrid=3</span>, &nbsp; u-velocity points
|A. Shchepetkin (UCLA-ROMS, 2005)
:::<span class="red">igrid=4</span>, &nbsp; v-velocity points
|-
:::<span class="red">igrid=5</span>, &nbsp; w-velocity points
|<span class="green">Vstretching = 3</span>
::<span class="green">h</span>: &nbsp;  Bottom depth at RHO-points, <span class="red">h(1:L+1,1:M+1)</span> (2D array; meter; positive)
|R. Geyer BBL refinement
::<span class="green">zeta</span>: &nbsp;  Free-surface at RHO-points, <span class="red">zeta(1:L+1,1:M+1)</span> (2D array; meter; optional)
|-
::<span class="green">h</span>: &nbsp;    Switch to report detailed information (logical; optional; default false)<section end=set_depth.m />
|<span class="green">Vstretching = 4</span>
|A. Shchepetkin (UCLA-ROMS, 2010)
|-
|}
::{| class="matlab"
|-
|<span class="green">theta_s</span>:
|S-coordinate surface control parameter (scalar)
|-
|<span class="green">theta_b</span>:
|S-coordinate bottom control parameter (scalar)
|-
|<span class="green">hc</span>:
|Width (meter) of surface or bottom boundary layer in which higher vertical resolution is required during stretching (scalar)
|-
|<span class="green">N</span>:
|Number of vertical levels (scalar)
|-
|<span class="green">igrid</span>:
|Staggered grid C-type (integer):
|-
|}
:::{| class="matlab"
|-
|<span class="green">igrid=1</span>
|density points
|-
|<span class="green">igrid=2</span>
|stream-function points
|-
|<span class="green">igrid=3</span>
|u-velocity points
|-
|<span class="green">igrid=4</span>
|v-velocity points
|-
|<span class="green">igrid=5</span>
|w-velocity points
|-
|}
::{| class="matlab"
|-
|<span class="green">h</span>:
|Bottom depth at RHO-points, '''h(1:L+1,1:M+1)''' (2D array; meter; positive)
|-
|<span class="green">zeta</span>:
|Free-surface at RHO-points, '''zeta(1:L+1,1:M+1)''' (2D array; meter; optional)
|-
|<span class="green">report</span>:
|Switch to report detailed information (logical; optional; default false)
|-
|}
:'''On Output:'''
:'''On Output:'''
::<span class="green">z</span>: &nbsp; Depths (3D array; meter; negative)
::{| class="matlab"
|-
|<span class="green">z</span>:
|Depths (3D array; meter; negative)
|-
|}<section end=set_depth.m />
 


<section begin=stretching.m />;<span id="stretching"></span><span class="blue">stretching.m</span>
<section begin=stretching.m />;<span id="stretching"></span><span class="blue">stretching.m</span>
:Given the vertical terrain-following vertical stretching parameters, this this routine computes the vertical stretching function used used in ROMS vertical coordinate transformation. Check this [[Vertical_S-coordinate|page]] for details. <br />
:Given the vertical terrain-following vertical stretching parameters, this routine computes the vertical stretching function used in ROMS vertical coordinate transformation. Check this [[Vertical_S-coordinate|page]] for details. <br />
::[<span class="green">s</span>, <span class="green">C</span>] = <span class="red">stretching</span> &nbsp;(<span class="green">Vstretching</span>, <span class="green">theta_s</span>, <span class="green">theta_b</span>, <span class="green">hc</span>, <span class="green">N</span>, <span class="green">kgrid</span>, <span class="green">report</span>)
::[<span class="green">s</span>, <span class="green">C</span>] = <span class="red">stretching</span> &nbsp;(<span class="green">Vstretching</span>, <span class="green">theta_s</span>, <span class="green">theta_b</span>, <span class="green">hc</span>, <span class="green">N</span>, <span class="green">kgrid</span>, <span class="green">report</span>)
:'''On Input:'''
:'''On Input:'''
Line 102: Line 260:
::<span class="green">theta_b</span>: &nbsp;  S-coordinate bottom control parameter (scalar)
::<span class="green">theta_b</span>: &nbsp;  S-coordinate bottom control parameter (scalar)
::<span class="green">hc</span>: &nbsp;  Width (meter) of surface or bottom boundary layer in which higher vertical resolution is required during stretching (scalar)
::<span class="green">hc</span>: &nbsp;  Width (meter) of surface or bottom boundary layer in which higher vertical resolution is required during stretching (scalar)
::<span class="green">N/span>: &nbsp;  Number of vertical levels (scalar)
::<span class="green">N</span>: &nbsp;  Number of vertical levels (scalar)
::<span class="green">kgrid</span>: &nbsp;  Depth grid type flag:
::<span class="green">kgrid</span>: &nbsp;  Depth grid type flag:
:::<span class="red">kgrid=0</span>, &nbsp; stretching at &rho;-points
:::<span class="red">kgrid=0</span>, &nbsp; stretching at &rho;-points
Line 110: Line 268:
::<span class="green">s</span>: &nbsp; S-coordinate independent variable, [-1 <= <span class="red">s</span> <= 0] at vertical &rho;- or w-points (vector)
::<span class="green">s</span>: &nbsp; S-coordinate independent variable, [-1 <= <span class="red">s</span> <= 0] at vertical &rho;- or w-points (vector)
::<span class="green">C</span>: &nbsp; Nondimensional, monotonic, vertical stretching function, <span class="red">C(s)</span>, [-1 <= <span class="red">C(s)</span> <= 0] (1D array)<section end=stretching.m />
::<span class="green">C</span>: &nbsp; Nondimensional, monotonic, vertical stretching function, <span class="red">C(s)</span>, [-1 <= <span class="red">C(s)</span> <= 0] (1D array)<section end=stretching.m />
<section begin=uv_barotropic.m />;<span id="uv_barotropic"></span><span class="blue">uv_barotropic.m</span>
:Computes vertically integrated (barotropic) velocity components for ROMS full grid or boundary edges. <br />
::[<span class="green">ubar</span>, <span class="green">vbar</span>] = <span class="red">uv_barotropic</span> &nbsp;(<span class="green">u</span>, <span class="green">v</span>, <span class="green">Hz</span>, <span class="green">boundary</span>)
:'''On Input:'''
::<span class="green">u</span>: &nbsp;    U-component velocity (array or structure, u-points)
::<span class="green">v</span>: &nbsp;    V-component velocity (array or structure, v-points)
::<span class="green">Hz</span>: &nbsp;  Vertical level thicknesses (meter) at &rho;-points (3D array)
::<span class="green">boundary</span>: &nbsp;  Open boundary switch (1D array, optional):
:::<span class="red">boundary(1)</span>, &nbsp; Process western  boundary
:::<span class="red">boundary(2)</span>, &nbsp; Process eastern  boundary
:::<span class="red">boundary(3)</span>, &nbsp; Process southern boundary
:::<span class="red">boundary(4)</span>, &nbsp; Process northern boundary
:'''On Output:'''
::<span class="green">ubar</span>: &nbsp;  Vertically integrated u-velocity (array or structure)
::<span class="green">vbar</span>: &nbsp;  Vertically integrated v-velocity (array or structure)<section end=uv_barotropic.m />

Latest revision as of 18:41, 4 May 2012

Matlab: Utility Scripts

This page describes several Matlab scripts in the matlab/utility repository sub-directory which are used for various purposes.



depths.m
Computes the depths at the requested staggered C-grid. If the time record (Tindex) is not provided, a zero free-surface is assumed and the unperturbed depths are returned.
z = depths  (Fname, Gname, igrid, idims, Tindex)
On Input:
Fname: ROMS NetCDF data file name (string)
Gname: ROMS NetCDF grid file name (string)
igrid: Staggered grid C-type (integer):
igrid=1 - density points
igrid=2 - stream-function points
igrid=3 - u-velocity points
igrid=4 - v-velocity points
igrid=5 - w-velocity points
idims: Depths dimension order switch (integer):
idims=0 - (i,j,k) column-major order (Fortran and Matlab order)
idims=1 - (j,i,k) row-major (C-language order)
Tindex: Time index for free-surface (integer)
On Output:
z: Depths (3D array; meters, negative)


gcircle.m
Computes great circle distance and initial bearing between two longitude and latitude points. The Earth is assumed to be a sphere. This approximation is valid for short distances. Longitude is positive to the east and negative to the west. Latitude is positive to the north and negative to the south.
[dist, bearing] = gcircle  (lon1, lat1,lon2, lat2, BEARING)
On Input:
lon1: longitude point 1 (decimal degrees)
lat1: latitude point 1 (decimal degrees)
lon2: longitude point 2 (decimal degrees)
lat2: latitude point 2 (decimal degrees)
BEARING: Switch to compute bearing angle (logical)
On Output:
dist: Great circle distance between point 1 and point 2 (kilometers)
bearing: Azimuth from point 1 to point 2 counterclockwise from true EAST (decimal degrees)


sample_grid.m
Computes the donor grid indices range of the polygon that tightly contains the target grid. This is done to sample the donor grid to accelerate the interpolation of fields for the receiver grid. The input coordinates can be either in terms of Cartesian or spherical coordinates
[Istr, Iend, Jstr, Jend] = sample_grid  (XD, YD, XR, YR, offset, plt)
On Input:
XD: Donor grid X-coordinates (2D array)
YD: Donor grid Y-coordinates (2D array)
XR: Receiver grid X-coordinates (2D array)
YR: Receiver grid Y-coordinates (2D array)
offset: Number of extra points used to sample the donor grid so it is large enough to contain the target grid (optional; default 5)
plt: Switch to plot parent and target grids (logical; optional; default false)
On Ouput:
Istr: Donor grid starting I-index for sampling
Iend: Donor grid ending   I-index for sampling
Jstr: Donor grid starting J-index for sampling
Jend: Donor grid ending   J-index for sampling


set_depth.m
Given a batymetry (h), free-surface (zeta) and terrain-following parameters, this function computes the 3D depths for the requested C-grid location. If the free-surface is not provided, a zero value is assumed resulting in unperturbed depths. This function can be used when generating initial conditions or climatology data for an application. Check this page for details.
z = set_depth  (Vtransform, Vstretching, theta_s, theta_b, hc, N, igrid, h, zeta, report)
On Input:
Vtransform: Vertical transformation equation (integer)
Vtransform = 1 original transformation
z(x,y,s,t) = Zo(x,y,s) + zeta(x,y,t) * [1+Zo(x,y,s)/h(x,y)]
Zo(x,y,s) = hc * s + [h(x,y) - hc] * C(s)
Vtransform = 2 new transformation
z(x,y,s,t) = zeta(x,y,t) + [zeta(x,y,t) + h(x,y)] * Zo(x,y,s)
Zo(x,y,s) = [hc * s(k)+h(x,y) * C(k)] / [hc + h(x,y)]
Vstretching: Vertical stretching function (integer):
Vstretching = 1 original (Song and Haidvogel, 1994)
Vstretching = 2 A. Shchepetkin (UCLA-ROMS, 2005)
Vstretching = 3 R. Geyer BBL refinement
Vstretching = 4 A. Shchepetkin (UCLA-ROMS, 2010)
theta_s: S-coordinate surface control parameter (scalar)
theta_b: S-coordinate bottom control parameter (scalar)
hc: Width (meter) of surface or bottom boundary layer in which higher vertical resolution is required during stretching (scalar)
N: Number of vertical levels (scalar)
igrid: Staggered grid C-type (integer):
igrid=1 density points
igrid=2 stream-function points
igrid=3 u-velocity points
igrid=4 v-velocity points
igrid=5 w-velocity points
h: Bottom depth at RHO-points, h(1:L+1,1:M+1) (2D array; meter; positive)
zeta: Free-surface at RHO-points, zeta(1:L+1,1:M+1) (2D array; meter; optional)
report: Switch to report detailed information (logical; optional; default false)
On Output:
z: Depths (3D array; meter; negative)


stretching.m
Given the vertical terrain-following vertical stretching parameters, this routine computes the vertical stretching function used in ROMS vertical coordinate transformation. Check this page for details.
[s, C] = stretching  (Vstretching, theta_s, theta_b, hc, N, kgrid, report)
On Input:
Vstretching:   Vertical stretching function (integer):
Vstretching = 1,   original (Song and Haidvogel, 1994)
Vstretching = 2,   A. Shchepetkin (UCLA-ROMS, 2005)
Vstretching = 3,   R. Geyer BBL refinement
Vstretching = 4,   A. Shchepetkin (UCLA-ROMS, 2010)
theta_s:   S-coordinate surface control parameter (scalar)
theta_b:   S-coordinate bottom control parameter (scalar)
hc:   Width (meter) of surface or bottom boundary layer in which higher vertical resolution is required during stretching (scalar)
N:   Number of vertical levels (scalar)
kgrid:   Depth grid type flag:
kgrid=0,   stretching at ρ-points
kgrid=1,   stretching at w-points
report:   Switch to report detailed information (logical; optional; default false)
On Output:
s:   S-coordinate independent variable, [-1 <= s <= 0] at vertical ρ- or w-points (vector)
C:   Nondimensional, monotonic, vertical stretching function, C(s), [-1 <= C(s) <= 0] (1D array)


uv_barotropic.m
Computes vertically integrated (barotropic) velocity components for ROMS full grid or boundary edges.
[ubar, vbar] = uv_barotropic  (u, v, Hz, boundary)
On Input:
u:   U-component velocity (array or structure, u-points)
v:   V-component velocity (array or structure, v-points)
Hz:   Vertical level thicknesses (meter) at ρ-points (3D array)
boundary:   Open boundary switch (1D array, optional):
boundary(1),   Process western boundary
boundary(2),   Process eastern boundary
boundary(3),   Process southern boundary
boundary(4),   Process northern boundary
On Output:
ubar:   Vertically integrated u-velocity (array or structure)
vbar:   Vertically integrated v-velocity (array or structure)