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

Go to the source code of this file.

Functions/Subroutines

subroutine historycreate1 (file, title, source, institution, dims, dimsizes, longnames, units, origin, interval, xtypes, history, origind, intervald, conventions, gt_version, overwrite, quiet, flag_mpi_gather, flag_mpi_split, err)
 gtool4 データ出力用初期設定
subroutine historycreate2 (file, title, source, institution, dims, dimsizes, longnames, units, origin, interval, xtypes, history, conventions, gt_version, overwrite, quiet, flag_mpi_gather, flag_mpi_split, err)
 gtool4 データ出力用初期設定
subroutine historycreate3 (file, title, source, institution, axes, origin, interval, history, origind, intervald, conventions, gt_version, overwrite, quiet, flag_mpi_gather, flag_mpi_split, err)
 gtool4 データ出力用初期設定

Function/Subroutine Documentation

◆ historycreate1()

subroutine historycreate1 ( character(*), intent(in) file,
character(*), intent(in) title,
character(*), intent(in) source,
character(*), intent(in) institution,
character(*), dimension(:), intent(in) dims,
integer, dimension (:), intent(in) dimsizes,
character(*), dimension (:), intent(in) longnames,
character(*), dimension(:), intent(in) units,
real, intent(in), optional origin,
real, intent(in), optional interval,
character(*), dimension(:), intent(in), optional xtypes,
type(gt_history), intent(out), optional, target history,
real(dp), intent(in), optional origind,
real(dp), intent(in), optional intervald,
character(*), intent(in), optional conventions,
character(*), intent(in), optional gt_version,
logical, intent(in), optional overwrite,
logical, intent(in), optional quiet,
logical, intent(in), optional flag_mpi_gather,
logical, intent(in), optional flag_mpi_split,
logical, intent(out), optional err )

gtool4 データ出力用初期設定

Parameters
[in]file

このサブルーチンは、gtool4 データ出力の初期設定を行います。 HistoryAddVariable、 HistoryCopyVariable、 HistoryPut、 HistoryAddAttr、 HistoryClose、 HistorySetTime を用いるためには、HistoryCreate による初期設定が必要です。

なお、プログラム内で HistoryCreate を呼び出した場合、 プログラムを終了する前に必ず、 HistoryClose を呼び出して 終了処理を行なって下さい。

HistoryCreate というサブルーチン名は 2 つの別々の サブルーチンの総称名です。上記のサブルーチンも参照ください。

Two specific subroutines share a common part: Both initialize a dataset file. The result of type GT_HISTORY will be returned by history or managed internally if omitted. Mandatory global attributes are defined by arguments title, source, and institution. Spatial axis definitions have two different forms: a primitive one uses several arrays of various types: dims, dimsizes, longnames, units, and xtypes. Another sophisticated one has only array of type GT_HISTORY_AXIS, axes. Temporal definition is done with origin and interval.

Definition at line 30 of file historycreate.f90.

