Skip to content

Fix memory leaks in GEOSlandassim and GEOSlandpert GridComps#180

Draft
weiyuan-jiang wants to merge 2 commits into
developfrom
fix/wjiang/memory_leak
Draft

Fix memory leaks in GEOSlandassim and GEOSlandpert GridComps#180
weiyuan-jiang wants to merge 2 commits into
developfrom
fix/wjiang/memory_leak

Conversation

@weiyuan-jiang

@weiyuan-jiang weiyuan-jiang commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

24-member simulations with perturbations on the c360 tile space crash after a few data-days. The exact data-time of the crash is different for each run. The error messages suggests that insufficient memory is the problem.

This PR fixes missing deallocate and nullify statements. These fixes should help address the crashes, but it remains unclear if the changes are sufficient to resolve the problem.

Specifically, the following fixes are included:

  • GEOSlandassim: add deallocate(Observations_lH) in non-MPI path of get_enkf_increments (clsm_ensupd_enkf_update.F90); pointer was allocated every assimilation cycle but never freed
  • GEOSlandassim: add deallocate(tmp_wFOV) to cleanup block of get_obs_pred (clsm_ensupd_upd_routines.F90); omitted alongside four sibling arrays that were already freed
  • GEOSlandassim: add comprehensive deallocate calls in Finalize() for all module-level variables allocated in Initialize() (GEOS_LandAssimGridComp.F90): tb_nodata, Pert_rseed, Pert_rseed_r8, N_catl_vec, low_ind, l2rf, rf2f, tile_coord_rf, rf2g, rf2l, obs_param
  • GEOSlandpert: add explicit deallocate(pert_rseed) before RETURN_ macro in GenerateRaw_ntrmdt, consistent with ApplyForcePert/ApplyPrognPert
  • GEOSlandpert: add deallocate(pert_iseed) + nullify in Finalize(); module-level pointer was never freed
  • GEOSlandpert: add deallocate(internal) + nullify(wrap%ptr) in Finalize(); T_LANDPERT_STATE struct itself was never freed
  • GEOSlandpert: nullify force_pert_param and progn_pert_param after their targets are deallocated in Finalize() to avoid dangling pointers

cc: @gmao-qliu @biljanaorescanin @gmao-rreichle

- GEOSlandassim: add deallocate(Observations_lH) in non-MPI path of
  get_enkf_increments (clsm_ensupd_enkf_update.F90); pointer was
  allocated every assimilation cycle but never freed
- GEOSlandassim: add deallocate(tmp_wFOV) to cleanup block of
  get_obs_pred (clsm_ensupd_upd_routines.F90); omitted alongside
  four sibling arrays that were already freed
- GEOSlandassim: add comprehensive deallocate calls in Finalize()
  for all module-level variables allocated in Initialize()
  (GEOS_LandAssimGridComp.F90): tb_nodata, Pert_rseed, Pert_rseed_r8,
  N_catl_vec, low_ind, l2rf, rf2f, tile_coord_rf, rf2g, rf2l, obs_param
- GEOSlandpert: add explicit deallocate(pert_rseed) before RETURN_ macro
  in GenerateRaw_ntrmdt, consistent with ApplyForcePert/ApplyPrognPert
- GEOSlandpert: add deallocate(pert_iseed) + nullify in Finalize();
  module-level pointer was never freed
- GEOSlandpert: add deallocate(internal) + nullify(wrap%ptr) in
  Finalize(); T_LANDPERT_STATE struct itself was never freed
- GEOSlandpert: nullify force_pert_param and progn_pert_param after
  their targets are deallocated in Finalize() to avoid dangling pointers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants