31 & file, title, source, institution, &
32 & dims, dimsizes, longnames, units, origin, interval, &
33 & xtypes, history, origind, intervald, conventions, gt_version, overwrite, quiet, &
34 & flag_mpi_gather, flag_mpi_split, err )
75 & dccalcreate, dccaldatecurrent, dccaldateinquire
77 use dc_date,
only: dcdatetimecreate,
tochar, dcdifftimecreate, &
78 & evalbyunit, parsetimeunits
81 character(*),
intent(in):: file
84 character(*),
intent(in):: title
87 character(*),
intent(in):: source
90 character(*),
intent(in):: institution
93 character(*),
intent(in):: dims(:)
112 integer,
intent(in):: dimsizes (:)
140 character(*),
intent(in):: longnames (:)
160 character(*),
intent(in):: units(:)
180 real,
intent(in),
optional:: origin
197 real,
intent(in),
optional:: interval
222 character(*),
intent(in),
optional:: xtypes(:)
252 type(
gt_history),
intent(out),
optional,
target:: history
271 real(DP),
intent(in),
optional:: origind
280 real(DP),
intent(in),
optional:: intervald
289 character(*),
intent(in),
optional:: conventions
308 character(*),
intent(in),
optional:: gt_version
330 logical,
intent(in),
optional:: overwrite
344 logical,
intent(in),
optional:: quiet
353 logical,
intent(in),
optional:: flag_mpi_gather
370 logical,
intent(in),
optional:: flag_mpi_split
392 logical,
intent(out),
optional:: err
406 integer:: numdims, i, stat, blank_index
408 character(TOKEN):: my_xtype, origin_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 = &
419 &
'$Id: historycreate.rb2f90,v 1.4 2009-11-03 05:22:46 morikawa Exp $'
421 call beginsub(subname,
'file=%c ndims=%d', &
422 & c1=trim(file), i=(/
size(dims)/), &
427 &
'dims(:)=%a, dimsizes(:)=%a, longnames(:)=%a, units(:)=%a', &
430 if (
present(history))
then
438 if ( hst % initialized )
then
440 cause_c =
'GT_HISTORY'
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'
454 if ( trim(cause_c) /=
"" )
then
461 allocate(hst % dimvars(numdims))
462 allocate(hst % dim_value_written(numdims))
463 hst % dim_value_written(:) = .false.
464 hst % unlimited_index = 0
469 if (trim(username) ==
'') username =
'unknown'
473 call dccaldatecurrent( now_date )
474 call dccalcreate(
'gregorian', cal_standard )
475 call dccaldateinquire( now_date_str, date = now_date, cal = cal_standard )
477 nc_history = trim(now_date_str) //
' ' // &
478 & trim(username) // &
479 &
'> gtool_history: HistoryCreate' // &
484 hst % mpi_gather = .false.
485 hst % mpi_split = .false.
495 if (
present(xtypes) )
then
496 if (
size(xtypes) >= i )
then
497 my_xtype =
cprintft(
'%c', c1=xtypes(i))
500 url =
urlmerge(file=file, var=dims(i))
501 overwrite_required = .true.
504 & hst % dimvars(i), trim(url), &
505 & dimsizes(i), xtype=trim(my_xtype), &
506 & overwrite=overwrite_required)
530 if (trim(institution) /=
"")
then
533 x_inst =
"a gtool_history (by GFD Dennou Club) user"
535 call put_attr(hst % dimvars(i),
'+Conventions', trim(x_conv))
537 call put_attr(hst % dimvars(i),
'+gt_version', trim(x_gtver))
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)
554 nullify(hst % vars, hst % growable_indices, hst % count)
557 if ( hst % unlimited_index == 0 )
then
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)
564 hst % unlimited_units_symbol = parsetimeunits( hst % unlimited_units )
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')
575 if (
present(interval) )
then
576 hst % interval = interval
577 elseif (
present(intervald) )
then
578 hst % interval = intervald
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.
590 hst % origin_setting = .false.
592 origin_str = trim(
tochar( hst % origin ) ) // &
593 &
' [' // trim( hst % unlimited_units ) //
']'
594 hst % newest = hst % origin
595 hst % oldest = hst % origin
599 hst % time_bnds = hst % origin
600 hst % time_bnds_output_count = 0
606 &
'"%c" is created (origin=%c)', &
607 & c1 = trim( file_work ), &
608 & c2 = trim( origin_str ), rank_mpi = -1 )
613 hst % initialized = .true.
615 call storeerror(stat, subname, err, cause_c=cause_c)
616 call endsub(subname,
'stat=%d', i = (/stat/) )
620 & file, title, source, institution, &
621 & dims, dimsizes, longnames, units, origin, interval, &
622 & xtypes, history, conventions, gt_version, overwrite, quiet, &
623 & flag_mpi_gather, flag_mpi_split, err )
656 use dc_date,
only: dcdatetimecreate, tochar, dcdifftimecreate, &
657 & evalbyunit, parsetimeunits
662 character(*),
intent(in):: file
665 character(*),
intent(in):: title
668 character(*),
intent(in):: source
671 character(*),
intent(in):: institution
674 character(*),
intent(in):: dims(:)
693 integer,
intent(in):: dimsizes (:)
721 character(*),
intent(in):: longnames (:)
741 character(*),
intent(in):: units(:)
803 character(*),
intent(in),
optional:: xtypes(:)
833 type(
gt_history),
intent(out),
optional,
target:: history
852 character(*),
intent(in),
optional:: conventions
871 character(*),
intent(in),
optional:: gt_version
893 logical,
intent(in),
optional:: overwrite
907 logical,
intent(in),
optional:: quiet
916 logical,
intent(in),
optional:: flag_mpi_gather
933 logical,
intent(in),
optional:: flag_mpi_split
955 logical,
intent(out),
optional:: err
970 real(DP):: origind, intervald
971 integer:: i, numdims, blank_index
972 character(TOKEN):: unlimited_units
973 integer:: unit_symbol
975 character(STRING):: cause_c
976 character(*),
parameter:: subname =
"HistoryCreate2"
977 character(*),
parameter:: version = &
979 &
'$Id: historycreate.rb2f90,v 1.4 2009-11-03 05:22:46 morikawa Exp $'
981 call beginsub(subname,
'file=%c ndims=%d', &
982 & c1=trim(file), i=(/
size(dims)/), &
987 unlimited_units =
'sec'
989 if (dimsizes(i) == 0) unlimited_units = units(i)
991 blank_index = index( trim( adjustl(unlimited_units) ),
' ' )
992 if ( blank_index > 1 )
then
993 unlimited_units = unlimited_units(1:blank_index-1)
995 unit_symbol = parsetimeunits( unlimited_units )
997 if (
present(interval))
then
998 intervald = evalbyunit( interval,
'', unit_symbol )
1002 origind = evalbyunit( origin,
'', unit_symbol )
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, &
1014 if (
present(history))
then
1019 call storeerror(stat, subname, cause_c=cause_c)
1020 call endsub(subname,
'stat=%d', i = (/stat/) )
1024 & axes, origin, interval, history, origind, intervald, conventions, gt_version, &
1025 & overwrite, quiet, flag_mpi_gather, flag_mpi_split, err )
1060 character(*),
intent(in):: file
1064 character(*),
intent(in):: title, source, institution
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
1088 logical,
intent(in),
optional:: flag_mpi_gather
1105 logical,
intent(in),
optional:: flag_mpi_split
1127 logical,
intent(out),
optional:: err
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(:)
1148 character(len = *),
parameter:: subname =
"HistoryCreate3"
1150 call beginsub(subname,
'file=%c ndims=%d', &
1151 & c1=trim(file), i=(/
size(axes)/) )
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) )
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) ) )
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, &
1188 deallocate( axes_name )
1189 deallocate( axes_length )
1190 deallocate( axes_longname )
1191 deallocate( axes_units )
1192 deallocate( axes_xtype )
1194 if ( .not.
associated( axes(i) % attrs ) ) cycle
1195 call append_attrs( axes(i) % name, axes(i) % attrs, history )
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 データ出力用初期設定
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 データ出力用初期設定
integer, parameter, public unit_symbol_err
無効な単位を示すシンボル
integer, parameter, public unit_symbol_sec
秒の単位を示すシンボル
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_ealreadyinit
integer, parameter, public dc_noerr
エラー等を保持
integer, parameter, public gt_eargsizemismatch
logical function, public present_and_false(arg)
logical function, public present_and_not_empty(arg)
logical function, public present_and_true(arg)
character(string) function, public joinchar(carray, expr)
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
integer, parameter, public dp
倍精度実数型変数
character(string), parameter, public gtool4_netcdf_version
character(string), parameter, public gtool4_netcdf_conventions
type(gt_history), target, save, public default
システムに依存する手続きのインタフェースを提供します
subroutine, public sysdepenvget(env, str)
環境変数を取得します