push_back Subroutine

private pure subroutine push_back(vec, val)

Poor man implementation of a dynamic array, a là std::vector (but without preallocation and smart doubling...)

Type Bound

xy_lattice

Arguments

Type IntentOptional Attributes Name
class(xy_lattice), intent(inout) :: vec
type(xy_site), intent(in) :: val

Called by

proc~~push_back~~CalledByGraph proc~push_back xy_coordinates::xy_lattice%push_back proc~xy_ordered_union xy_coordinates::xy_ordered_union proc~xy_ordered_union->proc~push_back proc~hex2lattice xy_coordinates::hex2lattice proc~hex2lattice->proc~xy_ordered_union proc~get_flake honeytools::get_flake proc~get_flake->proc~hex2lattice proc~get_stripe honeytools::get_stripe proc~get_stripe->proc~hex2lattice proc~get_supercell honeytools::get_supercell proc~get_supercell->proc~hex2lattice proc~get_triangle honeytools::get_triangle proc~get_triangle->proc~hex2lattice

Source Code

   pure subroutine push_back(vec,val)
      !! Poor man implementation of a dynamic
      !! array, a là std::vector (but without
      !! preallocation and smart doubling...)
      class(xy_lattice),intent(inout)  :: vec
      type(xy_site),intent(in)         :: val
      type(xy_site),allocatable        :: tmp(:)
      integer                          :: len
      if (allocated(vec%site)) then
         len = size(vec%site)
         allocate(tmp(len+1))
         tmp(:len) = vec%site
         call move_alloc(tmp,vec%site)
         len = len + 1
      else
         len = 1
         allocate(vec%site(len))
      end if
      !PUSH val at the BACK
      vec%site(len) = val
      !Increade formal size
      vec%size = len
   end subroutine push_back