wann_postproc.F90 22.6 KB
Newer Older
1 2 3 4 5 6 7
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------

MODULE m_wann_postproc
8
CONTAINS
9
  SUBROUTINE wann_postproc(&
10
       stars,vacuum,atoms,sphhar,input,kpts,sym,fmpi,&
11
       lapw,oneD,noco,nococonv,cell,vTot,enpara,sliceplot,eig_id,l_real,&
12 13 14 15 16 17 18 19 20
       wann, fullnkpts, l_proj,ef,l_sgwf,fullnqpts)
    !     <          fermi_weights)

    !***********************************************
    !     Collection of those subroutines which may
    !     be called after the Wannier functions have
    !     been computed.
    !     Frank Freimuth
    !***********************************************
21

22
    USE m_types
23
    USE m_constants
24 25 26 27 28 29 30 31 32
    USE m_wann_dipole
    USE m_wann_dipole2
    USE m_wann_wannierize
    USE m_wann_hopping
    USE m_wann_plot_um_dat
    USE m_wannier_to_lapw
    USE m_wann_plot_from_lapw
    USE m_wann_nabla_rs
    USE m_wann_pauli_rs
Frank Freimuth's avatar
Frank Freimuth committed
33
    USE m_wann_pauliat_rs
34 35 36 37 38 39 40 41 42
    USE m_wann_nabla_pauli_rs
    USE m_wann_socmat_rs
    USE m_wann_perpmag_rs
    USE m_wann_wigner_seitz
    USE m_wann_get_mp
    USE m_wann_get_kpts
    USE m_wann_fft4
    USE m_wann_fft5
    USE m_wann_rmat
Frank Freimuth's avatar
Frank Freimuth committed
43
    use m_wann_socmatvec_rs
44 45
    USE m_wann_nocoplot
    USE m_wann_torque_rs
Frank Freimuth's avatar
Frank Freimuth committed
46
#ifdef CPP_TOPO
47 48 49 50 51 52 53 54 55 56 57 58
    USE m_wann_offdiposop_rs
    USE m_wann_fft6
    USE m_wann_fft3
    USE m_wann_nedrho
#endif

#ifdef DCPP_WANN_EXT
    USE m_wannier_to_lapw_kpts
    USE m_wannier_lapw_gfleur
#endif
    IMPLICIT NONE

59

60 61 62 63 64 65 66
    TYPE(t_stars),INTENT(IN)     :: stars
    TYPE(t_vacuum),INTENT(IN)    :: vacuum
    TYPE(t_atoms),INTENT(IN)     :: atoms
    TYPE(t_sphhar),INTENT(IN)    :: sphhar
    TYPE(t_input),INTENT(IN)     :: input
    TYPE(t_kpts),INTENT(IN)      :: kpts
    TYPE(t_sym),INTENT(IN)       :: sym
67
    TYPE(t_mpi),INTENT(IN)       :: fmpi
68 69 70
    TYPE(t_lapw),INTENT(IN)      :: lapw
    TYPE(t_oneD),INTENT(IN)      :: oneD
    TYPE(t_noco),INTENT(IN)      :: noco
71
    TYPE(t_nococonv),INTENT(IN)  :: nococonv
72 73 74 75 76 77 78 79 80 81 82 83
    TYPE(t_cell),INTENT(IN)      :: cell
    TYPE(t_potden),INTENT(IN)    :: vTot
    TYPE(t_enpara),INTENT(IN)    :: enpara
    type(t_sliceplot),INTENT(IN) :: sliceplot

    TYPE(t_wann), INTENT(in) :: wann
    LOGICAL,      INTENT(in) :: l_real
    INTEGER,      INTENT(in) :: eig_id
    INTEGER,      INTENT(in) :: fullnkpts,fullnqpts
    LOGICAL,      INTENT(in) :: l_proj
    REAL,    INTENT (in) :: ef
    LOGICAL, INTENT (in) :: l_sgwf
84
    !      real,intent(inout)   :: fermi_weights(:,:,:) !(input%neig,nkptd,jspd)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

    CHARACTER(len=12) :: fending
    INTEGER :: i,nkpts,ikpt,nkqpts,iqpt
    REAL    :: delta3,time_lapw_expand,delta2,time_lapw_plot
    LOGICAL :: l_need_fft,l_file
    INTEGER :: hopmin_z,hopmax_z
    INTEGER :: hopmin_y,hopmax_y
    INTEGER :: hopmin_x,hopmax_x
    INTEGER             :: ii
    INTEGER             :: rvecnum,rvecind,num(3),int_dummy
    INTEGER,ALLOCATABLE :: rvec(:,:),ndegen(:)
    REAL                :: scale
    REAL,ALLOCATABLE    :: kpoints(:,:)!(3,fullnkpts)
    INTEGER             :: r1,r2,r3,spinspin,num_angl
    LOGICAL             :: l_nocosoc

    ALLOCATE(kpoints(3,fullnkpts))
    l_nocosoc=.FALSE.
    IF(noco%l_soc)l_nocosoc=.TRUE.
    IF(noco%l_noco)l_nocosoc=.TRUE.

    !***************************************************
    !     Read in the kpoints from w90kpts or kpts.
108
    !***************************************************
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    CALL wann_get_kpts(input,kpts,&
         wann%l_bzsym,input%film,oneD%odi%d1,.FALSE.,&
         nkpts,kpoints)
    IF (nkpts /= fullnkpts)&
         CALL juDFT_error ('mismatch in number of kpoints',&
         calledby="wann_postproc")

    CALL wann_get_kpts(input,kpts,&
         wann%l_bzsym,input%film,oneD%odi%d1,.TRUE.,&
         nkpts,kpoints)
    !*********************************************************
    !     Find out the structure of k-point set.
    !*********************************************************
    CALL wann_get_mp(&
         fullnkpts,kpoints,&
         num)

Frank Freimuth's avatar
Frank Freimuth committed
126
    IF(wann%l_wannierize)THEN
127 128 129 130 131 132 133
#ifndef CPP_WANN
       WRITE(*,*) 'At this point a wannierization has to be performed'
       WRITE(*,*) 'but the Wannier90 library is not linked!'
       CALL juDFT_error ('Wannierization without Wannier90 library',&
            calledby="wann_postproc")
#else
       CALL wann_wannierize(&
134
            input%film,wann,fmpi,kpoints,fullnkpts,input%jspins,&
135 136 137 138
            atoms%nat,atoms%pos,cell%amat,cell%bmat,atoms%ntype,atoms%neq,atoms%zatom)
#endif
    ENDIF

139
    IF(wann%l_dipole2.AND.fmpi%irank==0)THEN
140 141 142 143 144
       CALL wann_dipole2(&
            input%jspins,atoms%pos,cell%omtil,atoms%nat,&
            (noco%l_soc.OR.noco%l_noco))
    ENDIF

145
    IF(wann%l_dipole.AND.fmpi%irank==0)THEN
146 147 148 149 150 151
       CALL wann_dipole(&
            input%jspins,cell%omtil,atoms%nat,atoms%pos,cell%amat,&
            atoms%ntype,atoms%neq,atoms%zatom)
    ENDIF

#ifdef CPP_TOPO
152
    IF(wann%l_nedrho.AND.fmpi%irank==0)THEN
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
       CALL wann_nedrho(&
            fullnkpts,cell%area,ef,&
            fermi_weights)
    ENDIF
#endif

    IF(wann%l_byenergy) i=3
    IF(wann%l_bynumber) i=2
    IF(wann%l_byindex)  i=1

    IF(wann%l_plotw90)THEN
       CALL juDFT_error("not in this version",&
            calledby ="wann_postproc")

       !         call wann_plotw90(i,wann%band_min,wann%band_max,numbands,nwfs,
       !     >   atoms%l_dulo,noco%l_noco,noco%l_ss,atoms%lmaxd,atoms%ntype,
169
       !     >      input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),jspd,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,
170
       !     >      nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,
171
       !     >      sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,
172
       !     >      nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,fmpi%irank,fmpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,
173
       !     >      size(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,
174
       !     >      sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,
175
       !     >      stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,
176
       !     >      cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,
177 178 179 180 181 182 183 184
       !     >      cell%volint,sym%symor,atoms%pos,ef,wann%l_bzsym,irecl)

    ENDIF

    l_need_fft=.FALSE.
    IF(wann%l_hopping.OR.wann%l_nablars.OR.&
         wann%l_nablapaulirs.OR.wann%l_pauli.OR.&
         wann%l_perpmagrs.OR.wann%l_socmatrs.OR.&
Frank Freimuth's avatar
Frank Freimuth committed
185
         wann%l_socmatvecrs.OR.&
186 187 188
         wann%l_torquers.OR.wann%l_offdiposoprs.OR.&
         wann%l_socspicomrs.OR.wann%l_spindisprs.OR.&
         wann%l_anglmomrs .OR.wann%l_perturbrs.OR.&
Frank Freimuth's avatar
Frank Freimuth committed
189 190
         wann%l_orbcomprs.OR.wann%l_rmat.OR.&
         wann%l_pauliat)l_need_fft=.TRUE.
191

192
    IF(l_need_fft.AND.fmpi%irank==0)THEN
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247

       IF(.FALSE.)THEN !specify r-mesh by its boundaries
          hopmin_z=-5;hopmax_z=5
          hopmin_x=0;hopmax_x=0
          hopmin_y=0;hopmax_y=0
          rvecnum=(hopmax_z-hopmin_z+1)
          IF(.NOT.oneD%odi%d1.AND.input%film)THEN
             hopmin_x=-5;hopmax_x=5
             hopmin_y=-5;hopmax_y=5
             hopmin_z=0;     hopmax_z=0
          ELSE
             hopmin_x=-5;hopmax_x=5
             hopmin_y=-5;hopmax_y=5
          ENDIF
          rvecnum=        (hopmax_z-hopmin_z+1)
          rvecnum=rvecnum*(hopmax_y-hopmin_y+1)
          rvecnum=rvecnum*(hopmax_x-hopmin_x+1)

          ALLOCATE(rvec(3,rvecnum))
          rvecind=0
          DO r3=hopmin_z,hopmax_z
             DO r2=hopmin_y,hopmax_y
                DO r1=hopmin_x,hopmax_x
                   rvecind=rvecind+1
                   IF (rvecind > rvecnum)&
                        CALL juDFT_error ('mismatch in number of kpoints',&
                        calledby="wann_postproc")

                   rvec(1,rvecind)=r1
                   rvec(2,rvecind)=r2
                   rvec(3,rvecind)=r3
                ENDDO !r1
             ENDDO !r2
          ENDDO !r3
       ELSE !determine optimal r-mesh
          CALL wann_wigner_seitz(&
               .TRUE.,num,cell%amat,0,&
               rvecnum,rvec,ndegen)
          ALLOCATE(rvec(3,rvecnum))
          ALLOCATE(ndegen(rvecnum))
          CALL wann_wigner_seitz(&
               .FALSE.,num,cell%amat,rvecnum,&
               int_dummy,rvec,ndegen)

          OPEN(333,file='wig_vectors',recl=1000)
          DO ii=1,rvecnum
             WRITE(333,*)ii,rvec(1,ii),rvec(2,ii),rvec(3,ii),&
                  ndegen(ii)
          ENDDO
          CLOSE(333)

       ENDIF

    ENDIF

248
    IF(wann%l_hopping.AND.fmpi%irank==0) THEN
249 250 251 252
       CALL wann_hopping(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            l_nocosoc,wann%band_min,wann%band_max,&
253
            input%neig,wann%l_socmmn0,wann%l_ndegen,ndegen,&
254 255 256
            wann%wan90version,wann%l_unformatted)
    ENDIF

257
    IF(wann%l_nablars.AND.fmpi%irank==0) THEN
258 259 260 261
       CALL wann_nabla_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            noco%l_soc,wann%band_min,wann%band_max,&
262
            input%neig,.FALSE.,&
263 264 265
            wann%wan90version)
    ENDIF

266
    IF(wann%l_orbcomprs.AND.fmpi%irank==0)THEN
