chainset_append Subroutine

private subroutine chainset_append(cs, cei, cy, cn)

Store one chain, growing by doubling like bandset_append.

Chains of fewer than two points are dropped.

Arguments

Type IntentOptional Attributes Name
type(chainset_t), intent(inout) :: cs

Chain set.

integer(kind=int32), intent(in) :: cei(:)

Strip edge of each point; number of points.

real(kind=real64), intent(in) :: cy(:)

y of each point.

integer(kind=int32), intent(in) :: cn

Strip edge of each point; number of points.


Source Code

   subroutine chainset_append(cs, cei, cy, cn)
      !! Store one chain, growing by doubling like `bandset_append`.
      !!
      !! Chains of fewer than two points are dropped.
      ! Arguments
      type(chainset_t), intent(inout) :: cs
         !! Chain set.
      integer(int32), intent(in) :: cei(:), cn
         !! Strip edge of each point; number of points.
      real(real64), intent(in) :: cy(:)
         !! y of each point.
      type(chain_t), allocatable :: tmp(:)
      integer(int32) :: cap
      if (cn < 2) return
      if (.not. allocated(cs%c)) allocate (cs%c(8))
      cap = int(size(cs%c), int32)
      if (cs%nc == cap) then
         allocate (tmp(2*cap))
         tmp(1:cap) = cs%c
         call move_alloc(tmp, cs%c)
      end if
      cs%nc = cs%nc + 1
      cs%c(cs%nc)%n = cn
      cs%c(cs%nc)%ei = cei(1:cn)
      cs%c(cs%nc)%y = cy(1:cn)
   end subroutine chainset_append