Loading...
Searching...
No Matches
gtvarcopyattr.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarcopyattr (to, attrname, from, err)

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 )

Definition at line 13 of file gtvarcopyattr.f90.

14 !
15 !== 属性のコピー
16 !
17 ! 変数 *from* の属性 *attrname* を 変数 *to* へコピーします。
18 !
19 ! 属性のコピー時にエラーが生じた場合、メッセージを出力
20 ! してプログラムは強制終了します。*err* を与えてある場合には
21 ! の引数に .true. が返り、プログラムは終了しません。
22 !
23 ! *Copy_Attr* は 2 つのサブルーチンの総称名であり、
24 ! 他にも一括で変数の全ての属性をコピーする方法もあります。
25 ! 下記のサブルーチンを参照ください。
26 !
27 use gtdata_types, only: gt_variable
28 use gtdata_generic, only: get_attr, put_attr
29 use gtdata_internal_map, only: var_class, vtb_class_netcdf
32 use dc_trace, only: beginsub, endsub
33 use dc_error, only: storeerror, dc_noerr
34 use dc_types, only: string
35 implicit none
36 type(GT_VARIABLE), intent(inout):: to
37 character(len = *), intent(in):: attrname
38 type(GT_VARIABLE), intent(in):: from
39 logical, intent(out), optional:: err
40 character(STRING):: svalue
41 integer:: from_class, from_cid, to_class, to_cid, stat
42continue
43 if (present(err)) err = .false.
44 call beginsub('gtvarcopyattr', 'mapid to=%d from=%d name=%c', &
45 & i=(/to%mapid, from%mapid/), c1=attrname)
46 call var_class(from, from_class, from_cid)
47 call var_class(to, to_class, to_cid)
48 if (from_class == vtb_class_netcdf .and. to_class == vtb_class_netcdf) then
49 call copy_attr(gd_nc_variable(to_cid), attrname, &
50 & gd_nc_variable(from_cid), stat)
51 else
52 ! とりあえず文字列で入出力しておく
53 call get_attr(from, attrname, svalue, default='')
54 call put_attr(to, attrname, svalue, '', err)
55 stat = dc_noerr
56 endif
57 call storeerror(stat, "GTVarCopyAttr", err)
58 call endsub('gtvarcopyattr', 'stat = %d', i=(/stat/))
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public dc_noerr
Definition dc_error.f90:509
Provides kind type parameter values.
Definition dc_types.f90:49
integer, parameter, public string
Character length for string
Definition dc_types.f90:118
subroutine, public var_class(var, class, cid)

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

Here is the call graph for this function: