-
Notifications
You must be signed in to change notification settings - Fork 3
/
ED_HAMILTONIAN_COMMON.f90
110 lines (97 loc) · 3.19 KB
/
ED_HAMILTONIAN_COMMON.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
MODULE ED_HAMILTONIAN_COMMON
USE SF_MISC, only: assert_shape
USE SF_LINALG, only: kronecker_product,eye
USE ED_INPUT_VARS
USE ED_VARS_GLOBAL
USE ED_BATH
USE ED_SETUP
implicit none
!
integer :: Dim
integer :: DimUp
integer :: DimDw
integer,allocatable,dimension(:) :: DimUps
integer,allocatable,dimension(:) :: DimDws
!
integer :: Hsector=0
logical :: Hstatus=.false.
type(sector_map),dimension(:),allocatable :: Hs
integer,save,public :: iter=0
!
contains
!####################################################################
! ALL-2-ALL-V VECTOR MPI TRANSPOSITION
!####################################################################
#ifdef _MPI
subroutine vector_transpose_MPI(nrow,qcol,a,ncol,qrow,b)
integer :: nrow,ncol,qrow,qcol
complex(8) :: a(nrow,qcol)
complex(8) :: b(ncol,qrow)
integer,allocatable,dimension(:,:) :: send_counts,send_offset
integer,allocatable,dimension(:,:) :: recv_counts,recv_offset
integer :: counts,Ntot
integer :: i,j,irank,ierr
!
counts = Nrow/MpiSize
Ntot = Ncol/MpiSize
if(mod(Ncol,MpiSize)/=0)Ntot=Ntot+1
!
allocate(send_counts(0:MpiSize-1,Ntot));send_counts=0
allocate(send_offset(0:MpiSize-1,Ntot));send_offset=0
allocate(recv_counts(0:MpiSize-1,Ntot));recv_counts=0
allocate(recv_offset(0:MpiSize-1,Ntot));recv_offset=0
!
do i=1,qcol
do irank=0,MpiSize-1
if(irank < mod(Nrow,MpiSize))then
send_counts(irank,i) = counts+1
else
send_counts(irank,i) = counts
endif
enddo
enddo
!
do i=1,Ntot
call MPI_AllToAll(&
send_counts(0:,i),1,MPI_INTEGER,&
recv_counts(0:,i),1,MPI_INTEGER,&
MpiComm,ierr)
enddo
!
do i=1,Ntot
do irank=1,MpiSize-1
send_offset(irank,i) = send_counts(irank-1,i) + send_offset(irank-1,i)
enddo
enddo
!
!Get the irank=0 elements, i.e. first entries:
recv_offset(0,1) = 0
do i=2,Ntot
recv_offset(0,i) = sum(recv_counts(0,:i-1))
enddo
!the rest of the entries:
do i=1,Ntot
do irank=1,MpiSize-1
recv_offset(irank,i) = recv_offset(irank-1,i) + sum(recv_counts(irank-1,:))
enddo
enddo
!
!
do j=1,Ntot
call MPI_AllToAllV(&
A(:,j),send_counts(:,j),send_offset(:,j),MPI_DOUBLE_COMPLEX,&
B(:,:),recv_counts(:,j),recv_offset(:,j),MPI_DOUBLE_COMPLEX,&
MpiComm,ierr)
enddo
!
call local_transpose(b,ncol,qrow)
!
return
end subroutine vector_transpose_MPI
subroutine local_transpose(mat,nrow,ncol)
integer :: nrow,ncol
complex(8),dimension(Nrow,Ncol) :: mat
mat = transpose(reshape(mat,[Ncol,Nrow]))
end subroutine local_transpose
#endif
end MODULE ED_HAMILTONIAN_COMMON