35 !
36 !> @brief gtool4 データ出力用初期設定
37 !>
38 !> このサブルーチンは、gtool4 データ出力の初期設定を行います。
39 !> HistoryAddVariable、 HistoryCopyVariable、 HistoryPut、
40 !> HistoryAddAttr、 HistoryClose、 HistorySetTime
41 !> を用いるためには、HistoryCreate による初期設定が必要です。
42 !>
43 !> なお、プログラム内で HistoryCreate を呼び出した場合、
44 !> プログラムを終了する前に必ず、 HistoryClose を呼び出して
45 !> 終了処理を行なって下さい。
46 !>
47 !> HistoryCreate というサブルーチン名は 2 つの別々の
48 !> サブルーチンの総称名です。上記のサブルーチンも参照ください。
49 !>
50 !> Two specific subroutines share a common part:
51 !> Both initialize a dataset file.
52 !> The result of type GT_HISTORY will be returned by history
53 !> or managed internally if omitted.
54 !> Mandatory global attributes are defined by arguments
55 !> title, source, and institution.
56 !> Spatial axis definitions have two different forms:
57 !> a primitive one uses several arrays of various types:
58 !> dims, dimsizes, longnames, units, and xtypes.
59 !> Another sophisticated one has only array of type GT_HISTORY_AXIS,
60 !> axes.
61 !> Temporal definition is done with origin and interval.
62 !
70 use dc_url, only: urlmerge
72 use dc_types, only: string, token, dp
73 use dc_message, only: messagenotify
74 use dc_calendar, only: dc_cal, dc_cal_date, &
75 & dccalcreate, dccaldatecurrent, dccaldateinquire
77 use dc_date, only: dcdatetimecreate, tochar, dcdifftimecreate, &
78 & evalbyunit, parsetimeunits
79 use sysdep, only: sysdepenvget
80 implicit none
81 character(*), intent(in):: file
82 ! 出力するファイルの名前.
83 ! Name of output file
84 character(*), intent(in):: title
85 ! データ全体の表題.
86 ! Title of entire data
87 character(*), intent(in):: source
88 ! データを作成する際の手段.
89 ! Source of data file
90 character(*), intent(in):: institution
91 ! ファイルを最終的に変更した組織/個人.
92 ! Institution or person that changes files for the last time
93 character(*), intent(in):: dims(:)
94 ! 次元の名前.
95 !
96 ! 配列の大きさに制限はありません.
97 ! 個々の次元の文字数は dc_types::TOKEN まで.
98 ! 配列内の文字数は
99 ! 全て同じでなければなりません.
100 ! 足りない文字分は空白で
101 ! 補ってください.
102 !
103 ! Names of dimensions.
104 !
105 ! Length of array is unlimited.
106 ! Limits of numbers of characters of each
107 ! dimensions are "dc_types::TOKEN".
108 ! Numbers of characters in this array
109 ! must be same.
110 ! Make up a deficit with blanks.
111 !
112 integer, intent(in):: dimsizes (:)
113 ! dims で指定したそれぞれの次元大きさ.
114 !
115 ! 配列の大きさは dims の大きさと等しい
116 ! 必要があります. '0' (数字のゼロ) を指定
117 ! するとその次元は 無制限次元 (unlimited
118 ! dimension) となります. (gtool_history
119 ! では時間の次元に対して無制限次元を
120 ! 用いることを想定しています). ただし,
121 ! 1 つの NetCDF ファイル (バージョン 3)
122 ! は最大で 1 つの無制限次元しか持てないので,
123 ! 2 ヶ所以上に '0' を指定しないでください.
124 ! その場合, 正しく gtool4 データが出力されません.
125 !
126 ! Lengths of dimensions specified with "dims".
127 !
128 ! Length of this array must be same as
129 ! length of "dim". If '0' (zero) is
130 ! specified, the dimension is treated as
131 ! unlimited dimension.
132 ! (In "gtool_history", unlimited dimension is
133 ! expected to be used as time).
134 ! Note that one NetCDF file (version 3)
135 ! can not have two or more unlimited
136 ! dimensions, so that do not specify '0'
137 ! to two or more places. In that case,
138 ! gtoo4 data is not output currently
139 !
140 character(*), intent(in):: longnames (:)
141 ! dims で指定したそれぞれの次元の名前.
142 !
143 ! 配列の大きさは dims の大きさ
144 ! と等しい必要があります. 文字数
145 ! は dc_types::STRING まで.
146 ! 配列内の文字数は
147 ! 全て同じでなければなりません.
148 ! 足りない文字分は空白で補います.
149 !
150 ! Names of dimensions specified with "dims".
151 !
152 ! Length of this array must be same as
153 ! length of "dim".
154 ! Limits of numbers of characters are
155 ! "dc_types::STRING".
156 ! Numbers of characters in this array
157 ! must be same.
158 ! Make up a deficit with blanks.
159 !
160 character(*), intent(in):: units(:)
161 ! dims で指定したそれぞれの次元の単位.
162 !
163 ! 配列の大きさは dims の大きさ
164 ! と等しい必要があります. 文字数
165 ! は dc_types::STRING まで.
166 ! 配列内の文字数は
167 ! 全て同じでなければなりません.
168 ! 足りない文字分は空白で補います.
169 !
170 ! Units of dimensions specified with "dims".
171 !
172 ! Length of this array must be same as
173 ! length of "dim".
174 ! Limits of numbers of characters are
175 ! "dc_types::STRING".
176 ! Numbers of characters in this array
177 ! must be same.
178 ! Make up a deficit with blanks.
179 !
180 real, intent(in), optional:: origin
181 ! 時間の原点.
182 !
183 ! これは HistoryPut により変数を最初に
184 ! 出力するときの時間となります.
185 !
186 ! 省略した場合, 時間の原点には
187 ! 自動的に 0.0 が設定されます.
188 !
189 ! Origin of time.
190 !
191 ! This time is used as time
192 ! when first output is done by "HistoryPut".
193 !
194 ! If this argument is omitted,
195 ! 0.0 is specified automatically.
196 !
197 real, intent(in), optional:: interval
198 ! 出力時間間隔.
199 !
200 ! 同じ変数に対して HistoryPut が複数回
201 ! 呼ばれた時に, 自動的に時間変数がこの値
202 ! だけ増やされて出力されます. なお,
203 ! 各々の出力ファイルにつき HistorySetTime
204 ! を一度でも用いた場合, この値は無効に
205 ! なるので注意してください.
206 !
207 ! 省略した場合, 自動的に 1.0 が設定されます.
208 !
209 ! Interval of output time.
210 !
211 ! When "HistoryPut" is called two or
212 ! more times for the same variable, time
213 ! is increased as this value and
214 ! output automatically.
215 ! Note that this value becomes
216 ! invalid when "HistorySetTime" is
217 ! used for each output file even once.
218 !
219 ! If this argument is omitted,
220 ! 1.0 is specified automatically.
221 !
222 character(*), intent(in), optional:: xtypes(:)
223 ! dims で指定したそれぞれの
224 ! 次元のデータ型.
225 !
226 ! デフォルトは float (単精度実数型)
227 ! です. 有効なのは,
228 ! double (倍精度実数型),
229 ! int (整数型) です. 指定しない
230 ! 場合や, 無効な型を指定した場合には,
231 ! float となります. なお, 配列の大きさ
232 ! は *dims* の大きさと等しい必要が
233 ! あります. 配列内の文字数は全て
234 ! 同じでなければなりません.
235 ! 足りない文字分は空白で補います.
236 !
237 ! Data types of dimensions specified
238 ! with "dims".
239 !
240 ! Default value is "float" (single precision).
241 ! Other valid values are
242 ! "double" (double precision),
243 ! "int" (integer).
244 ! If no value or invalid value is specified,
245 ! "float" is applied.
246 ! Length of this array must be same as
247 ! length of "dim".
248 ! Numbers of characters in this array
249 ! must be same.
250 ! Make up a deficit with blanks.
251 !
252 type(GT_HISTORY), intent(out), optional, target:: history
253 ! 出力ファイルの設定に関する情報を
254 ! 格納した構造体.
255 !
256 ! 1 つのプログラムで複数のファイル
257 ! に gtool データを出力する
258 ! 場合に利用します.
259 ! (単独のファイルに書き出す場合は
260 ! 指定する必要はありません)
261 !
262 ! Derived type that
263 ! stores information about output files.
264 !
265 ! If multiple gtool4 data files are
266 ! output from one program, use this
267 ! argument.
268 ! (If onlye one file is output,
269 ! this argument is not needed).
270 !
271 real(DP), intent(in), optional:: origind
272 ! 時間の原点. (倍精度実数)
273 !
274 ! *time* と同様です.
275 !
276 ! Origin of time. (Double precision)
277 !
278 ! This is same as *time*.
279 !
280 real(DP), intent(in), optional:: intervald
281 ! 出力時間間隔. (倍精度実数)
282 !
283 ! *interval* と同様です.
284 !
285 ! Interval of output time. (Double precision)
286 !
287 ! This is same as *interval*.
288 !
289 character(*), intent(in), optional:: conventions
290 ! 出力するファイルの netCDF
291 ! 規約
292 !
293 ! 省略した場合,
294 ! もしくは空文字を与えた場合,
295 ! 出力する netCDF 規約の
296 ! Conventions 属性に値
297 ! gtool_history_internal#gtool4_netCDF_Conventions
298 ! が自動的に与えられます.
299 !
300 ! NetCDF conventions of output file.
301 !
302 ! If this argument is omitted or,
303 ! blanks are given,
304 ! gtool_history_internal#gtool4_netCDF_Conventions is given to
305 ! attribute "Conventions" of an output file
306 ! automatically.
307 !
308 character(*), intent(in), optional:: gt_version
309 ! gtool4 netCDF 規約のバージョン
310 !
311 ! 省略した場合, gt_version 属性に
312 ! 規約の最新版のバージョンナンバー
313 ! gtool4_netCDF_version
314 ! が与えられます.
315 ! (ただし, 引数 conventions に
316 ! gtool_history_internal#gtool4_netCDF_Conventions
317 ! 以外が与えられる場合は
318 ! gt_version 属性を作成しません).
319 !
320 ! Version of gtool4 netCDF Conventions.
321 !
322 ! If this argument is omitted,
323 ! latest version number of gtool4 netCDF
324 ! Conventions is given to attribute
325 ! "gt_version" of an output file
326 ! (However, gtool_history_internal#gtool4_netCDF_Conventions is
327 ! not given to an argument "conventions",
328 ! attribute "gt_version" is not created).
329 !
330 logical, intent(in), optional:: overwrite
331 ! 上書き可否
332 !
333 ! この引数に .false. を渡すと,
334 ! 既存のファイルを上書きしません.
335 ! デフォルトは上書きします.
336 !
337 ! Whether or not to overwrite.
338 !
339 ! If .false. is specified to this
340 ! argument, an existing file is not
341 ! overwritten.
342 ! By default, existing file is overwritten.
343 !
344 logical, intent(in), optional:: quiet
345 ! .true. を与えた場合,
346 ! メッセージ出力が抑制されます.
347 ! デフォルトは .false. です.
348 !
349 ! If ".true." is given,
350 ! messages are suppressed.
351 ! Default value is ".false.".
352 !
353 logical, intent(in), optional:: flag_mpi_gather
354 ! MPI 使用時に, 各ノードで HistoryPut
355 ! に与えたデータを一つのファイルに統合して出力
356 ! する場合には .true. を与えてください.
357 ! デフォルトは .false. です.
358 !
359 ! .true. を与えた場合, HistoryPutAxisMPI
360 ! に全体の軸データを与えてください.
361 !
362 ! When MPI is used, if ".true." is given,
363 ! data given to "HistoryPut" on each node
364 ! is integrated and output to one file.
365 ! Default value is ".false.".
366 !
367 ! If .true. is given, give data of axes in
368 ! whole area to "HistoryPutAxisMPI"
369 !
370 logical, intent(in), optional:: flag_mpi_split
371 ! MPI 使用時にこの引数に .true. を与えると,
372 ! 各ノードごとに
373 ! *file* 引数に "_rankXXXXXX"
374 ! (X は [0-9] の数値で, ノード番号を指す)
375 ! を付加したファイルを出力します.
376 ! 例えば, *file* に "output.nc" を与えた場合.
377 ! ノード 0 では "output_rank000000.nc",
378 ! ノード 12 では "output_rank000012.nc"
379 ! を出力します.
380 ! デフォルトは .false. です.
381 !
382 ! When MPI is used, if ".true." is given,
383 ! files that have names with suffixes
384 ! "_rankXXXXXX"
385 ! (X is [0-9] that indicates node number)
386 ! are output on each node.
387 ! For example, "output.nc" is given to *file*,
388 ! "output_rank000000.nc", "output_rank000012.nc"
389 ! are output on node 0 and node 12.
390 ! Default value is ".false.".
391 !
392 logical, intent(out), optional:: err
393 ! 例外処理用フラグ.
394 ! デフォルトでは, この手続き内でエラーが
395 ! 生じた場合, プログラムは強制終了します.
396 ! 引数 *err* が与えられる場合,
397 ! プログラムは強制終了せず, 代わりに
398 ! *err* に .true. が代入されます.
399 !
400 ! Exception handling flag.
401 ! By default, when error occur in
402 ! this procedure, the program aborts.
403 ! If this *err* argument is given,
404 ! .true. is substituted to *err* and
405 ! the program does not abort.
406 integer:: numdims, i, stat, blank_index
407 type(GT_HISTORY), pointer:: hst =>null()
408 character(TOKEN):: my_xtype, origin_str!, interval_str
409 character(STRING):: file_work, url, x_inst, x_conv, x_gtver, nc_history
410 character(STRING):: cause_c
411 logical:: gtver_add, overwrite_required
412 character(TOKEN):: username
413 type(DC_CAL):: cal_standard
414 type(DC_CAL_DATE):: now_date
415 character(TOKEN):: now_date_str
416 character(*), parameter:: subname = "HistoryCreate1"
417 character(*), parameter:: version = &
418 & '$Name: $' // &
419 & '$Id: historycreate.rb2f90,v 1.4 2009-11-03 05:22:46 morikawa Exp $'
420 continue
421 call beginsub(subname, 'file=%c ndims=%d', &
422 & c1=trim(file), i=(/size(dims)/), &
423 & version=version)
424 stat = dc_noerr
425 cause_c = ""
426 call dbgmessage( &
427 & 'dims(:)=%a, dimsizes(:)=%a, longnames(:)=%a, units(:)=%a', &
428 & ca=stoa(joinchar(dims), tochar(dimsizes), &
429 & joinchar(longnames), joinchar(units)))
430 if (present(history)) then
431 hst => history
432 else
433 hst => default
434 endif
435 ! 初期設定のチェック
436 ! Check initialization
437 !
438 if ( hst % initialized ) then
439 stat = dc_ealreadyinit
440 cause_c = 'GT_HISTORY'
441 goto 999
442 end if
443 ! dims, dimsizes, longnames, units の整合性チェック
444 ! Check consistency about "dims", "dimsizes", "longnames", "units"
445 !
446 numdims = size(dims)
447 if ( size(dimsizes) /= numdims ) then
448 cause_c = 'dimsizes, dims'
449 elseif ( size(longnames) /= numdims ) then
450 cause_c = 'longnames, dims'
451 elseif ( size(units) /= numdims ) then
452 cause_c = 'units, dims'
453 endif
454 if ( trim(cause_c) /= "" ) then
456 goto 999
457 end if
458 ! 次元変数表作成.
459 ! Create table of dimensional variables
460 !
461 allocate(hst % dimvars(numdims))
462 allocate(hst % dim_value_written(numdims))
463 hst % dim_value_written(:) = .false.
464 hst % unlimited_index = 0
465 ! ユーザ名の取得
466 ! Get user name
467 !
468 call sysdepenvget('USER', username)
469 if (trim(username) == '') username = 'unknown'
470 ! 現在時刻の取得
471 ! Get current time
472 !
473 call dccaldatecurrent( now_date )
474 call dccalcreate( 'gregorian', cal_standard )
475 call dccaldateinquire( now_date_str, date = now_date, cal = cal_standard )
476! call DCDateTimeCreate(now_time)
477 nc_history = trim(now_date_str) // ' ' // &
478 & trim(username) // &
479 & '> gtool_history: HistoryCreate' // &
480 & achar(10)
481 ! MPI に関連する情報の初期設定
482 ! Initialize information about MPI
483 !
484 hst % mpi_gather = .false.
485 hst % mpi_split = .false.
486 ! MPI 使用時のファイル名の扱い
487 ! Treat file names when MPI is used
488 !
489 file_work = file
490 ! 変数 URL (出力ファイル) の作成
491 ! Create variable URL (output file)
492 !
493 do, i = 1, numdims
494 my_xtype = ""
495 if ( present(xtypes) ) then
496 if ( size(xtypes) >= i ) then
497 my_xtype = cprintft('%c', c1=xtypes(i))
498 end if
499 end if
500 url = urlmerge(file=file, var=dims(i))
501 overwrite_required = .true.
502 if (present_and_false(overwrite)) overwrite_required = .false.
503 call create( &
504 & hst % dimvars(i), trim(url), &
505 & dimsizes(i), xtype=trim(my_xtype), &
506 & overwrite=overwrite_required)
507 ! conventions が存在しない場合はデフォルトの値を
508 ! 属性 Conventions に付加。
509 if ( present_and_not_empty(conventions) ) then
510 x_conv = conventions
511 else
513 endif
514 ! 1) gt_version がある場合、それを gt_version 属性に渡す。
515 ! 2) gt_version が無い場合、conventions も無いか、または
516 ! gtool4 netCDF 規約が入っていれば最新版を gt_version
517 ! に与える。そうでない場合は gt_version 属性を与えない。
518 if (present_and_not_empty(gt_version)) then
519 x_gtver = gt_version
520 gtver_add = .true.
521 else
522 if ( present_and_not_empty(conventions) .and. &
523 & .not. x_conv == gtool4_netcdf_conventions ) then
524 gtver_add = .false.
525 else
526 x_gtver = gtool4_netcdf_version
527 gtver_add = .true.
528 endif
529 endif
530 if (trim(institution) /= "") then
531 x_inst = institution
532 else
533 x_inst = "a gtool_history (by GFD Dennou Club) user"
534 endif
535 call put_attr(hst % dimvars(i), '+Conventions', trim(x_conv))
536 if (gtver_add) then
537 call put_attr(hst % dimvars(i), '+gt_version', trim(x_gtver))
538 endif
539 ! title, source, institution, history, long_name, units 属性の付加
540 call put_attr(hst % dimvars(i), '+title', title)
541 call put_attr(hst % dimvars(i), '+source', source)
542 call put_attr(hst % dimvars(i), '+institution', trim(x_inst))
543 call put_attr(hst % dimvars(i), '+history', trim(nc_history))
544 call put_attr(hst % dimvars(i), 'long_name', trim(longnames(i)))
545 call put_attr(hst % dimvars(i), 'units', trim(units(i)))
546 if (dimsizes(i) == 0) then
547 hst % unlimited_index = i
548 hst % unlimited_units = units(i)
549 end if
550 enddo
551 ! 従属変数表の初期化
552 ! Initialize table of dependent variables
553 !
554 nullify(hst % vars, hst % growable_indices, hst % count)
555 ! 時刻の単位
556 !
557 if ( hst % unlimited_index == 0 ) then
558 hst % unlimited_units_symbol = unit_symbol_sec
559 else
560 blank_index = index( trim( adjustl(hst % unlimited_units) ), ' ' )
561 if ( blank_index > 1 ) then
562 hst % unlimited_units = hst % unlimited_units(1:blank_index-1)
563 end if
564 hst % unlimited_units_symbol = parsetimeunits( hst % unlimited_units )
565 if ( hst % unlimited_units_symbol == unit_symbol_err ) then
566 call messagenotify('W', subname, &
567 & 'units of time (%c) can not be recognized as units of time. ' // &
568 & 'This units is treated as (%c)', &
569 & c1 = trim(hst % unlimited_units), c2 = 'sec')
570 hst % unlimited_units_symbol = unit_symbol_sec
571 end if
572 end if
573 ! 時間カウンタ
574 !
575 if ( present(interval) ) then
576 hst % interval = interval
577 elseif ( present(intervald) ) then
578 hst % interval = intervald
579 else
580 hst % interval = 1.0
581 end if
582 if ( present (origin) ) then
583 hst % origin = origin
584 hst % origin_setting = .true.
585 elseif( present(origind) ) then
586 hst % origin = origind
587 hst % origin_setting = .true.
588 else
589 hst % origin = 0.0
590 hst % origin_setting = .false.
591 end if
592 origin_str = trim( tochar( hst % origin ) ) // &
593 & ' [' // trim( hst % unlimited_units ) // ']'
594 hst % newest = hst % origin
595 hst % oldest = hst % origin
596 ! 時間平均値出力に関するデフォルト設定
597 ! Default settings for time-averaged value output
598 !
599 hst % time_bnds = hst % origin
600 hst % time_bnds_output_count = 0
601 ! メッセージ出力
602 ! Output messages
603 !
604 if ( .not. present_and_true(quiet) ) then
605 call messagenotify('M', subname, &
606 & '"%c" is created (origin=%c)', &
607 & c1 = trim( file_work ), &
608 & c2 = trim( origin_str ), rank_mpi = -1 )
609 end if
610 ! 終了処理, 例外処理
611 ! Termination and Exception handling
612 !
613 hst % initialized = .true.
614999 continue
615 call storeerror(stat, subname, err, cause_c=cause_c)
616 call endsub(subname, 'stat=%d', i = (/stat/) )
Calendar and date module.
Derived types and parameters for date and time.
integer, parameter, public unit_symbol_err
Symbol for invalid unit
integer, parameter, public unit_symbol_sec
Symbol for second unit
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
Message output module.
Judge optional control parameters.
logical function, public present_and_false(arg)
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 dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661
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 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
Variable URL string parser.
Definition dc_url.f90:61
character(string), parameter, public gtool4_netcdf_version
character(string), parameter, public gtool4_netcdf_conventions
type(gt_history), target, save, public default
Provides interface for system dependent procedures.
Definition sysdep.f90:54
subroutine, public sysdepenvget(env, str)
Get environment variable.
Definition sysdep.f90:176

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_error::dc_ealreadyinit, dc_error::dc_noerr, gtool_history_internal::default, dc_types::dp, dc_trace::endsub(), dc_error::gt_eargsizemismatch, gtool_history_internal::gtool4_netcdf_conventions, gtool_history_internal::gtool4_netcdf_version, dc_string::joinchar(), dc_present::present_and_false(), dc_present::present_and_not_empty(), dc_present::present_and_true(), dc_error::storeerror(), dc_types::string, sysdep::sysdepenvget(), dc_types::token, dc_date_types::unit_symbol_err, and dc_date_types::unit_symbol_sec.

