module disp_m

    use, intrinsic :: iso_fortran_env, only: output_unit, sp => real32, dp => real64
    implicit none
    private

    public :: disp

contains

    !> Displays dataset x
    subroutine disp(x)
        class(*), intent(in) :: x(..)                       !! Dataset to be displayed

        select rank (x)
        rank (0)
            select type (x)  ! <-- This line
            type is (real(sp)); write (*, '(g0.4)') x
            type is (real(dp)); write (*, '(g0.4)') x
            type is (integer); write (*, '(g0.4)') x
            type is (logical); write (*, '(g0.4)') x
            end select
        end select

    end subroutine disp

end module disp_m

program main

    use disp_m, only: disp

    logical :: l = .true.
    call disp(l)  ! <-- This line
    call disp(1)
    call disp(1.0)
    call disp(1.0d0)

end program main
