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.
fix access violation crash
TYPE: bug fix
KEYWORDS: crash, access violation error
SOURCE: Charlie Li, software developer from lakes environmental, Canada
DESCRIPTION OF CHANGES:
Problem:
wrf crashed for access violation frequently, check details in #1991
when namelist.input has
sf_urban_physics = 0
the /inc/allocs_5.F
IF(okay_to_alloc.AND.in_use_for_config(id,'dlg_bep').AND.(.NOT.grid%is_intermediate))THEN
will be false, then it would go to following branch:
ELSE
ALLOCATE(grid%dlg_bep(1,1,1),STAT=ierr)
if (ierr.ne.0) then
CALL wrf_error_fatal ( &
'frame/module_domain.f: Failed to allocate grid%dlg_bep(1,1,1). ')
endif
ENDIF
it only allocate (1,1,1) for memory, then it trigger crash in phys/module_bl_ysu.F
if(present(a_u_bep) .and. present(a_v_bep) .and. present(a_t_bep) .and. &
present(a_q_bep) .and. present(a_e_bep) .and. present(b_u_bep) .and. &
present(b_v_bep) .and. present(b_t_bep) .and. present(b_q_bep) .and. &
present(b_e_bep) .and. present(dlg_bep) .and. present(dl_u_bep) .and. &
present(sf_bep) .and. present(vl_bep) .and. present(frc_urb2d)) then
endif
the present() check in code won't help, since upper level
dyn_em\module_first_rk_step_part1.F
will always call pbl_driver with DLG_BEP=grid%dlg_bep, then it pass down to module_pbl_driver to module_bl_ysu
Solution:
the fix is actually using v4.5 logic like following:
if(present(a_u_bep) .and. present(a_v_bep) .and. present(a_t_bep) .and. &
present(a_q_bep) .and. present(a_e_bep) .and. present(b_u_bep) .and. &
present(b_v_bep) .and. present(b_t_bep) .and. present(b_q_bep) .and. &
present(b_e_bep) .and. present(dlg_bep) .and. present(dl_u_bep) .and. &
present(sf_bep) .and. present(vl_bep) .and. present(frc_urb2d)) then
endif
the flag_bep came from:
SELECT CASE(sf_urban_physics)
CASE (BEPSCHEME)
flag_bep=.true.
CASE (BEP_BEMSCHEME)
flag_bep=.true.
CASE DEFAULT
flag_bep=.false.
END SELECT
when namelist.inpu has sf_urban_physics = 0, flag_bep will be false,
thus the code to access array with (1,1,1) allocation won't execute
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"
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)phys/module_bl_ysu.F
share/wrf_timeseries.F
dyn_em/start_em.F
TESTS CONDUCTED:
RELEASE NOTE: Include a stand-alone message suitable for the inclusion in the minor and annual releases. A publication citation is appropriate.