check Program

Uses

  • program~~check~~UsesGraph program~check check module~forcolormap forcolormap program~check->module~forcolormap module~colormap_parameters colormap_parameters module~forcolormap->module~colormap_parameters module~matplotlib_colormaps matplotlib_colormaps module~forcolormap->module~matplotlib_colormaps module~miscellaneous_colormaps miscellaneous_colormaps module~forcolormap->module~miscellaneous_colormaps module~scientific_colour_maps scientific_colour_maps module~forcolormap->module~scientific_colour_maps iso_fortran_env iso_fortran_env module~colormap_parameters->iso_fortran_env module~matplotlib_colormaps->module~colormap_parameters module~miscellaneous_colormaps->module~colormap_parameters module~scientific_colour_maps->module~colormap_parameters

Automatic tests launched by fpm test. Test the shift() method: Test check() procedure within set() procedure Test check() procedure within create() procedure


Calls

program~~check~~CallsGraph program~check check proc~compute_rgb Colormap%compute_RGB program~check->proc~compute_rgb proc~create Colormap%create program~check->proc~create proc~get_levels~2 Colormap%get_levels program~check->proc~get_levels~2 proc~get_name~2 Colormap%get_name program~check->proc~get_name~2 proc~get_rgb Colormap%get_RGB program~check->proc~get_rgb proc~get_zmax Colormap%get_zmax program~check->proc~get_zmax proc~get_zmin Colormap%get_zmin program~check->proc~get_zmin proc~set Colormap%set program~check->proc~set proc~shift Colormap%shift program~check->proc~shift proc~compute_rgb->proc~get_rgb proc~check Colormap%check proc~create->proc~check proc~reverse Colormap%reverse proc~create->proc~reverse proc~set->proc~create proc~set->proc~check proc~cubehelix_colormap cubehelix_colormap proc~set->proc~cubehelix_colormap proc~fire_colormap fire_colormap proc~set->proc~fire_colormap proc~inv_rainbow_colormap inv_rainbow_colormap proc~set->proc~inv_rainbow_colormap proc~rainbow_colormap rainbow_colormap proc~set->proc~rainbow_colormap proc~set->proc~reverse proc~zebra_colormap zebra_colormap proc~set->proc~zebra_colormap proc~get_levels Colormaps_info%get_levels proc~check->proc~get_levels proc~get_name Colormaps_info%get_name proc~check->proc~get_name proc~get_ncolormaps Colormaps_info%get_ncolormaps proc~check->proc~get_ncolormaps proc~set_all Colormaps_info%set_all proc~check->proc~set_all proc~set_info table%set_info proc~set_all->proc~set_info

Variables

Type Attributes Name Initial
integer :: blue
type(Colormap) :: cmap
integer, dimension(0:6, 3) :: copy_colormap
integer :: green
integer :: i
integer :: red
integer, dimension(0:6, 3) :: test_colormap = reshape([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1], shape(test_colormap), order=[2, 1])

Source Code

program check
    use forcolormap

    implicit none
    type(Colormap) :: cmap
    integer :: red, green, blue
    integer, dimension(0:6, 3) :: test_colormap = reshape( [ &
        1, 2, 3, &
        4, 5, 6, &
        7, 8, 9, &
        0, 0, 0, &
        9, 8, 7, &
        6, 5, 4, &
        3, 2, 1 ], &
        shape(test_colormap), order = [2, 1] )
    integer, dimension(0:6, 3) :: copy_colormap
    integer :: i

    call cmap%create("discrete", 0.0_wp, 2.0_wp, test_colormap)
    copy_colormap = test_colormap

    if (cmap%get_levels() /= 7)    error stop "ERROR: colormap%get_levels()"
    if (cmap%get_zmin() /= 0.0_wp) error stop "ERROR: colormap%get_zmin()"
    if (cmap%get_zmax() /= 2.0_wp) error stop "ERROR: colormap%get_zmax()"
    if (trim(cmap%get_name()) /= "discrete") error stop "ERROR: colormap%get_current()"

    do i = 0, size(test_colormap(:, 1))-1
        call cmap%get_RGB(i, red, green, blue)
        if ((red /= test_colormap(i, 1)).or.(green /= test_colormap(i, 2)) &
            & .or.(blue /= test_colormap(i, 3))) error stop "ERROR: colormap%get_RGB()"
    end do

    call cmap%compute_RGB(0.0_wp, red, green, blue)
    if ((red /= test_colormap(0, 1)).or.(green /= test_colormap(0, 2)) &
            & .or.(blue /= test_colormap(0, 3))) error stop "ERROR: colormap%compute_RGB()"
    call cmap%compute_RGB(1.1_wp, red, green, blue)
    if ((red /= test_colormap(3, 1)).or.(green /= test_colormap(3, 2)) &
            & .or.(blue /= test_colormap(3, 3))) error stop "ERROR: colormap%compute_RGB()"
    call cmap%compute_RGB(2.0_wp, red, green, blue)
    if ((red /= test_colormap(6, 1)).or.(green /= test_colormap(6, 2)) &
            & .or.(blue /= test_colormap(6, 3))) error stop "ERROR: colormap%compute_RGB()"

    !! Test the shift() method:
    call cmap%shift(+2)         ! Toward left
    call cmap%get_RGB(0, red, green, blue)
    if ((red /= copy_colormap(2, 1)).or.(green /= copy_colormap(2, 2)) &
        & .or.(blue /= copy_colormap(2, 3))) error stop "ERROR: colormap%shift()"
    call cmap%shift(-1)         ! Toward right
    call cmap%get_RGB(6, red, green, blue)
    if ((red /= copy_colormap(0, 1)).or.(green /= copy_colormap(0, 2)) &
        & .or.(blue /= copy_colormap(0, 3))) error stop "ERROR: colormap%shift()"

    !! Test check() procedure within set() procedure
    print *, "---------------------------------------------------------------------------"
    print *, "The following error messages confirm that the private check() method is OK:"
    print *, "---------------------------------------------------------------------------"
    ! Name is not in the list
    call cmap%set('actom10', 0.0_wp, 2.0_wp)
    if (cmap%get_name() /= 'grayC') error stop "ERROR: colormap%check() name"

    ! Maximum value is less than minimum value
    call cmap%set('acton10', 2.0_wp, 0.0_wp)
    if (cmap%get_zmin() /= 0.0_wp .or. cmap%get_zmax() /= 2.0_wp) error stop "ERROR: colormap%check() zmin > zmax"

    ! Number of levels is not equal to predefined number of levels
    call cmap%set('acton10', 0.0_wp, 2.0_wp, 256)
    if (cmap%get_levels() /= 10) error stop "ERROR: colormap%check() levels /= predefined levels"

    !! Test check() procedure within create() procedure
    ! Maximum value is less than minimum value
    call cmap%create("discrete", 2.0_wp, 0.0_wp, test_colormap)
    if (cmap%get_zmin() /= 0.0_wp .or. cmap%get_zmax() /= 2.0_wp) error stop "ERROR: colormap%check() zmin > zmax"

end program check