Add optional Vstretching parameter to zlevs.m and zlevs_1d.m#2
Open
loganchal wants to merge 1 commit intoSAEON:masterfrom
Open
Add optional Vstretching parameter to zlevs.m and zlevs_1d.m#2loganchal wants to merge 1 commit intoSAEON:masterfrom
loganchal wants to merge 1 commit intoSAEON:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vstretching(1–5) tozlevs.mandzlevs_1d.m, supporting all 5 ROMS vertical stretching functionsvtransform=2andvstretchingis 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=1always used Song & Haidvogel (1994), andvtransform=2always usedcsf()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 optionalvstretchingparameter with all 5 stretching functions computed inline. Removescsf()dependency. Fixes redundant w-point loop. Removes dead commented-out debug code.zlevs_1d.m: Same changes for the 1D variant.Supported Vstretching values
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 whenvtransform=2is used without specifyingvstretching, since the default (4) may not match the ROMS file.