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

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

  ViewVC Help
Powered by ViewVC 1.1.22