Skip to content

Commit de5ee13

Browse files
committed
Fix: collect_used modules to recurse down whole submodule hierarchy
1 parent c28dbc4 commit de5ee13

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/fpm_targets.f90

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -615,25 +615,27 @@ recursive subroutine collect_used_modules(target)
615615
end if
616616

617617
if (allocated(target%source)) then
618-
do j=1,size(target%source%modules_used)
619-
620-
if (.not.(target%source%modules_used(j)%s .in. modules_used)) then
621-
622-
modules_used = [modules_used, target%source%modules_used(j)]
623-
624-
! Recurse into child submodules
625-
do k=1,size(targets)
626-
if (allocated(targets(k)%ptr%source)) then
627-
if (targets(k)%ptr%source%unit_type == FPM_UNIT_SUBMODULE) then
628-
if (target%source%modules_used(j)%s .in. targets(k)%ptr%source%parent_modules) then
629-
call collect_used_modules(targets(k)%ptr)
630-
end if
631-
end if
632-
end if
633-
end do
618+
619+
! Add modules from this target and from any of it's children submodules
620+
do j=1,size(target%source%modules_provided)
621+
622+
if (.not.(target%source%modules_provided(j)%s .in. modules_used)) then
623+
624+
modules_used = [modules_used, target%source%modules_provided(j)]
634625

635626
end if
636627

628+
! Recurse into child submodules
629+
do k=1,size(targets)
630+
if (allocated(targets(k)%ptr%source)) then
631+
if (targets(k)%ptr%source%unit_type == FPM_UNIT_SUBMODULE) then
632+
if (target%source%modules_provided(j)%s .in. targets(k)%ptr%source%parent_modules) then
633+
call collect_used_modules(targets(k)%ptr)
634+
end if
635+
end if
636+
end if
637+
end do
638+
637639
end do
638640
end if
639641

0 commit comments

Comments
 (0)