cube__bmp2seg Subroutine

private pure subroutine cube__bmp2seg(self, segments)

Type Bound

cube_t

Arguments

Type IntentOptional Attributes Name
class(cube_t), intent(in) :: self
type(segment_t), intent(inout), allocatable :: segments(:)

Source Code

   pure subroutine cube__bmp2seg(self, segments)
      implicit none
      class(cube_t), intent(in) :: self
      type(segment_t), allocatable, intent(inout) :: segments(:)

      type(segment_t), allocatable :: tmp(:)

      integer :: m, n

      if (allocated(segments)) deallocate(segments)

      if (.not. self%is_switched_to_bmp) then
         call self%ascii%ascii2seg(segments)
         return
      end if

      if (allocated(self%bmp)) then
         call self%bmp%bmp2seg(tmp)
         m = size(tmp, dim=1)
      else
         m = 0
      end if

      if (allocated(self%sps)) then
         n = size(self%sps, dim=1)
      else
         n = 0
      end if

      if (m+n > 0) then
         allocate(segments(m+n))
         segments(1:m) = tmp(1:m)
         if (n > 0) segments(m+1:m+n) = self%sps(1:n)
      end if

   end subroutine cube__bmp2seg