Commit 7e2002eb authored by Gregor Michalicek's avatar Gregor Michalicek

Nearly finished changing structure, stars, stepfunction, lattice harmonics in cdn.hdf

- Relaxation of atom positions now works as it should.
- The code also becomes clearer.
parent 25b3a023
......@@ -39,6 +39,7 @@
USE m_dwigner
USE m_strgn
USE m_stepf
USE m_cdn_io
USE m_mapatom
USE m_writegw
USE m_convn
......@@ -136,6 +137,10 @@
CALL od_mapatom(oneD,atoms,sym,cell)
END IF
! Store structure data
CALL storeStructureIfNew(input, atoms, cell, vacuum, oneD)
!+odim
IF (input%film.OR.(sym%namgrp.NE.'any ')) THEN
CALL strgn1(stars,sym,atoms, vacuum,sphhar, input,cell,xcpot)
......
......@@ -33,6 +33,7 @@ MODULE m_cdn_io
PUBLIC readStars, writeStars
PUBLIC readStepfunction, writeStepfunction
PUBLIC setStartingDensity, readPrevEFermi, deleteDensities
PUBLIC storeStructureIfNew
PUBLIC CDN_INPUT_DEN_const, CDN_OUTPUT_DEN_const
PUBLIC CDN_ARCHIVE_TYPE_CDN1_const, CDN_ARCHIVE_TYPE_NOCO_const
PUBLIC CDN_ARCHIVE_TYPE_CDN_const
......@@ -806,6 +807,7 @@ MODULE m_cdn_io
CALL readStructureHDF(fileID, inputTemp, atomsTemp, cellTemp, vacuumTemp, oneDTemp, currentStructureIndex)
CALL compareStructure(atoms, vacuum, cell, atomsTemp, vacuumTemp, cellTemp, l_same)
IF(.NOT.l_same) THEN
currentStructureIndex = currentStructureIndex + 1
l_writeStructure = .TRUE.
END IF
END IF
......@@ -855,7 +857,7 @@ MODULE m_cdn_io
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
currentStarsIndex = currentStarsIndex + 1
CALL writeStarsHDF(fileID, currentStarsIndex, stars)
CALL writeStarsHDF(fileID, currentStarsIndex, currentStructureIndex, stars)
CALL writeCDNHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
......@@ -904,6 +906,7 @@ MODULE m_cdn_io
INTEGER :: mode, ioStatus, ngz,izmin,izmax
LOGICAL :: l_exist, l_same
INTEGER :: structureIndexTemp
INTEGER :: currentStarsIndex,currentLatharmsIndex,currentStructureIndex
INTEGER :: currentStepfunctionIndex,readDensityIndex,lastDensityIndex
#ifdef CPP_HDF
......@@ -929,9 +932,12 @@ MODULE m_cdn_io
IF (currentStarsIndex.LT.1) THEN
mode = CDN_DIRECT_MODE ! (no stars entry found in cdn.hdf file)
ELSE
CALL readStarsHDF(fileID, currentStarsIndex, starsTemp)
CALL compareStars(stars, starsTemp, l_same)
WRITE(*,*) 'l_same', l_same
CALL peekStarsHDF(fileID, currentStarsIndex, structureIndexTemp)
l_same = structureIndexTemp.EQ.currentStructureIndex
IF(l_same) THEN
CALL readStarsHDF(fileID, currentStarsIndex, starsTemp)
CALL compareStars(stars, starsTemp, l_same)
END IF
IF(l_same) THEN
CALL readStarsHDF(fileID, currentStarsIndex, stars)
ELSE
......@@ -1028,8 +1034,7 @@ MODULE m_cdn_io
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
currentStepfunctionIndex = currentStepfunctionIndex + 1
! Note: Since the stepfunction is stored before the structure I add 1 to currentStructureIndex.
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex, currentStructureIndex+1, stars)
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex, currentStructureIndex, stars)
CALL writeCDNHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
......@@ -1088,19 +1093,9 @@ MODULE m_cdn_io
#ifdef CPP_HDF
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
starsIndexTemp = -1
IF(currentStepfunctionIndex.GT.0) THEN
CALL peekStepfunctionHDF(fileID, currentStepfunctionIndex, starsIndexTemp, structureIndexTemp)
END IF
IF(starsIndexTemp.EQ.currentStarsIndex) THEN
CALL readStarsHDF(fileID, starsIndexTemp, starsTemp)
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, starsTemp)
CALL readStructureHDF(fileID, inputTemp, atomsTemp, cellTemp, vacuumTemp, oneDTemp, structureIndexTemp)
CALL compareStars(stars, starsTemp, l_same)
CALL compareStructure(atoms, vacuum, cell, atomsTemp, vacuumTemp, cellTemp, l_sameTemp)
l_same = l_same.AND.l_sameTemp
IF (l_same) THEN
IF((starsIndexTemp.EQ.currentStarsIndex).AND.(structureIndexTemp.EQ.currentStructureIndex)) THEN
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, stars)
ELSE
mode = CDN_STREAM_MODE ! No adequate stepfunction entry found. Fall back to other IO modes.
......
......@@ -132,6 +132,7 @@ MODULE m_cdnpot_io_common
TYPE(t_cell) :: cellTemp
TYPE(t_oneD) :: oneDTemp
INTEGER :: starsIndexTemp, structureIndexTemp
LOGICAL :: l_same, l_writeAll
l_storeIndices = .FALSE.
......@@ -155,27 +156,35 @@ MODULE m_cdnpot_io_common
IF (currentStarsIndex.EQ.0) THEN
currentStarsIndex = 1
l_storeIndices = .TRUE.
CALL writeStarsHDF(fileID, currentStarsIndex, stars)
CALL writeStarsHDF(fileID, currentStarsIndex, currentStructureIndex, stars)
ELSE
CALL readStarsHDF(fileID, currentStarsIndex, starsTemp)
CALL compareStars(stars, starsTemp, l_same)
CALL peekStarsHDF(fileID, currentStarsIndex, structureIndexTemp)
l_same = structureIndexTemp.EQ.currentStructureIndex
IF(l_same) THEN
CALL readStarsHDF(fileID, currentStarsIndex, starsTemp)
CALL compareStars(stars, starsTemp, l_same)
END IF
IF((.NOT.l_same).OR.l_writeAll) THEN
currentStarsIndex = currentStarsIndex + 1
l_storeIndices = .TRUE.
CALL writeStarsHDF(fileID, currentStarsIndex, stars)
CALL writeStarsHDF(fileID, currentStarsIndex, currentStructureIndex, stars)
END IF
END IF
IF (currentLatharmsIndex.EQ.0) THEN
currentLatharmsIndex = 1
l_storeIndices = .TRUE.
CALL writeLatharmsHDF(fileID, currentLatharmsIndex, latharms)
CALL writeLatharmsHDF(fileID, currentLatharmsIndex, currentStructureIndex, latharms)
ELSE
CALL readLatharmsHDF(fileID, currentLatharmsIndex, latharmsTemp)
CALL compareLatharms(latharms, latharmsTemp, l_same)
CALL peekLatharmsHDF(fileID, currentLatharmsIndex, structureIndexTemp)
l_same = structureIndexTemp.EQ.currentStructureIndex
IF(l_same) THEN
CALL readLatharmsHDF(fileID, currentLatharmsIndex, latharmsTemp)
CALL compareLatharms(latharms, latharmsTemp, l_same)
END IF
IF((.NOT.l_same).OR.l_writeAll) THEN
currentLatharmsIndex = currentLatharmsIndex + 1
l_storeIndices = .TRUE.
CALL writeLatharmsHDF(fileID, currentLatharmsIndex, latharms)
CALL writeLatharmsHDF(fileID, currentLatharmsIndex, currentStructureIndex, latharms)
END IF
END IF
IF(currentStepfunctionIndex.EQ.0) THEN
......@@ -184,8 +193,12 @@ MODULE m_cdnpot_io_common
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex,&
currentStructureIndex, stars)
ELSE
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, starsTemp)
CALL compareStepfunctions(stars, starsTemp, l_same)
CALL peekStepfunctionHDF(fileID, currentStepfunctionIndex, starsIndexTemp, structureIndexTemp)
l_same = (starsIndexTemp.EQ.currentStarsIndex).AND.(structureIndexTemp.EQ.currentStructureIndex)
IF(l_same) THEN
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, starsTemp)
CALL compareStepfunctions(stars, starsTemp, l_same)
END IF
IF((.NOT.l_same).OR.l_writeAll) THEN
currentStepfunctionIndex = currentStepfunctionIndex + 1
l_storeIndices = .TRUE.
......
......@@ -17,8 +17,8 @@ MODULE m_cdnpot_io_hdf
PRIVATE
#ifdef CPP_HDF
PUBLIC openCDN_HDF, openPOT_HDF, closeCDNPOT_HDF
PUBLIC writeStarsHDF, readStarsHDF
PUBLIC writeLatharmsHDF, readLatharmsHDF
PUBLIC writeStarsHDF, readStarsHDF, peekStarsHDF
PUBLIC writeLatharmsHDF, readLatharmsHDF, peekLatharmsHDF
PUBLIC writeStructureHDF, readStructureHDF
PUBLIC writeStepfunctionHDF, readStepfunctionHDF, peekStepfunctionHDF
PUBLIC writeDensityHDF, readDensityHDF
......@@ -221,10 +221,10 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE writePOTHeaderData
SUBROUTINE writeStarsHDF(fileID, starsIndex, stars)
SUBROUTINE writeStarsHDF(fileID, starsIndex, structureIndex, stars)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: starsIndex
INTEGER, INTENT(IN) :: starsIndex, structureIndex
TYPE(t_stars), INTENT(IN) :: stars
INTEGER(HID_T) :: groupID
......@@ -262,6 +262,8 @@ MODULE m_cdnpot_io_hdf
ft2_gf_dim = SIZE(stars%ft2_gfx,1)
CALL io_write_attint0(groupID,'structureIndex',structureIndex)
CALL io_write_attreal0(groupID,'gmax',stars%gmax)
CALL io_write_attreal0(groupID,'gmaxInit',stars%gmaxInit)
CALL io_write_attint0(groupID,'ng3',stars%ng3)
......@@ -593,6 +595,31 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE readStarsHDF
SUBROUTINE peekStarsHDF(fileID, starsIndex, structureIndex)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: starsIndex
INTEGER, INTENT(OUT) :: structureIndex
INTEGER(HID_T) :: groupID
INTEGER :: hdfError
CHARACTER(LEN=30) :: groupName
LOGICAL :: l_exist
WRITE(groupname,'(a,i0)') '/stars-', starsIndex
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF (.NOT.l_exist) THEN
CALL juDFT_error('stars entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readStarsHDF")
END IF
CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_read_attint0(groupID,'structureIndex',structureIndex)
CALL h5gclose_f(groupID, hdfError)
END SUBROUTINE peekStarsHDF
SUBROUTINE writeStepfunctionHDF(fileID, stepfunctionIndex, starsIndex, structureIndex, stars)
INTEGER(HID_T), INTENT(IN) :: fileID
......@@ -734,10 +761,10 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE peekStepfunctionHDF
SUBROUTINE writeLatharmsHDF(fileID, latharmsIndex, latharms)
SUBROUTINE writeLatharmsHDF(fileID, latharmsIndex, structureIndex, latharms)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: latharmsIndex
INTEGER, INTENT(IN) :: latharmsIndex, structureIndex
TYPE(t_sphhar), INTENT(IN) :: latharms
INTEGER :: hdfError
......@@ -762,6 +789,7 @@ MODULE m_cdnpot_io_hdf
CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_write_attint0(groupID,'structureIndex',structureIndex)
CALL io_write_attint0(groupID,'ntypsd',latharms%ntypsd)
CALL io_write_attint0(groupID,'memd',latharms%memd)
CALL io_write_attint0(groupID,'nlhd',latharms%nlhd)
......@@ -877,6 +905,31 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE readLatharmsHDF
SUBROUTINE peekLatharmsHDF(fileID, latharmsIndex, structureIndex)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: latharmsIndex
INTEGER, INTENT(OUT) :: structureIndex
INTEGER(HID_T) :: groupID
INTEGER :: hdfError
CHARACTER(LEN=30) :: groupName
LOGICAL :: l_exist
WRITE(groupname,'(a,i0)') '/latharms-', latharmsIndex
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF (.NOT.l_exist) THEN
CALL juDFT_error('latharms entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readLatharmsHDF")
END IF
CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_read_attint0(groupID,'structureIndex',structureIndex)
CALL h5gclose_f(groupID, hdfError)
END SUBROUTINE peekLatharmsHDF
SUBROUTINE writeStructureHDF(fileID, input, atoms, cell, vacuum, oneD, structureIndex)
INTEGER(HID_T), INTENT(IN) :: fileID
......@@ -2095,6 +2148,7 @@ MODULE m_cdnpot_io_hdf
DEALLOCATE(cdomvzTemp)
cdomvxy = CMPLX(0.0,0.0)
! No change in od_nq2 allowed at the moment!
ALLOCATE(cdomvxyTemp(nmzxy,od_nq2-1,nvac))
dimsInt(:4)=(/2,nmzxy,od_nq2-1,nvac/)
CALL h5dopen_f(groupID, 'cdomvxy', cdomvxySetID, hdfError)
......
......@@ -51,6 +51,7 @@ SUBROUTINE r_inpXML(&
USE m_prpqfft
USE m_prpxcfft
USE m_stepf
USE m_cdn_io
USE m_convn
USE m_efield
USE m_writegw
......@@ -2243,6 +2244,11 @@ SUBROUTINE r_inpXML(&
oneD%pgft1y(0:1),oneD%pgft1yy(0:1))
END IF
oneD%odd%nq2 = oneD%odd%n2d
oneD%odi%nq2 = oneD%odd%nq2
! Store structure data
CALL storeStructureIfNew(input, atoms, cell, vacuum, oneD)
! Generate stars
......
......@@ -286,6 +286,7 @@
& oneD%pgft1y(0:1),oneD%pgft1yy(0:1))
ENDIF
oneD%odd%nq2 = oneD%odd%n2d
oneD%odi%nq2 = oneD%odd%nq2
!-odim
!+t3e
INQUIRE(file="cdn1",exist=l_opti)
......@@ -332,6 +333,7 @@
oneD%odg%pgfxx => oneD%pgft1xx ; oneD%odg%pgfyy => oneD%pgft1yy ; oneD%odg%pgfxy => oneD%pgft1xy
!+odim
!
#ifdef CPP_MPI
CALL MPI_BCAST(l_opti,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
CALL MPI_BCAST(noco%l_noco,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
......@@ -406,7 +408,6 @@
ENDDO
ENDDO
jij%qn = 0.0
!-t3e
!-odim
......@@ -446,7 +447,6 @@
ENDIF
!--- J>
IF( sym%invs .OR. noco%l_soc ) THEN
sym%nsym = sym%nop
ELSE
......
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