From 91640311361d5bbd1df348307ca15600cc6ade12 Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Tue, 21 Apr 2026 13:50:09 -0600 Subject: [PATCH 1/3] Fix Fortran standard violation due to pointer argument not being associated 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. --- src/core_atmosphere/dynamics/mpas_atm_time_integration.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_atmosphere/dynamics/mpas_atm_time_integration.F b/src/core_atmosphere/dynamics/mpas_atm_time_integration.F index 238ca7235f..c160729765 100644 --- a/src/core_atmosphere/dynamics/mpas_atm_time_integration.F +++ b/src/core_atmosphere/dynamics/mpas_atm_time_integration.F @@ -5813,7 +5813,7 @@ subroutine atm_compute_dyn_tend(tend, tend_physics, state, diag, mesh, diag_phys type (mpas_pool_type), intent(in) :: state type (mpas_pool_type), intent(in) :: diag type (mpas_pool_type), intent(in) :: mesh - type (mpas_pool_type), intent(in) :: diag_physics + type (mpas_pool_type), pointer, intent(in) :: diag_physics type (mpas_pool_type), intent(in) :: configs integer, intent(in) :: nVertLevels ! for allocating stack variables integer, intent(in) :: rk_step, dynamics_substep From 0974d8e8a8239659f43adcefe49e7d81b70295ff Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Tue, 21 Apr 2026 14:35:05 -0600 Subject: [PATCH 2/3] Add missing argument intent 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. --- src/core_atmosphere/dynamics/mpas_atm_time_integration.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_atmosphere/dynamics/mpas_atm_time_integration.F b/src/core_atmosphere/dynamics/mpas_atm_time_integration.F index c160729765..b6e620fe12 100644 --- a/src/core_atmosphere/dynamics/mpas_atm_time_integration.F +++ b/src/core_atmosphere/dynamics/mpas_atm_time_integration.F @@ -5809,7 +5809,7 @@ subroutine atm_compute_dyn_tend(tend, tend_physics, state, diag, mesh, diag_phys ! Dummy arguments ! type (mpas_pool_type), intent(inout) :: tend - type (mpas_pool_type), pointer :: tend_physics + type (mpas_pool_type), pointer, intent(in) :: tend_physics type (mpas_pool_type), intent(in) :: state type (mpas_pool_type), intent(in) :: diag type (mpas_pool_type), intent(in) :: mesh From 2bef546251748a54f577608661ed8b7b9cf5535b Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Tue, 21 Apr 2026 14:49:58 -0600 Subject: [PATCH 3/3] Avoid implicit `save` attribute during variable declaration 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. --- src/core_atmosphere/dynamics/mpas_atm_time_integration.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_atmosphere/dynamics/mpas_atm_time_integration.F b/src/core_atmosphere/dynamics/mpas_atm_time_integration.F index b6e620fe12..227fbde862 100644 --- a/src/core_atmosphere/dynamics/mpas_atm_time_integration.F +++ b/src/core_atmosphere/dynamics/mpas_atm_time_integration.F @@ -1918,7 +1918,7 @@ subroutine atm_srk3(domain, dt, itimestep, exchange_halo_group) type (mpas_pool_type), pointer :: diag_physics type (mpas_pool_type), pointer :: mesh type (mpas_pool_type), pointer :: tend - type (mpas_pool_type), pointer :: tend_physics => null() + type (mpas_pool_type), pointer :: tend_physics type (mpas_pool_type), pointer :: lbc ! regional_MPAS addition real (kind=RKIND), dimension(:,:), pointer :: w