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 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
       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
    !***********************************************
    USE m_types
    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_types
    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

56

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

    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.
105
    !***************************************************
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
    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,
166
       !     >      input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),jspd,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,
167
       !     >      nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,
168 169
       !     >      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,
170
       !     >      size(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,
171
       !     >      sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,
172
       !     >      stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,
173
       !     >      cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,
174 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
       !     >      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,&
248
            input%neig,wann%l_socmmn0,wann%l_ndegen,ndegen,&
249 250 251 252 253 254 255 256
            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,&
257
            input%neig,.FALSE.,&
258 259 260 261 262 263 264 265 266 267 268 269
            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,&
270
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
271 272 273 274 275 276 277 278 279 280
            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,&
281
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
282 283 284 285 286 287 288 289 290 291
               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,&
292
            input%neig,.FALSE.,wann%wan90version)
293 294 295 296 297 298 299 300 301
    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,&
302
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
303 304 305 306 307 308 309 310
            .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,&
311
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
312 313 314 315 316 317 318
            .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,&
319
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
320 321 322 323 324 325 326 327
            .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,&
328
            noco%l_soc,wann%band_min,wann%band_max,input%neig,&
329 330 331 332 333 334 335 336 337
            .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,&
338
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
339 340 341 342 343
               .FALSE.)
       ELSE
          CALL wann_fft6(&
               rvecnum,rvec,kpoints,&
               input%jspins,fullnkpts,wann%l_bzsym,input%film,oneD%odi%d1,&
344
               noco%l_soc,wann%band_min,wann%band_max,input%neig,&
345 346 347 348 349 350 351 352 353 354 355
               .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,&
356
            input%neig,.FALSE.)
357 358 359 360 361 362 363
    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,&
364
            input%neig,.FALSE.,wann%wan90version)
365 366 367 368 369 370 371
    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,&
372
            input%neig,.FALSE.,wann%l_ndegen,ndegen,&
373 374 375 376 377 378 379 380
            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,&
381
            input%neig,.FALSE.,wann%l_ndegen,ndegen,wann%wan90version,&
382 383 384 385 386 387 388 389
            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,&
390
            input%neig,.FALSE.,wann%wan90version)
391 392 393 394
    ENDIF

    IF(wann%l_plot_umdat)THEN
       CALL wann_plot_um_dat(&
395
            stars,vacuum,atoms,sphhar,input,sym,mpi,&
396
            lapw,oneD,noco,nococonv,cell,vTot,enpara,eig_id,l_real,&
397 398
            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,&
399
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
400
            cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
401 402
            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,&
403
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
404
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
405
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
406
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
407 408 409 410 411 412 413 414 415
            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,&
416
            input,lapw,oneD,noco,nococonv,sym,cell,atoms,stars,vacuum,sphhar,&
417 418 419
            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,&
420
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
421
            cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
422 423
            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,&
424
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
425
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
426
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
427
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
428 429 430 431 432 433 434 435 436
            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,&
437
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
438
            nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
439 440
            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,&
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 451 452 453 454 455
            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,&
456
            input%neig,atoms%nat,sym%nop,lapw%dim_nvd(),input%jspins,lapw%dim_nbasfcn(),atoms%llod,atoms%nlod,atoms%ntype,&
457
            nwdd,cell%omtil,atoms%nlo,atoms%llo,atoms%lapw_l,sym%invtab,sym%mrot,sym%ngopr,atoms%neq,atoms%lmax,&
458 459
            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,&
460
            SIZE(atoms%rmsh,1),sphhar%nlhd,stars%ng3,vacuum%nvac,sym%invs,sym%invs2,input%film,sphhar%nlh,atoms%jri,sphhar%ntypsd,&
461
            sym%ntypsy,input%jspins,kpts%nkpt,atoms%dx,stars%ng2,atoms%rmsh,sliceplot%e1s,sliceplot%e2s,atoms%ulo_der,&
462
            stars%ustep,stars%ig,stars%mx1,stars%mx2,stars%mx3,stars%rgphs,sliceplot%slice,sliceplot%kk,sliceplot%nnne,&
463
            cell%z1,lapw%dim_nv2d(),vacuum%nmzxy,vacuum%nmz,vacuum%delz,stars%ig2,cell%area,sym%tau,atoms%zatom,stars%ng2,sym%nop2,&
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
            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(
479
       !     >     lapw%dim_nv2d(),input%jspins,oneD%odi,oneD%ods,stars%ng3,vacuum%nmzxyd,stars%ng2,
480 481 482
       !     >     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,
483
       !     >     sym%invs,sym%invs2,cell%z1,vacuum%delz,sym%ngopr,sym%ntypsy,atoms%jri,atoms%pos,atoms%zatom,
484 485 486 487 488 489 490 491 492 493 494
       !     >     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

    WRITE(6,*)"time_lapw_expand=",time_lapw_expand
    WRITE(6,*)"time_lapw_plot=",time_lapw_plot

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

  END SUBROUTINE wann_postproc
END MODULE m_wann_postproc