diff --git a/io_pio/ice_restart.F90 b/io_pio/ice_restart.F90 index 8296e44..5d0820c 100644 --- a/io_pio/ice_restart.F90 +++ b/io_pio/ice_restart.F90 @@ -619,12 +619,30 @@ subroutine define_rest_field(File, vname, dims) integer (kind=int_kind) :: & status ! status variable from netCDF routine - status = pio_def_var(File,trim(vname),pio_double,dims,vardesc) + call check(pio_def_var(File,trim(vname),pio_double,dims,vardesc), & + 'def var: '//trim(vname)) end subroutine define_rest_field + +subroutine check(status, msg) + + use netcdf, only: nf90_noerr, nf90_strerror + + integer, intent (in) :: status + character(len=*), intent (in) :: msg + + if(status /= nf90_noerr) then + call abort_ice('ice: NetCDF error '//trim(nf90_strerror(status)//' '//trim(msg))) + end if + +end subroutine check + + !======================================================================= end module ice_restart + + !=======================================================================