df_apply_to_all_rows_real Function

public function df_apply_to_all_rows_real(df, func) result(outputs)

Apply a function to all rows

Applies a user-defined function to each row in the data frame, returning an array of results.

@param[in] df The data frame @param[in] func Function to apply (must match row_func_real interface) @return Array of results, one per row

Example

real(rk), dimension(:), allocatable :: row_sums
row_sums = df_apply_to_all_rows_real(df, row_sum)

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
procedure(row_func_real) :: func

Return Value real(kind=rk), dimension(:), allocatable


Source Code

    function df_apply_to_all_rows_real(df, func) result(outputs)
        type(data_frame), intent(in) :: df
        procedure(row_func_real) :: func
        real(rk), dimension(:), allocatable :: outputs
        integer :: i, n_rows

        n_rows = df % nrows()
        allocate (outputs(n_rows))

        do i = 1, n_rows
            outputs(i) = df_apply_to_row_real(df, i, func)
        end do
    end function df_apply_to_all_rows_real