/[MITgcm]/MITgcm_contrib/ecco_darwin/v5_llc270/code_darwin/dic_budgetDic.F
ViewVC logotype

Contents of /MITgcm_contrib/ecco_darwin/v5_llc270/code_darwin/dic_budgetDic.F

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


Revision 1.1 - (show annotations) (download)
Tue Jan 14 18:23:29 2020 UTC (5 years, 6 months ago) by dimitri
Branch: MAIN
CVS Tags: HEAD
- regressing v4_3deg to same vintage code as v4_llc270
- also adding some laggard files in v5_llc270/code_darwin

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

  ViewVC Help
Powered by ViewVC 1.1.22