Skip to content

Commit 5b67e4d

Browse files
authored
Option to build only application specific utilities (e.g. GFS) (ufs-community#777)
New option to build only GFS-specific utilities, triggered by specifying -DGFS=ON through the build_all.sh script. Retains the default of building all utilities. Fixes ufs-community#776
1 parent d6786bc commit 5b67e4d

File tree

3 files changed

+83
-29
lines changed

3 files changed

+83
-29
lines changed

CMakeLists.txt

+34-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,39 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1515
# User options.
1616
option(OPENMP "use OpenMP threading" ON)
1717
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
18+
19+
# Utilities to be built (Default: ALL)
20+
option(ICEBLEND "Enable building emcsfc_ice_blend.fd" ON)
21+
option(SNOW2MDL "Enable building emcsfc_snow2mdl.fd" ON)
22+
option(GCYCLE "Enable building global_cycle.fd" ON)
23+
option(FRENCTOOLS "Enable building fre-nctools.fd" ON)
24+
option(GRIDTOOLS "Enable building grid_tools.fd" ON)
25+
option(CHGRES "Enable building chgres_cube.fd" ON)
26+
option(OROG_MASK_TOOLS "Enable building orog_mask_tools.fd" ON)
27+
option(SFC_CLIMO_GEN "Enable building sfc_climo_gen.fd" ON)
28+
option(VCOORD_GEN "Enable building vcoord_gen.fd" ON)
29+
option(FVCOMTOOLS "Enable building fvcom_tools.fd" ON)
30+
option(GBLEVENTS "Enable building gblevents.fd" ON)
31+
option(CPLD_GRIDGEN "Enable building cpld_gridgen.fd" ON)
32+
option(WEIGHT_GEN "Enable building weight_gen.fd" ON)
33+
34+
# Option to build application specific utilities
35+
option(GFS "Enable building GFS-only utilities" OFF)
36+
37+
# When building the GFS, the following need not be built
38+
if(GFS)
39+
message(STATUS "Building utilities specific to the GFS")
40+
set(FRENCTOOLS OFF CACHE BOOL "Disable building fre-nctools.fd" FORCE)
41+
set(GRIDTOOLS OFF CACHE BOOL "Disable building grid_tools.fd" FORCE)
42+
set(OROG_MASK_TOOLS OFF CACHE BOOL "Disable building orog_mask_tools.fd" FORCE)
43+
set(SFC_CLIMO_GEN OFF CACHE BOOL "Disable building sfc_climo_gen.fd" FORCE)
44+
set(VCOORD_GEN OFF CACHE BOOL "Disable building vcoord_gen.fd" FORCE)
45+
set(FVCOMTOOLS OFF CACHE BOOL "Disable building fvcom_tools.fd" FORCE)
46+
set(GBLEVENTS OFF CACHE BOOL "Disable building gblevents.fd" FORCE)
47+
set(CPLD_GRIDGEN OFF CACHE BOOL "Disable building cpld_gridgen.fd" FORCE)
48+
set(WEIGHT_GEN OFF CACHE BOOL "Disable building weight_gen.fd" FORCE)
49+
endif()
50+
1851
SET(TEST_FILE_DIR "." CACHE STRING "Check this directory for test files before using FTP.")
1952

2053
# Set the build type.
@@ -80,7 +113,7 @@ find_package(sigio 2.3.0 REQUIRED)
80113
if(ENABLE_DOCS)
81114
find_package(Doxygen REQUIRED)
82115
set(abs_top_srcdir "${CMAKE_SOURCE_DIR}")
83-
add_subdirectory(docs)
116+
add_subdirectory(docs)
84117
endif()
85118

86119
add_subdirectory(sorc)

build_all.sh

+6-11
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,21 @@ else
2626
set -x
2727
fi
2828

29-
3029
# The unit test data download is part of the build system. Not all machines can
3130
# access the EMC ftp site, so turn off the build (-DBUILD_TESTING=OFF) of the units tests accordingly.
3231
# Those with access to the EMC ftp site are: Orion and Hera.
3332

34-
if [[ "$target" == "hera" || "$target" == "orion" || "$target" == "wcoss2" ]]; then
35-
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=OFF"
36-
#CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=ON"
37-
#CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DENABLE_DOCS=ON -DBUILD_TESTING=ON"
38-
else
39-
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=OFF"
40-
#CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DENABLE_DOCS=ON -DBUILD_TESTING=OFF"
41-
fi
33+
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DCMAKE_INSTALL_BINDIR=exec -DBUILD_TESTING=OFF"
34+
35+
# Allow users of this script to provide CMake options e.g. -DGFS=ON|OFF to build GFS specific utilities only
36+
CMAKE_OPTS=${CMAKE_OPTS:-}
4237

4338
rm -fr ./build
4439
mkdir ./build && cd ./build
4540

46-
cmake .. ${CMAKE_FLAGS}
41+
cmake .. ${CMAKE_FLAGS} ${CMAKE_OPTS}
4742

48-
make -j 8 VERBOSE=1
43+
make -j ${BUILD_JOBS:-8} VERBOSE=${BUILD_VERBOSE:-}
4944
make install
5045

5146
#ctest

sorc/CMakeLists.txt

+43-17
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,47 @@
22
# UFS_UTILS project.
33
#
44
# George Gayno
5-
add_subdirectory(emcsfc_ice_blend.fd)
6-
add_subdirectory(emcsfc_snow2mdl.fd)
7-
if (OpenMP_FOUND)
8-
add_subdirectory(global_cycle.fd)
9-
add_subdirectory(lsm_routines.fd)
10-
else()
11-
message(STATUS "OpenMP is required for global_cycle.fd and was NOT found, skipping ...")
12-
endif()
13-
add_subdirectory(fre-nctools.fd)
14-
add_subdirectory(grid_tools.fd)
15-
add_subdirectory(chgres_cube.fd)
16-
add_subdirectory(orog_mask_tools.fd)
17-
add_subdirectory(sfc_climo_gen.fd)
18-
add_subdirectory(vcoord_gen.fd)
19-
add_subdirectory(fvcom_tools.fd)
20-
add_subdirectory(gblevents.fd)
5+
if(ICEBLEND)
6+
add_subdirectory(emcsfc_ice_blend.fd)
7+
endif()
8+
if(SNOW2MDL)
9+
add_subdirectory(emcsfc_snow2mdl.fd)
10+
endif()
11+
if(GCYCLE)
12+
if (OpenMP_Fortran_FOUND)
13+
add_subdirectory(global_cycle.fd)
14+
add_subdirectory(lsm_routines.fd)
15+
else()
16+
message(STATUS "OpenMP is required for global_cycle.fd and was NOT found, skipping ...")
17+
endif()
18+
endif()
19+
if(FRENCTOOLS)
20+
add_subdirectory(fre-nctools.fd)
21+
endif()
22+
if(GRIDTOOLS)
23+
add_subdirectory(grid_tools.fd)
24+
endif()
25+
if(CHGRES)
26+
add_subdirectory(chgres_cube.fd)
27+
endif()
28+
if(OROG_MASK_TOOLS)
29+
add_subdirectory(orog_mask_tools.fd)
30+
endif()
31+
if(SFC_CLIMO_GEN)
32+
add_subdirectory(sfc_climo_gen.fd)
33+
endif()
34+
if(VCOORD_GEN)
35+
add_subdirectory(vcoord_gen.fd)
36+
endif()
37+
if(FVCOMTOOLS)
38+
add_subdirectory(fvcom_tools.fd)
39+
endif()
40+
if(GBLEVENTS)
41+
add_subdirectory(gblevents.fd)
42+
endif()
43+
if(CPLD_GRIDGEN)
2144
add_subdirectory(cpld_gridgen.fd)
22-
add_subdirectory(weight_gen.fd)
45+
endif()
46+
if(WEIGHT_GEN)
47+
add_subdirectory(weight_gen.fd)
48+
endif()

0 commit comments

Comments
 (0)