forked from altMITgcm/MITgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bling_main.F
285 lines (255 loc) · 10.4 KB
/
bling_main.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
C $Header: /u/gcmpack/MITgcm/pkg/bling/bling_main.F,v 1.9 2017/03/16 17:03:26 mmazloff Exp $
C $Name: $
#include "BLING_OPTIONS.h"
CBOP
subroutine BLING_MAIN( PTR_DIC, PTR_ALK, PTR_O2, PTR_NO3,
& PTR_PO4, PTR_FE, PTR_DON, PTR_DOP,
#ifdef ADVECT_PHYTO
& PTR_PHY,
#endif
& bi, bj, imin, imax, jmin, jmax,
& myIter, myTime, myThid)
C ==================================================================
C | subroutine bling_main
C | o Updates all the tracers for the effects of air-sea exchange,
C | biological production, and remineralization.
C | - The basic model includes 8 tracers
C | - There is an optional tracer for phytoplankton biomass
C | - River runoff is included here
C ==================================================================
implicit none
C === Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "GRID.h"
#include "PTRACERS_SIZE.h"
#include "PTRACERS_PARAMS.h"
#ifdef ALLOW_EXF
# include "EXF_OPTIONS.h"
# include "EXF_PARAM.h"
# include "EXF_FIELDS.h"
#endif
#ifdef ALLOW_AUTODIFF
# include "tamc.h"
#endif
#include "BLING_VARS.h"
C === Routine arguments ===
C bi,bj :: tile indices
C iMin,iMax :: computation domain: 1rst index range
C jMin,jMax :: computation domain: 2nd index range
C myTime :: current time
C myIter :: current timestep
C myThid :: thread Id. number
INTEGER bi, bj, imin, imax, jmin, jmax
_RL myTime
INTEGER myIter
INTEGER myThid
C === Input ===
C PTR_DIC :: dissolved inorganic carbon
C PTR_ALK :: alkalinity
C PTR_NO3 :: nitrate concentration
C PTR_PO4 :: phosphate concentration
C PTR_DON :: dissolved organic nitrogen concentration
C PTR_DOP :: dissolved organic phosphorus concentration
C PTR_O2 :: oxygen concentration
C PTR_FE :: iron concentration
C PTR_PHY :: total phytoplankton biomass
_RL PTR_DIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_ALK(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_NO3(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_FE (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_O2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_DON(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_DOP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
#ifdef ADVECT_PHYTO
_RL PTR_PHY(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
#endif
C === Local variables ===
C i,j,k :: loop indices
C G_xx :: tendency term for the tracers
C surf_DIC :: tendency of DIC due to air-sea exchange
C surf_O2 :: tendency of O2 due to air-sea exchange
C runoff_bgc :: tendency due to river runoff
INTEGER i,j,k
_RL G_DIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_ALK(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_NO3(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_FE (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_O2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_DON(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_DOP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_CaCO3(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL NCP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL bio_DIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL bio_ALK(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL bio_O2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL bio_NO3(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL bio_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL bio_Fe(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL surf_DIC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL surf_O2(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL surf_Fe(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL FluxO2(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL irr_eff(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL runoff_bgc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,8)
CEOP
c-----------------------------------------------------------
c Initialize local variables
DO j=jmin,jmax
DO i=imin,imax
DO k=1,Nr
G_DIC(i,j,k) = 0. _d 0
G_ALK(i,j,k) = 0. _d 0
G_NO3(i,j,k) = 0. _d 0
G_PO4(i,j,k) = 0. _d 0
G_FE(i,j,k) = 0. _d 0
G_O2(i,j,k) = 0. _d 0
G_DON(i,j,k) = 0. _d 0
G_DOP(i,j,k) = 0. _d 0
G_CaCO3(i,j,k) = 0. _d 0
NCP(i,j,k) = 0. _d 0
irr_eff(i,j,k) = 0. _d 0
bio_DIC(i,j,k) = 0. _d 0
bio_ALK(i,j,k) = 0. _d 0
bio_O2(i,j,k) = 0. _d 0
bio_NO3(i,j,k) = 0. _d 0
bio_PO4(i,j,k) = 0. _d 0
bio_Fe(i,j,k) = 0. _d 0
ENDDO
DO k=1,8
runoff_bgc(i,j,k) = 0. _d 0
ENDDO
surf_DIC(i,j) = 0. _d 0
surf_O2(i,j) = 0. _d 0
surf_Fe(i,j) = 0. _d 0
fluxO2(i,j) = 0. _d 0
ENDDO
ENDDO
c-----------------------------------------------------------
c carbon and oxygen air-sea interaction
CALL BLING_AIRSEAFLUX(
I PTR_DIC, PTR_ALK, PTR_O2,
I PTR_NO3, PTR_PO4,
U surf_DIC, surf_O2, fluxO2,
I bi, bj, imin, imax, jmin, jmax,
I myIter, myTime, myThid)
CADJ STORE ph = comlev1, key = ikey_dynamics,
CADJ & kind = isbyte
c-----------------------------------------------------------
c determine calcite saturation for remineralization
CALL BLING_CARBONATE_SYS(
I PTR_DIC, PTR_ALK, PTR_PO4,
I bi, bj, imin, imax, jmin, jmax,
I myIter, myTime, myThid)
C-----------------------------------------------------------
C biological activity
CALL BLING_PROD(
I PTR_NO3, PTR_PO4, PTR_FE,
I PTR_O2, PTR_DON, PTR_DOP,
#ifdef ADVECT_PHYTO
I PTR_PHY,
#endif
U G_NO3, G_PO4, G_FE,
U G_O2, G_DON, G_DOP,
U G_CACO3, NCP,
I bi, bj, imin, imax, jmin, jmax,
I myIter, myTime, myThid)
C-----------------------------------------------------------
C Calculate river runoff source
C Tracers are already diluted by freswater input, P-E+R
C This accounts for tracer concentration in river runoff
c DO k=1,8
c DO j=jmin,jmax
c DO i=imin,imax
c#ifdef ALLOW_EXF
c runoff_bgc(i,j,k) = river_conc_trac(k)*runoff(i,j,bi,bj)
c & *recip_drF(1)*recip_hFacC(i,j,1,bi,bj)
c#else
c runoff_bgc(i,j,k) = 0. _d 0
c#endif
c ENDDO
c ENDDO
c ENDDO
c ---------------------------------------------------------------------
c Carbon system
DO j=jmin,jmax
DO i=imin,imax
DO k=1,Nr
IF (hFacC(i,j,k,bi,bj) .gt. 0. _d 0) THEN
G_ALK(i,j,k) = - G_NO3(i,j,k)
& + 2. _d 0*G_CaCO3(i,j,k)
G_DIC(i,j,k) = -NCP(i,j,k) + G_CaCO3(i,j,k)
c For diagnostics
bio_DIC(i,j,k) = G_DIC(i,j,k)
bio_ALK(i,j,k) = G_ALK(i,j,k)
bio_O2(i,j,k) = G_O2(i,j,k)
bio_NO3(i,j,k) = G_NO3(i,j,k)
bio_PO4(i,j,k) = G_PO4(i,j,k)
bio_Fe(i,j,k) = G_Fe(i,j,k)
ENDIF
ENDDO
ENDDO
ENDDO
C-----------------------------------------------------------
C adding surface tendencies due to air-sea exchange
C adding surface tendencies due to river runoff
C adding aeolian iron source
DO j=jmin,jmax
DO i=imin,imax
G_DIC(i,j,1) = G_DIC(i,j,1) + runoff_bgc(i,j,1)
& + surf_DIC(i,j)
G_ALK(i,j,1) = G_ALK(i,j,1) + runoff_bgc(i,j,2)
G_O2(i,j,1) = G_O2(i,j,1) + runoff_bgc(i,j,3)
& + surf_O2(i,j)
G_NO3(i,j,1) = G_NO3(i,j,1) + runoff_bgc(i,j,4)
G_PO4(i,j,1) = G_PO4(i,j,1) + runoff_bgc(i,j,5)
surf_Fe(i,j) = alpfe*InputFe(i,j,bi,bj)*recip_drF(1)
& * recip_hFacC(i,j,1,bi,bj)
G_FE(i,j,1) = G_FE(i,j,1) + runoff_bgc(i,j,6)
& + alpfe*InputFe(i,j,bi,bj)*recip_drF(1)
& * recip_hFacC(i,j,1,bi,bj)
G_DON(i,j,1) = G_DON(i,j,1) + runoff_bgc(i,j,7)
G_DOP(i,j,1) = G_DOP(i,j,1) + runoff_bgc(i,j,8)
ENDDO
ENDDO
C-----------------------------------------------------------
C update
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
PTR_DIC(i,j,k)=PTR_DIC(i,j,k)+G_DIC(i,j,k)*PTRACERS_dTLev(k)
PTR_ALK(i,j,k)=PTR_ALK(i,j,k)+G_ALK(i,j,k)*PTRACERS_dTLev(k)
PTR_O2 (i,j,k)=PTR_O2 (i,j,k)+G_O2 (i,j,k)*PTRACERS_dTLev(k)
PTR_NO3(i,j,k)=PTR_NO3(i,j,k)+G_NO3(i,j,k)*PTRACERS_dTLev(k)
PTR_PO4(i,j,k)=PTR_PO4(i,j,k)+G_PO4(i,j,k)*PTRACERS_dTLev(k)
PTR_FE (i,j,k)=PTR_FE (i,j,k)+G_FE (i,j,k)*PTRACERS_dTLev(k)
PTR_DON(i,j,k)=PTR_DON(i,j,k)+G_DON(i,j,k)*PTRACERS_dTLev(k)
PTR_DOP(i,j,k)=PTR_DOP(i,j,k)+G_DOP(i,j,k)*PTRACERS_dTLev(k)
ENDDO
ENDDO
ENDDO
C-----------------------------------------------------------
#ifdef ALLOW_DIAGNOSTICS
IF ( useDiagnostics ) THEN
CALL DIAGNOSTICS_FILL(bio_DIC ,'BLGBIOC ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(bio_ALK ,'BLGBIOAL',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(bio_O2 ,'BLGBIOO2',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(bio_NO3 ,'BLGBION ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(bio_PO4 ,'BLGBIOP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(bio_Fe ,'BLGBIOFE',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(surf_Fe ,'BLGSURFE',0,1,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(pH ,'BLGPH3D ',0,Nr,1,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(OmegaAr ,'BLGOMAR ',0,Nr,1,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(pCO2 ,'BLGPCO2 ',0,1 ,1,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(fluxCO2 ,'BLGCFLX ',0,1 ,1,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(fluxO2 ,'BLGOFLX ',0,1 ,2,bi,bj,myThid)
#ifdef USE_EXFCO2
CALL DIAGNOSTICS_FILL(apco2 ,'BLGapco2',0,1,0,1,1,myThid)
#endif
ENDIF
#endif /* ALLOW_DIAGNOSTICS */
RETURN
END