From 4f6198de6917f61e9e49fc4d0bdd3c3e90b6f369 Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Fri, 11 Apr 2025 11:53:18 -0400 Subject: [PATCH 1/6] Attempt to reduce memory contention --- .../GOCART2G_GridCompMod.F90 | 89 +++++++++++-------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 index 7b0fb0d8..01d83c84 100644 --- a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 +++ b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 @@ -1649,6 +1649,7 @@ subroutine aerosol_activation_properties(state, rc) character(len=ESMF_MAXSTR) :: fld_name + integer :: k, k0, k1 integer :: i2, j2, km integer :: b, i, j, n, aerosol_bin integer :: varNameLen @@ -1675,6 +1676,7 @@ subroutine aerosol_activation_properties(state, rc) real, parameter :: k_BR = 0.0001 integer, parameter :: UNKNOWN_AEROSOL_MODE = 2015 + logical :: isPresent __Iam__('GOCART2G::aerosol_activation_properties') @@ -1727,6 +1729,14 @@ subroutine aerosol_activation_properties(state, rc) j2 = ubound(temperature, 2) km = ubound(temperature, 3) + call ESMF_AttributeGet(state, name='use_level', value=k, isPresent=isPresent, __RC__) + k0 = 1 + k1 = km + if (isPresent) then + k0 = k + k1= k + end if + ! Activation activation properties ! -------------------------------- call ESMF_AttributeGet(state, name='aerosol_number_concentration', value=fld_name, __RC__) @@ -1763,7 +1773,7 @@ subroutine aerosol_activation_properties(state, rc) mode_ = trim(mode) mode_ = ESMF_UtilStringLowerCase(mode_, __RC__) - allocate(q(i2,j2,km), __STAT__) + allocate(q(i2,j2,k0:k1), __STAT__) q = 0.0 if (index(mode_, 'du00') > 0) then ! Dust @@ -1773,11 +1783,11 @@ subroutine aerosol_activation_properties(state, rc) read (mode_(3:len(mode_)),*) aerosol_bin call ESMF_StateGet(state, trim(aeroList(i)), child_state, __RC__) call MAPL_GetPointer(child_state, ptr_4d, 'DU', __RC__) - q = q + ptr_4d(:,:,:,aerosol_bin) - ptr_3d => ptr_4d(:,:,:,aerosol_bin) + q = q + ptr_4d(:,:,k0:k1,aerosol_bin) + ptr_3d => ptr_4d(:,:,k0:k1,aerosol_bin) - hygroscopicity = k_DU - density = densDU + hygroscopicity(:,:,k0:k1) = k_DU + density(:,:,k0:k1) = densDU end if end do @@ -1788,12 +1798,12 @@ subroutine aerosol_activation_properties(state, rc) call ESMF_StateGet(state, trim(aeroList(i)), child_state, __RC__) call MAPL_GetPointer(child_state, ptr_4d, 'SS', __RC__) do j = 1, ubound(ptr_4d, 4) - q = q + ptr_4d(:,:,:,j) - ptr_3d => ptr_4d(:,:,:,j) + q = q + ptr_4d(:,:,k0:k1,j) + ptr_3d => ptr_4d(:,:,k0:k1,j) end do - hygroscopicity = k_SS - density = densSS + hygroscopicity(:,:,k0:k1) = k_SS + density(:,:,k0:k1) = densSS end if end do @@ -1805,9 +1815,9 @@ subroutine aerosol_activation_properties(state, rc) if (index(aeroList(i), 'SU') > 0) then call ESMF_StateGet(state, trim(aeroList(i)), child_state, __RC__) call MAPL_GetPointer(child_state, ptr_3d, 'SO4', __RC__) - q = q + ptr_3d - hygroscopicity = k_SO4 * ptr_3d + hygroscopicity - density = densSO4 * ptr_3d + density + q = q + ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) = k_SO4 * ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) + density(:,:,k0:k1) = densSO4 * ptr_3d(:,:,k0:k1) + density(:,:,k0:k1) end if if (index(aeroList(i), 'CA.oc') > 0) then @@ -1816,22 +1826,22 @@ subroutine aerosol_activation_properties(state, rc) ! the '5' refers to '_AERO', which we want to remove to get the CA component name (e.g. CA.oc, or CA.oc.data) varNameLen = varNameLen - 5 call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) - q = q + ptr_3d - hygroscopicity = k_ORG * ptr_3d + hygroscopicity - density = densORG * ptr_3d + density + q = q + ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) = k_ORG * ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) + density(:,:,k0:k1) = densORG * ptr_3d + density end if end do where (q > 2.0e-12 .and. hygroscopicity > tiny(0.0)) - hygroscopicity = hygroscopicity / q - hygroscopicity = max(0.001, hygroscopicity) + hygroscopicity(:,:,k0:k1) = hygroscopicity(:,:,k0:k1) / q + hygroscopicity(:,:,k0:k1) = max(0.001, hygroscopicity(:,:,k0:k1)) - density = density / q - density = min(max(density, densORG), densSO4) + density(:,:,k0:k1) = density(:,:,k0:k1) / q + density(:,:,k0:k1) = min(max(density(:,:,k0:k1), densORG), densSO4) elsewhere - hygroscopicity = k_SO4 - density = densSO4 + hygroscopicity(:,:,k0:k1) = k_SO4 + density(:,:,k0:k1) = densSO4 end where else if (index(mode_, 'bcphilic') > 0) then ! Black Carbon @@ -1842,9 +1852,9 @@ subroutine aerosol_activation_properties(state, rc) ! the '5' refers to '_AERO', which we want to remove to get the CA component name (e.g. CA.bc, or CA.bc.data) varNameLen = varNameLen - 5 call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) - q = q + ptr_3d - hygroscopicity = k_BC - density = densBC + q = q + ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) = k_BC + density(:,:,k0:k1) = densBC end if end do @@ -1856,9 +1866,9 @@ subroutine aerosol_activation_properties(state, rc) ! the '5' refers to '_AERO', which we want to remove to get the CA component name (e.g. CA.oc, or CA.oc.data) varNameLen = varNameLen - 5 call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) - q = q + ptr_3d + q = q + ptr_3d(:,:,k0:k1) hygroscopicity = k_OC - density = densOC + density(:,:,k0:k1) = densOC end if end do @@ -1870,8 +1880,8 @@ subroutine aerosol_activation_properties(state, rc) ! the '5' refers to '_AERO', which we want to remove to get the CA component name (e.g. CA.bc, or CA.bc.data) varNameLen = varNameLen - 5 call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) - q = q + ptr_3d - hygroscopicity = k_BR + q = q + ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) = k_BR density = densBR end if end do @@ -1880,17 +1890,18 @@ subroutine aerosol_activation_properties(state, rc) ! Obtain aerosol activation properties of this aerosol mode ! --------------------------------------------------------- - call aap_(mode, & - q, & - num, & - diameter, & - sigma, & - f_dust, & - f_soot, & - f_organic, & - density, & - ptr_3d, & - 1, i2, 1, j2, km, & + call aap_(mode, & +!# q, & + q, & + num, & + diameter(:,:,k0:k1), & + sigma(:,:,k0:k1), & + f_dust(:,:,k0:k1), & + f_soot(:,:,k0:k1), & + f_organic(:,:,k0:k1), & + density(:,:,k0:k1), & + ptr_3d(:,:,k0:k1), & + 1, i2, 1, j2, (k1-k0+1), & __RC__) deallocate(q, __STAT__) From 69040a324f1df816cb7eaae87f63f8257d91fc00 Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Fri, 11 Apr 2025 15:04:32 -0400 Subject: [PATCH 2/6] Missed two changes. --- ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 index 01d83c84..ea99ed1d 100644 --- a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 +++ b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 @@ -1867,7 +1867,7 @@ subroutine aerosol_activation_properties(state, rc) varNameLen = varNameLen - 5 call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) q = q + ptr_3d(:,:,k0:k1) - hygroscopicity = k_OC + hygroscopicity(:,:,k0:k1) = k_OC density(:,:,k0:k1) = densOC end if end do @@ -1882,7 +1882,7 @@ subroutine aerosol_activation_properties(state, rc) call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) q = q + ptr_3d(:,:,k0:k1) hygroscopicity(:,:,k0:k1) = k_BR - density = densBR + density(:,:,k0:k1) = densBR end if end do From fe1849b91e4b847271298e5c1adfc069effa8bce Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Fri, 11 Apr 2025 15:11:54 -0400 Subject: [PATCH 3/6] A few more things missed. --- ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 index ea99ed1d..7548ee5c 100644 --- a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 +++ b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 @@ -1808,8 +1808,8 @@ subroutine aerosol_activation_properties(state, rc) end do else if (index(mode_, 'sulforg') > 0) then ! Sulfate - hygroscopicity = 0.0 - density = 0.0 + hygroscopicity(:,:,k0:k1) = 0.0 + density(:,:,k0:k1) = 0.0 do i = 1, size(aeroList) if (index(aeroList(i), 'SU') > 0) then @@ -1828,7 +1828,7 @@ subroutine aerosol_activation_properties(state, rc) call MAPL_GetPointer(child_state, ptr_3d, aeroList(i)(1:varNameLen)//'philic', __RC__) q = q + ptr_3d(:,:,k0:k1) hygroscopicity(:,:,k0:k1) = k_ORG * ptr_3d(:,:,k0:k1) + hygroscopicity(:,:,k0:k1) - density(:,:,k0:k1) = densORG * ptr_3d + density + density(:,:,k0:k1) = densORG * ptr_3d(:,:,k0:k1) + density(:,:,k0:k1) end if end do From 97f584f8bdc0412d9ff0720d3422808400624806 Mon Sep 17 00:00:00 2001 From: Amidu Oloso Date: Tue, 15 Apr 2025 16:23:35 -0400 Subject: [PATCH 4/6] Changes to get the branch to run --- ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 index 7548ee5c..5dff9229 100644 --- a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 +++ b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 @@ -1729,7 +1729,7 @@ subroutine aerosol_activation_properties(state, rc) j2 = ubound(temperature, 2) km = ubound(temperature, 3) - call ESMF_AttributeGet(state, name='use_level', value=k, isPresent=isPresent, __RC__) + call ESMF_AttributeGet(state, name='at_level', value=k, isPresent=isPresent, __RC__) k0 = 1 k1 = km if (isPresent) then From e75ba9532620f4225590c00af2cd387691cd568b Mon Sep 17 00:00:00 2001 From: Amidu Oloso Date: Thu, 17 Apr 2025 16:23:55 -0400 Subject: [PATCH 5/6] Make num a 2D array in the call to app_ around line 1898 of GOCART2G_GridCompMod.F90 --- ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 index 5dff9229..74ca3579 100644 --- a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 +++ b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 @@ -1893,7 +1893,7 @@ subroutine aerosol_activation_properties(state, rc) call aap_(mode, & !# q, & q, & - num, & + num(:,:,k0:k1), & diameter(:,:,k0:k1), & sigma(:,:,k0:k1), & f_dust(:,:,k0:k1), & From 2ca1d7f395b59afe895777b8cfde2b56e447d611 Mon Sep 17 00:00:00 2001 From: Amidu Oloso Date: Fri, 18 Apr 2025 09:16:56 -0400 Subject: [PATCH 6/6] addedd timer for aero --- ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 index 74ca3579..1d9ab1ec 100644 --- a/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 +++ b/ESMF/GOCART2G_GridComp/GOCART2G_GridCompMod.F90 @@ -1677,11 +1677,15 @@ subroutine aerosol_activation_properties(state, rc) integer, parameter :: UNKNOWN_AEROSOL_MODE = 2015 logical :: isPresent + class(BaseProfiler), pointer :: t_p __Iam__('GOCART2G::aerosol_activation_properties') ! Begin... + t_p => get_global_time_profiler() + call t_p%start('inside_aerosol_acti',_RC) + ! Get list of child states within state and add to aeroList ! --------------------------------------------------------- call ESMF_StateGet (state, itemCount=n, __RC__) @@ -1906,6 +1910,8 @@ subroutine aerosol_activation_properties(state, rc) deallocate(q, __STAT__) + call t_p%stop('inside_aerosol_acti',_RC) + RETURN_(ESMF_SUCCESS) contains