gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
historyautochkoutput.f90
Go to the documentation of this file.
1!> @file historyautochkoutput.f90
2!>
3!> @author Yasuhiro MORIKAWA
4!> @copyright Copyright (C) GFD Dennou Club, 2010-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Check output setting of a variable
9!> @enden
10!>
11!> @ja
12!> @brief 変数の出力設定の確認手続
13!> @endja
14
15 !> @en
16 !> @brief Check output setting of a variable
17 !>
18 !> If output setting of @p varname is valid, .true. is returned.
19 !> If output setting of @p varname is invalid, .false. is returned.
20 !>
21 !> If initialization with HistoryAutoCreate is not done yet, .false. is returned.
22 !> If @p varname is invalid, .false. is returned.
23 !> @enden
24 !>
25 !> @ja
26 !> @brief 変数の出力設定の確認
27 !>
28 !> @p varname に指定された変数名が出力されるよう設定されている
29 !> 場合には .true. が, 出力されないよう設定されている場合は
30 !> .false. が返ります.
31 !>
32 !> HistoryAutoCreate による初期設定がなされていない場合や,
33 !> @p varname に指定された変数名が HistoryAutoAddVariable によって
34 !> 登録されていない場合, 返り値に .false. が返ります.
35 !> @endja
36 !>
37 !> @param[in] varname 変数の名前. Variable name.
38 !> @return 出力設定が有効であれば .true.
39 function historyautochkoutput( varname ) result(result)
42
43 implicit none
44 logical:: result
45 character(*), intent(in):: varname
46 ! 変数の名前.
47 ! Variable name
48
49 integer:: i, vnum
50 integer, save:: svnum = 1
51 continue
52 ! 初期設定チェック
53 ! Check initialization
54 !
55 if ( .not. initialized ) then
56 result = .false.
57 goto 999
58 end if
59
60 ! 変数 ID のサーチ
61 ! Search variable ID
62 !
63 varsearch: do
64 do i = svnum, numvars
65 if ( trim( varname_vars(i) ) == trim(varname) ) then
66 vnum = i
67 exit varsearch
68 end if
69 end do
70 do i = 1, svnum - 1
71 if ( trim( varname_vars(i) ) == trim(varname) ) then
72 vnum = i
73 exit varsearch
74 end if
75 end do
76
77 result = .false.
78 goto 999
79 end do varsearch
80
81 svnum = vnum
82
83 ! 出力設定の確認
84 ! Check output setting
85 !
86 result = output_valid_vars( vnum )
87
88999 continue
89 end function historyautochkoutput
90
91
92
93 !> @en
94 !> @brief Check output timing of a variable
95 !>
96 !> If @p varname is output on @p time, .true. is returned.
97 !>
98 !> Please use this function as follows.
99 !>
100 !> if ( HistoryAutoChkOutputTiming( time, var ) ) then
101 !> <some operation ...>
102 !> end if
103 !>
104 !> call HistoryAutoPut( time, var, data )
105 !>
106 !> Following usage does not return correct values.
107 !>
108 !> do i = 1, 10
109 !> write(*,*) HistoryAutoChkOutputTiming( i * timestep, var )
110 !> end do
111 !>
112 !> If initialization with HistoryAutoCreate is not done yet, .false. is returned.
113 !> If @p varname is invalid, .false. is returned.
114 !> @enden
115 !>
116 !> @ja
117 !> @brief 変数の出力タイミングの確認
118 !>
119 !> @p varname に指定された変数名が、@p time のタイミングで出力されるよう
120 !> 設定されている場合には .true. が, 出力されないよう設定されている場合は
121 !> .false. が返ります.
122 !>
123 !> なお, gtool_historyauto は時間ステップ可変に対応しているため,
124 !> @p time のタイミングで出力されるかどうかについては,
125 !> その前回に出力された時間に依存します. 従って, とある時間の
126 !> 出力設定の確認は下記のように HistoryAutoPut の前で使用して下さい.
127 !>
128 !> if ( HistoryAutoChkOutputTiming( time, var ) ) then
129 !> <some operation ...>
130 !> end if
131 !>
132 !> call HistoryAutoPut( time, var, data )
133 !>
134 !> 以下のように使用した場合には, 期待するような返り値が
135 !> 得られないことにご留意下さい.
136 !>
137 !> do i = 1, 10
138 !> write(*,*) HistoryAutoChkOutputTiming( i * timestep, var )
139 !> end do
140 !>
141 !> HistoryAutoCreate による初期設定がなされていない場合や,
142 !> @p varname に指定された変数名が HistoryAutoAddVariable によって
143 !> 登録されていない場合, 返り値に .false. が返ります.
144 !> @endja
145 !>
146 !> @param[in] time データの時刻. Time of data.
147 !> @param[in] varname 変数の名前. Variable name.
148 !> @return 出力タイミングであれば .true.
149 function historyautochkoutputtiming( time, varname ) result(result)
154 use dc_types, only: dp
155
156 implicit none
157 logical:: result
158 real(dp), intent(in):: time
159 ! データの時刻.
160 ! Time of data
161 character(*), intent(in):: varname
162 ! 変数の名前.
163 ! Variable name
164
165 real(dp), parameter:: zero_time = 0.0_dp
166 integer:: i, vnum
167 integer, save:: svnum = 1
168 continue
169
170 ! 初期設定チェック
171 ! Check initialization
172 !
173 if ( .not. initialized ) then
174 result = .false.
175 goto 999
176 end if
177
178 ! 変数 ID のサーチ
179 ! Search variable ID
180 !
181 varsearch: do
182 do i = svnum, numvars
183 if ( trim( varname_vars(i) ) == trim(varname) ) then
184 vnum = i
185 exit varsearch
186 end if
187 end do
188 do i = 1, svnum - 1
189 if ( trim( varname_vars(i) ) == trim(varname) ) then
190 vnum = i
191 exit varsearch
192 end if
193 end do
194
195 result = .false.
196 goto 999
197 end do varsearch
198
199 svnum = vnum
200
201 ! 出力設定の確認
202 ! Check output setting
203 !
204 result = output_valid_vars( vnum )
205
206 if ( .not. result ) goto 999
207
208 if ( origin_time_vars(vnum) > time ) then
209 result = .false.
210 goto 999
211 end if
212
213 if ( origin_time_vars(vnum) <= time &
214 & .and. ( terminus_time_vars(vnum) < zero_time &
215 & .or. terminus_time_vars(vnum) >= time ) &
216 & .and. .not. histaddvar_vars(vnum) ) then
217
218 result = .true.
219 goto 999
220 end if
221
222 if ( terminus_time_vars(vnum) > zero_time .and. terminus_time_vars(vnum) < time ) then
223 result = .false.
224 goto 999
225 end if
226
227 if ( newfile_inttime_vars(vnum) > zero_time ) then
228 if ( time - newfile_createtime_vars(vnum) >= newfile_inttime_vars(vnum) ) then
229 result = .true.
230 goto 999
231 end if
232 end if
233
234 if ( time - prev_outtime_vars(vnum) >= interval_time_vars(vnum) ) then
235 result = .true.
236 goto 999
237 end if
238
239 result = .false.
240
241999 continue
242 end function historyautochkoutputtiming
logical function historyautochkoutputtiming(time, varname)
logical function historyautochkoutput(varname)
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92
character(token), dimension(1:max_vars), save, public varname_vars
real(dp), dimension(1:max_vars), save, public newfile_inttime_vars
real(dp), dimension(1:max_vars), save, public interval_time_vars
real(dp), dimension(1:max_vars), save, public newfile_createtime_vars
real(dp), dimension(1:max_vars), save, public terminus_time_vars
real(dp), dimension(1:max_vars), save, public prev_outtime_vars
real(dp), dimension(1:max_vars), save, public origin_time_vars
logical, dimension(1:max_vars), save, public output_valid_vars
logical, dimension(1:max_vars), save, public histaddvar_vars