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

New folders in geom_mgr to accommodate submodule files. #2817

Merged
merged 4 commits into from
May 9, 2024
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
21 changes: 6 additions & 15 deletions geom_mgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,19 @@ set(srcs
GeomSpec.F90
NullGeomSpec.F90
MaplGeom.F90
MaplGeom_smod.F90

GeomFactory.F90

CoordinateAxis.F90
CoordinateAxis_smod.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 @@ -43,6 +28,12 @@ esma_add_library(${this}
TYPE ${MAPL_LIBRARY_TYPE}
)

add_subdirectory(MaplGeom)
add_subdirectory(CoordinateAxis)
add_subdirectory(latlon)
add_subdirectory(GeomManager)
add_subdirectory(VectorBasis)

target_include_directories (${this} PUBLIC
$<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)
target_link_libraries (${this} PUBLIC ESMF::ESMF)
Expand Down
12 changes: 12 additions & 0 deletions geom_mgr/CoordinateAxis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
target_sources(MAPL.geom_mgr PRIVATE

new_CoordinateAxis_CoordinateAxis.F90
equal_to_CoordinateAxis.F90
not_equal_to_CoordinateAxis.F90
get_extent_CoordinateAxis.F90
get_centers_CoordinateAxis.F90
get_corners_CoordinateAxis.F90
is_periodic_CoordinateAxis.F90
get_dim_name_CoordinateAxis.F90
get_coordinates_dim_CoordinateAxis.F90
)
25 changes: 25 additions & 0 deletions geom_mgr/CoordinateAxis/equal_to_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) equal_to_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

! Do the fast checks first
equal_to = size(a%centers) == size(b%centers)
if (.not. equal_to) return
equal_to = size(a%corners) == size(b%corners)
if (.not. equal_to) return

equal_to = all(a%centers == b%centers)
if (.not. equal_to) return
equal_to = all(a%corners == b%corners)
end function equal_to

end submodule equal_to_smod
19 changes: 19 additions & 0 deletions geom_mgr/CoordinateAxis/get_centers_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) get_centers_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

centers = this%centers

end function get_centers

end submodule get_centers_smod
37 changes: 37 additions & 0 deletions geom_mgr/CoordinateAxis/get_coordinates_dim_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) get_coordinates_dim_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

integer :: status
class (CoordinateVariable), pointer :: v
class (*), pointer :: ptr(:)

v => file_metadata%get_coordinate_variable(dim_name, _RC)
ptr => v%get_coordinate_data()
_ASSERT(associated(ptr),'coordinate data not allocated')

select type (ptr)
type is (real(kind=REAL64))
coordinates = ptr
type is (real(kind=REAL32))
coordinates = ptr
class default
_FAIL('unsuppoted kind for coordinate data -- must be REAL32 or REAL64')
end select

_RETURN(_SUCCESS)
end function get_coordinates_dim

end submodule get_coordinates_dim_smod
19 changes: 19 additions & 0 deletions geom_mgr/CoordinateAxis/get_corners_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) get_corners_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

corners = this%corners

end function get_corners

end submodule get_corners_smod
64 changes: 64 additions & 0 deletions geom_mgr/CoordinateAxis/get_dim_name_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) get_dim_name_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

integer :: status
type(StringVariableMap), pointer :: vars
type(Variable), pointer :: var
type(StringVariableMapIterator) :: iter
type(StringVector), pointer :: dims
character(:), allocatable :: units_lower_case
character(:), allocatable :: units_found
logical :: has_units
type(Attribute), pointer :: attr
logical :: found
integer :: counter

dim_name = ''
units_lower_case = ESMF_UtilStringLowerCase(units, _RC)
found = .false.
counter = 0

vars => file_metadata%get_variables(_RC)
associate ( e => vars%ftn_end() )
iter = vars%ftn_begin()
do while (iter /= e)
call iter%next()

var => iter%second()
has_units = var%is_attribute_present('units', _RC)
if (.not. has_units) cycle

attr => var%get_attribute('units', _RC)
units_found = attr%get_string(_RC)
units_found = ESMF_UtilStringLowerCase(units_found, _RC)
if (units_found /= units_lower_case) cycle

dims => var%get_dimensions()
if (dims%size() /= 1) cycle

found = .true.
counter = counter + 1
_ASSERT(counter == 1, 'Too many variables match requested units: ' // units)
dim_name = dims%of(1)

end do
end associate
_ASSERT(found, "No variable found with units: " // units//".")

_RETURN(_SUCCESS)
end function get_dim_name

end submodule get_dim_name_smod
20 changes: 20 additions & 0 deletions geom_mgr/CoordinateAxis/get_extent_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) get_extent_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

! 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
extent = size(this%centers)
end function get_extent

end submodule get_extent_smod
39 changes: 39 additions & 0 deletions geom_mgr/CoordinateAxis/is_periodic_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) is_periodic_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

real(kind=R8) :: span, spacing
real(kind=R8), parameter :: tolerance = 0.01

associate (corners => this%corners)
associate (n => size(corners))

if (n == 1) then
is_periodic = .false.
return
end if

span = corners(n) - corners(1)
spacing = corners(2) - corners(1)

if (abs(span - 360) < (tolerance * spacing)) then
is_periodic = .true.
else
is_periodic = .false.
end if

end associate
end associate

end function is_periodic

end submodule is_periodic_smod
21 changes: 21 additions & 0 deletions geom_mgr/CoordinateAxis/new_CoordinateAxis_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) new_CoordinateAxis_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains

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

axis%centers = centers
axis%corners = corners
end function new_CoordinateAxis


end submodule new_CoordinateAxis_smod
18 changes: 18 additions & 0 deletions geom_mgr/CoordinateAxis/not_equal_to_CoordinateAxis.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "MAPL_ErrLog.h"

submodule (mapl3g_CoordinateAxis) not_equal_to_smod
use esmf, only: ESMF_UtilStringLowerCase
use mapl_ErrorHandling
use gftl2_StringVector
use, intrinsic :: iso_fortran_env, only: REAL32, REAL64

contains


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

not_equal_to = .not. (a == b)
end function not_equal_to

end submodule not_equal_to_smod
Loading