Skip to content

Commit

Permalink
Merge pull request #1456 from GEOS-ESM/hotfix/atrayano/#1454_shmem_de…
Browse files Browse the repository at this point in the history
…allocate

Fixes #1454. Now MAPL_Shmem memory is deallocated properly
  • Loading branch information
mathomp4 authored Mar 24, 2022
2 parents 8edb2d0 + 5071b69 commit 3e2c0e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

## [2.19.1] - 2022-03-24

### Fixed

- Fix a bug deallocating a pointer potentially pointing to shared memory allocated by MAPL_Shmem

## [2.19.0] - 2022-03-18

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy (SET CMP0054 NEW)

project (
MAPL
VERSION 2.19.0
VERSION 2.19.1
LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF

# Set the default build type to release
Expand Down
17 changes: 14 additions & 3 deletions generic/GenericCplComp.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

#define _DEALLOC(A) \
if(associated(A))then; \
if(MAPL_ShmInitialized)then; \
call MAPL_SyncSharedMemory(rc=STATUS); \
call MAPL_DeAllocNodeArray(A,rc=STATUS); \
else; \
deallocate(A,stat=STATUS); \
endif; \
_VERIFY(STATUS); \
NULLIFY(A); \
endif
#include "MAPL_Generic.h"
#include "unused_dummy.H"

Expand All @@ -21,6 +31,7 @@ module MAPL_GenericCplCompMod

use ESMF
use ESMFL_Mod
use MAPL_ShmemMod
use MAPL_BaseMod
use MAPL_Constants
use MAPL_IOMod
Expand Down Expand Up @@ -1338,7 +1349,7 @@ subroutine ReadRestart(CC, SRC, DST, CLOCK, RC)
case default
_ASSERT(.false., "Unsupported rank")
end select
if(associated(mask)) deallocate(mask)
_DEALLOC(mask)
end do

if (am_i_root) call Free_File(unit = UNIT, rc=STATUS)
Expand Down Expand Up @@ -1532,7 +1543,7 @@ subroutine WriteRestart(CC, SRC, DST, CLOCK, RC)
case default
_ASSERT(.false.," Unsupported rank")
end select
if(associated(mask)) deallocate(mask)
_DEALLOC(mask)
end do

if(am_i_root) call Free_File(unit = UNIT, rc=STATUS)
Expand Down

0 comments on commit 3e2c0e1

Please sign in to comment.