Double allocation error of FIELD variable [w3wavemd] #14
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.
Relates to issue NOAA-EMC#252
When running on an
SMC
grid usingSHRD
andOMPG
/OMPX
switches,ww3_shel
crashes in thew3wavemd
module due to an array being allocated twice.The issue arises due to some incorrect logic relating to the allocation of the
FIELD
variable. There is a defunctOMP PARALLEL
section starting at line 1731 that was disabled some time ago in PR NOAA-EMC#160 due to it causing bit-for-bit differences. However, the logic for allocating the FILED array as a private variable inside the parallel section (rather than a shared variable outside) was left in - and this logic is incorrect. When the model is run with a combination ofSMC
andOMPX
switches, the array is erroneously allocated twice.The simplest solution is to keep only the initial allocation at line 580 - 583 and remove the allocation in the parallel section. Furthermore, as the
OMPX
statements are now defunct, we can remove them and the associatedFLOMP
logical. This also requires only a singleDEALLOCATE
statement.NOTE: If it is considered that the OMP section starting at line 1731 might be re-instated in the future, I can keep the second allocation and fix the incorrect logic.