Skip to content

Commit 8a91181

Browse files
committed
Update check modules subroutine so that it checks all packages for duplicates
1 parent 285925c commit 8a91181

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

fpm/src/fpm.f90

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,35 +162,39 @@ end subroutine build_model
162162
subroutine check_modules(model)
163163
type(fpm_model_t), intent(in) :: model
164164
integer :: maxsize
165-
integer :: i,j,k,modi
165+
integer :: i,j,k,l,m,modi
166166
type(string_t), allocatable :: modules(:)
167167
! Initialise the size of array
168168
maxsize = 0
169-
! Get number of modules provided by each source file
170-
do i=1,size(model%packages(1)%sources)
171-
if (allocated(model%packages(1)%sources(j)%modules_provided)) then
172-
maxsize = maxsize + size(model%packages(1)%sources(i)%modules_provided)
173-
end if
169+
! Get number of modules provided by each source file of every package
170+
do i=1,size(model%packages)
171+
do j=1,size(model%packages(i)%sources)
172+
if (allocated(model%packages(i)%sources(j)%modules_provided)) then
173+
maxsize = maxsize + size(model%packages(i)%sources(j)%modules_provided)
174+
end if
175+
end do
174176
end do
175177
! Allocate array to contain distinct names of modules
176178
allocate(modules(1:maxsize))
177179

178180
! Initialise index to point at start of the newly allocated array
179181
modi = 1
180182

181-
! Loop through modules provided by each source file
183+
! Loop through modules provided by each source file of every package
182184
! Add it to the array if it is not already there
183185
! Otherwise print out warning about duplicates
184-
do j=1,size(model%packages(1)%sources)
185-
if (allocated(model%packages(1)%sources(j)%modules_provided)) then
186-
do k=1,size(model%packages(1)%sources(j)%modules_provided)
187-
if (model%packages(1)%sources(j)%modules_provided(k)%s.in.modules) then
188-
print *,"Warning: Module ",model%packages(1)%sources(j)%modules_provided(k)%s," is duplicate"
189-
else
190-
modules(modi) = model%packages(1)%sources(j)%modules_provided(k)
191-
end if
192-
end do
193-
end if
186+
do k=1,size(model%packages)
187+
do l=1,size(model%packages(k)%sources)
188+
if (allocated(model%packages(k)%sources(l)%modules_provided)) then
189+
do m=1,size(model%packages(k)%sources(l)%modules_provided)
190+
if (model%packages(k)%sources(l)%modules_provided(m)%s.in.modules) then
191+
print *,"Warning: Module ",model%packages(k)%sources(l)%modules_provided(m)%s," is duplicate"
192+
else
193+
modules(modi) = model%packages(k)%sources(l)%modules_provided(m)
194+
end if
195+
end do
196+
end if
197+
end do
194198
end do
195199
end subroutine check_modules
196200

0 commit comments

Comments
 (0)