Shared tail of rdb_ocean_create_from_string AND
rdb_ocean_create_finalize (P2.5): engine_setup ->
resolved-n_inner check -> engine_enter_data -> finalize handle
bookkeeping. Consumes whatever geometry h%engine%staged_* fields
carry (empty/unset for the single-call path — byte-identical to
before P2.5). On any failure, destroys the WHOLE handle (F9) and
clears the single-live-handle guard; c_handle is c_null_ptr and
h is null on return in that case, matching rdb_ocean_destroy’s
out-null convention.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(c_ptr), | intent(inout) | :: | c_handle | |||
| type(ocean_handle_t), | intent(inout), | pointer | :: | h | ||
| integer(kind=c_int), | intent(out) | :: | status |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | ierr |
subroutine complete_ocean_create(c_handle, h, status) !! Shared tail of `rdb_ocean_create_from_string` AND !! `rdb_ocean_create_finalize` (P2.5): `engine_setup` -> !! resolved-`n_inner` check -> `engine_enter_data` -> finalize handle !! bookkeeping. Consumes whatever geometry `h%engine%staged_*` fields !! carry (empty/unset for the single-call path — byte-identical to !! before P2.5). On any failure, destroys the WHOLE handle (F9) and !! clears the single-live-handle guard; `c_handle` is `c_null_ptr` and !! `h` is null on return in that case, matching `rdb_ocean_destroy`'s !! out-null convention. type(c_ptr), intent(inout) :: c_handle type(ocean_handle_t), pointer, intent(inout) :: h integer(c_int), intent(out) :: status integer :: ierr call engine_setup(h%engine, h%cfg, ierr) if (ierr /= OCEAN_STATUS_OK) then status = int(ierr, c_int) call handle_destroy(c_handle) g_handle_live = .false. h => null() return end if if (h%engine%n_inner < 1) then call error_ring_push("rdb_ocean_create: barotropic substep count "// & "n_inner is unresolved (< 1) — set &ocean_bt_nml auto_n_inner "// & "= .true. or n_inner explicitly") status = int(OCEAN_STATUS_ERR_SETUP, c_int) call handle_destroy(c_handle) g_handle_live = .false. h => null() return end if h%n_inner = h%engine%n_inner ! ---- Device placement ---- call engine_enter_data(h%engine, h%cfg) ! `h%grid`/`h%state` are views onto the engine (see `ocean_handle_t`'s ! docstring) so every existing P2 accessor body below (`h%grid%...`, ! `h%state%...`) keeps working unchanged. h%grid = h%engine%grid h%state => h%engine%state h%device_mapped = .true. h%is_initialised = .true. h%is_pending = .false. status = int(OCEAN_STATUS_OK, c_int) end subroutine complete_ocean_create