File indexing completed on 2024-08-30 05:10:50 UTC
view on githubraw file Latest commit ae2be615 on 2024-08-29 19:00:27 UTC
8e447d7023 Step*0001 #include "DIC_OPTIONS.h"
0002
0003
5c4b83b693 Jean*0004
8e447d7023 Step*0005
0006
5c4b83b693 Jean*0007 SUBROUTINE CALCITE_SATURATION( PTR_DIC, PTR_ALK, PTR_PO4,
8e447d7023 Step*0008 I bi,bj,imin,imax,jmin,jmax,
2e3e8c330d Jona*0009 I myTime, myIter, myThid )
8e447d7023 Step*0010
0011
2e3e8c330d Jona*0012
0013
0014
8e447d7023 Step*0015
0016
0017 IMPLICIT NONE
0018 #include "SIZE.h"
0019 #include "EEPARAMS.h"
0020 #include "PARAMS.h"
0021 #include "GRID.h"
5c4b83b693 Jean*0022 #include "DYNVARS.h"
2ef8966791 Davi*0023 #include "DIC_VARS.h"
8e447d7023 Step*0024
0025
0026
2e3e8c330d Jona*0027
5c4b83b693 Jean*0028
720e9330bd Step*0029 _RL PTR_DIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0030 _RL PTR_ALK(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0031 _RL PTR_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
5c4b83b693 Jean*0032 INTEGER imin, imax, jmin, jmax, bi, bj
8e447d7023 Step*0033 _RL myTime
2e3e8c330d Jona*0034 INTEGER myIter
8e447d7023 Step*0035 INTEGER myThid
0036
0037
0038
2e3e8c330d Jona*0039 #if ( defined DIC_BIOTIC && defined DIC_CALCITE_SAT )
8e447d7023 Step*0040
0041
0042
5c4b83b693 Jean*0043 INTEGER i,j,k
ae2be6150b Jona*0044 LOGICAL doIni_pH, debugPrt
a1d0e455fd Hann*0045 _RL carbonate(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
8e447d7023 Step*0046 _RL calcium
a1d0e455fd Hann*0047 _RL sitlocal
8e447d7023 Step*0048 _RL po4local
0049 _RL diclocal
0050 _RL alklocal
a1d0e455fd Hann*0051 _RL pCO2local(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
5c4b83b693 Jean*0052 _RL locTemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0053 _RL locSalt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
ae2be6150b Jona*0054 INTEGER doIterCO3, CO3ITER
8e447d7023 Step*0055
0056
ae2be6150b Jona*0057 doIni_pH = ( myIter.EQ.(nIter0 + 1) ) .AND. .NOT.pH_isLoaded(2)
0058
0059 IF ( doIni_pH .OR.
0060 & ( calcOmegaCalciteFreq.GT.deltaTClock ) ) THEN
0061
0062
0063
0064
0065 doIterCO3 = nIterCO3
0066 ELSE
0067 doIterCO3 = 1
0068 ENDIF
0069
0070
0071
0072
0073
0074
5c4b83b693 Jean*0075 DO k=1,Nr
0076 DO j=1-OLy,sNy+OLy
0077 DO i=1-OLx,sNx+OLx
0078 locTemp(i,j) = theta(i,j,k,bi,bj)
0079 locSalt(i,j) = salt (i,j,k,bi,bj)
a1d0e455fd Hann*0080 carbonate(i,j) = 0. _d 0
0081 pCO2local(i,j) = 0. _d 0
6acab690ae Jona*0082 ENDDO
0083 ENDDO
7459d17a4c Jona*0084 #ifdef CARBONCHEM_SOLVESAPHE
6acab690ae Jona*0085 #ifdef ALLOW_DEBUG
a1d0e455fd Hann*0086 IF (debugMode) CALL DEBUG_CALL( 'DIC_COEFFS_DEEP',myThid )
6acab690ae Jona*0087 #endif
0088
0089 CALL DIC_COEFFS_SURF(
5c4b83b693 Jean*0090 I locTemp, locSalt,
6acab690ae Jona*0091 I bi,bj,iMin,iMax,jMin,jMax,myThid)
0092
0093
0094 CALL DIC_COEFFS_DEEP(
5c4b83b693 Jean*0095 I locTemp, locSalt,
6acab690ae Jona*0096 I bi,bj,iMin,iMax,jMin,jMax,
0097 I k,myThid)
0098 #else
0099 #ifdef ALLOW_DEBUG
a1d0e455fd Hann*0100 IF (debugMode) CALL DEBUG_CALL(
0101 & 'CARBON_COEFFS_PRESSURE_DEP',myThid)
6acab690ae Jona*0102 #endif
8e447d7023 Step*0103 CALL CARBON_COEFFS_PRESSURE_DEP(
5c4b83b693 Jean*0104 I locTemp, locSalt,
8e447d7023 Step*0105 I bi,bj,iMin,iMax,jMin,jMax,
5625485478 Jean*0106 I k,myThid)
6acab690ae Jona*0107 #endif
8e447d7023 Step*0108
6acab690ae Jona*0109 debugPrt = debugMode
51c3bf0077 Step*0110 DO j=jmin,jmax
0111 DO i=imin,imax
8e447d7023 Step*0112
a1d0e455fd Hann*0113 IF ( maskC(i,j,k,bi,bj).EQ.oneRS ) THEN
6acab690ae Jona*0114 #ifdef CARBONCHEM_SOLVESAPHE
2e3e8c330d Jona*0115
a1d0e455fd Hann*0116 calcium = cat(i,j,bi,bj)
6acab690ae Jona*0117 #else
a1d0e455fd Hann*0118 calcium = 1.028 _d -2*salt(i,j,k,bi,bj)/35. _d 0
6acab690ae Jona*0119 #endif
8e447d7023 Step*0120
2e3e8c330d Jona*0121
0122
a1d0e455fd Hann*0123 sitlocal = silicaDeep(i,j,k,bi,bj)
0124 po4local = PTR_PO4(i,j,k)
0125 diclocal = PTR_DIC(i,j,k)
0126 alklocal = PTR_ALK(i,j,k)
6acab690ae Jona*0127
0128 #ifdef CARBONCHEM_SOLVESAPHE
a1d0e455fd Hann*0129 IF ( selectPHsolver.GT.0 ) THEN
6acab690ae Jona*0130
ae2be6150b Jona*0131 IF ( doIni_pH ) THEN
6acab690ae Jona*0132 #ifdef ALLOW_DEBUG
ae2be6150b Jona*0133 IF (debugPrt) CALL DEBUG_CALL('AHINI_FOR_AT',myThid)
6acab690ae Jona*0134 #endif
0135
ae2be6150b Jona*0136 CALL AHINI_FOR_AT(alklocal*permil,
0137 I diclocal*permil,
0138 I bt(i,j,bi,bj),
0139 O pH3d(i,j,k,bi,bj),
0140 I i,j,k,bi,bj,myIter,myThid )
0141 ENDIF /* 3d pH is not loaded */
6acab690ae Jona*0142 #ifdef ALLOW_DEBUG
a1d0e455fd Hann*0143 IF (debugPrt) CALL DEBUG_CALL('CALC_PCO2_SOLVESAPHE',myThid)
6acab690ae Jona*0144 #endif
0145 CALL CALC_PCO2_SOLVESAPHE(
5c4b83b693 Jean*0146 I locTemp(i,j), locSalt(i,j),
6acab690ae Jona*0147 I diclocal, po4local,
a1d0e455fd Hann*0148 I sitlocal, alklocal,
ae2be6150b Jona*0149 U pH3d(i,j,k,bi,bj), pCO2local(i,j), carbonate(i,j),
6acab690ae Jona*0150 I i,j,k,bi,bj, debugPrt,myIter,myThid )
6b3f5dbce1 Hann*0151
0152
a1d0e455fd Hann*0153 carbonate(i,j) = carbonate(i,j)*permil
0154 ELSE
6acab690ae Jona*0155
0156 #endif /* CARBONCHEM_SOLVESAPHE */
0157 #ifdef ALLOW_DEBUG
0158 IF (debugPrt) CALL DEBUG_CALL('CALC_PCO2_APPROX',myThid)
0159 #endif
ae2be6150b Jona*0160 DO CO3iter = 1, doIterCO3
0161 CALL CALC_PCO2_APPROX(
5c4b83b693 Jean*0162 I locTemp(i,j), locSalt(i,j),
8e447d7023 Step*0163 I diclocal, po4local,
a1d0e455fd Hann*0164 I sitlocal, alklocal,
8e447d7023 Step*0165 I ak1(i,j,bi,bj),ak2(i,j,bi,bj),
0166 I ak1p(i,j,bi,bj),ak2p(i,j,bi,bj),ak3p(i,j,bi,bj),
0167 I aks(i,j,bi,bj),akb(i,j,bi,bj),akw(i,j,bi,bj),
e6a52874f7 Davi*0168 I aksi(i,j,bi,bj),akf(i,j,bi,bj),
0169 I ak0(i,j,bi,bj), fugf(i,j,bi,bj), ff(i,j,bi,bj),
8e447d7023 Step*0170 I bt(i,j,bi,bj),st(i,j,bi,bj),ft(i,j,bi,bj),
ae2be6150b Jona*0171 U pH3d(i,j,k,bi,bj), pCO2local(i,j), carbonate(i,j),
e098791e51 Jean*0172 I i,j,k,bi,bj,myIter,myThid )
5c4b83b693 Jean*0173 ENDDO
ae2be6150b Jona*0174
6acab690ae Jona*0175 #ifdef CARBONCHEM_SOLVESAPHE
a1d0e455fd Hann*0176 ENDIF
6acab690ae Jona*0177 #endif /* CARBONCHEM_SOLVESAPHE */
8e447d7023 Step*0178
a1d0e455fd Hann*0179 omegaC(i,j,k,bi,bj) = calcium * carbonate(i,j)
0180 & / Ksp_TP_Calc(i,j,bi,bj)
2e3e8c330d Jona*0181 debugPrt = .FALSE.
8e447d7023 Step*0182
5c4b83b693 Jean*0183
8e447d7023 Step*0184
0185
0186
0187
0188
ae2be6150b Jona*0189
5c4b83b693 Jean*0190
8e447d7023 Step*0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
5c4b83b693 Jean*0206
a1d0e455fd Hann*0207 ELSE
0208
0209 omegaC(i,j,k,bi,bj) = 0. _d 0
0210 ENDIF
8e447d7023 Step*0211
0212 ENDDO
0213 ENDDO
0214
a1d0e455fd Hann*0215 #ifdef ALLOW_DIAGNOSTICS
ae2be6150b Jona*0216
a1d0e455fd Hann*0217 IF ( useDiagnostics ) THEN
0218 CALL DIAGNOSTICS_FILL(pCO2local,'DIC3DPCO',k,1,2,bi,bj,myThid)
0219 CALL DIAGNOSTICS_FILL(carbonate,'DIC3DCO3',k,1,2,bi,bj,myThid)
0220 ENDIF
0221 #endif /* ALLOW_DIAGNOSTICS */
0222
5c4b83b693 Jean*0223
8e447d7023 Step*0224 ENDDO
5c4b83b693 Jean*0225
a1d0e455fd Hann*0226 #ifdef ALLOW_DIAGNOSTICS
ae2be6150b Jona*0227
a1d0e455fd Hann*0228 IF ( useDiagnostics ) THEN
ae2be6150b Jona*0229 CALL DIAGNOSTICS_FILL(pH3d ,'DIC3DPH ',0,Nr,1,bi,bj,myThid)
a1d0e455fd Hann*0230 CALL DIAGNOSTICS_FILL(omegaC ,'OMEGAC ',0,Nr,1,bi,bj,myThid)
0231 CALL DIAGNOSTICS_FILL(silicaDeep,'DIC3DSIT',0,Nr,1,bi,bj,myThid)
0232 ENDIF
0233 #endif /* ALLOW_DIAGNOSTICS */
0234
2e3e8c330d Jona*0235 #endif /* DIC_BIOTIC and DIC_CALCITE_SAT */
8e447d7023 Step*0236 RETURN
0237 END