bandset_append Subroutine

private subroutine bandset_append(bs, i0, i1, ylo, yhi)

Append one band, growing by doubling.

Arguments

Type IntentOptional Attributes Name
type(bandset_t), intent(inout) :: bs

Band set.

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

First and last model of band.

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

First and last model of band.

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

Lower and upper interface in each model, i1 - i0 + 1 entries.

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

Lower and upper interface in each model, i1 - i0 + 1 entries.


Source Code

   subroutine bandset_append(bs, i0, i1, ylo, yhi)
      !! Append one band, growing by doubling.
      ! Arguments
      type(bandset_t), intent(inout) :: bs
         !! Band set.
      integer(int32), intent(in)    :: i0, i1
         !! First and last model of band.
      real(real64), intent(in)    :: ylo(:), yhi(:)
         !! Lower and upper interface in each model, `i1 - i0 + 1` entries.
      type(band_t), allocatable :: tmp(:)
      integer(int32) :: cap
      if (.not. allocated(bs%b)) allocate (bs%b(8))
      cap = int(size(bs%b), int32)
      if (bs%nb == cap) then
         allocate (tmp(2*cap))
         tmp(1:cap) = bs%b
         call move_alloc(tmp, bs%b)
      end if
      bs%nb = bs%nb + 1
      bs%b(bs%nb)%i0 = i0
      bs%b(bs%nb)%i1 = i1
      bs%b(bs%nb)%ylo = ylo
      bs%b(bs%nb)%yhi = yhi
   end subroutine bandset_append