From a92cb4118fa5e1cc25f8de28f7e9f20fd432a7b3 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Thu, 28 Mar 2024 17:11:33 -0400 Subject: [PATCH 1/3] Add BUILD_WITH_NEMSIO build option to allow building UPP without nemsio --- CMakeLists.txt | 5 ++++- sorc/ncep_post.fd/CMakeLists.txt | 20 ++++++++++++++------ sorc/ncep_post.fd/{WRFPOST.f => WRFPOST.F} | 10 ++++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) rename sorc/ncep_post.fd/{WRFPOST.f => WRFPOST.F} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5874d98ac..dd59b532b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) diff --git a/sorc/ncep_post.fd/CMakeLists.txt b/sorc/ncep_post.fd/CMakeLists.txt index de439228c..b28f0f48b 100644 --- a/sorc/ncep_post.fd/CMakeLists.txt +++ b/sorc/ncep_post.fd/CMakeLists.txt @@ -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 @@ -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") @@ -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 @@ -244,6 +247,11 @@ if(BUILD_POSTEXEC) target_link_libraries(${EXENAME} PRIVATE IFI) target_link_libraries(${EXENAME} PRIVATE tdrp) endif() + if(BUILD_WITH_NEMSIO) + 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) diff --git a/sorc/ncep_post.fd/WRFPOST.f b/sorc/ncep_post.fd/WRFPOST.F similarity index 99% rename from sorc/ncep_post.fd/WRFPOST.f rename to sorc/ncep_post.fd/WRFPOST.F index 01a63baa1..1c778d6ab 100644 --- a/sorc/ncep_post.fd/WRFPOST.f +++ b/sorc/ncep_post.fd/WRFPOST.F @@ -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, & @@ -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. @@ -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 @@ -528,7 +533,7 @@ PROGRAM WRFPOST ! print*,'iostatusD3D in WRFPOST= ',iostatusD3D END IF - +#endif ELSE PRINT*,'UNKNOWN MODEL OUTPUT FORMAT, STOPPING' STOP 9999 @@ -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) @@ -607,7 +613,7 @@ PROGRAM WRFPOST STOP 9999 END IF - +#endif ELSE PRINT*,'UNKNOWN MODEL OUTPUT FORMAT, STOPPING' STOP 9999 From aefe33a20c14e597b2d48754b7880e9c685033e1 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Tue, 2 Apr 2024 09:26:23 -0500 Subject: [PATCH 2/3] Specify w3emc and bacio as dependencies of nemsio library --- sorc/ncep_post.fd/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sorc/ncep_post.fd/CMakeLists.txt b/sorc/ncep_post.fd/CMakeLists.txt index b28f0f48b..e439d125c 100644 --- a/sorc/ncep_post.fd/CMakeLists.txt +++ b/sorc/ncep_post.fd/CMakeLists.txt @@ -248,6 +248,8 @@ if(BUILD_POSTEXEC) 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) From 5b6815fcab46af1357cd2d4e0ef08564d6922ff5 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Wed, 3 Apr 2024 13:33:13 +0000 Subject: [PATCH 3/3] Add compile_upp.sh option to build without nemsio (-n) --- tests/compile_upp.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/compile_upp.sh b/tests/compile_upp.sh index c1cb507a1..bce87b787 100755 --- a/tests/compile_upp.sh +++ b/tests/compile_upp.sh @@ -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" @@ -26,11 +27,12 @@ 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 @@ -38,6 +40,9 @@ while getopts ":p:gwc:vhiId" opt; do g) gtg_opt=" -DBUILD_WITH_GTG=ON" ;; + n) + nemsio_opt=" -DBUILD_WITH_NEMSIO=OFF" + ;; w) wrfio_opt=" -DBUILD_WITH_WRFIO=OFF" ;; @@ -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)