mpi_col_den.F90 17.5 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

7 8 9 10 11
MODULE m_mpi_col_den
  !
  ! collect all data calculated in cdnval on different pe's on pe 0
  !
CONTAINS
12 13 14 15
  SUBROUTINE mpi_col_den(mpi,sphhar,atoms,oneD,stars,vacuum,&
       input, noco,l_fmpl,jspin,llpd,rhtxy,rht,qpw,ener,&
       sqal,results,svac,pvac,uu,dd,du,uunmt,ddnmt,udnmt,dunmt,sqlo,&
       aclo,bclo,cclo,acnmt,bcnmt,ccnmt,enerlo,orb,orbl,orblo,mt21,lo21,uloulop21,&
Gregor Michalicek's avatar
Gregor Michalicek committed
16
       uunmt21,ddnmt21,udnmt21,dunmt21,den,n_mmp)
17 18 19
    !
#include"cpp_double.h"
    USE m_types
Gregor Michalicek's avatar
Gregor Michalicek committed
20
    USE m_constants
21 22
    IMPLICIT NONE

23 24 25 26 27 28 29 30 31
    TYPE(t_results),INTENT(INOUT):: results
    TYPE(t_mpi),INTENT(IN)       :: mpi
    TYPE(t_oneD),INTENT(IN)      :: oneD 
    TYPE(t_input),INTENT(IN)     :: input 
    TYPE(t_vacuum),INTENT(IN)    :: vacuum 
    TYPE(t_noco),INTENT(IN)      :: noco 
    TYPE(t_stars),INTENT(IN)     :: stars 
    TYPE(t_sphhar),INTENT(IN)    :: sphhar 
    TYPE(t_atoms),INTENT(IN)     :: atoms
Gregor Michalicek's avatar
Gregor Michalicek committed
32
    TYPE(t_potden),INTENT(INOUT) :: den
33 34 35 36 37 38 39
    INCLUDE 'mpif.h'
    ! ..
    ! ..  Scalar Arguments ..
    INTEGER, INTENT (IN) :: jspin,llpd
    LOGICAL, INTENT (IN) :: l_fmpl
    ! ..
    ! ..  Array Arguments ..
40
    COMPLEX, INTENT (INOUT) :: qpw(stars%ng3)
41 42
    COMPLEX, INTENT (INOUT) :: rhtxy(vacuum%nmzxyd,oneD%odi%n2d-1,2)
    REAL,    INTENT (INOUT) :: rht(vacuum%nmzd,2) 
Daniel Wortmann's avatar
Daniel Wortmann committed
43
    REAL,    INTENT (INOUT) :: ener(0:3,atoms%ntype),sqal(0:3,atoms%ntype)
44
    REAL,    INTENT (INOUT) :: svac(2),pvac(2)
Daniel Wortmann's avatar
Daniel Wortmann committed
45 46 47 48 49 50 51 52 53 54 55 56 57
    REAL,  INTENT (INOUT) :: dd(0:atoms%lmaxd,atoms%ntype)
    REAL,  INTENT (INOUT) :: du(0:atoms%lmaxd,atoms%ntype)
    REAL,  INTENT (INOUT) :: uu(0:atoms%lmaxd,atoms%ntype)
    REAL,  INTENT (INOUT) :: ddnmt(0:llpd,sphhar%nlhd,atoms%ntype)
    REAL,  INTENT (INOUT) :: dunmt(0:llpd,sphhar%nlhd,atoms%ntype)
    REAL,  INTENT (INOUT) :: udnmt(0:llpd,sphhar%nlhd,atoms%ntype)
    REAL,  INTENT (INOUT) :: uunmt(0:llpd,sphhar%nlhd,atoms%ntype)
    REAL,  INTENT (INOUT) :: sqlo(atoms%nlod,atoms%ntype),enerlo(atoms%nlod,atoms%ntype)
    REAL,  INTENT (INOUT) :: aclo(atoms%nlod,atoms%ntype),bclo(atoms%nlod,atoms%ntype)
    REAL,  INTENT (INOUT) :: cclo(atoms%nlod,atoms%nlod,atoms%ntype)
    REAL,  INTENT (INOUT) :: acnmt(0:atoms%lmaxd,atoms%nlod,sphhar%nlhd,atoms%ntype)
    REAL,  INTENT (INOUT) :: bcnmt(0:atoms%lmaxd,atoms%nlod,sphhar%nlhd,atoms%ntype)
    REAL,  INTENT (INOUT) :: ccnmt(atoms%nlod,atoms%nlod,sphhar%nlhd,atoms%ntype)
