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

only memory leak related #2139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

likeuclinux
Copy link

Fix memory leak relate allocate array again before deallocate call

TYPE: bug fix,

KEYWORDS: Memory Leak

SOURCE: Charlie Li - Software developer from lakes environmental canada

DESCRIPTION OF CHANGES:
Problem:
the change in wrf_timeseries.F and start_em.F are memory leak detected when use PGI option:
-g -O0 -traceback -Mchkptr -Mbounds -Ktrap=fp -Msave -tp=px
It will failed for: "0: ALLOCATE: array already allocated"

  1. dyn_em/start_em.F
    ALLOCATE(dz8w(IMS:IME,KMS:KME,JMS:JME),STAT=I) ; dz8w = 0.

miss logic to deallocate dz8w
2../share/wrf_timeseries.F

SUBROUTINE calc_ts( grid )

#if ( EM_CORE == 1 )
PRINT *, "ALLOCATE WILL call in wrf_timeseries.F at line 356: ALLOCATE ( earth_u_profile(grid%max_ts_level), earth_v_profile(grid%max_ts_level) )"
ALLOCATE ( earth_u_profile(grid%max_ts_level), earth_v_profile(grid%max_ts_level) )
PRINT *, "ALLOCATE called in wrf_timeseries.F at line 356: ALLOCATE ( earth_u_profile(grid%max_ts_level), earth_v_profile(grid%max_ts_level) )"
#endif

IF ( grid%ntsloc_domain .LE. 0 ) RETURN

#if ((EM_CORE == 1) && (DA_CORE != 1))
IF ( grid%dfi_opt /= DFI_NODFI .AND. grid%dfi_stage /= DFI_FST ) RETURN
#endif

when it return, it didn't free memory for earth_u_profile and earth_v_profile if EM_CORE == 1

Solution:
Just in source code add code to free memory related

ISSUE: For use when this PR closes an issue.
Fixes #123

LIST OF MODIFIED FILES: list of changed files (use git diff --name-status master to get formatted list)
share/wrf_timeseries.F
dyn_em/start_em.F

TESTS CONDUCTED:

  1. Do mods fix problem? How can that be demonstrated, and was that test conducted?
  2. Are the Jenkins tests all passing?

RELEASE NOTE: Include a stand-alone message suitable for the inclusion in the minor and annual releases. A publication citation is appropriate.

@likeuclinux likeuclinux requested review from a team as code owners December 5, 2024 20:16
@weiwangncar
Copy link
Collaborator

The regression test results:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

1 similar comment
@weiwangncar
Copy link
Collaborator

The regression test results:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

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