From d45eb2b89ed370ba2fccee69fc73254982cbfdbb Mon Sep 17 00:00:00 2001 From: Nic Hannah Date: Wed, 18 Nov 2020 21:51:53 +1100 Subject: [PATCH] Check def var in restart. #34 --- io_pio/ice_restart.F90 | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 + + !=======================================================================