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

変数の印字 More...

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarputline (var, unit, indent, err)

Detailed Description

変数の印字

Author
Yasuhiro MORIKAWA, Eizi TOYODA

このサブルーチンは gtdata_generic から gtdata_generic#PutLine として提供されます。

Definition in file gtvarputline.f90.

Function/Subroutine Documentation

◆ gtvarputline()

subroutine gtvarputline ( type(gt_variable), intent(in) var,
integer, intent(in), optional unit,
character(*), intent(in), optional indent,
logical, intent(out), optional err )

変数情報の印字

引数 var に設定されている情報を印字します。 デフォルトではメッセージは標準出力に出力されます。 unit に装置番号を指定することで、出力先を変更することが可能です。

Parameters
[in]var変数ハンドル
[in]unit出力先の装置番号 (省略可能、デフォルト: 標準出力)
[in]indent表示メッセージの字下げ (省略可能)
[out]errエラーフラグ (省略可能)

Definition at line 47 of file gtvarputline.f90.

48 use dc_types, only: string, stdout
49 use gtdata_types, only: gt_variable
51 use dc_string, only: tochar, printf, putline
52 use gtdata_generic, only: get, inquire
54 implicit none
55 type(GT_VARIABLE), intent(in):: var
56 integer, intent(in), optional:: unit
57 character(*), intent(in), optional:: indent
58 logical, intent(out), optional:: err
59
60 !-----------------------------------
61 ! 作業変数
62 ! Work variables
63 real, allocatable:: rvalue(:)
64 integer:: siz, stat
65!!$ integer:: i
66 logical:: myerr
67 integer:: out_unit
68 integer:: indent_len
69 character(STRING):: indent_str
70 character(*), parameter:: subname = 'GTVarPutLine'
71continue
72 call beginsub(subname, '%d', i=(/var % mapid/))
73 stat = dc_noerr
74 !-----------------------------------------------------------------
75 ! 出力先装置番号と字下げの設定
76 ! Configure output unit number and indents
77 !-----------------------------------------------------------------
78 if ( present(unit) ) then
79 out_unit = unit
80 else
81 out_unit = stdout
82 end if
83
84 indent_len = 0
85 indent_str = ''
86 if ( present(indent) ) then
87 if ( len(indent) /= 0 ) then
88 indent_len = len(indent)
89 indent_str(1:indent_len) = indent
90 end if
91 end if
92
93 !-----------------------------------------------------------------
94 ! 初期設定されていない変数の印字
95 ! Print uninitialized variables
96 !-----------------------------------------------------------------
97 if ( var % mapid < 0 ) then
98 call printf( out_unit, &
99 & indent_str(1:indent_len) // &
100 & '#<GT_VARIABLE:: @initialized=%y>', &
101 & l = (/.false./) )
102 goto 999
103 end if
104
105 !-----------------------------------------------------------------
106 ! 初期設定されている変数の印字
107 ! Print initialized variables
108 !-----------------------------------------------------------------
109 call inquire(var, size=siz)
110 call dbgmessage('size = %d', i=(/siz/))
111 stat = dc_noerr
112 allocate(rvalue(siz), stat=stat)
113 if (stat /= dc_noerr) then
114 stat = gt_enomem
115 goto 999
116 endif
117 call get(var, rvalue, size(rvalue), err=myerr)
118 if (myerr) then
119 stat = errorcode()
120 if (stat /= dc_noerr) then
121 call printf( out_unit, &
122 & indent_str(1:indent_len) // &
123 & '#<GT_VARIABLE:: @initialized=%y>', &
124 & l = (/.false./) )
125 stat = dc_noerr
126 end if
127 goto 999
128 endif
129 call printf( out_unit, &
130 & indent_str(1:indent_len) // &
131 & '#<GT_VARIABLE:: @initialized=%y', &
132 & l = (/.true./) )
133
134 call putline( rvalue, unit = out_unit, &
135 & lbounds = lbound(rvalue), &
136 & ubounds = ubound(rvalue), &
137 & indent = indent_str(1:indent_len) // &
138 & ' @value=' )
139
140!!$ do, i = 1, size(rvalue)
141!!$ call Printf(fmt='%r', r=(/rvalue(i)/))
142!!$ end do
143
144 call printf( out_unit, &
145 & indent_str(1:indent_len) // &
146 & '>' )
147
148 deallocate(rvalue, stat=stat)
149 if (stat /= dc_noerr) stat = gt_enomem
150
151999 continue
152 call storeerror(stat, subname, err)
153 call endsub(subname, '%d stat=%d', i=(/var % mapid, stat/))
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public gt_enomem
Definition dc_error.f90:513
integer function, public errorcode()
Definition dc_error.f90:607
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
文字型変数の操作
Definition dc_string.f90:83
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661
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
integer, parameter, public stdout
標準出力の装置番号
Definition dc_types.f90:117

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_error::dc_noerr, dc_trace::endsub(), dc_error::errorcode(), dc_error::gt_enomem, dc_types::stdout, dc_error::storeerror(), and dc_types::string.

Here is the call graph for this function: