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

Bring ExtData2G into develop via optional build argument to cmake #1400

Merged
merged 21 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7291cfe
add ExtData2G with a USE_EXTDATA2G argument to cmake for user request
bena-nasa Feb 28, 2022
1ae16a6
update changelog
bena-nasa Feb 28, 2022
39e3582
more updates for optional use of gocart2g at runtime
bena-nasa Feb 28, 2022
48c77a1
Update gridcomps/Cap/MAPL_CapGridComp.F90
tclune Mar 1, 2022
96b09a9
restore original names so as to not make this non-backwards compatible
bena-nasa Mar 1, 2022
abfa8ed
Merge branch 'feature/bmauer/extdata_2g' of github.com:GEOS-ESM/MAPL …
bena-nasa Mar 1, 2022
e081ccb
more bug fixes...
bena-nasa Mar 1, 2022
eb2a67c
Update gridcomps/ExtData2G/ExtDataDerived.F90
tclune Mar 1, 2022
c8eb526
cleanup cmake file
bena-nasa Mar 2, 2022
6d15be3
Merge branch 'feature/bmauer/extdata_2g' of github.com:GEOS-ESM/MAPL …
bena-nasa Mar 2, 2022
a67a4d1
just get rid of ExtData target
bena-nasa Mar 2, 2022
a4093bf
Merge branch 'develop' into feature/bmauer/extdata_2g
tclune Mar 2, 2022
9f47b91
more changes
bena-nasa Mar 2, 2022
6b5220d
Merge branch 'feature/bmauer/extdata_2g' of github.com:GEOS-ESM/MAPL …
bena-nasa Mar 2, 2022
4e88247
Merge branch 'develop' into feature/bmauer/extdata_2g
mathomp4 Mar 4, 2022
d29d4eb
fix duplicate module name, renamed a bunch of variables for clarify w…
bena-nasa Mar 7, 2022
5e883d0
Merge branch 'feature/bmauer/extdata_2g' of github.com:GEOS-ESM/MAPL …
bena-nasa Mar 7, 2022
a922047
remove a print
bena-nasa Mar 7, 2022
c6fa500
more bug fixes exposed by gcc and cleanup
bena-nasa Mar 8, 2022
0063555
Merge branch 'develop' into feature/bmauer/extdata_2g
bena-nasa Mar 8, 2022
1734aee
Add Yafyaml explicit need to ExtData2G Cmake
mathomp4 Mar 9, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed duration of the clock to be the smaller of the user specified duration and (END_DATE - currTime)

### Added
- New cmake option USE_EXTDATA2G to enable the next generation of ExtData for development, by default uses 1st generation ExtData

- MAPL_ESMFFieldBundleRead/Write modules are now available in when using MAPL

Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ endif()
if(NOT TARGET FARGPARSE::fargparse)
find_package(FARGPARSE QUIET)
endif()
if(NOT TARGET YAFYAML::yafyaml)
find_package(YAFYAML QUIET)

option(USE_EXTDATA2G "Use ExtData2G" ON)
if(USE_EXTDATA2G)
set (EXTDATA2G_TARGET "MAPL.ExtData2G" CACHE STRING "ExtData2G Target")
if(NOT TARGET YAFYAML::yafyaml)
find_package(YAFYAML REQUIRED)
endif()
message (STATUS "Building with ExtData2G")
else()
set (EXTDATA2G_TARGET "" CACHE STRING "ExtData2G Target")
endif()

option(BUILD_WITH_PFLOGGER "Build MAPL with pFlogger library support" ON)
Expand Down
4 changes: 3 additions & 1 deletion MAPL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ esma_set_this()

esma_add_library (${this}
SRCS MAPL.F90
DEPENDENCIES MAPL.base MAPL.generic MAPL.pfio MAPL_cfio_r4 MAPL.gridcomps MAPL.orbit MAPL.griddedio
DEPENDENCIES MAPL.base MAPL.generic MAPL.pfio MAPL_cfio_r4 MAPL.gridcomps MAPL.orbit MAPL.griddedio ${EXTDATA_TARGET}
esmf NetCDF::NetCDF_Fortran MPI::MPI_Fortran
$<$<BOOL:${BUILD_WITH_FLAP}>:FLAP::FLAP>
TYPE ${MAPL_LIBRARY_TYPE}
)

target_compile_definitions (${this} PRIVATE $<$<BOOL:${USE_EXTDATA2G}>:BUILD_WITH_EXTDATA2G>)

target_include_directories (${this} PUBLIC
$<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)
1 change: 0 additions & 1 deletion MAPL/MAPL.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module MAPL
use MAPLBase_mod
use MAPL_GenericMod
use MAPL_VarSpecMiscMod
use MAPL_ExtDataGridCompMod, only: T_EXTDATA_STATE, EXTDATA_WRAP
use ESMF_CFIOMod
use pFIO
use MAPL_GridCompsMod
Expand Down
1 change: 1 addition & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if (BUILD_WITH_FLAP)
target_link_libraries(ExtDataDriver.x PRIVATE OpenMP::OpenMP_Fortran)
endif ()
set_target_properties(ExtDataDriver.x PROPERTIES Fortran_MODULE_DIRECTORY ${MODULE_DIRECTORY})
target_compile_definitions (ExtDataDriver.x PRIVATE $<$<BOOL:${USE_EXTDATA2G}>:BUILD_WITH_EXTDATA2G>)

ecbuild_add_executable (TARGET pfio_MAPL_demo.x SOURCES pfio_MAPL_demo.F90)
target_link_libraries (pfio_MAPL_demo.x PRIVATE MAPL FLAP::FLAP esmf)
Expand Down
21 changes: 16 additions & 5 deletions Tests/ExtDataDriverGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
module ExtData_DriverGridCompMod
use ESMF
use MAPL
use MAPL_ExtDataGridCompMod, only : ExtData_SetServices => SetServices
#if defined(BUILD_WITH_EXTDATA2G)
use MAPL_ExtDataGridComp2G, only : ExtData2G_SetServices => SetServices
#endif
use MAPL_ExtDataGridCompMod, only : ExtData1G_SetServices => SetServices
use MAPL_HistoryGridCompMod, only : Hist_SetServices => SetServices
use MAPL_Profiler, only : get_global_time_profiler, BaseProfiler

Expand Down Expand Up @@ -140,6 +143,7 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)
procedure(), pointer :: root_set_services
type(ExtData_DriverGridComp), pointer :: cap
class(BaseProfiler), pointer :: t_p
logical :: use_extdata2g

_UNUSED_DUMMY(import_state)
_UNUSED_DUMMY(export_state)
Expand Down Expand Up @@ -212,6 +216,7 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)
!EOR
enableTimers = ESMF_UtilStringUpperCase(enableTimers, rc = status)
_VERIFY(status)
call MAPL_GetResource(maplobj,use_extdata2g,"USE_EXTDATA2G:",default=.false.,_RC)

if (enableTimers /= 'YES') then
call MAPL_ProfDisable(rc = status)
Expand Down Expand Up @@ -319,10 +324,16 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)

call MAPL_Set(MAPLOBJ, CF=CAP%CF_EXT, RC=STATUS)
_VERIFY(STATUS)

cap%extdata_id = MAPL_AddChild (MAPLOBJ, name = 'EXTDATA', SS = ExtData_SetServices, rc = status)
_VERIFY(status)

if (use_extdata2g) then
#if defined(BUILD_WITH_EXTDATA2G)
cap%extdata_id = MAPL_AddChild (MAPLOBJ, name = 'EXTDATA', SS = ExtData2G_SetServices, _RC)
#else
_FAIL('ExtData2G requested but not built')
#endif
else
cap%extdata_id = MAPL_AddChild (MAPLOBJ, name = 'EXTDATA', SS = ExtData1G_SetServices, _RC)
end if

end if

! Query MAPL for the the children's for GCS, IMPORTS, EXPORTS
Expand Down
2 changes: 2 additions & 0 deletions base/FileMetadataUtilities.F90
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ subroutine get_time_info(this,startTime,startyear,startmonth,startday,starthour,
allocate(timeVector,source=tVec,stat=status)
_VERIFY(status)
end if
_RETURN(_SUCCESS)

end subroutine get_time_info

Expand Down Expand Up @@ -516,6 +517,7 @@ subroutine get_coordinate_info(this,coordinate_name,coordSize,coordUnits,coords,
_ASSERT(.false.,"unsupported coordel variable type")
end select
end if
_RETURN(_SUCCESS)

end subroutine get_coordinate_info

Expand Down
3 changes: 3 additions & 0 deletions gridcomps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ add_subdirectory(Cap)
add_subdirectory(History)
add_subdirectory(Orbit)
add_subdirectory(ExtData)
if(USE_EXTDATA2G)
add_subdirectory(ExtData2G)
endif()
5 changes: 4 additions & 1 deletion gridcomps/Cap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ set (srcs
MAPL_CapGridComp.F90
MAPL_NUOPCWrapperMod.F90
CapOptions.F90
ExternalGCStorage.F90
)
if (BUILD_WITH_FLAP)
list (APPEND srcs FlapCLI.F90)
endif()


esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL.shared MAPL.constants MAPL.base MAPL.profiler MAPL.history
MAPL.ExtData TYPE ${MAPL_LIBRARY_TYPE})
MAPL.ExtData ${EXTDATA2G_TARGET} TYPE ${MAPL_LIBRARY_TYPE})
target_link_libraries (${this} PUBLIC GFTL::gftl GFTL_SHARED::gftl-shared esmf NetCDF::NetCDF_Fortran
PRIVATE MPI::MPI_Fortran $<$<BOOL:${BUILD_WITH_FLAP}>:FLAP::FLAP>)

target_compile_definitions (${this} PRIVATE $<$<BOOL:${USE_EXTDATA2G}>:BUILD_WITH_EXTDATA2G>)

# CMake has an OpenMP issue with NAG Fortran: https://gitlab.kitware.com/cmake/cmake/-/issues/21280
if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
target_link_libraries(${this} PRIVATE OpenMP::OpenMP_Fortran)
Expand Down
14 changes: 14 additions & 0 deletions gridcomps/Cap/ExternalGCStorage.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module MAPL_ExternalGCStorage
use esmf
implicit none

type t_extdata_state
type(ESMF_State) :: expState
type(ESMF_GridComp) :: gc
end type t_extdata_state

type extdata_wrap
type (t_extdata_state), pointer :: PTR
end type extdata_wrap

end module MAPL_ExternalGCStorage
25 changes: 19 additions & 6 deletions gridcomps/Cap/MAPL_CapGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ module MAPL_CapGridCompMod
use MAPL_ShmemMod
use MAPL_HistoryGridCompMod, only : Hist_SetServices => SetServices
use MAPL_HistoryGridCompMod, only : HISTORY_ExchangeListWrap
use MAPL_ExtDataGridCompMod, only : ExtData_SetServices => SetServices
use MAPL_ExtDataGridCompMod, only : T_EXTDATA_STATE, EXTDATA_WRAP
#if defined(BUILD_WITH_EXTDATA2G)
use MAPL_ExtDataGridComp2G, only : ExtData2G_SetServices => SetServices
#endif
use MAPL_ExtDataGridCompMod, only : ExtData1G_SetServices => SetServices
use MAPL_ConfigMod
use MAPL_DirPathMod
use MAPL_KeywordEnforcerMod
Expand All @@ -28,6 +30,7 @@ module MAPL_CapGridCompMod
use gFTL_StringVector
use pflogger, only: logging, Logger
use MAPL_TimeUtilsMod, only: is_valid_time, is_valid_date
use MAPL_ExternalGCStorage

use iso_fortran_env

Expand Down Expand Up @@ -173,8 +176,8 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)

integer :: status

type (T_ExtData_STATE), pointer :: ExtData_internal_state => null()
type (ExtData_wrap) :: wrap
type (t_extdata_state), pointer :: ExtData_internal_state => null()
type (extdata_wrap) :: wrap