58 59 60 61
    COMPLEX,INTENT(INOUT) :: ddnmt21((atoms%lmaxd+1)**2  )
    COMPLEX,INTENT(INOUT) :: dunmt21((atoms%lmaxd+1)**2  )
    COMPLEX,INTENT(INOUT) :: udnmt21((atoms%lmaxd+1)**2  )
    COMPLEX,INTENT(INOUT) :: uunmt21((atoms%lmaxd+1)**2  )
Daniel Wortmann's avatar
Daniel Wortmann committed
62
    COMPLEX,INTENT(INOUT) :: uloulop21(atoms%nlod,atoms%nlod,atoms%ntype)
Gregor Michalicek's avatar
Gregor Michalicek committed
63
    COMPLEX,INTENT(INOUT) :: n_mmp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,atoms%n_u)
Daniel Wortmann's avatar
Daniel Wortmann committed
64 65 66 67 68
    TYPE (t_orb),  INTENT (INOUT) :: orb(0:atoms%lmaxd,-atoms%lmaxd:atoms%lmaxd,atoms%ntype)
    TYPE (t_orbl), INTENT (INOUT) :: orbl(atoms%nlod,-atoms%llod:atoms%llod,atoms%ntype)
    TYPE (t_orblo),INTENT (INOUT) :: orblo(atoms%nlod,atoms%nlod,-atoms%llod:atoms%llod,atoms%ntype)
    TYPE (t_mt21), INTENT (INOUT) :: mt21(0:atoms%lmaxd,atoms%ntype)
    TYPE (t_lo21), INTENT (INOUT) :: lo21(atoms%nlod,atoms%ntype)
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    ! ..
    ! ..  Local Scalars ..
    INTEGER :: n
    ! ..
    ! ..  Local Arrays ..
    INTEGER :: ierr(3)
    COMPLEX, ALLOCATABLE :: c_b(:)
    REAL,    ALLOCATABLE :: r_b(:)
    ! ..
    ! ..  External Subroutines
    EXTERNAL CPP_BLAS_scopy,CPP_BLAS_ccopy,MPI_REDUCE

    !
    ! -> Collect qpw()
    !
