/[MITgcm]/MITgcm_contrib/darwin2/pkg/darwin/dic_carbon_chem.F
ViewVC logotype

Annotation of /MITgcm_contrib/darwin2/pkg/darwin/dic_carbon_chem.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Wed Oct 9 15:37:05 2013 UTC (11 years, 9 months ago) by stephd
Branch: MAIN
CVS Tags: ctrb_darwin2_ckpt65w_20160512, ctrb_darwin2_ckpt65j_20150225, ctrb_darwin2_ckpt66g_20170424, ctrb_darwin2_ckpt66k_20171025, ctrb_darwin2_ckpt66n_20180118, ctrb_darwin2_ckpt65v_20160409, ctrb_darwin2_ckpt65s_20160114, ctrb_darwin2_ckpt65_20140718, ctrb_darwin2_ckpt66d_20170214, ctrb_darwin2_ckpt64r_20131210, ctrb_darwin2_ckpt65m_20150615, ctrb_darwin2_ckpt65q_20151118, ctrb_darwin2_ckpt65o_20150914, ctrb_darwin2_ckpt65p_20151023, ctrb_darwin2_ckpt65e_20140929, ctrb_darwin2_ckpt64o_20131024, ctrb_darwin2_ckpt64v_20140411, ctrb_darwin2_ckpt64z_20140711, ctrb_darwin2_ckpt65l_20150504, ctrb_darwin2_ckpt65z_20160929, ctrb_darwin2_ckpt65n_20150729, ctrb_darwin2_ckpt64y_20140622, ctrb_darwin2_ckpt65d_20140915, ctrb_darwin2_ckpt64t_20140202, ctrb_darwin2_ckpt66h_20170602, ctrb_darwin2_ckpt64s_20140105, ctrb_darwin2_ckpt64x_20140524, ctrb_darwin2_ckpt65x_20160612, ctrb_darwin2_ckpt66f_20170407, ctrb_darwin2_ckpt65g_20141120, ctrb_darwin2_ckpt65k_20150402, ctrb_darwin2_ckpt64w_20140502, ctrb_darwin2_ckpt66a_20161020, ctrb_darwin2_ckpt65f_20141014, ctrb_darwin2_ckpt66b_20161219, ctrb_darwin2_ckpt64u_20140308, ctrb_darwin2_ckpt65i_20150123, ctrb_darwin2_ckpt66j_20170815, ctrb_darwin2_ckpt65y_20160801, ctrb_darwin2_ckpt66c_20170121, ctrb_darwin2_ckpt65a_20140728, ctrb_darwin2_ckpt65b_20140812, ctrb_darwin2_ckpt65t_20160221, ctrb_darwin2_ckpt64p_20131118, ctrb_darwin2_ckpt66o_20180209, ctrb_darwin2_ckpt66e_20170314, ctrb_darwin2_ckpt64q_20131118, ctrb_darwin2_ckpt64p_20131024, ctrb_darwin2_ckpt65u_20160315, ctrb_darwin2_ckpt65r_20151221, ctrb_darwin2_ckpt66i_20170718, ctrb_darwin2_ckpt65c_20140830, ctrb_darwin2_ckpt66l_20171025, ctrb_darwin2_ckpt65h_20141217, ctrb_darwin2_ckpt66m_20171213, HEAD
Changes since 1.3: +92 -316 lines
o clean up carbon_coeffs so it can be pressure dependent or not (pass
  depth information); remove redundant subroutine

1 jahn 1.1 #include "CPP_OPTIONS.h"
2     #include "PTRACERS_OPTIONS.h"
3     #include "DARWIN_OPTIONS.h"
4    
5     #ifdef ALLOW_PTRACERS
6     #ifdef ALLOW_DARWIN
7    
8     #ifdef ALLOW_CARBON
9    
10     CBOP
11     C !ROUTINE: CALC_PCO2
12    
13     C !INTERFACE: ==========================================================
14     SUBROUTINE CALC_PCO2(
15     I donewt,inewtonmax,ibrackmax,
16     I t,s,diclocal,pt,sit,ta,
17     I k1local,k2local,
18     I k1plocal,k2plocal,k3plocal,
19     I kslocal,kblocal,kwlocal,
20     I ksilocal,kflocal,
21 stephd 1.2 I k0local, fugflocal,
22 jahn 1.1 I fflocal,btlocal,stlocal,ftlocal,
23     U pHlocal,pCO2surfloc,
24     I myThid)
25    
26     C !DESCRIPTION:
27     C surface ocean inorganic carbon chemistry to OCMIP2
28     C regulations modified from OCMIP2 code;
29     C Mick Follows, MIT, Oct 1999.
30    
31    
32     C !USES: ===============================================================
33     IMPLICIT NONE
34     #include "SIZE.h"
35     #include "DYNVARS.h"
36     #include "EEPARAMS.h"
37     #include "PARAMS.h"
38     #include "GRID.h"
39     #include "FFIELDS.h"
40     #include "DARWIN_FLUX.h"
41    
42     C == Routine arguments ==
43     C diclocal = total inorganic carbon (mol/m^3)
44     C where 1 T = 1 metric ton = 1000 kg
45     C ta = total alkalinity (eq/m^3)
46     C pt = inorganic phosphate (mol/^3)
47     C sit = inorganic silicate (mol/^3)
48     C t = temperature (degrees C)
49     C s = salinity (PSU)
50     INTEGER donewt
51     INTEGER inewtonmax
52     INTEGER ibrackmax
53     _RL t, s, pt, sit, ta
54     _RL pCO2surfloc, diclocal, pHlocal
55     _RL fflocal, btlocal, stlocal, ftlocal
56     _RL k1local, k2local
57     _RL k1plocal, k2plocal, k3plocal
58     _RL kslocal, kblocal, kwlocal, ksilocal, kflocal
59 stephd 1.2 _RL k0local, fugflocal
60 jahn 1.1 INTEGER myThid
61     CEndOfInterface
62    
63     C == Local variables ==
64     C INPUT
65     C phlo= lower limit of pH range
66     C phhi= upper limit of pH range
67     C atmpres = atmospheric pressure in atmospheres (1 atm==1013.25mbar)
68     C OUTPUT
69     C co2star = CO2*water (mol/m^3)
70     C pco2surf = oceanic pCO2 (ppmv)
71     C ---------------------------------------------------------------------
72     C OCMIP NOTE: Some words about units - (JCO, 4/4/1999)
73     C - Models carry tracers in mol/m^3 (on a per volume basis)
74     C - Conversely, this routine, which was written by
75     C observationalists (C. Sabine and R. Key), passes input
76     C arguments in umol/kg (i.e., on a per mass basis)
77     C - I have changed things slightly so that input arguments are in
78     C mol/m^3,
79     C - Thus, all input concentrations (diclocal, ta, pt, and st) should be
80     C given in mol/m^3; output arguments "co2star" and "dco2star"
81     C are likewise be in mol/m^3.
82     C ---------------------------------------------------------------------
83     _RL phhi
84     _RL phlo
85     _RL tk
86     _RL tk100
87     _RL tk1002
88     _RL dlogtk
89     _RL sqrtis
90     _RL sqrts
91     _RL s15
92     _RL scl
93     _RL c
94     _RL a
95     _RL a2
96     _RL da
97     _RL b
98     _RL b2
99     _RL db
100     _RL fn
101     _RL df
102     _RL deltax
103     _RL x
104     _RL x1
105     _RL x2
106     _RL x3
107     _RL xmid
108     _RL ftest
109     _RL htotal
110     _RL htotal2
111     _RL s2
112     _RL xacc
113     _RL co2star
114     _RL co2starair
115     _RL dco2star
116     _RL dpCO2
117     _RL phguess
118     _RL atmpres
119 stephd 1.2 _RL fco2
120 jahn 1.1 INTEGER inewton
121     INTEGER ibrack
122     INTEGER hstep
123     _RL fni(3)
124     _RL xlo
125     _RL xhi
126     _RL xguess
127     _RL invtk
128     _RL is
129     _RL is2
130     _RL k123p
131     _RL k12p
132     _RL k12
133     c ---------------------------------------------------------------------
134     c import donewt flag
135     c set donewt = 1 for newton-raphson iteration
136     c set donewt = 0 for bracket and bisection
137     c ---------------------------------------------------------------------
138     C Change units from the input of mol/m^3 -> mol/kg:
139     c (1 mol/m^3) x (1 m^3/1024.5 kg)
140     c where the ocean's mean surface density is 1024.5 kg/m^3
141     c Note: mol/kg are actually what the body of this routine uses
142     c for calculations. Units are reconverted back to mol/m^3 at the
143     c end of this routine.
144     c ---------------------------------------------------------------------
145     c To convert input in mol/m^3 -> mol/kg
146     pt=pt*permil
147     sit=sit*permil
148     ta=ta*permil
149     diclocal=diclocal*permil
150     c ---------------------------------------------------------------------
151     c set first guess and brackets for [H+] solvers
152     c first guess (for newton-raphson)
153     phguess = phlocal
154    
155    
156     c bracketing values (for bracket/bisection)
157     phhi = 10.0
158     phlo = 5.0
159     c convert to [H+]...
160     xguess = 10.0**(-phguess)
161     xlo = 10.0**(-phhi)
162     xhi = 10.0**(-phlo)
163     xmid = (xlo + xhi)*0.5
164    
165    
166     c----------------------------------------------------------------
167     c iteratively solve for [H+]
168     c (i) Newton-Raphson method with fixed number of iterations,
169     c use previous [H+] as first guess
170    
171     c select newton-raphson, inewt=1
172     c else select bracket and bisection
173    
174     cQQQQQ
175     if( donewt .eq. 1)then
176     c.........................................................
177     c NEWTON-RAPHSON METHOD
178     c.........................................................
179     x = xguess
180     cdiags
181     c WRITE(0,*)'xguess ',xguess
182     cdiags
183     do inewton = 1, inewtonmax
184     c set some common combinations of parameters used in
185     c the iterative [H+] solvers
186     x2=x*x
187     x3=x2*x
188     k12 = k1local*k2local
189     k12p = k1plocal*k2plocal
190     k123p = k12p*k3plocal
191     c = 1.0 + stlocal/kslocal
192     a = x3 + k1plocal*x2 + k12p*x + k123p
193     a2=a*a
194     da = 3.0*x2 + 2.0*k1plocal*x + k12p
195     b = x2 + k1local*x + k12
196     b2=b*b
197     db = 2.0*x + k1local
198    
199     c Evaluate f([H+]) and f'([H+])
200     c fn = hco3+co3+borate+oh+hpo4+2*po4+silicate+hfree
201     c +hso4+hf+h3po4-ta
202     fn = k1local*x*diclocal/b +
203     & 2.0*diclocal*k12/b +
204     & btlocal/(1.0 + x/kblocal) +
205     & kwlocal/x +
206     & pt*k12p*x/a +
207     & 2.0*pt*k123p/a +
208     & sit/(1.0 + x/ksilocal) -
209     & x/c -
210     & stlocal/(1.0 + kslocal/x/c) -
211     & ftlocal/(1.0 + kflocal/x) -
212     & pt*x3/a -
213     & ta
214    
215     c df = dfn/dx
216     cdiags
217     c WRITE(0,*)'values',b2,kblocal,x2,a2,c,x
218     cdiags
219     df = ((k1local*diclocal*b) - k1local*x*diclocal*db)/b2 -
220     & 2.0*diclocal*k12*db/b2 -
221     & btlocal/kblocal/(1.0+x/kblocal)**2. -
222     & kwlocal/x2 +
223     & (pt*k12p*(a - x*da))/a2 -
224     & 2.0*pt*k123p*da/a2 -
225     & sit/ksilocal/(1.0+x/ksilocal)**2. +
226     & 1.0/c +
227     & stlocal*(1.0 + kslocal/x/c)**(-2.0)*(kslocal/c/x2) +
228     & ftlocal*(1.0 + kflocal/x)**(-2.)*kflocal/x2 -
229     & pt*x2*(3.0*a-x*da)/a2
230     c evaluate increment in [H+]
231     deltax = - fn/df
232     c update estimate of [H+]
233     x = x + deltax
234     cdiags
235     c write value of x to check convergence....
236     c write(0,*)'inewton, x, deltax ',inewton, x, deltax
237     c write(6,*)
238     cdiags
239    
240     end do
241     c end of newton-raphson method
242     c....................................................
243     else
244     c....................................................
245     C BRACKET AND BISECTION METHOD
246     c....................................................
247     c (ii) If first step use Bracket and Bisection method
248     c with fixed, large number of iterations
249     do ibrack = 1, ibrackmax
250     do hstep = 1,3
251     if(hstep .eq. 1)x = xhi
252     if(hstep .eq. 2)x = xlo
253     if(hstep .eq. 3)x = xmid
254     c set some common combinations of parameters used in
255     c the iterative [H+] solvers
256    
257    
258     x2=x*x
259     x3=x2*x
260     k12 = k1local*k2local
261     k12p = k1plocal*k2plocal
262     k123p = k12p*k3plocal
263     c = 1.0 + stlocal/kslocal
264     a = x3 + k1plocal*x2 + k12p*x + k123p
265     a2=a*a
266     da = 3.0*x2 + 2.0*k1plocal*x + k12p
267     b = x2 + k1local*x + k12
268     b2=b*b
269     db = 2.0*x + k1local
270     c evaluate f([H+]) for bracketing and mid-value cases
271     fn = k1local*x*diclocal/b +
272     & 2.0*diclocal*k12/b +
273     & btlocal/(1.0 + x/kblocal) +
274     & kwlocal/x +
275     & pt*k12p*x/a +
276     & 2.0*pt*k123p/a +
277     & sit/(1.0 + x/ksilocal) -
278     & x/c -
279     & stlocal/(1.0 + kslocal/x/c) -
280     & ftlocal/(1.0 + kflocal/x) -
281     & pt*x3/a -
282     & ta
283     fni(hstep) = fn
284     end do
285     c now bracket solution within two of three
286     ftest = fni(1)/fni(3)
287     if(ftest .gt. 0.0)then
288     xhi = xmid
289     else
290     xlo = xmid
291     end if
292     xmid = (xlo + xhi)*0.5
293    
294     cdiags
295     c write value of x to check convergence....
296     c WRITE(0,*)'bracket-bisection iteration ',ibrack, xmid
297     cdiags
298     end do
299     c last iteration gives value
300     x = xmid
301     c end of bracket and bisection method
302     c....................................
303     end if
304     c iterative [H+] solver finished
305     c----------------------------------------------------------------
306    
307     c now determine pCO2 etc...
308     c htotal = [H+], hydrogen ion conc
309     htotal = x
310     C Calculate [CO2*] as defined in DOE Methods Handbook 1994 Ver.2,
311     C ORNL/CDIAC-74, dickson and Goyet, eds. (Ch 2 p 10, Eq A.49)
312     htotal2=htotal*htotal
313     co2star=diclocal*htotal2/(htotal2 + k1local*htotal
314     & + k1local*k2local)
315     phlocal=-log10(htotal)
316    
317     c ---------------------------------------------------------------
318     c Add two output arguments for storing pCO2surf
319     c Should we be using K0 or ff for the solubility here?
320     c ---------------------------------------------------------------
321 stephd 1.2 #ifdef WATERVAP_BUG
322 jahn 1.1 pCO2surfloc = co2star / fflocal
323 stephd 1.2 #else
324     c Corrected by Val Bennington (Nov 2010)
325     fco2 = co2star / k0local
326     pCO2surfloc = fco2/fugflocal
327     #endif
328 jahn 1.1
329     C ----------------------------------------------------------------
330     C Reconvert units back to original values for input arguments
331     C no longer necessary????
332     C ----------------------------------------------------------------
333     c Reconvert from mol/kg -> mol/m^3
334     pt=pt/permil
335     sit=sit/permil
336     ta=ta/permil
337     diclocal=diclocal/permil
338    
339     return
340     end
341    
342     c=================================================================
343     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
344     CC New efficient pCO2 solver, Mick Follows CC
345     CC Taka Ito CC
346     CC Stephanie Dutkiewicz CC
347     CC 20 April 2003 CC
348     CC ADD CO3 ESTIMATION AND PASS OUT CC
349     CC Karsten Friis, Mick Follows CC
350     CC 1 sep 04 CC
351     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
352     #include "DARWIN_OPTIONS.h"
353     CStartOfInterFace
354     SUBROUTINE CALC_PCO2_APPROX_CO3(
355     I t,s,diclocal,pt,sit,ta,
356     I k1local,k2local,
357     I k1plocal,k2plocal,k3plocal,
358     I kslocal,kblocal,kwlocal,
359     I ksilocal,kflocal,
360     I fflocal,btlocal,stlocal,ftlocal,
361     U pHlocal,pCO2surfloc,co3local,
362     I myThid)
363     C /==========================================================\
364     C | SUBROUTINE CALC_PCO2_APPROX_CO3 |
365     C \==========================================================/
366     IMPLICIT NONE
367    
368     C == GLobal variables ==
369     #include "SIZE.h"
370     #include "DYNVARS.h"
371     #include "EEPARAMS.h"
372     #include "PARAMS.h"
373     #include "GRID.h"
374     #include "FFIELDS.h"
375     #include "DARWIN_FLUX.h"
376    
377     C == Routine arguments ==
378     C diclocal = total inorganic carbon (mol/m^3)
379     C where 1 T = 1 metric ton = 1000 kg
380     C ta = total alkalinity (eq/m^3)
381     C pt = inorganic phosphate (mol/^3)
382     C sit = inorganic silicate (mol/^3)
383     C t = temperature (degrees C)
384     C s = salinity (PSU)
385     _RL t, s, pt, sit, ta
386     _RL pCO2surfloc, diclocal, pHlocal
387     _RL fflocal, btlocal, stlocal, ftlocal
388     _RL k1local, k2local
389     _RL k1plocal, k2plocal, k3plocal
390     _RL kslocal, kblocal, kwlocal, ksilocal, kflocal
391     INTEGER myThid
392     CEndOfInterface
393    
394     C == Local variables ==
395     _RL phguess
396     _RL cag
397     _RL bohg
398     _RL hguess
399     _RL stuff
400     _RL gamm
401     _RL hnew
402     _RL co2s
403     _RL h3po4g, h2po4g, hpo4g, po4g
404     _RL siooh3g
405     c carbonate
406     _RL co3local
407    
408    
409     c ---------------------------------------------------------------------
410     C Change units from the input of mol/m^3 -> mol/kg:
411     c (1 mol/m^3) x (1 m^3/1024.5 kg)
412     c where the ocean's mean surface density is 1024.5 kg/m^3
413     c Note: mol/kg are actually what the body of this routine uses
414     c for calculations. Units are reconverted back to mol/m^3 at the
415     c end of this routine.
416     c To convert input in mol/m^3 -> mol/kg
417     pt=pt*permil
418     sit=sit*permil
419     ta=ta*permil
420     diclocal=diclocal*permil
421     c ---------------------------------------------------------------------
422     c set first guess and brackets for [H+] solvers
423     c first guess (for newton-raphson)
424     phguess = phlocal
425     cmick - new approx method
426     cmick - make estimate of htotal (hydrogen ion conc) using
427     cmick appromate estimate of CA, carbonate alkalinity
428     hguess = 10.0**(-phguess)
429     cmick - first estimate borate contribution using guess for [H+]
430     bohg = btlocal*kblocal/(hguess+kblocal)
431    
432     cmick - first estimate of contribution from phosphate
433     cmick based on Dickson and Goyet
434     stuff = hguess*hguess*hguess
435     & + (k1plocal*hguess*hguess)
436     & + (k1plocal*k2plocal*hguess)
437     & + (k1plocal*k2plocal*k3plocal)
438     h3po4g = (pt*hguess*hguess*hguess) / stuff
439     h2po4g = (pt*k1plocal*hguess*hguess) / stuff
440     hpo4g = (pt*k1plocal*k2plocal*hguess) / stuff
441     po4g = (pt*k1plocal*k2plocal*k3plocal) / stuff
442    
443     cmick - estimate contribution from silicate
444     cmick based on Dickson and Goyet
445     siooh3g = sit*ksilocal / (ksilocal + hguess)
446    
447     cmick - now estimate carbonate alkalinity
448     cag = ta - bohg - (kwlocal/hguess) + hguess
449     & - hpo4g - 2.0*po4g + h3po4g
450     & - siooh3g
451    
452     cmick - now evaluate better guess of hydrogen ion conc
453     cmick htotal = [H+], hydrogen ion conc
454     gamm = diclocal/cag
455     stuff = (1.0-gamm)*(1.0-gamm)*k1local*k1local
456     & - 4.0*k1local*k2local*(1.0-2.0*gamm)
457     hnew = 0.5*( (gamm-1.0)*k1local + sqrt(stuff) )
458     cmick - now determine [CO2*]
459     co2s = diclocal/
460     & (1.0 + (k1local/hnew) + (k1local*k2local/(hnew*hnew)))
461     cmick - return update pH to main routine
462     phlocal = -log10(hnew)
463    
464     c NOW EVALUATE CO32-, carbonate ion concentration
465     c used in determination of calcite compensation depth
466     c Karsten Friis & Mick - Sep 2004
467     co3local = k1local*k2local*diclocal /
468     & (hnew*hnew + k1local*hnew + k1local*k2local)
469    
470     c ---------------------------------------------------------------
471     c surface pCO2 (following Dickson and Goyet, DOE...)
472     pCO2surfloc = co2s/fflocal
473    
474     C ----------------------------------------------------------------
475     c Reconvert from mol/kg -> mol/m^3
476     pt=pt/permil
477     sit=sit/permil
478     ta=ta/permil
479     diclocal=diclocal/permil
480     return
481     end
482    
483     c=================================================================
484     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
485     CC New efficient pCO2 solver, Mick Follows CC
486     CC Taka Ito CC
487     CC Stephanie Dutkiewicz CC
488     CC 20 April 2003 CC
489     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
490 stephd 1.2 C Apr 2011: fix vapour bug (following Bennington)
491 jahn 1.1 #include "DARWIN_OPTIONS.h"
492     CStartOfInterFace
493     SUBROUTINE CALC_PCO2_APPROX(
494     I t,s,diclocal,pt,sit,ta,
495     I k1local,k2local,
496     I k1plocal,k2plocal,k3plocal,
497     I kslocal,kblocal,kwlocal,
498     I ksilocal,kflocal,
499 stephd 1.2 I k0local, fugflocal,
500 jahn 1.1 I fflocal,btlocal,stlocal,ftlocal,
501     U pHlocal,pCO2surfloc,
502     I myThid)
503     C /==========================================================\
504     C | SUBROUTINE CALC_PCO2_APPROX |
505     C \==========================================================/
506     IMPLICIT NONE
507    
508     C == GLobal variables ==
509     #include "SIZE.h"
510     #include "DYNVARS.h"
511     #include "EEPARAMS.h"
512     #include "PARAMS.h"
513     #include "GRID.h"
514     #include "FFIELDS.h"
515     #include "DARWIN_FLUX.h"
516    
517     C == Routine arguments ==
518     C diclocal = total inorganic carbon (mol/m^3)
519     C where 1 T = 1 metric ton = 1000 kg
520     C ta = total alkalinity (eq/m^3)
521     C pt = inorganic phosphate (mol/^3)
522     C sit = inorganic silicate (mol/^3)
523     C t = temperature (degrees C)
524     C s = salinity (PSU)
525     _RL t, s, pt, sit, ta
526     _RL pCO2surfloc, diclocal, pHlocal
527     _RL fflocal, btlocal, stlocal, ftlocal
528     _RL k1local, k2local
529     _RL k1plocal, k2plocal, k3plocal
530     _RL kslocal, kblocal, kwlocal, ksilocal, kflocal
531 stephd 1.2 _RL k0local, fugflocal
532 jahn 1.1 INTEGER myThid
533     CEndOfInterface
534    
535     C == Local variables ==
536     _RL phguess
537     _RL cag
538     _RL bohg
539     _RL hguess
540     _RL stuff
541     _RL gamm
542     _RL hnew
543     _RL co2s
544     _RL h3po4g, h2po4g, hpo4g, po4g
545     _RL siooh3g
546 stephd 1.2 _RL fco2
547 jahn 1.1 c carbonate
548     _RL co3local
549    
550    
551     c ---------------------------------------------------------------------
552     C Change units from the input of mol/m^3 -> mol/kg:
553     c (1 mol/m^3) x (1 m^3/1024.5 kg)
554     c where the ocean's mean surface density is 1024.5 kg/m^3
555     c Note: mol/kg are actually what the body of this routine uses
556     c for calculations. Units are reconverted back to mol/m^3 at the
557     c end of this routine.
558     c To convert input in mol/m^3 -> mol/kg
559     pt=pt*permil
560     sit=sit*permil
561     ta=ta*permil
562     diclocal=diclocal*permil
563     c ---------------------------------------------------------------------
564     c set first guess and brackets for [H+] solvers
565     c first guess (for newton-raphson)
566     phguess = phlocal
567     cmick - new approx method
568     cmick - make estimate of htotal (hydrogen ion conc) using
569     cmick appromate estimate of CA, carbonate alkalinity
570     hguess = 10.0**(-phguess)
571     cmick - first estimate borate contribution using guess for [H+]
572     bohg = btlocal*kblocal/(hguess+kblocal)
573    
574     cmick - first estimate of contribution from phosphate
575     cmick based on Dickson and Goyet
576     stuff = hguess*hguess*hguess
577     & + (k1plocal*hguess*hguess)
578     & + (k1plocal*k2plocal*hguess)
579     & + (k1plocal*k2plocal*k3plocal)
580     h3po4g = (pt*hguess*hguess*hguess) / stuff
581     h2po4g = (pt*k1plocal*hguess*hguess) / stuff
582     hpo4g = (pt*k1plocal*k2plocal*hguess) / stuff
583     po4g = (pt*k1plocal*k2plocal*k3plocal) / stuff
584    
585     cmick - estimate contribution from silicate
586     cmick based on Dickson and Goyet
587     siooh3g = sit*ksilocal / (ksilocal + hguess)
588    
589     cmick - now estimate carbonate alkalinity
590     cag = ta - bohg - (kwlocal/hguess) + hguess
591     & - hpo4g - 2.0 _d 0*po4g + h3po4g
592     & - siooh3g
593    
594     cmick - now evaluate better guess of hydrogen ion conc
595     cmick htotal = [H+], hydrogen ion conc
596     gamm = diclocal/cag
597     stuff = (1.0 _d 0-gamm)*(1.0 _d 0-gamm)*k1local*k1local
598     & - 4.0 _d 0*k1local*k2local*(1.0 _d 0-2.0 _d 0*gamm)
599     hnew = 0.5 _d 0*( (gamm-1.0 _d 0)*k1local + sqrt(stuff) )
600     cmick - now determine [CO2*]
601     co2s = diclocal/
602     & (1.0 _d 0 + (k1local/hnew) + (k1local*k2local/(hnew*hnew)))
603     cmick - return update pH to main routine
604     phlocal = -log10(hnew)
605    
606     c NOW EVALUATE CO32-, carbonate ion concentration
607     c used in determination of calcite compensation depth
608     c Karsten Friis & Mick - Sep 2004
609     c co3local = k1local*k2local*diclocal /
610     c & (hnew*hnew + k1local*hnew + k1local*k2local)
611    
612     c ---------------------------------------------------------------
613     c surface pCO2 (following Dickson and Goyet, DOE...)
614 stephd 1.2 #ifdef WATERVAP_BUG
615 jahn 1.1 pCO2surfloc = co2s/fflocal
616 stephd 1.2 #else
617     c bug fix by Bennington
618     fco2 = co2s/k0local
619     pco2surfloc = fco2/fugflocal
620     #endif
621 jahn 1.1
622     C ----------------------------------------------------------------
623     c Reconvert from mol/kg -> mol/m^3
624     pt=pt/permil
625     sit=sit/permil
626     ta=ta/permil
627     diclocal=diclocal/permil
628     return
629     end
630    
631     c=================================================================
632     c *******************************************************************
633     c=================================================================
634     CStartOfInterFace
635     SUBROUTINE CARBON_COEFFS(
636     I ttemp,stemp,
637 stephd 1.4 I bi,bj,iMin,iMax,jMin,jMax,
638     I kLevel, myThid)
639 jahn 1.1 C
640     C /==========================================================\
641     C | SUBROUTINE CARBON_COEFFS |
642     C | determine coefficients for surface carbon chemistry |
643     C | adapted from OCMIP2: SUBROUTINE CO2CALC |
644     C | mick follows, oct 1999 |
645     c | minor changes to tidy, swd aug 2002 |
646 stephd 1.4 c | MODIFIED FOR PRESSURE DEPENDENCE |
647     c | Karsten Friis and Mick Follows 2004 |
648     c | added 2013 (steph) |
649 jahn 1.1 C \==========================================================/
650     C INPUT
651     C diclocal = total inorganic carbon (mol/m^3)
652     C where 1 T = 1 metric ton = 1000 kg
653     C ta = total alkalinity (eq/m^3)
654     C pt = inorganic phosphate (mol/^3)
655     C sit = inorganic silicate (mol/^3)
656     C t = temperature (degrees C)
657     C s = salinity (PSU)
658     C OUTPUT
659     C IMPORTANT: Some words about units - (JCO, 4/4/1999)
660     c - Models carry tracers in mol/m^3 (on a per volume basis)
661     c - Conversely, this routine, which was written by observationalists
662     c (C. Sabine and R. Key), passes input arguments in umol/kg
663     c (i.e., on a per mass basis)
664     c - I have changed things slightly so that input arguments are in mol/m^3,
665     c - Thus, all input concentrations (diclocal, ta, pt, and st) should be
666     c given in mol/m^3; output arguments "co2star" and "dco2star"
667     c are likewise be in mol/m^3.
668 stephd 1.2 C
669     C Apr 2011: fix vapour bug (following Bennington)
670 stephd 1.4 C Oct 2013: c NOW INCLUDES:
671     c PRESSURE DEPENDENCE of K1, K2, solubility product of calcite
672     c based on Takahashi, GEOSECS Atlantic Report, Vol. 1 (1981)
673 jahn 1.1 C--------------------------------------------------------------------------
674     IMPLICIT NONE
675     C == GLobal variables ==
676     #include "SIZE.h"
677     #include "DYNVARS.h"
678     #include "EEPARAMS.h"
679     #include "PARAMS.h"
680     #include "GRID.h"
681     #include "FFIELDS.h"
682     #include "DARWIN_FLUX.h"
683     C == Routine arguments ==
684     C ttemp and stemp are local theta and salt arrays
685     C dont really need to pass T and S in, could use theta, salt in
686     C common block in DYNVARS.h, but this way keeps subroutine more
687     C general
688 stephd 1.3 _RL ttemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
689     _RL stemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
690 jahn 1.1 INTEGER bi,bj,iMin,iMax,jMin,jMax
691 stephd 1.4 INTEGER kLevel
692 jahn 1.1 INTEGER myThid
693     CEndOfInterface
694    
695    
696     C LOCAL VARIABLES
697     _RL t
698     _RL s
699     _RL ta
700     _RL pt
701     _RL sit
702     _RL tk
703     _RL tk100
704     _RL tk1002
705     _RL dlogtk
706     _RL sqrtis
707     _RL sqrts
708     _RL s15
709     _RL scl
710     _RL x1
711     _RL x2
712     _RL s2
713     _RL xacc
714     _RL invtk
715     _RL is
716     _RL is2
717 stephd 1.4 c add pressure dependency
718     _RL bdepth
719     _RL cdepth
720     _RL pressc
721     c calcite stuff
722     _RL Ksp_T_Calc
723     _RL xvalue
724     _RL zdum
725     _RL tmpa1
726     _RL tmpa2
727     _RL tmpa3
728     _RL logKspc
729     _RL dv
730     _RL dk
731     _RL pfactor
732     _RL bigR
733 stephd 1.2 c add Bennington
734     _RL P1atm
735     _RL Rgas
736     _RL RT
737     _RL delta
738     _RL B1
739     _RL B
740 jahn 1.1 INTEGER i
741     INTEGER j
742 stephd 1.4 INTEGER k
743 jahn 1.1
744     C.....................................................................
745     C OCMIP note:
746     C Calculate all constants needed to convert between various measured
747     C carbon species. References for each equation are noted in the code.
748     C Once calculated, the constants are
749     C stored and passed in the common block "const". The original version
750     C of this code was based on the code by dickson in Version 2 of
751     C "Handbook of Methods C for the Analysis of the Various Parameters of
752     C the Carbon Dioxide System in Seawater", DOE, 1994 (SOP No. 3, p25-26).
753     C....................................................................
754    
755 stephd 1.4 c determine pressure (bar) from depth
756     c 1 BAR at z=0m (atmos pressure)
757     c use UPPER surface of cell so top layer pressure = 0 bar
758     c for surface exchange coeffs
759    
760     c if surface, calculate at interface pressure,
761     c else calculate at mid-depth pressure
762     if (Klevel.gt.1) then
763     bdepth = 0.0d0
764     cdepth = 0.0d0
765     pressc = 1.01325 _d 0
766     do k = 1,Klevel
767     cdepth = bdepth + 0.5d0*drF(k)
768     bdepth = bdepth + drF(k)
769     pressc = 1.0d0 + 0.1d0*cdepth
770     end do
771     else
772     pressc = 1.01325 _d 0
773     endif
774    
775 jahn 1.1 do i=imin,imax
776     do j=jmin,jmax
777     if (hFacC(i,j,1,bi,bj).gt.0. _d 0) then
778 stephd 1.3 t = ttemp(i,j)
779     s = stemp(i,j)
780 jahn 1.1 C terms used more than once
781     tk = 273.15 _d 0 + t
782     tk100 = tk/100. _d 0
783     tk1002=tk100*tk100
784     invtk=1.0 _d 0/tk
785     dlogtk=log(tk)
786     is=19.924 _d 0*s/(1000. _d 0-1.005 _d 0*s)
787     is2=is*is
788     sqrtis=sqrt(is)
789     s2=s*s
790     sqrts=sqrt(s)
791     s15=s**1.5 _d 0
792     scl=s/1.80655 _d 0
793 stephd 1.2 C -----------------------------------------------------------------------
794     C added by Val Bennington Nov 2010
795     C Fugacity Factor needed for non-ideality in ocean
796     C ff used for atmospheric correction for water vapor and pressure
797     C Weiss (1974) Marine Chemistry
798 stephd 1.4 P1atm = pressc ! bars
799 stephd 1.2 Rgas = 83.1451 _d 0 ! bar*cm3/(mol*K)
800     RT = Rgas*tk
801     delta = (57.7 _d 0 - 0.118 _d 0*tk)
802     B1 = -1636.75 _d 0 + 12.0408 _d 0*tk - 0.0327957 _d 0*tk*tk
803     B = B1 + 3.16528 _d 0*tk*tk*tk*(0.00001 _d 0)
804     fugf(i,j,bi,bj) = exp( (B+2. _d 0*delta) * P1atm / RT)
805 jahn 1.1 C------------------------------------------------------------------------
806     C f = k0(1-pH2O)*correction term for non-ideality
807     C Weiss & Price (1980, Mar. Chem., 8, 347-359; Eq 13 with table 6 values)
808     ff(i,j,bi,bj) = exp(-162.8301 _d 0 + 218.2968 _d 0/tk100 +
809     & 90.9241 _d 0*log(tk100) - 1.47696 _d 0*tk1002 +
810     & s * (.025695 _d 0 - .025225 _d 0*tk100 +
811     & 0.0049867 _d 0*tk1002))
812     C------------------------------------------------------------------------
813     C K0 from Weiss 1974
814     ak0(i,j,bi,bj) = exp(93.4517 _d 0/tk100 - 60.2409 _d 0 +
815     & 23.3585 _d 0 * log(tk100) +
816     & s * (0.023517 _d 0 - 0.023656 _d 0*tk100 +
817     & 0.0047036 _d 0*tk1002))
818     C------------------------------------------------------------------------
819     C k1 = [H][HCO3]/[H2CO3]
820     C k2 = [H][CO3]/[HCO3]
821     C Millero p.664 (1995) using Mehrbach et al. data on seawater scale
822     ak1(i,j,bi,bj)=10.**(-1. _d 0*(3670.7 _d 0*invtk -
823     & 62.008 _d 0 + 9.7944 _d 0*dlogtk -
824     & 0.0118 _d 0 * s + 0.000116 _d 0*s2))
825     ak2(i,j,bi,bj)=10.**(-1. _d 0*(1394.7 _d 0*invtk+ 4.777 _d 0-
826     & 0.0184 _d 0*s + 0.000118 _d 0*s2))
827 stephd 1.4 C
828     C NOW PRESSURE DEPENDENCE:
829     c Following Takahashi (1981) GEOSECS report - quoting Culberson and
830     c Pytkowicz (1968)
831     if (kLevel.gt.1) then
832     c pressc = pressure in bars
833     ak1(i,j,bi,bj) = ak1(i,j,bi,bj)*
834     & exp( (24.2-0.085*t)*(pressc-1.0)/(83.143*tk) )
835     c FIRST GO FOR K2: According to GEOSECS (1982) report
836     c ak2(i,j,bi,bj) = ak2(i,j,bi,bj)*
837     c & exp( (26.4-0.040*t)*(pressc-1.0)/(83.143*tk) )
838     c SECOND GO FOR K2: corrected coeff according to CO2sys documentation
839     c E. Lewis and D. Wallace (1998) ORNL/CDIAC-105
840     ak2(i,j,bi,bj) = ak2(i,j,bi,bj)*
841     & exp( (16.4-0.040*t)*(pressc-1.0)/(83.143*tk) )
842     endif
843 jahn 1.1 C------------------------------------------------------------------------
844     C kb = [H][BO2]/[HBO2]
845     C Millero p.669 (1995) using data from dickson (1990)
846     akb(i,j,bi,bj)=exp((-8966.90 _d 0- 2890.53 _d 0*sqrts -
847     & 77.942 _d 0*s + 1.728 _d 0*s15 - 0.0996 _d 0*s2)*invtk +
848     & (148.0248 _d 0 + 137.1942 _d 0*sqrts + 1.62142 _d 0*s) +
849     & (-24.4344 _d 0 - 25.085 _d 0*sqrts - 0.2474 _d 0*s) *
850     & dlogtk + 0.053105 _d 0*sqrts*tk)
851 stephd 1.4 if (kLevel.gt.1) then
852     C Mick and Karsten - Dec 04
853     C ADDING pressure dependence based on Millero (1995), p675
854     C with additional info from CO2sys documentation (E. Lewis and
855     C D. Wallace, 1998 - see endnotes for commentary on Millero, 95)
856     bigR = 83.145
857     dv = -29.48 + 0.1622*t + 2.608d-3*t*t
858     dk = -2.84d-3
859     pfactor = - (dv/(bigR*tk))*pressc
860     & + (0.5*dk/(bigR*tk))*pressc*pressc
861     akb(i,j,bi,bj) = akb(i,j,bi,bj)*exp(pfactor)
862     endif
863 jahn 1.1 C------------------------------------------------------------------------
864     C k1p = [H][H2PO4]/[H3PO4]
865     C DOE(1994) eq 7.2.20 with footnote using data from Millero (1974)
866     ak1p(i,j,bi,bj) = exp(-4576.752 _d 0*invtk + 115.525 _d 0 -
867     & 18.453 _d 0*dlogtk +
868     & (-106.736 _d 0*invtk + 0.69171 _d 0)*sqrts +
869     & (-0.65643 _d 0*invtk - 0.01844 _d 0)*s)
870     C------------------------------------------------------------------------
871     C k2p = [H][HPO4]/[H2PO4]
872     C DOE(1994) eq 7.2.23 with footnote using data from Millero (1974))
873     ak2p(i,j,bi,bj) = exp(-8814.715 _d 0*invtk + 172.0883 _d 0 -
874     & 27.927 _d 0*dlogtk +
875     & (-160.340 _d 0*invtk + 1.3566 _d 0) * sqrts +
876     & (0.37335 _d 0*invtk - 0.05778 _d 0) * s)
877     C------------------------------------------------------------------------
878     C k3p = [H][PO4]/[HPO4]
879     C DOE(1994) eq 7.2.26 with footnote using data from Millero (1974)
880     ak3p(i,j,bi,bj) = exp(-3070.75 _d 0*invtk - 18.141 _d 0 +
881     & (17.27039 _d 0*invtk + 2.81197 _d 0) *
882     & sqrts + (-44.99486 _d 0*invtk - 0.09984 _d 0) * s)
883     C------------------------------------------------------------------------
884     C ksi = [H][SiO(OH)3]/[Si(OH)4]
885     C Millero p.671 (1995) using data from Yao and Millero (1995)
886     aksi(i,j,bi,bj) = exp(-8904.2 _d 0*invtk + 117.385 _d 0 -
887     & 19.334 _d 0*dlogtk +
888     & (-458.79 _d 0*invtk + 3.5913 _d 0) * sqrtis +
889     & (188.74 _d 0*invtk - 1.5998 _d 0) * is +
890     & (-12.1652 _d 0*invtk + 0.07871 _d 0) * is2 +
891     & log(1.0 _d 0-0.001005 _d 0*s))
892     C------------------------------------------------------------------------
893     C kw = [H][OH]
894     C Millero p.670 (1995) using composite data
895     akw(i,j,bi,bj) = exp(-13847.26 _d 0*invtk + 148.9652 _d 0 -
896     & 23.6521 _d 0*dlogtk +
897     & (118.67 _d 0*invtk - 5.977 _d 0 + 1.0495 _d 0 * dlogtk)
898     & * sqrts - 0.01615 _d 0 * s)
899     C------------------------------------------------------------------------
900     C ks = [H][SO4]/[HSO4]
901     C dickson (1990, J. chem. Thermodynamics 22, 113)
902     aks(i,j,bi,bj)=exp(-4276.1 _d 0*invtk + 141.328 _d 0 -
903     & 23.093 _d 0*dlogtk +
904     & (-13856. _d 0*invtk + 324.57 _d 0 - 47.986 _d 0*dlogtk)*sqrtis+
905     & (35474. _d 0*invtk - 771.54 _d 0 + 114.723 _d 0*dlogtk)*is -
906     & 2698. _d 0*invtk*is**1.5 _d 0 + 1776. _d 0*invtk*is2 +
907     & log(1.0 _d 0 - 0.001005 _d 0*s))
908     C------------------------------------------------------------------------
909     C kf = [H][F]/[HF]
910     C dickson and Riley (1979) -- change pH scale to total
911     akf(i,j,bi,bj)=exp(1590.2 _d 0*invtk - 12.641 _d 0 +
912     & 1.525 _d 0*sqrtis + log(1.0 _d 0 - 0.001005 _d 0*s) +
913     & log(1.0 _d 0 + (0.1400 _d 0/96.062 _d 0)*(scl)/aks(i,j,bi,bj)))
914     C------------------------------------------------------------------------
915     C Calculate concentrations for borate, sulfate, and fluoride
916     C Uppstrom (1974)
917     bt(i,j,bi,bj) = 0.000232 _d 0 * scl/10.811 _d 0
918     C Morris & Riley (1966)
919     st(i,j,bi,bj) = 0.14 _d 0 * scl/96.062 _d 0
920     C Riley (1965)
921     ft(i,j,bi,bj) = 0.000067 _d 0 * scl/18.9984 _d 0
922     C------------------------------------------------------------------------
923     C solubility product for calcite
924     C
925     c Following Takahashi (1982) GEOSECS handbook
926     C NOT SURE THIS IS WORKING???
927     C Ingle et al. (1973)
928     c Ksp_T_Calc = ( -34.452 - 39.866*(s**0.333333)
929     c & + 110.21*log(s) - 7.5752d-6 * (tk**2.0)
930     c & ) * 1.0d-7
931     c with pressure dependence Culberson and Pytkowicz (1968)
932     c xvalue = (36-0.20*t)*(pressc-1.0)/(83.143*tk)
933     c Ksp_TP_Calc(i,j,bi,bj) = Ksp_T_Calc*exp(xvalue)
934     c
935     c
936     C Following Mucci (1983) - from Zeebe/Wolf-Gladrow equic.m
937     tmpa1 = - 171.9065 - (0.077993*tk) + (2839.319/tk)
938     & + (71.595*log10(tk))
939     tmpa2 = +(-0.77712 + (0.0028426*tk) + (178.34/tk) )*sqrts
940     tmpa3 = -(0.07711*s) + (0.0041249*s15)
941     logKspc = tmpa1 + tmpa2 + tmpa3
942     Ksp_T_Calc = 10.0**logKspc
943     c write(6,*)i,j,k,tmpa1,tmpa2,tmpa3,logkspc,Ksp_T_Calc
944     c with pressure dependence Culberson and Pytkowicz (1968)
945     c xvalue = (36.0-0.20*t)*(pressc-1.0)/(83.143*tk)
946     c Ksp_TP_Calc(i,j,bi,bj) = Ksp_T_Calc*exp(xvalue)
947    
948     c alternative pressure depdendence
949     c following Millero (1995) but using info from Appendix A11 of
950     c Zeebe and Wolf-Gladrow (2001) book
951     c dv = -48.6 - 0.5304*t
952     c dk = -11.76d-3 - 0.3692*t
953     c xvalue = - (dv/(bigR*tk))*pressc
954     c & + (0.5*dk/(bigR*tk))*pressc*pressc
955     c Ksp_TP_Calc(i,j,bi,bj) = Ksp_T_Calc*exp(xvalue)
956    
957     c alternative pressure dependence from Ingle (1975)
958    
959     zdum = (pressc*10.0d0 - 10.0d0)/10.0d0
960     xvalue = ( (48.8d0 - 0.53d0*t)*zdum
961     & + (-0.00588d0 + 0.0001845d0*t)*zdum*zdum)
962     & / (188.93d0*(t + 273.15d0))
963    
964     Ksp_TP_Calc(i,j,bi,bj) = Ksp_T_Calc*10**(xvalue)
965    
966     C------------------------------------------------------------------------
967     else
968 stephd 1.4 c add Bennington
969     fugf(i,j,bi,bj)=0. _d 0
970     ff(i,j,bi,bj)=0. _d 0
971     ak0(i,j,bi,bj)= 0. _d 0
972     ak1(i,j,bi,bj)= 0. _d 0
973     ak2(i,j,bi,bj)= 0. _d 0
974     akb(i,j,bi,bj)= 0. _d 0
975     ak1p(i,j,bi,bj) = 0. _d 0
976     ak2p(i,j,bi,bj) = 0. _d 0
977     ak3p(i,j,bi,bj) = 0. _d 0
978     aksi(i,j,bi,bj) = 0. _d 0
979     akw(i,j,bi,bj) = 0. _d 0
980     aks(i,j,bi,bj)= 0. _d 0
981     akf(i,j,bi,bj)= 0. _d 0
982     bt(i,j,bi,bj) = 0. _d 0
983     st(i,j,bi,bj) = 0. _d 0
984     ft(i,j,bi,bj) = 0. _d 0
985 jahn 1.1 Ksp_TP_Calc(i,j,bi,bj) = 0.d0
986     endif
987     end do
988     end do
989    
990     return
991     end
992    
993     #endif /*ALLOW_CARBON*/
994    
995     #endif /*DARWIN*/
996     #endif /*ALLOW_PTRACERS*/
997     c ==================================================================
998    

  ViewVC Help
Powered by ViewVC 1.1.22