Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/fabm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
env:
FFLAGS: ${{ env.FFLAGS }} -fp-model precise -fp-model source
ifx:
# for available versions, see https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/intel-oneapi-compilers/package.py
# for available versions, see https://github.com/spack/spack-packages/blob/develop/repos/spack_repo/builtin/packages/intel_oneapi_compilers/package.py
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
Expand Down Expand Up @@ -221,7 +221,7 @@ jobs:
- name: Run all test cases with pyfabm
run: python util/developers/run_all_testcases.py pyfabm --show_logs --compiler /home/runner/nvhpc/Linux_x86_64/${{ matrix.version }}/compilers/bin/pgfortran
aocc:
# for available versions, see https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/aocc/package.py
# for available versions, see https://github.com/spack/spack-packages/blob/develop/repos/spack_repo/builtin/packages/aocc/package.py
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
Expand Down
9 changes: 8 additions & 1 deletion src/fabm_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ module fabm_types
procedure :: request_coupling_ll
procedure :: request_coupling_il
procedure :: request_coupling_lt
generic :: request_coupling => request_coupling_ln, request_coupling_in, request_coupling_nn, &
procedure :: request_coupling_nn_ ! Workaround aocc/nvfortran bug that breaks generic when procedure is overridden
generic :: request_coupling => request_coupling_ln, request_coupling_in, request_coupling_nn_, &
request_coupling_ls, request_coupling_is, &
request_coupling_ll, request_coupling_il, &
request_coupling_lt
Expand Down Expand Up @@ -1446,6 +1447,12 @@ subroutine request_coupling_ln(self, link, target_name)
task%target_name = target_name
end subroutine request_coupling_ln

subroutine request_coupling_nn_(self, name, target_name)
class (type_base_model), intent(inout), target :: self
character(len=*), intent(in) :: name, target_name
call self%request_coupling_nn(name, target_name)
end subroutine

recursive subroutine request_coupling_nn(self, name, target_name)
class (type_base_model), intent(inout), target :: self
character(len=*), intent(in) :: name, target_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ subroutine create(self, name, model)
class (type_base_model), pointer :: model

select case (name)
case ('particle'); allocate(type_passive_particle::model)
case ('particle'); allocate(type_passive_particle_cs::model)
case ('particle_cs'); allocate(type_passive_particle_cs::model)
case ('particle_vs'); allocate(type_passive_particle_vs::model)
!case ('migration'); allocate(type_templates_migration::model)
case ('depth_integrated_predator'); allocate(type_depth_integrated_predator::model)
case default
Expand Down
50 changes: 44 additions & 6 deletions src/models/examples/particle/passive_particle.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,64 @@

module examples_particle_passive_particle

! A passive particle

! Two types are provided:
! * type_passive_particle_cs has constant C:N:P stoichoiometry.
! Its concentration is expressed in carbon units.
! Elemental ratios N:C and P:C are configurable and default to Redfield.
! * type_passive_particle_vs has variable C:N:P stoichoiometry.

use fabm_particle
use fabm_types

implicit none

private

type, extends(type_particle_model), public :: type_passive_particle
type, extends(type_particle_model), public :: type_passive_particle_cs
type (type_state_variable_id) :: id_c
contains
procedure :: initialize => initialize_cs
end type

type, extends(type_particle_model), public :: type_passive_particle_vs
type (type_state_variable_id) :: id_c
type (type_state_variable_id) :: id_n
type (type_state_variable_id) :: id_p
contains
procedure :: initialize
procedure :: initialize => initialize_vs
end type

contains

subroutine initialize(self, configunit)
class (type_passive_particle), intent(inout), target :: self
integer, intent(in) :: configunit
subroutine initialize_cs(self, configunit)
class (type_passive_particle_cs), intent(inout), target :: self
integer, intent(in) :: configunit

real(rk) :: NC, PC

call self%register_state_variable(self%id_c, 'c', 'mmol C m-3', 'concentration')

call self%get_parameter(NC, 'NC', 'mol N mol C-1', 'nitrogen : carbon ratio', default=16.0_rk/ 106.0_rk)
call self%get_parameter(PC, 'PC', 'mol P mol C-1', 'phosphorus : carbon ratio', default=1.0_rk/ 106.0_rk)

call self%add_to_aggregate_variable(standard_variables%total_carbon, self%id_c)
call self%add_to_aggregate_variable(standard_variables%total_nitrogen, self%id_c, scale_factor=NC)
call self%add_to_aggregate_variable(standard_variables%total_phosphorus, self%id_c, scale_factor=PC)
end subroutine

subroutine initialize_vs(self, configunit)
class (type_passive_particle_vs), intent(inout), target :: self
integer, intent(in) :: configunit

call self%register_state_variable(self%id_c, 'c', 'mmol C m-3', 'carbon')
call self%register_state_variable(self%id_n, 'n', 'mmol N m-3', 'nitrogen')
call self%register_state_variable(self%id_p, 'p', 'mmol P m-3', 'phosphorus')

call self%register_state_variable(self%id_c, 'c', 'mmol m-3', 'concentration')
call self%add_to_aggregate_variable(standard_variables%total_carbon, self%id_c)
call self%add_to_aggregate_variable(standard_variables%total_nitrogen, self%id_n)
call self%add_to_aggregate_variable(standard_variables%total_phosphorus, self%id_p)
end subroutine

end module
17 changes: 17 additions & 0 deletions testcases/fabm-examples-particle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
instances:
plankton:
model: examples/particle/particle_cs
initialization:
c: 1.0 # concentration [mmol C m-3; default=0.0]
detritus:
model: examples/particle/particle_vs
predator:
model: examples/particle/depth_integrated_predator
parameters:
clearance_rate: 0.1 # clearance rate [m3 d-1 mmol-1]
mortality: 0.02 # mortality [d-1]
initialization:
c: 0.001 # density [mmol C m-2; default=0.0]
coupling:
prey: plankton
waste: detritus
Loading