restart_io_ok Function

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

Translate a raw nc_check-style status (0 = ok) from one of the nc_* calls in ocean_restart_write_local into the caller’s ierr contract. Mirrors rdb_bathymetry’s bathy_io_ok / rdb_ocean_diag_netcdf’s diag_io_ok (P0.1 F1 / P7 F1): closes ncid (when given) on failure so a mid-write error does not leak the file handle, sets ierr = OCEAN_STATUS_ERR_IO when present, or error stops with the generic nc_check text when ierr is absent (byte-identical legacy behaviour).

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~~restart_io_ok~~CallsGraph proc~restart_io_ok restart_io_ok proc~nc_close nc_close proc~restart_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~~restart_io_ok~~CalledByGraph proc~restart_io_ok restart_io_ok proc~ocean_restart_write_local ocean_restart_write_local proc~ocean_restart_write_local->proc~restart_io_ok proc~ocean_state_restart_write ocean_state_restart_write proc~ocean_state_restart_write->proc~ocean_restart_write_local proc~ocean_state_restart_write_drop_field ocean_state_restart_write_drop_field proc~ocean_state_restart_write_drop_field->proc~ocean_restart_write_local proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~ocean_state_restart_write proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
integer, private :: discard_ierr

Source Code

   function restart_io_ok(local_ierr, ierr, ncid) result(ok)
      !! Translate a raw `nc_check`-style status (0 = ok) from one of the
      !! `nc_*` calls in `ocean_restart_write_local` into the caller's
      !! `ierr` contract. Mirrors `rdb_bathymetry`'s `bathy_io_ok` /
      !! `rdb_ocean_diag_netcdf`'s `diag_io_ok` (P0.1 F1 / P7 F1): closes
      !! `ncid` (when given) on failure so a mid-write error does not
      !! leak the file handle, sets `ierr = OCEAN_STATUS_ERR_IO` when
      !! present, or `error stop`s with the generic `nc_check` text when
      !! `ierr` is absent (byte-identical legacy behaviour).
      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 "NetCDF operation failed"
   end function restart_io_ok