Skip to content

Commit

Permalink
Fixes #3405
Browse files Browse the repository at this point in the history
Needs more testing of course.
  • Loading branch information
tclune committed Feb 11, 2025
1 parent bbec588 commit d28698c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions generic3g/ComponentSpecParser.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module mapl3g_ComponentSpecParser
character(*), parameter :: COMPONENT_INTERNAL_STATE_SECTION = 'internal'
character(*), parameter :: COMPONENT_CONNECTIONS_SECTION = 'connections'
character(*), parameter :: COMPONENT_CHILDREN_SECTION = 'children'
character(*), parameter :: COMPONENT_ACTIVATE_ALL_EXPORTS = 'activate_all_exports'

character(*), parameter :: KEY_DEFAULT_VALUE = 'default_value'
character(*), parameter :: KEY_UNGRIDDED_DIMS = 'ungridded_dims'
Expand Down
24 changes: 24 additions & 0 deletions generic3g/ComponentSpecParser/parse_component_spec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,34 @@ module function parse_component_spec(hconfig, registry, timeStep, refTime, rc) r
spec%connections = parse_connections(mapl_cfg, _RC)
spec%children = parse_children(mapl_cfg, _RC)

call parse_misc(spec, mapl_cfg, _RC)

call ESMF_HConfigDestroy(mapl_cfg, _RC)

_RETURN(_SUCCESS)
end function parse_component_spec

! TODO - we may want a `misc` section in the mapl section, but
! should wait to see what else goes there. Or maybe a `test`
! section?

subroutine parse_misc(spec, hconfig, rc)
type(ComponentSpec), intent(inout) :: spec
type(ESMF_HConfig), intent(in) :: hconfig
integer, optional, intent(out) :: rc

integer :: status
logical :: has_activate_all_exports

has_activate_all_exports = ESMF_HConfigIsDefined(hconfig,keyString=COMPONENT_ACTIVATE_ALL_EXPORTS, _RC)
if (has_activate_all_exports) then
spec%activate_all_exports = ESMF_HConfigASLogical(hconfig, keyString=COMPONENT_ACTIVATE_ALL_EXPORTS, _RC)
end if


_RETURN(_SUCCESS)
end subroutine parse_misc


end submodule parse_component_spec_smod

16 changes: 14 additions & 2 deletions generic3g/OuterMetaComponent/initialize_advertise.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ subroutine self_advertise(this, unusable, rc)
iter = this%component_spec%var_specs%begin()
do while (iter /= e)
var_spec => iter%of()
call advertise_variable (var_spec, this%registry, _RC)
call advertise_variable (var_spec, this%registry, this%component_spec%activate_all_exports, _RC)
call iter%next()
end do
end associate
Expand All @@ -93,9 +93,10 @@ subroutine self_advertise(this, unusable, rc)
end subroutine self_advertise


subroutine advertise_variable(var_spec, registry, unusable, rc)
subroutine advertise_variable(var_spec, registry, activate_all_exports, unusable, rc)
type(VariableSpec), intent(in) :: var_spec
type(StateRegistry), target, intent(inout) :: registry
logical, intent(in) :: activate_all_exports
class(KE), optional, intent(in) :: unusable
integer, optional, intent(out) :: rc

Expand All @@ -108,9 +109,20 @@ subroutine advertise_variable(var_spec, registry, unusable, rc)
item_spec = make_ItemSpec(var_spec, registry, _RC)
call item_spec%create(_RC)

if (activate_all_exports) then
if (var_spec%state_intent == ESMF_STATEINTENT_EXPORT) then
call item_spec%set_active()
end if
end if

if (var_spec%state_intent == ESMF_STATEINTENT_INTERNAL) then
call item_spec%set_active()
end if

virtual_pt = var_spec%make_virtualPt()
call registry%add_primary_spec(virtual_pt, item_spec)


_RETURN(_SUCCESS)
_UNUSED_DUMMY(unusable)
end subroutine advertise_variable
Expand Down
2 changes: 2 additions & 0 deletions generic3g/specs/ComponentSpec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module mapl3g_ComponentSpec
type(ESMF_HConfig), allocatable :: geom_hconfig ! optional
type(ESMF_TimeInterval), allocatable :: timestep
type(ESMF_Time), allocatable :: reference_time
logical :: activate_all_exports = .false. ! used for testing in isolation

contains
procedure :: has_geom_hconfig
procedure :: add_var_spec
Expand Down
4 changes: 0 additions & 4 deletions generic3g/specs/make_itemSpec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ function make_itemSpec(variable_spec, registry, rc) result(item_spec)
call aspects%insert(CLASS_ASPECT_ID, class_aspect)
item_spec = StateItemSpec(aspects)

if (variable_spec%state_intent == ESMF_STATEINTENT_INTERNAL) then
call item_spec%set_active()
end if

dependencies = variable_spec%make_dependencies(_RC)
call item_spec%set_dependencies(dependencies)
call item_spec%set_raw_dependencies(variable_spec%dependencies)
Expand Down

0 comments on commit d28698c

Please sign in to comment.