kipp_set_unit Subroutine

public subroutine kipp_set_unit(arg, ok)

Set display unit of axis matching unit's dimension.

solar and cgs set mass and radius units together; a time unit pins time axis, auto lets it follow visible span again. View limits converted so view stays in place; bands index x strips and hold cgs y, so nothing retraced.

Arguments

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

Unit name or alias known to unit_id, or auto, solar or cgs.

logical, intent(out) :: ok

False for unknown unit.


Source Code

   subroutine kipp_set_unit(arg, ok)
      !! Set display unit of axis matching unit's dimension.
      !!
      !! `solar` and `cgs` set mass and radius units together; a time unit pins time axis, `auto`
      !! lets it follow visible span again. View limits converted so view stays in place; bands
      !! index x strips and hold cgs y, so nothing retraced.
      ! Arguments
      character(len=*), intent(in) :: arg
         !! Unit name or alias known to `unit_id`, or `auto`, `solar` or `cgs`.
      logical, intent(out) :: ok
         !! False for unknown unit.
      integer(int32) :: k
      ok = .true.
      select case (arg)
      case ('auto')
         st%tauto = .true.
         return
      case ('solar')
         call set_y_units('Msun', 'Rsun')
         return
      case ('cgs')
         call set_y_units('g', 'cm')
         return
      end select
      k = unit_id(arg)
      ok = (k > 0)
      if (.not. ok) return
      select case (UDIM(k))
      case (DIM_TIME)
         st%tauto = .false.
         call set_time_unit(k)
      case (DIM_MASS)
         call set_y_units(UNAME(k), st%runit)
      case (DIM_LENGTH)
         call set_y_units(st%munit, UNAME(k))
      end select
   end subroutine kipp_set_unit