Skip to content

Commit

Permalink
fixes #38 in src/colormap_class.f90: check_bounds replaces check_zmin…
Browse files Browse the repository at this point in the history
… and check_zmax
  • Loading branch information
vmagnin committed Mar 6, 2024
1 parent bceaa70 commit 9283055
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/colormap_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
! SOFTWARE.
!-------------------------------------------------------------------------------
! Contributed by vmagnin: 2023-09-26
! Last modification: gha3mi 2024-02-16, vmagnin 2024-02-16
! Last modification: gha3mi 2024-02-16, vmagnin 2024-03-06
!-------------------------------------------------------------------------------


Expand Down Expand Up @@ -92,7 +92,7 @@ pure subroutine set(self, name, zmin, zmax, levels, varargs, reverse)
end if

! Check validity of the colormap and fix it if necessary
call self%check(check_name=.true., check_zmin=.true., check_zmax=.true., check_levels=.true.)
call self%check(check_name=.true., check_bounds=.true., check_levels=.true.)

select case(self%name)
! Miscellaneous colormaps collection
Expand Down Expand Up @@ -601,7 +601,7 @@ pure subroutine create(self, name, zmin, zmax, map, reverse)
self%zmin = zmin
self%zmax = zmax

call self%check(check_zmin=.true., check_zmax=.true., check_levels=.true.)
call self%check(check_bounds=.true., check_levels=.true.)

! Is the colormap reseted?
if (allocated(self%map)) then
Expand Down Expand Up @@ -634,7 +634,7 @@ pure subroutine create_lagrange(self, name, zmin, zmax, colors, levels, reverse)
self%zmin = zmin
self%zmax = zmax

call self%check(check_zmin=.true., check_zmax=.true., check_levels=.true.)
call self%check(check_bounds=.true., check_levels=.true.)

! Is the colormap reseted?
if (allocated(self%map)) then
Expand Down Expand Up @@ -667,7 +667,7 @@ pure subroutine create_bezier(self, name, zmin, zmax, colors, levels, reverse)
self%zmin = zmin
self%zmax = zmax

call self%check(check_zmin=.true., check_zmax=.true., check_levels=.true.)
call self%check(check_bounds=.true., check_levels=.true.)

! Is the colormap reseted?
if (allocated(self%map)) then
Expand Down Expand Up @@ -731,7 +731,7 @@ impure subroutine load(self, filename, zmin, zmax, reverse)
self%zmax = zmax
self%levels = n

call self%check(check_zmin=.true., check_zmax=.true.)
call self%check(check_bounds=.true.)

! Reverse the colormap if requested
if (present(reverse)) then
Expand Down Expand Up @@ -1105,13 +1105,13 @@ pure function lagrange_poly(t, n) result(B)
end do
end function lagrange_poly

! Check validity of the colormap and fix it if necessary
pure subroutine check(self,check_name, check_zmin, check_zmax, check_levels)
!> Check validity of the colormap and fix it if necessary
pure subroutine check(self,check_name, check_bounds, check_levels)
use forcolormap_info, only: Colormaps_info

class(Colormap), intent(inout) :: self
logical, dimension(4) :: status
logical, intent(in), optional :: check_name, check_zmin, check_zmax, check_levels
logical, intent(in), optional :: check_name, check_bounds, check_levels
real(wp) :: temp
type(Colormaps_info) :: cmap_info
integer :: input_levels, i, levels
Expand Down Expand Up @@ -1176,15 +1176,14 @@ end subroutine error
end if
end if

if (present(check_zmin)) then
if (check_zmin) then

if (present(check_bounds)) then
if (check_bounds) then
! Check validity of zmin and zmax
if (self%zmin > self%zmax) status(2) = .false.

! Fix zmin and zmax if they are not valid
if (status(2) .eqv. .false.) then
temp = self%zmin
temp = self%zmin
self%zmin = self%zmax
self%zmax = temp
end if
Expand Down

0 comments on commit 9283055

Please sign in to comment.