input_nc_check_attr Subroutine

public subroutine input_nc_check_attr(ivar)

Uses

    • netcdf
  • proc~~input_nc_check_attr~~UsesGraph proc~input_nc_check_attr input_nc_check_attr netcdf netcdf proc~input_nc_check_attr->netcdf

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: ivar

Calls

proc~~input_nc_check_attr~~CallsGraph proc~input_nc_check_attr input_nc_check_attr nf90_get_att nf90_get_att proc~input_nc_check_attr->nf90_get_att proc~log_debug log_debug proc~input_nc_check_attr->proc~log_debug proc~log_message log_message proc~log_debug->proc~log_message proc~log_write log_write proc~log_message->proc~log_write proc~log_format_message log_format_message proc~log_message->proc~log_format_message proc~to_string to_string proc~log_write->proc~to_string proc~date_time_str date_time_str proc~log_format_message->proc~date_time_str proc~colourise colourise proc~log_format_message->proc~colourise proc~string_index string_index proc~colourise->proc~string_index

Called by

proc~~input_nc_check_attr~~CalledByGraph proc~input_nc_check_attr input_nc_check_attr proc~input_nc_initialise input_nc_initialise proc~input_nc_initialise->proc~input_nc_check_attr proc~initialise initialise proc~initialise->proc~input_nc_initialise program~swim swim program~swim->proc~initialise

Contents

Source Code


Source Code

  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