Commit def6859f authored by Gregor Michalicek's avatar Gregor Michalicek

Move allocations and initializations for all t_potden arrays into init subroutine

parent beff00ea
......@@ -956,15 +956,19 @@ CONTAINS
TYPE(t_oneD),INTENT(IN) :: oneD
INTEGER,INTENT(IN) :: jsp, potden_type
LOGICAL,INTENT(IN) :: nocoExtraDim
CALL init_potden_simple(pd,stars%ng3,atoms%jmtd,sphhar%nlhd,atoms%ntype,jsp,nocoExtraDim,potden_type,vacuum%nmzd,vacuum%nmzxyd,stars%ng2)
CALL init_potden_simple(pd,stars%ng3,atoms%jmtd,sphhar%nlhd,atoms%ntype,&
atoms%n_u,noco%l_noco,jsp,nocoExtraDim,potden_type,&
vacuum%nmzd,vacuum%nmzxyd,stars%ng2)
END SUBROUTINE init_potden_types
SUBROUTINE init_potden_simple(pd,ng3,jmtd,nlhd,ntype,jsp,nocoExtraDim,potden_type,nmzd,nmzxyd,n2d)
SUBROUTINE init_potden_simple(pd,ng3,jmtd,nlhd,ntype,n_u,l_noco,jsp,nocoExtraDim,potden_type,nmzd,nmzxyd,n2d)
USE m_constants
USE m_judft
IMPLICIT NONE
CLASS(t_potden),INTENT(OUT) :: pd
INTEGER,INTENT(IN) :: ng3,jmtd,nlhd,ntype,jsp,potden_type
LOGICAL,INTENT(IN) :: nocoExtraDim
INTEGER,INTENT(IN) :: ng3,jmtd,nlhd,ntype,n_u,jsp,potden_type
LOGICAL,INTENT(IN) :: l_noco,nocoExtraDim
INTEGER,INTENT(IN),OPTIONAL :: nmzd,nmzxyd,n2d
INTEGER:: err(4)
......@@ -985,7 +989,24 @@ CONTAINS
IF (PRESENT(nmzd)) THEN
ALLOCATE(pd%vacz(nmzd,2,MERGE(4,jsp,nocoExtraDim)),stat=err(3))
ALLOCATE(pd%vacxy(nmzxyd,n2d-1,2,jsp),stat=err(4))
ENDIF
IF (l_noco) THEN
ALLOCATE (pd%cdomvz(nmzd,2))
ALLOCATE (pd%cdomvxy(nmzxyd,n2d-1,2))
ELSE
ALLOCATE (pd%cdomvz(1,1),pd%cdomvxy(1,1,1))
END IF
ELSE
ALLOCATE (pd%cdomvz(1,1),pd%cdomvxy(1,1,1))
END IF
IF (l_noco) THEN
ALLOCATE (pd%cdom(ng3))
ELSE
ALLOCATE (pd%cdom(1))
END IF
ALLOCATE (pd%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,n_u),jsp))
IF (ANY(err>0)) CALL judft_error("Not enough memory allocating potential or density")
pd%pw=CMPLX(0.0,0.0)
pd%mt=0.0
......@@ -993,6 +1014,10 @@ CONTAINS
pd%vacz=0.0
pd%vacxy=CMPLX(0.0,0.0)
ENDIF
pd%cdom = CMPLX(0.0,0.0)
pd%cdomvz = CMPLX(0.0,0.0)
pd%cdomvxy = CMPLX(0.0,0.0)
pd%mmpMat = CMPLX(0.0,0.0)
END SUBROUTINE init_potden_simple
......
......@@ -102,8 +102,6 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
INQUIRE(file='enpara',exist=l_enpara)
IF (l_enpara) OPEN (40,file ='enpara',form = 'formatted',status ='unknown')
ENDIF
ALLOCATE (outDen%cdom(stars%ng3),outDen%cdomvz(vacuum%nmzd,2))
ALLOCATE (outDen%cdomvxy(vacuum%nmzxyd,oneD%odi%n2d-1,2))
ALLOCATE (qa21(atoms%ntype))
ALLOCATE (qvac(dimension%neigd,2,kpts%nkpt,dimension%jspd))
ALLOCATE (qvlay(dimension%neigd,vacuum%layerd,2,kpts%nkpt,dimension%jspd))
......@@ -113,15 +111,7 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
qa21(:) = cmplx(0.0,0.0)
qvac(:,:,:,:) = 0.0
qvlay(:,:,:,:,:) = 0.0
outDen%mt(:,:,:,:) = 0.0
outDen%pw(:,:) = cmplx(0.0,0.0)
outDen%cdom(:) = cmplx(0.0,0.0)
IF (input%film) THEN
outDen%vacz(:,:,:) = 0.0
outDen%cdomvz(:,:) = cmplx(0.0,0.0)
outDen%vacxy(:,:,:,:) = cmplx(0.0,0.0)
outDen%cdomvxy(:,:,:) = cmplx(0.0,0.0)
END IF
outDen%iter = iter
!Set up pointer for backtransformation of from g-vector in
......@@ -130,11 +120,6 @@ SUBROUTINE cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,&
!It is done here to save memory.
CALL prp_qfft_map(stars,sym, input, igq2_fft,igq_fft)
!LDA+U: initialise density-matrix if needed
ALLOCATE (outDen%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
outDen%mmpMat(:,:,:,:) = CMPLX(0.0,0.0)
!in a non-collinear calcuation where the off-diagonal part of
!density matrix in the muffin-tins is calculated, the a- and
!b-coef. for both spins are needed at once. Thus, cdnval is only
......
......@@ -174,15 +174,10 @@ CONTAINS
! Initialize and load inDen density (start)
CALL inDen%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
IF (noco%l_noco) THEN
ALLOCATE (inDen%cdom(stars%ng3),inDen%cdomvz(vacuum%nmzd,2))
ALLOCATE (inDen%cdomvxy(vacuum%nmzxyd,oneD%odi%n2d-1,2))
archiveType = CDN_ARCHIVE_TYPE_NOCO_const
ELSE
ALLOCATE (inDen%cdom(1),inDen%cdomvz(1,1),inDen%cdomvxy(1,1,1))
archiveType = CDN_ARCHIVE_TYPE_CDN1_const
END IF
ALLOCATE (inDen%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
inDen%mmpMat = CMPLX(0.0,0.0)
IF(mpi%irank.EQ.0) THEN
CALL readDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
0,fermiEnergyTemp,l_qfix,inDen)
......@@ -198,10 +193,8 @@ CONTAINS
! Initialize potentials (start)
CALL vTot%init(stars,atoms,sphhar,vacuum,noco,oneD,DIMENSION%jspd,noco%l_noco,POTDEN_TYPE_POTTOT)
CALL vCoul%init(stars,atoms,sphhar,vacuum,noco,oneD,DIMENSION%jspd,noco%l_noco,POTDEN_TYPE_POTCOUL)
CALL vx%init(stars%ng3,atoms%jmtd,sphhar%nlhd,atoms%ntype,DIMENSION%jspd,.FALSE.,POTDEN_TYPE_POTX)
CALL vx%init(stars%ng3,atoms%jmtd,sphhar%nlhd,atoms%ntype,atoms%n_u,noco%l_noco,DIMENSION%jspd,.FALSE.,POTDEN_TYPE_POTX)
CALL vTemp%init(stars,atoms,sphhar,vacuum,noco,oneD,DIMENSION%jspd,noco%l_noco,POTDEN_TYPE_POTTOT)
ALLOCATE(vTot%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
ALLOCATE(vTemp%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
! Initialize potentials (end)
DO WHILE (l_cont)
......
......@@ -71,14 +71,6 @@ SUBROUTINE mix(stars,atoms,sphhar,vacuum,input,sym,cell,noco,oneD,&
EXTERNAL CPP_BLAS_sdot
CALL diffDen%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
IF (noco%l_noco) THEN
ALLOCATE (diffDen%cdom(stars%ng3),diffDen%cdomvz(vacuum%nmzd,2))
ALLOCATE (diffDen%cdomvxy(vacuum%nmzxyd,oneD%odi%n2d-1,2))
ELSE
ALLOCATE (diffDen%cdom(1),diffDen%cdomvz(1,1),diffDen%cdomvxy(1,1,1))
END IF
ALLOCATE (diffDen%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
diffDen%mmpMat = CMPLX(0.0,0.0)
! YM: I have exported 'vol' from outside, be aware
! IF (film) THEN
......
......@@ -82,9 +82,6 @@ CONTAINS
CHARACTER(LEN=20) :: attributes(3)
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
ALLOCATE (den%cdom(1),den%cdomvz(1,1),den%cdomvxy(1,1,1))
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%mmpMat = CMPLX(0.0,0.0)
WRITE (6,FMT=8000)
WRITE (16,FMT=8000)
......
......@@ -131,13 +131,6 @@ CONTAINS
vTot%iter = den%iter
CALL workDen%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
IF (noco%l_noco) THEN
ALLOCATE (workDen%cdom(stars%ng3),workDen%cdomvz(vacuum%nmzd,2))
ALLOCATE (workDen%cdomvxy(vacuum%nmzxyd,oneD%odi%n2d-1,2))
ELSE
ALLOCATE (workDen%cdom(1),workDen%cdomvz(1,1),workDen%cdomvxy(1,1,1))
END IF
!
workDen = den
IF (mpi%irank == 0) THEN
......@@ -176,7 +169,7 @@ CONTAINS
ENDIF ! (mpi%irank == 0)
#ifdef CPP_MPI
CALL MPI_BCAST(workDen%mt,atoms%jmtd*(1+sphhar%nlhd)*atoms%ntype*dimension%jspd,MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
CALL MPI_BCAST(workDen%mt,atoms%jmtd*(1+sphhar%nlhd)*atoms%ntype*dimension%jspd,MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
#endif
CALL timestart("psqpw")
......@@ -730,7 +723,9 @@ CONTAINS
IF (input%jspins.EQ.2) THEN
nat = 1
DO n = 1,atoms%ntype
workDen%mt(:atoms%jri(n),0:sphhar%nlh(atoms%ntypsy(nat)),n,1) = workDen%mt(:atoms%jri(n),0:sphhar%nlh(atoms%ntypsy(nat)),n,1) + workDen%mt(:atoms%jri(n),0:sphhar%nlh(atoms%ntypsy(nat)),n,input%jspins)
workDen%mt(:atoms%jri(n),0:sphhar%nlh(atoms%ntypsy(nat)),n,1) = &
workDen%mt(:atoms%jri(n),0:sphhar%nlh(atoms%ntypsy(nat)),n,1) + &
workDen%mt(:atoms%jri(n),0:sphhar%nlh(atoms%ntypsy(nat)),n,input%jspins)
nat = nat + atoms%neq(n)
ENDDO
......
......@@ -42,15 +42,10 @@ contains
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
IF(noco%l_noco) THEN
ALLOCATE(den%cdom(stars%ng3))
ALLOCATE(den%cdomvz(vacuum%nmz,2),den%cdomvxy(vacuum%nmzxy,stars%ng2-1,2))
archiveType = CDN_ARCHIVE_TYPE_NOCO_const
ELSE
ALLOCATE (den%cdom(1),den%cdomvz(1,1),den%cdomvxy(1,1,1))
archiveType = CDN_ARCHIVE_TYPE_CDN1_const
END IF
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%mmpMat = CMPLX(0.0,0.0)
CALL readDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,&
CDN_INPUT_DEN_const,0,fermiEnergyTemp,l_qfix,den)
......
......@@ -52,14 +52,9 @@
sfp = 2 * SQRT(pi_const)
!sphhar%nlhd = MAXVAL(sphhar%nlh(:))
IF (input%jspins/=2) CALL juDFT_error&
& ("cdnsp: set jspins = 2 and remove fl7para!",calledby&
& ="cdnsp")
IF (input%jspins/=2) CALL juDFT_error("cdnsp: set jspins = 2 and remove fl7para!", calledby ="cdnsp")
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
ALLOCATE (den%cdom(1),den%cdomvz(1,1),den%cdomvxy(1,1,1))
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%mmpMat = CMPLX(0.0,0.0)
input%jspins=1
CALL readCoreDensity(input,atoms,dimension,rhoc,tec,qintc)
......
......@@ -51,15 +51,10 @@ SUBROUTINE flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell)
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
IF(noco%l_noco) THEN
ALLOCATE(den%cdom(stars%ng3))
ALLOCATE(den%cdomvz(vacuum%nmz,2),den%cdomvxy(vacuum%nmzxy,stars%ng2-1,2))
archiveType = CDN_ARCHIVE_TYPE_NOCO_const
ELSE
ALLOCATE (den%cdom(1),den%cdomvz(1,1),den%cdomvxy(1,1,1))
archiveType = CDN_ARCHIVE_TYPE_CDN1_const
END IF
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%mmpMat = CMPLX(0.0,0.0)
! read the charge density
CALL readDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,&
......
......@@ -304,8 +304,6 @@ SUBROUTINE pldngen(sym,stars,atoms,sphhar,vacuum,&
inp%jspins=1
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,inp%jspins,.FALSE.,POTDEN_TYPE_DEN)
ALLOCATE (den%cdom(stars%ng3),den%cdomvz(vacuum%nmzd,2),den%cdomvxy(vacuum%nmzxyd,stars%ng2-1,2))
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%iter = iter
den%mt(:,0:,1:,1:1) = rho(:,0:,1:,1:1)
den%pw(1:,1:1) = qpw(1:,1:1)
......@@ -314,7 +312,6 @@ SUBROUTINE pldngen(sym,stars,atoms,sphhar,vacuum,&
den%cdom = cdom
den%cdomvz = cdomvz
den%cdomvxy = cdomvxy
den%mmpMat = CMPLX(0.0,0.0)
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,inp,sym,oneD,CDN_ARCHIVE_TYPE_CDN_const,CDN_INPUT_DEN_const,&
0,-1.0,0.0,.FALSE.,den)
......
......@@ -73,9 +73,6 @@ SUBROUTINE stden(mpi,sphhar,stars,atoms,sym,DIMENSION,vacuum,&
IF (input%jspins > DIMENSION%jspd) CALL juDFT_error("input%jspins > dimension%jspd", calledby = "stden")
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
ALLOCATE (den%cdom(1),den%cdomvz(1,1),den%cdomvxy(1,1,1))
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%mmpMat = CMPLX(0.0,0.0)
ALLOCATE ( xp(3,DIMENSION%nspd),rat(DIMENSION%msh,atoms%ntype),eig(DIMENSION%nstd,DIMENSION%jspd,atoms%ntype) )
ALLOCATE ( rh(DIMENSION%msh,atoms%ntype,DIMENSION%jspd),rh1(DIMENSION%msh,atoms%ntype,DIMENSION%jspd) )
......
......@@ -88,9 +88,6 @@ CONTAINS
eps = 1.0e-20
CALL den%init(stars,atoms,sphhar,vacuum,noco,oneD,input%jspins,.FALSE.,POTDEN_TYPE_DEN)
ALLOCATE(den%cdom(stars%ng3),den%cdomvz(vacuum%nmz,2),den%cdomvxy(vacuum%nmzxy,stars%ng2-1,2))
ALLOCATE (den%mmpMat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u),input%jspins))
den%mmpMat = CMPLX(0.0,0.0)
ALLOCATE (ris(0:27*stars%mx1*stars%mx2*stars%mx3-1,4),fftwork(0:27*stars%mx1*stars%mx2*stars%mx3-1),&
rz(vacuum%nmzd,2,2))
......
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