wann_postproc.F90 21.3 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,mpi,&
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    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
    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
    USE m_wann_nocoplot
#ifdef CPP_TOPO
    USE m_wann_torque_rs
    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

57

58 59 60 61 62 63 64 65 66 67 68
    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
    TYPE(t_mpi),INTENT(IN)       :: mpi
    TYPE(t_lapw),INTENT(IN)      :: lapw
    TYPE(t_oneD),INTENT(IN)      :: oneD
    TYPE(t_noco),INTENT(IN)      :: noco
69
    TYPE(t_nococonv),INTENT(IN)  :: nococonv
70 71 72 73 74 75 76 77 78 79 80 81
    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
82
    !      real,intent(inout)   :: fermi_weights(:,:,:) !(input%neig,nkptd,jspd)
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

    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.
106
    !***************************************************
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    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)

    IF(wann%l_wannierize.AND.mpi%irank==0)THEN
#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(&
            input%film,wann%l_bzsym,input%jspins,&
            atoms%nat,atoms%pos,cell%amat,cell%bmat,atoms%ntype,atoms%neq,atoms%zatom)
#endif
    ENDIF

    IF(wann%l_dipole2.AND.mpi%irank==0)THEN
       CALL wann_dipole2(&
            input%jspins,atoms%pos,cell%omtil,atoms%nat,&
            (noco%l_soc.OR.noco%l_noco))
    ENDIF

    IF(wann%l_dipole.AND.mpi%irank==0)THEN
       CALL wann_dipole(&
            input%jspins,cell%omtil,atoms%nat,atoms%pos,cell%amat,&
            atoms%ntype,atoms%neq,atoms%zatom)
    ENDIF

#ifdef CPP_TOPO
    IF(wann%l_nedrho.AND.mpi%irank==0)THEN
       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,
167
       !     >      input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),jspd,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,
168
       !     >      nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,
169 170
       !     >      sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,
       !     >      nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,mpi%irank,mpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,
171
       !     >      size(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,
172
       !     >      sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,
173
       !     >      stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,
174
       !     >      cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 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 248
       !     >      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.&
         wann%l_torquers.OR.wann%l_offdiposoprs.OR.&
         wann%l_socspicomrs.OR.wann%l_spindisprs.OR.&
         wann%l_anglmomrs .OR.wann%l_perturbrs.OR.&
         wann%l_orbcomprs.OR.wann%l_rmat)l_need_fft=.TRUE.

    IF(l_need_fft.AND.mpi%irank==0)THEN

       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

    IF(wann%l_hopping.AND.mpi%irank==0) THEN
       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,&
249
            input%neig,wann%l_socmmn0,wann%l_ndegen,ndegen,&
250 251 252 253 254 255 256 257
            wann%wan90version,wann%l_unformatted)
    ENDIF

    IF(wann%l_nablars.AND.mpi%irank==0) THEN
       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,&
258
            input%neig,.FALSE.,&
259 260 261 262 263 264 265 266 267 268 269 270
            wann%wan90version)
    ENDIF

    IF(wann%l_orbcomprs.AND.mpi%irank==0)THEN
       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,&
271
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
272 273 274 275 276 277 278 279 280 281
            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,&
282
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
283 284 285 286 287 288 289 290 291 292
               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,&
293
            input%neig,.FALSE.,wann%wan90version)
294 295 296 297 298 299 300 301 302
    ENDIF


    IF(wann%l_anglmomrs.AND.mpi%irank==0)THEN
       CALL wann_fft4(&
            'WF1.anglmom',&
            'anglmomrs.1',.FALSE.,&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
303
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
304 305 306 307 308 309 310 311
            .FALSE.,wann%wan90version)
    ENDIF

#ifdef CPP_TOPO
    IF(wann%l_offdiposoprs.AND.mpi%irank==0)THEN
       CALL wann_offdiposop_rs(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
312
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
313 314 315 316 317 318 319
            .FALSE.)
    ENDIF

    IF(wann%l_spindisprs.AND.mpi%irank==0)THEN
       CALL wann_fft5(&
            rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
320
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
321 322 323 324 325 326 327 328
            .FALSE.)
    ENDIF

    IF(wann%l_perturbrs.AND.mpi%irank==0)THEN
       CALL wann_fft3(&
            'WF1.perturb'  ,'perturbrs.1'  ,.FALSE.,&
            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 333 334 335 336 337 338
            .FALSE.)
    ENDIF

    IF(wann%l_socspicomrs.AND.mpi%irank==0)THEN
       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,&
339
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
340 341 342 343 344
               .FALSE.)
       ELSE
          CALL wann_fft6(&
               rvecnum,rvec,kpoints,&
               input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
345
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
346 347 348 349 350 351 352 353 354 355 356
               .FALSE.)
       ENDIF
    ENDIF



    IF(wann%l_torquers.AND.mpi%irank==0) THEN
       CALL wann_torque_rs(&
            atoms%ntype,atoms%neq,rvecnum,rvec,kpoints,&
            input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
            noco%l_soc,wann%band_min,wann%band_max,&
357
            input%neig,.FALSE.)