267 268 269 270 271 272 273 274
       num_angl=9
       IF(wann%l_oc_f)num_angl=16
       CALL wann_fft5(&
            .FALSE.,&
            num_angl,wann%oc_num_orbs,&
            'WF1.orbcomp','orbcomp.1',&
            rvecnum,rvec,kpoints,&
            1,fullnkpts,input%film,&
275
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
276 277 278 279 280 281 282 283 284 285
            wann%wan90version)
       IF( input%jspins.EQ.2 )THEN
          spinspin=2
          IF(noco%l_soc.OR.noco%l_noco)spinspin=1
          CALL wann_fft5(&
               .FALSE.,&
               num_angl,wann%oc_num_orbs,&
               'WF2.orbcomp','orbcomp.2',&
               rvecnum,rvec,kpoints,&
               spinspin,fullnkpts,input%film,&
286
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
287 288 289 290 291 292 293 294 295 296
               wann%wan90version)
       ENDIF
    ENDIF

    IF(wann%l_rmat)THEN
       CALL wann_rmat(&
            cell%bmat,cell%amat,&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            l_nocosoc,wann%band_min,wann%band_max,&
297
            input%neig,.FALSE.,wann%wan90version)
298 299 300
    ENDIF


301
    IF(wann%l_anglmomrs.AND.fmpi%irank==0)THEN
302 303 304 305
       CALL wann_fft4(&
            'WF1.anglmom',&
            'anglmomrs.1',.FALSE.,&
            rvecnum,rvec,kpoints,&
Frank Freimuth's avatar
Frank Freimuth committed
306
            1,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
307
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
308
            .FALSE.,wann%wan90version)
309 310

       IF( input%jspins.EQ.2 )THEN
Frank Freimuth's avatar
Frank Freimuth committed
311
          IF(.not.(noco%l_soc.OR.noco%l_noco))&
312 313 314 315
          CALL wann_fft4(&
            'WF2.anglmom',&
            'anglmomrs.2',.FALSE.,&
            rvecnum,rvec,kpoints,&
Frank Freimuth's avatar
Frank Freimuth committed
316
            2,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
317 318 319 320 321
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
            .FALSE.,wann%wan90version)
        ENDIF


322 323 324
    ENDIF

#ifdef CPP_TOPO
325
    IF(wann%l_offdiposoprs.AND.fmpi%irank==0)THEN
326 327 328
       CALL wann_offdiposop_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
329
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
330 331 332
            .FALSE.)
    ENDIF

333
    IF(wann%l_spindisprs.AND.fmpi%irank==0)THEN
334 335 336
       CALL wann_fft5(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
337
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
338 339 340
            .FALSE.)
    ENDIF

341
    IF(wann%l_perturbrs.AND.fmpi%irank==0)THEN
342 343 344 345
       CALL wann_fft3(&
            'WF1.perturb'  ,'perturbrs.1'  ,.FALSE.,&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
346
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
347 348 349
            .FALSE.)
    ENDIF

350
    IF(wann%l_socspicomrs.AND.fmpi%irank==0)THEN
351 352 353 354 355
       IF(noco%l_soc)THEN
          CALL wann_fft4(&
               'WF1.socspicom','socspicomrs.1',.TRUE.,&
               rvecnum,rvec,kpoints,&
               input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
356
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
357 358 359 360 361
               .FALSE.)
       ELSE
          CALL wann_fft6(&
               rvecnum,rvec,kpoints,&
               input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
362
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
363 364 365 366
               .FALSE.)
       ENDIF
    ENDIF

Frank Freimuth's avatar
Frank Freimuth committed
367
#endif
368

369
    IF(wann%l_torquers.AND.fmpi%irank==0) THEN
370 371 372
       CALL wann_torque_rs(&
            atoms%ntype,atoms%neq,rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
Frank Freimuth's avatar
Frank Freimuth committed
373
            (noco%l_soc.or.noco%l_noco),wann%band_min,wann%band_max,&
Frank Freimuth's avatar
Frank Freimuth committed
374 375
            input%neig,.FALSE.,wann%l_ndegen,ndegen, &
            wann%wan90version,wann%l_unformatted)
376
    ENDIF
Frank Freimuth's avatar
Frank Freimuth committed
377

Frank Freimuth's avatar
Frank Freimuth committed
378
     IF(wann%l_pauliat.AND.fmpi%irank==0) THEN
