From 82f2483e81ecf62a9ca434fc48dc4f125e765c6c Mon Sep 17 00:00:00 2001 From: sdargavi Date: Thu, 23 Nov 2023 17:33:20 +0000 Subject: [PATCH 1/2] Fixed bug in linked list where the lastnode wasn't being updated when the last value was popped off the end of the list --- femtools/Linked_Lists.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/femtools/Linked_Lists.F90 b/femtools/Linked_Lists.F90 index 942384d18f..30ce5bc3fe 100644 --- a/femtools/Linked_Lists.F90 +++ b/femtools/Linked_Lists.F90 @@ -353,6 +353,7 @@ function ipop_last(list) deallocate(node) prev_node%next => null() list%length = list%length - 1 + list%lastnode => prev_node end function ipop_last function ifetch(list, j) From ee3c155c1c6d7c82187bc746badb4c4794da67db Mon Sep 17 00:00:00 2001 From: sdargavi Date: Fri, 24 Nov 2023 13:59:37 +0000 Subject: [PATCH 2/2] Fixed update of lastnode in the case of zero length list after the pop_last --- femtools/Linked_Lists.F90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/femtools/Linked_Lists.F90 b/femtools/Linked_Lists.F90 index 30ce5bc3fe..b035e43119 100644 --- a/femtools/Linked_Lists.F90 +++ b/femtools/Linked_Lists.F90 @@ -353,7 +353,11 @@ function ipop_last(list) deallocate(node) prev_node%next => null() list%length = list%length - 1 - list%lastnode => prev_node + if (list%length == 0) then + list%lastnode => null() + else + list%lastnode => prev_node + end if end function ipop_last function ifetch(list, j)