| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | public, | allocatable | :: | areaT(:,:) |
Per-cell T-area (m²) copied from the metrics slot via |
||
| type(budget_contributor_t), | public, | allocatable | :: | contributors(:) | |||
| type(hgrid_t), | public | :: | grid | ||||
| logical, | public | :: | has_snapshot | = | .false. |
True once |
|
| logical, | public | :: | is_init | = | .false. | ||
| type(diag_mask_t), | public, | allocatable | :: | mask |
Optional region mask. Default = whole interior (built lazily);
reset via |
||
| integer, | public | :: | n_contributors | = | 0 | ||
| integer, | public | :: | n_contributors_max | = | 0 | ||
| integer, | public | :: | nbudgets | = | BUDGET_N_DEFAULT | ||
| real(kind=wp), | public | :: | values(BUDGET_N_DEFAULT) | = | 0.0_wp | ||
| real(kind=wp), | public | :: | values_init(BUDGET_N_DEFAULT) | = | 0.0_wp |
Counted allocatable footprint of the conservation budgets (own accumulator; registry contributors are counted by their owning slot) slot (0 when unallocated).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(in) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this |
For each contributor: integrate per_cell·mask·areaT (over k) into
total_integrated, then zero per_cell for the next window.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this |
Recompute this%values(:) from the current multilayer state.
Honours this%mask — sums are weighted by mask%weight · areaT.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this | |||
| type(multilayer_state_t), | intent(in) | :: | ms |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this | |||
| type(hgrid_t), | intent(in) | :: | grid |
Snapshot values_init from the current state. Call once
after the IC is set + the EOS has run, before stepping.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this | |||
| type(multilayer_state_t), | intent(in) | :: | ms |
Register a per-kernel contributor: store a non-owning pointer to
the kernel-owned per_cell + metadata. Set device_resident
when per_cell is GPU-mapped (drain syncs it). Idempotent on
name (re-registering updates the pointer, resets the integral).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this | |||
| character(len=*), | intent(in) | :: | name | |||
| integer, | intent(in) | :: | quantity | |||
| real(kind=wp), | intent(in), | target | :: | per_cell(:,:,:) | ||
| logical, | intent(in), | optional | :: | device_resident |
Cache the per-cell T-area (m²) from the metrics slot. After this,
physical integrals weight by mask%weight·areaT; before it they
fall back to grid%dx·grid%dy (= areaT on uniform Cartesian).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this | |||
| real(kind=wp), | intent(in) | :: | areaT(:,:) |
Override the default global mask. Useful for regional conservation diagnostics — “mass north of 30°S stays at FP.”
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_budgets_t), | intent(inout) | :: | this | |||
| type(diag_mask_t), | intent(in) | :: | mask |
type :: ocean_budgets_t logical :: is_init = .false. ! ---- Active integrals ---- integer :: nbudgets = BUDGET_N_DEFAULT real(wp) :: values(BUDGET_N_DEFAULT) = 0.0_wp real(wp) :: values_init(BUDGET_N_DEFAULT) = 0.0_wp logical :: has_snapshot = .false. !! True once `init_snapshot` has populated `values_init`. ! ---- Geometry cache ---- type(hgrid_t) :: grid real(wp), allocatable :: areaT(:, :) !! Per-cell T-area (m²) copied from the metrics slot via `set_area`. !! Physical integrals weight by `mask%weight·areaT`; falls back to !! `grid%dx·grid%dy` until set. ! ---- Region restriction ---- type(diag_mask_t), allocatable :: mask !! Optional region mask. Default = whole interior (built lazily); !! reset via `set_mask`. ! ---- Per-kernel contributors ---- ! Populated via `register_contributor`, drained each eval cadence. ! Budget identity: LHS = values(q) − values_init(q), ! RHS = Σ contributors of quantity q %total_integrated, residual = LHS − RHS. type(budget_contributor_t), allocatable :: contributors(:) integer :: n_contributors = 0 integer :: n_contributors_max = 0 contains procedure, non_overridable :: init => ocean_budgets_init procedure, non_overridable :: destroy => ocean_budgets_destroy procedure, non_overridable :: set_area => ocean_budgets_set_area procedure, non_overridable :: set_mask => ocean_budgets_set_mask procedure, non_overridable :: init_snapshot => ocean_budgets_init_snapshot procedure, non_overridable :: evaluate => ocean_budgets_evaluate procedure, non_overridable :: register_contributor => ocean_budgets_register_contributor procedure, non_overridable :: drain_contributors => ocean_budgets_drain_contributors procedure, non_overridable :: bytes => ocean_budgets_bytes end type ocean_budgets_t