LCOV - code coverage report
Current view: top level - io - cdnpot_io_hdf.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 1376 1824 75.4 %
Date: 2019-09-08 04:53:50 Functions: 21 27 77.8 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2017 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             : MODULE m_cdnpot_io_hdf
       8             : 
       9             :    USE m_constants
      10             :    USE m_types
      11             :    USE m_juDFT
      12             : #ifdef CPP_HDF
      13             :    USE hdf5
      14             :    USE m_hdf_tools
      15             : #endif
      16             :    IMPLICIT NONE
      17             : 
      18             :    PRIVATE
      19             : #ifdef CPP_HDF
      20             :    PUBLIC openCDN_HDF, openPOT_HDF, closeCDNPOT_HDF
      21             :    PUBLIC writeStarsHDF, readStarsHDF, peekStarsHDF
      22             :    PUBLIC writeLatharmsHDF, readLatharmsHDF, peekLatharmsHDF
      23             :    PUBLIC writeStructureHDF, readStructureHDF
      24             :    PUBLIC writeStepfunctionHDF, readStepfunctionHDF, peekStepfunctionHDF
      25             :    PUBLIC writeDensityHDF, readDensityHDF
      26             :    PUBLIC writePotentialHDF, readPotentialHDF
      27             :    PUBLIC writeCoreDensityHDF, readCoreDensityHDF
      28             :    PUBLIC writeCDNHeaderData, writePOTHeaderData
      29             :    PUBLIC isCoreDensityPresentHDF, deleteDensityEntryHDF
      30             :    PUBLIC isDensityEntryPresentHDF, isPotentialEntryPresentHDF
      31             :    PUBLIC peekDensityEntryHDF
      32             : #endif
      33             : 
      34             :    PUBLIC DENSITY_TYPE_UNDEFINED_const
      35             :    PUBLIC DENSITY_TYPE_IN_const, DENSITY_TYPE_OUT_const
      36             :    PUBLIC DENSITY_TYPE_NOCO_IN_const, DENSITY_TYPE_NOCO_OUT_const
      37             :    PUBLIC DENSITY_TYPE_PRECOND_const
      38             :    PUBLIC POTENTIAL_TYPE_IN_const, POTENTIAL_TYPE_OUT_const
      39             : 
      40             :    INTEGER,          PARAMETER :: DENSITY_TYPE_UNDEFINED_const = 0
      41             :    INTEGER,          PARAMETER :: DENSITY_TYPE_IN_const = 1
      42             :    INTEGER,          PARAMETER :: DENSITY_TYPE_OUT_const = 2
      43             :    INTEGER,          PARAMETER :: DENSITY_TYPE_NOCO_IN_const = 3
      44             :    INTEGER,          PARAMETER :: DENSITY_TYPE_NOCO_OUT_const = 4
      45             :    INTEGER,          PARAMETER :: DENSITY_TYPE_PRECOND_const = 5
      46             : 
      47             :    INTEGER,          PARAMETER :: POTENTIAL_TYPE_IN_const = 1
      48             :    INTEGER,          PARAMETER :: POTENTIAL_TYPE_OUT_const = 2
      49             : 
      50             :    INTEGER,          PARAMETER :: FILE_FORMAT_VERSION_const = 29
      51             : 
      52             :    CONTAINS
      53             : 
      54             : #ifdef CPP_HDF
      55             : 
      56         689 :    SUBROUTINE openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
      57             :                           currentStepfunctionIndex,readDensityIndex,lastDensityIndex,inFilename)
      58             : 
      59             :       INTEGER(HID_T), INTENT(OUT) :: fileID
      60             :       INTEGER, INTENT(OUT) :: currentStarsIndex,currentLatharmsIndex,currentStructureIndex
      61             :       INTEGER, INTENT(OUT) :: currentStepfunctionIndex, readDensityIndex,lastDensityIndex
      62             : 
      63             :       CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: inFilename
      64             : 
      65             :       INTEGER(HID_T) :: generalGroupID
      66             :       INTEGER        :: hdfError, fileFormatVersion
      67             :       LOGICAL        :: l_exist
      68             :       CHARACTER(LEN=30) :: filename
      69             : 
      70         689 :       currentStarsIndex = 0
      71         689 :       currentLatharmsIndex = 0
      72         689 :       currentStructureIndex = 0
      73         689 :       currentStepfunctionIndex = 0
      74         689 :       readDensityIndex = 0
      75         689 :       lastDensityIndex = 0
      76         689 :       fileFormatVersion = 0
      77             : 
      78         689 :       filename = 'cdn.hdf'
      79         689 :       IF(PRESENT(inFilename)) filename = TRIM(ADJUSTL(inFilename))//'.hdf'
      80             : 
      81         689 :       INQUIRE(FILE=TRIM(ADJUSTL(filename)),EXIST=l_exist)
      82         689 :       IF(l_exist) THEN ! only open file
      83         661 :          CALL h5fopen_f(TRIM(ADJUSTL(filename)), H5F_ACC_RDWR_F, fileID, hdfError, H5P_DEFAULT_F)
      84             : 
      85         661 :          CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
      86             :          ! read in primary attributes from the header '/general'
      87         661 :          CALL io_read_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
      88         661 :          CALL io_read_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
      89         661 :          CALL io_read_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
      90         661 :          CALL io_read_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
      91         661 :          CALL io_read_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
      92         661 :          CALL io_read_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
      93         661 :          CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
      94             : 
      95         661 :          CALL h5gclose_f(generalGroupID, hdfError)
      96         661 :          IF(fileFormatVersion.GT.FILE_FORMAT_VERSION_const) THEN
      97           0 :             WRITE(*,'(a,i4)') TRIM(ADJUSTL(filename))//' has file format version ', fileFormatVersion
      98           0 :             CALL juDFT_error(TRIM(ADJUSTL(filename))//' file format not readable.' ,calledby ="openCDN_HDF")
      99             :          END IF
     100             :       ELSE ! create file
     101          28 :          CALL h5fcreate_f(TRIM(ADJUSTL(filename)), H5F_ACC_TRUNC_F, fileID, hdfError, H5P_DEFAULT_F, H5P_DEFAULT_F)
     102             : 
     103          28 :          CALL h5gcreate_f(fileID, '/general', generalGroupID, hdfError)
     104             :          ! write initial values to primary attributes in the header '/general'
     105          28 :          CALL io_write_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
     106          28 :          CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
     107          28 :          CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
     108          28 :          CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
     109          28 :          CALL io_write_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
     110          28 :          CALL io_write_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
     111          28 :          CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
     112             : 
     113          28 :          CALL h5gclose_f(generalGroupID, hdfError)
     114             :       END IF
     115             : 
     116        1378 :    END SUBROUTINE openCDN_HDF
     117             : 
     118             : 
     119           0 :    SUBROUTINE openPOT_HDF(fileID,currentStarsIndex,currentLatharmsIndex,&
     120             :                           currentStructureIndex,currentStepfunctionIndex)
     121             : 
     122             :       INTEGER(HID_T), INTENT(OUT) :: fileID
     123             :       INTEGER, INTENT(OUT) :: currentStarsIndex,currentLatharmsIndex
     124             :       INTEGER, INTENT(OUT) :: currentStructureIndex, currentStepfunctionIndex
     125             : 
     126             :       INTEGER(HID_T) :: generalGroupID
     127             :       INTEGER        :: hdfError, fileFormatVersion
     128             :       LOGICAL        :: l_exist
     129             : 
     130           0 :       currentStarsIndex = 0
     131           0 :       currentLatharmsIndex = 0
     132           0 :       currentStructureIndex = 0
     133           0 :       currentStepfunctionIndex = 0
     134           0 :       fileFormatVersion = 0
     135             : 
     136           0 :       INQUIRE(FILE='pot.hdf',EXIST=l_exist)
     137           0 :       IF(l_exist) THEN ! only open file
     138           0 :          CALL h5fopen_f('pot.hdf', H5F_ACC_RDWR_F, fileID, hdfError, H5P_DEFAULT_F)
     139             : 
     140           0 :          CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
     141             :          ! read in primary attributes from the header '/general'
     142           0 :          CALL io_read_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
     143           0 :          CALL io_read_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
     144           0 :          CALL io_read_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
     145           0 :          CALL io_read_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
     146           0 :          CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
     147             : 
     148           0 :          CALL h5gclose_f(generalGroupID, hdfError)
     149           0 :          IF(fileFormatVersion.NE.FILE_FORMAT_VERSION_const) THEN
     150           0 :             WRITE(*,'(a,i4)') 'pot.hdf has file format version ', fileFormatVersion
     151           0 :             CALL juDFT_error('pot.hdf file format not readable.' ,calledby ="openPOT_HDF")
     152             :          END IF
     153             :       ELSE ! create file
     154           0 :          CALL h5fcreate_f('pot.hdf', H5F_ACC_TRUNC_F, fileID, hdfError, H5P_DEFAULT_F, H5P_DEFAULT_F)
     155             : 
     156           0 :          CALL h5gcreate_f(fileID, '/general', generalGroupID, hdfError)
     157             :          ! write initial values to primary attributes in the header '/general'
     158           0 :          CALL io_write_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
     159           0 :          CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
     160           0 :          CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
     161           0 :          CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
     162           0 :          CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
     163             : 
     164           0 :          CALL h5gclose_f(generalGroupID, hdfError)
     165             :       END IF
     166             : 
     167           0 :    END SUBROUTINE openPOT_HDF
     168             : 
     169         687 :    SUBROUTINE closeCDNPOT_HDF(fileID)
     170             : 
     171             :       INTEGER(HID_T), INTENT(IN) :: fileID
     172             : 
     173             :       INTEGER hdfError
     174             : 
     175         689 :       CALL h5fclose_f(fileID, hdfError)
     176             : 
     177         687 :    END SUBROUTINE closeCDNPOT_HDF
     178             : 
     179         271 :    SUBROUTINE writeCDNHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
     180             :                                  currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
     181             : 
     182             :       INTEGER(HID_T), INTENT(IN) :: fileID
     183             :       INTEGER, INTENT(IN)        :: currentStarsIndex
     184             :       INTEGER, INTENT(IN)        :: currentLatharmsIndex
     185             :       INTEGER, INTENT(IN)        :: currentStructureIndex
     186             :       INTEGER, INTENT(IN)        :: currentStepfunctionIndex
     187             :       INTEGER, INTENT(IN)        :: readDensityIndex
     188             :       INTEGER, INTENT(IN)        :: lastDensityIndex
     189             : 
     190             :       INTEGER(HID_T) :: generalGroupID
     191             :       INTEGER        :: hdfError
     192             : 
     193         271 :       CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
     194             : 
     195         271 :       CALL io_write_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
     196         271 :       CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
     197         271 :       CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
     198         271 :       CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
     199         271 :       CALL io_write_attint0(generalGroupID,'readDensityIndex',readDensityIndex)
     200         271 :       CALL io_write_attint0(generalGroupID,'lastDensityIndex',lastDensityIndex)
     201         271 :       CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
     202             : 
     203         271 :       CALL h5gclose_f(generalGroupID, hdfError)
     204             : 
     205         271 :    END SUBROUTINE writeCDNHeaderData
     206             : 
     207           0 :    SUBROUTINE writePOTHeaderData(fileID,currentStarsIndex,currentLatharmsIndex,&
     208             :                                  currentStructureIndex,currentStepfunctionIndex)
     209             : 
     210             :       INTEGER(HID_T), INTENT(IN) :: fileID
     211             :       INTEGER, INTENT(IN)        :: currentStarsIndex
     212             :       INTEGER, INTENT(IN)        :: currentLatharmsIndex
     213             :       INTEGER, INTENT(IN)        :: currentStructureIndex
     214             :       INTEGER, INTENT(IN)        :: currentStepfunctionIndex
     215             : 
     216             :       INTEGER(HID_T) :: generalGroupID
     217             :       INTEGER        :: hdfError
     218             : 
     219           0 :       CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
     220             : 
     221           0 :       CALL io_write_attint0(generalGroupID,'currentStarsIndex',currentStarsIndex)
     222           0 :       CALL io_write_attint0(generalGroupID,'currentLatharmsIndex',currentLatharmsIndex)
     223           0 :       CALL io_write_attint0(generalGroupID,'currentStructureIndex',currentStructureIndex)
     224           0 :       CALL io_write_attint0(generalGroupID,'currentStepfunctionIndex',currentStepfunctionIndex)
     225           0 :       CALL io_write_attint0(generalGroupID,'fileFormatVersion',FILE_FORMAT_VERSION_const)
     226             : 
     227           0 :       CALL h5gclose_f(generalGroupID, hdfError)
     228             : 
     229           0 :    END SUBROUTINE writePOTHeaderData
     230             : 
     231          28 :    SUBROUTINE writeStarsHDF(fileID, starsIndex, structureIndex, stars, l_checkBroyd)
     232             : 
     233             :       INTEGER(HID_T), INTENT(IN) :: fileID
     234             :       INTEGER,        INTENT(IN) :: starsIndex, structureIndex
     235             :       TYPE(t_stars),  INTENT(IN) :: stars
     236             :       LOGICAL,        INTENT(IN) :: l_CheckBroyd
     237             : 
     238             :       INTEGER(HID_T)            :: groupID
     239             :       INTEGER                   :: hdfError, ft2_gf_dim, dimsInt(7)
     240             :       CHARACTER(LEN=30)         :: groupName
     241             :       INTEGER(HSIZE_T)          :: dims(7)
     242             :       LOGICAL        :: l_exist
     243             : 
     244             :       INTEGER(HID_T)                   :: kv3SpaceID, kv3SetID
     245             :       INTEGER(HID_T)                   :: kv2SpaceID, kv2SetID
     246             :       INTEGER(HID_T)                   :: sk3SpaceID, sk3SetID
     247             :       INTEGER(HID_T)                   :: sk2SpaceID, sk2SetID
     248             :       INTEGER(HID_T)                   :: igSpaceID, igSetID
     249             :       INTEGER(HID_T)                   :: ig2SpaceID, ig2SetID
     250             :       INTEGER(HID_T)                   :: nstrSpaceID, nstrSetID
     251             :       INTEGER(HID_T)                   :: nstr2SpaceID, nstr2SetID
     252             :       INTEGER(HID_T)                   :: phi2SpaceID, phi2SetID
     253             :       INTEGER(HID_T)                   :: rgphsSpaceID, rgphsSetID
     254             :       INTEGER(HID_T)                   :: igfftSpaceID, igfftSetID
     255             :       INTEGER(HID_T)                   :: igfft2SpaceID, igfft2SetID
     256             :       INTEGER(HID_T)                   :: pgfftSpaceID, pgfftSetID
     257             :       INTEGER(HID_T)                   :: pgfft2SpaceID, pgfft2SetID
     258             :       INTEGER(HID_T)                   :: ft2_gfxSpaceID, ft2_gfxSetID
     259             :       INTEGER(HID_T)                   :: ft2_gfySpaceID, ft2_gfySetID
     260             : 
     261          28 :       WRITE(groupname,'(a,i0)') '/stars-', starsIndex
     262             : 
     263          28 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     264             : 
     265          28 :       IF (l_exist) THEN
     266           0 :          CALL juDFT_error('stars entry '//TRIM(ADJUSTL(groupName))//' already exists.' ,calledby ="writeStarsHDF")
     267             :       END IF
     268             : 
     269          28 :       INQUIRE(FILE='broyd',EXIST=l_exist)
     270          28 :       IF (.NOT.l_exist) INQUIRE(FILE='broyd.7',EXIST=l_exist)
     271          28 :       IF (l_exist.AND.l_CheckBroyd) CALL juDFT_warn('Stars change but broyden files detected!')
     272             : 
     273          28 :       CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     274             : 
     275          28 :       ft2_gf_dim = SIZE(stars%ft2_gfx,1)
     276             : 
     277          28 :       CALL io_write_attint0(groupID,'structureIndex',structureIndex)
     278             : 
     279          28 :       CALL io_write_attreal0(groupID,'gmax',stars%gmax)
     280          28 :       CALL io_write_attreal0(groupID,'gmaxInit',stars%gmaxInit)
     281          28 :       CALL io_write_attint0(groupID,'ng3',stars%ng3)
     282          28 :       CALL io_write_attint0(groupID,'ng2',stars%ng2)
     283          28 :       CALL io_write_attint0(groupID,'mx1',stars%mx1)
     284          28 :       CALL io_write_attint0(groupID,'mx2',stars%mx2)
     285          28 :       CALL io_write_attint0(groupID,'mx3',stars%mx3)
     286          28 :       CALL io_write_attint0(groupID,'kimax',stars%kimax)
     287          28 :       CALL io_write_attint0(groupID,'kimax2',stars%kimax2)
     288          28 :       CALL io_write_attint0(groupID,'kq1_fft',stars%kq1_fft)
     289          28 :       CALL io_write_attint0(groupID,'kq2_fft',stars%kq2_fft)
     290          28 :       CALL io_write_attint0(groupID,'kq3_fft',stars%kq3_fft)
     291          28 :       CALL io_write_attint0(groupID,'kmxq_fft',stars%kmxq_fft)
     292          28 :       CALL io_write_attint0(groupID,'kxc1_fft',stars%kxc1_fft)
     293          28 :       CALL io_write_attint0(groupID,'kxc2_fft',stars%kxc2_fft)
     294          28 :       CALL io_write_attint0(groupID,'kxc3_fft',stars%kxc3_fft)
     295          28 :       CALL io_write_attint0(groupID,'ng3_fft',stars%ng3_fft)
     296          28 :       CALL io_write_attint0(groupID,'kmxxc_fft',stars%kmxxc_fft)
     297          28 :       CALL io_write_attint0(groupID,'nxc3_fft',stars%nxc3_fft)
     298          28 :       CALL io_write_attint0(groupID,'ft2_gf_dim',ft2_gf_dim)
     299             : 
     300          28 :       dims(:2)=(/3,stars%ng3/)
     301         224 :       dimsInt=dims
     302          28 :       CALL h5screate_simple_f(2,dims(:2),kv3SpaceID,hdfError)
     303          28 :       CALL h5dcreate_f(groupID, "kv3", H5T_NATIVE_INTEGER, kv3SpaceID, kv3SetID, hdfError)
     304          28 :       CALL h5sclose_f(kv3SpaceID,hdfError)
     305          28 :       CALL io_write_integer2(kv3SetID,(/1,1/),dimsInt(:2),stars%kv3)
     306          28 :       CALL h5dclose_f(kv3SetID, hdfError)
     307             : 
     308          28 :       dims(:2)=(/2,stars%ng2/)
     309         224 :       dimsInt=dims
     310          28 :       CALL h5screate_simple_f(2,dims(:2),kv2SpaceID,hdfError)
     311          28 :       CALL h5dcreate_f(groupID, "kv2", H5T_NATIVE_INTEGER, kv2SpaceID, kv2SetID, hdfError)
     312          28 :       CALL h5sclose_f(kv2SpaceID,hdfError)
     313          28 :       CALL io_write_integer2(kv2SetID,(/1,1/),dimsInt(:2),stars%kv2)
     314          28 :       CALL h5dclose_f(kv2SetID, hdfError)
     315             : 
     316          28 :       dims(:1)=(/stars%ng3/)
     317         224 :       dimsInt=dims
     318          28 :       CALL h5screate_simple_f(1,dims(:1),sk3SpaceID,hdfError)
     319          28 :       CALL h5dcreate_f(groupID, "sk3", H5T_NATIVE_DOUBLE, sk3SpaceID, sk3SetID, hdfError)
     320          28 :       CALL h5sclose_f(sk3SpaceID,hdfError)
     321          28 :       CALL io_write_real1(sk3SetID,(/1/),dimsInt(:1),stars%sk3)
     322          28 :       CALL h5dclose_f(sk3SetID, hdfError)
     323             : 
     324          28 :       dims(:1)=(/stars%ng2/)
     325         224 :       dimsInt=dims
     326          28 :       CALL h5screate_simple_f(1,dims(:1),sk2SpaceID,hdfError)
     327          28 :       CALL h5dcreate_f(groupID, "sk2", H5T_NATIVE_DOUBLE, sk2SpaceID, sk2SetID, hdfError)
     328          28 :       CALL h5sclose_f(sk2SpaceID,hdfError)
     329          28 :       CALL io_write_real1(sk2SetID,(/1/),dimsInt(:1),stars%sk2)
     330          28 :       CALL h5dclose_f(sk2SetID, hdfError)
     331             : 
     332          28 :       dims(:3)=(/2*stars%mx1+1,2*stars%mx2+1,2*stars%mx3+1/)
     333         224 :       dimsInt=dims
     334          28 :       CALL h5screate_simple_f(3,dims(:3),igSpaceID,hdfError)
     335          28 :       CALL h5dcreate_f(groupID, "ig", H5T_NATIVE_INTEGER, igSpaceID, igSetID, hdfError)
     336          28 :       CALL h5sclose_f(igSpaceID,hdfError)
     337          28 :       CALL io_write_integer3(igSetID,(/1,1,1/),dimsInt(:3),stars%ig)
     338          28 :       CALL h5dclose_f(igSetID, hdfError)
     339             : 
     340          28 :       dims(:1)=(/stars%ng3/)
     341         224 :       dimsInt=dims
     342          28 :       CALL h5screate_simple_f(1,dims(:1),ig2SpaceID,hdfError)
     343          28 :       CALL h5dcreate_f(groupID, "ig2", H5T_NATIVE_INTEGER, ig2SpaceID, ig2SetID, hdfError)
     344          28 :       CALL h5sclose_f(ig2SpaceID,hdfError)
     345          28 :       CALL io_write_integer1(ig2SetID,(/1/),dimsInt(:1),stars%ig2)
     346          28 :       CALL h5dclose_f(ig2SetID, hdfError)
     347             : 
     348          28 :       dims(:1)=(/stars%ng3/)
     349         224 :       dimsInt=dims
     350          28 :       CALL h5screate_simple_f(1,dims(:1),nstrSpaceID,hdfError)
     351          28 :       CALL h5dcreate_f(groupID, "nstr", H5T_NATIVE_INTEGER, nstrSpaceID, nstrSetID, hdfError)
     352          28 :       CALL h5sclose_f(nstrSpaceID,hdfError)
     353          28 :       CALL io_write_integer1(nstrSetID,(/1/),dimsInt(:1),stars%nstr)
     354          28 :       CALL h5dclose_f(nstrSetID, hdfError)
     355             : 
     356          28 :       dims(:1)=(/stars%ng2/)
     357         224 :       dimsInt=dims
     358          28 :       CALL h5screate_simple_f(1,dims(:1),nstr2SpaceID,hdfError)
     359          28 :       CALL h5dcreate_f(groupID, "nstr2", H5T_NATIVE_INTEGER, nstr2SpaceID, nstr2SetID, hdfError)
     360          28 :       CALL h5sclose_f(nstr2SpaceID,hdfError)
     361          28 :       CALL io_write_integer1(nstr2SetID,(/1/),dimsInt(:1),stars%nstr2)
     362          28 :       CALL h5dclose_f(nstr2SetID, hdfError)
     363             : 
     364          28 :       dims(:1)=(/stars%ng2/)
     365         224 :       dimsInt=dims
     366          28 :       CALL h5screate_simple_f(1,dims(:1),phi2SpaceID,hdfError)
     367          28 :       CALL h5dcreate_f(groupID, "phi2", H5T_NATIVE_DOUBLE, phi2SpaceID, phi2SetID, hdfError)
     368          28 :       CALL h5sclose_f(phi2SpaceID,hdfError)
     369          28 :       CALL io_write_real1(phi2SetID,(/1/),dimsInt(:1),stars%phi2)
     370          28 :       CALL h5dclose_f(phi2SetID, hdfError)
     371             : 
     372          28 :       dims(:4)=(/2,2*stars%mx1+1,2*stars%mx2+1,2*stars%mx3+1/)
     373         224 :       dimsInt=dims
     374          28 :       CALL h5screate_simple_f(4,dims(:4),rgphsSpaceID,hdfError)
     375          28 :       CALL h5dcreate_f(groupID, "rgphs", H5T_NATIVE_DOUBLE, rgphsSpaceID, rgphsSetID, hdfError)
     376          28 :       CALL h5sclose_f(rgphsSpaceID,hdfError)
     377          28 :       CALL io_write_complex3(rgphsSetID,(/-1,1,1,1/),dimsInt(:4),stars%rgphs)
     378          28 :       CALL h5dclose_f(rgphsSetID, hdfError)
     379             : 
     380          28 :       dims(:2)=(/stars%kimax+1,2/)
     381         224 :       dimsInt=dims
     382          28 :       CALL h5screate_simple_f(2,dims(:2),igfftSpaceID,hdfError)
     383          28 :       CALL h5dcreate_f(groupID, "igfft", H5T_NATIVE_INTEGER, igfftSpaceID, igfftSetID, hdfError)
     384          28 :       CALL h5sclose_f(igfftSpaceID,hdfError)
     385          28 :       CALL io_write_integer2(igfftSetID,(/1,1/),dimsInt(:2),stars%igfft(0:stars%kimax,:))
     386          28 :       CALL h5dclose_f(igfftSetID, hdfError)
     387             : 
     388          28 :       dims(:2)=(/stars%kimax2+1,2/)
     389         224 :       dimsInt=dims
     390          28 :       CALL h5screate_simple_f(2,dims(:2),igfft2SpaceID,hdfError)
     391          28 :       CALL h5dcreate_f(groupID, "igfft2", H5T_NATIVE_INTEGER, igfft2SpaceID, igfft2SetID, hdfError)
     392          28 :       CALL h5sclose_f(igfft2SpaceID,hdfError)
     393          28 :       CALL io_write_integer2(igfft2SetID,(/1,1/),dimsInt(:2),stars%igfft2(0:stars%kimax2,:))
     394          28 :       CALL h5dclose_f(igfft2SetID, hdfError)
     395             : 
     396          28 :       dims(:2)=(/2,stars%kimax+1/)
     397         224 :       dimsInt=dims
     398          28 :       CALL h5screate_simple_f(2,dims(:2),pgfftSpaceID,hdfError)
     399          28 :       CALL h5dcreate_f(groupID, "pgfft", H5T_NATIVE_DOUBLE, pgfftSpaceID, pgfftSetID, hdfError)
     400          28 :       CALL h5sclose_f(pgfftSpaceID,hdfError)
     401          28 :       CALL io_write_complex1(pgfftSetID,(/-1,1/),dimsInt(:2),stars%pgfft(0:stars%kimax))
     402          28 :       CALL h5dclose_f(pgfftSetID, hdfError)
     403             : 
     404          28 :       dims(:2)=(/2,stars%kimax2+1/)
     405         224 :       dimsInt=dims
     406          28 :       CALL h5screate_simple_f(2,dims(:2),pgfft2SpaceID,hdfError)
     407          28 :       CALL h5dcreate_f(groupID, "pgfft2", H5T_NATIVE_DOUBLE, pgfft2SpaceID, pgfft2SetID, hdfError)
     408          28 :       CALL h5sclose_f(pgfft2SpaceID,hdfError)
     409          28 :       CALL io_write_complex1(pgfft2SetID,(/-1,1/),dimsInt(:2),stars%pgfft2(0:stars%kimax2))
     410          28 :       CALL h5dclose_f(pgfft2SetID, hdfError)
     411             : 
     412          28 :       dims(:1)=(/ft2_gf_dim/)
     413         224 :       dimsInt=dims
     414          28 :       CALL h5screate_simple_f(1,dims(:1),ft2_gfxSpaceID,hdfError)
     415          28 :       CALL h5dcreate_f(groupID, "ft2_gfx", H5T_NATIVE_DOUBLE, ft2_gfxSpaceID, ft2_gfxSetID, hdfError)
     416          28 :       CALL h5sclose_f(ft2_gfxSpaceID,hdfError)
     417          28 :       CALL io_write_real1(ft2_gfxSetID,(/1/),dimsInt(:1),stars%ft2_gfx)
     418          28 :       CALL h5dclose_f(ft2_gfxSetID, hdfError)
     419             : 
     420          28 :       dims(:1)=(/ft2_gf_dim/)
     421         224 :       dimsInt=dims
     422          28 :       CALL h5screate_simple_f(1,dims(:1),ft2_gfySpaceID,hdfError)
     423          28 :       CALL h5dcreate_f(groupID, "ft2_gfy", H5T_NATIVE_DOUBLE, ft2_gfySpaceID, ft2_gfySetID, hdfError)
     424          28 :       CALL h5sclose_f(ft2_gfySpaceID,hdfError)
     425          28 :       CALL io_write_real1(ft2_gfySetID,(/1/),dimsInt(:1),stars%ft2_gfy)
     426          28 :       CALL h5dclose_f(ft2_gfySetID, hdfError)
     427             : 
     428          28 :       CALL h5gclose_f(groupID, hdfError)
     429             : 
     430          28 :    END SUBROUTINE writeStarsHDF
     431             : 
     432         244 :    SUBROUTINE readStarsHDF(fileID, starsIndex, stars)
     433             : 
     434             :       INTEGER(HID_T), INTENT(IN)    :: fileID
     435             :       INTEGER,        INTENT(IN)    :: starsIndex
     436             :       TYPE(t_stars),  INTENT(INOUT) :: stars
     437             : 
     438             :       INTEGER(HID_T)            :: groupID
     439             :       INTEGER                   :: hdfError, ft2_gf_dim
     440             :       INTEGER                   :: dimsInt(7)
     441             :       CHARACTER(LEN=30)         :: groupName
     442             :       LOGICAL                   :: l_exist
     443             : 
     444             :       INTEGER(HID_T)                   :: kv3SetID
     445             :       INTEGER(HID_T)                   :: kv2SetID
     446             :       INTEGER(HID_T)                   :: sk3SetID
     447             :       INTEGER(HID_T)                   :: sk2SetID
     448             :       INTEGER(HID_T)                   :: igSetID
     449             :       INTEGER(HID_T)                   :: ig2SetID
     450             :       INTEGER(HID_T)                   :: nstrSetID
     451             :       INTEGER(HID_T)                   :: nstr2SetID
     452             :       INTEGER(HID_T)                   :: phi2SetID
     453             :       INTEGER(HID_T)                   :: rgphsSetID
     454             :       INTEGER(HID_T)                   :: igfftSetID
     455             :       INTEGER(HID_T)                   :: igfft2SetID
     456             :       INTEGER(HID_T)                   :: pgfftSetID
     457             :       INTEGER(HID_T)                   :: pgfft2SetID
     458             :       INTEGER(HID_T)                   :: ft2_gfxSetID
     459             :       INTEGER(HID_T)                   :: ft2_gfySetID
     460             : 
     461         244 :       WRITE(groupname,'(a,i0)') '/stars-', starsIndex
     462             : 
     463         244 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     464             : 
     465         244 :       IF (.NOT.l_exist) THEN
     466           0 :          CALL juDFT_error('stars entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readStarsHDF")
     467             :       END IF
     468             : 
     469         244 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     470             : 
     471         244 :       CALL io_read_attreal0(groupID,'gmax',stars%gmax)
     472         244 :       CALL io_read_attreal0(groupID,'gmaxInit',stars%gmaxInit)
     473         244 :       CALL io_read_attint0(groupID,'ng3',stars%ng3)
     474         244 :       CALL io_read_attint0(groupID,'ng2',stars%ng2)
     475         244 :       CALL io_read_attint0(groupID,'mx1',stars%mx1)
     476         244 :       CALL io_read_attint0(groupID,'mx2',stars%mx2)
     477         244 :       CALL io_read_attint0(groupID,'mx3',stars%mx3)
     478         244 :       CALL io_read_attint0(groupID,'kimax',stars%kimax)
     479         244 :       CALL io_read_attint0(groupID,'kimax2',stars%kimax2)
     480         244 :       CALL io_read_attint0(groupID,'kq1_fft',stars%kq1_fft)
     481         244 :       CALL io_read_attint0(groupID,'kq2_fft',stars%kq2_fft)
     482         244 :       CALL io_read_attint0(groupID,'kq3_fft',stars%kq3_fft)
     483         244 :       CALL io_read_attint0(groupID,'kmxq_fft',stars%kmxq_fft)
     484         244 :       CALL io_read_attint0(groupID,'kxc1_fft',stars%kxc1_fft)
     485         244 :       CALL io_read_attint0(groupID,'kxc2_fft',stars%kxc2_fft)
     486         244 :       CALL io_read_attint0(groupID,'kxc3_fft',stars%kxc3_fft)
     487         244 :       CALL io_read_attint0(groupID,'ng3_fft',stars%ng3_fft)
     488         244 :       CALL io_read_attint0(groupID,'kmxxc_fft',stars%kmxxc_fft)
     489         244 :       CALL io_read_attint0(groupID,'nxc3_fft',stars%nxc3_fft)
     490         244 :       CALL io_read_attint0(groupID,'ft2_gf_dim',ft2_gf_dim)
     491             : 
     492         244 :       IF(ALLOCATED(stars%kv3)) DEALLOCATE(stars%kv3)
     493         244 :       IF(ALLOCATED(stars%kv2)) DEALLOCATE(stars%kv2)
     494         244 :       IF(ALLOCATED(stars%sk3)) DEALLOCATE(stars%sk3)
     495         244 :       IF(ALLOCATED(stars%sk2)) DEALLOCATE(stars%sk2)
     496         244 :       IF(ALLOCATED(stars%ig)) DEALLOCATE(stars%ig)
     497         244 :       IF(ALLOCATED(stars%ig2)) DEALLOCATE(stars%ig2)
     498         244 :       IF(ALLOCATED(stars%nstr)) DEALLOCATE(stars%nstr)
     499         244 :       IF(ALLOCATED(stars%nstr2)) DEALLOCATE(stars%nstr2)
     500         244 :       IF(ALLOCATED(stars%phi2)) DEALLOCATE(stars%phi2)
     501         244 :       IF(ALLOCATED(stars%rgphs)) DEALLOCATE(stars%rgphs)
     502         244 :       IF(ALLOCATED(stars%igfft)) DEALLOCATE(stars%igfft)
     503         244 :       IF(ALLOCATED(stars%igfft2)) DEALLOCATE(stars%igfft2)
     504         244 :       IF(ALLOCATED(stars%pgfft)) DEALLOCATE(stars%pgfft)
     505         244 :       IF(ALLOCATED(stars%pgfft2)) DEALLOCATE(stars%pgfft2)
     506         244 :       IF(ALLOCATED(stars%ft2_gfx)) DEALLOCATE(stars%ft2_gfx)
     507         244 :       IF(ALLOCATED(stars%ft2_gfy)) DEALLOCATE(stars%ft2_gfy)
     508             : 
     509         244 :       ALLOCATE(stars%kv3(3,stars%ng3))
     510         244 :       ALLOCATE(stars%kv2(2,stars%ng2))
     511         244 :       ALLOCATE(stars%sk3(stars%ng3))
     512         244 :       ALLOCATE(stars%sk2(stars%ng2))
     513         244 :       ALLOCATE(stars%ig(-stars%mx1:stars%mx1,-stars%mx2:stars%mx2,-stars%mx3:stars%mx3))
     514         244 :       ALLOCATE(stars%ig2(stars%ng3))
     515         244 :       ALLOCATE(stars%nstr(stars%ng3))
     516         244 :       ALLOCATE(stars%nstr2(stars%ng2))
     517         244 :       ALLOCATE(stars%phi2(stars%ng2))
     518         244 :       ALLOCATE(stars%rgphs(-stars%mx1:stars%mx1,-stars%mx2:stars%mx2,-stars%mx3:stars%mx3))
     519         244 :       ALLOCATE(stars%igfft(0:stars%kimax,2))
     520         244 :       ALLOCATE(stars%igfft2(0:stars%kimax2,2))
     521         244 :       ALLOCATE(stars%pgfft(0:stars%kimax))
     522         244 :       ALLOCATE(stars%pgfft2(0:stars%kimax2))
     523         244 :       ALLOCATE(stars%ft2_gfx(0:ft2_gf_dim-1))
     524         244 :       ALLOCATE(stars%ft2_gfy(0:ft2_gf_dim-1))
     525             : 
     526         244 :       dimsInt(:2)=(/3,stars%ng3/)
     527         244 :       CALL h5dopen_f(groupID, 'kv3', kv3SetID, hdfError)
     528         244 :       CALL io_read_integer2(kv3SetID,(/1,1/),dimsInt(:2),stars%kv3)
     529         244 :       CALL h5dclose_f(kv3SetID, hdfError)
     530             : 
     531         244 :       dimsInt(:2)=(/2,stars%ng2/)
     532         244 :       CALL h5dopen_f(groupID, 'kv2', kv2SetID, hdfError)
     533         244 :       CALL io_read_integer2(kv2SetID,(/1,1/),dimsInt(:2),stars%kv2)
     534         244 :       CALL h5dclose_f(kv2SetID, hdfError)
     535             : 
     536         244 :       dimsInt(:1)=(/stars%ng3/)
     537         244 :       CALL h5dopen_f(groupID, 'sk3', sk3SetID, hdfError)
     538         244 :       CALL io_read_real1(sk3SetID,(/1/),dimsInt(:1),stars%sk3)
     539         244 :       CALL h5dclose_f(sk3SetID, hdfError)
     540             : 
     541         244 :       dimsInt(:1)=(/stars%ng2/)
     542         244 :       CALL h5dopen_f(groupID, 'sk2', sk2SetID, hdfError)
     543         244 :       CALL io_read_real1(sk2SetID,(/1/),dimsInt(:1),stars%sk2)
     544         244 :       CALL h5dclose_f(sk2SetID, hdfError)
     545             : 
     546         244 :       dimsInt(:3)=(/2*stars%mx1+1,2*stars%mx2+1,2*stars%mx3+1/)
     547         244 :       CALL h5dopen_f(groupID, 'ig', igSetID, hdfError)
     548         244 :       CALL io_read_integer3(igSetID,(/1,1,1/),dimsInt(:3),stars%ig)
     549         244 :       CALL h5dclose_f(igSetID, hdfError)
     550             : 
     551         244 :       dimsInt(:1)=(/stars%ng3/)
     552         244 :       CALL h5dopen_f(groupID, 'ig2', ig2SetID, hdfError)
     553         244 :       CALL io_read_integer1(ig2SetID,(/1/),dimsInt(:1),stars%ig2)
     554         244 :       CALL h5dclose_f(ig2SetID, hdfError)
     555             : 
     556         244 :       dimsInt(:1)=(/stars%ng3/)
     557         244 :       CALL h5dopen_f(groupID, 'nstr', nstrSetID, hdfError)
     558         244 :       CALL io_read_integer1(nstrSetID,(/1/),dimsInt(:1),stars%nstr)
     559         244 :       CALL h5dclose_f(nstrSetID, hdfError)
     560             : 
     561         244 :       dimsInt(:1)=(/stars%ng2/)
     562         244 :       CALL h5dopen_f(groupID, 'nstr2', nstr2SetID, hdfError)
     563         244 :       CALL io_read_integer1(nstr2SetID,(/1/),dimsInt(:1),stars%nstr2)
     564         244 :       CALL h5dclose_f(nstr2SetID, hdfError)
     565             : 
     566         244 :       dimsInt(:1)=(/stars%ng2/)
     567         244 :       CALL h5dopen_f(groupID, 'phi2', phi2SetID, hdfError)
     568         244 :       CALL io_read_real1(phi2SetID,(/1/),dimsInt(:1),stars%phi2)
     569         244 :       CALL h5dclose_f(phi2SetID, hdfError)
     570             : 
     571         244 :       dimsInt(:4)=(/2,2*stars%mx1+1,2*stars%mx2+1,2*stars%mx3+1/)
     572         244 :       CALL h5dopen_f(groupID, 'rgphs', rgphsSetID, hdfError)
     573         244 :       CALL io_read_complex3(rgphsSetID,(/-1,1,1,1/),dimsInt(:4),stars%rgphs)
     574         244 :       CALL h5dclose_f(rgphsSetID, hdfError)
     575             : 
     576         244 :       dimsInt(:2)=(/stars%kimax+1,2/)
     577         244 :       CALL h5dopen_f(groupID, 'igfft', igfftSetID, hdfError)
     578         244 :       CALL io_read_integer2(igfftSetID,(/1,1/),dimsInt(:2),stars%igfft(0:stars%kimax,:))
     579         244 :       CALL h5dclose_f(igfftSetID, hdfError)
     580             : 
     581         244 :       dimsInt(:2)=(/stars%kimax2+1,2/)
     582         244 :       CALL h5dopen_f(groupID, 'igfft2', igfft2SetID, hdfError)
     583         244 :       CALL io_read_integer2(igfft2SetID,(/1,1/),dimsInt(:2),stars%igfft2(0:stars%kimax2,:))
     584         244 :       CALL h5dclose_f(igfft2SetID, hdfError)
     585             : 
     586         244 :       dimsInt(:2)=(/2,stars%kimax+1/)
     587         244 :       CALL h5dopen_f(groupID, 'pgfft', pgfftSetID, hdfError)
     588         244 :       CALL io_read_complex1(pgfftSetID,(/-1,1/),dimsInt(:2),stars%pgfft(0:stars%kimax))
     589         244 :       CALL h5dclose_f(pgfftSetID, hdfError)
     590             : 
     591         244 :       dimsInt(:2)=(/2,stars%kimax2+1/)
     592         244 :       CALL h5dopen_f(groupID, 'pgfft2', pgfft2SetID, hdfError)
     593         244 :       CALL io_read_complex1(pgfft2SetID,(/-1,1/),dimsInt(:2),stars%pgfft2(0:stars%kimax2))
     594         244 :       CALL h5dclose_f(pgfft2SetID, hdfError)
     595             : 
     596         244 :       dimsInt(:1)=(/ft2_gf_dim/)
     597         244 :       CALL h5dopen_f(groupID, 'ft2_gfx', ft2_gfxSetID, hdfError)
     598         244 :       CALL io_read_real1(ft2_gfxSetID,(/1/),dimsInt(:1),stars%ft2_gfx)
     599         244 :       CALL h5dclose_f(ft2_gfxSetID, hdfError)
     600             : 
     601         244 :       dimsInt(:1)=(/ft2_gf_dim/)
     602         244 :       CALL h5dopen_f(groupID, 'ft2_gfy', ft2_gfySetID, hdfError)
     603         244 :       CALL io_read_real1(ft2_gfySetID,(/1/),dimsInt(:1),stars%ft2_gfy)
     604         244 :       CALL h5dclose_f(ft2_gfySetID, hdfError)
     605             : 
     606         244 :       CALL h5gclose_f(groupID, hdfError)
     607             : 
     608         244 :    END SUBROUTINE readStarsHDF
     609             : 
     610         233 :    SUBROUTINE peekStarsHDF(fileID, starsIndex, structureIndex)
     611             : 
     612             :       INTEGER(HID_T), INTENT(IN)    :: fileID
     613             :       INTEGER,        INTENT(IN)    :: starsIndex
     614             :       INTEGER,        INTENT(OUT)   :: structureIndex
     615             : 
     616             :       INTEGER(HID_T)            :: groupID
     617             :       INTEGER                   :: hdfError
     618             :       CHARACTER(LEN=30)         :: groupName
     619             :       LOGICAL                   :: l_exist
     620             : 
     621         233 :       WRITE(groupname,'(a,i0)') '/stars-', starsIndex
     622             : 
     623         233 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     624             : 
     625         233 :       IF (.NOT.l_exist) THEN
     626           0 :          CALL juDFT_error('stars entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readStarsHDF")
     627             :       END IF
     628             : 
     629         233 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     630         233 :       CALL io_read_attint0(groupID,'structureIndex',structureIndex)
     631         233 :       CALL h5gclose_f(groupID, hdfError)
     632             : 
     633         233 :    END SUBROUTINE peekStarsHDF
     634             : 
     635          28 :    SUBROUTINE writeStepfunctionHDF(fileID, stepfunctionIndex, starsIndex, structureIndex, stars, l_CheckBroyd)
     636             : 
     637             :       INTEGER(HID_T), INTENT(IN)    :: fileID
     638             :       INTEGER,        INTENT(IN)    :: stepfunctionIndex, starsIndex, structureIndex
     639             :       TYPE(t_stars),  INTENT(IN)    :: stars
     640             :       LOGICAL,        INTENT(IN)    :: l_CheckBroyd
     641             : 
     642             :       INTEGER                   :: ifftd
     643             : 
     644             :       INTEGER                   :: hdfError
     645             :       INTEGER(HID_T)            :: groupID
     646             :       INTEGER(HID_T)            :: ustepSpaceID, ustepSetID
     647             :       INTEGER(HID_T)            :: ufftSpaceID, ufftSetID
     648             :       CHARACTER(LEN=30)         :: groupName
     649             :       INTEGER(HSIZE_T)          :: dims(7)
     650             :       INTEGER                   :: dimsInt(7)
     651             :       LOGICAL                   :: l_exist
     652             : 
     653          28 :       WRITE(groupname,'(a,i0)') '/stepfunction-', stepfunctionIndex
     654             : 
     655          28 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     656             : 
     657          28 :       IF (l_exist) THEN
     658           0 :          CALL juDFT_error('stepfunction entry '//TRIM(ADJUSTL(groupName))//' already exists.' ,calledby ="writeStepfunctionHDF")
     659             :       END IF
     660             : 
     661          28 :       INQUIRE(FILE='broyd',EXIST=l_exist)
     662          28 :       IF (.NOT.l_exist) INQUIRE(FILE='broyd.7',EXIST=l_exist)
     663          28 :       IF (l_exist.AND.l_CheckBroyd) CALL juDFT_warn('Stepfunction change but broyden files detected!')
     664             : 
     665          28 :       ifftd = size(stars%ufft)
     666             : 
     667          28 :       CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     668             : 
     669          28 :       CALL io_write_attint0(groupID,'starsIndex',starsIndex)
     670          28 :       CALL io_write_attint0(groupID,'structureIndex',structureIndex)
     671          28 :       CALL io_write_attint0(groupID,'ifftd',ifftd)
     672          28 :       CALL io_write_attint0(groupID,'ng3',stars%ng3)
     673             : 
     674          28 :       dims(:2)=(/2,stars%ng3/)
     675         224 :       dimsInt = dims
     676          28 :       CALL h5screate_simple_f(2,dims(:2),ustepSpaceID,hdfError)
     677          28 :       CALL h5dcreate_f(groupID, "ustep", H5T_NATIVE_DOUBLE, ustepSpaceID, ustepSetID, hdfError)
     678          28 :       CALL h5sclose_f(ustepSpaceID,hdfError)
     679          28 :       CALL io_write_complex1(ustepSetID,(/-1,1/),dimsInt(:2),stars%ustep)
     680          28 :       CALL h5dclose_f(ustepSetID, hdfError)
     681             : 
     682          28 :       dims(:1)=(/ifftd/)
     683         224 :       dimsInt=dims
     684          28 :       CALL h5screate_simple_f(1,dims(:1),ufftSpaceID,hdfError)
     685          28 :       CALL h5dcreate_f(groupID, "ufft", H5T_NATIVE_DOUBLE, ufftSpaceID, ufftSetID, hdfError)
     686          28 :       CALL h5sclose_f(ufftSpaceID,hdfError)
     687          28 :       CALL io_write_real1(ufftSetID,(/1/),dimsInt(:1),stars%ufft)
     688          28 :       CALL h5dclose_f(ufftSetID, hdfError)
     689             : 
     690          28 :       CALL h5gclose_f(groupID, hdfError)
     691             : 
     692          28 :    END SUBROUTINE writeStepfunctionHDF
     693             : 
     694         233 :    SUBROUTINE readStepfunctionHDF(fileID, stepfunctionIndex, stars)
     695             : 
     696             :       INTEGER(HID_T), INTENT(IN)    :: fileID
     697             :       INTEGER,        INTENT(IN)    :: stepfunctionIndex
     698             :       TYPE(t_stars),  INTENT(INOUT) :: stars
     699             : 
     700             :       INTEGER                   :: starsIndex, ng3Temp, ifftd, ifftdStars
     701             :       INTEGER                   :: structureIndex
     702             : 
     703             :       INTEGER(HID_T)            :: groupID
     704             :       INTEGER                   :: hdfError
     705             :       INTEGER                   :: dimsInt(7)
     706             :       CHARACTER(LEN=30)         :: groupName
     707             :       LOGICAL                   :: l_exist
     708             : 
     709             :       INTEGER(HID_T)            :: ustepSetID
     710             :       INTEGER(HID_T)            :: ufftSetID
     711             : 
     712         233 :       WRITE(groupname,'(a,i0)') '/stepfunction-', stepfunctionIndex
     713             : 
     714         233 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     715             : 
     716         233 :       IF (.NOT.l_exist) THEN
     717           0 :          CALL juDFT_error('stepfunction entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readStepfunctionHDF")
     718             :       END IF
     719             : 
     720         233 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     721             : 
     722         233 :       ifftdStars = 27*stars%mx1*stars%mx2*stars%mx3
     723             : 
     724         233 :       CALL io_read_attint0(groupID,'starsIndex',starsIndex)
     725         233 :       CALL io_read_attint0(groupID,'structureIndex',structureIndex)
     726         233 :       CALL io_read_attint0(groupID,'ng3',ng3Temp)
     727         233 :       CALL io_read_attint0(groupID,'ifftd',ifftd)
     728             : 
     729         233 :       IF((ng3Temp.NE.stars%ng3).OR.(ifftd.NE.ifftdStars)) THEN
     730           0 :          WRITE(*,'(a,i7,a,i7)') 'ng3   (stepfunction): ', ng3Temp, ' ng3   (stars) :', stars%ng3
     731           0 :          WRITE(*,'(a,i7,a,i7)') 'ifftd (stepfunction): ', ifftd,   ' ifftd (stars) :', ifftdStars
     732           0 :          CALL juDFT_error('stepfunction entry '//TRIM(ADJUSTL(groupName))//' does not fit to stars.' ,calledby ="readStepfunctionHDF")
     733             :       END IF
     734             : 
     735         233 :       IF(ALLOCATED(stars%ustep)) DEALLOCATE(stars%ustep)
     736         233 :       IF(ALLOCATED(stars%ufft)) DEALLOCATE(stars%ufft)
     737             : 
     738         233 :       ALLOCATE(stars%ustep(stars%ng3))
     739         233 :       ALLOCATE(stars%ufft(0:ifftd-1))
     740             : 
     741         233 :       dimsInt(:2)=(/2,ng3Temp/)
     742         233 :       CALL h5dopen_f(groupID, 'ustep', ustepSetID, hdfError)
     743         233 :       CALL io_read_complex1(ustepSetID,(/-1,1/),dimsInt(:2),stars%ustep)
     744         233 :       CALL h5dclose_f(ustepSetID, hdfError)
     745             : 
     746         233 :       dimsInt(:1)=(/ifftd/)
     747         233 :       CALL h5dopen_f(groupID, 'ufft', ufftSetID, hdfError)
     748         233 :       CALL io_read_real1(ufftSetID,(/1/),dimsInt(:1),stars%ufft(0:ifftd-1))
     749         233 :       CALL h5dclose_f(ufftSetID, hdfError)
     750             : 
     751         233 :       CALL h5gclose_f(groupID, hdfError)
     752             : 
     753         233 :    END SUBROUTINE readStepfunctionHDF
     754             : 
     755         233 :    SUBROUTINE peekStepfunctionHDF(fileID, stepfunctionIndex, starsIndex, structureIndex)
     756             : 
     757             :       INTEGER(HID_T), INTENT(IN)    :: fileID
     758             :       INTEGER,        INTENT(IN)    :: stepfunctionIndex
     759             :       INTEGER,        INTENT(OUT)   :: starsIndex, structureIndex
     760             : 
     761             :       INTEGER(HID_T)            :: groupID
     762             :       INTEGER                   :: hdfError
     763             :       CHARACTER(LEN=30)         :: groupName
     764             :       LOGICAL                   :: l_exist
     765             : 
     766         233 :       WRITE(groupname,'(a,i0)') '/stepfunction-', stepfunctionIndex
     767             : 
     768         233 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     769             : 
     770         233 :       IF (.NOT.l_exist) THEN
     771           0 :          CALL juDFT_error('stepfunction entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readStepfunctionHDF")
     772             :       END IF
     773             : 
     774         233 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     775         233 :       CALL io_read_attint0(groupID,'starsIndex',starsIndex)
     776         233 :       CALL io_read_attint0(groupID,'structureIndex',structureIndex)
     777         233 :       CALL h5gclose_f(groupID, hdfError)
     778             : 
     779         233 :    END SUBROUTINE peekStepfunctionHDF
     780             : 
     781          29 :    SUBROUTINE writeLatharmsHDF(fileID, latharmsIndex, structureIndex, latharms, l_CheckBroyd)
     782             : 
     783             :       INTEGER(HID_T), INTENT(IN)  :: fileID
     784             :       INTEGER,        INTENT(IN)  :: latharmsIndex, structureIndex
     785             :       TYPE(t_sphhar), INTENT(IN)  :: latharms
     786             :       LOGICAL,        INTENT(IN)  :: l_CheckBroyd
     787             : 
     788             :       INTEGER                   :: hdfError
     789             :       INTEGER(HID_T)            :: groupID
     790             :       INTEGER(HID_T)            :: nlhSpaceID, nlhSetID
     791             :       INTEGER(HID_T)            :: llhSpaceID, llhSetID
     792             :       INTEGER(HID_T)            :: nmemSpaceID, nmemSetID
     793             :       INTEGER(HID_T)            :: mlhSpaceID, mlhSetID
     794             :       INTEGER(HID_T)            :: clnuSpaceID, clnuSetID
     795             :       CHARACTER(LEN=30)         :: groupName
     796             :       INTEGER(HSIZE_T)          :: dims(7)
     797             :       INTEGER                   :: dimsInt(7)
     798             :       LOGICAL                   :: l_exist
     799             : 
     800          29 :       WRITE(groupname,'(a,i0)') '/latharms-', latharmsIndex
     801             : 
     802          29 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     803             : 
     804          29 :       IF (l_exist) THEN
     805           0 :          CALL juDFT_error('latharms entry '//TRIM(ADJUSTL(groupName))//' already exists.' ,calledby ="writeLatharmsHDF")
     806             :       END IF
     807             : 
     808          29 :       INQUIRE(FILE='broyd',EXIST=l_exist)
     809          29 :       IF (.NOT.l_exist) INQUIRE(FILE='broyd.7',EXIST=l_exist)
     810          29 :       IF (l_exist.AND.l_CheckBroyd) CALL juDFT_warn('Lattice harmonics change but broyden files detected!')
     811             : 
     812          29 :       CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     813             : 
     814          29 :       CALL io_write_attint0(groupID,'structureIndex',structureIndex)
     815          29 :       CALL io_write_attint0(groupID,'ntypsd',latharms%ntypsd)
     816          29 :       CALL io_write_attint0(groupID,'memd',latharms%memd)
     817          29 :       CALL io_write_attint0(groupID,'nlhd',latharms%nlhd)
     818             : 
     819          29 :       dims(:1)=(/latharms%ntypsd/)
     820         232 :       dimsInt = dims
     821          29 :       CALL h5screate_simple_f(1,dims(:1),nlhSpaceID,hdfError)
     822          29 :       CALL h5dcreate_f(groupID, "nlh", H5T_NATIVE_INTEGER, nlhSpaceID, nlhSetID, hdfError)
     823          29 :       CALL h5sclose_f(nlhSpaceID,hdfError)
     824          29 :       CALL io_write_integer1(nlhSetID,(/1/),dimsInt(:1),latharms%nlh)
     825          29 :       CALL h5dclose_f(nlhSetID, hdfError)
     826             : 
     827          29 :       dims(:2)=(/latharms%nlhd+1,latharms%ntypsd/)
     828         232 :       dimsInt = dims
     829          29 :       CALL h5screate_simple_f(2,dims(:2),llhSpaceID,hdfError)
     830          29 :       CALL h5dcreate_f(groupID, "llh", H5T_NATIVE_INTEGER, llhSpaceID, llhSetID, hdfError)
     831          29 :       CALL h5sclose_f(llhSpaceID,hdfError)
     832          29 :       CALL io_write_integer2(llhSetID,(/1,1/),dimsInt(:2),latharms%llh)
     833          29 :       CALL h5dclose_f(llhSetID, hdfError)
     834             : 
     835          29 :       dims(:2)=(/latharms%nlhd+1,latharms%ntypsd/)
     836         232 :       dimsInt = dims
     837          29 :       CALL h5screate_simple_f(2,dims(:2),nmemSpaceID,hdfError)
     838          29 :       CALL h5dcreate_f(groupID, "nmem", H5T_NATIVE_INTEGER, nmemSpaceID, nmemSetID, hdfError)
     839          29 :       CALL h5sclose_f(nmemSpaceID,hdfError)
     840          29 :       CALL io_write_integer2(nmemSetID,(/1,1/),dimsInt(:2),latharms%nmem)
     841          29 :       CALL h5dclose_f(nmemSetID, hdfError)
     842             : 
     843          29 :       dims(:3)=(/latharms%memd,latharms%nlhd+1,latharms%ntypsd/)
     844         232 :       dimsInt = dims
     845          29 :       CALL h5screate_simple_f(3,dims(:3),mlhSpaceID,hdfError)
     846          29 :       CALL h5dcreate_f(groupID, "mlh", H5T_NATIVE_INTEGER, mlhSpaceID, mlhSetID, hdfError)
     847          29 :       CALL h5sclose_f(mlhSpaceID,hdfError)
     848          29 :       CALL io_write_integer3(mlhSetID,(/1,1,1/),dimsInt(:3),latharms%mlh)
     849          29 :       CALL h5dclose_f(mlhSetID, hdfError)
     850             : 
     851          29 :       dims(:4)=(/2,latharms%memd,latharms%nlhd+1,latharms%ntypsd/)
     852         232 :       dimsInt = dims
     853          29 :       CALL h5screate_simple_f(4,dims(:4),clnuSpaceID,hdfError)
     854          29 :       CALL h5dcreate_f(groupID, "clnu", H5T_NATIVE_DOUBLE, clnuSpaceID, clnuSetID, hdfError)
     855          29 :       CALL h5sclose_f(clnuSpaceID,hdfError)
     856          29 :       CALL io_write_complex3(clnuSetID,(/-1,1,1,1/),dimsInt(:4),latharms%clnu)
     857          29 :       CALL h5dclose_f(clnuSetID, hdfError)
     858             : 
     859          29 :       CALL h5gclose_f(groupID, hdfError)
     860             : 
     861          29 :    END SUBROUTINE writeLatharmsHDF
     862             : 
     863         194 :    SUBROUTINE readLatharmsHDF(fileID, latharmsIndex, latharms)
     864             : 
     865             :       INTEGER(HID_T), INTENT(IN)  :: fileID
     866             :       INTEGER,        INTENT(IN)  :: latharmsIndex
     867             :       TYPE(t_sphhar), INTENT(INOUT) :: latharms
     868             : 
     869             :       INTEGER(HID_T)            :: nlhSetID, llhSetID, nmemSetID
     870             :       INTEGER(HID_T)            :: mlhSetID, clnuSetID, groupID
     871             :       CHARACTER(LEN=30)         :: groupName
     872             :       INTEGER                   :: hdfError
     873             :       INTEGER                   :: dimsInt(7)
     874             :       LOGICAL                   :: l_exist
     875             : 
     876         194 :       WRITE(groupname,'(a,i0)') '/latharms-', latharmsIndex
     877             : 
     878         194 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     879             : 
     880         194 :       IF (.NOT.l_exist) THEN
     881           0 :          CALL juDFT_error('latharms entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readLatharmsHDF")
     882             :       END IF
     883             : 
     884         194 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     885             : 
     886         194 :       CALL io_read_attint0(groupID,'ntypsd',latharms%ntypsd)
     887         194 :       CALL io_read_attint0(groupID,'memd',latharms%memd)
     888         194 :       CALL io_read_attint0(groupID,'nlhd',latharms%nlhd)
     889             : 
     890         194 :       IF(ALLOCATED(latharms%nlh)) DEALLOCATE(latharms%nlh)
     891         194 :       IF(ALLOCATED(latharms%llh)) DEALLOCATE(latharms%llh)
     892         194 :       IF(ALLOCATED(latharms%nmem)) DEALLOCATE(latharms%nmem)
     893         194 :       IF(ALLOCATED(latharms%mlh)) DEALLOCATE(latharms%mlh)
     894         194 :       IF(ALLOCATED(latharms%clnu)) DEALLOCATE(latharms%clnu)
     895             : 
     896         194 :       ALLOCATE(latharms%clnu(latharms%memd,0:latharms%nlhd,latharms%ntypsd))
     897         194 :       ALLOCATE(latharms%llh(0:latharms%nlhd,latharms%ntypsd))
     898         194 :       ALLOCATE(latharms%mlh(latharms%memd,0:latharms%nlhd,latharms%ntypsd))
     899         194 :       ALLOCATE(latharms%nlh(latharms%ntypsd),latharms%nmem(0:latharms%nlhd,latharms%ntypsd))
     900             : 
     901         194 :       dimsInt(:1)=(/latharms%ntypsd/)
     902         194 :       CALL h5dopen_f(groupID, 'nlh', nlhSetID, hdfError)
     903         194 :       CALL io_read_integer1(nlhSetID,(/1/),dimsInt(:1),latharms%nlh)
     904         194 :       CALL h5dclose_f(nlhSetID, hdfError)
     905             : 
     906         194 :       dimsInt(:2)=(/latharms%nlhd+1,latharms%ntypsd/)
     907         194 :       CALL h5dopen_f(groupID, 'llh', llhSetID, hdfError)
     908         194 :       CALL io_read_integer2(llhSetID,(/1,1/),dimsInt(:2),latharms%llh)
     909         194 :       CALL h5dclose_f(llhSetID, hdfError)
     910             : 
     911         194 :       dimsInt(:2)=(/latharms%nlhd+1,latharms%ntypsd/)
     912         194 :       CALL h5dopen_f(groupID, 'nmem', nmemSetID, hdfError)
     913         194 :       CALL io_read_integer2(nmemSetID,(/1,1/),dimsInt(:2),latharms%nmem)
     914         194 :       CALL h5dclose_f(nmemSetID, hdfError)
     915             : 
     916         194 :       dimsInt(:3)=(/latharms%memd,latharms%nlhd+1,latharms%ntypsd/)
     917         194 :       CALL h5dopen_f(groupID, 'mlh', mlhSetID, hdfError)
     918         194 :       CALL io_read_integer3(mlhSetID,(/1,1,1/),dimsInt(:3),latharms%mlh)
     919         194 :       CALL h5dclose_f(mlhSetID, hdfError)
     920             : 
     921         194 :       dimsInt(:4)=(/2,latharms%memd,latharms%nlhd+1,latharms%ntypsd/)
     922         194 :       CALL h5dopen_f(groupID, 'clnu', clnuSetID, hdfError)
     923         194 :       CALL io_read_complex3(clnuSetID,(/-1,1,1,1/),dimsInt(:4),latharms%clnu)
     924         194 :       CALL h5dclose_f(clnuSetID, hdfError)
     925             : 
     926         194 :       CALL h5gclose_f(groupID, hdfError)
     927             : 
     928         194 :    END SUBROUTINE readLatharmsHDF
     929             : 
     930         194 :    SUBROUTINE peekLatharmsHDF(fileID, latharmsIndex, structureIndex)
     931             : 
     932             :       INTEGER(HID_T), INTENT(IN)    :: fileID
     933             :       INTEGER,        INTENT(IN)    :: latharmsIndex
     934             :       INTEGER,        INTENT(OUT)   :: structureIndex
     935             : 
     936             :       INTEGER(HID_T)            :: groupID
     937             :       INTEGER                   :: hdfError
     938             :       CHARACTER(LEN=30)         :: groupName
     939             :       LOGICAL                   :: l_exist
     940             : 
     941         194 :       WRITE(groupname,'(a,i0)') '/latharms-', latharmsIndex
     942             : 
     943         194 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
     944             : 
     945         194 :       IF (.NOT.l_exist) THEN
     946           0 :          CALL juDFT_error('latharms entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readLatharmsHDF")
     947             :       END IF
     948             : 
     949         194 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
     950         194 :       CALL io_read_attint0(groupID,'structureIndex',structureIndex)
     951         194 :       CALL h5gclose_f(groupID, hdfError)
     952             : 
     953         194 :    END SUBROUTINE peekLatharmsHDF
     954             : 
     955          28 :    SUBROUTINE writeStructureHDF(fileID, input, atoms, cell, vacuum, oneD, sym, structureIndex, l_CheckBroyd)
     956             : 
     957             :       INTEGER(HID_T), INTENT(IN) :: fileID
     958             :       INTEGER, INTENT(IN)        :: structureIndex
     959             :       TYPE(t_input),INTENT(IN)   :: input
     960             :       TYPE(t_atoms), INTENT(IN)  :: atoms
     961             :       TYPE(t_cell), INTENT(IN)   :: cell
     962             :       TYPE(t_vacuum), INTENT(IN) :: vacuum
     963             :       TYPE(t_oneD),INTENT(IN)    :: oneD
     964             :       TYPE(t_sym),INTENT(IN)     :: sym
     965             :       LOGICAL, INTENT(IN)        :: l_CheckBroyd
     966             : 
     967             :       INTEGER(HID_T)            :: groupID
     968             :       INTEGER                   :: hdfError, i
     969             :       CHARACTER(LEN=30)         :: groupName
     970             :       INTEGER(HSIZE_T)          :: dims(7)
     971             :       INTEGER                   :: dimsInt(7)
     972             :       LOGICAL                   :: l_exist
     973             : 
     974             :       !LDA+U arrays (start)
     975          56 :       INTEGER                   :: ldau_AtomType(MAX(1,atoms%n_u))
     976          56 :       INTEGER                   :: ldau_l(MAX(1,atoms%n_u))
     977          56 :       INTEGER                   :: ldau_l_amf(MAX(1,atoms%n_u)) ! 1 = true, 0 = false
     978          56 :       REAL                      :: ldau_U(MAX(1,atoms%n_u))
     979          56 :       REAL                      :: ldau_J(MAX(1,atoms%n_u))
     980             :       !LDA+U arrays (end)
     981             : 
     982             :       INTEGER(HID_T)                   :: amatSpaceID, amatSetID
     983             :       INTEGER(HID_T)                   :: nzSpaceID, nzSetID
     984             :       INTEGER(HID_T)                   :: neqSpaceID, neqSetID
     985             :       INTEGER(HID_T)                   :: jriSpaceID, jriSetID
     986             :       INTEGER(HID_T)                   :: lmaxSpaceID, lmaxSetID
     987             :       INTEGER(HID_T)                   :: ngoprSpaceID, ngoprSetID
     988             :       INTEGER(HID_T)                   :: ntypsySpaceID, ntypsySetID
     989             :       INTEGER(HID_T)                   :: nlhtypSpaceID, nlhtypSetID
     990             :       INTEGER(HID_T)                   :: invsatSpaceID, invsatSetID
     991             :       INTEGER(HID_T)                   :: rmtSpaceID, rmtSetID
     992             :       INTEGER(HID_T)                   :: dxSpaceID, dxSetID
     993             :       INTEGER(HID_T)                   :: volmtsSpaceID, volmtsSetID
     994             :       INTEGER(HID_T)                   :: rmshSpaceID, rmshSetID
     995             :       INTEGER(HID_T)                   :: zatomSpaceID, zatomSetID
     996             :       INTEGER(HID_T)                   :: posSpaceID, posSetID
     997             :       INTEGER(HID_T)                   :: taualSpaceID, taualSetID
     998             :       INTEGER(HID_T)                   :: mrotSpaceID, mrotSetID
     999             :       INTEGER(HID_T)                   :: tauSpaceID, tauSetID
    1000             : 
    1001             :       !LDA+U IDs (start)
    1002             :       INTEGER(HID_T)                   :: ldau_AtomTypeSpaceID, ldau_AtomTypeSetID
    1003             :       INTEGER(HID_T)                   :: ldau_lSpaceID, ldau_lSetID
    1004             :       INTEGER(HID_T)                   :: ldau_l_amfSpaceID, ldau_l_amfSetID
    1005             :       INTEGER(HID_T)                   :: ldau_USpaceID, ldau_USetID
    1006             :       INTEGER(HID_T)                   :: ldau_JSpaceID, ldau_JSetID
    1007             :       !LDA+U IDs (end)
    1008             : 
    1009          28 :       WRITE(groupname,'(a,i0)') '/structure-', structureIndex
    1010             : 
    1011          28 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1012             : 
    1013          28 :       IF (l_exist) THEN
    1014           0 :          CALL juDFT_error('structure entry '//TRIM(ADJUSTL(groupName))//' already exists.' ,calledby ="writeStructureHDF")
    1015             :       END IF
    1016             : 
    1017          28 :       INQUIRE(FILE='broyd',EXIST=l_exist)
    1018          28 :       IF (.NOT.l_exist) INQUIRE(FILE='broyd.7',EXIST=l_exist)
    1019          28 :       IF (l_exist.AND.l_CheckBroyd) CALL juDFT_warn('Structure / parameter change but broyden files detected!')
    1020             : 
    1021          28 :       CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1022             : 
    1023          28 :       CALL io_write_attlog0(groupID,'l_film',input%film)
    1024             : 
    1025          28 :       CALL io_write_attreal0(groupID,'omtil',cell%omtil)
    1026          28 :       CALL io_write_attreal0(groupID,'area',cell%area)
    1027          28 :       CALL io_write_attreal0(groupID,'z1',cell%z1)
    1028          28 :       CALL io_write_attreal0(groupID,'vol',cell%vol)
    1029          28 :       CALL io_write_attreal0(groupID,'volint',cell%volint)
    1030             : 
    1031          28 :       CALL io_write_attint0(groupID,'ntype',atoms%ntype)
    1032          28 :       CALL io_write_attint0(groupID,'nat',atoms%nat)
    1033          28 :       CALL io_write_attint0(groupID,'lmaxd',atoms%lmaxd)
    1034          28 :       CALL io_write_attint0(groupID,'jmtd',atoms%jmtd)
    1035          28 :       CALL io_write_attint0(groupID,'n_u',atoms%n_u)
    1036             : 
    1037          28 :       CALL io_write_attint0(groupID,'nmz',vacuum%nmz)
    1038          28 :       CALL io_write_attint0(groupID,'nmzd',vacuum%nmzd)
    1039          28 :       CALL io_write_attint0(groupID,'nmzxy',vacuum%nmzxy)
    1040          28 :       CALL io_write_attint0(groupID,'nmzxyd',vacuum%nmzxyd)
    1041          28 :       CALL io_write_attint0(groupID,'layerd',vacuum%layerd)
    1042          28 :       CALL io_write_attint0(groupID,'layers',vacuum%layers)
    1043          28 :       CALL io_write_attint0(groupID,'nvac',vacuum%nvac)
    1044          28 :       CALL io_write_attint0(groupID,'nvacd',vacuum%nvacd)
    1045          28 :       CALL io_write_attint0(groupID,'nstars',vacuum%nstars)
    1046          28 :       CALL io_write_attint0(groupID,'nstm',vacuum%nstm)
    1047          28 :       CALL io_write_attreal0(groupID,'delz',vacuum%delz)
    1048          28 :       CALL io_write_attreal0(groupID,'dvac',vacuum%dvac)
    1049             : 
    1050          28 :       CALL io_write_attint0(groupID,'od_nq2',oneD%odi%nq2)
    1051             : 
    1052          28 :       CALL io_write_attlog0(groupID,'invs2',sym%invs2)
    1053          28 :       CALL io_write_attlog0(groupID,'invs',sym%invs)
    1054          28 :       CALL io_write_attlog0(groupID,'zrfs',sym%zrfs)
    1055          28 :       CALL io_write_attint0(groupID,'nop',sym%nop)
    1056          28 :       CALL io_write_attint0(groupID,'nop2',sym%nop2)
    1057          28 :       CALL io_write_attchar0(groupID,'latnam',sym%latnam)
    1058          28 :       CALL io_write_attchar0(groupID,'namgrp',sym%namgrp)
    1059             : 
    1060          84 :       dims(:2)=(/3,3/)
    1061         224 :       dimsInt = dims
    1062          28 :       CALL h5screate_simple_f(2,dims(:2),amatSpaceID,hdfError)
    1063          28 :       CALL h5dcreate_f(groupID, "amat", H5T_NATIVE_DOUBLE, amatSpaceID, amatSetID, hdfError)
    1064          28 :       CALL h5sclose_f(amatSpaceID,hdfError)
    1065          28 :       CALL io_write_real2(amatSetID,(/1,1/),dimsInt(:2),cell%amat)
    1066          28 :       CALL h5dclose_f(amatSetID, hdfError)
    1067             : 
    1068          28 :       dims(:1)=(/atoms%ntype/)
    1069         224 :       dimsInt = dims
    1070          28 :       CALL h5screate_simple_f(1,dims(:1),nzSpaceID,hdfError)
    1071          28 :       CALL h5dcreate_f(groupID, "nz", H5T_NATIVE_INTEGER, nzSpaceID, nzSetID, hdfError)
    1072          28 :       CALL h5sclose_f(nzSpaceID,hdfError)
    1073          28 :       CALL io_write_integer1(nzSetID,(/1/),dimsInt(:1),atoms%nz)
    1074          28 :       CALL h5dclose_f(nzSetID, hdfError)
    1075             : 
    1076          28 :       dims(:1)=(/atoms%ntype/)
    1077         224 :       dimsInt = dims
    1078          28 :       CALL h5screate_simple_f(1,dims(:1),neqSpaceID,hdfError)
    1079          28 :       CALL h5dcreate_f(groupID, "neq", H5T_NATIVE_INTEGER, neqSpaceID, neqSetID, hdfError)
    1080          28 :       CALL h5sclose_f(neqSpaceID,hdfError)
    1081          28 :       CALL io_write_integer1(neqSetID,(/1/),dimsInt(:1),atoms%neq)
    1082          28 :       CALL h5dclose_f(neqSetID, hdfError)
    1083             : 
    1084          28 :       dims(:1)=(/atoms%ntype/)
    1085         224 :       dimsInt = dims
    1086          28 :       CALL h5screate_simple_f(1,dims(:1),jriSpaceID,hdfError)
    1087          28 :       CALL h5dcreate_f(groupID, "jri", H5T_NATIVE_INTEGER, jriSpaceID, jriSetID, hdfError)
    1088          28 :       CALL h5sclose_f(jriSpaceID,hdfError)
    1089          28 :       CALL io_write_integer1(jriSetID,(/1/),dimsInt(:1),atoms%jri)
    1090          28 :       CALL h5dclose_f(jriSetID, hdfError)
    1091             : 
    1092          28 :       dims(:1)=(/atoms%ntype/)
    1093         224 :       dimsInt = dims
    1094          28 :       CALL h5screate_simple_f(1,dims(:1),lmaxSpaceID,hdfError)
    1095          28 :       CALL h5dcreate_f(groupID, "lmax", H5T_NATIVE_INTEGER, lmaxSpaceID, lmaxSetID, hdfError)
    1096          28 :       CALL h5sclose_f(lmaxSpaceID,hdfError)
    1097          28 :       CALL io_write_integer1(lmaxSetID,(/1/),dimsInt(:1),atoms%lmax)
    1098          28 :       CALL h5dclose_f(lmaxSetID, hdfError)
    1099             : 
    1100          28 :       dims(:1)=(/atoms%nat/)
    1101         224 :       dimsInt = dims
    1102          28 :       CALL h5screate_simple_f(1,dims(:1),ngoprSpaceID,hdfError)
    1103          28 :       CALL h5dcreate_f(groupID, "ngopr", H5T_NATIVE_INTEGER, ngoprSpaceID, ngoprSetID, hdfError)
    1104          28 :       CALL h5sclose_f(ngoprSpaceID,hdfError)
    1105          28 :       CALL io_write_integer1(ngoprSetID,(/1/),dimsInt(:1),atoms%ngopr)
    1106          28 :       CALL h5dclose_f(ngoprSetID, hdfError)
    1107             : 
    1108          28 :       dims(:1)=(/atoms%nat/)
    1109         224 :       dimsInt = dims
    1110          28 :       CALL h5screate_simple_f(1,dims(:1),ntypsySpaceID,hdfError)
    1111          28 :       CALL h5dcreate_f(groupID, "ntypsy", H5T_NATIVE_INTEGER, ntypsySpaceID, ntypsySetID, hdfError)
    1112          28 :       CALL h5sclose_f(ntypsySpaceID,hdfError)
    1113          28 :       CALL io_write_integer1(ntypsySetID,(/1/),dimsInt(:1),atoms%ntypsy)
    1114          28 :       CALL h5dclose_f(ntypsySetID, hdfError)
    1115             : 
    1116          28 :       dims(:1)=(/atoms%ntype/)
    1117         224 :       dimsInt = dims
    1118          28 :       CALL h5screate_simple_f(1,dims(:1),nlhtypSpaceID,hdfError)
    1119          28 :       CALL h5dcreate_f(groupID, "nlhtyp", H5T_NATIVE_INTEGER, nlhtypSpaceID, nlhtypSetID, hdfError)
    1120          28 :       CALL h5sclose_f(nlhtypSpaceID,hdfError)
    1121          28 :       CALL io_write_integer1(nlhtypSetID,(/1/),dimsInt(:1),atoms%nlhtyp)
    1122          28 :       CALL h5dclose_f(nlhtypSetID, hdfError)
    1123             : 
    1124          28 :       dims(:1)=(/atoms%nat/)
    1125         224 :       dimsInt = dims
    1126          28 :       CALL h5screate_simple_f(1,dims(:1),invsatSpaceID,hdfError)
    1127          28 :       CALL h5dcreate_f(groupID, "invsat", H5T_NATIVE_INTEGER, invsatSpaceID, invsatSetID, hdfError)
    1128          28 :       CALL h5sclose_f(invsatSpaceID,hdfError)
    1129          28 :       CALL io_write_integer1(invsatSetID,(/1/),dimsInt(:1),atoms%invsat)
    1130          28 :       CALL h5dclose_f(invsatSetID, hdfError)
    1131             : 
    1132          28 :       dims(:1)=(/atoms%ntype/)
    1133         224 :       dimsInt = dims
    1134          28 :       CALL h5screate_simple_f(1,dims(:1),rmtSpaceID,hdfError)
    1135          28 :       CALL h5dcreate_f(groupID, "rmt", H5T_NATIVE_DOUBLE, rmtSpaceID, rmtSetID, hdfError)
    1136          28 :       CALL h5sclose_f(rmtSpaceID,hdfError)
    1137          28 :       CALL io_write_real1(rmtSetID,(/1/),dimsInt(:1),atoms%rmt)
    1138          28 :       CALL h5dclose_f(rmtSetID, hdfError)
    1139             : 
    1140          28 :       dims(:1)=(/atoms%ntype/)
    1141         224 :       dimsInt = dims
    1142          28 :       CALL h5screate_simple_f(1,dims(:1),dxSpaceID,hdfError)
    1143          28 :       CALL h5dcreate_f(groupID, "dx", H5T_NATIVE_DOUBLE, dxSpaceID, dxSetID, hdfError)
    1144          28 :       CALL h5sclose_f(dxSpaceID,hdfError)
    1145          28 :       CALL io_write_real1(dxSetID,(/1/),dimsInt(:1),atoms%dx)
    1146          28 :       CALL h5dclose_f(dxSetID, hdfError)
    1147             : 
    1148          28 :       dims(:1)=(/atoms%ntype/)
    1149         224 :       dimsInt = dims
    1150          28 :       CALL h5screate_simple_f(1,dims(:1),volmtsSpaceID,hdfError)
    1151          28 :       CALL h5dcreate_f(groupID, "volmts", H5T_NATIVE_DOUBLE, volmtsSpaceID, volmtsSetID, hdfError)
    1152          28 :       CALL h5sclose_f(volmtsSpaceID,hdfError)
    1153          28 :       CALL io_write_real1(volmtsSetID,(/1/),dimsInt(:1),atoms%volmts)
    1154          28 :       CALL h5dclose_f(volmtsSetID, hdfError)
    1155             : 
    1156          28 :       dims(:2)=(/atoms%jmtd,atoms%ntype/)
    1157         224 :       dimsInt = dims
    1158          28 :       CALL h5screate_simple_f(2,dims(:2),rmshSpaceID,hdfError)
    1159          28 :       CALL h5dcreate_f(groupID, "rmsh", H5T_NATIVE_DOUBLE, rmshSpaceID, rmshSetID, hdfError)
    1160          28 :       CALL h5sclose_f(rmshSpaceID,hdfError)
    1161          28 :       CALL io_write_real2(rmshSetID,(/1,1/),dimsInt(:2),atoms%rmsh)
    1162          28 :       CALL h5dclose_f(rmshSetID, hdfError)
    1163             : 
    1164          28 :       dims(:1)=(/atoms%ntype/)
    1165         224 :       dimsInt = dims
    1166          28 :       CALL h5screate_simple_f(1,dims(:1),zatomSpaceID,hdfError)
    1167          28 :       CALL h5dcreate_f(groupID, "zatom", H5T_NATIVE_DOUBLE, zatomSpaceID, zatomSetID, hdfError)
    1168          28 :       CALL h5sclose_f(zatomSpaceID,hdfError)
    1169          28 :       CALL io_write_real1(zatomSetID,(/1/),dimsInt(:1),atoms%zatom)
    1170          28 :       CALL h5dclose_f(zatomSetID, hdfError)
    1171             : 
    1172          28 :       dims(:2)=(/3,atoms%nat/)
    1173         224 :       dimsInt = dims
    1174          28 :       CALL h5screate_simple_f(2,dims(:2),posSpaceID,hdfError)
    1175          28 :       CALL h5dcreate_f(groupID, "pos", H5T_NATIVE_DOUBLE, posSpaceID, posSetID, hdfError)
    1176          28 :       CALL h5sclose_f(posSpaceID,hdfError)
    1177          28 :       CALL io_write_real2(posSetID,(/1,1/),dimsInt(:2),atoms%pos)
    1178          28 :       CALL h5dclose_f(posSetID, hdfError)
    1179             : 
    1180          28 :       dims(:2)=(/3,atoms%nat/)
    1181         224 :       dimsInt = dims
    1182          28 :       CALL h5screate_simple_f(2,dims(:2),taualSpaceID,hdfError)
    1183          28 :       CALL h5dcreate_f(groupID, "taual", H5T_NATIVE_DOUBLE, taualSpaceID, taualSetID, hdfError)
    1184          28 :       CALL h5sclose_f(taualSpaceID,hdfError)
    1185          28 :       CALL io_write_real2(taualSetID,(/1,1/),dimsInt(:2),atoms%taual)
    1186          28 :       CALL h5dclose_f(taualSetID, hdfError)
    1187             : 
    1188          28 :       dims(:3)=(/3,3,sym%nop/)
    1189         224 :       dimsInt = dims
    1190          28 :       CALL h5screate_simple_f(3,dims(:3),mrotSpaceID,hdfError)
    1191          28 :       CALL h5dcreate_f(groupID, "mrot", H5T_NATIVE_INTEGER, mrotSpaceID, mrotSetID, hdfError)
    1192          28 :       CALL h5sclose_f(mrotSpaceID,hdfError)
    1193          28 :       CALL io_write_integer3(mrotSetID,(/1,1,1/),dimsInt(:3),sym%mrot)
    1194          28 :       CALL h5dclose_f(mrotSetID, hdfError)
    1195             : 
    1196          28 :       dims(:2)=(/3,sym%nop/)
    1197         224 :       dimsInt = dims
    1198          28 :       CALL h5screate_simple_f(2,dims(:2),tauSpaceID,hdfError)
    1199          28 :       CALL h5dcreate_f(groupID, "tau", H5T_NATIVE_DOUBLE, tauSpaceID, tauSetID, hdfError)
    1200          28 :       CALL h5sclose_f(tauSpaceID,hdfError)
    1201          28 :       CALL io_write_real2(tauSetID,(/1,1/),dimsInt(:2),sym%tau)
    1202          28 :       CALL h5dclose_f(tauSetID, hdfError)
    1203             : 
    1204             :       !LDA+U data (start)
    1205          28 :       IF(atoms%n_u.GT.0) THEN
    1206           5 :          ldau_l_amf = 0
    1207           9 :          DO i = 1, atoms%n_u
    1208           4 :             ldau_AtomType(i) = atoms%lda_u(i)%atomType
    1209           4 :             ldau_l(i) = atoms%lda_u(i)%l
    1210           4 :             ldau_U(i) = atoms%lda_u(i)%u
    1211           4 :             ldau_J(i) = atoms%lda_u(i)%j
    1212           5 :             IF(atoms%lda_u(i)%l_amf) ldau_l_amf(i) = 1
    1213             :          END DO
    1214             : 
    1215           1 :          dims(:1)=(/atoms%n_u/)
    1216           8 :          dimsInt = dims
    1217           1 :          CALL h5screate_simple_f(1,dims(:1),ldau_AtomTypeSpaceID,hdfError)
    1218           1 :          CALL h5dcreate_f(groupID, "ldau_AtomType", H5T_NATIVE_INTEGER, ldau_AtomTypeSpaceID, ldau_AtomTypeSetID, hdfError)
    1219           1 :          CALL h5sclose_f(ldau_AtomTypeSpaceID,hdfError)
    1220           1 :          CALL io_write_integer1(ldau_AtomTypeSetID,(/1/),dimsInt(:1),ldau_AtomType(:atoms%n_u))
    1221           1 :          CALL h5dclose_f(ldau_AtomTypeSetID, hdfError)
    1222             : 
    1223           1 :          dims(:1)=(/atoms%n_u/)
    1224           8 :          dimsInt = dims
    1225           1 :          CALL h5screate_simple_f(1,dims(:1),ldau_lSpaceID,hdfError)
    1226           1 :          CALL h5dcreate_f(groupID, "ldau_l", H5T_NATIVE_INTEGER, ldau_lSpaceID, ldau_lSetID, hdfError)
    1227           1 :          CALL h5sclose_f(ldau_lSpaceID,hdfError)
    1228           1 :          CALL io_write_integer1(ldau_lSetID,(/1/),dimsInt(:1),ldau_l(:atoms%n_u))
    1229           1 :          CALL h5dclose_f(ldau_lSetID, hdfError)
    1230             : 
    1231           1 :          dims(:1)=(/atoms%n_u/)
    1232           8 :          dimsInt = dims
    1233           1 :          CALL h5screate_simple_f(1,dims(:1),ldau_l_amfSpaceID,hdfError)
    1234           1 :          CALL h5dcreate_f(groupID, "ldau_l_amf", H5T_NATIVE_INTEGER, ldau_l_amfSpaceID, ldau_l_amfSetID, hdfError)
    1235           1 :          CALL h5sclose_f(ldau_l_amfSpaceID,hdfError)
    1236           1 :          CALL io_write_integer1(ldau_l_amfSetID,(/1/),dimsInt(:1),ldau_l_amf(:atoms%n_u))
    1237           1 :          CALL h5dclose_f(ldau_l_amfSetID, hdfError)
    1238             : 
    1239           1 :          dims(:1)=(/atoms%n_u/)
    1240           8 :          dimsInt = dims
    1241           1 :          CALL h5screate_simple_f(1,dims(:1),ldau_USpaceID,hdfError)
    1242           1 :          CALL h5dcreate_f(groupID, "ldau_U", H5T_NATIVE_DOUBLE, ldau_USpaceID, ldau_USetID, hdfError)
    1243           1 :          CALL h5sclose_f(ldau_USpaceID,hdfError)
    1244           1 :          CALL io_write_real1(ldau_USetID,(/1/),dimsInt(:1),ldau_U(:atoms%n_u))
    1245           1 :          CALL h5dclose_f(ldau_USetID, hdfError)
    1246             : 
    1247           1 :          dims(:1)=(/atoms%n_u/)
    1248           8 :          dimsInt = dims
    1249           1 :          CALL h5screate_simple_f(1,dims(:1),ldau_JSpaceID,hdfError)
    1250           1 :          CALL h5dcreate_f(groupID, "ldau_J", H5T_NATIVE_DOUBLE, ldau_JSpaceID, ldau_JSetID, hdfError)
    1251           1 :          CALL h5sclose_f(ldau_JSpaceID,hdfError)
    1252           1 :          CALL io_write_real1(ldau_JSetID,(/1/),dimsInt(:1),ldau_J(:atoms%n_u))
    1253           1 :          CALL h5dclose_f(ldau_JSetID, hdfError)
    1254             :       END IF
    1255             :       !LDA+U data (end)
    1256             : 
    1257          28 :       CALL h5gclose_f(groupID, hdfError)
    1258             : 
    1259          28 :    END SUBROUTINE writeStructureHDF
    1260             : 
    1261         238 :    SUBROUTINE readStructureHDF(fileID, input, atoms, cell, vacuum, oneD, sym, structureIndex)
    1262             : 
    1263             :       INTEGER(HID_T), INTENT(IN)    :: fileID
    1264             :       INTEGER, INTENT(IN)           :: structureIndex
    1265             :       TYPE(t_input),INTENT(INOUT)   :: input
    1266             :       TYPE(t_atoms), INTENT(INOUT)  :: atoms
    1267             :       TYPE(t_cell), INTENT(INOUT)   :: cell
    1268             :       TYPE(t_vacuum), INTENT(INOUT) :: vacuum
    1269             :       TYPE(t_oneD),INTENT(INOUT)    :: oneD
    1270             :       TYPE(t_sym),INTENT(INOUT)     :: sym
    1271             : 
    1272             :       INTEGER(HID_T)            :: groupID, generalGroupID
    1273             :       INTEGER                   :: hdfError, fileFormatVersion, i
    1274             :       CHARACTER(LEN=30)         :: groupName
    1275             :       INTEGER                   :: dimsInt(7)
    1276             :       LOGICAL                   :: l_exist
    1277             : 
    1278             :       !LDA+U arrays (start)
    1279         238 :       INTEGER, ALLOCATABLE             :: ldau_AtomType(:)
    1280         238 :       INTEGER, ALLOCATABLE             :: ldau_l(:)
    1281         238 :       INTEGER, ALLOCATABLE             :: ldau_l_amf(:) ! 1 = true, 0 = false
    1282         238 :       REAL, ALLOCATABLE                :: ldau_U(:)
    1283         238 :       REAL, ALLOCATABLE                :: ldau_J(:)
    1284             : 
    1285             :       INTEGER(HID_T)                   :: amatSetID
    1286             :       INTEGER(HID_T)                   :: nzSetID
    1287             :       INTEGER(HID_T)                   :: neqSetID
    1288             :       INTEGER(HID_T)                   :: jriSetID
    1289             :       INTEGER(HID_T)                   :: lmaxSetID
    1290             :       INTEGER(HID_T)                   :: ngoprSetID
    1291             :       INTEGER(HID_T)                   :: ntypsySetID
    1292             :       INTEGER(HID_T)                   :: nlhtypSetID
    1293             :       INTEGER(HID_T)                   :: invsatSetID
    1294             :       INTEGER(HID_T)                   :: rmtSetID
    1295             :       INTEGER(HID_T)                   :: dxSetID
    1296             :       INTEGER(HID_T)                   :: volmtsSetID
    1297             :       INTEGER(HID_T)                   :: rmshSetID
    1298             :       INTEGER(HID_T)                   :: zatomSetID
    1299             :       INTEGER(HID_T)                   :: posSetID
    1300             :       INTEGER(HID_T)                   :: taualSetID
    1301             :       INTEGER(HID_T)                   :: mrotSetID
    1302             :       INTEGER(HID_T)                   :: tauSetID
    1303             : 
    1304             :       !LDA+U IDs (start)
    1305             :       INTEGER(HID_T)                   :: ldau_AtomTypeSetID
    1306             :       INTEGER(HID_T)                   :: ldau_lSetID
    1307             :       INTEGER(HID_T)                   :: ldau_l_amfSetID
    1308             :       INTEGER(HID_T)                   :: ldau_USetID
    1309             :       INTEGER(HID_T)                   :: ldau_JSetID
    1310             :       !LDA+U IDs (end)
    1311             : 
    1312         238 :       CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
    1313             :       ! read in file format version from the header '/general'
    1314         238 :       CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
    1315             : 
    1316         238 :       WRITE(groupname,'(a,i0)') '/structure-', structureIndex
    1317             : 
    1318         238 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1319             : 
    1320         238 :       IF (.NOT.l_exist) THEN
    1321           0 :          CALL juDFT_error('structure entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readStructureHDF")
    1322             :       END IF
    1323             : 
    1324         238 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1325             : 
    1326         238 :       CALL io_read_attlog0(groupID,'l_film',input%film)
    1327             : 
    1328         238 :       CALL io_read_attreal0(groupID,'omtil',cell%omtil)
    1329         238 :       CALL io_read_attreal0(groupID,'area',cell%area)
    1330         238 :       CALL io_read_attreal0(groupID,'z1',cell%z1)
    1331         238 :       CALL io_read_attreal0(groupID,'vol',cell%vol)
    1332         238 :       CALL io_read_attreal0(groupID,'volint',cell%volint)
    1333             : 
    1334         238 :       CALL io_read_attint0(groupID,'ntype',atoms%ntype)
    1335         238 :       CALL io_read_attint0(groupID,'nat',atoms%nat)
    1336         238 :       CALL io_read_attint0(groupID,'lmaxd',atoms%lmaxd)
    1337         238 :       CALL io_read_attint0(groupID,'jmtd',atoms%jmtd)
    1338             : 
    1339         238 :       CALL io_read_attint0(groupID,'nmz',vacuum%nmz)
    1340         238 :       CALL io_read_attint0(groupID,'nmzd',vacuum%nmzd)
    1341         238 :       CALL io_read_attint0(groupID,'nmzxy',vacuum%nmzxy)
    1342         238 :       CALL io_read_attint0(groupID,'nmzxyd',vacuum%nmzxyd)
    1343         238 :       CALL io_read_attint0(groupID,'layerd',vacuum%layerd)
    1344         238 :       CALL io_read_attint0(groupID,'layers',vacuum%layers)
    1345         238 :       CALL io_read_attint0(groupID,'nvac',vacuum%nvac)
    1346         238 :       CALL io_read_attint0(groupID,'nvacd',vacuum%nvacd)
    1347         238 :       CALL io_read_attint0(groupID,'nstars',vacuum%nstars)
    1348         238 :       CALL io_read_attint0(groupID,'nstm',vacuum%nstm)
    1349         238 :       CALL io_read_attreal0(groupID,'delz',vacuum%delz)
    1350         238 :       CALL io_read_attreal0(groupID,'dvac',vacuum%dvac)
    1351             : 
    1352         238 :       CALL io_read_attint0(groupID,'od_nq2',oneD%odi%nq2)
    1353             : 
    1354         238 :       CALL io_read_attlog0(groupID,'invs2',sym%invs2)
    1355         238 :       CALL io_read_attlog0(groupID,'invs',sym%invs)
    1356         238 :       CALL io_read_attlog0(groupID,'zrfs',sym%zrfs)
    1357         238 :       CALL io_read_attint0(groupID,'nop',sym%nop)
    1358         238 :       CALL io_read_attint0(groupID,'nop2',sym%nop2)
    1359         238 :       CALL io_read_attchar0(groupID,'latnam',sym%latnam)
    1360         238 :       CALL io_read_attchar0(groupID,'namgrp',sym%namgrp)
    1361             : 
    1362         238 :       IF(fileFormatVersion.GE.29) THEN
    1363         238 :          CALL io_read_attint0(groupID,'n_u',atoms%n_u)
    1364         238 :          IF(ALLOCATED(atoms%lda_u)) DEALLOCATE(atoms%lda_u)
    1365         238 :          ALLOCATE(atoms%lda_u(atoms%n_u))
    1366             :       END IF
    1367             : 
    1368         238 :       IF(ALLOCATED(atoms%nz)) DEALLOCATE(atoms%nz)
    1369         238 :       IF(ALLOCATED(atoms%neq)) DEALLOCATE(atoms%neq)
    1370         238 :       IF(ALLOCATED(atoms%jri)) DEALLOCATE(atoms%jri)
    1371         238 :       IF(ALLOCATED(atoms%lmax)) DEALLOCATE(atoms%lmax)
    1372         238 :       IF(ALLOCATED(atoms%ngopr)) DEALLOCATE(atoms%ngopr)
    1373         238 :       IF(ALLOCATED(atoms%ntypsy)) DEALLOCATE(atoms%ntypsy)
    1374         238 :       IF(ALLOCATED(atoms%nlhtyp)) DEALLOCATE(atoms%nlhtyp)
    1375         238 :       IF(ALLOCATED(atoms%invsat)) DEALLOCATE(atoms%invsat)
    1376         238 :       IF(ALLOCATED(atoms%rmt)) DEALLOCATE(atoms%rmt)
    1377         238 :       IF(ALLOCATED(atoms%dx)) DEALLOCATE(atoms%dx)
    1378         238 :       IF(ALLOCATED(atoms%volmts)) DEALLOCATE(atoms%volmts)
    1379         238 :       IF(ALLOCATED(atoms%rmsh)) DEALLOCATE(atoms%rmsh)
    1380         238 :       IF(ALLOCATED(atoms%zatom)) DEALLOCATE(atoms%zatom)
    1381         238 :       IF(ALLOCATED(atoms%pos)) DEALLOCATE(atoms%pos)
    1382         238 :       IF(ALLOCATED(atoms%taual)) DEALLOCATE(atoms%taual)
    1383         238 :       IF(ALLOCATED(sym%mrot)) DEALLOCATE(sym%mrot)
    1384         238 :       IF(ALLOCATED(sym%tau)) DEALLOCATE(sym%tau)
    1385             : 
    1386         238 :       ALLOCATE(atoms%nz(atoms%ntype))
    1387         238 :       ALLOCATE(atoms%neq(atoms%ntype))
    1388         238 :       ALLOCATE(atoms%jri(atoms%ntype))
    1389         238 :       ALLOCATE(atoms%lmax(atoms%ntype))
    1390         238 :       ALLOCATE(atoms%ngopr(atoms%nat))
    1391         238 :       ALLOCATE(atoms%ntypsy(atoms%nat))
    1392         238 :       ALLOCATE(atoms%nlhtyp(atoms%ntype))
    1393         238 :       ALLOCATE(atoms%invsat(atoms%nat))
    1394         238 :       ALLOCATE(atoms%rmt(atoms%ntype))
    1395         238 :       ALLOCATE(atoms%dx(atoms%ntype))
    1396         238 :       ALLOCATE(atoms%volmts(atoms%ntype))
    1397         238 :       ALLOCATE(atoms%rmsh(atoms%jmtd,atoms%ntype))
    1398         238 :       ALLOCATE(atoms%zatom(atoms%ntype))
    1399         238 :       ALLOCATE(atoms%pos(3,atoms%nat))
    1400         238 :       ALLOCATE(atoms%taual(3,atoms%nat))
    1401         238 :       ALLOCATE(sym%mrot(3,3,sym%nop))
    1402         238 :       ALLOCATE(sym%tau(3,sym%nop))
    1403             : 
    1404         714 :       dimsInt(:2)=(/3,3/)
    1405         238 :       CALL h5dopen_f(groupID, 'amat', amatSetID, hdfError)
    1406         238 :       CALL io_read_real2(amatSetID,(/1,1/),dimsInt(:2),cell%amat)
    1407         238 :       CALL h5dclose_f(amatSetID, hdfError)
    1408             : 
    1409         238 :       dimsInt(:1)=(/atoms%ntype/)
    1410         238 :       CALL h5dopen_f(groupID, 'nz', nzSetID, hdfError)
    1411         238 :       CALL io_read_integer1(nzSetID,(/1/),dimsInt(:1),atoms%nz)
    1412         238 :       CALL h5dclose_f(nzSetID, hdfError)
    1413             : 
    1414         238 :       dimsInt(:1)=(/atoms%ntype/)
    1415         238 :       CALL h5dopen_f(groupID, 'neq', neqSetID, hdfError)
    1416         238 :       CALL io_read_integer1(neqSetID,(/1/),dimsInt(:1),atoms%neq)
    1417         238 :       CALL h5dclose_f(neqSetID, hdfError)
    1418             : 
    1419         238 :       dimsInt(:1)=(/atoms%ntype/)
    1420         238 :       CALL h5dopen_f(groupID, 'jri', jriSetID, hdfError)
    1421         238 :       CALL io_read_integer1(jriSetID,(/1/),dimsInt(:1),atoms%jri)
    1422         238 :       CALL h5dclose_f(jriSetID, hdfError)
    1423             : 
    1424         238 :       dimsInt(:1)=(/atoms%ntype/)
    1425         238 :       CALL h5dopen_f(groupID, 'lmax', lmaxSetID, hdfError)
    1426         238 :       CALL io_read_integer1(lmaxSetID,(/1/),dimsInt(:1),atoms%lmax)
    1427         238 :       CALL h5dclose_f(lmaxSetID, hdfError)
    1428             : 
    1429         238 :       dimsInt(:1)=(/atoms%nat/)
    1430         238 :       CALL h5dopen_f(groupID, 'ngopr', ngoprSetID, hdfError)
    1431         238 :       CALL io_read_integer1(ngoprSetID,(/1/),dimsInt(:1),atoms%ngopr)
    1432         238 :       CALL h5dclose_f(ngoprSetID, hdfError)
    1433             : 
    1434         238 :       dimsInt(:1)=(/atoms%nat/)
    1435         238 :       CALL h5dopen_f(groupID, 'ntypsy', ntypsySetID, hdfError)
    1436         238 :       CALL io_read_integer1(ntypsySetID,(/1/),dimsInt(:1),atoms%ntypsy)
    1437         238 :       CALL h5dclose_f(ntypsySetID, hdfError)
    1438             : 
    1439         238 :       dimsInt(:1)=(/atoms%ntype/)
    1440         238 :       CALL h5dopen_f(groupID, 'nlhtyp', nlhtypSetID, hdfError)
    1441         238 :       CALL io_read_integer1(nlhtypSetID,(/1/),dimsInt(:1),atoms%nlhtyp)
    1442         238 :       CALL h5dclose_f(nlhtypSetID, hdfError)
    1443             : 
    1444         238 :       dimsInt(:1)=(/atoms%nat/)
    1445         238 :       CALL h5dopen_f(groupID, 'invsat', invsatSetID, hdfError)
    1446         238 :       CALL io_read_integer1(invsatSetID,(/1/),dimsInt(:1),atoms%invsat)
    1447         238 :       CALL h5dclose_f(invsatSetID, hdfError)
    1448             : 
    1449         238 :       dimsInt(:1)=(/atoms%ntype/)
    1450         238 :       CALL h5dopen_f(groupID, 'rmt', rmtSetID, hdfError)
    1451         238 :       CALL io_read_real1(rmtSetID,(/1/),dimsInt(:1),atoms%rmt)
    1452         238 :       CALL h5dclose_f(rmtSetID, hdfError)
    1453             : 
    1454         238 :       dimsInt(:1)=(/atoms%ntype/)
    1455         238 :       CALL h5dopen_f(groupID, 'dx', dxSetID, hdfError)
    1456         238 :       CALL io_read_real1(dxSetID,(/1/),dimsInt(:1),atoms%dx)
    1457         238 :       CALL h5dclose_f(dxSetID, hdfError)
    1458             : 
    1459         238 :       dimsInt(:1)=(/atoms%ntype/)
    1460         238 :       CALL h5dopen_f(groupID, 'volmts', volmtsSetID, hdfError)
    1461         238 :       CALL io_read_real1(volmtsSetID,(/1/),dimsInt(:1),atoms%volmts)
    1462         238 :       CALL h5dclose_f(volmtsSetID, hdfError)
    1463             : 
    1464         238 :       dimsInt(:2)=(/atoms%jmtd,atoms%ntype/)
    1465         238 :       CALL h5dopen_f(groupID, 'rmsh', rmshSetID, hdfError)
    1466         238 :       CALL io_read_real2(rmshSetID,(/1,1/),dimsInt(:2),atoms%rmsh)
    1467         238 :       CALL h5dclose_f(rmshSetID, hdfError)
    1468             : 
    1469         238 :       dimsInt(:1)=(/atoms%ntype/)
    1470         238 :       CALL h5dopen_f(groupID, 'zatom', zatomSetID, hdfError)
    1471         238 :       CALL io_read_real1(zatomSetID,(/1/),dimsInt(:1),atoms%zatom)
    1472         238 :       CALL h5dclose_f(zatomSetID, hdfError)
    1473             : 
    1474         238 :       dimsInt(:2)=(/3,atoms%nat/)
    1475         238 :       CALL h5dopen_f(groupID, 'pos', posSetID, hdfError)
    1476         238 :       CALL io_read_real2(posSetID,(/1,1/),dimsInt(:2),atoms%pos)
    1477         238 :       CALL h5dclose_f(posSetID, hdfError)
    1478             : 
    1479         238 :       dimsInt(:2)=(/3,atoms%nat/)
    1480         238 :       CALL h5dopen_f(groupID, 'taual', taualSetID, hdfError)
    1481         238 :       CALL io_read_real2(taualSetID,(/1,1/),dimsInt(:2),atoms%taual)
    1482         238 :       CALL h5dclose_f(taualSetID, hdfError)
    1483             : 
    1484         238 :       dimsInt(:3) = (/3,3,sym%nop/)
    1485         238 :       CALL h5dopen_f(groupID, 'mrot', mrotSetID, hdfError)
    1486         238 :       CALL io_read_integer3(mrotSetID,(/1,1,1/),dimsInt(:3),sym%mrot)
    1487         238 :       CALL h5dclose_f(mrotSetID, hdfError)
    1488             : 
    1489         238 :       dimsInt(:2) = (/3,sym%nop/)
    1490         238 :       CALL h5dopen_f(groupID, 'tau', tauSetID, hdfError)
    1491         238 :       CALL io_read_real2(tauSetID,(/1,1/),dimsInt(:2),sym%tau)
    1492         238 :       CALL h5dclose_f(tauSetID, hdfError)
    1493             : 
    1494             :       !LDA+U data (start)
    1495         238 :       IF((fileFormatVersion.GE.29).AND.(atoms%n_u.GT.0)) THEN
    1496          22 :          ALLOCATE(ldau_AtomType(atoms%n_u), ldau_l(atoms%n_u), ldau_l_amf(atoms%n_u))
    1497          22 :          ALLOCATE(ldau_U(atoms%n_u), ldau_J(atoms%n_u))
    1498             : 
    1499          22 :          dimsInt(:1)=(/atoms%n_u/)
    1500          22 :          CALL h5dopen_f(groupID, 'ldau_AtomType', ldau_AtomTypeSetID, hdfError)
    1501          22 :          CALL io_read_integer1(ldau_AtomTypeSetID,(/1/),dimsInt(:1),ldau_AtomType)
    1502          22 :          CALL h5dclose_f(ldau_AtomTypeSetID, hdfError)
    1503             : 
    1504          22 :          dimsInt(:1)=(/atoms%n_u/)
    1505          22 :          CALL h5dopen_f(groupID, 'ldau_l', ldau_lSetID, hdfError)
    1506          22 :          CALL io_read_integer1(ldau_lSetID,(/1/),dimsInt(:1),ldau_l)
    1507          22 :          CALL h5dclose_f(ldau_lSetID, hdfError)
    1508             : 
    1509          22 :          dimsInt(:1)=(/atoms%n_u/)
    1510          22 :          CALL h5dopen_f(groupID, 'ldau_l_amf', ldau_l_amfSetID, hdfError)
    1511          22 :          CALL io_read_integer1(ldau_l_amfSetID,(/1/),dimsInt(:1),ldau_l_amf)
    1512          22 :          CALL h5dclose_f(ldau_l_amfSetID, hdfError)
    1513             : 
    1514          22 :          dimsInt(:1)=(/atoms%n_u/)
    1515          22 :          CALL h5dopen_f(groupID, 'ldau_U', ldau_USetID, hdfError)
    1516          22 :          CALL io_read_real1(ldau_USetID,(/1/),dimsInt(:1),ldau_U)
    1517          22 :          CALL h5dclose_f(ldau_USetID, hdfError)
    1518             : 
    1519          22 :          dimsInt(:1)=(/atoms%n_u/)
    1520          22 :          CALL h5dopen_f(groupID, 'ldau_J', ldau_JSetID, hdfError)
    1521          22 :          CALL io_read_real1(ldau_JSetID,(/1/),dimsInt(:1),ldau_J)
    1522          22 :          CALL h5dclose_f(ldau_JSetID, hdfError)
    1523             : 
    1524         110 :          DO i = 1, atoms%n_u
    1525          88 :             atoms%lda_u(i)%atomType = ldau_AtomType(i)
    1526          88 :             atoms%lda_u(i)%l = ldau_l(i)
    1527          88 :             atoms%lda_u(i)%u = ldau_U(i)
    1528          88 :             atoms%lda_u(i)%j = ldau_J(i)
    1529          88 :             atoms%lda_u(i)%l_amf = .FALSE.
    1530         110 :             IF(ldau_l_amf(i).EQ.1) atoms%lda_u(i)%l_amf = .TRUE.
    1531             :          END DO
    1532          22 :          DEALLOCATE(ldau_AtomType,ldau_l,ldau_U,ldau_J,ldau_l_amf)
    1533             :       END IF
    1534             :       !LDA+U data (end)
    1535             : 
    1536         238 :       CALL h5gclose_f(groupID, hdfError)
    1537             : 
    1538         238 :    END SUBROUTINE readStructureHDF
    1539             : 
    1540         223 :    SUBROUTINE writeDensityHDF(input, fileID, archiveName, densityType, previousDensityIndex,&
    1541             :                               starsIndex, latharmsIndex, structureIndex, stepfunctionIndex,&
    1542             :                               date,time,distance,fermiEnergy,l_qfix,iter,den)
    1543             : 
    1544             :       TYPE(t_input),    INTENT(IN) :: input
    1545             :       TYPE(t_potden),   INTENT(IN) :: den
    1546             :       INTEGER(HID_T),   INTENT(IN) :: fileID
    1547             :       INTEGER,          INTENT(IN) :: densityType, previousDensityIndex
    1548             :       INTEGER,          INTENT(IN) :: starsIndex, latharmsIndex, structureIndex
    1549             :       INTEGER,          INTENT(IN) :: stepfunctionIndex
    1550             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    1551             : 
    1552             :       INTEGER, INTENT (IN)         :: date, time, iter
    1553             :       REAL,    INTENT (IN)         :: fermiEnergy, distance
    1554             :       LOGICAL, INTENT (IN)         :: l_qfix
    1555             : 
    1556             :       INTEGER                      :: i, iVac
    1557             :       INTEGER                      :: ntype,jmtd,nmzd,nmzxyd,nlhd,ng3,ng2
    1558             :       INTEGER                      :: nmz,nvac,od_nq2,nmzxy,n_u
    1559             :       INTEGER                      :: hdfError, fileFormatVersion
    1560             :       LOGICAL                      :: l_film,l_exist,l_delete
    1561             :       INTEGER(HID_T)               :: archiveID, groupID, generalGroupID
    1562             :       CHARACTER(LEN=30)            :: groupName, densityTypeName
    1563             :       INTEGER(HSIZE_T)             :: dims(7)
    1564             :       INTEGER                      :: dimsInt(7)
    1565             :       INTEGER                      :: starsIndexTemp, latharmsIndexTemp
    1566             :       INTEGER                      :: structureIndexTemp, stepfunctionIndexTemp
    1567             :       INTEGER                      :: jspinsTemp
    1568             : 
    1569             :       INTEGER(HID_T)               :: frSpaceID, frSetID
    1570             :       INTEGER(HID_T)               :: fpwSpaceID, fpwSetID
    1571             :       INTEGER(HID_T)               :: fzSpaceID, fzSetID
    1572             :       INTEGER(HID_T)               :: fzxySpaceID, fzxySetID
    1573             :       INTEGER(HID_T)               :: cdomSpaceID, cdomSetID
    1574             :       INTEGER(HID_T)               :: cdomvzSpaceID, cdomvzSetID
    1575             :       INTEGER(HID_T)               :: cdomvxySpaceID, cdomvxySetID
    1576             :       INTEGER(HID_T)               :: mmpMatSpaceID, mmpMatSetID
    1577             : 
    1578         223 :       COMPLEX, ALLOCATABLE         :: cdomvz(:,:)
    1579             : 
    1580             : 
    1581         223 :       CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
    1582             :       ! read in file format version from the header '/general'
    1583         223 :       CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
    1584             : 
    1585         223 :       WRITE(groupname,'(a,i0)') '/structure-', structureIndex
    1586         223 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1587         223 :       IF(.NOT.l_exist) THEN
    1588           0 :          CALL juDFT_error("Structure entry "//TRIM(ADJUSTL(groupName))//" does not exist",calledby ="writeDensityHDF")
    1589             :       END IF
    1590         223 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1591         223 :       CALL io_read_attlog0(groupID,'l_film',l_film)
    1592         223 :       CALL io_read_attint0(groupID,'ntype',ntype)
    1593         223 :       CALL io_read_attint0(groupID,'jmtd',jmtd)
    1594         223 :       CALL io_read_attint0(groupID,'nmzd',nmzd)
    1595         223 :       CALL io_read_attint0(groupID,'nmzxyd',nmzxyd)
    1596         223 :       CALL io_read_attint0(groupID,'nmzxy',nmzxy)
    1597         223 :       CALL io_read_attint0(groupID,'nmz',nmz)
    1598         223 :       CALL io_read_attint0(groupID,'nvac',nvac)
    1599         223 :       CALL io_read_attint0(groupID,'od_nq2',od_nq2)
    1600         223 :       n_u = 0
    1601         223 :       IF(fileFormatVersion.GE.29) THEN
    1602         223 :          CALL io_read_attint0(groupID,'n_u',n_u)
    1603             :       END IF
    1604             : 
    1605         223 :       CALL h5gclose_f(groupID, hdfError)
    1606             : 
    1607         223 :       WRITE(groupname,'(a,i0)') '/latharms-', latharmsIndex
    1608         223 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1609         223 :       IF(.NOT.l_exist) THEN
    1610           0 :          CALL juDFT_error("Latharms entry "//TRIM(ADJUSTL(groupName))//" does not exist",calledby ="writeDensityHDF")
    1611             :       END IF
    1612         223 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1613         223 :       CALL io_read_attint0(groupID,'nlhd',nlhd)
    1614         223 :       CALL h5gclose_f(groupID, hdfError)
    1615             : 
    1616         223 :       WRITE(groupname,'(a,i0)') '/stars-', starsIndex
    1617         223 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1618         223 :       IF(.NOT.l_exist) THEN
    1619           0 :          CALL juDFT_error("Stars entry "//TRIM(ADJUSTL(groupName))//" does not exist",calledby ="writeDensityHDF")
    1620             :       END IF
    1621         223 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1622         223 :       CALL io_read_attint0(groupID,'ng3',ng3)
    1623         223 :       CALL io_read_attint0(groupID,'ng2',ng2)
    1624         223 :       CALL h5gclose_f(groupID, hdfError)
    1625             : 
    1626         223 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    1627             : 
    1628         315 :       SELECT CASE (densityType)
    1629             :          CASE(DENSITY_TYPE_IN_const)
    1630          92 :             densityTypeName = '/in'
    1631             :          CASE(DENSITY_TYPE_OUT_const)
    1632           0 :             densityTypeName = '/out'
    1633             :          CASE(DENSITY_TYPE_NOCO_IN_const)
    1634         131 :             densityTypeName = '/noco_in'
    1635             :          CASE(DENSITY_TYPE_NOCO_OUT_const)
    1636           0 :             densityTypeName = '/noco_out'
    1637             :          CASE(DENSITY_TYPE_PRECOND_const)
    1638           0 :             densityTypeName = '/precond'
    1639             :          CASE DEFAULT
    1640         223 :             CALL juDFT_error("Unknown density type selected",calledby ="writeDensityHDF")
    1641             :       END SELECT
    1642             : 
    1643         223 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    1644             : 
    1645         223 :       l_delete = .FALSE.
    1646         223 :       IF(l_exist) THEN
    1647          33 :          CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    1648             : 
    1649          33 :          CALL io_read_attint0(archiveID,'starsIndex',starsIndexTemp)
    1650          33 :          CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndexTemp)
    1651          33 :          CALL io_read_attint0(archiveID,'structureIndex',structureIndexTemp)
    1652          33 :          CALL io_read_attint0(archiveID,'stepfunctionIndex',stepfunctionIndexTemp)
    1653          33 :          CALL io_read_attint0(archiveID,'spins',jspinsTemp)
    1654             : 
    1655          33 :          IF (starsIndex.NE.starsIndexTemp) l_delete = .TRUE.
    1656          33 :          IF (latharmsIndex.NE.latharmsIndexTemp) l_delete = .TRUE.
    1657          33 :          IF (structureIndex.NE.structureIndexTemp) l_delete = .TRUE.
    1658          33 :          IF (stepfunctionIndex.NE.stepfunctionIndexTemp) l_delete = .TRUE.
    1659          33 :          IF (input%jspins.NE.jspinsTemp) l_delete = .TRUE.
    1660             : 
    1661          33 :          CALL h5gclose_f(archiveID, hdfError)
    1662             :       END IF
    1663             : 
    1664          33 :       IF(l_delete) THEN
    1665           0 :          CALL h5ldelete_f(fileID, archiveName, hdfError)
    1666           0 :          l_exist = .FALSE.
    1667             :       END IF
    1668             : 
    1669         223 :       IF(l_exist) THEN
    1670          33 :          CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    1671             : 
    1672          33 :          CALL io_write_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
    1673          33 :          CALL io_write_attint0(archiveID,'starsIndex',starsIndex)
    1674          33 :          CALL io_write_attint0(archiveID,'latharmsIndex',latharmsIndex)
    1675          33 :          CALL io_write_attint0(archiveID,'structureIndex',structureIndex)
    1676          33 :          CALL io_write_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    1677          33 :          CALL io_write_attint0(archiveID,'spins',input%jspins)
    1678          33 :          CALL io_write_attint0(archiveID,'iter',iter)
    1679          33 :          IF (distance.GE.-1e-10) THEN
    1680           0 :             CALL io_write_attreal0(archiveID,'distance',distance)
    1681             :          END IF
    1682             : 
    1683          33 :          l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1684             : 
    1685          33 :          IF(l_exist) THEN
    1686          26 :             CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1687             : 
    1688          26 :             CALL io_write_attreal0(groupID,'fermiEnergy',fermiEnergy)
    1689          26 :             CALL io_write_attlog0(groupID,'l_qfix',l_qfix)
    1690             : 
    1691          26 :             dimsInt(:4)=(/jmtd,nlhd+1,ntype,input%jspins/)
    1692          26 :             CALL h5dopen_f(groupID, 'fr', frSetID, hdfError)
    1693          26 :             CALL io_write_real4(frSetID,(/1,1,1,1/),dimsInt(:4),den%mt)
    1694          26 :             CALL h5dclose_f(frSetID, hdfError)
    1695             : 
    1696          26 :             dimsInt(:3)=(/2,ng3,input%jspins/)
    1697          26 :             CALL h5dopen_f(groupID, 'fpw', fpwSetID, hdfError)
    1698          26 :             CALL io_write_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),den%pw(:,:input%jspins))
    1699          26 :             CALL h5dclose_f(fpwSetID, hdfError)
    1700             : 
    1701          26 :             IF (l_film) THEN
    1702           5 :                dimsInt(:3)=(/nmzd,2,input%jspins/)
    1703           5 :                CALL h5dopen_f(groupID, 'fz', fzSetID, hdfError)
    1704           5 :                CALL io_write_real3(fzSetID,(/1,1,1/),dimsInt(:3),den%vacz(:,:,:input%jspins))
    1705           5 :                CALL h5dclose_f(fzSetID, hdfError)
    1706             : 
    1707           5 :                dimsInt(:5)=(/2,nmzxyd,ng2-1,2,input%jspins/)
    1708           5 :                CALL h5dopen_f(groupID, 'fzxy', fzxySetID, hdfError)
    1709           5 :                CALL io_write_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),den%vacxy(:,:,:,:input%jspins))
    1710           5 :                CALL h5dclose_f(fzxySetID, hdfError)
    1711             :             END IF
    1712             : 
    1713          26 :             IF((densityType.EQ.DENSITY_TYPE_NOCO_IN_const).OR.&
    1714             :                (densityType.EQ.DENSITY_TYPE_NOCO_OUT_const)) THEN
    1715             : 
    1716           0 :                dimsInt(:2)=(/2,ng3/)
    1717           0 :                CALL h5dopen_f(groupID, 'cdom', cdomSetID, hdfError)
    1718           0 :                CALL io_write_complex1(cdomSetID,(/-1,1/),dimsInt(:2),den%pw(:,3))
    1719           0 :                CALL h5dclose_f(cdomSetID, hdfError)
    1720             : 
    1721           0 :                IF (l_film) THEN
    1722           0 :                   ALLOCATE(cdomvz(nmz,nvac))
    1723           0 :                   DO iVac = 1, nvac
    1724           0 :                      DO i = 1, nmz
    1725           0 :                         cdomvz(i,iVac) = CMPLX(den%vacz(i,iVac,3),den%vacz(i,iVac,4))
    1726             :                      END DO
    1727             :                   END DO
    1728           0 :                   dimsInt(:3)=(/2,nmz,nvac/)
    1729           0 :                   CALL h5dopen_f(groupID, 'cdomvz', cdomvzSetID, hdfError)
    1730           0 :                   CALL io_write_complex2(cdomvzSetID,(/-1,1,1/),dimsInt(:3),cdomvz)
    1731           0 :                   CALL h5dclose_f(cdomvzSetID, hdfError)
    1732           0 :                   DEALLOCATE(cdomvz)
    1733             : 
    1734           0 :                   dimsInt(:4)=(/2,nmzxy,od_nq2-1,nvac/)
    1735           0 :                   CALL h5dopen_f(groupID, 'cdomvxy', cdomvxySetID, hdfError)
    1736           0 :                   CALL io_write_complex3(cdomvxySetID,(/-1,1,1,1/),dimsInt(:4),den%vacxy(:,:,:nvac,3))
    1737           0 :                   CALL h5dclose_f(cdomvxySetID, hdfError)
    1738             :                END IF
    1739             :             END IF
    1740             : 
    1741          26 :             IF ((fileFormatVersion.GE.29).AND.(n_u.GT.0)) THEN
    1742           3 :                dimsInt(:5)=(/2,2*lmaxU_const+1,2*lmaxU_const+1,n_u,input%jspins/)
    1743           3 :                CALL h5dopen_f(groupID, 'mmpMat', mmpMatSetID, hdfError)
    1744           3 :                CALL io_write_complex4(mmpMatSetID,(/-1,1,1,1,1/),dimsInt(:5),den%mmpMat)
    1745           3 :                CALL h5dclose_f(mmpMatSetID, hdfError)
    1746             :             END IF
    1747             : 
    1748          26 :             CALL h5gclose_f(groupID, hdfError)
    1749             :          ELSE
    1750           7 :             CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1751             : 
    1752           7 :             CALL io_write_attreal0(groupID,'fermiEnergy',fermiEnergy)
    1753           7 :             CALL io_write_attlog0(groupID,'l_qfix',l_qfix)
    1754             : 
    1755           7 :             dims(:4)=(/jmtd,nlhd+1,ntype,input%jspins/)
    1756          56 :             dimsInt = dims
    1757           7 :             CALL h5screate_simple_f(4,dims(:4),frSpaceID,hdfError)
    1758           7 :             CALL h5dcreate_f(groupID, "fr", H5T_NATIVE_DOUBLE, frSpaceID, frSetID, hdfError)
    1759           7 :             CALL h5sclose_f(frSpaceID,hdfError)
    1760           7 :             CALL io_write_real4(frSetID,(/1,1,1,1/),dimsInt(:4),den%mt)
    1761           7 :             CALL h5dclose_f(frSetID, hdfError)
    1762             : 
    1763           7 :             dims(:3)=(/2,ng3,input%jspins/)
    1764          56 :             dimsInt = dims
    1765           7 :             CALL h5screate_simple_f(3,dims(:3),fpwSpaceID,hdfError)
    1766           7 :             CALL h5dcreate_f(groupID, "fpw", H5T_NATIVE_DOUBLE, fpwSpaceID, fpwSetID, hdfError)
    1767           7 :             CALL h5sclose_f(fpwSpaceID,hdfError)
    1768           7 :             CALL io_write_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),den%pw(:,:input%jspins))
    1769           7 :             CALL h5dclose_f(fpwSetID, hdfError)
    1770             : 
    1771           7 :             IF (l_film) THEN
    1772           0 :                dims(:3)=(/nmzd,2,input%jspins/)
    1773           0 :                dimsInt = dims
    1774           0 :                CALL h5screate_simple_f(3,dims(:3),fzSpaceID,hdfError)
    1775           0 :                CALL h5dcreate_f(groupID, "fz", H5T_NATIVE_DOUBLE, fzSpaceID, fzSetID, hdfError)
    1776           0 :                CALL h5sclose_f(fzSpaceID,hdfError)
    1777           0 :                CALL io_write_real3(fzSetID,(/1,1,1/),dimsInt(:3),den%vacz(:,:,:input%jspins))
    1778           0 :                CALL h5dclose_f(fzSetID, hdfError)
    1779             : 
    1780           0 :                dims(:5)=(/2,nmzxyd,ng2-1,2,input%jspins/)
    1781           0 :                dimsInt = dims
    1782           0 :                CALL h5screate_simple_f(5,dims(:5),fzxySpaceID,hdfError)
    1783           0 :                CALL h5dcreate_f(groupID, "fzxy", H5T_NATIVE_DOUBLE, fzxySpaceID, fzxySetID, hdfError)
    1784           0 :                CALL h5sclose_f(fzxySpaceID,hdfError)
    1785           0 :                CALL io_write_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),den%vacxy(:,:,:,:input%jspins))
    1786           0 :                CALL h5dclose_f(fzxySetID, hdfError)
    1787             :             END IF
    1788             : 
    1789           7 :             IF((densityType.EQ.DENSITY_TYPE_NOCO_IN_const).OR.&
    1790             :                (densityType.EQ.DENSITY_TYPE_NOCO_OUT_const)) THEN
    1791             : 
    1792           7 :                dims(:2)=(/2,ng3/)
    1793          56 :                dimsInt = dims
    1794           7 :                CALL h5screate_simple_f(2,dims(:2),cdomSpaceID,hdfError)
    1795           7 :                CALL h5dcreate_f(groupID, "cdom", H5T_NATIVE_DOUBLE, cdomSpaceID, cdomSetID, hdfError)
    1796           7 :                CALL h5sclose_f(cdomSpaceID,hdfError)
    1797           7 :                CALL io_write_complex1(cdomSetID,(/-1,1/),dimsInt(:2),den%pw(:,3))
    1798           7 :                CALL h5dclose_f(cdomSetID, hdfError)
    1799             : 
    1800           7 :                IF (l_film) THEN
    1801           0 :                   ALLOCATE(cdomvz(nmz,nvac))
    1802           0 :                   DO iVac = 1, nvac
    1803           0 :                      DO i = 1, nmz
    1804           0 :                         cdomvz(i,iVac) = CMPLX(den%vacz(i,iVac,3),den%vacz(i,iVac,4))
    1805             :                      END DO
    1806             :                   END DO
    1807           0 :                   dims(:3)=(/2,nmz,nvac/)
    1808           0 :                   dimsInt = dims
    1809           0 :                   CALL h5screate_simple_f(3,dims(:3),cdomvzSpaceID,hdfError)
    1810           0 :                   CALL h5dcreate_f(groupID, "cdomvz", H5T_NATIVE_DOUBLE, cdomvzSpaceID, cdomvzSetID, hdfError)
    1811           0 :                   CALL h5sclose_f(cdomvzSpaceID,hdfError)
    1812           0 :                   CALL io_write_complex2(cdomvzSetID,(/-1,1,1/),dimsInt(:3),cdomvz)
    1813           0 :                   CALL h5dclose_f(cdomvzSetID, hdfError)
    1814           0 :                   DEALLOCATE(cdomvz)
    1815             : 
    1816           0 :                   dims(:4)=(/2,nmzxy,od_nq2-1,nvac/)
    1817           0 :                   dimsInt = dims
    1818           0 :                   CALL h5screate_simple_f(4,dims(:4),cdomvxySpaceID,hdfError)
    1819           0 :                   CALL h5dcreate_f(groupID, "cdomvxy", H5T_NATIVE_DOUBLE, cdomvxySpaceID, cdomvxySetID, hdfError)
    1820           0 :                   CALL h5sclose_f(cdomvxySpaceID,hdfError)
    1821           0 :                   CALL io_write_complex3(cdomvxySetID,(/-1,1,1,1/),dimsInt(:4),den%vacxy(:,:,:nvac,3))
    1822           0 :                   CALL h5dclose_f(cdomvxySetID, hdfError)
    1823             :                END IF
    1824             :             END IF
    1825             : 
    1826           7 :             IF ((fileFormatVersion.GE.29).AND.(n_u.GT.0)) THEN
    1827           0 :                dims(:5)=(/2,2*lmaxU_const+1,2*lmaxU_const+1,n_u,input%jspins/)
    1828           0 :                dimsInt = dims
    1829           0 :                CALL h5screate_simple_f(5,dims(:5),mmpMatSpaceID,hdfError)
    1830           0 :                CALL h5dcreate_f(groupID, "mmpMat", H5T_NATIVE_DOUBLE, mmpMatSpaceID, mmpMatSetID, hdfError)
    1831           0 :                CALL h5sclose_f(mmpMatSpaceID,hdfError)
    1832           0 :                CALL io_write_complex4(mmpMatSetID,(/-1,1,1,1,1/),dimsInt(:5),den%mmpMat)
    1833           0 :                CALL h5dclose_f(mmpMatSetID, hdfError)
    1834             :             END IF
    1835             : 
    1836           7 :             CALL h5gclose_f(groupID, hdfError)
    1837             :          END IF
    1838             : 
    1839          33 :          CALL h5gclose_f(archiveID, hdfError)
    1840             :       ELSE
    1841         190 :          CALL h5gcreate_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    1842             : 
    1843         190 :          CALL io_write_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
    1844         190 :          CALL io_write_attint0(archiveID,'starsIndex',starsIndex)
    1845         190 :          CALL io_write_attint0(archiveID,'latharmsIndex',latharmsIndex)
    1846         190 :          CALL io_write_attint0(archiveID,'structureIndex',structureIndex)
    1847         190 :          CALL io_write_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    1848         190 :          CALL io_write_attint0(archiveID,'spins',input%jspins)
    1849         190 :          CALL io_write_attint0(archiveID,'iter',iter)
    1850         190 :          CALL io_write_attint0(archiveID,'date',date)
    1851         190 :          CALL io_write_attint0(archiveID,'time',time)
    1852         190 :          CALL io_write_attreal0(archiveID,'distance',distance)
    1853             : 
    1854         190 :          CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1855             : 
    1856         190 :          CALL io_write_attreal0(groupID,'fermiEnergy',fermiEnergy)
    1857         190 :          CALL io_write_attlog0(groupID,'l_qfix',l_qfix)
    1858             : 
    1859         190 :          dims(:4)=(/jmtd,nlhd+1,ntype,input%jspins/)
    1860        1520 :          dimsInt = dims
    1861         190 :          CALL h5screate_simple_f(4,dims(:4),frSpaceID,hdfError)
    1862         190 :          CALL h5dcreate_f(groupID, "fr", H5T_NATIVE_DOUBLE, frSpaceID, frSetID, hdfError)
    1863         190 :          CALL h5sclose_f(frSpaceID,hdfError)
    1864         190 :          CALL io_write_real4(frSetID,(/1,1,1,1/),dimsInt(:4),den%mt)
    1865         190 :          CALL h5dclose_f(frSetID, hdfError)
    1866             : 
    1867         190 :          dims(:3)=(/2,ng3,input%jspins/)
    1868        1520 :          dimsInt = dims
    1869         190 :          CALL h5screate_simple_f(3,dims(:3),fpwSpaceID,hdfError)
    1870         190 :          CALL h5dcreate_f(groupID, "fpw", H5T_NATIVE_DOUBLE, fpwSpaceID, fpwSetID, hdfError)
    1871         190 :          CALL h5sclose_f(fpwSpaceID,hdfError)
    1872         190 :          CALL io_write_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),den%pw(:,:input%jspins))
    1873         190 :          CALL h5dclose_f(fpwSetID, hdfError)
    1874             : 
    1875         190 :          IF (l_film) THEN
    1876          10 :             dims(:3)=(/nmzd,2,input%jspins/)
    1877          80 :             dimsInt = dims
    1878          10 :             CALL h5screate_simple_f(3,dims(:3),fzSpaceID,hdfError)
    1879          10 :             CALL h5dcreate_f(groupID, "fz", H5T_NATIVE_DOUBLE, fzSpaceID, fzSetID, hdfError)
    1880          10 :             CALL h5sclose_f(fzSpaceID,hdfError)
    1881          10 :             CALL io_write_real3(fzSetID,(/1,1,1/),dimsInt(:3),den%vacz(:,:,:input%jspins))
    1882          10 :             CALL h5dclose_f(fzSetID, hdfError)
    1883             : 
    1884          10 :             dims(:5)=(/2,nmzxyd,ng2-1,2,input%jspins/)
    1885          80 :             dimsInt = dims
    1886          10 :             CALL h5screate_simple_f(5,dims(:5),fzxySpaceID,hdfError)
    1887          10 :             CALL h5dcreate_f(groupID, "fzxy", H5T_NATIVE_DOUBLE, fzxySpaceID, fzxySetID, hdfError)
    1888          10 :             CALL h5sclose_f(fzxySpaceID,hdfError)
    1889          10 :             CALL io_write_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),den%vacxy(:,:,:,:input%jspins))
    1890          10 :             CALL h5dclose_f(fzxySetID, hdfError)
    1891             :          END IF
    1892             : 
    1893         190 :          IF((densityType.EQ.DENSITY_TYPE_NOCO_IN_const).OR.&
    1894             :             (densityType.EQ.DENSITY_TYPE_NOCO_OUT_const)) THEN
    1895             : 
    1896         124 :             dims(:2)=(/2,ng3/)
    1897         992 :             dimsInt = dims
    1898         124 :             CALL h5screate_simple_f(2,dims(:2),cdomSpaceID,hdfError)
    1899         124 :             CALL h5dcreate_f(groupID, "cdom", H5T_NATIVE_DOUBLE, cdomSpaceID, cdomSetID, hdfError)
    1900         124 :             CALL h5sclose_f(cdomSpaceID,hdfError)
    1901         124 :             CALL io_write_complex1(cdomSetID,(/-1,1/),dimsInt(:2),den%pw(:,3))
    1902         124 :             CALL h5dclose_f(cdomSetID, hdfError)
    1903             : 
    1904         124 :             IF (l_film) THEN
    1905           0 :                ALLOCATE(cdomvz(nmz,nvac))
    1906           0 :                DO iVac = 1, nvac
    1907           0 :                   DO i = 1, nmz
    1908           0 :                      cdomvz(i,iVac) = CMPLX(den%vacz(i,iVac,3),den%vacz(i,iVac,4))
    1909             :                   END DO
    1910             :                END DO
    1911           0 :                dims(:3)=(/2,nmz,nvac/)
    1912           0 :                dimsInt = dims
    1913           0 :                CALL h5screate_simple_f(3,dims(:3),cdomvzSpaceID,hdfError)
    1914           0 :                CALL h5dcreate_f(groupID, "cdomvz", H5T_NATIVE_DOUBLE, cdomvzSpaceID, cdomvzSetID, hdfError)
    1915           0 :                CALL h5sclose_f(cdomvzSpaceID,hdfError)
    1916           0 :                CALL io_write_complex2(cdomvzSetID,(/-1,1,1/),dimsInt(:3),cdomvz)
    1917           0 :                CALL h5dclose_f(cdomvzSetID, hdfError)
    1918           0 :                DEALLOCATE(cdomvz)
    1919             : 
    1920           0 :                dims(:4)=(/2,nmzxy,od_nq2-1,nvac/)
    1921           0 :                dimsInt = dims
    1922           0 :                CALL h5screate_simple_f(4,dims(:4),cdomvxySpaceID,hdfError)
    1923           0 :                CALL h5dcreate_f(groupID, "cdomvxy", H5T_NATIVE_DOUBLE, cdomvxySpaceID, cdomvxySetID, hdfError)
    1924           0 :                CALL h5sclose_f(cdomvxySpaceID,hdfError)
    1925           0 :                CALL io_write_complex3(cdomvxySetID,(/-1,1,1,1/),dimsInt(:4),den%vacxy(:,:,:nvac,3))
    1926           0 :                CALL h5dclose_f(cdomvxySetID, hdfError)
    1927             :             END IF
    1928             :          END IF
    1929             : 
    1930         190 :          IF ((fileFormatVersion.GE.29).AND.(n_u.GT.0)) THEN
    1931          15 :             dims(:5)=(/2,2*lmaxU_const+1,2*lmaxU_const+1,n_u,input%jspins/)
    1932         120 :             dimsInt = dims
    1933          15 :             CALL h5screate_simple_f(5,dims(:5),mmpMatSpaceID,hdfError)
    1934          15 :             CALL h5dcreate_f(groupID, "mmpMat", H5T_NATIVE_DOUBLE, mmpMatSpaceID, mmpMatSetID, hdfError)
    1935          15 :             CALL h5sclose_f(mmpMatSpaceID,hdfError)
    1936          15 :             CALL io_write_complex4(mmpMatSetID,(/-1,1,1,1,1/),dimsInt(:5),den%mmpMat)
    1937          15 :             CALL h5dclose_f(mmpMatSetID, hdfError)
    1938             :          END IF
    1939             : 
    1940         190 :          CALL h5gclose_f(groupID, hdfError)
    1941             : 
    1942         190 :          CALL h5gclose_f(archiveID, hdfError)
    1943             :       END IF
    1944             : 
    1945         446 :    END SUBROUTINE writeDensityHDF
    1946             : 
    1947           0 :    SUBROUTINE writePotentialHDF(input, fileID, archiveName, potentialType,&
    1948             :                                 starsIndex, latharmsIndex, structureIndex,stepfunctionIndex,&
    1949           0 :                                 iter,pot,fpw)
    1950             : 
    1951             :       TYPE(t_input),    INTENT(IN) :: input
    1952             :       TYPE(t_potden),   INTENT(IN) :: pot
    1953             :       INTEGER(HID_T),   INTENT(IN) :: fileID
    1954             :       INTEGER,          INTENT(IN) :: potentialType
    1955             :       INTEGER,          INTENT(IN) :: starsIndex, latharmsIndex, structureIndex
    1956             :       INTEGER,          INTENT(IN) :: stepfunctionIndex
    1957             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    1958             : 
    1959             :       INTEGER, INTENT (IN)         :: iter
    1960             : 
    1961             :       COMPLEX, INTENT (IN)         :: fpw(:,:)
    1962             : 
    1963             :       INTEGER                      :: ntype,jmtd,nmzd,nmzxyd,nlhd,ng3,ng2
    1964             :       INTEGER                      :: nmz, nvac, od_nq2, nmzxy
    1965             :       INTEGER                      :: hdfError
    1966             :       LOGICAL                      :: l_film, l_exist, l_delete
    1967             :       INTEGER(HID_T)               :: archiveID, groupID
    1968             :       CHARACTER(LEN=30)            :: groupName, potentialTypeName
    1969             :       INTEGER(HSIZE_T)             :: dims(7)
    1970             :       INTEGER                      :: dimsInt(7)
    1971             : 
    1972             :       INTEGER                      :: starsIndexTemp, latharmsIndexTemp
    1973             :       INTEGER                      :: structureIndexTemp, stepfunctionIndexTemp
    1974             :       INTEGER                      :: jspinsTemp
    1975             : 
    1976             :       INTEGER(HID_T)               :: frSpaceID, frSetID
    1977             :       INTEGER(HID_T)               :: fpwSpaceID, fpwSetID
    1978             :       INTEGER(HID_T)               :: fzSpaceID, fzSetID
    1979             :       INTEGER(HID_T)               :: fzxySpaceID, fzxySetID
    1980             : 
    1981           0 :       WRITE(groupname,'(a,i0)') '/structure-', structureIndex
    1982           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    1983           0 :       IF(.NOT.l_exist) THEN
    1984           0 :          CALL juDFT_error("Structure entry "//TRIM(ADJUSTL(groupName))//" does not exist",calledby ="writePotentialHDF")
    1985             :       END IF
    1986           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    1987           0 :       CALL io_read_attlog0(groupID,'l_film',l_film)
    1988           0 :       CALL io_read_attint0(groupID,'ntype',ntype)
    1989           0 :       CALL io_read_attint0(groupID,'jmtd',jmtd)
    1990           0 :       CALL io_read_attint0(groupID,'nmzd',nmzd)
    1991           0 :       CALL io_read_attint0(groupID,'nmzxyd',nmzxyd)
    1992           0 :       CALL io_read_attint0(groupID,'nmzxy',nmzxy)
    1993           0 :       CALL io_read_attint0(groupID,'nmz',nmz)
    1994           0 :       CALL io_read_attint0(groupID,'nvac',nvac)
    1995           0 :       CALL io_read_attint0(groupID,'od_nq2',od_nq2)
    1996           0 :       CALL h5gclose_f(groupID, hdfError)
    1997             : 
    1998           0 :       WRITE(groupname,'(a,i0)') '/latharms-', latharmsIndex
    1999           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2000           0 :       IF(.NOT.l_exist) THEN
    2001           0 :          CALL juDFT_error("Latharms entry "//TRIM(ADJUSTL(groupName))//" does not exist",calledby ="writePotentialHDF")
    2002             :       END IF
    2003           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2004           0 :       CALL io_read_attint0(groupID,'nlhd',nlhd)
    2005           0 :       CALL h5gclose_f(groupID, hdfError)
    2006             : 
    2007           0 :       WRITE(groupname,'(a,i0)') '/stars-', starsIndex
    2008           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2009           0 :       IF(.NOT.l_exist) THEN
    2010           0 :          CALL juDFT_error("Stars entry "//TRIM(ADJUSTL(groupName))//" does not exist",calledby ="writePotentialHDF")
    2011             :       END IF
    2012           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2013           0 :       CALL io_read_attint0(groupID,'ng3',ng3)
    2014           0 :       CALL io_read_attint0(groupID,'ng2',ng2)
    2015           0 :       CALL h5gclose_f(groupID, hdfError)
    2016             : 
    2017           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2018             : 
    2019           0 :       SELECT CASE (potentialType)
    2020             :          CASE(POTENTIAL_TYPE_IN_const)
    2021           0 :             potentialTypeName = '/in'
    2022             :          CASE(POTENTIAL_TYPE_OUT_const)
    2023           0 :             potentialTypeName = '/out'
    2024             :          CASE DEFAULT
    2025           0 :             CALL juDFT_error("Unknown potential type selected",calledby ="writePotentialHDF")
    2026             :       END SELECT
    2027             : 
    2028           0 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(potentialTypeName))
    2029             : 
    2030           0 :       l_delete = .FALSE.
    2031           0 :       IF(l_exist) THEN
    2032           0 :          CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    2033             : 
    2034           0 :          CALL io_read_attint0(archiveID,'starsIndex',starsIndexTemp)
    2035           0 :          CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndexTemp)
    2036           0 :          CALL io_read_attint0(archiveID,'structureIndex',structureIndexTemp)
    2037           0 :          CALL io_read_attint0(archiveID,'stepfunctionIndex',stepfunctionIndexTemp)
    2038           0 :          CALL io_read_attint0(archiveID,'spins',jspinsTemp)
    2039             : 
    2040           0 :          IF (starsIndex.NE.starsIndexTemp) l_delete = .TRUE.
    2041           0 :          IF (latharmsIndex.NE.latharmsIndexTemp) l_delete = .TRUE.
    2042           0 :          IF (structureIndex.NE.structureIndexTemp) l_delete = .TRUE.
    2043           0 :          IF (stepfunctionIndex.NE.stepfunctionIndexTemp) l_delete = .TRUE.
    2044           0 :          IF (input%jspins.NE.jspinsTemp) l_delete = .TRUE.
    2045             : 
    2046           0 :          CALL h5gclose_f(archiveID, hdfError)
    2047             :       END IF
    2048             : 
    2049           0 :       IF(l_delete) THEN
    2050           0 :          CALL h5ldelete_f(fileID, archiveName, hdfError)
    2051           0 :          l_exist = .FALSE.
    2052             :       END IF
    2053             : 
    2054           0 :       IF(l_exist) THEN
    2055           0 :          CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    2056             : 
    2057           0 :          CALL io_write_attint0(archiveID,'starsIndex',starsIndex)
    2058           0 :          CALL io_write_attint0(archiveID,'latharmsIndex',latharmsIndex)
    2059           0 :          CALL io_write_attint0(archiveID,'structureIndex',structureIndex)
    2060           0 :          CALL io_write_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    2061           0 :          CALL io_write_attint0(archiveID,'spins',input%jspins)
    2062           0 :          CALL io_write_attint0(archiveID,'iter',iter)
    2063             : 
    2064           0 :          l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2065             : 
    2066           0 :          IF(l_exist) THEN
    2067           0 :             CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2068             : 
    2069           0 :             dimsInt(:4)=(/jmtd,nlhd+1,ntype,input%jspins/)
    2070           0 :             CALL h5dopen_f(groupID, 'fr', frSetID, hdfError)
    2071           0 :             CALL io_write_real4(frSetID,(/1,1,1,1/),dimsInt(:4),pot%mt)
    2072           0 :             CALL h5dclose_f(frSetID, hdfError)
    2073             : 
    2074           0 :             dimsInt(:3)=(/2,ng3,input%jspins/)
    2075           0 :             CALL h5dopen_f(groupID, 'fpw', fpwSetID, hdfError)
    2076           0 :             CALL io_write_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),fpw)
    2077           0 :             CALL h5dclose_f(fpwSetID, hdfError)
    2078             : 
    2079           0 :             IF (l_film) THEN
    2080           0 :                dimsInt(:3)=(/nmzd,2,input%jspins/)
    2081           0 :                CALL h5dopen_f(groupID, 'fz', fzSetID, hdfError)
    2082           0 :                CALL io_write_real3(fzSetID,(/1,1,1/),dimsInt(:3),pot%vacz(:,:,:input%jspins))
    2083           0 :                CALL h5dclose_f(fzSetID, hdfError)
    2084             : 
    2085           0 :                dimsInt(:5)=(/2,nmzxyd,ng2-1,2,input%jspins/)
    2086           0 :                CALL h5dopen_f(groupID, 'fzxy', fzxySetID, hdfError)
    2087           0 :                CALL io_write_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),pot%vacxy(:,:,:,:input%jspins))
    2088           0 :                CALL h5dclose_f(fzxySetID, hdfError)
    2089             :             END IF
    2090             : 
    2091           0 :             CALL h5gclose_f(groupID, hdfError)
    2092             :          ELSE
    2093           0 :             CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2094             : 
    2095           0 :             dims(:4)=(/jmtd,nlhd+1,ntype,input%jspins/)
    2096           0 :             dimsInt = dims
    2097           0 :             CALL h5screate_simple_f(4,dims(:4),frSpaceID,hdfError)
    2098           0 :             CALL h5dcreate_f(groupID, "fr", H5T_NATIVE_DOUBLE, frSpaceID, frSetID, hdfError)
    2099           0 :             CALL h5sclose_f(frSpaceID,hdfError)
    2100           0 :             CALL io_write_real4(frSetID,(/1,1,1,1/),dimsInt(:4),pot%mt)
    2101           0 :             CALL h5dclose_f(frSetID, hdfError)
    2102             : 
    2103           0 :             dims(:3)=(/2,ng3,input%jspins/)
    2104           0 :             dimsInt = dims
    2105           0 :             CALL h5screate_simple_f(3,dims(:3),fpwSpaceID,hdfError)
    2106           0 :             CALL h5dcreate_f(groupID, "fpw", H5T_NATIVE_DOUBLE, fpwSpaceID, fpwSetID, hdfError)
    2107           0 :             CALL h5sclose_f(fpwSpaceID,hdfError)
    2108           0 :             CALL io_write_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),fpw)
    2109           0 :             CALL h5dclose_f(fpwSetID, hdfError)
    2110             : 
    2111           0 :             IF (l_film) THEN
    2112           0 :                dims(:3)=(/nmzd,2,input%jspins/)
    2113           0 :                dimsInt = dims
    2114           0 :                CALL h5screate_simple_f(3,dims(:3),fzSpaceID,hdfError)
    2115           0 :                CALL h5dcreate_f(groupID, "fz", H5T_NATIVE_DOUBLE, fzSpaceID, fzSetID, hdfError)
    2116           0 :                CALL h5sclose_f(fzSpaceID,hdfError)
    2117           0 :                CALL io_write_real3(fzSetID,(/1,1,1/),dimsInt(:3),pot%vacz(:,:,:input%jspins))
    2118           0 :                CALL h5dclose_f(fzSetID, hdfError)
    2119             : 
    2120           0 :                dims(:5)=(/2,nmzxyd,ng2-1,2,input%jspins/)
    2121           0 :                dimsInt = dims
    2122           0 :                CALL h5screate_simple_f(5,dims(:5),fzxySpaceID,hdfError)
    2123           0 :                CALL h5dcreate_f(groupID, "fzxy", H5T_NATIVE_DOUBLE, fzxySpaceID, fzxySetID, hdfError)
    2124           0 :                CALL h5sclose_f(fzxySpaceID,hdfError)
    2125           0 :                CALL io_write_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),pot%vacxy(:,:,:,:input%jspins))
    2126           0 :                CALL h5dclose_f(fzxySetID, hdfError)
    2127             :             END IF
    2128             : 
    2129           0 :             CALL h5gclose_f(groupID, hdfError)
    2130             :          END IF
    2131             : 
    2132           0 :          CALL h5gclose_f(archiveID, hdfError)
    2133             :       ELSE
    2134           0 :          CALL h5gcreate_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    2135             : 
    2136           0 :          CALL io_write_attint0(archiveID,'starsIndex',starsIndex)
    2137           0 :          CALL io_write_attint0(archiveID,'latharmsIndex',latharmsIndex)
    2138           0 :          CALL io_write_attint0(archiveID,'structureIndex',structureIndex)
    2139           0 :          CALL io_write_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    2140           0 :          CALL io_write_attint0(archiveID,'spins',input%jspins)
    2141           0 :          CALL io_write_attint0(archiveID,'iter',iter)
    2142             : 
    2143           0 :          CALL h5gcreate_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2144             : 
    2145           0 :          dims(:4)=(/jmtd,nlhd+1,ntype,input%jspins/)
    2146           0 :          dimsInt = dims
    2147           0 :          CALL h5screate_simple_f(4,dims(:4),frSpaceID,hdfError)
    2148           0 :          CALL h5dcreate_f(groupID, "fr", H5T_NATIVE_DOUBLE, frSpaceID, frSetID, hdfError)
    2149           0 :          CALL h5sclose_f(frSpaceID,hdfError)
    2150           0 :          CALL io_write_real4(frSetID,(/1,1,1,1/),dimsInt(:4),pot%mt)
    2151           0 :          CALL h5dclose_f(frSetID, hdfError)
    2152             : 
    2153           0 :          dims(:3)=(/2,ng3,input%jspins/)
    2154           0 :          dimsInt = dims
    2155           0 :          CALL h5screate_simple_f(3,dims(:3),fpwSpaceID,hdfError)
    2156           0 :          CALL h5dcreate_f(groupID, "fpw", H5T_NATIVE_DOUBLE, fpwSpaceID, fpwSetID, hdfError)
    2157           0 :          CALL h5sclose_f(fpwSpaceID,hdfError)
    2158           0 :          CALL io_write_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),fpw)
    2159           0 :          CALL h5dclose_f(fpwSetID, hdfError)
    2160             : 
    2161           0 :          IF (l_film) THEN
    2162           0 :             dims(:3)=(/nmzd,2,input%jspins/)
    2163           0 :             dimsInt = dims
    2164           0 :             CALL h5screate_simple_f(3,dims(:3),fzSpaceID,hdfError)
    2165           0 :             CALL h5dcreate_f(groupID, "fz", H5T_NATIVE_DOUBLE, fzSpaceID, fzSetID, hdfError)
    2166           0 :             CALL h5sclose_f(fzSpaceID,hdfError)
    2167           0 :             CALL io_write_real3(fzSetID,(/1,1,1/),dimsInt(:3),pot%vacz(:,:,:input%jspins))
    2168           0 :             CALL h5dclose_f(fzSetID, hdfError)
    2169             : 
    2170           0 :             dims(:5)=(/2,nmzxyd,ng2-1,2,input%jspins/)
    2171           0 :             dimsInt = dims
    2172           0 :             CALL h5screate_simple_f(5,dims(:5),fzxySpaceID,hdfError)
    2173           0 :             CALL h5dcreate_f(groupID, "fzxy", H5T_NATIVE_DOUBLE, fzxySpaceID, fzxySetID, hdfError)
    2174           0 :             CALL h5sclose_f(fzxySpaceID,hdfError)
    2175           0 :             CALL io_write_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),pot%vacxy(:,:,:,:input%jspins))
    2176           0 :             CALL h5dclose_f(fzxySetID, hdfError)
    2177             :          END IF
    2178             : 
    2179           0 :          CALL h5gclose_f(groupID, hdfError)
    2180             : 
    2181           0 :          CALL h5gclose_f(archiveID, hdfError)
    2182             :       END IF
    2183             : 
    2184           0 :    END SUBROUTINE writePotentialHDF
    2185             : 
    2186          35 :    SUBROUTINE readDensityHDF(fileID, input, stars, latharms, atoms, vacuum, oneD,&
    2187             :                              archiveName, densityType,fermiEnergy,l_qfix,l_DimChange,den)
    2188             : 
    2189             :       TYPE(t_input),INTENT(IN)     :: input
    2190             :       TYPE(t_stars),INTENT(IN)     :: stars
    2191             :       TYPE(t_sphhar),INTENT(IN)    :: latharms
    2192             :       TYPE(t_atoms),INTENT(IN)     :: atoms
    2193             :       TYPE(t_vacuum),INTENT(IN)    :: vacuum
    2194             :       TYPE(t_oneD),INTENT(IN)      :: oneD
    2195             :       TYPE(t_potden),INTENT(INOUT) :: den
    2196             : 
    2197             :       INTEGER(HID_T), INTENT(IN)   :: fileID
    2198             :       INTEGER, INTENT(IN)          :: densityType
    2199             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    2200             : 
    2201             :       REAL,    INTENT (OUT)        :: fermiEnergy
    2202             :       LOGICAL, INTENT (OUT)        :: l_qfix, l_DimChange
    2203             : 
    2204             :       INTEGER               :: starsIndex, latharmsIndex, structureIndex, stepfunctionIndex
    2205             :       INTEGER               :: previousDensityIndex, jspins
    2206             :       INTEGER               :: ntype,jmtd,nmzd,nmzxyd,nlhd,ng3,ng2
    2207             :       INTEGER               :: nmz, nvac, od_nq2, nmzxy, n_u, i, j
    2208             :       INTEGER               :: localDensityType
    2209             :       LOGICAL               :: l_film, l_exist, l_mmpMatDimEquals, l_amf_Temp
    2210             :       INTEGER(HID_T)        :: archiveID, groupID, groupBID, generalGroupID
    2211             :       INTEGER               :: hdfError, fileFormatVersion
    2212             :       CHARACTER(LEN=30)     :: groupName, groupBName, densityTypeName
    2213             :       INTEGER               :: dimsInt(7)
    2214             :       INTEGER               :: jmtdOut, ntypeOut, nmzdOut, nmzxydOut, nlhdOut, ng3Out, ng2Out
    2215             :       INTEGER               :: nmzOut, nvacOut, od_nq2Out, nmzxyOut, jspinsOut
    2216             : 
    2217             :       INTEGER(HID_T)        :: frSetID
    2218             :       INTEGER(HID_T)        :: fpwSetID
    2219             :       INTEGER(HID_T)        :: fzSetID
    2220             :       INTEGER(HID_T)        :: fzxySetID
    2221             :       INTEGER(HID_T)        :: cdomSetID
    2222             :       INTEGER(HID_T)        :: cdomvzSetID
    2223             :       INTEGER(HID_T)        :: cdomvxySetID
    2224             :       INTEGER(HID_T)        :: ldau_AtomTypeSetID
    2225             :       INTEGER(HID_T)        :: ldau_lSetID
    2226             :       INTEGER(HID_T)        :: ldau_l_amfSetID
    2227             :       INTEGER(HID_T)        :: ldau_USetID
    2228             :       INTEGER(HID_T)        :: ldau_JSetID
    2229             :       INTEGER(HID_T)        :: mmpMatSetID
    2230             : 
    2231          70 :       INTEGER, ALLOCATABLE  :: ldau_AtomType(:), ldau_l(:), ldau_l_amf(:)
    2232          70 :       REAL,    ALLOCATABLE  :: ldau_U(:), ldau_J(:)
    2233          35 :       REAL,    ALLOCATABLE  :: frTemp(:,:,:,:)
    2234          35 :       REAL,    ALLOCATABLE  :: fzTemp(:,:,:)
    2235          35 :       COMPLEX, ALLOCATABLE  :: fpwTemp(:,:)
    2236          35 :       COMPLEX, ALLOCATABLE  :: fzxyTemp(:,:,:,:)
    2237          35 :       COMPLEX, ALLOCATABLE  :: cdomTemp(:), cdomvzTemp(:,:), cdomvxyTemp(:,:,:)
    2238          35 :       COMPLEX, ALLOCATABLE  :: mmpMatTemp(:,:,:,:)
    2239             : 
    2240          35 :       den%pw = CMPLX(0.0,0.0)
    2241          35 :       den%vacz = CMPLX(0.0,0.0)
    2242          35 :       den%vacxy = CMPLX(0.0,0.0)
    2243             : 
    2244          35 :       CALL h5gopen_f(fileID, '/general', generalGroupID, hdfError)
    2245             :       ! read in file format version from the header '/general'
    2246          35 :       CALL io_read_attint0(generalGroupID,'fileFormatVersion',fileFormatVersion)
    2247             : 
    2248          35 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2249          35 :       IF(.NOT.l_exist) THEN
    2250           0 :          CALL juDFT_error('density archive '//TRIM(ADJUSTL(archiveName))//' does not exist.' ,calledby ="readDensityHDF")
    2251             :       END IF
    2252             : 
    2253          35 :       localDensityType = densityType
    2254          28 :       SELECT CASE (densityType)
    2255             :          CASE(DENSITY_TYPE_IN_const)
    2256          28 :             densityTypeName = '/in'
    2257             :          CASE(DENSITY_TYPE_OUT_const)
    2258           0 :             densityTypeName = '/out'
    2259             :          CASE(DENSITY_TYPE_NOCO_IN_const)
    2260           7 :             densityTypeName = '/noco_in'
    2261           7 :             groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2262           7 :             l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2263           7 :             IF(.NOT.l_exist) THEN
    2264           7 :                localDensityType = DENSITY_TYPE_IN_const
    2265           7 :                densityTypeName = '/in'
    2266             :             END IF
    2267             :          CASE(DENSITY_TYPE_NOCO_OUT_const)
    2268           0 :             densityTypeName = '/noco_out'
    2269           0 :             groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2270           0 :             l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2271           0 :             IF(.NOT.l_exist) THEN
    2272           0 :                localDensityType = DENSITY_TYPE_OUT_const
    2273           0 :                densityTypeName = '/out'
    2274             :             END IF
    2275             :          CASE(DENSITY_TYPE_PRECOND_const)
    2276           0 :             densityTypeName = '/precond'
    2277             :          CASE DEFAULT
    2278          35 :             CALL juDFT_error("Unknown density type selected",calledby ="readDensityHDF")
    2279             :       END SELECT
    2280             : 
    2281          35 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2282          35 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2283          35 :       IF(.NOT.l_exist) THEN
    2284           0 :          CALL juDFT_error('Density entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readDensityHDF")
    2285             :       END IF
    2286             : 
    2287          35 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    2288          35 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2289             : 
    2290          35 :       CALL io_read_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
    2291          35 :       CALL io_read_attint0(archiveID,'starsIndex',starsIndex)
    2292          35 :       CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndex)
    2293          35 :       CALL io_read_attint0(archiveID,'structureIndex',structureIndex)
    2294          35 :       CALL io_read_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    2295          35 :       CALL io_read_attint0(archiveID,'spins',jspins)
    2296          35 :       CALL io_read_attint0(archiveID,'iter',den%iter)
    2297             : 
    2298          35 :       WRITE(groupBName,'(a,i0)') '/structure-', structureIndex
    2299          35 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupBName)))
    2300          35 :       IF(.NOT.l_exist) THEN
    2301           0 :          CALL juDFT_error("Structure entry "//TRIM(ADJUSTL(groupBName))//" does not exist",calledby ="readDensityHDF")
    2302             :       END IF
    2303          35 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupBName)), groupBID, hdfError)
    2304          35 :       CALL io_read_attlog0(groupBID,'l_film',l_film)
    2305          35 :       CALL io_read_attint0(groupBID,'ntype',ntype)
    2306          35 :       CALL io_read_attint0(groupBID,'jmtd',jmtd)
    2307          35 :       CALL io_read_attint0(groupBID,'nmzd',nmzd)
    2308          35 :       CALL io_read_attint0(groupBID,'nmzxyd',nmzxyd)
    2309          35 :       CALL io_read_attint0(groupBID,'nmzxy',nmzxy)
    2310          35 :       CALL io_read_attint0(groupBID,'nmz',nmz)
    2311          35 :       CALL io_read_attint0(groupBID,'nvac',nvac)
    2312          35 :       CALL io_read_attint0(groupBID,'od_nq2',od_nq2)
    2313          35 :       IF(fileFormatVersion.GE.29) THEN
    2314          35 :          CALL io_read_attint0(groupBID,'n_u',n_u)
    2315          35 :          IF(n_u.GT.0) THEN
    2316           3 :             ALLOCATE(ldau_AtomType(n_u), ldau_l(n_u), ldau_l_amf(n_u))
    2317           3 :             ALLOCATE(ldau_U(n_u), ldau_J(n_u))
    2318             : 
    2319           3 :             dimsInt(:1)=(/n_u/)
    2320           3 :             CALL h5dopen_f(groupBID, 'ldau_AtomType', ldau_AtomTypeSetID, hdfError)
    2321           3 :             CALL io_read_integer1(ldau_AtomTypeSetID,(/1/),dimsInt(:1),ldau_AtomType)
    2322           3 :             CALL h5dclose_f(ldau_AtomTypeSetID, hdfError)
    2323             : 
    2324           3 :             dimsInt(:1)=(/n_u/)
    2325           3 :             CALL h5dopen_f(groupBID, 'ldau_l', ldau_lSetID, hdfError)
    2326           3 :             CALL io_read_integer1(ldau_lSetID,(/1/),dimsInt(:1),ldau_l)
    2327           3 :             CALL h5dclose_f(ldau_lSetID, hdfError)
    2328             : 
    2329           3 :             dimsInt(:1)=(/n_u/)
    2330           3 :             CALL h5dopen_f(groupBID, 'ldau_l_amf', ldau_l_amfSetID, hdfError)
    2331           3 :             CALL io_read_integer1(ldau_l_amfSetID,(/1/),dimsInt(:1),ldau_l_amf)
    2332           3 :             CALL h5dclose_f(ldau_l_amfSetID, hdfError)
    2333             : 
    2334           3 :             dimsInt(:1)=(/n_u/)
    2335           3 :             CALL h5dopen_f(groupBID, 'ldau_U', ldau_USetID, hdfError)
    2336           3 :             CALL io_read_real1(ldau_USetID,(/1/),dimsInt(:1),ldau_U)
    2337           3 :             CALL h5dclose_f(ldau_USetID, hdfError)
    2338             : 
    2339           3 :             dimsInt(:1)=(/n_u/)
    2340           3 :             CALL h5dopen_f(groupBID, 'ldau_J', ldau_JSetID, hdfError)
    2341           3 :             CALL io_read_real1(ldau_JSetID,(/1/),dimsInt(:1),ldau_J)
    2342           3 :             CALL h5dclose_f(ldau_JSetID, hdfError)
    2343             :          END IF
    2344             :       END IF
    2345          35 :       CALL h5gclose_f(groupBID, hdfError)
    2346             : 
    2347          35 :       WRITE(groupBName,'(a,i0)') '/latharms-', latharmsIndex
    2348          35 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupBName)))
    2349          35 :       IF(.NOT.l_exist) THEN
    2350           0 :          CALL juDFT_error("Latharms entry "//TRIM(ADJUSTL(groupBName))//" does not exist",calledby ="readDensityHDF")
    2351             :       END IF
    2352          35 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupBName)), groupBID, hdfError)
    2353          35 :       CALL io_read_attint0(groupBID,'nlhd',nlhd)
    2354          35 :       CALL h5gclose_f(groupBID, hdfError)
    2355             : 
    2356          35 :       WRITE(groupBName,'(a,i0)') '/stars-', starsIndex
    2357          35 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupBName)))
    2358          35 :       IF(.NOT.l_exist) THEN
    2359           0 :          CALL juDFT_error("Stars entry "//TRIM(ADJUSTL(groupBName))//" does not exist",calledby ="readDensityHDF")
    2360             :       END IF
    2361          35 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupBName)), groupBID, hdfError)
    2362          35 :       CALL io_read_attint0(groupBID,'ng3',ng3)
    2363          35 :       CALL io_read_attint0(groupBID,'ng2',ng2)
    2364          35 :       CALL h5gclose_f(groupBID, hdfError)
    2365             : 
    2366          35 :       CALL io_read_attreal0(groupID,'fermiEnergy',fermiEnergy)
    2367          35 :       CALL io_read_attlog0(groupID,'l_qfix',l_qfix)
    2368             : 
    2369          35 :       jmtdOut = MIN(jmtd,atoms%jmtd)
    2370          35 :       ntypeOut = MIN(ntype,atoms%ntype)
    2371          35 :       nmzdOut = MIN(nmzd,vacuum%nmzd)
    2372          35 :       nmzxydOut = MIN(nmzxyd,vacuum%nmzxyd)
    2373          35 :       nlhdOut = MIN(nlhd,latharms%nlhd)
    2374          35 :       ng3Out = MIN(ng3,stars%ng3)
    2375          35 :       ng2Out = MIN(ng2,stars%ng2)
    2376          35 :       nmzOut = MIN(nmz,vacuum%nmz)
    2377          35 :       nvacOut = MIN(nvac,vacuum%nvac)
    2378          35 :       od_nq2Out = MIN(od_nq2,oneD%odi%nq2)
    2379          35 :       nmzxyOut = MIN(nmzxy,vacuum%nmzxy)
    2380          35 :       jspinsOut = MIN(jspins,input%jspins)
    2381             : 
    2382          35 :       l_DimChange = .FALSE.
    2383          35 :       IF(atoms%jmtd.NE.jmtd) l_DimChange = .TRUE.
    2384          35 :       IF(atoms%ntype.NE.ntype) l_DimChange = .TRUE.
    2385          35 :       IF(vacuum%nmzd.NE.nmzd) l_DimChange = .TRUE.
    2386          35 :       IF(vacuum%nmzxyd.NE.nmzxyd) l_DimChange = .TRUE.
    2387          35 :       IF(latharms%nlhd.NE.nlhd) l_DimChange = .TRUE.
    2388          35 :       IF(stars%ng3.NE.ng3) l_DimChange = .TRUE.
    2389          35 :       IF(stars%ng2.NE.ng2) l_DimChange = .TRUE.
    2390          35 :       IF(vacuum%nmz.NE.nmz) l_DimChange = .TRUE.
    2391          35 :       IF(vacuum%nvac.NE.nvac) l_DimChange = .TRUE.
    2392          35 :       IF(oneD%odi%nq2.NE.od_nq2) l_DimChange = .TRUE.
    2393          35 :       IF(vacuum%nmzxy.NE.nmzxy) l_DimChange = .TRUE.
    2394          35 :       IF(input%jspins.NE.jspins) l_DimChange = .TRUE.
    2395             : 
    2396          35 :       l_mmpMatDimEquals = .TRUE.
    2397          35 :       IF(fileFormatVersion.GE.29) THEN
    2398          35 :          IF(atoms%n_u.NE.n_u) THEN
    2399           0 :             l_DimChange = .TRUE.
    2400           0 :             l_mmpMatDimEquals = .FALSE.
    2401             :          ELSE
    2402          59 :             DO i = 1, n_u
    2403          12 :                IF (atoms%lda_u(i)%atomType.NE.ldau_AtomType(i)) l_mmpMatDimEquals = .FALSE.
    2404          12 :                IF (atoms%lda_u(i)%l.NE.ldau_l(i)) l_mmpMatDimEquals = .FALSE.
    2405          12 :                l_amf_Temp = .FALSE.
    2406          12 :                IF(ldau_l_amf(i).EQ.1) l_amf_Temp = .TRUE.
    2407          12 :                IF (atoms%lda_u(i)%l_amf.NEQV.l_amf_Temp) l_mmpMatDimEquals = .FALSE. ! Am I sure about this? parameter change => dim change?
    2408          12 :                IF (ABS(atoms%lda_u(i)%u-ldau_U(i)).GT.1.0e-10) l_mmpMatDimEquals = .FALSE. ! Am I sure about this? parameter change => dim change?
    2409          47 :                IF (ABS(atoms%lda_u(i)%j-ldau_J(i)).GT.1.0e-10) l_mmpMatDimEquals = .FALSE. ! Am I sure about this? parameter change => dim change?
    2410             :             END DO
    2411          35 :             IF (.NOT.l_mmpMatDimEquals) l_DimChange = .TRUE.
    2412             :          END IF
    2413             :       END IF
    2414             : 
    2415          35 :       den%mt = 0.0
    2416          35 :       ALLOCATE(frTemp(jmtd,1:nlhd+1,ntype,jspins))
    2417          35 :       dimsInt(:4)=(/jmtd,nlhd+1,ntype,jspins/)
    2418          35 :       CALL h5dopen_f(groupID, 'fr', frSetID, hdfError)
    2419          35 :       CALL io_read_real4(frSetID,(/1,1,1,1/),dimsInt(:4),frTemp)
    2420          35 :       CALL h5dclose_f(frSetID, hdfError)
    2421             :       den%mt(1:jmtdOut,0:nlhdOut,1:ntypeOut,1:jspinsOut) =&
    2422          35 :          frTemp(1:jmtdOut,1:nlhdOut+1,1:ntypeOut,1:jspinsOut)
    2423          35 :       DEALLOCATE(frTemp)
    2424             : 
    2425          35 :       den%pw = CMPLX(0.0,0.0)
    2426          35 :       ALLOCATE(fpwTemp(ng3,jspins))
    2427          35 :       dimsInt(:3)=(/2,ng3,jspins/)
    2428          35 :       CALL h5dopen_f(groupID, 'fpw', fpwSetID, hdfError)
    2429          35 :       CALL io_read_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),fpwTemp(:,:jspins))
    2430          35 :       CALL h5dclose_f(fpwSetID, hdfError)
    2431          35 :       den%pw(1:ng3Out,1:jspinsOut) = fpwTemp(1:ng3Out,1:jspinsOut)
    2432          35 :       DEALLOCATE(fpwTemp)
    2433             : 
    2434          35 :       IF (l_film) THEN
    2435           7 :          den%vacz = 0.0
    2436           7 :          ALLOCATE(fzTemp(nmzd,2,jspins))
    2437           7 :          dimsInt(:3)=(/nmzd,2,jspins/)
    2438           7 :          CALL h5dopen_f(groupID, 'fz', fzSetID, hdfError)
    2439           7 :          CALL io_read_real3(fzSetID,(/1,1,1/),dimsInt(:3),fzTemp(:,:,:jspins))
    2440           7 :          CALL h5dclose_f(fzSetID, hdfError)
    2441           7 :          den%vacz(1:nmzdOut,1:2,1:jspinsOut) = fzTemp(1:nmzdOut,1:2,1:jspinsOut)
    2442           7 :          DEALLOCATE(fzTemp)
    2443             : 
    2444           7 :          den%vacxy = CMPLX(0.0,0.0)
    2445           7 :          ALLOCATE(fzxyTemp(nmzxyd,ng2-1,2,jspins))
    2446           7 :          dimsInt(:5)=(/2,nmzxyd,ng2-1,2,jspins/)
    2447           7 :          CALL h5dopen_f(groupID, 'fzxy', fzxySetID, hdfError)
    2448           7 :          CALL io_read_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),fzxyTemp(:,:,:,:jspins))
    2449           7 :          CALL h5dclose_f(fzxySetID, hdfError)
    2450             :          den%vacxy(1:nmzxydOut,1:ng2Out-1,1:2,1:jspinsOut) =&
    2451           7 :             fzxyTemp(1:nmzxydOut,1:ng2Out-1,1:2,1:jspinsOut)
    2452           7 :          DEALLOCATE(fzxyTemp)
    2453             :       END IF
    2454             : 
    2455          35 :       IF((localDensityType.EQ.DENSITY_TYPE_NOCO_IN_const).OR.&
    2456             :          (localDensityType.EQ.DENSITY_TYPE_NOCO_OUT_const)) THEN
    2457             : 
    2458           0 :          den%pw(:,3) = CMPLX(0.0,0.0)
    2459           0 :          ALLOCATE(cdomTemp(ng3))
    2460           0 :          dimsInt(:2)=(/2,ng3/)
    2461           0 :          CALL h5dopen_f(groupID, 'cdom', cdomSetID, hdfError)
    2462           0 :          CALL io_read_complex1(cdomSetID,(/-1,1/),dimsInt(:2),cdomTemp)
    2463           0 :          CALL h5dclose_f(cdomSetID, hdfError)
    2464           0 :          den%pw(1:ng3Out,3) = cdomTemp(1:ng3Out)
    2465           0 :          DEALLOCATE(cdomTemp)
    2466             : 
    2467           0 :          IF (l_film) THEN
    2468           0 :             den%vacz(:,:,3:4) = 0.0
    2469           0 :             ALLOCATE(cdomvzTemp(nmz,nvac))
    2470           0 :             dimsInt(:3)=(/2,nmz,nvac/)
    2471           0 :             CALL h5dopen_f(groupID, 'cdomvz', cdomvzSetID, hdfError)
    2472           0 :             CALL io_read_complex2(cdomvzSetID,(/-1,1,1/),dimsInt(:3),cdomvzTemp)
    2473           0 :             CALL h5dclose_f(cdomvzSetID, hdfError)
    2474           0 :             den%vacz(1:nmzOut,1:nvacOut,3) = REAL(cdomvzTemp(1:nmzOut,1:nvacOut))
    2475           0 :             den%vacz(1:nmzOut,1:nvacOut,4) = AIMAG(cdomvzTemp(1:nmzOut,1:nvacOut))
    2476           0 :             DEALLOCATE(cdomvzTemp)
    2477             : 
    2478           0 :             den%vacxy(:,:,:,3) = CMPLX(0.0,0.0)
    2479             :             ! No change in od_nq2 allowed at the moment!
    2480           0 :             ALLOCATE(cdomvxyTemp(nmzxy,od_nq2-1,nvac))
    2481           0 :             dimsInt(:4)=(/2,nmzxy,od_nq2-1,nvac/)
    2482           0 :             CALL h5dopen_f(groupID, 'cdomvxy', cdomvxySetID, hdfError)
    2483           0 :             CALL io_read_complex3(cdomvxySetID,(/-1,1,1,1/),dimsInt(:4),cdomvxyTemp)
    2484           0 :             CALL h5dclose_f(cdomvxySetID, hdfError)
    2485             :             den%vacxy(1:nmzxyOut,1:od_nq2Out-1,1:nvacOut,3) =&
    2486           0 :                cdomvxyTemp(1:nmzxyOut,1:od_nq2Out-1,1:nvacOut)
    2487           0 :             DEALLOCATE(cdomvxyTemp)
    2488             :          END IF
    2489             :       END IF
    2490             : 
    2491          35 :       IF((fileFormatVersion.GE.29).AND.(n_u.GT.0)) THEN
    2492           3 :          ALLOCATE (mmpMatTemp(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,n_u,jspins))
    2493           3 :          dimsInt(:5)=(/2,2*lmaxU_const+1,2*lmaxU_const+1,n_u,jspins/)
    2494           3 :          CALL h5dopen_f(groupID, 'mmpMat', mmpMatSetID, hdfError)
    2495           3 :          CALL io_read_complex4(mmpMatSetID,(/-1,1,1,1,1/),dimsInt(:5),mmpMatTemp)
    2496           3 :          CALL h5dclose_f(mmpMatSetID, hdfError)
    2497             : 
    2498           3 :          den%mmpMat = CMPLX(0.0,0.0)
    2499           3 :          IF(l_mmpMatDimEquals) THEN
    2500           3 :             den%mmpMat(:,:,:,1:jspinsOut) = mmpMatTemp(:,:,:,1:jspinsOut)
    2501             :          ELSE
    2502           0 :             DO i = 1, n_u
    2503           0 :                DO j = 1, atoms%n_u
    2504           0 :                   IF (atoms%lda_u(j)%atomType.NE.ldau_AtomType(i)) CYCLE
    2505           0 :                   IF (atoms%lda_u(j)%l.NE.ldau_l(i)) CYCLE
    2506           0 :                   den%mmpMat(:,:,j,1:jspinsOut) = mmpMatTemp(:,:,i,1:jspinsOut)
    2507             :                END DO
    2508             :             END DO
    2509             :          END IF
    2510             : 
    2511           3 :          DEALLOCATE (mmpMatTemp)
    2512             :       END IF
    2513             : 
    2514          35 :       CALL h5gclose_f(groupID, hdfError)
    2515          35 :       CALL h5gclose_f(archiveID, hdfError)
    2516             : 
    2517          70 :    END SUBROUTINE readDensityHDF
    2518             : 
    2519           0 :    SUBROUTINE readPotentialHDF(fileID, archiveName, potentialType,&
    2520           0 :                                iter,fr,fpw,fz,fzxy)
    2521             : 
    2522             :       INTEGER(HID_T), INTENT(IN)   :: fileID
    2523             :       INTEGER, INTENT(IN)          :: potentialType
    2524             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    2525             : 
    2526             :       INTEGER, INTENT (OUT)        :: iter
    2527             : 
    2528             :       REAL,    INTENT (OUT)        :: fr(:,:,:,:)
    2529             :       REAL,    INTENT (OUT)        :: fz(:,:,:)
    2530             :       COMPLEX, INTENT (OUT)        :: fpw(:,:)
    2531             :       COMPLEX, INTENT (OUT)        :: fzxy(:,:,:,:)
    2532             : 
    2533             :       INTEGER              :: starsIndex, latharmsIndex, structureIndex, stepfunctionIndex
    2534             :       INTEGER              :: jspins
    2535             :       INTEGER              :: ntype,jmtd,nmzd,nmzxyd,nlhd,ng3,ng2
    2536             :       INTEGER              :: nmz, nvac, od_nq2, nmzxy
    2537             :       LOGICAL              :: l_film, l_exist
    2538             :       INTEGER(HID_T)       :: archiveID, groupID, groupBID
    2539             :       INTEGER              :: hdfError
    2540             :       CHARACTER(LEN=30)    :: groupName, groupBName, potentialTypeName
    2541             :       INTEGER              :: dimsInt(7)
    2542             : 
    2543             :       INTEGER(HID_T)              :: frSetID
    2544             :       INTEGER(HID_T)              :: fpwSetID
    2545             :       INTEGER(HID_T)              :: fzSetID
    2546             :       INTEGER(HID_T)              :: fzxySetID
    2547             : 
    2548           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2549           0 :       IF(.NOT.l_exist) THEN
    2550           0 :          CALL juDFT_error('density archive '//TRIM(ADJUSTL(archiveName))//' does not exist.' ,calledby ="readPotentialHDF")
    2551             :       END IF
    2552             : 
    2553           0 :       SELECT CASE (potentialType)
    2554             :          CASE(POTENTIAL_TYPE_IN_const)
    2555           0 :             potentialTypeName = '/in'
    2556             :          CASE(POTENTIAL_TYPE_OUT_const)
    2557           0 :             potentialTypeName = '/out'
    2558             :          CASE DEFAULT
    2559           0 :             CALL juDFT_error("Unknown potential type selected",calledby ="readPotentialHDF")
    2560             :       END SELECT
    2561             : 
    2562           0 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(potentialTypeName))
    2563           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2564           0 :       IF(.NOT.l_exist) THEN
    2565           0 :          CALL juDFT_error('Potential entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="readPotentialHDF")
    2566             :       END IF
    2567             : 
    2568           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    2569           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2570             : 
    2571           0 :       CALL io_read_attint0(archiveID,'starsIndex',starsIndex)
    2572           0 :       CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndex)
    2573           0 :       CALL io_read_attint0(archiveID,'structureIndex',structureIndex)
    2574           0 :       CALL io_read_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    2575           0 :       CALL io_read_attint0(archiveID,'spins',jspins)
    2576           0 :       CALL io_read_attint0(archiveID,'iter',iter)
    2577             : 
    2578           0 :       WRITE(groupBName,'(a,i0)') '/structure-', structureIndex
    2579           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupBName)))
    2580           0 :       IF(.NOT.l_exist) THEN
    2581           0 :          CALL juDFT_error("Structure entry "//TRIM(ADJUSTL(groupBName))//" does not exist",calledby ="readPotentialHDF")
    2582             :       END IF
    2583           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupBName)), groupBID, hdfError)
    2584           0 :       CALL io_read_attlog0(groupBID,'l_film',l_film)
    2585           0 :       CALL io_read_attint0(groupBID,'ntype',ntype)
    2586           0 :       CALL io_read_attint0(groupBID,'jmtd',jmtd)
    2587           0 :       CALL io_read_attint0(groupBID,'nmzd',nmzd)
    2588           0 :       CALL io_read_attint0(groupBID,'nmzxyd',nmzxyd)
    2589           0 :       CALL io_read_attint0(groupBID,'nmzxy',nmzxy)
    2590           0 :       CALL io_read_attint0(groupBID,'nmz',nmz)
    2591           0 :       CALL io_read_attint0(groupBID,'nvac',nvac)
    2592           0 :       CALL io_read_attint0(groupBID,'od_nq2',od_nq2)
    2593           0 :       CALL h5gclose_f(groupBID, hdfError)
    2594             : 
    2595           0 :       WRITE(groupBName,'(a,i0)') '/latharms-', latharmsIndex
    2596           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupBName)))
    2597           0 :       IF(.NOT.l_exist) THEN
    2598           0 :          CALL juDFT_error("Latharms entry "//TRIM(ADJUSTL(groupBName))//" does not exist",calledby ="readPotentialHDF")
    2599             :       END IF
    2600           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupBName)), groupBID, hdfError)
    2601           0 :       CALL io_read_attint0(groupBID,'nlhd',nlhd)
    2602           0 :       CALL h5gclose_f(groupBID, hdfError)
    2603             : 
    2604           0 :       WRITE(groupBName,'(a,i0)') '/stars-', starsIndex
    2605           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupBName)))
    2606           0 :       IF(.NOT.l_exist) THEN
    2607           0 :          CALL juDFT_error("Stars entry "//TRIM(ADJUSTL(groupBName))//" does not exist",calledby ="readPotentialHDF")
    2608             :       END IF
    2609           0 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupBName)), groupBID, hdfError)
    2610           0 :       CALL io_read_attint0(groupBID,'ng3',ng3)
    2611           0 :       CALL io_read_attint0(groupBID,'ng2',ng2)
    2612           0 :       CALL h5gclose_f(groupBID, hdfError)
    2613             : 
    2614           0 :       dimsInt(:4)=(/jmtd,nlhd+1,ntype,jspins/)
    2615           0 :       CALL h5dopen_f(groupID, 'fr', frSetID, hdfError)
    2616           0 :       CALL io_read_real4(frSetID,(/1,1,1,1/),dimsInt(:4),fr)
    2617           0 :       CALL h5dclose_f(frSetID, hdfError)
    2618             : 
    2619           0 :       dimsInt(:3)=(/2,ng3,jspins/)
    2620           0 :       CALL h5dopen_f(groupID, 'fpw', fpwSetID, hdfError)
    2621           0 :       CALL io_read_complex2(fpwSetID,(/-1,1,1/),dimsInt(:3),fpw)
    2622           0 :       CALL h5dclose_f(fpwSetID, hdfError)
    2623             : 
    2624           0 :       IF (l_film) THEN
    2625           0 :          dimsInt(:3)=(/nmzd,2,jspins/)
    2626           0 :          CALL h5dopen_f(groupID, 'fz', fzSetID, hdfError)
    2627           0 :          CALL io_read_real3(fzSetID,(/1,1,1/),dimsInt(:3),fz)
    2628           0 :          CALL h5dclose_f(fzSetID, hdfError)
    2629             : 
    2630           0 :          dimsInt(:5)=(/2,nmzxyd,ng2-1,2,jspins/)
    2631           0 :          CALL h5dopen_f(groupID, 'fzxy', fzxySetID, hdfError)
    2632           0 :          CALL io_read_complex4(fzxySetID,(/-1,1,1,1,1/),dimsInt(:5),fzxy)
    2633           0 :          CALL h5dclose_f(fzxySetID, hdfError)
    2634             :       END IF
    2635             : 
    2636           0 :       CALL h5gclose_f(groupID, hdfError)
    2637           0 :       CALL h5gclose_f(archiveID, hdfError)
    2638             : 
    2639           0 :    END SUBROUTINE readPotentialHDF
    2640             : 
    2641             : 
    2642          48 :    SUBROUTINE peekDensityEntryHDF(fileID, archiveName, densityType,&
    2643             :                                   iter, starsIndex, latharmsIndex, structureIndex,&
    2644             :                                   stepfunctionIndex, previousDensityIndex, jspins,&
    2645             :                                   date, time, distance, fermiEnergy, l_qfix)
    2646             : 
    2647             :       INTEGER(HID_T), INTENT(IN)   :: fileID
    2648             :       INTEGER, INTENT(IN)          :: densityType
    2649             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    2650             : 
    2651             :       INTEGER, INTENT(OUT),OPTIONAL          :: date, time, iter
    2652             :       INTEGER, INTENT(OUT),OPTIONAL          :: starsIndex, latharmsIndex, structureIndex, stepfunctionIndex
    2653             :       INTEGER, INTENT(OUT),OPTIONAL          :: previousDensityIndex, jspins
    2654             :       REAL,    INTENT(OUT),OPTIONAL          :: fermiEnergy, distance
    2655             :       LOGICAL, INTENT(OUT),OPTIONAL          :: l_qfix
    2656             : 
    2657             :       INTEGER              :: localDensityType
    2658             :       LOGICAL              :: l_exist
    2659             :       INTEGER(HID_T)       :: archiveID, groupID
    2660             :       INTEGER              :: hdfError
    2661             :       CHARACTER(LEN=30)    :: groupName, densityTypeName
    2662             : 
    2663          48 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2664          48 :       IF(.NOT.l_exist) THEN
    2665           0 :          CALL juDFT_error('density archive '//TRIM(ADJUSTL(archiveName))//' does not exist.' ,calledby ="peekDensityEntryHDF")
    2666             :       END IF
    2667             : 
    2668          48 :       localDensityType = densityType
    2669          33 :       SELECT CASE (densityType)
    2670             :          CASE(DENSITY_TYPE_UNDEFINED_const)
    2671          33 :             densityTypeName = ''
    2672             :          CASE(DENSITY_TYPE_IN_const)
    2673           5 :             densityTypeName = '/in'
    2674             :          CASE(DENSITY_TYPE_OUT_const)
    2675           0 :             densityTypeName = '/out'
    2676             :          CASE(DENSITY_TYPE_NOCO_IN_const)
    2677          10 :             densityTypeName = '/noco_in'
    2678          10 :             groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2679          10 :             l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2680          10 :             IF(.NOT.l_exist) THEN
    2681          10 :                localDensityType = DENSITY_TYPE_IN_const
    2682          10 :                densityTypeName = '/in'
    2683             :             END IF
    2684             :          CASE(DENSITY_TYPE_NOCO_OUT_const)
    2685           0 :             densityTypeName = '/noco_out'
    2686           0 :             groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2687           0 :             l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2688           0 :             IF(.NOT.l_exist) THEN
    2689           0 :                localDensityType = DENSITY_TYPE_OUT_const
    2690           0 :                densityTypeName = '/out'
    2691             :             END IF
    2692             :          CASE(DENSITY_TYPE_PRECOND_const)
    2693           0 :             densityTypeName = '/precond'
    2694             :          CASE DEFAULT
    2695          48 :             CALL juDFT_error("Unknown density type selected",calledby ="peekDensityEntryHDF")
    2696             :       END SELECT
    2697             : 
    2698          48 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2699          48 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2700          48 :       IF(.NOT.l_exist) THEN
    2701           0 :          CALL juDFT_error('density entry '//TRIM(ADJUSTL(groupName))//' does not exist.' ,calledby ="peekDensityEntryHDF")
    2702             :       END IF
    2703             : 
    2704          48 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(archiveName)), archiveID, hdfError)
    2705          48 :       CALL h5gopen_f(fileID, TRIM(ADJUSTL(groupName)), groupID, hdfError)
    2706             : 
    2707          48 :       IF (PRESENT(previousDensityIndex)) CALL io_read_attint0(archiveID,'previousDensityIndex',previousDensityIndex)
    2708          48 :       IF (PRESENT(starsIndex)) CALL io_read_attint0(archiveID,'starsIndex',starsIndex)
    2709          48 :       IF (PRESENT(latharmsIndex)) CALL io_read_attint0(archiveID,'latharmsIndex',latharmsIndex)
    2710          48 :       IF (PRESENT(structureIndex)) CALL io_read_attint0(archiveID,'structureIndex',structureIndex)
    2711          48 :       IF (PRESENT(stepfunctionIndex)) CALL io_read_attint0(archiveID,'stepfunctionIndex',stepfunctionIndex)
    2712          48 :       IF (PRESENT(jspins)) CALL io_read_attint0(archiveID,'spins',jspins)
    2713          48 :       IF (PRESENT(iter)) CALL io_read_attint0(archiveID,'iter',iter)
    2714          48 :       IF (PRESENT(date)) CALL io_read_attint0(archiveID,'date',date)
    2715          48 :       IF (PRESENT(time)) CALL io_read_attint0(archiveID,'time',time)
    2716          48 :       IF (PRESENT(distance)) CALL io_read_attreal0(archiveID,'distance',distance)
    2717             : 
    2718          48 :       IF (densityType.NE.DENSITY_TYPE_UNDEFINED_const) THEN
    2719          15 :          IF (PRESENT(fermiEnergy)) CALL io_read_attreal0(groupID,'fermiEnergy',fermiEnergy)
    2720          15 :          IF (PRESENT(l_qfix)) CALL io_read_attlog0(groupID,'l_qfix',l_qfix)
    2721             :       END IF
    2722             : 
    2723          48 :       CALL h5gclose_f(groupID, hdfError)
    2724          48 :       CALL h5gclose_f(archiveID, hdfError)
    2725             : 
    2726          96 :    END SUBROUTINE peekDensityEntryHDF
    2727             : 
    2728         162 :    SUBROUTINE writeCoreDensityHDF(fileID,input,atoms,dimension,rhcs,tecs,qints)
    2729             : 
    2730             :       TYPE(t_atoms),    INTENT(IN) :: atoms
    2731             :       TYPE(t_input),    INTENT(IN) :: input
    2732             :       TYPE(t_dimension),INTENT(IN) :: DIMENSION
    2733             : 
    2734             :       INTEGER(HID_T), INTENT(IN) :: fileID
    2735             :       REAL,           INTENT(IN) :: rhcs(:,:,:)!(dimension%msh,atoms%ntype,input%jspins)
    2736             :       REAL,           INTENT(IN) :: tecs(:,:)!(atoms%ntype,input%jspins)
    2737             :       REAL,           INTENT(IN) :: qints(:,:)!(atoms%ntype,input%jspins)
    2738             : 
    2739             :       INTEGER hdfError
    2740             :       INTEGER(HID_T) cdncGroupID, rhcsSpaceID, rhcsSetID
    2741             :       INTEGER(HID_T) tecsSpaceID, tecsSetID, qintsSpaceID, qintsSetID
    2742             :       LOGICAL l_exist
    2743             :       INTEGER(HSIZE_T) :: dims(7)
    2744             :       INTEGER          :: dimsInt(7)
    2745             : 
    2746         162 :       l_exist = io_groupexists(fileID,'/cdnc')
    2747             : 
    2748         162 :       IF(l_exist) THEN ! replace current core density
    2749         139 :          CALL h5gopen_f(fileID, '/cdnc', cdncGroupID, hdfError)
    2750             : 
    2751         139 :          CALL io_write_attint0(cdncGroupID,'jspd',input%jspins)
    2752         139 :          CALL io_write_attint0(cdncGroupID,'ntype',atoms%ntype)
    2753         139 :          CALL io_write_attint0(cdncGroupID,'jmtd',atoms%jmtd)
    2754             : 
    2755         139 :          dimsInt(:3)=(/atoms%jmtd,atoms%ntype,input%jspins/)
    2756         139 :          CALL h5dopen_f(cdncGroupID, 'rhcs', rhcsSetID, hdfError)
    2757         139 :          CALL io_write_real3(rhcsSetID,(/1,1,1/),dimsInt(:3),rhcs(:dimsInt(1),:dimsInt(2),:dimsInt(3)))
    2758         139 :          CALL h5dclose_f(rhcsSetID, hdfError)
    2759             : 
    2760         139 :          dimsInt(:2)=(/atoms%ntype,input%jspins/)
    2761         139 :          CALL h5dopen_f(cdncGroupID, 'tecs', tecsSetID, hdfError)
    2762         139 :          CALL io_write_real2(tecsSetID,(/1,1/),dimsInt(:2),tecs)
    2763         139 :          CALL h5dclose_f(tecsSetID, hdfError)
    2764             : 
    2765         139 :          dimsInt(:2)=(/atoms%ntype,input%jspins/)
    2766         139 :          CALL h5dopen_f(cdncGroupID, 'qints', qintsSetID, hdfError)
    2767         139 :          CALL io_write_real2(qintsSetID,(/1,1/),dimsInt(:2),qints)
    2768         139 :          CALL h5dclose_f(qintsSetID, hdfError)
    2769             : 
    2770         139 :          CALL h5gclose_f(cdncGroupID, hdfError)
    2771             :       ELSE ! write new core density
    2772          23 :          CALL h5gcreate_f(fileID, '/cdnc', cdncGroupID, hdfError)
    2773             : 
    2774          23 :          CALL io_write_attint0(cdncGroupID,'jspd',input%jspins)
    2775          23 :          CALL io_write_attint0(cdncGroupID,'ntype',atoms%ntype)
    2776          23 :          CALL io_write_attint0(cdncGroupID,'jmtd',atoms%jmtd)
    2777             : 
    2778          23 :          dims(:3)=(/atoms%jmtd,atoms%ntype,input%jspins/)
    2779         184 :          dimsInt = dims
    2780          23 :          CALL h5screate_simple_f(3,dims(:3),rhcsSpaceID,hdfError)
    2781          23 :          CALL h5dcreate_f(cdncGroupID, "rhcs", H5T_NATIVE_DOUBLE, rhcsSpaceID, rhcsSetID, hdfError)
    2782          23 :          CALL h5sclose_f(rhcsSpaceID,hdfError)
    2783          23 :          CALL io_write_real3(rhcsSetID,(/1,1,1/),dimsInt(:3),rhcs(:dimsInt(1),:dimsInt(2),:dimsInt(3)))
    2784          23 :          CALL h5dclose_f(rhcsSetID, hdfError)
    2785             : 
    2786          23 :          dims(:2)=(/atoms%ntype,input%jspins/)
    2787         184 :          dimsInt = dims
    2788          23 :          CALL h5screate_simple_f(2,dims(:2),tecsSpaceID,hdfError)
    2789          23 :          CALL h5dcreate_f(cdncGroupID, "tecs", H5T_NATIVE_DOUBLE, tecsSpaceID, tecsSetID, hdfError)
    2790          23 :          CALL h5sclose_f(tecsSpaceID,hdfError)
    2791          23 :          CALL io_write_real2(tecsSetID,(/1,1/),dimsInt(:2),tecs)
    2792          23 :          CALL h5dclose_f(tecsSetID, hdfError)
    2793             : 
    2794          23 :          dims(:2)=(/atoms%ntype,input%jspins/)
    2795         184 :          dimsInt = dims
    2796          23 :          CALL h5screate_simple_f(2,dims(:2),qintsSpaceID,hdfError)
    2797          23 :          CALL h5dcreate_f(cdncGroupID, "qints", H5T_NATIVE_DOUBLE, qintsSpaceID, qintsSetID, hdfError)
    2798          23 :          CALL h5sclose_f(qintsSpaceID,hdfError)
    2799          23 :          CALL io_write_real2(qintsSetID,(/1,1/),dimsInt(:2),qints)
    2800          23 :          CALL h5dclose_f(qintsSetID, hdfError)
    2801             : 
    2802          23 :          CALL h5gclose_f(cdncGroupID, hdfError)
    2803             :       END IF
    2804             : 
    2805         162 :    END SUBROUTINE writeCoreDensityHDF
    2806             : 
    2807           2 :    SUBROUTINE readCoreDensityHDF(fileID,input,atoms,dimension,rhcs,tecs,qints)
    2808             : 
    2809             :       TYPE(t_atoms),    INTENT(IN) :: atoms
    2810             :       TYPE(t_input),    INTENT(IN) :: input
    2811             :       TYPE(t_dimension),INTENT(IN) :: DIMENSION
    2812             : 
    2813             :       INTEGER(HID_T), INTENT(IN) :: fileID
    2814             :       REAL,    INTENT(OUT)       :: rhcs(atoms%jmtd,atoms%ntype,input%jspins)
    2815             :       REAL,    INTENT(OUT)       :: tecs(atoms%ntype,input%jspins)
    2816             :       REAL,    INTENT(OUT)       :: qints(atoms%ntype,input%jspins)
    2817             : 
    2818             :       INTEGER hdfError
    2819             :       INTEGER(HID_T) cdncGroupID, rhcsSetID, tecsSetID, qintsSetID
    2820             :       INTEGER jspdTemp, ntypeTemp, jmtdTemp
    2821             :       LOGICAL l_exist
    2822             :       INTEGER :: dimsInt(7)
    2823             : 
    2824           2 :       l_exist = io_groupexists(fileID,'/cdnc')
    2825           2 :       IF(.NOT.l_exist) THEN
    2826           0 :          CALL juDFT_error("no core density found",calledby ="readCoreDensityHDF")
    2827             :       END IF
    2828             : 
    2829           2 :       CALL h5gopen_f(fileID, '/cdnc', cdncGroupID, hdfError)
    2830             : 
    2831           2 :       CALL io_read_attint0(cdncGroupID,'jspd',jspdTemp)
    2832           2 :       CALL io_read_attint0(cdncGroupID,'ntype',ntypeTemp)
    2833           2 :       CALL io_read_attint0(cdncGroupID,'jmtd',jmtdTemp)
    2834             : 
    2835           2 :       IF(jspdTemp.NE.input%jspins) CALL juDFT_error("jspd is inconsistent",calledby ="readCoreDensityHDF")
    2836           2 :       IF(ntypeTemp.NE.atoms%ntype) CALL juDFT_error("ntype is inconsistent",calledby ="readCoreDensityHDF")
    2837           2 :       IF(jmtdTemp.NE.atoms%jmtd) CALL juDFT_error("jmtd is inconsistent",calledby ="readCoreDensityHDF")
    2838             : 
    2839           2 :       dimsInt(:3)=(/atoms%jmtd,atoms%ntype,input%jspins/)
    2840           2 :       CALL h5dopen_f(cdncGroupID, 'rhcs', rhcsSetID, hdfError)
    2841           2 :       CALL io_read_real3(rhcsSetID,(/1,1,1/),dimsInt(:3),rhcs)
    2842           2 :       CALL h5dclose_f(rhcsSetID, hdfError)
    2843             : 
    2844           2 :       dimsInt(:2)=(/atoms%ntype,input%jspins/)
    2845           2 :       CALL h5dopen_f(cdncGroupID, 'tecs', tecsSetID, hdfError)
    2846           2 :       CALL io_read_real2(tecsSetID,(/1,1/),dimsInt(:2),tecs)
    2847           2 :       CALL h5dclose_f(tecsSetID, hdfError)
    2848             : 
    2849           2 :       dimsInt(:2)=(/atoms%ntype,input%jspins/)
    2850           2 :       CALL h5dopen_f(cdncGroupID, 'qints', qintsSetID, hdfError)
    2851           2 :       CALL io_read_real2(qintsSetID,(/1,1/),dimsInt(:2),qints)
    2852           2 :       CALL h5dclose_f(qintsSetID, hdfError)
    2853             : 
    2854           2 :       CALL h5gclose_f(cdncGroupID, hdfError)
    2855             : 
    2856           2 :    END SUBROUTINE readCoreDensityHDF
    2857             : 
    2858           0 :    LOGICAL FUNCTION deleteDensityEntryHDF(fileID,archiveName)
    2859             : 
    2860             :       INTEGER(HID_T), INTENT(IN)   :: fileID
    2861             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    2862             : 
    2863             :       INTEGER                      :: hdfError
    2864             :       LOGICAL                      :: l_exist
    2865             : 
    2866           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2867           0 :       IF(.NOT.l_exist) THEN
    2868             :          deleteDensityEntryHDF = .FALSE.
    2869             :          RETURN
    2870             :       END IF
    2871             : 
    2872           0 :       CALL h5ldelete_f(fileID, archiveName, hdfError)
    2873             : 
    2874           0 :       deleteDensityEntryHDF = .TRUE.
    2875             : 
    2876           0 :    END FUNCTION deleteDensityEntryHDF
    2877             : 
    2878           2 :    LOGICAL FUNCTION isCoreDensityPresentHDF()
    2879             : 
    2880             :       INTEGER(HID_T) :: fileID
    2881             :       INTEGER        :: currentStarsIndex,currentLatharmsIndex
    2882             :       INTEGER        :: currentStructureIndex, currentStepfunctionIndex
    2883             :       INTEGER        :: readDensityIndex, lastDensityIndex
    2884             :       LOGICAL        :: l_exist
    2885             : 
    2886           2 :       INQUIRE(FILE='cdn.hdf',EXIST=l_exist)
    2887           2 :       IF(.NOT.l_exist) THEN
    2888             :          isCoreDensityPresentHDF = .FALSE.
    2889             :          RETURN
    2890             :       END IF
    2891             :       CALL openCDN_HDF(fileID,currentStarsIndex,currentLatharmsIndex,currentStructureIndex,&
    2892           2 :                        currentStepfunctionIndex,readDensityIndex,lastDensityIndex)
    2893           2 :       isCoreDensityPresentHDF = io_groupexists(fileID,'/cdnc')
    2894           2 :       CALL closeCDNPOT_HDF(fileID)
    2895           2 :    END FUNCTION
    2896             : 
    2897          69 :    LOGICAL FUNCTION isDensityEntryPresentHDF(fileID,archiveName,densityType)
    2898             : 
    2899             :       INTEGER(HID_T), INTENT(IN)   :: fileID
    2900             :       INTEGER , INTENT(IN)         :: densityType
    2901             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    2902             : 
    2903             :       INTEGER                      :: localDensityType
    2904             :       CHARACTER(LEN=30)            :: groupName, densityTypeName
    2905             :       LOGICAL                      :: l_exist
    2906             : 
    2907          69 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2908          69 :       IF(.NOT.l_exist) THEN
    2909             :          isDensityEntryPresentHDF = .FALSE.
    2910             :          RETURN
    2911             :       END IF
    2912             : 
    2913          68 :       localDensityType = densityType
    2914          33 :       SELECT CASE (densityType)
    2915             :          CASE(DENSITY_TYPE_UNDEFINED_const)
    2916          33 :             densityTypeName = ''
    2917             :          CASE(DENSITY_TYPE_IN_const)
    2918          28 :             densityTypeName = '/in'
    2919             :          CASE(DENSITY_TYPE_OUT_const)
    2920           0 :             densityTypeName = '/out'
    2921             :          CASE(DENSITY_TYPE_NOCO_IN_const)
    2922           7 :             densityTypeName = '/noco_in'
    2923           7 :             groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2924           7 :             l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2925           7 :             IF(.NOT.l_exist) THEN
    2926           7 :                localDensityType = DENSITY_TYPE_IN_const
    2927           7 :                densityTypeName = '/in'
    2928             :             END IF
    2929             :          CASE(DENSITY_TYPE_NOCO_OUT_const)
    2930           0 :             densityTypeName = '/noco_out'
    2931           0 :             groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2932           0 :             l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2933           0 :             IF(.NOT.l_exist) THEN
    2934           0 :                localDensityType = DENSITY_TYPE_OUT_const
    2935           0 :                densityTypeName = '/out'
    2936             :             END IF
    2937             :          CASE(DENSITY_TYPE_PRECOND_const)
    2938           0 :             densityTypeName = '/precond'
    2939             :          CASE DEFAULT
    2940          68 :             CALL juDFT_error("Unknown density type selected",calledby ="isDensityEntryPresentHDF")
    2941             :       END SELECT
    2942             : 
    2943          68 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(densityTypeName))
    2944          68 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2945             : 
    2946          68 :       isDensityEntryPresentHDF = l_exist
    2947         137 :    END FUNCTION
    2948             : 
    2949           0 :    LOGICAL FUNCTION isPotentialEntryPresentHDF(fileID,archiveName,potentialType)
    2950             : 
    2951             :       INTEGER(HID_T), INTENT(IN)   :: fileID
    2952             :       INTEGER , INTENT(IN)         :: potentialType
    2953             :       CHARACTER(LEN=*), INTENT(IN) :: archiveName
    2954             : 
    2955             :       CHARACTER(LEN=30)            :: groupName, potentialTypeName
    2956             :       LOGICAL                      :: l_exist
    2957             : 
    2958           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(archiveName)))
    2959           0 :       IF(.NOT.l_exist) THEN
    2960             :          isPotentialEntryPresentHDF = .FALSE.
    2961             :          RETURN
    2962             :       END IF
    2963             : 
    2964           0 :       SELECT CASE (potentialType)
    2965             :          CASE(POTENTIAL_TYPE_IN_const)
    2966           0 :             potentialTypeName = '/in'
    2967             :          CASE(POTENTIAL_TYPE_OUT_const)
    2968           0 :             potentialTypeName = '/out'
    2969             :          CASE DEFAULT
    2970           0 :             CALL juDFT_error("Unknown potential type selected",calledby ="isPotentialEntryPresentHDF")
    2971             :       END SELECT
    2972             : 
    2973           0 :       groupName = TRIM(ADJUSTL(archiveName))//TRIM(ADJUSTL(potentialTypeName))
    2974           0 :       l_exist = io_groupexists(fileID,TRIM(ADJUSTL(groupName)))
    2975             : 
    2976           0 :       isPotentialEntryPresentHDF = l_exist
    2977           0 :    END FUNCTION
    2978             : 
    2979             : #endif
    2980             : 
    2981             : END MODULE m_cdnpot_io_hdf

Generated by: LCOV version 1.13