gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
Functions/Subroutines
gtvarcopyattr.f90 File Reference

属性のコピー More...

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarcopyattr (to, attrname, from, err)
 

Detailed Description

属性のコピー

Author
Eizi TOYODA, Yasuhiro MORIKAWA

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 
)

1つの属性を変数間でコピー

変数 from の属性 attrname を変数 to へコピーします。 属性のコピー時にエラーが生じた場合、メッセージを出力 してプログラムは強制終了します。err を与えてある場合には の引数に .true. が返り、プログラムは終了しません。

Copy_Attr は 2 つのサブルーチンの総称名であり、 他にも一括で変数の全ての属性をコピーする方法もあります。

Parameters
[in,out]toコピー先の変数ハンドル
[in]attrnameコピーする属性名
[in]fromコピー元の変数ハンドル
[out]errエラーフラグ (省略可能)

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/))
エラー処理用モジュール
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
エラー等を保持
Definition dc_error.f90:468
デバッグ時の追跡用モジュール
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
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public 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: