tem_resizeInt2dArray Subroutine

private subroutine tem_resizeInt2dArray(Array, Newsize1, Newsize2)

append an entry to an allocatable array 2d with integer If the array is too small, reallocate with double size

Arguments

Type IntentOptional Attributes Name
integer(kind=int_k), intent(inout), allocatable :: Array(:,:)

array to resize

integer, intent(in) :: Newsize1

first new size

integer, intent(in) :: Newsize2

second new size


Called by

proc~~tem_resizeint2darray~~CalledByGraph proc~tem_resizeint2darray tem_resizeInt2dArray interface~resize resize interface~resize->proc~tem_resizeint2darray

Source Code

  subroutine tem_resizeInt2dArray( Array, Newsize1, Newsize2 )
    ! ---------------------------------------------------------------------------
    !> array to resize
    integer(kind=int_k),intent(inout), allocatable :: Array(:,:)
    !> first new size
    integer,intent(in) :: Newsize1
    !> second new size
    integer,intent(in) :: Newsize2
    ! ---------------------------------------------------------------------------
    integer,allocatable :: tempArray(:,:)
    integer :: ierr
    ! ---------------------------------------------------------------------------

    ! allocate temporary array with new size
    allocate(tempArray(NewSize1,NewSize2),stat=ierr)
    if(ierr .ne. 0) Write(*,*) 'Error in allocating temp_array'
    ! Copy to temp array
    tempArray(1:NewSize1, 1:NewSize2) = Array(1:NewSize1, 1:NewSize2)
    ! Deallocate Array
    deallocate(Array)
    ! Reallocate Array
    allocate(Array(NewSize1, Newsize2), stat=ierr)
    ! Deallocate temp array
    Array(1:NewSize1,1:NewSize2) = tempArray(1:NewSize1, 1:NewSize2)
    deallocate(tempArray)
    if(ierr .ne. 0) Write(*,*) 'Error in reallocating array'

  end subroutine tem_resizeInt2dArray