! 指定された変数のすべての属性を複写する。

subroutine gtvarcopyattrall(to, from, err)
    use gtdata_types, only: gt_variable
    use gtdata_generic, only: attr_rewind, attr_next, gtvarcopyattr
    use dc_error, only: dumperror
    use dc_trace, only: beginsub, endsub, DbgMessage
    use dc_types, only: string
    type(gt_variable), intent(inout):: to
    type(gt_variable), intent(inout):: from
    logical, intent(out):: err
    character(len = *), parameter:: subnam = "gtvarcopyattrall"
    character(len = STRING):: aname
    logical:: end
    err = .false.
    call beginsub(subnam)
    call attr_rewind(from)
    do
        call attr_next(from, aname, end)
        if (end) exit
        call DbgMessage("attr=%c", c1=aname)
        call gtvarcopyattr(to=to, attrname=aname, from=from, err=err)
        if (err) exit
    enddo
    call endsub(subnam)
end subroutine
