gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
Functions/Subroutines
hstnmlinfoenddefine.f90 File Reference

Transit from define mode to output mode . More...

Go to the source code of this file.

Functions/Subroutines

subroutine hstnmlinfoenddefine (gthstnml, err)
 

Detailed Description

Transit from define mode to output mode

.

Author
Yasuhiro MORIKAWA

Definition in file hstnmlinfoenddefine.f90.

Function/Subroutine Documentation

◆ hstnmlinfoenddefine()

subroutine hstnmlinfoenddefine ( type(gthst_nmlinfo), intent(inout)  gthstnml,
logical, intent(out), optional  err 
)

Transit from define mode to output mode

Transit from define mode to output mode, and determine information configured in gthstnml. Use this subroutine before HstNmlInfoAssocGTHist is used. If HstNmlInfoAdd, HstNmlInfoDelete, HstNmlInfoResetDefault are used after this subroutine is used, error is occurred.

If gthstnml is not initialized by HstNmlInfoCreate yet, error is occurred.

Parameters
[in,out]gthstnmlgtool_history_nmlinfo_types::GTHST_NMLINFO 型変数
[out]err例外処理用フラグ. Exception handling flag.

Definition at line 46 of file hstnmlinfoenddefine.f90.

50 use dc_trace, only: beginsub, endsub
52 use dc_types, only: string, sp_eps
57 use dc_message, only: messagenotify
58 implicit none
59 type(GTHST_NMLINFO), intent(inout):: gthstnml
60 logical, intent(out), optional:: err
61 ! 例外処理用フラグ.
62 ! デフォルトでは, この手続き内でエラーが
63 ! 生じた場合, プログラムは強制終了します.
64 ! 引数 *err* が与えられる場合,
65 ! プログラムは強制終了せず, 代わりに
66 ! *err* に .true. が代入されます.
67 !
68 ! Exception handling flag.
69 ! By default, when error occur in
70 ! this procedure, the program aborts.
71 ! If this *err* argument is given,
72 ! .true. is substituted to *err* and
73 ! the program does not abort.
74
75 !-----------------------------------
76 ! 複数の変数を一つのファイルへ出力するためのチェック用変数
77 ! Variables for checking for output multiple variables to one file
78 character(STRING):: opname, opfile
79 logical:: end
80
81 !-----------------------------------
82 ! 作業変数
83 ! Work variables
84 character(STRING):: fullfilename
85 type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
86 type(GTHST_NMLINFO_ENTRY), pointer:: hptr_prev =>null()
87 integer:: stat
88 character(STRING):: cause_c
89 character(*), parameter:: subname = 'HstNmlInfoEndDefine'
90 continue
91 call beginsub( subname )
92 stat = dc_noerr
93 cause_c = ''
94
95 !-----------------------------------------------------------------
96 ! 初期設定のチェック
97 ! Check initialization
98 !-----------------------------------------------------------------
99 if ( .not. gthstnml % initialized ) then
100 stat = dc_enotinit
101 cause_c = 'GTHST_NMLINFO'
102 goto 999
103 end if
104
105 if ( .not. gthstnml % define_mode ) then
106 stat = hst_enotindefine
107 cause_c = 'EndDefine'
108 goto 999
109 end if
110
111 !-----------------------------------------------------------------
112 ! gtool_history_types#GT_HISTORY 変数の割付
113 ! Allocate "gtool_history_types#GT_HISTORY" variables
114 !-----------------------------------------------------------------
115 hptr => gthstnml % gthstnml_list
116 if ( .not. associated( hptr % history ) ) then
117 allocate( hptr % history )
118 end if
119 wholeloop : do while ( associated( hptr % next ) )
120 call listnext( gthstnml_list = hptr ) ! (inout)
121 if ( trim(hptr % name) == '' .or. trim(hptr % file) == '' ) &
122 & cycle wholeloop
123
124 fullfilename = trim( hptr % fileprefix ) // hptr % file
125
126 !---------------------------------------------------------------
127 ! 以前に同一ファイル名の gtool_history_types#GT_HISTORY 変数がある場合, そちらに結合
128 ! If "gtool_history_types#GT_HISTORY" that has same filename exist already, associate to it
129 !---------------------------------------------------------------
130 nullify( hptr_prev )
131 call dchashrewind(opened_files) ! (inout)
132 searchloop : do
133 call dchashnext( opened_files, & ! (inout)
134 & opname, opfile, end ) ! (out)
135 if ( end ) exit searchloop
136 if ( trim(opfile) /= trim(fullfilename) ) cycle searchloop
137 hptr_prev => gthstnml % gthstnml_list
138
139 call listsearch( gthstnml_list = hptr_prev, & ! (inout)
140 & name = opname ) ! (in)
141 if ( .not. associated( hptr_prev ) ) cycle searchloop
142 if ( trim(hptr % name) == trim(hptr_prev % name) ) cycle searchloop
143
144 ! interval_value, interval_unit の同一性をチェック
145 ! Check consistency of "interval_value", "interval_unit"
146 !
147 if ( abs(hptr % interval_value - hptr_prev % interval_value) > sp_eps ) then
148 call messagenotify( 'W', subname, &
149 & '@interval_value=%r (var=%a) and @interval_value=%r (var=%a) are applied to a file "%a"', &
150 & r = (/hptr % interval_value, hptr_prev % interval_value/), &
151 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
152 stat = hst_eintfile
153 cause_c = fullfilename
154 goto 999
155 elseif ( hptr % interval_unit /= hptr_prev % interval_unit ) then
156 call messagenotify( 'W', subname, &
157 & '@interval_unit=%a (var=%a) and @interval_unit=%a (var=%a) are applied to a file "%a"', &
158 & ca = stoa(hptr % interval_unit, hptr % name, &
159 & hptr_prev % interval_unit, hptr_prev % name, &
160 & fullfilename) )
161 stat = hst_eintfile
162 cause_c = fullfilename
163 goto 999
164 end if
165
166 ! origin_value, origin_unit の同一性をチェック
167 ! Check consistency of "origin_value", "origin_unit"
168 !
169 if ( abs(hptr % origin_value - hptr_prev % origin_value) > sp_eps ) then
170 call messagenotify( 'W', subname, &
171 & '@origin_value=%r (var=%a) and @origin_value=%r (var=%a) are applied to a file "%a"', &
172 & r = (/hptr % origin_value, hptr_prev % origin_value/), &
173 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
174 stat = hst_ebadorigin
175 cause_c = fullfilename
176 goto 999
177 elseif ( hptr % origin_unit /= hptr_prev % origin_unit ) then
178 call messagenotify( 'W', subname, &
179 & '@origin_unit=%a (var=%a) and @origin_unit=%a (var=%a) are applied to a file "%a"', &
180 & ca = stoa(hptr % origin_unit, hptr % name, &
181 & hptr_prev % origin_unit, hptr_prev % name, &
182 & fullfilename) )
183 stat = hst_ebadorigin
184 cause_c = fullfilename
185 goto 999
186 end if
187
188 ! terminus_value, terminus_unit の同一性をチェック
189 ! Check consistency of "terminus_value", "terminus_unit"
190 !
191 if ( abs(hptr % terminus_value - hptr_prev % terminus_value) > sp_eps ) then
192 call messagenotify( 'W', subname, &
193 & '@terminus_value=%r (var=%a) and @terminus_value=%r (var=%a) are applied to a file "%a"', &
194 & r = (/hptr % terminus_value, hptr_prev % terminus_value/), &
195 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
196 stat = hst_ebadterminus
197 cause_c = fullfilename
198 goto 999
199 elseif ( hptr % terminus_unit /= hptr_prev % terminus_unit ) then
200 call messagenotify( 'W', subname, &
201 & '@terminus_unit=%a (var=%a) and @terminus_unit=%a (var=%a) are applied to a file "%a"', &
202 & ca = stoa(hptr % terminus_unit, hptr % name, &
203 & hptr_prev % terminus_unit, hptr_prev % name, &
204 & fullfilename) )
205 stat = hst_ebadterminus
206 cause_c = fullfilename
207 goto 999
208 end if
209
210 ! newfile_intvalue が有効な場合はエラーを返す.
211 ! Error is occurred when "newfile_intvalue" is valid
212 !
213 if ( ( hptr % newfile_intvalue > 0.0 ) &
214 & .or. ( hptr_prev % newfile_intvalue > 0.0 ) ) then
215 call messagenotify( 'W', subname, &
216 & 'when @newfile_intvalue=%d (var=%a) > 0 or' // &
217 & ' @newfile_intvalue=%d (var=%a) > 0, multiple variables can not be output to one file "%a"', &
218 & i = (/hptr % newfile_intvalue, hptr_prev % newfile_intvalue/), &
219 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
220 stat = hst_ebadnewfileint
221 cause_c = fullfilename
222 goto 999
223 end if
224
225 ! newfile_intvalue, newfile_intunit の同一性をチェック
226 ! Check consistency of "newfile_intvalue", "newfile_intunit"
227 !
228 if ( hptr % newfile_intvalue /= hptr_prev % newfile_intvalue ) then
229 call messagenotify( 'W', subname, &
230 & '@newfile_intvalue=%d (var=%a) and @newfile_intvalue=%d (var=%a) are applied to a file "%a"', &
231 & i = (/hptr % newfile_intvalue, hptr_prev % newfile_intvalue/), &
232 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
233 stat = hst_ebadnewfileint
234 cause_c = fullfilename
235 goto 999
236 elseif ( hptr % newfile_intunit /= hptr_prev % newfile_intunit ) then
237 call messagenotify( 'W', subname, &
238 & '@newfile_intunit=%a (var=%a) and @newfile_intunit=%a (var=%a) are applied to a file "%a"', &
239 & ca = stoa(hptr % newfile_intunit, hptr % name, &
240 & hptr_prev % newfile_intunit, hptr_prev % name, &
241 & fullfilename) )
242 stat = hst_ebadnewfileint
243 cause_c = fullfilename
244 goto 999
245 end if
246
247
248 ! slice_start, slice_end, slice_stride, space_average の同一性チェック
249 ! Check consistency of "slice_start", "slice_end", "slice_stride", "space_average"
250 !
251 if ( any( hptr % slice_start /= hptr_prev % slice_start ) ) then
252 call messagenotify( 'W', subname, &
253 & '@slice_start=%*d (var=%a) and @slice_start=%*d (var=%a) are applied to a file "%a"', &
254 & i = (/hptr % slice_start(1:10), hptr_prev % slice_start(1:10)/), &
255 & n = (/10, 10/), &
256 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
257 stat = hst_ebadslice
258 cause_c = fullfilename
259 goto 999
260 elseif ( any( hptr % slice_end /= hptr_prev % slice_end ) ) then
261 call messagenotify( 'W', subname, &
262 & '@slice_end=%*d (var=%a) and @slice_end=%*d (var=%a) are applied to a file "%a"', &
263 & i = (/hptr % slice_end(1:10), hptr_prev % slice_end(1:10)/), &
264 & n = (/10, 10/), &
265 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
266 stat = hst_ebadslice
267 cause_c = fullfilename
268 goto 999
269 elseif ( any( hptr % slice_stride /= hptr_prev % slice_stride ) ) then
270 call messagenotify( 'W', subname, &
271 & '@slice_stride=%*d (var=%a) and @slice_stride=%*d (var=%a) are applied to a file "%a"', &
272 & i = (/hptr % slice_stride(1:10), hptr_prev % slice_stride(1:10)/), &
273 & n = (/10, 10/), &
274 & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
275 stat = hst_ebadslice
276 cause_c = fullfilename
277 goto 999
278 end if
279
280 !
281 ! GT_HISTORY 変数の結合
282 ! Associate "GT_HISTORY" variable
283 !
284 hptr % history => hptr_prev % history
285 exit searchloop
286 end do searchloop
287
288 !---------------------------------------------------------------
289 ! 新規に割付
290 ! Allocate newly
291 !---------------------------------------------------------------
292 if ( .not. associated( hptr % history ) ) then
293 allocate( hptr % history )
294 hptr % history % initialized = .false.
295 end if
296
297 !---------------------------------------------------------------
298 ! 割り付けられた名前とファイル名を登録
299 ! Regist allocated name and filename
300 !---------------------------------------------------------------
301 call dchashput( opened_files, & ! (inout)
302 & hptr % name, fullfilename ) ! (in)
303
304 end do wholeloop
305
306 nullify( hptr )
307 nullify( hptr_prev )
308
309 !-----------------------------------------------------------------
310 ! 終了処理, 例外処理
311 ! Termination and Exception handling
312 !-----------------------------------------------------------------
313 gthstnml % define_mode = .false.
314999 continue
315 call storeerror( stat, subname, err, cause_c )
316 call endsub( subname )
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 hst_ebadslice
Definition dc_error.f90:568
integer, parameter, public dc_enotinit
-400 or less: DC utilities errors
Definition dc_error.f90:534
integer, parameter, public hst_eintfile
Definition dc_error.f90:559
integer, parameter, public hst_ebadorigin
Definition dc_error.f90:573
integer, parameter, public hst_ebadterminus
Definition dc_error.f90:572
integer, parameter, public hst_enotindefine
-500 or less: Data I/O layer errors
Definition dc_error.f90:557
integer, parameter, public hst_ebadnewfileint
Definition dc_error.f90:569
Hash (associative array) module.
Definition dc_hash.f90:143
Message output module.
Handling character types.
Definition dc_string.f90:83
character(string) function, public joinchar(carray, expr)
Debug tracing module.
Definition dc_trace.f90:150
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
Provides kind type parameter values.
Definition dc_types.f90:55
real(sp), parameter, public sp_eps
Machine epsilon for single precision real number.
Definition dc_types.f90:87
integer, parameter, public string
Character length for string
Definition dc_types.f90:137

References dc_trace::beginsub(), dc_error::dc_enotinit, dc_error::dc_noerr, dc_trace::endsub(), dc_error::hst_ebadnewfileint, dc_error::hst_ebadorigin, dc_error::hst_ebadslice, dc_error::hst_ebadterminus, dc_error::hst_eintfile, dc_error::hst_enotindefine, dc_string::joinchar(), gtool_history_nmlinfo_internal::opened_files, dc_types::sp_eps, dc_error::storeerror(), and dc_types::string.

Here is the call graph for this function: