read_int64_scalar_8 Subroutine

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

Arguments

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

Contents

Source Code


Source Code

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

        integer(hid_t), intent(in) :: parent
        character(*), intent(in) :: nm
        integer(int64), intent(out) :: val
        logical, intent(out), optional :: exists
        logical, intent(in), optional :: required
        integer(int64), intent(in), optional :: default
        character(*), parameter :: t_r = 'read_int64_scalar'

        integer(hid_t) :: dataset
        integer(hdf_err) :: err
        logical(hdf_log) :: exists_
        integer(int32), pointer :: ptr

        ! Test if the relevant key exists
        call h5lexists_f(parent, nm, exists_, err)
        if (exists_) then
            call h5dopen_f(parent, nm, dataset, err)
            call ptr_abuse_scalar(val, ptr)
            call h5dread_f(dataset, h5kind_to_type(int64,H5_INTEGER_KIND), ptr, [1_hsize_t], err)
            if (err /= 0) &
                call stop_all(t_r, 'Read error')
            call h5dclose_f(dataset, err)
        endif

        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_int64_scalar_8