Skip to content

Commit 5e91e71

Browse files
committed
Fix duplicate stream check in mpas_stream_list_insert
Fixed a bug in the mpas_stream_list_insert subroutine (in MPAS_stream_list.F), where the duplicate stream check would fail if the duplicate stream being inserted was adjacent to its duplicate. The updated logic ensures that all nodes, including the last, are checked before insertion.
1 parent 619bffe commit 5e91e71

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/framework/mpas_stream_list.F

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,16 @@ subroutine MPAS_stream_list_insert(list, stream, ierr) !{{{
118118
list % head => stream
119119
else
120120
node => list % head
121-
do while (associated(node % next))
121+
do while (associated(node))
122122
if (node % name == stream % name) then
123123
if (present(ierr)) ierr = MPAS_STREAM_LIST_DUPLICATE
124124
LIST_ERROR_WRITE('Found duplicate item '//trim(stream % name)//' in list.')
125125
return
126126
end if
127+
if (.not. associated(node % next)) then
128+
node % next => stream
129+
exit
130+
end if
127131
node => node % next
128132
end do
129133
node % next => stream

0 commit comments

Comments
 (0)