kipp_set_cmap Subroutine

public subroutine kipp_set_cmap(arg, ok)

Select colormap by name or by number in kipp_list_cmaps.

_r suffix on either reverses it; grey reads as gray.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: arg

Colormap name or number, optionally suffixed _r.

logical, intent(out) :: ok

False for unknown colormap, leaving st%cmap unchanged.


Source Code

   subroutine kipp_set_cmap(arg, ok)
      !! Select colormap by name or by number in `kipp_list_cmaps`.
      !!
      !! `_r` suffix on either reverses it; `grey` reads as `gray`.
      ! Arguments
      character(len=*), intent(in) :: arg
         !! Colormap name or number, optionally suffixed `_r`.
      logical, intent(out) :: ok
         !! False for unknown colormap, leaving `st%cmap` unchanged.
      character(len=len(arg)) :: base
      integer(int32) :: k
      logical :: rev
      rev = is_reversed(arg)
      base = arg(1:len_trim(arg) - merge(2, 0, rev))
      if (base == 'grey') base = 'gray'
      k = findloc(CMAP_NAMES, base, 1)
      if (k == 0) k = list_index(base)
      ok = k >= 1 .and. k <= NCMAPS
      if (ok) st%cmap = trim(CMAP_NAMES(k))//merge('_r', '  ', rev)
   end subroutine kipp_set_cmap