Skip to content

Commit

Permalink
Merge pull request #2309 from GEOS-ESM/feature/tclune/mapl3-latlongeo…
Browse files Browse the repository at this point in the history
…mfactory

Feature/tclune/mapl3 latlongeomfactory
  • Loading branch information
tclune authored Aug 22, 2023
2 parents 08cd9b8 + 55e5cfa commit 650749b
Show file tree
Hide file tree
Showing 34 changed files with 3,715 additions and 1,105 deletions.
2 changes: 1 addition & 1 deletion base/Base/Base_Base.F90
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ module subroutine MAPL_SetPointer3DR4(state, ptr, name, rc)
integer, optional, intent( OUT) :: rc
end subroutine MAPL_SetPointer3DR4

module subroutine MAPL_DecomposeDim ( dim_world,dim,NDEs, unusable, symmetric, min_DE_extent )
pure module subroutine MAPL_DecomposeDim ( dim_world,dim,NDEs, unusable, symmetric, min_DE_extent )
use MAPL_KeywordEnforcerMod

integer, intent(in) :: dim_world, NDEs
Expand Down
8 changes: 3 additions & 5 deletions base/Base/Base_Base_implementation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ module subroutine MAPL_SetPointer3DR4(state, ptr, name, rc)
_RETURN(ESMF_SUCCESS)
end subroutine MAPL_SetPointer3DR4

module subroutine MAPL_DecomposeDim ( dim_world,dim,NDEs, unusable, symmetric, min_DE_extent )
pure module subroutine MAPL_DecomposeDim ( dim_world,dim,NDEs, unusable, symmetric, min_DE_extent )
use MAPL_KeywordEnforcerMod

integer, intent(in) :: dim_world, NDEs
Expand All @@ -748,8 +748,6 @@ module subroutine MAPL_DecomposeDim ( dim_world,dim,NDEs, unusable, symmetric, m
logical :: symmetrize
integer :: NDEs_used

_UNUSED_DUMMY(unusable)

if (present(symmetric)) then
do_symmetric=symmetric
else
Expand Down Expand Up @@ -829,12 +827,12 @@ module subroutine MAPL_DecomposeDim ( dim_world,dim,NDEs, unusable, symmetric, m

contains

logical function even(n)
pure logical function even(n)
integer, intent(in) :: n
even = mod(n,2).EQ.0
end function even

logical function odd(n)
pure logical function odd(n)
integer, intent(in) :: n
odd = mod(n,2).EQ.1
end function odd
Expand Down
68 changes: 6 additions & 62 deletions generic3g/ComponentSpecParser.F90
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,15 @@ function to_typekind(attributes, rc) result(typekind)
integer, optional, intent(out) :: rc

integer :: status
logical :: typekind_is_specified
character(:), allocatable :: typekind_str

typekind = ESMF_TYPEKIND_R4 ! GEOS default
if (.not. ESMF_HConfigIsDefined(attributes,keyString='typekind')) then
_RETURN(_SUCCESS)
end if
typekind_str= ESMF_HConfigAsString(attributes,keyString='typekind',_RC)
typekind = ESMF_TYPEKIND_R4 ! GEOS defaults

typekind_is_specified = ESMF_HConfigIsDefined(attributes, keyString='typekind', _RC)
_RETURN_UNLESS(typekind_is_specified)

typekind_str= ESMF_HConfigAsString(attributes,keyString='typekind',_RC)
select case (typekind_str)
case ('R4')
typekind = ESMF_TYPEKIND_R4
Expand Down Expand Up @@ -508,26 +509,6 @@ end subroutine get_intents
end function parse_connections


!!$ type(ChildSpec) function parse_ChildSpec(hconfig, rc) result(child_spec)
!!$ type(ESMF_HConfig), intent(in) :: hconfig
!!$ integer, optional, intent(out) :: rc
!!$
!!$ type(ESMF_HConfig) :: subcfg
!!$ integer :: status
!!$ logical :: has_config_file
!!$
!!$ _ASSERT(ESMF_HConfigIsDefined(hconfig, keyString='setServices'),"child spec must specify a 'setServices' spec")
!!$ subcfg = ESMF_HConfigCreateAt(hconfig, keyString='setServices', _RC)
!!$ child_spec%user_setservices = parse_setservices(subcfg, _RC)
!!$
!!$ has_config_file = ESMF_HConfigIsDefined(hconfig, keyString='config_file', _RC)
!!$ if (has_config_file) then
!!$ child_spec%config_file = ESMF_HConfigAsString(hconfig, keyString='config_file',_RC)
!!$ end if
!!$
!!$ _RETURN(_SUCCESS)
!!$ end function parse_ChildSpec

type(DSOSetServices) function parse_setservices(config, rc) result(user_ss)
type(ESMF_HConfig), target, intent(in) :: config
integer, optional, intent(out) :: rc
Expand All @@ -549,43 +530,6 @@ type(DSOSetServices) function parse_setservices(config, rc) result(user_ss)
_RETURN(_SUCCESS)
end function parse_setservices

!!$
!!$ ! Note: It is convenient to allow a null pointer for the config in
!!$ ! the case of no child specs. It spares the higher level procedure
!!$ ! making the relevant check.
!!$
!!$ type(ChildSpecMap) function parse_ChildSpecMap(config, rc) result(specs)
!!$ type(ESMF_HConfig), pointer, intent(in) :: config
!!$ integer, optional, intent(out) :: rc
!!$
!!$ integer :: status
!!$ type(ESMF_HConfigIter) :: hconfigIter,hconfigIterBegin,hconfigIterEnd
!!$
!!$ character(:), allocatable :: child_name
!!$ type(ChildSpec) :: child_spec
!!$ type(ESMF_HConfig) :: subcfg
!!$
!!$ if (.not. associated(config)) then
!!$ specs = ChildSpecMap()
!!$ _RETURN(_SUCCESS)
!!$ end if
!!$ _ASSERT(ESMF_HConfigIsMap(config), 'children spec must be mapping of names to child specs')
!!$
!!$
!!$ hconfigIter = ESMF_HConfigIterBegin(config,_RC)
!!$ hconfigIterBegin = ESMF_HConfigIterBegin(config,_RC)
!!$ hconfigIterEnd = ESMF_HConfigIterEnd(config,_RC)
!!$ do while (ESMF_HConfigIterLoop(hconfigIter,hconfigIterBegin,hconfigIterEnd))
!!$ child_name = ESMF_HConfigAsStringMapKey(hconfigIter)
!!$ subcfg = ESMF_HConfigCreateAtMapVal(hconfigIter)
!!$ child_spec = parse_ChildSpec(subcfg)
!!$ call specs%insert(child_name, child_spec)
!!$ end do
!!$
!!$ _RETURN(_SUCCESS)
!!$ end function parse_ChildSpecMap
!!$


function parse_children(hconfig, rc) result(children)
type(ChildSpecMap) :: children
Expand Down
4 changes: 2 additions & 2 deletions generic3g/tests/Test_Scenarios.pf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Test_Scenarios
use mapl3g_MultiState
use mapl3g_OuterMetaComponent
use mapl3g_ChildComponent
use mapl3g_GenericGridComp
use mapl3g_GenericGridComp, generic_setservices => setservices
use mapl3g_UserSetServices
use mapl3g_ESMF_Utilities
use mapl3g_VerticalGeom
Expand Down Expand Up @@ -158,7 +158,7 @@ contains
associate (outer_gc => this%outer_gc, outer_states => this%outer_states, grid => this%grid)

outer_gc = create_grid_comp('ROOT', user_setservices('libsimple_parent_gridcomp'), config, _RC)
call ESMF_GridCompSetServices(outer_gc, setServices, userRC=user_status, _RC)
call ESMF_GridCompSetServices(outer_gc, generic_setServices, userRC=user_status, _RC)
_VERIFY(user_status)
grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], name='I_AM_GROOT', _RC)
call MAPL_GridCompSetGeom(outer_gc, grid, _RC)
Expand Down
25 changes: 21 additions & 4 deletions geom_mgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,35 @@ set(srcs
GeomSpec.F90
NullGeomSpec.F90
MaplGeom.F90
MaplGeom_smod.F90

GeomFactory.F90
# LatLonGeomFactory.F90

CoordinateAxis.F90
CoordinateAxis_smod.F90
HConfigUtils.F90

latlon/LonAxis.F90
latlon/LonAxis_smod.F90
latlon/LatAxis.F90
latlon/LatAxis_smod.F90
latlon/LatLonDecomposition.F90
latlon/LatLonDecomposition_smod.F90
latlon/LatLonGeomSpec.F90
latlon/LatLonGeomSpec_smod.F90
latlon/LatLonGeomFactory.F90
latlon/LatLonGeomFactory_smod.F90

GeomManager.F90
GeomManager_smod.F90

# gFTL containers
GeomFactoryVector.F90
GeomSpecVector.F90
IntegerMaplGeomMap.F90

VectorBasis.F90
VectorBasis_smod.F90
)

