Skip to content

Commit dace922

Browse files
WOMBAT: Precompute expensive terms in iron chemistry calculations (#64)
Co-authored-by: Manodeep Sinha <[email protected]>
1 parent 0e8fb6c commit dace922

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

generic_tracers/generic_WOMBATlite.F90

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,13 +2058,13 @@ subroutine generic_WOMBATlite_update_from_source(tracer_list, Temp, Salt, &
20582058
real :: pi = 3.14159265358979
20592059
integer :: ichl
20602060
real :: par_phy_mldsum, par_z_mldsum
2061-
real :: chl, zchl, zval, phy_chlc
2061+
real :: chl, zchl, zval, sqrt_zval, phy_chlc
20622062
real :: phy_pisl, phy_pisl2
20632063
real :: pchl_pisl, pchl_mumin, pchl_muopt
20642064
real, dimension(:,:), allocatable :: ek_bgr, par_bgr_mid, par_bgr_top
20652065
real, dimension(:), allocatable :: wsink, wsinkcal
20662066
real, dimension(4,61) :: zbgr
2067-
real :: ztemk, fe_keq, fe_par, fe_sfe, fe_tfe, partic
2067+
real :: ztemk, I_ztemk, fe_keq, fe_par, fe_sfe, fe_tfe, partic
20682068
real :: fesol1, fesol2, fesol3, fesol4, fesol5, hp, fe3sol
20692069
real :: biof, biodoc, zno3, zfermin
20702070
real :: phy_Fe2C, zoo_Fe2C, det_Fe2C
@@ -2670,24 +2670,29 @@ subroutine generic_WOMBATlite_update_from_source(tracer_list, Temp, Salt, &
26702670

26712671
! Estimate solubility of Fe3+ (free Fe) in solution using temperature, pH and salinity
26722672
ztemk = max(5.0, Temp(i,j,k)) + 273.15 ! temperature in kelvin
2673+
I_ztemk = 1.0 / ztemk
26732674
zval = 19.924 * Salt(i,j,k) / ( 1000. - 1.005 * Salt(i,j,k))
2674-
fesol1 = 10**(-13.486 - 0.1856*zval**0.5 + 0.3073*zval + 5254.0/ztemk)
2675-
fesol2 = 10**(2.517 - 0.8885*zval**0.5 + 0.2139*zval - 1320.0/ztemk)
2676-
fesol3 = 10**(0.4511 - 0.3305*zval**0.5 - 1996.0/ztemk)
2677-
fesol4 = 10**(-0.2965 - 0.7881*zval**0.5 - 4086.0/ztemk)
2678-
fesol5 = 10**(4.4466 - 0.8505*zval**0.5 - 7980.0/ztemk)
2679-
hp = 10**(-7.9)
2680-
if (wombat%htotal(i,j,k).gt.0.0) hp = wombat%htotal(i,j,k)
2681-
fe3sol = fesol1 * ( hp**3 + fesol2 * hp**2 + fesol3 * hp + fesol4 + fesol5 / hp ) *1e9
2675+
sqrt_zval = sqrt(zval)
2676+
fesol1 = 10.0**(-13.486 - 0.1856*sqrt_zval + 0.3073*zval + 5254.0*I_ztemk)
2677+
fesol2 = 10.0**(2.517 - 0.8885*sqrt_zval + 0.2139*zval - 1320.0*I_ztemk)
2678+
fesol3 = 10.0**(0.4511 - 0.3305*sqrt_zval - 1996.0*I_ztemk)
2679+
fesol4 = 10.0**(-0.2965 - 0.7881*sqrt_zval - 4086.0*I_ztemk)
2680+
fesol5 = 10.0**(4.4466 - 0.8505*sqrt_zval - 7980.0*I_ztemk)
2681+
if (wombat%htotal(i,j,k).gt.0.0) then
2682+
hp = wombat%htotal(i,j,k)
2683+
else
2684+
hp = 1.25893e-08 ! dts: =10.0**(-7.9)
2685+
endif
2686+
fe3sol = fesol1 * ( hp*hp*hp + fesol2*hp*hp + fesol3*hp + fesol4 + fesol5/hp ) *1e9
26822687

26832688
! Estimate total colloidal iron
26842689
! ... for now, we assume that 50% of all dFe is colloidal, and we separate this from the
26852690
! equilibrium fractionation between Fe' and Fe-L below
26862691
wombat%fecol(i,j,k) = wombat%fcolloid * biofer
26872692

26882693
! Determine equilibriuim fractionation of the remain dFe (non-colloidal fraction) into Fe' and L-Fe
2689-
fe_keq = 10**( 17.27 - 1565.7 / ztemk ) * 1e-9 ! Temperature reduces solubility
2690-
fe_par = 4.77e-7 * wombat%radbio(i,j,k) * 0.5 / 10**(-6.3) ! Light increases solubility
2694+
fe_keq = 10.0**( 17.27 - 1565.7 * I_ztemk ) * 1e-9 ! Temperature reduces solubility
2695+
fe_par = 0.47587 * wombat%radbio(i,j,k) ! Light increases solubility. dts: 0.47587=4.77e-7*0.5/10.0**(-6.3)
26912696
fe_sfe = max(0.0, biofer - wombat%fecol(i,j,k))
26922697
fe_tfe = (1.0 + fe_par) * fe_sfe
26932698
wombat%feIII(i,j,k) = ( -( 1. + wombat%ligand * fe_keq + fe_par - fe_sfe * fe_keq ) &
@@ -2760,8 +2765,8 @@ subroutine generic_WOMBATlite_update_from_source(tracer_list, Temp, Salt, &
27602765
! We also add a T-dependent function to scale down CaCO3 production in waters colder
27612766
! than 3 degrees C based off the observation of no E hux growth beneath this (Fielding 2013; L&O)
27622767
hco3 = wombat%f_dic(i,j,k) - wombat%co3(i,j,k) - wombat%co2_star(i,j,k)
2763-
wombat%pic2poc(i,j,k) = min(0.3, (wombat%f_inorg + 10**(-3.0 + 4.31 * &
2764-
hco3 / (wombat%htotal(i,j,k)*1e6))) * &
2768+
wombat%pic2poc(i,j,k) = min(0.3, (wombat%f_inorg + 10.0**(-3.0 + 4.31e-6 * &
2769+
hco3 / wombat%htotal(i,j,k))) * &
27652770
(0.55 + 0.45 * tanh(Temp(i,j,k) - 4.0)) )
27662771

27672772
! The dissolution rate is a function of omegas for calcite and aragonite, as well the

generic_tracers/generic_WOMBATmid.F90

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ subroutine generic_WOMBATmid_update_from_source(tracer_list, Temp, Salt, &
27702770
real :: pi = 3.14159265358979
27712771
integer :: ichl
27722772
real :: par_phy_mldsum, par_z_mldsum
2773-
real :: chl, zchl, zval, phy_chlc, dia_chlc
2773+
real :: chl, zchl, zval, sqrt_zval, phy_chlc, dia_chlc
27742774
real :: phy_limnh4, phy_limno3, phy_limdin
27752775
real :: dia_limnh4, dia_limno3, dia_limdin
27762776
real :: phy_pisl, phy_pisl2
@@ -2786,7 +2786,7 @@ subroutine generic_WOMBATmid_update_from_source(tracer_list, Temp, Salt, &
27862786
real, dimension(:,:), allocatable :: ek_bgr, par_bgr_mid, par_bgr_top
27872787
real, dimension(:), allocatable :: wsink, wsinkcal
27882788
real, dimension(4,61) :: zbgr
2789-
real :: ztemk, fe_keq, fe_par, fe_sfe, fe_tfe, partic
2789+
real :: ztemk, I_ztemk, fe_keq, fe_par, fe_sfe, fe_tfe, partic
27902790
real :: fesol1, fesol2, fesol3, fesol4, fesol5, hp, fe3sol
27912791
real :: biof, biodoc, zno3, zfermin
27922792
real :: phy_Fe2C, dia_Fe2C, zoo_Fe2C, mes_Fe2C, det_Fe2C
@@ -3530,24 +3530,29 @@ subroutine generic_WOMBATmid_update_from_source(tracer_list, Temp, Salt, &
35303530

35313531
! Estimate solubility of Fe3+ (free Fe) in solution using temperature, pH and salinity
35323532
ztemk = max(5.0, Temp(i,j,k)) + 273.15 ! temperature in kelvin
3533+
I_ztemk = 1.0 / ztemk
35333534
zval = 19.924 * Salt(i,j,k) / ( 1000. - 1.005 * Salt(i,j,k))
3534-
fesol1 = 10**(-13.486 - 0.1856*zval**0.5 + 0.3073*zval + 5254.0/ztemk)
3535-
fesol2 = 10**(2.517 - 0.8885*zval**0.5 + 0.2139*zval - 1320.0/ztemk)
3536-
fesol3 = 10**(0.4511 - 0.3305*zval**0.5 - 1996.0/ztemk)
3537-
fesol4 = 10**(-0.2965 - 0.7881*zval**0.5 - 4086.0/ztemk)
3538-
fesol5 = 10**(4.4466 - 0.8505*zval**0.5 - 7980.0/ztemk)
3539-
hp = 10**(-7.9)
3540-
if (wombat%htotal(i,j,k).gt.0.0) hp = wombat%htotal(i,j,k)
3541-
fe3sol = fesol1 * ( hp**3 + fesol2 * hp**2 + fesol3 * hp + fesol4 + fesol5 / hp ) *1e9
3535+
sqrt_zval = sqrt(zval)
3536+
fesol1 = 10.0**(-13.486 - 0.1856*sqrt_zval + 0.3073*zval + 5254.0*I_ztemk)
3537+
fesol2 = 10.0**(2.517 - 0.8885*sqrt_zval + 0.2139*zval - 1320.0*I_ztemk)
3538+
fesol3 = 10.0**(0.4511 - 0.3305*sqrt_zval - 1996.0*I_ztemk)
3539+
fesol4 = 10.0**(-0.2965 - 0.7881*sqrt_zval - 4086.0*I_ztemk)
3540+
fesol5 = 10.0**(4.4466 - 0.8505*sqrt_zval - 7980.0*I_ztemk)
3541+
if (wombat%htotal(i,j,k).gt.0.0) then
3542+
hp = wombat%htotal(i,j,k)
3543+
else
3544+
hp = 1.25893e-08 ! dts: =10.0**(-7.9)
3545+
endif
3546+
fe3sol = fesol1 * ( hp*hp*hp + fesol2*hp*hp + fesol3*hp + fesol4 + fesol5/hp ) *1e9
35423547

35433548
! Estimate total colloidal iron
35443549
! ... for now, we assume that 50% of all dFe is colloidal, and we separate this from the
35453550
! equilibrium fractionation between Fe' and Fe-L below
35463551
wombat%fecol(i,j,k) = wombat%fcolloid * biofer
35473552

35483553
! Determine equilibriuim fractionation of the remain dFe (non-colloidal fraction) into Fe' and L-Fe
3549-
fe_keq = 10**( 17.27 - 1565.7 / ztemk ) * 1e-9 ! Temperature reduces solubility
3550-
fe_par = 4.77e-7 * wombat%radbio(i,j,k) * 0.5 / 10**(-6.3) ! Light increases solubility
3554+
fe_keq = 10.0**( 17.27 - 1565.7 * I_ztemk ) * 1e-9 ! Temperature reduces solubility
3555+
fe_par = 0.47587 * wombat%radbio(i,j,k) ! Light increases solubility. dts: 0.47587=4.77e-7*0.5/10.0**(-6.3)
35513556
fe_sfe = max(0.0, biofer - wombat%fecol(i,j,k))
35523557
fe_tfe = (1.0 + fe_par) * fe_sfe
35533558
wombat%feIII(i,j,k) = ( -( 1. + wombat%ligand * fe_keq + fe_par - fe_sfe * fe_keq ) &
@@ -3642,8 +3647,8 @@ subroutine generic_WOMBATmid_update_from_source(tracer_list, Temp, Salt, &
36423647
! We also add a T-dependent function to scale down CaCO3 production in waters colder
36433648
! than 3 degrees C based off the observation of no E hux growth beneath this (Fielding 2013; L&O)
36443649
hco3 = wombat%f_dic(i,j,k) - wombat%co3(i,j,k) - wombat%co2_star(i,j,k)
3645-
wombat%pic2poc(i,j,k) = min(0.3, (wombat%f_inorg + 10**(-3.0 + 4.31 * &
3646-
hco3 / (wombat%htotal(i,j,k)*1e6))) * &
3650+
wombat%pic2poc(i,j,k) = min(0.3, (wombat%f_inorg + 10.0**(-3.0 + 4.31e-6 * &
3651+
hco3 / wombat%htotal(i,j,k))) * &
36473652
(0.55 + 0.45 * tanh(Temp(i,j,k) - 4.0)) )
36483653

36493654
! The dissolution rate is a function of omegas for calcite and aragonite, as well the

0 commit comments

Comments
 (0)