testSV
Overview
testSV (code/tests/testSV.c, authored by John Hughes Clarke in July 1994 and updated by Jason Bartlett in 2004–2007 and JHC in 2015–2019) is the primary OMG testbed for empirical seawater sound speed equations, UNESCO seawater density equations, and j_watercolumn sound velocity profile (SVP) sorting and interpolation.
It supports five distinct modes of operation:
- Single-Point / Interactive Sound Speed & Density Calculator (Default or
-stz): Computes seawater sound speed using either Chen & Millero (1977) (-chenmill, default, requiring-lat <deg>for latitude-dependent depth-to-pressure conversion viadepth2press()) or Wilson (1962) (-wilson), or computes UNESCO Seawater Density (-unesco_density, viadensity()fromwater.h). - Batch ASCII CTD Profile Processing (
-dofile <file>): Reads 3-column(depth, temp, sal)records from<file>and prints(depth, sound_speed)or(depth, density)tostdout. - SVP Cast Sorting & Ray-Trace Layer Interpolation (
-dotrace <svpfile>): Loads an OMGj_watercolumnSVP file viajWC_read(), sorts asynchronous down/up casts viajWC_sort_async(&wc, JWC_BOTHCAST), and interpolates depth/velocity layers down to-maxdepth(jWC_interp_zv()). - 2D Temperature–Salinity Sound Speed Grid Generation (when
<inname> <outname>are supplied): Computes a $400 \times 300$ floating-point matrix of sound speeds at $z = 2.0\text{ m}$ across Salinity $S \in [0, 40]\text{ ppt}$ ($\Delta S = 0.1\text{ ppt}$) and Temperature $T \in [0, 30]^\circ\text{C}$ ($\Delta T = 0.1^\circ\text{C}$) and writes anOMG1.r4grid to<outname>.
Syntax & CLI Options
# 1. Single-point evaluation on command line (Chen-Millero requires -lat)
testSV [-chenmill -lat <deg> | -wilson | -unesco_density] [-atmos <kg/cm2>] -stz <sal_ppt> <temp_C> <depth_m>
# 2. Interactive loop on stdin
testSV [-chenmill -lat <deg> | -wilson | -unesco_density]
# 3. Process a 3-column (depth, temp, sal) ASCII profile
testSV [-chenmill -lat <deg> | -wilson | -unesco_density] -dofile <ctd_profile.txt>
# 4. Test j_watercolumn SVP reading, sorting, and interpolation
testSV [-v] -dotrace [-maxdepth <m>] [-maxSV <m/s>] <svpfile>
# 5. Export a 400x300 (Salinity x Temperature) OMG .r4 sound speed surface
testSV [-wilson | -chenmill -lat <deg>] <dummy_in> <grid_out.r4>
| Option | Description | Default |
|---|---|---|
-chenmill | Use Chen & Millero’s (1977) equation (do_cml = 1). Requires -lat <deg> so depth2press(depth, latitude) can account for gravitational variation with latitude. | Enabled by default (1) |
-lat <deg> | Geographic latitude in decimal degrees (required when -chenmill is active). | 0.0 (must be non-zero for -chenmill) |
-wilson | Use W. D. Wilson’s (1962) equation (vsw, do_wilson = 1, do_cml = 0). | 0 |
-unesco_density | Compute UNESCO (1981) seawater density (density(sal, temp, pressure) from water.h) instead of sound speed. | 0 |
-stz <S> <T> <Z> | Evaluate a single point with Salinity <S> (ppt), Temperature <T> ($^\circ\text{C}$), and Depth <Z> (m), print the result, and exit (do_just_once = 1). | Interactive loop |
-dofile <file> | Read 3-column (depth, temp, sal) lines from <file> and print depth value pairs to stdout. | Disabled |
-dotrace | Test jWC_init, jWC_read, jWC_sort_async, and jWC_interp_zv on <inname>. | Disabled |
-maxdepth <m> | Maximum interpolation depth (meters) passed to jWC_interp_zv() in -dotrace mode. | 100.0 |
-maxSV <m/s> | Maximum sound velocity parameter for -dotrace (note: line 158 assigns to max_interp_depth in source). | 1490.0 |
-atmos <val> | Atmospheric pressure in $\text{kg/cm}^2$ added to hydrostatic gauge pressure in Wilson / UNESCO / -dofile modes. | 1.0332 |
-v | Enable verbose output (calls jWC_print(&wc) in -dotrace mode). | 0 |
Oceanographic Equations & Historical Verification Notes
- Latitude-Dependent Pressure & Chen-Millero (
soundspeed.c): As documented by Jason Bartlett (JDB, February 2007, lines 303–317), in interactive/-stzChen-Millero mode,testSVconverts depth $z$ (m) and latitude $\phi$ (deg) to pressure in MPa viadepth2press(depth, latitude), scales to bars (MPA_TO_BARS * pressure), and calls the NPL-validatedChenMillero(sal, temp, press_bars)fromsubr/soundspeed.c—achieving agreement with Sea-Bird SBE CTD software on CCGS Amundsen. - Correction of
this_vchemilli(a3term, line 479) andthis_vsw(vstpterm, line 430):testSV.ccontains both the correcteda3term (1.0405e-12 * pow(t, 4)) and the corrected additive+ p *cross-terms inthis_vsw()that were buggy in earlier standalone files (one.c,speed2salinity.c, andspeedtosalinity.c).
Example Usage
# 1. Compute Chen-Millero sound speed at S=34.5 PSU, T=4.2°C, Z=500 m at 70.5°N latitude
testSV -chenmill -lat 70.5 -stz 34.5 4.2 500.0
# 2. Compute UNESCO seawater density at S=35.0 PSU, T=10.0°C, Z=100 m
testSV -unesco_density -stz 35.0 10.0 100.0
# 3. Generate a 400x300 Salinity-Temperature sound speed .r4 raster using Wilson's equation
testSV -wilson dummy_in ts_wilson_grid.r4