gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtvarputline.f90
Go to the documentation of this file.
1
20
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)
Error handling module.
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
Error storage variables
Definition dc_error.f90:468
integer, parameter, public gt_enomem
Definition dc_error.f90:513
integer function, public errorcode()
Definition dc_error.f90:607
Handling character types.
Definition dc_string.f90:83
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:680
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public stdout
Unit number for Standard OUTPUT
Definition dc_types.f90:117
integer, parameter, public string
Character length for string
Definition dc_types.f90:137