append an entry to an allocatable array 2d with long integer If the array is too small, reallocate with double size
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(inout), | allocatable | :: | Array(:,:) |
array to resize |
|
integer, | intent(in) | :: | Newsize1 |
first new size |
||
integer, | intent(in) | :: | Newsize2 |
second new size |
subroutine tem_resizeIntLong2dArray( Array, Newsize1, Newsize2 ) ! --------------------------------------------------------------------------- !> array to resize integer(kind=long_k),intent(inout), allocatable :: Array(:,:) !> first new size integer,intent(in) :: Newsize1 !> second new size integer,intent(in) :: Newsize2 ! --------------------------------------------------------------------------- integer(kind=long_k),allocatable :: tempArray(:,:) integer :: ierr ! --------------------------------------------------------------------------- ! allocate temporary array with new size allocate(tempArray(NewSize1,NewSize2),stat=ierr) ! 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_resizeIntLong2dArray