diff --git a/mpcdf_common.py b/mpcdf_common.py
index 7a7430e534c46f0cc0b30aadc0adae8886754646..6ab446d5ed0c23e16a40c4827387a7faa2c55489 100644
--- a/mpcdf_common.py
+++ b/mpcdf_common.py
@@ -610,6 +610,15 @@ def parse_prjconf(api_url, project):
     return orig_prjconf, prjconf_head, prjconf_ours, prjconf_tail
 
 
+def openmpi_flavor_dependencies(flavor, distribution):
+    if flavor.startswith("mofed_"):
+        mofed_version = flavor[len("mofed_"):].replace("_", ".")
+        mofed_repo = "extern:mofed:" + mofed_version
+        return ((mofed_repo, distribution),)
+    else:
+        return ()
+
+
 def mpcdf_setup_subproject(api_url, project, distribution, microarchitecture,
                            parent=None, dry_run=False, diff=False, remove_old=False, remove_old_matching=None, all_possible=False, only_project=False):
     import re
@@ -798,9 +807,8 @@ Macros:
             if "openmpi" in mpi:
                 for of in openmpi_flavors:
                     dependencies = ((project, compiler),)
-                    if "mofed" in of:
-                        dependencies = (("extern:" + of, distribution),) + dependencies
-
+                    if not parent:
+                        dependencies = openmpi_flavor_dependencies(of, distribution) + dependencies
                     repo(mpi + "_" + compiler + "_" + of, dependencies, mpi=True,
                          mpi_repository=mpi, mpi_module=mpi_module(mpi),
                          openmpi_flavor=of)
@@ -823,8 +831,8 @@ Macros:
                                           "Prefer: mpcdf_" + cuda,))
                     for of in openmpi_flavors:
                         dependencies = ((project, cuda + "_" + mpi + "_" + compiler),)
-                        if "mofed" in of:
-                            dependencies = (("extern:" + of, distribution),) + dependencies
+                        if not parent:
+                            dependencies = openmpi_flavor_dependencies(of, distribution) + dependencies
                         repo(cuda + "_aware_" + mpi + "_" + compiler + "_" + of,
                              dependencies,
                              cuda_aware_mpi=True, openmpi_flavor=of,