Skip to content

Commit

Permalink
Merge branch 'master' into 95-code-breaks-if-iswcal=0
Browse files Browse the repository at this point in the history
  • Loading branch information
wathen authored Feb 22, 2024
2 parents 760a2b0 + a018ee0 commit c72d53d
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ git clone https://github.com/pmlmodelling/ersem-setups.git
cd ersem-setups/0d-aquarium

echo "Running FABM with repo configuration"
~/local/fabm/0d/bin/fabm0d -y ../L4/fabm.yaml
~/local/fabm/0d/bin/fabm0d -y ../../ersem/testcases/fabm-ersem-15.06-L4-ben-docdyn-iop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

echo "Installing netCDF"
sudo apt update
sudo apt install libnetcdff-dev
sudo apt install libnetcdff-dev cmake
1 change: 1 addition & 0 deletions github-actions/gotm-fabm-ersem/gotm-tut-config-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
echo "Cloning config repo"
git clone https://github.com/pmlmodelling/ersem-setups.git

cp ersem/testcases/fabm-ersem-15.06-L4-ben-docdyn-iop.yaml ersem-setups/L4/fabm.yaml
cd ersem-setups/L4

echo "Running GOTM with repo configuration"
Expand Down
6 changes: 5 additions & 1 deletion github-actions/gotm-fabm-ersem/test_profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_ersem_func_names(self):
name = self.ersem["name"].tolist()
name_expected = self.ersem_expected["name"].tolist()
self.assertListEqual(sorted(name_expected), sorted(name))

@pytest.mark.skip()
def test_gotm_func_names(self):
"""
Expand Down Expand Up @@ -154,6 +154,7 @@ def test_netcdf_func_names(self):
name_expected = self.netcdf_expected["name"].tolist()
self.assertListEqual(sorted(name_expected), sorted(name))

@pytest.mark.skip()
def test_ersem_func_calls(self):
"""
Check the number of func calls for ERSEM modules stays the same
Expand All @@ -169,6 +170,7 @@ def test_ersem_func_calls(self):
self.ersem["name"], self.ersem['self calls'])}
assert calls == calls_expected

@pytest.mark.skip()
def test_gotm_func_calls(self):
"""
Check the number of func calls for GOTM modules stays the same
Expand All @@ -182,6 +184,7 @@ def test_gotm_func_calls(self):
{n: c for n, c in zip(self.gotm["name"], self.gotm['self calls'])}
assert calls == calls_expected

@pytest.mark.skip()
def test_fabm_func_calls(self):
"""
Check the number of func calls for FABM modules stays the same
Expand All @@ -195,6 +198,7 @@ def test_fabm_func_calls(self):
{n: c for n, c in zip(self.fabm["name"], self.fabm['self calls'])}
assert calls == calls_expected