Frank Freimuth's avatar
Frank Freimuth committed
379
         call wann_pauliat_rs(&
Frank Freimuth's avatar
Frank Freimuth committed
380 381 382
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            (noco%l_soc.or.noco%l_noco),wann%band_min,wann%band_max,&
Frank Freimuth's avatar
Frank Freimuth committed
383
            input%neig,.false.,atoms%ntype,atoms%neq,wann%l_ndegen,ndegen,&
Frank Freimuth's avatar
Frank Freimuth committed
384 385 386
            wann%wan90version,wann%l_unformatted)
     ENDIF

387
    IF (wann%l_nablapaulirs.AND.fmpi%irank==0)THEN
388 389 390 391
       CALL wann_nabla_pauli_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            noco%l_soc,wann%band_min,wann%band_max,&
392
            input%neig,.FALSE.,wann%wan90version)
393 394
    ENDIF

395
    IF (wann%l_pauli.AND.fmpi%irank==0)THEN
396 397 398 399
       CALL wann_pauli_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            l_nocosoc,wann%band_min,wann%band_max,&
400
            input%neig,.FALSE.,wann%l_ndegen,ndegen,&
401 402 403
            wann%wan90version,wann%l_unformatted)
    ENDIF

404
    IF (wann%l_perpmagrs.AND.fmpi%irank==0)THEN
405 406 407 408
       CALL wann_perpmag_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            noco%l_soc,wann%band_min,wann%band_max,&
409
            input%neig,.FALSE.,wann%l_ndegen,ndegen,wann%wan90version,&
410 411 412
            wann%l_unformatted)
    ENDIF

413
    IF (wann%l_socmatrs.AND.fmpi%irank==0)THEN
414 415 416 417
       CALL wann_socmat_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            noco%l_soc,wann%band_min,wann%band_max,&
418
            input%neig,.FALSE.,wann%wan90version)
419 420
    ENDIF

421
      if (wann%l_socmatvecrs.and.fmpi%irank==0)then
Frank Freimuth's avatar
Frank Freimuth committed
422 423 424 425 426 427 428 429 430
         call wann_socmatvec_rs( &
            rvecnum,rvec,kpoints, &
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1, &
            noco%l_soc,wann%band_min,wann%band_max, &
            input%neig,.false.,wann%l_ndegen,ndegen,&
            wann%wan90version,wann%l_unformatted)
      endif


431 432
    IF(wann%l_plot_umdat)THEN
       CALL wann_plot_um_dat(&
433
            kpts,stars,vacuum,atoms,sphhar,input,sym,fmpi,&
Frank Freimuth's avatar
Frank Freimuth committed
434
            oneD,noco,nococonv,cell,vTot,enpara,eig_id,l_real,&
435
            fmpi%mpi_comm,i,wann%band_min,wann%band_max,noco%l_soc,&
436
            atoms%l_dulo,noco%l_noco,noco%l_ss,atoms%lmaxd,atoms%ntype,&
Frank Freimuth's avatar
Frank Freimuth committed
437
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,atoms%llod,atoms%nlod,atoms%ntype,&
438
            cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
439
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
440
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,fmpi%irank,fmpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
441
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
442
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
443
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
444
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
445 446 447 448 449 450
            cell%volint,sym%symor,atoms%pos,ef,wann%l_bzsym,wann%l_proj_plot,&
            wann%wan90version)
    ENDIF


    CALL CPU_TIME(delta2)
451
    IF(wann%l_lapw.AND.fmpi%irank==0)THEN
452
       CALL wannier_to_lapw(&
453
            fmpi%mpi_comm,eig_id,l_real,&
454
            input,lapw,oneD,noco,nococonv,sym,cell,atoms,stars,vacuum,sphhar,&
455 456 457
            vTot,&
            noco%l_soc,wann%unigrid,i,wann%band_min,wann%band_max,&
            atoms%l_dulo,noco%l_noco,noco%l_ss,atoms%lmaxd,atoms%ntype,&
458
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
459
            cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
460
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
461
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,fmpi%irank,fmpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
462
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
463
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
464
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
465
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
466 467 468 469 470 471 472 473 474
            cell%volint,sym%symor,atoms%pos,ef,wann%l_bzsym,wann%l_proj_plot,&
            wann%wan90version)
    ENDIF

    IF(wann%l_lapw_kpts)THEN
#ifdef DCPP_WANN_EXT
       CALL wannier_to_lapw_kpts(&
            unigrid,i,wann%band_min,wann%band_max,&
            atoms%l_dulo,noco%l_noco,noco%l_ss,atoms%lmaxd,atoms%ntype,&
475
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
476
            nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
477
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
478
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,fmpi%irank,fmpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
479
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
480
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
481
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
482
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
483 484 485 486 487 488 489 490 491 492 493
            cell%volint,sym%symor,atoms%pos,ef,wann%l_bzsym,wann%l_proj_plot,irecl)
#else
       CALL juDFT_error("not yet tested in this release",calledby&
            ="wann_postproc")
#endif
    ENDIF
    IF(wann%l_lapw_gfleur)THEN
#ifdef DCPP_WANN_EXT
       CALL wannier_lapw_gfleur(&
            gfthick,gfcut,i,wann%band_min,wann%band_max,&
            atoms%l_dulo,noco%l_noco,noco%l_ss,atoms%lmaxd,atoms%ntype,&
494
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
495
            nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
496
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
497
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,fmpi%irank,fmpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
498
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
499
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
500
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
501
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
502 503 504 505 506 507 508 509 510 511 512
            cell%volint,sym%symor,atoms%pos,ef,wann%l_bzsym,wann%l_proj_plot,irecl)
#else
       CALL juDFT_error("not yet tested in this release",calledby&
            ="wann_postproc")
#endif
    ENDIF

    CALL CPU_TIME(delta3)
    time_lapw_expand=delta3-delta2

    CALL CPU_TIME(delta2)
513
    IF(wann%l_plot_lapw.AND.fmpi%irank==0)THEN
514 515 516
       CALL juDFT_error("not yet tested in this release",calledby&
            ="wann_postproc")
       !         call wann_plot_from_lapw(
517
       !     >     lapw%dim_nv2d(),input%jspins,oneD%odi,oneD%ods,stars%ng3,vacuum%nmzxyd,stars%ng2,
518 519 520
       !     >     sphhar%ntypsd,
       !     >     atoms%ntype,atoms%lmaxd,size(atoms%rmsh,1),atoms%nat,vacuum%nmzd,atoms%neq,stars%ng3,vacuum%nvac,
       !     >     vacuum%nmz,vacuum%nmzxy,stars%ng2,sym%nop,sym%nop2,cell%volint,input%film,sliceplot%slice,sym%symor,
521
       !     >     sym%invs,sym%invs2,cell%z1,vacuum%delz,sym%ngopr,sym%ntypsy,atoms%jri,atoms%pos,atoms%zatom,
522 523 524 525 526 527
       !     >     atoms%lmax,sym%mrot,sym%tau,atoms%rmsh,sym%invtab,cell%amat,cell%bmat,cell%bbmat,sliceplot%nnne,sliceplot%kk,
       !     >     atoms%nlod,atoms%llod,lmd,cell%omtil,atoms%nlo,atoms%llo)
    ENDIF
    CALL CPU_TIME(delta3)
    time_lapw_plot=delta3-delta2

528 529
    WRITE(oUnit,*)"time_lapw_expand=",time_lapw_expand
    WRITE(oUnit,*)"time_lapw_plot=",time_lapw_plot
530

531
    IF(wann%l_finishnocoplot.AND.fmpi%irank==0) THEN
532
       !         write(*,*)'doing the UNK mixing'
533 534
       !         write(*,*)'nococonv%alph',nococonv%alph
       !         write(*,*)'nococonv%beta',nococonv%beta
535
       !         nkqpts=fullnkpts
536
       !         if(l_sgwf) nkqpts=fullnkpts*fullnqpts
537 538 539
       CALL wann_nocoplot(atoms,sliceplot%slice,sliceplot%nnne,&!nslibd&
            cell%amat,cell%bmat,fullnkpts,oneD%odi,input%film,&
            atoms%nat,atoms%ntype,SIZE(atoms%rmsh,1),atoms%ntype,atoms%neq,atoms%pos,&
540
            atoms%jri,atoms%rmsh,nococonv%alph,nococonv%beta,fullnqpts,nococonv%qss,&
541 542 543 544 545
            cell%z1,atoms%zatom)
    ENDIF

  END SUBROUTINE wann_postproc
END MODULE m_wann_postproc