Check NetCDF return status and log error if it failed
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | status |
Return code from nf90_* call |
||
| character(len=*), | intent(in) | :: | context |
Description of what was being attempted |
||
| integer, | intent(out), | optional | :: | ierr |
Non-zero (the raw |
subroutine nc_check(status, context, ierr) !! Check NetCDF return status and log error if it failed integer, intent(in) :: status !! Return code from nf90_* call character(len=*), intent(in) :: context !! Description of what was being attempted integer, intent(out), optional :: ierr !! Non-zero (the raw `nf90_*` status) on failure when present; !! absent behaves as today (`error stop`). The specific reason !! is always logged via `global_logger%error` first, so the !! caller-facing code only needs to say THAT a read/write failed. if (status /= nf90_noerr) then call fail("NetCDF error in "//trim(context)//": "// & trim(nf90_strerror(status)), ierr, status) return end if if (present(ierr)) ierr = nf90_noerr end subroutine nc_check