read_int64_attribute Subroutine

public subroutine read_int64_attribute(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_attribute(parent, nm, val, exists, default, &
                                    required)

        ! Read in a 64bit scalar attribute

        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_attribute'

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

        call h5aexists_f(parent, nm, exists_, err)
        if (exists_) then
            call h5aopen_f(parent, nm, attribute, err)
            call ptr_abuse_scalar(val, ptr)
            call h5aread_f(attribute, h5kind_to_type(int64,H5_INTEGER_KIND), ptr, &
                           [1_hsize_t], err)
            call h5aclose_f(attribute, 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_int64_attribute