Here is the call graph for this function:

◆ historycreate2()

subroutine historycreate2 ( character(*), intent(in) file,
character(*), intent(in) title,
character(*), intent(in) source,
character(*), intent(in) institution,
character(*), dimension(:), intent(in) dims,
integer, dimension (:), intent(in) dimsizes,
character(*), dimension (:), intent(in) longnames,
character(*), dimension(:), intent(in) units,
type(dc_difftime), intent(in) origin,
type(dc_difftime), intent(in), optional interval,
character(*), dimension(:), intent(in), optional xtypes,
type(gt_history), intent(out), optional, target history,
character(*), intent(in), optional conventions,
character(*), intent(in), optional gt_version,
logical, intent(in), optional overwrite,
logical, intent(in), optional quiet,
logical, intent(in), optional flag_mpi_gather,
logical, intent(in), optional flag_mpi_split,
logical, intent(out), optional err )

gtool4 データ出力用初期設定

Parameters
[in]file

このサブルーチンは、gtool4 データ出力の初期設定を行います。 HistoryAddVariable、 HistoryCopyVariable、 HistoryPut、 HistoryAddAttr、 HistoryClose、 HistorySetTime を用いるためには、HistoryCreate による初期設定が必要です。

なお、プログラム内で HistoryCreate を呼び出した場合、 プログラムを終了する前に必ず、 HistoryClose を呼び出して 終了処理を行なって下さい。