esma_add_library(${this}
Expand All @@ -31,7 +48,7 @@ target_include_directories (${this} PUBLIC
$<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)
target_link_libraries (${this} PUBLIC esmf)

if (PFUNIT_FOUND)
# add_subdirectory(tests EXCLUDE_FROM_ALL)
endif ()
if (PFUNIT_FOUND)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif ()

111 changes: 111 additions & 0 deletions geom_mgr/CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
module mapl3g_CoordinateAxis
use mapl_RangeMod
use esmf, only: ESMF_KIND_R8
use esmf, only: ESMF_HConfig
use pfio
implicit none
private

public :: CoordinateAxis
public :: operator(==)
public :: operator(/=)

public :: get_coordinates
public :: get_dim_name
public :: AxisRanges

integer, parameter :: R8 = ESMF_KIND_R8

type :: AxisRanges
real(kind=R8) :: center_min
real(kind=R8) :: center_max
real(kind=R8) :: corner_min
real(kind=R8) :: corner_max
end type AxisRanges

type :: CoordinateAxis
private
real(kind=R8), allocatable :: centers(:)
real(kind=R8), allocatable :: corners(:)
contains
procedure :: get_extent
procedure :: get_centers
procedure :: get_corners
procedure :: is_periodic
end type CoordinateAxis

interface CoordinateAxis
procedure new_CoordinateAxis
end interface CoordinateAxis

interface operator(==)
module procedure equal_to
end interface operator(==)

interface operator(/=)
module procedure not_equal_to
end interface operator(/=)

interface get_coordinates
procedure get_coordinates_dim
end interface get_coordinates

! Submodule
interface

pure module function new_CoordinateAxis(centers, corners) result(axis)
type(CoordinateAxis) :: axis
real(kind=R8), intent(in) :: centers(:)
real(kind=R8), intent(in) :: corners(:)
end function new_CoordinateAxis

elemental logical module function equal_to(a, b)
type(CoordinateAxis), intent(in) :: a, b
end function equal_to

elemental logical module function not_equal_to(a, b)
type(CoordinateAxis), intent(in) :: a, b
end function not_equal_to

! Accessors
!----------
! Note that size(this%corners) might be one larger for non-periodic
pure module function get_extent(this) result(extent)
class(CoordinateAxis), intent(in) :: this
integer :: extent
end function get_extent

pure module function get_centers(this) result(centers)
real(kind=R8), allocatable :: centers(:)
class(CoordinateAxis), intent(in) :: this
end function get_centers

pure module function get_corners(this) result(corners)
real(kind=R8), allocatable :: corners(:)
class(CoordinateAxis), intent(in) :: this
end function get_corners

pure logical module function is_periodic(this)
class(CoordinateAxis), intent(in) :: this
end function is_periodic

module function get_dim_name(file_metadata, units, rc) result(dim_name)
character(:), allocatable :: dim_name
type(FileMetadata), target, intent(in) :: file_metadata
character(*), intent(in) :: units
integer, optional, intent(out) :: rc
end function get_dim_name

module function get_coordinates_dim(file_metadata, dim_name, rc) result(coordinates)
use pfio, only: FileMetadata
real(kind=R8), dimension(:), allocatable :: coordinates
type(FileMetadata), intent(in) :: file_metadata
character(len=*), intent(in) :: dim_name
integer, optional, intent(out) :: rc
end function get_coordinates_dim


end interface

end module mapl3g_CoordinateAxis

Loading

0 comments on commit 650749b

Please sign in to comment.