Find maximum value along a dimension
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(in), | target | :: | a | ||
| integer, | intent(in) | :: | dim |
function maxval_array(a, dim) result(c) !! Find maximum value along a dimension implicit none class(array_type), intent(in), target :: a integer, intent(in) :: dim real(real32), dimension(:), allocatable :: c integer :: i, s if(size(a%shape) .ne. 1)then call stop_program("maxval: only 1D arrays can be used") end if if(dim.eq.1)then allocate(c(size(a%val,2))) do concurrent(s=1:size(a%val,2)) c(s) = maxval(a%val(:,s)) end do else if(dim.eq.2)then allocate(c(size(a%val,1))) do concurrent(i=1:size(a%val,1)) c(i) = maxval(a%val(i,:)) end do else call stop_program("maxval: only 1 or 2 dimensions are supported") end if end function maxval_array