HistoryCreate というサブルーチン名は 2 つの別々の サブルーチンの総称名です。上記のサブルーチンも参照ください。

Two specific subroutines share a common part: Both initialize a dataset file. The result of type GT_HISTORY will be returned by history or managed internally if omitted. Mandatory global attributes are defined by arguments title, source, and institution. Spatial axis definitions have two different forms: a primitive one uses several arrays of various types: dims, dimsizes, longnames, units, and xtypes. Another sophisticated one has only array of type GT_HISTORY_AXIS, axes. Temporal definition is done with origin and interval.

Definition at line 619 of file historycreate.f90.

624 !
625 !> @brief gtool4 データ出力用初期設定
626 !>
627 !> このサブルーチンは、gtool4 データ出力の初期設定を行います。
628 !> HistoryAddVariable、 HistoryCopyVariable、 HistoryPut、
629 !> HistoryAddAttr、 HistoryClose、 HistorySetTime
630 !> を用いるためには、HistoryCreate による初期設定が必要です。
631 !>
632 !> なお、プログラム内で HistoryCreate を呼び出した場合、
633 !> プログラムを終了する前に必ず、 HistoryClose を呼び出して
634 !> 終了処理を行なって下さい。
635 !>
636 !> HistoryCreate というサブルーチン名は 2 つの別々の
637 !> サブルーチンの総称名です。上記のサブルーチンも参照ください。
638 !>
639 !> Two specific subroutines share a common part:
640 !> Both initialize a dataset file.
641 !> The result of type GT_HISTORY will be returned by history
642 !> or managed internally if omitted.
643 !> Mandatory global attributes are defined by arguments
644 !> title, source, and institution.
645 !> Spatial axis definitions have two different forms:
646 !> a primitive one uses several arrays of various types:
647 !> dims, dimsizes, longnames, units, and xtypes.
648 !> Another sophisticated one has only array of type GT_HISTORY_AXIS,
649 !> axes.
650 !> Temporal definition is done with origin and interval.
651 !
652 use dc_trace, only: beginsub, endsub
653 use dc_error, only: storeerror, dc_noerr
654 use dc_types, only: string, token, dp
656 use dc_date, only: dcdatetimecreate, tochar, dcdifftimecreate, &
657 & evalbyunit, parsetimeunits
661 implicit none
662 character(*), intent(in):: file
663 ! 出力するファイルの名前.
664 ! Name of output file
665 character(*), intent(in):: title
666 ! データ全体の表題.
667 ! Title of entire data
668 character(*), intent(in):: source
669 ! データを作成する際の手段.
670 ! Source of data file
671 character(*), intent(in):: institution
672 ! ファイルを最終的に変更した組織/個人.
673 ! Institution or person that changes files for the last time
674 character(*), intent(in):: dims(:)
675 ! 次元の名前.
676 !
677 ! 配列の大きさに制限はありません.
678 ! 個々の次元の文字数は dc_types::TOKEN まで.
679 ! 配列内の文字数は
680 ! 全て同じでなければなりません.
681 ! 足りない文字分は空白で
682 ! 補ってください.
683 !
684 ! Names of dimensions.
685 !
686 ! Length of array is unlimited.
687 ! Limits of numbers of characters of each
688 ! dimensions are "dc_types::TOKEN".
689 ! Numbers of characters in this array
690 ! must be same.
691 ! Make up a deficit with blanks.
692 !
693 integer, intent(in):: dimsizes (:)
694 ! dims で指定したそれぞれの次元大きさ.
695 !
696 ! 配列の大きさは dims の大きさと等しい
697 ! 必要があります. '0' (数字のゼロ) を指定
698 ! するとその次元は 無制限次元 (unlimited
699 ! dimension) となります. (gtool_history
700 ! では時間の次元に対して無制限次元を
701 ! 用いることを想定しています). ただし,
702 ! 1 つの NetCDF ファイル (バージョン 3)
703 ! は最大で 1 つの無制限次元しか持てないので,
704 ! 2 ヶ所以上に '0' を指定しないでください.
705 ! その場合, 正しく gtool4 データが出力されません.
706 !
707 ! Lengths of dimensions specified with "dims".
708 !
709 ! Length of this array must be same as
710 ! length of "dim". If '0' (zero) is
711 ! specified, the dimension is treated as
712 ! unlimited dimension.
713 ! (In "gtool_history", unlimited dimension is
714 ! expected to be used as time).
715 ! Note that one NetCDF file (version 3)
716 ! can not have two or more unlimited
717 ! dimensions, so that do not specify '0'
718 ! to two or more places. In that case,
719 ! gtoo4 data is not output currently
720 !
721 character(*), intent(in):: longnames (:)
722 ! dims で指定したそれぞれの次元の名前.
723 !
724 ! 配列の大きさは dims の大きさ
725 ! と等しい必要があります. 文字数
726 ! は dc_types::STRING まで.
727 ! 配列内の文字数は
728 ! 全て同じでなければなりません.
729 ! 足りない文字分は空白で補います.
730 !
731 ! Names of dimensions specified with "dims".
732 !
733 ! Length of this array must be same as
734 ! length of "dim".
735 ! Limits of numbers of characters are
736 ! "dc_types::STRING".
737 ! Numbers of characters in this array
738 ! must be same.
739 ! Make up a deficit with blanks.
740 !
741 character(*), intent(in):: units(:)
742 ! dims で指定したそれぞれの次元の単位.
743 !
744 ! 配列の大きさは dims の大きさ
745 ! と等しい必要があります. 文字数
746 ! は dc_types::STRING まで.
747 ! 配列内の文字数は
748 ! 全て同じでなければなりません.
749 ! 足りない文字分は空白で補います.
750 !
751 ! Units of dimensions specified with "dims".
752 !
753 ! Length of this array must be same as
754 ! length of "dim".
755 ! Limits of numbers of characters are
756 ! "dc_types::STRING".
757 ! Numbers of characters in this array
758 ! must be same.
759 ! Make up a deficit with blanks.
760 !
761 type(DC_DIFFTIME), intent(in):: origin
762 ! 時間の原点.
763 !
764 ! これは HistoryPut により変数を最初に
765 ! 出力するときの時間となります.
766 !
767 ! 省略した場合, 時間の原点には
768 ! 自動的に 0.0 が設定されます.
769 !
770 ! Origin of time.
771 !
772 ! This time is used as time
773 ! when first output is done by "HistoryPut".
774 !
775 ! If this argument is omitted,
776 ! 0.0 is specified automatically.
777 !
778 type(DC_DIFFTIME), intent(in), optional:: interval
779 ! 出力時間間隔.
780 !
781 ! 同じ変数に対して HistoryPut が複数回
782 ! 呼ばれた時に, 自動的に時間変数がこの値
783 ! だけ増やされて出力されます. なお,
784 ! 各々の出力ファイルにつき HistorySetTime
785 ! を一度でも用いた場合, この値は無効に
786 ! なるので注意してください.
787 !
788 ! 省略した場合, 自動的に 1.0 が設定されます.
789 !
790 ! Interval of output time.
791 !
792 ! When "HistoryPut" is called two or
793 ! more times for the same variable, time
794 ! is increased as this value and
795 ! output automatically.
796 ! Note that this value becomes
797 ! invalid when "HistorySetTime" is
798 ! used for each output file even once.
799 !
800 ! If this argument is omitted,
801 ! 1.0 is specified automatically.
802 !
803 character(*), intent(in), optional:: xtypes(:)
804 ! dims で指定したそれぞれの
805 ! 次元のデータ型.
806 !
807 ! デフォルトは float (単精度実数型)
808 ! です. 有効なのは,
809 ! double (倍精度実数型),
810 ! int (整数型) です. 指定しない
811 ! 場合や, 無効な型を指定した場合には,
812 ! float となります. なお, 配列の大きさ
813 ! は *dims* の大きさと等しい必要が
814 ! あります. 配列内の文字数は全て
815 ! 同じでなければなりません.
816 ! 足りない文字分は空白で補います.
817 !
818 ! Data types of dimensions specified
819 ! with "dims".
820 !
821 ! Default value is "float" (single precision).
822 ! Other valid values are
823 ! "double" (double precision),
824 ! "int" (integer).
825 ! If no value or invalid value is specified,
826 ! "float" is applied.
827 ! Length of this array must be same as
828 ! length of "dim".
829 ! Numbers of characters in this array
830 ! must be same.
831 ! Make up a deficit with blanks.
832 !
833 type(GT_HISTORY), intent(out), optional, target:: history
834 ! 出力ファイルの設定に関する情報を
835 ! 格納した構造体.
836 !
837 ! 1 つのプログラムで複数のファイル
838 ! に gtool データを出力する
839 ! 場合に利用します.
840 ! (単独のファイルに書き出す場合は
841 ! 指定する必要はありません)
842 !
843 ! Derived type that
844 ! stores information about output files.
845 !
846 ! If multiple gtool4 data files are
847 ! output from one program, use this
848 ! argument.
849 ! (If onlye one file is output,
850 ! this argument is not needed).
851 !
852 character(*), intent(in), optional:: conventions
853 ! 出力するファイルの netCDF
854 ! 規約
855 !
856 ! 省略した場合,
857 ! もしくは空文字を与えた場合,
858 ! 出力する netCDF 規約の
859 ! Conventions 属性に値
860 ! gtool4_netCDF_Conventions
861 ! が自動的に与えられます.
862 !
863 ! NetCDF conventions of output file.
864 !
865 ! If this argument is omitted or,
866 ! blanks are given,
867 ! gtool4_netCDF_Conventions is given to
868 ! attribute "Conventions" of an output file
869 ! automatically.
870 !
871 character(*), intent(in), optional:: gt_version
872 ! gtool4 netCDF 規約のバージョン
873 !
874 ! 省略した場合, gt_version 属性に
875 ! 規約の最新版のバージョンナンバー
876 ! gtool4_netCDF_version
877 ! が与えられます.
878 ! (ただし, 引数 conventions に
879 ! gtool4_netCDF_Conventions
880 ! 以外が与えられる場合は
881 ! gt_version 属性を作成しません).
882 !
883 ! Version of gtool4 netCDF Conventions.
884 !
885 ! If this argument is omitted,
886 ! latest version number of gtool4 netCDF
887 ! Conventions is given to attribute
888 ! "gt_version" of an output file
889 ! (However, gtool4_netCDF_Conventions is
890 ! not given to an argument "conventions",
891 ! attribute "gt_version" is not created).
892 !
893 logical, intent(in), optional:: overwrite
894 ! 上書き可否
895 !
896 ! この引数に .false. を渡すと,
897 ! 既存のファイルを上書きしません.
898 ! デフォルトは上書きします.
899 !
900 ! Whether or not to overwrite.
901 !
902 ! If .false. is specified to this
903 ! argument, an existing file is not
904 ! overwritten.
905 ! By default, existing file is overwritten.
906 !
907 logical, intent(in), optional:: quiet
908 ! .true. を与えた場合,
909 ! メッセージ出力が抑制されます.
910 ! デフォルトは .false. です.
911 !
912 ! If ".true." is given,
913 ! messages are suppressed.
914 ! Default value is ".false.".
915 !
916 logical, intent(in), optional:: flag_mpi_gather
917 ! MPI 使用時に, 各ノードで HistoryPut
918 ! に与えたデータを一つのファイルに統合して出力
919 ! する場合には .true. を与えてください.
920 ! デフォルトは .false. です.
921 !
922 ! .true. を与えた場合, HistoryPutAxisMPI
923 ! に全体の軸データを与えてください.
924 !
925 ! When MPI is used, if ".true." is given,
926 ! data given to "HistoryPut" on each node
927 ! is integrated and output to one file.
928 ! Default value is ".false.".
929 !
930 ! If .true. is given, give data of axes in
931 ! whole area to "HistoryPutAxisMPI"
932 !
933 logical, intent(in), optional:: flag_mpi_split
934 ! MPI 使用時にこの引数に .true. を与えると,
935 ! 各ノードごとに
936 ! *file* 引数に "_rankXXXXXX"
937 ! (X は [0-9] の数値で, ノード番号を指す)
938 ! を付加したファイルを出力します.
939 ! 例えば, *file* に "output.nc" を与えた場合.
940 ! ノード 0 では "output_rank000000.nc",
941 ! ノード 12 では "output_rank000012.nc"
942 ! を出力します.
943 ! デフォルトは .false. です.
944 !
945 ! When MPI is used, if ".true." is given,
946 ! files that have names with suffixes
947 ! "_rankXXXXXX"
948 ! (X is [0-9] that indicates node number)
949 ! are output on each node.
950 ! For example, "output.nc" is given to *file*,
951 ! "output_rank000000.nc", "output_rank000012.nc"
952 ! are output on node 0 and node 12.
953 ! Default value is ".false.".
954 !
955 logical, intent(out), optional:: err
956 ! 例外処理用フラグ.
957 ! デフォルトでは, この手続き内でエラーが
958 ! 生じた場合, プログラムは強制終了します.
959 ! 引数 *err* が与えられる場合,
960 ! プログラムは強制終了せず, 代わりに
961 ! *err* に .true. が代入されます.
962 !
963 ! Exception handling flag.
964 ! By default, when error occur in
965 ! this procedure, the program aborts.
966 ! If this *err* argument is given,
967 ! .true. is substituted to *err* and
968 ! the program does not abort.
969 type(GT_HISTORY), pointer:: hst =>null()
970 real(DP):: origind, intervald
971 integer:: i, numdims, blank_index
972 character(TOKEN):: unlimited_units
973 integer:: unit_symbol
974 integer:: stat
975 character(STRING):: cause_c
976 character(*), parameter:: subname = "HistoryCreate2"
977 character(*), parameter:: version = &
978 & '$Name: $' // &
979 & '$Id: historycreate.rb2f90,v 1.4 2009-11-03 05:22:46 morikawa Exp $'
980 continue
981 call beginsub(subname, 'file=%c ndims=%d', &
982 & c1=trim(file), i=(/size(dims)/), &
983 & version=version)
984 stat = dc_noerr
985 cause_c = ""
986 numdims = size(dims)
987 unlimited_units = 'sec'
988 do, i = 1, numdims
989 if (dimsizes(i) == 0) unlimited_units = units(i)
990 end do
991 blank_index = index( trim( adjustl(unlimited_units) ), ' ' )
992 if ( blank_index > 1 ) then
993 unlimited_units = unlimited_units(1:blank_index-1)
994 end if
995 unit_symbol = parsetimeunits( unlimited_units )
996 if ( unit_symbol == unit_symbol_err ) unit_symbol = unit_symbol_sec
997 if (present(interval)) then
998 intervald = evalbyunit( interval, '', unit_symbol )
999 else
1000 intervald = 1.0_dp
1001 end if
1002 origind = evalbyunit( origin, '', unit_symbol )
1003 call historycreate( &
1004 & file = file, title = title, &
1005 & source = source, institution = institution, &
1006 & dims = dims, dimsizes = dimsizes, &
1007 & longnames = longnames, units = units, &
1008 & xtypes = xtypes, history = history, &
1009 & origind = origind, intervald = intervald, &
1010 & conventions = conventions, gt_version = gt_version, &
1011 & overwrite = overwrite, quiet = quiet, &
1012 & flag_mpi_gather = flag_mpi_gather, flag_mpi_split = flag_mpi_split, &
1013 & err = err )
1014 if (present(history)) then
1015 hst => history
1016 else
1017 hst => default
1018 endif
1019 call storeerror(stat, subname, cause_c=cause_c)
1020 call endsub(subname, 'stat=%d', i = (/stat/) )

