Translate a raw nc_check-style status (0 = ok) from one of the
nc_* reader calls in seed_ts_from_zfile/read_dims 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-read failure
does not leak the file handle), or error stops with the SAME
generic text nc_check itself would have used had ierr never
been threaded through — keeps the legacy (no ierr) behaviour
byte-identical while unblocking the ierr-present return path
(F1/F2 of the P0.1 review).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | local_ierr | |||
| integer, | intent(out), | optional | :: | ierr | ||
| integer, | intent(in), | optional | :: | ncid |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | discard_ierr |
function zinit_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 `seed_ts_from_zfile`/`read_dims` 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-read failure !! does not leak the file handle), or `error stop`s with the SAME !! generic text `nc_check` itself would have used had `ierr` never !! been threaded through — keeps the legacy (no `ierr`) behaviour !! byte-identical while unblocking the `ierr`-present return path !! (F1/F2 of the P0.1 review). 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 zinit_io_ok