File indexing completed on 2023-10-26 05:10:19 UTC
view on githubraw file Latest commit a2c35952 on 2023-10-25 14:50:13 UTC
6acab690ae Jona*0001 #include "DIC_OPTIONS.h"
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 SUBROUTINE AHINI_FOR_AT(p_alkcb, p_dictot, p_bortot, p_hini,
0079 & i, j, k, bi, bj, myIter, myThid )
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 IMPLICIT NONE
0091
0092
0093 #include "SIZE.h"
0094 #include "EEPARAMS.h"
0095 #include "DIC_VARS.h"
0096
0097
0098
0099
0100
0101 _RL p_alkcb
0102 _RL p_dictot
0103 _RL p_bortot
0104 _RL p_hini
0105 INTEGER i,j,k,bi,bj,myIter,myThid
0106
0107 #ifdef CARBONCHEM_SOLVESAPHE
0108
0109
0110
0111
0112 _RL zcar, zbor
0113 _RL zd, zsqrtd, zhmin
0114 _RL za2, za1, za0
0115
0116 IF (p_alkcb .LE. 0. _d 0) THEN
0117 p_hini = 1. _d -3
0118 ELSEIF (p_alkcb .GE. (2. _d 0*p_dictot + p_bortot)) THEN
0119 p_hini = 1. _d -10
0120 ELSE
0121 zcar = p_dictot/p_alkcb
0122 zbor = p_bortot/p_alkcb
0123
0124
0125 za2 = akb(i,j,bi,bj)*(1. _d 0 - zbor) + ak1(i,j,bi,bj)
0126 & *(1. _d 0-zcar)
0127 za1 = ak1(i,j,bi,bj)*akb(i,j,bi,bj)*(1. _d 0 - zbor - zcar)
0128 & + ak1(i,j,bi,bj)*ak2(i,j,bi,bj)*(1. _d 0 - (zcar+zcar))
0129 za0 = ak1(i,j,bi,bj)*ak2(i,j,bi,bj)*akb(i,j,bi,bj)
0130 & *(1. _d 0 - zbor - (zcar+zcar))
0131
0132
0133 zd = za2*za2 - 3. _d 0*za1
0134
0135
0136
0137 IF(zd .GT. 0. _d 0) THEN
0138
0139 zsqrtd = SQRT(zd)
0140 IF(za2 .LT. 0) THEN
0141 zhmin = (-za2 + zsqrtd)/3. _d 0
0142 ELSE
0143 zhmin = -za1/(za2 + zsqrtd)
0144 ENDIF
0145 p_hini = zhmin + SQRT(-(za0 + zhmin*(za1 + zhmin*(za2 + zhmin)))
0146 & /zsqrtd)
0147 ELSE
0148 p_hini = 1. _d -7
0149 ENDIF
0150 ENDIF
0151
0152 #endif /* CARBONCHEM_SOLVESAPHE */
0153 RETURN
0154 END
0155
0156
0157
0158
0159 SUBROUTINE ANW_INFSUP(p_dictot, p_bortot,
0160 & p_po4tot, p_siltot,
0161 & p_nh4tot, p_h2stot,
0162 & p_so4tot, p_flutot,
0163 & p_alknw_inf, p_alknw_sup,
0164 & i, j, k, bi, bj, myIter,
0165 & myThid )
0166
0167
0168
0169
0170
0171 IMPLICIT NONE
0172
0173
0174 #include "SIZE.h"
0175 #include "EEPARAMS.h"
0176 #include "DIC_VARS.h"
0177
0178
0179
0180
0181
0182 _RL p_dictot
0183 _RL p_bortot
0184 _RL p_po4tot
0185 _RL p_siltot
0186 _RL p_nh4tot
0187 _RL p_h2stot
0188 _RL p_so4tot
0189 _RL p_flutot
0190 _RL p_alknw_inf
0191 _RL p_alknw_sup
0192 INTEGER i,j,k,bi,bj,myIter,myThid
0193
0194 #ifdef CARBONCHEM_SOLVESAPHE
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206 p_alknw_inf = -p_po4tot - p_so4tot - p_flutot
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219 p_alknw_sup = p_dictot + p_dictot + p_bortot
0220 & + p_po4tot + p_po4tot + p_siltot
0221 & + p_nh4tot + p_h2stot
0222
0223 #endif /* CARBONCHEM_SOLVESAPHE */
0224 RETURN
0225 END
0226
0227
0228
b5953f02df Jona*0229
6acab690ae Jona*0230 SUBROUTINE CALC_PCO2_SOLVESAPHE(
0231 I t,s,z_dictot,z_po4tot,z_siltot,z_alktot,
0232 U pHlocal,z_pco2,z_co3,
0233 I i,j,k,bi,bj,debugPrt,myIter,myThid )
0234
0235 IMPLICIT NONE
0236
0237
0238 #include "SIZE.h"
0239 #include "EEPARAMS.h"
0240 #include "DIC_VARS.h"
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
ba0b047096 Mart*0251
6acab690ae Jona*0252 _RL t, s, z_po4tot, z_siltot, z_alktot
0253 _RL z_pco2, z_dictot, pHlocal
0254 _RL z_co3
0255 INTEGER i,j,k,bi,bj
0256 LOGICAL debugPrt
0257 INTEGER myIter,myThid
0258
0259 #ifdef CARBONCHEM_SOLVESAPHE
0260
0261
0262 _RL z_h
0263 _RL z_hini
0264 _RL z_bortot
0265 _RL z_nh4tot
0266 _RL z_h2stot
0267 _RL z_so4tot
0268 _RL z_flutot
0269 _RL z_val
0270 _RL z_co2s
0271 _RL z_fco2
0272 _RL z_hco3
0273 _RL z_co2aq
0274 CHARACTER*(MAX_LEN_MBUF) msgBuf
0275
0276
0277
0278
0279
0280
0281
0282
0283 z_po4tot=z_po4tot*permil
0284 z_siltot=z_siltot*permil
0285 z_alktot=z_alktot*permil
0286 z_dictot=z_dictot*permil
0287
0288
0289 z_so4tot = st(i,j,bi,bj)
0290 z_flutot = ft(i,j,bi,bj)
0291 z_bortot = bt(i,j,bi,bj)
0292
0293 z_nh4tot = 0. _d 0
0294 z_h2stot = 0. _d 0
0295
0296 z_hini = 10. _d 0**(-1. _d 0 * pHlocal)
0297
0298 at_maxniter = 50
0299
0300 IF ( selectPHsolver.EQ.1 ) THEN
0301 #ifdef ALLOW_DEBUG
0302 IF (debugPrt) CALL DEBUG_CALL('SOLVE_AT_GENERAL',myThid)
0303 #endif
0304 CALL SOLVE_AT_GENERAL(z_alktot, z_dictot, z_bortot,
0305 & z_po4tot, z_siltot, z_nh4tot, z_h2stot,
0306 & z_so4tot, z_flutot, z_hini, z_val,
0307 & z_h,
0308 & i, j, k, bi, bj, debugPrt, myIter, myThid )
0309 ELSEIF ( selectPHsolver.EQ.2 ) THEN
0310 #ifdef ALLOW_DEBUG
0311 IF (debugPrt) CALL DEBUG_CALL('SOLVE_AT_GENERAL_SEC',myThid)
0312 #endif
0313 CALL SOLVE_AT_GENERAL_SEC(z_alktot, z_dictot, z_bortot,
0314 & z_po4tot, z_siltot, z_nh4tot, z_h2stot,
0315 & z_so4tot, z_flutot, z_hini, z_val,
0316 & z_h,
0317 & i, j, k, bi, bj, debugPrt, myIter, myThid )
0318 ELSEIF ( selectPHsolver.EQ.3 ) THEN
0319 #ifdef ALLOW_DEBUG
0320 IF (debugPrt) CALL DEBUG_CALL('SOLVE_AT_FAST',myThid)
0321 #endif
0322 CALL SOLVE_AT_FAST(z_alktot, z_dictot, z_bortot,
0323 & z_po4tot, z_siltot, z_nh4tot, z_h2stot,
0324 & z_so4tot, z_flutot, z_hini, z_val,
0325 & z_h,
0326 & i, j, k, bi, bj, debugPrt, myIter, myThid )
0327 ENDIF
0328
0329
0330 IF ( z_h .LT. 0. _d 0 ) THEN
0331 WRITE(msgBuf,'(A,A,A)')
0332 & 'S/R CALC_PCO2_SOLVESAPHE:',
0333 & ' H+ ion concentration less than 0',
0334 & ' Divergence or too many iterations'
0335 CALL PRINT_ERROR( msgBuf, myThid )
0336 STOP 'ABNORMAL END: S/R CALC_PCO2_SOLVESAPHE'
0337 ENDIF
0338
0339
0340 phlocal = -log10(z_h)
0341
0342
0343 z_co2s = z_dictot/
0344 & (1.0 _d 0 + (ak1(i,j,bi,bj)/z_h)
0345 & + (ak1(i,j,bi,bj)*ak2(i,j,bi,bj)/(z_h*z_h)))
0346
0347
0348 z_hco3 = ak1(i,j,bi,bj)*z_dictot /
0349 & (z_h*z_h + ak1(i,j,bi,bj)*z_h
0350 & + ak1(i,j,bi,bj)*ak2(i,j,bi,bj))
0351 z_co3 = ak1(i,j,bi,bj)*ak2(i,j,bi,bj)*z_dictot /
0352 & (z_h*z_h + ak1(i,j,bi,bj)*z_h
0353 & + ak1(i,j,bi,bj)*ak2(i,j,bi,bj))
0354
0355
0356
0357 #ifdef WATERVAP_BUG
0358 z_pco2 = z_co2s/ff(i,j,bi,bj)
0359 #else
0360
0361 z_fco2 = z_co2s/ak0(i,j,bi,bj)
0362 z_pco2 = z_fco2/fugf(i,j,bi,bj)
0363 #endif
0364
0365
0366
0367 z_po4tot = z_po4tot/permil
0368 z_siltot = z_siltot/permil
0369 z_alktot = z_alktot/permil
0370 z_dictot = z_dictot/permil
0371 z_hco3 = z_hco3/permil
0372 z_co3 = z_co3/permil
0373 z_co2aq = z_co2s/permil
0374
0375 #endif /* CARBONCHEM_SOLVESAPHE */
0376 RETURN
0377 END
0378
0379
0380
0381
0382 SUBROUTINE DIC_COEFFS_SURF(
0383 & ttemp,stemp,
0384 & bi,bj,iMin,iMax,jMin,jMax,myThid)
0385
0386
0387
0388
0389 IMPLICIT NONE
0390
0391
0392 #include "SIZE.h"
0393 #include "EEPARAMS.h"
0394 #include "PARAMS.h"
0395 #include "GRID.h"
0396 #include "DIC_VARS.h"
0397
0398 _RL ttemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0399 _RL stemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0400 INTEGER bi,bj,iMin,iMax,jMin,jMax,myThid
0401
0402 #ifdef CARBONCHEM_SOLVESAPHE
0403
0404
0405 INTEGER i, j
0406 _RL t
0407 _RL s
0408 _RL t_k
0409 _RL t_k_o_100
0410 _RL t_k_o_100_2
0411 _RL dlog_t_k
a2c35952f2 Jona*0412 _RL dlog10_t_k
6acab690ae Jona*0413 _RL inv_t_k
0414 _RL ion_st, is_2, sqrtis
0415 _RL s_2, sqrts, s_15, scl, s35
0416 _RL log_fw2sw
0417 _RL B, B1
0418 _RL delta
0419 _RL P1atm
0420 _RL RT
0421 _RL Rgas
0422
0423 _RL total2free
8d230ec051 Jona*0424 _RL free2total
6acab690ae Jona*0425 _RL free2sw
8d230ec051 Jona*0426 _RL sw2free
6acab690ae Jona*0427 _RL total2sw
8d230ec051 Jona*0428 _RL sw2total
92031a2908 Jean*0429
6acab690ae Jona*0430 do i=imin,imax
0431 do j=jmin,jmax
0432 if (hFacC(i,j,1,bi,bj).gt.0. _d 0) then
0433 t = ttemp(i,j)
0434 s = stemp(i,j)
0435
0436
0437 t_k = 273.15 _d 0 + t
0438 t_k_o_100 = t_k/100. _d 0
0439 t_k_o_100_2 = t_k_o_100*t_k_o_100
0440 inv_t_k=1.0 _d 0/t_k
a2c35952f2 Jona*0441 dlog_t_k = LOG(t_k)
0442 dlog10_t_k = LOG10(t_k)
6acab690ae Jona*0443
0444 ion_st=19.924 _d 0*s/(1000. _d 0-1.005 _d 0*s)
0445 is_2=ion_st*ion_st
0446 sqrtis=sqrt(ion_st)
0447
0448 s_2 = s*s
0449 sqrts=sqrt(s)
0450 s_15 = s*sqrts
0451 scl = s/1.80655 _d 0
0452 s35 = s/35. _d 0
0453
0454 log_fw2sw = LOG( 1. _d 0 - 0.001005 _d 0*s )
0455
0456 IF ( selectBTconst.EQ.1 ) THEN
0457
0458
0459
0460
0461
0462
0463 bt(i,j,bi,bj) = 0.000232 _d 0* scl/10.811 _d 0
0464 ELSEIF ( selectBTconst.EQ.2 ) THEN
0465
0466
0467
0468
0469
0470 bt(i,j,bi,bj) = 0.0002414 _d 0* scl/10.811 _d 0
0471 ENDIF
0472
0473 IF ( selectFTconst.EQ.1 ) THEN
0474
0475
0476
0477
0478
0479 ft(i,j,bi,bj) = 0.000067 _d 0 * scl/18.9984 _d 0
0480 ELSEIF ( selectFTconst.EQ.2 ) THEN
0481
0482
0483
0484
0485
0486 ft(i,j,bi,bj) = 0.000068 _d 0*(s35)
0487 ENDIF
0488
0489
0490
0491
0492
0493
0494 st(i,j,bi,bj) = 0.14 _d 0 * scl/96.062 _d 0
0495
0496
0497
0498
0499
0500
0501 cat(i,j,bi,bj) = 0.010282 _d 0*(s35)
0502
0503
0504
0505
0506
0507
0508 ak0(i,j,bi,bj) = EXP( 93.4517 _d 0/t_k_o_100 - 60.2409 _d 0
0509 & + 23.3585 _d 0*LOG(t_k_o_100)
0510 & + s * (0.023517 _d 0 - 0.023656 _d 0*t_k_o_100
0511 & + 0.0047036 _d 0*t_k_o_100_2))
0512
0513
0514
0515
0516
0517
0518 ff(i,j,bi,bj) = exp(-162.8301 _d 0 + 218.2968 _d 0/t_k_o_100
0519 & + 90.9241 _d 0*log(t_k_o_100) - 1.47696 _d 0*t_k_o_100_2
0520 & + s * (.025695 _d 0 - .025225 _d 0*t_k_o_100
0521 & + 0.0049867 _d 0*t_k_o_100_2))
0522
0523
0524
0525
0526
0527 P1atm = 1.01325 _d 0
0528 Rgas = 83.1451 _d 0
0529 RT = Rgas*t_k
0530 delta = (57.7 _d 0 - 0.118 _d 0*t_k)
92031a2908 Jean*0531 B1 = -1636.75 _d 0 + 12.0408 _d 0*t_k
791313b485 Jona*0532 & - 0.0327957 _d 0*t_k*t_k
6acab690ae Jona*0533 B = B1 + 3.16528 _d 0*t_k*t_k*t_k*(0.00001 _d 0)
0534
0535
0536
0537 fugf(i,j,bi,bj) = exp( (B+2. _d 0*delta) * P1atm / RT)
0538
0539 IF ( selectK1K2const.EQ.1 ) THEN
0540
0541
0542
0543
0544
0545
0546 ak1(i,j,bi,bj)=10.**(-1. _d 0*(3670.7 _d 0*inv_t_k
0547 & - 62.008 _d 0 + 9.7944 _d 0*dlog_t_k
0548 & - 0.0118 _d 0 * s + 0.000116 _d 0*s_2))
0549
0550
0551
0552
0553
0554
0555 ak2(i,j,bi,bj)=10.**(-1. _d 0*(1394.7 _d 0*inv_t_k
0556 & + 4.777 _d 0 - 0.0184 _d 0*s + 0.000118 _d 0*s_2))
0557
0558 ELSEIF ( selectK1K2const.EQ.2 ) THEN
0559
0560
0561
0562
0563
0564
0565 ak1(i,j,bi,bj) = EXP(-2307.1255 _d 0*inv_t_k + 2.83655 _d 0
0566 & - 1.5529413 _d 0*dlog_t_k
0567 & + (-4.0484 _d 0*inv_t_k - 0.20760841)*sqrts
0568 & + 0.08468345*s
0569 & - 0.00654208*s_15
0570 & + log_fw2sw )
0571
0572
0573
0574
0575
0576
0577 ak2(i,j,bi,bj) = EXP(-3351.6106 _d 0*inv_t_k - 9.226508 _d 0
0578 & - 0.2005743 _d 0*dlog_t_k
0579 & + ( -23.9722 _d 0*inv_t_k - 0.106901773 _d 0)*sqrts
0580 & + 0.1130822*s - 0.00846934 _d 0*s_15
0581 & + log_fw2sw )
0582
0583 ELSEIF ( selectK1K2const.EQ.3 ) THEN
0584
0585
0586
0587
0588
0589 ak1(i,j,bi,bj) = EXP(2.18867 _d 0 - 2275.0360 _d 0*inv_t_k
0590 & - 1.468591 _d 0*dlog_t_k
0591 & + ( -0.138681 _d 0 - 9.33291 _d 0*inv_t_k)*sqrts
0592 & + 0.0726483 _d 0*s - 0.00574938 _d 0*s_15)
0593
0594
0595
0596
0597
0598 ak2(i,j,bi,bj) = EXP(-0.84226 _d 0 - 3741.1288 _d 0*inv_t_k
0599 & - 1.437139 _d 0*dlog_t_k
0600 & + (-0.128417 _d 0 - 24.41239 _d 0*inv_t_k)*sqrts
0601 & + 0.1195308 _d 0*s - 0.00912840 _d 0*s_15)
0602
0603 ELSEIF ( selectK1K2const.EQ.4 ) THEN
0604
0605
0606
0607
0608
0609
0610 ak1(i,j,bi,bj) = 10. _d 0**( 61.2172 _d 0
0611 & - 3633.86 _d 0*inv_t_k - 9.67770 _d 0*dlog_t_k
0612 & + s*(0.011555 - s*0.0001152 _d 0))
0613
0614
0615
0616
0617
0618
0619 ak2(i,j,bi,bj) = 10. _d 0**(-25.9290 _d 0
0620 & - 471.78 _d 0*inv_t_k + 3.16967 _d 0*dlog_t_k
0621 & + s*(0.01781 _d 0 - s*0.0001122 _d 0))
0622
0623 ELSEIF ( selectK1K2const.EQ.5 ) THEN
0624
0625
0626
0627
0628
0629
0630
0631 ak1(i,j,bi,bj) = 10.0 _d 0**(-1*(6320.813 _d 0*inv_t_k
0632 & + 19.568224 _d 0*dlog_t_k -126.34048 _d 0
0633 & + 13.4038 _d 0*sqrts + 0.03206 _d 0*s - (5.242 _d -5)*s_2
0634 & + (-530.659 _d 0*sqrts - 5.8210 _d 0*s)*inv_t_k
0635 & -2.0664 _d 0*sqrts*dlog_t_k))
0636
0637
0638
0639
0640
0641
0642
0643 ak2(i,j,bi,bj) = 10.0 _d 0**(-1*(5143.692 _d 0*inv_t_k
0644 & + 14.613358 _d 0*dlog_t_k -90.18333 _d 0
0645 & + 21.3728 _d 0*sqrts + 0.1218 _d 0*s - (3.688 _d -4)*s_2
0646 & + (-788.289 _d 0*sqrts - 19.189 _d 0*s)*inv_t_k
0647 & -3.374 _d 0*sqrts*dlog_t_k))
0648
0649 ELSEIF ( selectK1K2const.EQ.6 ) THEN
0650
0651
0652
0653
0654
0655
0656
0657 ak1(i,j,bi,bj) = 10.0 _d 0**(-1.*(6320.813 _d 0*inv_t_k
0658 & + 19.568224 _d 0*dlog_t_k -126.34048 _d 0
0659 & + 13.409160 _d 0*sqrts + 0.031646 _d 0*s - (5.1895 _d -5)*s_2
0660 & + (-531.3642 _d 0*sqrts - 5.713 _d 0*s)*inv_t_k
0661 & -2.0669166 _d 0*sqrts*dlog_t_k))
0662
0663
0664
0665
0666
0667
0668
0669 ak2(i,j,bi,bj) = 10.0 _d 0**(-1.*
0670 & ( 5143.692 _d 0*inv_t_k + 14.613358 _d 0*dlog_t_k
0671 & - 90.18333 _d 0 + 21.225890 _d 0*sqrts + 0.12450870 _d 0*s
0672 & - (3.7243 _d -4)*s_2
0673 & + (-779.3444 _d 0*sqrts - 19.91739 _d 0*s)*inv_t_k
0674 & - 3.3534679 _d 0*sqrts*dlog_t_k ) )
0675
0676 ENDIF /* selectK1K2const */
0677
0678
0679
0680
0681
0682
0683 akb(i,j,bi,bj) = EXP(( -8966.90 _d 0 - 2890.53 _d 0*sqrts
0684 & -77.942 _d 0*s + 1.728 _d 0*s_15 - 0.0996 _d 0*s_2 )*inv_t_k
0685 & + (148.0248 _d 0 + 137.1942 _d 0*sqrts + 1.62142 _d 0*s)
0686 & + (-24.4344 _d 0 - 25.085 _d 0*sqrts - 0.2474 _d 0*s)*
0687 & dlog_t_k + 0.053105 _d 0*sqrts*t_k )
0688
0689
0690
0691
0692
0693
0694 ak1p(i,j,bi,bj) = EXP(115.54 _d 0
0695 & - 4576.752 _d 0*inv_t_k - 18.453 _d 0*dlog_t_k
0696 & + ( 0.69171 _d 0 - 106.736 _d 0*inv_t_k)*sqrts
0697 & + (-0.01844 _d 0 - 0.65643 _d 0*inv_t_k)*s)
0698
0699
0700
0701
0702
0703
0704 ak2p(i,j,bi,bj) = EXP( 172.1033 _d 0
0705 & - 8814.715 _d 0*inv_t_k
0706 & - 27.927 _d 0*dlog_t_k
0707 & + ( 1.3566 _d 0 - 160.340 _d 0*inv_t_k)*sqrts
0708 & + (-0.05778 _d 0 + 0.37335 _d 0*inv_t_k)*s)
0709
0710
0711
0712
0713
0714
0715 ak3p(i,j,bi,bj) = EXP(-18.126 _d 0 - 3070.75 _d 0*inv_t_k
0716 & + ( 2.81197 _d 0 + 17.27039 _d 0*inv_t_k)*sqrts
0717 & + (-0.09984 _d 0 - 44.99486 _d 0*inv_t_k)*s)
0718
0719
0720
0721
0722
0723
0724
0725 aksi(i,j,bi,bj) = EXP(
0726 & 117.40 _d 0 - 8904.2 _d 0*inv_t_k
0727 & - 19.334 _d 0 * dlog_t_k
0728 & + ( 3.5913 _d 0 - 458.79 _d 0*inv_t_k) * sqrtis
0729 & + (-1.5998 _d 0 + 188.74 _d 0*inv_t_k) * ion_st
0730 & + (0.07871 _d 0 - 12.1652 _d 0*inv_t_k) * ion_st*ion_st
0731 & + log_fw2sw )
0732
0733
0734
0735
0736
0737
0738 akn(i,j,bi,bj) = EXP(-0.25444 _d 0 - 6285.33 _d 0*inv_t_k
0739 & + 0.0001635 _d 0 * t_k
0740 & + ( 0.46532 _d 0 - 123.7184 _d 0*inv_t_k)*sqrts
0741 & + (-0.01992 _d 0 + 3.17556 _d 0*inv_t_k)*s)
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753 akhs(i,j,bi,bj) = EXP( 225.838 _d 0 - 13275.3 _d 0*inv_t_k
0754 & - 34.6435 _d 0 * dlog_t_k
0755 & + 0.3449 _d 0*sqrts - 0.0274 _d 0*s)
0756
0757
0758
0759
0760
0761
0762 aks(i,j,bi,bj) = EXP(141.328 _d 0
0763 & - 4276.1 _d 0*inv_t_k - 23.093 _d 0*dlog_t_k
0764 & + ( 324.57 _d 0 - 13856. _d 0*inv_t_k
0765 & - 47.986 _d 0*dlog_t_k) * sqrtis
0766 & + (-771.54 _d 0 + 35474. _d 0*inv_t_k
0767 & + 114.723 _d 0*dlog_t_k) * ion_st
0768 & - 2698. _d 0*inv_t_k*ion_st**1.5 _d 0
0769 & + 1776. _d 0*inv_t_k*ion_st*ion_st
0770 & + log_fw2sw )
0771
0772 IF ( selectHFconst.EQ.1 ) THEN
0773
0774
0775
0776
0777
0778
0779
0780 akf(i,j,bi,bj) = EXP(1590.2 _d 0*inv_t_k - 12.641 _d 0
0781 & + 1.525 _d 0*sqrtis
0782 & + log_fw2sw )
0783 ELSEIF ( selectHFconst.EQ.2 ) THEN
0784
0785
0786
0787
0788
0789 akf(i,j,bi,bj) = EXP( 874. _d 0*inv_t_k - 9.68 _d 0
0790 & + 0.111 _d 0*sqrts )
0791 ENDIF
0792
0793
0794
0795
0796
0797 akw(i,j,bi,bj) = EXP(148.9802 _d 0 - 13847.26 _d 0*inv_t_k
0798 & - 23.6521 _d 0*dlog_t_k
0799 & + (-5.977 _d 0 + 118.67 _d 0*inv_t_k
0800 & + 1.0495 _d 0*dlog_t_k)*sqrts
0801 & - 0.01615 _d 0*s )
0802
0803
0804
0805 total2free = 1. _d 0/
0806 & (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
0807
92031a2908 Jean*0808 free2total = (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
8d230ec051 Jona*0809
6acab690ae Jona*0810 free2sw = 1. _d 0
0811 & + (st(i,j,bi,bj)/ aks(i,j,bi,bj))
0812 & + (ft(i,j,bi,bj)/(akf(i,j,bi,bj)*total2free))
0813
8d230ec051 Jona*0814 sw2free = 1. _d 0 / free2sw
92031a2908 Jean*0815
6acab690ae Jona*0816 total2sw = total2free * free2sw
0817
8d230ec051 Jona*0818 sw2total = 1. _d 0 / total2sw
0819
6acab690ae Jona*0820 aphscale(i,j,bi,bj) = 1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj)
0821
0822 IF ( selectK1K2const.NE.2 .AND. selectK1K2const.NE.4 ) THEN
0823
8d230ec051 Jona*0824 ak1(i,j,bi,bj) = ak1(i,j,bi,bj)*sw2total
0825 ak2(i,j,bi,bj) = ak2(i,j,bi,bj)*sw2total
6acab690ae Jona*0826 ENDIF
8d230ec051 Jona*0827 ak1p(i,j,bi,bj) = ak1p(i,j,bi,bj)*sw2total
0828 ak2p(i,j,bi,bj) = ak2p(i,j,bi,bj)*sw2total
0829 ak3p(i,j,bi,bj) = ak3p(i,j,bi,bj)*sw2total
0830 aksi(i,j,bi,bj) = aksi(i,j,bi,bj)*sw2total
0831 akn (i,j,bi,bj) = akn (i,j,bi,bj)*sw2total
0832 akhs(i,j,bi,bj) = akhs(i,j,bi,bj)*sw2total
0833 aks (i,j,bi,bj) = aks (i,j,bi,bj)*free2total
6acab690ae Jona*0834 IF ( selectHFconst.EQ.1 ) THEN
8d230ec051 Jona*0835 akf (i,j,bi,bj) = akf (i,j,bi,bj)*free2total
6acab690ae Jona*0836 ENDIF
8d230ec051 Jona*0837 akw (i,j,bi,bj) = akw (i,j,bi,bj)*sw2total
6acab690ae Jona*0838
0839
0840
0841
0842
0843
0844
0845
0846 Ksp_TP_Calc(i,j,bi,bj) = 10. _d 0**(-171.9065 _d 0
0847 & - 0.077993 _d 0*t_k
a2c35952f2 Jona*0848 & + 2839.319 _d 0*inv_t_k + 71.595 _d 0*dlog10_t_k
6acab690ae Jona*0849 & + ( -0.77712 _d 0 + 0.0028426 _d 0*t_k
0850 & + 178.34 _d 0*inv_t_k)*sqrts
0851 & - 0.07711 _d 0*s + 0.0041249 _d 0*s_15)
0852
0853
0854
0855
0856
0857
0858
0859
0860 Ksp_TP_Arag(i,j,bi,bj) = 10. _d 0**(-171.945 _d 0
0861 & - 0.077993 _d 0*t_k
a2c35952f2 Jona*0862 & + 2903.293 _d 0*inv_t_k + 71.595 _d 0*dlog10_t_k
6acab690ae Jona*0863 & + ( -0.068393 _d 0 + 0.0017276 _d 0*t_k
0864 & + 88.135 _d 0*inv_t_k)*sqrts
0865 & - 0.10018 _d 0*s + 0.0059415 _d 0*s_15)
0866 else
0867 bt(i,j,bi,bj) = 0. _d 0
0868 st(i,j,bi,bj) = 0. _d 0
0869 ft(i,j,bi,bj) = 0. _d 0
0870 cat(i,j,bi,bj) = 0. _d 0
0871 fugf(i,j,bi,bj)= 0. _d 0
0872 ff(i,j,bi,bj) = 0. _d 0
0873 ak0(i,j,bi,bj) = 0. _d 0
0874 ak1(i,j,bi,bj) = 0. _d 0
0875 ak2(i,j,bi,bj) = 0. _d 0
0876 akb(i,j,bi,bj) = 0. _d 0
0877 ak1p(i,j,bi,bj)= 0. _d 0
0878 ak2p(i,j,bi,bj)= 0. _d 0
0879 ak3p(i,j,bi,bj)= 0. _d 0
0880 aksi(i,j,bi,bj)= 0. _d 0
0881 akw(i,j,bi,bj) = 0. _d 0
0882 aks(i,j,bi,bj) = 0. _d 0
0883 akf(i,j,bi,bj) = 0. _d 0
0884 akn(i,j,bi,bj) = 0. _d 0
0885 akhs(i,j,bi,bj)= 0. _d 0
0886 Ksp_TP_Calc(i,j,bi,bj) = 0. _d 0
0887 Ksp_TP_Arag(i,j,bi,bj) = 0. _d 0
0888 aphscale(i,j,bi,bj) = 0. _d 0
0889 endif
0890 end do
0891 end do
0892 #endif /* CARBONCHEM_SOLVESAPHE */
0893 RETURN
0894 END
0895
0896
0897
0898
0899 SUBROUTINE DIC_COEFFS_DEEP(
0900 & ttemp,stemp,
0901 & bi,bj,iMin,iMax,jMin,jMax,
0902 & Klevel,myThid)
0903
0904
0905
0906
0907 IMPLICIT NONE
0908
0909
0910 #include "SIZE.h"
0911 #include "EEPARAMS.h"
0912 #include "PARAMS.h"
0913 #include "GRID.h"
0914 #include "DIC_VARS.h"
0915
0916 _RL ttemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0917 _RL stemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0918 INTEGER bi,bj,iMin,iMax,jMin,jMax,Klevel,myThid
0919
0920 #ifdef CARBONCHEM_SOLVESAPHE
0921
0922 INTEGER i, j, k
0923 _RL bdepth
0924 _RL cdepth
0925 _RL pressc
0926 _RL t
0927 _RL s
0928 _RL zds
0929 _RL t_k
0930 _RL t_k_o_100
0931 _RL t_k_o_100_2
0932 _RL dlog_t_k
0933 _RL sqrtis
0934 _RL sqrts
0935 _RL s_2
0936 _RL s_15
0937 _RL inv_t_k
0938 _RL ion_st
0939 _RL is_2
0940 _RL scl
0941 _RL zrt
0942 _RL B1
0943 _RL B
0944 _RL delta
0945 _RL Pzatm
0946 _RL zdvi
0947 _RL zdki
0948 _RL pfac
0949
0950 _RL total2free_surf
0951 _RL free2sw_surf
0952 _RL total2sw_surf
0953 _RL total2free
8d230ec051 Jona*0954 _RL free2total
6acab690ae Jona*0955 _RL free2sw
8d230ec051 Jona*0956 _RL sw2free
6acab690ae Jona*0957 _RL total2sw
8d230ec051 Jona*0958 _RL sw2total
92031a2908 Jean*0959
6acab690ae Jona*0960
0961
0962
0963
0964
0965
0966
0967
0968 bdepth = 0. _d 0
0969 cdepth = 0. _d 0
0970 pressc = 1. _d 0
0971 do k = 1,Klevel
0972 cdepth = bdepth + 0.5 _d 0*drF(k)
0973 bdepth = bdepth + drF(k)
0974 pressc = 1. _d 0 + 0.1 _d 0*cdepth
0975 end do
0976
0977
0978
0979
0980 do i=imin,imax
0981 do j=jmin,jmax
0982 if (hFacC(i,j,Klevel,bi,bj).gt.0. _d 0) then
0983 t = ttemp(i,j)
0984 s = stemp(i,j)
0985
0986
0987 t_k = 273.15 _d 0 + t
0988 zrt= 83.14472 _d 0 * t_k
0989 t_k_o_100 = t_k/100. _d 0
0990 t_k_o_100_2=t_k_o_100*t_k_o_100
0991 inv_t_k=1.0 _d 0/t_k
0992 dlog_t_k=log(t_k)
0993
0994 ion_st=19.924 _d 0*s/(1000. _d 0-1.005 _d 0*s)
0995 is_2=ion_st*ion_st
0996 sqrtis=sqrt(ion_st)
0997
0998 s_2=s*s
0999 sqrts=sqrt(s)
1000 s_15=s**1.5 _d 0
1001 scl=s/1.80655 _d 0
1002 zds = s - 34.8 _d 0
1003
1004 total2free_surf = 1. _d 0/
1005 & (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
1006
1007 free2sw_surf = 1. _d 0
1008 & + st(i,j,bi,bj)/ aks(i,j,bi,bj)
1009 & + ft(i,j,bi,bj)/(akf(i,j,bi,bj)*total2free_surf)
1010
1011 total2sw_surf = total2free_surf * free2sw_surf
1012
1013
1014
1015
1016
1017
1018 Pzatm = 1.01325 _d 0+pressc
1019 delta = (57.7 _d 0 - 0.118 _d 0*t_k)
1020 B1 = -1636.75 _d 0 + 12.0408 _d 0*t_k -0.0327957 _d 0*t_k*t_k
1021 B = B1 + 3.16528 _d 0*t_k*t_k*t_k*(0.00001 _d 0)
1022
1023
1024 fugf(i,j,bi,bj) = exp( (B+2. _d 0*delta) * Pzatm / zrt)
1025
1026
1027
1028
1029 zdvi = -18.03 _d 0 + t*(0.0466 _d 0 + t*0.316 _d -3)
1030 zdki = ( -4.53 _d 0 + t*0.0900 _d 0)*1. _d -3
1031 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
1032 aks(i,j,bi,bj) = total2free_surf*aks(i,j,bi,bj) * exp(pfac)
1033
1034 total2free = 1. _d 0/
1035 & (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
92031a2908 Jean*1036
8d230ec051 Jona*1037 free2total = (1. _d 0 + st(i,j,bi,bj)/aks(i,j,bi,bj))
6acab690ae Jona*1038
1039
1040 free2sw = 1. _d 0
1041 & + st(i,j,bi,bj)/ aks(i,j,bi,bj)
92031a2908 Jean*1042
8d230ec051 Jona*1043 aks(i,j,bi,bj) = aks(i,j,bi,bj)*free2total
6acab690ae Jona*1044
1045
1046
1047
1048 zdvi = -9.78 _d 0 + t*(-0.0090 _d 0 - t*0.942 _d -3)
1049 zdki = ( -3.91 _d 0 + t*0.054 _d 0)*1. _d -3
1050 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
1051 akf(i,j,bi,bj) = total2free_surf*akf(i,j,bi,bj) * exp(pfac)
1052
b5953f02df Jona*1053
6acab690ae Jona*1054 free2sw = free2sw
1055 & + ft(i,j,bi,bj)/akf(i,j,bi,bj)
92031a2908 Jean*1056
8d230ec051 Jona*1057 sw2free = 1. _d 0 / free2sw
92031a2908 Jean*1058
6acab690ae Jona*1059 total2sw = total2free * free2sw
1060
92031a2908 Jean*1061 sw2total = 1. _d 0 / total2sw
8d230ec051 Jona*1062
1063 akf(i,j,bi,bj) = akf(i,j,bi,bj)*free2total
6acab690ae Jona*1064
1065
1066
1067
1068 zdvi = -25.50 _d 0 -0.151 _d 0*zds + 0.1271 _d 0*t
1069 zdki = ( -3.08 _d 0 -0.578 _d 0*zds + 0.0877 _d 0*t)*1. _d -3
1070 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1071 ak1(i,j,bi,bj) = (total2sw_surf*ak1(i,j,bi,bj)
8d230ec051 Jona*1072 & * exp(pfac))*sw2total
92031a2908 Jean*1073
6acab690ae Jona*1074
1075
1076
1077 zdvi = -15.82 _d 0 + 0.321 _d 0*zds - 0.0219 _d 0*t
1078 zdki = ( 1.13 _d 0 - 0.314 _d 0*zds - 0.1475 _d 0*t)*1. _d -3
1079 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1080 ak2(i,j,bi,bj) = (total2sw_surf*ak2(i,j,bi,bj)
8d230ec051 Jona*1081 & * exp(pfac))*sw2total
6acab690ae Jona*1082
1083
1084
1085
1086 zdvi = -29.48 _d 0 + 0.295 _d 0*zds + 0.1622 _d 0*t
1087 & - 0.002608 _d 0*t*t
1088 zdki = (-2.84 _d 0 + 0.354 _d 0*zds)*1. _d -3
1089 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1090 akb(i,j,bi,bj) = (total2sw_surf*akb(i,j,bi,bj)
8d230ec051 Jona*1091 & * exp(pfac))*sw2total
6acab690ae Jona*1092
1093
1094
1095
1096 zdvi = -20.02 _d 0 + 0.1119 _d 0*t - 0.1409 _d -2*t*t
1097 zdki = ( -5.13 _d 0 + 0.0794 _d 0*t)*1. _d -3
1098 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1099 akw(i,j,bi,bj) = (total2sw_surf*akw(i,j,bi,bj)
8d230ec051 Jona*1100 & * exp(pfac))*sw2total
6acab690ae Jona*1101
1102
1103
1104
1105
1106 zdvi = -14.51 _d 0 + 0.1211 _d 0*t - 0.321 _d -3*t*t
1107 zdki = ( -2.67 _d 0 + 0.0427 _d 0*t)*1. _d -3
1108 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1109 ak1p(i,j,bi,bj) = (total2sw_surf*ak1p(i,j,bi,bj)
8d230ec051 Jona*1110 & * exp(pfac))*sw2total
6acab690ae Jona*1111
1112
1113
1114
1115
1116 zdvi = -23.12 _d 0 + 0.1758 _d 0*t -2.647 _d -3*t*t
1117 zdki = ( -5.15 _d 0 + 0.09 _d 0*t)*1. _d -3
1118 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1119 ak2p(i,j,bi,bj) = (total2sw_surf*ak2p(i,j,bi,bj)
8d230ec051 Jona*1120 & * exp(pfac))*sw2total
6acab690ae Jona*1121
1122
1123
1124
1125
1126 zdvi = -26.57 _d 0 + 0.2020 _d 0*t -3.042 _d -3*t*t
1127 zdki = ( -4.08 _d 0 + 0.0714 _d 0*t)*1. _d -3
1128 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1129 ak3p(i,j,bi,bj) = (total2sw_surf*ak3p(i,j,bi,bj)
8d230ec051 Jona*1130 & * exp(pfac))*sw2total
6acab690ae Jona*1131
1132
1133
1134
1135
1136
1137 zdvi = -29.48 _d 0 + 0.295 _d 0*zds + 0.1622 _d 0*t
1138 & - 0.002608 _d 0*t*t
1139 zdki = (-2.84 _d 0 + 0.354 _d 0*zds)*1. _d -3
1140 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1141 aksi(i,j,bi,bj) = (total2sw_surf*aksi(i,j,bi,bj)
8d230ec051 Jona*1142 & * exp(pfac))*sw2total
6acab690ae Jona*1143
1144
1145
1146
1147
1148 zdvi = -14.80 _d 0 + t*(0.0020 _d 0 - t*0.400 _d -3)
1149 zdki = ( 2.89 _d 0 + t*0.054 _d 0)*1. _d -3
1150 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1151 akhs(i,j,bi,bj) = (total2sw_surf*akhs(i,j,bi,bj)
8d230ec051 Jona*1152 & * exp(pfac))*sw2total
6acab690ae Jona*1153
1154
1155
1156
1157
1158 zdvi = -26.43 _d 0 + t*(0.0889 _d 0 - t*0.905 _d -3)
1159 zdki = ( -5.03 _d 0 + t*0.0814 _d 0)*1. _d -3
1160 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
079499602a Jona*1161 akn(i,j,bi,bj) = (total2sw_surf*akn(i,j,bi,bj)
8d230ec051 Jona*1162 & * exp(pfac))*sw2total
6acab690ae Jona*1163
1164
1165
1166
1167
1168 zdvi = -48.76 _d 0 + 0.5304 _d 0*t
1169 zdki = (-11.76 _d 0 + 0.3692 _d 0*t)*1. _d -3
1170 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
1171 Ksp_TP_Calc(i,j,bi,bj) = Ksp_TP_Calc(i,j,bi,bj) * exp(pfac)
1172
1173
1174
1175
1176
1177 zdvi = -48.76 _d 0 + 0.5304 _d 0*t + 2.8 _d 0
1178 zdki = (-11.76 _d 0 + 0.3692 _d 0*t)*1. _d -3
1179 pfac = (-zdvi + zdki*pressc/2. _d 0)*pressc/zrt
1180 Ksp_TP_Arag(i,j,bi,bj) = Ksp_TP_Arag(i,j,bi,bj) * exp(pfac)
1181 else
1182 bt(i,j,bi,bj) = 0. _d 0
1183 st(i,j,bi,bj) = 0. _d 0
1184 ft(i,j,bi,bj) = 0. _d 0
1185 cat(i,j,bi,bj) = 0. _d 0
1186 fugf(i,j,bi,bj)= 0. _d 0
1187 ff(i,j,bi,bj) = 0. _d 0
1188 ak0(i,j,bi,bj) = 0. _d 0
1189 ak1(i,j,bi,bj) = 0. _d 0
1190 ak2(i,j,bi,bj) = 0. _d 0
1191 akb(i,j,bi,bj) = 0. _d 0
1192 ak1p(i,j,bi,bj)= 0. _d 0
1193 ak2p(i,j,bi,bj)= 0. _d 0
1194 ak3p(i,j,bi,bj)= 0. _d 0
1195 aksi(i,j,bi,bj)= 0. _d 0
1196 akw(i,j,bi,bj) = 0. _d 0
1197 aks(i,j,bi,bj) = 0. _d 0
1198 akf(i,j,bi,bj) = 0. _d 0
1199 akn(i,j,bi,bj) = 0. _d 0
1200 akhs(i,j,bi,bj)= 0. _d 0
1201 Ksp_TP_Calc(i,j,bi,bj) = 0. _d 0
1202 Ksp_TP_Arag(i,j,bi,bj) = 0. _d 0
1203 aphscale(i,j,bi,bj) = 0. _d 0
1204 endif
1205 enddo
1206 enddo
1207 #endif /* CARBONCHEM_SOLVESAPHE */
1208
1209 RETURN
1210 END
1211
1212
1213
1214
1215 SUBROUTINE EQUATION_AT(p_alktot, p_h, p_dictot,
1216 & p_bortot, p_po4tot, p_siltot,
1217 & p_nh4tot, p_h2stot, p_so4tot,
1218 & p_flutot, p_eqn , p_deriveqn,
1219 & i, j, k, bi, bj, myIter,
1220 & myThid )
1221
1222 IMPLICIT NONE
1223
1224
1225 #include "SIZE.h"
1226 #include "EEPARAMS.h"
1227 #include "DIC_VARS.h"
1228
1229
1230
1231
1232
1233 _RL p_alktot
1234 _RL p_h
1235 _RL p_dictot
1236 _RL p_bortot
1237 _RL p_po4tot
1238 _RL p_siltot
1239 _RL p_nh4tot
1240 _RL p_h2stot
1241 _RL p_so4tot
1242 _RL p_flutot
1243 _RL p_deriveqn
1244 _RL p_eqn
1245 INTEGER i,j,k,bi,bj,myIter,myThid
1246
1247 #ifdef CARBONCHEM_SOLVESAPHE
1248
1249
1250
1251
1252
1253 _RL znumer_dic, zdnumer_dic, zdenom_dic, zalk_dic, zdalk_dic
1254 _RL znumer_bor, zdnumer_bor, zdenom_bor, zalk_bor, zdalk_bor
1255 _RL znumer_po4, zdnumer_po4, zdenom_po4, zalk_po4, zdalk_po4
1256 _RL znumer_sil, zdnumer_sil, zdenom_sil, zalk_sil, zdalk_sil
1257 _RL znumer_nh4, zdnumer_nh4, zdenom_nh4, zalk_nh4, zdalk_nh4
1258 _RL znumer_h2s, zdnumer_h2s, zdenom_h2s, zalk_h2s, zdalk_h2s
1259 _RL znumer_so4, zdnumer_so4, zdenom_so4, zalk_so4, zdalk_so4
1260 _RL znumer_flu, zdnumer_flu, zdenom_flu, zalk_flu, zdalk_flu
1261 _RL zalk_wat
1262
1263
1264 znumer_dic = 2. _d 0*ak1(i,j,bi,bj)*ak2(i,j,bi,bj)
1265 & + p_h* ak1(i,j,bi,bj)
1266 zdenom_dic = ak1(i,j,bi,bj)*ak2(i,j,bi,bj)
1267 & + p_h*(ak1(i,j,bi,bj) + p_h)
1268 zalk_dic = p_dictot * (znumer_dic/zdenom_dic)
1269
1270
1271 znumer_bor = akb(i,j,bi,bj)
1272 zdenom_bor = akb(i,j,bi,bj) + p_h
1273 zalk_bor = p_bortot * (znumer_bor/zdenom_bor)
1274
1275
1276 znumer_po4 =
1277 & 3. _d 0*ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)*ak3p(i,j,bi,bj)
1278 & + p_h*(2. _d 0*ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1279 & + p_h*ak1p(i,j,bi,bj))
1280 zdenom_po4 = ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)*ak3p(i,j,bi,bj)
1281 & + p_h*(ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1282 & + p_h*(ak1p(i,j,bi,bj) + p_h))
1283 zalk_po4 = p_po4tot * (znumer_po4/zdenom_po4 - 1. _d 0)
1284
1285
1286
1287 znumer_sil = aksi(i,j,bi,bj)
1288 zdenom_sil = aksi(i,j,bi,bj) + p_h
1289 zalk_sil = p_siltot * (znumer_sil/zdenom_sil)
1290
1291
1292 znumer_nh4 = akn(i,j,bi,bj)
1293 zdenom_nh4 = akn(i,j,bi,bj) + p_h
1294 zalk_nh4 = p_nh4tot * (znumer_nh4/zdenom_nh4)
1295
1296
1297 znumer_h2s = akhs(i,j,bi,bj)
1298 zdenom_h2s = akhs(i,j,bi,bj) + p_h
1299 zalk_h2s = p_h2stot * (znumer_h2s/zdenom_h2s)
1300
1301
1302 znumer_so4 = aks(i,j,bi,bj)
1303 zdenom_so4 = aks(i,j,bi,bj) + p_h
1304 zalk_so4 = p_so4tot * (znumer_so4/zdenom_so4 - 1. _d 0)
1305
1306
1307 znumer_flu = akf(i,j,bi,bj)
1308 zdenom_flu = akf(i,j,bi,bj) + p_h
1309 zalk_flu = p_flutot * (znumer_flu/zdenom_flu - 1. _d 0)
1310
1311
1312 zalk_wat = akw(i,j,bi,bj)/p_h - p_h/aphscale(i,j,bi,bj)
1313
1314
1315
1316
1317 p_eqn = zalk_dic + zalk_bor + zalk_po4 + zalk_sil
1318 & + zalk_nh4 + zalk_h2s + zalk_so4 + zalk_flu
1319 & + zalk_wat - p_alktot
1320
1321
1322
1323
1324 zdnumer_dic = ak1(i,j,bi,bj)*ak1(i,j,bi,bj)*ak2(i,j,bi,bj)
1325 & + p_h*(4. _d 0*ak1(i,j,bi,bj)*ak2(i,j,bi,bj)
1326 & + p_h* ak1(i,j,bi,bj))
1327 zdalk_dic = -p_dictot*(zdnumer_dic/zdenom_dic**2)
1328
1329
1330 zdnumer_bor = akb(i,j,bi,bj)
1331 zdalk_bor = -p_bortot*(zdnumer_bor/zdenom_bor**2)
1332
1333
1334 zdnumer_po4 = ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1335 & *ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1336 & *ak3p(i,j,bi,bj)
1337 & + p_h*(4. _d 0*ak1p(i,j,bi,bj)*ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1338 & *ak3p(i,j,bi,bj)
1339 & + p_h*(9. _d 0*ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)*ak3p(i,j,bi,bj)
1340 & + ak1p(i,j,bi,bj)*ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1341 & + p_h*(4. _d 0*ak1p(i,j,bi,bj)*ak2p(i,j,bi,bj)
1342 & + p_h* ak1p(i,j,bi,bj))))
1343 zdalk_po4 = -p_po4tot * (zdnumer_po4/zdenom_po4**2)
1344
1345
1346 zdnumer_sil = aksi(i,j,bi,bj)
1347 zdalk_sil = -p_siltot * (zdnumer_sil/zdenom_sil**2)
1348
1349
1350 zdnumer_nh4 = akn(i,j,bi,bj)
1351 zdalk_nh4 = -p_nh4tot * (zdnumer_nh4/zdenom_nh4**2)
1352
1353
1354 zdnumer_h2s = akhs(i,j,bi,bj)
1355 zdalk_h2s = -p_h2stot * (zdnumer_h2s/zdenom_h2s**2)
1356
1357
1358 zdnumer_so4 = aks(i,j,bi,bj)
1359 zdalk_so4 = -p_so4tot * (zdnumer_so4/zdenom_so4**2)
1360
1361
1362 zdnumer_flu = akf(i,j,bi,bj)
1363 zdalk_flu = -p_flutot * (zdnumer_flu/zdenom_flu**2)
1364
1365 p_deriveqn = zdalk_dic + zdalk_bor + zdalk_po4 + zdalk_sil
1366 & + zdalk_nh4 + zdalk_h2s + zdalk_so4 + zdalk_flu
1367 & - akw(i,j,bi,bj)/p_h**2 - 1. _d 0/aphscale(i,j,bi,bj)
1368
1369
1370 #endif /* CARBONCHEM_SOLVESAPHE */
1371 RETURN
1372 END
1373
1374
1375
1376
1377 SUBROUTINE SOLVE_AT_FAST(p_alktot, p_dictot, p_bortot,
1378 & p_po4tot, p_siltot, p_nh4tot,
1379 & p_h2stot, p_so4tot, p_flutot,
1380 & p_hini, p_val, p_hnew,
1381 & i, j, k, bi, bj,
1382 & debugPrt, myIter, myThid )
1383
1384
1385
1386 IMPLICIT NONE
1387
1388
1389 #include "SIZE.h"
1390 #include "EEPARAMS.h"
1391 #include "DIC_VARS.h"
1392
1393
1394
1395
1396
1397
1398
1399 _RL p_alktot
1400 _RL p_dictot
1401 _RL p_bortot
1402 _RL p_po4tot
1403 _RL p_siltot
1404 _RL p_nh4tot
1405 _RL p_h2stot
1406 _RL p_so4tot
1407 _RL p_flutot
1408 _RL p_hini
1409 _RL p_val
1410 _RL p_hnew
1411 INTEGER i, j, k, bi, bj
1412 LOGICAL debugPrt
1413 INTEGER myIter, myThid
1414
1415 #ifdef CARBONCHEM_SOLVESAPHE
1416
1417
1418
1419
1420
1421 _RL zh_ini, zh, zh_prev, zh_lnfactor
1422 _RL zhdelta
1423 _RL zeqn, zdeqndh
1424
1425
1426 LOGICAL iterate4pH
1427 _RL pz_exp_threshold
1428 _RL pp_rdel_ah_target
1429 INTEGER niter_atfast
1430
1431 pp_rdel_ah_target = 1. _d -8
1432 pz_exp_threshold = 1.0 _d 0
1433
1434
1435
1436 zh_ini = p_hini
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449 zh = zh_ini
1450
1451 niter_atfast = 0
1452
1453 iterate4pH = .TRUE.
1454 DO WHILE ( iterate4pH )
1455
1456 niter_atfast = niter_atfast + 1
1457 IF ( niter_atfast .GT. at_maxniter ) THEN
1458 zh = -1. _d 0
1459 iterate4pH = .FALSE.
1460 ELSE
1461
1462 zh_prev = zh
1463
1464
1465
1466
1467
1468 CALL EQUATION_AT( p_alktot, zh , p_dictot, p_bortot,
1469 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1470 & p_so4tot, p_flutot,
1471 & zeqn , zdeqndh,
1472 & i, j, k, bi, bj, myIter, myThid )
1473
1474 iterate4pH = ( zeqn .NE. 0. _d 0 )
1475 ENDIF
1476
1477 IF ( iterate4pH ) THEN
1478 zh_lnfactor = -zeqn/(zdeqndh*zh_prev)
1479 IF(ABS(zh_lnfactor) .GT. pz_exp_threshold) THEN
1480 zh = zh_prev*EXP(zh_lnfactor)
1481 ELSE
1482 zhdelta = zh_lnfactor*zh_prev
1483 zh = zh_prev + zhdelta
1484 ENDIF
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505 iterate4pH = ( ABS(zh_lnfactor) .GE. pp_rdel_ah_target )
1506
1507 ENDIF
1508 ENDDO
1509
1510
1511 p_hnew = zh
1512
1513
1514 IF(zh .GT. 0. _d 0) THEN
1515
1516
1517
1518 CALL EQUATION_AT( p_alktot, zh, p_dictot, p_bortot,
1519 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1520 & p_so4tot, p_flutot,
1521 & p_val , zdeqndh,
1522 & i, j, k, bi, bj, myIter, myThid )
1523 ELSE
1524
1525 p_val = 1. _d +65
1526 ENDIF
1527
1528
1529 #endif /* CARBONCHEM_SOLVESAPHE */
1530 RETURN
1531 END
1532
1533
1534
1535
1536 SUBROUTINE SOLVE_AT_GENERAL(p_alktot, p_dictot, p_bortot,
1537 & p_po4tot, p_siltot, p_nh4tot,
1538 & p_h2stot, p_so4tot, p_flutot,
1539 & p_hini, p_val, p_hnew,
1540 & i, j, k, bi, bj,
1541 & debugPrt, myIter, myThid )
1542
1543
1544
1545 IMPLICIT NONE
1546
1547
1548 #include "SIZE.h"
1549 #include "EEPARAMS.h"
1550 #include "DIC_VARS.h"
1551
1552
1553
1554
1555
1556
1557
1558 _RL p_alktot
1559 _RL p_dictot
1560 _RL p_bortot
1561 _RL p_po4tot
1562 _RL p_siltot
1563 _RL p_nh4tot
1564 _RL p_h2stot
1565 _RL p_so4tot
1566 _RL p_flutot
1567 _RL p_hini
1568 _RL p_hnew
1569 _RL p_val
1570 INTEGER i, j, k, bi, bj
1571 LOGICAL debugPrt
1572 INTEGER myIter, myThid
1573
1574 #ifdef CARBONCHEM_SOLVESAPHE
1575
1576
1577
1578
1579
1580 _RL zh_ini, zh, zh_prev, zh_lnfactor
1581 _RL p_alknw_inf, p_alknw_sup
1582 _RL zh_min, zh_max
1583 _RL zdelta, zh_delta
1584 _RL zeqn, zdeqndh, zeqn_absmin
1585 INTEGER niter_atgen
1586
1587
1588 LOGICAL iterate4pH
1589 _RL pz_exp_threshold
1590 _RL pp_rdel_ah_target
1591
1592 pp_rdel_ah_target = 1. _d -8
1593 pz_exp_threshold = 1. _d 0
1594
1595
1596 zh_ini = p_hini
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606 #ifdef ALLOW_DEBUG
1607 IF (debugPrt) CALL DEBUG_CALL('ANW_INFSUP',myThid)
1608 #endif
1609 CALL ANW_INFSUP(p_dictot, p_bortot,
1610 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1611 & p_so4tot, p_flutot,
1612 & p_alknw_inf, p_alknw_sup,
1613 & i, j, k, bi, bj, myIter, myThid )
1614
1615 zdelta = (p_alktot-p_alknw_inf)**2 + 4. _d 0*akw(i,j,bi,bj)
1616 & /aphscale(i,j,bi,bj)
1617
1618 IF(p_alktot .GE. p_alknw_inf) THEN
1619 zh_min = 2. _d 0*akw(i,j,bi,bj) /( p_alktot-p_alknw_inf
1620 & + SQRT(zdelta) )
1621 ELSE
1622 zh_min = aphscale(i,j,bi,bj)*(-(p_alktot-p_alknw_inf)
1623 & + SQRT(zdelta) ) / 2. _d 0
1624 ENDIF
1625
1626 zdelta = (p_alktot-p_alknw_sup)**2 + 4. _d 0*akw(i,j,bi,bj)
1627 & /aphscale(i,j,bi,bj)
1628
1629 IF(p_alktot .LE. p_alknw_sup) THEN
1630 zh_max = aphscale(i,j,bi,bj)*(-(p_alktot-p_alknw_sup)
1631 & + SQRT(zdelta) ) / 2. _d 0
1632 ELSE
1633 zh_max = 2. _d 0*akw(i,j,bi,bj) /( p_alktot-p_alknw_sup
1634 & + SQRT(zdelta) )
1635 ENDIF
1636
1637
1638
1639
1640
1641
1642 zh = MAX(MIN(zh_max, zh_ini), zh_min)
1643
1644
1645
1646
1647 niter_atgen = 0
1648
1649 zeqn_absmin = 1. _d +65
1650
1651 iterate4pH = .TRUE.
1652 DO WHILE ( iterate4pH )
1653
1654 IF ( niter_atgen .GE. at_maxniter ) THEN
1655 zh = -1. _d 0
1656 iterate4pH = .FALSE.
1657 ELSE
1658
1659 zh_prev = zh
1660 #ifdef ALLOW_DEBUG
1661 IF (debugPrt) CALL DEBUG_CALL('EQUATION_AT',myThid)
1662 #endif
1663
1664
1665
1666 CALL EQUATION_AT( p_alktot, zh, p_dictot, p_bortot,
1667 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1668 & p_so4tot, p_flutot,
1669 & zeqn , zdeqndh,
1670 & i, j, k, bi, bj, myIter, myThid )
1671
1672
1673 IF(zeqn .GT. 0. _d 0) THEN
1674 zh_min = zh_prev
1675 ELSEIF(zeqn .LT. 0. _d 0) THEN
1676 zh_max = zh_prev
1677 ELSE
1678
1679 iterate4pH = .FALSE.
1680 ENDIF
1681 ENDIF
1682
1683 IF ( iterate4pH ) THEN
1684
1685 niter_atgen = niter_atgen + 1
1686
1687 IF(ABS(zeqn) .GE. 0.5 _d 0*zeqn_absmin) THEN
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697 zh = SQRT(zh_max * zh_min)
1698
1699 zh_lnfactor = (zh - zh_prev)/zh_prev
1700 ELSE
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712 zh_lnfactor = -zeqn/(zdeqndh*zh_prev)
1713
1714 IF(ABS(zh_lnfactor) .GT. pz_exp_threshold) THEN
1715 zh = zh_prev*EXP(zh_lnfactor)
1716 ELSE
1717 zh_delta = zh_lnfactor*zh_prev
1718 zh = zh_prev + zh_delta
1719 ENDIF
1720
1721
1722
1723
1724
1725 IF( zh .LT. zh_min ) THEN
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736 zh = SQRT(zh_prev * zh_min)
1737
1738 zh_lnfactor = (zh - zh_prev)/zh_prev
1739 ENDIF
1740
1741 IF( zh .GT. zh_max ) THEN
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752 zh = SQRT(zh_prev * zh_max)
1753
1754 zh_lnfactor = (zh - zh_prev)/zh_prev
1755
1756 ENDIF
1757 ENDIF
1758
1759 zeqn_absmin = MIN( ABS(zeqn), zeqn_absmin)
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774 iterate4pH = ( ABS(zh_lnfactor) .GE. pp_rdel_ah_target )
1775
1776 ENDIF
1777 ENDDO
1778
1779
1780 p_hnew = zh
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790 #ifdef ALLOW_DEBUG
1791 IF (debugPrt) CALL DEBUG_LEAVE('SOLVE_AT_GENERAL',myThid)
1792 #endif
1793 #endif /* CARBONCHEM_SOLVESAPHE */
1794 RETURN
1795 END
1796
1797
1798
1799
1800 SUBROUTINE SOLVE_AT_GENERAL_SEC(p_alktot, p_dictot,
1801 & p_bortot, p_po4tot,
1802 & p_siltot, p_nh4tot,
1803 & p_h2stot, p_so4tot,
1804 & p_flutot, p_hini,
1805 & p_val, p_hnew,
1806 & i, j, k, bi, bj,
1807 & debugPrt, myIter, myThid )
1808
1809
1810
1811 IMPLICIT NONE
1812
1813
1814 #include "SIZE.h"
1815 #include "EEPARAMS.h"
1816 #include "DIC_VARS.h"
1817
1818
1819
1820
1821
1822 _RL p_alktot
1823 _RL p_dictot
1824 _RL p_bortot
1825 _RL p_po4tot
1826 _RL p_siltot
1827 _RL p_nh4tot
1828 _RL p_h2stot
1829 _RL p_so4tot
1830 _RL p_flutot
1831 _RL p_hini
1832 _RL p_hnew
1833 _RL p_val
1834 INTEGER i, j, k, bi, bj
1835 LOGICAL debugPrt
1836 INTEGER myIter, myThid
1837
1838 #ifdef CARBONCHEM_SOLVESAPHE
1839
1840
1841
1842
1843
1844 _RL zh_ini, zh, zh_1, zh_2, zh_delta
1845 _RL p_alknw_inf, p_alknw_sup
1846 _RL zh_min, zh_max
1847 _RL zeqn, zeqn_1, zeqn_2, zeqn_absmin
1848 _RL zdelta, zdeqndh
1849 _RL pp_rdel_ah_target
1850 INTEGER niter_atsec
1851
1852 LOGICAL iterate4pH
1853
1854 pp_rdel_ah_target = 1. _d -8
1855
1856
1857 zh_ini = p_hini
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868 CALL ANW_INFSUP(p_dictot, p_bortot,
1869 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1870 & p_so4tot, p_flutot,
1871 & p_alknw_inf, p_alknw_sup,
1872 & i, j, k, bi, bj, myIter, myThid )
1873
1874 zdelta = (p_alktot-p_alknw_inf)**2 + 4. _d 0*akw(i,j,bi,bj)
1875 & /aphscale(i,j,bi,bj)
1876
1877 IF(p_alktot .GE. p_alknw_inf) THEN
1878 zh_min = 2. _d 0*akw(i,j,bi,bj) /( p_alktot-p_alknw_inf
1879 & + SQRT(zdelta) )
1880 ELSE
1881 zh_min = aphscale(i,j,bi,bj)*(-(p_alktot-p_alknw_inf)
1882 & + SQRT(zdelta) ) / 2. _d 0
1883 ENDIF
1884
1885 zdelta = (p_alktot-p_alknw_sup)**2 + 4. _d 0*akw(i,j,bi,bj)
1886 & /aphscale(i,j,bi,bj)
1887
1888 IF(p_alktot .LE. p_alknw_sup) THEN
1889 zh_max = aphscale(i,j,bi,bj)*(-(p_alktot-p_alknw_sup)
1890 & + SQRT(zdelta) ) / 2. _d 0
1891 ELSE
1892 zh_max = 2. _d 0*akw(i,j,bi,bj) /( p_alktot-p_alknw_sup
1893 & + SQRT(zdelta) )
1894 ENDIF
1895
1896
1897
1898
1899
1900
1901
1902 zh = MAX(MIN(zh_max, zh_ini), zh_min)
1903
1904
1905
1906 niter_atsec = 0
1907
1908
1909
1910
1911
1912
1913
1914
1915 zh_2 = zh
1916
1917
1918
1919 CALL EQUATION_AT( p_alktot, zh_2, p_dictot, p_bortot,
1920 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1921 & p_so4tot, p_flutot,
1922 & zeqn_2 , zdeqndh,
1923 & i, j, k, bi, bj, myIter, myThid )
1924
1925 zeqn_absmin = ABS(zeqn_2)
1926
1927
1928
1929 IF(zeqn_2 .LT. 0. _d 0) THEN
1930
1931
1932 zh_max = zh_2
1933
1934
1935
1936 zh_1 = MAX(zh_max/1.25 _d 0, SQRT(zh_min*zh_max))
1937
1938 ELSEIF(zeqn_2 .GT. 0. _d 0) THEN
1939
1940
1941 zh_min = zh_2
1942
1943
1944
1945 zh_1 = MIN(zh_min*1.25 _d 0, SQRT(zh_min*zh_max))
1946
1947 ELSE
1948
1949
1950 p_hnew = zh_2
1951
1952 p_val = zeqn_2
1953 RETURN
1954 ENDIF
1955
1956
1957
1958
1959
1960
1961 niter_atsec = 1
1962
1963
1964
1965
1966 CALL EQUATION_AT( p_alktot, zh_1, p_dictot, p_bortot,
1967 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
1968 & p_so4tot, p_flutot,
1969 & zeqn_1 , zdeqndh,
1970 & i, j, k, bi, bj, myIter, myThid )
1971
1972
1973
1974
1975 IF(zeqn_1 .GT. 0. _d 0) THEN
1976 zh_min = zh_1
1977 ELSEIF(zeqn_1 .LT. 0. _d 0) THEN
1978 zh_max = zh_1
1979 ELSE
1980
1981
1982 p_hnew = zh_1
1983
1984 p_val = zeqn_1
1985 ENDIF
1986
1987 IF(ABS(zeqn_1) .GT. zeqn_absmin) THEN
1988
1989
1990
1991 zh = zh_1
1992 zeqn = zeqn_1
1993 zh_1 = zh_2
1994 zeqn_1 = zeqn_2
1995 zh_2 = zh
1996 zeqn_2 = zeqn
1997 ELSE
1998 zeqn_absmin = ABS(zeqn_1)
1999 ENDIF
2000
2001
2002 niter_atsec = 2
2003
2004 zh_delta = -zeqn_1/((zeqn_2-zeqn_1)/(zh_2 - zh_1))
2005 zh = zh_1 + zh_delta
2006
2007
2008
2009
2010 IF (zh .GT. zh_max) THEN
2011
2012
2013 zh = SQRT(zh_1*zh_max)
2014 ENDIF
2015
2016 IF (zh .LT. zh_min) THEN
2017
2018
2019 zh = SQRT(zh_1*zh_min)
2020 ENDIF
2021
2022 iterate4pH = .TRUE.
2023 DO WHILE ( iterate4pH )
2024
2025 IF ( niter_atsec .GE. at_maxniter ) THEN
2026 zh = -1. _d 0
2027 iterate4pH = .FALSE.
2028 ELSE
2029
2030
2031
2032
2033 CALL EQUATION_AT( p_alktot, zh, p_dictot, p_bortot,
2034 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
2035 & p_so4tot, p_flutot,
2036 & zeqn , zdeqndh,
2037 & i, j, k, bi, bj, myIter, myThid )
2038
2039
2040
2041
2042 IF(zeqn .GT. 0. _d 0) THEN
2043 zh_min = zh
2044 ELSEIF(zeqn .LT. 0. _d 0) THEN
2045 zh_max = zh
2046 ELSE
2047
2048 iterate4pH = .FALSE.
2049 ENDIF
2050 ENDIF
2051
2052 IF ( iterate4pH ) THEN
2053
2054 niter_atsec = niter_atsec + 1
2055
2056 zh_2 = zh_1
2057 zeqn_2 = zeqn_1
2058 zh_1 = zh
2059 zeqn_1 = zeqn
2060
2061 IF(ABS(zeqn) .GE. 0.5 _d 0*zeqn_absmin) THEN
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072 zh = SQRT(zh_max * zh_min)
2073 zh_delta = zh - zh_1
2074 ELSE
2075
2076
2077 zh_delta = -zeqn_1/((zeqn_2-zeqn_1)/(zh_2 - zh_1))
2078 zh = zh_1 + zh_delta
2079
2080
2081
2082
2083 IF( zh .LT. zh_min ) THEN
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094 zh = SQRT(zh_1 * zh_min)
2095 zh_delta = zh - zh_1
2096 ENDIF
2097
2098 IF( zh .GT. zh_max ) THEN
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109 zh = SQRT(zh_1 * zh_max)
2110 zh_delta = zh - zh_1
2111 ENDIF
2112 ENDIF
2113
2114 zeqn_absmin = MIN(ABS(zeqn), zeqn_absmin)
2115
2116
2117
2118
2119 iterate4pH = ( ABS(zh_delta) .GE. pp_rdel_ah_target*zh_1 )
2120
2121 ENDIF
2122 ENDDO
2123
2124
2125 p_hnew = zh
2126
2127
2128 IF(zh .GT. 0. _d 0) THEN
2129
2130
2131
2132 CALL EQUATION_AT( p_alktot, zh, p_dictot, p_bortot,
2133 & p_po4tot, p_siltot, p_nh4tot, p_h2stot,
2134 & p_so4tot, p_flutot,
2135 & p_val , zdeqndh,
2136 & i, j, k, bi, bj, myIter, myThid )
2137 ELSE
2138
2139 p_val = 1. _d +65
2140 ENDIF
2141
2142
2143 #endif /* CARBONCHEM_SOLVESAPHE */
2144 RETURN
2145 END
2146
2147