copy a matrix of datatype sp
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(inout) | :: | dest(:,:) | |||
| real(kind=sp), | intent(in) | :: | source(:,:) | |||
| logical, | intent(in), | optional | :: | threaded | ||
| type(error_t), | intent(inout), | optional | :: | err |
set to ERROR_VALIDATION on a size mismatch, leaving dest unchanged; when absent a mismatch aborts with error stop |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | cols | ||||
| integer(kind=default_int), | private | :: | i | ||||
| integer(kind=default_int), | private | :: | ii | ||||
| integer(kind=default_int), | private | :: | j | ||||
| integer(kind=default_int), | private | :: | jj | ||||
| integer(kind=default_int), | private | :: | rows | ||||
| logical, | private | :: | use_threads |
subroutine copy_matrix_sp(dest, source, threaded, err) !! copy a matrix of datatype sp real(sp), intent(inout) :: dest(:, :) real(sp), intent(in) :: source(:, :) logical, intent(in), optional :: threaded type(error_t), intent(inout), optional :: err !! set to ERROR_VALIDATION on a size mismatch, leaving dest unchanged; !! when absent a mismatch aborts with error stop logical :: use_threads integer(default_int) :: i, j, rows, cols integer(default_int) :: ii, jj if (size(dest, 1) /= size(source, 1) .or. size(dest, 2) /= size(source, 2)) then if (present(err)) then call error_raise(err, ERROR_VALIDATION, "pic_copy: matrix size mismatch") return end if error stop "pic_copy: matrix size mismatch" end if rows = size(source, 1) cols = size(source, 2) use_threads = pic_optional(threaded, use_threaded_default) if (use_threads) then !$omp parallel do collapse(2) private(i,j,ii,jj) do jj = 1, cols, block_size do ii = 1, rows, block_size do j = jj, min(jj + block_size - 1, cols) do i = ii, min(ii + block_size - 1, rows) dest(i, j) = source(i, j) end do end do end do end do !$omp end parallel do else dest = source end if end subroutine copy_matrix_sp