Skip to content

Commit

Permalink
Add CDEPS to UFS-weather-model for Data component needs (NOAA-EMC#524)
Browse files Browse the repository at this point in the history
* point to Jun fv3atm personal fork
* add CDEPS submodule
* add building instructions
* fix issues that came from building
* builds CDEPS targets
* missed w3nco dep
* cleanup use of FoX and remove redundant library links in components
* Add 3 files generated by genf90.pl to the CDEPS-interface/ufs directory. (#1)
* remove dependency on genf90.pl for CDEPS/share
* remove FoX (#2)
remove FoX dependency building and use ESMF Config instead.
Co-authored-by: Jun Wang <[email protected]>
Co-authored-by: BinLi-NOAA <[email protected]>
Co-authored-by: Brian Curtis <[email protected]>
  • Loading branch information
aerorahul committed Apr 16, 2021
1 parent 65f5341 commit 75f1fc5
Show file tree
Hide file tree
Showing 19 changed files with 12,677 additions and 1,698 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
path = DATM
url = https://github.com/NOAA-EMC/NEMSdatm
branch = develop
[submodule "CDEPS"]
path = CDEPS-interface/CDEPS
url = https://github.com/NOAA-EMC/CDEPS
branch = emc/develop
1 change: 1 addition & 0 deletions CDEPS-interface/CDEPS
Submodule CDEPS added at 69a3a6
137 changes: 137 additions & 0 deletions CDEPS-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# CDEPS compiler flags
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_Fortran_FLAGS "-g -fbacktrace -ffree-line-length-none")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fcheck=bounds -ffpe-trap=invalid,zero,overflow,underflow" )
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "-g -traceback")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O -assume realloc_lhs")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -fp-model precise")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check -check noarg_temp_created -check nopointer -fpe0 -ftrapuv")
else()
message(WARNING "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options")
endif()

# Too many files to list, so include them via this file
include("cdeps_files.cmake")

