Grow the persistent send/recv buffers to hold at least a wide 2D exchange at ghost width ng_wide. Uses the same exit-delete / dealloc / alloc / enter-create pattern as ocean_halo_buffers_ensure_nz. Safe to call with ng_wide == oh_nghost (no-op if already large enough).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ng_wide |
Wide ghost cell width required |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | need_ew | ||||
| integer, | private | :: | need_ns | ||||
| integer, | private | :: | nxt_wide | ||||
| integer, | private | :: | nyt_wide |
subroutine ocean_halo_buffers_ensure_wide(ng_wide) !! Grow the persistent send/recv buffers to hold at least a wide !! 2D exchange at ghost width ng_wide. !! Uses the same exit-delete / dealloc / alloc / enter-create pattern !! as ocean_halo_buffers_ensure_nz. Safe to call with ng_wide == !! oh_nghost (no-op if already large enough). integer, intent(in) :: ng_wide !! Wide ghost cell width required integer :: nyt_wide, nxt_wide, need_ew, need_ns nyt_wide = oh_ny_local + 2*ng_wide nxt_wide = oh_nx_local + 2*ng_wide ! face-x send-east uses (ng_wide+1)*nyt_wide; face-y send-north uses ! (ng_wide+1)*nxt_wide. need_ew = (ng_wide + 1)*nyt_wide need_ns = (ng_wide + 1)*nxt_wide if (need_ew <= oh_cap_ew .and. need_ns <= oh_cap_ns) return call logger%warning("ocean_halo_buffers_ensure_wide: growing halo buffers "// & "mid-run (E/W: "//to_string(oh_cap_ew)//" -> "// & to_string(need_ew)//", N/S: "//to_string(oh_cap_ns)//" -> "// & to_string(need_ns)//"). "// & "Call ocean_halo_reserve(nz, ng_wide) at init to avoid "// & "a mid-run device reallocation (breaks UCX IPC handle reuse).") if (need_ew > oh_cap_ew) then !$acc exit data delete(oh_buf_send_east, oh_buf_recv_east, & !$acc& oh_buf_send_west, oh_buf_recv_west) deallocate (oh_buf_send_east, oh_buf_recv_east) deallocate (oh_buf_send_west, oh_buf_recv_west) allocate (oh_buf_send_east(need_ew), oh_buf_recv_east(need_ew)) allocate (oh_buf_send_west(need_ew), oh_buf_recv_west(need_ew)) !$acc enter data create(oh_buf_send_east, oh_buf_recv_east, & !$acc& oh_buf_send_west, oh_buf_recv_west) oh_cap_ew = need_ew end if if (need_ns > oh_cap_ns) then !$acc exit data delete(oh_buf_send_north, oh_buf_recv_north, & !$acc& oh_buf_send_south, oh_buf_recv_south) deallocate (oh_buf_send_north, oh_buf_recv_north) deallocate (oh_buf_send_south, oh_buf_recv_south) allocate (oh_buf_send_north(need_ns), oh_buf_recv_north(need_ns)) allocate (oh_buf_send_south(need_ns), oh_buf_recv_south(need_ns)) !$acc enter data create(oh_buf_send_north, oh_buf_recv_north, & !$acc& oh_buf_send_south, oh_buf_recv_south) oh_cap_ns = need_ns end if end subroutine ocean_halo_buffers_ensure_wide