subroutine GTVarCopyAttr(to, attrname, from, err)
implicit none
type(GT_VARIABLE), intent(inout):: to
character(len = *), intent(in):: attrname
type(GT_VARIABLE), intent(in):: from
logical, intent(out), optional:: err
type(VSTRING):: svalue
integer:: from_class, from_cid, to_class, to_cid, stat
continue
if (present(err)) err = .false.
call beginsub('gtvarcopyattr', 'mapid to=%d from=%d name=%c', i=(/to%mapid, from%mapid/), c1=attrname)
call var_class(from, from_class, from_cid)
call var_class(to, to_class, to_cid)
if (from_class == vtb_class_netcdf .and. to_class == vtb_class_netcdf) then
call Copy_Attr(an_variable(to_cid), attrname, an_variable(from_cid), stat)
else
! とりあえず文字列で入出力しておく
call Get_Attr(from, attrname, svalue, default="")
call Put_Attr(to, attrname, svalue, err)
stat = DC_NOERR
endif
call StoreError(stat, "GTVarCopyAttr", err)
call endsub('gtvarcopyattr', 'stat = %d', i=(/stat/))
end subroutine