SAL: Explicitly allocate sht variable in SAL_CS #627
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For reasons not entirely clear, deallocation of the RK2 control structure caused a segmentation fault when compiled by Nvidia. A deeper investigation suggested that the compiler was attempting to deallocate a nullified pointer during automatic cleanup of RK2->SAL->sht. Apparently deallocation of a NULL pointer is an error (even though free() is not supposed to care).
By redefining
sht
as an allocatable component rather than a local component of the SAL_CS instance, it seemed to satisfy the compiler that nothing was needed and the error went away.There are still some lingering questions behind the cause of the segfault, but for now I am going to put this under "compiler bug".
This patch also initializes some of the logical flags in the SAL_CS type. This is possibly unnecessary, but it is consistent with the general rules of safety followed in other MOM6 derived types.