gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
historycopy.f90
Go to the documentation of this file.
1!> @file historycopy.F
2!>
3!> @author Yasuhiro MORIKAWA
4!> @copyright Copyright (C) GFD Dennou Club, 2004-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Copy configurations of output
9!> @enden
10!>
11!> @ja
12!> @brief 出力設定のコピー
13!> @endja
14!>
15!> @en
16!> @brief Copy output configurations
17!>
18!> Copies the contents of hist_src and returns them in hist_dest.
19!> If hist_src is not given, the settings of HistoryCreate called
20!> without the history argument are referenced.
21!> Like HistoryCreate, this performs initial output settings.
22!> file must always be given; attempting to output to the same file
23!> as hist_src causes an error.
24!> Settings made by HistoryAddVariable are not copied.
25!> Arguments after file can override settings from hist_src.
26!> @param[out] hist_dest Destination history structure
27!> @param[in] file Output file name
28!> @param[in] hist_src Source history structure (optional)
29!> @param[in] title Title (optional, override)
30!> @param[in] source Source (optional, override)
31!> @param[in] institution Institution (optional, override)
32!> @param[in] origin Origin time (optional, override)
33!> @param[in] interval Output interval (optional, override)
34!> @param[in] conventions Conventions (optional, override)
35!> @param[in] gt_version gt_version (optional, override)
36!> @enden
37!>
38!> @ja
39!> @brief 出力設定のコピー
40!>
41!> 引数 hist_src の内容をコピーし、hist_dest へ返します。
42!> hist_src が与えられない場合は、引数 history を与えずに呼び出した
43!> HistoryCreate の設定内容が参照されます。
44!> HistoryCreate と同様に、出力の初期設定を行います。
45!> file は必ず与えなければならず、hist_src と同じファイルへ出力
46!> しようとする場合はエラーを生じます。
47!> HistoryAddVariable で設定される内容に関してはコピーされません。
48!> それ以降の引数を与えることで、hist_src の設定を上書きできます。
49!> @param[out] hist_dest コピー先ヒストリー構造体
50!> @param[in] file 出力ファイル名
51!> @param[in] hist_src コピー元ヒストリー構造体 (省略可能)
52!> @param[in] title タイトル (省略可能, 上書き)
53!> @param[in] source ソース (省略可能, 上書き)
54!> @param[in] institution 組織 (省略可能, 上書き)
55!> @param[in] origin 開始時間 (省略可能, 上書き)
56!> @param[in] interval 出力時間間隔 (省略可能, 上書き)
57!> @param[in] conventions 規約 (省略可能, 上書き)
58!> @param[in] gt_version gtバージョン (省略可能, 上書き)
59!> @endja
60!>
61 subroutine historycopy1(hist_dest, file, hist_src, &
62 & title, source, institution, &
63 & origin, interval, &
64 & conventions, gt_version)
65 !
68 use gtdata_generic, only: copy_attr, get
69 use dc_present, only: present_select
70 use dc_types, only: string, dp, dp_eps
71 use dc_trace, only: beginsub, endsub
73 implicit none
74 type(gt_history), intent(out), target:: hist_dest
75 character(*), intent(in):: file
76 type(gt_history), intent(in), optional, target:: hist_src
77 character(*), intent(in), optional:: title, source, institution
78 real, intent(in), optional:: origin, interval
79 character(*), intent(in), optional:: conventions, gt_version
80 ! Internal Work
81 type(gt_history), pointer:: src =>null()
82 character(STRING) :: title_src, source_src, institution_src
83 character(STRING) :: conventions_src, gt_version_src
84 character(STRING), pointer:: dims(:) => null()
85 integer , pointer:: dimsizes(:) => null()
86 character(STRING), pointer:: longnames(:) => null()
87 character(STRING), pointer:: units(:) => null()
88 character(STRING), pointer:: xtypes(:) => null()
89 real(DP):: originw, intervalw
90 integer :: i, numdims
91 logical :: err
92 real(DP),pointer :: dimvalue(:) => null()
93 character(len = *),parameter:: subname = "HistoryCopy1"
94 continue
95 call beginsub(subname, 'file=<%c>', c1=trim(file))
96 if (present(hist_src)) then
97 src => hist_src
98 else
99 src => default
100 endif
101 numdims = size(src % dimvars)
102 call historyinquire(history=src, title=title_src, &
103 & source=source_src, institution=institution_src, &
104 & dims=dims, dimsizes=dimsizes, longnames=longnames, &
105 & units=units, xtypes=xtypes, &
106 & conventions=conventions_src, gt_version=gt_version_src)
107 if ( present(origin) ) then
108 originw = real(origin, kind(originw))
109 else
110 originw = real(src % origin, kind(originw))
111! originw = EvalByUnit( src % origin, '', src % unlimited_units_symbol )
112 end if
113 intervalw = src % interval
114! intervalw = EvalByUnit( src % interval, '', src % unlimited_units_symbol )
115 if ( present(interval) ) then
116 if ( abs(real(interval, kind(intervalw))) > dp_eps ) then
117 intervalw = real(interval, kind(intervalw))
118 end if
119 end if
120 call historycreate(file=trim(file), &
121 & title=trim(present_select('', title_src, title)), &
122 & source=trim(present_select('', source_src, source)), &
123 & institution=trim(present_select('', institution_src, institution)), &
124 & dims=dims, dimsizes=dimsizes, longnames=longnames, units=units, &
125 & origind=originw, intervald=intervalw, &
126 & xtypes=xtypes, &
127 & history=hist_dest, &
128 & conventions=trim(present_select('', conventions_src, conventions)), &
129 & gt_version=trim(present_select('', gt_version_src, gt_version)) )
130 !
131 ! 次元変数が属性を持っている場合のことも考え, 最後に直接
132 ! hist_dst % dimvars へ copy_attr (gtvarcopyattrall) をかける.
133 !
134 do i = 1, numdims
135 call copy_attr(hist_dest % dimvars(i), src % dimvars (i), global=.false.)
136 end do
137 ! dimvars を Get してみて, 値を持っているようならデータを与えてしまう.
138 do i = 1, numdims
139 if (dimsizes(i) == 0) cycle
140 call get(src % dimvars(i), dimvalue, err)
141 if (err) cycle
142 call historyput(dims(i), dimvalue, hist_dest)
143 deallocate(dimvalue)
144 end do
145 deallocate(dims, dimsizes, longnames, units, xtypes)
146 call endsub(subname)
147 end subroutine historycopy1
148 !-------------------------------------------------------------------
149!> @en
150 !> @brief Copy output configurations (generic interface)
151 !>
152 !> Usage is same as HistoryCopy.
153 !> @enden
154 !> @ja
155 !> @brief 出力設定のコピー (総称インターフェース)
156 !>
157 !> 使用方法は HistoryCopy と同様です。
158 !> @endja
159 subroutine historycopy2(hist_dest, file, hist_src, &
160 & title, source, institution, &
161 & origin, interval, &
162 & conventions, gt_version)
163 use dc_trace, only: beginsub, endsub
166 implicit none
167 type(gt_history), intent(out), target:: hist_dest
168 character(*), intent(in):: file
169 type(gt_history), intent(in), optional, target:: hist_src
170 character(*), intent(in), optional:: title, source, institution
171 real, intent(in), optional:: origin, interval
172 character(*), intent(in), optional:: conventions, gt_version
173 ! Internal Work
174 character(len = *),parameter:: subname = "HistoryCopy2"
175 continue
176 call beginsub(subname, 'file=<%c>', c1=trim(file))
177 call historycopy(hist_dest, file, hist_src, &
178 & title, source, institution, &
179 & origin, interval, &
180 & conventions, gt_version)
181 call endsub(subname)
182 end subroutine historycopy2
subroutine historycopy1(hist_dest, file, hist_src, title, source, institution, origin, interval, conventions, gt_version)
subroutine historycopy2(hist_dest, file, hist_src, title, source, institution, origin, interval, conventions, gt_version)
Judge optional control parameters.
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
real(dp), parameter, public dp_eps
Machine epsilon for dobule precision real number.
Definition dc_types.f90:97
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92
type(gt_history), target, save, public default