From eff666d15d9c91eceab217754e662494c088b8d9 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Wed, 23 Oct 2024 19:31:33 -0400 Subject: [PATCH 1/3] 1. Excluding negative values of gridToFieldMap 2. Making get_fptr_shape public --- field_utils/FieldCondensedArray.F90 | 1 + field_utils/FieldCondensedArray_private.F90 | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/field_utils/FieldCondensedArray.F90 b/field_utils/FieldCondensedArray.F90 index bb8ad6e467e1..42e18561b16c 100644 --- a/field_utils/FieldCondensedArray.F90 +++ b/field_utils/FieldCondensedArray.F90 @@ -11,6 +11,7 @@ module mapl3g_FieldCondensedArray implicit none private public :: assign_fptr_condensed_array + public :: get_fptr_shape interface assign_fptr_condensed_array module procedure :: assign_fptr_condensed_array_r4 diff --git a/field_utils/FieldCondensedArray_private.F90 b/field_utils/FieldCondensedArray_private.F90 index b641c43545ea..8b00161d05c6 100644 --- a/field_utils/FieldCondensedArray_private.F90 +++ b/field_utils/FieldCondensedArray_private.F90 @@ -26,9 +26,9 @@ function get_fptr_shape_private(gridToFieldMap, localElementCount, has_vertical, vert_dim = 0 vert_size = 1 - + rank = size(localElementCount) - grid_dims = pack(gridToFieldMap, gridToFieldMap /= 0) + grid_dims = pack(gridToFieldMap, gridToFieldMap > 0) _ASSERT(all(grid_dims <= size(grid_dims)), 'MAPL expects geom dims before ungridded.') if(has_vertical) vert_dim = 1 if(size(grid_dims) > 0) vert_dim = maxval(grid_dims) + vert_dim From ab2a744c28124a8cc3da9b547018243cac6258a0 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Thu, 24 Oct 2024 11:48:17 -0400 Subject: [PATCH 2/3] get_fptr_shape does not need to be public, after all --- field_utils/FieldCondensedArray.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/field_utils/FieldCondensedArray.F90 b/field_utils/FieldCondensedArray.F90 index 42e18561b16c..b265e1988353 100644 --- a/field_utils/FieldCondensedArray.F90 +++ b/field_utils/FieldCondensedArray.F90 @@ -11,7 +11,6 @@ module mapl3g_FieldCondensedArray implicit none private public :: assign_fptr_condensed_array - public :: get_fptr_shape interface assign_fptr_condensed_array module procedure :: assign_fptr_condensed_array_r4 @@ -72,6 +71,7 @@ function get_fptr_shape(f, rc) result(fptr_shape) has_vertical = spec_name /= VERTICAL_DIM_NONE_NAME fptr_shape = get_fptr_shape_private(gridToFieldMap, localElementCount, has_vertical, _RC) + _RETURN(_SUCCESS) end function get_fptr_shape end module mapl3g_FieldCondensedArray From e599fa87a2e243fbd5b07aca53d1a33ee146f6bc Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Thu, 24 Oct 2024 18:22:02 -0400 Subject: [PATCH 3/3] dimCount was used to allocate gridToFieldMap, should have been geomDimCount. Fixed that --- field_utils/FieldCondensedArray.F90 | 8 ++++---- field_utils/FieldCondensedArray_private.F90 | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/field_utils/FieldCondensedArray.F90 b/field_utils/FieldCondensedArray.F90 index b265e1988353..407b81b427bf 100644 --- a/field_utils/FieldCondensedArray.F90 +++ b/field_utils/FieldCondensedArray.F90 @@ -56,13 +56,13 @@ function get_fptr_shape(f, rc) result(fptr_shape) logical :: has_vertical character(len=:), allocatable :: spec_name character(len=*), parameter :: VERTICAL_DIM_NONE_NAME = 'VERTICAL_DIM_NONE' - integer :: dimCount + integer :: geomDimCount - call ESMF_FieldGet(f, dimCount=dimCount, rank=rank, _RC) + call ESMF_FieldGet(f, geomDimCount=geomDimCount, rank=rank, _RC) _ASSERT(.not. rank < 0, 'rank cannot be negative.') - _ASSERT(.not. dimCount < 0, 'dimCount cannot be negative.') + _ASSERT(.not. geomDimCount < 0, 'geomDimCount cannot be negative.') allocate(localElementCount(rank)) - allocate(gridToFieldMap(dimCount)) + allocate(gridToFieldMap(geomDimCount)) call ESMF_FieldGet(f, gridToFieldMap=gridToFieldMap, _RC) ! Due to an ESMF bug, getting the localElementCount must use the module function. ! See FieldGetLocalElementCount (specific function) comments. diff --git a/field_utils/FieldCondensedArray_private.F90 b/field_utils/FieldCondensedArray_private.F90 index 8b00161d05c6..3ca2edde9714 100644 --- a/field_utils/FieldCondensedArray_private.F90 +++ b/field_utils/FieldCondensedArray_private.F90 @@ -28,7 +28,7 @@ function get_fptr_shape_private(gridToFieldMap, localElementCount, has_vertical, vert_size = 1 rank = size(localElementCount) - grid_dims = pack(gridToFieldMap, gridToFieldMap > 0) + grid_dims = pack(gridToFieldMap, gridToFieldMap /= 0) _ASSERT(all(grid_dims <= size(grid_dims)), 'MAPL expects geom dims before ungridded.') if(has_vertical) vert_dim = 1 if(size(grid_dims) > 0) vert_dim = maxval(grid_dims) + vert_dim