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

Constructor of gtool_history_nmlinfo_types::GTHST_NMLINFO . More...

Go to the source code of this file.

Functions/Subroutines

subroutine hstnmlinfocreate (gthstnml, interval_value, interval_unit, precision, time_average, average, fileprefix, origin_value, origin_unit, terminus_value, terminus_unit, slice_start, slice_end, slice_stride, space_average, newfile_intvalue, newfile_intunit, err)

Detailed Description

Constructor of gtool_history_nmlinfo_types::GTHST_NMLINFO

.

Author
Yasuhiro MORIKAWA

Definition in file hstnmlinfocreate.f90.

Function/Subroutine Documentation

◆ hstnmlinfocreate()

subroutine hstnmlinfocreate ( type(gthst_nmlinfo), intent(inout) gthstnml,
real(dp), intent(in), optional interval_value,
character(*), intent(in), optional interval_unit,
character(*), intent(in), optional precision,
logical, intent(in), optional time_average,
logical, intent(in), optional average,
character(*), intent(in), optional fileprefix,
real(dp), intent(in), optional origin_value,
character(*), intent(in), optional origin_unit,
real(dp), intent(in), optional terminus_value,
character(*), intent(in), optional terminus_unit,
integer, dimension(:), intent(in), optional slice_start,
integer, dimension(:), intent(in), optional slice_end,
integer, dimension(:), intent(in), optional slice_stride,
logical, dimension(:), intent(in), optional space_average,
integer, intent(in), optional newfile_intvalue,
character(*), intent(in), optional newfile_intunit,
logical, intent(out), optional err )

Constructor of gtool_history_nmlinfo_types::GTHST_NMLINFO

Initialize gthstnml by this subroutine, before other procedures are used.

interval_value, interval_unit, precision, time_average (now-defunct average), etc. are set as default values. fileprefix is used as prefixes of output filenames of each variable.

Note that if gthstnml is already initialized by this procedure, error is occurred.

Parameters
[in,out]gthstnmlgtool_history_nmlinfo_types::GTHST_NMLINFO 型変数
[in]interval_value出力間隔の数値 (optional). Numerical value for interval.
[in]interval_unit出力間隔の単位 (optional). Unit for interval.
[in]precision精度 (optional). Precision.
[in]time_average時間平均化フラグ (optional). Flag for time average.
[in]averagetime_average の旧版 (optional). Old version of time_average.
[in]fileprefixファイル名の接頭詞 (optional). Prefixes of filenames.
[in]origin_value出力開始時刻 (optional). Start time of output.
[in]origin_unit出力開始時刻の単位 (optional). Unit of start time.
[in]terminus_value出力終了時刻 (optional). End time of output.
[in]terminus_unit出力終了時刻の単位 (optional). Unit of end time.
[in]slice_start空間方向の開始点 (optional). Start points of spaces.
[in]slice_end空間方向の終了点 (optional). End points of spaces.
[in]slice_stride空間方向の刻み幅 (optional). Strides of spaces.
[in]space_average平均化のフラグ (optional). Flag of average.
[in]newfile_intvalueファイル分割時間間隔 (optional). Interval of file separation.
[in]newfile_intunitファイル分割時間間隔の単位 (optional). Unit of file separation interval.
[out]err例外処理用フラグ. Exception handling flag.

Definition at line 70 of file hstnmlinfocreate.f90.

