reg_io_ok Function

private function reg_io_ok(local_ierr, ierr, ncid) result(ok)

Translate a raw nc_check-style status (0 = ok) from one of the nc_* reader calls in register_common into the caller’s ierr contract: .true. on success; on failure, .false. with ierr = OCEAN_STATUS_ERR_IO when ierr is present (closing ncid first, when given, so a mid-registration failure does not leak the file handle), or error stops with a generic message when ierr is absent — the SPECIFIC reason was already logged by nc_check/fail before this returns, so the legacy (no ierr) log output is unchanged; only the raw error stop text is generic (same idiom as rdb_bathymetry::bathy_io_ok, P0.1 F1/F2).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: local_ierr
integer, intent(out), optional :: ierr
integer, intent(in), optional :: ncid

Return Value logical


Calls

proc~~reg_io_ok~~CallsGraph proc~reg_io_ok reg_io_ok proc~nc_close nc_close proc~reg_io_ok->proc~nc_close nf90_close nf90_close proc~nc_close->nf90_close proc~nc_check nc_check proc~nc_close->proc~nc_check nf90_strerror nf90_strerror proc~nc_check->nf90_strerror proc~fail fail proc~nc_check->proc~fail error error proc~fail->error proc~error_ring_push error_ring_push proc~fail->proc~error_ring_push

Called by

proc~~reg_io_ok~~CalledByGraph proc~reg_io_ok reg_io_ok proc~register_common register_common proc~register_common->proc~reg_io_ok proc~ocean_data_input_register_2d ocean_data_input_register_2d proc~ocean_data_input_register_2d->proc~register_common proc~ocean_data_input_register_3d ocean_data_input_register_3d proc~ocean_data_input_register_3d->proc~register_common proc~ocean_data_input_register_segment_2d ocean_data_input_register_segment_2d proc~ocean_data_input_register_segment_2d->proc~register_common proc~ocean_data_input_register_segment_3d ocean_data_input_register_segment_3d proc~ocean_data_input_register_segment_3d->proc~register_common proc~ocean_data_input_load_static_2d ocean_data_input_load_static_2d proc~ocean_data_input_load_static_2d->proc~ocean_data_input_register_2d proc~register_tag register_tag proc~register_tag->proc~ocean_data_input_register_2d proc~ocean_data_forcing_configure ocean_data_forcing_configure proc~ocean_data_forcing_configure->proc~register_tag proc~seed_cavity_draft seed_cavity_draft proc~seed_cavity_draft->proc~ocean_data_input_load_static_2d proc~engine_setup engine_setup proc~engine_setup->proc~ocean_data_forcing_configure proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_cavity_draft

Variables

Type Visibility Attributes Name Initial
integer, private :: discard_ierr

Source Code

   function reg_io_ok(local_ierr, ierr, ncid) result(ok)
      !! Translate a raw `nc_check`-style status (0 = ok) from one of the
      !! `nc_*` reader calls in `register_common` into the caller's `ierr`
      !! contract: `.true.` on success; on failure, `.false.` with
      !! `ierr = OCEAN_STATUS_ERR_IO` when `ierr` is present (closing
      !! `ncid` first, when given, so a mid-registration failure does not
      !! leak the file handle), or `error stop`s with a generic message
      !! when `ierr` is absent — the SPECIFIC reason was already logged by
      !! `nc_check`/`fail` before this returns, so the legacy (no `ierr`)
      !! log output is unchanged; only the raw `error stop` text is
      !! generic (same idiom as `rdb_bathymetry::bathy_io_ok`, P0.1 F1/F2).
      integer, intent(in) :: local_ierr
      integer, intent(out), optional :: ierr
      integer, intent(in), optional :: ncid
      logical :: ok

      integer :: discard_ierr

      ok = (local_ierr == 0)
      if (ok) return

      if (present(ierr)) then
         if (present(ncid)) call nc_close(ncid, ierr=discard_ierr)
         ierr = OCEAN_STATUS_ERR_IO
         return
      end if

      error stop "ocean_data_input: NetCDF registration failure"
   end function reg_io_ok