Loading...
Searching...
No Matches
gtool_history_nmlinfo_internal.f90
Go to the documentation of this file.
1!= gtool_history_nmlinfo 内で使用される内部向け定数, 変数, 手続き群
2!= Internal constants, variables, procedures used in "gtool_history_nmlinfo"
3!
4! Authors:: Yasuhiro MORIKAWA
5! Version:: $Id: gtool_history_nmlinfo_internal.f90,v 1.1 2009-05-11 15:15:15 morikawa Exp $
6! Tag Name:: $Name: $
7! Copyright:: Copyright (C) GFD Dennou Club, 2007-2009. All rights reserved.
8! License:: See COPYRIGHT[link:../../../COPYRIGHT]
9!
10
12 !
13 != gtool_history_nmlinfo 内で使用される内部向け定数, 変数, 手続き群
14 !
15 != Internal constants, variables, procedures used in "gtool_history_nmlinfo"
16 !
17
18 use dc_hash, only: hash
19 implicit none
20 private
22
23 character(1), parameter, public:: name_delimiter = ','
24 ! 複数の変数名の区切り文字
25 ! Delimiter for multiple variable names
26
27 type(hash), save, public:: opened_files
28 ! 複数の変数を一つのファイルへ
29 ! 出力するためのチェック用変数.
30 !
31 ! Variables for checking for
32 ! output multiple variables to one file.
33
34 character(*), parameter, public:: version = &
35 & '$Name: $' // &
36 & '$Id: gtool_history_nmlinfo_internal.f90,v 1.1 2009-05-11 15:15:15 morikawa Exp $'
37
38 !-----------------------------------------------------------------
39 ! 非公開手続
40 ! Private procedures
41 !-----------------------------------------------------------------
42
43 interface listnext
44 module procedure hstnmlinfolistnext
45 end interface
46
47 interface listlast
48 module procedure hstnmlinfolistlast
49 end interface
50
51 interface listsearch
52 module procedure hstnmlinfolistsearch
53 end interface
54
55contains
56
57 subroutine hstnmlinfolistnext( &
58 & gthstnml_list, err )
59 !
60 ! リスト構造である *gthstnml_list* (GTHST_NMLINFO_ENTRY 型) を受け取り,
61 ! 次のエントリを *gthstnml_list* に再結合して返します.
62 ! 次のエントリが無い場合, *gthstnml_list* の最後のエントリの
63 ! *next* (空状態) に接続して返します.
64 ! *gthstnml_list* が始めから空の場合には空状態を返します.
65 !
66 ! *gthstnml_list* (type "GTHST_NMLINFO_ENTRY") that is a list structure
67 ! is recieved, and *gthstnml_list* is reassociated to next entry, and
68 ! is returned.
69 ! If next entry is not found, *gthstnml_list* is associated to
70 ! *next* in last entry (null), and returned.
71 ! If *gthstnml_list* is null from the beginning, null is returned.
72 !
74 use dc_trace, only: beginsub, endsub
75 use dc_error, only: storeerror, dc_noerr
76 use dc_types, only: token, string
77 implicit none
78 type(gthst_nmlinfo_entry), pointer:: gthstnml_list
79 ! (inout)
80 logical, intent(out), optional:: err
81 ! 例外処理用フラグ.
82 ! デフォルトでは, この手続き内でエラーが
83 ! 生じた場合, プログラムは強制終了します.
84 ! 引数 *err* が与えられる場合,
85 ! プログラムは強制終了せず, 代わりに
86 ! *err* に .true. が代入されます.
87 !
88 ! Exception handling flag.
89 ! By default, when error occur in
90 ! this procedure, the program aborts.
91 ! If this *err* argument is given,
92 ! .true. is substituted to *err* and
93 ! the program does not abort.
94
95 !-----------------------------------
96 ! 作業変数
97 ! Work variables
98 integer:: stat
99 character(STRING):: cause_c
100 character(*), parameter:: subname = 'HstNmlInfoListNext'
101 continue
102 call beginsub( subname )
103 stat = dc_noerr
104 cause_c = ''
105
106 !-----------------------------------------------------------------
107 ! 空状態の場合は何もしないで返す
108 ! If null, return without change
109 !-----------------------------------------------------------------
110 if ( .not. associated( gthstnml_list ) ) goto 999
111
112 !-----------------------------------------------------------------
113 ! 次のエントリに結合して返す
114 ! Next entry is associated, and returned
115 !-----------------------------------------------------------------
116 gthstnml_list => gthstnml_list % next
117
118 !-----------------------------------------------------------------
119 ! 終了処理, 例外処理
120 ! Termination and Exception handling
121 !-----------------------------------------------------------------
122999 continue
123 call storeerror( stat, subname, err, cause_c )
124 call endsub( subname )
125 end subroutine hstnmlinfolistnext
126
127 subroutine hstnmlinfolistlast( &
128 & gthstnml_list, previous, err )
129 !
130 ! リスト構造である *gthstnml_list* (GTHST_NMLINFO_ENTRY 型) を受け取り,
131 ! 最後のエントリに再結合して返します.
132 ! *gthstnml_list* が始めから空の場合には空状態を返します.
133 !
134 ! *previous* が与えられる場合, 当該エントリの一つ前の
135 ! エントリに結合します.
136 !
137 ! *gthstnml_list* (type "GTHST_NMLINFO_ENTRY") that is a list structure
138 ! is recieved, and *gthstnml_list* is reassociated to
139 ! last entry, and returned.
140 ! If *gthstnml_list* is null from the beginning, null is returned.
141 !
142 ! If *previous* is given, an entry previous to the above entry
143 ! is associated.
144 !
146 use dc_trace, only: beginsub, endsub
147 use dc_error, only: storeerror, dc_noerr
148 use dc_types, only: token, string
149 implicit none
150 type(gthst_nmlinfo_entry), pointer:: gthstnml_list
151 ! (inout)
152 type(gthst_nmlinfo_entry), pointer, optional:: previous
153 ! (out)
154 logical, intent(out), optional:: err
155 ! 例外処理用フラグ.
156 ! デフォルトでは, この手続き内でエラーが
157 ! 生じた場合, プログラムは強制終了します.
158 ! 引数 *err* が与えられる場合,
159 ! プログラムは強制終了せず, 代わりに
160 ! *err* に .true. が代入されます.
161 !
162 ! Exception handling flag.
163 ! By default, when error occur in
164 ! this procedure, the program aborts.
165 ! If this *err* argument is given,
166 ! .true. is substituted to *err* and
167 ! the program does not abort.
168
169 !-----------------------------------
170 ! 作業変数
171 ! Work variables
172 integer:: stat
173 character(STRING):: cause_c
174 character(*), parameter:: subname = 'HstNmlInfoListLast'
175 continue
176 call beginsub( subname )
177 stat = dc_noerr
178 cause_c = ''
179
180 if ( present( previous ) ) nullify( previous )
181
182 !-----------------------------------------------------------------
183 ! 空状態の場合は何もしないで返す
184 ! If null, return without change
185 !-----------------------------------------------------------------
186 if ( .not. associated( gthstnml_list ) ) goto 999
187
188 !-----------------------------------------------------------------
189 ! 最後のエントリの *next* に結合して返す
190 ! "*next*" in last entry is associated, and returned
191 !-----------------------------------------------------------------
192 do while ( associated( gthstnml_list % next ) )
193 if ( present( previous ) ) previous => gthstnml_list
194 call listnext( gthstnml_list = gthstnml_list ) ! (inout)
195 end do
196
197 !-----------------------------------------------------------------
198 ! 終了処理, 例外処理
199 ! Termination and Exception handling
200 !-----------------------------------------------------------------
201999 continue
202 call storeerror( stat, subname, err, cause_c )
203 call endsub( subname )
204 end subroutine hstnmlinfolistlast
205
206 subroutine hstnmlinfolistsearch( &
207 & gthstnml_list, name, &
208 & previous, next, err )
209 !
210 ! リスト構造である *gthstnml_list* (GTHST_NMLINFO_ENTRY 型) を受け取り,
211 ! 引数 *name* と同じ値を持つエントリに再結合して返します.
212 ! 見つからない場合は空状態を返します.
213 ! *gthstnml_list* が始めから空の場合には空状態を返します.
214 !
215 ! *previous* が与えられる場合, 当該エントリの一つ前の
216 ! エントリに結合します. 前のエントリが無い場合には
217 ! 空状態を返します.
218 !
219 ! *next* が与えられる場合, 当該エントリの一つ後ろの
220 ! エントリに結合します. 後ろのエントリが無い場合には
221 ! 空状態を返します.
222 !
223 ! *gthstnml_list* (type "GTHST_NMLINFO_ENTRY") that is a list structure
224 ! is recieved, and *gthstnml_list* is reassociated to
225 ! the entry that has a value that is same as argument *name*,
226 ! and returned.
227 ! If the entry is not found, null is returned.
228 ! If *gthstnml_list* is null from the beginning, null is returned.
229 !
230 ! If *previous* is given, an entry previous to the above entry
231 ! is associated. If previous entries are not found,
232 ! null is returned.
233 !
234 ! If *next* is given, an entry next to the above entry
235 ! is associated. If next entries are not found,
236 ! null is returned.
237 !
239 use dc_trace, only: beginsub, endsub
240 use dc_error, only: storeerror, dc_noerr
241 use dc_types, only: token, string
242 implicit none
243 type(gthst_nmlinfo_entry), pointer:: gthstnml_list
244 ! (inout)
245 character(*), intent(in):: name
246 ! 変数名.
247 ! 先頭の空白は無視されます.
248 !
249 ! Variable identifier.
250 ! Blanks at the head of the name are ignored.
251 type(gthst_nmlinfo_entry), pointer, optional:: previous
252 ! (out)
253 type(gthst_nmlinfo_entry), pointer, optional:: next
254 ! (out)
255 logical, intent(out), optional:: err
256 ! 例外処理用フラグ.
257 ! デフォルトでは, この手続き内でエラーが
258 ! 生じた場合, プログラムは強制終了します.
259 ! 引数 *err* が与えられる場合,
260 ! プログラムは強制終了せず, 代わりに
261 ! *err* に .true. が代入されます.
262 !
263 ! Exception handling flag.
264 ! By default, when error occur in
265 ! this procedure, the program aborts.
266 ! If this *err* argument is given,
267 ! .true. is substituted to *err* and
268 ! the program does not abort.
269
270 !-----------------------------------
271 ! 作業変数
272 ! Work variables
273 integer:: stat
274 character(STRING):: cause_c
275 character(*), parameter:: subname = 'HstNmlInfoListSearch'
276 continue
277 call beginsub( subname )
278 stat = dc_noerr
279 cause_c = ''
280
281 !-----------------------------------------------------------------
282 ! 空状態の場合は何もしないで返す
283 ! If null, return without change
284 !-----------------------------------------------------------------
285 if ( .not. associated( gthstnml_list ) ) goto 999
286
287 !-----------------------------------------------------------------
288 ! 引数 *name* と同じ *name* を持つエントリを探査
289 ! The entry that has *name* that is same as argument *name* is searched
290 !-----------------------------------------------------------------
291 if ( present( previous ) ) nullify( previous )
292 if ( present( next ) ) nullify( next )
293 if ( trim( adjustl( gthstnml_list % name ) ) == trim( adjustl( name ) ) ) then
294 if ( present( next ) ) then
295 next => gthstnml_list % next
296 end if
297 goto 999
298 end if
299
300 do while ( associated( gthstnml_list ) )
301 if ( present( previous ) ) previous => gthstnml_list
302 call listnext( gthstnml_list = gthstnml_list ) ! (inout)
303 if ( .not. associated( gthstnml_list ) ) goto 999
304 if ( trim( adjustl( gthstnml_list % name ) ) == trim( adjustl( name ) ) ) then
305 if ( present( next ) ) then
306 next => gthstnml_list % next
307 end if
308 goto 999
309 end if
310 end do
311
312 !-----------------------------------------------------------------
313 ! 終了処理, 例外処理
314 ! Termination and Exception handling
315 !-----------------------------------------------------------------
316999 continue
317 call storeerror( stat, subname, err, cause_c )
318 call endsub( subname )
319 end subroutine hstnmlinfolistsearch
320
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
Provides kind type parameter values.
Definition dc_types.f90:49
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:109
integer, parameter, public string
Character length for string
Definition dc_types.f90:118
character(1), parameter, public name_delimiter