gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtvarcopyattr.f90 File Reference

Copy attribute. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarcopyattr (to, attrname, from, err)

Detailed Description

Copy attribute.

Author
Eizi TOYODA, Yasuhiro MORIKAWA

This subroutine is provided as gtdata_generic#Copy_Attr through gtdata_generic.

Definition in file gtvarcopyattr.f90.

Function/Subroutine Documentation

◆ gtvarcopyattr()

subroutine gtvarcopyattr ( type(gt_variable), intent(inout) to,
character(len = *), intent(in) attrname,
type(gt_variable), intent(in) from,
logical, intent(out), optional err )

Copy single attribute from one variable to another

Copies attribute attrname of variable from to variable to. If an error occurs during copying, outputs a message and terminates the program. If err is provided, returns .true. in that argument and program does not terminate.

Copy_Attr is a generic name for 2 subroutines; there is also a method to copy all attributes of a variable at once.

Parameters
[in,out]toDestination variable handle
[in]attrnameAttribute name to copy
[in]fromSource variable handle
[out]errError flag (optional)

Definition at line 55 of file gtvarcopyattr.f90.

56 use gtdata_types, only: gt_variable
58 use gtdata_internal_map, only: var_class, vtb_class_netcdf
61 use dc_trace, only: beginsub, endsub
62 use dc_error, only: storeerror, dc_noerr
63 use dc_types, only: string
64 implicit none
65 type(GT_VARIABLE), intent(inout):: to
66 character(len = *), intent(in):: attrname
67 type(GT_VARIABLE), intent(in):: from
68 logical, intent(out), optional:: err
69 character(STRING):: svalue
70 integer:: from_class, from_cid, to_class, to_cid, stat
71continue
72 if (present(err)) err = .false.
73 call beginsub('gtvarcopyattr', 'mapid to=%d from=%d name=%c', &
74 & i=(/to%mapid, from%mapid/), c1=attrname)
75 call var_class(from, from_class, from_cid)
76 call var_class(to, to_class, to_cid)
77 if (from_class == vtb_class_netcdf .and. to_class == vtb_class_netcdf) then
78 call copy_attr(gd_nc_variable(to_cid), attrname, &
79 & gd_nc_variable(from_cid), stat)
80 else
81 ! とりあえず文字列で入出力しておく
82 call get_attr(from, attrname, svalue, default='')
83 call put_attr(to, attrname, svalue, '', err)
84 stat = dc_noerr
85 endif
86 call storeerror(stat, "GTVarCopyAttr", err)
87 call endsub('gtvarcopyattr', 'stat = %d', i=(/stat/))
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
subroutine, public var_class(var, class, cid)

References dc_trace::beginsub(), dc_error::dc_noerr, dc_trace::endsub(), dc_error::storeerror(), dc_types::string, and gtdata_internal_map::var_class().

Here is the call graph for this function: