Loading...
Searching...
No Matches
Functions/Subroutines
gtvarputline.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarputline (var, unit, indent, err)
 

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 
)

Definition at line 13 of file gtvarputline.f90.

14 !
15 ! 引数 *var* に設定されている情報を印字します.
16 ! デフォルトではメッセージは標準出力に出力されます.
17 ! *unit* に装置番号を指定することで, 出力先を変更することが可能です.
18 !
19 ! Print information of *var*.
20 ! By default messages are output to standard output.
21 ! Unit number for output can be changed by *unit* argument.
22 !
23 use dc_types, only: string, stdout
24 use gtdata_types, only: gt_variable
26 use dc_string, only: tochar, printf, putline
27 use gtdata_generic, only: get, inquire
28 use dc_trace, only: beginsub, endsub, dbgmessage
29 implicit none
30 type(GT_VARIABLE), intent(in):: var
31 integer, intent(in), optional:: unit
32 ! 出力先の装置番号.
33 ! デフォルトの出力先は標準出力.
34 !
35 ! Unit number for output.
36 ! Default value is standard output.
37 character(*), intent(in), optional:: indent
38 ! 表示されるメッセージの字下げ.
39 !
40 ! Indent of displayed messages.
41 logical, intent(out), optional:: err
42 ! 例外処理用フラグ.
43 ! デフォルトでは, この手続き内でエラーが
44 ! 生じた場合, プログラムは強制終了します.
45 ! 引数 *err* が与えられる場合,
46 ! プログラムは強制終了せず, 代わりに
47 ! *err* に .true. が代入されます.
48 !
49 ! Exception handling flag.
50 ! By default, when error occur in
51 ! this procedure, the program aborts.
52 ! If this *err* argument is given,
53 ! .true. is substituted to *err* and
54 ! the program does not abort.
55
56 !-----------------------------------
57 ! 作業変数
58 ! Work variables
59 real, allocatable:: rvalue(:)
60 integer:: siz, stat
61!!$ integer:: i
62 logical:: myerr
63 integer:: out_unit
64 integer:: indent_len
65 character(STRING):: indent_str
66 character(*), parameter:: subname = 'GTVarPutLine'
67continue
68 call beginsub(subname, '%d', i=(/var % mapid/))
69 stat = dc_noerr
70 !-----------------------------------------------------------------
71 ! 出力先装置番号と字下げの設定
72 ! Configure output unit number and indents
73 !-----------------------------------------------------------------
74 if ( present(unit) ) then
75 out_unit = unit
76 else
77 out_unit = stdout
78 end if
79
80 indent_len = 0
81 indent_str = ''
82 if ( present(indent) ) then
83 if ( len(indent) /= 0 ) then
84 indent_len = len(indent)
85 indent_str(1:indent_len) = indent
86 end if
87 end if
88
89 !-----------------------------------------------------------------
90 ! 初期設定されていない変数の印字
91 ! Print uninitialized variables
92 !-----------------------------------------------------------------
93 if ( var % mapid < 0 ) then
94 call printf( out_unit, &
95 & indent_str(1:indent_len) // &
96 & '#<GT_VARIABLE:: @initialized=%y>', &
97 & l = (/.false./) )
98 goto 999
99 end if
100
101 !-----------------------------------------------------------------
102 ! 初期設定されている変数の印字
103 ! Print initialized variables
104 !-----------------------------------------------------------------
105 call inquire(var, size=siz)
106 call dbgmessage('size = %d', i=(/siz/))
107 stat = dc_noerr
108 allocate(rvalue(siz), stat=stat)
109 if (stat /= dc_noerr) then
110 stat = gt_enomem
111 goto 999
112 endif
113 call get(var, rvalue, size(rvalue), err=myerr)
114 if (myerr) then
115 stat = errorcode()
116 if (stat /= dc_noerr) then
117 call printf( out_unit, &
118 & indent_str(1:indent_len) // &
119 & '#<GT_VARIABLE:: @initialized=%y>', &
120 & l = (/.false./) )
121 stat = dc_noerr
122 end if
123 goto 999
124 endif
125 call printf( out_unit, &
126 & indent_str(1:indent_len) // &
127 & '#<GT_VARIABLE:: @initialized=%y', &
128 & l = (/.true./) )
129
130 call putline( rvalue, unit = out_unit, &
131 & lbounds = lbound(rvalue), &
132 & ubounds = ubound(rvalue), &
133 & indent = indent_str(1:indent_len) // &
134 & ' @value=' )
135
136!!$ do, i = 1, size(rvalue)
137!!$ call Printf(fmt='%r', r=(/rvalue(i)/))
138!!$ end do
139
140 call printf( out_unit, &
141 & indent_str(1:indent_len) // &
142 & '>' )
143
144 deallocate(rvalue, stat=stat)
145 if (stat /= dc_noerr) stat = gt_enomem
146
147999 continue
148 call storeerror(stat, subname, err)
149 call endsub(subname, '%d stat=%d', i=(/var % mapid, stat/))
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public gt_enomem
Definition dc_error.f90:534
integer function, public errorcode()
Definition dc_error.f90:620
integer, parameter, public dc_noerr
Definition dc_error.f90:509
種別型パラメタを提供します。
Definition dc_types.f90:49
integer, parameter, public stdout
標準出力の装置番号
Definition dc_types.f90:98
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:118

References dc_error::dc_noerr, 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: