diff --git a/CHANGELOG.md b/CHANGELOG.md index 3423e26c7526..637de532d1ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5090ffa19888..de364339a5cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/generic/GenericCplComp.F90 b/generic/GenericCplComp.F90 index aa1cb263343b..180f75dc7959 100644 --- a/generic/GenericCplComp.F90 +++ b/generic/GenericCplComp.F90 @@ -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" @@ -21,6 +31,7 @@ module MAPL_GenericCplCompMod use ESMF use ESMFL_Mod + use MAPL_ShmemMod use MAPL_BaseMod use MAPL_Constants use MAPL_IOMod @@ -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) @@ -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)