File indexing completed on 2023-02-04 06:09:50 UTC
view on githubraw file Latest commit 2e3e8c33 on 2023-02-03 17:26:01 UTC
6d54cf9ca1 Ed H*0001 #include "DIC_OPTIONS.h"
11c3150c71 Mart*0002 #ifdef ALLOW_AUTODIFF
0003 # include "AUTODIFF_OPTIONS.h"
0004 #endif
daab022f42 Step*0005
08536d17ba Step*0006
0007
0008
0009
e098791e51 Jean*0010 SUBROUTINE DIC_SURFFORCING( PTR_CO2 , PTR_ALK, PTR_PO4, GDC,
a1d0e455fd Hann*0011 I bi, bj, iMin, iMax, jMin, jMax,
2e3e8c330d Jona*0012 I myTime, myIter, myThid )
daab022f42 Step*0013
08536d17ba Step*0014
e098791e51 Jean*0015
0016
daab022f42 Step*0017
08536d17ba Step*0018
0019 IMPLICIT NONE
daab022f42 Step*0020 #include "SIZE.h"
0021 #include "DYNVARS.h"
0022 #include "EEPARAMS.h"
0023 #include "PARAMS.h"
0024 #include "GRID.h"
0025 #include "FFIELDS.h"
2ef8966791 Davi*0026 #include "DIC_VARS.h"
11c3150c71 Mart*0027 #ifdef ALLOW_AUTODIFF_TAMC
0028 # include "tamc.h"
0029 #endif
daab022f42 Step*0030
08536d17ba Step*0031
a1d0e455fd Hann*0032
2e3e8c330d Jona*0033
0034
0035
daab022f42 Step*0036 _RL PTR_CO2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
720e9330bd Step*0037 _RL PTR_ALK(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0038 _RL PTR_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
daab022f42 Step*0039 INTEGER iMin,iMax,jMin,jMax, bi, bj
2e3e8c330d Jona*0040 _RL myTime
0041 INTEGER myIter, myThid
daab022f42 Step*0042
08536d17ba Step*0043
a1d0e455fd Hann*0044
08536d17ba Step*0045 _RL GDC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0046
6acab690ae Jona*0047 #ifdef ALLOW_DIC
08536d17ba Step*0048
0049
c845fbfeae Jean*0050 INTEGER i,j, kLev
6acab690ae Jona*0051 LOGICAL debugPrt
e6a52874f7 Davi*0052 _RL co3dummy
daab022f42 Step*0053
0054
0055 _RL SchmidtNoDIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0056 _RL pCO2sat(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0057 _RL Kwexch(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
c8d7031b60 Davi*0058 _RL pisvel(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
daab022f42 Step*0059
0060 _RL surfalk(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0061 _RL surfphos(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0062 _RL surfsi(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
8bf2c0e0ad Step*0063 _RL surftemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0064 _RL surfsalt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0065 _RL surfdic(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
04d6738595 Davi*0066 #ifdef ALLOW_OLD_VIRTUALFLUX
daab022f42 Step*0067 _RL VirtualFlux(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
04d6738595 Davi*0068 #endif
11c3150c71 Mart*0069 #ifdef ALLOW_AUTODIFF_TAMC
edb6656069 Mart*0070 INTEGER tkey
11c3150c71 Mart*0071 #endif
08536d17ba Step*0072
daab022f42 Step*0073
a1d0e455fd Hann*0074 kLev = 1
daab022f42 Step*0075
a1d0e455fd Hann*0076
0077
1ef1c61fb1 Step*0078
0079
0080
0081
0082
0083
0084
0085
daab022f42 Step*0086
0087
0088
a1d0e455fd Hann*0089 DO j=jMin,jMax
0090 DO i=iMin,iMax
daab022f42 Step*0091 #ifdef DIC_BIOTIC
0092
8bf2c0e0ad Step*0093 #ifdef DIC_BOUNDS
a1d0e455fd Hann*0094 surfalk(i,j) = MAX( 0.4 _d 0,
0095 & MIN( 10. _d 0, PTR_ALK(i,j,klev) ) )
0096 & * maskC(i,j,kLev,bi,bj)
0097 surfphos(i,j) = MAX( 1.0 _d -11,
0098 & MIN( 1. _d -1, PTR_PO4(i,j,klev) ) )
0099 & * maskC(i,j,kLev,bi,bj)
8bf2c0e0ad Step*0100 #else
a1d0e455fd Hann*0101 surfalk(i,j) = PTR_ALK(i,j,klev)*maskC(i,j,kLev,bi,bj)
0102 surfphos(i,j) = PTR_PO4(i,j,klev)*maskC(i,j,kLev,bi,bj)
8bf2c0e0ad Step*0103 #endif
6acab690ae Jona*0104 #else /* DIC_BIOTIC */
a1d0e455fd Hann*0105 surfalk(i,j) = 2.366595 _d 0 * salt(i,j,kLev,bi,bj)/gsm_s
0106 & * maskC(i,j,kLev,bi,bj)
0107 surfphos(i,j) = 5.1225 _d -4 * maskC(i,j,kLev,bi,bj)
6acab690ae Jona*0108 #endif /* DIC_BIOTIC */
a1d0e455fd Hann*0109
0110 surfsi(i,j) = silicaSurf(i,j,bi,bj)*maskC(i,j,kLev,bi,bj)
8bf2c0e0ad Step*0111 #ifdef DIC_BOUNDS
a1d0e455fd Hann*0112 surftemp(i,j) = MAX( -4. _d 0,
0113 & MIN( 50. _d 0, theta(i,j,kLev,bi,bj) ) )
0114 surfsalt(i,j) = MAX( 4. _d 0,
0115 & MIN( 50. _d 0, salt(i,j,kLev,bi,bj) ) )
0116 surfdic(i,j) = MAX( 0.4 _d 0,
0117 & MIN( 10. _d 0, PTR_CO2(i,j,kLev) ) )
8bf2c0e0ad Step*0118 #else
a1d0e455fd Hann*0119 surftemp(i,j) = theta(i,j,kLev,bi,bj)
0120 surfsalt(i,j) = salt(i,j,kLev,bi,bj)
0121 surfdic(i,j) = PTR_CO2(i,j,kLev)
8bf2c0e0ad Step*0122 #endif
a1d0e455fd Hann*0123 ENDDO
0124 ENDDO
daab022f42 Step*0125
6acab690ae Jona*0126 #ifdef CARBONCHEM_SOLVESAPHE
0127 #ifdef ALLOW_DEBUG
0128 IF (debugMode) CALL DEBUG_CALL('DIC_COEFFS_SURF',myThid)
0129 #endif
a1d0e455fd Hann*0130 CALL DIC_COEFFS_SURF(
8bf2c0e0ad Step*0131 I surftemp,surfsalt,
5625485478 Jean*0132 I bi,bj,iMin,iMax,jMin,jMax,myThid)
6acab690ae Jona*0133 #else /* CARBONCHEM_SOLVESAPHE */
0134 #ifdef ALLOW_DEBUG
0135 IF (debugMode) CALL DEBUG_CALL('CARBON_COEFFS',myThid)
0136 #endif
a1d0e455fd Hann*0137 CALL CARBON_COEFFS(
6acab690ae Jona*0138 I surftemp,surfsalt,
0139 I bi,bj,iMin,iMax,jMin,jMax,myThid)
0140 #endif /* CARBONCHEM_SOLVESAPHE */
daab022f42 Step*0141
0142
a5bfd8de3c Jean*0143 DO j=jMin,jMax
0144 DO i=iMin,iMax
c8d7031b60 Davi*0145
0146
0147 #ifdef USE_PLOAD
0148
0149
0150
0151
0152
b31669ac34 Jean*0153 AtmosP(i,j,bi,bj)= ( surf_pRef + pLoad(i,j,bi,bj) )/Pa2Atm
c8d7031b60 Davi*0154 #endif
0155
0156
0157
a1d0e455fd Hann*0158 pisvel(i,j) = 0.337 _d 0 *wind(i,j,bi,bj)**2/3.6 _d 5
0159 Kwexch_Pre(i,j,bi,bj) = pisvel(i,j)
0160 & * (1. _d 0 - fIce(i,j,bi,bj))
c8d7031b60 Davi*0161 ENDDO
0162 ENDDO
0163
11c3150c71 Mart*0164 #ifdef ALLOW_AUTODIFF_TAMC
edb6656069 Mart*0165 tkey = bi + (bj-1)*nSx + (ikey_dynamics-1)*nSx*nSy
0166
11c3150c71 Mart*0167 #endif
6acab690ae Jona*0168 debugPrt = debugMode
a1d0e455fd Hann*0169
29ad036528 Step*0170
a5bfd8de3c Jean*0171 DO j=jMin,jMax
29ad036528 Step*0172
a5bfd8de3c Jean*0173 DO i=iMin,iMax
75e97f1e14 Davi*0174 IF ( maskC(i,j,kLev,bi,bj).NE.0. _d 0 ) THEN
6acab690ae Jona*0175 #ifdef CARBONCHEM_SOLVESAPHE
0176 IF ( selectPHsolver.GT.0 ) THEN
0177
0178 #ifdef ALLOW_DEBUG
0179 IF (debugPrt) CALL DEBUG_CALL(
0180 & 'CALC_PCO2_SOLVESAPHE from DIC_SURFFORCING',myThid)
0181 #endif
0182 CALL CALC_PCO2_SOLVESAPHE(
0183 I surftemp(i,j),surfsalt(i,j),
0184 I surfdic(i,j), surfphos(i,j),
0185 I surfsi(i,j),surfalk(i,j),
0186 U pH(i,j,bi,bj),pCO2(i,j,bi,bj),co3dummy,
0187 I i,j,kLev,bi,bj, debugPrt, myIter, myThid )
0188 debugPrt = .FALSE.
0189 ELSE
0190
0191 #endif /* CARBONCHEM_SOLVESAPHE */
0192 #ifdef ALLOW_DEBUG
0193 IF (debugPrt) CALL DEBUG_CALL(
0194 & 'CALC_PCO2_APPROX',myThid)
0195 debugPrt = .FALSE.
0196 #endif
0197 CALL CALC_PCO2_APPROX(
0198 I surftemp(i,j),surfsalt(i,j),
0199 I surfdic(i,j), surfphos(i,j),
0200 I surfsi(i,j),surfalk(i,j),
0201 I ak1(i,j,bi,bj),ak2(i,j,bi,bj),
0202 I ak1p(i,j,bi,bj),ak2p(i,j,bi,bj),ak3p(i,j,bi,bj),
0203 I aks(i,j,bi,bj),akb(i,j,bi,bj),akw(i,j,bi,bj),
0204 I aksi(i,j,bi,bj),akf(i,j,bi,bj),
0205 I ak0(i,j,bi,bj), fugf(i,j,bi,bj),
0206 I ff(i,j,bi,bj),
0207 I bt(i,j,bi,bj),st(i,j,bi,bj),ft(i,j,bi,bj),
0208 U pH(i,j,bi,bj),pCO2(i,j,bi,bj),co3dummy,
0209 I i,j,kLev,bi,bj,myIter, myThid )
0210 #ifdef CARBONCHEM_SOLVESAPHE
0211 ENDIF
0212 #endif /* CARBONCHEM_SOLVESAPHE */
daab022f42 Step*0213 ELSE
75e97f1e14 Davi*0214 pCO2(i,j,bi,bj)=0. _d 0
0215 ENDIF
daab022f42 Step*0216 ENDDO
0217 ENDDO
0218
a5bfd8de3c Jean*0219 DO j=jMin,jMax
0220 DO i=iMin,iMax
daab022f42 Step*0221
75e97f1e14 Davi*0222 IF ( maskC(i,j,kLev,bi,bj).NE.0. _d 0 ) THEN
daab022f42 Step*0223
a1d0e455fd Hann*0224 SchmidtNoDIC(i,j) =
e098791e51 Jean*0225 & sca1
daab022f42 Step*0226 & + sca2 * theta(i,j,kLev,bi,bj)
e098791e51 Jean*0227 & + sca3 * theta(i,j,kLev,bi,bj)*theta(i,j,kLev,bi,bj)
0228 & + sca4 * theta(i,j,kLev,bi,bj)*theta(i,j,kLev,bi,bj)
daab022f42 Step*0229 & *theta(i,j,kLev,bi,bj)
a1d0e455fd Hann*0230
0231 SchmidtNoDIC(i,j) = MAX( 1.0 _d -2, SchmidtNoDIC(i,j) )
daab022f42 Step*0232
0233
0234
a1d0e455fd Hann*0235 pCO2sat(i,j) =
daab022f42 Step*0236 & AtmosP(i,j,bi,bj)*AtmospCO2(i,j,bi,bj)
0237
c8d7031b60 Davi*0238
a1d0e455fd Hann*0239 Kwexch(i,j) = Kwexch_Pre(i,j,bi,bj)
0240 & / SQRT(SchmidtNoDIC(i,j)/660.0 _d 0)
daab022f42 Step*0241
d0092a57ac Step*0242 #ifdef WATERVAP_BUG
daab022f42 Step*0243
0244
0245
0246
a1d0e455fd Hann*0247 FluxCO2(i,j,bi,bj) =
e098791e51 Jean*0248 & Kwexch(i,j)*(
0249 & ak0(i,j,bi,bj)*pCO2sat(i,j) -
0250 & ff(i,j,bi,bj)*pCO2(i,j,bi,bj)
0251 & )
d0092a57ac Step*0252 #else
a1d0e455fd Hann*0253
f169dabedd Jean*0254
d0092a57ac Step*0255
a1d0e455fd Hann*0256
0257 FluxCO2(i,j,bi,bj) =
d0092a57ac Step*0258 & Kwexch(i,j)*(
0259 & ff(i,j,bi,bj)*pCO2sat(i,j) -
0260 & pCO2(i,j,bi,bj)*fugf(i,j,bi,bj)
0261 & *ak0(i,j,bi,bj) )
6acab690ae Jona*0262
d0092a57ac Step*0263 #endif
75e97f1e14 Davi*0264 ELSE
a1d0e455fd Hann*0265 FluxCO2(i,j,bi,bj) = 0. _d 0
75e97f1e14 Davi*0266 ENDIF
daab022f42 Step*0267
a1d0e455fd Hann*0268 FluxCO2(i,j,bi,bj) = FluxCO2(i,j,bi,bj)/permil
daab022f42 Step*0269
04d6738595 Davi*0270 #ifdef ALLOW_OLD_VIRTUALFLUX
a1d0e455fd Hann*0271 IF (maskC(i,j,kLev,bi,bj).NE.0. _d 0) THEN
0272
0273
daab022f42 Step*0274
0275
0276
0277
0278
93d40906a6 Jean*0279 VirtualFlux(i,j)=gsm_DIC*surfaceForcingS(i,j,bi,bj)/gsm_s
a1d0e455fd Hann*0280
0281
0282
0283 ELSE
daab022f42 Step*0284 VirtualFlux(i,j)=0. _d 0
a1d0e455fd Hann*0285 ENDIF
04d6738595 Davi*0286 #endif /* ALLOW_OLD_VIRTUALFLUX */
a1d0e455fd Hann*0287 ENDDO
0288 ENDDO
daab022f42 Step*0289
e098791e51 Jean*0290
a1d0e455fd Hann*0291 DO j=jMin,jMax
0292 DO i=iMin,iMax
c8d7031b60 Davi*0293 GDC(i,j)= recip_drF(kLev)*recip_hFacC(i,j,kLev,bi,bj)
e098791e51 Jean*0294 & *(FluxCO2(i,j,bi,bj)
04d6738595 Davi*0295 #ifdef ALLOW_OLD_VIRTUALFLUX
c8d7031b60 Davi*0296 & + VirtualFlux(i,j)
04d6738595 Davi*0297 #endif
c8d7031b60 Davi*0298 & )
a1d0e455fd Hann*0299 ENDDO
0300 ENDDO
daab022f42 Step*0301
6acab690ae Jona*0302 #endif /* ALLOW_DIC */
a1d0e455fd Hann*0303 RETURN
0304 END