gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
historyclose.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine historyclose (history, quiet, err)

Function/Subroutine Documentation

◆ historyclose()

subroutine historyclose ( type(gt_history), intent(inout), optional, target history,
logical, intent(in), optional quiet,
logical, intent(out), optional err )

Definition at line 37 of file historyclose.f90.

38 !
42 use gtdata_generic, only: close, inquire
43 use gtdata_types, only: gt_variable
44 use dc_message, only: messagenotify
45 use dc_url, only: urlsplit
48 use dc_types, only: string, dp
51 implicit none
52 type(GT_HISTORY), intent(inout), optional, target:: history
53 ! 出力ファイルの設定に関する情報を
54 ! 格納した構造体
55 !
56 ! ここに指定するものは,
57 ! HistoryCreate によって初期設定
58 ! されていなければなりません.
59 !
60 logical, intent(in), optional:: quiet
61 ! .true. を与えた場合,
62 ! メッセージ出力が抑制されます.
63 !
64 ! If ".true." is given,
65 ! messages are suppressed.
66 !
67 logical, intent(out), optional:: err
68 ! 例外処理用フラグ.
69 ! デフォルトでは, この手続き内でエラーが
70 ! 生じた場合, プログラムは強制終了します.
71 ! 引数 *err* が与えられる場合,
72 ! プログラムは強制終了せず, 代わりに
73 ! *err* に .true. が代入されます.
74 !
75 ! Exception handling flag.
76 ! By default, when error occur in
77 ! this procedure, the program aborts.
78 ! If this *err* argument is given,
79 ! .true. is substituted to *err* and
80 ! the program does not abort.
81 type(GT_HISTORY), pointer:: hst =>null()
82 character(STRING):: url, file
83 integer:: i, v_size
84 integer:: stat
85 character(STRING):: cause_c
86 character(len = *), parameter:: subname = "HistoryClose"
87 continue
88 call beginsub(subname)
89 stat = dc_noerr
90 cause_c = ""
91 if (present(history)) then
92 hst => history
93 else
94 hst => default
95 endif
96 !-----------------------------------------------------------------
97 ! 初期設定のチェック
98 ! Check initialization
99 !-----------------------------------------------------------------
100 if ( .not. hst % initialized ) then
101 stat = dc_enotinit
102 cause_c = 'GT_HISTORY'
103 goto 999
104 end if
105 !-----------------------------------------------------------------
106 ! メッセージ出力用にファイル名取得
107 ! Get filename for output messages
108 !-----------------------------------------------------------------
109 if ( .not. hst % mpi_gather &
110 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
111 if ( .not. present_and_true(quiet) ) then
112 call inquire( hst % dimvars(1), & ! (in)
113 & url = url ) ! (out)
114 call urlsplit( fullname = url, & ! (in)
115 & file = file ) ! (out)
116 end if
117 endif
118 !-----------------------------------------------------------------
119 ! 変数のクローズ
120 ! Close variables
121 !-----------------------------------------------------------------
122 if ( .not. hst % mpi_gather &
123 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
124 v_size = size(hst % dimvars)
125 do, i = 1, v_size
126 if (.not. hst % dim_value_written(i)) &
127 call set_fake_dim_value(hst, i)
128 call close(hst % dimvars(i))
129 enddo
130 v_size = size(hst % vars)
131 do, i = 1, v_size
132 call close(hst % vars(i))
133 enddo
134 endif
135 deallocate(hst % dimvars)
136 v_size = size(hst % vars)
137 !-----------------------------------------------------------------
138 ! 設定のクリア
139 ! Clear configurations
140 !-----------------------------------------------------------------
141 hst % unlimited_index = 0
142 hst % unlimited_units = ''
143 hst % unlimited_units_symbol = unit_symbol_err
144 if (associated(hst % dim_value_written)) deallocate(hst % dim_value_written)
145 if (associated(hst % vars)) deallocate(hst % vars)
146 if (associated(hst % growable_indices)) deallocate(hst % growable_indices)
147 if (associated(hst % count)) deallocate(hst % count)
148 if (associated(hst % var_avr_count)) deallocate(hst % var_avr_count)
149 do, i = 1, v_size
150 if (associated(hst % var_avr_data(i) % a_DataAvr)) deallocate(hst % var_avr_data(i) % a_DataAvr)
151 enddo
152 if (associated(hst % var_avr_data)) deallocate(hst % var_avr_data)
153 if (associated(hst % var_avr_firstput)) deallocate(hst % var_avr_firstput)
154 if (associated(hst % var_avr_coefsum)) deallocate(hst % var_avr_coefsum)
155 if (associated(hst % var_avr_baseint)) deallocate(hst % var_avr_baseint)
156 if (associated(hst % var_avr_prevtime)) deallocate(hst % var_avr_prevtime)
157 hst % time_bnds = 0.0_dp
158 hst % time_bnds_output_count = 0
159 hst % time_nv_index = 0
160 hst % origin_setting = .false.
161 if ( associated( hst % mpi_fileinfo % axes ) ) deallocate( hst % mpi_fileinfo % axes )
162 if ( associated( hst % mpi_fileinfo ) ) deallocate( hst % mpi_fileinfo )
163 v_size = size(hst % mpi_dimdata_all)
164 do, i = 1, v_size
165 if ( associated( hst % mpi_dimdata_all(i) % a_Axis ) ) deallocate( hst % mpi_dimdata_all(i) % a_Axis )
166 if ( associated( hst % mpi_dimdata_all(i) % attrs ) ) deallocate( hst % mpi_dimdata_all(i) % attrs )
167 enddo
168 if ( associated( hst % mpi_dimdata_all ) ) deallocate( hst % mpi_dimdata_all )
169 v_size = size(hst % mpi_dimdata_each)
170 do, i = 1, v_size
171 if ( associated( hst % mpi_dimdata_each(i) % a_Axis ) ) deallocate( hst % mpi_dimdata_each(i) % a_Axis )
172 enddo
173 if ( associated( hst % mpi_dimdata_each ) ) deallocate( hst % mpi_dimdata_each )
174 if ( associated( hst % mpi_gthr_info ) ) then
175 v_size = size(hst % mpi_gthr_info)
176 do, i = 1, v_size
177 if ( associated( hst % mpi_gthr_info(i) % index_all ) ) deallocate( hst % mpi_gthr_info(i) % index_all )
178 if ( associated( hst % mpi_gthr_info(i) % length ) ) deallocate( hst % mpi_gthr_info(i) % length )
179 end do
180 deallocate( hst % mpi_gthr_info )
181 end if
182 if ( associated(hst % mpi_varinfo) ) then
183 v_size = size(hst % mpi_varinfo)
184 do, i = 1, v_size
185 call historyvarinfoclear( hst % mpi_varinfo(i), err )
186 end do
187 deallocate( hst % mpi_varinfo )
188 end if
189 if ( associated(hst % mpi_vars_index) ) then
190 v_size = size(hst % mpi_vars_index)
191 do, i = 1, v_size
192 if ( associated( hst % mpi_vars_index(i) % each2all ) ) deallocate( hst % mpi_vars_index(i) % each2all )
193 if ( associated( hst % mpi_vars_index(i) % allcount ) ) deallocate( hst % mpi_vars_index(i) % allcount )
194 end do
195 deallocate( hst % mpi_vars_index )
196 end if
197 !-----------------------------------------------------------------
198 ! メッセージ出力
199 ! Output messages
200 !-----------------------------------------------------------------
201 if ( .not. hst % mpi_gather &
202 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
203 if ( .not. present_and_true(quiet) ) then
204 call messagenotify('M', subname, &
205 & '"%c" is closed', &
206 & c1 = trim( file ), rank_mpi = -1 )
207 end if
208 endif
209 hst % mpi_myrank = -1
210 hst % mpi_nprocs = -1
211 hst % mpi_gather = .false.
212 hst % mpi_split = .false.
213 !-----------------------------------------------------------------
214 ! 終了処理, 例外処理
215 ! Termination and Exception handling
216 !-----------------------------------------------------------------
217 hst % initialized = .false.
218999 continue
219 call storeerror( stat, subname, err, cause_c )
220 call endsub( subname )
日付・時刻に関する構造データ型と定数
integer, parameter, public unit_symbol_err
無効な単位を示すシンボル
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_enotinit
-400 以下: dc ユーティリティのエラー
Definition dc_error.f90:534
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
メッセージの出力
省略可能な制御パラメータの判定
logical function, public present_and_true(arg)
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:680
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
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92
変数 URL の文字列解析
Definition dc_url.f90:61
type(gt_history), target, save, public default

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_error::dc_enotinit, dc_error::dc_noerr, gtool_history_internal::default, dc_types::dp, dc_trace::endsub(), dc_present::present_and_true(), dc_error::storeerror(), dc_types::string, and dc_date_types::unit_symbol_err.

Here is the call graph for this function: