Skip to content
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

Replaces pointers which are allocated with allocatables #1208

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ganganoaa
Copy link
Contributor

@ganganoaa ganganoaa commented Apr 28, 2023

Description
Updates member pointers of grid_box_type, grid_type, comm_type, and xmap_type to allocatables, which were previously allocated, to handle better memory management and to prevent memory leaks. Some local pointers in subroutine load_xgrid() are also updated to allocatables for the same reason.

Fixes #1099

How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also note
any relevant details for your test configuration (e.g. compiler, OS). Include
enough information so someone can reproduce your tests.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@@ -287,17 +287,17 @@ module xgrid_mod
!> Type to hold pointers for grid boxes
!> @ingroup xgrid_mod
type grid_box_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is public and so are it's fields so we're gonna have to check the component's code to make sure these fields aren't used as pointers anywhere else besides internally (unless we want to make them private now but doubt that'll work).

This applies to xmap_type as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You are right. If component codes are using them, this change certainly breaks something.

@@ -2257,7 +2254,7 @@ end subroutine set_comm_get1_repro

!#######################################################################
subroutine set_comm_get1(xmap)
type (xmap_type), intent(inout) :: xmap
type (xmap_type), intent(inout), target :: xmap
type (grid_type), pointer, save :: grid1 =>NULL()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess we can't do much about these saved pointers right? might be less memory to save them as pointers anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointers which are used as pointers should not be upgraded.

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.

Allocated Pointers: Potential Memory Leak Issue
2 participants