version 3.0.5, 2015-01-06
-----------------------------------
- Function buffer: K0 is computed with potential T and atm pressure only (K0pot);
- Function buffer: the pH scale conversions are corrected as done previously (v3.0.4) in carb.R
- Function buffer: indices for variables from carb have been corrected (they differ in new version of carb).


version 3.0.4, 2015-01-05
-----------------------------------
- New function: tetha to compute potential temperature (corresponding help file added too)
- Function carb: added potential fCO2 and pCO2 (fCO2pot, pCO2pot) in the output
- Function carb: added a new option "gas" as an input argument as recommended by Orr & Epitalon (2015). It can be either 'insitu' or 'potential' (the default). For flags 21 to 25, this new option describes whether the input pCO2 that is given is "in situ" pCO2 or potential pCO2. For other flags, this input option is not used. In situ values are calculated after making pressure corrections to K0 and the fugacity coefficient following Weiss (1974) using total in situ pressure and in situ temperature. Potential values are calculated at 1 atm pressure while using potential instead of in situ temperature.
- Function carb: as a result of the change above, the carb function now uses the swTheta function of the oce package which therefore needs to be installed.
- Function carb: corrected errors in pH scale conversion and fCO2 to pCO2 conversion
- Functions carb, buffer, buffesm and Ks: removed unused variables ION and iom0
- Function Kf: fixed erroneous equation using wrong ionic strength (replaced ION with iom0) 
- Changed data set Pcoeffs.txt: changed 'a0' for Kspa from -46.00 to -45.96, consitent with literature
- Function rho: convert input T (ITS 90) to T (IPTS 68) and then compute density, as intended
- Functions Ks, Pcorrect, at, buffer, buffesm, kconv, pHconv: more accurate Ft equation and clearer St equation (best practices)
- Function Kb: refined pH scale conversion
- Functions K1, K2 and carb: corrected errors in pH scale conversion
- Corrected English

version 3.0.3, 2014-12-10
-----------------------------------
- Changed the formulation for the concentration of boron from Lee et al. (2000) to Upstrom (1974), as recommended by Orr and Epitalon (2014)
- Corrected a bug introduced in the carb function of v3.0.2
- The changes below clarify the changes described for v3.0.2
- Fugacity coefficient (for fCO2 <-> pCO2 conversion) modified: (1) changed the gas constant R to use the correct units (as in Weiss (1974); (2) included the "x2" term in Weiss (1974); (3) accounted for total pressure (Ptot = atmospheric + hydrostatic) as in Weiss (1974) instead of assuming Ptot = 1 atm
- K0 modified: added the pressure correction term in Weiss (1974).

version 3.0.2, 2014-11-17
-----------------------------------
- Functions carb and buffer now have an extra setting: Patm, the atmospheric pressure in atm
- Added three new functions written by James Orr: vapress, x2pCO2 and p2xCO2.
- James Orr also added pressure correction to K0, using Weiss (1974, equation 5)
- James Orr corrected an error in the fugacity coefficient
- Removed function carbex
- Removed function carbm which will be rewritten on par with carb IF it is useful to someone

version 3.0.1, 2014-08-19
-----------------------------------
- Pt and Sit are set to 0 if NA (in all functions where these variables are used except carbex and carbm)
- Improved citation information

version 3.0, 2014-03-06
-----------------------------------
1- Major update led by Jean-Marie Epitalon, who has become a coauthor of the package.

2- Speed optimisation of the computation of dissociation constants by (1) using vectors rather than loops and (2) passing optional parameters. The increase in speed is up to 35x.

3- Computation of dissociation constants:
- One or two pHScale conversion factor(s) are passed as optional parameter(s) to speed-up computation: (i) kSWS2scale to convert from the seawater scale (SWS) to the pH scale selected at the hydrostatic pressure value indicated and (ii) ktotal2SWS_P0 to convert from the total scale to the SWS at an hydrostatic pressure of 0.These conversion factors are calculated using function kconv() if they are not given.
- Computations are vectorized rather than using loops.
- Warning messages for out-of-validity-domain: only one message per constant (instead of one per data entry).

4- Pressure correction function Pcorrect:
- Two pHScale conversion factors are passed as optional parameters to speed-up computation: (i) kconv2Scale to convert from the pH scale selected to the SWS (or free for Kf) scale at the hydrostatic pressure value indicated and (ii) kconv2ScaleP0 to convert from pH scale selected to the SWS (or free for Kf) scale at the hydrostatic pressure value indicated. These conversion factors are calculated using function kconv() if they are not given.
- Computations are vectorized rather than using loops

5- pH scale conversion kconv:
- Two dissociation constants passed as optional parameters to speed-up computation: Ks and Kff, which is Kf on the free pH scale

6- All these optional parameters not only allow faster calculations, they also allow more precise computation since the pHscale conversions are now based on the Ks and Kf values calculated as selected by the user (Dickson or Khoo for Ks, Perez & Fragra or Dickson & Goyet for Kf). In a previous version, an attempt has been made to remember Kf formulation choice but it does not support the case of data set with different choice for each entry.

7- carb function:
- Instead of looping though data: processing is made in batches
- For each particular value f of flag, a subset of all data is created based on flag=f, then this subset is processed in one shot
- When the Taylor approximation algorithm is used (call to uniroot()), a loop iteration over data is still used
- Dissociation constants Kxy: for each Kxy, a vector of values for all data is computed at the beginning in one shot; there is only one call to the function Kxy()
- When flag=8, the approximation of DIC by the Taylor algorithm is replaced by direct computation as DIC is linearly dependent on carbonate alkalinity.

8- buffer function: computations are vectorized rather than using loops.

9- Kf now uses a correct formulation for ionic strength.

-----------------------------------
version 2.4.10, 2013-04-17
- Added function carbex to experiment potential future changes. DO NOT USE this function

-----------------------------------
version 2.4.9, 2013-03-11
- Replaced Kh by K0, the right symbol for the solubility of carbon dioxide in sea water. Many functions and help files were changed.
- The range of salinity for K1 and K2 according to Roy et al. (1993) was wrong (0-45). The correct range of salinity (5-45) is now used. Several functions, including K1 and K2, and their help files were changed.

-----------------------------------
version 2.4.8, 2013-02-22
The previous version 2.4.7 was rejected by CRAN. This version is an attempt to fix two issues. There are no bug fix nor new capabilities.

-----------------------------------
version 2.4.7, 2013-01-18 [not distributed through CRAN which rejected it]
Thanks to James Orr for identifying the errors below and providing corrected code for all the routines mentioned.
- Corrected a bug in the calculation of Kf, the stability constant of hydrogen fluoride, according to Dickson and Goyet (1994)[flag kf="dg"]. The effect on computed results is negligible.
- Corrected a bug in the pressure correction of Ksi, the dissociation constant of Si(OH)4. The coefficient a2 had the wrong sign. There is no impact on surface values; small but significant differences will be found for deep samples where Si concentrations are substantial.
- Modified calculations of Kw, K1p, K2p, K3p and Ksi to use the exact method to convert each constant from the seawater to the total scale instead of the approximation that simply subtracts 0.015 (Dickson et al., 2007, Chapter 5, page 14, footnote 5). That "constant" now varies from 0.000 to 0.032, but the impact on computed results are quite small (as are differences between the Seawater and Total scales)
- Made minor changes to Kf and kconv for consistent recovery of the kf option.

-----------------------------------
version 2.4.6, 2012-12-12
- Corrected a small bug which prevented to use function K2 with a vector.

-----------------------------------
version 2.4.5, 2012-10-18
Thanks to Jean-Marie Epitalon for reporting the following two minor errors.
- Minor error corrected in the documentation of carb (example of method #1, Sit and Pt were not corretly used)
- "seacarb_test" removed as it is no longer used. It was replaced by "seacarb_test_P0" and "seacarb_test_P300" long ago but remained in the documentation.

-----------------------------------
version 2.4.4, 2012-06-26
- Modification on Pcorrect to optimise processing speed.
- New function zzz.R which loads Pcoeff when package is loaded.

-----------------------------------
version 2.4.3, 2011-11-13
- New function: carbm Returns parameters of the seawater carbonate system, in case of artificial addition of boron in seawater.
- bor, buffer, bufferesm, oa, Om, pCa, pgas, pHinsi, pmix, pTA were modified in order to add the formulation of Lee et al. (2011) to compute total boron from salinity.

-----------------------------------
version 2.4.2, 2011-05-25
- Fixed a major bug in Om

-----------------------------------
version 2.4.1, 2011-03-21
- Changed name of function oMgCa to Om in preparation for consistency with new functions Oa (aragonite saturation state) and Oc (calcite saturation state). Sorry for the inconvenience.
- Fixed small mistakes in the ChangeLog

-----------------------------------
version 2.4, 2011-03-15
- New function: at computes total alkalinity with potentiometric titration data
- New function: oMgCa computes the saturation state of magnesian calcite
- New function: Pcorrect performs pressure corrections of the dissociation constants
- New data set: alkalinity (see function at)
- New data set: Pcoeffs (see function Pcorrect)
- Kf: bug fixed when using Dickson and Goyet formulation with the free and seawater scale

-----------------------------------
version 2.3.5, 2010-09-06
- New function: buffesm contributed to by Jim Orr

-----------------------------------
version 2.3.4, 2010-04-23
- New functions: p2d and d2p to convert pressure to depth and vice versa.
- Kb: pressure correction modified in order to be consistent with Millero (1979). 
- Kw modified in order to be consistent with Dickson et al. (2007). 
- Pressure correction constants in Kw were modified in order to be consistent with a seawater system (and not fresh water), according to Millero 1983. 
- The changes on Kb and Kw were made following comments from James Rae, to whom we are grateful. 

-----------------------------------
version 2.3.3, 2010-03-29
- New functions: p2fCO2 and f2pCO2 to convert pCO2 to fCO2 and vice versa.
- K1p, K2p, K3p, Kb, Kf, Khs, Kn, Ks, Kw, Ksi were modified in order to return warnings if they are used outside of the ranges of salinity and temperature of the formulations used.  
- carb was modified in order to return NA if an NA is given in var1 or var2. 
- K1 and K2 were modified in order to add the formulation of Millero (2010). 
- Ks was modified in order to add the formulation of Khoo et al. (1977).  
- Minor changes to the documentation of K1, K2 and Kf. Also, the reference to Kf was changed to Dickson and Riley (1979 in Dickson and Goyet, 1994).

-----------------------------------
version 2.3.2, 2010-03-04
- carb was modified in order to fix minor bugs occurring when a pH scale other than the total scale is used. 
- K1 and K2 were modified in order to add the calculation from Millero et al. (2006). 
- The default values of K1, K2 and Kh now depend on T and S.
- minor changes to the documentation of Ks, 
- K1, K2 and Kf were modified in order to return warnings if they are used out of the T/S range of validity of formulations. 

-----------------------------------
version 2.3.1, 2010-01-26
- minor changes to the documentation
- In order to better reflect the contribution of the authors, the main authors are now Lavigne & Gattuso and Proye is listed as a contributor

-----------------------------------
version 2.3, 2010-01-06
- identical to 2.2.3

-----------------------------------
version 2.2.3, 2010-01-06
- minor changes on function ocean acidification and its help file

-----------------------------------
version 2.2.2, 2009-12-31
- oa: new function added. It describes the different ways to simulate an ocean acidification.
- Minor corrections in pph to take into account the dilution effect on DIC and ALK. However, the effect of dilution on salinity is not taken into account (i.e; it is assumed that the salinity change is minor or that the acid added has the same salinity as the sample).

-----------------------------------
version 2.2.1, 2009-10-17
- Help of pmix revised with the correct definition of wf: "Weight fraction of the high CO2 seawater per kg seawater" (instead of "Weight fraction of the high CO2 seawater vs normal seawater")
- Other minor changes to some help files.

-----------------------------------
version 2.2, 2009-10-06
- Andreas Hofmann identified bugs in the pressure corrections. These were fixed as explained below.
- K1, K2, pK1, pK2, pK3, Kw, Kb, Khs, Ksi: pH is converted from the total to the SWS scale before doing the pressure corrections.
- Kf using the Perez and Fraga formulation (kf = "pf"): pH is converted from the total to the free scale before doing the pressure correction
- kconv: it is now possible to choose the formulation of Kf ("pf" for using Kf from Perez and Fraga (1987) and "dg" for using Kf from Dickson and Riley (1979 in Dickson and Goyet, 1994), default is "pf").
- K1, K2, pK1, pK2, pK3, Kw, Kb, Khs, Ksi: help files updated with information on the pressure correction.
- Kh, Kspa and Kspc: minor changes were made in the example section of the help files.

-----------------------------------
version 2.1.5, 2009-07-17
- corrected citations and list of references in the man pages of the carb function.

-----------------------------------
version 2.1.4, 2009-07-09
- Another attempt to put line breaks in the documentation files

-----------------------------------
version 2.1.3, 2009-06-20
- carb was modified in order to fix some bugs occurring when extremes values were given in arguments. 
- renamed data set "seacarb_test" for P=0 as "seacarb_test_P0"
- added a new data set "seacarb_test_P0" for P=300. 

-----------------------------------
version 2.1.2, 2009-05-26
- Cosmetic changes in the documentation

--------------------------
version 2.1.1, 2009-04-30
- New functions: pH, pHslope, tris, amp

--------------------------
version 2.1.0, 2009-04-21
- the pHscales were added in option to calculate the constants of acidity and in the functions : carb, buffer, pgas, pTA, pCa, ppH, pmix and psi.
- the choice of the method of calculation for K1, K2 and Kf was added in option in the functions : carb, buffer, pgas, pTA, pCa, ppH, pmix and psi.
- two bugs were fixed in the function carb: one about effect of pressure (P) and the other one in the computation of pCO2 and fCO2 when (P>0).
- pHconv was changed in order to fix a bug and facilitate his using.

--------------------------
version 2.0.9, 2009-04-20
- added function psi

--------------------------
version 2.0.8, 2009-04-16
- changed the help file of seacarb_test to remove the use of \item (it prevented compilation on CRAN).

--------------------------
version 2.0.7, 2009-04-07
- changed the help file of ppH to correct an error concerning the addition of acid (the normality was wrong).

--------------------------
version 2.0.6, 2009-02-09
Changes made thanks to comments kindly provided by Andreas Hofmann (A.Hofmann@nioo.knaw.nl):
- Kf was modified in order to convert Kf from free scale to total scale after pressure corrections in the Dickson and Goyet Method.

--------------------------
version 2.0.5, 2008-12-08
Changes made thanks to comments kindly provided by Andreas Hofmann (A.Hofmann@nioo.knaw.nl):
- K2 modified to fix a bug which provided warnings when several pressures were used.
- Khs modified to fix a bug (in coefficient a2).
- The value of the R constant was updated according to Dickson et al. (2007). The new value is 8.314475 J/(K*mol).
- kconv was modified in order to include pressure correction.

--------------------------
version 2.0.4, 2008-11-06
- pH, pTA, pmix, pCa, and pgas now accept Sit (concentration of silicate) and Pt (concentration of total phosphate) as input arguments.
- Various style changes in the help files.

--------------------------
version 2.0.3, 2008-11-04
- The code of all functions which calculate constants was modified in order to be able to use vectors as input arguments.
- The man files were changed accordingly by adding a "details" section.
--------------------------

version 2.0.1, 2008-10-28
- added the data set seacarb_test
- added and example to use carb with a data frame
- various cosmetic changes in the help files

--------------------------
version 2.0, 2008-10-27

- added function "pCa" which calculates the changes in the saturation states of aragonite and calcite resulting from the manipulation of the calcium concentration
- added function "pgas" which calculates the carbonate chemistry after changes in pCO2 generated by gas bubbling
- added function "pmix" which calculates the carbonate chemistry after mixing of two water samples with different pCO2
- added function "ppH" which calculates the carbonate chemistry after pH manipulations through addition of acid or base
- added function "pTA" which calculates the carbonate chemistry following addition of CO3 or HCO3
- carb function modified to return only S, T, P, pH, pCO2, fCO2, HCO3, CO3, DIC, ALK, OmegaAragonite and OmegaCalcite.
- added function "buffer" which calculates the buffer parameters of the seawater carbonate system. 
- carb function modified in order to closely follow the recommendations of the "Guide to Best Practices for Ocean CO2 Measurements" (Dickson et al., 2007). Phosphate ans ilicate concentrations are now taken into account.
- K1 function uses the equation of Lueker et al. (2000) by default
- K2 function uses the equation the method of Lueker et al. (2000) by default
- Kf function uses, by default, the equation of Perez and Fraga (1987). The equation of Dickson and Roy can be used with the argument kf = 'dg'.

--------------------------
version 1.2.3, 2007-11-27

- carb function modified to allow NA values in the input data. A warning is returned if this happens but all other data rows are processed. Change made by Bernard Gentili.

--------------------------
version 1.2.2, 2007-09-09

- correction of the definition of PiH and PhiH in the "carb" documentation file
- BetaD is the Revelle factor (the "carb" documentation has been updated
- cosmetic changes to some documentation files

--------------------------
version 1.2.1, 2007-08-21

- cosmetic changes to some documentation files

--------------------------
version 1.2, 2007-08-21

- added function "speciation" which estimates the concentration of the various ionic forms of a molecule as a function of pH (contributed by Karline Soetaert)
- added function "kconv" which provides conversion factors to change the pH scale of dissociation constants (contributed by Karline Soetaert)
- added function "pHconv" which provides conversion factors for changing the pH scale (contributed by Karline Soetaert)
- added function "Kn" which provides the ammonium dissociation constant (contributed by Karline Soetaert)
- added function "Khs" which provides the dissociation constant of hydrogen sulfide (contributed by Karline Soetaert)
- added function "Ksi" which provides the Si(OH)4 dissociation constant (contributed by Karline Soetaert)
- added function "bjerrum" which makes a bjerrum plot (contributed by Karline Soetaert)

--------------------------
version 1.1.1, 2007-08-14

- bor(), K1(), K1p() and K2() now return the values
- return values are now set for all variables
 
--------------------------
version 1.1, 2007-07-24

- carb() has now 5 more flags (code contributed by Jim Orr):
	# flag = 21     pH-pCO2 given
	# flag = 22     pCO2-HCO3 given
	# flag = 23     pCO2-CO3 given
	# flag = 24     pCO2-ALK given
	# flag = 25     pCO2-DIC given 

--------------------------
version 1.0.5, 2007-07-23

- minor changes to the documentation (tried to have the superscripts right)

--------------------------
version 1.0, 2007-01-08

- added function phinsi which calculates the pH at in situ temperature from pH values measured in the laboratory and other ancillay data

--------------------------
version 1.0, 2007-01-08

- a test data file is now provided
- various cosmetic changes

--------------------------
version 0.98, 2006-05-07

- data entry via a file is NO LONGER possible
- results of the carb command are no longer automatically saved in a file
