Skip to content

SAL: Explicitly allocate sht variable in SAL_CS#627

Merged
marshallward merged 3 commits into
NOAA-GFDL:dev/gfdlfrom
marshallward:SAL_sht_to_heap
May 14, 2024
Merged

SAL: Explicitly allocate sht variable in SAL_CS#627
marshallward merged 3 commits into
NOAA-GFDL:dev/gfdlfrom
marshallward:SAL_sht_to_heap

Conversation

@marshallward
Copy link
Copy Markdown
Member

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.

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.
@marshallward
Copy link
Copy Markdown
Member Author

The issue appears to be resolved: https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/jobs/127658

@marshallward
Copy link
Copy Markdown
Member Author

@marshallward marshallward merged commit 0c790f2 into NOAA-GFDL:dev/gfdl May 14, 2024
@marshallward marshallward deleted the SAL_sht_to_heap branch May 24, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants