Commit e2dad80b authored by Gregor Michalicek's avatar Gregor Michalicek

Getting nearer to changing structure, stars, stepfunction, lattice harmonics in cdn.hdf

- Relaxation of atom positions should work now, but it is not yet beautiful.
   -> An unnecessary additional step function is store in cdn.hdf in this case.
parent 49d52ff5
......@@ -46,7 +46,7 @@
!
ifftd = 27*stars%mx1*stars%mx2*stars%mx3
CALL readStepfunction(stars,l_error)
CALL readStepfunction(stars, atoms, cell, vacuum, l_error)
IF(.NOT.l_error) THEN
RETURN
END IF
......
......@@ -156,7 +156,7 @@ MODULE m_cdn_io
REAL, INTENT (OUT) :: fr(atoms%jmtd,0:sphhar%nlhd,atoms%ntype,input%jspins), fz(vacuum%nmzd,2,input%jspins)
! local variables
INTEGER :: mode, datend, k, i, iVac, j, iUnit
INTEGER :: mode, datend, k, i, iVac, j, iUnit, l
LOGICAL :: l_exist, l_rhomatFile, l_DimChange
CHARACTER(LEN=30) :: filename
......@@ -226,7 +226,6 @@ MODULE m_cdn_io
CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,inOrOutCDN,&
1,-1.0,fermiEnergy,l_qfix,iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
END IF
RETURN
ELSE
WRITE(*,*) 'cdn.hdf file or relevant density entry not found.'
WRITE(*,*) 'Falling back to stream access file cdn.str.'
......@@ -240,7 +239,6 @@ MODULE m_cdn_io
IF (l_exist) THEN
!load density from cdn.str and exit subroutine
RETURN
ELSE
WRITE(*,*) 'cdn.str file not found.'
WRITE(*,*) 'Falling back to direct access file cdn1.'
......@@ -310,10 +308,9 @@ MODULE m_cdn_io
cdomvxy = CMPLX(0.0,0.0)
END IF
END IF
CLOSE(iUnit)
END IF
CLOSE(iUnit)
END SUBROUTINE readDensity
SUBROUTINE writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,inOrOutCDN,&
......@@ -973,7 +970,8 @@ MODULE m_cdn_io
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
currentStepfunctionIndex = currentStepfunctionIndex + 1
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex, stars)
! Note: Since the stepfunction is stored before the structure I add 1 to currentStructureIndex.
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex, currentStructureIndex+1, stars)
CALL writeCDNHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
......@@ -994,14 +992,25 @@ MODULE m_cdn_io
END SUBROUTINE writeStepfunction
SUBROUTINE readStepfunction(stars, l_error)
SUBROUTINE readStepfunction(stars, atoms, cell, vacuum, l_error)
TYPE(t_stars),INTENT(INOUT) :: stars
LOGICAL, INTENT(OUT) :: l_error
TYPE(t_stars),INTENT(INOUT) :: stars
TYPE(t_atoms), INTENT(IN) :: atoms
TYPE(t_cell), INTENT(IN) :: cell
TYPE(t_vacuum), INTENT(IN) :: vacuum
LOGICAL, INTENT(OUT) :: l_error
TYPE(t_stars) :: starsTemp
TYPE(t_input) :: inputTemp
TYPE(t_atoms) :: atomsTemp
TYPE(t_cell) :: cellTemp
TYPE(t_vacuum) :: vacuumTemp
TYPE(t_oneD) :: oneDTemp
INTEGER :: mode
INTEGER :: ifftd, ng3Temp, ifftdTemp, ioStatus, i, starsIndexTemp
LOGICAL :: l_exist
INTEGER :: structureIndexTemp
LOGICAL :: l_exist, l_same, l_sameTemp
INTEGER :: currentStarsIndex,currentLatharmsIndex,currentStructureIndex
INTEGER :: currentStepfunctionIndex,readDensityIndex,lastDensityIndex
......@@ -1023,10 +1032,21 @@ MODULE m_cdn_io
currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
starsIndexTemp = -1
IF(currentStepfunctionIndex.GT.0) THEN
CALL peekStepfunctionHDF(fileID, currentStepfunctionIndex, starsIndexTemp)
CALL peekStepfunctionHDF(fileID, currentStepfunctionIndex, starsIndexTemp, structureIndexTemp)
END IF
IF(starsIndexTemp.EQ.currentStarsIndex) THEN
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, stars)
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
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, stars)
ELSE
mode = CDN_STREAM_MODE ! No adequate stepfunction entry found. Fall back to other IO modes.
END IF
ELSE
mode = CDN_STREAM_MODE ! No adequate stepfunction entry found. Fall back to other IO modes.
END IF
......
......@@ -77,7 +77,7 @@ MODULE m_cdnpot_io_common
IF(ANY(ABS(cell%amat(:,:)-refCell%amat(:,:)).GT.1e-10)) l_same = .FALSE.
IF(l_same) THEN
IF(ANY(atoms%nz(:).NE.refAtoms%nz(:))) l_same = .FALSE.
IF(ANY(atoms%lmax(:).NE.refAtoms%lmax(:))) l_same = .FALSE.
! IF(ANY(atoms%lmax(:).NE.refAtoms%lmax(:))) l_same = .FALSE.
END IF
IF(l_same) THEN
DO i = 1, atoms%nat
......@@ -181,14 +181,16 @@ MODULE m_cdnpot_io_common
IF(currentStepfunctionIndex.EQ.0) THEN
currentStepfunctionIndex = 1
l_storeIndices = .TRUE.
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex, stars)
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex,&
currentStructureIndex, stars)
ELSE
CALL readStepfunctionHDF(fileID, currentStepfunctionIndex, starsTemp)
CALL compareStepfunctions(stars, starsTemp, l_same)
IF((.NOT.l_same).OR.l_writeAll) THEN
currentStepfunctionIndex = currentStepfunctionIndex + 1
l_storeIndices = .TRUE.
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex, stars)
CALL writeStepfunctionHDF(fileID, currentStepfunctionIndex, currentStarsIndex,&
currentStructureIndex, stars)
END IF
END IF
......
......@@ -593,10 +593,10 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE readStarsHDF
SUBROUTINE writeStepfunctionHDF(fileID, stepfunctionIndex, starsIndex, stars)
SUBROUTINE writeStepfunctionHDF(fileID, stepfunctionIndex, starsIndex, structureIndex, stars)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: stepfunctionIndex, starsIndex
INTEGER, INTENT(IN) :: stepfunctionIndex, starsIndex, structureIndex
TYPE(t_stars), INTENT(IN) :: stars
INTEGER :: ifftd
......@@ -623,6 +623,7 @@ MODULE m_cdnpot_io_hdf
CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_write_attint0(groupID,'starsIndex',starsIndex)
CALL io_write_attint0(groupID,'structureIndex',structureIndex)
CALL io_write_attint0(groupID,'ifftd',ifftd)
CALL io_write_attint0(groupID,'ng3',stars%ng3)
......@@ -653,6 +654,7 @@ MODULE m_cdnpot_io_hdf
TYPE(t_stars), INTENT(INOUT) :: stars
INTEGER :: starsIndex, ng3Temp, ifftd, ifftdStars
INTEGER :: structureIndex
INTEGER(HID_T) :: groupID
INTEGER :: hdfError
......@@ -676,6 +678,7 @@ MODULE m_cdnpot_io_hdf
ifftdStars = 27*stars%mx1*stars%mx2*stars%mx3
CALL io_read_attint0(groupID,'starsIndex',starsIndex)
CALL io_read_attint0(groupID,'structureIndex',structureIndex)
CALL io_read_attint0(groupID,'ng3',ng3Temp)
CALL io_read_attint0(groupID,'ifftd',ifftd)
......@@ -705,11 +708,11 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE readStepfunctionHDF
SUBROUTINE peekStepfunctionHDF(fileID, stepfunctionIndex, starsIndex)
SUBROUTINE peekStepfunctionHDF(fileID, stepfunctionIndex, starsIndex, structureIndex)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: stepfunctionIndex
INTEGER, INTENT(OUT) :: starsIndex
INTEGER, INTENT(OUT) :: starsIndex, structureIndex
INTEGER(HID_T) :: groupID
INTEGER :: hdfError
......@@ -726,6 +729,7 @@ MODULE m_cdnpot_io_hdf
CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_read_attint0(groupID,'starsIndex',starsIndex)
CALL io_read_attint0(groupID,'structureIndex',structureIndex)
CALL h5gclose_f(groupID, hdfError)
END SUBROUTINE peekStepfunctionHDF
......@@ -1306,8 +1310,6 @@ MODULE m_cdnpot_io_hdf
INTEGER(HID_T) :: cdomvzSpaceID, cdomvzSetID
INTEGER(HID_T) :: cdomvxySpaceID, cdomvxySetID
WRITE(*,*) 'writeDensity - start'
WRITE(groupname,'(a,i0)') '/structure-', structureIndex
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF(.NOT.l_exist) THEN
......@@ -1615,8 +1617,6 @@ MODULE m_cdnpot_io_hdf
CALL h5gclose_f(archiveID, hdfError)
END IF
WRITE(*,*) 'writeDensity - end'
END SUBROUTINE writeDensityHDF
SUBROUTINE writePotentialHDF(input, fileID, archiveName, potentialType,&
......@@ -1655,8 +1655,6 @@ MODULE m_cdnpot_io_hdf
INTEGER(HID_T) :: fzSpaceID, fzSetID
INTEGER(HID_T) :: fzxySpaceID, fzxySetID
WRITE(*,*) 'writePotential - start'
WRITE(groupname,'(a,i0)') '/structure-', structureIndex
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF(.NOT.l_exist) THEN
......@@ -1860,8 +1858,6 @@ MODULE m_cdnpot_io_hdf
CALL h5gclose_f(archiveID, hdfError)
END IF
WRITE(*,*) 'writePotential - end'
END SUBROUTINE writePotentialHDF
SUBROUTINE readDensityHDF(fileID, input, stars, latharms, atoms, vacuum, oneD,&
......@@ -1920,8 +1916,6 @@ MODULE m_cdnpot_io_hdf
cdomvz = CMPLX(0.0,0.0)
cdomvxy = CMPLX(0.0,0.0)
WRITE(*,*) 'readDensity - start'
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
IF(.NOT.l_exist) THEN
CALL juDFT_error('density archive '//TRIM(ADJUSTL(archiveName))//' does not exist.' ,calledby ="readDensityHDF")
......@@ -2115,8 +2109,6 @@ MODULE m_cdnpot_io_hdf
CALL h5gclose_f(groupID, hdfError)
CALL h5gclose_f(archiveID, hdfError)
WRITE(*,*) 'readDensity - end'
END SUBROUTINE readDensityHDF
SUBROUTINE readPotentialHDF(fileID, archiveName, potentialType,&
......@@ -2148,8 +2140,6 @@ MODULE m_cdnpot_io_hdf
INTEGER(HID_T) :: fzSetID
INTEGER(HID_T) :: fzxySetID
WRITE(*,*) 'readPotential - start'
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
IF(.NOT.l_exist) THEN
CALL juDFT_error('density archive '//TRIM(ADJUSTL(archiveName))//' does not exist.' ,calledby ="readPotentialHDF")
......@@ -2241,8 +2231,6 @@ MODULE m_cdnpot_io_hdf
CALL h5gclose_f(groupID, hdfError)
CALL h5gclose_f(archiveID, hdfError)
WRITE(*,*) 'readPotential - end'
END SUBROUTINE readPotentialHDF
......@@ -2350,8 +2338,6 @@ MODULE m_cdnpot_io_hdf
INTEGER(HSIZE_T) :: dims(7)
INTEGER :: dimsInt(7)
WRITE(*,*) 'writeCoreDensity - start'
l_exist = io_groupexists(fileID,'/cdnc')
IF(l_exist) THEN ! replace current core density
......@@ -2411,8 +2397,6 @@ MODULE m_cdnpot_io_hdf
CALL h5gclose_f(cdncGroupID, hdfError)
END IF
WRITE(*,*) 'writeCoreDensity - end'
END SUBROUTINE writeCoreDensityHDF
SUBROUTINE readCoreDensityHDF(fileID,input,atoms,dimension,rhcs,tecs,qints)
......@@ -2432,8 +2416,6 @@ MODULE m_cdnpot_io_hdf
LOGICAL l_exist
INTEGER :: dimsInt(7)
WRITE(*,*) 'readCoreDensity - start'
l_exist = io_groupexists(fileID,'/cdnc')
IF(.NOT.l_exist) THEN
CALL juDFT_error("no core density found",calledby ="readCoreDensityHDF")
......@@ -2466,8 +2448,6 @@ MODULE m_cdnpot_io_hdf
CALL h5gclose_f(cdncGroupID, hdfError)
WRITE(*,*) 'readCoreDensity - end'
END SUBROUTINE readCoreDensityHDF
LOGICAL FUNCTION deleteDensityEntryHDF(fileID,archiveName)
......
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