From a7a262ed59b86d64d31949044d5505ba1ba66ebb Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Fri, 24 Sep 2021 14:20:04 -0700 Subject: [PATCH] fix(topological_sort): rm nonconforming concurrent In both `do concurrent` blocks inside the topological_sort function, each iteration conditionally references an "order" array that is defined in other iterations. Fortran disallows such code for variables that have no specified locality and adding locality would not help: the algorithm needs to accumulate values across iterations. A different algorithm would need to be chosen to parallelize the topological sort. --- src/dag_s.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dag_s.f90 b/src/dag_s.f90 index f7613a1..5e9bb53 100644 --- a/src/dag_s.f90 +++ b/src/dag_s.f90 @@ -39,7 +39,7 @@ pure module function topological_sort(dag) result(order) searched_and_ordered = searched_and_ordered_t(s = [integer::], o = [integer::]) - do concurrent(v = 1:size(dag%vertices)) + do v = 1, size(dag%vertices) if (.not. any(v == searched_and_ordered%s)) & searched_and_ordered = depth_first_search(v, [integer::], searched_and_ordered%o) end do @@ -60,7 +60,7 @@ pure recursive function depth_first_search(v, d, o) result(hybrid) associate(dependencies => dag%depends_on(v)) block integer w - do concurrent(w = 1:size(dependencies)) + do w = 1, size(dependencies) associate(w_dependencies => dependencies(w)) if (.not. any(w_dependencies == hybrid%s)) hybrid = depth_first_search(w_dependencies, [d, v], hybrid%o) end associate