Commit b431148a authored by Gregor Michalicek's avatar Gregor Michalicek

Added density IO wrappers to more subroutines

parent cfc39301
......@@ -194,6 +194,7 @@ MODULE m_cdn_io
INTEGER :: mode, iterTemp, k, i, iVac, j, iUnit
INTEGER :: d1, d10, asciioffset, iUnitTemp
LOGICAL :: l_exist
CHARACTER(len=30) :: filename
CHARACTER(len=5) :: cdnfile
......@@ -215,10 +216,17 @@ MODULE m_cdn_io
filename = 'cdn'
END IF
IF ((relCdnIndex.EQ.1).AND.(archiveType.EQ.CDN_ARCHIVE_TYPE_CDN1_const).AND.(iter.EQ.0)) THEN
INQUIRE(file=TRIM(ADJUSTL(filename)),EXIST=l_exist)
IF(l_exist) THEN
CALL juDFT_error("Trying to generate starting density while a density exists.",calledby ="writeDensity")
END IF
END IF
iUnit = 93
OPEN (iUnit,file=TRIM(ADJUSTL(filename)),FORM='unformatted',STATUS='unknown')
IF ((relCdnIndex.EQ.1).AND.(archiveType.EQ.CDN_ARCHIVE_TYPE_CDN1_const)) THEN
IF ((relCdnIndex.EQ.1).AND.(archiveType.EQ.CDN_ARCHIVE_TYPE_CDN1_const).AND.(iter.GE.1)) THEN
starsTemp%n3d = stars%n3d
inputTemp%jspins = input%jspins
vacuumTemp%nmzxyd = vacuum%nmzxyd
......
......@@ -45,14 +45,14 @@ CONTAINS
! | +- fitchk
! | +- cotra1
! | +- ylm3
! +-- cdnsp -+- loddop
! | +- wrtdop
! +-- cdnsp -+- readDensity
! | +- writeDensity
! | +- intgr3
! +-- flipcdn -+- loddop
! | +- wrtdop
! +-- flipcdn -+- readDensity
! | +- writeDensity
! +-- f2u -- wrtdop
! +-- u2f -- loddop
! +-- bmt -+- loddop
! +-- bmt -+- readDensity
! +- wrtdop
!----------------------------------------
USE m_bmt
......@@ -181,7 +181,7 @@ CONTAINS
CALL timestart('optional: flip magnetic moments')
CALL flipcdn(&
& atoms,input,vacuum,sphhar,&
& stars,sym,cell,noco%l_noco)
& stars,sym,oneD,cell,noco%l_noco)
!
CALL timestop('optional: flip magnetic moments')
END IF
......
......@@ -18,10 +18,9 @@
CONTAINS
SUBROUTINE flipcdn(&
& atoms,input,vacuum,sphhar,&
& stars,sym,cell,&
& stars,sym,oneD,cell,&
& l_noco)
USE m_loddop
USE m_wrtdop
USE m_cdn_io
USE m_types
IMPLICIT NONE
TYPE(t_stars),INTENT(IN) :: stars
......@@ -30,12 +29,14 @@
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_input),INTENT(IN) :: input
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_oneD),INTENT(IN) :: oneD
TYPE(t_cell),INTENT(IN) :: cell
LOGICAL,INTENT(IN) :: l_noco
! .. Local Scalars ..
REAL rhodummy,rhodumms
INTEGER i,iter,n,nt,j,lh,na ,mp,ispin,n_ldau,urec,itype,m
INTEGER archiveType
CHARACTER(len=8) iop,dop
LOGICAL n_exist
......@@ -51,29 +52,17 @@
!sphhar%nlhd = MAXVAL(sphhar%nlh(:))
ALLOCATE ( rho(atoms%jmtd,0:sphhar%nlhd,atoms%ntype,input%jspins),qpw(stars%ng3,input%jspins) )
ALLOCATE ( rhtxy(vacuum%nmzxy,stars%ng2-1,2,input%jspins),rht(vacuum%nmz,2,input%jspins) )
archiveType = CDN_ARCHIVE_TYPE_CDN1_const
IF (l_noco) THEN
ALLOCATE( cdom(stars%ng3) )
ALLOCATE( cdomvz(vacuum%nmz,2),cdomvxy(vacuum%nmzxy,stars%ng2-1,2) )
archiveType = CDN_ARCHIVE_TYPE_NOCO_const
ENDIF
nt = 71 !gs, see sub mix
IF (l_noco) THEN
OPEN (nt,file='rhomat_inp',form='unformatted',status='old')
ELSE
OPEN (nt,file='cdn1',form='unformatted',status='old')
ENDIF
! ---> read the charge density
CALL loddop(&
& stars,vacuum,atoms,sphhar,input,sym,&
& nt,&
& iter,rho,qpw,rht,rhtxy)
IF (l_noco) THEN
READ (nt) (cdom(j),j=1,stars%ng3)
IF (input%film) THEN
READ (nt) ((cdomvz(n,i),n=1,vacuum%nmz),i=1,vacuum%nvac)
READ (nt) (((cdomvxy(n,j-1,i),n=1,vacuum%nmzxy),j=2,stars%ng2),i=1,vacuum%nvac)
ENDIF
ENDIF
CALL readDensity(stars,vacuum,atoms,sphhar,input,sym,oneD,archiveType,&
CDN_INPUT_DEN_const,0,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
! ---> flip cdn for each atom with nflip=-1
!
na = 1
......@@ -99,20 +88,9 @@
END IF
na = na + atoms%neq(n)
ENDDO
! ----> write the spin-polarized density on unit nt
REWIND nt
CALL wrtdop(&
& stars,vacuum,atoms,sphhar,input,sym,&
& nt,&
& iter,rho,qpw,rht,rhtxy)
IF (l_noco) THEN
WRITE (nt) (cdom(j),j=1,stars%ng3)
IF (input%film) THEN
WRITE (nt) ((cdomvz(n,i),n=1,vacuum%nmz),i=1,vacuum%nvac)
WRITE (nt) (((cdomvxy(n,j-1,i),n=1,vacuum%nmzxy),j=2,stars%ng2),i=1,vacuum%nvac)
ENDIF
ENDIF
CLOSE (nt)
! ----> write the spin-polarized density
CALL writeDensity(stars,vacuum,atoms,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
0,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
!
! for lda+U: flip n-matrix
!
......
......@@ -38,6 +38,7 @@
! all stored on real space mesh
!**********************************************************************
USE m_cdn_io
USE m_loddop
USE m_wrtdop
USE m_qfix
......@@ -321,15 +322,11 @@
ENDIF
!---> save charge density to file cdn
OPEN (72,FILE='cdn',FORM='unformatted',STATUS='unknown')
inp=input
inp%jspins=1
CALL wrtdop(&
& stars,vacuum,atoms,sphhar,&
& inp,sym,72, &
& iter,rho(:,0:,1:,1:1),qpw(1:,1:1),rht(1:,1:,1:1),&
& rhtxy(1:,1:,1:,1:1))
CLOSE (72)
CALL writeDensity(stars,vacuum,atoms,sphhar,inp,sym,oneD,CDN_ARCHIVE_TYPE_CDN_const,CDN_INPUT_DEN_const,&
0,iter,rho(:,0:,1:,1:1),qpw(1:,1:1),rht(1:,1:,1:1),rhtxy(1:,1:,1:,1:1),cdom,cdomvz,cdomvxy)
!---> save mx to file mdnx
OPEN (72,FILE='mdnx',FORM='unformatted',STATUS='unknown')
......
......@@ -24,7 +24,7 @@
USE m_qsf
USE m_checkdop
USE m_cdnovlp
USE m_wrtdop
USE m_cdn_io
USE m_qfix
USE m_atom2
USE m_types
......@@ -58,6 +58,7 @@
INTEGER i,iter,ivac,iza,j,jr,k,n,n1,npd,ispin
INTEGER nw,ilo,natot,icorr_dummy,nat
COMPLEX czero
COMPLEX :: cdom(1),cdomvz(1,1),cdomvxy(1,1,1)
! ..
! .. Local Arrays ..
COMPLEX, ALLOCATABLE :: qpw(:,:),rhtxy(:,:,:,:)
......@@ -241,16 +242,9 @@
!
! Write superposed density onto density file
!
iter = 1
name_l(:) = name(:)
name_l(10) = 'ordered*' ! always create ordered start density
OPEN (71,file='cdn1',form='unformatted',status='new')
CALL wrtdop(&
& stars,vacuum,atoms,sphhar,&
& input,sym,&
& 71,&
& iter,rho,qpw,rht,rhtxy)
CLOSE (71)
iter = 0
CALL writeDensity(stars,vacuum,atoms,sphhar,input,sym,oneD,CDN_ARCHIVE_TYPE_CDN1_const,CDN_INPUT_DEN_const,&
1,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
!
! Check continuity
!
......
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