# CDEPS/share
add_library(share STATIC ${cdeps_share_files} ${ufs_cdeps_share_files})
add_library(cdeps::share ALIAS share)
set_target_properties(share PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(share PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ufs/cdeps_share)
target_include_directories(share PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(share PUBLIC esmf)
list(APPEND LIB_TARGETS share)

# CDEPS/streams
add_library(streams STATIC ${cdeps_streams_files})
add_library(cdeps::streams ALIAS streams)
add_dependencies(streams cdeps::share)
set_target_properties(streams PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(streams PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_compile_definitions(streams PUBLIC "DISABLE_FoX")
target_link_libraries(streams PUBLIC cdeps::share)
target_link_libraries(streams PUBLIC esmf PIO::PIO_Fortran)
list(APPEND LIB_TARGETS streams)

# CDEPS/dshr
add_library(dshr STATIC ${cdeps_dshr_files})
add_library(cdeps::dshr ALIAS dshr)
add_dependencies(dshr cdeps::share cdeps::streams)
set_target_properties(dshr PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dshr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(dshr PUBLIC cdeps::share cdeps::streams)
target_link_libraries(dshr PUBLIC esmf PIO::PIO_Fortran)
list(APPEND LIB_TARGETS dshr)

# CDEPS/datm
add_library(datm STATIC ${cdeps_datm_files})
add_library(cdeps::datm ALIAS datm)
add_dependencies(datm cdeps::share cdeps::streams cdeps::dshr)
set_target_properties(datm PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(datm PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(datm PUBLIC cdeps::dshr cdeps::share cdeps::streams)
target_link_libraries(datm PUBLIC esmf PIO::PIO_Fortran)
list(APPEND LIB_TARGETS datm)

# CDEPS/dice
add_library(dice STATIC ${cdeps_dice_files})
add_library(cdeps::dice ALIAS dice)
add_dependencies(dice cdeps::share cdeps::streams cdeps::dshr)
set_target_properties(dice PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dice PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(dice PUBLIC cdeps::dshr cdeps::share cdeps::streams)
target_link_libraries(dice PUBLIC esmf)
list(APPEND LIB_TARGETS dice)

# CDEPS/dlnd
add_library(dlnd STATIC ${cdeps_dlnd_files})
add_library(cdeps::dlnd ALIAS dlnd)
add_dependencies(dlnd cdeps::share cdeps::streams cdeps::dshr)
set_target_properties(dlnd PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dlnd PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(dlnd PUBLIC cdeps::dshr cdeps::share cdeps::streams)
target_link_libraries(dlnd PUBLIC esmf)
list(APPEND LIB_TARGETS dlnd)

# CDEPS/docn
add_library(docn STATIC ${cdeps_docn_files})
add_library(cdeps::docn ALIAS docn)
add_dependencies(docn cdeps::share cdeps::streams cdeps::dshr)
set_target_properties(docn PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(docn PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(docn PUBLIC cdeps::dshr cdeps::share cdeps::streams)
target_link_libraries(docn PUBLIC esmf)
list(APPEND LIB_TARGETS docn)

# CDEPS/drof
add_library(drof STATIC ${cdeps_drof_files})
add_library(cdeps::drof ALIAS drof)
add_dependencies(drof cdeps::share cdeps::streams cdeps::dshr)
set_target_properties(drof PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(drof PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(drof PUBLIC cdeps::dshr cdeps::share cdeps::streams)
target_link_libraries(drof PUBLIC esmf)
list(APPEND LIB_TARGETS drof)

# CDEPS/dwav
add_library(dwav STATIC ${cdeps_dwav_files})
add_library(cdeps::dwav ALIAS dwav)
add_dependencies(dwav cdeps::share cdeps::streams cdeps::dshr)
set_target_properties(dwav PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dwav PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(dwav PUBLIC cdeps::dshr cdeps::share cdeps::streams)
target_link_libraries(dwav PUBLIC esmf)
list(APPEND LIB_TARGETS dwav)

###############################################################################
### Install
###############################################################################

install(
TARGETS ${LIB_TARGETS}
EXPORT CDEPSExports
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT Library)

export(EXPORT CDEPSExports
NAMESPACE cdeps::
FILE cdeps-targets.cmake)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}/CDEPS)

install(EXPORT CDEPSExports
NAMESPACE cdeps::
FILE cdeps-targets.cmake
DESTINATION lib/cmake)
74 changes: 74 additions & 0 deletions CDEPS-interface/cdeps_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# CDEPS generates these with genf90.pl acting on templates .in in CDEPS/share
# For the UFS, they are pre-generated and committed to the UFS repository
list(APPEND ufs_cdeps_share_files
ufs/cdeps_share/shr_assert_mod.F90
ufs/cdeps_share/shr_frz_mod.F90
ufs/cdeps_share/shr_infnan_mod.F90
)

list(APPEND cdeps_share_files
CDEPS/share/glc_elevclass_mod.F90
CDEPS/share/shr_abort_mod.F90
CDEPS/share/shr_assert.h
CDEPS/share/shr_cal_mod.F90
CDEPS/share/shr_const_mod.F90
CDEPS/share/shr_kind_mod.F90
CDEPS/share/shr_log_mod.F90
CDEPS/share/shr_mpi_mod.F90
CDEPS/share/shr_orb_mod.F90
CDEPS/share/shr_precip_mod.F90
CDEPS/share/shr_strconvert_mod.F90
CDEPS/share/shr_string_mod.F90
CDEPS/share/shr_sys_mod.F90
CDEPS/share/shr_timer_mod.F90
)

list(APPEND cdeps_streams_files
CDEPS/streams/dshr_methods_mod.F90
CDEPS/streams/dshr_strdata_mod.F90
CDEPS/streams/dshr_stream_mod.F90
CDEPS/streams/dshr_tinterp_mod.F90
)

list(APPEND cdeps_dshr_files
CDEPS/dshr/dshr_dfield_mod.F90
CDEPS/dshr/dshr_fldlist_mod.F90
CDEPS/dshr/dshr_mod.F90
)

list(APPEND cdeps_datm_files
CDEPS/datm/atm_comp_nuopc.F90
CDEPS/datm/datm_datamode_cfsr_mod.F90
CDEPS/datm/datm_datamode_clmncep_mod.F90
CDEPS/datm/datm_datamode_core2_mod.F90
CDEPS/datm/datm_datamode_cplhist_mod.F90
CDEPS/datm/datm_datamode_era5_mod.F90
CDEPS/datm/datm_datamode_gefs_mod.F90
CDEPS/datm/datm_datamode_jra_mod.F90
)

list(APPEND cdeps_dice_files
CDEPS/dice/dice_datamode_ssmi_mod.F90
CDEPS/dice/dice_flux_atmice_mod.F90
CDEPS/dice/ice_comp_nuopc.F90
)

list(APPEND cdeps_dlnd_files
CDEPS/dlnd/lnd_comp_nuopc.F90
)

list(APPEND cdeps_docn_files
CDEPS/docn/docn_datamode_aquaplanet_mod.F90
CDEPS/docn/docn_datamode_copyall_mod.F90
CDEPS/docn/docn_datamode_iaf_mod.F90
CDEPS/docn/docn_datamode_som_mod.F90
CDEPS/docn/ocn_comp_nuopc.F90
)

list(APPEND cdeps_drof_files
CDEPS/drof/rof_comp_nuopc.F90
)

list(APPEND cdeps_dwav_files
CDEPS/dwav/wav_comp_nuopc.F90
)
6 changes: 6 additions & 0 deletions CDEPS-interface/ufs/cdeps_share/dtypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define TYPETEXT 100
#define TYPEREAL 101
#define TYPEDOUBLE 102
#define TYPEINT 103
#define TYPELONG 104
#define TYPELOGICAL 105
Loading

0 comments on commit 75f1fc5

Please sign in to comment.