base_util_append_arr_I4B Subroutine

public subroutine base_util_append_arr_I4B(arr, source, nold, lsource_mask)

Append a single array of integer(I4B) onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it.

Arguments

Type IntentOptional Attributes Name
integer(kind=I4B), intent(inout), dimension(:), allocatable :: arr

Destination array

integer(kind=I4B), intent(in), dimension(:), allocatable :: source

Array to append

integer(kind=I4B), intent(in), optional :: nold

Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used.

logical, intent(in), optional, dimension(:) :: lsource_mask

Logical mask indicating which elements to append to


Calls

proc~~base_util_append_arr_i4b~~CallsGraph proc~base_util_append_arr_i4b base_util_append_arr_I4B interface~util_resize~2 util_resize proc~base_util_append_arr_i4b->interface~util_resize~2 proc~base_util_resize_arr_char_string base_util_resize_arr_char_string interface~util_resize~2->proc~base_util_resize_arr_char_string proc~base_util_resize_arr_dp base_util_resize_arr_DP interface~util_resize~2->proc~base_util_resize_arr_dp proc~base_util_resize_arr_dpvec base_util_resize_arr_DPvec interface~util_resize~2->proc~base_util_resize_arr_dpvec proc~base_util_resize_arr_i4b base_util_resize_arr_I4B interface~util_resize~2->proc~base_util_resize_arr_i4b proc~base_util_resize_arr_logical base_util_resize_arr_logical interface~util_resize~2->proc~base_util_resize_arr_logical

Called by

proc~~base_util_append_arr_i4b~~CalledByGraph proc~base_util_append_arr_i4b base_util_append_arr_I4B interface~util_append~2 util_append interface~util_append~2->proc~base_util_append_arr_i4b

Source Code

      subroutine base_util_append_arr_I4B(arr, source, nold, lsource_mask)
         !! author: David A. Minton 
         !! 
         !! Append a single array of integer(I4B) onto another. If the destination array is not allocated, or is not big enough,
         !! this will allocate space for it. 
         implicit none
         ! Arguments
         integer(I4B), dimension(:), allocatable, intent(inout) :: arr          
            !! Destination array  
         integer(I4B), dimension(:), allocatable, intent(in)    :: source       
            !! Array to append  
         integer(I4B), intent(in), optional :: nold 
            !! Extent of original array. If passed, the source array will begin at arr(nold+1).
            !! Otherwise, the size of arr will be used. 
         logical, dimension(:), intent(in), optional :: lsource_mask 
            !! Logical mask indicating which elements to append to 
         ! Internals
         integer(I4B) :: nnew, nsrc, nend_orig

         if (.not.allocated(source)) return

         if (present(lsource_mask)) then
            nsrc = count(lsource_mask(:))
         else
            nsrc = size(source)
         end if
         if (nsrc == 0) return

         if (.not.allocated(arr)) then
            nend_orig = 0
            allocate(arr(nsrc))
         else
            if (present(nold)) then
               nend_orig = nold
            else
               nend_orig = size(arr)
            end if
            call util_resize(arr, nend_orig + nsrc)
         end if
         nnew = nend_orig + nsrc

         if (present(lsource_mask)) then
            arr(nend_orig + 1:nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc))
         else
            arr(nend_orig + 1:nnew) = source(1:nsrc)
         end if

         return
      end subroutine base_util_append_arr_I4B