Allocate communication buffers and local boxes for a tree that has already been created
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
subroutine mg_allocate_storage(mg) type(mg_t), intent(inout) :: mg integer :: i, id, lvl, nc integer :: n_send(0:mg%n_cpu-1, 3) integer :: n_recv(0:mg%n_cpu-1, 3) integer :: dsize(3) integer :: n_in, n_out, n_id if (.not. mg%tree_created) error stop "allocate_storage: tree is not yet created" if (mg%is_allocated) error stop "allocate_storage: tree is already allocated" do lvl = mg%lowest_lvl, mg%highest_lvl nc = mg%box_size_lvl(lvl) do i = 1, size(mg%lvls(lvl)%my_ids) id = mg%lvls(lvl)%my_ids(i) allocate(mg%boxes(id)%cc(0:nc+1, 0:nc+1, 0:nc+1,& mg_num_vars + mg%n_extra_vars)) ! Set all initial values to zero mg%boxes(id)%cc(:, :, :, :) = 0.0_dp end do end do allocate(mg%buf(0:mg%n_cpu-1)) call mg_ghost_cell_buffer_size(mg, n_send(:, 1), n_recv(:, 1), dsize(1)) call mg_restrict_buffer_size(mg, n_send(:, 2), n_recv(:, 2), dsize(2)) call mg_prolong_buffer_size(mg, n_send(:, 3), n_recv(:, 3), dsize(3)) do i = 0, mg%n_cpu-1 n_out = maxval(n_send(i, :) * dsize(:)) n_in = maxval(n_recv(i, :) * dsize(:)) n_id = maxval(n_send(i, :)) allocate(mg%buf(i)%send(n_out)) allocate(mg%buf(i)%recv(n_in)) allocate(mg%buf(i)%ix(n_id)) end do mg%is_allocated = .true. end subroutine mg_allocate_storage