Commit 64f82bd8 authored by Gregor Michalicek's avatar Gregor Michalicek

Add distance to stored densities and to info mode

Note: At the moment the distance in the info mode is off by one iteration.

Also in this commit: Added version info to cdn.hdf and pot.hdf
parent bf803829
......@@ -65,7 +65,7 @@ MODULE m_cdn_io
INTEGER :: iterTemp, starsIndexTemp, latharmsIndexTemp
INTEGER :: structureIndexTemp,stepfunctionIndexTemp
INTEGER :: previousDensityIndex, jspinsTemp
REAL :: fermiEnergyTemp
REAL :: fermiEnergyTemp, distanceTemp
LOGICAL :: l_qfixTemp
......@@ -80,7 +80,7 @@ MODULE m_cdn_io
IF (l_exist) THEN
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
WRITE(*,'(a)') 'densityIndex prevDensity iteration'
WRITE(*,'(a)') 'densityIndex prevDensity iteration distance'
DO i = 1, lastDensityIndex
archiveName = ''
WRITE(archiveName,'(a,i0)') '/cdn-', i
......@@ -93,9 +93,9 @@ MODULE m_cdn_io
CALL peekDensityEntryHDF(fileID, archiveName, DENSITY_TYPE_UNDEFINED_const,&
iterTemp, starsIndexTemp, latharmsIndexTemp, structureIndexTemp,&
stepfunctionIndexTemp,previousDensityIndex, jspinsTemp,&
fermiEnergyTemp, l_qfixTemp)
distanceTemp, fermiEnergyTemp, l_qfixTemp)
WRITE(*,'(3i10)') i, previousDensityIndex, iterTemp
WRITE(*,'(i7,8x,i7,5x,i7,4x,f15.8)') i, previousDensityIndex, iterTemp, distanceTemp
END DO
CALL closeCDNPOT_HDF(fileID)
......@@ -293,7 +293,7 @@ MODULE m_cdn_io
END SUBROUTINE readDensity
SUBROUTINE writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,inOrOutCDN,&
relCdnIndex,fermiEnergy,l_qfix,iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
relCdnIndex,distance,fermiEnergy,l_qfix,iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
TYPE(t_stars),INTENT(IN) :: stars
TYPE(t_vacuum),INTENT(IN) :: vacuum
......@@ -307,7 +307,7 @@ MODULE m_cdn_io
INTEGER, INTENT (IN) :: inOrOutCDN
INTEGER, INTENT (IN) :: relCdnIndex, iter
INTEGER, INTENT (IN) :: archiveType
REAL, INTENT (IN) :: fermiEnergy
REAL, INTENT (IN) :: fermiEnergy, distance
LOGICAL, INTENT (IN) :: l_qfix
! ..
! .. Array Arguments ..
......@@ -341,7 +341,7 @@ MODULE m_cdn_io
INTEGER :: starsIndexTemp, latharmsIndexTemp, structureIndexTemp
INTEGER :: stepfunctionIndexTemp
INTEGER :: jspinsTemp
REAL :: fermiEnergyTemp
REAL :: fermiEnergyTemp, distanceTemp
LOGICAL :: l_qfixTemp
CHARACTER(LEN=30) :: archiveName
......@@ -414,7 +414,7 @@ MODULE m_cdn_io
CALL peekDensityEntryHDF(fileID, archiveName, DENSITY_TYPE_UNDEFINED_const,&
iterTemp, starsIndexTemp, latharmsIndexTemp, structureIndexTemp,&
stepfunctionIndexTemp,previousDensityIndex, jspinsTemp,&
fermiEnergyTemp, l_qfixTemp)
distanceTemp, fermiEnergyTemp, l_qfixTemp)
END IF
END IF
......@@ -433,7 +433,7 @@ MODULE m_cdn_io
CALL writeDensityHDF(input, fileID, archiveName, densityType, previousDensityIndex,&
currentStarsIndex, currentLatharmsIndex, currentStructureIndex,&
currentStepfunctionIndex,fermiEnergy,l_qfix,iter+relCdnIndex,&
currentStepfunctionIndex,distance,fermiEnergy,l_qfix,iter+relCdnIndex,&
fr,fpw,fzTemp,fzxyTemp,cdom,cdomvz,cdomvxy)
DEALLOCATE(fzTemp,fzxyTemp)
......@@ -599,7 +599,7 @@ MODULE m_cdn_io
INTEGER :: starsIndex, latharmsIndex, structureIndex
INTEGER :: stepfunctionIndex
INTEGER :: iter, jspins, previousDensityIndex
REAL :: fermiEnergy
REAL :: fermiEnergy, distance
LOGICAL :: l_qfix, l_exist
CHARACTER(LEN=30) :: archiveName
......@@ -614,14 +614,14 @@ MODULE m_cdn_io
WRITE(archiveName,'(a,i0)') '/cdn-', readDensityIndex
CALL peekDensityEntryHDF(fileID, archiveName, DENSITY_TYPE_UNDEFINED_const,&
iter, starsIndex, latharmsIndex, structureIndex, stepfunctionIndex,&
previousDensityIndex, jspins, fermiEnergy, l_qfix)
previousDensityIndex, jspins, distance, fermiEnergy, l_qfix)
archiveName = ''
WRITE(archiveName,'(a,i0)') '/cdn-', previousDensityIndex
l_exist = isDensityEntryPresentHDF(fileID,archiveName,DENSITY_TYPE_NOCO_OUT_const)
IF(l_exist) THEN
CALL peekDensityEntryHDF(fileID, archiveName, DENSITY_TYPE_NOCO_OUT_const,&
iter, starsIndex, latharmsIndex, structureIndex, stepfunctionIndex,&
previousDensityIndex, jspins, fermiEnergy, l_qfix)
previousDensityIndex, jspins, distance, fermiEnergy, l_qfix)
eFermiPrev = fermiEnergy
ELSE
l_error = .TRUE.
......
......@@ -46,6 +46,8 @@ MODULE m_cdnpot_io_hdf
INTEGER, PARAMETER :: POTENTIAL_TYPE_IN_const = 1
INTEGER, PARAMETER :: POTENTIAL_TYPE_OUT_const = 2
INTEGER, PARAMETER :: FILE_FORMAT_VERSION_const = 28
CONTAINS
#ifdef CPP_HDF
......@@ -58,7 +60,7 @@ MODULE m_cdnpot_io_hdf
INTEGER, INTENT(OUT) :: currentStepfunctionIndex, readDensityIndex,lastDensityIndex
INTEGER(HID_T) :: generalGroupID
INTEGER :: hdfError
INTEGER :: hdfError, fileFormatVersion
LOGICAL :: l_exist
currentStarsIndex = 0
......@@ -67,6 +69,7 @@ MODULE m_cdnpot_io_hdf
currentStepfunctionIndex = 0
readDensityIndex = 0
lastDensityIndex = 0
fileFormatVersion = 0
INQUIRE(FILE='cdn.hdf',EXIST=l_exist)
IF(l_exist) THEN ! only open file
......@@ -80,8 +83,13 @@ MODULE m_cdnpot_io_hdf
CALL io_read_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
CALL io_read_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
CALL io_read_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
CALL h5gclose_f(generalGroupID, hdfError)
IF(fileFormatVersion.NE.FILE_FORMAT_VERSION_const) THEN
WRITE(*,'(a,i4)') 'cdn.hdf has file format version ', fileFormatVersion
CALL juDFT_error('cdn.hdf file format not readable.' ,calledby ="openCDN_HDF")
END IF
ELSE ! create file
CALL h5fcreate_f('cdn.hdf', H5F_ACC_TRUNC_F, fileID, hdfError, H5P_DEFAULT_F, H5P_DEFAULT_F)
......@@ -93,6 +101,7 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
CALL io_write_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
CALL io_write_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
CALL h5gclose_f(generalGroupID, hdfError)
END IF
......@@ -108,13 +117,14 @@ MODULE m_cdnpot_io_hdf
INTEGER, INTENT(OUT) :: currentStructureIndex, currentStepfunctionIndex
INTEGER(HID_T) :: generalGroupID
INTEGER :: hdfError
INTEGER :: hdfError, fileFormatVersion
LOGICAL :: l_exist
currentStarsIndex = 0
currentLatharmsIndex = 0
currentStructureIndex = 0
currentStepfunctionIndex = 0
fileFormatVersion = 0
INQUIRE(FILE='pot.hdf',EXIST=l_exist)
IF(l_exist) THEN ! only open file
......@@ -126,8 +136,13 @@ MODULE m_cdnpot_io_hdf
CALL io_read_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
CALL io_read_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
CALL io_read_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
CALL h5gclose_f(generalGroupID, hdfError)
IF(fileFormatVersion.NE.FILE_FORMAT_VERSION_const) THEN
WRITE(*,'(a,i4)') 'pot.hdf has file format version ', fileFormatVersion
CALL juDFT_error('pot.hdf file format not readable.' ,calledby ="openPOT_HDF")
END IF
ELSE ! create file
CALL h5fcreate_f('pot.hdf', H5F_ACC_TRUNC_F, fileID, hdfError, H5P_DEFAULT_F, H5P_DEFAULT_F)
......@@ -137,6 +152,7 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
CALL h5gclose_f(generalGroupID, hdfError)
END IF
......@@ -175,6 +191,7 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
CALL io_write_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
CALL io_write_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
CALL h5gclose_f(generalGroupID, hdfError)
......@@ -198,6 +215,7 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
CALL h5gclose_f(generalGroupID, hdfError)
......@@ -1248,7 +1266,7 @@ MODULE m_cdnpot_io_hdf
SUBROUTINE writeDensityHDF(input, fileID, archiveName, densityType, previousDensityIndex,&
starsIndex, latharmsIndex, structureIndex, stepfunctionIndex,&
fermiEnergy,l_qfix,iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
distance,fermiEnergy,l_qfix,iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
TYPE(t_input), INTENT(IN) :: input
INTEGER(HID_T), INTENT(IN) :: fileID
......@@ -1258,7 +1276,7 @@ MODULE m_cdnpot_io_hdf
CHARACTER(LEN=*), INTENT(IN) :: archiveName
INTEGER, INTENT (IN) :: iter
REAL, INTENT (IN) :: fermiEnergy
REAL, INTENT (IN) :: fermiEnergy, distance
LOGICAL, INTENT (IN) :: l_qfix
REAL, INTENT (IN) :: fr(:,:,:,:)
......@@ -1349,6 +1367,9 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
CALL io_write_attint0(archiveID,'spins',input%jspins)
CALL io_write_attint0(archiveID,'iter',iter)
IF (distance.GE.-1e-10) THEN
CALL io_write_attreal0(archiveID,'distance',distance)
END IF
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
......@@ -1486,6 +1507,7 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
CALL io_write_attint0(archiveID,'spins',input%jspins)
CALL io_write_attint0(archiveID,'iter',iter)
CALL io_write_attreal0(archiveID,'distance',distance)
CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
......@@ -2080,7 +2102,7 @@ MODULE m_cdnpot_io_hdf
SUBROUTINE peekDensityEntryHDF(fileID, archiveName, densityType,&
iter, starsIndex, latharmsIndex, structureIndex,&
stepfunctionIndex, previousDensityIndex, jspins,&
fermiEnergy, l_qfix)
distance, fermiEnergy, l_qfix)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: densityType
......@@ -2089,7 +2111,7 @@ MODULE m_cdnpot_io_hdf
INTEGER, INTENT(OUT) :: iter
INTEGER, INTENT(OUT) :: starsIndex, latharmsIndex, structureIndex, stepfunctionIndex
INTEGER, INTENT(OUT) :: previousDensityIndex, jspins
REAL, INTENT(OUT) :: fermiEnergy
REAL, INTENT(OUT) :: fermiEnergy, distance
LOGICAL, INTENT(OUT) :: l_qfix
INTEGER :: localDensityType
......@@ -2149,6 +2171,7 @@ MODULE m_cdnpot_io_hdf
CALL io_read_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
CALL io_read_attint0(archiveID,'spins',jspins)
CALL io_read_attint0(archiveID,'iter',iter)
CALL io_read_attreal0(archiveID,'distance',distance)
IF (densityType.NE.DENSITY_TYPE_UNDEFINED_const) THEN
CALL io_read_attreal0(groupID,'fermiEnergy',fermiEnergy)
......
......@@ -487,7 +487,8 @@
END IF
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,&
CDN_OUTPUT_DEN_const,0,results%ef,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
CDN_OUTPUT_DEN_const,0,results%last_distance,results%ef,.FALSE.,iter,&
rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
ENDIF
DEALLOCATE (cdom,cdomvz,cdomvxy,qa21)
......
......@@ -247,6 +247,7 @@
it = 0
ithf = 0
l_cont = ( it < input%itmax )
results%last_distance = -1.0
IF (mpi%irank.EQ.0) CALL openXMLElementNoAttributes('scfLoop')
DO 80 WHILE ( l_cont )
it = it + 1
......
......@@ -305,7 +305,7 @@ CONTAINS
qpw,rhtxy,rho,rht,.FALSE., fix)
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
1,results%ef,.TRUE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
1,results%last_distance,results%ef,.TRUE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
DEALLOCATE ( cdom,cdomvz,cdomvxy )
IF ( atoms%n_u > 0 ) THEN
......
......@@ -170,7 +170,7 @@ CONTAINS
IF (input%total.OR.reap) THEN
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
0,-1.0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
END IF
WRITE (6,FMT=8000)
......
......@@ -109,7 +109,7 @@
ENDIF
! ----> write the spin-polarized density
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,CDN_ARCHIVE_TYPE_CDN1_const,&
CDN_INPUT_DEN_const,0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
CDN_INPUT_DEN_const,0,-1.0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
!
! -----> This part is only used for testing th e magnetic moment in
! -----> each sphere
......
......@@ -90,7 +90,7 @@
ENDDO
! ----> write the spin-polarized density
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
0,-1.0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
!
! for lda+U: flip n-matrix
!
......
......@@ -326,7 +326,7 @@
inp%jspins=1
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,inp,sym,oneD,CDN_ARCHIVE_TYPE_CDN_const,CDN_INPUT_DEN_const,&
0,0.0,.FALSE.,iter,rho(:,0:,1:,1:1),qpw(1:,1:1),rht(1:,1:,1:1),rhtxy(1:,1:,1:,1:1),cdom,cdomvz,cdomvxy)
0,-1.0,0.0,.FALSE.,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')
......
......@@ -244,7 +244,7 @@
!
iter = 0
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,CDN_ARCHIVE_TYPE_CDN1_const,CDN_INPUT_DEN_const,&
1,0.0,.TRUE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
1,-1.0,0.0,.TRUE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
!
! Check continuity
!
......
......@@ -400,7 +400,7 @@ CONTAINS
!---> write spin-up and -down density on file cdn
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,CDN_ARCHIVE_TYPE_CDN_const,CDN_INPUT_DEN_const,&
0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
0,-1.0,0.0,.FALSE.,iter,rho,qpw,rht,rhtxy,cdom,cdomvz,cdomvxy)
DEALLOCATE (qpw,rhtxy,cdom,cdomvz,cdomvxy,&
& ris,fftwork,rz,rho,rht)
......
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