/[MITgcm]/MITgcm_contrib/ecco_darwin/v4_llc270/code_darwin/dic_budgetApCO2.F
ViewVC logotype

Annotation of /MITgcm_contrib/ecco_darwin/v4_llc270/code_darwin/dic_budgetApCO2.F

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


Revision 1.2 - (hide annotations) (download)
Thu Aug 15 23:38:50 2019 UTC (7 years ago) by dcarroll
Branch: MAIN
Changes since 1.1: +6 -1 lines
check in of revised CO2 flux budget code (development in progress)

1 dcarroll 1.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 dcarroll 1.2 O deltaApCO2,
16 dcarroll 1.1 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 dcarroll 1.2 _RL deltaApCO2(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
72 dcarroll 1.1 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    
191     pCO2sat(i,j) = budgetApCO21(i,j,bi,bj)
192     budgetApCO21(i,j,bi,bj) =
193     & AtmosP(i,j,bi,bj)*AtmospCO2(i,j,bi,bj)
194    
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    
202     C Determine surface flux (FDIC)
203     C then account for Schmidt number
204     Kwexch(i,j) = Kwexch_Pre(i,j,bi,bj)
205     & / sqrt(SchmidtNoDIC(i,j)/660.0 _d 0)
206    
207    
208     #ifdef WATERVAP_BUG
209     C Calculate flux in terms of DIC units using K0, solubility
210     C Flux = Vp * ([CO2sat] - [CO2])
211     C CO2sat = K0*pCO2atmos*P/P0
212     C Converting pCO2 to [CO2] using ff, as in CALC_PCO2
213     FluxCO2_loc(i,j) =
214     & Kwexch(i,j)*(
215     & ak0(i,j,bi,bj)*pCO2sat(i,j) -
216     & ff(i,j,bi,bj)*pCO2(i,j,bi,bj)
217     & )
218     #else
219     C Corrected by Val Bennington Nov 2010 per G.A. McKinley's finding
220     C of error in application of water vapor correction
221     c Flux = kw*rho*(ff*pCO2atm-k0*FugFac*pCO2ocean)
222     FluxCO2_loc(i,j) =
223     & Kwexch(i,j)*(
224     & ff(i,j,bi,bj)*pCO2sat(i,j) -
225     & pCO2(i,j,bi,bj)*fugf(i,j,bi,bj)
226     & *ak0(i,j,bi,bj) )
227     &
228     #endif
229     ELSE
230     FluxCO2_loc(i,j) = 0. _d 0
231     ENDIF
232     C convert flux (mol kg-1 m s-1) to (mol m-2 s-1)
233     FluxCO2_loc(i,j) = FluxCO2_loc(i,j)/permil
234     c convert flux (mol m-2 s-1) to (mmol m-2 s-1)
235     FluxCO2_loc(i,j) = FluxCO2_loc(i,j)*1. _d 3
236    
237     #ifdef ALLOW_OLD_VIRTUALFLUX
238     IF (maskC(i,j,kLev,bi,bj).NE.0. _d 0) THEN
239     c calculate virtual flux
240     c EminusPforV = dS/dt*(1/Sglob)
241     C NOTE: Be very careful with signs here!
242     C Positive EminusPforV => loss of water to atmos and increase
243     C in salinity. Thus, also increase in other surface tracers
244     C (i.e. positive virtual flux into surface layer)
245     C ...so here, VirtualFLux = dC/dt!
246     VirtualFlux(i,j)=gsm_DIC*surfaceForcingS(i,j,bi,bj)/gsm_s
247     c OR
248     c let virtual flux be zero
249     c VirtualFlux(i,j)=0.d0
250     c
251     ELSE
252     VirtualFlux(i,j)=0. _d 0
253     ENDIF
254     #endif /* ALLOW_OLD_VIRTUALFLUX */
255     ENDDO
256     ENDDO
257    
258     C update tendency
259     DO j=jmin,jmax
260     DO i=imin,imax
261     if(budgetTStep1.EQ.0) then
262     C if first timestep
263     C this is problematic at restart; clean-up later
264 dcarroll 1.2 dFluxCO2ApCO2(i,j,bi,bj) = 0. _d 0
265     deltaApCO2(i,j) = 0. _d 0
266 dcarroll 1.1 else
267     C at this point in code, fluxCO2_1 contains total flux for current time step
268     dFluxCO2ApCO2(i,j,bi,bj) = fluxCO2_1(i,j,bi,bj) -
269     & FluxCO2_loc(i,j)
270 dcarroll 1.2 deltaApCO2(i,j) = budgetApCO21(i,j,bi,bj) -
271     & pCO2sat(i,j)
272 dcarroll 1.1 endif
273     ENDDO
274     ENDDO
275    
276     RETURN
277     END
278     #endif /*ALLOW_CARBON*/
279    
280     #endif /*DARWIN*/
281     #endif /*ALLOW_PTRACERS*/
282     c ==================================================================

  ViewVC Help
Powered by ViewVC 1.1.22