! Copyright (C) GFD Dennou Club, 2000.  All rights reserved.

subroutine GTVarCopyAttr(to, attrname, from, err)
    use gtdata_types, only: GT_VARIABLE
    use dc_string
    use gtdata_generic, only: GET_ATTR, PUT_ATTR
    use an_generic, only: copy_attr
    use dc_error
    type(GT_VARIABLE), intent(in):: to
    character(len = *), intent(in):: attrname
    type(GT_VARIABLE), intent(in):: from
    logical, intent(out), optional:: err
    type(VSTRING):: svalue
    if (associated(to%an) .and. associated(from%an)) then
        call Copy_Attr(to%an, attrname, from%an, err)
    else
        ! とりあえず文字列で入出力しておく
        call Get_Attr(from, attrname, svalue, default="")
        call Put_Attr(to, attrname, svalue, err)
    endif
end subroutine
