diff --git a/femtools/Linked_Lists.F90 b/femtools/Linked_Lists.F90 index 942384d18f..b035e43119 100644 --- a/femtools/Linked_Lists.F90 +++ b/femtools/Linked_Lists.F90 @@ -353,6 +353,11 @@ function ipop_last(list) deallocate(node) prev_node%next => null() list%length = list%length - 1 + if (list%length == 0) then + list%lastnode => null() + else + list%lastnode => prev_node + end if end function ipop_last function ifetch(list, j)