forked from AquaticEcoDynamics/libaed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aed2_chlorophylla.F90
275 lines (223 loc) · 11.2 KB
/
aed2_chlorophylla.F90
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
!###############################################################################
!# #
!# aed2_chlorophylla.F90 #
!# #
!# Developed by : #
!# AquaticEcoDynamics (AED) Group #
!# School of Agriculture and Environment #
!# The University of Western Australia #
!# #
!# http://aquatic.science.uwa.edu.au/ #
!# #
!# Copyright 2013 - 2018 - The University of Western Australia #
!# #
!# GLM is free software: you can redistribute it and/or modify #
!# it under the terms of the GNU General Public License as published by #
!# the Free Software Foundation, either version 3 of the License, or #
!# (at your option) any later version. #
!# #
!# GLM is distributed in the hope that it will be useful, #
!# but WITHOUT ANY WARRANTY; without even the implied warranty of #
!# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
!# GNU General Public License for more details. #
!# #
!# You should have received a copy of the GNU General Public License #
!# along with this program. If not, see <http://www.gnu.org/licenses/>. #
!# #
!# ----------------------------------------------------------------------- #
!# #
!# Created August 2011 #
!# #
!###############################################################################
#include "aed2.h"
MODULE aed2_chlorophylla
!-------------------------------------------------------------------------------
! aed2_chlorphylla --- simple lumped chl-a model
!-------------------------------------------------------------------------------
USE aed2_core
IMPLICIT NONE
PRIVATE
!
PUBLIC aed2_chla_data_t
!
TYPE,extends(aed2_model_data_t) :: aed2_chla_data_t
!# Variable identifiers
INTEGER :: id_p
INTEGER :: id_exctarget,id_morttarget,id_upttarget
INTEGER :: id_par
INTEGER :: id_I_0
INTEGER :: id_GPP,id_NCP,id_PPR,id_NPR,id_dPAR
!# Model parameters
AED_REAL :: p0,z0,kc,i_min,rmax,gmax,iv,alpha,rpn,rzn,rdn,rpdu,rpdl,rzd
AED_REAL :: dic_per_n
LOGICAL :: do_exc,do_mort,do_upt
CONTAINS
PROCEDURE :: define => aed2_define_chla
PROCEDURE :: calculate => aed2_calculate_chla
! PROCEDURE :: mobility => aed2_mobility_chla
PROCEDURE :: light_extinction => aed2_light_extinction_chla
! PROCEDURE :: delete => aed2_delete_chla
END TYPE
! MODULE GLOBALS
INTEGER :: diag_level = 10
!===============================================================================
CONTAINS
!###############################################################################
SUBROUTINE aed2_define_chla(data, namlst)
!-------------------------------------------------------------------------------
! Initialise the chlorophyl model
!
! Here, the chla namelist is read and te variables exported
! by the model are registered with AED2.
!-------------------------------------------------------------------------------
!ARGUMENTS
CLASS (aed2_chla_data_t),INTENT(inout) :: data
INTEGER,INTENT(in) :: namlst
!
!LOCALS
INTEGER :: status
! %% NAMELIST
AED_REAL :: p_initial=0.
AED_REAL :: p0=0.0225
AED_REAL :: w_p=-1.157407e-05
AED_REAL :: i_min=25.
AED_REAL :: rmax=1.157407e-05
AED_REAL :: alpha=0.3
AED_REAL :: rpn=1.157407e-07
AED_REAL :: rpdu=2.314814e-07
AED_REAL :: rpdl=1.157407e-06
CHARACTER(len=64) :: excretion_target_variable=''
CHARACTER(len=64) :: mortality_target_variable=''
CHARACTER(len=64) :: uptake_target_variable=''
! %% END NAMELIST
NAMELIST /aed2_chla/ p_initial,p0,w_p,i_min,rmax,alpha,rpn,rpdu,rpdl, &
excretion_target_variable,mortality_target_variable, &
uptake_target_variable
!-------------------------------------------------------------------------------
!BEGIN
print *," aed2_chla initialization"
! Read the namelist
read(namlst,nml=aed2_chla,iostat=status)
IF (status /= 0) STOP 'Error reading namelist aed2_chla'
! Store parameter values in our own derived type
! NB: all rates must be provided in values per day,
! and are converted here to values per second.
data%p0 = p0
data%i_min = i_min
data%rmax = rmax/secs_per_day
data%alpha = alpha
data%rpn = rpn /secs_per_day
data%rpdu = rpdu/secs_per_day
data%rpdl = rpdl/secs_per_day
! Register state variables
data%id_p = aed2_define_variable('phy','mmol/m**3','phytoplankton', &
p_initial,minimum=zero_,mobility=w_p/secs_per_day)
! Register link to external DIC pool, if DIC variable name is provided in namelist.
data%do_exc = excretion_target_variable .NE. ''
IF (data%do_exc) data%id_exctarget = aed2_locate_variable(excretion_target_variable)
data%do_mort = mortality_target_variable .NE. ''
IF (data%do_mort) data%id_morttarget = aed2_locate_variable(mortality_target_variable)
data%do_upt = uptake_target_variable .NE. ''
IF (data%do_upt) data%id_upttarget = aed2_locate_variable(uptake_target_variable)
! Register diagnostic variables
data%id_GPP = aed2_define_diag_variable('GPP','mmol/m**3/d', 'gross primary production')
data%id_NCP = aed2_define_diag_variable('NCP','mmol/m**3/d', 'net community production')
data%id_PPR = aed2_define_diag_variable('PPR','-','phytoplankton p/r ratio (gross)')
data%id_NPR = aed2_define_diag_variable('NPR','-','phytoplankton p/r ratio (net)')
data%id_dPAR = aed2_define_diag_variable('PAR','W/m**2', 'photosynthetically active radiation')
! Register environmental dependencies
data%id_par = aed2_locate_global('par')
data%id_I_0 = aed2_locate_global_sheet('par_sf')
PRINT *,'AED_CHLA : Note this module has not been completed.'
END SUBROUTINE aed2_define_chla
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!###############################################################################
SUBROUTINE aed2_calculate_chla(data,column,layer_idx)
!-------------------------------------------------------------------------------
! Right hand sides of chlorophylla model
!-------------------------------------------------------------------------------
!ARGUMENTS
CLASS (aed2_chla_data_t),INTENT(in) :: data
TYPE (aed2_column_t),INTENT(inout) :: column(:)
INTEGER,INTENT(in) :: layer_idx
!
!LOCALS
AED_REAL :: n,p,par,I_0
AED_REAL :: iopt,rpd,primprod
!-------------------------------------------------------------------------------
!BEGIN
! Retrieve current (local) state variable values.
p = _STATE_VAR_(data%id_p)! phytoplankton
n = _STATE_VAR_(data%id_upttarget)! nutrients
! Retrieve current environmental conditions.
par = _STATE_VAR_(data%id_par) ! local photosynthetically active radiation
I_0 = _STATE_VAR_S_(data%id_I_0) ! surface short wave radiation
! Light acclimation formulation based on surface light intensity.
iopt = max(0.25*I_0,data%I_min)
! Loss rate of phytoplankton to detritus depends on local light intensity.
IF (par .ge. data%I_min) THEN
rpd = data%rpdu
ELSE
rpd = data%rpdl
ENDIF
! Define some intermediate quantities that will be reused multiple times.
primprod = fnp(data,n,p,par,iopt)
! Set temporal derivatives
_FLUX_VAR_(data%id_p) = _FLUX_VAR_(data%id_p) + (primprod - data%rpn*p - rpd*p)
! If an externally maintained ...
IF (data%do_upt) THEN
_FLUX_VAR_(data%id_upttarget) = _FLUX_VAR_(data%id_upttarget) + (-primprod)
ENDIF
IF (data%do_mort) THEN
_FLUX_VAR_(data%id_morttarget) = _FLUX_VAR_(data%id_morttarget) + (rpd*p)
ENDIF
IF (data%do_exc) THEN
_FLUX_VAR_(data%id_exctarget) = _FLUX_VAR_(data%id_exctarget) + (data%rpn*p)
ENDIF
! Export diagnostic variables
_DIAG_VAR_(data%id_dPAR) = par
_DIAG_VAR_(data%id_GPP ) = primprod*secs_per_day
_DIAG_VAR_(data%id_NCP ) = (primprod - data%rpn*p)*secs_per_day
_DIAG_VAR_(data%id_PPR ) = primprod/(data%rpn*p - rpd*p)
_DIAG_VAR_(data%id_NPR ) = (primprod - data%rpn*p)/(data%rpn*p - rpd*p)
END SUBROUTINE aed2_calculate_chla
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!###############################################################################
SUBROUTINE aed2_light_extinction_chla(data,column,layer_idx,extinction)
!-------------------------------------------------------------------------------
! Get the light extinction coefficient due to biogeochemical variables
!-------------------------------------------------------------------------------
!ARGUMENTS
CLASS (aed2_chla_data_t),INTENT(in) :: data
TYPE (aed2_column_t),INTENT(inout) :: column(:)
INTEGER,INTENT(in) :: layer_idx
AED_REAL,INTENT(inout) :: extinction
!
!LOCALS
AED_REAL :: p
!
!-------------------------------------------------------------------------------
!BEGIN
! Retrieve current (local) state variable values.
p = _STATE_VAR_(data%id_p)! phytoplankton
! Self-shading with explicit contribution from background phytoplankton concentration.
extinction = extinction + (0.0*p)
END SUBROUTINE aed2_light_extinction_chla
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!###############################################################################
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!###############################################################################
PURE AED_REAL FUNCTION fnp(data,n,p,par,iopt)
!-------------------------------------------------------------------------------
! Michaelis-Menten formulation for nutrient uptake
!-------------------------------------------------------------------------------
!ARGUMENTS
CLASS (aed2_chla_data_t),INTENT(in) :: data
AED_REAL,INTENT(in) :: n,p,par,iopt
!
!-------------------------------------------------------------------------------
!BEGIN
fnp = data%rmax*par/iopt*exp(one_-par/iopt)*n/(data%alpha+n)*(p+data%p0)
END FUNCTION fnp
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
END MODULE aed2_chlorophylla