8
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
9
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
10
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
11
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
12
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
13
integer, parameter, private :: BUD_ID_LEn = 36
14
character(len=*), parameter, private :: &
15
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
16
character(len=*), parameter, private :: &
19
type(iD1D_CSC_), pointer :: D => null()
26
character(len=BUD_ID_LEN) :: id_ = "null_id"
30
module procedure new_data_
33
interface assignment(=)
34
module procedure get_elem1_assign_
35
module procedure get_elem2_assign_
36
module procedure set_elem1_
37
module procedure set_elem2_
40
module procedure get_elem1_
41
module procedure get_elem2_
44
module procedure set_elem1_
45
module procedure set_elem2_
48
module procedure get_elem1_
51
interface set_element1
52
module procedure set_elem1_
54
public :: set_element1
56
module procedure get_elem1p_
60
module procedure get_elem2_
63
interface set_element2
64
module procedure set_elem2_
66
public :: set_element2
68
module procedure get_elem2p_
73
interface assignment(=)
74
module procedure common_assign_
76
public :: assignment(=)
77
private :: common_assign_
79
module procedure common_initialize_
82
private :: common_initialize_
83
interface is_initialized
84
module procedure common_is_initialized_
86
public :: is_initialized
87
private :: common_is_initialized_
89
module procedure common_is_initialized_
93
module procedure common_is_initialized_
97
module procedure common_is_same_
100
private :: common_is_same_
102
module procedure common_is_same_
106
module procedure common_delete_
109
private :: common_delete_
111
module procedure common_nullify_
114
private :: common_nullify_
116
module procedure copy_
119
private :: common_copy_
121
module procedure print_
125
module procedure read_
129
module procedure write_
133
module procedure common_references_
136
private :: common_references_
138
module procedure common_references_
142
module procedure common_set_error_is_
143
module procedure common_set_error_ii_
144
module procedure common_set_error_il_
147
private :: common_set_error_is_
148
private :: common_set_error_ii_
149
private :: common_set_error_il_
151
module procedure common_error_
154
private :: common_error_
156
subroutine common_copy_(from, to)
157
type(iD1D_CSC), intent(in) :: from
158
type(iD1D_CSC), intent(inout) :: to
159
call set_error(to, error(from))
160
end subroutine common_copy_
161
subroutine common_initialize_(this)
162
type(iD1D_CSC), intent(inout) :: this
165
allocate(this%D, stat=error)
166
call set_error(this, error)
167
if ( error /= 0 ) return
169
call common_tag_object_(this)
170
end subroutine common_initialize_
171
pure function common_is_initialized_(this) result(init)
172
type(iD1D_CSC), intent(in) :: this
174
init = associated(this%D)
175
end function common_is_initialized_
176
elemental function common_is_same_(lhs, rhs) result(same)
177
type(iD1D_CSC), intent(in) :: lhs, rhs
179
same = is_initd(lhs) .and. is_initd(rhs)
180
if ( .not. same ) return
181
same = associated(lhs%D, target=rhs%D)
182
end function common_is_same_
183
subroutine common_delete_(this)
184
type(iD1D_CSC), intent(inout) :: this
186
call set_error(this, 0)
187
if (.not. is_initd(this) ) return
188
this%D%refs_ = this%D%refs_ - 1
189
if ( 0 == this%D%refs_ ) then
191
deallocate(this%D, stat=error)
192
call set_error(this, error)
195
end subroutine common_delete_
196
elemental subroutine common_nullify_(this)
197
type(iD1D_CSC), intent(inout) :: this
198
if (.not. is_initd(this) ) return
200
end subroutine common_nullify_
201
subroutine common_assign_(lhs, rhs)
202
type(iD1D_CSC), intent(inout) :: lhs
203
type(iD1D_CSC), intent(in) :: rhs
205
if ( .not. is_initd(rhs) ) return
207
lhs%D%refs_ = rhs%D%refs_ + 1
208
end subroutine common_assign_
209
elemental function common_references_(this) result(refs)
210
type(iD1D_CSC), intent(in) :: this
212
if ( is_initd(this) ) then
217
end function common_references_
218
elemental function common_error_(this) result(error)
219
type(iD1D_CSC), intent(in) :: this
221
if ( is_initd(this) ) then
226
end function common_error_
227
elemental subroutine common_set_error_is_(this, error)
228
type(iD1D_CSC), intent(inout) :: this
229
integer(is_), intent(in) :: error
231
end subroutine common_set_error_is_
232
elemental subroutine common_set_error_ii_(this, error)
233
type(iD1D_CSC), intent(inout) :: this
234
integer(ii_), intent(in) :: error
236
end subroutine common_set_error_ii_
237
elemental subroutine common_set_error_il_(this, error)
238
type(iD1D_CSC), intent(inout) :: this
239
integer(il_), intent(in) :: error
241
end subroutine common_set_error_il_
242
elemental function common_id_(this) result(str)
243
type(iD1D_CSC), intent(in) :: this
244
character(len=BUD_ID_LEn) :: str
246
end function common_id_
247
subroutine common_tag_object_(this)
248
type(iD1D_CSC), intent(inout) :: this
249
end subroutine common_tag_object_
250
subroutine delete_(this)
251
type(iD1D_CSC), intent(inout) :: this
252
call set_error(this, 0)
253
call delete(this%D%e1)
254
if ( 0 /= error(this%D%e1) ) &
255
call set_error(this, error(this%D%e1))
256
call delete(this%D%e2)
257
if ( 0 /= error(this%D%e2) ) &
258
call set_error(this, error(this%D%e2))
259
end subroutine delete_
260
subroutine copy_(from, to)
261
type(iD1D_CSC), intent(in) :: from
262
type(iD1D_CSC), intent(inout) :: to
264
if ( .not. is_initd(from) ) return
266
call common_copy_(from, to)
267
call copy(from%D%e1, to%D%e1)
268
call copy(from%D%e2, to%D%e2)
270
subroutine new_data_(this, a, b &
272
type(iD1D_CSC), intent(inout) :: this
273
type(iDist1D), intent(inout) :: a
274
type(iSM_CSC), intent(inout) :: b
278
end subroutine new_data_
279
subroutine new_(this)
280
type(iD1D_CSC), intent(inout) :: this
281
call initialize(this)
283
subroutine get_elem1_(this, item)
284
type(iD1D_CSC), intent(in) :: this
285
type(iDist1D), intent(inout) :: item
286
if ( .not. is_initd(this) ) then
292
subroutine get_elem1_assign_(item, this)
293
type(iDist1D), intent(inout) :: item
294
type(iD1D_CSC), intent(in) :: this
295
if ( .not. is_initd(this) ) then
301
subroutine set_elem1_(this, item)
302
type(iD1D_CSC), intent(inout) :: this
303
type(iDist1D), intent(in) :: item
304
if ( .not. is_initd(this) ) return
307
function get_elem1p_(this) result(p)
308
type(iD1D_CSC), intent(inout) :: this
309
type(iDist1D), pointer :: p
310
if ( .not. is_initd(this) ) then
316
subroutine get_elem2_(this, item)
317
type(iD1D_CSC), intent(in) :: this
318
type(iSM_CSC), intent(inout) :: item
319
if ( .not. is_initd(this) ) then
325
subroutine get_elem2_assign_(item, this)
326
type(iSM_CSC), intent(inout) :: item
327
type(iD1D_CSC), intent(in) :: this
328
if ( .not. is_initd(this) ) then
334
subroutine set_elem2_(this, item)
335
type(iD1D_CSC), intent(inout) :: this
336
type(iSM_CSC), intent(in) :: item
337
if ( .not. is_initd(this) ) return
340
function get_elem2p_(this) result(p)
341
type(iD1D_CSC), intent(inout) :: this
342
type(iSM_CSC), pointer :: p
343
if ( .not. is_initd(this) ) then
349
subroutine print_(this, info, indent)
350
type(iD1D_CSC), intent(in) :: this
351
character(len=*), intent(in), optional :: info
352
integer, intent(in), optional :: indent
354
character(len=32) :: fmt
355
character(len=256) :: name
357
if ( present(info) ) name = info
359
if ( present(indent) ) lindent = indent
360
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
361
if ( .not. is_initd(this) ) then
362
write(*,fmt) "<", trim(name), " not initialized>"
365
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
366
lindent = lindent + 2 ! step indentation
367
write(*,fmt) "<<", trim(name), " coll>"
368
call print(this%D%e1, indent = lindent)
369
call print(this%D%e2, indent = lindent)
370
lindent = lindent - 2 ! go back to requested indentation
371
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
372
write(*,fmt) " <coll-refs: ", references(this), ">>"
373
end subroutine print_
374
subroutine write_(f, this)
376
type( File ), intent(inout) :: f
377
type(iD1D_CSC), intent(in) :: this
378
type( MP_Comm ) :: comm
379
type(iDist1D) :: dist
381
logical :: formatted, do_io
382
integer :: iu, io_rank
383
integer(ii_) :: nr, nc, nz
384
integer(ii_) :: gnr, gnc, gnl, gnz
385
integer(ii_) :: ir, il, ig, i, ic
386
integer(ii_), pointer :: ptr(:), nrc(:), indx(:)
387
integer(ii_), allocatable :: data(:)
388
if ( .not. is_initd(this) ) return
393
end subroutine write_
394
subroutine read_(f, dist, this)
396
type( File ), intent(inout) :: f
397
type(iDist1D) :: dist
398
type(iD1D_CSC), intent(inout) :: this
399
type( MP_Comm ) :: comm
401
logical :: formatted, do_io, sorted
402
integer :: iu, io_rank, my_rank
403
integer(ii_) :: nr, nc, nz, nl
404
integer(ii_) :: gnr, gnc, gnz, gnl
405
integer(ii_) :: ir, il, ig
406
integer(ii_), pointer :: ptr(:), nrc(:), indx(:)
407
integer(ii_), allocatable :: data(:), idx(:)
408
if ( .not. is_open(f) ) return
411
call new(this, dist, sm)
416
module bud_Dist1D_CSC