I have a derived type array, where the derived types can also be arrays. Is there any way to sum over elements without resorting to a do loop?
program main
type t_couple
real :: income(2) = 5
end type t_couple
type(t_couple) :: couple(2)
print *, " sum 1 ", sum(couple(1)%income) ! works fine
print *, " sum 2 ", sum(couple%income) ! doesn't work
end program main
%F90-E-ERROR, A component cannot be an array if the encompassing structure is an array.
Of course we have all seen this error message many times and can write a do loop to solve this, but I'm wondering if there is a simpler and more concise way?