hstnmlinfoenddefine.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine hstnmlinfoenddefine (gthstnml, err)
 

Function/Subroutine Documentation

◆ hstnmlinfoenddefine()

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

Definition at line 11 of file hstnmlinfoenddefine.f90.

References dc_trace::beginsub(), dc_error::dc_enotinit, dc_error::dc_noerr, dc_types::dp, 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::stdout, dc_error::storeerror(), dc_types::string, and dc_types::token.

11  !
12  ! 定義モードから出力モードに移行し,
13  ! *gthstnml* に設定した情報を確定します.
14  ! HstNmlInfoAssocGTHist サブルーチンを呼び出す前に,
15  ! 必ずこのサブルーチンを呼び出してください.
16  ! このサブルーチンを呼んだ後に
17  ! HstNmlInfoAdd, HstNmlInfoDelete, HstNmlInfoResetDefault
18  ! を呼ぶとプログラムはエラーを発生させます.
19  !
20  ! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
21  ! されていない場合にも, プログラムはエラーを発生させます.
22  !
23  ! Transit from define mode to output mode,
24  ! and determine information configured in *gthstnml*.
25  ! Use this subroutine before "HstNmlInfoAssocGTHist" is used.
26  ! If "HstNmlInfoAdd", "HstNmlInfoDelete", "HstNmlInfoResetDefault"
27  ! are used after
28  ! this subroutine is used, error is occurred.
29  !
30  ! If *gthstnml* is not initialized by "HstNmlInfoCreate" yet,
31  ! error is occurred.
32  !
36  use dc_trace, only: beginsub, endsub
38  use dc_types, only: dp, string, token, stdout
40  use dc_error, only: storeerror, dc_noerr, dc_enotinit, &
43  use dc_message, only: messagenotify
44  implicit none
45  type(gthst_nmlinfo), intent(inout):: gthstnml
46  logical, intent(out), optional:: err
47  ! 例外処理用フラグ.
48  ! デフォルトでは, この手続き内でエラーが
49  ! 生じた場合, プログラムは強制終了します.
50  ! 引数 *err* が与えられる場合,
51  ! プログラムは強制終了せず, 代わりに
52  ! *err* に .true. が代入されます.
53  !
54  ! Exception handling flag.
55  ! By default, when error occur in
56  ! this procedure, the program aborts.
57  ! If this *err* argument is given,
58  ! .true. is substituted to *err* and
59  ! the program does not abort.
60 
61  !-----------------------------------
62  ! 複数の変数を一つのファイルへ出力するためのチェック用変数
63  ! Variables for checking for output multiple variables to one file
64  character(STRING):: opname, opfile
65  logical:: end
66 
67  !-----------------------------------
68  ! 作業変数
69  ! Work variables
70  character(STRING):: fullfilename
71  type(gthst_nmlinfo_entry), pointer:: hptr =>null()
72  type(gthst_nmlinfo_entry), pointer:: hptr_prev =>null()
73  integer:: stat
74  character(STRING):: cause_c
75  character(*), parameter:: subname = 'HstNmlInfoEndDefine'
76  continue
77  call beginsub( subname )
78  stat = dc_noerr
79  cause_c = ''
80 
81  !-----------------------------------------------------------------
82  ! 初期設定のチェック
83  ! Check initialization
84  !-----------------------------------------------------------------
85  if ( .not. gthstnml % initialized ) then
86  stat = dc_enotinit
87  cause_c = 'GTHST_NMLINFO'
88  goto 999
89  end if
90 
91  if ( .not. gthstnml % define_mode ) then
92  stat = hst_enotindefine
93  cause_c = 'EndDefine'
94  goto 999
95  end if
96 
97  !-----------------------------------------------------------------
98  ! gtool_history_types#GT_HISTORY 変数の割付
99  ! Allocate "gtool_history_types#GT_HISTORY" variables
100  !-----------------------------------------------------------------
101  hptr => gthstnml % gthstnml_list
102  if ( .not. associated( hptr % history ) ) then
103  allocate( hptr % history )
104  end if
105  wholeloop : do while ( associated( hptr % next ) )
106  call listnext( gthstnml_list = hptr ) ! (inout)
107  if ( trim(hptr % name) == '' .or. trim(hptr % file) == '' ) &
108  & cycle wholeloop
109 
110  fullfilename = trim( hptr % fileprefix ) // hptr % file
111 
112  !---------------------------------------------------------------
113  ! 以前に同一ファイル名の gtool_history_types#GT_HISTORY 変数がある場合, そちらに結合
114  ! If "gtool_history_types#GT_HISTORY" that has same filename exist already, associate to it
115  !---------------------------------------------------------------
116  nullify( hptr_prev )
117  call dchashrewind(opened_files) ! (inout)
118  searchloop : do
119  call dchashnext( opened_files, & ! (inout)
120  & opname, opfile, end ) ! (out)
121  if ( end ) exit searchloop
122  if ( trim(opfile) /= trim(fullfilename) ) cycle searchloop
123  hptr_prev => gthstnml % gthstnml_list
124 
125  call listsearch( gthstnml_list = hptr_prev, & ! (inout)
126  & name = opname ) ! (in)
127  if ( .not. associated( hptr_prev ) ) cycle searchloop
128  if ( trim(hptr % name) == trim(hptr_prev % name) ) cycle searchloop
129 
130  ! interval_value, interval_unit の同一性をチェック
131  ! Check consistency of "interval_value", "interval_unit"
132  !
133  if ( hptr % interval_value /= hptr_prev % interval_value ) then
134  call messagenotify( 'W', subname, &
135  & '@interval_value=%r (var=%a) and @interval_value=%r (var=%a) are applied to a file "%a"', &
136  & r = (/hptr % interval_value, hptr_prev % interval_value/), &
137  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
138  stat = hst_eintfile
139  cause_c = fullfilename
140  goto 999
141  elseif ( hptr % interval_unit /= hptr_prev % interval_unit ) then
142  call messagenotify( 'W', subname, &
143  & '@interval_unit=%a (var=%a) and @interval_unit=%a (var=%a) are applied to a file "%a"', &
144  & ca = stoa(hptr % interval_unit, hptr % name, &
145  & hptr_prev % interval_unit, hptr_prev % name, &
146  & fullfilename) )
147  stat = hst_eintfile
148  cause_c = fullfilename
149  goto 999
150  end if
151 
152  ! origin_value, origin_unit の同一性をチェック
153  ! Check consistency of "origin_value", "origin_unit"
154  !
155  if ( hptr % origin_value /= hptr_prev % origin_value ) then
156  call messagenotify( 'W', subname, &
157  & '@origin_value=%r (var=%a) and @origin_value=%r (var=%a) are applied to a file "%a"', &
158  & r = (/hptr % origin_value, hptr_prev % origin_value/), &
159  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
160  stat = hst_ebadorigin
161  cause_c = fullfilename
162  goto 999
163  elseif ( hptr % origin_unit /= hptr_prev % origin_unit ) then
164  call messagenotify( 'W', subname, &
165  & '@origin_unit=%a (var=%a) and @origin_unit=%a (var=%a) are applied to a file "%a"', &
166  & ca = stoa(hptr % origin_unit, hptr % name, &
167  & hptr_prev % origin_unit, hptr_prev % name, &
168  & fullfilename) )
169  stat = hst_ebadorigin
170  cause_c = fullfilename
171  goto 999
172  end if
173 
174  ! terminus_value, terminus_unit の同一性をチェック
175  ! Check consistency of "terminus_value", "terminus_unit"
176  !
177  if ( hptr % terminus_value /= hptr_prev % terminus_value ) then
178  call messagenotify( 'W', subname, &
179  & '@terminus_value=%r (var=%a) and @terminus_value=%r (var=%a) are applied to a file "%a"', &
180  & r = (/hptr % terminus_value, hptr_prev % terminus_value/), &
181  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
182  stat = hst_ebadterminus
183  cause_c = fullfilename
184  goto 999
185  elseif ( hptr % terminus_unit /= hptr_prev % terminus_unit ) then
186  call messagenotify( 'W', subname, &
187  & '@terminus_unit=%a (var=%a) and @terminus_unit=%a (var=%a) are applied to a file "%a"', &
188  & ca = stoa(hptr % terminus_unit, hptr % name, &
189  & hptr_prev % terminus_unit, hptr_prev % name, &
190  & fullfilename) )
191  stat = hst_ebadterminus
192  cause_c = fullfilename
193  goto 999
194  end if
195 
196  ! newfile_intvalue が有効な場合はエラーを返す.
197  ! Error is occurred when "newfile_intvalue" is valid
198  !
199  if ( ( hptr % newfile_intvalue > 0.0 ) &
200  & .or. ( hptr_prev % newfile_intvalue > 0.0 ) ) then
201  call messagenotify( 'W', subname, &
202  & 'when @newfile_intvalue=%d (var=%a) > 0 or' // &
203  & ' @newfile_intvalue=%d (var=%a) > 0, multiple variables can not be output to one file "%a"', &
204  & i = (/hptr % newfile_intvalue, hptr_prev % newfile_intvalue/), &
205  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
206  stat = hst_ebadnewfileint
207  cause_c = fullfilename
208  goto 999
209  end if
210 
211  ! newfile_intvalue, newfile_intunit の同一性をチェック
212  ! Check consistency of "newfile_intvalue", "newfile_intunit"
213  !
214  if ( hptr % newfile_intvalue /= hptr_prev % newfile_intvalue ) then
215  call messagenotify( 'W', subname, &
216  & '@newfile_intvalue=%d (var=%a) and @newfile_intvalue=%d (var=%a) are applied to a file "%a"', &
217  & i = (/hptr % newfile_intvalue, hptr_prev % newfile_intvalue/), &
218  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
219  stat = hst_ebadnewfileint
220  cause_c = fullfilename
221  goto 999
222  elseif ( hptr % newfile_intunit /= hptr_prev % newfile_intunit ) then
223  call messagenotify( 'W', subname, &
224  & '@newfile_intunit=%a (var=%a) and @newfile_intunit=%a (var=%a) are applied to a file "%a"', &
225  & ca = stoa(hptr % newfile_intunit, hptr % name, &
226  & hptr_prev % newfile_intunit, hptr_prev % name, &
227  & fullfilename) )
228  stat = hst_ebadnewfileint
229  cause_c = fullfilename
230  goto 999
231  end if
232 
233 
234  ! slice_start, slice_end, slice_stride, space_average の同一性チェック
235  ! Check consistency of "slice_start", "slice_end", "slice_stride", "space_average"
236  !
237  if ( any( hptr % slice_start /= hptr_prev % slice_start ) ) then
238  call messagenotify( 'W', subname, &
239  & '@slice_start=%*d (var=%a) and @slice_start=%*d (var=%a) are applied to a file "%a"', &
240  & i = (/hptr % slice_start(1:10), hptr_prev % slice_start(1:10)/), &
241  & n = (/10, 10/), &
242  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
243  stat = hst_ebadslice
244  cause_c = fullfilename
245  goto 999
246  elseif ( any( hptr % slice_end /= hptr_prev % slice_end ) ) then
247  call messagenotify( 'W', subname, &
248  & '@slice_end=%*d (var=%a) and @slice_end=%*d (var=%a) are applied to a file "%a"', &
249  & i = (/hptr % slice_end(1:10), hptr_prev % slice_end(1:10)/), &
250  & n = (/10, 10/), &
251  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
252  stat = hst_ebadslice
253  cause_c = fullfilename
254  goto 999
255  elseif ( any( hptr % slice_stride /= hptr_prev % slice_stride ) ) then
256  call messagenotify( 'W', subname, &
257  & '@slice_stride=%*d (var=%a) and @slice_stride=%*d (var=%a) are applied to a file "%a"', &
258  & i = (/hptr % slice_stride(1:10), hptr_prev % slice_stride(1:10)/), &
259  & n = (/10, 10/), &
260  & ca = stoa(hptr % name, hptr_prev % name, fullfilename) )
261  stat = hst_ebadslice
262  cause_c = fullfilename
263  goto 999
264  end if
265 
266  !
267  ! GT_HISTORY 変数の結合
268  ! Associate "GT_HISTORY" variable
269  !
270  hptr % history => hptr_prev % history
271  exit searchloop
272  end do searchloop
273 
274  !---------------------------------------------------------------
275  ! 新規に割付
276  ! Allocate newly
277  !---------------------------------------------------------------
278  if ( .not. associated( hptr % history ) ) then
279  allocate( hptr % history )
280  hptr % history % initialized = .false.
281  end if
282 
283  !---------------------------------------------------------------
284  ! 割り付けられた名前とファイル名を登録
285  ! Regist allocated name and filename
286  !---------------------------------------------------------------
287  call dchashput( opened_files, & ! (inout)
288  & hptr % name, fullfilename ) ! (in)
289 
290  end do wholeloop
291 
292  nullify( hptr )
293  nullify( hptr_prev )
294 
295  !-----------------------------------------------------------------
296  ! 終了処理, 例外処理
297  ! Termination and Exception handling
298  !-----------------------------------------------------------------
299  gthstnml % define_mode = .false.
300 999 continue
301  call storeerror( stat, subname, err, cause_c )
302  call endsub( subname )
integer, parameter, public hst_enotindefine
Definition: dc_error.f90:581
integer, parameter, public dc_enotinit
Definition: dc_error.f90:557
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition: dc_types.f90:109
integer, parameter, public hst_eintfile
Definition: dc_error.f90:583
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
integer, parameter, public hst_ebadterminus
Definition: dc_error.f90:596
character(string) function, public joinchar(carray, expr)
Definition: dc_string.f90:861
integer, parameter, public hst_ebadslice
Definition: dc_error.f90:592
integer, parameter, public hst_ebadnewfileint
Definition: dc_error.f90:593
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
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
種別型パラメタを提供します。
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 hst_ebadorigin
Definition: dc_error.f90:597
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118
Here is the call graph for this function: