-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmod_chemconst.F90
2478 lines (1554 loc) · 65.3 KB
/
mod_chemconst.F90
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
! -*- f90 -*-
!
! Copyright 2013 Guy Munhoven
!
! This file is part of SolveSAPHE.
! SolveSAPHE is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! SolveSAPHE is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public License
! along with SolveSAPHE. If not, see <http://www.gnu.org/licenses/>.
!
MODULE MOD_CHEMCONST
USE MOD_PRECISION
USE MOD_COMMON, ONLY: one, two, ten, hundred
IMPLICIT NONE
! --------------------------------------------------------
! List of subroutines for the chemical constants (PRIVATE)
! --------------------------------------------------------
!PRIVATE AK_CARB_0_WEIS74
!PRIVATE AK_CARB_1_MILL95, AK_CARB_2_MILL95
!PRIVATE AK_CARB_1_LUEK00, AK_CARB_2_LUEK00
!PRIVATE AK_CARB_1_ROYE93, AK_CARB_2_ROYE93
!PRIVATE AK_BORA_DICK90
!PRIVATE AK_PHOS_1_MILL95, AK_PHOS_2_MILL95, AK_PHOS_3_MILL95
!PRIVATE AK_SILI_1_MILL95
!PRIVATE AK_H2S_1_MILL95
!PRIVATE AK_AMMO_1_YAMI95
!PRIVATE AK_W_MILL95
!PRIVATE AK_HSO4_DICK90
!PRIVATE ABETA_HF_DIRI79
!PRIVATE AK_HF_PEFR87
! --------------------------------------
! Parameters for usage within the module
! --------------------------------------
! Gas constant
! ------------
REAL(KIND=wp), PARAMETER :: gasconst_bar_cm3_o_mol_k = 83.14510_wp ! libthdyct
!REAL(KIND=wp), PARAMETER, PRIVATE :: gasconst_bar_cm3_o_mol_k = 83.14472_wp ! Handbook (2007)
! 0 degrees centigrade in Kelvin
! ------------------------------
REAL(KIND=wp), PARAMETER :: t_k_zerodegc = 273.15_wp ! Handbook (2007)
! --------------------------------------------------------------
! Chemical constants products: for usage by users of the module
! --------------------------------------------------------------
! For each acid system A,
! - api1_aaa <-- K_A1
! - api2_aaa <-- K_A1*K_A2
! - api3_aaa <-- K_A1*K_A2*K_A3
! - ...
REAL(KIND=wp) :: api1_dic, api2_dic
REAL(KIND=wp) :: api1_bor
REAL(KIND=wp) :: api1_po4, api2_po4, api3_po4
REAL(KIND=wp) :: api1_sil
REAL(KIND=wp) :: api1_nh4
REAL(KIND=wp) :: api1_h2s
REAL(KIND=wp) :: api1_so4
REAL(KIND=wp) :: api1_flu
REAL(KIND=wp) :: api1_wat, aphscale
!*******************************************************************************
CONTAINS
!*******************************************************************************
!=======================================================================
SUBROUTINE SETUP_API4PHTOT(t_k, s, p_bar)
!=======================================================================
IMPLICIT NONE
! ------------------
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! ---------------
! Local variables
! ---------------
REAL(KIND=wp) :: zcvt_htot_o_hsws, zcvt_htot_o_hfree
zcvt_htot_o_hsws = one/ACVT_HSWS_O_HTOT(t_k, s, p_bar)
zcvt_htot_o_hfree = ACVT_HTOT_O_HFREE(t_k, s, p_bar)
api1_dic = AK_CARB_1_LUEK00(t_k, s, p_bar)
api2_dic = api1_dic * AK_CARB_2_LUEK00(t_k, s, p_bar)
api1_bor = AK_BORA_DICK90(t_k, s, p_bar)
api1_po4 = AK_PHOS_1_MILL95(t_k, s, p_bar) * zcvt_htot_o_hsws
api2_po4 = api1_po4 * AK_PHOS_2_MILL95(t_k, s, p_bar) * zcvt_htot_o_hsws
api3_po4 = api2_po4 * AK_PHOS_3_MILL95(t_k, s, p_bar) * zcvt_htot_o_hsws
api1_sil = AK_SILI_1_MILL95(t_k, s ) * zcvt_htot_o_hsws
api1_nh4 = AK_AMMO_1_YAMI95(t_k, s, p_bar) * zcvt_htot_o_hsws
api1_h2s = AK_H2S_1_MILL95 (t_k, s, p_bar) * zcvt_htot_o_hsws
api1_so4 = AK_HSO4_DICK90(t_k, s, p_bar) * zcvt_htot_o_hfree
api1_flu = AK_HF_PEFR87(t_k, s, p_bar)
api1_wat = AK_W_MILL95(t_k, s, p_bar) * zcvt_htot_o_hsws
aphscale = zcvt_htot_o_hfree
!=======================================================================
END SUBROUTINE SETUP_API4PHTOT
!=======================================================================
!=======================================================================
SUBROUTINE SETUP_API4PHSWS(t_k, s, p_bar)
!=======================================================================
! ------------------
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! ---------------
! Local variables
! ---------------
REAL(KIND=wp) :: zcvt_hsws_o_htot, zcvt_hsws_o_hfree
zcvt_hsws_o_htot = ACVT_HSWS_O_HTOT(t_k, s, p_bar)
zcvt_hsws_o_hfree = ACVT_HSWS_O_HFREE(t_k, s, p_bar)
api1_dic = AK_CARB_1_MILL95(t_k, s, p_bar)
api2_dic = api1_dic * AK_CARB_2_MILL95(t_k, s, p_bar)
api1_bor = AK_BORA_DICK90(t_k, s, p_bar) * zcvt_hsws_o_htot
api1_po4 = AK_PHOS_1_MILL95(t_k, s, p_bar)
api2_po4 = api1_po4 * AK_PHOS_2_MILL95(t_k, s, p_bar)
api3_po4 = api2_po4 * AK_PHOS_3_MILL95(t_k, s, p_bar)
api1_sil = AK_SILI_1_MILL95(t_k, s )
api1_nh4 = AK_AMMO_1_YAMI95(t_k, s, p_bar)
api1_h2s = AK_H2S_1_MILL95 (t_k, s, p_bar)
api1_so4 = AK_HSO4_DICK90(t_k, s, p_bar) * zcvt_hsws_o_hfree
api1_flu = zcvt_hsws_o_hfree/ABETA_HF_DIRI79(t_k, s, p_bar)
api1_wat = AK_W_MILL95(t_k, s, p_bar)
aphscale = zcvt_hsws_o_hfree
!=======================================================================
END SUBROUTINE SETUP_API4PHSWS
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_0_WEIS74(t_k, s)
!=======================================================================
! Function calculates K0 in (mol/kg-SW)/atmosphere
! References: Weiss (1979) [(mol/kg-SW)/atm]
! pH scale : N/A
! Note : currently no pressure correction
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_0_WEIS74
! ------------------
! Argument variables
! ------------------
! s : salinity
! t_k : temperature in K
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
! ---------------
! Local variables
! ---------------
! zt_k_o_100 : zt_k/100
REAL(KIND=wp) :: zt_k_o_100
zt_k_o_100 = t_k/hundred
AK_CARB_0_WEIS74 &
= EXP( -60.2409_wp + 93.4517_wp/zt_k_o_100 &
+ 23.3585_wp*LOG(zt_k_o_100) &
+ ( 0.023517_wp - 0.023656_wp*zt_k_o_100 &
+ 0.0047036_wp*zt_k_o_100*zt_k_o_100)*s )
RETURN
!=======================================================================
END FUNCTION AK_CARB_0_WEIS74
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_1_MILL95(t_k, s, p_bar)
!=======================================================================
! Function calculates first dissociation constant of carbonic acid
! in mol/kg-SW on the SWS pH-scale.
! References: Millero (1995, eq 50 -- ln K1(COM))
! Millero (1982) pressure correction
! pH scale: SWS
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_1_MILL95
! ------------------
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! ---------------
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zsqrts : square root of salinity
! zds : salinity-34.8
! zln_kc1_p0 : ln(K_C1) at p_bar = 0
! zln_kc1_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds, zsqrts
REAL(KIND=wp) :: zln_kc1_p0, zln_kc1_pp
! ln(K_C1) value at p_bar = 0
zsqrts = SQRT(s)
zln_kc1_p0 = 2.18867_wp &
- 2275.0360_wp/t_k &
- 1.468591_wp*LOG(t_k) &
+ ( -0.138681_wp - 9.33291_wp/t_k)*zsqrts &
+ 0.0726483_wp*s - 0.00574938_wp*s*zsqrts
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -25.50_wp - 0.151_wp*zds + 0.1271_wp*zt_degc
zdki = ( -3.08_wp - 0.578_wp*zds + 0.0877_wp*zt_degc)*1.0E-03_wp
zln_kc1_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_C1 value
AK_CARB_1_MILL95 = EXP( zln_kc1_p0 + zln_kc1_pp )
RETURN
!=======================================================================
END FUNCTION AK_CARB_1_MILL95
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_2_MILL95(t_k, s, p_bar)
!=======================================================================
! Function calculates second dissociation constant K1
! in mol/kg-SW on the SWS pH-scale.
! References: Millero (1995, eq 51 -- ln K2(COM))
! Millero (1979) pressure correction
! pH scale: SWS
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_2_MILL95
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zsqrts : square root of salinity
! zds : salinity-34.8
! zln_kc2_p0 : ln(K_C2) at p_bar = 0
! zln_kc2_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds, zsqrts
REAL(KIND=wp) :: zln_kc2_p0, zln_kc2_pp
! ln(K_C2) value at p_bar = 0
zsqrts = SQRT(s)
zln_kc2_p0 = -0.84226_wp &
- 3741.1288_wp/t_k &
- 1.437139_wp*LOG(t_k) &
+ (-0.128417_wp - 24.41239_wp/t_k)*zsqrts &
+ 0.1195308_wp*s &
- 0.00912840_wp*s*zsqrts
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -15.82_wp + 0.321_wp*zds - 0.0219_wp*zt_degc
zdki = ( 1.13_wp - 0.314_wp*zds - 0.1475_wp*zt_degc)*1.0E-03_wp
zln_kc2_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_C2 value
AK_CARB_2_MILL95 = EXP( zln_kc2_p0 + zln_kc2_pp )
RETURN
!=======================================================================
END FUNCTION AK_CARB_2_MILL95
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_1_LUEK00(t_k, s, p_bar)
!=======================================================================
! Function calculates first dissociation constant of carbonic acid
! in mol/kg-SW on the Total pH-scale.
! References: Luecker et al. (2000) -- also Handbook (2007)
! Millero (1979) pressure correction
! pH scale: Total
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_1_LUEK00
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zds : salinity-34.8
! zlog10_kc1_p0 : log_10(k_C1) at p_bar = 0
! zln_kc1_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds, zsqrts
REAL(KIND=wp) :: zlog10_kc1_p0, zln_kc1_pp
! log_10(K_C1) value at p_bar = 0
zlog10_kc1_p0 = 61.2172_wp &
- 3633.86_wp/t_k &
- 9.67770_wp*LOG(t_k) &
+ s*(0.011555_wp - s*0.0001152_wp)
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -25.50_wp - 0.151_wp*zds + 0.1271_wp*zt_degc
zdki = ( -3.08_wp - 0.578_wp*zds + 0.0877_wp*zt_degc)*1.0E-03_wp
zln_kc1_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_C1 value
AK_CARB_1_LUEK00 = ten**zlog10_kc1_p0 * EXP(zln_kc1_pp)
RETURN
!=======================================================================
END FUNCTION AK_CARB_1_LUEK00
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_2_LUEK00(t_k, s, p_bar)
!=======================================================================
! Function calculates second dissociation constant K1
! in mol/kg-SW on the Total pH-scale.
! References: Luecker et al. (2000) -- also Handbook (2007)
! Millero (1979) pressure correction
! pH scale: Total
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_2_LUEK00
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zsqrts : square root of salinity
! zds : salinity-34.8
! zlog10_kc2_p0 : log_10(K_C2) at p_bar = 0
! zln_kc2_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds, zsqrts
REAL(KIND=wp) :: zlog10_kc2_p0, zln_kc2_pp
! log_10(K_C2) value at p_bar = 0
zlog10_kc2_p0 = -25.9290_wp &
- 471.78_wp/t_k + 3.16967_wp*LOG(t_k) &
+ s*(0.01781_wp - s*0.0001122_wp)
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -15.82_wp + 0.321_wp*zds - 0.0219_wp*zt_degc
zdki = ( 1.13_wp - 0.314_wp*zds - 0.1475_wp*zt_degc)*1.0E-03_wp
zln_kc2_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_C2 value
AK_CARB_2_LUEK00 = ten**zlog10_kc2_p0 *EXP(zln_kc2_pp)
RETURN
!=======================================================================
END FUNCTION AK_CARB_2_LUEK00
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_1_ROYE93(t_k, s, p_bar)
!=======================================================================
! Function calculates first dissociation constant of carbonic acid
! in mol/kg-SW on the Total pH-scale.
! References: Roy et al. (1993) -- also Handbook (1994)
! Millero (1979) pressure correction
! pH scale : Total
! Note : converted here from mol/kg-H2O to mol/kg-SW
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_1_ROYE93
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zds : salinity-34.8
! zln_kc1_p0 : ln(k_C1) at p_bar = 0
! zln_kc1_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zsqrts, zcvt_to_kgsw
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds
REAL(KIND=wp) :: zln_kc1_p0, zln_kc1_pp
! ln(K_C1) value at p_bar = 0
zsqrts = SQRT(s)
zcvt_to_kgsw = ACVT_KGH2O_O_KGSW(s)
zln_kc1_p0 = -2307.1255_wp/t_k + 2.83655_wp - 1.5529413_wp*LOG(t_k) &
+ (-4.0484_wp/t_k - 0.20760841_wp)*zsqrts &
+ 0.08468345_wp*s &
- 0.00654208_wp*zsqrts*s
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -25.50_wp - 0.151_wp*zds + 0.1271_wp*zt_degc
zdki = ( -3.08_wp - 0.578_wp*zds + 0.0877_wp*zt_degc)*1.0E-03_wp
zln_kc1_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_C1 value
AK_CARB_1_ROYE93 = EXP(zln_kc1_p0 + zln_kc1_pp) * zcvt_to_kgsw
RETURN
!=======================================================================
END FUNCTION AK_CARB_1_ROYE93
!=======================================================================
!=======================================================================
FUNCTION AK_CARB_2_ROYE93(t_k, s, p_bar)
!=======================================================================
! Function calculates second dissociation constant K1
! in mol/kg-SW on the Total pH-scale.
! References: Roy et al. (1993) -- also Handbook (1994)
! Millero (1979) pressure correction
! pH scale : Total
! Note : converted here from mol/kg-H2O to mol/kg-SW
IMPLICIT NONE
REAL(KIND=wp) :: AK_CARB_2_ROYE93
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zsqrts : square root of salinity
! zds : salinity-34.8
! zln_kc2_p0 : ln(K_C2) at p_bar = 0
! zln_kc2_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zsqrts, zcvt_to_kgsw
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds
REAL(KIND=wp) :: zln_kc2_p0, zln_kc2_pp
! ln(K_C2) value at p_bar = 0
zsqrts = SQRT(s)
zcvt_to_kgsw = ACVT_KGH2O_O_KGSW(s)
zln_kc2_p0 = -3351.6106_wp/t_k - 9.226508_wp - 0.2005743_wp*LOG(t_k) &
+ ( -23.9722_wp/t_k - 0.106901773_wp)*zsqrts &
+ 0.1130822_wp*s - 0.00846934_wp*zsqrts*s
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -15.82_wp + 0.321_wp*zds - 0.0219_wp*zt_degc
zdki = ( 1.13_wp - 0.314_wp*zds - 0.1475_wp*zt_degc)*1.0E-03_wp
zln_kc2_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_C2 value
AK_CARB_2_ROYE93 = EXP(zln_kc2_p0 + zln_kc2_pp) * zcvt_to_kgsw
RETURN
!=======================================================================
END FUNCTION AK_CARB_2_ROYE93
!=======================================================================
!=======================================================================
FUNCTION AK_BORA_DICK90(t_k, s, p_bar)
!=======================================================================
! Function calculates boric acid dissociation constant KB
! in mol/kg-SW on the total pH-scale.
! References: Dickson (1990, eq. 23) -- also Handbook (2007, eq. 37)
! Millero (1979) pressure correction
! pH scale : total
IMPLICIT NONE
REAL(KIND=wp) :: AK_BORA_DICK90
! ------------------
! Argument variables
! ------------------
! t_k : temperature in Kelvin
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k
REAL(KIND=wp), INTENT(IN) :: s
REAL(KIND=wp), INTENT(IN) :: p_bar
! ---------------
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zsqrts : square root of salinity
! zds : salinity-34.8
! zln_kb_p0 : K_b at p_bar = 0
! zln_kb_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds, zsqrts
REAL(KIND=wp) :: zln_kb_p0, zln_kb_pp
! ln(K_B) value at p_bar = 0
zsqrts = SQRT(s)
zln_kb_p0 = ( -8966.90_wp &
+ zsqrts*( -2890.53_wp &
+ zsqrts*( -77.942_wp &
+ zsqrts*( 1.728_wp - 0.0996_wp*zsqrts)))) / t_k &
+ 148.0248_wp + zsqrts*(137.1942_wp + zsqrts*1.62142_wp) &
+ (-24.4344_wp + zsqrts*(-25.085_wp - zsqrts*0.2474_wp)) * LOG(t_k) &
+ 0.053105_wp*zsqrts*t_k
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zds = s - 34.8_wp
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -29.48_wp + 0.295_wp*zds + 0.1622_wp*zt_degc - 0.002608_wp*zt_degc*zt_degc
zdki = (-2.84_wp + 0.354_wp*zds)*1.0E-03_wp
zln_kb_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_B value
AK_BORA_DICK90 = EXP( zln_kb_p0 + zln_kb_pp )
!=======================================================================
END FUNCTION AK_BORA_DICK90
!=======================================================================
!=======================================================================
FUNCTION AK_W_MILL95(t_k, s, p_bar)
!=======================================================================
! Function calculates water dissociation constant Kw in (mol/kg-SW)^2
! References: Millero (1995) for value at p_bar = 0
! Millero (pers. comm. 1996) for pressure correction
! pH scale : SWS
IMPLICIT NONE
REAL(KIND=wp) :: AK_W_MILL95
! ------------------
! Argument variables
! ------------------
! t_k : temperature in K
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k, s, p_bar
! ---------------
! Local variables
! ---------------
! zrt : R*t_k
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zln_kw_p0 : ln(K_w) at p_bar = 0
! zln_kw_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki, zds, zsqrts
REAL(KIND=wp) :: zln_kw_p0, zln_kw_pp
! ln(K_w) value at p_bar = 0
zln_kw_p0 = 148.9802_wp &
- 13847.26_wp/t_k &
- 23.6521_wp*LOG(t_k) &
+ ( -5.977_wp + 118.67_wp/t_k + 1.0495_wp*LOG(t_k))*SQRT(s) &
- 0.01615_wp*s
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -20.02_wp + 0.1119_wp*zt_degc - 0.1409E-02_wp*zt_degc*zt_degc
zdki = ( -5.13_wp + 0.0794_wp*zt_degc)*1.0E-03_wp
zln_kw_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final K_w value
AK_W_MILL95 = EXP( zln_kw_p0 + zln_kw_pp )
RETURN
!=======================================================================
END FUNCTION AK_W_MILL95
!=======================================================================
!=======================================================================
FUNCTION AK_PHOS_1_MILL95(t_k, s, p_bar)
!=======================================================================
! Function returns the first dissociation constant
! of phosphoric acid (H3PO4) in seawater
! References: Yao and Millero (1995)
! Millero (1995) for pressure correction
! pH scale : SWS
IMPLICIT NONE
REAL(KIND=wp) :: AK_PHOS_1_MILL95
! ------------------
! Argument variables
! ------------------
! t_k : temperature in K
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k, s, p_bar
! ---------------
! Local variables
! ---------------
! zrt : R*t_k, R in bar*cm3/(mol*K)
! zt_degc : temperature in degrees Celsius
! zdvi : volume change for ionization
! zdki : compressibility change for ionization
! zln_kp1_p0 : ln(K_p1) at p_bar = 0
! zln_kp1_pp : pressure correction for p_bar /= 0
REAL(KIND=wp) :: zrt, zt_degc, zdvi, zdki
REAL(KIND=wp) :: zln_kp1_p0, zln_kp1_pp
! ln(K_P1) for p_bar = 0
zln_kp1_p0 = 115.54_wp - 4576.752_wp/t_k - 18.453_wp*LOG(t_k) &
+ ( 0.69171_wp - 106.736_wp/t_k)* SQRT(s) &
+ (-0.01844_wp - 0.65643_wp/t_k)*s
! Pressure correction
zt_degc = t_k - t_k_zerodegc
zrt = gasconst_bar_cm3_o_mol_k * t_k
zdvi = -14.51_wp + 0.1211_wp*zt_degc - 0.321E-03_wp*zt_degc*zt_degc
zdki = ( -2.67_wp + 0.0427_wp*zt_degc)*1.0E-03_wp
zln_kp1_pp = (-zdvi + zdki*p_bar/two)*p_bar/zrt
! Final value of K_P1
AK_PHOS_1_MILL95 = EXP(zln_kp1_p0 + zln_kp1_pp)
RETURN
!=======================================================================
END FUNCTION AK_PHOS_1_MILL95
!=======================================================================
!=======================================================================
FUNCTION AK_PHOS_2_MILL95(t_k, s, p_bar)
!=======================================================================
! Function returns the second dissociation constant
! of phosphoric acid (H3PO4) in seawater
! References: Yao and Millero (1995)
! Millero (1995) for pressure correction
! pH scale : SWS
IMPLICIT NONE
REAL(KIND=wp) :: AK_PHOS_2_MILL95
! ------------------
! Argument variables
! ------------------
! t_k : temperature in K
! s : salinity
! p_bar : applied pressure in bar
REAL(KIND=wp), INTENT(IN) :: t_k, s, p_bar
! ---------------
! Local variables
! ---------------