Commit 343d8e18 authored by Gregor Michalicek's avatar Gregor Michalicek

Introduced readDensityIndex into cdn.hdf file

parent e7539fd9
......@@ -76,8 +76,9 @@ MODULE m_cdn_io
INTEGER(HID_T) :: fileID
#endif
INTEGER :: currentStarsIndex,currentLatharmsIndex
INTEGER :: currentStructureIndex,currentDensityIndex
INTEGER :: lastDensityIndex, densityType
INTEGER :: currentStructureIndex
INTEGER :: readDensityIndex, lastDensityIndex
INTEGER :: previousDensityIndex, densityType
CHARACTER(LEN=30) :: archiveName
TYPE(t_cell) :: cellTemp
......@@ -91,14 +92,13 @@ MODULE m_cdn_io
INQUIRE(FILE='cdn.hdf',EXIST=l_exist)
IF (l_exist) THEN
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
currentDensityIndex = currentDensityIndex + relCdnIndex ! This is actually wrong. I should go back step by step.
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
IF (archiveType.EQ.CDN_ARCHIVE_TYPE_CDN_const) THEN
archiveName = 'cdn'
ELSE
WRITE(archiveName,'(a,i0)') '/cdn-', currentDensityIndex
WRITE(archiveName,'(a,i0)') '/cdn-', readDensityIndex
END IF
SELECT CASE (inOrOutCDN)
......@@ -123,7 +123,8 @@ MODULE m_cdn_io
END IF
IF (l_exist) THEN
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
CALL readDensityHDF(fileID, archiveName, densityType,&
iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
......@@ -260,15 +261,19 @@ MODULE m_cdn_io
INTEGER(HID_T) :: fileID
#endif
INTEGER :: currentStarsIndex,currentLatharmsIndex
INTEGER :: currentStructureIndex,currentDensityIndex
INTEGER :: lastDensityIndex, densityType
INTEGER :: currentStructureIndex
INTEGER :: readDensityIndex, writeDensityIndex, lastDensityIndex
INTEGER :: previousDensityIndex, densityType
INTEGER :: starsIndexTemp, latharmsIndexTemp, structureIndexTemp
INTEGER :: jspinsTemp
CHARACTER(LEN=30) :: archiveName
CALL getMode(mode)
IF(mode.EQ.CDN_HDF5_MODE) THEN
#ifdef CPP_HDF
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
l_storeIndices = .FALSE.
IF (currentStarsIndex.EQ.0) THEN
......@@ -286,9 +291,12 @@ MODULE m_cdn_io
l_storeIndices = .TRUE.
CALL writeStructureHDF(fileID, input, atoms, cell, vacuum, oneD, currentStructureIndex)
END IF
lastDensityIndex = currentDensityIndex
previousDensityIndex = readDensityIndex
writeDensityIndex = readDensityIndex
IF(relCdnIndex.NE.0) THEN
currentDensityIndex = currentDensityIndex+relCdnIndex
writeDensityIndex = lastDensityIndex+relCdnIndex
lastDensityIndex = writeDensityIndex
readDensityIndex = writeDensityIndex
l_storeIndices = .TRUE.
END IF
......@@ -296,7 +304,7 @@ MODULE m_cdn_io
IF (archiveType.EQ.CDN_ARCHIVE_TYPE_CDN_const) THEN
archiveName = 'cdn'
ELSE
WRITE(archiveName,'(a,i0)') '/cdn-', currentDensityIndex
WRITE(archiveName,'(a,i0)') '/cdn-', writeDensityIndex
END IF
densityType = 0
......@@ -318,13 +326,22 @@ MODULE m_cdn_io
CALL juDFT_error("Invalid inOrOutCDN selected.",calledby ="writeDensity")
END SELECT
CALL writeDensityHDF(input, fileID, archiveName, densityType, lastDensityIndex,&
IF(relCdnIndex.EQ.0) THEN
l_exist = isDensityEntryPresentHDF(fileID,archiveName,DENSITY_TYPE_UNDEFINED_const)
IF(l_exist) THEN
CALL peekDensityEntryHDF(fileID, archiveName, DENSITY_TYPE_UNDEFINED_const,&
iterTemp, starsIndexTemp, latharmsIndexTemp, structureIndexTemp,&
previousDensityIndex, jspinsTemp)
END IF
END IF
CALL writeDensityHDF(input, fileID, archiveName, densityType, previousDensityIndex,&
currentStarsIndex, currentLatharmsIndex, currentStructureIndex,&
iter+relCdnIndex,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
IF(l_storeIndices) THEN
CALL writeHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,&
currentStructureIndex,currentDensityIndex)
currentStructureIndex,readDensityIndex,lastDensityIndex)
END IF
CALL closeCDN_HDF(fileID)
......@@ -485,7 +502,8 @@ MODULE m_cdn_io
INTEGER(HID_T) :: fileID
#endif
INTEGER :: currentStarsIndex,currentLatharmsIndex
INTEGER :: currentStructureIndex,currentDensityIndex
INTEGER :: currentStructureIndex
INTEGER :: readDensityIndex, lastDensityIndex
CALL getMode(mode)
......@@ -493,7 +511,8 @@ MODULE m_cdn_io
#ifdef CPP_HDF
l_exist = isCoreDensityPresentHDF()
IF (l_exist) THEN
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
CALL readCoreDensityHDF(fileID,input,atoms,dimension,rhcs,tecs,qints)
CALL closeCDN_HDF(fileID)
RETURN
......@@ -554,13 +573,15 @@ MODULE m_cdn_io
INTEGER(HID_T) :: fileID
#endif
INTEGER :: currentStarsIndex,currentLatharmsIndex
INTEGER :: currentStructureIndex,currentDensityIndex
INTEGER :: currentStructureIndex
INTEGER :: readDensityIndex, lastDensityIndex
CALL getMode(mode)
IF(mode.EQ.CDN_HDF5_MODE) THEN
#ifdef CPP_HDF
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
CALL writeCoreDensityHDF(fileID,input,atoms,dimension,rhcs,tecs,qints)
CALL closeCDN_HDF(fileID)
#endif
......
......@@ -24,12 +24,15 @@ MODULE m_cdnpot_io_hdf
PUBLIC writeCoreDensityHDF, readCoreDensityHDF
PUBLIC writeHeaderData
PUBLIC isCoreDensityPresentHDF, isDensityEntryPresentHDF
PUBLIC peekDensityEntryHDF
#endif
PUBLIC DENSITY_TYPE_UNDEFINED_const
PUBLIC DENSITY_TYPE_IN_const, DENSITY_TYPE_OUT_const
PUBLIC DENSITY_TYPE_NOCO_IN_const, DENSITY_TYPE_NOCO_OUT_const
PUBLIC DENSITY_TYPE_PRECOND_const
INTEGER, PARAMETER :: DENSITY_TYPE_UNDEFINED_const = 0
INTEGER, PARAMETER :: DENSITY_TYPE_IN_const = 1
INTEGER, PARAMETER :: DENSITY_TYPE_OUT_const = 2
INTEGER, PARAMETER :: DENSITY_TYPE_NOCO_IN_const = 3
......@@ -40,10 +43,12 @@ MODULE m_cdnpot_io_hdf
#ifdef CPP_HDF
SUBROUTINE openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
SUBROUTINE openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
INTEGER(HID_T), INTENT(OUT) :: fileID
INTEGER, INTENT(OUT) :: currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex
INTEGER, INTENT(OUT) :: currentStarsIndex,currentLatharmsIndex,currentStructureIndex
INTEGER, INTENT(OUT) :: readDensityIndex,lastDensityIndex
INTEGER(HID_T) :: generalGroupID
INTEGER :: hdfError
......@@ -52,7 +57,8 @@ MODULE m_cdnpot_io_hdf
currentStarsIndex = 0
currentLatharmsIndex = 0
currentStructureIndex = 0
currentDensityIndex = 0
readDensityIndex = 0
lastDensityIndex = 0
INQUIRE(FILE='cdn.hdf',EXIST=l_exist)
IF(l_exist) THEN ! only open file
......@@ -63,7 +69,8 @@ MODULE m_cdnpot_io_hdf
CALL io_read_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
CALL io_read_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
CALL io_read_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
CALL io_read_attint0(generalGroupID,'currentDensityIndex',currentDensityIndex)
CALL io_read_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
CALL io_read_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
CALL h5gclose_f(generalGroupID, hdfError)
ELSE ! create file
......@@ -74,7 +81,8 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
CALL io_write_attint0(generalGroupID,'currentDensityIndex',currentDensityIndex)
CALL io_write_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
CALL io_write_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
CALL h5gclose_f(generalGroupID, hdfError)
END IF
......@@ -92,13 +100,15 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE closeCDN_HDF
SUBROUTINE writeHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
SUBROUTINE writeHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: currentStarsIndex
INTEGER, INTENT(IN) :: currentLatharmsIndex
INTEGER, INTENT(IN) :: currentStructureIndex
INTEGER, INTENT(IN) :: currentDensityIndex
INTEGER, INTENT(IN) :: readDensityIndex
INTEGER, INTENT(IN) :: lastDensityIndex
INTEGER(HID_T) :: generalGroupID
INTEGER :: hdfError
......@@ -108,7 +118,8 @@ MODULE m_cdnpot_io_hdf
CALL io_write_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
CALL io_write_attint0(generalGroupID,'currentDensityIndex',currentDensityIndex)
CALL io_write_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
CALL io_write_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
CALL h5gclose_f(generalGroupID, hdfError)
......@@ -1020,13 +1031,13 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE readStructureHDF
SUBROUTINE writeDensityHDF(input, fileID, archiveName, densityType, lastDensityIndex,&
SUBROUTINE writeDensityHDF(input, fileID, archiveName, densityType, previousDensityIndex,&
starsIndex, latharmsIndex, structureIndex,&
iter,fr,fpw,fz,fzxy,cdom,cdomvz,cdomvxy)
TYPE(t_input), INTENT(IN) :: input
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: densityType, lastDensityIndex
INTEGER, INTENT(IN) :: densityType, previousDensityIndex
INTEGER, INTENT(IN) :: starsIndex, latharmsIndex, structureIndex
CHARACTER(LEN=*), INTENT(IN) :: archiveName
......@@ -1113,7 +1124,7 @@ MODULE m_cdnpot_io_hdf
IF(l_exist) THEN
CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
CALL io_write_attint0(archiveID,'lastDensityIndex',lastDensityIndex)
CALL io_write_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
CALL io_write_attint0(archiveID,'starsIndex',starsIndex)
CALL io_write_attint0(archiveID,'latharmsIndex',latharmsIndex)
CALL io_write_attint0(archiveID,'structureIndex',structureIndex)
......@@ -1243,7 +1254,7 @@ MODULE m_cdnpot_io_hdf
ELSE
CALL h5gcreate_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
CALL io_write_attint0(archiveID,'lastDensityIndex',lastDensityIndex)
CALL io_write_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
CALL io_write_attint0(archiveID,'starsIndex',starsIndex)
CALL io_write_attint0(archiveID,'latharmsIndex',latharmsIndex)
CALL io_write_attint0(archiveID,'structureIndex',structureIndex)
......@@ -1339,7 +1350,7 @@ MODULE m_cdnpot_io_hdf
COMPLEX, INTENT (OUT) :: cdom(:), cdomvz(:,:), cdomvxy(:,:,:)
INTEGER :: starsIndex, latharmsIndex, structureIndex
INTEGER :: lastDensityIndex, jspins
INTEGER :: previousDensityIndex, jspins
INTEGER :: ntype,jmtd,nmzd,nmzxyd,nlhd,ng3,ng2
INTEGER :: nmz, nvac, od_nq2, nmzxy
INTEGER :: localDensityType
......@@ -1399,7 +1410,7 @@ MODULE m_cdnpot_io_hdf
CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_read_attint0(archiveID,'lastDensityIndex',lastDensityIndex)
CALL io_read_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
CALL io_read_attint0(archiveID,'starsIndex',starsIndex)
CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndex)
CALL io_read_attint0(archiveID,'structureIndex',structureIndex)
......@@ -1490,6 +1501,80 @@ MODULE m_cdnpot_io_hdf
END SUBROUTINE readDensityHDF
SUBROUTINE peekDensityEntryHDF(fileID, archiveName, densityType,&
iter, starsIndex, latharmsIndex, structureIndex,&
previousDensityIndex, jspins)
INTEGER(HID_T), INTENT(IN) :: fileID
INTEGER, INTENT(IN) :: densityType
CHARACTER(LEN=*), INTENT(IN) :: archiveName
INTEGER, INTENT (OUT) :: iter
INTEGER,INTENT(OUT) :: starsIndex, latharmsIndex, structureIndex
INTEGER,INTENT(OUT) :: previousDensityIndex, jspins
INTEGER :: localDensityType
LOGICAL :: l_exist
INTEGER(HID_T) :: archiveID, groupID
INTEGER :: hdfError
CHARACTER(LEN=30) :: groupName, densityTypeName
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")
END IF
localDensityType = densityType
SELECT CASE (densityType)
CASE(DENSITY_TYPE_UNDEFINED_const)
densityTypeName = ''
CASE(DENSITY_TYPE_IN_const)
densityTypeName = '/in'
CASE(DENSITY_TYPE_OUT_const)
densityTypeName = '/out'
CASE(DENSITY_TYPE_NOCO_IN_const)
densityTypeName = '/noco_in'
groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF(.NOT.l_exist) THEN
localDensityType = DENSITY_TYPE_IN_const
densityTypeName = '/in'
END IF
CASE(DENSITY_TYPE_NOCO_OUT_const)
densityTypeName = '/noco_out'
groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF(.NOT.l_exist) THEN
localDensityType = DENSITY_TYPE_OUT_const
densityTypeName = '/out'
END IF
CASE(DENSITY_TYPE_PRECOND_const)
densityTypeName = '/precond'
CASE DEFAULT
CALL juDFT_error("Unknown density type selected",calledby ="writeDensityHDF")
END SELECT
groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
IF(.NOT.l_exist) THEN
CALL juDFT_error('density entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readDensityHDF")
END IF
CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
CALL io_read_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
CALL io_read_attint0(archiveID,'starsIndex',starsIndex)
CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndex)
CALL io_read_attint0(archiveID,'structureIndex',structureIndex)
CALL io_read_attint0(archiveID,'spins',jspins)
CALL io_read_attint0(archiveID,'iter',iter)
CALL h5gclose_f(groupID, hdfError)
CALL h5gclose_f(archiveID, hdfError)
END SUBROUTINE peekDensityEntryHDF
SUBROUTINE writeCoreDensityHDF(fileID,input,atoms,dimension,rhcs,tecs,qints)
TYPE(t_atoms), INTENT(IN) :: atoms
......@@ -1624,7 +1709,8 @@ MODULE m_cdnpot_io_hdf
INTEGER(HID_T) :: fileID
INTEGER :: currentStarsIndex,currentLatharmsIndex
INTEGER :: currentStructureIndex,currentDensityIndex
INTEGER :: currentStructureIndex
INTEGER :: readDensityIndex, lastDensityIndex
LOGICAL :: l_exist
INQUIRE(FILE='cdn.hdf',EXIST=l_exist)
......@@ -1632,7 +1718,8 @@ MODULE m_cdnpot_io_hdf
isCoreDensityPresentHDF = .FALSE.
RETURN
END IF
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,currentDensityIndex)
CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
readDensityIndex,lastDensityIndex)
isCoreDensityPresentHDF = io_groupexists(fileID,'/cdnc')
CALL closeCDN_HDF(fileID)
END FUNCTION
......@@ -1655,6 +1742,8 @@ MODULE m_cdnpot_io_hdf
localDensityType = densityType
SELECT CASE (densityType)
CASE(DENSITY_TYPE_UNDEFINED_const)
densityTypeName = ''
CASE(DENSITY_TYPE_IN_const)
densityTypeName = '/in'
CASE(DENSITY_TYPE_OUT_const)
......
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