NCEPLIBS-ncio  1.0.0
All Namespaces Files Functions
read_scalar_attribute_code.f90
1 
10  type(Dataset), intent(in) :: dset
11  character(len=*), intent(in), optional :: varname
12  integer, intent(out), optional :: errcode
13  character(len=*), intent(in) :: attname
14  integer ncerr, varid, nvar
15  logical return_errcode
16  ! optional return of errcode
17  if(present(errcode)) then
18  return_errcode=.true.
19  errcode = 0
20  else
21  return_errcode=.false.
22  endif
23  ! access attribute name based on variable name
24  if(present(varname))then
25  nvar = get_nvar(dset,varname)
26  varid = dset%variables(nvar)%varid
27  else
28  varid = nf90_global
29  endif
30  ncerr = nf90_get_att(dset%ncid, varid, trim(attname), values)
31  ! err check
32  if (return_errcode) then
33  call nccheck(ncerr,halt=.false.)
34  errcode=ncerr
35  return
36  else
37  call nccheck(ncerr)
38  endif