draw_energy Subroutine

private subroutine draw_energy(layer)

Fill energy layer as nested solid bands.

One cached bandset per integer contour level, so one polygon per contiguous model run. Loss levels shade white to magenta, outermost first, then gain levels white to blue, nested inward.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: layer

Energy layer index, as in layers.f90.


Source Code

   subroutine draw_energy(layer)
      !! Fill energy layer as nested solid bands.
      !!
      !! One cached bandset per integer contour level, so one polygon per contiguous model run. Loss
      !! levels shade white to magenta, outermost first, then gain levels white to blue, nested
      !! inward.
      ! Arguments
      integer(int32), intent(in) :: layer
         !! Energy layer index, as in layers.f90.
      integer(int32) :: lev
      real(real64) :: f
      if (.not. ecache(layer)%valid) call build_energy_cache(layer)

      call giza_set_fill(1)         ! solid bands (convection hatch goes on top)
      call giza_set_line_width(1.d0)
      associate (ec => ecache(layer))
         ! loss (negative) levels: white -> magenta, outermost first
         do lev = 1, ec%lmax
            f = real(lev, real64)/real(max(ec%lmax, 1_int32), real64)
            call giza_set_colour_representation(7, 1.d0, 1.d0 - 0.85d0*f, 1.d0)
            call giza_set_colour_index(7)
            call draw_bandset(ec%loss(lev))
         end do
         ! gain (positive) levels: white -> blue, nested inwards
         do lev = 1, ec%gmax
            f = real(lev, real64)/real(max(ec%gmax, 1_int32), real64)
            call giza_set_colour_representation(7, 1.d0 - 0.85d0*f, 1.d0 - 0.85d0*f, 1.d0)
            call giza_set_colour_index(7)
            call draw_bandset(ec%gain(lev))
         end do
      end associate
   end subroutine draw_energy