-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix str1d deallocation #2161
Fix str1d deallocation #2161
Conversation
415c969
to
2df070a
Compare
@Manangka I see that gfortran 12 is the oldest supported version right now. I don't see any indication how long they will support 12, but if the bug has been fixed in 13+, this workaround is hopefully temporary? |
@wpbonelli I hope this is temporary as well. I don't know how long we will be supporting gfortran 12 (and 11?) I don't have a clear overview of how many of our users are using it. |
Just a note: the oldest compiler versions are usually on HPC/supercomputers, and they are not as flexible to upgrade (sometimes impossible even) as it would be for your personal machine. MODFLOW on Snellius (Dutch national supercomputer) is currently build with gfortran 12, for example. |
I was thinking, using iso_c_binding is powerful. If we do that, maybe we could make that the type of str1d in the memory manager for the time being? So: type MemoryType Maybe that's an option too? Let's discuss. |
I rather won't do that. Doing so would mean that the "workaround" will also get into the memorymanager. The way it is setup now it is constraint to the memory class |
I tested the code on with different gfortran versions. The bug causing this issue is solved in gfortran 13,3. So from that version and onwards we don't have to apply the workaround anymore. There is one caveat. In gfortran 13.3 and 14.1 I did get a warning that some variables didn't get deallocated. There could be something else wrong in the compiler, or there might still be something wrong in our code. However we don't get the segementation error anymore On windows with ifx and ifort everthing works fine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, @Manangka!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, nice job!
Due to a bug in gfortran 11, 12, 13.1, and 13.2 we cant store a str1d in the MemoryType.
Upon deallocation a segmentation fault is produced. That's because due to the bug the len of the character is correctly assigned to the type descriptor
We worked around this by either ignoring it (potential bug) or using the CharString type
In this PR I added another workaround that allows us deallocated the str1d. To do so I'm using a c_ptr cast to readd the needed information to the type descriptor.
Note:
I tested it in WSL using gfortran 11.4
I tested it in WSL using gfortran 12.3
I tested it in WSL using gfortran 13.1
I tested it in WSL using gfortran 13.2
I tested it in WSL using gfortran 13.3
I tested it in WSL using gfortran 14.1
Note2
This also fix the remaining memory leaks we have according to valgrind
Checklist of items for pull request
ruff
on new and modified python scripts in .doc, autotests, doc, distribution, pymake, and utils subdirectories.fprettify
For additional information see instructions for contributing and instructions for developing.