kipp_set_cfield Subroutine

public subroutine kipp_set_cfield(arg, ok)

Select colour field by name or by number in kipp_list_fields.

Negative number shows column field in its other (linear or log) scale. Refused selection prints reason, leaves st unchanged.

Arguments

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

Selector name, number, or negative number.

logical, intent(out) :: ok

False if selection refused.


Source Code

   subroutine kipp_set_cfield(arg, ok)
      !! Select colour field by name or by number in `kipp_list_fields`.
      !!
      !! Negative number shows column field in its other (linear or log) scale. Refused selection
      !! prints reason, leaves `st` unchanged.
      ! Arguments
      character(len=*), intent(in) :: arg
         !! Selector name, number, or negative number.
      logical, intent(out) :: ok
         !! False if selection refused.
      character(len=8), parameter :: FIXED(3) = [character(len=8) :: 'convtype', 'epsnuc', 'neu']
      integer(int32) :: k
      logical :: flip
      flip = .false.
      k = list_index(arg)
      if (k == 0 .and. arg(1:1) == '-') then
         k = list_index(arg(2:))
         flip = k > 0
      end if
      ok = .false.
      if (k > 3 + nfields) then
         print *, 'no color entry ', arg, '   (type color for the list)'
         return
      end if
      if (flip) then
         if (k <= 3) then
            print *, 'no lin/log switch for the fixed selectors 1-3'
            return
         end if
         if (.not. field_log(k - 3) .and. field_vpos(k - 3) > field_vmax(k - 3)) then
            print *, 'no log scale for ', trim(field_names(k - 3)), ': no positive values'
            return
         end if
      end if
      ok = .true.
      st%cflip = flip
      if (k == 0) then
         st%cfield = arg
      else if (k <= 3) then
         st%cfield = FIXED(k)
      else
         st%cfield = field_names(k - 3)
      end if
   end subroutine kipp_set_cfield