GSoC: Linked List || Blog post by Chetan Karwa || #2

cc: @Arjen, @certik

@Chetan_Karwa , very interesting project with GSoC and great effort thus far, hope this project cements your interest in scientific and technical computing generally and also with Fortran specifically!

Based on a quick glance at the code at your GitHub site, my take is the root cause of the memory leak you are noticing is with an unfinalized temporary with the function result of initialise_parent_node(new_child) instruction and a local unfinalized object new_child in your append_in_new_child method in your linked_list module.

I suggest including finalizers (FINAL procedures) in your “classes” i.e., Fortran derived types, especially where the derived type components with the POINTER attributes appear in ALLOCATE statements e.g., your List derived type.

Given where things are with gfortran in terms of finalization semantics in that the implementation in this compiler is aimed toward Fortran 2003 standard revision but it didn’t quite achieve all of it and in the mean time, the standard had considerable corrections as part of Fortran 2008 Corrigenda and further refinements with Fortran 2018 that are pending in gfortran as far as I know, you may need to be mindful of the need to refactor your code to work around the limitations if gfortran is your primary compiler for this project.

In my experience, the “free” Intel oneAPI 2021.2 gets finalization right with respect to current Fortran standard and it will be a good processor to cross-check your code, especially with memory leaks.

All the best and keep up the great job,

5 Likes