Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3267 refactor variable spec #3271

Merged
merged 7 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions esmf_utils/UngriddedDims.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module mapl3g_UngriddedDims

public :: UngriddedDims
public :: make_UngriddedDims
public :: mirror_ungridded_dims
public :: operator(==)
public :: operator(/=)

Expand Down Expand Up @@ -52,14 +51,6 @@ module mapl3g_UngriddedDims

contains

function mirror_ungridded_dims() result(spec)
type(UngriddedDims) :: spec

spec%dim_specs = UngriddedDimVector()
spec%is_mirror = .true.

end function mirror_ungridded_dims

function new_UngriddedDims_empty() result(spec)
type(UngriddedDims) :: spec

Expand Down
2 changes: 0 additions & 2 deletions generic3g/ComponentSpecParser/parse_var_specs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc)
dependencies = to_dependencies(attributes, _RC)

esmf_state_intent = to_esmf_state_intent(state_intent)

var_spec = VariableSpec(esmf_state_intent, short_name=short_name, &
itemtype=itemtype, &
service_items=service_items, &
Expand All @@ -115,7 +114,6 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc)
if (allocated(units)) deallocate(units)
if (allocated(standard_name)) deallocate(standard_name)
if (allocated(accumulation_type)) deallocate(accumulation_type)

call var_specs%push_back(var_spec)

call ESMF_HConfigDestroy(attributes, _RC)
Expand Down
16 changes: 3 additions & 13 deletions generic3g/actions/CopyAction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,23 @@ module mapl3g_CopyAction
end type CopyAction

interface CopyAction
module procedure new_CopyAction
module procedure new_CopyAction2
module procedure new_CopyAction
end interface CopyAction

contains

function new_CopyAction(f_in, f_out) result(action)
type(CopyAction) :: action
type(ESMF_Field), intent(in) :: f_in
type(ESMF_Field), intent(in) :: f_out

action%f_in = f_in
action%f_out = f_out
end function new_CopyAction

! We don't really need to know the typekind as the low level conversion routines
! will accept whatever is handed. So these arguments are more to preserve
! a consistent form for constructions across Action subclasses.
function new_CopyAction2(src_typekind, dst_typekind) result(action)
function new_CopyAction(src_typekind, dst_typekind) result(action)
type(CopyAction) :: action
type(ESMF_Typekind_Flag), intent(in) :: src_typekind
type(ESMF_Typekind_Flag), intent(in) :: dst_typekind

action%src_typekind = src_typekind
action%dst_typekind = dst_typekind

end function new_CopyAction2
end function new_CopyAction

subroutine initialize(this, importState, exportState, clock, rc)
use esmf
Expand Down
2 changes: 1 addition & 1 deletion generic3g/registry/StateItemExtension.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ recursive function make_extension(this, goal, rc) result(extension)
aspect_name => aspect_names%of(i)
src_aspect => new_spec%get_aspect(aspect_name, _RC)
dst_aspect => goal%get_aspect(aspect_name, _RC)
_ASSERT(src_aspect%can_connect_to(dst_aspect), 'cannoct connect aspect ' // aspect_name)
_ASSERT(src_aspect%can_connect_to(dst_aspect), 'cannot connect aspect ' // aspect_name)

if (src_aspect%needs_extension_for(dst_aspect)) then
allocate(action, source=src_aspect%make_action(dst_aspect, rc=status))
Expand Down
53 changes: 52 additions & 1 deletion generic3g/specs/AspectCollection.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module mapl3g_AspectCollection

use mapl3g_GeomAspect
use mapl3g_UnitsAspect
use mapl3g_TypekindAspect

use mapl3g_UngriddedDimsAspect

use mapl_KeywordEnforcer
use mapl_ErrorHandling
Expand All @@ -17,15 +20,24 @@ module mapl3g_AspectCollection
private
type(GeomAspect), allocatable :: geom_aspect
type(UnitsAspect), allocatable :: units_aspect
type(TypekindAspect), allocatable :: typekind_aspect
type(UngriddedDimsAspect), allocatable :: ungridded_dims_aspect
contains
procedure :: get_aspect ! polymorphic
procedure :: has_aspect ! polymorphic
procedure :: set_aspect ! polymorphic

procedure :: get_geom_aspect
procedure :: set_geom_aspect

procedure :: get_units_aspect
procedure :: set_units_aspect

procedure :: get_typekind_aspect
procedure :: set_typekind_aspect

procedure :: get_ungridded_dims_aspect
procedure :: set_ungridded_dims_aspect

end type AspectCollection

Expand Down Expand Up @@ -61,6 +73,10 @@ function get_aspect(this, name, rc) result(aspect)
aspect => this%get_geom_aspect()
case ('UNITS')
aspect => this%get_units_aspect()
case ('TYPEKIND')
aspect => this%get_typekind_aspect()
case ('UNGRIDDED_DIMS')
aspect => this%get_ungridded_dims_aspect()
case default
_FAIL('unknown aspect type: '//name)
end select
Expand All @@ -73,7 +89,7 @@ logical function has_aspect(this, name)
character(*), intent(in) :: name

select case (name)
case ('GEOM', 'UNITS')
case ('GEOM', 'UNITS', 'UNGRIDDED_DIMS')
has_aspect = .true.
case default
has_aspect = .false.
Expand All @@ -93,6 +109,10 @@ subroutine set_aspect(this, aspect, rc)
this%geom_aspect = aspect
type is (UnitsAspect)
this%units_aspect = aspect
type is (TypekindAspect)
this%typekind_aspect = aspect
type is (UngriddedDimsAspect)
this%ungridded_dims_aspect = aspect
class default
_FAIL('unsupported aspect type: ')
end select
Expand Down Expand Up @@ -130,5 +150,36 @@ subroutine set_units_aspect(this, units_aspect)
this%units_aspect = units_aspect
end subroutine set_units_aspect

function get_typekind_aspect(this) result(typekind_aspect)
type(TypekindAspect), pointer :: typekind_aspect
class(AspectCollection), target, intent(in) :: this

typekind_aspect => null()
if (allocated(this%typekind_aspect)) then
typekind_aspect => this%typekind_aspect
end if
end function get_typekind_aspect

subroutine set_typekind_aspect(this, typekind_aspect)
class(AspectCollection), intent(inout) :: this
type(TypekindAspect), intent(in) :: typekind_aspect
this%typekind_aspect = typekind_aspect
end subroutine set_typekind_aspect

function get_ungridded_dims_aspect(this) result(ungridded_dims_aspect)
type(UngriddedDimsAspect), pointer :: ungridded_dims_aspect
class(AspectCollection), target, intent(in) :: this
ungridded_dims_aspect => null()
if (allocated(this%ungridded_dims_aspect)) then
ungridded_dims_aspect => this%ungridded_dims_aspect
end if
end function get_ungridded_dims_aspect

subroutine set_ungridded_dims_aspect(this, ungridded_dims_aspect)
class(AspectCollection), intent(inout) :: this
type(UngriddedDimsAspect), intent(in) :: ungridded_dims_aspect
this%ungridded_dims_aspect = ungridded_dims_aspect
end subroutine set_ungridded_dims_aspect

end module mapl3g_AspectCollection

1 change: 1 addition & 0 deletions generic3g/specs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ target_sources(MAPL.generic3g PRIVATE
StateItemAspect.F90
AspectCollection.F90
GeomAspect.F90
TypekindAspect.F90
UngriddedDimsAspect.F90
UnitsAspect.F90

Expand Down
Loading
Loading