Fix crash in dynamics due to Fortran standard violation#1448
Open
kuanchihwang wants to merge 3 commits intoMPAS-Dev:developfrom
Open
Fix crash in dynamics due to Fortran standard violation#1448kuanchihwang wants to merge 3 commits intoMPAS-Dev:developfrom
kuanchihwang wants to merge 3 commits intoMPAS-Dev:developfrom
Conversation
…ciated At line 1970, if the `DO_PHYSICS` macro is undefined, the `diag_physics` pointer will not be initialized by the call to `mpas_pool_get_subpool`, and therefore its pointer association status will remain undefined. However, at line 2250, this pointer is used as an argument to call `atm_compute_dyn_tend`, which constitutes a Fortran standard violation. Quoted from Fortran 2023, > 15.5.2.4 Argument association > Except in references to intrinsic inquiry functions, a pointer actual argument that > corresponds to a nonoptional nonpointer dummy argument shall be pointer associated with > a target. This bug can lead to a runtime crash for models that use MPAS as a dynamical core (e.g., CAM, CAM-SIMA). Fix this issue by adding the `pointer` attribute to the `diag_physics` dummy argument for the `atm_compute_dyn_tend` subroutine.
Throughout the `atm_compute_dyn_tend` subroutine, the `tend_physics` pointer never changes its pointer association status. Add the missing `intent(in)` attribute for better safety.
In Fortran, explicit initialization of a variable implies the `save` attribute, which may have surprising result and is not thread-safe. Avoid doing it to conform to the Fortran best practices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
At line 1970 inside the
atm_srk3time stepping subroutine, if theDO_PHYSICSmacro is undefined, thediag_physicspointer will not be initialized by the call tompas_pool_get_subpool, and therefore its pointer association status will remain undefined.However, at line 2250, this pointer is used as an actual argument to call
atm_compute_dyn_tend, which constitutes a Fortran standard violation.Quoted from Fortran 2023,
This bug can lead to a runtime crash for models that use MPAS as a dynamical core (e.g., CAM, CAM-SIMA).
Fix this issue by adding the
pointerattribute to thediag_physicsdummy argument for theatm_compute_dyn_tendsubroutine.In addition, two one-line changes have also been introduced to better conform to the Fortran best practices.