gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
historyautocreate.f90
Go to the documentation of this file.
1!> @file historyautocreate.f90
2!>
3!> @author Yasuhiro MORIKAWA
4!> @copyright Copyright (C) GFD Dennou Club, 2008-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Initialization of gtool_historyauto
9!> @enden
10!>
11!> @ja
12!> @brief gtool_historyauto の初期設定
13!> @endja
14
15 !> @en
16 !> @brief Initialization for multiple history data output
17 !>
18 !> Set all axes and their weights depended by variables
19 !> output from numerical models to this HistoryAutoCreate.
20 !>
21 !> All variables registered by HistoryAutoAddVariable
22 !> are output if .true. is given to @p all_output or
23 !> @p namelist_filename is not given (or blanks are given).
24 !> On the other hand, if a filename of NAMELIST file is
25 !> given to @p namelist_filename, on/off of output,
26 !> output filename and output interval, etc. can be changed
27 !> from the NAMELIST file.
28 !> For available items, see NAMELIST gtool_historyauto_nml.
29 !>
30 !> Settings about
31 !> @p interval, @p origin, @p terminus, @p slice_start, @p slice_end, @p slice_stride,
32 !> @p space_average, @p time_average, @p newfile_interval
33 !> etc. are used as default values.
34 !> Their set values are overwritten by
35 !> HistoryAutoAddVariable or
36 !> NAMELIST gtool_historyauto_nml.
37 !> (NAMELIST gtool_historyauto_nml is high priority,
38 !> arguments of HistoryAutoAddVariable are medium,
39 !> arguments of HistoryAutoCreate are low).
40 !> @enden
41 !>
42 !> @ja
43 !> @brief 複数のデータ出力を行うための初期化
44 !>
45 !> この HistoryAutoCreate には, モデル内で出力する
46 !> 変数が依存する座標や座標重みなどを全てを設定してください.
47 !>
48 !> @p all_output に .true. を与えた場合や,
49 !> @p namelist_filename を与えない (空文字を与える) 場合には,
50 !> HistoryAutoAddVariable で登録される全ての変数が出力されます.
51 !> 一方で @p namelist_filename に NAMELIST ファイル名を与える場合には,
52 !> その NAMELIST ファイルから出力のオンオフや,
53 !> 出力ファイル名, 出力間隔などを変更可能です.
54 !> 変更可能な項目に関しては NAMELIST gtool_historyauto_nml
55 !> を参照して下さい.
56 !>
57 !> @p interval, @p origin, @p terminus, @p slice_start, @p slice_end, @p slice_stride,
58 !> @p space_average, @p time_average, @p newfile_interval
59 !> などの設定はデフォルト値として使用されます.
60 !> これらの設定値は HistoryAutoAddVariable および
61 !> NAMELIST gtool_historyauto_nml で上書きされます.
62 !> (優先度が高いのは NAMELIST gtool_historyauto_nml,
63 !> HistoryAutoAddVariable の引数,
64 !> HistoryAutoCreate の引数 の順です).
65 !> @endja
66 subroutine historyautocreate3( &
67 & title, source, institution, & ! (in)
68 & dims, dimsizes, longnames, units, & ! (in)
69 & origin, terminus, & ! (in)
70 & xtypes, conventions, gt_version, & ! (in) optional
71 & all_output, & ! (in) optional
72 & file_prefix, & ! (in) optional
73 & namelist_filename, & ! (in) optional
74 & interval, & ! (in) optional
75 & slice_start, slice_end, slice_stride, & ! (in) optional
76 & space_average, & ! (in) optional
77 & time_average, & ! (in) optional
78 & newfile_interval, & ! (in) optional
79 & rank, & ! (in) optional
80 & origin_date, origin_date_invalid, & ! (in) optional
81 & start_date, cal, & ! (in) optional
82 & flag_mpi_gather, flag_mpi_split & ! (in) optional
83 & )
85 & zero_time, numdims, &
90 use gtool_history, only: historyaxiscreate, historyaxisaddattr
94 use dc_trace, only: beginsub, endsub
97 use netcdf, only: nf90_emaxdims, nf90_max_dims
101 use dc_calendar, only: dc_cal, dc_cal_date, &
102 & dccaldateinquire, dccalinquire, dccaldefault
103 use dc_date, only: dcdifftimecreate, evalbyunit, tochar, tocharcal, eval
105 use dc_message, only: messagenotify
106 use dc_iounit, only: fileopen
107 use dc_types, only: dp, string, token
108 implicit none
109 character(*), intent(in):: title
110 ! データ全体の表題.
111 ! Title of entire data
112 character(*), intent(in):: source
113 ! データを作成する際の手段.
114 ! Source of data file
115 character(*), intent(in):: institution
116 ! ファイルを最終的に変更した組織/個人.
117 ! Institution or person that changes files for the last time
118 character(*), intent(in):: dims(:)
119 ! 次元の名前.
120 !
121 ! 配列の大きさに制限はありません.
122 ! 個々の次元の文字数は dc_types#TOKEN まで.
123 ! 配列内の文字数は
124 ! 全て同じでなければなりません.
125 ! 足りない文字分は空白で
126 ! 補ってください.
127 !
128 ! Names of dimensions.
129 !
130 ! Length of array is unlimited.
131 ! Limits of numbers of characters of each
132 ! dimensions are "dc_types#TOKEN".
133 ! Numbers of characters in this array
134 ! must be same.
135 ! Make up a deficit with blanks.
136 !
137 integer, intent(in):: dimsizes (:)
138 ! dims で指定したそれぞれの次元大きさ.
139 !
140 ! 配列の大きさは dims の大きさと等しい
141 ! 必要があります. '0' (数字のゼロ) を指定
142 ! するとその次元は 無制限次元 (unlimited
143 ! dimension) となります. (gtool_history
144 ! では時間の次元に対して無制限次元を
145 ! 用いることを想定しています). ただし,
146 ! 1 つの NetCDF ファイル (バージョン 3)
147 ! は最大で 1 つの無制限次元しか持てないので,
148 ! 2 ヶ所以上に '0' を指定しないでください.
149 ! その場合, 正しく gtool4 データが出力されません.
150 !
151 ! Lengths of dimensions specified with "dims".
152 !
153 ! Length of this array must be same as
154 ! length of "dim". If '0' (zero) is
155 ! specified, the dimension is treated as
156 ! unlimited dimension.
157 ! (In "gtool_history", unlimited dimension is
158 ! expected to be used as time).
159 ! Note that one NetCDF file (version 3)
160 ! can not have two or more unlimited
161 ! dimensions, so that do not specify '0'
162 ! to two or more places. In that case,
163 ! gtoo4 data is not output currently
164 !
165 character(*), intent(in):: longnames (:)
166 ! dims で指定したそれぞれの次元の名前.
167 !
168 ! 配列の大きさは dims の大きさ
169 ! と等しい必要があります. 文字数
170 ! は dc_types#STRING まで.
171 ! 配列内の文字数は
172 ! 全て同じでなければなりません.
173 ! 足りない文字分は空白で補います.
174 !
175 ! Names of dimensions specified with "dims".
176 !
177 ! Length of this array must be same as
178 ! length of "dim".
179 ! Limits of numbers of characters are
180 ! "dc_types#STRING".
181 ! Numbers of characters in this array
182 ! must be same.
183 ! Make up a deficit with blanks.
184 !
185 character(*), intent(in):: units(:)
186 ! dims で指定したそれぞれの次元の単位.
187 !
188 ! 配列の大きさは dims の大きさ
189 ! と等しい必要があります. 文字数
190 ! は dc_types#STRING まで.
191 ! 配列内の文字数は
192 ! 全て同じでなければなりません.
193 ! 足りない文字分は空白で補います.
194 !
195 ! Units of dimensions specified with "dims".
196 !
197 ! Length of this array must be same as
198 ! length of "dim".
199 ! Limits of numbers of characters are
200 ! "dc_types#STRING".
201 ! Numbers of characters in this array
202 ! must be same.
203 ! Make up a deficit with blanks.
204 !
205 type(dc_difftime), intent(in):: origin
206 ! 出力開始時刻.
207 !
208 ! Start time of output.
209 !
210 type(dc_difftime), intent(in):: terminus
211 ! 出力終了時刻.
212 !
213 ! End time of output.
214 !
215 character(*), intent(in), optional:: xtypes(:)
216 ! dims で指定したそれぞれの
217 ! 次元のデータ型.
218 !
219 ! デフォルトは float (単精度実数型)
220 ! です. 有効なのは,
221 ! double (倍精度実数型),
222 ! int (整数型) です. 指定しない
223 ! 場合や, 無効な型を指定した場合には,
224 ! float となります. なお, 配列の大きさ
225 ! は *dims* の大きさと等しい必要が
226 ! あります. 配列内の文字数は全て
227 ! 同じでなければなりません.
228 ! 足りない文字分は空白で補います.
229 !
230 ! Data types of dimensions specified
231 ! with "dims".
232 !
233 ! Default value is "float" (single precision).
234 ! Other valid values are
235 ! "double" (double precision),
236 ! "int" (integer).
237 ! If no value or invalid value is specified,
238 ! "float" is applied.
239 ! Length of this array must be same as
240 ! length of "dim".
241 ! Numbers of characters in this array
242 ! must be same.
243 ! Make up a deficit with blanks.
244 !
245 character(*), intent(in), optional:: conventions
246 ! 出力するファイルの netCDF
247 ! 規約
248 !
249 ! 省略した場合,
250 ! もしくは空文字を与えた場合,
251 ! 出力する netCDF 規約の
252 ! Conventions 属性に値
253 ! gtool4_netCDF_Conventions
254 ! が自動的に与えられます.
255 !
256 ! NetCDF conventions of output file.
257 !
258 ! If this argument is omitted or,
259 ! blanks are given,
260 ! gtool4_netCDF_Conventions is given to
261 ! attribute "Conventions" of an output file
262 ! automatically.
263 !
264 character(*), intent(in), optional:: gt_version
265 ! gtool4 netCDF 規約のバージョン
266 !
267 ! 省略した場合, gt_version 属性に
268 ! 規約の最新版のバージョンナンバー
269 ! gtool4_netCDF_version
270 ! が与えられます.
271 ! (ただし, 引数 conventions に
272 ! gtool4_netCDF_Conventions
273 ! 以外が与えられる場合は
274 ! gt_version 属性を作成しません).
275 !
276 ! Version of gtool4 netCDF Conventions.
277 !
278 ! If this argument is omitted,
279 ! latest version number of gtool4 netCDF
280 ! Conventions is given to attribute
281 ! "gt_version" of an output file
282 ! (However, gtool4_netCDF_Conventions is
283 ! not given to an argument "conventions",
284 ! attribute "gt_version" is not created).
285 !
286 logical, intent(in), optional:: all_output
287 ! 登録変数を全て出力するためのフラグ.
288 !
289 ! .true. を指定すると,
290 ! HistoryAutoAddVariable で登録された
291 ! 変数が全て出力されるようになります.
292 !
293 ! *namelist_filename* が指定される場合
294 ! には, デフォルトは .false. となります.
295 ! この場合には,
296 ! *namelist_filename* に指定された
297 ! NAMELIST ファイルから読み込まれる
298 ! NAMELIST#gtool_historyauto_nml
299 ! で指定された変数のみ出力されます.
300 !
301 ! *namelist_filename* が指定されない場合
302 ! には, .true. となります.
303 !
304 !
305 ! Flag for output all registered variables.
306 !
307 ! When .true. is specified,
308 ! all variables registered by
309 ! "HistoryAutoAddVariable" are output.
310 !
311 ! If *namelist_filename* is specified,
312 ! default value becomes .false. .
313 ! In this case,
314 ! only variables specified in
315 ! "NAMELIST#gtool_historyauto_nml"
316 ! loaded from a NAMELIST file
317 ! *namelist_filename*.
318 !
319 ! If *namelist_filename* is not specified,
320 ! this value becomes .true. .
321 !
322 character(*), intent(in), optional:: file_prefix
323 ! データのファイル名の接頭詞.
324 ! Prefixes of history data filenames
325 character(*), intent(in), optional:: namelist_filename
326 ! NAMELIST ファイルの名称.
327 !
328 ! 省略した場合, もしくは空白文字を与えた場合,
329 ! NAMELIST ファイルは読み込みません.
330 !
331 ! Name of NAMELIST file.
332 !
333 ! If this argument is omitted,
334 ! or blanks are specified,
335 ! no NAMELIST file is loaded.
336 !
337 type(dc_difftime), intent(in), optional:: interval
338 ! 出力時間間隔.
339 !
340 ! 省略した場合,
341 ! 自動的に 1.0 [sec] が設定されます.
342 !
343 ! Interval of output time.
344 !
345 ! If this argument is omitted,
346 ! 1.0 [sec] is specified
347 ! automatically.
348 !
349 integer, intent(in), optional:: slice_start(:)
350 ! 空間方向の開始点.
351 !
352 ! 省略した場合, 座標データの開始点が設定されます.
353 !
354 ! Start points of spaces.
355 !
356 ! If this argument is omitted,
357 ! start points of dimensions are set.
358 !
359 integer, intent(in), optional:: slice_end(:)
360 ! 空間方向の終了点.
361 !
362 ! 省略した場合, もしくは負の値が与えら得た場合,
363 ! 座標データの終了点が設定されます.
364 !
365 ! End points of spaces.
366 !
367 ! If this argument is omitted or
368 ! negative value is specified,
369 ! end points of dimensions are set.
370 !
371 integer, intent(in), optional:: slice_stride(:)
372 ! 空間方向の刻み幅.
373 !
374 ! 省略した場合, 1 が設定されます.
375 !
376 ! Strides of spaces
377 !
378 ! If this argument is omitted,
379 ! 1 is set.
380 !
381 logical, intent(in), optional:: space_average(:)
382 ! 平均化のフラグ.
383 !
384 ! .true. が指定される座標に対して平均化を
385 ! 行います.
386 ! 省略した場合, .false. が設定されます.
387 !
388 ! Flag of average.
389 !
390 ! Axes specified .true. are averaged.
391 ! If this argument is omitted,
392 ! .false. is set.
393 !
394 logical, intent(in), optional:: time_average
395 ! 出力データの時間平均フラグ.
396 ! デフォルトは .false.
397 ! Flag for time average of output data
398 ! Default value is .false.
399 integer, intent(in), optional:: newfile_interval
400 ! ファイル分割時間間隔.
401 !
402 ! 省略した場合,
403 ! 時間方向へのファイル分割を行いません.
404 !
405 ! Interval of time of separation of a file.
406 !
407 ! If this argument is omitted,
408 ! a files is not separated in time direction.
409 !
410 character(*), intent(in), optional:: rank
411 ! ランクの名称.
412 !
413 ! Name of a rank.
414 !
415 type(dc_datetime), intent(in), optional:: origin_date
416 ! 出力開始日時.
417 ! この引数は廃止予定のため, start_date を使用して下さい.
418 !
419 ! Start date of output.
420 ! Use "start_date" because this argument is obsolete.
421 !
422 logical, intent(in), optional:: origin_date_invalid
423 ! .true. を与えると, origin_date を無効にします.
424 !
425 ! If ".true." is given, "origin_date" is ignored.
426 type(dc_cal_date), intent(in), optional:: start_date
427 ! 出力開始日時.
428 !
429 ! Start date of output.
430 !
431 type(dc_cal), intent(in), optional:: cal
432 ! 暦情報.
433 ! これを指定しない場合, dc_calendar モジュールの
434 ! デフォルトの暦が使用されます.
435 !
436 ! Calendar.
437 ! If this argument is specified, default calendar in
438 ! "dc_calendar" module is used.
439 !
440 logical, intent(in), optional:: flag_mpi_gather
441 ! MPI 使用時に, 各ノードで HistoryPut
442 ! に与えたデータを一つのファイルに統合して出力
443 ! する場合には .true. を与えてください.
444 ! デフォルトは .false. です.
445 !
446 ! .true. を与えた場合, HistoryPutAxisMPI
447 ! に全体の軸データを与えてください.
448 !
449 ! When MPI is used, if ".true." is given,
450 ! data given to "HistoryPut" on each node
451 ! is integrated and output to one file.
452 ! Default value is ".false.".
453 !
454 ! If .true. is given, give data of axes in
455 ! whole area to "HistoryPutAxisMPI"
456 !
457 logical, intent(in), optional:: flag_mpi_split
458 ! MPI 使用時に, 各ノードで HistoryPut
459 ! に与えたデータをそれぞれ別名のファイルに
460 ! 出力する場合には .true. を与えてください.
461 ! デフォルトは .false. です.
462 !
463 ! When MPI is used, if ".true." is given,
464 ! data given to "HistoryPut" on each node
465 ! is split into discrete files.
466 ! Default value is ".false.".
467 !
468
469
470 ! NAMELIST 変数群 ; NAMELIST group of variables
471 character(STRING):: Name
472 ! 変数名.
473 ! 空白の場合には, この他の設定値は
474 ! gtool_historyauto モジュールにおいて
475 ! 出力されるデータ全ての
476 ! デフォルト値となります.
477 !
478 ! "Data1,Data2" のようにカンマで区切って複数
479 ! の変数を指定することも可能です.
480 !
481 ! Variable identifier.
482 ! If blank is given, other values are
483 ! used as default values of output data
484 ! in "gtool_historyauto".
485 !
486 ! Multiple variables can be specified
487 ! as "Data1,Data2" too. Delimiter is comma.
488 character(STRING):: File
489 ! 出力ファイル名.
490 ! これはデフォルト値としては使用されません.
491 ! *Name* に値が設定されている時のみ有効です.
492 !
493 ! Output file name.
494 ! This is not used as default value.
495 ! This value is valid only when *Name* is
496 ! specified.
497
498 real(DP):: IntValue
499 ! データの出力間隔の数値.
500 ! 負の値を与えると, 出力を抑止します.
501 ! Numerical value for interval of history data output
502 ! Negative values suppresses output.
503 character(TOKEN):: IntUnit
504 ! データの出力間隔の単位.
505 ! Unit for interval of history data output
506 character(TOKEN):: Precision
507 ! データの精度.
508 ! デフォルトは float (単精度実数型)
509 ! です. 有効なのは,
510 ! double (倍精度実数型),
511 ! int (整数型) です. 指定しない
512 ! 場合や, 無効な型を指定した場合には,
513 ! float となります.
514 !
515 ! Precision of history data
516 ! Default value is "float" (single precision).
517 ! Other valid values are
518 ! "double" (double precision),
519 ! "int" (integer).
520 ! If no value or invalid value is specified,
521 ! "float" is applied.
522 character(STRING):: FilePrefix
523 ! データのファイル名の接頭詞.
524 ! Prefixes of history data filenames
525 logical:: TimeAverage
526 ! 出力データの時間平均フラグ.
527 !
528 ! ".true." を与えると, 時間平均値が出力されます.
529 !
530 ! Flag for time average of output data
531 !
532 ! If ".ture." is specified,
533 ! time average values are output.
534 !
535 logical:: AllOutput
536 ! 登録変数を全て出力するためのフラグ.
537 ! Flag for output all registered variables.
538 real(DP):: OriginValue
539 ! 出力開始時刻.
540 ! Start time of output.
541 character(TOKEN):: OriginUnit
542 ! 出力開始時刻の単位.
543 ! Unit of start time of output.
544 real(DP):: TerminusValue
545 ! 出力終了時刻.
546 ! End time of output.
547 character(TOKEN):: TerminusUnit
548 ! 出力終了時刻の単位.
549 ! Unit of end time of output.
550 integer:: SliceStart(1:NF90_MAX_DIMS)
551 ! 空間方向の開始点.
552 ! Start points of spaces.
553 integer:: SliceEnd(1:NF90_MAX_DIMS)
554 ! 空間方向の終了点.
555 !
556 ! 省略した場合, もしくは負の値が与えら得た場合,
557 ! 座標データの終了点が設定されます.
558 !
559 ! End points of spaces.
560 !
561 ! If this argument is omitted or
562 ! negative value is specified,
563 ! end points of dimensions are set.
564 !
565 integer:: SliceStride(1:NF90_MAX_DIMS)
566 ! 空間方向の刻み幅.
567 ! Strides of spaces.
568 logical:: SpaceAverage(1:NF90_MAX_DIMS)
569 ! 空間平均のフラグ.
570 ! Flag of spatial average.
571 integer:: NewFileIntValue
572 ! ファイル分割時間間隔の数値.
573 ! Numerical value for interval of time of separation of a file.
574 character(TOKEN):: NewFileIntUnit
575 ! ファイル分割時間間隔の単位.
576 ! Unit of interval of time of separation of a file.
577
578 namelist /gtool_historyauto_nml/ &
579 & name, file, &
580 & intvalue, intunit, &
581 & precision, &
582 & fileprefix, &
583 & timeaverage, alloutput, &
584 & originvalue, originunit, &
585 & terminusvalue, terminusunit, &
586 & slicestart, sliceend, slicestride, spaceaverage, &
587 & newfileintvalue, newfileintunit
588 ! gtool_historyauto モジュールのデータ用
589 ! NAMELIST 変数群名.
590 !
591 ! gtool_historyauto_generic#HistoryAutoCreate
592 ! を使用する際に, オプショナル引数 *namelist_filename*
593 ! へ NAMELIST ファイル名を指定することで,
594 ! そのファイルからこの NAMELIST 変数群を
595 ! 読み込みます.
596 !
597 ! NAMELIST group name for
598 ! history data of "gtool_historyauto" module.
599 !
600 ! If a NAMELIST filename is specified to
601 ! an optional argument *namelist_filename* when
602 ! "gtool_historyauto_generic#HistoryAutoCreate"
603 ! is used, this NAMELIST group is
604 ! loaded from the file.
605
606
607 ! 作業変数 ; Work variables
608 integer:: blank_index
609 integer:: stat
610 character(STRING):: cause_c
611 integer:: unit_nml ! NAMELIST ファイルオープン用装置番号.
612 ! Unit number for NAMELIST file open
613 integer:: iostat_nml ! NAMELIST 読み込み時の IOSTAT.
614 ! IOSTAT of NAMELIST read
615 character(TOKEN):: pos_nml
616 ! NAMELIST 読み込み時のファイル位置.
617 ! File position of NAMELIST read
618 integer:: i, j
619 character(TOKEN):: my_xtype
620
621 real(DP):: interval_work, origin_work, terminus_work
622 integer:: date_day
623 real(DP):: date_sec
624 real(DP), parameter:: time_eps = epsilon(1.0_dp)
625 integer:: msnot_rank
626 character(STRING):: date_str
627 character(TOKEN):: cal_str
628 integer:: origin_year, origin_month, origin_day, origin_hour, origin_min
629 real(DP):: origin_sec
630 integer:: month_in_year, hour_in_day, min_in_hour
631 integer, pointer:: day_in_month(:) =>null()
632 real(DP):: sec_in_min
633 character(*), parameter:: subname = "HistoryAutoCreate3"
634 continue
635 call beginsub(subname, version = version)
636 stat = dc_noerr
637 cause_c = ""
638
639 ! このサブルーチンが 2 度呼ばれたらエラー
640 ! Error is occurred when this subroutine is called twice
641 !
642 if ( initialized ) then
643 stat = dc_ealreadyinit
644 cause_c = 'gtool_historyauto'
645 goto 999
646 end if
647
648 ! ゼロ秒の作成.
649 ! Create zero seconds
650 !
651 zero_time = 0.0_dp
652!!$ call DCDiffTimeCreate( &
653!!$ & zero_time, & ! (out)
654!!$ & sec = 0.0_DP ) ! (in)
655
656 ! 次元の数に関するエラー処理
657 ! Error handling for number of dimensions
658 !
659 numdims = size(dims)
660
661 if ( size(dimsizes) /= numdims ) then
662 cause_c = 'dimsizes, dims'
663 elseif ( size(longnames) /= numdims ) then
664 cause_c = 'longnames, dims'
665 elseif ( size(units) /= numdims ) then
666 cause_c = 'units, dims'
667 endif
668 if ( trim(cause_c) /= "" ) then
670 goto 999
671 end if
672
673 if ( numdims > nf90_max_dims ) then
674 stat = nf90_emaxdims
675 goto 999
676 end if
677
678 ! 時刻次元に関するエラー処理
679 ! Error handling for time dimension
680 !
681 if ( dimsizes(numdims) /= 0 ) then
682 call messagenotify( 'W', subname, &
683 & 'time dimension must be specified to the last of "dims"' )
684 stat = hst_enotimedim
685 goto 999
686 end if
687
688 ! 出力ファイルの基本メタデータの保管
689 ! Save basic meta data for output file
690 !
691 title_save = title
692 source_save = source
693 institution_save = institution
694
696 if ( present(conventions) ) conventions_save = conventions
697
698 gt_version_save = ''
699 if ( present(gt_version) ) gt_version_save = gt_version
700
701 rank_save = ''
702 if ( present(rank) ) rank_save = rank
703
704 ! MPI に関する情報の保管
705 ! Save information about MPI
706 !
707 save_mpi_split = present_and_true( flag_mpi_split )
708 save_mpi_gather = present_and_true( flag_mpi_gather )
709
710 msnot_rank = -1
711 if ( save_mpi_gather ) msnot_rank = 0
712
713 ! 時刻の単位のチェック
714 ! Check units of time
715 !
718 blank_index = index( trim( adjustl(time_unit_bycreate) ), ' ' )
719 if ( blank_index > 1 ) then
720 time_unit_suffix = time_unit_bycreate(blank_index+1:)
721 time_unit_bycreate = time_unit_bycreate(1:blank_index-1)
722 end if
723
724 ! 座標軸データの保管
725 ! Save axes data
726 !
727 do i = 1, numdims
728 my_xtype = ''
729 if ( present(xtypes) ) then
730 if ( size(xtypes) >= i ) then
731 my_xtype = xtypes(i)
732 end if
733 end if
734
735 call historyaxiscreate( &
736 & axis = gthst_axes(i), & ! (out)
737 & name = dims(i), size = dimsizes(i), & ! (in)
738 & longname = longnames(i), units = units(i), & ! (in)
739 & xtype = my_xtype ) ! (in)
740
741 allocate( data_axes(i) % a_axis( dimsizes(i) ) )
742 data_axes(i) % a_axis = (/ ( real( j, dp ), j = 1, dimsizes(i) ) /)
743
744 end do
745
746 ! 暦の登録
747 ! Register calendar
748 !
749 if ( present(cal) ) then
750 cal_save = cal
751 else
752 call dccaldefault( cal_save )
753 end if
754
755 ! 日時の指定
756 ! Specify date
757 !
758 if ( present(start_date) ) then
759
760 call dccaldateinquire( &
761 & date_str = date_str, & ! (out)
762 & date = start_date, & ! (in) optional
763 & cal = cal & ! (in) optional
764 ! & , zone = "+09:00" &
765 & ) ! (in) optional
766
767 call dccaldateinquire( &
768 & origin_year, origin_month, origin_day, & ! (out) optional
769 & origin_hour, origin_min, origin_sec, & ! (out) optional
770 & date = start_date, & ! (in) optional
771 & cal = cal & ! (in) optional
772 & )
773
774 call dccalinquire( &
775 & cal_str, & ! (out) optional
776 & month_in_year = month_in_year, & ! (out) optional
777 & day_in_month_ptr = day_in_month , & ! (out) optional
778 & hour_in_day = hour_in_day , & ! (out) optional
779 & min_in_hour = min_in_hour , & ! (out) optional
780 & sec_in_min = sec_in_min , & ! (out) optional
781 & cal = cal_save ) ! (in) optional
782
783 ! 地球暦の場合のみ units 属性に "since ..." を付加
784 !
785 select case ( trim(cal_str) )
786 case ( 'gregorian' )
788 & ' since ' // trim(date_str)
789 case ( 'julian' )
791 & ' since ' // trim(date_str)
792 case ( 'noleap' )
794 & ' since ' // trim(date_str)
795 case ( '360day' )
797 & ' since ' // trim(date_str)
798 case ( 'cyclic' )
800 & ' since ' // trim(date_str)
801 end select
802
803 ! 開始日時情報の付与
804 !
805 call historyaxisaddattr( &
806 & axis = gthst_axes(numdims), & ! (inout)
807 & attrname = 'origin', & ! (in)
808 & value = 'origin_year origin_month origin_day ' // &
809 & 'origin_hour origin_min origin_sec' ) ! (in)
810
811 call historyaxisaddattr( gthst_axes(numdims), 'origin_year', origin_year )
812 call historyaxisaddattr( gthst_axes(numdims), 'origin_month', origin_month )
813 call historyaxisaddattr( gthst_axes(numdims), 'origin_day', origin_day )
814 call historyaxisaddattr( gthst_axes(numdims), 'origin_hour', origin_hour )
815 call historyaxisaddattr( gthst_axes(numdims), 'origin_min', origin_min )
816
817 ! 暦情報の付与
818 !
819 call historyaxisaddattr( &
820 & axis = gthst_axes(numdims), & ! (inout)
821 & attrname = 'calendar', & ! (in)
822 & value = cal_str ) ! (in)
823
824 if ( trim(cal_str) == 'user_defined' ) then
825 call historyaxisaddattr( gthst_axes(numdims), 'month_in_year', month_in_year )
826 call historyaxisaddattr( gthst_axes(numdims), 'day_in_month', day_in_month )
827 call historyaxisaddattr( gthst_axes(numdims), 'hour_in_day', hour_in_day )
828 call historyaxisaddattr( gthst_axes(numdims), 'min_in_hour', min_in_hour )
829 call historyaxisaddattr( gthst_axes(numdims), 'sec_in_min', sec_in_min )
830 end if
831
832 deallocate( day_in_month )
833
834 elseif ( present(origin_date) &
835 & .and. .not. present_and_true(origin_date_invalid) ) then
836 call eval( origin_date, & ! (in)
837 & day = date_day, sec = date_sec ) ! (out)
838 if ( date_day /= 0 .or. abs(date_sec) > time_eps ) then
840 & ' since ' // tochar(origin_date)
841
842 call historyaxisaddattr( &
843 & axis = gthst_axes(numdims), & ! (inout)
844 & attrname = 'calendar', & ! (in)
845 & value = tocharcal(origin_date) ) ! (in)
846
847 end if
848 end if
849
850 ! 登録変数を全て出力するためのフラグの保管
851 ! Save flag for output all registered variables
852 !
853 if ( present(all_output) ) all_output_save = all_output
854 if ( .not. present_and_not_empty(namelist_filename) ) all_output_save = .true.
855 alloutput = all_output_save
856
857 ! 出力時間間隔のデフォルト値設定
858 ! Configure default interval of output time
859 !
860 if ( all_output_save ) then
861 if ( present(interval) ) then
862 interval_work = evalbyunit( interval, time_unit_bycreate )
863 else
864 interval_work = 1.0
865 end if
866 else
867 interval_work = - 1.0
868 end if
869
870 ! 出力開始・終了時刻のデフォルト値設定
871 ! Configure default origin/terminus time of output
872 !
873 origin_work = evalbyunit( origin, 'sec' )
874 terminus_work = evalbyunit( terminus, time_unit_bycreate )
875
876 ! gtool_historyauto_nml へデフォルト値の設定
877 ! Configure default values for "gtool_historyauto_nml"
878 !
879 call hstnmlinfocreate( gthstnml ) ! (out)
880
881 call hstnmlinfoadd( &
882 & gthstnml = gthstnml, & ! (inout)
883 & name = '', & ! (in) optional
884 & precision = 'float', & ! (in) optional
885 & fileprefix = file_prefix, & ! (in) optional
886 & interval_value = interval_work, & ! (in) optional
887 & interval_unit = time_unit_bycreate, & ! (in) optional
888 & origin_value = origin_work, & ! (in) optional
889 & origin_unit = 'sec', & ! (in) optional
890!!$ & origin_unit = time_unit_bycreate, & ! (in) optional
891 & terminus_value = terminus_work, & ! (in) optional
892 & terminus_unit = time_unit_bycreate, & ! (in) optional
893 & time_average = time_average, & ! (in) optional
894 & slice_start = slice_start, & ! (in) optional
895 & slice_end = slice_end, & ! (in) optional
896 & slice_stride = slice_stride, & ! (in) optional
897 & space_average = space_average, & ! (in) optional
898 & newfile_intvalue = newfile_interval, & ! (in) optional
899 & newfile_intunit = time_unit_bycreate ) ! (in) optional
900
901 ! NAMELIST ファイルの読み込み
902 ! Load NAMELIST file
903 !
904 if ( present_and_not_empty(namelist_filename) ) then
905 call fileopen( unit_nml, & ! (out)
906 & namelist_filename, mode = 'r' ) ! (in)
907
908 iostat_nml = 0
909 pos_nml = ''
910
911 call messagenotify( 'M', sub_sname, '----- "gtool_historyauto_nml" is loaded from "%c" -----', &
912 & c1 = trim(namelist_filename), rank_mpi = msnot_rank )
913
914 do while ( trim(pos_nml) /= 'APPEND' .and. iostat_nml == 0 )
915
916 name = ''
917 file = ''
918 call hstnmlinfoinquire( &
919 & gthstnml = gthstnml, & ! (in)
920 & interval_value = intvalue, & ! (out) optional
921 & interval_unit = intunit, & ! (out) optional
922 & precision = precision, & ! (out) optional
923 & time_average = timeaverage, & ! (out) optional
924 & origin_value = originvalue, & ! (out) optional
925 & origin_unit = originunit, & ! (out) optional
926 & terminus_value = terminusvalue, & ! (out) optional
927 & terminus_unit = terminusunit, & ! (out) optional
928 & slice_start = slicestart, & ! (out) optional
929 & slice_end = sliceend, & ! (out) optional
930 & slice_stride = slicestride, & ! (out) optional
931 & space_average = spaceaverage, & ! (out) optional
932 & newfile_intvalue = newfileintvalue, & ! (out) optional
933 & newfile_intunit = newfileintunit, & ! (out) optional
934 & fileprefix = fileprefix ) ! (out) optional
935
936 read( unit = unit_nml, & ! (in)
937 & nml = gtool_historyauto_nml, & ! (out)
938 & iostat = iostat_nml ) ! (out)
939 inquire( unit = unit_nml, & ! (in)
940 & position = pos_nml ) ! (out)
941
942 if ( iostat_nml == 0 ) then
943
944 ! NAMELIST から与えられた値が無効な場合, デフォルト値を使用
945 ! Default values are used when values from NAMELIST are invalid
946 !
947 if ( .not. intvalue > 0.0 ) then
948 intvalue = interval_work
949 intunit = time_unit_bycreate
950 end if
951 if ( .not. originvalue > 0.0 ) then
952 originvalue = origin_work
953 originunit = 'sec'
954 end if
955 if ( .not. terminusvalue > 0.0 ) then
956 terminusvalue = terminus_work
957 terminusunit = time_unit_bycreate
958 end if
959
960 ! 情報の登録
961 ! Register information
962 !
963 call hstnmlinfoadd( &
964 & gthstnml = gthstnml, & ! (inout)
965 & name = name, & ! (in) optional
966 & file = file, & ! (in) optional
967 & interval_value = intvalue, & ! (in) optional
968 & interval_unit = intunit, & ! (in) optional
969 & precision = precision, & ! (in) optional
970 & time_average = timeaverage, & ! (in) optional
971 & origin_value = originvalue, & ! (in) optional
972 & origin_unit = originunit, & ! (in) optional
973 & terminus_value = terminusvalue, & ! (in) optional
974 & terminus_unit = terminusunit, & ! (in) optional
975 & slice_start = slicestart, & ! (in) optional
976 & slice_end = sliceend, & ! (in) optional
977 & slice_stride = slicestride, & ! (in) optional
978 & space_average = spaceaverage, & ! (in) optional
979 & newfile_intvalue = newfileintvalue, & ! (in) optional
980 & newfile_intunit = newfileintunit, & ! (in) optional
981 & fileprefix = fileprefix ) ! (in) optional
982
983 ! 登録変数を全て出力するためのフラグの保管
984 ! Save flag for output all registered variables
985 !
986 if ( trim(name) == '' ) then
987 all_output_save = alloutput
988 end if
989
990 ! 印字 ; Print
991 !
992 if ( trim(file) == '' ) file = trim(fileprefix) // '<Name>.nc'
993
994 if ( trim(name) == '' ) then
995 call messagenotify( 'M', sub_sname, 'Global Settings:', rank_mpi = msnot_rank )
996 call messagenotify( 'M', sub_sname, ' AllOutput = %b', l = (/ alloutput /), rank_mpi = msnot_rank )
997 call messagenotify( 'M', sub_sname, ' FilePrefix = %c', c1 = trim(fileprefix ), rank_mpi = msnot_rank )
998 else
999 call messagenotify( 'M', sub_sname, 'Individual Settings:', rank_mpi = msnot_rank )
1000 call messagenotify( 'M', sub_sname, ' Name = %c', c1 = trim(name ), rank_mpi = msnot_rank )
1001 call messagenotify( 'M', sub_sname, ' File = %c', c1 = trim(file ), rank_mpi = msnot_rank )
1002 end if
1003 call messagenotify( 'M', sub_sname, ' Interval = %f [%c]', &
1004 & d = (/ intvalue /), c1 = trim( intunit ), rank_mpi = msnot_rank )
1005 call messagenotify( 'M', sub_sname, ' Precision = %c', c1 = trim(precision ), rank_mpi = msnot_rank )
1006 call messagenotify( 'M', sub_sname, ' TimeAverage = %b', l = (/ timeaverage /), rank_mpi = msnot_rank )
1007 call messagenotify( 'M', sub_sname, ' Origin = %f [%c]', &
1008 & d = (/ originvalue /), c1 = trim( originunit ), rank_mpi = msnot_rank )
1009 call messagenotify( 'M', sub_sname, ' Terminus = %f [%c]', &
1010 & d = (/ terminusvalue /), c1 = trim( terminusunit ), rank_mpi = msnot_rank )
1011 call messagenotify( 'M', sub_sname, ' SliceStart = (/ %*d /)', &
1012 & i = slicestart(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1013 call messagenotify( 'M', sub_sname, ' SliceEnd = (/ %*d /)', &
1014 & i = sliceend(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1015 call messagenotify( 'M', sub_sname, ' SliceStride = (/ %*d /)', &
1016 & i = slicestride(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1017 call messagenotify( 'M', sub_sname, ' SpaceAverage = (/ %*b /)', &
1018 & l = spaceaverage(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1019 call messagenotify( 'M', sub_sname, ' NewFileInterval = %d [%c]', &
1020 & i = (/ newfileintvalue /), c1 = trim( newfileintunit ), rank_mpi = msnot_rank )
1021 call messagenotify( 'M', sub_sname, '', rank_mpi = msnot_rank )
1022
1023 else
1024 call messagenotify( 'M', sub_sname, '----- loading is finished (iostat=%d) -----', &
1025 & i = (/iostat_nml/), rank_mpi = msnot_rank )
1026 end if
1027 end do
1028
1029 close( unit_nml )
1030
1031
1032 ! NAMELIST ファイルを読み込まない場合
1033 ! NAMELIST file is not loaded
1034 !
1035 else
1036 call messagenotify( 'M', sub_sname, '----- "gtool_historyauto_nml" is not loaded" -----', rank_mpi = msnot_rank )
1037 name = ''
1038 file = ''
1039 call hstnmlinfoinquire( &
1040 & gthstnml = gthstnml, & ! (in)
1041 & interval_value = intvalue, & ! (out) optional
1042 & interval_unit = intunit, & ! (out) optional
1043 & precision = precision, & ! (out) optional
1044 & time_average = timeaverage, & ! (out) optional
1045 & origin_value = originvalue, & ! (out) optional
1046 & origin_unit = originunit, & ! (out) optional
1047 & terminus_value = terminusvalue, & ! (out) optional
1048 & terminus_unit = terminusunit, & ! (out) optional
1049 & slice_start = slicestart, & ! (out) optional
1050 & slice_end = sliceend, & ! (out) optional
1051 & slice_stride = slicestride, & ! (out) optional
1052 & space_average = spaceaverage, & ! (out) optional
1053 & newfile_intvalue = newfileintvalue, & ! (out) optional
1054 & newfile_intunit = newfileintunit, & ! (out) optional
1055 & fileprefix = fileprefix ) ! (out) optional
1056
1057 ! 印字 ; Print
1058 !
1059 call messagenotify( 'M', sub_sname, 'Global Settings:', rank_mpi = msnot_rank )
1060 call messagenotify( 'M', sub_sname, ' AllOutput = %b', l = (/ alloutput /), rank_mpi = msnot_rank )
1061 call messagenotify( 'M', sub_sname, ' FilePrefix = %c', c1 = trim(fileprefix ), rank_mpi = msnot_rank )
1062 call messagenotify( 'M', sub_sname, ' Interval = %f [%c]', &
1063 & d = (/ intvalue /), c1 = trim( intunit ), rank_mpi = msnot_rank )
1064 call messagenotify( 'M', sub_sname, ' Precision = %c', c1 = trim(precision ), rank_mpi = msnot_rank )
1065 call messagenotify( 'M', sub_sname, ' TimeAverage = %b', l = (/ timeaverage /), rank_mpi = msnot_rank )
1066 call messagenotify( 'M', sub_sname, ' Origin = %f [%c]', &
1067 & d = (/ originvalue /), c1 = trim( originunit ), rank_mpi = msnot_rank )
1068 call messagenotify( 'M', sub_sname, ' Terminus = %f [%c]', &
1069 & d = (/ terminusvalue /), c1 = trim( terminusunit ), rank_mpi = msnot_rank )
1070 call messagenotify( 'M', sub_sname, ' SliceStart = (/ %*d /)', &
1071 & i = slicestart(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1072 call messagenotify( 'M', sub_sname, ' SliceEnd = (/ %*d /)', &
1073 & i = sliceend(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1074 call messagenotify( 'M', sub_sname, ' SliceStride = (/ %*d /)', &
1075 & i = slicestride(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1076 call messagenotify( 'M', sub_sname, ' SpaceAverage = (/ %*b /)', &
1077 & l = spaceaverage(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
1078 call messagenotify( 'M', sub_sname, ' NewFileInterval = %d [%c]', &
1079 & i = (/ newfileintvalue /), c1 = trim( newfileintunit ), rank_mpi = msnot_rank )
1080 call messagenotify( 'M', sub_sname, '' , rank_mpi = msnot_rank)
1081
1082 end if
1083
1084 ! 終了処理, 例外処理
1085 ! Termination and Exception handling
1086 !
1087 initialized = .true.
1088
1089999 continue
1090 call storeerror(stat, subname, cause_c = cause_c)
1091 call endsub(subname, 'stat=%d', i = (/stat/) )
1092 end subroutine historyautocreate3
1093
1094 !-------------------------------------------------------------------
1095
1097 & title, source, institution, & ! (in)
1098 & dims, dimsizes, longnames, units, & ! (in)
1099 & xtypes, conventions, gt_version,& ! (in) optional
1100 & all_output, & ! (in) optional
1101 & file_prefix, & ! (in) optional
1102 & namelist_filename, & ! (in) optional
1103 & interval, origin, terminus, & ! (in) optional
1104 & slice_start, slice_end, slice_stride, & ! (in) optional
1105 & space_average, & ! (in) optional
1106 & time_average, & ! (in) optional
1107 & newfile_interval, & ! (in) optional
1108 & rank, & ! (in) optional
1109 & origin_date, origin_date_invalid, & ! (in) optional
1110 & start_date, cal, & ! (in) optional
1111 & flag_mpi_gather, flag_mpi_split & ! (in) optional
1112 & )
1113 !
1114 ! 複数のヒストリデータ出力を行うための初期化を行います.
1115 !
1116 ! この HistoryAutoCreate には, モデル内で出力する
1117 ! 変数が依存する座標や座標重みなどを全てを設定してください.
1118 !
1119 ! all_output に .true. を与えた場合や,
1120 ! namelist_filename を与えない (空文字を与える) 場合には,
1121 ! HistoryAutoAddVariable で登録される全ての変数が出力されます.
1122 ! 一方で namelist_filename に NAMELIST ファイル名を与える場合には,
1123 ! その NAMELIST ファイルから出力のオンオフや,
1124 ! 出力ファイル名, 出力間隔などを変更可能です.
1125 ! 変更可能な項目に関しては NAMELIST#gtool_historyauto_nml
1126 ! を参照して下さい.
1127 !
1128 ! interval, origin, terminus, slice_start, slice_end, slice_stride,
1129 ! space_average, time_average, newfile_interval
1130 ! などの設定はデフォルト値として使用されます.
1131 ! これらの設定値は HistoryAutoAddVariable および
1132 ! NAMELIST#gtool_historyauto_nml で上書きされます.
1133 ! (優先度が高いのは NAMELIST#gtool_historyauto_nml ,
1134 ! HistoryAutoAddVariable の引数,
1135 ! HistoryAutoCreate の引数 の順です).
1136 !
1137 !
1138 ! Initialization for multiple history data output
1139 !
1140 ! Set all axes and their weights depended by variables
1141 ! output from numerical models to this "HistoryAutoCreate".
1142 !
1143 ! All variables registered by "HistoryAutoAddVariable"
1144 ! are output if .true. is given to "all_output" or
1145 ! "namelist_filename" is not given (or blanks are given)
1146 ! On the other hand, if a filename of NAMELIST file is
1147 ! given to "namelist_filename", on/off of output,
1148 ! output filename and output interval, etc. can be changed
1149 ! from the NAMELIST file.
1150 ! For available items, see "NAMELIST#gtool_historyauto_nml".
1151 !
1152 ! Settings about
1153 ! "interval", "origin", "terminus", "slice_start", "slice_end", "slice_stride",
1154 ! "space_average", "time_average", "newfile_interval"
1155 ! etc. are used as default values.
1156 ! Their set values are overwritten by
1157 ! "HistoryAutoAddVariable" or
1158 ! "NAMELIST#gtool_historyauto_nml".
1159 ! ("NAMELIST#gtool_historyauto_nml" is high priority,
1160 ! arguments of "HistoryAutoAddVariable" are medium,
1161 ! arguments of "HistoryAutoCreate" are low).
1162 !
1165 use gtool_history, only: historyaxiscreate
1169 use dc_trace, only: beginsub, endsub
1172 use netcdf, only: nf90_emaxdims, nf90_max_dims
1176 use dc_calendar, only: dc_cal, dc_cal_date
1177 use dc_date, only: dcdifftimecreate, evalbyunit
1179 use dc_message, only: messagenotify
1180 use dc_iounit, only: fileopen
1181 use dc_types, only: string
1182 implicit none
1183 character(*), intent(in):: title
1184 ! データ全体の表題.
1185 ! Title of entire data
1186 character(*), intent(in):: source
1187 ! データを作成する際の手段.
1188 ! Source of data file
1189 character(*), intent(in):: institution
1190 ! ファイルを最終的に変更した組織/個人.
1191 ! Institution or person that changes files for the last time
1192 character(*), intent(in):: dims(:)
1193 ! 次元の名前.
1194 !
1195 ! 配列の大きさに制限はありません.
1196 ! 個々の次元の文字数は dc_types#TOKEN まで.
1197 ! 配列内の文字数は
1198 ! 全て同じでなければなりません.
1199 ! 足りない文字分は空白で
1200 ! 補ってください.
1201 !
1202 ! Names of dimensions.
1203 !
1204 ! Length of array is unlimited.
1205 ! Limits of numbers of characters of each
1206 ! dimensions are "dc_types#TOKEN".
1207 ! Numbers of characters in this array
1208 ! must be same.
1209 ! Make up a deficit with blanks.
1210 !
1211 integer, intent(in):: dimsizes (:)
1212 ! dims で指定したそれぞれの次元大きさ.
1213 !
1214 ! 配列の大きさは dims の大きさと等しい
1215 ! 必要があります. '0' (数字のゼロ) を指定
1216 ! するとその次元は 無制限次元 (unlimited
1217 ! dimension) となります. (gtool_history
1218 ! では時間の次元に対して無制限次元を
1219 ! 用いることを想定しています). ただし,
1220 ! 1 つの NetCDF ファイル (バージョン 3)
1221 ! は最大で 1 つの無制限次元しか持てないので,
1222 ! 2 ヶ所以上に '0' を指定しないでください.
1223 ! その場合, 正しく gtool4 データが出力されません.
1224 !
1225 ! Lengths of dimensions specified with "dims".
1226 !
1227 ! Length of this array must be same as
1228 ! length of "dim". If '0' (zero) is
1229 ! specified, the dimension is treated as
1230 ! unlimited dimension.
1231 ! (In "gtool_history", unlimited dimension is
1232 ! expected to be used as time).
1233 ! Note that one NetCDF file (version 3)
1234 ! can not have two or more unlimited
1235 ! dimensions, so that do not specify '0'
1236 ! to two or more places. In that case,
1237 ! gtoo4 data is not output currently
1238 !
1239 character(*), intent(in):: longnames (:)
1240 ! dims で指定したそれぞれの次元の名前.
1241 !
1242 ! 配列の大きさは dims の大きさ
1243 ! と等しい必要があります. 文字数
1244 ! は dc_types#STRING まで.
1245 ! 配列内の文字数は
1246 ! 全て同じでなければなりません.
1247 ! 足りない文字分は空白で補います.
1248 !
1249 ! Names of dimensions specified with "dims".
1250 !
1251 ! Length of this array must be same as
1252 ! length of "dim".
1253 ! Limits of numbers of characters are
1254 ! "dc_types#STRING".
1255 ! Numbers of characters in this array
1256 ! must be same.
1257 ! Make up a deficit with blanks.
1258 !
1259 character(*), intent(in):: units(:)
1260 ! dims で指定したそれぞれの次元の単位.
1261 !
1262 ! 配列の大きさは dims の大きさ
1263 ! と等しい必要があります. 文字数
1264 ! は dc_types#STRING まで.
1265 ! 配列内の文字数は
1266 ! 全て同じでなければなりません.
1267 ! 足りない文字分は空白で補います.
1268 !
1269 ! Units of dimensions specified with "dims".
1270 !
1271 ! Length of this array must be same as
1272 ! length of "dim".
1273 ! Limits of numbers of characters are
1274 ! "dc_types#STRING".
1275 ! Numbers of characters in this array
1276 ! must be same.
1277 ! Make up a deficit with blanks.
1278 !
1279 character(*), intent(in), optional:: xtypes(:)
1280 ! dims で指定したそれぞれの
1281 ! 次元のデータ型.
1282 !
1283 ! デフォルトは float (単精度実数型)
1284 ! です. 有効なのは,
1285 ! double (倍精度実数型),
1286 ! int (整数型) です. 指定しない
1287 ! 場合や, 無効な型を指定した場合には,
1288 ! float となります. なお, 配列の大きさ
1289 ! は *dims* の大きさと等しい必要が
1290 ! あります. 配列内の文字数は全て
1291 ! 同じでなければなりません.
1292 ! 足りない文字分は空白で補います.
1293 !
1294 ! Data types of dimensions specified
1295 ! with "dims".
1296 !
1297 ! Default value is "float" (single precision).
1298 ! Other valid values are
1299 ! "double" (double precision),
1300 ! "int" (integer).
1301 ! If no value or invalid value is specified,
1302 ! "float" is applied.
1303 ! Length of this array must be same as
1304 ! length of "dim".
1305 ! Numbers of characters in this array
1306 ! must be same.
1307 ! Make up a deficit with blanks.
1308 !
1309 character(*), intent(in), optional:: conventions
1310 ! 出力するファイルの netCDF
1311 ! 規約
1312 !
1313 ! 省略した場合,
1314 ! もしくは空文字を与えた場合,
1315 ! 出力する netCDF 規約の
1316 ! Conventions 属性に値
1317 ! gtool4_netCDF_Conventions
1318 ! が自動的に与えられます.
1319 !
1320 ! NetCDF conventions of output file.
1321 !
1322 ! If this argument is omitted or,
1323 ! blanks are given,
1324 ! gtool4_netCDF_Conventions is given to
1325 ! attribute "Conventions" of an output file
1326 ! automatically.
1327 !
1328 character(*), intent(in), optional:: gt_version
1329 ! gtool4 netCDF 規約のバージョン
1330 !
1331 ! 省略した場合, gt_version 属性に
1332 ! 規約の最新版のバージョンナンバー
1333 ! gtool4_netCDF_version
1334 ! が与えられます.
1335 ! (ただし, 引数 conventions に
1336 ! gtool4_netCDF_Conventions
1337 ! 以外が与えられる場合は
1338 ! gt_version 属性を作成しません).
1339 !
1340 ! Version of gtool4 netCDF Conventions.
1341 !
1342 ! If this argument is omitted,
1343 ! latest version number of gtool4 netCDF
1344 ! Conventions is given to attribute
1345 ! "gt_version" of an output file
1346 ! (However, gtool4_netCDF_Conventions is
1347 ! not given to an argument "conventions",
1348 ! attribute "gt_version" is not created).
1349 !
1350 logical, intent(in), optional:: all_output
1351 ! 登録変数を全て出力するためのフラグ.
1352 !
1353 ! .true. を指定すると,
1354 ! HistoryAutoAddVariable で登録された
1355 ! 変数が全て出力されるようになります.
1356 !
1357 ! *namelist_filename* が指定される場合
1358 ! には, デフォルトは .false. となります.
1359 ! この場合には,
1360 ! *namelist_filename* に指定された
1361 ! NAMELIST ファイルから読み込まれる
1362 ! NAMELIST#gtool_historyauto_nml
1363 ! で指定された変数のみ出力されます.
1364 !
1365 ! *namelist_filename* が指定されない場合
1366 ! には, .true. となります.
1367 !
1368 !
1369 ! Flag for output all registered variables.
1370 !
1371 ! When .true. is specified,
1372 ! all variables registered by
1373 ! "HistoryAutoAddVariable" are output.
1374 !
1375 ! If *namelist_filename* is specified,
1376 ! default value becomes .false. .
1377 ! In this case,
1378 ! only variables specified in
1379 ! "NAMELIST#gtool_historyauto_nml"
1380 ! loaded from a NAMELIST file
1381 ! *namelist_filename*.
1382 !
1383 ! If *namelist_filename* is not specified,
1384 ! this value becomes .true. .
1385 !
1386 character(*), intent(in), optional:: file_prefix
1387 ! ヒストリデータのファイル名の接頭詞.
1388 ! Prefixes of history data filenames
1389 character(*), intent(in), optional:: namelist_filename
1390 ! NAMELIST ファイルの名称.
1391 !
1392 ! 省略した場合, もしくは空白文字を与えた場合,
1393 ! NAMELIST ファイルは読み込みません.
1394 !
1395 ! Name of NAMELIST file.
1396 !
1397 ! If this argument is omitted,
1398 ! or blanks are specified,
1399 ! no NAMELIST file is loaded.
1400 !
1401 real, intent(in), optional:: interval
1402 ! 出力時間間隔.
1403 !
1404 ! 省略した場合,
1405 ! 自動的に 1.0 [sec] が設定されます.
1406 !
1407 ! Interval of output time.
1408 !
1409 ! If this argument is omitted,
1410 ! 1.0 [sec] is specified
1411 ! automatically.
1412 !
1413 real, intent(in), optional:: origin
1414 ! 出力開始時刻.
1415 !
1416 ! 省略した場合, 自動的に 0.0 [sec] が
1417 ! 設定されます.
1418 !
1419 ! Start time of output.
1420 !
1421 ! If this argument is omitted,
1422 ! 0.0 [sec] is specified
1423 ! automatically.
1424 !
1425 real, intent(in), optional:: terminus
1426 ! 出力終了時刻.
1427 !
1428 ! 省略した場合, 数値モデルの実行が終了するまで
1429 ! 出力を行います.
1430 !
1431 ! End time of output.
1432 !
1433 ! If this argument is omitted,
1434 ! output is continued until a numerical model
1435 ! is finished.
1436 !
1437 integer, intent(in), optional:: slice_start(:)
1438 ! 空間方向の開始点.
1439 !
1440 ! 省略した場合, 座標データの開始点が設定されます.
1441 !
1442 ! Start points of spaces.
1443 !
1444 ! If this argument is omitted,
1445 ! start points of dimensions are set.
1446 !
1447 integer, intent(in), optional:: slice_end(:)
1448 ! 空間方向の終了点.
1449 !
1450 ! 省略した場合, 座標データの終了点が設定されます.
1451 !
1452 ! End points of spaces.
1453 !
1454 ! If this argument is omitted,
1455 ! End points of dimensions are set.
1456 !
1457 integer, intent(in), optional:: slice_stride(:)
1458 ! 空間方向の刻み幅.
1459 !
1460 ! 省略した場合, 1 が設定されます.
1461 !
1462 ! Strides of spaces
1463 !
1464 ! If this argument is omitted,
1465 ! 1 is set.
1466 !
1467 logical, intent(in), optional:: space_average(:)
1468 ! 平均化のフラグ.
1469 !
1470 ! .true. が指定される座標に対して平均化を
1471 ! 行います.
1472 ! 省略した場合, .false. が設定されます.
1473 !
1474 ! Flag of average.
1475 !
1476 ! Axes specified .true. are averaged.
1477 ! If this argument is omitted,
1478 ! .false. is set.
1479 !
1480 logical, intent(in), optional:: time_average
1481 ! 出力データの時間平均フラグ.
1482 ! デフォルトは .false.
1483 ! Flag for time average of output data
1484 ! Default value is .false.
1485 integer, intent(in), optional:: newfile_interval
1486 ! ファイル分割時間間隔.
1487 !
1488 ! 省略した場合,
1489 ! 時間方向へのファイル分割を行いません.
1490 !
1491 ! Interval of time of separation of a file.
1492 !
1493 ! If this argument is omitted,
1494 ! a files is not separated in time direction.
1495 !
1496 character(*), intent(in), optional:: rank
1497 ! ランクの名称.
1498 ! 空文字を与えた場合には無視されます.
1499 !
1500 ! Name of a rank.
1501 ! If blank is given, this argument is ignored.
1502 !
1503 type(dc_datetime), intent(in), optional:: origin_date
1504 ! 出力開始日時.
1505 ! この引数は廃止予定のため, start_date を使用して下さい.
1506 !
1507 ! Start date of output.
1508 ! Use "start_date" because this argument is obsolete.
1509 !
1510 logical, intent(in), optional:: origin_date_invalid
1511 ! .true. を与えると, origin_date を無効にします.
1512 !
1513 ! If ".true." is given, "origin_date" is ignored.
1514 !
1515 type(dc_cal_date), intent(in), optional:: start_date
1516 ! 出力開始日時.
1517 !
1518 ! Start date of output.
1519 !
1520 type(dc_cal), intent(in), optional:: cal
1521 ! 暦情報.
1522 ! これを指定しない場合, dc_calendar モジュールの
1523 ! デフォルトの暦が使用されます.
1524 !
1525 ! Calendar.
1526 ! If this argument is specified, default calendar in
1527 ! "dc_calendar" module is used.
1528 !
1529 logical, intent(in), optional:: flag_mpi_gather
1530 ! MPI 使用時に, 各ノードで HistoryPut
1531 ! に与えたデータを一つのファイルに統合して出力
1532 ! する場合には .true. を与えてください.
1533 ! デフォルトは .false. です.
1534 !
1535 ! .true. を与えた場合, HistoryPutAxisMPI
1536 ! に全体の軸データを与えてください.
1537 !
1538 ! When MPI is used, if ".true." is given,
1539 ! data given to "HistoryPut" on each node
1540 ! is integrated and output to one file.
1541 ! Default value is ".false.".
1542 !
1543 ! If .true. is given, give data of axes in
1544 ! whole area to "HistoryPutAxisMPI"
1545 !
1546 logical, intent(in), optional:: flag_mpi_split
1547 ! MPI 使用時に, 各ノードで HistoryPut
1548 ! に与えたデータをそれぞれ別名のファイルに
1549 ! 出力する場合には .true. を与えてください.
1550 ! デフォルトは .false. です.
1551 !
1552 ! When MPI is used, if ".true." is given,
1553 ! data given to "HistoryPut" on each node
1554 ! is split into discrete files.
1555 ! Default value is ".false.".
1556 !
1557 integer:: blank_index
1558 type(dc_difftime):: interval_difftime, origin_difftime, terminus_difftime
1559 integer:: stat
1560 character(STRING):: cause_c
1561 character(*), parameter:: subname = "HistoryAutoCreate2"
1562 continue
1563 call beginsub(subname)
1564 stat = dc_noerr
1565 cause_c = ""
1566
1567 ! このサブルーチンが 2 度呼ばれたらエラー
1568 ! Error is occurred when this subroutine is called twice
1569 !
1570 if ( initialized ) then
1571 stat = dc_ealreadyinit
1572 cause_c = 'gtool_historyauto'
1573 goto 999
1574 end if
1575
1576 ! 次元の数に関するエラー処理
1577 ! Error handling for number of dimensions
1578 !
1579 numdims = size(dims)
1580
1581 if ( size(dimsizes) /= numdims ) then
1582 cause_c = 'dimsizes, dims'
1583 elseif ( size(longnames) /= numdims ) then
1584 cause_c = 'longnames, dims'
1585 elseif ( size(units) /= numdims ) then
1586 cause_c = 'units, dims'
1587 endif
1588 if ( trim(cause_c) /= "" ) then
1589 stat = gt_eargsizemismatch
1590 goto 999
1591 end if
1592
1593 if ( numdims > nf90_max_dims ) then
1594 stat = nf90_emaxdims
1595 goto 999
1596 end if
1597
1598 ! 時刻次元に関するエラー処理
1599 ! Error handling for time dimension
1600 !
1601 if ( dimsizes(numdims) /= 0 ) then
1602 call messagenotify( 'W', subname, &
1603 & 'time dimension must be specified to the last of "dims"' )
1604 stat = hst_enotimedim
1605 goto 999
1606 end if
1607
1608 ! 時刻の単位のチェック
1609 ! Check units of time
1610 !
1612 time_unit_suffix = ''
1613 blank_index = index( trim( adjustl(time_unit_bycreate) ), ' ' )
1614 if ( blank_index > 1 ) then
1615 time_unit_suffix = time_unit_bycreate(blank_index+1:)
1616 time_unit_bycreate = time_unit_bycreate(1:blank_index-1)
1617 end if
1618
1619 ! 出力時間間隔のデフォルト値設定
1620 ! Configure default interval of output time
1621 !
1622 if ( present(interval) ) then
1623 call dcdifftimecreate( &
1624 & interval_difftime, & ! (out)
1625 & interval, time_unit_bycreate ) ! (in)
1626 else
1627 call dcdifftimecreate( &
1628 & interval_difftime, & ! (out)
1629 & 1.0, time_unit_bycreate ) ! (in)
1630 end if
1631
1632 ! 出力開始・終了時刻のデフォルト値設定
1633 ! Configure default origin/terminus time of output
1634 !
1635 if ( present(origin) ) then
1636 call dcdifftimecreate( &
1637 & origin_difftime, & ! (out)
1638 & origin, time_unit_bycreate ) ! (in)
1639 else
1640 call dcdifftimecreate( &
1641 & origin_difftime, & ! (out)
1642 & 0.0, time_unit_bycreate ) ! (in)
1643 end if
1644
1645 if ( present(terminus) ) then
1646 call dcdifftimecreate( &
1647 & terminus_difftime, & ! (out)
1648 & terminus, time_unit_bycreate ) ! (in)
1649 else
1650 call dcdifftimecreate( &
1651 & terminus_difftime, & ! (out)
1652 & -1.0, time_unit_bycreate ) ! (in)
1653 end if
1654
1655 ! HistoryAutoCreate1 の呼び出し
1656 ! Call "HistoryAutoCreate1"
1657 !
1658 call historyautocreate( &
1659 & title = title, source = source, & ! (in)
1660 & institution = institution, & ! (in)
1661 & dims = dims, dimsizes = dimsizes, & ! (in)
1662 & longnames = longnames, units = units, & ! (in)
1663 & origin = origin_difftime, & ! (in)
1664 & terminus = terminus_difftime, & ! (in)
1665 & xtypes = xtypes, & ! (in) optional
1666 & conventions = conventions, & ! (in) optional
1667 & gt_version = gt_version, & ! (in) optional
1668 & all_output = all_output, & ! (in) optional
1669 & file_prefix = file_prefix, & ! (in) optional
1670 & namelist_filename = namelist_filename, & ! (in) optional
1671 & interval = interval_difftime, & ! (in) optional
1672 & slice_start = slice_start, & ! (in) optional
1673 & slice_end = slice_end, & ! (in) optional
1674 & slice_stride = slice_stride, & ! (in) optional
1675 & space_average = space_average, & ! (in) optional
1676 & time_average = time_average, & ! (in) optional
1677 & newfile_interval = newfile_interval, & ! (in) optional
1678 & rank = rank, & ! (in) optional
1679 & origin_date = origin_date, & ! (in) optional
1680 & origin_date_invalid = origin_date_invalid, & ! (in) optional
1681 & start_date = start_date, & ! (in) optional
1682 & cal = cal, & ! (in) optional
1683 & flag_mpi_gather = flag_mpi_gather, & ! (in) optional
1684 & flag_mpi_split = flag_mpi_split ) ! (in) optional
1685
1686999 continue
1687 call storeerror(stat, subname, cause_c = cause_c)
1688 call endsub(subname)
1689 end subroutine historyautocreate2
1690
1691 !-------------------------------------------------------------------
1692
1694 & title, source, institution, & ! (in)
1695 & dims, dimsizes, longnames, units, & ! (in)
1696 & origin, terminus, & ! (in)
1697 & xtypes, conventions, gt_version, & ! (in) optional
1698 & all_output, & ! (in) optional
1699 & file_prefix, & ! (in) optional
1700 & namelist_filename, & ! (in) optional
1701 & interval, & ! (in) optional
1702 & slice_start, slice_end, slice_stride, & ! (in) optional
1703 & space_average, & ! (in) optional
1704 & time_average, & ! (in) optional
1705 & newfile_interval, & ! (in) optional
1706 & rank, & ! (in) optional
1707 & origin_date, origin_date_invalid, & ! (in) optional
1708 & start_date, cal, & ! (in) optional
1709 & flag_mpi_gather, flag_mpi_split & ! (in) optional
1710 & )
1711 !
1712 ! 複数のデータ出力を行うための初期化を行います.
1713 !
1714 ! この HistoryAutoCreate には, モデル内で出力する
1715 ! 変数が依存する座標や座標重みなどを全てを設定してください.
1716 !
1717 ! all_output に .true. を与えた場合や,
1718 ! namelist_filename を与えない (空文字を与える) 場合には,
1719 ! HistoryAutoAddVariable で登録される全ての変数が出力されます.
1720 ! 一方で namelist_filename に NAMELIST ファイル名を与える場合には,
1721 ! その NAMELIST ファイルから出力のオンオフや,
1722 ! 出力ファイル名, 出力間隔などを変更可能です.
1723 ! 変更可能な項目に関しては NAMELIST#gtool_historyauto_nml
1724 ! を参照して下さい.
1725 !
1726 ! interval, origin, terminus, slice_start, slice_end, slice_stride,
1727 ! space_average, time_average, newfile_interval
1728 ! などの設定はデフォルト値として使用されます.
1729 ! これらの設定値は HistoryAutoAddVariable および
1730 ! NAMELIST#gtool_historyauto_nml で上書きされます.
1731 ! (優先度が高いのは NAMELIST#gtool_historyauto_nml ,
1732 ! HistoryAutoAddVariable の引数,
1733 ! HistoryAutoCreate の引数 の順です).
1734 !
1735 !
1736 ! Initialization for multiple history data output
1737 !
1738 ! Set all axes and their weights depended by variables
1739 ! output from numerical models to this "HistoryAutoCreate".
1740 !
1741 ! All variables registered by "HistoryAutoAddVariable"
1742 ! are output if .true. is given to "all_output" or
1743 ! "namelist_filename" is not given (or blanks are given)
1744 ! On the other hand, if a filename of NAMELIST file is
1745 ! given to "namelist_filename", on/off of output,
1746 ! output filename and output interval, etc. can be changed
1747 ! from the NAMELIST file.
1748 ! For available items, see "NAMELIST#gtool_historyauto_nml".
1749 !
1750 ! Settings about
1751 ! "interval", "origin", "terminus", "slice_start", "slice_end", "slice_stride",
1752 ! "space_average", "time_average", "newfile_interval"
1753 ! etc. are used as default values.
1754 ! Their set values are overwritten by
1755 ! "HistoryAutoAddVariable" or
1756 ! "NAMELIST#gtool_historyauto_nml".
1757 ! ("NAMELIST#gtool_historyauto_nml" is high priority,
1758 ! arguments of "HistoryAutoAddVariable" are medium,
1759 ! arguments of "HistoryAutoCreate" are low).
1760 !
1762 & zero_time, numdims, &
1767 use gtool_history, only: historyaxiscreate, historyaxisaddattr
1771 use dc_trace, only: beginsub, endsub
1774 use netcdf, only: nf90_emaxdims, nf90_max_dims
1778 use dc_calendar, only: dc_cal, dc_cal_date, &
1779 & dccaldateinquire, dccalinquire, dccaldefault, dccalconvertbyunit
1780 use dc_date, only: dcdifftimecreate, evalbyunit, tochar, tocharcal, eval
1782 use dc_message, only: messagenotify
1783 use dc_iounit, only: fileopen
1784 use dc_types, only: dp, string, token
1785 implicit none
1786 character(*), intent(in):: title
1787 ! データ全体の表題.
1788 ! Title of entire data
1789 character(*), intent(in):: source
1790 ! データを作成する際の手段.
1791 ! Source of data file
1792 character(*), intent(in):: institution
1793 ! ファイルを最終的に変更した組織/個人.
1794 ! Institution or person that changes files for the last time
1795 character(*), intent(in):: dims(:)
1796 ! 次元の名前.
1797 !
1798 ! 配列の大きさに制限はありません.
1799 ! 個々の次元の文字数は dc_types#TOKEN まで.
1800 ! 配列内の文字数は
1801 ! 全て同じでなければなりません.
1802 ! 足りない文字分は空白で
1803 ! 補ってください.
1804 !
1805 ! Names of dimensions.
1806 !
1807 ! Length of array is unlimited.
1808 ! Limits of numbers of characters of each
1809 ! dimensions are "dc_types#TOKEN".
1810 ! Numbers of characters in this array
1811 ! must be same.
1812 ! Make up a deficit with blanks.
1813 !
1814 integer, intent(in):: dimsizes (:)
1815 ! dims で指定したそれぞれの次元大きさ.
1816 !
1817 ! 配列の大きさは dims の大きさと等しい
1818 ! 必要があります. '0' (数字のゼロ) を指定
1819 ! するとその次元は 無制限次元 (unlimited
1820 ! dimension) となります. (gtool_history
1821 ! では時間の次元に対して無制限次元を
1822 ! 用いることを想定しています). ただし,
1823 ! 1 つの NetCDF ファイル (バージョン 3)
1824 ! は最大で 1 つの無制限次元しか持てないので,
1825 ! 2 ヶ所以上に '0' を指定しないでください.
1826 ! その場合, 正しく gtool4 データが出力されません.
1827 !
1828 ! Lengths of dimensions specified with "dims".
1829 !
1830 ! Length of this array must be same as
1831 ! length of "dim". If '0' (zero) is
1832 ! specified, the dimension is treated as
1833 ! unlimited dimension.
1834 ! (In "gtool_history", unlimited dimension is
1835 ! expected to be used as time).
1836 ! Note that one NetCDF file (version 3)
1837 ! can not have two or more unlimited
1838 ! dimensions, so that do not specify '0'
1839 ! to two or more places. In that case,
1840 ! gtoo4 data is not output currently
1841 !
1842 character(*), intent(in):: longnames (:)
1843 ! dims で指定したそれぞれの次元の名前.
1844 !
1845 ! 配列の大きさは dims の大きさ
1846 ! と等しい必要があります. 文字数
1847 ! は dc_types#STRING まで.
1848 ! 配列内の文字数は
1849 ! 全て同じでなければなりません.
1850 ! 足りない文字分は空白で補います.
1851 !
1852 ! Names of dimensions specified with "dims".
1853 !
1854 ! Length of this array must be same as
1855 ! length of "dim".
1856 ! Limits of numbers of characters are
1857 ! "dc_types#STRING".
1858 ! Numbers of characters in this array
1859 ! must be same.
1860 ! Make up a deficit with blanks.
1861 !
1862 character(*), intent(in):: units(:)
1863 ! dims で指定したそれぞれの次元の単位.
1864 !
1865 ! 配列の大きさは dims の大きさ
1866 ! と等しい必要があります. 文字数
1867 ! は dc_types#STRING まで.
1868 ! 配列内の文字数は
1869 ! 全て同じでなければなりません.
1870 ! 足りない文字分は空白で補います.
1871 !
1872 ! Units of dimensions specified with "dims".
1873 !
1874 ! Length of this array must be same as
1875 ! length of "dim".
1876 ! Limits of numbers of characters are
1877 ! "dc_types#STRING".
1878 ! Numbers of characters in this array
1879 ! must be same.
1880 ! Make up a deficit with blanks.
1881 !
1882 real(DP), intent(in):: origin
1883 ! 出力開始時刻.
1884 !
1885 ! Start time of output.
1886 !
1887 real(DP), intent(in):: terminus
1888 ! 出力終了時刻.
1889 !
1890 ! End time of output.
1891 !
1892 character(*), intent(in), optional:: xtypes(:)
1893 ! dims で指定したそれぞれの
1894 ! 次元のデータ型.
1895 !
1896 ! デフォルトは float (単精度実数型)
1897 ! です. 有効なのは,
1898 ! double (倍精度実数型),
1899 ! int (整数型) です. 指定しない
1900 ! 場合や, 無効な型を指定した場合には,
1901 ! float となります. なお, 配列の大きさ
1902 ! は *dims* の大きさと等しい必要が
1903 ! あります. 配列内の文字数は全て
1904 ! 同じでなければなりません.
1905 ! 足りない文字分は空白で補います.
1906 !
1907 ! Data types of dimensions specified
1908 ! with "dims".
1909 !
1910 ! Default value is "float" (single precision).
1911 ! Other valid values are
1912 ! "double" (double precision),
1913 ! "int" (integer).
1914 ! If no value or invalid value is specified,
1915 ! "float" is applied.
1916 ! Length of this array must be same as
1917 ! length of "dim".
1918 ! Numbers of characters in this array
1919 ! must be same.
1920 ! Make up a deficit with blanks.
1921 !
1922 character(*), intent(in), optional:: conventions
1923 ! 出力するファイルの netCDF
1924 ! 規約
1925 !
1926 ! 省略した場合,
1927 ! もしくは空文字を与えた場合,
1928 ! 出力する netCDF 規約の
1929 ! Conventions 属性に値
1930 ! gtool4_netCDF_Conventions
1931 ! が自動的に与えられます.
1932 !
1933 ! NetCDF conventions of output file.
1934 !
1935 ! If this argument is omitted or,
1936 ! blanks are given,
1937 ! gtool4_netCDF_Conventions is given to
1938 ! attribute "Conventions" of an output file
1939 ! automatically.
1940 !
1941 character(*), intent(in), optional:: gt_version
1942 ! gtool4 netCDF 規約のバージョン
1943 !
1944 ! 省略した場合, gt_version 属性に
1945 ! 規約の最新版のバージョンナンバー
1946 ! gtool4_netCDF_version
1947 ! が与えられます.
1948 ! (ただし, 引数 conventions に
1949 ! gtool4_netCDF_Conventions
1950 ! 以外が与えられる場合は
1951 ! gt_version 属性を作成しません).
1952 !
1953 ! Version of gtool4 netCDF Conventions.
1954 !
1955 ! If this argument is omitted,
1956 ! latest version number of gtool4 netCDF
1957 ! Conventions is given to attribute
1958 ! "gt_version" of an output file
1959 ! (However, gtool4_netCDF_Conventions is
1960 ! not given to an argument "conventions",
1961 ! attribute "gt_version" is not created).
1962 !
1963 logical, intent(in), optional:: all_output
1964 ! 登録変数を全て出力するためのフラグ.
1965 !
1966 ! .true. を指定すると,
1967 ! HistoryAutoAddVariable で登録された
1968 ! 変数が全て出力されるようになります.
1969 !
1970 ! *namelist_filename* が指定される場合
1971 ! には, デフォルトは .false. となります.
1972 ! この場合には,
1973 ! *namelist_filename* に指定された
1974 ! NAMELIST ファイルから読み込まれる
1975 ! NAMELIST#gtool_historyauto_nml
1976 ! で指定された変数のみ出力されます.
1977 !
1978 ! *namelist_filename* が指定されない場合
1979 ! には, .true. となります.
1980 !
1981 !
1982 ! Flag for output all registered variables.
1983 !
1984 ! When .true. is specified,
1985 ! all variables registered by
1986 ! "HistoryAutoAddVariable" are output.
1987 !
1988 ! If *namelist_filename* is specified,
1989 ! default value becomes .false. .
1990 ! In this case,
1991 ! only variables specified in
1992 ! "NAMELIST#gtool_historyauto_nml"
1993 ! loaded from a NAMELIST file
1994 ! *namelist_filename*.
1995 !
1996 ! If *namelist_filename* is not specified,
1997 ! this value becomes .true. .
1998 !
1999 character(*), intent(in), optional:: file_prefix
2000 ! データのファイル名の接頭詞.
2001 ! Prefixes of history data filenames
2002 character(*), intent(in), optional:: namelist_filename
2003 ! NAMELIST ファイルの名称.
2004 !
2005 ! 省略した場合, もしくは空白文字を与えた場合,
2006 ! NAMELIST ファイルは読み込みません.
2007 !
2008 ! Name of NAMELIST file.
2009 !
2010 ! If this argument is omitted,
2011 ! or blanks are specified,
2012 ! no NAMELIST file is loaded.
2013 !
2014 real(DP), intent(in), optional:: interval
2015 ! 出力時間間隔.
2016 !
2017 ! 省略した場合,
2018 ! 自動的に 1.0 [sec] が設定されます.
2019 !
2020 ! Interval of output time.
2021 !
2022 ! If this argument is omitted,
2023 ! 1.0 [sec] is specified
2024 ! automatically.
2025 !
2026 integer, intent(in), optional:: slice_start(:)
2027 ! 空間方向の開始点.
2028 !
2029 ! 省略した場合, 座標データの開始点が設定されます.
2030 !
2031 ! Start points of spaces.
2032 !
2033 ! If this argument is omitted,
2034 ! start points of dimensions are set.
2035 !
2036 integer, intent(in), optional:: slice_end(:)
2037 ! 空間方向の終了点.
2038 !
2039 ! 省略した場合, もしくは負の値が与えら得た場合,
2040 ! 座標データの終了点が設定されます.
2041 !
2042 ! End points of spaces.
2043 !
2044 ! If this argument is omitted or
2045 ! negative value is specified,
2046 ! end points of dimensions are set.
2047 !
2048 integer, intent(in), optional:: slice_stride(:)
2049 ! 空間方向の刻み幅.
2050 !
2051 ! 省略した場合, 1 が設定されます.
2052 !
2053 ! Strides of spaces
2054 !
2055 ! If this argument is omitted,
2056 ! 1 is set.
2057 !
2058 logical, intent(in), optional:: space_average(:)
2059 ! 平均化のフラグ.
2060 !
2061 ! .true. が指定される座標に対して平均化を
2062 ! 行います.
2063 ! 省略した場合, .false. が設定されます.
2064 !
2065 ! Flag of average.
2066 !
2067 ! Axes specified .true. are averaged.
2068 ! If this argument is omitted,
2069 ! .false. is set.
2070 !
2071 logical, intent(in), optional:: time_average
2072 ! 出力データの時間平均フラグ.
2073 ! デフォルトは .false.
2074 ! Flag for time average of output data
2075 ! Default value is .false.
2076 integer, intent(in), optional:: newfile_interval
2077 ! ファイル分割時間間隔.
2078 !
2079 ! 省略した場合,
2080 ! 時間方向へのファイル分割を行いません.
2081 !
2082 ! Interval of time of separation of a file.
2083 !
2084 ! If this argument is omitted,
2085 ! a files is not separated in time direction.
2086 !
2087 character(*), intent(in), optional:: rank
2088 ! ランクの名称.
2089 !
2090 ! Name of a rank.
2091 !
2092 type(dc_datetime), intent(in), optional:: origin_date
2093 ! 出力開始日時.
2094 ! この引数は廃止予定のため, start_date を使用して下さい.
2095 !
2096 ! Start date of output.
2097 ! Use "start_date" because this argument is obsolete.
2098 !
2099 logical, intent(in), optional:: origin_date_invalid
2100 ! .true. を与えると, origin_date を無効にします.
2101 !
2102 ! If ".true." is given, "origin_date" is ignored.
2103 type(dc_cal_date), intent(in), optional:: start_date
2104 ! 出力開始日時.
2105 !
2106 ! Start date of output.
2107 !
2108 type(dc_cal), intent(in), optional:: cal
2109 ! 暦情報.
2110 ! これを指定しない場合, dc_calendar モジュールの
2111 ! デフォルトの暦が使用されます.
2112 !
2113 ! Calendar.
2114 ! If this argument is specified, default calendar in
2115 ! "dc_calendar" module is used.
2116 !
2117 logical, intent(in), optional:: flag_mpi_gather
2118 ! MPI 使用時に, 各ノードで HistoryPut
2119 ! に与えたデータを一つのファイルに統合して出力
2120 ! する場合には .true. を与えてください.
2121 ! デフォルトは .false. です.
2122 !
2123 ! .true. を与えた場合, HistoryPutAxisMPI
2124 ! に全体の軸データを与えてください.
2125 !
2126 ! When MPI is used, if ".true." is given,
2127 ! data given to "HistoryPut" on each node
2128 ! is integrated and output to one file.
2129 ! Default value is ".false.".
2130 !
2131 ! If .true. is given, give data of axes in
2132 ! whole area to "HistoryPutAxisMPI"
2133 !
2134 logical, intent(in), optional:: flag_mpi_split
2135 ! MPI 使用時に, 各ノードで HistoryPut
2136 ! に与えたデータをそれぞれ別名のファイルに
2137 ! 出力する場合には .true. を与えてください.
2138 ! デフォルトは .false. です.
2139 !
2140 ! When MPI is used, if ".true." is given,
2141 ! data given to "HistoryPut" on each node
2142 ! is split into discrete files.
2143 ! Default value is ".false.".
2144 !
2145
2146
2147 ! NAMELIST 変数群 ; NAMELIST group of variables
2148 character(STRING):: Name
2149 ! 変数名.
2150 ! 空白の場合には, この他の設定値は
2151 ! gtool_historyauto モジュールにおいて
2152 ! 出力されるデータ全ての
2153 ! デフォルト値となります.
2154 !
2155 ! "Data1,Data2" のようにカンマで区切って複数
2156 ! の変数を指定することも可能です.
2157 !
2158 ! Variable identifier.
2159 ! If blank is given, other values are
2160 ! used as default values of output data
2161 ! in "gtool_historyauto".
2162 !
2163 ! Multiple variables can be specified
2164 ! as "Data1,Data2" too. Delimiter is comma.
2165 character(STRING):: File
2166 ! 出力ファイル名.
2167 ! これはデフォルト値としては使用されません.
2168 ! *Name* に値が設定されている時のみ有効です.
2169 !
2170 ! Output file name.
2171 ! This is not used as default value.
2172 ! This value is valid only when *Name* is
2173 ! specified.
2174
2175 real(DP):: IntValue
2176 ! データの出力間隔の数値.
2177 ! 負の値を与えると, 出力を抑止します.
2178 ! Numerical value for interval of history data output
2179 ! Negative values suppresses output.
2180 character(TOKEN):: IntUnit
2181 ! データの出力間隔の単位.
2182 ! Unit for interval of history data output
2183 character(TOKEN):: Precision
2184 ! データの精度.
2185 ! デフォルトは float (単精度実数型)
2186 ! です. 有効なのは,
2187 ! double (倍精度実数型),
2188 ! int (整数型) です. 指定しない
2189 ! 場合や, 無効な型を指定した場合には,
2190 ! float となります.
2191 !
2192 ! Precision of history data
2193 ! Default value is "float" (single precision).
2194 ! Other valid values are
2195 ! "double" (double precision),
2196 ! "int" (integer).
2197 ! If no value or invalid value is specified,
2198 ! "float" is applied.
2199 character(STRING):: FilePrefix
2200 ! データのファイル名の接頭詞.
2201 ! Prefixes of history data filenames
2202 logical:: TimeAverage
2203 ! 出力データの時間平均フラグ.
2204 !
2205 ! ".true." を与えると, 時間平均値が出力されます.
2206 !
2207 ! Flag for time average of output data
2208 !
2209 ! If ".ture." is specified,
2210 ! time average values are output.
2211 !
2212 logical:: AllOutput
2213 ! 登録変数を全て出力するためのフラグ.
2214 ! Flag for output all registered variables.
2215 real(DP):: OriginValue
2216 ! 出力開始時刻.
2217 ! Start time of output.
2218 character(TOKEN):: OriginUnit
2219 ! 出力開始時刻の単位.
2220 ! Unit of start time of output.
2221 real(DP):: TerminusValue
2222 ! 出力終了時刻.
2223 ! End time of output.
2224 character(TOKEN):: TerminusUnit
2225 ! 出力終了時刻の単位.
2226 ! Unit of end time of output.
2227 integer:: SliceStart(1:NF90_MAX_DIMS)
2228 ! 空間方向の開始点.
2229 ! Start points of spaces.
2230 integer:: SliceEnd(1:NF90_MAX_DIMS)
2231 ! 空間方向の終了点.
2232 !
2233 ! 省略した場合, もしくは負の値が与えら得た場合,
2234 ! 座標データの終了点が設定されます.
2235 !
2236 ! End points of spaces.
2237 !
2238 ! If this argument is omitted or
2239 ! negative value is specified,
2240 ! end points of dimensions are set.
2241 !
2242 integer:: SliceStride(1:NF90_MAX_DIMS)
2243 ! 空間方向の刻み幅.
2244 ! Strides of spaces.
2245 logical:: SpaceAverage(1:NF90_MAX_DIMS)
2246 ! 空間平均のフラグ.
2247 ! Flag of spatial average.
2248 integer:: NewFileIntValue
2249 ! ファイル分割時間間隔の数値.
2250 ! Numerical value for interval of time of separation of a file.
2251 character(TOKEN):: NewFileIntUnit
2252 ! ファイル分割時間間隔の単位.
2253 ! Unit of interval of time of separation of a file.
2254
2255 namelist /gtool_historyauto_nml/ &
2256 & name, file, &
2257 & intvalue, intunit, &
2258 & precision, &
2259 & fileprefix, &
2260 & timeaverage, alloutput, &
2261 & originvalue, originunit, &
2262 & terminusvalue, terminusunit, &
2263 & slicestart, sliceend, slicestride, spaceaverage, &
2264 & newfileintvalue, newfileintunit
2265 ! gtool_historyauto モジュールのデータ用
2266 ! NAMELIST 変数群名.
2267 !
2268 ! gtool_historyauto_generic#HistoryAutoCreate
2269 ! を使用する際に, オプショナル引数 *namelist_filename*
2270 ! へ NAMELIST ファイル名を指定することで,
2271 ! そのファイルからこの NAMELIST 変数群を
2272 ! 読み込みます.
2273 !
2274 ! NAMELIST group name for
2275 ! history data of "gtool_historyauto" module.
2276 !
2277 ! If a NAMELIST filename is specified to
2278 ! an optional argument *namelist_filename* when
2279 ! "gtool_historyauto_generic#HistoryAutoCreate"
2280 ! is used, this NAMELIST group is
2281 ! loaded from the file.
2282
2283
2284 ! 作業変数 ; Work variables
2285 integer:: blank_index
2286 integer:: stat
2287 character(STRING):: cause_c
2288 integer:: unit_nml ! NAMELIST ファイルオープン用装置番号.
2289 ! Unit number for NAMELIST file open
2290 integer:: iostat_nml ! NAMELIST 読み込み時の IOSTAT.
2291 ! IOSTAT of NAMELIST read
2292 character(TOKEN):: pos_nml
2293 ! NAMELIST 読み込み時のファイル位置.
2294 ! File position of NAMELIST read
2295 integer:: i, j
2296 character(TOKEN):: my_xtype
2297
2298 real(DP):: interval_work, origin_work, terminus_work
2299 integer:: date_day
2300 real(DP):: date_sec
2301 real(DP), parameter:: time_eps = epsilon(1.0_dp)
2302 integer:: msnot_rank
2303 character(STRING):: date_str
2304 character(TOKEN):: cal_str
2305 integer:: origin_year, origin_month, origin_day, origin_hour, origin_min
2306 real(DP):: origin_sec
2307 integer:: month_in_year, hour_in_day, min_in_hour
2308 integer, pointer:: day_in_month(:) =>null()
2309 real(DP):: sec_in_min
2310 character(*), parameter:: subname = "HistoryAutoCreate1"
2311 continue
2312 call beginsub(subname, version = version)
2313 stat = dc_noerr
2314 cause_c = ""
2315
2316 ! このサブルーチンが 2 度呼ばれたらエラー
2317 ! Error is occurred when this subroutine is called twice
2318 !
2319 if ( initialized ) then
2320 stat = dc_ealreadyinit
2321 cause_c = 'gtool_historyauto'
2322 goto 999
2323 end if
2324
2325 ! ゼロ秒の作成.
2326 ! Create zero seconds
2327 !
2328 zero_time = 0.0_dp
2329!!$ call DCDiffTimeCreate( &
2330!!$ & zero_time, & ! (out)
2331!!$ & sec = 0.0_DP ) ! (in)
2332
2333 ! 次元の数に関するエラー処理
2334 ! Error handling for number of dimensions
2335 !
2336 numdims = size(dims)
2337
2338 if ( size(dimsizes) /= numdims ) then
2339 cause_c = 'dimsizes, dims'
2340 elseif ( size(longnames) /= numdims ) then
2341 cause_c = 'longnames, dims'
2342 elseif ( size(units) /= numdims ) then
2343 cause_c = 'units, dims'
2344 endif
2345 if ( trim(cause_c) /= "" ) then
2346 stat = gt_eargsizemismatch
2347 goto 999
2348 end if
2349
2350 if ( numdims > nf90_max_dims ) then
2351 stat = nf90_emaxdims
2352 goto 999
2353 end if
2354
2355 ! 時刻次元に関するエラー処理
2356 ! Error handling for time dimension
2357 !
2358 if ( dimsizes(numdims) /= 0 ) then
2359 call messagenotify( 'W', subname, &
2360 & 'time dimension must be specified to the last of "dims"' )
2361 stat = hst_enotimedim
2362 goto 999
2363 end if
2364
2365 ! 出力ファイルの基本メタデータの保管
2366 ! Save basic meta data for output file
2367 !
2368 title_save = title
2369 source_save = source
2370 institution_save = institution
2371
2372 conventions_save = ''
2373 if ( present(conventions) ) conventions_save = conventions
2374
2375 gt_version_save = ''
2376 if ( present(gt_version) ) gt_version_save = gt_version
2377
2378 rank_save = ''
2379 if ( present(rank) ) rank_save = rank
2380
2381 ! MPI に関する情報の保管
2382 ! Save information about MPI
2383 !
2384 save_mpi_split = present_and_true( flag_mpi_split )
2385 save_mpi_gather = present_and_true( flag_mpi_gather )
2386
2387 msnot_rank = -1
2388 if ( save_mpi_gather ) msnot_rank = 0
2389
2390 ! 時刻の単位のチェック
2391 ! Check units of time
2392 !
2394 time_unit_suffix = ''
2395 blank_index = index( trim( adjustl(time_unit_bycreate) ), ' ' )
2396 if ( blank_index > 1 ) then
2397 time_unit_suffix = time_unit_bycreate(blank_index+1:)
2398 time_unit_bycreate = time_unit_bycreate(1:blank_index-1)
2399 end if
2400
2401 ! 座標軸データの保管
2402 ! Save axes data
2403 !
2404 do i = 1, numdims
2405 my_xtype = ''
2406 if ( present(xtypes) ) then
2407 if ( size(xtypes) >= i ) then
2408 my_xtype = xtypes(i)
2409 end if
2410 end if
2411
2412 call historyaxiscreate( &
2413 & axis = gthst_axes(i), & ! (out)
2414 & name = dims(i), size = dimsizes(i), & ! (in)
2415 & longname = longnames(i), units = units(i), & ! (in)
2416 & xtype = my_xtype ) ! (in)
2417
2418 allocate( data_axes(i) % a_axis( dimsizes(i) ) )
2419 data_axes(i) % a_axis = (/ ( real( j, dp ), j = 1, dimsizes(i) ) /)
2420
2421 end do
2422
2423 ! 暦の登録
2424 ! Register calendar
2425 !
2426 if ( present(cal) ) then
2427 cal_save = cal
2428 else
2429 call dccaldefault( cal_save )
2430 end if
2431
2432 ! 日時の指定
2433 ! Specify date
2434 !
2435 if ( present(start_date) ) then
2436
2437 call dccaldateinquire( &
2438 & date_str = date_str, & ! (out)
2439 & date = start_date, & ! (in) optional
2440 & cal = cal & ! (in) optional
2441 ! & , zone = "+09:00" &
2442 & )
2443
2444 call dccaldateinquire( &
2445 & origin_year, origin_month, origin_day, & ! (out) optional
2446 & origin_hour, origin_min, origin_sec, & ! (out) optional
2447 & date = start_date, & ! (in) optional
2448 & cal = cal & ! (in) optional
2449 & )
2450
2451 call dccalinquire( &
2452 & cal_str, & ! (out) optional
2453 & month_in_year = month_in_year, & ! (out) optional
2454 & day_in_month_ptr = day_in_month , & ! (out) optional
2455 & hour_in_day = hour_in_day , & ! (out) optional
2456 & min_in_hour = min_in_hour , & ! (out) optional
2457 & sec_in_min = sec_in_min , & ! (out) optional
2458 & cal = cal_save ) ! (in) optional
2459
2460 ! 地球暦の場合のみ units 属性に "since ..." を付加
2461 !
2462 select case ( trim(cal_str) )
2463 case ( 'gregorian' )
2465 & ' since ' // trim(date_str)
2466 case ( 'julian' )
2468 & ' since ' // trim(date_str)
2469 case ( 'noleap' )
2471 & ' since ' // trim(date_str)
2472 case ( '360day' )
2474 & ' since ' // trim(date_str)
2475 case ( 'cyclic' )
2477 & ' since ' // trim(date_str)
2478 end select
2479
2480 ! 開始日時情報の付与
2481 !
2482 call historyaxisaddattr( &
2483 & axis = gthst_axes(numdims), & ! (inout)
2484 & attrname = 'origin', & ! (in)
2485 & value = 'origin_year origin_month origin_day ' // &
2486 & 'origin_hour origin_min origin_sec' ) ! (in)
2487
2488 call historyaxisaddattr( gthst_axes(numdims), 'origin_year', origin_year )
2489 call historyaxisaddattr( gthst_axes(numdims), 'origin_month', origin_month )
2490 call historyaxisaddattr( gthst_axes(numdims), 'origin_day', origin_day )
2491 call historyaxisaddattr( gthst_axes(numdims), 'origin_hour', origin_hour )
2492 call historyaxisaddattr( gthst_axes(numdims), 'origin_min', origin_min )
2493
2494 ! 暦情報の付与
2495 !
2496 call historyaxisaddattr( &
2497 & axis = gthst_axes(numdims), & ! (inout)
2498 & attrname = 'calendar', & ! (in)
2499 & value = cal_str ) ! (in)
2500
2501 if ( trim(cal_str) == 'user_defined' ) then
2502 call historyaxisaddattr( gthst_axes(numdims), 'month_in_year', month_in_year )
2503 call historyaxisaddattr( gthst_axes(numdims), 'day_in_month', day_in_month )
2504 call historyaxisaddattr( gthst_axes(numdims), 'hour_in_day', hour_in_day )
2505 call historyaxisaddattr( gthst_axes(numdims), 'min_in_hour', min_in_hour )
2506 call historyaxisaddattr( gthst_axes(numdims), 'sec_in_min', sec_in_min )
2507 end if
2508
2509 deallocate( day_in_month )
2510
2511 elseif ( present(origin_date) &
2512 & .and. .not. present_and_true(origin_date_invalid) ) then
2513 call eval( origin_date, & ! (in)
2514 & day = date_day, sec = date_sec ) ! (out)
2515 if ( date_day /= 0 .or. abs(date_sec) > time_eps ) then
2517 & ' since ' // tochar(origin_date)
2518
2519 call historyaxisaddattr( &
2520 & axis = gthst_axes(numdims), & ! (inout)
2521 & attrname = 'calendar', & ! (in)
2522 & value = tocharcal(origin_date) ) ! (in)
2523
2524 end if
2525 end if
2526
2527 ! 登録変数を全て出力するためのフラグの保管
2528 ! Save flag for output all registered variables
2529 !
2530 if ( present(all_output) ) all_output_save = all_output
2531 if ( .not. present_and_not_empty(namelist_filename) ) all_output_save = .true.
2532 alloutput = all_output_save
2533
2534 ! 出力時間間隔のデフォルト値設定
2535 ! Configure default interval of output time
2536 !
2537 if ( all_output_save ) then
2538 if ( present(interval) ) then
2539 interval_work = interval
2540! interval_work = EvalbyUnit( interval, time_unit_bycreate )
2541 else
2542 interval_work = 1.0
2543 end if
2544 else
2545 interval_work = - 1.0
2546 end if
2547
2548 ! 出力開始・終了時刻のデフォルト値設定
2549 ! Configure default origin/terminus time of output
2550 !
2551 origin_work = &
2552 & dccalconvertbyunit( origin, time_unit_bycreate, 'sec', cal_save )
2553 terminus_work = terminus
2554
2555! origin_work = EvalbyUnit( origin, 'sec' )
2556! terminus_work = EvalbyUnit( terminus, time_unit_bycreate )
2557
2558 ! gtool_historyauto_nml へデフォルト値の設定
2559 ! Configure default values for "gtool_historyauto_nml"
2560 !
2561 call hstnmlinfocreate( gthstnml ) ! (out)
2562
2563 call hstnmlinfoadd( &
2564 & gthstnml = gthstnml, & ! (inout)
2565 & name = '', & ! (in) optional
2566 & precision = 'float', & ! (in) optional
2567 & fileprefix = file_prefix, & ! (in) optional
2568 & interval_value = interval_work, & ! (in) optional
2569 & interval_unit = time_unit_bycreate, & ! (in) optional
2570 & origin_value = origin_work, & ! (in) optional
2571 & origin_unit = 'sec', & ! (in) optional
2572!!$ & origin_unit = time_unit_bycreate, & ! (in) optional
2573 & terminus_value = terminus_work, & ! (in) optional
2574 & terminus_unit = time_unit_bycreate, & ! (in) optional
2575 & time_average = time_average, & ! (in) optional
2576 & slice_start = slice_start, & ! (in) optional
2577 & slice_end = slice_end, & ! (in) optional
2578 & slice_stride = slice_stride, & ! (in) optional
2579 & space_average = space_average, & ! (in) optional
2580 & newfile_intvalue = newfile_interval, & ! (in) optional
2581 & newfile_intunit = time_unit_bycreate ) ! (in) optional
2582
2583 ! NAMELIST ファイルの読み込み
2584 ! Load NAMELIST file
2585 !
2586 if ( present_and_not_empty(namelist_filename) ) then
2587 call fileopen( unit_nml, & ! (out)
2588 & namelist_filename, mode = 'r' ) ! (in)
2589
2590 iostat_nml = 0
2591 pos_nml = ''
2592
2593 call messagenotify( 'M', sub_sname, '----- "gtool_historyauto_nml" is loaded from "%c" -----', &
2594 & c1 = trim(namelist_filename), rank_mpi = msnot_rank )
2595
2596 do while ( trim(pos_nml) /= 'APPEND' .and. iostat_nml == 0 )
2597
2598 name = ''
2599 file = ''
2600 call hstnmlinfoinquire( &
2601 & gthstnml = gthstnml, & ! (in)
2602 & interval_value = intvalue, & ! (out) optional
2603 & interval_unit = intunit, & ! (out) optional
2604 & precision = precision, & ! (out) optional
2605 & time_average = timeaverage, & ! (out) optional
2606 & origin_value = originvalue, & ! (out) optional
2607 & origin_unit = originunit, & ! (out) optional
2608 & terminus_value = terminusvalue, & ! (out) optional
2609 & terminus_unit = terminusunit, & ! (out) optional
2610 & slice_start = slicestart, & ! (out) optional
2611 & slice_end = sliceend, & ! (out) optional
2612 & slice_stride = slicestride, & ! (out) optional
2613 & space_average = spaceaverage, & ! (out) optional
2614 & newfile_intvalue = newfileintvalue, & ! (out) optional
2615 & newfile_intunit = newfileintunit, & ! (out) optional
2616 & fileprefix = fileprefix ) ! (out) optional
2617
2618 read( unit = unit_nml, & ! (in)
2619 & nml = gtool_historyauto_nml, & ! (out)
2620 & iostat = iostat_nml ) ! (out)
2621 inquire( unit = unit_nml, & ! (in)
2622 & position = pos_nml ) ! (out)
2623
2624 if ( iostat_nml == 0 ) then
2625
2626 ! NAMELIST から与えられた値が無効な場合, デフォルト値を使用
2627 ! Default values are used when values from NAMELIST are invalid
2628 !
2629 if ( .not. intvalue > 0.0 ) then
2630 intvalue = interval_work
2631 intunit = time_unit_bycreate
2632 end if
2633 if ( .not. originvalue > 0.0 ) then
2634 originvalue = origin_work
2635 originunit = 'sec'
2636 end if
2637 if ( .not. terminusvalue > 0.0 ) then
2638 terminusvalue = terminus_work
2639 terminusunit = time_unit_bycreate
2640 end if
2641
2642 ! 情報の登録
2643 ! Register information
2644 !
2645 call hstnmlinfoadd( &
2646 & gthstnml = gthstnml, & ! (inout)
2647 & name = name, & ! (in) optional
2648 & file = file, & ! (in) optional
2649 & interval_value = intvalue, & ! (in) optional
2650 & interval_unit = intunit, & ! (in) optional
2651 & precision = precision, & ! (in) optional
2652 & time_average = timeaverage, & ! (in) optional
2653 & origin_value = originvalue, & ! (in) optional
2654 & origin_unit = originunit, & ! (in) optional
2655 & terminus_value = terminusvalue, & ! (in) optional
2656 & terminus_unit = terminusunit, & ! (in) optional
2657 & slice_start = slicestart, & ! (in) optional
2658 & slice_end = sliceend, & ! (in) optional
2659 & slice_stride = slicestride, & ! (in) optional
2660 & space_average = spaceaverage, & ! (in) optional
2661 & newfile_intvalue = newfileintvalue, & ! (in) optional
2662 & newfile_intunit = newfileintunit, & ! (in) optional
2663 & fileprefix = fileprefix ) ! (in) optional
2664
2665 ! 登録変数を全て出力するためのフラグの保管
2666 ! Save flag for output all registered variables
2667 !
2668 if ( trim(name) == '' ) then
2669 all_output_save = alloutput
2670 end if
2671
2672 ! 印字 ; Print
2673 !
2674 if ( trim(file) == '' ) file = trim(fileprefix) // '<Name>.nc'
2675
2676 if ( trim(name) == '' ) then
2677 call messagenotify( 'M', sub_sname, 'Global Settings:', rank_mpi = msnot_rank )
2678 call messagenotify( 'M', sub_sname, ' AllOutput = %b', l = (/ alloutput /), rank_mpi = msnot_rank )
2679 call messagenotify( 'M', sub_sname, ' FilePrefix = %c', c1 = trim(fileprefix ), rank_mpi = msnot_rank )
2680 else
2681 call messagenotify( 'M', sub_sname, 'Individual Settings:', rank_mpi = msnot_rank )
2682 call messagenotify( 'M', sub_sname, ' Name = %c', c1 = trim(name ), rank_mpi = msnot_rank )
2683 call messagenotify( 'M', sub_sname, ' File = %c', c1 = trim(file ), rank_mpi = msnot_rank )
2684 end if
2685 call messagenotify( 'M', sub_sname, ' Interval = %f [%c]', &
2686 & d = (/ intvalue /), c1 = trim( intunit ), rank_mpi = msnot_rank )
2687 call messagenotify( 'M', sub_sname, ' Precision = %c', c1 = trim(precision ), rank_mpi = msnot_rank )
2688 call messagenotify( 'M', sub_sname, ' TimeAverage = %b', l = (/ timeaverage /), rank_mpi = msnot_rank )
2689 call messagenotify( 'M', sub_sname, ' Origin = %f [%c]', &
2690 & d = (/ originvalue /), c1 = trim( originunit ), rank_mpi = msnot_rank )
2691 call messagenotify( 'M', sub_sname, ' Terminus = %f [%c]', &
2692 & d = (/ terminusvalue /), c1 = trim( terminusunit ), rank_mpi = msnot_rank )
2693 call messagenotify( 'M', sub_sname, ' SliceStart = (/ %*d /)', &
2694 & i = slicestart(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2695 call messagenotify( 'M', sub_sname, ' SliceEnd = (/ %*d /)', &
2696 & i = sliceend(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2697 call messagenotify( 'M', sub_sname, ' SliceStride = (/ %*d /)', &
2698 & i = slicestride(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2699 call messagenotify( 'M', sub_sname, ' SpaceAverage = (/ %*b /)', &
2700 & l = spaceaverage(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2701 call messagenotify( 'M', sub_sname, ' NewFileInterval = %d [%c]', &
2702 & i = (/ newfileintvalue /), c1 = trim( newfileintunit ), rank_mpi = msnot_rank )
2703 call messagenotify( 'M', sub_sname, '', rank_mpi = msnot_rank )
2704
2705 else
2706 call messagenotify( 'M', sub_sname, '----- loading is finished (iostat=%d) -----', &
2707 & i = (/iostat_nml/), rank_mpi = msnot_rank )
2708 end if
2709 end do
2710
2711 close( unit_nml )
2712
2713
2714 ! NAMELIST ファイルを読み込まない場合
2715 ! NAMELIST file is not loaded
2716 !
2717 else
2718 call messagenotify( 'M', sub_sname, '----- "gtool_historyauto_nml" is not loaded" -----', rank_mpi = msnot_rank )
2719 name = ''
2720 file = ''
2721 call hstnmlinfoinquire( &
2722 & gthstnml = gthstnml, & ! (in)
2723 & interval_value = intvalue, & ! (out) optional
2724 & interval_unit = intunit, & ! (out) optional
2725 & precision = precision, & ! (out) optional
2726 & time_average = timeaverage, & ! (out) optional
2727 & origin_value = originvalue, & ! (out) optional
2728 & origin_unit = originunit, & ! (out) optional
2729 & terminus_value = terminusvalue, & ! (out) optional
2730 & terminus_unit = terminusunit, & ! (out) optional
2731 & slice_start = slicestart, & ! (out) optional
2732 & slice_end = sliceend, & ! (out) optional
2733 & slice_stride = slicestride, & ! (out) optional
2734 & space_average = spaceaverage, & ! (out) optional
2735 & newfile_intvalue = newfileintvalue, & ! (out) optional
2736 & newfile_intunit = newfileintunit, & ! (out) optional
2737 & fileprefix = fileprefix ) ! (out) optional
2738
2739 ! 印字 ; Print
2740 !
2741 call messagenotify( 'M', sub_sname, 'Global Settings:', rank_mpi = msnot_rank )
2742 call messagenotify( 'M', sub_sname, ' AllOutput = %b', l = (/ alloutput /), rank_mpi = msnot_rank )
2743 call messagenotify( 'M', sub_sname, ' FilePrefix = %c', c1 = trim(fileprefix ), rank_mpi = msnot_rank )
2744 call messagenotify( 'M', sub_sname, ' Interval = %f [%c]', &
2745 & d = (/ intvalue /), c1 = trim( intunit ), rank_mpi = msnot_rank )
2746 call messagenotify( 'M', sub_sname, ' Precision = %c', c1 = trim(precision ), rank_mpi = msnot_rank )
2747 call messagenotify( 'M', sub_sname, ' TimeAverage = %b', l = (/ timeaverage /), rank_mpi = msnot_rank )
2748 call messagenotify( 'M', sub_sname, ' Origin = %f [%c]', &
2749 & d = (/ originvalue /), c1 = trim( originunit ), rank_mpi = msnot_rank )
2750 call messagenotify( 'M', sub_sname, ' Terminus = %f [%c]', &
2751 & d = (/ terminusvalue /), c1 = trim( terminusunit ), rank_mpi = msnot_rank )
2752 call messagenotify( 'M', sub_sname, ' SliceStart = (/ %*d /)', &
2753 & i = slicestart(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2754 call messagenotify( 'M', sub_sname, ' SliceEnd = (/ %*d /)', &
2755 & i = sliceend(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2756 call messagenotify( 'M', sub_sname, ' SliceStride = (/ %*d /)', &
2757 & i = slicestride(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2758 call messagenotify( 'M', sub_sname, ' SpaceAverage = (/ %*b /)', &
2759 & l = spaceaverage(1:numdims-1), n = (/ numdims-1 /), rank_mpi = msnot_rank )
2760 call messagenotify( 'M', sub_sname, ' NewFileInterval = %d [%c]', &
2761 & i = (/ newfileintvalue /), c1 = trim( newfileintunit ), rank_mpi = msnot_rank )
2762 call messagenotify( 'M', sub_sname, '' , rank_mpi = msnot_rank)
2763
2764 end if
2765
2766 ! 終了処理, 例外処理
2767 ! Termination and Exception handling
2768 !
2769 initialized = .true.
2770
2771999 continue
2772 call storeerror(stat, subname, cause_c = cause_c)
2773 call endsub(subname, 'stat=%d', i = (/stat/) )
2774 end subroutine historyautocreate1
subroutine historyautocreate2(title, source, institution, dims, dimsizes, longnames, units, xtypes, conventions, gt_version, all_output, file_prefix, namelist_filename, interval, origin, terminus, slice_start, slice_end, slice_stride, space_average, time_average, newfile_interval, rank, origin_date, origin_date_invalid, start_date, cal, flag_mpi_gather, flag_mpi_split)
subroutine historyautocreate3(title, source, institution, dims, dimsizes, longnames, units, origin, terminus, xtypes, conventions, gt_version, all_output, file_prefix, namelist_filename, interval, slice_start, slice_end, slice_stride, space_average, time_average, newfile_interval, rank, origin_date, origin_date_invalid, start_date, cal, flag_mpi_gather, flag_mpi_split)
subroutine historyautocreate1(title, source, institution, dims, dimsizes, longnames, units, origin, terminus, xtypes, conventions, gt_version, all_output, file_prefix, namelist_filename, interval, slice_start, slice_end, slice_stride, space_average, time_average, newfile_interval, rank, origin_date, origin_date_invalid, start_date, cal, flag_mpi_gather, flag_mpi_split)
Interface of procedures provided from gtool_historyauto.
Calendar and date module.
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 dc_ealreadyinit
Definition dc_error.f90:535
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
integer, parameter, public gt_eargsizemismatch
Definition dc_error.f90:515
integer, parameter, public hst_enotimedim
Definition dc_error.f90:564
Unit number handling at file open.
Message output module.
Judge optional control parameters.
logical function, public present_and_not_empty(arg)
logical function, public present_and_true(arg)
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:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:128
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
character(token), save, public gt_version_save
type(gthst_nmlinfo), save, public gthstnml
character(string), save, public conventions_save
character(token), save, public time_unit_bycreate
character(*), parameter, public sub_sname
character(token), save, public rank_save
character(string), save, public time_unit_suffix
character(string), save, public source_save
character(*), parameter, public version
type(gt_history_axis), dimension(1:nf90_max_dims), target, save, public gthst_axes
type(gt_history_axis_data), dimension(1:nf90_max_dims), target, save, public data_axes
character(string), save, public title_save
character(string), save, public institution_save