84 use dc_trace, only: beginsub, endsub
85 use dc_types, only: dp, string
88 use dc_date_types, only: dc_difftime
89 use dc_date, only: dcdifftimecreate
90 use netcdf, only: nf90_max_dims
91 implicit none
92 type(GTHST_NMLINFO), intent(inout):: gthstnml
93 real(DP), intent(in), optional:: interval_value
94 ! ヒストリデータの出力間隔の数値.
95 ! 負の値を与えると, 出力を抑止します.
96 !
97 ! Numerical value for interval of history data output.
98 ! Negative values suppresses output.
99 character(*), intent(in), optional:: interval_unit
100 ! ヒストリデータの出力間隔の単位.
101 ! Unit for interval of history data output
102 character(*), intent(in), optional:: precision
103 ! ヒストリデータの精度.
104 ! Precision of history data
105 logical, intent(in), optional:: time_average
106 ! 出力データの時間平均化フラグ.
107 ! Flag for time average of output data.
108 logical, intent(in), optional:: average
109 ! time_average の旧版.
110 ! Old version of "time_average"
111 character(*), intent(in), optional:: fileprefix
112 ! ヒストリデータのファイル名の接頭詞.
113 ! Prefixes of history data filenames
114 real(DP), intent(in), optional:: origin_value
115 ! 出力開始時刻.
116 ! Start time of output.
117 character(*), intent(in), optional:: origin_unit
118 ! 出力開始時刻の単位.
119 ! Unit of start time of output.
120 real(DP), intent(in), optional:: terminus_value
121 ! 出力終了時刻.
122 ! End time of output.
123 character(*), intent(in), optional:: terminus_unit
124 ! 出力終了時刻の単位.
125 ! Unit of end time of output.
126 integer, intent(in), optional:: slice_start(:)
127 ! 空間方向の開始点.
128 ! Start points of spaces.
129 integer, intent(in), optional:: slice_end(:)
130 ! 空間方向の終了点.
131 ! End points of spaces.
132 integer, intent(in), optional:: slice_stride(:)
133 ! 空間方向の刻み幅.
134 ! Strides of spaces.
135 logical, intent(in), optional:: space_average(:)
136 ! 平均化のフラグ.
137 ! Flag of average.
138 integer, intent(in), optional:: newfile_intvalue
139 ! ファイル分割時間間隔.
140 ! Interval of time of separation of a file.
141 character(*), intent(in), optional:: newfile_intunit
142 ! ファイル分割時間間隔の単位.
143 ! Unit of interval of time of separation of a file.
144 logical, intent(out), optional:: err
145 ! 例外処理用フラグ.
146 ! デフォルトでは, この手続き内でエラーが
147 ! 生じた場合, プログラムは強制終了します.
148 ! 引数 *err* が与えられる場合,
149 ! プログラムは強制終了せず, 代わりに
150 ! *err* に .true. が代入されます.
151 !
152 ! Exception handling flag.
153 ! By default, when error occur in
154 ! this procedure, the program aborts.
155 ! If this *err* argument is given,
156 ! .true. is substituted to *err* and
157 ! the program does not abort.
158
159 !-----------------------------------
160 ! 作業変数
161 ! Work variables
162 type(DC_DIFFTIME):: interval_time
163 integer:: stat, ary_size
164 character(STRING):: cause_c
165 character(*), parameter:: subname = 'HstNmlInfoCreate'
166 continue
167 call beginsub( subname, &
168 & fmt = '@interval_value=%r @interval_unit=%c @precision=%c @time_average=%y @fileprefix=%c', &
169 & d = (/ present_select(.true., -1.0_dp, interval_value) /), &
170 & c1 = trim( present_select(.true., '<no>', interval_unit) ), &
171 & c2 = trim( present_select(.true., '<no>', precision) ), &
172 & l = (/ present_and_true(time_average) /), &
173 & c3 = trim( present_select(.true., '<no>', fileprefix) ), &
174 & version = version )
175 stat = dc_noerr
176 cause_c = ''
177
178 !-----------------------------------------------------------------
179 ! 初期設定のチェック
180 ! Check initialization
181 !-----------------------------------------------------------------
182 if ( gthstnml % initialized ) then
183 stat = dc_ealreadyinit
184 cause_c = 'GTHST_NMLINFO'
185 goto 999
186 end if
187
188 !-----------------------------------------------------------------
189 ! 割付
190 ! Allocate
191 !-----------------------------------------------------------------
192 allocate( gthstnml % gthstnml_list )
193 nullify( gthstnml % gthstnml_list % next )
194
195 !-----------------------------------------------------------------
196 ! デフォルト値の設定
197 ! Configure default values
198 !-----------------------------------------------------------------
199 gthstnml % gthstnml_list % name = ''
200 gthstnml % gthstnml_list % file = ''
201
202 allocate( gthstnml % gthstnml_list % interval_value )
203 allocate( gthstnml % gthstnml_list % interval_unit )
204 allocate( gthstnml % gthstnml_list % precision )
205 allocate( gthstnml % gthstnml_list % time_average )
206 allocate( gthstnml % gthstnml_list % fileprefix )
207
208 allocate( gthstnml % gthstnml_list % origin_value )
209 allocate( gthstnml % gthstnml_list % origin_unit )
210 allocate( gthstnml % gthstnml_list % terminus_value )
211 allocate( gthstnml % gthstnml_list % terminus_unit )
212 allocate( gthstnml % gthstnml_list % slice_start (1:nf90_max_dims) )
213 allocate( gthstnml % gthstnml_list % slice_end (1:nf90_max_dims) )
214 allocate( gthstnml % gthstnml_list % slice_stride (1:nf90_max_dims) )
215 allocate( gthstnml % gthstnml_list % space_average (1:nf90_max_dims) )
216 allocate( gthstnml % gthstnml_list % newfile_intvalue )
217 allocate( gthstnml % gthstnml_list % newfile_intunit )
218
219
220 gthstnml % gthstnml_list % interval_value = -1.0
221 gthstnml % gthstnml_list % interval_unit = 'sec'
222 gthstnml % gthstnml_list % precision = 'float'
223 gthstnml % gthstnml_list % time_average = .false.
224 gthstnml % gthstnml_list % fileprefix = ''
225
226 gthstnml % gthstnml_list % origin_value = -1.0
227 gthstnml % gthstnml_list % origin_unit = 'sec'
228 gthstnml % gthstnml_list % terminus_value = -1.0
229 gthstnml % gthstnml_list % terminus_unit = 'sec'
230 gthstnml % gthstnml_list % slice_start = 1
231 gthstnml % gthstnml_list % slice_end = -1
232 gthstnml % gthstnml_list % slice_stride = 1
233 gthstnml % gthstnml_list % space_average = .false.
234 gthstnml % gthstnml_list % newfile_intvalue = -1
235 gthstnml % gthstnml_list % newfile_intunit = 'sec'
236
237 if ( present(interval_value) ) gthstnml % gthstnml_list % interval_value = &
238 & real( interval_value, kind = kind( gthstnml % gthstnml_list % interval_value ) )
239 if ( present(interval_unit) ) gthstnml % gthstnml_list % interval_unit = interval_unit
240 if ( present(precision) ) gthstnml % gthstnml_list % precision = precision
241
242 if ( present(average) ) gthstnml % gthstnml_list % time_average = average
243 if ( present(time_average) ) gthstnml % gthstnml_list % time_average = time_average
244 if ( present(fileprefix) ) gthstnml % gthstnml_list % fileprefix = fileprefix
245
246 if ( present(origin_value ) ) gthstnml % gthstnml_list % origin_value = &
247 & real( origin_value, kind = kind( gthstnml % gthstnml_list % origin_value ) )
248 if ( present(origin_unit ) ) gthstnml % gthstnml_list % origin_unit = origin_unit
249 if ( present(terminus_value ) ) gthstnml % gthstnml_list % terminus_value = &
250 & real( terminus_value, kind = kind( gthstnml % gthstnml_list % terminus_value ) )
251 if ( present(terminus_unit ) ) gthstnml % gthstnml_list % terminus_unit = terminus_unit
252 if ( present(slice_start ) ) then
253 ary_size = size(slice_start)
254 gthstnml % gthstnml_list % slice_start(1:ary_size) = slice_start
255 end if
256 if ( present(slice_end ) ) then
257 ary_size = size(slice_end)
258 gthstnml % gthstnml_list % slice_end(1:ary_size) = slice_end
259 end if
260 if ( present(slice_stride ) ) then
261 ary_size = size(slice_stride)
262 gthstnml % gthstnml_list % slice_stride(1:ary_size) = slice_stride
263 end if
264 if ( present(space_average ) ) then
265 ary_size = size(space_average)
266 gthstnml % gthstnml_list % space_average(1:ary_size) = space_average
267 end if
268 if ( present(newfile_intvalue) ) gthstnml % gthstnml_list % newfile_intvalue = newfile_intvalue
269 if ( present(newfile_intunit ) ) gthstnml % gthstnml_list % newfile_intunit = newfile_intunit
270
271 !-----------------------------------------------------------------
272 ! 時間の単位のチェック
273 ! Check unit of time
274 !-----------------------------------------------------------------
275 call dcdifftimecreate( &
276 & diff = interval_time, & ! (out)
277 & value = &
278 & real( gthstnml % gthstnml_list % interval_value, dp ), & ! (in)
279 & unit = gthstnml % gthstnml_list % interval_unit, & ! (in)
280 & err = err ) ! (out)
281 if ( present_and_true( err ) ) then
282 stat = usr_errno
283 goto 999
284 end if
285
286 !-----------------------------------------------------------------
287 ! 終了処理, 例外処理
288 ! Termination and Exception handling
289 !-----------------------------------------------------------------
290 gthstnml % initialized = .true.
291 gthstnml % define_mode = .true.
292999 continue
293 call storeerror( stat, subname, err, cause_c )
294 call endsub( subname )
Derived types and parameters for date and time.
Date and time manipulation module.
Definition dc_date.f90:57
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 usr_errno
-1000 or less: User-defined errors
Definition dc_error.f90:579
integer, parameter, public dc_ealreadyinit
Definition dc_error.f90:535
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
Judge optional control parameters.
logical function, public present_and_not_empty(arg)
logical function, public present_and_true(arg)
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
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92

References dc_trace::beginsub(), dc_error::dc_ealreadyinit, dc_error::dc_noerr, dc_types::dp, dc_trace::endsub(), dc_present::present_and_not_empty(), dc_present::present_and_true(), dc_error::storeerror(), dc_types::string, dc_error::usr_errno, and gtool_history_nmlinfo_internal::version.

Here is the call graph for this function: