Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BUILD_WITH_NEMSIO build option to allow building UPP without nemsio #911

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Handle user options.
option(OPENMP "use OpenMP threading" ON)
option(BUILD_POSTEXEC "Build NCEPpost executable" ON)
option(BUILD_WITH_NEMSIO "Build NCEPpost with nemsio library" ON)
option(BUILD_WITH_WRFIO "Build NCEPpost with WRF-IO library" OFF)
option(BUILD_WITH_IFI "Build NCEPpost with In-Flight Icing (IFI) library if present" OFF)
option(REQUIRE_IFI "Abort if libIFI is not found ; enables BUILD_WITH_IFI=ON" OFF)
Expand Down Expand Up @@ -84,7 +85,9 @@ else()
endif()

if(BUILD_POSTEXEC)
find_package(nemsio REQUIRED)
if(BUILD_WITH_NEMSIO)
find_package(nemsio REQUIRED)
endif()
find_package(sfcio REQUIRED)
find_package(sigio REQUIRED)
find_package(sp REQUIRED)
Expand Down
22 changes: 16 additions & 6 deletions sorc/ncep_post.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,10 @@ endif()
list(APPEND LIB_SRC ${GTG_LIB_SRC})

list(APPEND EXE_SRC
ASSIGNNEMSIOVAR.f
GETNEMSNDSCATTER.f
GFSPOSTSIG.F
INITPOST.F
INITPOST_GFS_NEMS_MPIIO.f
INITPOST_NEMS.f
INITPOST_NETCDF.f
WRFPOST.f
WRFPOST.F
getIVariableN.f
getVariable.f
getlvls.f
Expand All @@ -171,6 +167,14 @@ if(NOT wrf_io_FOUND)
io_int_stubs.f)
endif()

