transpose a matrix of datatype sp
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | A(:,:) | |||
| real(kind=sp), | intent(out) | :: | B(:,:) | |||
| logical, | intent(in), | optional | :: | threaded | ||
| type(error_t), | intent(inout), | optional | :: | err |
set to ERROR_VALIDATION when B is not shaped (cols, rows); B is intent(out) and therefore undefined on that path. When err is 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 transpose_matrix_sp(A, B, threaded, err) !! transpose a matrix of datatype sp real(sp), intent(in) :: A(:, :) real(sp), intent(out) :: B(:, :) logical, intent(in), optional :: threaded type(error_t), intent(inout), optional :: err !! set to ERROR_VALIDATION when B is not shaped (cols, rows); B is !! intent(out) and therefore undefined on that path. When err is !! absent a mismatch aborts with error stop logical :: use_threads integer(default_int) :: i, j, ii, jj, rows, cols rows = size(A, 1) cols = size(A, 2) if (size(B, 1) /= cols .or. size(B, 2) /= rows) then if (present(err)) then call error_raise(err, ERROR_VALIDATION, "pic_transpose: size mismatch") return end if error stop "pic_transpose: size mismatch" end if 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) B(j, i) = A(i, j) end do end do end do end do !$omp end parallel do else B = transpose(A) end if end subroutine transpose_matrix_sp