@pytest.mark.skip()
def test_netcdf_func_calls(self):
"""
Check the number of func calls for NETCDF modules stays the same
Expand Down
8 changes: 5 additions & 3 deletions github-actions/pyfabm-ersem/pyfabm-ersem-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ git clone https://github.com/fabm-model/fabm.git
echo "Checking out branch: $BRANCH"
cd ersem && git checkout $BRANCH && cd ..

echo "Moving ERSEM config files for pyFABM"
cp github-actions/pyfabm-ersem/setup.cfg fabm

echo "Building PyFABM-ERSEM"
mkdir build && cd build
cmake ../fabm/src/drivers/python -DFABM_ERSEM_BASE=../ersem
make install
cd fabm
python -m pip install .
4 changes: 4 additions & 0 deletions github-actions/pyfabm-ersem/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build_ext]
cmake_opts=-DFABM_ERSEM_BASE=../ersem
force=1
debug=1
11 changes: 10 additions & 1 deletion src/benthic_column_particulate_matter.F90
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ module ersem_benthic_column_particulate_matter
type,extends(type_ersem_benthic_base),public :: type_ersem_benthic_column_particulate_matter
type (type_bottom_state_variable_id) :: id_penetration_c,id_penetration_n,id_penetration_p,id_penetration_s
type (type_bottom_state_variable_id) :: id_buried_c,id_buried_n,id_buried_p,id_buried_s
type (type_bottom_state_variable_id) :: id_resuspendable_c,id_resuspendable_p,id_resuspendable_n,id_resuspendable_s
type (type_horizontal_diagnostic_variable_id) :: id_burial_flux_c, id_burial_flux_n, id_burial_flux_p, id_burial_flux_s
type (type_bottom_state_variable_id) :: id_resuspendable_c,id_resuspendable_p,id_resuspendable_n,id_resuspendable_s
type (type_horizontal_dependency_id) :: id_D, id_z_tur, id_d_tot, id_er

logical :: burial
Expand Down Expand Up @@ -426,18 +427,22 @@ subroutine initialize(self,configunit)
if (_VARIABLE_REGISTERED_(self%id_c)) then
call self%register_state_dependency(self%id_buried_c,'buried_c','mg C/m^2','buried carbon')
call self%request_coupling_to_model(self%id_buried_c,'burial_target','c')
call self%register_diagnostic_variable(self%id_burial_flux_c,'burial_flux_c','mg C/m^2/d','burial of carbon',source=source_do_bottom)
end if
if (_VARIABLE_REGISTERED_(self%id_p)) then
call self%register_state_dependency(self%id_buried_p,'buried_p','mmol P/m^2','buried phosphorus')
call self%request_coupling_to_model(self%id_buried_p,'burial_target','p')
call self%register_diagnostic_variable(self%id_burial_flux_p,'burial_flux_p','mmol P/m^2/d','burial of phosphorus',source=source_do_bottom)
end if
if (_VARIABLE_REGISTERED_(self%id_n)) then
call self%register_state_dependency(self%id_buried_n,'buried_n','mmol N/m^2','buried nitrogen')
call self%request_coupling_to_model(self%id_buried_n,'burial_target','n')
call self%register_diagnostic_variable(self%id_burial_flux_n,'burial_flux_n','mmol N/m^2/d','burial of nitrogen',source=source_do_bottom)
end if
if (_VARIABLE_REGISTERED_(self%id_s)) then
call self%register_state_dependency(self%id_buried_s,'buried_s','mmol Si/m^2','buried silicate')
call self%request_coupling_to_model(self%id_buried_s,'burial_target','s')
call self%register_diagnostic_variable(self%id_burial_flux_s,'burial_flux_s','mmol Si/m^2/d','burial of silicate',source=source_do_bottom)
end if
end if

Expand Down Expand Up @@ -508,6 +513,7 @@ subroutine do_bottom(self,_ARGUMENTS_DO_BOTTOM_)
burial_flux = C_int/(1.0_rk - exp(-z_bot/z_mean))*exp(-z_bot/z_mean)*z_bot/z_mean*z_mean_sms/z_mean
_SET_BOTTOM_ODE_(self%id_c,-burial_flux)
_SET_BOTTOM_ODE_(self%id_buried_c,burial_flux)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_burial_flux_c,burial_flux)
end if
if (self%resuspension) then
_GET_HORIZONTAL_(self%id_c,C_int)
Expand All @@ -526,6 +532,7 @@ subroutine do_bottom(self,_ARGUMENTS_DO_BOTTOM_)
burial_flux = C_int/(1.0_rk - exp(-z_bot/z_mean))*exp(-z_bot/z_mean)*z_bot/z_mean*z_mean_sms/z_mean
_SET_BOTTOM_ODE_(self%id_p,-burial_flux)
_SET_BOTTOM_ODE_(self%id_buried_p,burial_flux)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_burial_flux_p,burial_flux)
end if
if (self%resuspension) then
_GET_HORIZONTAL_(self%id_p,C_int)
Expand All @@ -544,6 +551,7 @@ subroutine do_bottom(self,_ARGUMENTS_DO_BOTTOM_)
burial_flux = C_int/(1.0_rk - exp(-z_bot/z_mean))*exp(-z_bot/z_mean)*z_bot/z_mean*z_mean_sms/z_mean
_SET_BOTTOM_ODE_(self%id_n,-burial_flux)
_SET_BOTTOM_ODE_(self%id_buried_n,burial_flux)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_burial_flux_n,burial_flux)
end if
if (self%resuspension) then
_GET_HORIZONTAL_(self%id_n,C_int)
Expand All @@ -562,6 +570,7 @@ subroutine do_bottom(self,_ARGUMENTS_DO_BOTTOM_)
burial_flux = C_int/(1.0_rk - exp(-z_bot/z_mean))*exp(-z_bot/z_mean)*z_bot/z_mean*z_mean_sms/z_mean
_SET_BOTTOM_ODE_(self%id_s,-burial_flux)
_SET_BOTTOM_ODE_(self%id_buried_s,burial_flux)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_burial_flux_s,burial_flux)
end if
if (self%resuspension) then
_GET_HORIZONTAL_(self%id_s,C_int)
Expand Down
7 changes: 4 additions & 3 deletions src/benthic_fauna.F90
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,10 @@ subroutine do_bottom(self,_ARGUMENTS_DO_BOTTOM_)

_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYKIn,excess_n)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYK1p,excess_p)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYQPc,mortflux*cP+excess_c)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYQPn,mortflux*cP*self%qnc)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYQPp,mortflux*cP*self%qpc)
! fluxes from fauna to POC
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYQPc,mortflux*cP+excess_c+fBTYc-nfBTYc)
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYQPn,mortflux*cP*self%qnc+sum(grossfluxn)-sum(netfluxn))
_SET_HORIZONTAL_DIAGNOSTIC_(self%id_fYQPp,mortflux*cP*self%qpc+sum(grossfluxp) - sum(netfluxp))

if (.not.legacy_ersem_compatibility) then
! Alkalinity contributions: +1 for NH4, -1 for PO4
Expand Down
4 changes: 4 additions & 0 deletions testcases/fabm-ersem-15.06-L4-ben-docdyn-iop-denit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ instances:
iswbioalk: 1 # use bioalkalinity (0: off, 1: on), default = 1
initialization:
c: 2130.0 # total dissolved inorganic carbon (mmol C/m^3)
bioalk: 0 # bioalkalinity (mmol/m^3)
R1:
long_name: labile dissolved organic matter
model: ersem/pelagic_base
Expand Down Expand Up @@ -803,6 +804,7 @@ instances:
minD: 0.0001 # minimum depth of zero-concentration isocline (m)
initialization:
o: 0.0225 # oxygen (mmol/m^2)
o_deep: 0 # oxygen below zero isocline (mmol/m^2)
coupling:
o_pel: O2/o # pelagic oxygen (mmol/m^3)
G3:
Expand Down Expand Up @@ -863,6 +865,8 @@ instances:
K4n2: K4/per_layer/n2 # benthic ammonium in 2nd layer (mmol N/m^2)
G2o2: G2/per_layer/o2 # oxygen in 2nd layer (mmol O_2/m^2)
layer2_thickness: ben_col/layer2_thickness # thickness of 2nd layer (m)
initialization:
G4n: 0 # dinitrogen gas (mmol N/m^2)
H1:
long_name: benthic aerobic bacteria
model: ersem/benthic_bacteria
Expand Down
4 changes: 4 additions & 0 deletions testcases/fabm-ersem-15.06-L4-ben-docdyn-iop-n2o.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ instances:
iswbioalk: 1 # use bioalkalinity (0: off, 1: on), default = 1
initialization:
c: 2130.0 # total dissolved inorganic carbon (mmol C/m^3)
bioalk: 0 # bioalkalinity (mmol/m^3)
R1:
long_name: labile dissolved organic matter
model: ersem/pelagic_base
Expand Down Expand Up @@ -796,6 +797,7 @@ instances:
minD: 0.0001 # minimum depth of zero-concentration isocline (m)
initialization:
o: 0.0225 # oxygen (mmol/m^2)
o_deep: 0 # oxygen below zero isocline (mmol/m^2)
coupling:
o_pel: O2/o # pelagic oxygen (mmol/m^3)
G5:
Expand Down Expand Up @@ -868,6 +870,8 @@ instances:
K4n2: K4/per_layer/n2 # benthic ammonium in 2nd layer (mmol N/m^2)
G2o2: G2/per_layer/o2 # oxygen in 2nd layer (mmol O_2/m^2)
layer2_thickness: ben_col/layer2_thickness # thickness of 2nd layer (m)
initialization:
G4n: 0 # dinitrogen gas (mmol N/m^2)
H1:
long_name: benthic aerobic bacteria
model: ersem/benthic_bacteria
Expand Down
4 changes: 4 additions & 0 deletions testcases/fabm-ersem-15.06-L4-ben-docdyn-iop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ instances:
iswbioalk: 1 # use bioalkalinity (0: off, 1: on), default = 1
initialization:
c: 2130.0 # total dissolved inorganic carbon (mmol C/m^3)
bioalk: 0 # bioalkalinity (mmol/m^3)
R1:
long_name: labile dissolved organic matter
model: ersem/pelagic_base
Expand Down Expand Up @@ -787,6 +788,7 @@ instances:
minD: 0.0001 # minimum depth of zero-concentration isocline (m)
initialization:
o: 0.0225 # oxygen (mmol/m^2)
o_deep: 0 # oxygen below zero isocline (mmol/m^2)
coupling:
o_pel: O2/o # pelagic oxygen (mmol/m^3)
G3:
Expand Down Expand Up @@ -847,6 +849,8 @@ instances:
K4n2: K4/per_layer/n2 # benthic ammonium in 2nd layer (mmol N/m^2)
G2o2: G2/per_layer/o2 # oxygen in 2nd layer (mmol O_2/m^2)
layer2_thickness: ben_col/layer2_thickness # thickness of 2nd layer (m)
initialization:
G4n: 0 # dinitrogen gas (mmol N/m^2)
H1:
long_name: benthic aerobic bacteria
model: ersem/benthic_bacteria
Expand Down
1 change: 1 addition & 0 deletions testcases/fabm-ersem-15.06-L4-noben-docdyn-iop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ instances:
iswbioalk: 1 # use bioalkalinity (0: off, 1: on), default = 1
initialization:
c: 2130.0 # total dissolved inorganic carbon (mmol C/m^3)
bioalk: 0 # bioalkalinity (mmol/m^3)
R1:
long_name: labile dissolved organic matter
model: ersem/pelagic_base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ instances:
iswbioalk: 1 # use bioalkalinity (0: off, 1: on), default = 1
initialization:
c: 2130.0 # total dissolved inorganic carbon (mmol C/m^3)
bioalk: 0 # bioalkalinity (mmol/m^3)
R1:
long_name: labile dissolved organic matter
model: ersem/pelagic_base
Expand Down Expand Up @@ -768,6 +769,7 @@ instances:
minD: 0.0001 # minimum depth of zero-concentration isocline (m)
initialization:
o: 0.0225 # oxygen (mmol/m^2)
o_deep: 0 # oxygen below zero isocline (mmol/m^2)
coupling:
o_pel: O2/o # pelagic oxygen (mmol/m^3)
G3:
Expand Down Expand Up @@ -828,6 +830,8 @@ instances:
K4n2: K4/per_layer/n2 # benthic ammonium in 2nd layer (mmol N/m^2)
G2o2: G2/per_layer/o2 # oxygen in 2nd layer (mmol O_2/m^2)
layer2_thickness: ben_col/layer2_thickness # thickness of 2nd layer (m)
initialization:
G4n: 0 # dinitrogen gas (mmol N/m^2)
H1:
long_name: benthic aerobic bacteria
model: ersem/benthic_bacteria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ instances:
iswbioalk: 1 # use bioalkalinity (0: off, 1: on), default = 1
initialization:
c: 2130.0 # total dissolved inorganic carbon (mmol C/m^3)
bioalk: 0 # bioalkalinity (mmol/m^3)
R1:
long_name: labile dissolved organic matter
model: ersem/pelagic_base
Expand Down

0 comments on commit c72d53d

Please sign in to comment.