gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gtvarputline.f90
Go to the documentation of this file.
1!> @file gtvarputline.f90
2!>
3!> @author Yasuhiro MORIKAWA, Eizi TOYODA
4!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Print variable information
9!>
10!> This subroutine is provided as gtdata_generic#PutLine
11!> through gtdata_generic.
12!> @enden
13!>
14!> @ja
15!> @brief 変数の印字
16!>
17!> このサブルーチンは gtdata_generic から gtdata_generic#PutLine
18!> として提供されます。
19!> @endja
20
21!>
22!> @en
23!> @brief Print variable information
24!>
25!> Prints the information set in var.
26!> By default, messages are output to standard output.
27!> The output destination can be changed by specifying a unit number
28!> with unit.
29!> @param[in] var Variable handle
30!> @param[in] unit Output unit number (optional, default: standard output)
31!> @param[in] indent Indent string for displayed messages (optional)
32!> @param[out] err Error flag (optional)
33!> @enden
34!>
35!> @ja
36!> @brief 変数情報の印字
37!>
38!> 引数 var に設定されている情報を印字します。
39!> デフォルトではメッセージは標準出力に出力されます。
40!> unit に装置番号を指定することで、出力先を変更することが可能です。
41!> @param[in] var 変数ハンドル
42!> @param[in] unit 出力先の装置番号 (省略可能、デフォルト: 標準出力)
43!> @param[in] indent 表示メッセージの字下げ (省略可能)
44!> @param[out] err エラーフラグ (省略可能)
45!> @endja
46!>
47subroutine gtvarputline( var, unit, indent, err )
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/))
154end subroutine gtvarputline
subroutine gtvarputline(var, unit, indent, err)
エラー処理用モジュール
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