-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
built-in models: add tracer and test case (#103)
* add builtin/tracer * correct output visibility of result of single-term sums * set units for result of aggregate sums and source sums * add test case for builtin models * use standard unit notation for sources
- Loading branch information
Showing
7 changed files
with
202 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "fabm_driver.h" | ||
|
||
module fabm_builtin_tracer | ||
|
||
! This model describe a single passive tracer. Optionally, a vertical velocity | ||
! (sinking/floating) and light attenuation coefficient can be specified. | ||
! The unit is mol/m^3 by default, but may be explicitly configured as well. | ||
|
||
use fabm_types | ||
|
||
implicit none | ||
|
||
private | ||
|
||
type, extends(type_base_model), public :: type_tracer | ||
! Variables | ||
type (type_state_variable_id) :: id_c | ||
contains | ||
procedure initialize | ||
end type | ||
|
||
contains | ||
|
||
subroutine initialize(self, configunit) | ||
class (type_tracer), intent(inout), target :: self | ||
integer, intent(in) :: configunit | ||
|
||
character(len=64) :: units | ||
real(rk) :: vertical_velocity | ||
real(rk) :: specific_light_attenuation | ||
real(rk), parameter :: days_per_second = 1.0_rk/86400.0_rk | ||
logical :: conserved | ||
character(len=attribute_length) :: standard_name | ||
|
||
call self%register_implemented_routines() | ||
|
||
! Retrieve parameter values | ||
call self%get_parameter(units, 'units', default='mol m-3') | ||
call self%get_parameter(vertical_velocity, 'vertical_velocity', 'm d-1', 'vertical velocity (negative for settling, positive for rising)', default=0.0_rk, scale_factor=days_per_second) | ||
call self%get_parameter(specific_light_attenuation, 'specific_light_attenuation', 'm-1 ('//trim(units)//')-1', 'specific light attenuation', default=0.0_rk) | ||
call self%get_parameter(conserved, 'conserved', '', 'treat tracer as conserved quantity (activates budget tracking in host)', default=.false.) | ||
|
||
! Register state variables | ||
call self%register_state_variable(self%id_c, 'c', units, 'concentration', 1.0_rk, & | ||
minimum=0.0_rk, vertical_movement=vertical_velocity, specific_light_extinction=specific_light_attenuation) | ||
|
||
if (conserved) then | ||
! User has activated conservation checking. | ||
! We create a "conserved quantity" for this tracer, which should induce the host model to compute and save the integral across the domain. | ||
standard_name = get_safe_name(trim(self%get_path()) // '_total') | ||
call self%add_to_aggregate_variable(type_universal_standard_variable(name=standard_name(2:), units=units, aggregate_variable=.true., conserved=.true.), self%id_c) | ||
end if | ||
end subroutine initialize | ||
|
||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
instances: | ||
tracer: | ||
model: tracer | ||
interior_constant: | ||
model: interior_constant | ||
parameters: | ||
value: 1.0 | ||
horizontal_constant: | ||
model: horizontal_constant | ||
parameters: | ||
value: 1.0 | ||
surface_constant: | ||
model: horizontal_constant | ||
parameters: | ||
value: 1.0 | ||
bottom_constant: | ||
model: horizontal_constant | ||
parameters: | ||
value: 1.0 | ||
global_constant: | ||
model: global_constant | ||
parameters: | ||
value: 1.0 | ||
interior_sum_empty: | ||
model: weighted_sum | ||
parameters: | ||
n: 0 | ||
interior_sum_1term: | ||
model: weighted_sum | ||
parameters: | ||
n: 1 | ||
coupling: | ||
term1: interior_constant/data | ||
interior_sum_nterms: | ||
model: weighted_sum | ||
parameters: | ||
n: 2 | ||
coupling: | ||
term1: tracer/c | ||
term2: interior_constant/data | ||
interior_sum_1term_scaled: | ||
model: weighted_sum | ||
parameters: | ||
n: 1 | ||
weight1: 2.0 | ||
coupling: | ||
term1: interior_constant/data | ||
interior_sum_nterm_scaled: | ||
model: weighted_sum | ||
parameters: | ||
n: 2 | ||
weight1: 1.0 | ||
weight2: 2.0 | ||
coupling: | ||
term1: tracer/c | ||
term2: interior_constant/data | ||
horizontal_sum_empty: | ||
model: horizontal_weighted_sum | ||
parameters: | ||
n: 0 | ||
horizontal_sum_1term: | ||
model: horizontal_weighted_sum | ||
parameters: | ||
n: 1 | ||
coupling: | ||
term1: horizontal_constant/data | ||
horizontal_sum_nterms: | ||
model: horizontal_weighted_sum | ||
parameters: | ||
n: 3 | ||
coupling: | ||
term1: horizontal_constant/data | ||
term2: surface_constant/data | ||
term3: bottom_constant/data | ||
horizontal_sum_1term_scaled: | ||
model: horizontal_weighted_sum | ||
parameters: | ||
n: 1 | ||
weight1: 2.0 | ||
coupling: | ||
term1: horizontal_constant/data | ||
horizontal_sum_nterms_scaled: | ||
model: horizontal_weighted_sum | ||
parameters: | ||
n: 3 | ||
weight1: 1.0 | ||
weight2: 2.0 | ||
weight3: 3.0 | ||
coupling: | ||
term1: horizontal_constant/data | ||
term2: surface_constant/data | ||
term3: bottom_constant/data | ||
bottom_layer: | ||
model: bottom_layer | ||
coupling: | ||
source: tracer/c | ||
surface_layer: | ||
model: surface_layer | ||
coupling: | ||
source: tracer/c | ||
vertical_integral: | ||
model: vertical_integral | ||
coupling: | ||
source: tracer/c | ||
vertical_average: | ||
model: vertical_integral | ||
parameters: | ||
average: true | ||
coupling: | ||
source: tracer/c | ||
bounded_vertical_integral: | ||
model: bounded_vertical_integral | ||
parameters: | ||
minimum_depth: 10.0 | ||
maximum_depth: 20.0 | ||
coupling: | ||
source: tracer/c | ||
bounded_vertical_average: | ||
model: bounded_vertical_integral | ||
parameters: | ||
average: true | ||
minimum_depth: 10.0 | ||
maximum_depth: 20.0 | ||
coupling: | ||
source: tracer/c | ||
|