-
Notifications
You must be signed in to change notification settings - Fork 237
/
bling_solvesaphe.F
2079 lines (1858 loc) · 78.7 KB
/
bling_solvesaphe.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "BLING_OPTIONS.h"
C-- File bling_solvesaphe.F:
C-- Contents:
C-- o AHINI_FOR_AT
C-- o ANW_INFSUP
C-- o CALC_PCO2_SOLVESAPHE
C-- o DIC_COEFFS_SURF
C-- o DIC_COEFFS_DEEP
C-- o EQUATION_AT
C-- o SOLVE_AT_FAST
C-- o SOLVE_AT_GENERAL
C-- o SOLVE_AT_GENERAL_SEC
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
C SolveSAPHE is free software: you can redistribute it and/or modify
C it under the terms of the GNU Lesser General Public License as published by
C the Free Software Foundation, either version 3 of the License, or
C (at your option) any later version.
C
C SolveSAPHE is distributed in the hope that it will be useful,
C but WITHOUT ANY WARRANTY; without even the implied warranty of
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C GNU Lesser General Public License for more details.
C
C You should have received a copy of the GNU Lesser General Public License
C along with SolveSAPHE. If not, see <http://www.gnu.org/licenses/>.
C
C Copyright 2013 Guy Munhoven
C
C From the paper: Munhoven, G (2013),
C Mathematics of the total alkalinity–pH equation – pathway to robust
C and universal solution algorithms: the SolveSAPHE package v1.0.1.
C Geosci. Model Dev., 6, 1367–1388, doi:10.5194/gmd-6-1367-2013
C
C JMLauderdale Summer 2018:
C - Modified for MITGCM style, just keeping the "general" equations from
C MOD_PHSOLVERS SOLVE_AT_GENERAL SOLVE_AT_GENERAL_SEC and SOLVE_AT_FAST.
C Use runtime flags in data.dic to use GENERAL (selectPHsolver=1,
C default), SEC (selectPHsolver=2) or FAST (selectPHsolver=3).
C
C - MOD_CHEMCONST is included here as DIC_COEFFS_SURF, with the
C style brought in line with S/R CARBON_COEFF (i.e all ak values are
C filled in one call, rather than all as separate functions).
C
C - MOD_CHEMCONST pressure corrections have been split off into the new
C S/R DIC_COEFFS_DEEP, call both to get pressure
C adjusted dissociation constants
C
C - Different coefficients can be accessed using runtime flags in data.dic:
C
C Borate concentration from salinity:
C selectBTconst=1 for the default formulation of Uppström (1974)
C i.e. the same as S/R CARBON_COEFFS
C selectBTconst=2 for the new formulation from Lee et al (2010)
C
C Fluoride concentration from salinity:
C selectFTconst=1 for the default formulation of Riley (1965)
C i.e. the same as S/R CARBON_COEFFS
C selectFTconst=2 for the new formulation from Culkin (1965)
C
C First dissociation constant for hydrogen fluoride:
C selectHFconst=1 for the default Dickson and Riley (1979)
C i.e. the same as S/R CARBON_COEFFS
C selectHFconst=2 for the formulation of Perez and Fraga (1987)
C
C First and second dissociation constants of carbonic acid:
C selectK1K2const=1 for the default formulation of Millero (1995) with data
C from Mehrbach et al. (1973), i.e. the same as S/R CARBON_COEFFS
C selectK1K2const=2 for the formulation of Roy et al. (1993)
C selectK1K2const=3 for the "combination" formulation of Millero (1995)
C selectK1K2const=4 for the formulation of Luecker et al. (2000)
C selectK1K2const=5 for the formulation of Millero
C (2010, Mar. Fresh Wat. Res.)
C selectK1K2const=6 for the formulation of Waters, Millero, Woosley
C (2014, Mar. Chem.)
C =========================================================================
SUBROUTINE AHINI_FOR_AT(p_alkcb, p_dictot, p_bortot, p_hini,
& i, j, k, bi, bj, myIter, myThid )
C Subroutine returns the root for the 2nd order approximation of the
C DIC -- B_T -- A_CB equation for [H+] (reformulated as a cubic polynomial)
C around the local minimum, if it exists.
C Returns * 1E-03 if p_alkcb <= 0
C * 1E-10 if p_alkcb >= 2*p_dictot + p_bortot
C * 1E-07 if 0 < p_alkcb < 2*p_dictot + p_bortot
C and the 2nd order approximation does not have a solution
IMPLICIT NONE
C MITgcm GLobal variables
#include "SIZE.h"
#include "EEPARAMS.h"
#include "BLING_VARS.h"
C -----------------------------------------------------------------------
C Argument variables
C -----------------------------------------------------------------------
_RL p_alkcb
_RL p_dictot
_RL p_bortot
_RL p_hini
INTEGER i,j,k,bi,bj,myIter,myThid
#ifdef CARBONCHEM_SOLVESAPHE
C -----------------------------------------------------------------------
C Local variables
C -----------------------------------------------------------------------
_RL zcar, zbor
_RL zd, zsqrtd, zhmin
_RL za2, za1, za0
IF (p_alkcb .LE. 0. _d 0) THEN
p_hini = 1. _d -3
ELSEIF (p_alkcb .GE. (2. _d 0*p_dictot + p_bortot)) THEN
p_hini = 1. _d -10
ELSE
zcar = p_dictot/p_alkcb
zbor = p_bortot/p_alkcb
C Coefficients of the cubic polynomial
za2 = akb(i,j,bi,bj)*(1. _d 0 - zbor) + ak1(i,j,bi,bj)
& *(1. _d 0-zcar)
za1 = ak1(i,j,bi,bj)*akb(i,j,bi,bj)*(1. _d 0 - zbor - zcar)
& + ak1(i,j,bi,bj)*ak2(i,j,bi,bj)*(1. _d 0 - (zcar+zcar))
za0 = ak1(i,j,bi,bj)*ak2(i,j,bi,bj)*akb(i,j,bi,bj)
& *(1. _d 0 - zbor - (zcar+zcar))
C Taylor expansion around the minimum
zd = za2*za2 - 3. _d 0*za1
C Discriminant of the quadratic equation
C for the minimum close to the root
IF(zd .GT. 0. _d 0) THEN
C If the discriminant is positive
zsqrtd = SQRT(zd)
IF(za2 .LT. 0) THEN
zhmin = (-za2 + zsqrtd)/3. _d 0
ELSE
zhmin = -za1/(za2 + zsqrtd)
ENDIF
p_hini = zhmin + SQRT(-(za0 + zhmin*(za1 + zhmin*(za2 + zhmin)))
& /zsqrtd)
ELSE
p_hini = 1. _d -7
ENDIF
ENDIF
#endif /* CARBONCHEM_SOLVESAPHE */
RETURN
END
C END SUBROUTINE AHINI_FOR_AT
C =========================================================================
C =========================================================================
SUBROUTINE ANW_INFSUP(p_dictot, p_bortot,
& p_po4tot, p_siltot,
& p_nh4tot, p_h2stot,
& p_so4tot, p_flutot,
& p_alknw_inf, p_alknw_sup,
& i, j, k, bi, bj, myIter,
& myThid )
C Subroutine returns the lower and upper bounds of "non-water-selfionization"
C Contributions to total alkalinity (the infimum and the supremum), i.e
C inf(TA - [OH-] + [H+]) and sup(TA - [OH-] + [H+])
IMPLICIT NONE
C MITgcm GLobal variables
#include "SIZE.h"
#include "EEPARAMS.h"
#include "BLING_VARS.h"
C --------------------
C Argument variables
C --------------------
_RL p_dictot
_RL p_bortot
_RL p_po4tot
_RL p_siltot
_RL p_nh4tot
_RL p_h2stot
_RL p_so4tot
_RL p_flutot
_RL p_alknw_inf
_RL p_alknw_sup
INTEGER i,j,k,bi,bj,myIter,myThid
#ifdef CARBONCHEM_SOLVESAPHE
C p_alknw_inf = -\Sum_i m_i Xtot_i
C
C p_alknw_inf =-p_dictot*0. _d 0 & ! n = 2, m = 0
C -p_bortot*0. _d 0 & ! n = 1, m = 0
C -p_po4tot*1. _d 0 & ! n = 3, m = 1
C -p_siltot*0. _d 0 & ! n = 1, m = 0
C -p_nh4tot*0. _d 0 & ! n = 1, m = 0
C -p_h2stot*0. _d 0 & ! n = 1, m = 0
C -p_so4tot*1. _d 0 & ! n = 1, m = 1
C -p_flutot*1. _d 0 ! n = 1, m = 1
p_alknw_inf = -p_po4tot - p_so4tot - p_flutot
C p_alknw_sup = \Sum_i (n_i - m_i) Xtot_i
C
C p_alknw_sup = p_dictot*(2. _d 0-0. _d 0) & ! n = 2, m = 0
C p_bortot*(1. _d 0-0. _d 0) & ! n = 1, m = 0
C p_po4tot*(3. _d 0-1. _d 0) & ! n = 3, m = 1
C p_siltot*(1. _d 0-0. _d 0) & ! n = 1, m = 0
C p_nh4tot*(1. _d 0-0. _d 0) & ! n = 1, m = 0
C p_h2stot*(1. _d 0-0. _d 0) & ! n = 1, m = 0
C p_so4tot*(1. _d 0-1. _d 0) & ! n = 1, m = 1
C p_flutot*(1. _d 0-1. _d 0) ! n = 1, m = 1
p_alknw_sup = p_dictot + p_dictot + p_bortot
& + p_po4tot + p_po4tot + p_siltot
& + p_nh4tot + p_h2stot
#endif /* CARBONCHEM_SOLVESAPHE */
RETURN
END
C END SUBROUTINE ANW_INFSUP
C =========================================================================
C INTERFACE: ==========================================================
SUBROUTINE CALC_PCO2_SOLVESAPHE(
I t,s,z_dictot,z_po4tot,z_siltot,z_alktot,
U pHlocal,z_pco2,z_co3,
I i,j,k,bi,bj,debugPrt,myIter,myThid )
IMPLICIT NONE
C MITgcm GLobal variables
#include "SIZE.h"
#include "EEPARAMS.h"
#include "BLING_VARS.h"
C -----------------------------------------------------------------------
C General parameters
C -----------------------------------------------------------------------
C diclocal = total inorganic carbon (mol/m^3)
C where 1 T = 1 metric ton = 1000 kg
C ta = total alkalinity (eq/m^3)
C pt = inorganic phosphate (mol/^3)
C sit = inorganic silicate (mol/^3)
C t = temperature (degrees C)
C s = salinity (g/kg)
_RL t, s, z_po4tot, z_siltot, z_alktot
_RL z_pco2, z_dictot, pHlocal
_RL z_co3
INTEGER i,j,k,bi,bj
LOGICAL debugPrt
INTEGER myIter,myThid
#ifdef CARBONCHEM_SOLVESAPHE
C == Local variables ==
_RL z_h
_RL z_hini
_RL z_bortot
_RL z_nh4tot
_RL z_h2stot
_RL z_so4tot
_RL z_flutot
_RL z_val
_RL z_co2s
_RL z_fco2
_RL z_hco3
_RL z_co2aq
CHARACTER*(MAX_LEN_MBUF) msgBuf
C -----------------------------------------------------------------------
C Change units from the input of mol/m^3 -> mol/kg:
c (1 mol/m^3) x (1 m^3/1024.5 kg)
c where the ocean mean surface density is 1024.5 kg/m^3
c Note: mol/kg are actually what the body of this routine uses
c for calculations. Units are reconverted back to mol/m^3 at the
c end of this routine.
c To convert input in mol/m^3 -> mol/kg
z_po4tot=z_po4tot*permil
z_siltot=z_siltot*permil
z_alktot=z_alktot*permil
z_dictot=z_dictot*permil
C Load from the carbon_chem common block
z_so4tot = st(i,j,bi,bj)
z_flutot = ft(i,j,bi,bj)
z_bortot = bt(i,j,bi,bj)
z_nh4tot = 0. _d 0
z_h2stot = 0. _d 0
z_hini = 10. _d 0**(-1. _d 0 * pHlocal)
at_maxniter = 50
IF ( selectPHsolver.EQ.1 ) THEN
#ifdef ALLOW_DEBUG
IF (debugPrt) CALL DEBUG_CALL('SOLVE_AT_GENERAL',myThid)
#endif
CALL SOLVE_AT_GENERAL(z_alktot, z_dictot, z_bortot,
& z_po4tot, z_siltot, z_nh4tot, z_h2stot,
& z_so4tot, z_flutot, z_hini, z_val,
& z_h,
& i, j, k, bi, bj, debugPrt, myIter, myThid )
ELSEIF ( selectPHsolver.EQ.2 ) THEN
#ifdef ALLOW_DEBUG
IF (debugPrt) CALL DEBUG_CALL('SOLVE_AT_GENERAL_SEC',myThid)
#endif
CALL SOLVE_AT_GENERAL_SEC(z_alktot, z_dictot, z_bortot,
& z_po4tot, z_siltot, z_nh4tot, z_h2stot,
& z_so4tot, z_flutot, z_hini, z_val,
& z_h,
& i, j, k, bi, bj, debugPrt, myIter, myThid )
ELSEIF ( selectPHsolver.EQ.3 ) THEN
#ifdef ALLOW_DEBUG
IF (debugPrt) CALL DEBUG_CALL('SOLVE_AT_FAST',myThid)
#endif
CALL SOLVE_AT_FAST(z_alktot, z_dictot, z_bortot,
& z_po4tot, z_siltot, z_nh4tot, z_h2stot,
& z_so4tot, z_flutot, z_hini, z_val,
& z_h,
& i, j, k, bi, bj, debugPrt, myIter, myThid )
ENDIF
C Unlikely, but it might happen...
IF ( z_h .LT. 0. _d 0 ) THEN
WRITE(msgBuf,'(A,A,A)')
& 'S/R CALC_PCO2_SOLVESAPHE:',
& ' H+ ion concentration less than 0',
& ' Divergence or too many iterations'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R CALC_PCO2_SOLVESAPHE'
ENDIF
C Return update pH to main routine
phlocal = -log10(z_h)
C now determine [CO2*]
z_co2s = z_dictot/
& (1.0 _d 0 + (ak1(i,j,bi,bj)/z_h)
& + (ak1(i,j,bi,bj)*ak2(i,j,bi,bj)/(z_h*z_h)))
C Evaluate HCO3- and CO32- , carbonate ion concentration
C used in determination of calcite compensation depth
z_hco3 = ak1(i,j,bi,bj)*z_dictot /
& (z_h*z_h + ak1(i,j,bi,bj)*z_h
& + ak1(i,j,bi,bj)*ak2(i,j,bi,bj))
z_co3 = ak1(i,j,bi,bj)*ak2(i,j,bi,bj)*z_dictot /
& (z_h*z_h + ak1(i,j,bi,bj)*z_h
& + ak1(i,j,bi,bj)*ak2(i,j,bi,bj))
c ---------------------------------------------------------------
c surface pCO2 (following Dickson and Goyet, DOE...)
#ifdef WATERVAP_BUG
z_pco2 = z_co2s/ff(i,j,bi,bj)
#else
c bug fix by Bennington
z_fco2 = z_co2s/ak0(i,j,bi,bj)
z_pco2 = z_fco2/fugf(i,j,bi,bj)
#endif
C ----------------------------------------------------------------
C Reconvert from mol/kg -> mol/m^3
z_po4tot = z_po4tot/permil
z_siltot = z_siltot/permil
z_alktot = z_alktot/permil
z_dictot = z_dictot/permil
z_hco3 = z_hco3/permil
z_co3 = z_co3/permil
z_co2aq = z_co2s/permil
#endif /* CARBONCHEM_SOLVESAPHE */
RETURN
END
C END SUBROUTINE CALC_PCO2_SOLVESAPHE
C =========================================================================
C =========================================================================
SUBROUTINE DIC_COEFFS_SURF(
& ttemp,stemp,
& bi,bj,iMin,iMax,jMin,jMax,myThid)
C Determine coefficients for surface carbon chemistry,
C loaded into common block
IMPLICIT NONE
C MITgcm GLobal variables
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "GRID.h"
#include "BLING_VARS.h"
_RL ttemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL stemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
INTEGER bi,bj,iMin,iMax,jMin,jMax,myThid
#ifdef CARBONCHEM_SOLVESAPHE
C LOCAL VARIABLES
INTEGER i, j
_RL t
_RL s
_RL t_k
_RL t_k_o_100
_RL t_k_o_100_2
_RL dlog_t_k
_RL inv_t_k
_RL ion_st, is_2, sqrtis
_RL s_2, sqrts, s_15, scl, s35
_RL log_fw2sw
_RL B, B1
_RL delta
_RL P1atm
_RL RT
_RL Rgas
C conversions for different pH scales
_RL total2free
_RL free2sw
_RL total2sw
do i=imin,imax
do j=jmin,jmax
if (hFacC(i,j,1,bi,bj).gt.0. _d 0) then
t = ttemp(i,j)
s = stemp(i,j)
C terms used more than once for:
C temperature
t_k = 273.15 _d 0 + t
t_k_o_100 = t_k/100. _d 0
t_k_o_100_2 = t_k_o_100*t_k_o_100
inv_t_k=1.0 _d 0/t_k
dlog_t_k=LOG(t_k)
C ionic strength (converted to kgsw)
ion_st=19.924 _d 0*s/(1000. _d 0-1.005 _d 0*s)
is_2=ion_st*ion_st
sqrtis=sqrt(ion_st)
C salinity
s_2 = s*s
sqrts=sqrt(s)
s_15 = s*sqrts
scl = s/1.80655 _d 0
s35 = s/35. _d 0
log_fw2sw = LOG( 1. _d 0 - 0.001005 _d 0*s )
IF ( selectBTconst.EQ.1 ) THEN
C -----------------------------------------------------------------------
C Calculate the total borate concentration in mol/kg-SW
C given the salinity of a sample
C Ref: Uppström (1974), cited by Dickson et al. (2007, chapter 5, p 10)
C Millero (1982) cited in Millero (1995)
C pH scale : N/A
bt(i,j,bi,bj) = 0.000232 _d 0* scl/10.811 _d 0
ELSEIF ( selectBTconst.EQ.2 ) THEN
C -----------------------------------------------------------------------
C Calculate the total borate concentration in mol/kg-SW
C given the salinity of a sample
C References: New formulation from Lee et al (2010)
C pH scale : N/A
bt(i,j,bi,bj) = 0.0002414 _d 0* scl/10.811 _d 0
ENDIF
IF ( selectFTconst.EQ.1 ) THEN
C -----------------------------------------------------------------------
C Calculate the total fluoride concentration in mol/kg-SW
C given the salinity of a sample
C References: Riley (1965)
C pH scale : N/A
ft(i,j,bi,bj) = 0.000067 _d 0 * scl/18.9984 _d 0
ELSEIF ( selectFTconst.EQ.2 ) THEN
C -----------------------------------------------------------------------
C Calculate the total fluoride concentration in mol/kg-SW
C given the salinity of a sample
C References: Culkin (1965) (???)
C pH scale : N/A
ft(i,j,bi,bj) = 0.000068 _d 0*(s35)
ENDIF
C -----------------------------------------------------------------------
C Calculate the total sulfate concentration in mol/kg-SW
C given the salinity of a sample
C References: Morris & Riley (1966) quoted in Handbook (2007)
C pH scale : N/A
st(i,j,bi,bj) = 0.14 _d 0 * scl/96.062 _d 0
C -----------------------------------------------------------------------
C Calculate the total calcium concentration in mol/kg-SW
C given the salinity of a sample
C References: Culkin (1965) (???)
C pH scale : N/A
cat(i,j,bi,bj) = 0.010282 _d 0*(s35)
C -----------------------------------------------------------------------
C Calculate K0 in (mol/kg-SW)/atmosphere
C References: Weiss (1979) [(mol/kg-SW)/atm]
C pH scale : N/A
C Note : currently no pressure correction
ak0(i,j,bi,bj) = EXP( 93.4517 _d 0/t_k_o_100 - 60.2409 _d 0
& + 23.3585 _d 0*LOG(t_k_o_100)
& + s * (0.023517 _d 0 - 0.023656 _d 0*t_k_o_100
& + 0.0047036 _d 0*t_k_o_100_2))
C------------------------------------------------------------------------
C Calculate f = k0(1-pH2O)*correction term for non-ideality
C References: Weiss & Price (1980, Mar. Chem., 8, 347-359
C Eq 13 with table 6 values)
C pH scale : N/A
ff(i,j,bi,bj) = exp(-162.8301 _d 0 + 218.2968 _d 0/t_k_o_100
& + 90.9241 _d 0*log(t_k_o_100) - 1.47696 _d 0*t_k_o_100_2
& + s * (.025695 _d 0 - .025225 _d 0*t_k_o_100
& + 0.0049867 _d 0*t_k_o_100_2))
C------------------------------------------------------------------------
C Calculate Fugacity Factor needed for non-ideality in ocean
C References: Weiss (1974) Marine Chemistry
C pH scale : N/A
P1atm = 1.01325 _d 0 ! bars
Rgas = 83.1451 _d 0 ! bar*cm3/(mol*K)
RT = Rgas*t_k
delta = (57.7 _d 0 - 0.118 _d 0*t_k)
B1 = -1636.75 _d 0 + 12.0408 _d 0*t_k - 0.0327957 _d 0*t_k*t_k
B = B1 + 3.16528 _d 0*t_k*t_k*t_k*(0.00001 _d 0)
C "x2" term often neglected (assumed=1) in applications of Weiss's (1974) eq.9
C x2 = 1 - x1 = 1 - xCO2 (it is very close to 1, but not quite)
fugf(i,j,bi,bj) = exp( (B+2. _d 0*delta) * P1atm / RT)
IF ( selectK1K2const.EQ.1 ) THEN
C -----------------------------------------------------------------------
C Calculate first dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C References: Millero (1995, eq 35 -- pK1(MEHR));
C Mehrbach et al. (1973) data
C pH scale: Seawater
ak1(i,j,bi,bj)=10.**(-1. _d 0*(3670.7 _d 0*inv_t_k
& - 62.008 _d 0 + 9.7944 _d 0*dlog_t_k
& - 0.0118 _d 0 * s + 0.000116 _d 0*s_2))
C Calculate second dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C References: Millero (1995, eq 36 -- pK2(MEHR))
C Mehrbach et al. (1973) data
C pH scale: Seawater
ak2(i,j,bi,bj)=10.**(-1. _d 0*(1394.7 _d 0*inv_t_k
& + 4.777 _d 0 - 0.0184 _d 0*s + 0.000118 _d 0*s_2))
ELSEIF ( selectK1K2const.EQ.2 ) THEN
C -----------------------------------------------------------------------
C Calculate first dissociation constant of carbonic acid
C in mol/kg-SW on the Total pH-scale.
C References: Roy et al. (1993) -- also Handbook (1994)
C pH scale : Total
C Note : converted here from mol/kg-H2O to mol/kg-SW
ak1(i,j,bi,bj) = EXP(-2307.1255 _d 0*inv_t_k + 2.83655 _d 0
& - 1.5529413 _d 0*dlog_t_k
& + (-4.0484 _d 0*inv_t_k - 0.20760841)*sqrts
& + 0.08468345*s
& - 0.00654208*s_15
& + log_fw2sw )
C Calculate second dissociation constant of carbonic acid
C in mol/kg-SW on the Total pH-scale.
C References: Roy et al. (1993) -- also Handbook (1994)
C pH scale : Total
C Note : converted here from mol/kg-H2O to mol/kg-SW
ak2(i,j,bi,bj) = EXP(-3351.6106 _d 0*inv_t_k - 9.226508 _d 0
& - 0.2005743 _d 0*dlog_t_k
& + ( -23.9722 _d 0*inv_t_k - 0.106901773 _d 0)*sqrts
& + 0.1130822*s - 0.00846934 _d 0*s_15
& + log_fw2sw )
ELSEIF ( selectK1K2const.EQ.3 ) THEN
C -----------------------------------------------------------------------
C Calculate first dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C References: Millero (1995, eq 50 -- ln K1(COM))
C pH scale: Seawater
ak1(i,j,bi,bj) = EXP(2.18867 _d 0 - 2275.0360 _d 0*inv_t_k
& - 1.468591 _d 0*dlog_t_k
& + ( -0.138681 _d 0 - 9.33291 _d 0*inv_t_k)*sqrts
& + 0.0726483 _d 0*s - 0.00574938 _d 0*s_15)
C Calculate second dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C References: Millero (1995, eq 51 -- ln K2(COM))
C pH scale: Seawater
ak2(i,j,bi,bj) = EXP(-0.84226 _d 0 - 3741.1288 _d 0*inv_t_k
& - 1.437139 _d 0*dlog_t_k
& + (-0.128417 _d 0 - 24.41239 _d 0*inv_t_k)*sqrts
& + 0.1195308 _d 0*s - 0.00912840 _d 0*s_15)
ELSEIF ( selectK1K2const.EQ.4 ) THEN
C -----------------------------------------------------------------------
C Calculate first dissociation constant of carbonic acid
C in mol/kg-SW on the Total pH-scale.
C Suitable when 2 < T < 35 and 19 < S < 43
C References: Luecker et al. (2000) -- also Handbook (2007)
C pH scale: Total
ak1(i,j,bi,bj) = 10. _d 0**( 61.2172 _d 0
& - 3633.86 _d 0*inv_t_k - 9.67770 _d 0*dlog_t_k
& + s*(0.011555 - s*0.0001152 _d 0))
C Calculate second dissociation constant of carbonic acid
C in mol/kg-SW on the Total pH-scale.
C Suitable when 2 < T < 35 and 19 < S < 43
C References: Luecker et al. (2000) -- also Handbook (2007)
C pH scale: Total
ak2(i,j,bi,bj) = 10. _d 0**(-25.9290 _d 0
& - 471.78 _d 0*inv_t_k + 3.16967 _d 0*dlog_t_k
& + s*(0.01781 _d 0 - s*0.0001122 _d 0))
ELSEIF ( selectK1K2const.EQ.5 ) THEN
C -----------------------------------------------------------------------
C Calculate first dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C Suitable when 0 < T < 50 and 1 < S < 50
C References: Millero (2010, Mar. Fresh Wat. Res.)
C Millero (1979) pressure correction
C pH scale: Seawater
ak1(i,j,bi,bj) = 10.0 _d 0**(-1*(6320.813 _d 0*inv_t_k
& + 19.568224 _d 0*dlog_t_k -126.34048 _d 0
& + 13.4038 _d 0*sqrts + 0.03206 _d 0*s - (5.242 _d -5)*s_2
& + (-530.659 _d 0*sqrts - 5.8210 _d 0*s)*inv_t_k
& -2.0664 _d 0*sqrts*dlog_t_k))
C Calculate second dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C Suitable when 0 < T < 50 and 1 < S < 50
C References: Millero (2010, Mar. Fresh Wat. Res.)
C Millero (1979) pressure correction
C pH scale: Seawater
ak2(i,j,bi,bj) = 10.0 _d 0**(-1*(5143.692 _d 0*inv_t_k
& + 14.613358 _d 0*dlog_t_k -90.18333 _d 0
& + 21.3728 _d 0*sqrts + 0.1218 _d 0*s - (3.688 _d -4)*s_2
& + (-788.289 _d 0*sqrts - 19.189 _d 0*s)*inv_t_k
& -3.374 _d 0*sqrts*dlog_t_k))
ELSEIF ( selectK1K2const.EQ.6 ) THEN
C -----------------------------------------------------------------------
C Calculate first dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C Suitable when 0 < T < 50 and 1 < S < 50
C References: Waters, Millero, Woosley (Mar. Chem., 165, 66-67, 2014)
C Millero (1979) pressure correction
C pH scale: Seawater
ak1(i,j,bi,bj) = 10.0 _d 0**(-1.*(6320.813 _d 0*inv_t_k
& + 19.568224 _d 0*dlog_t_k -126.34048 _d 0
& + 13.409160 _d 0*sqrts + 0.031646 _d 0*s - (5.1895 _d -5)*s_2
& + (-531.3642 _d 0*sqrts - 5.713 _d 0*s)*inv_t_k
& -2.0669166 _d 0*sqrts*dlog_t_k))
C Calculate second dissociation constant of carbonic acid
C in mol/kg-SW on the Seawater pH-scale.
C Suitable when 0 < T < 50 and 1 < S < 50
C References: Waters, Millero, Woosley (Mar. Chem., 165, 66-67, 2014)
C Millero (1979) pressure correction
C pH scale: Seawater
ak2(i,j,bi,bj) = 10.0 _d 0**(-1.*
& ( 5143.692 _d 0*inv_t_k + 14.613358 _d 0*dlog_t_k
& - 90.18333 _d 0 + 21.225890 _d 0*sqrts + 0.12450870 _d 0*s
& - (3.7243 _d -4)*s_2
& + (-779.3444 _d 0*sqrts - 19.91739 _d 0*s)*inv_t_k
& - 3.3534679 _d 0*sqrts*dlog_t_k ) )
ENDIF /* selectK1K2const */
C -----------------------------------------------------------------------
C Calculate boric acid dissociation constant KB
C in mol/kg-SW on the total pH-scale.
C References: Dickson (1990, eq. 23) -- also Handbook (2007, eq. 37)
C pH scale : total
akb(i,j,bi,bj) = EXP(( -8966.90 _d 0 - 2890.53 _d 0*sqrts
& -77.942 _d 0*s + 1.728 _d 0*s_15 - 0.0996 _d 0*s_2 )*inv_t_k
& + (148.0248 _d 0 + 137.1942 _d 0*sqrts + 1.62142 _d 0*s)
& + (-24.4344 _d 0 - 25.085 _d 0*sqrts - 0.2474 _d 0*s)*
& dlog_t_k + 0.053105 _d 0*sqrts*t_k )
C -----------------------------------------------------------------------
C Calculate the first dissociation constant
C of phosphoric acid (H3PO4) in seawater
C References: Yao and Millero (1995)
C pH scale : Seawater
ak1p(i,j,bi,bj) = EXP(115.54 _d 0
& - 4576.752 _d 0*inv_t_k - 18.453 _d 0*dlog_t_k
& + ( 0.69171 _d 0 - 106.736 _d 0*inv_t_k)*sqrts
& + (-0.01844 _d 0 - 0.65643 _d 0*inv_t_k)*s)
C -----------------------------------------------------------------------
C Calculate the second dissociation constant
C of phosphoric acid (H3PO4) in seawater
C References: Yao and Millero (1995)
C pH scale : Seawater
ak2p(i,j,bi,bj) = EXP( 172.1033 _d 0
& - 8814.715 _d 0*inv_t_k
& - 27.927 _d 0*dlog_t_k
& + ( 1.3566 _d 0 - 160.340 _d 0*inv_t_k)*sqrts
& + (-0.05778 _d 0 + 0.37335 _d 0*inv_t_k)*s)
C -----------------------------------------------------------------------
C Calculate the third dissociation constant
C of phosphoric acid (H3PO4) in seawater
C References: Yao and Millero (1995)
C pH scale : Seawater
ak3p(i,j,bi,bj) = EXP(-18.126 _d 0 - 3070.75 _d 0*inv_t_k
& + ( 2.81197 _d 0 + 17.27039 _d 0*inv_t_k)*sqrts
& + (-0.09984 _d 0 - 44.99486 _d 0*inv_t_k)*s)
C -----------------------------------------------------------------------
C Calculate the first dissociation constant
C of silicic acid (H4SiO4) in seawater
C References: Yao and Millero (1995) cited by Millero (1995)
C pH scale : Seawater (according to Dickson et al, 2007)
C Note : converted here from mol/kg-H2O to mol/kg-sw
aksi(i,j,bi,bj) = EXP(
& 117.40 _d 0 - 8904.2 _d 0*inv_t_k
& - 19.334 _d 0 * dlog_t_k
& + ( 3.5913 _d 0 - 458.79 _d 0*inv_t_k) * sqrtis
& + (-1.5998 _d 0 + 188.74 _d 0*inv_t_k) * ion_st
& + (0.07871 _d 0 - 12.1652 _d 0*inv_t_k) * ion_st*ion_st
& + log_fw2sw )
C -----------------------------------------------------------------------
C Calculate the dissociation constant
C of ammonium in sea-water [mol/kg-SW]
C References: Yao and Millero (1995)
C pH scale : Seawater
akn(i,j,bi,bj) = EXP(-0.25444 _d 0 - 6285.33 _d 0*inv_t_k
& + 0.0001635 _d 0 * t_k
& + ( 0.46532 _d 0 - 123.7184 _d 0*inv_t_k)*sqrts
& + (-0.01992 _d 0 + 3.17556 _d 0*inv_t_k)*s)
C -----------------------------------------------------------------------
C Calculate the dissociation constant of hydrogen sulfide in sea-water
C References: Millero et al. (1988) (cited by Millero (1995)
C pH scale : - Seawater (according to Yao and Millero, 1995,
C p. 82: "refitted if necessary")
C - Total (according to Lewis and Wallace, 1998)
C Note : we stick to Seawater here for the time being
C Note : the fits from Millero (1995) and Yao and Millero (1995)
C derive from Millero et al. (1998), with all the coefficients
C multiplied by -ln(10)
akhs(i,j,bi,bj) = EXP( 225.838 _d 0 - 13275.3 _d 0*inv_t_k
& - 34.6435 _d 0 * dlog_t_k
& + 0.3449 _d 0*sqrts - 0.0274 _d 0*s)
C -----------------------------------------------------------------------
C Calculate the dissociation constant of hydrogen sulfate (bisulfate)
C References: Dickson (1990) -- also Handbook (2007)
C pH scale : free
C Note : converted here from mol/kg-H2O to mol/kg-SW
aks(i,j,bi,bj) = EXP(141.328 _d 0
& - 4276.1 _d 0*inv_t_k - 23.093 _d 0*dlog_t_k
& + ( 324.57 _d 0 - 13856. _d 0*inv_t_k
& - 47.986 _d 0*dlog_t_k) * sqrtis
& + (-771.54 _d 0 + 35474. _d 0*inv_t_k
& + 114.723 _d 0*dlog_t_k) * ion_st
& - 2698. _d 0*inv_t_k*ion_st**1.5 _d 0
& + 1776. _d 0*inv_t_k*ion_st*ion_st
& + log_fw2sw )
IF ( selectHFconst.EQ.1 ) THEN
C -----------------------------------------------------------------------
C Calculate the dissociation constant \beta_{HF} [(mol/kg-SW)^{-1}]
C in (mol/kg-SW)^{-1}, where
C \beta_{HF} = \frac{ [HF] }{ [H^{+}] [F^{-}] }
C References: Dickson and Riley (1979)
C pH scale : free
C Note : converted here from mol/kg-H2O to mol/kg-SW
akf(i,j,bi,bj) = EXP(1590.2 _d 0*inv_t_k - 12.641 _d 0
& + 1.525 _d 0*sqrtis
& + log_fw2sw )
ELSEIF ( selectHFconst.EQ.2 ) THEN
C -----------------------------------------------------------------------
C Calculate the dissociation constant for hydrogen fluoride
C in mol/kg-SW
C References: Perez and Fraga (1987)
C pH scale : Total (according to Handbook, 2007)
akf(i,j,bi,bj) = EXP( 874. _d 0*inv_t_k - 9.68 _d 0
& + 0.111 _d 0*sqrts )
ENDIF
C -----------------------------------------------------------------------
C Calculate the water dissociation constant Kw in (mol/kg-SW)^2
C References: Millero (1995) for value at pressc = 0
C pH scale : Seawater
akw(i,j,bi,bj) = EXP(148.9802 _d 0 - 13847.26 _d 0*inv_t_k
& - 23.6521 _d 0*dlog_t_k
& + (-5.977 _d 0 + 118.67 _d 0*inv_t_k
& + 1.0495 _d 0*dlog_t_k)*sqrts
& - 0.01615 _d 0*s )
C -----------------------------------------------------------------------
C pH scale conversion factors and conversions. Everything on total pH scale
total2free = 1. _d 0/
& (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
free2sw = 1. _d 0
& + (st(i,j,bi,bj)/ aks(i,j,bi,bj))
& + (ft(i,j,bi,bj)/(akf(i,j,bi,bj)*total2free))
total2sw = total2free * free2sw
aphscale(i,j,bi,bj) = 1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj)
IF ( selectK1K2const.NE.2 .AND. selectK1K2const.NE.4 ) THEN
C Convert to the total pH scale
ak1(i,j,bi,bj) = ak1(i,j,bi,bj)/total2sw
ak2(i,j,bi,bj) = ak2(i,j,bi,bj)/total2sw
ENDIF
ak1p(i,j,bi,bj) = ak1p(i,j,bi,bj)/total2sw
ak2p(i,j,bi,bj) = ak2p(i,j,bi,bj)/total2sw
ak3p(i,j,bi,bj) = ak3p(i,j,bi,bj)/total2sw
aksi(i,j,bi,bj) = aksi(i,j,bi,bj)/total2sw
akn (i,j,bi,bj) = akn (i,j,bi,bj)/total2sw
akhs(i,j,bi,bj) = akhs(i,j,bi,bj)/total2sw
aks (i,j,bi,bj) = aks (i,j,bi,bj)/total2free
IF ( selectHFconst.EQ.1 ) THEN
akf (i,j,bi,bj) = akf (i,j,bi,bj)/total2free
ENDIF
akw (i,j,bi,bj) = akw (i,j,bi,bj)/total2free
C -----------------------------------------------------------------------
C Calculate the stoichiometric solubility product
C of calcite in seawater
C References: Mucci (1983)
C pH scale : N/A
C Units : (mol/kg-SW)^2
Ksp_TP_Calc(i,j,bi,bj) = 10. _d 0**(-171.9065 _d 0
& - 0.077993 _d 0*t_k
& + 2839.319 _d 0*inv_t_k + 71.595 _d 0*LOG10(t_k)
& + ( -0.77712 _d 0 + 0.0028426 _d 0*t_k
& + 178.34 _d 0*inv_t_k)*sqrts
& - 0.07711 _d 0*s + 0.0041249 _d 0*s_15)
C -----------------------------------------------------------------------
C Calculate the stoichiometric solubility product
C of aragonite in seawater
C References: Mucci (1983)
C pH scale : N/A
C Units : (mol/kg-SW)^2
Ksp_TP_Arag(i,j,bi,bj) = 10. _d 0**(-171.945 _d 0
& - 0.077993 _d 0*t_k
& + 2903.293 _d 0*inv_t_k + 71.595 _d 0*LOG10(t_k)
& + ( -0.068393 _d 0 + 0.0017276 _d 0*t_k
& + 88.135 _d 0*inv_t_k)*sqrts
& - 0.10018 _d 0*s + 0.0059415 _d 0*s_15)
else
bt(i,j,bi,bj) = 0. _d 0
st(i,j,bi,bj) = 0. _d 0
ft(i,j,bi,bj) = 0. _d 0
cat(i,j,bi,bj) = 0. _d 0
fugf(i,j,bi,bj)= 0. _d 0
ff(i,j,bi,bj) = 0. _d 0
ak0(i,j,bi,bj) = 0. _d 0
ak1(i,j,bi,bj) = 0. _d 0
ak2(i,j,bi,bj) = 0. _d 0
akb(i,j,bi,bj) = 0. _d 0
ak1p(i,j,bi,bj)= 0. _d 0
ak2p(i,j,bi,bj)= 0. _d 0
ak3p(i,j,bi,bj)= 0. _d 0
aksi(i,j,bi,bj)= 0. _d 0
akw(i,j,bi,bj) = 0. _d 0
aks(i,j,bi,bj) = 0. _d 0
akf(i,j,bi,bj) = 0. _d 0
akn(i,j,bi,bj) = 0. _d 0
akhs(i,j,bi,bj)= 0. _d 0
Ksp_TP_Calc(i,j,bi,bj) = 0. _d 0
Ksp_TP_Arag(i,j,bi,bj) = 0. _d 0
aphscale(i,j,bi,bj) = 0. _d 0
endif
end do
end do
#endif /* CARBONCHEM_SOLVESAPHE */
RETURN
END
C END SUBROUTINE DIC_COEFFS_SURF
C -----------------------------------------------------------------------
C -----------------------------------------------------------------------
SUBROUTINE DIC_COEFFS_DEEP(
& ttemp,stemp,
& bi,bj,iMin,iMax,jMin,jMax,
& Klevel,myThid)
C Add depth dependence to carbon chemistry coefficients loaded into
C common block. Corrections occur on the Seawater pH scale and are
C converted back to the total scale
IMPLICIT NONE
C MITgcm GLobal variables
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "GRID.h"
#include "BLING_VARS.h"
_RL ttemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL stemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
INTEGER bi,bj,iMin,iMax,jMin,jMax,Klevel,myThid
#ifdef CARBONCHEM_SOLVESAPHE
C LOCAL VARIABLES
INTEGER i, j, k
_RL bdepth
_RL cdepth
_RL pressc
_RL t
_RL s
_RL zds
_RL t_k
_RL t_k_o_100
_RL t_k_o_100_2
_RL dlog_t_k
_RL sqrtis
_RL sqrts
_RL s_2
_RL s_15
_RL inv_t_k
_RL ion_st
_RL is_2
_RL scl
_RL zrt
_RL B1
_RL B
_RL delta
_RL Pzatm
_RL zdvi
_RL zdki
_RL pfac
C pH scale converstions
_RL total2free_surf
_RL free2sw_surf
_RL total2sw_surf
_RL total2free
_RL free2sw
_RL total2sw
c determine pressure (bar) from depth
c 1 BAR at z=0m (atmos pressure)
c use UPPER surface of cell so top layer pressure = 0 bar
c for surface exchange coeffs
cmick..............................
c write(6,*)'Klevel ',klevel
bdepth = 0. _d 0
cdepth = 0. _d 0
pressc = 1. _d 0
do k = 1,Klevel
cdepth = bdepth + 0.5 _d 0*drF(k)
bdepth = bdepth + drF(k)
pressc = 1. _d 0 + 0.1 _d 0*cdepth
end do
cmick...................................................
c write(6,*)'depth,pressc ',cdepth,pressc
cmick....................................................
do i=imin,imax
do j=jmin,jmax
if (hFacC(i,j,Klevel,bi,bj).gt.0. _d 0) then
t = ttemp(i,j)
s = stemp(i,j)
C terms used more than once for:
C temperature
t_k = 273.15 _d 0 + t
zrt= 83.14472 _d 0 * t_k
t_k_o_100 = t_k/100. _d 0
t_k_o_100_2=t_k_o_100*t_k_o_100
inv_t_k=1.0 _d 0/t_k
dlog_t_k=log(t_k)
C ionic strength
ion_st=19.924 _d 0*s/(1000. _d 0-1.005 _d 0*s)
is_2=ion_st*ion_st
sqrtis=sqrt(ion_st)
C salinity
s_2=s*s
sqrts=sqrt(s)
s_15=s**1.5 _d 0
scl=s/1.80655 _d 0
zds = s - 34.8 _d 0
total2free_surf = 1. _d 0/
& (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
free2sw_surf = 1. _d 0
& + st(i,j,bi,bj)/ aks(i,j,bi,bj)
& + ft(i,j,bi,bj)/(akf(i,j,bi,bj)*total2free_surf)
total2sw_surf = total2free_surf * free2sw_surf
C------------------------------------------------------------------------
C Recalculate Fugacity Factor needed for non-ideality in ocean
C with pressure dependence.
C Reference : Weiss (1974) Marine Chemistry
C pH scale : N/A
Pzatm = 1.01325 _d 0+pressc ! bars
delta = (57.7 _d 0 - 0.118 _d 0*t_k)
B1 = -1636.75 _d 0 + 12.0408 _d 0*t_k -0.0327957 _d 0*t_k*t_k
B = B1 + 3.16528 _d 0*t_k*t_k*t_k*(0.00001 _d 0)
C "x2" term often neglected (assumed=1) in applications of Weiss's (1974) eq.9
C x2 = 1 - x1 = 1 - xCO2 (it is very close to 1, but not quite)
fugf(i,j,bi,bj) = exp( (B+2. _d 0*delta) * Pzatm / zrt)
C -----------------------------------------------------------------------
C Apply pressure dependence to the dissociation constant of hydrogen
C sulfate (bisulfate). Ref: Millero (1995) for pressure correction
zdvi = -18.03 _d 0 + t*(0.0466 _d 0 + t*0.316 _d -3)
zdki = ( -4.53 _d 0 + t*0.0900 _d 0)*1. _d -3
pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
aks(i,j,bi,bj) = total2free_surf*aks(i,j,bi,bj) * exp(pfac)
total2free = 1. _d 0/
& (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
C free2sw has an additional component from fluoride
free2sw = 1. _d 0
& + st(i,j,bi,bj)/ aks(i,j,bi,bj)
aks(i,j,bi,bj) = aks(i,j,bi,bj)/total2free
C -----------------------------------------------------------------------
C Apply pressure dependence to dissociation constant for hydrogen fluoride
C References: Millero (1995) for pressure correction
zdvi = -9.78 _d 0 + t*(-0.0090 _d 0 - t*0.942 _d -3)
zdki = ( -3.91 _d 0 + t*0.054 _d 0)*1. _d -3
pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
akf(i,j,bi,bj) = total2free_surf*akf(i,j,bi,bj) * exp(pfac)
free2sw = free2sw
& + ft(i,j,bi,bj)/akf(i,j,bi,bj)
total2sw = total2free * free2sw
akf(i,j,bi,bj) = akf(i,j,bi,bj)/total2free
C -----------------------------------------------------------------------
C Apply pressure dependence to 1rst dissociation constant of carbonic acid
C References: Millero (1982) pressure correction
zdvi = -25.50 _d 0 -0.151 _d 0*zds + 0.1271 _d 0*t