Commit 6827f484 authored by Gregor Michalicek's avatar Gregor Michalicek

Rename cdnvalKLoop into cdnvalJob

+integrate weights array into t_cdnvalJob type
parent 9a64cbe9
......@@ -10,8 +10,8 @@ USE m_juDFT
CONTAINS
SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atoms,enpara,stars,&
vacuum,dimension,sphhar,sym,obsolete,vTot,oneD,coreSpecInput,cdnvalKLoop,den,regCharges,dos,results,&
SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,noco,input,banddos,cell,atoms,enpara,stars,&
vacuum,dimension,sphhar,sym,obsolete,vTot,oneD,coreSpecInput,cdnvalJob,den,regCharges,dos,results,&
moments,mcd,slab,orbcomp)
!************************************************************************************
......@@ -61,7 +61,6 @@ SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atom
TYPE(t_enpara), INTENT(IN) :: enpara
TYPE(t_obsolete), INTENT(IN) :: obsolete
TYPE(t_banddos), INTENT(IN) :: banddos
TYPE(t_sliceplot), INTENT(IN) :: sliceplot
TYPE(t_input), INTENT(IN) :: input
TYPE(t_vacuum), INTENT(IN) :: vacuum
TYPE(t_noco), INTENT(IN) :: noco
......@@ -73,7 +72,7 @@ SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atom
TYPE(t_atoms), INTENT(IN) :: atoms
TYPE(t_coreSpecInput), INTENT(IN) :: coreSpecInput
TYPE(t_potden), INTENT(IN) :: vTot
TYPE(t_cdnvalKLoop), INTENT(IN) :: cdnvalKLoop
TYPE(t_cdnvalJob), INTENT(IN) :: cdnvalJob
TYPE(t_potden), INTENT(INOUT) :: den
TYPE(t_regionCharges), INTENT(INOUT) :: regCharges
TYPE(t_dos), INTENT(INOUT) :: dos
......@@ -170,11 +169,11 @@ SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atom
skip_tt = dot_product(enpara%skiplo(:atoms%ntype,jspin),atoms%neq(:atoms%ntype))
IF (noco%l_soc.OR.noco%l_noco) skip_tt = 2 * skip_tt
ALLOCATE (we(MAXVAL(cdnvalKLoop%noccbd(:))))
ALLOCATE (eig(MAXVAL(cdnvalKLoop%noccbd(:))))
ALLOCATE (we(MAXVAL(cdnvalJob%noccbd(:))))
ALLOCATE (eig(MAXVAL(cdnvalJob%noccbd(:))))
jsp = MERGE(1,jspin,noco%l_noco)
DO ikpt = cdnvalKLoop%ikptStart, cdnvalKLoop%nkptExtended, cdnvalKLoop%ikptIncrement
DO ikpt = cdnvalJob%ikptStart, cdnvalJob%nkptExtended, cdnvalJob%ikptIncrement
IF (ikpt.GT.kpts%nkpt) THEN
#ifdef CPP_MPI
......@@ -185,17 +184,13 @@ SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atom
CALL lapw%init(input,noco, kpts,atoms,sym,ikpt,cell,.false., mpi)
skip_t = skip_tt
noccbd = cdnvalKLoop%noccbd(ikpt)
nStart = cdnvalKLoop%nStart(ikpt)
nEnd = cdnvalKLoop%nEnd(ikpt)
we = 0.0
we(1:noccbd) = results%w_iks(nStart:nEnd,ikpt,jsp)
IF (sliceplot%slice.AND.input%pallst) we(:) = kpts%wtkpt(ikpt)
we(:noccbd) = 2.0 * we(:noccbd) / input%jspins ! add in spin-doubling factor
noccbd = cdnvalJob%noccbd(ikpt)
nStart = cdnvalJob%nStart(ikpt)
nEnd = cdnvalJob%nEnd(ikpt)
we(1:noccbd) = cdnvalJob%weights(1:noccbd,ikpt)
eig(1:noccbd) = results%eig(nStart:nEnd,ikpt,jsp)
IF (cdnvalKLoop%l_evp) THEN
IF (cdnvalJob%l_evp) THEN
IF (nStart > skip_tt) skip_t = 0
IF (nEnd <= skip_tt) skip_t = noccbd
IF ((nStart <= skip_tt).AND.(nEnd > skip_tt)) skip_t = mod(skip_tt,noccbd)
......@@ -240,7 +235,7 @@ SUBROUTINE cdnval(eig_id, mpi,kpts,jspin,sliceplot,noco, input,banddos,cell,atom
! perform Brillouin zone integration and summation over the
! bands in order to determine the energy parameters for each atom and angular momentum
CALL eparas(ispin,atoms,noccbd,mpi,ikpt,noccbd,we,eig,&
skip_t,cdnvalKLoop%l_evp,eigVecCoeffs,usdus,regCharges,dos,mcd,banddos%l_mcd)
skip_t,cdnvalJob%l_evp,eigVecCoeffs,usdus,regCharges,dos,mcd,banddos%l_mcd)
IF (noco%l_mperp.AND.(ispin==jsp_end)) CALL qal_21(dimension,atoms,input,noccbd,noco,eigVecCoeffs,denCoeffsOffdiag,ikpt,dos)
......
......@@ -75,7 +75,7 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
TYPE(t_mcd) :: mcd
TYPE(t_slab) :: slab
TYPE(t_orbcomp) :: orbcomp
TYPE(t_cdnvalKLoop) :: cdnvalKLoop
TYPE(t_cdnvalJob) :: cdnvalJob
!Local Scalars
......@@ -98,9 +98,9 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
jspmax = input%jspins
IF (noco%l_mperp) jspmax = 1
DO jspin = 1,jspmax
CALL cdnvalKLoop%init(mpi,input,kpts,banddos,noco,results,jspin,sliceplot)
CALL cdnval(eig_id,mpi,kpts,jspin,sliceplot,noco,input,banddos,cell,atoms,enpara,stars,vacuum,dimension,&
sphhar,sym,obsolete,vTot,oneD,coreSpecInput,cdnvalKLoop,outDen,regCharges,dos,results,moments,mcd,slab,orbcomp)
CALL cdnvalJob%init(mpi,input,kpts,banddos,noco,results,jspin,sliceplot)
CALL cdnval(eig_id,mpi,kpts,jspin,noco,input,banddos,cell,atoms,enpara,stars,vacuum,dimension,&
sphhar,sym,obsolete,vTot,oneD,coreSpecInput,cdnvalJob,outDen,regCharges,dos,results,moments,mcd,slab,orbcomp)
END DO
IF (mpi%irank.EQ.0) THEN
......
......@@ -118,7 +118,7 @@ PRIVATE
PROCEDURE,PASS :: init => orbcomp_init
END TYPE t_orbcomp
TYPE t_cdnvalKLoop
TYPE t_cdnvalJob
INTEGER :: ikptIncrement
INTEGER :: ikptStart
......@@ -128,10 +128,11 @@ PRIVATE
INTEGER, ALLOCATABLE :: noccbd(:)
INTEGER, ALLOCATABLE :: nStart(:)
INTEGER, ALLOCATABLE :: nEnd(:)
REAL, ALLOCATABLE :: weights(:,:)
CONTAINS
PROCEDURE,PASS :: init => cdnvalKLoop_init
END TYPE t_cdnvalKLoop
PROCEDURE,PASS :: init => cdnvalJob_init
END TYPE t_cdnvalJob
TYPE t_gVacMap
......@@ -143,7 +144,7 @@ PRIVATE
END TYPE t_gVacMap
PUBLIC t_orb, t_denCoeffs, t_slab, t_eigVecCoeffs
PUBLIC t_mcd, t_moments, t_orbcomp, t_cdnvalKLoop, t_gVacMap
PUBLIC t_mcd, t_moments, t_orbcomp, t_cdnvalJob, t_gVacMap
CONTAINS
......@@ -444,7 +445,7 @@ SUBROUTINE orbcomp_init(thisOrbcomp,input,banddos,dimension,atoms,kpts)
END SUBROUTINE orbcomp_init
SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,jspin,sliceplot)
SUBROUTINE cdnvalJob_init(thisCdnvalJob,mpi,input,kpts,banddos,noco,results,jspin,sliceplot)
USE m_types_setup
USE m_types_kpts
......@@ -453,7 +454,7 @@ SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,
IMPLICIT NONE
CLASS(t_cdnvalKLoop), INTENT(INOUT) :: thisCdnvalKLoop
CLASS(t_cdnvalJob), INTENT(INOUT) :: thisCdnvalJob
TYPE(t_mpi), INTENT(IN) :: mpi
TYPE(t_input), INTENT(IN) :: input
TYPE(t_kpts), INTENT(IN) :: kpts
......@@ -464,54 +465,54 @@ SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,
INTEGER, INTENT(IN) :: jspin
INTEGER :: jsp, iBand, ikpt, nslibd, noccbd_l
INTEGER :: jsp, iBand, ikpt, nslibd, noccbd_l, noccbd, nStart, nEnd
thisCdnvalKLoop%l_evp = .FALSE.
thisCdnvalJob%l_evp = .FALSE.
IF (kpts%nkpt < mpi%isize) THEN
thisCdnvalKLoop%l_evp = .TRUE.
thisCdnvalKLoop%nkptExtended = kpts%nkpt
thisCdnvalKLoop%ikptStart = 1
thisCdnvalKLoop%ikptIncrement = 1
thisCdnvalJob%l_evp = .TRUE.
thisCdnvalJob%nkptExtended = kpts%nkpt
thisCdnvalJob%ikptStart = 1
thisCdnvalJob%ikptIncrement = 1
ELSE
! the number of iterations is adjusted to the number of MPI processes to synchronize RMA operations
thisCdnvalKLoop%nkptExtended = (kpts%nkpt / mpi%isize + 1) * mpi%isize
thisCdnvalKLoop%ikptStart = mpi%irank + 1
thisCdnvalKLoop%ikptIncrement = mpi%isize
thisCdnvalJob%nkptExtended = (kpts%nkpt / mpi%isize + 1) * mpi%isize
thisCdnvalJob%ikptStart = mpi%irank + 1
thisCdnvalJob%ikptIncrement = mpi%isize
END IF
IF (ALLOCATED(thisCdnvalKLoop%noccbd)) DEALLOCATE (thisCdnvalKLoop%noccbd)
IF (ALLOCATED(thisCdnvalKLoop%nStart)) DEALLOCATE (thisCdnvalKLoop%nStart)
IF (ALLOCATED(thisCdnvalKLoop%nEnd)) DEALLOCATE (thisCdnvalKLoop%nEnd)
IF (ALLOCATED(thisCdnvalJob%noccbd)) DEALLOCATE (thisCdnvalJob%noccbd)
IF (ALLOCATED(thisCdnvalJob%nStart)) DEALLOCATE (thisCdnvalJob%nStart)
IF (ALLOCATED(thisCdnvalJob%nEnd)) DEALLOCATE (thisCdnvalJob%nEnd)
ALLOCATE(thisCdnvalKLoop%noccbd(kpts%nkpt))
ALLOCATE(thisCdnvalKLoop%nStart(kpts%nkpt))
ALLOCATE(thisCdnvalKLoop%nEnd(kpts%nkpt))
ALLOCATE(thisCdnvalJob%noccbd(kpts%nkpt))
ALLOCATE(thisCdnvalJob%nStart(kpts%nkpt))
ALLOCATE(thisCdnvalJob%nEnd(kpts%nkpt))
thisCdnvalKLoop%noccbd = 0
thisCdnvalKLoop%nStart = 1
thisCdnvalKLoop%nEnd = -1
thisCdnvalJob%noccbd = 0
thisCdnvalJob%nStart = 1
thisCdnvalJob%nEnd = -1
jsp = MERGE(1,jspin,noco%l_noco)
! determine bands to be used for each k point, MPI process
DO ikpt = thisCdnvalKLoop%ikptStart, kpts%nkpt, thisCdnvalKLoop%ikptIncrement
DO ikpt = thisCdnvalJob%ikptStart, kpts%nkpt, thisCdnvalJob%ikptIncrement
DO iBand = 1,results%neig(ikpt,jsp)
IF ((results%w_iks(iBand,ikpt,jsp).GE.1.e-8).OR.input%pallst) THEN
thisCdnvalKLoop%noccbd(ikpt) = thisCdnvalKLoop%noccbd(ikpt) + 1
thisCdnvalJob%noccbd(ikpt) = thisCdnvalJob%noccbd(ikpt) + 1
END IF
END DO
IF (banddos%dos) thisCdnvalKLoop%noccbd(ikpt) = results%neig(ikpt,jsp)
IF (banddos%dos) thisCdnvalJob%noccbd(ikpt) = results%neig(ikpt,jsp)
thisCdnvalKLoop%nStart(ikpt) = 1
thisCdnvalKLoop%nEnd(ikpt) = thisCdnvalKLoop%noccbd(ikpt)
thisCdnvalJob%nStart(ikpt) = 1
thisCdnvalJob%nEnd(ikpt) = thisCdnvalJob%noccbd(ikpt)
!---> if slice, only certain bands are taken into account
IF(PRESENT(sliceplot)) THEN
IF (sliceplot%slice.AND.thisCdnvalKLoop%noccbd(ikpt).GT.0) THEN
thisCdnvalKLoop%nStart(ikpt) = 1
thisCdnvalKLoop%nEnd(ikpt) = -1
IF (sliceplot%slice.AND.thisCdnvalJob%noccbd(ikpt).GT.0) THEN
thisCdnvalJob%nStart(ikpt) = 1
thisCdnvalJob%nEnd(ikpt) = -1
IF (mpi%irank==0) WRITE (16,FMT=*) 'NNNE',sliceplot%nnne
IF (mpi%irank==0) WRITE (16,FMT=*) 'sliceplot%kk',sliceplot%kk
nslibd = 0
......@@ -526,7 +527,7 @@ SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,
iBand = iBand + 1
IF(iBand.GT.results%neig(ikpt,jsp)) EXIT
END DO
thisCdnvalKLoop%nStart(ikpt) = iBand
thisCdnvalJob%nStart(ikpt) = iBand
IF(iBand.LE.results%neig(ikpt,jsp)) THEN
DO WHILE (results%eig(iBand,ikpt,jsp).LE.sliceplot%e2s)
iBand = iBand + 1
......@@ -534,8 +535,8 @@ SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,
END DO
iBand = iBand - 1
END IF
thisCdnvalKLoop%nEnd(ikpt) = iBand
nslibd = MAX(0,thisCdnvalKLoop%nEnd(ikpt) - thisCdnvalKLoop%nStart(ikpt) + 1)
thisCdnvalJob%nEnd(ikpt) = iBand
nslibd = MAX(0,thisCdnvalJob%nEnd(ikpt) - thisCdnvalJob%nStart(ikpt) + 1)
IF (mpi%irank==0) WRITE (16,'(a,i3)') ' eigenvalues in sliceplot%slice:', nslibd
ELSE IF (sliceplot%kk.EQ.ikpt) THEN
IF (mpi%irank==0) WRITE (16,FMT='(a,i2)') ' sliceplot%slice: k-point nr.',ikpt
......@@ -543,15 +544,15 @@ SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,
IF (mpi%irank==0) WRITE (16,FMT='(a,i5,f10.5)') 'slice: eigenvalue nr.',&
sliceplot%nnne,results%eig(sliceplot%nnne,ikpt,jsp)
nslibd = 1
thisCdnvalKLoop%nStart(ikpt) = sliceplot%nnne
thisCdnvalKLoop%nEnd(ikpt) = sliceplot%nnne
thisCdnvalJob%nStart(ikpt) = sliceplot%nnne
thisCdnvalJob%nEnd(ikpt) = sliceplot%nnne
ELSE
iBand = 1
DO WHILE (results%eig(iBand,ikpt,jsp).LT.sliceplot%e1s)
iBand = iBand + 1
IF(iBand.GT.results%neig(ikpt,jsp)) EXIT
END DO
thisCdnvalKLoop%nStart(ikpt) = iBand
thisCdnvalJob%nStart(ikpt) = iBand
IF(iBand.LE.results%neig(ikpt,jsp)) THEN
DO WHILE (results%eig(iBand,ikpt,jsp).LE.sliceplot%e2s)
iBand = iBand + 1
......@@ -559,26 +560,42 @@ SUBROUTINE cdnvalKLoop_init(thisCdnvalKLoop,mpi,input,kpts,banddos,noco,results,
END DO
iBand = iBand - 1
END IF
thisCdnvalKLoop%nEnd(ikpt) = iBand
nslibd = MAX(0,thisCdnvalKLoop%nEnd(ikpt) - thisCdnvalKLoop%nStart(ikpt) + 1)
thisCdnvalJob%nEnd(ikpt) = iBand
nslibd = MAX(0,thisCdnvalJob%nEnd(ikpt) - thisCdnvalJob%nStart(ikpt) + 1)
IF (mpi%irank==0) WRITE (16,FMT='(a,i3)')' eigenvalues in sliceplot%slice:',nslibd
END IF
END IF
thisCdnvalKLoop%noccbd(ikpt) = nslibd
thisCdnvalJob%noccbd(ikpt) = nslibd
END IF ! sliceplot%slice
END IF
IF (thisCdnvalKLoop%l_evp) THEN
noccbd_l = CEILING(REAL(thisCdnvalKLoop%noccbd(ikpt)) / mpi%isize)
thisCdnvalKLoop%nStart(ikpt) = thisCdnvalKLoop%nStart(ikpt) + mpi%irank*noccbd_l
thisCdnvalKLoop%nEnd(ikpt) = min(thisCdnvalKLoop%nStart(ikpt)+(mpi%irank+1)*noccbd_l-1, thisCdnvalKLoop%noccbd(ikpt))
thisCdnvalKLoop%noccbd(ikpt) = thisCdnvalKLoop%nEnd(ikpt) - thisCdnvalKLoop%nStart(ikpt) + 1
IF (thisCdnvalKLoop%noccbd(ikpt).LT.1) thisCdnvalKLoop%noccbd(ikpt) = 0
IF (thisCdnvalJob%l_evp) THEN
noccbd_l = CEILING(REAL(thisCdnvalJob%noccbd(ikpt)) / mpi%isize)
thisCdnvalJob%nStart(ikpt) = thisCdnvalJob%nStart(ikpt) + mpi%irank*noccbd_l
thisCdnvalJob%nEnd(ikpt) = min(thisCdnvalJob%nStart(ikpt)+(mpi%irank+1)*noccbd_l-1, thisCdnvalJob%noccbd(ikpt))
thisCdnvalJob%noccbd(ikpt) = thisCdnvalJob%nEnd(ikpt) - thisCdnvalJob%nStart(ikpt) + 1
IF (thisCdnvalJob%noccbd(ikpt).LT.1) thisCdnvalJob%noccbd(ikpt) = 0
END IF
END DO
END SUBROUTINE cdnvalKLoop_init
IF (ALLOCATED(thisCdnvalJob%weights)) DEALLOCATE (thisCdnvalJob%weights)
ALLOCATE(thisCdnvalJob%weights(MAXVAL(thisCdnvalJob%noccbd(:)),kpts%nkpt))
thisCdnvalJob%weights = 0.0
DO ikpt = thisCdnvalJob%ikptStart, kpts%nkpt, thisCdnvalJob%ikptIncrement
noccbd = thisCdnvalJob%noccbd(ikpt)
nStart = thisCdnvalJob%nStart(ikpt)
nEnd = thisCdnvalJob%nEnd(ikpt)
thisCdnvalJob%weights(1:noccbd,ikpt) = results%w_iks(nStart:nEnd,ikpt,jsp)
IF(PRESENT(sliceplot)) THEN
IF (sliceplot%slice.AND.input%pallst) thisCdnvalJob%weights(:,ikpt) = kpts%wtkpt(ikpt)
END IF
thisCdnvalJob%weights(:noccbd,ikpt) = 2.0 * thisCdnvalJob%weights(:noccbd,ikpt) / input%jspins ! add in spin-doubling factor
END DO
END SUBROUTINE cdnvalJob_init
SUBROUTINE gVacMap_init(thisGVacMap,dimension,sym,atoms,vacuum,stars,lapw,input,cell,kpts,enpara,vTot,ikpt,jspin)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment