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 = "iCSC0_b3D"
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(iCSC0_b3D_), 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 :: iCSC0_b3D_
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(iCSC0_b3D), intent(in) :: from
191
type(iCSC0_b3D), intent(inout) :: to
192
call set_error(to, error(from))
193
end subroutine common_copy_
194
subroutine common_initialize_(this)
195
type(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), intent(inout) :: this
231
if (.not. is_initd(this) ) return
233
end subroutine common_nullify_
234
subroutine common_assign_(lhs, rhs)
235
type(iCSC0_b3D), intent(inout) :: lhs
236
type(iCSC0_b3D), 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(iCSC0_b3D), intent(in) :: this
245
if ( is_initd(this) ) then
250
end function common_references_
251
elemental function common_error_(this) result(error)
252
type(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), intent(in) :: this
277
character(len=BUD_ID_LEn) :: str
279
end function common_id_
280
subroutine common_tag_object_(this)
281
type(iCSC0_b3D), intent(inout) :: this
282
end subroutine common_tag_object_
283
subroutine delete_(this)
284
type(iCSC0_b3D), 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(iCSC0_b3D), intent(in) :: from
295
type(iCSC0_b3D), 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(iCSC0_b3D), intent(inout) :: this
306
type(iSM_CSC0), intent(inout) :: a
307
type(bArray3D), intent(inout) :: b
311
end subroutine new_data_
312
subroutine new_(this)
313
type(iCSC0_b3D), intent(inout) :: this
314
call initialize(this)
316
subroutine get_elem1_(this, item)
317
type(iCSC0_b3D), intent(in) :: this
318
type(iSM_CSC0), intent(inout) :: item
319
if ( .not. is_initd(this) ) then
325
subroutine get_elem1_assign_(item, this)
326
type(iSM_CSC0), intent(inout) :: item
327
type(iCSC0_b3D), intent(in) :: this
328
if ( .not. is_initd(this) ) then
334
subroutine set_elem1_(this, item)
335
type(iCSC0_b3D), intent(inout) :: this
336
type(iSM_CSC0), intent(in) :: item
337
if ( .not. is_initd(this) ) return
340
function get_elem1p_(this) result(p)
341
type(iCSC0_b3D), intent(inout) :: this
342
type(iSM_CSC0), pointer :: p
343
if ( .not. is_initd(this) ) then
349
subroutine get_elem2_(this, item)
350
type(iCSC0_b3D), intent(in) :: this
351
type(bArray3D), intent(inout) :: item
352
if ( .not. is_initd(this) ) then
358
subroutine get_elem2_assign_(item, this)
359
type(bArray3D), intent(inout) :: item
360
type(iCSC0_b3D), intent(in) :: this
361
if ( .not. is_initd(this) ) then
367
subroutine set_elem2_(this, item)
368
type(iCSC0_b3D), intent(inout) :: this
369
type(bArray3D), intent(in) :: item
370
if ( .not. is_initd(this) ) return
373
function get_elem2p_(this) result(p)
374
type(iCSC0_b3D), intent(inout) :: this
375
type(bArray3D), pointer :: p
376
if ( .not. is_initd(this) ) then
382
subroutine print_(this, info, indent)
383
type(iCSC0_b3D), 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(iCSC0_b3D), 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(iCSC0_b3D), intent(in) :: this
416
end function sparse_index_
417
pure function dimensions_(this) result(d)
418
type(iCSC0_b3D), intent(in) :: this
420
if ( is_initd(this) ) then
425
end function dimensions_
426
recursive subroutine add_element_(this, ir, ic, val)
427
type(iCSC0_b3D), intent(inout) :: this
428
integer(ii_), intent(in) :: ir, ic
429
logical, intent(in) :: val
431
type(iCSC0_b3D) :: 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) )
454
end subroutine add_element_
455
subroutine write_(f, this, only_array)
457
type( File ), intent(inout) :: f
458
type(iCSC0_b3D), intent(inout) :: this
459
logical, intent(in), optional :: only_array
461
type(bArray3D) :: arr
462
logical :: lonly_array
463
if ( .not. is_open(f) ) return
464
if ( .not. is_initd(this) ) return
465
lonly_array = .false.
466
if ( present(only_array) ) lonly_array = only_array
469
if ( .not. is_finalized(sm) ) then
472
call set_error(this, -1)
475
if ( .not. lonly_array ) then
481
end subroutine write_
482
subroutine read_(f, this, sm)
484
type( File ), intent(inout) :: f
485
type(iCSC0_b3D), intent(inout) :: this
486
type(iSM_CSC0), intent(inout), optional :: sm
487
type(iSM_CSC0) :: lsm
488
type(bArray3D) :: arr
489
if ( .not. is_open(f) ) return
490
if ( present(sm) ) then
496
call new(this, lsm, arr)
505
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
506
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
507
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
508
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
509
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
510
integer, parameter, private :: BUD_ID_LEn = 36
511
character(len=*), parameter, private :: &
512
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
513
character(len=*), parameter, private :: &
514
BUD_TYPe = "iCSC0_r3D"
515
integer(ii_), parameter :: ONE = 1_ii_
516
integer(ii_), parameter :: ZERO = 0_ii_
518
module procedure matrix_p_
521
interface sparse_matrix
522
module procedure get_elem1_
524
public :: sparse_matrix
525
interface sparse_matrix_p
526
module procedure get_elem1p_
528
public :: sparse_matrix_p
529
interface sparse_index
530
module procedure sparse_index_
532
public :: sparse_index
534
module procedure dimensions_
538
module procedure get_elem2_
542
module procedure get_elem2p_
545
interface add_element
546
module procedure add_element_
548
public :: add_element
550
type(iCSC0_r3D_), pointer :: D => null()
551
integer :: error_ = 0
556
integer :: sm_idx = 3
558
character(len=BUD_ID_LEN) :: id_ = "null_id"
561
module procedure new_
562
module procedure new_data_
565
interface assignment(=)
566
module procedure get_elem1_assign_
567
module procedure get_elem2_assign_
568
module procedure set_elem1_
569
module procedure set_elem2_
572
module procedure get_elem1_
573
module procedure get_elem2_
575
interface set_element
576
module procedure set_elem1_
577
module procedure set_elem2_
580
module procedure get_elem1_
583
interface set_element1
584
module procedure set_elem1_
586
public :: set_element1
588
module procedure get_elem1p_
592
module procedure get_elem2_
595
interface set_element2
596
module procedure set_elem2_
598
public :: set_element2
600
module procedure get_elem2p_
604
private :: iCSC0_r3D_
605
interface assignment(=)
606
module procedure common_assign_
608
public :: assignment(=)
609
private :: common_assign_
611
module procedure common_initialize_
614
private :: common_initialize_
615
interface is_initialized
616
module procedure common_is_initialized_
618
public :: is_initialized
619
private :: common_is_initialized_
620
interface initialized
621
module procedure common_is_initialized_
623
public :: initialized
625
module procedure common_is_initialized_
629
module procedure common_is_same_
632
private :: common_is_same_
634
module procedure common_is_same_
638
module procedure common_delete_
641
private :: common_delete_
643
module procedure common_nullify_
646
private :: common_nullify_
648
module procedure copy_
651
private :: common_copy_
653
module procedure print_
657
module procedure read_
661
module procedure write_
665
module procedure common_references_
668
private :: common_references_
670
module procedure common_references_
674
module procedure common_set_error_is_
675
module procedure common_set_error_ii_
676
module procedure common_set_error_il_
679
private :: common_set_error_is_
680
private :: common_set_error_ii_
681
private :: common_set_error_il_
683
module procedure common_error_
686
private :: common_error_
688
subroutine common_copy_(from, to)
689
type(iCSC0_r3D), intent(in) :: from
690
type(iCSC0_r3D), intent(inout) :: to
691
call set_error(to, error(from))
692
end subroutine common_copy_
693
subroutine common_initialize_(this)
694
type(iCSC0_r3D), intent(inout) :: this
697
allocate(this%D, stat=error)
698
call set_error(this, error)
699
if ( error /= 0 ) return
701
call common_tag_object_(this)
702
end subroutine common_initialize_
703
pure function common_is_initialized_(this) result(init)
704
type(iCSC0_r3D), intent(in) :: this
706
init = associated(this%D)
707
end function common_is_initialized_
708
elemental function common_is_same_(lhs, rhs) result(same)
709
type(iCSC0_r3D), intent(in) :: lhs, rhs
711
same = is_initd(lhs) .and. is_initd(rhs)
712
if ( .not. same ) return
713
same = associated(lhs%D, target=rhs%D)
714
end function common_is_same_
715
subroutine common_delete_(this)
716
type(iCSC0_r3D), intent(inout) :: this
718
call set_error(this, 0)
719
if (.not. is_initd(this) ) return
720
this%D%refs_ = this%D%refs_ - 1
721
if ( 0 == this%D%refs_ ) then
723
deallocate(this%D, stat=error)
724
call set_error(this, error)
727
end subroutine common_delete_
728
elemental subroutine common_nullify_(this)
729
type(iCSC0_r3D), intent(inout) :: this
730
if (.not. is_initd(this) ) return
732
end subroutine common_nullify_
733
subroutine common_assign_(lhs, rhs)
734
type(iCSC0_r3D), intent(inout) :: lhs
735
type(iCSC0_r3D), intent(in) :: rhs
737
if ( .not. is_initd(rhs) ) return
739
lhs%D%refs_ = rhs%D%refs_ + 1
740
end subroutine common_assign_
741
elemental function common_references_(this) result(refs)
742
type(iCSC0_r3D), intent(in) :: this
744
if ( is_initd(this) ) then
749
end function common_references_
750
elemental function common_error_(this) result(error)
751
type(iCSC0_r3D), intent(in) :: this
753
if ( is_initd(this) ) then
758
end function common_error_
759
elemental subroutine common_set_error_is_(this, error)
760
type(iCSC0_r3D), intent(inout) :: this
761
integer(is_), intent(in) :: error
763
end subroutine common_set_error_is_
764
elemental subroutine common_set_error_ii_(this, error)
765
type(iCSC0_r3D), intent(inout) :: this
766
integer(ii_), intent(in) :: error
768
end subroutine common_set_error_ii_
769
elemental subroutine common_set_error_il_(this, error)
770
type(iCSC0_r3D), intent(inout) :: this
771
integer(il_), intent(in) :: error
773
end subroutine common_set_error_il_
774
elemental function common_id_(this) result(str)
775
type(iCSC0_r3D), intent(in) :: this
776
character(len=BUD_ID_LEn) :: str
778
end function common_id_
779
subroutine common_tag_object_(this)
780
type(iCSC0_r3D), intent(inout) :: this
781
end subroutine common_tag_object_
782
subroutine delete_(this)
783
type(iCSC0_r3D), intent(inout) :: this
784
call set_error(this, 0)
785
call delete(this%D%e1)
786
if ( 0 /= error(this%D%e1) ) &
787
call set_error(this, error(this%D%e1))
788
call delete(this%D%e2)
789
if ( 0 /= error(this%D%e2) ) &
790
call set_error(this, error(this%D%e2))
791
end subroutine delete_
792
subroutine copy_(from, to)
793
type(iCSC0_r3D), intent(in) :: from
794
type(iCSC0_r3D), intent(inout) :: to
796
if ( .not. is_initd(from) ) return
798
call common_copy_(from, to)
799
call copy(from%D%e1, to%D%e1)
800
call copy(from%D%e2, to%D%e2)
802
subroutine new_data_(this, a, b &
804
type(iCSC0_r3D), intent(inout) :: this
805
type(iSM_CSC0), intent(inout) :: a
806
type(rArray3D), intent(inout) :: b
810
end subroutine new_data_
811
subroutine new_(this)
812
type(iCSC0_r3D), intent(inout) :: this
813
call initialize(this)
815
subroutine get_elem1_(this, item)
816
type(iCSC0_r3D), intent(in) :: this
817
type(iSM_CSC0), intent(inout) :: item
818
if ( .not. is_initd(this) ) then
824
subroutine get_elem1_assign_(item, this)
825
type(iSM_CSC0), intent(inout) :: item
826
type(iCSC0_r3D), intent(in) :: this
827
if ( .not. is_initd(this) ) then
833
subroutine set_elem1_(this, item)
834
type(iCSC0_r3D), intent(inout) :: this
835
type(iSM_CSC0), intent(in) :: item
836
if ( .not. is_initd(this) ) return
839
function get_elem1p_(this) result(p)
840
type(iCSC0_r3D), intent(inout) :: this
841
type(iSM_CSC0), pointer :: p
842
if ( .not. is_initd(this) ) then
848
subroutine get_elem2_(this, item)
849
type(iCSC0_r3D), intent(in) :: this
850
type(rArray3D), intent(inout) :: item
851
if ( .not. is_initd(this) ) then
857
subroutine get_elem2_assign_(item, this)
858
type(rArray3D), intent(inout) :: item
859
type(iCSC0_r3D), intent(in) :: this
860
if ( .not. is_initd(this) ) then
866
subroutine set_elem2_(this, item)
867
type(iCSC0_r3D), intent(inout) :: this
868
type(rArray3D), intent(in) :: item
869
if ( .not. is_initd(this) ) return
872
function get_elem2p_(this) result(p)
873
type(iCSC0_r3D), intent(inout) :: this
874
type(rArray3D), pointer :: p
875
if ( .not. is_initd(this) ) then
881
subroutine print_(this, info, indent)
882
type(iCSC0_r3D), intent(in) :: this
883
character(len=*), intent(in), optional :: info
884
integer, intent(in), optional :: indent
886
character(len=32) :: fmt
887
character(len=256) :: name
889
if ( present(info) ) name = info
891
if ( present(indent) ) lindent = indent
892
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
893
if ( .not. is_initd(this) ) then
894
write(*,fmt) "<", trim(name), " not initialized>"
897
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
898
lindent = lindent + 2 ! step indentation
899
write(*,fmt) "<<", trim(name), " coll>"
900
call print(this%D%e1, indent = lindent)
901
call print(this%D%e2, indent = lindent)
902
lindent = lindent - 2 ! go back to requested indentation
903
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
904
write(*,fmt) " <coll-refs: ", references(this), ">>"
905
end subroutine print_
906
function matrix_p_(this) result(p)
907
type(iCSC0_r3D), intent(in) :: this
908
real(rr_), pointer :: p (:,:,:)
909
p => array_p(this%D%e2)
910
end function matrix_p_
911
function sparse_index_(this) result(idx)
912
type(iCSC0_r3D), intent(in) :: this
915
end function sparse_index_
916
pure function dimensions_(this) result(d)
917
type(iCSC0_r3D), intent(in) :: this
919
if ( is_initd(this) ) then
924
end function dimensions_
925
recursive subroutine add_element_(this, ir, ic, val)
926
type(iCSC0_r3D), intent(inout) :: this
927
integer(ii_), intent(in) :: ir, ic
928
real(rr_), intent(in) :: val
930
type(iCSC0_r3D) :: nthis
931
integer(ii_) :: i, c, ix, nr, nc, npc
932
real(rr_), pointer :: p (:,:,:)
933
if ( .not. is_initd(this) ) return
935
call add_element(sm, ir, ic, dry_run = .true.)
936
if ( error(sm) /= 0 ) then
938
call set_error(this, -1)
941
call add_element(sm, ir, ic)
942
i = index(sm, ir, ic)
944
select case ( sparse_index(this) )
953
end subroutine add_element_
954
subroutine write_(f, this, only_array)
956
type( File ), intent(inout) :: f
957
type(iCSC0_r3D), intent(inout) :: this
958
logical, intent(in), optional :: only_array
960
type(rArray3D) :: arr
961
logical :: lonly_array
962
if ( .not. is_open(f) ) return
963
if ( .not. is_initd(this) ) return
964
lonly_array = .false.
965
if ( present(only_array) ) lonly_array = only_array
968
if ( .not. is_finalized(sm) ) then
971
call set_error(this, -1)
974
if ( .not. lonly_array ) then
980
end subroutine write_
981
subroutine read_(f, this, sm)
983
type( File ), intent(inout) :: f
984
type(iCSC0_r3D), intent(inout) :: this
985
type(iSM_CSC0), intent(inout), optional :: sm
986
type(iSM_CSC0) :: lsm
987
type(rArray3D) :: arr
988
if ( .not. is_open(f) ) return
989
if ( present(sm) ) then
995
call new(this, lsm, arr)
1004
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1005
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
1006
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
1007
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
1008
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
1009
integer, parameter, private :: BUD_ID_LEn = 36
1010
character(len=*), parameter, private :: &
1011
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
1012
character(len=*), parameter, private :: &
1013
BUD_TYPe = "iCSC0_d3D"
1014
integer(ii_), parameter :: ONE = 1_ii_
1015
integer(ii_), parameter :: ZERO = 0_ii_
1017
module procedure matrix_p_
1020
interface sparse_matrix
1021
module procedure get_elem1_
1023
public :: sparse_matrix
1024
interface sparse_matrix_p
1025
module procedure get_elem1p_
1027
public :: sparse_matrix_p
1028
interface sparse_index
1029
module procedure sparse_index_
1031
public :: sparse_index
1032
interface dimensions
1033
module procedure dimensions_
1035
public :: dimensions
1037
module procedure get_elem2_
1041
module procedure get_elem2p_
1044
interface add_element
1045
module procedure add_element_
1047
public :: add_element
1049
type(iCSC0_d3D_), pointer :: D => null()
1050
integer :: error_ = 0
1053
type(iSM_CSC0) :: e1
1054
type(dArray3D) :: e2
1055
integer :: sm_idx = 3
1056
integer :: refs_ = 0
1057
character(len=BUD_ID_LEN) :: id_ = "null_id"
1060
module procedure new_
1061
module procedure new_data_
1064
interface assignment(=)
1065
module procedure get_elem1_assign_
1066
module procedure get_elem2_assign_
1067
module procedure set_elem1_
1068
module procedure set_elem2_
1071
module procedure get_elem1_
1072
module procedure get_elem2_
1074
interface set_element
1075
module procedure set_elem1_
1076
module procedure set_elem2_
1079
module procedure get_elem1_
1082
interface set_element1
1083
module procedure set_elem1_
1085
public :: set_element1
1086
interface element1_p
1087
module procedure get_elem1p_
1089
public :: element1_p
1091
module procedure get_elem2_
1094
interface set_element2
1095
module procedure set_elem2_
1097
public :: set_element2
1098
interface element2_p
1099
module procedure get_elem2p_
1101
public :: element2_p
1103
private :: iCSC0_d3D_
1104
interface assignment(=)
1105
module procedure common_assign_
1107
public :: assignment(=)
1108
private :: common_assign_
1109
interface initialize
1110
module procedure common_initialize_
1112
public :: initialize
1113
private :: common_initialize_
1114
interface is_initialized
1115
module procedure common_is_initialized_
1117
public :: is_initialized
1118
private :: common_is_initialized_
1119
interface initialized
1120
module procedure common_is_initialized_
1122
public :: initialized
1124
module procedure common_is_initialized_
1128
module procedure common_is_same_
1131
private :: common_is_same_
1133
module procedure common_is_same_
1137
module procedure common_delete_
1140
private :: common_delete_
1142
module procedure common_nullify_
1145
private :: common_nullify_
1147
module procedure copy_
1150
private :: common_copy_
1152
module procedure print_
1156
module procedure read_
1160
module procedure write_
1163
interface references
1164
module procedure common_references_
1166
public :: references
1167
private :: common_references_
1169
module procedure common_references_
1173
module procedure common_set_error_is_
1174
module procedure common_set_error_ii_
1175
module procedure common_set_error_il_
1178
private :: common_set_error_is_
1179
private :: common_set_error_ii_
1180
private :: common_set_error_il_
1182
module procedure common_error_
1185
private :: common_error_
1187
subroutine common_copy_(from, to)
1188
type(iCSC0_d3D), intent(in) :: from
1189
type(iCSC0_d3D), intent(inout) :: to
1190
call set_error(to, error(from))
1191
end subroutine common_copy_
1192
subroutine common_initialize_(this)
1193
type(iCSC0_d3D), intent(inout) :: this
1196
allocate(this%D, stat=error)
1197
call set_error(this, error)
1198
if ( error /= 0 ) return
1200
call common_tag_object_(this)
1201
end subroutine common_initialize_
1202
pure function common_is_initialized_(this) result(init)
1203
type(iCSC0_d3D), intent(in) :: this
1205
init = associated(this%D)
1206
end function common_is_initialized_
1207
elemental function common_is_same_(lhs, rhs) result(same)
1208
type(iCSC0_d3D), intent(in) :: lhs, rhs
1210
same = is_initd(lhs) .and. is_initd(rhs)
1211
if ( .not. same ) return
1212
same = associated(lhs%D, target=rhs%D)
1213
end function common_is_same_
1214
subroutine common_delete_(this)
1215
type(iCSC0_d3D), intent(inout) :: this
1217
call set_error(this, 0)
1218
if (.not. is_initd(this) ) return
1219
this%D%refs_ = this%D%refs_ - 1
1220
if ( 0 == this%D%refs_ ) then
1222
deallocate(this%D, stat=error)
1223
call set_error(this, error)
1226
end subroutine common_delete_
1227
elemental subroutine common_nullify_(this)
1228
type(iCSC0_d3D), intent(inout) :: this
1229
if (.not. is_initd(this) ) return
1231
end subroutine common_nullify_
1232
subroutine common_assign_(lhs, rhs)
1233
type(iCSC0_d3D), intent(inout) :: lhs
1234
type(iCSC0_d3D), intent(in) :: rhs
1236
if ( .not. is_initd(rhs) ) return
1238
lhs%D%refs_ = rhs%D%refs_ + 1
1239
end subroutine common_assign_
1240
elemental function common_references_(this) result(refs)
1241
type(iCSC0_d3D), intent(in) :: this
1243
if ( is_initd(this) ) then
1248
end function common_references_
1249
elemental function common_error_(this) result(error)
1250
type(iCSC0_d3D), intent(in) :: this
1252
if ( is_initd(this) ) then
1257
end function common_error_
1258
elemental subroutine common_set_error_is_(this, error)
1259
type(iCSC0_d3D), intent(inout) :: this
1260
integer(is_), intent(in) :: error
1262
end subroutine common_set_error_is_
1263
elemental subroutine common_set_error_ii_(this, error)
1264
type(iCSC0_d3D), intent(inout) :: this
1265
integer(ii_), intent(in) :: error
1267
end subroutine common_set_error_ii_
1268
elemental subroutine common_set_error_il_(this, error)
1269
type(iCSC0_d3D), intent(inout) :: this
1270
integer(il_), intent(in) :: error
1272
end subroutine common_set_error_il_
1273
elemental function common_id_(this) result(str)
1274
type(iCSC0_d3D), intent(in) :: this
1275
character(len=BUD_ID_LEn) :: str
1277
end function common_id_
1278
subroutine common_tag_object_(this)
1279
type(iCSC0_d3D), intent(inout) :: this
1280
end subroutine common_tag_object_
1281
subroutine delete_(this)
1282
type(iCSC0_d3D), intent(inout) :: this
1283
call set_error(this, 0)
1284
call delete(this%D%e1)
1285
if ( 0 /= error(this%D%e1) ) &
1286
call set_error(this, error(this%D%e1))
1287
call delete(this%D%e2)
1288
if ( 0 /= error(this%D%e2) ) &
1289
call set_error(this, error(this%D%e2))
1290
end subroutine delete_
1291
subroutine copy_(from, to)
1292
type(iCSC0_d3D), intent(in) :: from
1293
type(iCSC0_d3D), intent(inout) :: to
1295
if ( .not. is_initd(from) ) return
1297
call common_copy_(from, to)
1298
call copy(from%D%e1, to%D%e1)
1299
call copy(from%D%e2, to%D%e2)
1300
end subroutine copy_
1301
subroutine new_data_(this, a, b &
1303
type(iCSC0_d3D), intent(inout) :: this
1304
type(iSM_CSC0), intent(inout) :: a
1305
type(dArray3D), intent(inout) :: b
1309
end subroutine new_data_
1310
subroutine new_(this)
1311
type(iCSC0_d3D), intent(inout) :: this
1312
call initialize(this)
1314
subroutine get_elem1_(this, item)
1315
type(iCSC0_d3D), intent(in) :: this
1316
type(iSM_CSC0), intent(inout) :: item
1317
if ( .not. is_initd(this) ) then
1323
subroutine get_elem1_assign_(item, this)
1324
type(iSM_CSC0), intent(inout) :: item
1325
type(iCSC0_d3D), intent(in) :: this
1326
if ( .not. is_initd(this) ) then
1332
subroutine set_elem1_(this, item)
1333
type(iCSC0_d3D), intent(inout) :: this
1334
type(iSM_CSC0), intent(in) :: item
1335
if ( .not. is_initd(this) ) return
1338
function get_elem1p_(this) result(p)
1339
type(iCSC0_d3D), intent(inout) :: this
1340
type(iSM_CSC0), pointer :: p
1341
if ( .not. is_initd(this) ) then
1347
subroutine get_elem2_(this, item)
1348
type(iCSC0_d3D), intent(in) :: this
1349
type(dArray3D), intent(inout) :: item
1350
if ( .not. is_initd(this) ) then
1356
subroutine get_elem2_assign_(item, this)
1357
type(dArray3D), intent(inout) :: item
1358
type(iCSC0_d3D), intent(in) :: this
1359
if ( .not. is_initd(this) ) then
1365
subroutine set_elem2_(this, item)
1366
type(iCSC0_d3D), intent(inout) :: this
1367
type(dArray3D), intent(in) :: item
1368
if ( .not. is_initd(this) ) return
1371
function get_elem2p_(this) result(p)
1372
type(iCSC0_d3D), intent(inout) :: this
1373
type(dArray3D), pointer :: p
1374
if ( .not. is_initd(this) ) then
1380
subroutine print_(this, info, indent)
1381
type(iCSC0_d3D), intent(in) :: this
1382
character(len=*), intent(in), optional :: info
1383
integer, intent(in), optional :: indent
1385
character(len=32) :: fmt
1386
character(len=256) :: name
1388
if ( present(info) ) name = info
1390
if ( present(indent) ) lindent = indent
1391
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1392
if ( .not. is_initd(this) ) then
1393
write(*,fmt) "<", trim(name), " not initialized>"
1396
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1397
lindent = lindent + 2 ! step indentation
1398
write(*,fmt) "<<", trim(name), " coll>"
1399
call print(this%D%e1, indent = lindent)
1400
call print(this%D%e2, indent = lindent)
1401
lindent = lindent - 2 ! go back to requested indentation
1402
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
1403
write(*,fmt) " <coll-refs: ", references(this), ">>"
1404
end subroutine print_
1405
function matrix_p_(this) result(p)
1406
type(iCSC0_d3D), intent(in) :: this
1407
real(rd_), pointer :: p (:,:,:)
1408
p => array_p(this%D%e2)
1409
end function matrix_p_
1410
function sparse_index_(this) result(idx)
1411
type(iCSC0_d3D), intent(in) :: this
1414
end function sparse_index_
1415
pure function dimensions_(this) result(d)
1416
type(iCSC0_d3D), intent(in) :: this
1418
if ( is_initd(this) ) then
1423
end function dimensions_
1424
recursive subroutine add_element_(this, ir, ic, val)
1425
type(iCSC0_d3D), intent(inout) :: this
1426
integer(ii_), intent(in) :: ir, ic
1427
real(rd_), intent(in) :: val
1428
type(iSM_CSC0) :: sm
1429
type(iCSC0_d3D) :: nthis
1430
integer(ii_) :: i, c, ix, nr, nc, npc
1431
real(rd_), pointer :: p (:,:,:)
1432
if ( .not. is_initd(this) ) return
1434
call add_element(sm, ir, ic, dry_run = .true.)
1435
if ( error(sm) /= 0 ) then
1437
call set_error(this, -1)
1440
call add_element(sm, ir, ic)
1441
i = index(sm, ir, ic)
1443
select case ( sparse_index(this) )
1452
end subroutine add_element_
1453
subroutine write_(f, this, only_array)
1455
type( File ), intent(inout) :: f
1456
type(iCSC0_d3D), intent(inout) :: this
1457
logical, intent(in), optional :: only_array
1458
type(iSM_CSC0) :: sm
1459
type(dArray3D) :: arr
1460
logical :: lonly_array
1461
if ( .not. is_open(f) ) return
1462
if ( .not. is_initd(this) ) return
1463
lonly_array = .false.
1464
if ( present(only_array) ) lonly_array = only_array
1467
if ( .not. is_finalized(sm) ) then
1470
call set_error(this, -1)
1473
if ( .not. lonly_array ) then
1479
end subroutine write_
1480
subroutine read_(f, this, sm)
1482
type( File ), intent(inout) :: f
1483
type(iCSC0_d3D), intent(inout) :: this
1484
type(iSM_CSC0), intent(inout), optional :: sm
1485
type(iSM_CSC0) :: lsm
1486
type(dArray3D) :: arr
1487
if ( .not. is_open(f) ) return
1488
if ( present(sm) ) then
1494
call new(this, lsm, arr)
1496
end subroutine read_
1498
module bud_iCSC0_c3D
1503
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
1504
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
1505
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
1506
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
1507
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
1508
integer, parameter, private :: BUD_ID_LEn = 36
1509
character(len=*), parameter, private :: &
1510
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
1511
character(len=*), parameter, private :: &
1512
BUD_TYPe = "iCSC0_c3D"
1513
integer(ii_), parameter :: ONE = 1_ii_
1514
integer(ii_), parameter :: ZERO = 0_ii_
1516
module procedure matrix_p_
1519
interface sparse_matrix
1520
module procedure get_elem1_
1522
public :: sparse_matrix
1523
interface sparse_matrix_p
1524
module procedure get_elem1p_
1526
public :: sparse_matrix_p
1527
interface sparse_index
1528
module procedure sparse_index_
1530
public :: sparse_index
1531
interface dimensions
1532
module procedure dimensions_
1534
public :: dimensions
1536
module procedure get_elem2_
1540
module procedure get_elem2p_
1543
interface add_element
1544
module procedure add_element_
1546
public :: add_element
1548
type(iCSC0_c3D_), pointer :: D => null()
1549
integer :: error_ = 0
1552
type(iSM_CSC0) :: e1
1553
type(cArray3D) :: e2
1554
integer :: sm_idx = 3
1555
integer :: refs_ = 0
1556
character(len=BUD_ID_LEN) :: id_ = "null_id"
1559
module procedure new_
1560
module procedure new_data_
1563
interface assignment(=)
1564
module procedure get_elem1_assign_
1565
module procedure get_elem2_assign_
1566
module procedure set_elem1_
1567
module procedure set_elem2_
1570
module procedure get_elem1_
1571
module procedure get_elem2_
1573
interface set_element
1574
module procedure set_elem1_
1575
module procedure set_elem2_
1578
module procedure get_elem1_
1581
interface set_element1
1582
module procedure set_elem1_
1584
public :: set_element1
1585
interface element1_p
1586
module procedure get_elem1p_
1588
public :: element1_p
1590
module procedure get_elem2_
1593
interface set_element2
1594
module procedure set_elem2_
1596
public :: set_element2
1597
interface element2_p
1598
module procedure get_elem2p_
1600
public :: element2_p
1602
private :: iCSC0_c3D_
1603
interface assignment(=)
1604
module procedure common_assign_
1606
public :: assignment(=)
1607
private :: common_assign_
1608
interface initialize
1609
module procedure common_initialize_
1611
public :: initialize
1612
private :: common_initialize_
1613
interface is_initialized
1614
module procedure common_is_initialized_
1616
public :: is_initialized
1617
private :: common_is_initialized_
1618
interface initialized
1619
module procedure common_is_initialized_
1621
public :: initialized
1623
module procedure common_is_initialized_
1627
module procedure common_is_same_
1630
private :: common_is_same_
1632
module procedure common_is_same_
1636
module procedure common_delete_
1639
private :: common_delete_
1641
module procedure common_nullify_
1644
private :: common_nullify_
1646
module procedure copy_
1649
private :: common_copy_
1651
module procedure print_
1655
module procedure read_
1659
module procedure write_
1662
interface references
1663
module procedure common_references_
1665
public :: references
1666
private :: common_references_
1668
module procedure common_references_
1672
module procedure common_set_error_is_
1673
module procedure common_set_error_ii_
1674
module procedure common_set_error_il_
1677
private :: common_set_error_is_
1678
private :: common_set_error_ii_
1679
private :: common_set_error_il_
1681
module procedure common_error_
1684
private :: common_error_
1686
subroutine common_copy_(from, to)
1687
type(iCSC0_c3D), intent(in) :: from
1688
type(iCSC0_c3D), intent(inout) :: to
1689
call set_error(to, error(from))
1690
end subroutine common_copy_
1691
subroutine common_initialize_(this)
1692
type(iCSC0_c3D), intent(inout) :: this
1695
allocate(this%D, stat=error)
1696
call set_error(this, error)
1697
if ( error /= 0 ) return
1699
call common_tag_object_(this)
1700
end subroutine common_initialize_
1701
pure function common_is_initialized_(this) result(init)
1702
type(iCSC0_c3D), intent(in) :: this
1704
init = associated(this%D)
1705
end function common_is_initialized_
1706
elemental function common_is_same_(lhs, rhs) result(same)
1707
type(iCSC0_c3D), intent(in) :: lhs, rhs
1709
same = is_initd(lhs) .and. is_initd(rhs)
1710
if ( .not. same ) return
1711
same = associated(lhs%D, target=rhs%D)
1712
end function common_is_same_
1713
subroutine common_delete_(this)
1714
type(iCSC0_c3D), intent(inout) :: this
1716
call set_error(this, 0)
1717
if (.not. is_initd(this) ) return
1718
this%D%refs_ = this%D%refs_ - 1
1719
if ( 0 == this%D%refs_ ) then
1721
deallocate(this%D, stat=error)
1722
call set_error(this, error)
1725
end subroutine common_delete_
1726
elemental subroutine common_nullify_(this)
1727
type(iCSC0_c3D), intent(inout) :: this
1728
if (.not. is_initd(this) ) return
1730
end subroutine common_nullify_
1731
subroutine common_assign_(lhs, rhs)
1732
type(iCSC0_c3D), intent(inout) :: lhs
1733
type(iCSC0_c3D), intent(in) :: rhs
1735
if ( .not. is_initd(rhs) ) return
1737
lhs%D%refs_ = rhs%D%refs_ + 1
1738
end subroutine common_assign_
1739
elemental function common_references_(this) result(refs)
1740
type(iCSC0_c3D), intent(in) :: this
1742
if ( is_initd(this) ) then
1747
end function common_references_
1748
elemental function common_error_(this) result(error)
1749
type(iCSC0_c3D), intent(in) :: this
1751
if ( is_initd(this) ) then
1756
end function common_error_
1757
elemental subroutine common_set_error_is_(this, error)
1758
type(iCSC0_c3D), intent(inout) :: this
1759
integer(is_), intent(in) :: error
1761
end subroutine common_set_error_is_
1762
elemental subroutine common_set_error_ii_(this, error)
1763
type(iCSC0_c3D), intent(inout) :: this
1764
integer(ii_), intent(in) :: error
1766
end subroutine common_set_error_ii_
1767
elemental subroutine common_set_error_il_(this, error)
1768
type(iCSC0_c3D), intent(inout) :: this
1769
integer(il_), intent(in) :: error
1771
end subroutine common_set_error_il_
1772
elemental function common_id_(this) result(str)
1773
type(iCSC0_c3D), intent(in) :: this
1774
character(len=BUD_ID_LEn) :: str
1776
end function common_id_
1777
subroutine common_tag_object_(this)
1778
type(iCSC0_c3D), intent(inout) :: this
1779
end subroutine common_tag_object_
1780
subroutine delete_(this)
1781
type(iCSC0_c3D), intent(inout) :: this
1782
call set_error(this, 0)
1783
call delete(this%D%e1)
1784
if ( 0 /= error(this%D%e1) ) &
1785
call set_error(this, error(this%D%e1))
1786
call delete(this%D%e2)
1787
if ( 0 /= error(this%D%e2) ) &
1788
call set_error(this, error(this%D%e2))
1789
end subroutine delete_
1790
subroutine copy_(from, to)
1791
type(iCSC0_c3D), intent(in) :: from
1792
type(iCSC0_c3D), intent(inout) :: to
1794
if ( .not. is_initd(from) ) return
1796
call common_copy_(from, to)
1797
call copy(from%D%e1, to%D%e1)
1798
call copy(from%D%e2, to%D%e2)
1799
end subroutine copy_
1800
subroutine new_data_(this, a, b &
1802
type(iCSC0_c3D), intent(inout) :: this
1803
type(iSM_CSC0), intent(inout) :: a
1804
type(cArray3D), intent(inout) :: b
1808
end subroutine new_data_
1809
subroutine new_(this)
1810
type(iCSC0_c3D), intent(inout) :: this
1811
call initialize(this)
1813
subroutine get_elem1_(this, item)
1814
type(iCSC0_c3D), intent(in) :: this
1815
type(iSM_CSC0), intent(inout) :: item
1816
if ( .not. is_initd(this) ) then
1822
subroutine get_elem1_assign_(item, this)
1823
type(iSM_CSC0), intent(inout) :: item
1824
type(iCSC0_c3D), intent(in) :: this
1825
if ( .not. is_initd(this) ) then
1831
subroutine set_elem1_(this, item)
1832
type(iCSC0_c3D), intent(inout) :: this
1833
type(iSM_CSC0), intent(in) :: item
1834
if ( .not. is_initd(this) ) return
1837
function get_elem1p_(this) result(p)
1838
type(iCSC0_c3D), intent(inout) :: this
1839
type(iSM_CSC0), pointer :: p
1840
if ( .not. is_initd(this) ) then
1846
subroutine get_elem2_(this, item)
1847
type(iCSC0_c3D), intent(in) :: this
1848
type(cArray3D), intent(inout) :: item
1849
if ( .not. is_initd(this) ) then
1855
subroutine get_elem2_assign_(item, this)
1856
type(cArray3D), intent(inout) :: item
1857
type(iCSC0_c3D), intent(in) :: this
1858
if ( .not. is_initd(this) ) then
1864
subroutine set_elem2_(this, item)
1865
type(iCSC0_c3D), intent(inout) :: this
1866
type(cArray3D), intent(in) :: item
1867
if ( .not. is_initd(this) ) return
1870
function get_elem2p_(this) result(p)
1871
type(iCSC0_c3D), intent(inout) :: this
1872
type(cArray3D), pointer :: p
1873
if ( .not. is_initd(this) ) then
1879
subroutine print_(this, info, indent)
1880
type(iCSC0_c3D), intent(in) :: this
1881
character(len=*), intent(in), optional :: info
1882
integer, intent(in), optional :: indent
1884
character(len=32) :: fmt
1885
character(len=256) :: name
1887
if ( present(info) ) name = info
1889
if ( present(indent) ) lindent = indent
1890
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1891
if ( .not. is_initd(this) ) then
1892
write(*,fmt) "<", trim(name), " not initialized>"
1895
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
1896
lindent = lindent + 2 ! step indentation
1897
write(*,fmt) "<<", trim(name), " coll>"
1898
call print(this%D%e1, indent = lindent)
1899
call print(this%D%e2, indent = lindent)
1900
lindent = lindent - 2 ! go back to requested indentation
1901
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
1902
write(*,fmt) " <coll-refs: ", references(this), ">>"
1903
end subroutine print_
1904
function matrix_p_(this) result(p)
1905
type(iCSC0_c3D), intent(in) :: this
1906
complex(rr_), pointer :: p (:,:,:)
1907
p => array_p(this%D%e2)
1908
end function matrix_p_
1909
function sparse_index_(this) result(idx)
1910
type(iCSC0_c3D), intent(in) :: this
1913
end function sparse_index_
1914
pure function dimensions_(this) result(d)
1915
type(iCSC0_c3D), intent(in) :: this
1917
if ( is_initd(this) ) then
1922
end function dimensions_
1923
recursive subroutine add_element_(this, ir, ic, val)
1924
type(iCSC0_c3D), intent(inout) :: this
1925
integer(ii_), intent(in) :: ir, ic
1926
complex(rr_), intent(in) :: val
1927
type(iSM_CSC0) :: sm
1928
type(iCSC0_c3D) :: nthis
1929
integer(ii_) :: i, c, ix, nr, nc, npc
1930
complex(rr_), pointer :: p (:,:,:)
1931
if ( .not. is_initd(this) ) return
1933
call add_element(sm, ir, ic, dry_run = .true.)
1934
if ( error(sm) /= 0 ) then
1936
call set_error(this, -1)
1939
call add_element(sm, ir, ic)
1940
i = index(sm, ir, ic)
1942
select case ( sparse_index(this) )
1951
end subroutine add_element_
1952
subroutine write_(f, this, only_array)
1954
type( File ), intent(inout) :: f
1955
type(iCSC0_c3D), intent(inout) :: this
1956
logical, intent(in), optional :: only_array
1957
type(iSM_CSC0) :: sm
1958
type(cArray3D) :: arr
1959
logical :: lonly_array
1960
if ( .not. is_open(f) ) return
1961
if ( .not. is_initd(this) ) return
1962
lonly_array = .false.
1963
if ( present(only_array) ) lonly_array = only_array
1966
if ( .not. is_finalized(sm) ) then
1969
call set_error(this, -1)
1972
if ( .not. lonly_array ) then
1978
end subroutine write_
1979
subroutine read_(f, this, sm)
1981
type( File ), intent(inout) :: f
1982
type(iCSC0_c3D), intent(inout) :: this
1983
type(iSM_CSC0), intent(inout), optional :: sm
1984
type(iSM_CSC0) :: lsm
1985
type(cArray3D) :: arr
1986
if ( .not. is_open(f) ) return
1987
if ( present(sm) ) then
1993
call new(this, lsm, arr)
1995
end subroutine read_
1997
module bud_iCSC0_z3D
2002
integer, parameter :: rr_ = selected_real_kind(p=6) ! single (real*4)
2003
integer, parameter :: rd_ = selected_real_kind(p=15) ! double (real*8)
2004
integer, parameter :: is_ = selected_int_kind(4) ! short (integer*2)
2005
integer, parameter :: ii_ = selected_int_kind(9) ! int (integer*4)
2006
integer, parameter :: il_ = selected_int_kind(18) ! long (integer*8)
2007
integer, parameter, private :: BUD_ID_LEn = 36
2008
character(len=*), parameter, private :: &
2009
BUD_MOd = 'BUD_CC2(BUD_MOD,_)BUD_MOD_NAME'
2010
character(len=*), parameter, private :: &
2011
BUD_TYPe = "iCSC0_z3D"
2012
integer(ii_), parameter :: ONE = 1_ii_
2013
integer(ii_), parameter :: ZERO = 0_ii_
2015
module procedure matrix_p_
2018
interface sparse_matrix
2019
module procedure get_elem1_
2021
public :: sparse_matrix
2022
interface sparse_matrix_p
2023
module procedure get_elem1p_
2025
public :: sparse_matrix_p
2026
interface sparse_index
2027
module procedure sparse_index_
2029
public :: sparse_index
2030
interface dimensions
2031
module procedure dimensions_
2033
public :: dimensions
2035
module procedure get_elem2_
2039
module procedure get_elem2p_
2042
interface add_element
2043
module procedure add_element_
2045
public :: add_element
2047
type(iCSC0_z3D_), pointer :: D => null()
2048
integer :: error_ = 0
2051
type(iSM_CSC0) :: e1
2052
type(zArray3D) :: e2
2053
integer :: sm_idx = 3
2054
integer :: refs_ = 0
2055
character(len=BUD_ID_LEN) :: id_ = "null_id"
2058
module procedure new_
2059
module procedure new_data_
2062
interface assignment(=)
2063
module procedure get_elem1_assign_
2064
module procedure get_elem2_assign_
2065
module procedure set_elem1_
2066
module procedure set_elem2_
2069
module procedure get_elem1_
2070
module procedure get_elem2_
2072
interface set_element
2073
module procedure set_elem1_
2074
module procedure set_elem2_
2077
module procedure get_elem1_
2080
interface set_element1
2081
module procedure set_elem1_
2083
public :: set_element1
2084
interface element1_p
2085
module procedure get_elem1p_
2087
public :: element1_p
2089
module procedure get_elem2_
2092
interface set_element2
2093
module procedure set_elem2_
2095
public :: set_element2
2096
interface element2_p
2097
module procedure get_elem2p_
2099
public :: element2_p
2101
private :: iCSC0_z3D_
2102
interface assignment(=)
2103
module procedure common_assign_
2105
public :: assignment(=)
2106
private :: common_assign_
2107
interface initialize
2108
module procedure common_initialize_
2110
public :: initialize
2111
private :: common_initialize_
2112
interface is_initialized
2113
module procedure common_is_initialized_
2115
public :: is_initialized
2116
private :: common_is_initialized_
2117
interface initialized
2118
module procedure common_is_initialized_
2120
public :: initialized
2122
module procedure common_is_initialized_
2126
module procedure common_is_same_
2129
private :: common_is_same_
2131
module procedure common_is_same_
2135
module procedure common_delete_
2138
private :: common_delete_
2140
module procedure common_nullify_
2143
private :: common_nullify_
2145
module procedure copy_
2148
private :: common_copy_
2150
module procedure print_
2154
module procedure read_
2158
module procedure write_
2161
interface references
2162
module procedure common_references_
2164
public :: references
2165
private :: common_references_
2167
module procedure common_references_
2171
module procedure common_set_error_is_
2172
module procedure common_set_error_ii_
2173
module procedure common_set_error_il_
2176
private :: common_set_error_is_
2177
private :: common_set_error_ii_
2178
private :: common_set_error_il_
2180
module procedure common_error_
2183
private :: common_error_
2185
subroutine common_copy_(from, to)
2186
type(iCSC0_z3D), intent(in) :: from
2187
type(iCSC0_z3D), intent(inout) :: to
2188
call set_error(to, error(from))
2189
end subroutine common_copy_
2190
subroutine common_initialize_(this)
2191
type(iCSC0_z3D), intent(inout) :: this
2194
allocate(this%D, stat=error)
2195
call set_error(this, error)
2196
if ( error /= 0 ) return
2198
call common_tag_object_(this)
2199
end subroutine common_initialize_
2200
pure function common_is_initialized_(this) result(init)
2201
type(iCSC0_z3D), intent(in) :: this
2203
init = associated(this%D)
2204
end function common_is_initialized_
2205
elemental function common_is_same_(lhs, rhs) result(same)
2206
type(iCSC0_z3D), intent(in) :: lhs, rhs
2208
same = is_initd(lhs) .and. is_initd(rhs)
2209
if ( .not. same ) return
2210
same = associated(lhs%D, target=rhs%D)
2211
end function common_is_same_
2212
subroutine common_delete_(this)
2213
type(iCSC0_z3D), intent(inout) :: this
2215
call set_error(this, 0)
2216
if (.not. is_initd(this) ) return
2217
this%D%refs_ = this%D%refs_ - 1
2218
if ( 0 == this%D%refs_ ) then
2220
deallocate(this%D, stat=error)
2221
call set_error(this, error)
2224
end subroutine common_delete_
2225
elemental subroutine common_nullify_(this)
2226
type(iCSC0_z3D), intent(inout) :: this
2227
if (.not. is_initd(this) ) return
2229
end subroutine common_nullify_
2230
subroutine common_assign_(lhs, rhs)
2231
type(iCSC0_z3D), intent(inout) :: lhs
2232
type(iCSC0_z3D), intent(in) :: rhs
2234
if ( .not. is_initd(rhs) ) return
2236
lhs%D%refs_ = rhs%D%refs_ + 1
2237
end subroutine common_assign_
2238
elemental function common_references_(this) result(refs)
2239
type(iCSC0_z3D), intent(in) :: this
2241
if ( is_initd(this) ) then
2246
end function common_references_
2247
elemental function common_error_(this) result(error)
2248
type(iCSC0_z3D), intent(in) :: this
2250
if ( is_initd(this) ) then
2255
end function common_error_
2256
elemental subroutine common_set_error_is_(this, error)
2257
type(iCSC0_z3D), intent(inout) :: this
2258
integer(is_), intent(in) :: error
2260
end subroutine common_set_error_is_
2261
elemental subroutine common_set_error_ii_(this, error)
2262
type(iCSC0_z3D), intent(inout) :: this
2263
integer(ii_), intent(in) :: error
2265
end subroutine common_set_error_ii_
2266
elemental subroutine common_set_error_il_(this, error)
2267
type(iCSC0_z3D), intent(inout) :: this
2268
integer(il_), intent(in) :: error
2270
end subroutine common_set_error_il_
2271
elemental function common_id_(this) result(str)
2272
type(iCSC0_z3D), intent(in) :: this
2273
character(len=BUD_ID_LEn) :: str
2275
end function common_id_
2276
subroutine common_tag_object_(this)
2277
type(iCSC0_z3D), intent(inout) :: this
2278
end subroutine common_tag_object_
2279
subroutine delete_(this)
2280
type(iCSC0_z3D), intent(inout) :: this
2281
call set_error(this, 0)
2282
call delete(this%D%e1)
2283
if ( 0 /= error(this%D%e1) ) &
2284
call set_error(this, error(this%D%e1))
2285
call delete(this%D%e2)
2286
if ( 0 /= error(this%D%e2) ) &
2287
call set_error(this, error(this%D%e2))
2288
end subroutine delete_
2289
subroutine copy_(from, to)
2290
type(iCSC0_z3D), intent(in) :: from
2291
type(iCSC0_z3D), intent(inout) :: to
2293
if ( .not. is_initd(from) ) return
2295
call common_copy_(from, to)
2296
call copy(from%D%e1, to%D%e1)
2297
call copy(from%D%e2, to%D%e2)
2298
end subroutine copy_
2299
subroutine new_data_(this, a, b &
2301
type(iCSC0_z3D), intent(inout) :: this
2302
type(iSM_CSC0), intent(inout) :: a
2303
type(zArray3D), intent(inout) :: b
2307
end subroutine new_data_
2308
subroutine new_(this)
2309
type(iCSC0_z3D), intent(inout) :: this
2310
call initialize(this)
2312
subroutine get_elem1_(this, item)
2313
type(iCSC0_z3D), intent(in) :: this
2314
type(iSM_CSC0), intent(inout) :: item
2315
if ( .not. is_initd(this) ) then
2321
subroutine get_elem1_assign_(item, this)
2322
type(iSM_CSC0), intent(inout) :: item
2323
type(iCSC0_z3D), intent(in) :: this
2324
if ( .not. is_initd(this) ) then
2330
subroutine set_elem1_(this, item)
2331
type(iCSC0_z3D), intent(inout) :: this
2332
type(iSM_CSC0), intent(in) :: item
2333
if ( .not. is_initd(this) ) return
2336
function get_elem1p_(this) result(p)
2337
type(iCSC0_z3D), intent(inout) :: this
2338
type(iSM_CSC0), pointer :: p
2339
if ( .not. is_initd(this) ) then
2345
subroutine get_elem2_(this, item)
2346
type(iCSC0_z3D), intent(in) :: this
2347
type(zArray3D), intent(inout) :: item
2348
if ( .not. is_initd(this) ) then
2354
subroutine get_elem2_assign_(item, this)
2355
type(zArray3D), intent(inout) :: item
2356
type(iCSC0_z3D), intent(in) :: this
2357
if ( .not. is_initd(this) ) then
2363
subroutine set_elem2_(this, item)
2364
type(iCSC0_z3D), intent(inout) :: this
2365
type(zArray3D), intent(in) :: item
2366
if ( .not. is_initd(this) ) return
2369
function get_elem2p_(this) result(p)
2370
type(iCSC0_z3D), intent(inout) :: this
2371
type(zArray3D), pointer :: p
2372
if ( .not. is_initd(this) ) then
2378
subroutine print_(this, info, indent)
2379
type(iCSC0_z3D), intent(in) :: this
2380
character(len=*), intent(in), optional :: info
2381
integer, intent(in), optional :: indent
2383
character(len=32) :: fmt
2384
character(len=256) :: name
2386
if ( present(info) ) name = info
2388
if ( present(indent) ) lindent = indent
2389
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
2390
if ( .not. is_initd(this) ) then
2391
write(*,fmt) "<", trim(name), " not initialized>"
2394
write(fmt, '(a,i0,a)') '(t',lindent,',3a)'
2395
lindent = lindent + 2 ! step indentation
2396
write(*,fmt) "<<", trim(name), " coll>"
2397
call print(this%D%e1, indent = lindent)
2398
call print(this%D%e2, indent = lindent)
2399
lindent = lindent - 2 ! go back to requested indentation
2400
write(fmt, '(a,i0,a)') '(t',lindent,',a,i0,a)'
2401
write(*,fmt) " <coll-refs: ", references(this), ">>"
2402
end subroutine print_
2403
function matrix_p_(this) result(p)
2404
type(iCSC0_z3D), intent(in) :: this
2405
complex(rd_), pointer :: p (:,:,:)
2406
p => array_p(this%D%e2)
2407
end function matrix_p_
2408
function sparse_index_(this) result(idx)
2409
type(iCSC0_z3D), intent(in) :: this
2412
end function sparse_index_
2413
pure function dimensions_(this) result(d)
2414
type(iCSC0_z3D), intent(in) :: this
2416
if ( is_initd(this) ) then
2421
end function dimensions_
2422
recursive subroutine add_element_(this, ir, ic, val)
2423
type(iCSC0_z3D), intent(inout) :: this
2424
integer(ii_), intent(in) :: ir, ic
2425
complex(rd_), intent(in) :: val
2426
type(iSM_CSC0) :: sm
2427
type(iCSC0_z3D) :: nthis
2428
integer(ii_) :: i, c, ix, nr, nc, npc
2429
complex(rd_), pointer :: p (:,:,:)
2430
if ( .not. is_initd(this) ) return
2432
call add_element(sm, ir, ic, dry_run = .true.)
2433
if ( error(sm) /= 0 ) then
2435
call set_error(this, -1)
2438
call add_element(sm, ir, ic)
2439
i = index(sm, ir, ic)
2441
select case ( sparse_index(this) )
2450
end subroutine add_element_
2451
subroutine write_(f, this, only_array)
2453
type( File ), intent(inout) :: f
2454
type(iCSC0_z3D), intent(inout) :: this
2455
logical, intent(in), optional :: only_array
2456
type(iSM_CSC0) :: sm
2457
type(zArray3D) :: arr
2458
logical :: lonly_array
2459
if ( .not. is_open(f) ) return
2460
if ( .not. is_initd(this) ) return
2461
lonly_array = .false.
2462
if ( present(only_array) ) lonly_array = only_array
2465
if ( .not. is_finalized(sm) ) then
2468
call set_error(this, -1)
2471
if ( .not. lonly_array ) then
2477
end subroutine write_
2478
subroutine read_(f, this, sm)
2480
type( File ), intent(inout) :: f
2481
type(iCSC0_z3D), intent(inout) :: this
2482
type(iSM_CSC0), intent(inout), optional :: sm
2483
type(iSM_CSC0) :: lsm
2484
type(zArray3D) :: arr
2485
if ( .not. is_open(f) ) return
2486
if ( present(sm) ) then
2492
call new(this, lsm, arr)
2494
end subroutine read_