This PR fixes an OpenMP error in the deallocation of rthdynten when certain cumulus schemes are not used.
When neither the Grell-Freitas nor the Tiedtke/nTiedtke cumulus schemes were used, the rthdynten array was allocated locally in the compute_dyn_tend(...) routine, since it is a required argument to the compute_dyn_tend_work(...) routine. The local rthdynten pointer was initialized and therefore implicitly had the SAVE attribute, which, according to 2.15.1.2 of the OpenMP 4.5 standard, made the rthdynten pointer shared:
Local variables declared in called routines in the region and that have the
save attribute, or that are data initialized, are shared unless they appear in
a threadprivate directive.
The allocation and deallocation of rthdynten happened inside of a threaded region, leading to potential model failures when multiple threads attempted to deallocate the same shared rthdynten pointer.
The simple solution is to remove packages from the rthdynten field in the atmosphere core's Registry.xml file, and to remove the additional code that handled selective local allocation of this array in the compute_dyn_tend(...) routine.
Since rthdynten is allocated by the compute_dyn_tend(...) routine if it is not otherwise allocated due to packages, simply removing packages from the rthdynten field in the atmosphere core's Registry.xml file should have little impact on the memory usage of the dynamics, only increasing memory use outside of the dynamics in cases where neither
the Grell-Freitas nor the Tiedtke/nTiedtke schemes are used. However, this potentially larger memory use comes with the benefit of significantly simplified logic in the dynamics.
This PR fixes an OpenMP error in the deallocation of
rthdynten
when certain cumulus schemes are not used.When neither the Grell-Freitas nor the Tiedtke/nTiedtke cumulus schemes were used, the
rthdynten
array was allocated locally in thecompute_dyn_tend(...)
routine, since it is a required argument to thecompute_dyn_tend_work(...)
routine. The localrthdynten
pointer was initialized and therefore implicitly had theSAVE
attribute, which, according to 2.15.1.2 of the OpenMP 4.5 standard, made therthdynten
pointer shared:The allocation and deallocation of
rthdynten
happened inside of a threaded region, leading to potential model failures when multiple threads attempted to deallocate the same sharedrthdynten
pointer.The simple solution is to remove packages from the
rthdynten
field in the atmosphere core'sRegistry.xml
file, and to remove the additional code that handled selective local allocation of this array in thecompute_dyn_tend(...)
routine.Since
rthdynten
is allocated by thecompute_dyn_tend(...)
routine if it is not otherwise allocated due to packages, simply removing packages from therthdynten
field in the atmosphere core'sRegistry.xml
file should have little impact on the memory usage of the dynamics, only increasing memory use outside of the dynamics in cases where neither the Grell-Freitas nor the Tiedtke/nTiedtke schemes are used. However, this potentially larger memory use comes with the benefit of significantly simplified logic in the dynamics.