From 5326fd97e189f643f4725635fea504df11e151a7 Mon Sep 17 00:00:00 2001 From: Lauren Chilutti <60401591+laurenchilutti@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:58:58 -0400 Subject: [PATCH] fix: unallocated variable access in test_mpp_nesting (#1336) --- test_fms/mpp/test_mpp_nesting.F90 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test_fms/mpp/test_mpp_nesting.F90 b/test_fms/mpp/test_mpp_nesting.F90 index 833c580bf5..8808f0e9c8 100644 --- a/test_fms/mpp/test_mpp_nesting.F90 +++ b/test_fms/mpp/test_mpp_nesting.F90 @@ -950,15 +950,15 @@ subroutine test_update_nest_domain_r8( type ) !--- loop over nest level do l = 1, num_nest_level npes_my_level = mpp_get_nest_npes(nest_domain, l) - npes_my_fine = mpp_get_nest_fine_npes(nest_domain,l) allocate(my_pelist(npes_my_level)) - allocate(my_pelist_fine(npes_my_fine)) call mpp_get_nest_pelist(nest_domain, l, my_pelist) call mpp_declare_pelist(my_pelist(:)) write(type2, '(a,I2)')trim(type)//" nest_level = ",l if(ANY(my_pelist(:)==mpp_pe())) then + npes_my_fine = mpp_get_nest_fine_npes(nest_domain,l) + allocate(my_pelist_fine(npes_my_fine)) call mpp_get_nest_fine_pelist(nest_domain, l, my_pelist_fine) call mpp_set_current_pelist(my_pelist) @@ -2625,7 +2625,8 @@ subroutine test_update_nest_domain_r8( type ) deallocate(wbuffery2, ebuffery2, sbuffery2, nbuffery2) endif endif - deallocate(my_pelist, my_pelist_fine) + if(ANY(my_pelist(:)==mpp_pe())) deallocate(my_pelist_fine) + deallocate(my_pelist) call mpp_set_current_pelist() enddo @@ -2984,15 +2985,15 @@ subroutine test_update_nest_domain_r4( type ) !--- loop over nest level do l = 1, num_nest_level npes_my_level = mpp_get_nest_npes(nest_domain, l) - npes_my_fine = mpp_get_nest_fine_npes(nest_domain,l) allocate(my_pelist(npes_my_level)) - allocate(my_pelist_fine(npes_my_fine)) call mpp_get_nest_pelist(nest_domain, l, my_pelist) call mpp_declare_pelist(my_pelist(:)) write(type2, '(a,I2)')trim(type)//" nest_level = ",l if(ANY(my_pelist(:) == mpp_pe())) then + npes_my_fine = mpp_get_nest_fine_npes(nest_domain,l) + allocate(my_pelist_fine(npes_my_fine)) call mpp_get_nest_fine_pelist(nest_domain, l, my_pelist_fine) call mpp_set_current_pelist(my_pelist) @@ -4655,7 +4656,8 @@ subroutine test_update_nest_domain_r4( type ) endif endif - deallocate(my_pelist, my_pelist_fine) + if(ANY(my_pelist(:)==mpp_pe())) deallocate(my_pelist_fine) + deallocate(my_pelist) call mpp_set_current_pelist() enddo