if(BUILD_WITH_NEMSIO)
list(APPEND EXE_SRC
ASSIGNNEMSIOVAR.f
GETNEMSNDSCATTER.f
INITPOST_GFS_NEMS_MPIIO.f
INITPOST_NEMS.f)
endif()

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS
"-g -traceback -fp-model source -free -convert big_endian")
Expand Down Expand Up @@ -234,7 +238,6 @@ if(BUILD_POSTEXEC)
add_executable(${EXENAME} ${EXE_SRC})
target_link_libraries(${EXENAME} PRIVATE
${LIBNAME}
nemsio::nemsio
w3emc::w3emc_4
sp::sp_4
sfcio::sfcio
Expand All @@ -244,6 +247,13 @@ if(BUILD_POSTEXEC)
target_link_libraries(${EXENAME} PRIVATE IFI)
target_link_libraries(${EXENAME} PRIVATE tdrp)
endif()
if(BUILD_WITH_NEMSIO)
set_target_properties(nemsio::nemsio PROPERTIES
INTERFACE_LINK_LIBRARIES "w3emc::w3emc_4;bacio::bacio_4")
target_link_libraries(${EXENAME} PRIVATE
nemsio::nemsio)
target_compile_definitions(${EXENAME} PRIVATE BUILD_WITH_NEMSIO)
endif()
if(wrf_io_FOUND)
target_link_libraries(${EXENAME} PRIVATE
wrf_io::wrf_io)
Expand Down
10 changes: 8 additions & 2 deletions sorc/ncep_post.fd/WRFPOST.f → sorc/ncep_post.fd/WRFPOST.F
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ PROGRAM WRFPOST
!===========================================================================================
!
use netcdf
#if defined(BUILD_WITH_NEMSIO)
use nemsio_module, only: nemsio_getheadvar, nemsio_gfile, nemsio_init, nemsio_open, &
nemsio_getfilehead,nemsio_close
#endif
use CTLBLK_mod, only: filenameaer, me, num_procs, num_servers, mpi_comm_comp, datestr, &
mpi_comm_inter, filename, ioform, grib, idat, filenameflux, filenamed3d, gdsdegr, &
spldef, modelname, ihrst, lsmdef,vtimeunits, tprec, pthresh, datahandle, im, jm, lm, &
Expand All @@ -134,7 +136,9 @@ PROGRAM WRFPOST
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
implicit none
!
#if defined(BUILD_WITH_NEMSIO)
type(nemsio_gfile) :: nfile,ffile,rfile
#endif
INCLUDE "mpif.h"
!
! DECLARE VARIABLES.
Expand Down Expand Up @@ -472,6 +476,7 @@ PROGRAM WRFPOST
print*,'WRF Binary format is no longer supported'
STOP 9996
! NEMSIO format
#if defined(BUILD_WITH_NEMSIO)
ELSE IF(TRIM(IOFORM) == 'binarynemsio' .or. &
TRIM(IOFORM) == 'binarynemsiompiio' )THEN

Expand Down Expand Up @@ -528,7 +533,7 @@ PROGRAM WRFPOST
! print*,'iostatusD3D in WRFPOST= ',iostatusD3D

END IF

#endif
ELSE
PRINT*,'UNKNOWN MODEL OUTPUT FORMAT, STOPPING'
STOP 9999
Expand Down Expand Up @@ -585,6 +590,7 @@ PROGRAM WRFPOST
PRINT*,'POST does not have mpiio option for this model, STOPPING'
STOP 9998
END IF
#if defined(BUILD_WITH_NEMSIO)
ELSE IF(TRIM(IOFORM) == 'binarynemsio') THEN
IF(MODELNAME == 'NMM') THEN
CALL INITPOST_NEMS(NREC,nfile)
Expand All @@ -607,7 +613,7 @@ PROGRAM WRFPOST
STOP 9999

END IF

#endif
ELSE
PRINT*,'UNKNOWN MODEL OUTPUT FORMAT, STOPPING'
STOP 9999
Expand Down
9 changes: 7 additions & 2 deletions tests/compile_upp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ usage() {
echo " -g build with GTG(users with gtg repos. access only) DEFAULT: OFF"
echo " -I build with libIFI(users with ifi repos. access only) DEFAULT: OFF"
echo " -i build with libIFI(users with ifi install access only) DEFAULT: OFF"
echo " -n build without nemsio DEFAULT: ON"
echo " -w build without WRF-IO DEFAULT: ON"
echo " -v build with cmake verbose DEFAULT: NO"
echo " -c Compiler to use for build DEFAULT: intel"
Expand All @@ -26,18 +27,22 @@ usage() {
prefix="../install"
ifi_opt=" -DBUILD_WITH_IFI=OFF"
gtg_opt=" -DBUILD_WITH_GTG=OFF"
nemsio_opt=" -DBUILD_WITH_NEMSIO=ON"
wrfio_opt=" -DBUILD_WITH_WRFIO=ON"
compiler="intel"
verbose_opt=""
debug_opt=""
while getopts ":p:gwc:vhiId" opt; do
while getopts ":p:gnwc:vhiId" opt; do
case $opt in
p)
prefix=$OPTARG
;;
g)
gtg_opt=" -DBUILD_WITH_GTG=ON"
;;
n)
nemsio_opt=" -DBUILD_WITH_NEMSIO=OFF"
;;
w)
wrfio_opt=" -DBUILD_WITH_WRFIO=OFF"
;;
Expand Down Expand Up @@ -69,7 +74,7 @@ if [[ ! -z $debug_opt && $ifi_opt =~ INTERNAL.*=ON ]] ; then
debug_opt="$debug_opt -DIFI_DEBUG=ON"
fi

cmake_opts=" -DCMAKE_INSTALL_PREFIX=$prefix"${wrfio_opt}${gtg_opt}${ifi_opt}${debug_opt}
cmake_opts=" -DCMAKE_INSTALL_PREFIX=$prefix"${nemsio_opt}${wrfio_opt}${gtg_opt}${ifi_opt}${debug_opt}

if [[ $(uname -s) == Darwin ]]; then
readonly MYDIR=$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
Expand Down
Loading