Visual Basic for oceanographic calculations
Please note: These files are in text format. To use with Excel® you will need to change the filename extension from txt to bas. Then they can be loaded as modules in the Visual Basic Editor. Use the ALT-F11 key to start the Visual Basic Editor followed by CTRL-M to import the file into the worksheet.
VB-scripts adapted from the MATLAB® scripts that I have written:
Function Name | Text Filename | Calculation |
---|---|---|
AOU | AOU.txt | AOU from observed O2 conc vs the expected O2 conc from Weiss (1970) |
DENSATP | STP2Dens.txt | Calculate the in situ density of seawater as a function of S, T & P (Millero & Poisson, 1981) |
DENSITY | SwDensity.txt | Calculate the density of seawater as a function of S & T at Pabs = 1 atm (Millero & Poisson, 1981) |
N2SAT | N2sat_v1.txt | N2 saturation as a function of S, & T from Weiss (1970) |
N2SAT_V2 | N2sat_v2.txt | N2 saturation as a function of S, & T from Hamme & Emerson (2004) |
O2SAT_V2A | O2sat_v2a.txt | O2 saturation as a function of S, & T according to Garcia & Gordon (1992) in units of ml O2/L of seawater |
O2SAT_V2B | O2sat_v2b.txt | O2 saturation as a function of S, & T according to Garcia & Gordon (1992) in units of umol O2/kg of seawater |
SAL | Cond2Sal.txt | Calculate Salinity (pss-78) of seawater from Conductivity (S/m), T & P (UNESCO, 1983) |
SBE | SbeC2Sal.txt | Calculate Salinity (pss-78) of seawater from Conductivity (mS/cm), T & P (UNESCO, 1983) |
VapPress | VapPress.txt | Calculate the fugacity coefficient of CO2 in seawater (Weiss & Price, 1980) |
VB-scripts adapted from the MATLAB® scripts that I have collected and modified/optimized for use on a PC: (see note #1 below)
Function Name | Text Filename | Calculation |
---|---|---|
ADIABAT | Adiabat.txt | Computes the adiabatic temperature gradient. |
DEPTH | PLat2Dep.txt | Depth given the pressure at some latitude. |
POTENTMP | Potentmp.txt | Potential temperature from in-situ measurements. Requires adiabat. |
PRESS | DLat2Prs.txt | Pressure given the depth at some latitude. |
Sndspd | Sndspd.txt | Velocity of sound in seawater according to Mackenzie (1981). |
SW_svel | SW_svel.txt | Velocity of sound in seawater according to UNESCO (1983). |
VB-scripts for CO2 systems: (see note #2 below)
Function Name | Text Filename | Calculation |
---|---|---|
CO2Ast_T | CO2Ast_total.txt | Calculate CO2(aq) + H2CO3 as a function of S, T, P, TP, TSi, TAlk & TCO2. |
CO3_T | CO3_total.txt | Calculate CO3= as a function of S, T, P, TP, TSi, TAlk & TCO2. |
fCO2_T | fCO2_total.txt | Calculate fCO2 as a function of S, T, P, TP, TSi, TAlk & TCO2. |
HCO3_T | HCO3_total.txt | Calculate HCO3– as a function of S, T, P, TP, TSi, TAlk & TCO2. |
pH_nbs2sws | pH_nbs2sws.txt | Convert pH on the NBS scale to pH on the Seawater scale |
pH_nbs2total | pH_nbs2total.txt | Convert pH on the NBS scale to pH on the Total scale |
pH_T | pH_total.txt | Calculate pH on the Total scale as a function of S, T, P, TP, TSi, TAlk & TCO2. |
pH_total2nbs | pH_total2nbs.txt | Convert pH on the Total scale to pH on the NBS scale |
pH_nbs2sws | pH_nbs2sws.txt | Convert pH on the Total scale to pH on the Seawater scale |
phi_CO2 | phi_CO2.txt | Calculate the fugacity coefficient of CO2 in seawater according to Kortzinger (1999) |
Notes:
- These algorithms were originally part of the oceanography toolbox [v1.4] compiled by R. Pawlowicz @ WHOI.
- This code was adapted from the work of others: CO2SYS.exe was originally written by Ernie Lewis and Doug Wallace. It was converted to Matlab by Richard E. Zeebe & Dieter A. Wolf-Gladrow. Parts were then extracted and modified by Rachel M. Dunk. I am indebted to all of them for their initial development of this code.