subroutine ANVarAttrCopy(to, attrname, from, stat)
implicit none
type(AN_VARIABLE), intent(in):: to
character(len = *), intent(in):: attrname
type(AN_VARIABLE), intent(in):: from
integer, intent(out):: stat
character(NF_MAX_NAME):: nc_aname
integer:: id_var_from, id_var_to
logical:: myerr
type(an_variable_entry):: to_ent, from_ent
stat = vtable_lookup(to, to_ent)
if (stat /= NF_NOERR) goto 999
stat = vtable_lookup(from, from_ent)
if (stat /= NF_NOERR) goto 999
stat = ANFileDefineMode(to_ent%fileid)
if (stat /= NF_NOERR) goto 999
call inquire(from, attrname, id_var_from, nc_aname)
call inquire(to, attrname, id_var_to, nc_aname)
stat = nf_copy_att(from_ent%fileid, id_var_from, nc_aname, to_ent%fileid, id_var_to)
999 continue
call StoreError(stat, "ANVarAttrCopy", myerr)
return
end subroutine