write_gdata_hdf5 Subroutine

private subroutine write_gdata_hdf5(this, gdata_buf, pos)

Type Bound

gdata_io_t

Arguments

Type IntentOptional Attributes Name
class(gdata_io_t), intent(in) :: this
integer(kind=hsize_t), intent(out) :: gdata_buf(:)
integer, intent(in) :: pos

Contents

Source Code


Source Code

    subroutine write_gdata_hdf5(this, gdata_buf, pos)
        ! Write the gdata of a single determinant to a buffer usable in hdf5 popsfiles
        ! Input: gdata_buf - gdata for the determinant at pos, has to be of size this%entry_size
        !        pos - position to get the written data from
        class(gdata_io_t), intent(in) :: this
        integer(hsize_t), intent(out) :: gdata_buf(:)
        integer, intent(in) :: pos

        logical :: t_aas, t_sb, t_ap

        ! if these are above 0, the option has been set and memory is reserved
        t_aas = this%fvals_end - this%fvals_start + 1 > 0
        t_sb = this%max_ratio_end - this%max_ratio_start + 1 > 0
        t_ap = this%apvals_end - this%apvals_start + 1 > 0

        if (this%entry_size() <= size(gdata_buf, dim=1)) then
            if (t_aas) then
                ! write the fvals to the buffer at the respective position
                call writeFValsAsInt(gdata_buf(this%fvals_start:this%fvals_end), pos)
            end if

            if (t_sb) then
                ! write the ratios to the buffer at the respective position
                call write_max_ratio_as_int(gdata_buf(this%max_ratio_start:this%max_ratio_end), pos)
            end if

            if (t_ap) then
                ! write the apvals to the buffer at the respective position
                call writeAPValsAsInt(gdata_buf(this%apvals_start:this%apvals_end), pos)
            end if
        else
            write(stderr, *) "WARNING: Dimension mismatch in write_gdata_hdf5, writing 0"
            gdata_buf = 0_hsize_t
        end if
    end subroutine write_gdata_hdf5