References dc_trace::beginsub(), dc_error::dc_noerr, gtool_history_internal::default, dc_types::dp, dc_trace::endsub(), dc_error::storeerror(), dc_types::string, dc_types::token, dc_date_types::unit_symbol_err, and dc_date_types::unit_symbol_sec.

Here is the call graph for this function:

◆ historycreate3()

subroutine historycreate3 ( character(*), intent(in) file,
character(*), intent(in) title,
character(*), intent(in) source,
character(*), intent(in) institution,
type(gt_history_axis), dimension(:), intent(in) axes,
real, intent(in), optional origin,
real, intent(in), optional interval,
type(gt_history), intent(out), optional, target history,
real(dp), intent(in), optional origind,
real(dp), intent(in), optional intervald,
character(*), intent(in), optional conventions,
character(*), intent(in), optional gt_version,
logical, intent(in), optional overwrite,
logical, intent(in), optional quiet,
logical, intent(in), optional flag_mpi_gather,
logical, intent(in), optional flag_mpi_split,
logical, intent(out), optional err )

gtool4 データ出力用初期設定

Parameters
[in]file

HistoryCreate というサブルーチン名は 2 つの別々の サブルーチンの総称名です。まずは HistoryCreate を参照ください。

もう 1 つのサブルーチンと異なる点は、座標軸の情報を dims, dimsizes, longnames, units, xtypes といった 個別の引数で与えるのではなく、構造体 GT_HISTORY_AXIS 型の 引数 axes で与える点にあります。

