Skip to content

Commit

Permalink
Fix for "mirror" ungridded
Browse files Browse the repository at this point in the history
UngriddedDimsAspect is a rare case where an Aspect has a sensible
default value (none) but absences must still be considered to be
mirror.   This commit corrects an inconsistency in the treatment which
was not affecting the tests before.
  • Loading branch information
tclune committed Dec 26, 2024
1 parent 6fcc006 commit 0881269
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 17 deletions.
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: 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
2 changes: 1 addition & 1 deletion generic3g/specs/FieldSpec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function new_FieldSpec_geom(unusable, geom, vertical_grid, vertical_dim_spec, ty
class(VerticalGrid), optional, intent(in) :: vertical_grid
type(VerticalDimSpec), intent(in) :: vertical_dim_spec
type(ESMF_Typekind_Flag), intent(in) :: typekind
type(UngriddedDims), intent(in) :: ungridded_dims
type(UngriddedDims), optional, intent(in) :: ungridded_dims
character(*), optional, intent(in) :: standard_name
character(*), optional, intent(in) :: units
character(*), optional, intent(in) :: long_name
Expand Down
5 changes: 2 additions & 3 deletions generic3g/tests/Test_FieldSpec.pf
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,18 @@ contains
type(FieldSpec) :: export_spec
type(ESMF_Geom) :: geom

type(UngriddedDims) :: mirror_ungrid, export_dims
type(UngriddedDims) :: export_dims
type(UngriddedDimVector) :: ungrid_dims
type(UngriddedDim) :: ungrid_dim

mirror_ungrid = mirror_ungridded_dims()
ungrid_dim = UngriddedDim(2)
call ungrid_dims%push_back(ungrid_dim)
export_dims = UngriddedDims(ungrid_dims)

! Mirror ungrids by not specifying anything
import_spec = FieldSpec( &
geom=geom, vertical_grid=BasicVerticalGrid(1), vertical_dim_spec=VerticalDimSpec(), &
typekind=ESMF_TYPEKIND_R4, &
ungridded_dims = mirror_ungrid, &
standard_name='A', long_name='AA', attributes=StringVector(), &
units='m')

Expand Down
4 changes: 1 addition & 3 deletions gridcomps/History3G/HistoryCollectionGridComp_private.F90
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,13 @@ subroutine add_specs(gridcomp, names, rc)
type(StringVectorIterator) :: ftn_iter, ftn_end
type(VariableSpec) :: varspec
character(len=:), allocatable :: short_name
type(UngriddedDims) :: mirror_ungrid

mirror_ungrid = mirror_ungridded_dims()
ftn_end = names%ftn_end()
ftn_iter = names%ftn_begin()
do while (ftn_iter /= ftn_end)
call ftn_iter%next()
short_name = ftn_iter%of()
varspec = VariableSpec(ESMF_STATEINTENT_IMPORT, short_name, vertical_dim_spec=VERTICAL_DIM_MIRROR, ungridded_dims=mirror_ungrid)
varspec = VariableSpec(ESMF_STATEINTENT_IMPORT, short_name, vertical_dim_spec=VERTICAL_DIM_MIRROR)
call MAPL_AddSpec(gridcomp, varspec, _RC)
end do

Expand Down

0 comments on commit 0881269

Please sign in to comment.