/[MITgcm]/MITgcm_contrib/dcarroll/highres_darwin/code/dic_budgetApCO2.F
ViewVC logotype

Contents of /MITgcm_contrib/dcarroll/highres_darwin/code/dic_budgetApCO2.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Sun Sep 22 21:23:46 2019 UTC (5 years, 10 months ago) by dcarroll
Branch: MAIN
CVS Tags: HEAD
Initial check in of high resolution Darwin simulation code

1 #include "CPP_OPTIONS.h"
2 #include "PTRACERS_OPTIONS.h"
3 #include "DARWIN_OPTIONS.h"
4
5 #ifdef ALLOW_PTRACERS
6 #ifdef ALLOW_DARWIN
7
8 #ifdef ALLOW_CARBON
9
10 CBOP
11 C !ROUTINE: DIC_BUDGETAPCO2
12
13 C !INTERFACE: ==========================================================
14 SUBROUTINE DIC_BUDGETAPCO2( PTR_DIC , PTR_ALK, PTR_PO4, PTR_SIL,
15 O deltaApCO2,
16 I bi,bj,imin,imax,jmin,jmax,
17 I myIter,myTime,myThid)
18
19 C !DESCRIPTION:
20 C Calculate the carbon air-sea flux terms
21 C following external_forcing_dic.F (OCMIP run) from Mick
22
23 C !USES: ===============================================================
24 IMPLICIT NONE
25 #include "SIZE.h"
26 #include "DYNVARS.h"
27 #include "EEPARAMS.h"
28 #include "PARAMS.h"
29 #include "GRID.h"
30 #include "FFIELDS.h"
31 #include "DARWIN_SIZE.h"
32 #include "DARWIN_IO.h"
33 #include "DARWIN_FLUX.h"
34 #ifdef USE_EXFWIND
35 #include "EXF_FIELDS.h"
36 #endif
37
38 C !INPUT PARAMETERS: ===================================================
39 C myThid :: thread number
40 C myIter :: current timestep
41 C myTime :: current time
42 c PTR_DIC :: DIC tracer field
43 INTEGER myIter, myThid
44 _RL myTime
45 _RL PTR_DIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
46 _RL PTR_ALK(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
47 _RL PTR_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
48 _RL PTR_SIL(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
49 INTEGER iMin,iMax,jMin,jMax, bi, bj
50
51 C !LOCAL VARIABLES: ====================================================
52 INTEGER I,J, kLev, it
53 C Number of iterations for pCO2 solvers...
54 C Solubility relation coefficients
55 _RL SchmidtNoDIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
56 _RL pCO2sat(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
57 _RL Kwexch(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
58 _RL pisvel(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
59 C local variables for carbon chem
60 _RL surfdic(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
61 _RL surfalk(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
62 _RL surfphos(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
63 _RL surfsi(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
64 _RL surfsalt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
65 _RL surftemp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
66 #ifdef ALLOW_OLD_VIRTUALFLUX
67 _RL VirtualFlux(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
68 #endif
69 C local variables for CO2_FLUX_BUDGET
70 _RL FluxCO2_loc(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
71 _RL deltaApCO2(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
72 CEOP
73
74 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
75
76 kLev=1
77
78 cc if coupled to atmsopheric model, use the
79 cc Co2 value passed from the coupler
80 c#ifndef USE_ATMOSCO2
81 cC PRE-INDUSTRIAL STEADY STATE pCO2 = 278.0 ppmv
82 c DO j=1-OLy,sNy+OLy
83 c DO i=1-OLx,sNx+OLx
84 c AtmospCO2(i,j,bi,bj)=278.0 _d -6
85 c ENDDO
86 c ENDDO
87 c#endif
88 C =================================================================
89 C determine inorganic carbon chem coefficients
90 DO j=jmin,jmax
91 DO i=imin,imax
92 c put bounds on tracers so pH solver doesn't blow up
93 surfdic(i,j) =
94 & max(100. _d 0 , min(4000. _d 0, PTR_DIC(i,j)))*1e-3
95 & * maskC(i,j,kLev,bi,bj)
96 surfalk(i,j) =
97 & max(100. _d 0 , min(4000. _d 0, PTR_ALK(i,j)))*1e-3
98 & * maskC(i,j,kLev,bi,bj)
99 surfphos(i,j) =
100 & max(1. _d -10, min(10. _d 0, PTR_PO4(i,j)))*1e-3
101 & * maskC(i,j,kLev,bi,bj)
102 surfsi(i,j) =
103 & max(1. _d -8, min(500. _d 0, PTR_SIL(i,j)))*1e-3
104 & * maskC(i,j,kLev,bi,bj)
105 surfsalt(i,j) =
106 & max(4. _d 0, min(50. _d 0, salt(i,j,kLev,bi,bj)))
107 surftemp(i,j) =
108 & max(-4. _d 0, min(39. _d 0, theta(i,j,kLev,bi,bj)))
109 ENDDO
110 ENDDO
111
112 CALL CARBON_COEFFS(
113 I surftemp,surfsalt,
114 I bi,bj,iMin,iMax,jMin,jMax,myThid)
115 C====================================================================
116
117 DO j=jmin,jmax
118 DO i=imin,imax
119 C Compute AtmosP and Kwexch_Pre which are re-used for flux of O2
120
121 #ifdef USE_PLOAD
122 C Convert anomalous pressure pLoad (in Pa) from atmospheric model
123 C to total pressure (in Atm)
124 C Note: it is assumed the reference atmospheric pressure is 1Atm=1013mb
125 C rather than the actual ref. pressure from Atm. model so that on
126 C average AtmosP is about 1 Atm.
127 AtmosP(i,j,bi,bj)= 1. _d 0 + pLoad(i,j,bi,bj)/Pa2Atm
128 #endif
129
130 C Pre-compute part of exchange coefficient: pisvel*(1-fice)
131 C Schmidt number is accounted for later
132 #ifdef USE_EXFWIND
133 pisvel(i,j)=0.337 _d 0 *wspeed(i,j,bi,bj)**2/3.6 _d 5
134 cBX linear piston velocity after Krakauer et al. (2006), Eq. 3
135 cBX using <k> = 20, n=0.5, and <u^n> = 2.6747 (as determined from 2010
136 cBX EXFwspee field from cube92 run)
137 cDc pisvel(i,j)=20 _d 0 *(wspeed(i,j,bi,bj)**0.5
138 cDc & /2.6747 _d 0) /3.6 _d 5
139 #else
140 pisvel(i,j)=0.337 _d 0 *wind(i,j,bi,bj)**2/3.6 _d 5
141 #endif
142 Kwexch_Pre(i,j,bi,bj) = pisvel(i,j)
143 & * (1. _d 0 - FIce(i,j,bi,bj))
144
145 ENDDO
146 ENDDO
147
148 c pCO2 solver...
149 C$TAF LOOP = parallel
150 DO j=jmin,jmax
151 C$TAF LOOP = parallel
152 DO i=imin,imax
153
154 IF ( maskC(i,j,kLev,bi,bj).NE.0. _d 0 ) THEN
155 CALL CALC_PCO2_APPROX(
156 I surftemp(i,j),surfsalt(i,j),
157 I surfdic(i,j), surfphos(i,j),
158 I surfsi(i,j),surfalk(i,j),
159 I ak1(i,j,bi,bj),ak2(i,j,bi,bj),
160 I ak1p(i,j,bi,bj),ak2p(i,j,bi,bj),ak3p(i,j,bi,bj),
161 I aks(i,j,bi,bj),akb(i,j,bi,bj),akw(i,j,bi,bj),
162 I aksi(i,j,bi,bj),akf(i,j,bi,bj),
163 I ak0(i,j,bi,bj), fugf(i,j,bi,bj),
164 I ff(i,j,bi,bj),
165 I bt(i,j,bi,bj),st(i,j,bi,bj),ft(i,j,bi,bj),
166 U pH(i,j,bi,bj),pCO2(i,j,bi,bj),CO3(i,j,bi,bj),
167 I myThid )
168 ELSE
169 pH(i,j,bi,bj) = 0. _d 0
170 pCO2(i,j,bi,bj) = 0. _d 0
171 CO3(i,j,bi,bj) = 0. _d 0
172 ENDIF
173 ENDDO
174 ENDDO
175
176
177 DO j=jmin,jmax
178 DO i=imin,imax
179
180 IF ( maskC(i,j,kLev,bi,bj).NE.0. _d 0 ) THEN
181 C calculate SCHMIDT NO. for CO2
182 SchmidtNoDIC(i,j) =
183 & sca1
184 & + sca2 * surftemp(i,j)
185 & + sca3 * surftemp(i,j)*surftemp(i,j)
186 & + sca4 * surftemp(i,j)*surftemp(i,j)
187 & *surftemp(i,j)
188 c put positive bound on SCHMIT number (will go negative for temp>40)
189 SchmidtNoDIC(i,j) = max(1. _d -2, SchmidtNoDIC(i,j))
190 C apCO2 from previous timestep
191 pCO2sat(i,j) = budgetApCO21(i,j,bi,bj)
192 C apCO2 from current timestep
193 budgetApCO21(i,j,bi,bj) =
194 & AtmosP(i,j,bi,bj)*AtmospCO2(i,j,bi,bj)
195 if(budgetTStep1.EQ.0) then
196 C if first timestep
197 C this is problematic for restarts; to do correctly we will have to
198 C add to pickups or run simulation without interruptions
199 pCO2sat(i,j) = budgetApCO21(i,j,bi,bj)
200 endif
201 C Determine surface flux (FDIC)
202 C then account for Schmidt number
203 Kwexch(i,j) = Kwexch_Pre(i,j,bi,bj)
204 & / sqrt(SchmidtNoDIC(i,j)/660.0 _d 0)
205
206 #ifdef WATERVAP_BUG
207 C Calculate flux in terms of DIC units using K0, solubility
208 C Flux = Vp * ([CO2sat] - [CO2])
209 C CO2sat = K0*pCO2atmos*P/P0
210 C Converting pCO2 to [CO2] using ff, as in CALC_PCO2
211 FluxCO2_loc(i,j) =
212 & Kwexch(i,j)*(
213 & ak0(i,j,bi,bj)*pCO2sat(i,j) -
214 & ff(i,j,bi,bj)*pCO2(i,j,bi,bj)
215 & )
216 #else
217 C Corrected by Val Bennington Nov 2010 per G.A. McKinley's finding
218 C of error in application of water vapor correction
219 c Flux = kw*rho*(ff*pCO2atm-k0*FugFac*pCO2ocean)
220 FluxCO2_loc(i,j) =
221 & Kwexch(i,j)*(
222 & ff(i,j,bi,bj)*pCO2sat(i,j) -
223 & pCO2(i,j,bi,bj)*fugf(i,j,bi,bj)
224 & *ak0(i,j,bi,bj) )
225 &
226 #endif
227 ELSE
228 FluxCO2_loc(i,j) = 0. _d 0
229 ENDIF
230 C convert flux (mol kg-1 m s-1) to (mol m-2 s-1)
231 FluxCO2_loc(i,j) = FluxCO2_loc(i,j)/permil
232 c convert flux (mol m-2 s-1) to (mmol m-2 s-1)
233 FluxCO2_loc(i,j) = FluxCO2_loc(i,j)*1. _d 3
234
235 #ifdef ALLOW_OLD_VIRTUALFLUX
236 IF (maskC(i,j,kLev,bi,bj).NE.0. _d 0) THEN
237 c calculate virtual flux
238 c EminusPforV = dS/dt*(1/Sglob)
239 C NOTE: Be very careful with signs here!
240 C Positive EminusPforV => loss of water to atmos and increase
241 C in salinity. Thus, also increase in other surface tracers
242 C (i.e. positive virtual flux into surface layer)
243 C ...so here, VirtualFLux = dC/dt!
244 VirtualFlux(i,j)=gsm_DIC*surfaceForcingS(i,j,bi,bj)/gsm_s
245 c OR
246 c let virtual flux be zero
247 c VirtualFlux(i,j)=0.d0
248 c
249 ELSE
250 VirtualFlux(i,j)=0. _d 0
251 ENDIF
252 #endif /* ALLOW_OLD_VIRTUALFLUX */
253 ENDDO
254 ENDDO
255
256 C update tendency
257 DO j=jmin,jmax
258 DO i=imin,imax
259 if(budgetTStep1.EQ.0) then
260 C if first timestep
261 C this is problematic at restart; clean-up later
262 dFluxCO2ApCO2(i,j,bi,bj) = 0. _d 0
263 deltaApCO2(i,j) = 0. _d 0
264 else
265 C at this point in code, fluxCO2_1 contains total flux for current time step
266 dFluxCO2ApCO2(i,j,bi,bj) = fluxCO2_1(i,j,bi,bj) -
267 & FluxCO2_loc(i,j)
268 C current value - value from previous timestep
269 deltaApCO2(i,j) = budgetApCO21(i,j,bi,bj) -
270 & pCO2sat(i,j)
271 endif
272 ENDDO
273 ENDDO
274
275 RETURN
276 END
277 #endif /*ALLOW_CARBON*/
278
279 #endif /*DARWIN*/
280 #endif /*ALLOW_PTRACERS*/
281 c ==================================================================

  ViewVC Help
Powered by ViewVC 1.1.22