function [ssum,tbohw,caw,so4w] = ph_swconst(salt,rsw)
%-------------------------------------------------------------------
% PH_SWCONST $Revision: 1.0 $ $Date: 1998/12/07 $
%
% USAGE: [ssum,tbohw,caw,so4w] = ph_swconst(salt,rsw)
%
% DESCRIPTION:
%  calculate concentrations of conservative species (change these 
%  to appropriate values if the porewater is not seawater based.)
%
% INPUT:
%  salt  : salinity of seawater at the specific location [PSU]
%  rsw   : density of seawater at the specific location [kg/m^3]
%
% OUTPUT:
%  ssum  : sum concentration of the conservative species in seawater
%  tbohw  : concentration of total borate in seawater
%  caw   : concentration of total calcite in seawater
%  so4w  : concentration of total sulfate in seawater
%
% ORIGINAL AUTHOR OF THE FORTRAN VERSION: 
%   Bernard Boudreau 
%   Dept. Oceanography 
%   Dalhousie University
%   Halifax, NS B3H 4J1,Canada 
%   bernie@boudreau.ocean.dal.ca
% MATLAB VERSION FROM
%   Roger Luff 98-12-07
%   GEOMAR Research Centre for Marine Geosciences
%   Wischhofstr. 1-3, D-24148 Kiel, Germany
%   visumod@technologist.com
%
% DISCLAIMER:
%   This software is provided "as it is" without warranty of any kind.
%
% REFERENCES:
%   Boudreau B. P. (1996) A method-of-lines code for carbon and 
%   nutrient diagenesis in aquatic sediments.Computers & Geosciences
%   22(5), 479-496.
%   Luff, Haeckel and Wallmann (submitted) "Robust and fast FORTRAN
%   and MATLAB libraries to calculate pH distributions in
%   marine systems", Computers & Geosciences.
%-------------------------------------------------------------------

%-------------------------------------------------------------------
% CHECK INPUT ARGUMENTS
%-------------------------------------------------------------------
if nargin ~=2
   error('ph_swconst.m: Must pass 2 parameters')
end

%-------------------------------------------------------------------
% CALCULATE CONCENTRATIONS OF CONSERVATIVE SPECIES
% (Change these to appropriate values if the porewater
% is not seawater based.)
%-------------------------------------------------------------------
refs= 3.5d+01;
chl = salt/1.80655d+00;
ccl = chl*0.0281756d+00*rsw;
cna = chl*0.0242077d+00*rsw;
cmg = chl*0.0027262d+00*rsw;
caw = chl*0.0005307d+00*rsw;
ck  = chl*0.0005268d+00*rsw;
csr = chl*0.0000047d+00*rsw;
so4w = chl*0.00145753*rsw;
cbr = chl*0.0000434*rsw;
cf  = chl*0.0000035*rsw;
tbohw = 1.212d-05*salt*rsw;
cli = 0.0265*salt/refs;
crb = 0.00135*salt/refs;
ssum = (cna+ck+cli+crb+2.0d+00*(cmg+csr))-(ccl+cf+cbr);
