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_b2D"
16
integer(ii_), parameter :: ONE = 1_ii_
17
integer(ii_), parameter :: ZERO = 0_ii_
19
module procedure matrix_p_
22
interface sparse_matrix
23
module procedure get_elem1_
25
public :: sparse_matrix
26
interface sparse_matrix_p
27
module procedure get_elem1p_
29
public :: sparse_matrix_p
30
interface sparse_index
31
module procedure sparse_index_
33
public :: sparse_index
35
module procedure dimensions_
39
module procedure get_elem2_
43
module procedure get_elem2p_
47
module procedure add_element_
51
type(iCSR_C_b2D_), pointer :: D => null()
59
character(len=BUD_ID_LEN) :: id_ = "null_id"
63
module procedure new_data_
66
interface assignment(=)
67
module procedure get_elem1_assign_
68
module procedure get_elem2_assign_
69
module procedure set_elem1_
70
module procedure set_elem2_
73
module procedure get_elem1_
74
module procedure get_elem2_
77
module procedure set_elem1_
78
module procedure set_elem2_
81
module procedure get_elem1_
84
interface set_element1
85
module procedure set_elem1_
87
public :: set_element1
89
module procedure get_elem1p_
93
module procedure get_elem2_
96
interface set_element2
97
module procedure set_elem2_
99
public :: set_element2
101
module procedure get_elem2p_
105
private :: iCSR_C_b2D_
106
interface assignment(=)
107
module procedure common_assign_
109
public :: assignment(=)
110
private :: common_assign_
112
module procedure common_initialize_
115
private :: common_initialize_
116
interface is_initialized
117
module procedure common_is_initialized_
119
public :: is_initialized
120
private :: common_is_initialized_
121
interface initialized
122
module procedure common_is_initialized_
124
public :: initialized
126
module procedure common_is_initialized_
130
module procedure common_is_same_
133
private :: common_is_same_
135
module procedure common_is_same_
139
module procedure common_delete_
142
private :: common_delete_
144
module procedure common_nullify_
147
private :: common_nullify_
149
module procedure copy_
152
private :: common_copy_
154
module procedure print_
158
module procedure read_
162
module procedure write_
166
module procedure common_references_
169
private :: common_references_
171
module procedure common_references_
175
module procedure common_set_error_is_
176
module procedure common_set_error_ii_
177
module procedure common_set_error_il_
180
private :: common_set_error_is_
181
private :: common_set_error_ii_
182
private :: common_set_error_il_
184
module procedure common_error_
187
private :: common_error_
189
subroutine common_copy_(from, to)
190
type(iCSR_C_b2D), intent(in) :: from
191
type(iCSR_C_b2D), intent(inout) :: to
192
call set_error(to, error(from))
193
end subroutine common_copy_
194
subroutine common_initialize_(this)
195
type(iCSR_C_b2D), intent(inout) :: this
198
allocate(this%D, stat=error)
199
call set_error(this, error)
200
if ( error /= 0 ) return
202
call common_tag_object_(this)
203
end subroutine common_initialize_
204
pure function common_is_initialized_(this) result(init)
205
type(iCSR_C_b2D), intent(in) :: this
207
init = associated(this%D)
208
end function common_is_initialized_
209
elemental function common_is_same_(lhs, rhs) result(same)
210
type(iCSR_C_b2D), intent(in) :: lhs, rhs
212
same = is_initd(lhs) .and. is_initd(rhs)
213
if ( .not. same ) return
214
same = associated(lhs%D, target=rhs%D)
215
end function common_is_same_
216
subroutine common_delete_(this)
217
type(iCSR_C_b2D), intent(inout) :: this
219
call set_error(this, 0)
220
if (.not. is_initd(this) ) return
221
this%D%refs_ = this%D%refs_ - 1
222
if ( 0 == this%D%refs_ ) then
224
deallocate(this%D, stat=error)
225
call set_error(this, error)
228
end subroutine common_delete_
229
elemental subroutine common_nullify_(this)
230
type(iCSR_C_b2D), intent(inout) :: this
231
if (.not. is_initd(this) ) return
233
end subroutine common_nullify_
234
subroutine common_assign_(lhs, rhs)
235
type(iCSR_C_b2D), intent(inout) :: lhs
236
type(iCSR_C_b2D), intent(in) :: rhs
238
if ( .not. is_initd(rhs) ) return
240
lhs%D%refs_ = rhs%D%refs_ + 1
241
end subroutine common_assign_
242
elemental function common_references_(this) result(refs)
243
type(iCSR_C_b2D), intent(in) :: this
245
if ( is_initd(this) ) then
250
end function common_references_
251
elemental function common_error_(this) result(error)
252
type(iCSR_C_b2D), intent(in) :: this
254
if ( is_initd(this) ) then
259
end function common_error_
260
elemental subroutine common_set_error_is_(this, error)
261
type(iCSR_C_b2D), intent(inout) :: this
262
integer(is_), intent(in) :: error
264
end subroutine common_set_error_is_
265
elemental subroutine common_set_error_ii_(this, error)
266
type(iCSR_C_b2D), intent(inout) :: this
267
integer(ii_), intent(in) :: error
269
end subroutine common_set_error_ii_
270
elemental subroutine common_set_error_il_(this, error)
271
type(iCSR_C_b2D), intent(inout) :: this
272
integer(il_), intent(in) :: error
274
end subroutine common_set_error_il_
275
elemental function common_id_(this) result(str)
276
type(iCSR_C_b2D), intent(in) :: this
277
character(len=BUD_ID_LEn) :: str
279
end function common_id_
280
subroutine common_tag_object_(this)
281
type(iCSR_C_b2D), intent(inout) :: this
282
end subroutine common_tag_object_
283
subroutine delete_(this)
284
type(iCSR_C_b2D), intent(inout) :: this
285
call set_error(this, 0)
286
call delete(this%D%e1)
287
if ( 0 /= error(this%D%e1) ) &
288
call set_error(this, error(this%D%e1))
289
call delete(this%D%e2)
290
if ( 0 /= error(this%D%e2) ) &
291
call set_error(this, error(this%D%e2))
292
end subroutine delete_
293
subroutine copy_(from, to)
294
type(iCSR_C_b2D), intent(in) :: from
295
type(iCSR_C_b2D), intent(inout) :: to
297
if ( .not. is_initd(from) ) return
299
call common_copy_(from, to)
300
call copy(from%D%e1, to%D%e1)
301
call copy(from%D%e2, to%D%e2)
303
subroutine new_data_(this, a, b &
305
type(iCSR_C_b2D), intent(inout) :: this
306
type(iSM_CSR_C), intent(inout) :: a
307
type(bArray2D), intent(inout) :: b
311
end subroutine new_data_
312
subroutine new_(this)
313
type(iCSR_C_b2D), intent(inout) :: this
314
call initialize(this)
316
subroutine get_elem1_(this, item)
317
type(iCSR_C_b2D), intent(in) :: this
318
type(iSM_CSR_C), intent(inout) :: item
319
if ( .not. is_initd(this) ) then
325
subroutine get_elem1_assign_(item, this)
326
type(iSM_CSR_C), intent(inout) :: item
327
type(iCSR_C_b2D), intent(in) :: this
328
if ( .not. is_initd(this) ) then
334
subroutine set_elem1_(this, item)
335
type(iCSR_C_b2D), intent(inout) :: this
336
type(iSM_CSR_C), intent(in) :: item
337
if ( .not. is_initd(this) ) return
340
function get_elem1p_(this) result(p)
341
type(iCSR_C_b2D), intent(inout) :: this
342
type(iSM_CSR_C), pointer :: p
343
if ( .not. is_initd(this) ) then
349
subroutine get_elem2_(this, item)
350
type(iCSR_C_b2D), intent(in) :: this
351
type(bArray2D), intent(inout) :: item
352
if ( .not. is_initd(this) ) then
358
subroutine get_elem2_assign_(item, this)
359
type(bArray2D), intent(inout) :: item
360
type(iCSR_C_b2D), intent(in) :: this
361
if ( .not. is_initd(this) ) then
367
subroutine set_elem2_(this, item)
368
type(iCSR_C_b2D), intent(inout) :: this
369
type(bArray2D), intent(in) :: item
370
if ( .not. is_initd(this) ) return
373
function get_elem2p_(this) result(p)
374
type(iCSR_C_b2D), intent(inout) :: this
375
type(bArray2D), pointer :: p
376
if ( .not. is_initd(this) ) then
382
subroutine print_(this, info, indent)
383
type(iCSR_C_b2D), intent(in) :: this
384
character(len=*), intent(in), optional :: info
385
integer, intent(in), optional :: indent
387
character(len=32) :: fmt
388
character(len=256) :: name
390
if ( present(info) ) name = info
392
if ( present(indent) ) lindent = indent
393
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
394
if ( .not. is_initd(this) ) then
395
write(*,fmt) "<", trim(name), " not initialized>"
398
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
399
lindent = lindent + 2 ! step indentation
400
write(*,fmt) "<<", trim(name), " coll>"
401
call print(this%D%e1, indent = lindent)
402
call print(this%D%e2, indent = lindent)
403
lindent = lindent - 2 ! go back to requested indentation
404
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
405
write(*,fmt) " <coll-refs: ", references(this), ">>"
406
end subroutine print_
407
function matrix_p_(this) result(p)
408
type(iCSR_C_b2D), intent(in) :: this
409
logical, pointer :: p (:,:)
410
p => array_p(this%D%e2)
411
end function matrix_p_
412
function sparse_index_(this) result(idx)
413
type(iCSR_C_b2D), intent(in) :: this
416
end function sparse_index_
417
pure function dimensions_(this) result(d)
418
type(iCSR_C_b2D), intent(in) :: this
420
if ( is_initd(this) ) then
425
end function dimensions_
426
recursive subroutine add_element_(this, ir, ic, val)
427
type(iCSR_C_b2D), intent(inout) :: this
428
integer(ii_), intent(in) :: ir, ic
429
logical, intent(in) :: val
430
type(iSM_CSR_C) :: sm
431
type(iCSR_C_b2D) :: nthis
432
integer(ii_) :: i, c, ix, nr, nc, npc
433
logical, pointer :: p (:,:)
434
if ( .not. is_initd(this) ) return
436
call add_element(sm, ir, ic, dry_run = .true.)
437
if ( error(sm) /= 0 ) then
439
call set_error(this, -1)
442
call add_element(sm, ir, ic)
443
i = index(sm, ir, ic)
445
select case ( sparse_index(this) )
453
end subroutine add_element_
454
subroutine write_(f, this, only_array)
456
type( File ), intent(inout) :: f
457
type(iCSR_C_b2D), intent(inout) :: this
458
logical, intent(in), optional :: only_array
459
type(iSM_CSR_C) :: sm
460
type(bArray2D) :: arr
461
logical :: lonly_array
462
if ( .not. is_open(f) ) return
463
if ( .not. is_initd(this) ) return
464
lonly_array = .false.
465
if ( present(only_array) ) lonly_array = only_array
468
if ( .not. is_finalized(sm) ) then
471
call set_error(this, -1)
474
if ( .not. lonly_array ) then
480
end subroutine write_
481
subroutine read_(f, this, sm)
483
type( File ), intent(inout) :: f
484
type(iCSR_C_b2D), intent(inout) :: this
485
type(iSM_CSR_C), intent(inout), optional :: sm
486
type(iSM_CSR_C) :: lsm
487
type(bArray2D) :: arr
488
if ( .not. is_open(f) ) return
489
if ( present(sm) ) then
495
call new(this, lsm, arr)
499
module bud_iCSR_C_r2D
504
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
505
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
506
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
507
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
508
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
509
integer, parameter, private :: BUD_ID_LEn = 36
510
character(len=*), parameter, private :: &
511
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
512
character(len=*), parameter, private :: &
513
BUD_TYPe = "iCSR_C_r2D"
514
integer(ii_), parameter :: ONE = 1_ii_
515
integer(ii_), parameter :: ZERO = 0_ii_
517
module procedure matrix_p_
520
interface sparse_matrix
521
module procedure get_elem1_
523
public :: sparse_matrix
524
interface sparse_matrix_p
525
module procedure get_elem1p_
527
public :: sparse_matrix_p
528
interface sparse_index
529
module procedure sparse_index_
531
public :: sparse_index
533
module procedure dimensions_
537
module procedure get_elem2_
541
module procedure get_elem2p_
544
interface add_element
545
module procedure add_element_
547
public :: add_element
549
type(iCSR_C_r2D_), pointer :: D => null()
550
integer :: error_ = 0
553
type(iSM_CSR_C) :: e1
555
integer :: sm_idx = 2
557
character(len=BUD_ID_LEN) :: id_ = "null_id"
560
module procedure new_
561
module procedure new_data_
564
interface assignment(=)
565
module procedure get_elem1_assign_
566
module procedure get_elem2_assign_
567
module procedure set_elem1_
568
module procedure set_elem2_
571
module procedure get_elem1_
572
module procedure get_elem2_
574
interface set_element
575
module procedure set_elem1_
576
module procedure set_elem2_
579
module procedure get_elem1_
582
interface set_element1
583
module procedure set_elem1_
585
public :: set_element1
587
module procedure get_elem1p_
591
module procedure get_elem2_
594
interface set_element2
595
module procedure set_elem2_
597
public :: set_element2
599
module procedure get_elem2p_
603
private :: iCSR_C_r2D_
604
interface assignment(=)
605
module procedure common_assign_
607
public :: assignment(=)
608
private :: common_assign_
610
module procedure common_initialize_
613
private :: common_initialize_
614
interface is_initialized
615
module procedure common_is_initialized_
617
public :: is_initialized
618
private :: common_is_initialized_
619
interface initialized
620
module procedure common_is_initialized_
622
public :: initialized
624
module procedure common_is_initialized_
628
module procedure common_is_same_
631
private :: common_is_same_
633
module procedure common_is_same_
637
module procedure common_delete_
640
private :: common_delete_
642
module procedure common_nullify_
645
private :: common_nullify_
647
module procedure copy_
650
private :: common_copy_
652
module procedure print_
656
module procedure read_
660
module procedure write_
664
module procedure common_references_
667
private :: common_references_
669
module procedure common_references_
673
module procedure common_set_error_is_
674
module procedure common_set_error_ii_
675
module procedure common_set_error_il_
678
private :: common_set_error_is_
679
private :: common_set_error_ii_
680
private :: common_set_error_il_
682
module procedure common_error_
685
private :: common_error_
687
subroutine common_copy_(from, to)
688
type(iCSR_C_r2D), intent(in) :: from
689
type(iCSR_C_r2D), intent(inout) :: to
690
call set_error(to, error(from))
691
end subroutine common_copy_
692
subroutine common_initialize_(this)
693
type(iCSR_C_r2D), intent(inout) :: this
696
allocate(this%D, stat=error)
697
call set_error(this, error)
698
if ( error /= 0 ) return
700
call common_tag_object_(this)
701
end subroutine common_initialize_
702
pure function common_is_initialized_(this) result(init)
703
type(iCSR_C_r2D), intent(in) :: this
705
init = associated(this%D)
706
end function common_is_initialized_
707
elemental function common_is_same_(lhs, rhs) result(same)
708
type(iCSR_C_r2D), intent(in) :: lhs, rhs
710
same = is_initd(lhs) .and. is_initd(rhs)
711
if ( .not. same ) return
712
same = associated(lhs%D, target=rhs%D)
713
end function common_is_same_
714
subroutine common_delete_(this)
715
type(iCSR_C_r2D), intent(inout) :: this
717
call set_error(this, 0)
718
if (.not. is_initd(this) ) return
719
this%D%refs_ = this%D%refs_ - 1
720
if ( 0 == this%D%refs_ ) then
722
deallocate(this%D, stat=error)
723
call set_error(this, error)
726
end subroutine common_delete_
727
elemental subroutine common_nullify_(this)
728
type(iCSR_C_r2D), intent(inout) :: this
729
if (.not. is_initd(this) ) return
731
end subroutine common_nullify_
732
subroutine common_assign_(lhs, rhs)
733
type(iCSR_C_r2D), intent(inout) :: lhs
734
type(iCSR_C_r2D), intent(in) :: rhs
736
if ( .not. is_initd(rhs) ) return
738
lhs%D%refs_ = rhs%D%refs_ + 1
739
end subroutine common_assign_
740
elemental function common_references_(this) result(refs)
741
type(iCSR_C_r2D), intent(in) :: this
743
if ( is_initd(this) ) then
748
end function common_references_
749
elemental function common_error_(this) result(error)
750
type(iCSR_C_r2D), intent(in) :: this
752
if ( is_initd(this) ) then
757
end function common_error_
758
elemental subroutine common_set_error_is_(this, error)
759
type(iCSR_C_r2D), intent(inout) :: this
760
integer(is_), intent(in) :: error
762
end subroutine common_set_error_is_
763
elemental subroutine common_set_error_ii_(this, error)
764
type(iCSR_C_r2D), intent(inout) :: this
765
integer(ii_), intent(in) :: error
767
end subroutine common_set_error_ii_
768
elemental subroutine common_set_error_il_(this, error)
769
type(iCSR_C_r2D), intent(inout) :: this
770
integer(il_), intent(in) :: error
772
end subroutine common_set_error_il_
773
elemental function common_id_(this) result(str)
774
type(iCSR_C_r2D), intent(in) :: this
775
character(len=BUD_ID_LEn) :: str
777
end function common_id_
778
subroutine common_tag_object_(this)
779
type(iCSR_C_r2D), intent(inout) :: this
780
end subroutine common_tag_object_
781
subroutine delete_(this)
782
type(iCSR_C_r2D), intent(inout) :: this
783
call set_error(this, 0)
784
call delete(this%D%e1)
785
if ( 0 /= error(this%D%e1) ) &
786
call set_error(this, error(this%D%e1))
787
call delete(this%D%e2)
788
if ( 0 /= error(this%D%e2) ) &
789
call set_error(this, error(this%D%e2))
790
end subroutine delete_
791
subroutine copy_(from, to)
792
type(iCSR_C_r2D), intent(in) :: from
793
type(iCSR_C_r2D), intent(inout) :: to
795
if ( .not. is_initd(from) ) return
797
call common_copy_(from, to)
798
call copy(from%D%e1, to%D%e1)
799
call copy(from%D%e2, to%D%e2)
801
subroutine new_data_(this, a, b &
803
type(iCSR_C_r2D), intent(inout) :: this
804
type(iSM_CSR_C), intent(inout) :: a
805
type(rArray2D), intent(inout) :: b
809
end subroutine new_data_
810
subroutine new_(this)
811
type(iCSR_C_r2D), intent(inout) :: this
812
call initialize(this)
814
subroutine get_elem1_(this, item)
815
type(iCSR_C_r2D), intent(in) :: this
816
type(iSM_CSR_C), intent(inout) :: item
817
if ( .not. is_initd(this) ) then
823
subroutine get_elem1_assign_(item, this)
824
type(iSM_CSR_C), intent(inout) :: item
825
type(iCSR_C_r2D), intent(in) :: this
826
if ( .not. is_initd(this) ) then
832
subroutine set_elem1_(this, item)
833
type(iCSR_C_r2D), intent(inout) :: this
834
type(iSM_CSR_C), intent(in) :: item
835
if ( .not. is_initd(this) ) return
838
function get_elem1p_(this) result(p)
839
type(iCSR_C_r2D), intent(inout) :: this
840
type(iSM_CSR_C), pointer :: p
841
if ( .not. is_initd(this) ) then
847
subroutine get_elem2_(this, item)
848
type(iCSR_C_r2D), intent(in) :: this
849
type(rArray2D), intent(inout) :: item
850
if ( .not. is_initd(this) ) then
856
subroutine get_elem2_assign_(item, this)
857
type(rArray2D), intent(inout) :: item
858
type(iCSR_C_r2D), intent(in) :: this
859
if ( .not. is_initd(this) ) then
865
subroutine set_elem2_(this, item)
866
type(iCSR_C_r2D), intent(inout) :: this
867
type(rArray2D), intent(in) :: item
868
if ( .not. is_initd(this) ) return
871
function get_elem2p_(this) result(p)
872
type(iCSR_C_r2D), intent(inout) :: this
873
type(rArray2D), pointer :: p
874
if ( .not. is_initd(this) ) then
880
subroutine print_(this, info, indent)
881
type(iCSR_C_r2D), intent(in) :: this
882
character(len=*), intent(in), optional :: info
883
integer, intent(in), optional :: indent
885
character(len=32) :: fmt
886
character(len=256) :: name
888
if ( present(info) ) name = info
890
if ( present(indent) ) lindent = indent
891
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
892
if ( .not. is_initd(this) ) then
893
write(*,fmt) "<", trim(name), " not initialized>"
896
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
897
lindent = lindent + 2 ! step indentation
898
write(*,fmt) "<<", trim(name), " coll>"
899
call print(this%D%e1, indent = lindent)
900
call print(this%D%e2, indent = lindent)
901
lindent = lindent - 2 ! go back to requested indentation
902
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
903
write(*,fmt) " <coll-refs: ", references(this), ">>"
904
end subroutine print_
905
function matrix_p_(this) result(p)
906
type(iCSR_C_r2D), intent(in) :: this
907
real(rr_), pointer :: p (:,:)
908
p => array_p(this%D%e2)
909
end function matrix_p_
910
function sparse_index_(this) result(idx)
911
type(iCSR_C_r2D), intent(in) :: this
914
end function sparse_index_
915
pure function dimensions_(this) result(d)
916
type(iCSR_C_r2D), intent(in) :: this
918
if ( is_initd(this) ) then
923
end function dimensions_
924
recursive subroutine add_element_(this, ir, ic, val)
925
type(iCSR_C_r2D), intent(inout) :: this
926
integer(ii_), intent(in) :: ir, ic
927
real(rr_), intent(in) :: val
928
type(iSM_CSR_C) :: sm
929
type(iCSR_C_r2D) :: nthis
930
integer(ii_) :: i, c, ix, nr, nc, npc
931
real(rr_), pointer :: p (:,:)
932
if ( .not. is_initd(this) ) return
934
call add_element(sm, ir, ic, dry_run = .true.)
935
if ( error(sm) /= 0 ) then
937
call set_error(this, -1)
940
call add_element(sm, ir, ic)
941
i = index(sm, ir, ic)
943
select case ( sparse_index(this) )
951
end subroutine add_element_
952
subroutine write_(f, this, only_array)
954
type( File ), intent(inout) :: f
955
type(iCSR_C_r2D), intent(inout) :: this
956
logical, intent(in), optional :: only_array
957
type(iSM_CSR_C) :: sm
958
type(rArray2D) :: arr
959
logical :: lonly_array
960
if ( .not. is_open(f) ) return
961
if ( .not. is_initd(this) ) return
962
lonly_array = .false.
963
if ( present(only_array) ) lonly_array = only_array
966
if ( .not. is_finalized(sm) ) then
969
call set_error(this, -1)
972
if ( .not. lonly_array ) then
978
end subroutine write_
979
subroutine read_(f, this, sm)
981
type( File ), intent(inout) :: f
982
type(iCSR_C_r2D), intent(inout) :: this
983
type(iSM_CSR_C), intent(inout), optional :: sm
984
type(iSM_CSR_C) :: lsm
985
type(rArray2D) :: arr
986
if ( .not. is_open(f) ) return
987
if ( present(sm) ) then
993
call new(this, lsm, arr)
997
module bud_iCSR_C_d2D
1002
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1003
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
1004
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
1005
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
1006
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
1007
integer, parameter, private :: BUD_ID_LEn = 36
1008
character(len=*), parameter, private :: &
1009
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
1010
character(len=*), parameter, private :: &
1011
BUD_TYPe = "iCSR_C_d2D"
1012
integer(ii_), parameter :: ONE = 1_ii_
1013
integer(ii_), parameter :: ZERO = 0_ii_
1015
module procedure matrix_p_
1018
interface sparse_matrix
1019
module procedure get_elem1_
1021
public :: sparse_matrix
1022
interface sparse_matrix_p
1023
module procedure get_elem1p_
1025
public :: sparse_matrix_p
1026
interface sparse_index
1027
module procedure sparse_index_
1029
public :: sparse_index
1030
interface dimensions
1031
module procedure dimensions_
1033
public :: dimensions
1035
module procedure get_elem2_
1039
module procedure get_elem2p_
1042
interface add_element
1043
module procedure add_element_
1045
public :: add_element
1047
type(iCSR_C_d2D_), pointer :: D => null()
1048
integer :: error_ = 0
1051
type(iSM_CSR_C) :: e1
1052
type(dArray2D) :: e2
1053
integer :: sm_idx = 2
1054
integer :: refs_ = 0
1055
character(len=BUD_ID_LEN) :: id_ = "null_id"
1056
end type iCSR_C_d2D_
1058
module procedure new_
1059
module procedure new_data_
1062
interface assignment(=)
1063
module procedure get_elem1_assign_
1064
module procedure get_elem2_assign_
1065
module procedure set_elem1_
1066
module procedure set_elem2_
1069
module procedure get_elem1_
1070
module procedure get_elem2_
1072
interface set_element
1073
module procedure set_elem1_
1074
module procedure set_elem2_
1077
module procedure get_elem1_
1080
interface set_element1
1081
module procedure set_elem1_
1083
public :: set_element1
1084
interface element1_p
1085
module procedure get_elem1p_
1087
public :: element1_p
1089
module procedure get_elem2_
1092
interface set_element2
1093
module procedure set_elem2_
1095
public :: set_element2
1096
interface element2_p
1097
module procedure get_elem2p_
1099
public :: element2_p
1100
public :: iCSR_C_d2D
1101
private :: iCSR_C_d2D_
1102
interface assignment(=)
1103
module procedure common_assign_
1105
public :: assignment(=)
1106
private :: common_assign_
1107
interface initialize
1108
module procedure common_initialize_
1110
public :: initialize
1111
private :: common_initialize_
1112
interface is_initialized
1113
module procedure common_is_initialized_
1115
public :: is_initialized
1116
private :: common_is_initialized_
1117
interface initialized
1118
module procedure common_is_initialized_
1120
public :: initialized
1122
module procedure common_is_initialized_
1126
module procedure common_is_same_
1129
private :: common_is_same_
1131
module procedure common_is_same_
1135
module procedure common_delete_
1138
private :: common_delete_
1140
module procedure common_nullify_
1143
private :: common_nullify_
1145
module procedure copy_
1148
private :: common_copy_
1150
module procedure print_
1154
module procedure read_
1158
module procedure write_
1161
interface references
1162
module procedure common_references_
1164
public :: references
1165
private :: common_references_
1167
module procedure common_references_
1171
module procedure common_set_error_is_
1172
module procedure common_set_error_ii_
1173
module procedure common_set_error_il_
1176
private :: common_set_error_is_
1177
private :: common_set_error_ii_
1178
private :: common_set_error_il_
1180
module procedure common_error_
1183
private :: common_error_
1185
subroutine common_copy_(from, to)
1186
type(iCSR_C_d2D), intent(in) :: from
1187
type(iCSR_C_d2D), intent(inout) :: to
1188
call set_error(to, error(from))
1189
end subroutine common_copy_
1190
subroutine common_initialize_(this)
1191
type(iCSR_C_d2D), intent(inout) :: this
1194
allocate(this%D, stat=error)
1195
call set_error(this, error)
1196
if ( error /= 0 ) return
1198
call common_tag_object_(this)
1199
end subroutine common_initialize_
1200
pure function common_is_initialized_(this) result(init)
1201
type(iCSR_C_d2D), intent(in) :: this
1203
init = associated(this%D)
1204
end function common_is_initialized_
1205
elemental function common_is_same_(lhs, rhs) result(same)
1206
type(iCSR_C_d2D), intent(in) :: lhs, rhs
1208
same = is_initd(lhs) .and. is_initd(rhs)
1209
if ( .not. same ) return
1210
same = associated(lhs%D, target=rhs%D)
1211
end function common_is_same_
1212
subroutine common_delete_(this)
1213
type(iCSR_C_d2D), intent(inout) :: this
1215
call set_error(this, 0)
1216
if (.not. is_initd(this) ) return
1217
this%D%refs_ = this%D%refs_ - 1
1218
if ( 0 == this%D%refs_ ) then
1220
deallocate(this%D, stat=error)
1221
call set_error(this, error)
1224
end subroutine common_delete_
1225
elemental subroutine common_nullify_(this)
1226
type(iCSR_C_d2D), intent(inout) :: this
1227
if (.not. is_initd(this) ) return
1229
end subroutine common_nullify_
1230
subroutine common_assign_(lhs, rhs)
1231
type(iCSR_C_d2D), intent(inout) :: lhs
1232
type(iCSR_C_d2D), intent(in) :: rhs
1234
if ( .not. is_initd(rhs) ) return
1236
lhs%D%refs_ = rhs%D%refs_ + 1
1237
end subroutine common_assign_
1238
elemental function common_references_(this) result(refs)
1239
type(iCSR_C_d2D), intent(in) :: this
1241
if ( is_initd(this) ) then
1246
end function common_references_
1247
elemental function common_error_(this) result(error)
1248
type(iCSR_C_d2D), intent(in) :: this
1250
if ( is_initd(this) ) then
1255
end function common_error_
1256
elemental subroutine common_set_error_is_(this, error)
1257
type(iCSR_C_d2D), intent(inout) :: this
1258
integer(is_), intent(in) :: error
1260
end subroutine common_set_error_is_
1261
elemental subroutine common_set_error_ii_(this, error)
1262
type(iCSR_C_d2D), intent(inout) :: this
1263
integer(ii_), intent(in) :: error
1265
end subroutine common_set_error_ii_
1266
elemental subroutine common_set_error_il_(this, error)
1267
type(iCSR_C_d2D), intent(inout) :: this
1268
integer(il_), intent(in) :: error
1270
end subroutine common_set_error_il_
1271
elemental function common_id_(this) result(str)
1272
type(iCSR_C_d2D), intent(in) :: this
1273
character(len=BUD_ID_LEn) :: str
1275
end function common_id_
1276
subroutine common_tag_object_(this)
1277
type(iCSR_C_d2D), intent(inout) :: this
1278
end subroutine common_tag_object_
1279
subroutine delete_(this)
1280
type(iCSR_C_d2D), intent(inout) :: this
1281
call set_error(this, 0)
1282
call delete(this%D%e1)
1283
if ( 0 /= error(this%D%e1) ) &
1284
call set_error(this, error(this%D%e1))
1285
call delete(this%D%e2)
1286
if ( 0 /= error(this%D%e2) ) &
1287
call set_error(this, error(this%D%e2))
1288
end subroutine delete_
1289
subroutine copy_(from, to)
1290
type(iCSR_C_d2D), intent(in) :: from
1291
type(iCSR_C_d2D), intent(inout) :: to
1293
if ( .not. is_initd(from) ) return
1295
call common_copy_(from, to)
1296
call copy(from%D%e1, to%D%e1)
1297
call copy(from%D%e2, to%D%e2)
1298
end subroutine copy_
1299
subroutine new_data_(this, a, b &
1301
type(iCSR_C_d2D), intent(inout) :: this
1302
type(iSM_CSR_C), intent(inout) :: a
1303
type(dArray2D), intent(inout) :: b
1307
end subroutine new_data_
1308
subroutine new_(this)
1309
type(iCSR_C_d2D), intent(inout) :: this
1310
call initialize(this)
1312
subroutine get_elem1_(this, item)
1313
type(iCSR_C_d2D), intent(in) :: this
1314
type(iSM_CSR_C), intent(inout) :: item
1315
if ( .not. is_initd(this) ) then
1321
subroutine get_elem1_assign_(item, this)
1322
type(iSM_CSR_C), intent(inout) :: item
1323
type(iCSR_C_d2D), intent(in) :: this
1324
if ( .not. is_initd(this) ) then
1330
subroutine set_elem1_(this, item)
1331
type(iCSR_C_d2D), intent(inout) :: this
1332
type(iSM_CSR_C), intent(in) :: item
1333
if ( .not. is_initd(this) ) return
1336
function get_elem1p_(this) result(p)
1337
type(iCSR_C_d2D), intent(inout) :: this
1338
type(iSM_CSR_C), pointer :: p
1339
if ( .not. is_initd(this) ) then
1345
subroutine get_elem2_(this, item)
1346
type(iCSR_C_d2D), intent(in) :: this
1347
type(dArray2D), intent(inout) :: item
1348
if ( .not. is_initd(this) ) then
1354
subroutine get_elem2_assign_(item, this)
1355
type(dArray2D), intent(inout) :: item
1356
type(iCSR_C_d2D), intent(in) :: this
1357
if ( .not. is_initd(this) ) then
1363
subroutine set_elem2_(this, item)
1364
type(iCSR_C_d2D), intent(inout) :: this
1365
type(dArray2D), intent(in) :: item
1366
if ( .not. is_initd(this) ) return
1369
function get_elem2p_(this) result(p)
1370
type(iCSR_C_d2D), intent(inout) :: this
1371
type(dArray2D), pointer :: p
1372
if ( .not. is_initd(this) ) then
1378
subroutine print_(this, info, indent)
1379
type(iCSR_C_d2D), intent(in) :: this
1380
character(len=*), intent(in), optional :: info
1381
integer, intent(in), optional :: indent
1383
character(len=32) :: fmt
1384
character(len=256) :: name
1386
if ( present(info) ) name = info
1388
if ( present(indent) ) lindent = indent
1389
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1390
if ( .not. is_initd(this) ) then
1391
write(*,fmt) "<", trim(name), " not initialized>"
1394
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1395
lindent = lindent + 2 ! step indentation
1396
write(*,fmt) "<<", trim(name), " coll>"
1397
call print(this%D%e1, indent = lindent)
1398
call print(this%D%e2, indent = lindent)
1399
lindent = lindent - 2 ! go back to requested indentation
1400
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
1401
write(*,fmt) " <coll-refs: ", references(this), ">>"
1402
end subroutine print_
1403
function matrix_p_(this) result(p)
1404
type(iCSR_C_d2D), intent(in) :: this
1405
real(rd_), pointer :: p (:,:)
1406
p => array_p(this%D%e2)
1407
end function matrix_p_
1408
function sparse_index_(this) result(idx)
1409
type(iCSR_C_d2D), intent(in) :: this
1412
end function sparse_index_
1413
pure function dimensions_(this) result(d)
1414
type(iCSR_C_d2D), intent(in) :: this
1416
if ( is_initd(this) ) then
1421
end function dimensions_
1422
recursive subroutine add_element_(this, ir, ic, val)
1423
type(iCSR_C_d2D), intent(inout) :: this
1424
integer(ii_), intent(in) :: ir, ic
1425
real(rd_), intent(in) :: val
1426
type(iSM_CSR_C) :: sm
1427
type(iCSR_C_d2D) :: nthis
1428
integer(ii_) :: i, c, ix, nr, nc, npc
1429
real(rd_), pointer :: p (:,:)
1430
if ( .not. is_initd(this) ) return
1432
call add_element(sm, ir, ic, dry_run = .true.)
1433
if ( error(sm) /= 0 ) then
1435
call set_error(this, -1)
1438
call add_element(sm, ir, ic)
1439
i = index(sm, ir, ic)
1441
select case ( sparse_index(this) )
1449
end subroutine add_element_
1450
subroutine write_(f, this, only_array)
1452
type( File ), intent(inout) :: f
1453
type(iCSR_C_d2D), intent(inout) :: this
1454
logical, intent(in), optional :: only_array
1455
type(iSM_CSR_C) :: sm
1456
type(dArray2D) :: arr
1457
logical :: lonly_array
1458
if ( .not. is_open(f) ) return
1459
if ( .not. is_initd(this) ) return
1460
lonly_array = .false.
1461
if ( present(only_array) ) lonly_array = only_array
1464
if ( .not. is_finalized(sm) ) then
1467
call set_error(this, -1)
1470
if ( .not. lonly_array ) then
1476
end subroutine write_
1477
subroutine read_(f, this, sm)
1479
type( File ), intent(inout) :: f
1480
type(iCSR_C_d2D), intent(inout) :: this
1481
type(iSM_CSR_C), intent(inout), optional :: sm
1482
type(iSM_CSR_C) :: lsm
1483
type(dArray2D) :: arr
1484
if ( .not. is_open(f) ) return
1485
if ( present(sm) ) then
1491
call new(this, lsm, arr)
1493
end subroutine read_
1495
module bud_iCSR_C_c2D
1500
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1501
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
1502
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
1503
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
1504
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
1505
integer, parameter, private :: BUD_ID_LEn = 36
1506
character(len=*), parameter, private :: &
1507
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
1508
character(len=*), parameter, private :: &
1509
BUD_TYPe = "iCSR_C_c2D"
1510
integer(ii_), parameter :: ONE = 1_ii_
1511
integer(ii_), parameter :: ZERO = 0_ii_
1513
module procedure matrix_p_
1516
interface sparse_matrix
1517
module procedure get_elem1_
1519
public :: sparse_matrix
1520
interface sparse_matrix_p
1521
module procedure get_elem1p_
1523
public :: sparse_matrix_p
1524
interface sparse_index
1525
module procedure sparse_index_
1527
public :: sparse_index
1528
interface dimensions
1529
module procedure dimensions_
1531
public :: dimensions
1533
module procedure get_elem2_
1537
module procedure get_elem2p_
1540
interface add_element
1541
module procedure add_element_
1543
public :: add_element
1545
type(iCSR_C_c2D_), pointer :: D => null()
1546
integer :: error_ = 0
1549
type(iSM_CSR_C) :: e1
1550
type(cArray2D) :: e2
1551
integer :: sm_idx = 2
1552
integer :: refs_ = 0
1553
character(len=BUD_ID_LEN) :: id_ = "null_id"
1554
end type iCSR_C_c2D_
1556
module procedure new_
1557
module procedure new_data_
1560
interface assignment(=)
1561
module procedure get_elem1_assign_
1562
module procedure get_elem2_assign_
1563
module procedure set_elem1_
1564
module procedure set_elem2_
1567
module procedure get_elem1_
1568
module procedure get_elem2_
1570
interface set_element
1571
module procedure set_elem1_
1572
module procedure set_elem2_
1575
module procedure get_elem1_
1578
interface set_element1
1579
module procedure set_elem1_
1581
public :: set_element1
1582
interface element1_p
1583
module procedure get_elem1p_
1585
public :: element1_p
1587
module procedure get_elem2_
1590
interface set_element2
1591
module procedure set_elem2_
1593
public :: set_element2
1594
interface element2_p
1595
module procedure get_elem2p_
1597
public :: element2_p
1598
public :: iCSR_C_c2D
1599
private :: iCSR_C_c2D_
1600
interface assignment(=)
1601
module procedure common_assign_
1603
public :: assignment(=)
1604
private :: common_assign_
1605
interface initialize
1606
module procedure common_initialize_
1608
public :: initialize
1609
private :: common_initialize_
1610
interface is_initialized
1611
module procedure common_is_initialized_
1613
public :: is_initialized
1614
private :: common_is_initialized_
1615
interface initialized
1616
module procedure common_is_initialized_
1618
public :: initialized
1620
module procedure common_is_initialized_
1624
module procedure common_is_same_
1627
private :: common_is_same_
1629
module procedure common_is_same_
1633
module procedure common_delete_
1636
private :: common_delete_
1638
module procedure common_nullify_
1641
private :: common_nullify_
1643
module procedure copy_
1646
private :: common_copy_
1648
module procedure print_
1652
module procedure read_
1656
module procedure write_
1659
interface references
1660
module procedure common_references_
1662
public :: references
1663
private :: common_references_
1665
module procedure common_references_
1669
module procedure common_set_error_is_
1670
module procedure common_set_error_ii_
1671
module procedure common_set_error_il_
1674
private :: common_set_error_is_
1675
private :: common_set_error_ii_
1676
private :: common_set_error_il_
1678
module procedure common_error_
1681
private :: common_error_
1683
subroutine common_copy_(from, to)
1684
type(iCSR_C_c2D), intent(in) :: from
1685
type(iCSR_C_c2D), intent(inout) :: to
1686
call set_error(to, error(from))
1687
end subroutine common_copy_
1688
subroutine common_initialize_(this)
1689
type(iCSR_C_c2D), intent(inout) :: this
1692
allocate(this%D, stat=error)
1693
call set_error(this, error)
1694
if ( error /= 0 ) return
1696
call common_tag_object_(this)
1697
end subroutine common_initialize_
1698
pure function common_is_initialized_(this) result(init)
1699
type(iCSR_C_c2D), intent(in) :: this
1701
init = associated(this%D)
1702
end function common_is_initialized_
1703
elemental function common_is_same_(lhs, rhs) result(same)
1704
type(iCSR_C_c2D), intent(in) :: lhs, rhs
1706
same = is_initd(lhs) .and. is_initd(rhs)
1707
if ( .not. same ) return
1708
same = associated(lhs%D, target=rhs%D)
1709
end function common_is_same_
1710
subroutine common_delete_(this)
1711
type(iCSR_C_c2D), intent(inout) :: this
1713
call set_error(this, 0)
1714
if (.not. is_initd(this) ) return
1715
this%D%refs_ = this%D%refs_ - 1
1716
if ( 0 == this%D%refs_ ) then
1718
deallocate(this%D, stat=error)
1719
call set_error(this, error)
1722
end subroutine common_delete_
1723
elemental subroutine common_nullify_(this)
1724
type(iCSR_C_c2D), intent(inout) :: this
1725
if (.not. is_initd(this) ) return
1727
end subroutine common_nullify_
1728
subroutine common_assign_(lhs, rhs)
1729
type(iCSR_C_c2D), intent(inout) :: lhs
1730
type(iCSR_C_c2D), intent(in) :: rhs
1732
if ( .not. is_initd(rhs) ) return
1734
lhs%D%refs_ = rhs%D%refs_ + 1
1735
end subroutine common_assign_
1736
elemental function common_references_(this) result(refs)
1737
type(iCSR_C_c2D), intent(in) :: this
1739
if ( is_initd(this) ) then
1744
end function common_references_
1745
elemental function common_error_(this) result(error)
1746
type(iCSR_C_c2D), intent(in) :: this
1748
if ( is_initd(this) ) then
1753
end function common_error_
1754
elemental subroutine common_set_error_is_(this, error)
1755
type(iCSR_C_c2D), intent(inout) :: this
1756
integer(is_), intent(in) :: error
1758
end subroutine common_set_error_is_
1759
elemental subroutine common_set_error_ii_(this, error)
1760
type(iCSR_C_c2D), intent(inout) :: this
1761
integer(ii_), intent(in) :: error
1763
end subroutine common_set_error_ii_
1764
elemental subroutine common_set_error_il_(this, error)
1765
type(iCSR_C_c2D), intent(inout) :: this
1766
integer(il_), intent(in) :: error
1768
end subroutine common_set_error_il_
1769
elemental function common_id_(this) result(str)
1770
type(iCSR_C_c2D), intent(in) :: this
1771
character(len=BUD_ID_LEn) :: str
1773
end function common_id_
1774
subroutine common_tag_object_(this)
1775
type(iCSR_C_c2D), intent(inout) :: this
1776
end subroutine common_tag_object_
1777
subroutine delete_(this)
1778
type(iCSR_C_c2D), intent(inout) :: this
1779
call set_error(this, 0)
1780
call delete(this%D%e1)
1781
if ( 0 /= error(this%D%e1) ) &
1782
call set_error(this, error(this%D%e1))
1783
call delete(this%D%e2)
1784
if ( 0 /= error(this%D%e2) ) &
1785
call set_error(this, error(this%D%e2))
1786
end subroutine delete_
1787
subroutine copy_(from, to)
1788
type(iCSR_C_c2D), intent(in) :: from
1789
type(iCSR_C_c2D), intent(inout) :: to
1791
if ( .not. is_initd(from) ) return
1793
call common_copy_(from, to)
1794
call copy(from%D%e1, to%D%e1)
1795
call copy(from%D%e2, to%D%e2)
1796
end subroutine copy_
1797
subroutine new_data_(this, a, b &
1799
type(iCSR_C_c2D), intent(inout) :: this
1800
type(iSM_CSR_C), intent(inout) :: a
1801
type(cArray2D), intent(inout) :: b
1805
end subroutine new_data_
1806
subroutine new_(this)
1807
type(iCSR_C_c2D), intent(inout) :: this
1808
call initialize(this)
1810
subroutine get_elem1_(this, item)
1811
type(iCSR_C_c2D), intent(in) :: this
1812
type(iSM_CSR_C), intent(inout) :: item
1813
if ( .not. is_initd(this) ) then
1819
subroutine get_elem1_assign_(item, this)
1820
type(iSM_CSR_C), intent(inout) :: item
1821
type(iCSR_C_c2D), intent(in) :: this
1822
if ( .not. is_initd(this) ) then
1828
subroutine set_elem1_(this, item)
1829
type(iCSR_C_c2D), intent(inout) :: this
1830
type(iSM_CSR_C), intent(in) :: item
1831
if ( .not. is_initd(this) ) return
1834
function get_elem1p_(this) result(p)
1835
type(iCSR_C_c2D), intent(inout) :: this
1836
type(iSM_CSR_C), pointer :: p
1837
if ( .not. is_initd(this) ) then
1843
subroutine get_elem2_(this, item)
1844
type(iCSR_C_c2D), intent(in) :: this
1845
type(cArray2D), intent(inout) :: item
1846
if ( .not. is_initd(this) ) then
1852
subroutine get_elem2_assign_(item, this)
1853
type(cArray2D), intent(inout) :: item
1854
type(iCSR_C_c2D), intent(in) :: this
1855
if ( .not. is_initd(this) ) then
1861
subroutine set_elem2_(this, item)
1862
type(iCSR_C_c2D), intent(inout) :: this
1863
type(cArray2D), intent(in) :: item
1864
if ( .not. is_initd(this) ) return
1867
function get_elem2p_(this) result(p)
1868
type(iCSR_C_c2D), intent(inout) :: this
1869
type(cArray2D), pointer :: p
1870
if ( .not. is_initd(this) ) then
1876
subroutine print_(this, info, indent)
1877
type(iCSR_C_c2D), intent(in) :: this
1878
character(len=*), intent(in), optional :: info
1879
integer, intent(in), optional :: indent
1881
character(len=32) :: fmt
1882
character(len=256) :: name
1884
if ( present(info) ) name = info
1886
if ( present(indent) ) lindent = indent
1887
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1888
if ( .not. is_initd(this) ) then
1889
write(*,fmt) "<", trim(name), " not initialized>"
1892
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1893
lindent = lindent + 2 ! step indentation
1894
write(*,fmt) "<<", trim(name), " coll>"
1895
call print(this%D%e1, indent = lindent)
1896
call print(this%D%e2, indent = lindent)
1897
lindent = lindent - 2 ! go back to requested indentation
1898
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
1899
write(*,fmt) " <coll-refs: ", references(this), ">>"
1900
end subroutine print_
1901
function matrix_p_(this) result(p)
1902
type(iCSR_C_c2D), intent(in) :: this
1903
complex(rr_), pointer :: p (:,:)
1904
p => array_p(this%D%e2)
1905
end function matrix_p_
1906
function sparse_index_(this) result(idx)
1907
type(iCSR_C_c2D), intent(in) :: this
1910
end function sparse_index_
1911
pure function dimensions_(this) result(d)
1912
type(iCSR_C_c2D), intent(in) :: this
1914
if ( is_initd(this) ) then
1919
end function dimensions_
1920
recursive subroutine add_element_(this, ir, ic, val)
1921
type(iCSR_C_c2D), intent(inout) :: this
1922
integer(ii_), intent(in) :: ir, ic
1923
complex(rr_), intent(in) :: val
1924
type(iSM_CSR_C) :: sm
1925
type(iCSR_C_c2D) :: nthis
1926
integer(ii_) :: i, c, ix, nr, nc, npc
1927
complex(rr_), pointer :: p (:,:)
1928
if ( .not. is_initd(this) ) return
1930
call add_element(sm, ir, ic, dry_run = .true.)
1931
if ( error(sm) /= 0 ) then
1933
call set_error(this, -1)
1936
call add_element(sm, ir, ic)
1937
i = index(sm, ir, ic)
1939
select case ( sparse_index(this) )
1947
end subroutine add_element_
1948
subroutine write_(f, this, only_array)
1950
type( File ), intent(inout) :: f
1951
type(iCSR_C_c2D), intent(inout) :: this
1952
logical, intent(in), optional :: only_array
1953
type(iSM_CSR_C) :: sm
1954
type(cArray2D) :: arr
1955
logical :: lonly_array
1956
if ( .not. is_open(f) ) return
1957
if ( .not. is_initd(this) ) return
1958
lonly_array = .false.
1959
if ( present(only_array) ) lonly_array = only_array
1962
if ( .not. is_finalized(sm) ) then
1965
call set_error(this, -1)
1968
if ( .not. lonly_array ) then
1974
end subroutine write_
1975
subroutine read_(f, this, sm)
1977
type( File ), intent(inout) :: f
1978
type(iCSR_C_c2D), intent(inout) :: this
1979
type(iSM_CSR_C), intent(inout), optional :: sm
1980
type(iSM_CSR_C) :: lsm
1981
type(cArray2D) :: arr
1982
if ( .not. is_open(f) ) return
1983
if ( present(sm) ) then
1989
call new(this, lsm, arr)
1991
end subroutine read_
1993
module bud_iCSR_C_z2D
1998
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1999
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
2000
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
2001
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
2002
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
2003
integer, parameter, private :: BUD_ID_LEn = 36
2004
character(len=*), parameter, private :: &
2005
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
2006
character(len=*), parameter, private :: &
2007
BUD_TYPe = "iCSR_C_z2D"
2008
integer(ii_), parameter :: ONE = 1_ii_
2009
integer(ii_), parameter :: ZERO = 0_ii_
2011
module procedure matrix_p_
2014
interface sparse_matrix
2015
module procedure get_elem1_
2017
public :: sparse_matrix
2018
interface sparse_matrix_p
2019
module procedure get_elem1p_
2021
public :: sparse_matrix_p
2022
interface sparse_index
2023
module procedure sparse_index_
2025
public :: sparse_index
2026
interface dimensions
2027
module procedure dimensions_
2029
public :: dimensions
2031
module procedure get_elem2_
2035
module procedure get_elem2p_
2038
interface add_element
2039
module procedure add_element_
2041
public :: add_element
2043
type(iCSR_C_z2D_), pointer :: D => null()
2044
integer :: error_ = 0
2047
type(iSM_CSR_C) :: e1
2048
type(zArray2D) :: e2
2049
integer :: sm_idx = 2
2050
integer :: refs_ = 0
2051
character(len=BUD_ID_LEN) :: id_ = "null_id"
2052
end type iCSR_C_z2D_
2054
module procedure new_
2055
module procedure new_data_
2058
interface assignment(=)
2059
module procedure get_elem1_assign_
2060
module procedure get_elem2_assign_
2061
module procedure set_elem1_
2062
module procedure set_elem2_
2065
module procedure get_elem1_
2066
module procedure get_elem2_
2068
interface set_element
2069
module procedure set_elem1_
2070
module procedure set_elem2_
2073
module procedure get_elem1_
2076
interface set_element1
2077
module procedure set_elem1_
2079
public :: set_element1
2080
interface element1_p
2081
module procedure get_elem1p_
2083
public :: element1_p
2085
module procedure get_elem2_
2088
interface set_element2
2089
module procedure set_elem2_
2091
public :: set_element2
2092
interface element2_p
2093
module procedure get_elem2p_
2095
public :: element2_p
2096
public :: iCSR_C_z2D
2097
private :: iCSR_C_z2D_
2098
interface assignment(=)
2099
module procedure common_assign_
2101
public :: assignment(=)
2102
private :: common_assign_
2103
interface initialize
2104
module procedure common_initialize_
2106
public :: initialize
2107
private :: common_initialize_
2108
interface is_initialized
2109
module procedure common_is_initialized_
2111
public :: is_initialized
2112
private :: common_is_initialized_
2113
interface initialized
2114
module procedure common_is_initialized_
2116
public :: initialized
2118
module procedure common_is_initialized_
2122
module procedure common_is_same_
2125
private :: common_is_same_
2127
module procedure common_is_same_
2131
module procedure common_delete_
2134
private :: common_delete_
2136
module procedure common_nullify_
2139
private :: common_nullify_
2141
module procedure copy_
2144
private :: common_copy_
2146
module procedure print_
2150
module procedure read_
2154
module procedure write_
2157
interface references
2158
module procedure common_references_
2160
public :: references
2161
private :: common_references_
2163
module procedure common_references_
2167
module procedure common_set_error_is_
2168
module procedure common_set_error_ii_
2169
module procedure common_set_error_il_
2172
private :: common_set_error_is_
2173
private :: common_set_error_ii_
2174
private :: common_set_error_il_
2176
module procedure common_error_
2179
private :: common_error_
2181
subroutine common_copy_(from, to)
2182
type(iCSR_C_z2D), intent(in) :: from
2183
type(iCSR_C_z2D), intent(inout) :: to
2184
call set_error(to, error(from))
2185
end subroutine common_copy_
2186
subroutine common_initialize_(this)
2187
type(iCSR_C_z2D), intent(inout) :: this
2190
allocate(this%D, stat=error)
2191
call set_error(this, error)
2192
if ( error /= 0 ) return
2194
call common_tag_object_(this)
2195
end subroutine common_initialize_
2196
pure function common_is_initialized_(this) result(init)
2197
type(iCSR_C_z2D), intent(in) :: this
2199
init = associated(this%D)
2200
end function common_is_initialized_
2201
elemental function common_is_same_(lhs, rhs) result(same)
2202
type(iCSR_C_z2D), intent(in) :: lhs, rhs
2204
same = is_initd(lhs) .and. is_initd(rhs)
2205
if ( .not. same ) return
2206
same = associated(lhs%D, target=rhs%D)
2207
end function common_is_same_
2208
subroutine common_delete_(this)
2209
type(iCSR_C_z2D), intent(inout) :: this
2211
call set_error(this, 0)
2212
if (.not. is_initd(this) ) return
2213
this%D%refs_ = this%D%refs_ - 1
2214
if ( 0 == this%D%refs_ ) then
2216
deallocate(this%D, stat=error)
2217
call set_error(this, error)
2220
end subroutine common_delete_
2221
elemental subroutine common_nullify_(this)
2222
type(iCSR_C_z2D), intent(inout) :: this
2223
if (.not. is_initd(this) ) return
2225
end subroutine common_nullify_
2226
subroutine common_assign_(lhs, rhs)
2227
type(iCSR_C_z2D), intent(inout) :: lhs
2228
type(iCSR_C_z2D), intent(in) :: rhs
2230
if ( .not. is_initd(rhs) ) return
2232
lhs%D%refs_ = rhs%D%refs_ + 1
2233
end subroutine common_assign_
2234
elemental function common_references_(this) result(refs)
2235
type(iCSR_C_z2D), intent(in) :: this
2237
if ( is_initd(this) ) then
2242
end function common_references_
2243
elemental function common_error_(this) result(error)
2244
type(iCSR_C_z2D), intent(in) :: this
2246
if ( is_initd(this) ) then
2251
end function common_error_
2252
elemental subroutine common_set_error_is_(this, error)
2253
type(iCSR_C_z2D), intent(inout) :: this
2254
integer(is_), intent(in) :: error
2256
end subroutine common_set_error_is_
2257
elemental subroutine common_set_error_ii_(this, error)
2258
type(iCSR_C_z2D), intent(inout) :: this
2259
integer(ii_), intent(in) :: error
2261
end subroutine common_set_error_ii_
2262
elemental subroutine common_set_error_il_(this, error)
2263
type(iCSR_C_z2D), intent(inout) :: this
2264
integer(il_), intent(in) :: error
2266
end subroutine common_set_error_il_
2267
elemental function common_id_(this) result(str)
2268
type(iCSR_C_z2D), intent(in) :: this
2269
character(len=BUD_ID_LEn) :: str
2271
end function common_id_
2272
subroutine common_tag_object_(this)
2273
type(iCSR_C_z2D), intent(inout) :: this
2274
end subroutine common_tag_object_
2275
subroutine delete_(this)
2276
type(iCSR_C_z2D), intent(inout) :: this
2277
call set_error(this, 0)
2278
call delete(this%D%e1)
2279
if ( 0 /= error(this%D%e1) ) &
2280
call set_error(this, error(this%D%e1))
2281
call delete(this%D%e2)
2282
if ( 0 /= error(this%D%e2) ) &
2283
call set_error(this, error(this%D%e2))
2284
end subroutine delete_
2285
subroutine copy_(from, to)
2286
type(iCSR_C_z2D), intent(in) :: from
2287
type(iCSR_C_z2D), intent(inout) :: to
2289
if ( .not. is_initd(from) ) return
2291
call common_copy_(from, to)
2292
call copy(from%D%e1, to%D%e1)
2293
call copy(from%D%e2, to%D%e2)
2294
end subroutine copy_
2295
subroutine new_data_(this, a, b &
2297
type(iCSR_C_z2D), intent(inout) :: this
2298
type(iSM_CSR_C), intent(inout) :: a
2299
type(zArray2D), intent(inout) :: b
2303
end subroutine new_data_
2304
subroutine new_(this)
2305
type(iCSR_C_z2D), intent(inout) :: this
2306
call initialize(this)
2308
subroutine get_elem1_(this, item)
2309
type(iCSR_C_z2D), intent(in) :: this
2310
type(iSM_CSR_C), intent(inout) :: item
2311
if ( .not. is_initd(this) ) then
2317
subroutine get_elem1_assign_(item, this)
2318
type(iSM_CSR_C), intent(inout) :: item
2319
type(iCSR_C_z2D), intent(in) :: this
2320
if ( .not. is_initd(this) ) then
2326
subroutine set_elem1_(this, item)
2327
type(iCSR_C_z2D), intent(inout) :: this
2328
type(iSM_CSR_C), intent(in) :: item
2329
if ( .not. is_initd(this) ) return
2332
function get_elem1p_(this) result(p)
2333
type(iCSR_C_z2D), intent(inout) :: this
2334
type(iSM_CSR_C), pointer :: p
2335
if ( .not. is_initd(this) ) then
2341
subroutine get_elem2_(this, item)
2342
type(iCSR_C_z2D), intent(in) :: this
2343
type(zArray2D), intent(inout) :: item
2344
if ( .not. is_initd(this) ) then
2350
subroutine get_elem2_assign_(item, this)
2351
type(zArray2D), intent(inout) :: item
2352
type(iCSR_C_z2D), intent(in) :: this
2353
if ( .not. is_initd(this) ) then
2359
subroutine set_elem2_(this, item)
2360
type(iCSR_C_z2D), intent(inout) :: this
2361
type(zArray2D), intent(in) :: item
2362
if ( .not. is_initd(this) ) return
2365
function get_elem2p_(this) result(p)
2366
type(iCSR_C_z2D), intent(inout) :: this
2367
type(zArray2D), pointer :: p
2368
if ( .not. is_initd(this) ) then
2374
subroutine print_(this, info, indent)
2375
type(iCSR_C_z2D), intent(in) :: this
2376
character(len=*), intent(in), optional :: info
2377
integer, intent(in), optional :: indent
2379
character(len=32) :: fmt
2380
character(len=256) :: name
2382
if ( present(info) ) name = info
2384
if ( present(indent) ) lindent = indent
2385
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
2386
if ( .not. is_initd(this) ) then
2387
write(*,fmt) "<", trim(name), " not initialized>"
2390
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
2391
lindent = lindent + 2 ! step indentation
2392
write(*,fmt) "<<", trim(name), " coll>"
2393
call print(this%D%e1, indent = lindent)
2394
call print(this%D%e2, indent = lindent)
2395
lindent = lindent - 2 ! go back to requested indentation
2396
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
2397
write(*,fmt) " <coll-refs: ", references(this), ">>"
2398
end subroutine print_
2399
function matrix_p_(this) result(p)
2400
type(iCSR_C_z2D), intent(in) :: this
2401
complex(rd_), pointer :: p (:,:)
2402
p => array_p(this%D%e2)
2403
end function matrix_p_
2404
function sparse_index_(this) result(idx)
2405
type(iCSR_C_z2D), intent(in) :: this
2408
end function sparse_index_
2409
pure function dimensions_(this) result(d)
2410
type(iCSR_C_z2D), intent(in) :: this
2412
if ( is_initd(this) ) then
2417
end function dimensions_
2418
recursive subroutine add_element_(this, ir, ic, val)
2419
type(iCSR_C_z2D), intent(inout) :: this
2420
integer(ii_), intent(in) :: ir, ic
2421
complex(rd_), intent(in) :: val
2422
type(iSM_CSR_C) :: sm
2423
type(iCSR_C_z2D) :: nthis
2424
integer(ii_) :: i, c, ix, nr, nc, npc
2425
complex(rd_), pointer :: p (:,:)
2426
if ( .not. is_initd(this) ) return
2428
call add_element(sm, ir, ic, dry_run = .true.)
2429
if ( error(sm) /= 0 ) then
2431
call set_error(this, -1)
2434
call add_element(sm, ir, ic)
2435
i = index(sm, ir, ic)
2437
select case ( sparse_index(this) )
2445
end subroutine add_element_
2446
subroutine write_(f, this, only_array)
2448
type( File ), intent(inout) :: f
2449
type(iCSR_C_z2D), intent(inout) :: this
2450
logical, intent(in), optional :: only_array
2451
type(iSM_CSR_C) :: sm
2452
type(zArray2D) :: arr
2453
logical :: lonly_array
2454
if ( .not. is_open(f) ) return
2455
if ( .not. is_initd(this) ) return
2456
lonly_array = .false.
2457
if ( present(only_array) ) lonly_array = only_array
2460
if ( .not. is_finalized(sm) ) then
2463
call set_error(this, -1)
2466
if ( .not. lonly_array ) then
2472
end subroutine write_
2473
subroutine read_(f, this, sm)
2475
type( File ), intent(inout) :: f
2476
type(iCSR_C_z2D), intent(inout) :: this
2477
type(iSM_CSR_C), intent(inout), optional :: sm
2478
type(iSM_CSR_C) :: lsm
2479
type(zArray2D) :: arr
2480
if ( .not. is_open(f) ) return
2481
if ( present(sm) ) then
2487
call new(this, lsm, arr)
2489
end subroutine read_