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 14 of file gtvarputline.f90.

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.

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'
67 continue
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 
147 999 continue
148  call storeerror(stat, subname, err)
149  call endsub(subname, '%d stat=%d', i=(/var % mapid, stat/))
integer, parameter, public gt_enomem
Definition: dc_error.f90:534
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
subroutine, public dbgmessage(fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:509
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
integer, parameter, public stdout
標準出力の装置番号
Definition: dc_types.f90:98
文字型変数の操作.
Definition: dc_string.f90:24
integer function, public errorcode()
Definition: dc_error.f90:620
種別型パラメタを提供します。
Definition: dc_types.f90:49
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118
Here is the call graph for this function: