Skip to content

Commit

Permalink
Baby steps towards oomph.
Browse files Browse the repository at this point in the history
  - Partial refactoring of old VarConnPoint.
  - Introduced gFTL VarConnVector
  - Split types into separate files.
    It can be hard to find the definitions of types when they are not
    tied to an obvious module/file.  This is particularly true in
    light of some recent refactorings that left chaos in their wake.
    Current MAPL style guidelines points to a natural solution.
  - Introduced fine-grained specs.

    . Legacy VarSpecType has a long laundry list of components.  Some
      rarely used; some never used. And worse, some that no one even
      recalls what they are for.

    . New specs are more targeted and hierarchical.  E.g., DimsSpec
      has spec components for horizontal, vertical, and ungridded
      dimensions.

    . Mostl likely these new specs will be just "structs" with no
      methods.  But at least one component (possibly otherwise unused)
      should remain private to prevent use of default constructors.

    . Legacy VarSpecType now has a FieldSpec component that is
      initialized during the VarSpecType component.

  - Consolidated new files in ./oomph
  - Also changed namespace to "oomph" from "mapl.
  • Loading branch information
tclune committed Oct 26, 2021
1 parent 0d0d68c commit e071566
Show file tree
Hide file tree
Showing 30 changed files with 2,888 additions and 2,425 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- OOMPH
- Introduced new oomph subdirectory
- Modified old MAPL_VarConnPoint to use new ConnectionPoint (partial).
- Introduced gFTL vector to replace CONN ptr arrays.
- Split types into separate files.


- Moved newcfio modules from base into new griddedio directory
- Renamed newCFIO modules and routines to GriddedIO
- Refactored ExtData modules. Because of the dependencies, the following changes were also done:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ add_subdirectory (MAPL_cfio MAPL_cfio_r8)
add_subdirectory (pfio)
add_subdirectory (profiler)
add_subdirectory (generic)
add_subdirectory (oomph) # temporary - will rename to generic when done
add_subdirectory (shared)
add_subdirectory (include)
add_subdirectory (base)
Expand Down
2 changes: 1 addition & 1 deletion MAPL/MAPL.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module MAPL
use MAPLBase_mod
use MAPL_GenericMod
use MAPL_VarSpecMod
use MAPL_VarSpecMiscMod
use MAPL_ExtDataGridCompMod, only: T_EXTDATA_STATE, EXTDATA_WRAP
use ESMF_CFIOMod
use pFIO
Expand Down
19 changes: 17 additions & 2 deletions generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ set (srcs
DecoratorComponent.F90
StubComponent.F90

# Specs
VarSpecType.F90
VarSpec.F90
VarSpecPtr.F90
VarConnPoint.F90
VarConnType.F90
VariableSpecification.F90
VarSpecMiscMod.F90
VarSpecVector.F90
MAPL_VarSpecMod.F90
VarConnPoint.F90
VarConnType.F90
VarConnVector.F90
VarConn.F90
StateSpecification.F90
ComponentSpecification.F90
MAPL_ServiceConnectionItemVector.F90
Expand All @@ -43,7 +53,12 @@ endif ()
find_package(GFTL REQUIRED)
find_package(GFTL_SHARED REQUIRED)

esma_add_library(${this} SRCS ${srcs} DEPENDENCIES MAPL.shared MAPL.profiler MAPL.base PFLOGGER::pflogger GFTL_SHARED::gftl-shared GFTL::gftl TYPE ${MAPL_LIBRARY_TYPE})
esma_add_library(${this}
SRCS ${srcs}
DEPENDENCIES MAPL.oomph MAPL.shared MAPL.profiler MAPL.base
PFLOGGER::pflogger GFTL_SHARED::gftl-shared-v2 GFTL_SHARED::gftl-shared-v1 GFTL::gftl
TYPE ${MAPL_LIBRARY_TYPE}
)
target_include_directories (${this} PUBLIC
$<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)
target_link_libraries (${this} PUBLIC esmf NetCDF::NetCDF_Fortran)
Expand Down
2 changes: 1 addition & 1 deletion generic/GenericCplComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module MAPL_GenericCplCompMod
use MAPL_CommsMod
use MAPL_ProfMod
use MAPL_SunMod
use MAPL_VarSpecMod
use MAPL_VarSpecMiscMod
use MAPL_ExceptionHandling

implicit none
Expand Down
137 changes: 72 additions & 65 deletions generic/MAPL_Generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ module MAPL_GenericMod
use MAPL_Constants
use MAPL_SunMod
use mapl_MaplGrid
use mapl_VarSpecMod
use MaplGeneric
use MAPL_GenericCplCompMod
use MAPL_LocStreamMod
Expand Down Expand Up @@ -298,7 +299,6 @@ module MAPL_GenericMod
module procedure MAPL_AddConnectivityRename
module procedure MAPL_AddConnectivityRenameMany
module procedure MAPL_AddConnectivityMany
! module procedure MAPL_AddConnectivityOld
end interface

interface MAPL_GridCompGetFriendlies
Expand Down Expand Up @@ -365,8 +365,8 @@ module MAPL_GenericMod


type MAPL_Connectivity
type (MAPL_VarConn), pointer :: CONNECT(:) => null()
type (MAPL_VarConn), pointer :: DONOTCONN(:) => null()
type (VarConn) :: CONNECT
type (VarConn) :: DONOTCONN
type (ServiceConnectionItemVector) :: ServiceConnectionItems
end type MAPL_Connectivity

Expand Down Expand Up @@ -448,7 +448,7 @@ module MAPL_GenericMod
contains

procedure :: get_ith_child

procedure :: get_child_idx
procedure :: get_child_gridcomp
procedure :: get_child_import_state
procedure :: get_child_export_state
Expand Down Expand Up @@ -551,7 +551,7 @@ recursive subroutine MAPL_GenericSetServices ( GC, RC )
type(ESMF_State), pointer :: STATE
type(ESMF_VM) :: VM

type (MAPL_VarConn), pointer :: CONNECT(:)
type (VarConn), pointer :: CONNECT
type (MAPL_VarSpec), pointer :: IM_SPECS(:)
type (MAPL_VarSpec), pointer :: EX_SPECS(:)
type (MAPL_VarSpecPtr), pointer :: ImSpecPtr(:)
Expand Down Expand Up @@ -632,7 +632,7 @@ recursive subroutine MAPL_GenericSetServices ( GC, RC )
ExSpecPtr(I)%Spec => EX_SPECS
END DO

call MAPL_ConnCheckReq(CONNECT, ImSpecPtr, ExSpecPtr, rc=status)
call connect%checkReq(ImSpecPtr, ExSpecPtr, rc=status)
_VERIFY(STATUS)

deallocate (ImSpecPtr, ExSpecPtr)
Expand Down Expand Up @@ -3373,6 +3373,8 @@ end subroutine MAPL_StateAddExportSpec_
!BOPI
! !IIROUTINE: MAPL_StateAddExportSpecFrmChld --- Add \texttt{EXPORT} spec from child

! This is an odd procedure in that it not only adds an export spec, it also adds
! a connectivity.
!INTERFACE:
subroutine MAPL_StateAddExportSpecFrmChld ( GC, SHORT_NAME, CHILD_ID, RC, TO_NAME )

Expand All @@ -3386,18 +3388,44 @@ subroutine MAPL_StateAddExportSpecFrmChld ( GC, SHORT_NAME, CHILD_ID, RC, TO_NAM
!EOPI

character(len=ESMF_MAXSTR), parameter :: IAm="MAPL_StateAddExportSpecFrmChld"
integer :: STATUS
integer :: status
type(MAPL_MetaComp), pointer :: maplobj


call MAPL_InternalStateRetrieve(gc, maplobj, _RC)
call MAPL_StateAddExportSpecFrmChldName(gc, short_name, maplobj%gcnamelist(child_id), _RC)

_RETURN(ESMF_SUCCESS)
end subroutine MAPL_StateAddExportSpecFrmChld

!BOPI
! !IIROUTINE: MAPL_StateAddExportSpecFrmChld --- Add \texttt{EXPORT} spec from child

!INTERFACE:
subroutine MAPL_StateAddExportSpecFrmChldName ( GC, short_name, child_name, rc )

!ARGUMENTS:
type(ESMF_GridComp), intent(INOUT) :: GC
character (len=*) , intent(IN) :: short_name
character(*), intent(in) :: child_name
integer , optional , intent(OUT) :: rc
!EOPI

character(len=ESMF_MAXSTR), parameter :: IAm="MAPL_StateAddExportSpecFrmChld"
integer :: child_id
integer :: status
type(MAPL_MetaComp), pointer :: maplobj

call MAPL_InternalStateRetrieve(gc, maplobj, _RC)
child_id = maplobj%get_child_idx(child_name)

call MAPL_AddConnectivityE2E ( GC, SHORT_NAME, &
TO_NAME = TO_NAME, &
SRC_ID = CHILD_ID, &
TO_EXPORT = MAPL_Self, RC=STATUS )
_VERIFY(STATUS)

TO_EXPORT = MAPL_Self, _RC)

_RETURN(ESMF_SUCCESS)
end subroutine MAPL_StateAddExportSpecFrmChld
end subroutine MAPL_StateAddExportSpecFrmChldName


!BOPI
Expand Down Expand Up @@ -4922,34 +4950,6 @@ end function MAPL_AddChildFromDSO



subroutine MAPL_AddConnectivityOld ( GC, SHORT_NAME, TO_NAME, &
FROM_IMPORT, FROM_EXPORT, TO_IMPORT, TO_EXPORT, RC )

type(ESMF_GridComp), intent(INOUT) :: GC ! Gridded component
character (len=*) , intent(IN ) :: SHORT_NAME
character (len=*), optional, intent(IN ) :: TO_NAME
integer, optional, intent(IN ) :: FROM_IMPORT
integer, optional, intent(IN ) :: FROM_EXPORT
integer, optional, intent(IN ) :: TO_IMPORT
integer, optional, intent(IN ) :: TO_EXPORT
integer, optional, intent( OUT) :: RC ! Error code:

character(len=ESMF_MAXSTR), parameter :: IAm="MAPL_AddConnectivity"
integer :: STATUS
type (MAPL_Connectivity), pointer :: conn


call MAPL_ConnectivityGet(gc, connectivityPtr=conn, RC=status)
_VERIFY(STATUS)

call MAPL_VarConnCreate(CONN%CONNECT, SHORT_NAME, TO_NAME=TO_NAME, &
FROM_IMPORT=FROM_IMPORT, FROM_EXPORT=FROM_EXPORT, &
TO_IMPORT =TO_IMPORT, TO_EXPORT =TO_EXPORT, RC=STATUS )
_VERIFY(STATUS)

_RETURN(ESMF_SUCCESS)
end subroutine MAPL_AddConnectivityOld

subroutine MAPL_AddConnectivityE2E ( GC, SHORT_NAME, &
SRC_ID, TO_EXPORT, TO_NAME, RC )

Expand All @@ -4964,14 +4964,10 @@ subroutine MAPL_AddConnectivityE2E ( GC, SHORT_NAME, &
integer :: STATUS
type (MAPL_Connectivity), pointer :: conn

call MAPL_ConnectivityGet(gc, connectivityPtr=conn, RC=status)
_VERIFY(STATUS)
call MAPL_ConnectivityGet(gc, connectivityPtr=conn, _RC)

call MAPL_VarConnCreate(CONN%CONNECT, SHORT_NAME, &
TO_NAME = TO_NAME, &
FROM_EXPORT=SRC_ID, &
TO_EXPORT=TO_EXPORT, RC=STATUS )
_VERIFY(STATUS)
call conn%connect%append(SHORT_NAME, TO_NAME=TO_NAME, &
FROM_EXPORT=SRC_ID, TO_IMPORT=TO_EXPORT, _RC)

_RETURN(ESMF_SUCCESS)
end subroutine MAPL_AddConnectivityE2E
Expand Down Expand Up @@ -5004,9 +5000,8 @@ subroutine MAPL_AddConnectivityRename ( GC, SRC_NAME, SRC_ID, &
call MAPL_ConnectivityGet(gc, connectivityPtr=conn, RC=status)
_VERIFY(STATUS)

call MAPL_VarConnCreate(CONN%CONNECT, SHORT_NAME=SRC_NAME, TO_NAME=DST_NAME, &
FROM_EXPORT=SRC_ID, TO_IMPORT=DST_ID, RC=STATUS )
_VERIFY(STATUS)
call CONN%CONNECT%append(SHORT_NAME=SRC_NAME, TO_NAME=DST_NAME, &
FROM_EXPORT=SRC_ID, TO_IMPORT=DST_ID, _RC)

_RETURN(ESMF_SUCCESS)
end subroutine MAPL_AddConnectivityRename
Expand Down Expand Up @@ -5093,9 +5088,7 @@ subroutine MAPL_DoNotConnect ( GC, SHORT_NAME, CHILD, RC )
call MAPL_ConnectivityGet(gc, connectivityPtr=conn, RC=status)
_VERIFY(STATUS)

call MAPL_VarConnCreate(CONN%DONOTCONN, SHORT_NAME, &
FROM_IMPORT=CHILD, RC=STATUS )
_VERIFY(STATUS)
call CONN%DONOTCONN%append(SHORT_NAME, TO_IMPORT=CHILD, _RC)


_RETURN(ESMF_SUCCESS)
Expand Down Expand Up @@ -5174,7 +5167,7 @@ subroutine MAPL_TerminateImportAllBut ( GC, SHORT_NAMES, CHILD_IDS, RC )
logical :: SKIP
character(len=ESMF_MAXSTR), allocatable :: SNAMES(:)
type (MAPL_Connectivity), pointer :: conn
type (MAPL_VarConn), pointer :: CONNECT(:)
type (VarConn), pointer :: CONNECT
logical :: isConnected
type(ESMF_GridComp), pointer :: gridcomp

Expand All @@ -5196,7 +5189,7 @@ subroutine MAPL_TerminateImportAllBut ( GC, SHORT_NAMES, CHILD_IDS, RC )
_VERIFY(STATUS)
do J=1 ,size(META_CHILD%component_spec%import%old_var_specs)
call MAPL_VarSpecGet(META_CHILD%component_spec%import%old_var_specs(J),SHORT_NAME=SHORT_NAME,RC=STATUS)
isConnected = MAPL_VarIsConnected(connect,short_name,I,rc=status)
isConnected = connect%varIsConnected(short_name,I,rc=status)
SKIP = ANY(SNAMES==TRIM(SHORT_NAME)) .and. (ANY(CHILD_IDS==I))
if ((.not.isConnected) .and. (.not.skip)) then
call MAPL_DoNotConnect(GC, SHORT_NAME, I, RC=status)
Expand Down Expand Up @@ -7030,8 +7023,8 @@ recursive subroutine MAPL_WireComponent(GC, RC)
logical :: SATISFIED
logical :: PARENTIMPORT
type (MAPL_Connectivity), pointer :: conn
type (MAPL_VarConn), pointer :: CONNECT(:)
type (MAPL_VarConn), pointer :: DONOTCONN(:)
type (VarConn), pointer :: CONNECT
type (VarConn), pointer :: DONOTCONN
type(ESMF_GridComp), pointer :: gridcomp
! Begin

Expand Down Expand Up @@ -7089,8 +7082,8 @@ recursive subroutine MAPL_WireComponent(GC, RC)

do K=1,size(EX_SPECS)
call MAPL_VarSpecGet(EX_SPECS(K), SHORT_NAME=SHORT_NAME, RC=STATUS)
if (MAPL_VarIsConnected(CONNECT, SHORT_NAME=SHORT_NAME, &
FROM_EXPORT=I, TO_EXPORT=MAPL_Self, &
if (connect%varIsConnected(IMPORT_NAME=SHORT_NAME, &
export=I, import=MAPL_Self, &
RC=STATUS)) then

_VERIFY(STATUS)
Expand All @@ -7113,7 +7106,7 @@ recursive subroutine MAPL_WireComponent(GC, RC)

! check "do not connect" list for
PARENTIMPORT = .true.
if (MAPL_VarIsListed(DONOTCONN, SHORT_NAME="MAPL_AnyChildImport", &
if (DONOTCONN%varIsListed(SHORT_NAME="MAPL_AnyChildImport", &
IMPORT=I, RC=STATUS)) then
_VERIFY(STATUS)
PARENTIMPORT = .false.
Expand Down Expand Up @@ -7141,7 +7134,7 @@ recursive subroutine MAPL_WireComponent(GC, RC)
#endif

! check "do not connect" list
if (MAPL_VarIsListed(DONOTCONN, SHORT_NAME=SHORT_NAME, &
if (DONOTCONN%varIsListed(SHORT_NAME=SHORT_NAME, &
IMPORT=I, RC=STATUS)) then
_VERIFY(STATUS)
cycle
Expand All @@ -7157,7 +7150,7 @@ recursive subroutine MAPL_WireComponent(GC, RC)
do J=1,NC
if(I==J) cycle
! then check if this is internally satisfied
if (MAPL_VarIsConnected(CONNECT, IMPORT_NAME=SHORT_NAME, &
if (connect%varIsConnected(IMPORT_NAME=SHORT_NAME, &
IMPORT=I, EXPORT=J, RC=STATUS)) then

_VERIFY(STATUS)
Expand All @@ -7183,8 +7176,7 @@ recursive subroutine MAPL_WireComponent(GC, RC)


! then check if this is internally satisfied
if (MAPL_VarIsConnected(CONNECT, &
IMPORT_NAME=SHORT_NAME, EXPORT_NAME=ENAME, &
if (connect%varIsConnected(IMPORT_NAME=SHORT_NAME, EXPORT_NAME=ENAME, &
IMPORT=I, EXPORT=J, RC=STATUS)) then
! If a match is found, add it to that coupler's src and dst specs
! ?? Mark the import satisfied and the export needed.
Expand Down Expand Up @@ -8345,12 +8337,12 @@ recursive subroutine MAPL_GenericConnCheck(GC, RC)
conn => state%connectList

err = .false.
if (.not. MAPL_ConnCheckUnused(CONN%CONNECT)) then
if (.not. conn%connect%checkUnused()) then
err = .true.
CALL WRITE_PARALLEL("CONNECT ERRORS FOUND in " // trim(COMP_NAME))
end if

if (.not. MAPL_ConnCheckUnused(CONN%DONOTCONN)) then
if (.not. CONN%DONOTCONN%checkUnused()) then
err = .true.
CALL WRITE_PARALLEL("DO_NOT_CONNECT ERRORS FOUND in " // trim(COMP_NAME))
end if
Expand Down Expand Up @@ -11371,6 +11363,21 @@ function get_ith_child(this, i) result(child)

end function get_ith_child

integer function get_child_idx(this, child_name) result(idx)
class(MAPL_MetaComp), target, intent(in) :: this
character(*), intent(in) :: child_name

integer :: i

idx = -1
do i = 1, this%get_num_children()
if (this%gcnamelist(i) == trim(child_name)) then
idx = i
return
end if
end do
end function get_child_idx



function get_child_gridcomp(this, i) result(gridcomp)
Expand Down
Loading

0 comments on commit e071566

Please sign in to comment.