sum_of_arrays Function

public function sum_of_arrays(list)

sum of all elements for each array stored in list

Arguments

TypeIntentOptionalAttributesName
type(array_list), intent(in) :: list

Return Value integer,ALLOCATABLE,DIMENSION(:)


Contents

Source Code


Source Code

   FUNCTION sum_of_arrays(list)
      !! sum of all elements for each array stored in list
      TYPE(array_list), INTENT(IN)       :: list
      INTEGER, ALLOCATABLE, DIMENSION(:) :: sum_of_arrays

      INTEGER                            :: i_data, num_data

      num_data = number_of_arrays(list)
      ALLOCATE (sum_of_arrays(num_data))
      DO i_data = 1, num_data
         sum_of_arrays(i_data) = SUM(list%col_data(list%ptr(i_data):list%ptr(i_data + 1) - 1))
      END DO

   END FUNCTION sum_of_arrays