5 type(Dataset),
intent(in) :: dset
6 character(len=*),
intent(in),
optional :: varname
7 character(len=*),
intent(in) :: attname
8 integer,
intent(out),
optional :: errcode
9 integer ncerr, varid, nvar, nlen
10 logical return_errcode
12 if(
present(errcode))
then
16 return_errcode=.false.
19 if(
present(varname))
then
20 nvar = get_nvar(dset,varname)
21 varid = dset%variables(nvar)%varid
25 ncerr = nf90_inquire_attribute(dset%ncid, varid, attname, len=nlen)
26 if (return_errcode)
then
27 call nccheck(ncerr,halt=.false.)
29 if (ncerr /= 0)
return
33 if (
allocated(values))
deallocate(values)
34 allocate(values(nlen))
35 ncerr = nf90_get_att(dset%ncid, varid, trim(attname), values)
37 if (return_errcode)
then
38 call nccheck(ncerr,halt=.false.)