Configure the equilibrium body-force tide slot (C1): parse the
constituent list + reference dates, fill the astronomy catalog
(phase0, nodal f/u), and build the (nx,ny,3) spatial-structure
arrays from metrics%geolatT/geolonT. Host-side setup — runs
AFTER configure_ocean_metrics (lat/lon must be filled) and
BEFORE ocean_state_enter_data. enable=.false. => no-op,
bit-identical.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(config_t), | intent(in) | :: | cfg | |||
| type(ocean_state_t), | intent(inout) | :: | ocean_state | |||
| type(hgrid_t), | intent(in) | :: | grid | |||
| integer, | intent(in) | :: | compute_rank | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a tides configuration conflict when present;
absent behaves as today ( |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | cat_idx(TIDES_CATALOG_SIZE) | ||||
| integer, | private | :: | d | ||||
| real(kind=wp), | private | :: | dnodal | ||||
| real(kind=wp), | private | :: | dref | ||||
| integer, | private | :: | local_ierr | ||||
| integer, | private | :: | m | ||||
| integer, | private | :: | nconst | ||||
| character(len=16), | private | :: | nodal_str | ||||
| integer, | private | :: | nx | ||||
| integer, | private | :: | ny | ||||
| logical, | private | :: | ok | ||||
| integer, | private | :: | y |
subroutine configure_ocean_tides(cfg, ocean_state, grid, compute_rank, ierr) !! Configure the equilibrium body-force tide slot (C1): parse the !! constituent list + reference dates, fill the astronomy catalog !! (phase0, nodal f/u), and build the (nx,ny,3) spatial-structure !! arrays from `metrics%geolatT/geolonT`. Host-side setup — runs !! AFTER `configure_ocean_metrics` (lat/lon must be filled) and !! BEFORE `ocean_state_enter_data`. `enable=.false.` => no-op, !! bit-identical. type(config_t), intent(in) :: cfg type(ocean_state_t), intent(inout) :: ocean_state type(hgrid_t), intent(in) :: grid integer, intent(in) :: compute_rank integer, intent(out), optional :: ierr !! Non-zero on a tides configuration conflict when present; !! absent behaves as today (`error stop`). integer :: cat_idx(TIDES_CATALOG_SIZE) integer :: nconst, y, m, d, nx, ny, local_ierr real(wp) :: dref, dnodal logical :: ok character(len=16) :: nodal_str associate (td => ocean_state%tides, tcfg => cfg%ocean%tides) td%enable = tcfg%enable if (.not. tcfg%enable) then if (present(ierr)) ierr = OCEAN_STATUS_OK return end if td%use_sal = tcfg%use_sal td%beta_sal = tcfg%beta_sal td%t_epoch = 0.0_wp if (td%use_sal .and. td%beta_sal <= 0.0_wp .and. compute_rank == 0) then call logger%warning("ocean_tides_nml: use_sal=.true. but "// & "beta_sal<=0 => scalar SAL is inert "// & "(typical beta ~0.085-0.12)") end if ! Parse the active constituent list -> catalog indices. if (present(ierr)) then call parse_constituent_list(tcfg%constituents, cat_idx, nconst, ierr=local_ierr) if (local_ierr /= 0) then ierr = local_ierr return end if else call parse_constituent_list(tcfg%constituents, cat_idx, nconst) end if if (nconst < 1) then call fail("ocean_tides_nml: constituents='"// & trim(tcfg%constituents)//"' has no valid entries", ierr, OCEAN_STATUS_ERR_SETUP) return end if ! Reference date -> day number since 1900-01-01. call parse_date_string(tcfg%ref_date, y, m, d, ok) if (.not. ok) then call fail("ocean_tides_nml: bad ref_date '"// & trim(tcfg%ref_date)//"' (want YYYY-MM-DD)", ierr, OCEAN_STATUS_ERR_SETUP) return end if dref = days_since_1900(y, m, d) nodal_str = tcfg%nodal_ref_date if (len_trim(nodal_str) == 0) nodal_str = tcfg%ref_date call parse_date_string(nodal_str, y, m, d, ok) if (.not. ok) then call fail("ocean_tides_nml: bad nodal_ref_date '"// & trim(nodal_str)//"' (want YYYY-MM-DD)", ierr, OCEAN_STATUS_ERR_SETUP) return end if dnodal = days_since_1900(y, m, d) nx = grid%nx_total ny = grid%ny_total call tides_configure_astronomy(td, cat_idx(1:nconst), nconst, & dref, dnodal, tcfg%add_nodal, nx, ny) call tides_build_struct(td, ocean_state%metrics%geolatT, & ocean_state%metrics%geolonT, nx, ny) if (compute_rank == 0) then call logger%info("Equilibrium tide: C1 body force enabled ("// & to_string(nconst)//" constituents, ref="// & trim(tcfg%ref_date)//")") end if end associate if (present(ierr)) ierr = OCEAN_STATUS_OK end subroutine configure_ocean_tides