84
    n = stars%ng3
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    ALLOCATE(c_b(n))
    CALL MPI_REDUCE(qpw,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_ccopy(n, c_b, 1, qpw, 1)
    ENDIF
    DEALLOCATE (c_b)
    !
    ! -> Collect rhtxy()
    !
    IF (input%film) THEN

       n = vacuum%nmzxyd*(oneD%odi%n2d-1)*2
       ALLOCATE(c_b(n))
       CALL MPI_REDUCE(rhtxy,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, rhtxy, 1)
       ENDIF
       DEALLOCATE (c_b)
       !
       ! -> Collect rht()
       !
       n = vacuum%nmzd*2
       ALLOCATE(r_b(n))
       CALL MPI_REDUCE(rht,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, rht, 1)
       ENDIF
       DEALLOCATE (r_b)

    ENDIF
    !
    ! -> Collect uu(),ud() and dd()
    !
Daniel Wortmann's avatar
Daniel Wortmann committed
118
    n = (atoms%lmaxd+1)*atoms%ntype
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    ALLOCATE(r_b(n))
    CALL MPI_REDUCE(uu,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, uu, 1)
    ENDIF
    CALL MPI_REDUCE(du,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, du, 1)
    ENDIF
    CALL MPI_REDUCE(dd,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, dd, 1)
    ENDIF
    DEALLOCATE (r_b)
    !
    !--> Collect uunmt,udnmt,dunmt,ddnmt
    !
Daniel Wortmann's avatar
Daniel Wortmann committed
136
    n = (llpd+1)*sphhar%nlhd*atoms%ntype
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    ALLOCATE(r_b(n))
    CALL MPI_REDUCE(uunmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, uunmt, 1)
    ENDIF
    CALL MPI_REDUCE(udnmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, udnmt, 1)
    ENDIF
    CALL MPI_REDUCE(dunmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, dunmt, 1)
    ENDIF
    CALL MPI_REDUCE(ddnmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, ddnmt, 1)
    ENDIF
    DEALLOCATE (r_b)
    !
    !--> ener & sqal
    !
Daniel Wortmann's avatar
Daniel Wortmann committed
158
    n=4*atoms%ntype
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
    ALLOCATE(r_b(n))
    CALL MPI_REDUCE(ener,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, ener, 1)
    ENDIF
    CALL MPI_REDUCE(sqal,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
    IF (mpi%irank.EQ.0) THEN
       CALL CPP_BLAS_scopy(n, r_b, 1, sqal, 1)
    ENDIF
    DEALLOCATE (r_b)
    !
    !--> svac & pvac
    !
    IF ( input%film ) THEN

       n=2
       ALLOCATE(r_b(n))
       CALL MPI_REDUCE(svac,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, svac, 1)
       ENDIF
       CALL MPI_REDUCE(pvac,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, pvac, 1)
       ENDIF
       DEALLOCATE (r_b)

    ENDIF
    !
    ! -> Collect force
    !   
    IF (input%l_f) THEN

Daniel Wortmann's avatar
Daniel Wortmann committed
192
       n=3*atoms%ntype
193
       ALLOCATE(r_b(n))
194
       CALL MPI_REDUCE(results%force(1,1,jspin),r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
195
       IF (mpi%irank.EQ.0) THEN
196
          CALL CPP_BLAS_scopy(n, r_b, 1, results%force(1,1,jspin), 1)
197 198 199 200 201 202 203 204 205
       ENDIF
       DEALLOCATE (r_b)

    ENDIF
    !
    ! -> Optional the LO-coefficients: aclo,bclo,enerlo,cclo,acnmt,bcnmt,ccnmt
    !
    IF (atoms%nlod.GE.1) THEN

Daniel Wortmann's avatar
Daniel Wortmann committed
206
       n=atoms%nlod*atoms%ntype 
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(aclo,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, aclo, 1)
       ENDIF
       CALL MPI_REDUCE(bclo,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, bclo, 1)
       ENDIF
       CALL MPI_REDUCE(enerlo,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, enerlo, 1)
       ENDIF
       CALL MPI_REDUCE(sqlo,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, sqlo, 1)
       ENDIF
       DEALLOCATE (r_b)

Daniel Wortmann's avatar
Daniel Wortmann committed
226
       n = atoms%nlod * atoms%nlod * atoms%ntype
227 228 229 230 231 232 233
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(cclo,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, cclo, 1)
       ENDIF
       DEALLOCATE (r_b)

Daniel Wortmann's avatar
Daniel Wortmann committed
234
       n = (atoms%lmaxd+1) * atoms%ntype * atoms%nlod * sphhar%nlhd
235 236 237 238 239 240 241 242 243 244 245
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(acnmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, acnmt, 1)
       ENDIF
       CALL MPI_REDUCE(bcnmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, bcnmt, 1)
       ENDIF
       DEALLOCATE (r_b)

Daniel Wortmann's avatar
Daniel Wortmann committed
246
       n = atoms%ntype * sphhar%nlhd * atoms%nlod**2
247 248 249 250 251 252 253 254 255 256 257 258 259 260
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(ccnmt,r_b,n,CPP_MPI_REAL,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, ccnmt, 1)
       ENDIF
       DEALLOCATE (r_b)

    ENDIF
    !
    ! ->  Now the SOC - stuff: orb, orblo and orblo
    !
    IF (noco%l_soc) THEN
       !
       ! orb
Daniel Wortmann's avatar
Daniel Wortmann committed
261
       n=(atoms%lmaxd+1)*(2*atoms%lmaxd+1)*atoms%ntype
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(orb(:,:,:)%uu,r_b,n,CPP_MPI_REAL, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, orb(:,:,:)%uu, 1)
       ENDIF
       CALL MPI_REDUCE(orb(:,:,:)%dd,r_b,n,CPP_MPI_REAL, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, orb(:,:,:)%dd, 1)
       ENDIF
       DEALLOCATE (r_b)

       ALLOCATE (c_b(n))
       CALL MPI_REDUCE(orb(:,:,:)%uup,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orb(:,:,:)%uup, 1)
       ENDIF
       CALL MPI_REDUCE(orb(:,:,:)%ddp,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orb(:,:,:)%ddp, 1)
       ENDIF
       CALL MPI_REDUCE(orb(:,:,:)%uum,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orb(:,:,:)%uum, 1)
       ENDIF
       CALL MPI_REDUCE(orb(:,:,:)%ddm,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orb(:,:,:)%ddm, 1)
       ENDIF
       DEALLOCATE (c_b)
       ! orbl
       !
Daniel Wortmann's avatar
Daniel Wortmann committed
293
       n = atoms%nlod * (2*atoms%llod+1) * atoms%ntype
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(orbl(:,:,:)%uulo,r_b,n,CPP_MPI_REAL, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, orbl(:,:,:)%uulo, 1)
       ENDIF
       CALL MPI_REDUCE(orbl(:,:,:)%dulo,r_b,n,CPP_MPI_REAL, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, orbl(:,:,:)%dulo, 1)
       ENDIF
       DEALLOCATE (r_b)

       ALLOCATE (c_b(n))
       CALL MPI_REDUCE(orbl(:,:,:)%uulop,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orbl(:,:,:)%uulop, 1)
       ENDIF
       CALL MPI_REDUCE(orbl(:,:,:)%dulop,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orbl(:,:,:)%dulop, 1)
       ENDIF
       CALL MPI_REDUCE(orbl(:,:,:)%uulom,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orbl(:,:,:)%uulom, 1)
       ENDIF
       CALL MPI_REDUCE(orbl(:,:,:)%dulom,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orbl(:,:,:)%dulom, 1)
       ENDIF
       DEALLOCATE (c_b)
       ! orblo
       !
Daniel Wortmann's avatar
Daniel Wortmann committed
325
       n = atoms%nlod * atoms%nlod * (2*atoms%llod+1) * atoms%ntype
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
       ALLOCATE (r_b(n))
       CALL MPI_REDUCE(orblo(:,:,:,:)%z,r_b,n,CPP_MPI_REAL, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_scopy(n, r_b, 1, orblo(:,:,:,:)%z, 1)
       ENDIF
       DEALLOCATE (r_b)

       ALLOCATE (c_b(n))
       CALL MPI_REDUCE(orblo(:,:,:,:)%p,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orblo(:,:,:,:)%p, 1)
       ENDIF
       CALL MPI_REDUCE(orblo(:,:,:,:)%m,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, orblo(:,:,:,:)%m, 1)
       ENDIF
       DEALLOCATE (c_b)

    ENDIF

    !
    ! -> Collect the noco staff: 
    !
    IF ( noco%l_noco .AND. jspin.EQ.1 ) THEN

351
       n = stars%ng3
352
       ALLOCATE(c_b(n))
Gregor Michalicek's avatar
Gregor Michalicek committed
353
       CALL MPI_REDUCE(den%cdom,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0, MPI_COMM_WORLD,ierr)
354
       IF (mpi%irank.EQ.0) THEN
Gregor Michalicek's avatar
Gregor Michalicek committed
355
          CALL CPP_BLAS_ccopy(n, c_b, 1, den%cdom, 1)
356 357 358 359 360 361 362
       ENDIF
       DEALLOCATE (c_b)
       !
       IF (input%film) THEN

          n = vacuum%nmzxyd*(oneD%odi%n2d-1)*2
          ALLOCATE(c_b(n))
Gregor Michalicek's avatar
Gregor Michalicek committed
363
          CALL MPI_REDUCE(den%vacxy(:,:,:,3),c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0, MPI_COMM_WORLD,ierr)
364
          IF (mpi%irank.EQ.0) THEN
Gregor Michalicek's avatar
Gregor Michalicek committed
365
             CALL CPP_BLAS_ccopy(n, c_b, 1, den%vacxy(:,:,:,3), 1)
366 367 368 369 370
          ENDIF
          DEALLOCATE (c_b)
          !
          n = vacuum%nmzd*2
          ALLOCATE(c_b(n))
Gregor Michalicek's avatar
Gregor Michalicek committed
371
          CALL MPI_REDUCE(den%cdomvz,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0, MPI_COMM_WORLD,ierr)
372
          IF (mpi%irank.EQ.0) THEN
Gregor Michalicek's avatar
Gregor Michalicek committed
373
             CALL CPP_BLAS_ccopy(n, c_b, 1, den%cdomvz, 1)
374 375 376 377 378 379 380 381 382 383
          ENDIF
          DEALLOCATE (c_b)

       ENDIF ! input%film


       IF (noco%l_mperp) THEN
          !
          ! -->     for (spin)-off diagonal part of muffin-tin
          !
Daniel Wortmann's avatar
Daniel Wortmann committed
384
          n = (atoms%lmaxd+1) * atoms%ntype
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
          ALLOCATE(c_b(n))
          CALL MPI_REDUCE(mt21(:,:)%uu,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, mt21(:,:)%uu, 1)
          ENDIF
          CALL MPI_REDUCE(mt21(:,:)%ud,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, mt21(:,:)%ud, 1)
          ENDIF
          CALL MPI_REDUCE(mt21(:,:)%du,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, mt21(:,:)%du, 1)
          ENDIF
          CALL MPI_REDUCE(mt21(:,:)%dd,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, mt21(:,:)%dd, 1)
          ENDIF
          DEALLOCATE (c_b)
          !
          ! -->     lo,u coeff's:
          !
Daniel Wortmann's avatar
Daniel Wortmann committed
406
          n = atoms%nlod * atoms%ntype
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
          ALLOCATE(c_b(n))
          CALL MPI_REDUCE(lo21(:,:)%uulo,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, lo21(:,:)%uulo, 1)
          ENDIF
          CALL MPI_REDUCE(lo21(:,:)%ulou,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, lo21(:,:)%ulou, 1)
          ENDIF
          CALL MPI_REDUCE(lo21(:,:)%dulo,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, lo21(:,:)%dulo, 1)
          ENDIF
          CALL MPI_REDUCE(lo21(:,:)%ulod,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, lo21(:,:)%ulod, 1)
          ENDIF
          DEALLOCATE (c_b)
          !
          ! -->     lo,lo' coeff's:
          !
Daniel Wortmann's avatar
Daniel Wortmann committed
428
          n = atoms%nlod*atoms%nlod*atoms%ntype
429 430 431 432 433 434 435 436 437 438 439
          ALLOCATE(c_b(n))
          CALL MPI_REDUCE(uloulop21,c_b,n,CPP_MPI_COMPLEX, MPI_SUM,0,MPI_COMM_WORLD,ierr)
          IF (mpi%irank.EQ.0) THEN
             CALL CPP_BLAS_ccopy(n, c_b, 1, uloulop21, 1)
          ENDIF
          DEALLOCATE (c_b)

          IF (l_fmpl) THEN
             !
             !-->        Full magnetization plots: Collect uunmt21, etc.
             !
Daniel Wortmann's avatar
Daniel Wortmann committed
440
             n = (atoms%lmaxd+1)**2 *sphhar%nlhd*atoms%ntype
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
             ALLOCATE(c_b(n))
             CALL MPI_REDUCE(uunmt21,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0 ,MPI_COMM_WORLD,ierr)
             IF (mpi%irank.EQ.0) THEN
                CALL CPP_BLAS_ccopy(n, c_b, 1, uunmt21, 1)
             ENDIF
             CALL MPI_REDUCE(udnmt21,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0 ,MPI_COMM_WORLD,ierr)
             IF (mpi%irank.EQ.0) THEN
                CALL CPP_BLAS_ccopy(n, c_b, 1, udnmt21, 1)
             ENDIF
             CALL MPI_REDUCE(dunmt21,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0 ,MPI_COMM_WORLD,ierr)
             IF (mpi%irank.EQ.0) THEN
                CALL CPP_BLAS_ccopy(n, c_b, 1, dunmt21, 1)
             ENDIF
             CALL MPI_REDUCE(ddnmt21,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0 ,MPI_COMM_WORLD,ierr)
             IF (mpi%irank.EQ.0) THEN
                CALL CPP_BLAS_ccopy(n, c_b, 1, ddnmt21, 1)
             ENDIF
             DEALLOCATE (c_b)

          ENDIF ! fmpl
       ENDIF  ! mperp
    ENDIF   ! noco

    !+lda+U
    IF ( atoms%n_u.GT.0 ) THEN
       n = 49*atoms%n_u 
       ALLOCATE(c_b(n))
       CALL MPI_REDUCE(n_mmp,c_b,n,CPP_MPI_COMPLEX,MPI_SUM,0, MPI_COMM_WORLD,ierr)
       IF (mpi%irank.EQ.0) THEN
          CALL CPP_BLAS_ccopy(n, c_b, 1, n_mmp, 1)
       ENDIF
       DEALLOCATE (c_b)
    ENDIF
    !-lda+U

    RETURN
  END SUBROUTINE mpi_col_den
END MODULE m_mpi_col_den