Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ivar |
subroutine input_nc_check_attr(ivar)
use netcdf, only : nf90_get_att, NF90_NOERR
! variable counter
integer, intent (in) :: ivar
integer :: err, i
real(dp) :: attval
! check for variable attributes
do i = 1, 4
err = nf90_get_att(nc_ids(ivar), nc_var_ids(ivar), trim(nc_attr_names(i)) , attval)
if (err == NF90_NOERR) then
nc_attr_vals(ivar, i) = attval
! Attribute default values if not set in addition to initialisation (=0)
elseif (i == 1) then ! scale_factor
nc_attr_vals(ivar, i) = 1
elseif (i == 4) then ! missing value
nc_attr_vals(ivar, i) = nc_attr_vals(ivar, 3)
endif
if (NC_DEBUG .and. err == NF90_NOERR) then
call log_debug("input_nc_check_attr", trim(NC_VNAMES(ivar))//' has a '// &
nc_attr_names(i)//' attribute of:', real=nc_attr_vals(ivar, i))
elseif (NC_DEBUG) then
call log_debug("input_nc_check_attr", trim(NC_VNAMES(ivar))//' has a '// &
nc_attr_names(i)//' default value of:', real=nc_attr_vals(ivar, i))
endif
enddo
endsubroutine input_nc_check_attr