character(len=ESMF_MAXSTR ) :: timerModeStr
Expand Down Expand Up @@ -210,6 +213,7 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)
class(BaseProfiler), pointer :: t_p
class(Logger), pointer :: lgr
type(ESMF_Clock) :: cap_clock
logical :: use_extdata2g

_UNUSED_DUMMY(import_state)
_UNUSED_DUMMY(export_state)
Expand Down Expand Up @@ -399,6 +403,7 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)
!EOR
enableTimers = ESMF_UtilStringUpperCase(enableTimers, rc = status)
_VERIFY(status)
call MAPL_GetResource(maplobj,use_extdata2g,"USE_EXTDATA2G:",default=.false.,_RC)

if (enableTimers /= 'YES') then
call MAPL_ProfDisable(rc = status)
Expand Down Expand Up @@ -566,8 +571,16 @@ subroutine initialize_gc(gc, import_state, export_state, clock, rc)
call MAPL_Set(MAPLOBJ, CF=CAP%CF_EXT, RC=STATUS)
_VERIFY(STATUS)

cap%extdata_id = MAPL_AddChild (MAPLOBJ, name = 'EXTDATA', SS = ExtData_SetServices, rc = status)
_VERIFY(status)
if (use_extdata2g) then
#if defined(BUILD_WITH_EXTDATA2G)
cap%extdata_id = MAPL_AddChild (MAPLOBJ, name = 'EXTDATA', SS = ExtData2G_SetServices, _RC)
#else
call lgr%error('ExtData2G requested but not built')
_FAIL('ExtData2G requested but not built')
#endif
else
cap%extdata_id = MAPL_AddChild (MAPLOBJ, name = 'EXTDATA', SS = ExtData1G_SetServices, _RC)
end if
call t_p%stop('SetService')

! Add NX and NY from AGCM.rc to ExtData.rc as well as name of ExtData rc file
Expand Down
13 changes: 0 additions & 13 deletions gridcomps/ExtData/ExtDataGridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ MODULE MAPL_ExtDataGridCompMod
! !PUBLIC MEMBER FUNCTIONS:

PUBLIC SetServices
public T_EXTDATA_STATE
public EXTDATA_WRAP
!EOP
!
! !REVISION HISTORY:
Expand Down Expand Up @@ -212,17 +210,6 @@ MODULE MAPL_ExtDataGridCompMod
type (MAPL_ExtData_State), pointer :: PTR => null()
end type MAPL_ExtData_WRAP

type T_EXTDATA_STATE
type(ESMF_State) :: expState
type(ESMF_GridComp) :: gc
end type T_EXTDATA_STATE

! Wrapper for extracting internal state
! -------------------------------------
type EXTDATA_WRAP
type (T_EXTDATA_STATE), pointer :: PTR
end type EXTDATA_WRAP

class(Logger), pointer :: lgr


Expand Down
32 changes: 32 additions & 0 deletions gridcomps/ExtData2G/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
esma_set_this (OVERRIDE MAPL.ExtData2G)

set (srcs
ExtDataFileStream.F90
ExtDataRule.F90
ExtDataDerived.F90
ExtDataConfig.F90
ExtDataGridCompNG.F90
TimeStringConversion.F90
ExtDataTypeDef.F90
ExtDataOldTypesCreator.F90
ExtDataBracket.F90
ExtDataUpdatePointer.F90
ExtDataAbstractFileHandler.F90
ExtDataClimFileHandler.F90
ExtDataSimpleFileHandler.F90
ExtDataNode.F90
ExtDataLgr.F90
ExtDataConstants.F90
ExtDataSample.F90
ExtData_IOBundleMod.F90
ExtData_IOBundleVectorMod.F90
)


esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL.shared MAPL.base MAPL.generic MAPL.griddedio TYPE SHARED)
target_link_libraries (${this} PUBLIC GFTL::gftl GFTL_SHARED::gftl-shared YAFYAML::yafyaml esmf NetCDF::NetCDF_Fortran
PRIVATE MPI::MPI_Fortran)
target_include_directories (${this} PUBLIC ${INC_ESMF} ${INC_NETCDF}
$<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)

set_target_properties (${this} PROPERTIES Fortran_MODULE_DIRECTORY ${include_${this}})
Loading