6
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
7
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
8
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
9
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
10
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
11
integer, parameter, private :: BUD_ID_LEn = 36
12
character(len=*), parameter, private :: &
13
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
14
character(len=*), parameter, private :: &
15
BUD_TYPe = "iCSR_C_b1D"
16
integer(ii_), parameter :: ONE = 1_ii_
17
integer(ii_), parameter :: ZERO = 0_ii_
19
module procedure matrix_p_
20
module procedure matrix_ip_
21
module procedure matrix_lp_
24
interface sparse_matrix
25
module procedure get_elem1_
27
public :: sparse_matrix
28
interface sparse_matrix_p
29
module procedure get_elem1p_
31
public :: sparse_matrix_p
32
interface sparse_index
33
module procedure sparse_index_
35
public :: sparse_index
37
module procedure dimensions_
41
module procedure get_elem2_
45
module procedure get_elem2p_
49
module procedure add_element_
53
type(iCSR_C_b1D_), pointer :: D => null()
60
character(len=BUD_ID_LEN) :: id_ = "null_id"
64
module procedure new_data_
67
interface assignment(=)
68
module procedure get_elem1_assign_
69
module procedure get_elem2_assign_
70
module procedure set_elem1_
71
module procedure set_elem2_
74
module procedure get_elem1_
75
module procedure get_elem2_
78
module procedure set_elem1_
79
module procedure set_elem2_
82
module procedure get_elem1_
85
interface set_element1
86
module procedure set_elem1_
88
public :: set_element1
90
module procedure get_elem1p_
94
module procedure get_elem2_
97
interface set_element2
98
module procedure set_elem2_
100
public :: set_element2
102
module procedure get_elem2p_
106
private :: iCSR_C_b1D_
107
interface assignment(=)
108
module procedure common_assign_
110
public :: assignment(=)
111
private :: common_assign_
113
module procedure common_initialize_
116
private :: common_initialize_
117
interface is_initialized
118
module procedure common_is_initialized_
120
public :: is_initialized
121
private :: common_is_initialized_
122
interface initialized
123
module procedure common_is_initialized_
125
public :: initialized
127
module procedure common_is_initialized_
131
module procedure common_is_same_
134
private :: common_is_same_
136
module procedure common_is_same_
140
module procedure common_delete_
143
private :: common_delete_
145
module procedure common_nullify_
148
private :: common_nullify_
150
module procedure copy_
153
private :: common_copy_
155
module procedure print_
159
module procedure read_
163
module procedure write_
167
module procedure common_references_
170
private :: common_references_
172
module procedure common_references_
176
module procedure common_set_error_is_
177
module procedure common_set_error_ii_
178
module procedure common_set_error_il_
181
private :: common_set_error_is_
182
private :: common_set_error_ii_
183
private :: common_set_error_il_
185
module procedure common_error_
188
private :: common_error_
190
subroutine common_copy_(from, to)
191
type(iCSR_C_b1D), intent(in) :: from
192
type(iCSR_C_b1D), intent(inout) :: to
193
call set_error(to, error(from))
194
end subroutine common_copy_
195
subroutine common_initialize_(this)
196
type(iCSR_C_b1D), intent(inout) :: this
199
allocate(this%D, stat=error)
200
call set_error(this, error)
201
if ( error /= 0 ) return
203
call common_tag_object_(this)
204
end subroutine common_initialize_
205
pure function common_is_initialized_(this) result(init)
206
type(iCSR_C_b1D), intent(in) :: this
208
init = associated(this%D)
209
end function common_is_initialized_
210
elemental function common_is_same_(lhs, rhs) result(same)
211
type(iCSR_C_b1D), intent(in) :: lhs, rhs
213
same = is_initd(lhs) .and. is_initd(rhs)
214
if ( .not. same ) return
215
same = associated(lhs%D, target=rhs%D)
216
end function common_is_same_
217
subroutine common_delete_(this)
218
type(iCSR_C_b1D), intent(inout) :: this
220
call set_error(this, 0)
221
if (.not. is_initd(this) ) return
222
this%D%refs_ = this%D%refs_ - 1
223
if ( 0 == this%D%refs_ ) then
225
deallocate(this%D, stat=error)
226
call set_error(this, error)
229
end subroutine common_delete_
230
elemental subroutine common_nullify_(this)
231
type(iCSR_C_b1D), intent(inout) :: this
232
if (.not. is_initd(this) ) return
234
end subroutine common_nullify_
235
subroutine common_assign_(lhs, rhs)
236
type(iCSR_C_b1D), intent(inout) :: lhs
237
type(iCSR_C_b1D), intent(in) :: rhs
239
if ( .not. is_initd(rhs) ) return
241
lhs%D%refs_ = rhs%D%refs_ + 1
242
end subroutine common_assign_
243
elemental function common_references_(this) result(refs)
244
type(iCSR_C_b1D), intent(in) :: this
246
if ( is_initd(this) ) then
251
end function common_references_
252
elemental function common_error_(this) result(error)
253
type(iCSR_C_b1D), intent(in) :: this
255
if ( is_initd(this) ) then
260
end function common_error_
261
elemental subroutine common_set_error_is_(this, error)
262
type(iCSR_C_b1D), intent(inout) :: this
263
integer(is_), intent(in) :: error
265
end subroutine common_set_error_is_
266
elemental subroutine common_set_error_ii_(this, error)
267
type(iCSR_C_b1D), intent(inout) :: this
268
integer(ii_), intent(in) :: error
270
end subroutine common_set_error_ii_
271
elemental subroutine common_set_error_il_(this, error)
272
type(iCSR_C_b1D), intent(inout) :: this
273
integer(il_), intent(in) :: error
275
end subroutine common_set_error_il_
276
elemental function common_id_(this) result(str)
277
type(iCSR_C_b1D), intent(in) :: this
278
character(len=BUD_ID_LEn) :: str
280
end function common_id_
281
subroutine common_tag_object_(this)
282
type(iCSR_C_b1D), intent(inout) :: this
283
end subroutine common_tag_object_
284
subroutine delete_(this)
285
type(iCSR_C_b1D), intent(inout) :: this
286
call set_error(this, 0)
287
call delete(this%D%e1)
288
if ( 0 /= error(this%D%e1) ) &
289
call set_error(this, error(this%D%e1))
290
call delete(this%D%e2)
291
if ( 0 /= error(this%D%e2) ) &
292
call set_error(this, error(this%D%e2))
293
end subroutine delete_
294
subroutine copy_(from, to)
295
type(iCSR_C_b1D), intent(in) :: from
296
type(iCSR_C_b1D), intent(inout) :: to
298
if ( .not. is_initd(from) ) return
300
call common_copy_(from, to)
301
call copy(from%D%e1, to%D%e1)
302
call copy(from%D%e2, to%D%e2)
304
subroutine new_data_(this, a, b &
306
type(iCSR_C_b1D), intent(inout) :: this
307
type(iSM_CSR_C), intent(inout) :: a
308
type(bArray1D), intent(inout) :: b
312
end subroutine new_data_
313
subroutine new_(this)
314
type(iCSR_C_b1D), intent(inout) :: this
315
call initialize(this)
317
subroutine get_elem1_(this, item)
318
type(iCSR_C_b1D), intent(in) :: this
319
type(iSM_CSR_C), intent(inout) :: item
320
if ( .not. is_initd(this) ) then
326
subroutine get_elem1_assign_(item, this)
327
type(iSM_CSR_C), intent(inout) :: item
328
type(iCSR_C_b1D), intent(in) :: this
329
if ( .not. is_initd(this) ) then
335
subroutine set_elem1_(this, item)
336
type(iCSR_C_b1D), intent(inout) :: this
337
type(iSM_CSR_C), intent(in) :: item
338
if ( .not. is_initd(this) ) return
341
function get_elem1p_(this) result(p)
342
type(iCSR_C_b1D), intent(inout) :: this
343
type(iSM_CSR_C), pointer :: p
344
if ( .not. is_initd(this) ) then
350
subroutine get_elem2_(this, item)
351
type(iCSR_C_b1D), intent(in) :: this
352
type(bArray1D), intent(inout) :: item
353
if ( .not. is_initd(this) ) then
359
subroutine get_elem2_assign_(item, this)
360
type(bArray1D), intent(inout) :: item
361
type(iCSR_C_b1D), intent(in) :: this
362
if ( .not. is_initd(this) ) then
368
subroutine set_elem2_(this, item)
369
type(iCSR_C_b1D), intent(inout) :: this
370
type(bArray1D), intent(in) :: item
371
if ( .not. is_initd(this) ) return
374
function get_elem2p_(this) result(p)
375
type(iCSR_C_b1D), intent(inout) :: this
376
type(bArray1D), pointer :: p
377
if ( .not. is_initd(this) ) then
383
subroutine print_(this, info, indent)
384
type(iCSR_C_b1D), intent(in) :: this
385
character(len=*), intent(in), optional :: info
386
integer, intent(in), optional :: indent
388
character(len=32) :: fmt
389
character(len=256) :: name
391
if ( present(info) ) name = info
393
if ( present(indent) ) lindent = indent
394
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
395
if ( .not. is_initd(this) ) then
396
write(*,fmt) "<", trim(name), " not initialized>"
399
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
400
lindent = lindent + 2 ! step indentation
401
write(*,fmt) "<<", trim(name), " coll>"
402
call print(this%D%e1, indent = lindent)
403
call print(this%D%e2, indent = lindent)
404
lindent = lindent - 2 ! go back to requested indentation
405
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
406
write(*,fmt) " <coll-refs: ", references(this), ">>"
407
end subroutine print_
408
function matrix_p_(this) result(p)
409
type(iCSR_C_b1D), intent(in) :: this
410
logical, pointer :: p (:)
411
p => array_p(this%D%e2)
412
end function matrix_p_
413
function matrix_ip_(this, i) result(p)
414
type(iCSR_C_b1D), intent(in) :: this
415
logical, pointer :: p (:)
416
integer(ii_), intent(in) :: i
417
p => array_p(this%D%e2)
418
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
419
end function matrix_ip_
420
function matrix_lp_(this, i) result(p)
421
type(iCSR_C_b1D), intent(in) :: this
422
logical, pointer :: p (:)
423
integer(il_), intent(in) :: i
424
p => array_p(this%D%e2)
425
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
426
end function matrix_lp_
427
function sparse_index_(this) result(idx)
428
type(iCSR_C_b1D), intent(in) :: this
431
end function sparse_index_
432
pure function dimensions_(this) result(d)
433
type(iCSR_C_b1D), intent(in) :: this
435
if ( is_initd(this) ) then
440
end function dimensions_
441
recursive subroutine add_element_(this, ir, ic, val)
442
type(iCSR_C_b1D), intent(inout) :: this
443
integer(ii_), intent(in) :: ir, ic
444
logical, intent(in) :: val
445
type(iSM_CSR_C) :: sm
446
type(iCSR_C_b1D) :: nthis
447
integer(ii_) :: i, c, ix, nr, nc, npc
448
logical, pointer :: p (:)
449
if ( .not. is_initd(this) ) return
451
call add_element(sm, ir, ic, dry_run = .true.)
452
if ( error(sm) /= 0 ) then
454
call set_error(this, -1)
457
call add_element(sm, ir, ic)
458
i = index(sm, ir, ic)
460
select case ( sparse_index(this) )
467
end subroutine add_element_
468
subroutine write_(f, this, only_array)
470
type( File ), intent(inout) :: f
471
type(iCSR_C_b1D), intent(inout) :: this
472
logical, intent(in), optional :: only_array
473
type(iSM_CSR_C) :: sm
474
type(bArray1D) :: arr
475
logical :: lonly_array
476
if ( .not. is_open(f) ) return
477
if ( .not. is_initd(this) ) return
478
lonly_array = .false.
479
if ( present(only_array) ) lonly_array = only_array
482
if ( .not. is_finalized(sm) ) then
485
call set_error(this, -1)
488
if ( .not. lonly_array ) then
494
end subroutine write_
495
subroutine read_(f, this, sm)
497
type( File ), intent(inout) :: f
498
type(iCSR_C_b1D), intent(inout) :: this
499
type(iSM_CSR_C), intent(inout), optional :: sm
500
type(iSM_CSR_C) :: lsm
501
type(bArray1D) :: arr
502
if ( .not. is_open(f) ) return
503
if ( present(sm) ) then
509
call new(this, lsm, arr)
513
module bud_iCSR_C_r1D
518
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
519
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
520
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
521
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
522
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
523
integer, parameter, private :: BUD_ID_LEn = 36
524
character(len=*), parameter, private :: &
525
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
526
character(len=*), parameter, private :: &
527
BUD_TYPe = "iCSR_C_r1D"
528
integer(ii_), parameter :: ONE = 1_ii_
529
integer(ii_), parameter :: ZERO = 0_ii_
531
module procedure matrix_p_
532
module procedure matrix_ip_
533
module procedure matrix_lp_
536
interface sparse_matrix
537
module procedure get_elem1_
539
public :: sparse_matrix
540
interface sparse_matrix_p
541
module procedure get_elem1p_
543
public :: sparse_matrix_p
544
interface sparse_index
545
module procedure sparse_index_
547
public :: sparse_index
549
module procedure dimensions_
553
module procedure get_elem2_
557
module procedure get_elem2p_
560
interface add_element
561
module procedure add_element_
563
public :: add_element
565
type(iCSR_C_r1D_), pointer :: D => null()
566
integer :: error_ = 0
569
type(iSM_CSR_C) :: e1
572
character(len=BUD_ID_LEN) :: id_ = "null_id"
575
module procedure new_
576
module procedure new_data_
579
interface assignment(=)
580
module procedure get_elem1_assign_
581
module procedure get_elem2_assign_
582
module procedure set_elem1_
583
module procedure set_elem2_
586
module procedure get_elem1_
587
module procedure get_elem2_
589
interface set_element
590
module procedure set_elem1_
591
module procedure set_elem2_
594
module procedure get_elem1_
597
interface set_element1
598
module procedure set_elem1_
600
public :: set_element1
602
module procedure get_elem1p_
606
module procedure get_elem2_
609
interface set_element2
610
module procedure set_elem2_
612
public :: set_element2
614
module procedure get_elem2p_
618
private :: iCSR_C_r1D_
619
interface assignment(=)
620
module procedure common_assign_
622
public :: assignment(=)
623
private :: common_assign_
625
module procedure common_initialize_
628
private :: common_initialize_
629
interface is_initialized
630
module procedure common_is_initialized_
632
public :: is_initialized
633
private :: common_is_initialized_
634
interface initialized
635
module procedure common_is_initialized_
637
public :: initialized
639
module procedure common_is_initialized_
643
module procedure common_is_same_
646
private :: common_is_same_
648
module procedure common_is_same_
652
module procedure common_delete_
655
private :: common_delete_
657
module procedure common_nullify_
660
private :: common_nullify_
662
module procedure copy_
665
private :: common_copy_
667
module procedure print_
671
module procedure read_
675
module procedure write_
679
module procedure common_references_
682
private :: common_references_
684
module procedure common_references_
688
module procedure common_set_error_is_
689
module procedure common_set_error_ii_
690
module procedure common_set_error_il_
693
private :: common_set_error_is_
694
private :: common_set_error_ii_
695
private :: common_set_error_il_
697
module procedure common_error_
700
private :: common_error_
702
subroutine common_copy_(from, to)
703
type(iCSR_C_r1D), intent(in) :: from
704
type(iCSR_C_r1D), intent(inout) :: to
705
call set_error(to, error(from))
706
end subroutine common_copy_
707
subroutine common_initialize_(this)
708
type(iCSR_C_r1D), intent(inout) :: this
711
allocate(this%D, stat=error)
712
call set_error(this, error)
713
if ( error /= 0 ) return
715
call common_tag_object_(this)
716
end subroutine common_initialize_
717
pure function common_is_initialized_(this) result(init)
718
type(iCSR_C_r1D), intent(in) :: this
720
init = associated(this%D)
721
end function common_is_initialized_
722
elemental function common_is_same_(lhs, rhs) result(same)
723
type(iCSR_C_r1D), intent(in) :: lhs, rhs
725
same = is_initd(lhs) .and. is_initd(rhs)
726
if ( .not. same ) return
727
same = associated(lhs%D, target=rhs%D)
728
end function common_is_same_
729
subroutine common_delete_(this)
730
type(iCSR_C_r1D), intent(inout) :: this
732
call set_error(this, 0)
733
if (.not. is_initd(this) ) return
734
this%D%refs_ = this%D%refs_ - 1
735
if ( 0 == this%D%refs_ ) then
737
deallocate(this%D, stat=error)
738
call set_error(this, error)
741
end subroutine common_delete_
742
elemental subroutine common_nullify_(this)
743
type(iCSR_C_r1D), intent(inout) :: this
744
if (.not. is_initd(this) ) return
746
end subroutine common_nullify_
747
subroutine common_assign_(lhs, rhs)
748
type(iCSR_C_r1D), intent(inout) :: lhs
749
type(iCSR_C_r1D), intent(in) :: rhs
751
if ( .not. is_initd(rhs) ) return
753
lhs%D%refs_ = rhs%D%refs_ + 1
754
end subroutine common_assign_
755
elemental function common_references_(this) result(refs)
756
type(iCSR_C_r1D), intent(in) :: this
758
if ( is_initd(this) ) then
763
end function common_references_
764
elemental function common_error_(this) result(error)
765
type(iCSR_C_r1D), intent(in) :: this
767
if ( is_initd(this) ) then
772
end function common_error_
773
elemental subroutine common_set_error_is_(this, error)
774
type(iCSR_C_r1D), intent(inout) :: this
775
integer(is_), intent(in) :: error
777
end subroutine common_set_error_is_
778
elemental subroutine common_set_error_ii_(this, error)
779
type(iCSR_C_r1D), intent(inout) :: this
780
integer(ii_), intent(in) :: error
782
end subroutine common_set_error_ii_
783
elemental subroutine common_set_error_il_(this, error)
784
type(iCSR_C_r1D), intent(inout) :: this
785
integer(il_), intent(in) :: error
787
end subroutine common_set_error_il_
788
elemental function common_id_(this) result(str)
789
type(iCSR_C_r1D), intent(in) :: this
790
character(len=BUD_ID_LEn) :: str
792
end function common_id_
793
subroutine common_tag_object_(this)
794
type(iCSR_C_r1D), intent(inout) :: this
795
end subroutine common_tag_object_
796
subroutine delete_(this)
797
type(iCSR_C_r1D), intent(inout) :: this
798
call set_error(this, 0)
799
call delete(this%D%e1)
800
if ( 0 /= error(this%D%e1) ) &
801
call set_error(this, error(this%D%e1))
802
call delete(this%D%e2)
803
if ( 0 /= error(this%D%e2) ) &
804
call set_error(this, error(this%D%e2))
805
end subroutine delete_
806
subroutine copy_(from, to)
807
type(iCSR_C_r1D), intent(in) :: from
808
type(iCSR_C_r1D), intent(inout) :: to
810
if ( .not. is_initd(from) ) return
812
call common_copy_(from, to)
813
call copy(from%D%e1, to%D%e1)
814
call copy(from%D%e2, to%D%e2)
816
subroutine new_data_(this, a, b &
818
type(iCSR_C_r1D), intent(inout) :: this
819
type(iSM_CSR_C), intent(inout) :: a
820
type(rArray1D), intent(inout) :: b
824
end subroutine new_data_
825
subroutine new_(this)
826
type(iCSR_C_r1D), intent(inout) :: this
827
call initialize(this)
829
subroutine get_elem1_(this, item)
830
type(iCSR_C_r1D), intent(in) :: this
831
type(iSM_CSR_C), intent(inout) :: item
832
if ( .not. is_initd(this) ) then
838
subroutine get_elem1_assign_(item, this)
839
type(iSM_CSR_C), intent(inout) :: item
840
type(iCSR_C_r1D), intent(in) :: this
841
if ( .not. is_initd(this) ) then
847
subroutine set_elem1_(this, item)
848
type(iCSR_C_r1D), intent(inout) :: this
849
type(iSM_CSR_C), intent(in) :: item
850
if ( .not. is_initd(this) ) return
853
function get_elem1p_(this) result(p)
854
type(iCSR_C_r1D), intent(inout) :: this
855
type(iSM_CSR_C), pointer :: p
856
if ( .not. is_initd(this) ) then
862
subroutine get_elem2_(this, item)
863
type(iCSR_C_r1D), intent(in) :: this
864
type(rArray1D), intent(inout) :: item
865
if ( .not. is_initd(this) ) then
871
subroutine get_elem2_assign_(item, this)
872
type(rArray1D), intent(inout) :: item
873
type(iCSR_C_r1D), intent(in) :: this
874
if ( .not. is_initd(this) ) then
880
subroutine set_elem2_(this, item)
881
type(iCSR_C_r1D), intent(inout) :: this
882
type(rArray1D), intent(in) :: item
883
if ( .not. is_initd(this) ) return
886
function get_elem2p_(this) result(p)
887
type(iCSR_C_r1D), intent(inout) :: this
888
type(rArray1D), pointer :: p
889
if ( .not. is_initd(this) ) then
895
subroutine print_(this, info, indent)
896
type(iCSR_C_r1D), intent(in) :: this
897
character(len=*), intent(in), optional :: info
898
integer, intent(in), optional :: indent
900
character(len=32) :: fmt
901
character(len=256) :: name
903
if ( present(info) ) name = info
905
if ( present(indent) ) lindent = indent
906
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
907
if ( .not. is_initd(this) ) then
908
write(*,fmt) "<", trim(name), " not initialized>"
911
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
912
lindent = lindent + 2 ! step indentation
913
write(*,fmt) "<<", trim(name), " coll>"
914
call print(this%D%e1, indent = lindent)
915
call print(this%D%e2, indent = lindent)
916
lindent = lindent - 2 ! go back to requested indentation
917
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
918
write(*,fmt) " <coll-refs: ", references(this), ">>"
919
end subroutine print_
920
function matrix_p_(this) result(p)
921
type(iCSR_C_r1D), intent(in) :: this
922
real(rr_), pointer :: p (:)
923
p => array_p(this%D%e2)
924
end function matrix_p_
925
function matrix_ip_(this, i) result(p)
926
type(iCSR_C_r1D), intent(in) :: this
927
real(rr_), pointer :: p (:)
928
integer(ii_), intent(in) :: i
929
p => array_p(this%D%e2)
930
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
931
end function matrix_ip_
932
function matrix_lp_(this, i) result(p)
933
type(iCSR_C_r1D), intent(in) :: this
934
real(rr_), pointer :: p (:)
935
integer(il_), intent(in) :: i
936
p => array_p(this%D%e2)
937
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
938
end function matrix_lp_
939
function sparse_index_(this) result(idx)
940
type(iCSR_C_r1D), intent(in) :: this
943
end function sparse_index_
944
pure function dimensions_(this) result(d)
945
type(iCSR_C_r1D), intent(in) :: this
947
if ( is_initd(this) ) then
952
end function dimensions_
953
recursive subroutine add_element_(this, ir, ic, val)
954
type(iCSR_C_r1D), intent(inout) :: this
955
integer(ii_), intent(in) :: ir, ic
956
real(rr_), intent(in) :: val
957
type(iSM_CSR_C) :: sm
958
type(iCSR_C_r1D) :: nthis
959
integer(ii_) :: i, c, ix, nr, nc, npc
960
real(rr_), pointer :: p (:)
961
if ( .not. is_initd(this) ) return
963
call add_element(sm, ir, ic, dry_run = .true.)
964
if ( error(sm) /= 0 ) then
966
call set_error(this, -1)
969
call add_element(sm, ir, ic)
970
i = index(sm, ir, ic)
972
select case ( sparse_index(this) )
979
end subroutine add_element_
980
subroutine write_(f, this, only_array)
982
type( File ), intent(inout) :: f
983
type(iCSR_C_r1D), intent(inout) :: this
984
logical, intent(in), optional :: only_array
985
type(iSM_CSR_C) :: sm
986
type(rArray1D) :: arr
987
logical :: lonly_array
988
if ( .not. is_open(f) ) return
989
if ( .not. is_initd(this) ) return
990
lonly_array = .false.
991
if ( present(only_array) ) lonly_array = only_array
994
if ( .not. is_finalized(sm) ) then
997
call set_error(this, -1)
1000
if ( .not. lonly_array ) then
1006
end subroutine write_
1007
subroutine read_(f, this, sm)
1009
type( File ), intent(inout) :: f
1010
type(iCSR_C_r1D), intent(inout) :: this
1011
type(iSM_CSR_C), intent(inout), optional :: sm
1012
type(iSM_CSR_C) :: lsm
1013
type(rArray1D) :: arr
1014
if ( .not. is_open(f) ) return
1015
if ( present(sm) ) then
1021
call new(this, lsm, arr)
1023
end subroutine read_
1025
module bud_iCSR_C_d1D
1030
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1031
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
1032
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
1033
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
1034
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
1035
integer, parameter, private :: BUD_ID_LEn = 36
1036
character(len=*), parameter, private :: &
1037
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
1038
character(len=*), parameter, private :: &
1039
BUD_TYPe = "iCSR_C_d1D"
1040
integer(ii_), parameter :: ONE = 1_ii_
1041
integer(ii_), parameter :: ZERO = 0_ii_
1043
module procedure matrix_p_
1044
module procedure matrix_ip_
1045
module procedure matrix_lp_
1048
interface sparse_matrix
1049
module procedure get_elem1_
1051
public :: sparse_matrix
1052
interface sparse_matrix_p
1053
module procedure get_elem1p_
1055
public :: sparse_matrix_p
1056
interface sparse_index
1057
module procedure sparse_index_
1059
public :: sparse_index
1060
interface dimensions
1061
module procedure dimensions_
1063
public :: dimensions
1065
module procedure get_elem2_
1069
module procedure get_elem2p_
1072
interface add_element
1073
module procedure add_element_
1075
public :: add_element
1077
type(iCSR_C_d1D_), pointer :: D => null()
1078
integer :: error_ = 0
1081
type(iSM_CSR_C) :: e1
1082
type(dArray1D) :: e2
1083
integer :: refs_ = 0
1084
character(len=BUD_ID_LEN) :: id_ = "null_id"
1085
end type iCSR_C_d1D_
1087
module procedure new_
1088
module procedure new_data_
1091
interface assignment(=)
1092
module procedure get_elem1_assign_
1093
module procedure get_elem2_assign_
1094
module procedure set_elem1_
1095
module procedure set_elem2_
1098
module procedure get_elem1_
1099
module procedure get_elem2_
1101
interface set_element
1102
module procedure set_elem1_
1103
module procedure set_elem2_
1106
module procedure get_elem1_
1109
interface set_element1
1110
module procedure set_elem1_
1112
public :: set_element1
1113
interface element1_p
1114
module procedure get_elem1p_
1116
public :: element1_p
1118
module procedure get_elem2_
1121
interface set_element2
1122
module procedure set_elem2_
1124
public :: set_element2
1125
interface element2_p
1126
module procedure get_elem2p_
1128
public :: element2_p
1129
public :: iCSR_C_d1D
1130
private :: iCSR_C_d1D_
1131
interface assignment(=)
1132
module procedure common_assign_
1134
public :: assignment(=)
1135
private :: common_assign_
1136
interface initialize
1137
module procedure common_initialize_
1139
public :: initialize
1140
private :: common_initialize_
1141
interface is_initialized
1142
module procedure common_is_initialized_
1144
public :: is_initialized
1145
private :: common_is_initialized_
1146
interface initialized
1147
module procedure common_is_initialized_
1149
public :: initialized
1151
module procedure common_is_initialized_
1155
module procedure common_is_same_
1158
private :: common_is_same_
1160
module procedure common_is_same_
1164
module procedure common_delete_
1167
private :: common_delete_
1169
module procedure common_nullify_
1172
private :: common_nullify_
1174
module procedure copy_
1177
private :: common_copy_
1179
module procedure print_
1183
module procedure read_
1187
module procedure write_
1190
interface references
1191
module procedure common_references_
1193
public :: references
1194
private :: common_references_
1196
module procedure common_references_
1200
module procedure common_set_error_is_
1201
module procedure common_set_error_ii_
1202
module procedure common_set_error_il_
1205
private :: common_set_error_is_
1206
private :: common_set_error_ii_
1207
private :: common_set_error_il_
1209
module procedure common_error_
1212
private :: common_error_
1214
subroutine common_copy_(from, to)
1215
type(iCSR_C_d1D), intent(in) :: from
1216
type(iCSR_C_d1D), intent(inout) :: to
1217
call set_error(to, error(from))
1218
end subroutine common_copy_
1219
subroutine common_initialize_(this)
1220
type(iCSR_C_d1D), intent(inout) :: this
1223
allocate(this%D, stat=error)
1224
call set_error(this, error)
1225
if ( error /= 0 ) return
1227
call common_tag_object_(this)
1228
end subroutine common_initialize_
1229
pure function common_is_initialized_(this) result(init)
1230
type(iCSR_C_d1D), intent(in) :: this
1232
init = associated(this%D)
1233
end function common_is_initialized_
1234
elemental function common_is_same_(lhs, rhs) result(same)
1235
type(iCSR_C_d1D), intent(in) :: lhs, rhs
1237
same = is_initd(lhs) .and. is_initd(rhs)
1238
if ( .not. same ) return
1239
same = associated(lhs%D, target=rhs%D)
1240
end function common_is_same_
1241
subroutine common_delete_(this)
1242
type(iCSR_C_d1D), intent(inout) :: this
1244
call set_error(this, 0)
1245
if (.not. is_initd(this) ) return
1246
this%D%refs_ = this%D%refs_ - 1
1247
if ( 0 == this%D%refs_ ) then
1249
deallocate(this%D, stat=error)
1250
call set_error(this, error)
1253
end subroutine common_delete_
1254
elemental subroutine common_nullify_(this)
1255
type(iCSR_C_d1D), intent(inout) :: this
1256
if (.not. is_initd(this) ) return
1258
end subroutine common_nullify_
1259
subroutine common_assign_(lhs, rhs)
1260
type(iCSR_C_d1D), intent(inout) :: lhs
1261
type(iCSR_C_d1D), intent(in) :: rhs
1263
if ( .not. is_initd(rhs) ) return
1265
lhs%D%refs_ = rhs%D%refs_ + 1
1266
end subroutine common_assign_
1267
elemental function common_references_(this) result(refs)
1268
type(iCSR_C_d1D), intent(in) :: this
1270
if ( is_initd(this) ) then
1275
end function common_references_
1276
elemental function common_error_(this) result(error)
1277
type(iCSR_C_d1D), intent(in) :: this
1279
if ( is_initd(this) ) then
1284
end function common_error_
1285
elemental subroutine common_set_error_is_(this, error)
1286
type(iCSR_C_d1D), intent(inout) :: this
1287
integer(is_), intent(in) :: error
1289
end subroutine common_set_error_is_
1290
elemental subroutine common_set_error_ii_(this, error)
1291
type(iCSR_C_d1D), intent(inout) :: this
1292
integer(ii_), intent(in) :: error
1294
end subroutine common_set_error_ii_
1295
elemental subroutine common_set_error_il_(this, error)
1296
type(iCSR_C_d1D), intent(inout) :: this
1297
integer(il_), intent(in) :: error
1299
end subroutine common_set_error_il_
1300
elemental function common_id_(this) result(str)
1301
type(iCSR_C_d1D), intent(in) :: this
1302
character(len=BUD_ID_LEn) :: str
1304
end function common_id_
1305
subroutine common_tag_object_(this)
1306
type(iCSR_C_d1D), intent(inout) :: this
1307
end subroutine common_tag_object_
1308
subroutine delete_(this)
1309
type(iCSR_C_d1D), intent(inout) :: this
1310
call set_error(this, 0)
1311
call delete(this%D%e1)
1312
if ( 0 /= error(this%D%e1) ) &
1313
call set_error(this, error(this%D%e1))
1314
call delete(this%D%e2)
1315
if ( 0 /= error(this%D%e2) ) &
1316
call set_error(this, error(this%D%e2))
1317
end subroutine delete_
1318
subroutine copy_(from, to)
1319
type(iCSR_C_d1D), intent(in) :: from
1320
type(iCSR_C_d1D), intent(inout) :: to
1322
if ( .not. is_initd(from) ) return
1324
call common_copy_(from, to)
1325
call copy(from%D%e1, to%D%e1)
1326
call copy(from%D%e2, to%D%e2)
1327
end subroutine copy_
1328
subroutine new_data_(this, a, b &
1330
type(iCSR_C_d1D), intent(inout) :: this
1331
type(iSM_CSR_C), intent(inout) :: a
1332
type(dArray1D), intent(inout) :: b
1336
end subroutine new_data_
1337
subroutine new_(this)
1338
type(iCSR_C_d1D), intent(inout) :: this
1339
call initialize(this)
1341
subroutine get_elem1_(this, item)
1342
type(iCSR_C_d1D), intent(in) :: this
1343
type(iSM_CSR_C), intent(inout) :: item
1344
if ( .not. is_initd(this) ) then
1350
subroutine get_elem1_assign_(item, this)
1351
type(iSM_CSR_C), intent(inout) :: item
1352
type(iCSR_C_d1D), intent(in) :: this
1353
if ( .not. is_initd(this) ) then
1359
subroutine set_elem1_(this, item)
1360
type(iCSR_C_d1D), intent(inout) :: this
1361
type(iSM_CSR_C), intent(in) :: item
1362
if ( .not. is_initd(this) ) return
1365
function get_elem1p_(this) result(p)
1366
type(iCSR_C_d1D), intent(inout) :: this
1367
type(iSM_CSR_C), pointer :: p
1368
if ( .not. is_initd(this) ) then
1374
subroutine get_elem2_(this, item)
1375
type(iCSR_C_d1D), intent(in) :: this
1376
type(dArray1D), intent(inout) :: item
1377
if ( .not. is_initd(this) ) then
1383
subroutine get_elem2_assign_(item, this)
1384
type(dArray1D), intent(inout) :: item
1385
type(iCSR_C_d1D), intent(in) :: this
1386
if ( .not. is_initd(this) ) then
1392
subroutine set_elem2_(this, item)
1393
type(iCSR_C_d1D), intent(inout) :: this
1394
type(dArray1D), intent(in) :: item
1395
if ( .not. is_initd(this) ) return
1398
function get_elem2p_(this) result(p)
1399
type(iCSR_C_d1D), intent(inout) :: this
1400
type(dArray1D), pointer :: p
1401
if ( .not. is_initd(this) ) then
1407
subroutine print_(this, info, indent)
1408
type(iCSR_C_d1D), intent(in) :: this
1409
character(len=*), intent(in), optional :: info
1410
integer, intent(in), optional :: indent
1412
character(len=32) :: fmt
1413
character(len=256) :: name
1415
if ( present(info) ) name = info
1417
if ( present(indent) ) lindent = indent
1418
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1419
if ( .not. is_initd(this) ) then
1420
write(*,fmt) "<", trim(name), " not initialized>"
1423
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1424
lindent = lindent + 2 ! step indentation
1425
write(*,fmt) "<<", trim(name), " coll>"
1426
call print(this%D%e1, indent = lindent)
1427
call print(this%D%e2, indent = lindent)
1428
lindent = lindent - 2 ! go back to requested indentation
1429
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
1430
write(*,fmt) " <coll-refs: ", references(this), ">>"
1431
end subroutine print_
1432
function matrix_p_(this) result(p)
1433
type(iCSR_C_d1D), intent(in) :: this
1434
real(rd_), pointer :: p (:)
1435
p => array_p(this%D%e2)
1436
end function matrix_p_
1437
function matrix_ip_(this, i) result(p)
1438
type(iCSR_C_d1D), intent(in) :: this
1439
real(rd_), pointer :: p (:)
1440
integer(ii_), intent(in) :: i
1441
p => array_p(this%D%e2)
1442
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
1443
end function matrix_ip_
1444
function matrix_lp_(this, i) result(p)
1445
type(iCSR_C_d1D), intent(in) :: this
1446
real(rd_), pointer :: p (:)
1447
integer(il_), intent(in) :: i
1448
p => array_p(this%D%e2)
1449
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
1450
end function matrix_lp_
1451
function sparse_index_(this) result(idx)
1452
type(iCSR_C_d1D), intent(in) :: this
1455
end function sparse_index_
1456
pure function dimensions_(this) result(d)
1457
type(iCSR_C_d1D), intent(in) :: this
1459
if ( is_initd(this) ) then
1464
end function dimensions_
1465
recursive subroutine add_element_(this, ir, ic, val)
1466
type(iCSR_C_d1D), intent(inout) :: this
1467
integer(ii_), intent(in) :: ir, ic
1468
real(rd_), intent(in) :: val
1469
type(iSM_CSR_C) :: sm
1470
type(iCSR_C_d1D) :: nthis
1471
integer(ii_) :: i, c, ix, nr, nc, npc
1472
real(rd_), pointer :: p (:)
1473
if ( .not. is_initd(this) ) return
1475
call add_element(sm, ir, ic, dry_run = .true.)
1476
if ( error(sm) /= 0 ) then
1478
call set_error(this, -1)
1481
call add_element(sm, ir, ic)
1482
i = index(sm, ir, ic)
1484
select case ( sparse_index(this) )
1491
end subroutine add_element_
1492
subroutine write_(f, this, only_array)
1494
type( File ), intent(inout) :: f
1495
type(iCSR_C_d1D), intent(inout) :: this
1496
logical, intent(in), optional :: only_array
1497
type(iSM_CSR_C) :: sm
1498
type(dArray1D) :: arr
1499
logical :: lonly_array
1500
if ( .not. is_open(f) ) return
1501
if ( .not. is_initd(this) ) return
1502
lonly_array = .false.
1503
if ( present(only_array) ) lonly_array = only_array
1506
if ( .not. is_finalized(sm) ) then
1509
call set_error(this, -1)
1512
if ( .not. lonly_array ) then
1518
end subroutine write_
1519
subroutine read_(f, this, sm)
1521
type( File ), intent(inout) :: f
1522
type(iCSR_C_d1D), intent(inout) :: this
1523
type(iSM_CSR_C), intent(inout), optional :: sm
1524
type(iSM_CSR_C) :: lsm
1525
type(dArray1D) :: arr
1526
if ( .not. is_open(f) ) return
1527
if ( present(sm) ) then
1533
call new(this, lsm, arr)
1535
end subroutine read_
1537
module bud_iCSR_C_c1D
1542
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1543
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
1544
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
1545
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
1546
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
1547
integer, parameter, private :: BUD_ID_LEn = 36
1548
character(len=*), parameter, private :: &
1549
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
1550
character(len=*), parameter, private :: &
1551
BUD_TYPe = "iCSR_C_c1D"
1552
integer(ii_), parameter :: ONE = 1_ii_
1553
integer(ii_), parameter :: ZERO = 0_ii_
1555
module procedure matrix_p_
1556
module procedure matrix_ip_
1557
module procedure matrix_lp_
1560
interface sparse_matrix
1561
module procedure get_elem1_
1563
public :: sparse_matrix
1564
interface sparse_matrix_p
1565
module procedure get_elem1p_
1567
public :: sparse_matrix_p
1568
interface sparse_index
1569
module procedure sparse_index_
1571
public :: sparse_index
1572
interface dimensions
1573
module procedure dimensions_
1575
public :: dimensions
1577
module procedure get_elem2_
1581
module procedure get_elem2p_
1584
interface add_element
1585
module procedure add_element_
1587
public :: add_element
1589
type(iCSR_C_c1D_), pointer :: D => null()
1590
integer :: error_ = 0
1593
type(iSM_CSR_C) :: e1
1594
type(cArray1D) :: e2
1595
integer :: refs_ = 0
1596
character(len=BUD_ID_LEN) :: id_ = "null_id"
1597
end type iCSR_C_c1D_
1599
module procedure new_
1600
module procedure new_data_
1603
interface assignment(=)
1604
module procedure get_elem1_assign_
1605
module procedure get_elem2_assign_
1606
module procedure set_elem1_
1607
module procedure set_elem2_
1610
module procedure get_elem1_
1611
module procedure get_elem2_
1613
interface set_element
1614
module procedure set_elem1_
1615
module procedure set_elem2_
1618
module procedure get_elem1_
1621
interface set_element1
1622
module procedure set_elem1_
1624
public :: set_element1
1625
interface element1_p
1626
module procedure get_elem1p_
1628
public :: element1_p
1630
module procedure get_elem2_
1633
interface set_element2
1634
module procedure set_elem2_
1636
public :: set_element2
1637
interface element2_p
1638
module procedure get_elem2p_
1640
public :: element2_p
1641
public :: iCSR_C_c1D
1642
private :: iCSR_C_c1D_
1643
interface assignment(=)
1644
module procedure common_assign_
1646
public :: assignment(=)
1647
private :: common_assign_
1648
interface initialize
1649
module procedure common_initialize_
1651
public :: initialize
1652
private :: common_initialize_
1653
interface is_initialized
1654
module procedure common_is_initialized_
1656
public :: is_initialized
1657
private :: common_is_initialized_
1658
interface initialized
1659
module procedure common_is_initialized_
1661
public :: initialized
1663
module procedure common_is_initialized_
1667
module procedure common_is_same_
1670
private :: common_is_same_
1672
module procedure common_is_same_
1676
module procedure common_delete_
1679
private :: common_delete_
1681
module procedure common_nullify_
1684
private :: common_nullify_
1686
module procedure copy_
1689
private :: common_copy_
1691
module procedure print_
1695
module procedure read_
1699
module procedure write_
1702
interface references
1703
module procedure common_references_
1705
public :: references
1706
private :: common_references_
1708
module procedure common_references_
1712
module procedure common_set_error_is_
1713
module procedure common_set_error_ii_
1714
module procedure common_set_error_il_
1717
private :: common_set_error_is_
1718
private :: common_set_error_ii_
1719
private :: common_set_error_il_
1721
module procedure common_error_
1724
private :: common_error_
1726
subroutine common_copy_(from, to)
1727
type(iCSR_C_c1D), intent(in) :: from
1728
type(iCSR_C_c1D), intent(inout) :: to
1729
call set_error(to, error(from))
1730
end subroutine common_copy_
1731
subroutine common_initialize_(this)
1732
type(iCSR_C_c1D), intent(inout) :: this
1735
allocate(this%D, stat=error)
1736
call set_error(this, error)
1737
if ( error /= 0 ) return
1739
call common_tag_object_(this)
1740
end subroutine common_initialize_
1741
pure function common_is_initialized_(this) result(init)
1742
type(iCSR_C_c1D), intent(in) :: this
1744
init = associated(this%D)
1745
end function common_is_initialized_
1746
elemental function common_is_same_(lhs, rhs) result(same)
1747
type(iCSR_C_c1D), intent(in) :: lhs, rhs
1749
same = is_initd(lhs) .and. is_initd(rhs)
1750
if ( .not. same ) return
1751
same = associated(lhs%D, target=rhs%D)
1752
end function common_is_same_
1753
subroutine common_delete_(this)
1754
type(iCSR_C_c1D), intent(inout) :: this
1756
call set_error(this, 0)
1757
if (.not. is_initd(this) ) return
1758
this%D%refs_ = this%D%refs_ - 1
1759
if ( 0 == this%D%refs_ ) then
1761
deallocate(this%D, stat=error)
1762
call set_error(this, error)
1765
end subroutine common_delete_
1766
elemental subroutine common_nullify_(this)
1767
type(iCSR_C_c1D), intent(inout) :: this
1768
if (.not. is_initd(this) ) return
1770
end subroutine common_nullify_
1771
subroutine common_assign_(lhs, rhs)
1772
type(iCSR_C_c1D), intent(inout) :: lhs
1773
type(iCSR_C_c1D), intent(in) :: rhs
1775
if ( .not. is_initd(rhs) ) return
1777
lhs%D%refs_ = rhs%D%refs_ + 1
1778
end subroutine common_assign_
1779
elemental function common_references_(this) result(refs)
1780
type(iCSR_C_c1D), intent(in) :: this
1782
if ( is_initd(this) ) then
1787
end function common_references_
1788
elemental function common_error_(this) result(error)
1789
type(iCSR_C_c1D), intent(in) :: this
1791
if ( is_initd(this) ) then
1796
end function common_error_
1797
elemental subroutine common_set_error_is_(this, error)
1798
type(iCSR_C_c1D), intent(inout) :: this
1799
integer(is_), intent(in) :: error
1801
end subroutine common_set_error_is_
1802
elemental subroutine common_set_error_ii_(this, error)
1803
type(iCSR_C_c1D), intent(inout) :: this
1804
integer(ii_), intent(in) :: error
1806
end subroutine common_set_error_ii_
1807
elemental subroutine common_set_error_il_(this, error)
1808
type(iCSR_C_c1D), intent(inout) :: this
1809
integer(il_), intent(in) :: error
1811
end subroutine common_set_error_il_
1812
elemental function common_id_(this) result(str)
1813
type(iCSR_C_c1D), intent(in) :: this
1814
character(len=BUD_ID_LEn) :: str
1816
end function common_id_
1817
subroutine common_tag_object_(this)
1818
type(iCSR_C_c1D), intent(inout) :: this
1819
end subroutine common_tag_object_
1820
subroutine delete_(this)
1821
type(iCSR_C_c1D), intent(inout) :: this
1822
call set_error(this, 0)
1823
call delete(this%D%e1)
1824
if ( 0 /= error(this%D%e1) ) &
1825
call set_error(this, error(this%D%e1))
1826
call delete(this%D%e2)
1827
if ( 0 /= error(this%D%e2) ) &
1828
call set_error(this, error(this%D%e2))
1829
end subroutine delete_
1830
subroutine copy_(from, to)
1831
type(iCSR_C_c1D), intent(in) :: from
1832
type(iCSR_C_c1D), intent(inout) :: to
1834
if ( .not. is_initd(from) ) return
1836
call common_copy_(from, to)
1837
call copy(from%D%e1, to%D%e1)
1838
call copy(from%D%e2, to%D%e2)
1839
end subroutine copy_
1840
subroutine new_data_(this, a, b &
1842
type(iCSR_C_c1D), intent(inout) :: this
1843
type(iSM_CSR_C), intent(inout) :: a
1844
type(cArray1D), intent(inout) :: b
1848
end subroutine new_data_
1849
subroutine new_(this)
1850
type(iCSR_C_c1D), intent(inout) :: this
1851
call initialize(this)
1853
subroutine get_elem1_(this, item)
1854
type(iCSR_C_c1D), intent(in) :: this
1855
type(iSM_CSR_C), intent(inout) :: item
1856
if ( .not. is_initd(this) ) then
1862
subroutine get_elem1_assign_(item, this)
1863
type(iSM_CSR_C), intent(inout) :: item
1864
type(iCSR_C_c1D), intent(in) :: this
1865
if ( .not. is_initd(this) ) then
1871
subroutine set_elem1_(this, item)
1872
type(iCSR_C_c1D), intent(inout) :: this
1873
type(iSM_CSR_C), intent(in) :: item
1874
if ( .not. is_initd(this) ) return
1877
function get_elem1p_(this) result(p)
1878
type(iCSR_C_c1D), intent(inout) :: this
1879
type(iSM_CSR_C), pointer :: p
1880
if ( .not. is_initd(this) ) then
1886
subroutine get_elem2_(this, item)
1887
type(iCSR_C_c1D), intent(in) :: this
1888
type(cArray1D), intent(inout) :: item
1889
if ( .not. is_initd(this) ) then
1895
subroutine get_elem2_assign_(item, this)
1896
type(cArray1D), intent(inout) :: item
1897
type(iCSR_C_c1D), intent(in) :: this
1898
if ( .not. is_initd(this) ) then
1904
subroutine set_elem2_(this, item)
1905
type(iCSR_C_c1D), intent(inout) :: this
1906
type(cArray1D), intent(in) :: item
1907
if ( .not. is_initd(this) ) return
1910
function get_elem2p_(this) result(p)
1911
type(iCSR_C_c1D), intent(inout) :: this
1912
type(cArray1D), pointer :: p
1913
if ( .not. is_initd(this) ) then
1919
subroutine print_(this, info, indent)
1920
type(iCSR_C_c1D), intent(in) :: this
1921
character(len=*), intent(in), optional :: info
1922
integer, intent(in), optional :: indent
1924
character(len=32) :: fmt
1925
character(len=256) :: name
1927
if ( present(info) ) name = info
1929
if ( present(indent) ) lindent = indent
1930
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1931
if ( .not. is_initd(this) ) then
1932
write(*,fmt) "<", trim(name), " not initialized>"
1935
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1936
lindent = lindent + 2 ! step indentation
1937
write(*,fmt) "<<", trim(name), " coll>"
1938
call print(this%D%e1, indent = lindent)
1939
call print(this%D%e2, indent = lindent)
1940
lindent = lindent - 2 ! go back to requested indentation
1941
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
1942
write(*,fmt) " <coll-refs: ", references(this), ">>"
1943
end subroutine print_
1944
function matrix_p_(this) result(p)
1945
type(iCSR_C_c1D), intent(in) :: this
1946
complex(rr_), pointer :: p (:)
1947
p => array_p(this%D%e2)
1948
end function matrix_p_
1949
function matrix_ip_(this, i) result(p)
1950
type(iCSR_C_c1D), intent(in) :: this
1951
complex(rr_), pointer :: p (:)
1952
integer(ii_), intent(in) :: i
1953
p => array_p(this%D%e2)
1954
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
1955
end function matrix_ip_
1956
function matrix_lp_(this, i) result(p)
1957
type(iCSR_C_c1D), intent(in) :: this
1958
complex(rr_), pointer :: p (:)
1959
integer(il_), intent(in) :: i
1960
p => array_p(this%D%e2)
1961
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
1962
end function matrix_lp_
1963
function sparse_index_(this) result(idx)
1964
type(iCSR_C_c1D), intent(in) :: this
1967
end function sparse_index_
1968
pure function dimensions_(this) result(d)
1969
type(iCSR_C_c1D), intent(in) :: this
1971
if ( is_initd(this) ) then
1976
end function dimensions_
1977
recursive subroutine add_element_(this, ir, ic, val)
1978
type(iCSR_C_c1D), intent(inout) :: this
1979
integer(ii_), intent(in) :: ir, ic
1980
complex(rr_), intent(in) :: val
1981
type(iSM_CSR_C) :: sm
1982
type(iCSR_C_c1D) :: nthis
1983
integer(ii_) :: i, c, ix, nr, nc, npc
1984
complex(rr_), pointer :: p (:)
1985
if ( .not. is_initd(this) ) return
1987
call add_element(sm, ir, ic, dry_run = .true.)
1988
if ( error(sm) /= 0 ) then
1990
call set_error(this, -1)
1993
call add_element(sm, ir, ic)
1994
i = index(sm, ir, ic)
1996
select case ( sparse_index(this) )
2003
end subroutine add_element_
2004
subroutine write_(f, this, only_array)
2006
type( File ), intent(inout) :: f
2007
type(iCSR_C_c1D), intent(inout) :: this
2008
logical, intent(in), optional :: only_array
2009
type(iSM_CSR_C) :: sm
2010
type(cArray1D) :: arr
2011
logical :: lonly_array
2012
if ( .not. is_open(f) ) return
2013
if ( .not. is_initd(this) ) return
2014
lonly_array = .false.
2015
if ( present(only_array) ) lonly_array = only_array
2018
if ( .not. is_finalized(sm) ) then
2021
call set_error(this, -1)
2024
if ( .not. lonly_array ) then
2030
end subroutine write_
2031
subroutine read_(f, this, sm)
2033
type( File ), intent(inout) :: f
2034
type(iCSR_C_c1D), intent(inout) :: this
2035
type(iSM_CSR_C), intent(inout), optional :: sm
2036
type(iSM_CSR_C) :: lsm
2037
type(cArray1D) :: arr
2038
if ( .not. is_open(f) ) return
2039
if ( present(sm) ) then
2045
call new(this, lsm, arr)
2047
end subroutine read_
2049
module bud_iCSR_C_z1D
2054
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
2055
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
2056
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
2057
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
2058
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
2059
integer, parameter, private :: BUD_ID_LEn = 36
2060
character(len=*), parameter, private :: &
2061
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
2062
character(len=*), parameter, private :: &
2063
BUD_TYPe = "iCSR_C_z1D"
2064
integer(ii_), parameter :: ONE = 1_ii_
2065
integer(ii_), parameter :: ZERO = 0_ii_
2067
module procedure matrix_p_
2068
module procedure matrix_ip_
2069
module procedure matrix_lp_
2072
interface sparse_matrix
2073
module procedure get_elem1_
2075
public :: sparse_matrix
2076
interface sparse_matrix_p
2077
module procedure get_elem1p_
2079
public :: sparse_matrix_p
2080
interface sparse_index
2081
module procedure sparse_index_
2083
public :: sparse_index
2084
interface dimensions
2085
module procedure dimensions_
2087
public :: dimensions
2089
module procedure get_elem2_
2093
module procedure get_elem2p_
2096
interface add_element
2097
module procedure add_element_
2099
public :: add_element
2101
type(iCSR_C_z1D_), pointer :: D => null()
2102
integer :: error_ = 0
2105
type(iSM_CSR_C) :: e1
2106
type(zArray1D) :: e2
2107
integer :: refs_ = 0
2108
character(len=BUD_ID_LEN) :: id_ = "null_id"
2109
end type iCSR_C_z1D_
2111
module procedure new_
2112
module procedure new_data_
2115
interface assignment(=)
2116
module procedure get_elem1_assign_
2117
module procedure get_elem2_assign_
2118
module procedure set_elem1_
2119
module procedure set_elem2_
2122
module procedure get_elem1_
2123
module procedure get_elem2_
2125
interface set_element
2126
module procedure set_elem1_
2127
module procedure set_elem2_
2130
module procedure get_elem1_
2133
interface set_element1
2134
module procedure set_elem1_
2136
public :: set_element1
2137
interface element1_p
2138
module procedure get_elem1p_
2140
public :: element1_p
2142
module procedure get_elem2_
2145
interface set_element2
2146
module procedure set_elem2_
2148
public :: set_element2
2149
interface element2_p
2150
module procedure get_elem2p_
2152
public :: element2_p
2153
public :: iCSR_C_z1D
2154
private :: iCSR_C_z1D_
2155
interface assignment(=)
2156
module procedure common_assign_
2158
public :: assignment(=)
2159
private :: common_assign_
2160
interface initialize
2161
module procedure common_initialize_
2163
public :: initialize
2164
private :: common_initialize_
2165
interface is_initialized
2166
module procedure common_is_initialized_
2168
public :: is_initialized
2169
private :: common_is_initialized_
2170
interface initialized
2171
module procedure common_is_initialized_
2173
public :: initialized
2175
module procedure common_is_initialized_
2179
module procedure common_is_same_
2182
private :: common_is_same_
2184
module procedure common_is_same_
2188
module procedure common_delete_
2191
private :: common_delete_
2193
module procedure common_nullify_
2196
private :: common_nullify_
2198
module procedure copy_
2201
private :: common_copy_
2203
module procedure print_
2207
module procedure read_
2211
module procedure write_
2214
interface references
2215
module procedure common_references_
2217
public :: references
2218
private :: common_references_
2220
module procedure common_references_
2224
module procedure common_set_error_is_
2225
module procedure common_set_error_ii_
2226
module procedure common_set_error_il_
2229
private :: common_set_error_is_
2230
private :: common_set_error_ii_
2231
private :: common_set_error_il_
2233
module procedure common_error_
2236
private :: common_error_
2238
subroutine common_copy_(from, to)
2239
type(iCSR_C_z1D), intent(in) :: from
2240
type(iCSR_C_z1D), intent(inout) :: to
2241
call set_error(to, error(from))
2242
end subroutine common_copy_
2243
subroutine common_initialize_(this)
2244
type(iCSR_C_z1D), intent(inout) :: this
2247
allocate(this%D, stat=error)
2248
call set_error(this, error)
2249
if ( error /= 0 ) return
2251
call common_tag_object_(this)
2252
end subroutine common_initialize_
2253
pure function common_is_initialized_(this) result(init)
2254
type(iCSR_C_z1D), intent(in) :: this
2256
init = associated(this%D)
2257
end function common_is_initialized_
2258
elemental function common_is_same_(lhs, rhs) result(same)
2259
type(iCSR_C_z1D), intent(in) :: lhs, rhs
2261
same = is_initd(lhs) .and. is_initd(rhs)
2262
if ( .not. same ) return
2263
same = associated(lhs%D, target=rhs%D)
2264
end function common_is_same_
2265
subroutine common_delete_(this)
2266
type(iCSR_C_z1D), intent(inout) :: this
2268
call set_error(this, 0)
2269
if (.not. is_initd(this) ) return
2270
this%D%refs_ = this%D%refs_ - 1
2271
if ( 0 == this%D%refs_ ) then
2273
deallocate(this%D, stat=error)
2274
call set_error(this, error)
2277
end subroutine common_delete_
2278
elemental subroutine common_nullify_(this)
2279
type(iCSR_C_z1D), intent(inout) :: this
2280
if (.not. is_initd(this) ) return
2282
end subroutine common_nullify_
2283
subroutine common_assign_(lhs, rhs)
2284
type(iCSR_C_z1D), intent(inout) :: lhs
2285
type(iCSR_C_z1D), intent(in) :: rhs
2287
if ( .not. is_initd(rhs) ) return
2289
lhs%D%refs_ = rhs%D%refs_ + 1
2290
end subroutine common_assign_
2291
elemental function common_references_(this) result(refs)
2292
type(iCSR_C_z1D), intent(in) :: this
2294
if ( is_initd(this) ) then
2299
end function common_references_
2300
elemental function common_error_(this) result(error)
2301
type(iCSR_C_z1D), intent(in) :: this
2303
if ( is_initd(this) ) then
2308
end function common_error_
2309
elemental subroutine common_set_error_is_(this, error)
2310
type(iCSR_C_z1D), intent(inout) :: this
2311
integer(is_), intent(in) :: error
2313
end subroutine common_set_error_is_
2314
elemental subroutine common_set_error_ii_(this, error)
2315
type(iCSR_C_z1D), intent(inout) :: this
2316
integer(ii_), intent(in) :: error
2318
end subroutine common_set_error_ii_
2319
elemental subroutine common_set_error_il_(this, error)
2320
type(iCSR_C_z1D), intent(inout) :: this
2321
integer(il_), intent(in) :: error
2323
end subroutine common_set_error_il_
2324
elemental function common_id_(this) result(str)
2325
type(iCSR_C_z1D), intent(in) :: this
2326
character(len=BUD_ID_LEn) :: str
2328
end function common_id_
2329
subroutine common_tag_object_(this)
2330
type(iCSR_C_z1D), intent(inout) :: this
2331
end subroutine common_tag_object_
2332
subroutine delete_(this)
2333
type(iCSR_C_z1D), intent(inout) :: this
2334
call set_error(this, 0)
2335
call delete(this%D%e1)
2336
if ( 0 /= error(this%D%e1) ) &
2337
call set_error(this, error(this%D%e1))
2338
call delete(this%D%e2)
2339
if ( 0 /= error(this%D%e2) ) &
2340
call set_error(this, error(this%D%e2))
2341
end subroutine delete_
2342
subroutine copy_(from, to)
2343
type(iCSR_C_z1D), intent(in) :: from
2344
type(iCSR_C_z1D), intent(inout) :: to
2346
if ( .not. is_initd(from) ) return
2348
call common_copy_(from, to)
2349
call copy(from%D%e1, to%D%e1)
2350
call copy(from%D%e2, to%D%e2)
2351
end subroutine copy_
2352
subroutine new_data_(this, a, b &
2354
type(iCSR_C_z1D), intent(inout) :: this
2355
type(iSM_CSR_C), intent(inout) :: a
2356
type(zArray1D), intent(inout) :: b
2360
end subroutine new_data_
2361
subroutine new_(this)
2362
type(iCSR_C_z1D), intent(inout) :: this
2363
call initialize(this)
2365
subroutine get_elem1_(this, item)
2366
type(iCSR_C_z1D), intent(in) :: this
2367
type(iSM_CSR_C), intent(inout) :: item
2368
if ( .not. is_initd(this) ) then
2374
subroutine get_elem1_assign_(item, this)
2375
type(iSM_CSR_C), intent(inout) :: item
2376
type(iCSR_C_z1D), intent(in) :: this
2377
if ( .not. is_initd(this) ) then
2383
subroutine set_elem1_(this, item)
2384
type(iCSR_C_z1D), intent(inout) :: this
2385
type(iSM_CSR_C), intent(in) :: item
2386
if ( .not. is_initd(this) ) return
2389
function get_elem1p_(this) result(p)
2390
type(iCSR_C_z1D), intent(inout) :: this
2391
type(iSM_CSR_C), pointer :: p
2392
if ( .not. is_initd(this) ) then
2398
subroutine get_elem2_(this, item)
2399
type(iCSR_C_z1D), intent(in) :: this
2400
type(zArray1D), intent(inout) :: item
2401
if ( .not. is_initd(this) ) then
2407
subroutine get_elem2_assign_(item, this)
2408
type(zArray1D), intent(inout) :: item
2409
type(iCSR_C_z1D), intent(in) :: this
2410
if ( .not. is_initd(this) ) then
2416
subroutine set_elem2_(this, item)
2417
type(iCSR_C_z1D), intent(inout) :: this
2418
type(zArray1D), intent(in) :: item
2419
if ( .not. is_initd(this) ) return
2422
function get_elem2p_(this) result(p)
2423
type(iCSR_C_z1D), intent(inout) :: this
2424
type(zArray1D), pointer :: p
2425
if ( .not. is_initd(this) ) then
2431
subroutine print_(this, info, indent)
2432
type(iCSR_C_z1D), intent(in) :: this
2433
character(len=*), intent(in), optional :: info
2434
integer, intent(in), optional :: indent
2436
character(len=32) :: fmt
2437
character(len=256) :: name
2439
if ( present(info) ) name = info
2441
if ( present(indent) ) lindent = indent
2442
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
2443
if ( .not. is_initd(this) ) then
2444
write(*,fmt) "<", trim(name), " not initialized>"
2447
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
2448
lindent = lindent + 2 ! step indentation
2449
write(*,fmt) "<<", trim(name), " coll>"
2450
call print(this%D%e1, indent = lindent)
2451
call print(this%D%e2, indent = lindent)
2452
lindent = lindent - 2 ! go back to requested indentation
2453
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
2454
write(*,fmt) " <coll-refs: ", references(this), ">>"
2455
end subroutine print_
2456
function matrix_p_(this) result(p)
2457
type(iCSR_C_z1D), intent(in) :: this
2458
complex(rd_), pointer :: p (:)
2459
p => array_p(this%D%e2)
2460
end function matrix_p_
2461
function matrix_ip_(this, i) result(p)
2462
type(iCSR_C_z1D), intent(in) :: this
2463
complex(rd_), pointer :: p (:)
2464
integer(ii_), intent(in) :: i
2465
p => array_p(this%D%e2)
2466
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
2467
end function matrix_ip_
2468
function matrix_lp_(this, i) result(p)
2469
type(iCSR_C_z1D), intent(in) :: this
2470
complex(rd_), pointer :: p (:)
2471
integer(il_), intent(in) :: i
2472
p => array_p(this%D%e2)
2473
p => p(this%D%e1%D%rptr(i)+ONE:this%D%e1%D%rptr(i)+this%D%e1%D%nrow(i))
2474
end function matrix_lp_
2475
function sparse_index_(this) result(idx)
2476
type(iCSR_C_z1D), intent(in) :: this
2479
end function sparse_index_
2480
pure function dimensions_(this) result(d)
2481
type(iCSR_C_z1D), intent(in) :: this
2483
if ( is_initd(this) ) then
2488
end function dimensions_
2489
recursive subroutine add_element_(this, ir, ic, val)
2490
type(iCSR_C_z1D), intent(inout) :: this
2491
integer(ii_), intent(in) :: ir, ic
2492
complex(rd_), intent(in) :: val
2493
type(iSM_CSR_C) :: sm
2494
type(iCSR_C_z1D) :: nthis
2495
integer(ii_) :: i, c, ix, nr, nc, npc
2496
complex(rd_), pointer :: p (:)
2497
if ( .not. is_initd(this) ) return
2499
call add_element(sm, ir, ic, dry_run = .true.)
2500
if ( error(sm) /= 0 ) then
2502
call set_error(this, -1)
2505
call add_element(sm, ir, ic)
2506
i = index(sm, ir, ic)
2508
select case ( sparse_index(this) )
2515
end subroutine add_element_
2516
subroutine write_(f, this, only_array)
2518
type( File ), intent(inout) :: f
2519
type(iCSR_C_z1D), intent(inout) :: this
2520
logical, intent(in), optional :: only_array
2521
type(iSM_CSR_C) :: sm
2522
type(zArray1D) :: arr
2523
logical :: lonly_array
2524
if ( .not. is_open(f) ) return
2525
if ( .not. is_initd(this) ) return
2526
lonly_array = .false.
2527
if ( present(only_array) ) lonly_array = only_array
2530
if ( .not. is_finalized(sm) ) then
2533
call set_error(this, -1)
2536
if ( .not. lonly_array ) then
2542
end subroutine write_
2543
subroutine read_(f, this, sm)
2545
type( File ), intent(inout) :: f
2546
type(iCSR_C_z1D), intent(inout) :: this
2547
type(iSM_CSR_C), intent(inout), optional :: sm
2548
type(iSM_CSR_C) :: lsm
2549
type(zArray1D) :: arr
2550
if ( .not. is_open(f) ) return
2551
if ( present(sm) ) then
2557
call new(this, lsm, arr)
2559
end subroutine read_