38
51 implicit none
52 type(GT_HISTORY), intent(inout), optional, target:: history
53
54
55
56
57
58
59
60 logical, intent(in), optional:: quiet
61
62
63
64
65
66
67 logical, intent(out), optional:: err
68
69
70
71
72
73
74
75
76
77
78
79
80
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
90 cause_c = ""
91 if (present(history)) then
92 hst => history
93 else
95 endif
96
97
98
99
100 if ( .not. hst % initialized ) then
102 cause_c = 'GT_HISTORY'
103 goto 999
104 end if
105
106
107
108
109 if ( .not. hst % mpi_gather &
110 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
112 call inquire( hst % dimvars(1), &
113 & url = url )
115 & file = file )
116 end if
117 endif
118
119
120
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)) &
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
140
141 hst % unlimited_index = 0
142 hst % unlimited_units = ''
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
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
200
201 if ( .not. hst % mpi_gather &
202 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
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
216
217 hst % initialized = .false.
218999 continue
219 call storeerror( stat, subname, err, cause_c )
integer, parameter, public unit_symbol_err
無効な単位を示すシンボル
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_enotinit
-400 以下: dc ユーティリティのエラー
integer, parameter, public dc_noerr
エラー等を保持
logical function, public present_and_true(arg)
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 string
文字列を保持する 文字型変数の種別型パラメタ
integer, parameter, public dp
倍精度実数型変数
type(gt_history), target, save, public default