From e40a16c5fad1e8f1c55dd8c13c78f5a08632c160 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 17 Feb 2023 11:41:15 -0500 Subject: [PATCH 1/3] option to build only application specific utilities (e.g. GFS) --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++- build_all.sh | 17 +++++--------- sorc/CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++------------ 3 files changed, 83 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3629ec68a..f22bf7e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,40 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # User options. option(OPENMP "use OpenMP threading" ON) option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) + +# Utilities to be built (Default: ALL) +option(ICEBLEND "Enable building emcsfc_ice_blend.fd" ON) +option(SNOW2MDL "Enable building emcsfc_snow2mdl.fd" ON) +option(GCYCLE "Enable building global_cycle.fd" ON) +option(LSM "Enable building lsm_routines.fd" ON) +option(FRENCTOOLS "Enable building fre-nctools.fd" ON) +option(GRIDTOOLS "Enable building grid_tools.fd" ON) +option(CHGRES "Enable building chgres_cube.fd" ON) +option(OROG_MASK_TOOLS "Enable building orog_mask_tools.fd" ON) +option(SFC_CLIMO_GEN "Enable building sfc_climo_gen.fd" ON) +option(VCOORD_GEN "Enable building vcoord_gen.fd" ON) +option(FVCOMTOOLS "Enable building fvcom_tools.fd" ON) +option(GBLEVENTS "Enable building gblevents.fd" ON) +option(CPLD_GRIDGEN "Enable building cpld_gridgen.fd" ON) +option(WEIGHT_GEN "Enable building weight_gen.fd" ON) + +# Option to build application specific utilities +option(GFS "Enable building GFS-only utilities" OFF) + +# When building the GFS, the following need not be built +if(GFS) + message(STATUS 'Building utilities specific to the GFS') + set(FRENCTOOLS OFF CACHE BOOL "Disable building fre-nctools.fd" FORCE) + set(GRIDTOOLS OFF CACHE BOOL "Disable building grid_tools.fd" FORCE) + set(OROG_MASK_TOOLS OFF CACHE BOOL "Disable building orog_mask_tools.fd" FORCE) + set(SFC_CLIMO_GEN OFF CACHE BOOL "Disable building sfc_climo_gen.fd" FORCE) + set(VCOORD_GEN OFF CACHE BOOL "Disable building vcoord_gen.fd" FORCE) + set(FVCOMTOOLS OFF CACHE BOOL "Disable building fvcom_tools.fd" FORCE) + set(GBLEVENTS OFF CACHE BOOL "Disable building gblevents.fd" FORCE) + set(CPLD_GRIDGEN OFF CACHE BOOL "Disable building cpld_gridgen.fd" FORCE) + set(WEIGHT_GEN OFF CACHE BOOL "Disable building weight_gen.fd" FORCE) +endif() + SET(TEST_FILE_DIR "." CACHE STRING "Check this directory for test files before using FTP.") # Set the build type. @@ -80,7 +114,7 @@ find_package(sigio 2.3.0 REQUIRED) if(ENABLE_DOCS) find_package(Doxygen REQUIRED) set(abs_top_srcdir "${CMAKE_SOURCE_DIR}") - add_subdirectory(docs) + add_subdirectory(docs) endif() add_subdirectory(sorc) diff --git a/build_all.sh b/build_all.sh index 9f9f090ae..41d380f14 100755 --- a/build_all.sh +++ b/build_all.sh @@ -26,26 +26,21 @@ else set -x fi - # The unit test data download is part of the build system. Not all machines can # access the EMC ftp site, so turn off the build (-DBUILD_TESTING=OFF) of the units tests accordingly. # Those with access to the EMC ftp site are: Orion and Hera. -if [[ "$target" == "hera" || "$target" == "orion" || "$target" == "wcoss2" ]]; then - CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=OFF" - #CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=ON" - #CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DENABLE_DOCS=ON -DBUILD_TESTING=ON" -else - CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=OFF" - #CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DENABLE_DOCS=ON -DBUILD_TESTING=OFF" -fi +CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=OFF" + +# Allow users of this script to provide CMake options e.g. -DGFS=ON|OFF to build GFS specific utilities only +CMAKE_OPTS=${CMAKE_OPTS:-} rm -fr ./build mkdir ./build && cd ./build -cmake .. ${CMAKE_FLAGS} +cmake .. ${CMAKE_FLAGS} ${CMAKE_OPTS} -make -j 8 VERBOSE=1 +make -j ${BUILD_JOBS:-8} VERBOSE=${BUILD_VERBOSE:-} make install #ctest diff --git a/sorc/CMakeLists.txt b/sorc/CMakeLists.txt index d13e43c72..f13399460 100644 --- a/sorc/CMakeLists.txt +++ b/sorc/CMakeLists.txt @@ -2,21 +2,49 @@ # UFS_UTILS project. # # George Gayno -add_subdirectory(emcsfc_ice_blend.fd) -add_subdirectory(emcsfc_snow2mdl.fd) +if(ICEBLEND) + add_subdirectory(emcsfc_ice_blend.fd) +endif() +if(SNOW2MDL) + add_subdirectory(emcsfc_snow2mdl.fd) +endif() if (OpenMP_FOUND) + if(GCYCLE) add_subdirectory(global_cycle.fd) - add_subdirectory(lsm_routines.fd) + endif() + if(LSM) + add_subdirectory(lsm_routines.fd) + endif() else() - message(STATUS "OpenMP is required for global_cycle.fd and was NOT found, skipping ...") -endif() -add_subdirectory(fre-nctools.fd) -add_subdirectory(grid_tools.fd) -add_subdirectory(chgres_cube.fd) -add_subdirectory(orog_mask_tools.fd) -add_subdirectory(sfc_climo_gen.fd) -add_subdirectory(vcoord_gen.fd) -add_subdirectory(fvcom_tools.fd) -add_subdirectory(gblevents.fd) + message(STATUS "OpenMP is required for global_cycle.fd, lsm_routines.fd and was NOT found, skipping ...") +endif() +if(FRENCTOOLS) + add_subdirectory(fre-nctools.fd) +endif() +if(GRIDTOOLS) + add_subdirectory(grid_tools.fd) +endif() +if(CHGRES) + add_subdirectory(chgres_cube.fd) +endif() +if(OROG_MASK_TOOLS) + add_subdirectory(orog_mask_tools.fd) +endif() +if(SFC_CLIMO_GEN) + add_subdirectory(sfc_climo_gen.fd) +endif() +if(VCOORD_GEN) + add_subdirectory(vcoord_gen.fd) +endif() +if(FVCOMTOOLS) + add_subdirectory(fvcom_tools.fd) +endif() +if(GBLEVENTS) + add_subdirectory(gblevents.fd) +endif() +if(CPLD_GRIDGEN) add_subdirectory(cpld_gridgen.fd) -add_subdirectory(weight_gen.fd) +endif() +if(WEIGHT_GEN) + add_subdirectory(weight_gen.fd) +endif() From dfb285b0395bfc8c893cef88fef90ae4e9abb9d8 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 22 Feb 2023 11:04:51 -0500 Subject: [PATCH 2/3] use double quotes for better formatting to stdout --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f22bf7e4a..53913e603 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ option(GFS "Enable building GFS-only utilities" OFF) # When building the GFS, the following need not be built if(GFS) - message(STATUS 'Building utilities specific to the GFS') + message(STATUS "Building utilities specific to the GFS") set(FRENCTOOLS OFF CACHE BOOL "Disable building fre-nctools.fd" FORCE) set(GRIDTOOLS OFF CACHE BOOL "Disable building grid_tools.fd" FORCE) set(OROG_MASK_TOOLS OFF CACHE BOOL "Disable building orog_mask_tools.fd" FORCE) From b83c1202cefbaeda741bbc46b31c80439f7a3edf Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 22 Feb 2023 15:01:24 -0500 Subject: [PATCH 3/3] LSM is required for global-cycle. It need not be an option --- CMakeLists.txt | 1 - sorc/CMakeLists.txt | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53913e603..190573745 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) option(ICEBLEND "Enable building emcsfc_ice_blend.fd" ON) option(SNOW2MDL "Enable building emcsfc_snow2mdl.fd" ON) option(GCYCLE "Enable building global_cycle.fd" ON) -option(LSM "Enable building lsm_routines.fd" ON) option(FRENCTOOLS "Enable building fre-nctools.fd" ON) option(GRIDTOOLS "Enable building grid_tools.fd" ON) option(CHGRES "Enable building chgres_cube.fd" ON) diff --git a/sorc/CMakeLists.txt b/sorc/CMakeLists.txt index f13399460..f238e2f76 100644 --- a/sorc/CMakeLists.txt +++ b/sorc/CMakeLists.txt @@ -8,15 +8,13 @@ endif() if(SNOW2MDL) add_subdirectory(emcsfc_snow2mdl.fd) endif() -if (OpenMP_FOUND) - if(GCYCLE) - add_subdirectory(global_cycle.fd) - endif() - if(LSM) +if(GCYCLE) + if (OpenMP_Fortran_FOUND) + add_subdirectory(global_cycle.fd) add_subdirectory(lsm_routines.fd) + else() + message(STATUS "OpenMP is required for global_cycle.fd and was NOT found, skipping ...") endif() -else() - message(STATUS "OpenMP is required for global_cycle.fd, lsm_routines.fd and was NOT found, skipping ...") endif() if(FRENCTOOLS) add_subdirectory(fre-nctools.fd)