Skip to content

Commit d1979bc

Browse files
committed
Give detailed error info when WRF not found, and fail if it was requested
1 parent 607a666 commit d1979bc

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

CMakeLists.txt

+42-34
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,48 @@ set( USE_WRF ON CACHE BOOL "USE_WRF" )
5151
## MPI & OpenMP
5252
##
5353
################################################################################
54+
55+
# First do externals
56+
if ( ${BUILD_EXTERNALS} )
57+
add_subdirectory( external )
58+
# If we got here everything built, we are safe to add find paths for libs
59+
set( ZLIB_ROOT ${INTERNAL_GRIB2_PATH} ) # This may get overridden by HDF5 if zlib is packaged with that
60+
set( PNG_ROOT ${INTERNAL_GRIB2_PATH} )
61+
set( Jasper_ROOT ${INTERNAL_GRIB2_PATH} )
62+
endif()
63+
64+
65+
# Now find required libraries, which may have been affected by externals
66+
if ( ${USE_WRF} )
67+
# PATHS will be checked last
68+
find_package(
69+
WRF
70+
COMPONENTS
71+
WRF_Core io_netcdf io_grib1 io_int
72+
# REQUIRED # this is technically required but we'll print our own msg
73+
PATHS
74+
${PROJECT_SOURCE_DIR}/../WRF/install
75+
${PROJECT_SOURCE_DIR}/../wrf/install
76+
QUIET
77+
NO_CMAKE_ENVIRONMENT_PATH # Do not use _DIR option
78+
)
79+
if ( ${WRF_FOUND} )
80+
message( STATUS "Found WRF : ${WRF_CONFIG} (found version \"${WRF_VERSION}\")" )
81+
else()
82+
message(
83+
FATAL_ERROR
84+
"Compiled WRF model not found. Please ensure a compiled WRF exists "
85+
"and can be found by trying one of the following : \n"
86+
"(1) provide -DWRF_ROOT=<path to install location> to CMake, if done "
87+
"via the configure_new script use -- before option or see ./configure_new -h for more info\n"
88+
"(2) set the environment variable WRF_ROOT to the path to the install location\n"
89+
"(3) compile the WRF model code in ../WRF using the default install location\n"
90+
"\nMore detail on search modes of CMake can be found at\n"
91+
"https://cmake.org/cmake/help/latest/command/find_package.html#search-modes"
92+
)
93+
endif()
94+
endif()
95+
5496
if ( ${USE_MPI} )
5597
# Through ***MUCH*** debugging, if utilizing MPI_<LANG>_COMPILER
5698
# https://cmake.org/cmake/help/latest/module/FindMPI.html#variables-for-locating-mpi
@@ -83,40 +125,6 @@ if ( ${USE_OPENMP} )
83125
endif()
84126

85127

86-
# First do externals
87-
if ( ${BUILD_EXTERNALS} )
88-
add_subdirectory( external )
89-
# If we got here everything built, we are safe to add find paths for libs
90-
set( ZLIB_ROOT ${INTERNAL_GRIB2_PATH} ) # This may get overridden by HDF5 if zlib is packaged with that
91-
set( PNG_ROOT ${INTERNAL_GRIB2_PATH} )
92-
set( Jasper_ROOT ${INTERNAL_GRIB2_PATH} )
93-
endif()
94-
95-
96-
# Now find required libraries, which may have been affected by externals
97-
if (
98-
DEFINED WRF_DIR OR
99-
DEFINED WRF_ROOT OR
100-
DEFINED ENV{WRF_DIR} OR
101-
DEFINED ENV{WRF_ROOT} OR
102-
EXISTS "${PROJECT_SOURCE_DIR}/../WRF/" OR EXISTS "${PROJECT_SOURCE_DIR}/../wrf/" )
103-
# PATHS will be checked last
104-
find_package(
105-
WRF
106-
COMPONENTS
107-
WRF_Core io_netcdf io_grib1 io_int
108-
REQUIRED
109-
PATHS
110-
${PROJECT_SOURCE_DIR}/../WRF/install
111-
${PROJECT_SOURCE_DIR}/../wrf/install
112-
)
113-
if ( ${WRF_FOUND} )
114-
message( STATUS "Found WRF : ${WRF_CONFIG} (found version \"${WRF_VERSION}\")" )
115-
endif()
116-
elseif ( ${USE_WRF} )
117-
message( STATUS "No WRF_DIR or WRF_ROOT provided, skipping targets that rely on WRF" )
118-
endif()
119-
120128
# Find externals now -- this is a little different than normal since we want WRF to
121129
# take precedence if it is present on which libraries to use to avoid library splicing
122130
# rather than finding our external thirdparty libraries first

arch/configure_reader.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def projectSpecificOptions( options, stanzaCfg ) :
588588
# togglable
589589
# we can safely check this since the user would not have been able to select this stanza if it couldn't be disabled
590590
if stanzaCfg.dmCompilersAvailable() :
591-
useMPI = not( input( "[DM] Use MPI? Default [N] [y/N] : " ).lower() in yesValues )
591+
useMPI = not( input( "[DM] Use MPI? Default [N] [y/N] : " ).lower() in yesValues )
592592
else :
593593
useMPI = False
594594
else:
@@ -598,23 +598,15 @@ def projectSpecificOptions( options, stanzaCfg ) :
598598
useOpenMP = False
599599
if ( stanzaCfg.serialOpt_ or stanzaCfg.dmparOpt_ ) and ( stanzaCfg.smparOpt_ or stanzaCfg.dmsmOpt_ ):
600600
# togglable
601-
useOpenMP = input( "[SM] Use OpenMP? Default [N] [y/N] : " ).lower() in yesValues
601+
useOpenMP = input( "[SM] Use OpenMP? Default [N] [y/N] : " ).lower() in yesValues
602602
else:
603603
# User has no choice in the matter
604604
useOpenMP = ( stanzaCfg.smparOpt_ or stanzaCfg.dmsmOpt_ )
605605

606606
##############################################################################
607607

608608
buildExt = input( "[GRIB2] Build GRIB2 libraries (zlib, libpng, JasPer) from source in external/? Default [N] [y/N] : " ).lower() in yesValues
609-
useWRF = not( input( inspect.cleandoc(
610-
"""
611-
[WRF] Try to find WRF for metgrid/geogrid?
612-
Requires WRF path set or ../WRF or ../wrf to exist.
613-
Valid input paths are WRF_ROOT or WRF_DIR, set via env var or passed into cmake.
614-
!!! If no valid path is found, these targets will be skipped !!!
615-
Default [Y] [Y/n] :
616-
"""
617-
) ).lower() in noValues )
609+
useWRF = not( input( "[WRF] Attempt to find compiled WRF model (needed for geogrid and metgrid)? Default [Y] [Y/n] : " ).lower() in noValues )
618610

619611
additionalOptions = {
620612
# "WRF_CORE" : coreOption,

0 commit comments

Comments
 (0)