diff --git a/CMakeLists.txt b/CMakeLists.txt index 3629ec68a..190573745 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,39 @@ 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(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 +113,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..f238e2f76 100644 --- a/sorc/CMakeLists.txt +++ b/sorc/CMakeLists.txt @@ -2,21 +2,47 @@ # UFS_UTILS project. # # George Gayno -add_subdirectory(emcsfc_ice_blend.fd) -add_subdirectory(emcsfc_snow2mdl.fd) -if (OpenMP_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() -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) +if(ICEBLEND) + add_subdirectory(emcsfc_ice_blend.fd) +endif() +if(SNOW2MDL) + add_subdirectory(emcsfc_snow2mdl.fd) +endif() +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() +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()