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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | allocatable | :: | areaT(:,:) | |||
| real(kind=wp), | private | :: | col_sum | ||||
| integer, | private | :: | i | ||||
| integer, | private | :: | ic | ||||
| real(kind=wp), | private | :: | increment | ||||
| integer, | private | :: | j | ||||
| integer, | private | :: | k | ||||
| integer, | private | :: | nx | ||||
| integer, | private | :: | ny | ||||
| integer, | private | :: | nz | ||||
| real(kind=wp), | private | :: | w_dA |
subroutine ocean_budgets_drain_contributors(this) !! For each contributor: integrate `per_cell·mask·areaT` (over k) into !! `total_integrated`, then zero `per_cell` for the next window. class(ocean_budgets_t), intent(inout) :: this integer :: ic, i, j, k, nx, ny, nz real(wp) :: w_dA, col_sum, increment real(wp), allocatable :: areaT(:, :) if (.not. this%is_init) return if (.not. allocated(this%mask)) then allocate (this%mask, source=diag_mask_global(this%grid)) end if call budget_area_field(this, areaT) do ic = 1, this%n_contributors associate (c => this%contributors(ic)) if (.not. c%is_active) cycle if (.not. associated(c%per_cell)) cycle if (c%device_resident) then !$acc update self(c%per_cell) if_present end if nx = min(this%mask%nx, size(c%per_cell, 1)) ny = min(this%mask%ny, size(c%per_cell, 2)) nz = size(c%per_cell, 3) increment = 0.0_wp do j = 1, ny do i = 1, nx w_dA = this%mask%weight(i, j)*areaT(i, j) if (w_dA <= 0.0_wp) cycle col_sum = 0.0_wp do k = 1, nz col_sum = col_sum + c%per_cell(i, j, k) end do increment = increment + w_dA*col_sum end do end do c%total_integrated = c%total_integrated + increment c%per_cell = 0.0_wp if (c%device_resident) then !$acc update device(c%per_cell) if_present end if end associate end do end subroutine ocean_budgets_drain_contributors