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

Revist the creation of submodules in geom_mgr #2834

Merged
merged 1 commit into from
May 17, 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
14 changes: 14 additions & 0 deletions geom_mgr/GeomManager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ module mapl3g_GeomManager
procedure new_GeomManager
end interface GeomManager

abstract interface
logical function I_FactoryPredicate(factory)
import GeomFactory
class(GeomFactory), intent(in) :: factory
end function I_FactoryPredicate
end interface

interface
module function new_GeomManager() result(mgr)
type(GeomManager) :: mgr
Expand Down Expand Up @@ -172,6 +179,13 @@ end function get_geom_from_id
module function get_geom_manager() result(geom_mgr)
type(GeomManager), pointer :: geom_mgr
end function get_geom_manager

module function find_factory(factories, predicate, rc) result(factory)
class(GeomFactory), pointer :: factory
type(GeomFactoryVector), pointer, intent(in) :: factories ! Force TARGET attr on actual
procedure(I_FactoryPredicate) :: predicate
integer, optional, intent(out) :: rc
end function find_factory
end interface

end module mapl3g_GeomManager
1 change: 1 addition & 0 deletions geom_mgr/GeomManager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_sources(MAPL.geom_mgr PRIVATE
get_mapl_geom_from_id.F90
get_mapl_geom_from_spec.F90
add_mapl_geom.F90
find_factory.F90
make_geom_spec_from_metadata.F90
make_geom_spec_from_hconfig.F90
make_mapl_geom_from_spec.F90
Expand Down
19 changes: 1 addition & 18 deletions geom_mgr/GeomManager/add_factory.F90
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) add_factory_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

abstract interface
logical function I_FactoryPredicate(factory)
import GeomFactory
class(GeomFactory), intent(in) :: factory
end function I_FactoryPredicate
end interface

contains

module subroutine add_factory(this, factory)
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/add_mapl_geom.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) add_mapl_geom_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/delete_mapl_geom.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) delete_mapl_geom_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
34 changes: 34 additions & 0 deletions geom_mgr/GeomManager/find_factory.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) find_factory_smod

implicit none

! abstract interface
! logical function I_FactoryPredicate(factory)
! import GeomFactory
! class(GeomFactory), intent(in) :: factory
! end function I_FactoryPredicate
! end interface

contains

! If factory not found, return a null pointer _and_ a nonzero rc.
module function find_factory(factories, predicate, rc) result(factory)
class(GeomFactory), pointer :: factory
type(GeomFactoryVector), pointer, intent(in) :: factories ! Force TARGET attr on actual
procedure(I_FactoryPredicate) :: predicate
integer, optional, intent(out) :: rc

integer :: status
type(GeomFactoryVectorIterator) :: iter

factory => null()
iter = find_if(factories%begin(), factories%end(), predicate)
_ASSERT(iter /= factories%end(), "No factory found satisfying given predicate.")
factory => iter%of()

_RETURN(_SUCCESS)
end function find_factory

end submodule find_factory_smod
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/get_geom_from_id.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) get_geom_from_id_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/get_mapl_geom_from_hconfig.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) get_mapl_geom_from_hconfig_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/get_mapl_geom_from_id.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) get_mapl_geom_from_id_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/get_mapl_geom_from_metadata.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) get_mapl_geom_from_metadata_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/get_mapl_geom_from_spec.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) get_mapl_geom_from_spec_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/initialize.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) initialize_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
37 changes: 1 addition & 36 deletions geom_mgr/GeomManager/make_geom_spec_from_hconfig.F90
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) make_geom_spec_from_hconfig_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

abstract interface
logical function I_FactoryPredicate(factory)
import GeomFactory
class(GeomFactory), intent(in) :: factory
end function I_FactoryPredicate
end interface

contains

! If factory not found, return a null pointer _and_ a nonzero rc.
function find_factory(factories, predicate, rc) result(factory)
class(GeomFactory), pointer :: factory
type(GeomFactoryVector), pointer, intent(in) :: factories ! Force TARGET attr on actual
procedure(I_FactoryPredicate) :: predicate
integer, optional, intent(out) :: rc

integer :: status
type(GeomFactoryVectorIterator) :: iter

factory => null()
iter = find_if(factories%begin(), factories%end(), predicate)
_ASSERT(iter /= factories%end(), "No factory found satisfying given predicate.")
factory => iter%of()

_RETURN(_SUCCESS)
end function find_factory

module function make_geom_spec_from_hconfig(this, hconfig, rc) result(geom_spec)
class(GeomSpec), allocatable :: geom_spec
class(GeomManager), target, intent(inout) :: this
Expand Down
37 changes: 1 addition & 36 deletions geom_mgr/GeomManager/make_geom_spec_from_metadata.F90
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) make_geom_spec_from_metadata_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

abstract interface
logical function I_FactoryPredicate(factory)
import GeomFactory
class(GeomFactory), intent(in) :: factory
end function I_FactoryPredicate
end interface

contains

! If factory not found, return a null pointer _and_ a nonzero rc.
function find_factory(factories, predicate, rc) result(factory)
class(GeomFactory), pointer :: factory
type(GeomFactoryVector), pointer, intent(in) :: factories ! Force TARGET attr on actual
procedure(I_FactoryPredicate) :: predicate
integer, optional, intent(out) :: rc

integer :: status
type(GeomFactoryVectorIterator) :: iter

factory => null()
iter = find_if(factories%begin(), factories%end(), predicate)
_ASSERT(iter /= factories%end(), "No factory found satisfying given predicate.")
factory => iter%of()

_RETURN(_SUCCESS)
end function find_factory

module function make_geom_spec_from_metadata(this, file_metadata, rc) result(geom_spec)
class(GeomSpec), allocatable :: geom_spec
class(GeomManager), target, intent(inout) :: this
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/make_mapl_geom_from_spec.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) make_mapl_geom_from_spec_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down
12 changes: 1 addition & 11 deletions geom_mgr/GeomManager/new_GeomManager.F90
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#include "MAPL_Generic.h"

submodule (mapl3g_GeomManager) new_GeomManager_smod
use mapl3g_GeomSpec
use mapl3g_NullGeomSpec
use mapl3g_MaplGeom
use mapl3g_GeomFactory
use mapl3g_GeomFactoryVector
use mapl3g_GeomSpecVector
use mapl3g_IntegerMaplGeomMap
use mapl_ErrorHandlingMod
use pfio_FileMetadataMod
use esmf
use gftl2_IntegerVector

implicit none

contains
Expand Down