move_alloc_str Subroutine

public subroutine move_alloc_str(source, dest)

Arguments

TypeIntentOptionalAttributesName
character(len=:), intent(inout), dimension(:, :), allocatable:: source
character(len=:), intent(inout), dimension(:, :), allocatable:: dest

Contents

Source Code


Source Code

subroutine move_alloc_str(source, dest)

    character(len=:), dimension(:, :), allocatable, &
        intent(inout) :: source
    character(len=:), dimension(:, :), allocatable, &
        intent(inout) :: dest

    integer :: i, j

    if (allocated(dest)) deallocate(dest)
    if (.not. allocated(source)) return

    allocate(character(len(source)) :: dest(size(source, 1), size(source, 2)))

    do i = 1, size(source, 1)
        do j = 1, size(source, 2)
            dest(i, j)(1:len(source)) = source (i, j)(1:len(source))
        end do
    end do

    deallocate(source)

end subroutine move_alloc_str