MONC
netcdf_misc.F90
Go to the documentation of this file.
1 
3  use netcdf, only : nf90_ebaddim, nf90_enotatt, nf90_enotvar, nf90_noerr, nf90_strerror
4  use logging_mod, only : log_error, log_log
5  implicit none
6 
7 #ifndef TEST_MODE
8  private
9 #endif
10 
11  public check_netcdf_status
12 contains
13 
18  subroutine check_netcdf_status(status, found_flag)
19  integer, intent(in) :: status
20  logical, intent(out), optional :: found_flag
21 
22  if (present(found_flag)) then
23  found_flag = status /= nf90_ebaddim .and. status /= nf90_enotatt .and. status /= nf90_enotvar
24  if (.not. found_flag) return
25  end if
26 
27  if (status /= nf90_noerr) then
28  call log_log(log_error, "NetCDF returned error code of "//trim(nf90_strerror(status)))
29  end if
30  end subroutine check_netcdf_status
31 end module netcdf_misc_mod
logging_mod::log_error
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
netcdf_misc_mod
NetCDF misc functionality which can be shared between modules that work with NetCDF files.
Definition: netcdf_misc.F90:2
logging_mod::log_log
subroutine, public log_log(level, message, str)
Logs a message at the specified level. If the level is above the current level then the message is ig...
Definition: logging.F90:75
logging_mod
Logging utility.
Definition: logging.F90:2
netcdf_misc_mod::check_netcdf_status
subroutine, public check_netcdf_status(status, found_flag)
Will check a NetCDF status and write to log_log error any decoded statuses. Can be used to decode whe...
Definition: netcdf_misc.F90:19