read_dp_1d_dataset Subroutine

public subroutine read_dp_1d_dataset(parent, nm, val, exists, default, required)

Arguments

Type IntentOptional Attributes Name
integer(kind=hid_t), intent(in) :: parent
character(len=*), intent(in) :: nm
real(kind=dp), intent(out), target :: val(:)
logical, intent(out), optional :: exists
real(kind=dp), intent(in), optional :: default(:)
logical, intent(in), optional :: required

Contents

Source Code


Source Code

    subroutine read_dp_1d_dataset(parent, nm, val, exists, default, required)

        integer(hid_t), intent(in) :: parent
        character(*), intent(in) :: nm
        real(dp), intent(out), target :: val(:)
        logical, intent(out), optional :: exists
        logical, intent(in), optional :: required
        real(dp), intent(in), optional :: default(:)
        character(*), parameter :: t_r = 'read_dp_1d_dataset'

        integer(hid_t) :: dataset, type_id
        integer(hdf_err) :: err
        integer(hsize_t) :: dims(1)
        logical(hdf_log) :: exists_
        real(dp), allocatable :: buf(:)

        call h5lexists_f(parent, nm, exists_, err)
        if (exists_) then
            call h5dopen_f(parent, nm, dataset, err)
            call h5dget_type_f(dataset, type_id, err)

            ! set up the read-buffer: We might need to add/remove replicas
            call setup_dp_1d_dataset_buffer(buf,val)

            ! Check dimensions and types.
            dims = [size(buf, kind=int64)]
            ! check versus the input, not the calculation's parameters
            call check_dataset_params(dataset, nm, 8_hsize_t, H5T_FLOAT_F, dims)

            ! And actually read the data.
            call h5dread_f(dataset, type_id, buf, dims, err)

            ! and move the data to val
            call move_dp_1d_dataset_buffer(val,buf)

            call h5tclose_f(type_id, err)
            call h5dclose_f(dataset, err)

        end if

        if (present(required)) then
            if (required .and. .not. exists_) then
                write(stdout, *) nm
                call stop_all(t_r, "Required field does not exist")
            end if
        end if
        if (present(exists)) exists = exists_
        if (present(default) .and. .not. exists_) val = default

    end subroutine read_dp_1d_dataset