Skip to content

Commit

Permalink
Renamed k_values -> vertical_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
pchakraborty committed Jan 10, 2025
1 parent 431faf9 commit bca4af6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
20 changes: 10 additions & 10 deletions generic3g/tests/Test_Scenarios.pf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ contains
params = [params, add_params('field status', check_field_status)]
params = [params, add_params('field typekind', check_field_typekind)]
params = [params, add_params('field value', check_field_value)]
params = [params, add_params('field k_values', check_field_k_values)]
params = [params, add_params('field vertical_profile', check_field_vertical_profile)]
params = [params, add_params('field exists', check_field_rank)]

! Service oriented tests
Expand Down Expand Up @@ -515,14 +515,14 @@ contains
rc = 0
end subroutine check_field_value

subroutine check_field_k_values(expectations, state, short_name, description, rc)
subroutine check_field_vertical_profile(expectations, state, short_name, description, rc)
type(ESMF_HConfig), intent(in) :: expectations
type(ESMF_State), intent(inout) :: state
character(*), intent(in) :: short_name
character(*), intent(in) :: description
integer, intent(out) :: rc

real, allocatable :: expected_k_values(:)
real, allocatable :: expected_vertical_profile(:)
integer :: rank
type(ESMF_TypeKind_Flag) :: typekind
integer :: status
Expand All @@ -539,12 +539,12 @@ contains
return
end if
if (.not. ESMF_HConfigIsDefined(expectations,keyString='k_values')) then
if (.not. ESMF_HConfigIsDefined(expectations,keyString='vertical_profile')) then
rc = 0
return
end if
expected_k_values = ESMF_HConfigAsR4Seq(expectations,keyString='k_values',_RC)
expected_vertical_profile = ESMF_HConfigAsR4Seq(expectations,keyString='vertical_profile',_RC)
call ESMF_StateGet(state, short_name, field, _RC)
call ESMF_FieldGet(field, typekind=typekind, rank=rank, rc=status)
Expand All @@ -559,7 +559,7 @@ contains
shape3 = shape(x3)
do i = 1, shape3(1)
do j = 1, shape3(2)
@assert_that("value of "//short_name, x3(i, j, :), is(equal_to(expected_k_values)))
@assert_that("value of "//short_name, x3(i, j, :), is(equal_to(expected_vertical_profile)))
end do
end do
case(4)
Expand All @@ -568,7 +568,7 @@ contains
do i = 1, shape4(1)
do j = 1, shape4(2)
do l = 1, shape4(4)
@assert_that("value of "//short_name, x4(i, j, :, l), is(equal_to(expected_k_values)))
@assert_that("value of "//short_name, x4(i, j, :, l), is(equal_to(expected_vertical_profile)))
end do
end do
end do
Expand All @@ -585,7 +585,7 @@ contains
shape3 = shape(x3)
do i = 1, shape3(1)
do j = 1, shape3(2)
@assert_that("value of "//short_name, x3(i, j, :), is(equal_to(expected_k_values)))
@assert_that("value of "//short_name, x3(i, j, :), is(equal_to(expected_vertical_profile)))
end do
end do
case(4)
Expand All @@ -594,7 +594,7 @@ contains
do i = 1, shape4(1)
do j = 1, shape4(2)
do l = 1, shape4(4)
@assert_that("value of "//short_name, x4(i, j, :, l), is(equal_to(expected_k_values)))
@assert_that("value of "//short_name, x4(i, j, :, l), is(equal_to(expected_vertical_profile)))
end do
end do
end do
Expand All @@ -607,7 +607,7 @@ contains
end if
rc = 0
end subroutine check_field_k_values
end subroutine check_field_vertical_profile
subroutine check_field_rank(expectations, state, short_name, description, rc)
type(ESMF_HConfig), intent(in) :: expectations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
- component: DYN
export:
PL: {status: complete}
T_DYN: {status: complete, typekind: R4, rank: 3, k_values: [40., 20., 10., 5.]}
T_DYN: {status: complete, typekind: R4, rank: 3, vertical_profile: [40., 20., 10., 5.]}

- component: PHYS
import:
T_PHYS: {status: complete, typekind: R4, rank: 3, k_values: [18., 6.]}
T_PHYS: {status: complete, typekind: R4, rank: 3, vertical_profile: [18., 6.]}

- component: C
import:
I_C: {status: complete, typekind: R4, rank: 3, k_values: [40., 20., 10.]}
I_C: {status: complete, typekind: R4, rank: 3, vertical_profile: [40., 20., 10.]}
19 changes: 9 additions & 10 deletions gridcomps/configurable/ConfigurableGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module mapl3g_ConfigurableGridComp
character(*), parameter :: MAPL_SECTION = "mapl"
character(*), parameter :: COMPONENT_STATES_SECTION = "states"
character(*), parameter :: COMPONENT_EXPORT_STATE_SECTION = "export"
character(*), parameter :: KEY_K_VALUES = "k_values"
character(*), parameter :: KEY_DEFAULT_VERT_PROFILE = "default_vertical_profile"

contains

Expand All @@ -41,8 +41,8 @@ subroutine init(gridcomp, importState, exportState, clock, rc)

character(:), allocatable :: field_name
type(ESMF_HConfig) :: hconfig, mapl_cfg, states_cfg, export_cfg, field_cfg
logical :: has_export_section, has_k_values
real(kind=ESMF_KIND_R4), allocatable :: k_values(:)
logical :: has_export_section, has_default_vert_profile
real(kind=ESMF_KIND_R4), allocatable :: default_vert_profile(:)
real(kind=ESMF_KIND_R4), pointer :: ptr3d(:, :, :)
integer :: ii, jj, shape_(3), status

Expand All @@ -55,7 +55,7 @@ subroutine init(gridcomp, importState, exportState, clock, rc)
has_export_section = ESMF_HConfigIsDefined(states_cfg, keyString=COMPONENT_EXPORT_STATE_SECTION, _RC)
_RETURN_UNLESS(has_export_section)

! For each field getting 'export'ed, check hconfig and use k_values if specified
! For each field getting 'export'ed, check hconfig and use default_vert_profile if specified
export_cfg = ESMF_HConfigCreateAt(states_cfg, keyString=COMPONENT_EXPORT_STATE_SECTION, _RC)
b = ESMF_HConfigIterBegin(export_cfg, _RC)
e = ESMF_HConfigIterEnd(export_cfg, _RC)
Expand All @@ -64,16 +64,15 @@ subroutine init(gridcomp, importState, exportState, clock, rc)
field_name = ESMF_HConfigAsStringMapKey(iter, _RC)
! print *, "FIELD: ", field_name
field_cfg = ESMF_HConfigCreateAtMapVal(iter, _RC)
has_k_values = ESMF_HConfigIsDefined(field_cfg, keyString=KEY_K_VALUES, _RC)
if (has_k_values) then
k_values = ESMF_HConfigAsR4Seq(field_cfg, keyString=KEY_K_VALUES, _RC)
! print *, "K VALUES: ", k_values
has_default_vert_profile = ESMF_HConfigIsDefined(field_cfg, keyString=KEY_DEFAULT_VERT_PROFILE, _RC)
if (has_default_vert_profile) then
default_vert_profile = ESMF_HConfigAsR4Seq(field_cfg, keyString=KEY_DEFAULT_VERT_PROFILE, _RC)
call MAPL_GetPointer(exportState, ptr3d, trim(field_name), _RC)
shape_ = shape(ptr3d)
_ASSERT(shape_(3) == size(k_values), "incorrect number of k_values")
_ASSERT(shape_(3) == size(default_vert_profile), "incorrect size of vertical profile")
print *, ptr3d(1, 4, 3)
do concurrent(ii = 1:shape_(1), jj=1:shape_(2))
ptr3d(ii, jj, :) = k_values
ptr3d(ii, jj, :) = default_vert_profile
end do
print *, ptr3d(1, 4, 3)
end if
Expand Down

0 comments on commit bca4af6

Please sign in to comment.