Skip to content

Add optional Vstretching parameter to zlevs.m and zlevs_1d.m#2

Open
loganchal wants to merge 1 commit intoSAEON:masterfrom
loganchal:add-vstretching-support
Open

Add optional Vstretching parameter to zlevs.m and zlevs_1d.m#2
loganchal wants to merge 1 commit intoSAEON:masterfrom
loganchal:add-vstretching-support

Conversation

@loganchal
Copy link
Copy Markdown

Summary

  • Adds optional 9th argument vstretching (1–5) to zlevs.m and zlevs_1d.m, supporting all 5 ROMS vertical stretching functions
  • Fully backwards compatible: existing 8-argument calls produce identical results (defaults to Vstretching=1 for Vtransform=1, Vstretching=4 for Vtransform=2)
  • Emits a warning when vtransform=2 and vstretching is not specified, alerting users who may be reading ROMS files with non-default stretching (e.g. Vstretching=5)

Motivation

The vertical stretching function was previously hardcoded: vtransform=1 always used Song & Haidvogel (1994), and vtransform=2 always used csf() which implements Shchepetkin (2010) — equivalent to Vstretching=4. This broke compatibility with ROMS output files using other Vstretching values, particularly Vstretching=5 (Souza et al., 2015 quadratic Legendre polynomial), used by e.g. the Moana Hindcast (Vtransform=2, Vstretching=5).

Changes

  • zlevs.m: Add optional vstretching parameter with all 5 stretching functions computed inline. Removes csf() dependency. Fixes redundant w-point loop. Removes dead commented-out debug code.
  • zlevs_1d.m: Same changes for the 1D variant.

Supported Vstretching values

Value Function Reference
1 Song and Haidvogel (1994) J. Comput. Phys., 115, 228–244
2 A. Shchepetkin (UCLA-ROMS, 2005) Ocean Modelling, 9, 347–404
3 R. Geyer BBL refinement
4 A. Shchepetkin (UCLA-ROMS, 2010) ROMS default
5 Souza et al. (2015) quadratic Legendre J. Phys. Oceanogr., 45, 424–440

See: https://www.myroms.org/wiki/Vertical_S-coordinate

Backwards compatibility

Calling zlevs(h, zeta, theta_s, theta_b, hc, N, type, vtransform) with 8 arguments works exactly as before. The only new behavior is a warning when vtransform=2 is used without specifying vstretching, since the default (4) may not match the ROMS file.

The vertical stretching function (Vstretching) was previously hardcoded:
vtransform=1 always used Song & Haidvogel (1994), and vtransform=2
always used csf() (Shchepetkin 2010). This broke compatibility with
ROMS output files using other Vstretching values, particularly
Vstretching=5 (Souza et al., 2015 quadratic Legendre polynomial),
used by e.g. the Moana Hindcast (Vtransform=2, Vstretching=5).

Changes:
- Add optional 9th argument 'vstretching' (1-5) to zlevs.m and zlevs_1d.m
- Fully backwards compatible: existing 8-arg calls produce identical results
- Emit warning when vtransform=2 and vstretching is not specified,
  to alert users who may be reading ROMS files with non-default stretching
- Support all 5 ROMS vertical stretching functions inline (no new deps)
- Remove csf() dependency (formulas computed inline)
- Fix redundant w-point loop computation
- Remove dead commented-out debug code

References:
- Song & Haidvogel (1994), J. Comput. Phys., 115, 228-244
- Shchepetkin & McWilliams (2005), Ocean Modelling, 9, 347-404
- Souza et al. (2015), J. Phys. Oceanogr., 45, 424-440
- https://www.myroms.org/wiki/Vertical_S-coordinate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant