Skip to content

Commit

Permalink
Merge pull request #3112 from GEOS-ESM/feature/wdboggs/change_extensi…
Browse files Browse the repository at this point in the history
…on_action_methods_3108

Feature/wdboggs/change extension action methods 3108
  • Loading branch information
tclune authored Oct 21, 2024
2 parents ba32955 + b36965b commit 012dd9a
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update `Findudunits.cmake` to link with libdl and look for the `udunits2.xml` file (as some MAPL tests require it)
- Modified `ESMF_GridComp` creation in `GenericGridComp` to use `ESMF_CONTEXT_PARENT_VM` by default.
- Changed `get_fptr_shape` in `FieldCondensedArray*.F90`
- Change name of ExtensionAction%run to ExtensionAction%update in the abstract type and derived types.
- Add invalid method to ExtensionAction with a no-op implementation in the abstract type

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions generic3g/actions/ConvertUnitsAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module mapl3g_ConvertUnitsAction
character(:), allocatable :: src_units, dst_units
contains
procedure :: initialize
procedure :: run
procedure :: update
end type ConvertUnitsAction


Expand Down Expand Up @@ -59,7 +59,7 @@ subroutine initialize(this, importState, exportState, clock, rc)
end subroutine initialize


subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
use esmf
class(ConvertUnitsAction), intent(inout) :: this
type(ESMF_State) :: importState
Expand Down Expand Up @@ -95,6 +95,6 @@ subroutine run(this, importState, exportState, clock, rc)

_FAIL('unsupported typekind')
_UNUSED_DUMMY(clock)
end subroutine run
end subroutine update

end module mapl3g_ConvertUnitsAction
6 changes: 3 additions & 3 deletions generic3g/actions/CopyAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module mapl3g_CopyAction
type(ESMF_Field) :: f_in, f_out
contains
procedure :: initialize
procedure :: run
procedure :: update
end type CopyAction

interface CopyAction
Expand Down Expand Up @@ -65,7 +65,7 @@ subroutine initialize(this, importState, exportState, clock, rc)
_UNUSED_DUMMY(clock)
end subroutine initialize

subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
use esmf
class(CopyAction), intent(inout) :: this
type(ESMF_State) :: importState
Expand All @@ -82,7 +82,7 @@ subroutine run(this, importState, exportState, clock, rc)
call FieldCopy(f_in, f_out, _RC)

_RETURN(_SUCCESS)
end subroutine run
end subroutine update


end module mapl3g_CopyAction
23 changes: 22 additions & 1 deletion generic3g/actions/ExtensionAction.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "MAPL_Generic.h"
module mapl3g_ExtensionAction
use mapl_ErrorHandling
implicit none
private

Expand All @@ -7,7 +9,8 @@ module mapl3g_ExtensionAction
type, abstract :: ExtensionAction
contains
procedure(I_run), deferred :: initialize
procedure(I_run), deferred :: run
procedure(I_run), deferred :: update
procedure :: invalidate
end type ExtensionAction


Expand All @@ -23,4 +26,22 @@ subroutine I_run(this, importState, exportState, clock, rc)
end subroutine I_run
end interface

contains

! This is a default no-op implementation of invalidate.
! Types derived from ExtensionAction should overload it
! as needed.
subroutine invalidate(this, importState, exportState, clock, rc)
use ESMF
class(ExtensionAction), intent(inout) :: this
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
type(ESMF_Clock) :: clock
integer, optional, intent(out) :: rc
_UNUSED_DUMMY(this)
_UNUSED_DUMMY(importState)
_UNUSED_DUMMY(exportState)
_UNUSED_DUMMY(clock)
end subroutine invalidate

end module mapl3g_ExtensionAction
6 changes: 3 additions & 3 deletions generic3g/actions/NullAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module mapl3g_NullAction
type, extends(ExtensionAction) :: NullAction
contains
procedure :: initialize
procedure :: run
procedure :: update
end type NullAction

interface NullAction
Expand All @@ -42,7 +42,7 @@ subroutine initialize(this, importState, exportState, clock, rc)
_UNUSED_DUMMY(clock)
end subroutine initialize

subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
use esmf
class(NullAction), intent(inout) :: this
type(ESMF_State) :: importState
Expand All @@ -54,6 +54,6 @@ subroutine run(this, importState, exportState, clock, rc)
_UNUSED_DUMMY(importState)
_UNUSED_DUMMY(exportState)
_UNUSED_DUMMY(clock)
end subroutine run
end subroutine update

end module mapl3g_NullAction
6 changes: 3 additions & 3 deletions generic3g/actions/RegridAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module mapl3g_RegridAction
class(Regridder), pointer :: regrdr
contains
procedure :: initialize
procedure :: run
procedure :: update
end type ScalarRegridAction

interface RegridAction
Expand Down Expand Up @@ -67,7 +67,7 @@ subroutine initialize(this, importState, exportState, clock, rc)
end subroutine initialize


subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
class(ScalarRegridAction), intent(inout) :: this
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
Expand All @@ -84,6 +84,6 @@ subroutine run(this, importState, exportState, clock, rc)

_RETURN(_SUCCESS)
_UNUSED_DUMMY(clock)
end subroutine run
end subroutine update

end module mapl3g_RegridAction
6 changes: 3 additions & 3 deletions generic3g/actions/TimeInterpolateAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module mapl3g_TimeInterpolateAction
type, extends(ExtensionAction) :: TimeInterpolateAction
contains
procedure :: initialize
procedure :: run
procedure :: update
end type TimeInterpolateAction

interface TimeInterpolateAction
Expand All @@ -42,7 +42,7 @@ subroutine initialize(this, importState, exportState, clock, rc)
_RETURN(_SUCCESS)
end subroutine initialize

subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
class(TimeInterpolateAction), intent(inout) :: this
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
Expand Down Expand Up @@ -80,7 +80,7 @@ subroutine run(this, importState, exportState, clock, rc)

_RETURN(_SUCCESS)
_UNUSED_DUMMY(clock)
end subroutine run
end subroutine update


subroutine run_r4(bundle_in, field_out, rc)
Expand Down
6 changes: 3 additions & 3 deletions generic3g/actions/VerticalRegridAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module mapl3g_VerticalRegridAction
type(VerticalRegridMethod) :: method = VERTICAL_REGRID_UNKNOWN
contains
procedure :: initialize
procedure :: run
procedure :: update
end type VerticalRegridAction

interface VerticalRegridAction
Expand Down Expand Up @@ -72,7 +72,7 @@ subroutine initialize(this, importState, exportState, clock, rc)
_RETURN(_SUCCESS)
end subroutine initialize

subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
use esmf
class(VerticalRegridAction), intent(inout) :: this
type(ESMF_State) :: importState
Expand Down Expand Up @@ -117,6 +117,6 @@ subroutine run(this, importState, exportState, clock, rc)
end do

_RETURN(_SUCCESS)
end subroutine run
end subroutine update

end module mapl3g_VerticalRegridAction
2 changes: 1 addition & 1 deletion generic3g/couplers/CouplerMetaComponent.F90
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ recursive subroutine update(this, importState, exportState, clock, rc)
!# call this%propagate_attributes(_RC)
call this%update_sources(_RC)

call this%action%run(importState, exportState, clock, _RC)
call this%action%update(importState, exportState, clock, _RC)
call this%set_up_to_date()

_RETURN(_SUCCESS)
Expand Down
6 changes: 3 additions & 3 deletions generic3g/tests/MockItemSpec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module MockItemSpecMod
character(:), allocatable :: details
contains
procedure :: initialize
procedure :: run
procedure :: update
end type MockAction

interface MockItemSpec
Expand Down Expand Up @@ -215,15 +215,15 @@ subroutine initialize(this, importState, exportState, clock, rc)
_FAIL('This procedure should not be called.')
end subroutine initialize

subroutine run(this, importState, exportState, clock, rc)
subroutine update(this, importState, exportState, clock, rc)
use esmf
class(MockAction), intent(inout) :: this
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
type(ESMF_Clock) :: clock
integer, optional, intent(out) :: rc
_FAIL('This procedure should not be called.')
end subroutine run
end subroutine update

function make_adapters(this, goal_spec, rc) result(adapters)
type(StateItemAdapterWrapper), allocatable :: adapters(:)
Expand Down
6 changes: 3 additions & 3 deletions generic3g/tests/Test_TimeInterpolateAction.pf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contains
call ESMF_FieldEmptyComplete(f, typekind=ESMF_TYPEKIND_R4, _RC)
call ESMF_StateAdd(exportState, [f], _RC)

call action%run(importState, exportState, clock, _RC)
call action%update(importState, exportState, clock, _RC)

call assign_fptr(f, x, _RC)
@assert_that(x, every_item(is(equal_to(7.))))
Expand Down Expand Up @@ -96,7 +96,7 @@ contains
call ESMF_FieldEmptyComplete(f, typekind=ESMF_TYPEKIND_R4, _RC)
call ESMF_StateAdd(exportState, [f], _RC)

call action%run(importState, exportState, clock, _RC)
call action%update(importState, exportState, clock, _RC)

call assign_fptr(f, x, _RC)
@assert_that(x, every_item(is(equal_to(4.))))
Expand Down Expand Up @@ -155,7 +155,7 @@ contains
call ESMF_FieldEmptyComplete(f, typekind=ESMF_TYPEKIND_R4, _RC)
call ESMF_StateAdd(exportState, [f], _RC)

call action%run(importState, exportState, clock, _RC)
call action%update(importState, exportState, clock, _RC)

call assign_fptr(f, x, _RC)
@assert_that(x(1), is(equal_to(4.)))
Expand Down

0 comments on commit 012dd9a

Please sign in to comment.