358 359 360 361 362 363 364
    ENDIF
#endif
    IF (wann%l_nablapaulirs.AND.mpi%irank==0)THEN
       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,&
365
            input%neig,.FALSE.,wann%wan90version)
366 367 368 369 370 371 372
    ENDIF

    IF (wann%l_pauli.AND.mpi%irank==0)THEN
       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,&
373
            input%neig,.FALSE.,wann%l_ndegen,ndegen,&
374 375 376 377 378 379 380 381
            wann%wan90version,wann%l_unformatted)
    ENDIF

    IF (wann%l_perpmagrs.AND.mpi%irank==0)THEN
       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,&
382
            input%neig,.FALSE.,wann%l_ndegen,ndegen,wann%wan90version,&
383 384 385 386 387 388 389 390
            wann%l_unformatted)
    ENDIF

    IF (wann%l_socmatrs.AND.mpi%irank==0)THEN
       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,&
391
            input%neig,.FALSE.,wann%wan90version)
392 393 394 395
    ENDIF

    IF(wann%l_plot_umdat)THEN
       CALL wann_plot_um_dat(&
396
            stars,vacuum,atoms,sphhar,input,sym,mpi,&
397
            lapw,oneD,noco,nococonv,cell,vTot,enpara,eig_id,l_real,&
398 399
            mpi%mpi_comm,i,wann%band_min,wann%band_max,noco%l_soc,&
            atoms%l_dulo,noco%l_noco,noco%l_ss,atoms%lmaxd,atoms%ntype,&
400
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
401
            cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
402 403
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,mpi%irank,mpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
404
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
405
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
406
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
407
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
408 409 410 411 412 413 414 415 416
            cell%volint,sym%symor,atoms%pos,ef,wann%l_bzsym,wann%l_proj_plot,&
            wann%wan90version)
    ENDIF


    CALL CPU_TIME(delta2)
    IF(wann%l_lapw.AND.mpi%irank==0)THEN
       CALL wannier_to_lapw(&
            mpi%mpi_comm,eig_id,l_real,&
417
            input,lapw,oneD,noco,nococonv,sym,cell,atoms,stars,vacuum,sphhar,&
418 419 420
            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,&
421
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
422
            cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
423 424
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,mpi%irank,mpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
425
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
426
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
427
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
428
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
429 430 431 432 433 434 435 436 437
            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,&
438
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
439
            nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
440 441
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,mpi%irank,mpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
442
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
443
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
444
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
445
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
446 447 448 449 450 451 452 453 454 455 456
            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,&
457
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
458
            nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
459 460
            sym%invsat,sym%invsatnr,kpts%nkpt,atoms%taual,atoms%rmt,cell%amat,cell%bmat,cell%bbmat,nococonv%alph,&
            nococonv%beta,nococonv%qss,stars%sk2,stars%phi2,oneD%odi,oneD%ods,mpi%irank,mpi%isize,stars%ng3,vacuum%nmzxyd,vacuum%nmzd,&
461
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
462
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
463
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
464
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
            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)
    IF(wann%l_plot_lapw.AND.mpi%irank==0)THEN
       CALL juDFT_error("not yet tested in this release",calledby&
            ="wann_postproc")
       !         call wann_plot_from_lapw(
480
       !     >     lapw%dim_nv2d(),input%jspins,oneD%odi,oneD%ods,stars%ng3,vacuum%nmzxyd,stars%ng2,
481 482 483
       !     >     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,
484
       !     >     sym%invs,sym%invs2,cell%z1,vacuum%delz,sym%ngopr,sym%ntypsy,atoms%jri,atoms%pos,atoms%zatom,
485 486 487 488 489 490
       !     >     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

491 492
    WRITE(oUnit,*)"time_lapw_expand=",time_lapw_expand
    WRITE(oUnit,*)"time_lapw_plot=",time_lapw_plot
493 494 495

    IF(wann%l_finishnocoplot.AND.mpi%irank==0) THEN
       !         write(*,*)'doing the UNK mixing'
496 497
       !         write(*,*)'nococonv%alph',nococonv%alph
       !         write(*,*)'nococonv%beta',nococonv%beta
498
       !         nkqpts=fullnkpts
499
       !         if(l_sgwf) nkqpts=fullnkpts*fullnqpts
500 501 502
       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,&
503
            atoms%jri,atoms%rmsh,nococonv%alph,nococonv%beta,fullnqpts,nococonv%qss,&
504 505 506 507 508
            cell%z1,atoms%zatom)
    ENDIF

  END SUBROUTINE wann_postproc
END MODULE m_wann_postproc