GT_HISTORY_AXIS 型変数の生成 (constructor) は HistoryAxisCreate にて行います。

Two specific subroutines share a common part: Both initialize a dataset file. The result of type GT_HISTORY will be returned by history or managed internally if omitted. Mandatory global attributes are defined by arguments title, source, and institution. Spatial axis definitions have two different forms: a primitive one uses several arrays of various types: dims, dimsizes, longnames, units, and xtypes. Another sophisticated one has only array of type GT_HISTORY_AXIS, axes. Temporal definition is done with origin and interval.

Definition at line 1023 of file historycreate.f90.

1026 !
1027 !> @brief gtool4 データ出力用初期設定
1028 !>
1029 !> HistoryCreate というサブルーチン名は 2 つの別々の
1030 !> サブルーチンの総称名です。まずは HistoryCreate を参照ください。
1031 !>
1032 !> もう 1 つのサブルーチンと異なる点は、座標軸の情報を
1033 !> dims, dimsizes, longnames, units, xtypes といった
1034 !> 個別の引数で与えるのではなく、構造体 GT_HISTORY_AXIS 型の
1035 !> 引数 axes で与える点にあります。
1036 !>
1037 !> GT_HISTORY_AXIS 型変数の生成 (constructor) は
1038 !> HistoryAxisCreate にて行います。
1039 !>
1040 !> Two specific subroutines share a common part:
1041 !> Both initialize a dataset file.
1042 !> The result of type GT_HISTORY will be returned by history
1043 !> or managed internally if omitted.
1044 !> Mandatory global attributes are defined by arguments
1045 !> title, source, and institution.
1046 !> Spatial axis definitions have two different forms:
1047 !> a primitive one uses several arrays of various types:
1048 !> dims, dimsizes, longnames, units, and xtypes.
1049 !> Another sophisticated one has only array of type GT_HISTORY_AXIS,
1050 !> axes.
1051 !> Temporal definition is done with origin and interval.
1052 !
1053 use dc_types, only: string, dp
1054 use dc_present, only: present_and_true
1055 use dc_trace, only: beginsub, endsub, dbgmessage
1059 implicit none
1060 character(*), intent(in):: file
1061 ! HistoryCreate 参照
1062 ! (以下 axes を除く引数も同様)
1063 !
1064 character(*), intent(in):: title, source, institution
1065 type(GT_HISTORY_AXIS), intent(in):: axes(:)
1066 ! 次元情報を格納した構造型変数
1067 !
1068 ! GT_HISTORY_AXIS 型変数の生成
1069 ! (constructer) は
1070 ! HistoryAxisCreate にて行いま
1071 ! す。配列の大きさに制限は
1072 ! ありません。
1073 !
1074 real, intent(in), optional:: origin, interval
1075 type(GT_HISTORY), intent(out), optional, target:: history
1076 real(DP), intent(in), optional:: origind, intervald
1077 character(*), intent(in), optional:: conventions, gt_version
1078 logical, intent(in), optional:: overwrite
1079 logical, intent(in), optional:: quiet
1080 ! .true. を与えた場合,
1081 ! メッセージ出力が抑制されます.
1082 ! デフォルトは .false. です.
1083 !
1084 ! If ".true." is given,
1085 ! messages are suppressed.
1086 ! Default value is ".false.".
1087 !
1088 logical, intent(in), optional:: flag_mpi_gather
1089 ! MPI 使用時に, 各ノードで HistoryPut
1090 ! に与えたデータを一つのファイルに統合して出力
1091 ! する場合には .true. を与えてください.
1092 ! デフォルトは .false. です.
1093 !
1094 ! .true. を与えた場合, HistoryPutAxisMPI
1095 ! に全体の軸データを与えてください.
1096 !
1097 ! When MPI is used, if ".true." is given,
1098 ! data given to "HistoryPut" on each node
1099 ! is integrated and output to one file.
1100 ! Default value is ".false.".
1101 !
1102 ! If .true. is given, give data of axes in
1103 ! whole area to "HistoryPutAxisMPI"
1104 !
1105 logical, intent(in), optional:: flag_mpi_split
1106 ! MPI 使用時にこの引数に .true. を与えると,
1107 ! 各ノードごとに
1108 ! *file* 引数に "_rankXXXXXX"
1109 ! (X は [0-9] の数値で, ノード番号を指す)
1110 ! を付加したファイルを出力します.
1111 ! 例えば, *file* に "output.nc" を与えた場合.
1112 ! ノード 0 では "output_rank000000.nc",
1113 ! ノード 12 では "output_rank000012.nc"
1114 ! を出力します.
1115 ! デフォルトは .false. です.
1116 !
1117 ! When MPI is used, if ".true." is given,
1118 ! files that have names with suffixes
1119 ! "_rankXXXXXX"
1120 ! (X is [0-9] that indicates node number)
1121 ! are output on each node.
1122 ! For example, "output.nc" is given to *file*,
1123 ! "output_rank000000.nc", "output_rank000012.nc"
1124 ! are output on node 0 and node 12.
1125 ! Default value is ".false.".
1126 !
1127 logical, intent(out), optional:: err
1128 ! 例外処理用フラグ.
1129 ! デフォルトでは, この手続き内でエラーが
1130 ! 生じた場合, プログラムは強制終了します.
1131 ! 引数 *err* が与えられる場合,
1132 ! プログラムは強制終了せず, 代わりに
1133 ! *err* に .true. が代入されます.
1134 !
1135 ! Exception handling flag.
1136 ! By default, when error occur in
1137 ! this procedure, the program aborts.
1138 ! If this *err* argument is given,
1139 ! .true. is substituted to *err* and
1140 ! the program does not abort.
1141 ! 構造体 GT_HISTORY_AXIS のデータ蓄積用
1142 character(STRING), allocatable:: axes_name(:)
1143 integer , allocatable:: axes_length(:)
1144 character(STRING), allocatable:: axes_longname(:)
1145 character(STRING), allocatable:: axes_units(:)
1146 character(STRING), allocatable:: axes_xtype(:)
1147 integer:: i, ndims
1148 character(len = *), parameter:: subname = "HistoryCreate3"
1149 continue
1150 call beginsub(subname, 'file=%c ndims=%d', &
1151 & c1=trim(file), i=(/size(axes)/) )
1152 ! 構造体 GT_HISTORY_AXIS の axes からのデータ取得
1153 ! (Fujitsu Fortran などなら axes(:)%name という表記で配列
1154 ! データをそのまま引き渡せるが、Intel Fortran 8 などだと
1155 ! その表記をまともに解釈してくれないので、美しくないけど
1156 ! いったん他の配列に情報を引き渡す)。2004/11/27 morikawa
1157 ndims = size( axes(:) )
1158 allocate( axes_name(ndims) )
1159 allocate( axes_length(ndims) )
1160 allocate( axes_longname(ndims) )
1161 allocate( axes_units(ndims) )
1162 allocate( axes_xtype(ndims) )
1163 do i = 1, ndims
1164 axes_name(i) = axes(i) % name
1165 axes_length(i) = axes(i) % length
1166 axes_longname(i) = axes(i) % longname
1167 axes_units(i) = axes(i) % units
1168 axes_xtype(i) = axes(i) % xtype
1169 call dbgmessage('axes(%d):name=<%c>, length=<%d>, ' // &
1170 & 'longname=<%c>, units=<%c>' , &
1171 & i=(/i, axes(i) % length/) , &
1172 & c1=( trim(axes(i) % name) ) , &
1173 & c2=( trim(axes(i) % longname) ) , &
1174 & c3=( trim(axes(i) % units) ) )
1175 enddo
1176 call historycreate(file, title, source, institution, &
1177 & dims = axes_name(:), dimsizes = axes_length(:), &
1178 & longnames = axes_longname(:), units = axes_units(:), &
1179 & xtypes = axes_xtype(:), &
1180 & origin = origin, interval = interval, &
1181 & history = history, &
1182 & origind = origind, intervald = intervald, &
1183 & conventions = conventions, &
1184 & gt_version = gt_version, overwrite = overwrite, quiet = quiet, &
1185 & flag_mpi_gather = flag_mpi_gather, &
1186 & flag_mpi_split = flag_mpi_split, &
1187 & err = err )
1188 deallocate( axes_name )
1189 deallocate( axes_length )
1190 deallocate( axes_longname )
1191 deallocate( axes_units )
1192 deallocate( axes_xtype )
1193 do i = 1, ndims
1194 if ( .not. associated( axes(i) % attrs ) ) cycle
1195 call append_attrs( axes(i) % name, axes(i) % attrs, history )
1196 end do
1197 call endsub(subname)

References dc_trace::beginsub(), dc_trace::dbgmessage(), gtool_history_internal::default, dc_types::dp, dc_trace::endsub(), dc_present::present_and_true(), and dc_types::string.

Here is the call graph for this function: