From 369cc60d9e52a7b32bde6430afbb9ce5a08a7515 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 9 Feb 2021 14:43:48 -0500 Subject: [PATCH 01/58] WIP: cleanup top-level CMakeLists.txt --- CMakeLists.txt | 356 +++-------------------- cmake/{Modules => }/FindNetCDF.cmake | 0 cmake/compiler_flags_GNU_Fortran.cmake | 43 +++ cmake/compiler_flags_Intel_Fortran.cmake | 41 +++ cmake/gsi_compiler_flags.cmake | 15 + src/CMakeLists.txt | 6 + 6 files changed, 152 insertions(+), 309 deletions(-) rename cmake/{Modules => }/FindNetCDF.cmake (100%) create mode 100644 cmake/compiler_flags_GNU_Fortran.cmake create mode 100644 cmake/compiler_flags_Intel_Fortran.cmake create mode 100644 cmake/gsi_compiler_flags.cmake create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2603bc76d9..304cf97434 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,317 +1,55 @@ -# disable in source builds to protect against overwriting other Makefiles -#set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) -if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() -endif() - -project(GSI) - enable_language (Fortran) - option(USE_WRF "Find WRF object files and build regional GSI model" ON) - option(USE_BASELIBS "Look for and use GMAO Baselibs" OFF) - option(BUILD_GLOBAL "Build GSI without WRF (regional) module " OFF) - option(BUILD_ENKF "Build the Enkf executable " ON) - option(USE_BASELINE "Use baseline control runs" ON) - SET(ENKF_MODE "GFS" CACHE STRING "EnKF build mode: GFS, WRF, NMMB") - string(TOUPPER ${ENKF_MODE} ENKF_MODE) - if (ENKF_MODE MATCHES "^GFS$") - message("Build the EnKF with GFS module") - option(BUILD_GFS "Build the Enkf with GFS module " ON) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - elseif (ENKF_MODE MATCHES "^WRF$") - message("Build the EnKF with WRF module") - option(BUILD_GFS "Build the Enkf with GFS module " OFF) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " ON) - elseif (ENKF_MODE MATCHES "^NMMB$") - message("Build the EnKF with NMMB module") - option(BUILD_GFS "Build the Enkf with GFS module " OFF) - option(BUILD_NMMB "Build the Enkf with NMMB module " ON) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - else() - message("unkown ENKF_MODE: ${ENKF_MODE} !\nBuild the EnKF with GFS module by default") - option(BUILD_GFS "Build the Enkf with GFS module " ON) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - endif() - option(BUILD_UTIL "Build the Enkf utilities " OFF) - - option(BUILD_UTIL_COM "Build community utilities " OFF) - option(BUILD_ENKF_PREPROCESS_ARW "Build enkf preprocess for ARW " OFF) - option(BUILD_COV_CALC "Build the Desroziers utility" OFF) - option(BUILD_NCDIAG "Build the NCDIAG libraries" ON) - option(BUILD_FV3GFS_NCIO "Build the FV3GFS_NCIO library" ON) - option(BUILD_NCIO_UTIL "Build the NCIO Utilities" ON) - option(BUILD_NCDIAG_SERIAL "Build the serial NCDIAG libraries" ON) - option(BUILD_REG_TESTING "Build the Regression Testing Suite" ON) - option(BUILD_UNIT_TESTING "Build the Unit Testing Suite" OFF) - option(BUILD_GSDCLOUD_ARW "Build the GSD cloud analysis " OFF) - cmake_minimum_required(VERSION 2.8) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - SET(ARCHIVE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - set(CMAKE_INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_INCLUDE_4_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include4") - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - file(MAKE_DIRECTORY ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - file(MAKE_DIRECTORY ${CMAKE_INCLUDE_4_OUTPUT_DIRECTORY}) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Orion.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/WCOSS.cmake) - if(BUILD_REG_TESTING) - set(CTEST_TEST_TIMEOUT 86400 ) - find_package(GSICONTROL) - include( CTest ) - endif(BUILD_REG_TESTING) - - cmake_policy(SET CMP0009 NEW) - cmake_policy(SET CMP0054 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - if(FIND_HDF5_HL) - find_package(HDF5 COMPONENTS C HL) - elseif(FIND_HDF5) - find_package(HDF5) - endif() - - MESSAGE(${CMAKE_CURRENT_SOURCE_DIR}) - # make sure that the default is a RELEASE - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PROFILE" BUILD_PROFILE) - if( BUILD_PRODUCTION ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/exec ) - endif() - if( BUILD_PROFILE ) - set(CMAKE_SKIP_RPATH "TRUE") - if(NOT ENV{TAU_MAKEFILE}) - message("Must set TAU MAKEFILE environment variable to build in profiling mode") - exit() - endif() - endif() - - if(BUILD_GSDCLOUD_ARW) - set(GSDCLOUDOPT "-DRR_CLOUDANALYSIS" CACHE INTERNAL "" ) - else(BUILD_GSDCLOUD_ARW) - set( GSDCLOUDOPT "" CACHE INTERNAL "" ) - endif(BUILD_GSDCLOUD_ARW) +cmake_minimum_required(VERSION 3.15) - set(CMAKE_Fortran_FLAGS_RELEASE "") - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() +project(GSI + VERSION 1.0.0 + LANGUAGES Fortran) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") +include(${PROJECT_NAME}_compiler_flags) +include(GNUInstallDirs) - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) -# if( (HOST-Discover) AND (NOT HOST-Generic)) - if( USE_BASELIBS ) - find_package(Baselibs REQUIRED) - else() - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package( ZLIB ) - find_package( CURL ) - endif() - if(( NOT HOST-WCOSS_D ) AND ( NOT HOST-WCOSS_C ) AND ( NOT HOST-Gaea ) ) - message(" trying to find lapack, ${host}") - find_package( LAPACK ) - endif() -# build the WRF I/O libraries - if(DEFINED ENV{GSIWRF_LIB}) - set(wrflib "$ENV{GSIWRF_LIB}" CACHE INTERNAL "WRFIO library" ) - elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libsrc/wrflib) - add_subdirectory(libsrc/wrflib) - else() - message("libsrc/wrflib not pulled from git, looking for WRF dependencies locally") - find_package( WRF ) - endif() - - # default installation - get_filename_component (default_prefix ".." ABSOLUTE) -# set (CMAKE_INSTALL_PREFIX ${default_prefix} CACHE STRING "set prefix" -# FORCE) - - - # FFLAGS depend on the compiler - get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME) - set(CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder") - set (CMAKE_Fortran_INC_FLAGS "-I ./ -I ${CORE_INCS} -I ${NETCDF_INCLUDE_DIRS} ") - set (CFLAGS_N "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder") - - - if(BUILD_CORELIBS ) - message("setting values for corelibs") - set(BUILD_BACIO "ON" CACHE STRING "Build the BACIO library" ) - set(BUILD_BUFR "ON" CACHE STRING "Build the BUFR library" ) - set(BUILD_SFCIO "ON" CACHE STRING "Build the SFCIO library" ) - set(BUILD_SIGIO "ON" CACHE STRING "Build the SIGIO library" ) - set(BUILD_NEMSIO "ON" CACHE STRING "Build the NEMSIO library" ) - set(BUILD_SP "ON" CACHE STRING "Build the SP library" ) - set(BUILD_CRTM "ON" CACHE STRING "Build the CRTM library" ) - set(BUILD_W3EMC "ON" CACHE STRING "Build the EMC library" ) - set(BUILD_NCO "ON" CACHE STRING "Build the NCO library" ) - endif() - find_package( BACIO ) - find_package( BUFR ) - find_package( SIGIO ) - find_package( NEMSIO ) - find_package( CRTM ) - find_package( SP ) - find_package( SFCIO ) - find_package( W3EMC ) - find_package( W3NCO ) - find_package( IP ) +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") +endif() - if(BUILD_NCDIAG) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - endif(BUILD_NCDIAG) - if(BUILD_FV3GFS_NCIO) - set(FV3GFS_NCIO_INCS "${PROJECT_BINARY_DIR}/src/fv3gfs_ncio/include") - add_subdirectory(src/fv3gfs_ncio) - set(FV3GFS_NCIO_LIBRARIES fv3gfs_ncio ) - endif(BUILD_FV3GFS_NCIO) - if(BUILD_NCIO_UTIL) - add_subdirectory(util/netcdf_io) - endif(BUILD_NCIO_UTIL) +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() - find_package( BACIO ) - find_package( BUFR ) - find_package( SIGIO ) - find_package( NEMSIO ) - find_package( CRTM ) - find_package( SP ) - find_package( SFCIO ) - find_package( W3EMC ) - find_package( W3NCO ) - find_package( IP ) +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_NCDIAG "Enable NetCDF diagnostic files" OFF) - if(BUILD_GSDCLOUD_ARW) - set(GSDCLOUD_DIR "${CMAKE_SOURCE_DIR}/src/GSD/gsdcloud") - set(gsdcloud gsdcloud_arw) - add_subdirectory(src/GSD/gsdcloud) - set(GSDCLOUD_LIBRARY ${gsdcloud} ) - else(BUILD_GSDCLOUD_ARW) - set(GSDCLOUD_LIBRARY "") - endif(BUILD_GSDCLOUD_ARW) +# Dependencies +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +find_package(LAPACK QUIET) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() - add_subdirectory(src/gsi) - if(BUILD_ENKF) - add_subdirectory(src/enkf) - endif(BUILD_ENKF) - if(BUILD_UTIL) - add_subdirectory(util/EnKF/gfs/src) - add_subdirectory(util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd) - add_subdirectory(util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared.v3.0.0/sorc/verf_radang.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared.v3.0.0/sorc/verf_radbcoef.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared.v3.0.0/sorc/verf_radbcor.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared.v3.0.0/sorc/verf_radtime.fd) - endif(BUILD_UTIL) - find_package( NDATE ) - if( NOT NDATE ) - add_subdirectory(util/ndate) - endif() - if(BUILD_ENKF_PREPROCESS_ARW) - add_subdirectory(util/EnKF/arw/src) - endif(BUILD_ENKF_PREPROCESS_ARW) - if(BUILD_UTIL_COM) - add_subdirectory(util/Analysis_Utilities/read_diag) - add_subdirectory(util/radar_process/radialwind) - add_subdirectory(util/radar_process/reflectivity) - add_subdirectory(util/bufr_tools) - endif(BUILD_UTIL_COM) - if(BUILD_COV_CALC) - add_subdirectory(util/Correlated_Obs) - endif (BUILD_COV_CALC) - if(BUILD_UNIT_TESTING) - set(CTEST_TEST_TIMEOUT 400 ) - find_package(GSICONTROL) - include( CTest ) - add_subdirectory(unit-tests) - endif(BUILD_UNIT_TESTING) - if(BUILD_REG_TESTING) - if(USE_BASELINE) - set(BASELINE_FLAG "1") - else() - set(BASELINE_FLAG "0") - endif(USE_BASELINE) - if(USE_WRF) - file(WRITE "${PROJECT_BINARY_DIR}/regression_var.out" "${CMAKE_SOURCE_DIR}/regression/regression_var.sh ${host} ${CMAKE_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${GSIEXEC} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${ENKFEXEC} ${GSICONTROL} ${ENKFCONTROL} ${BASELINE_FLAG} ") - set( REG_TEST_NAMES "global_T62;global_T62_ozonly;global_4dvar_T62;global_4denvar_T126;global_fv3_4denvar_T126;;global_fv3_4denvar_C192;global_lanczos_T62;arw_netcdf; - arw_binary;nmm_binary;nmm_netcdf;nmmb_nems_4denvar;hwrf_nmm_d2;hwrf_nmm_d3;rtma;global_enkf_T62;netcdf_fv3_regional;global_C96_fv3aero;global_C96_fv3aerorad") - else() - file(WRITE "${PROJECT_BINARY_DIR}/regression_var.out" "${CMAKE_SOURCE_DIR}/regression/regression_var.sh ${host} ${CMAKE_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${GSIEXEC} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${ENKFEXEC} ${GSICONTROL} ${ENKFCONTROL} ${BASELINE_FLAG} ") - set( REG_TEST_NAMES "global_T62;global_T62_ozonly;global_4dvar_T62;global_lanczos_T62;global_nemsio_T62;global_C96_fv3aero;global_C96_fv3aerorad") - endif() - foreach( REG_TEST ${REG_TEST_NAMES} ) - add_test(NAME ${REG_TEST} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/regression COMMAND regression_driver.sh ${REG_TEST} ${PROJECT_BINARY_DIR}) - endforeach( REG_TEST ) - set_tests_properties( ${REG_TEST_NAMES} PROPERTIES TIMEOUT 86400 ) - endif() +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(wrf_io REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(ip REQUIRED) +find_package(w3emc REQUIRED) +find_package(w3nco REQUIRED) +find_package(bufr REQUIRED) +find_package(crtm REQUIRED) + +# Build components +#add_subdirectory(src) +#add_subdirectory(util) +#add_subdirectory(unit-tests) +#add_subdirectory(regression) diff --git a/cmake/Modules/FindNetCDF.cmake b/cmake/FindNetCDF.cmake similarity index 100% rename from cmake/Modules/FindNetCDF.cmake rename to cmake/FindNetCDF.cmake diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..5e19e25453 --- /dev/null +++ b/cmake/compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,43 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions ") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/cmake/compiler_flags_Intel_Fortran.cmake b/cmake/compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..7339c76f99 --- /dev/null +++ b/cmake/compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -ip -ipo -unroll -inline -no-heap-arrays") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/cmake/gsi_compiler_flags.cmake b/cmake/gsi_compiler_flags.cmake new file mode 100644 index 0000000000..2c1ea8ebba --- /dev/null +++ b/cmake/gsi_compiler_flags.cmake @@ -0,0 +1,15 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(compiler_flags_GNU_Fortran) +elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000000..87e2d0695f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(gsi) +#add_subdirectory(enkf) +#add_subdirectory(GSD) +if(ENABLE_NCDIAG) + add_subdirectory(ncdiag) +endif() From 5fbdde58be1758c5ce62b6f3eca5e3a9fa162a23 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 10 Feb 2021 11:48:57 -0500 Subject: [PATCH 02/58] clean up ncdiag cmake build --- src/ncdiag/CMakeLists.txt | 152 ++++++-- src/ncdiag/cmake/FindNetCDF.cmake | 347 ++++++++++++++++++ src/ncdiag/cmake/PackageConfig.cmake.in | 18 + .../cmake/compiler_flags_GNU_Fortran.cmake | 43 +++ .../cmake/compiler_flags_Intel_Fortran.cmake | 41 +++ src/ncdiag/cmake/ncdiag_compiler_flags.cmake | 15 + src/ncdiag/ncdiag_files.cmake | 53 +++ src/ncdiag/serial/CMakeLists.txt | 31 -- 8 files changed, 644 insertions(+), 56 deletions(-) create mode 100644 src/ncdiag/cmake/FindNetCDF.cmake create mode 100644 src/ncdiag/cmake/PackageConfig.cmake.in create mode 100644 src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake create mode 100644 src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake create mode 100644 src/ncdiag/cmake/ncdiag_compiler_flags.cmake create mode 100644 src/ncdiag/ncdiag_files.cmake delete mode 100644 src/ncdiag/serial/CMakeLists.txt diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index 043545c73b..e8d6398364 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -1,26 +1,128 @@ -cmake_minimum_required(VERSION 2.8) -if(BUILD_NCDIAG) - if(BUILD_NCDIAG_SERIAL) - add_subdirectory(serial) - endif(BUILD_NCDIAG_SERIAL) - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - - # NetCDF-4 library - include_directories( ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS} ) - - # 32-bit reals, for now - add_definitions(-D_REAL4_ -DUSE_MPI) - FILE(GLOB NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set_source_files_properties( ${NCDIAG_SRC} PROPERTIES COMPILE_FLAGS ${NCDIAG_Fortran_FLAGS} ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/test_nc_unlimdims.F90 ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_cat.F90 ) - add_library(ncdiag STATIC ${NCDIAG_SRC}) - add_executable(test_nc_unlimdims.x ${CMAKE_CURRENT_SOURCE_DIR}/test_nc_unlimdims.F90 ) - add_executable(ncdiag_cat_mpi.x ${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_cat.F90 ) - target_link_libraries(ncdiag_cat_mpi.x ncdiag ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${HDF5_Fortran_HL_LIBRARIES} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - target_link_libraries(test_nc_unlimdims.x ncdiag ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${HDF5_Fortran_HL_LIBRARIES} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ${MPI_Fortran_LIBRARIES}) -# set_target_properties(test_nc_unlimdims.x PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_INCS} ) -# set_target_properties(ncdiag_cat_mpi.x PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_INCS} ${MPI_Fortran_INCLUDE_PATH}) - -endif(BUILD_NCDIAG) +cmake_minimum_required(VERSION 3.15) +project(ncdiag + VERSION 1.0.0 + LANGUAGES Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +include(${PROJECT_NAME}_compiler_flags) +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +option(ENABLE_NCDIAG_SERIAL "Enable Serial NetCDF diagnostics" ON) + +# Dependencies +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED COMPONENTS Fortran) + +# Echo user options +message(STATUS "ENABLE_NCDIAG_SERIAL .. ${ENABLE_NCDIAG_SERIAL}") + +# Get list of files +include(ncdiag_files.cmake) + +if(CMAKE_BUILD_TYPE MATCHES "^(Debug)$") + list(APPEND debug_defs + DEBUG + _DEBUG_MEM_ + ERROR_TRACEBACK + ) +endif() + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/ncdiag") +add_library(ncdiag STATIC ${NCDIAG_SRC_lib}) +add_library(${PROJECT_NAME}::ncdiag ALIAS ncdiag) +set_target_properties(ncdiag PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_compile_definitions(ncdiag PRIVATE "_REAL4_") +target_compile_definitions(ncdiag PRIVATE "USE_MPI") +target_compile_definitions(ncdiag PRIVATE "${debug_defs}") +target_link_libraries(ncdiag PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(ncdiag PUBLIC MPI::MPI_Fortran) +target_include_directories(ncdiag INTERFACE + $ + $) +list(APPEND NCDIAG_Targets + ncdiag) +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +# Build applications +foreach(app ${NCDIAG_SRC_app}) + get_filename_component(app_name ${app} NAME_WLE) + add_executable(${app_name}.x ${app}) + add_dependencies(${app_name}.x ncdiag) + target_compile_definitions(${app_name}.x PRIVATE "USE_MPI") + target_link_libraries(${app_name}.x PUBLIC ncdiag) + target_link_libraries(${app_name}.x PUBLIC NetCDF::NetCDF_Fortran) + target_link_libraries(${app_name}.x PUBLIC MPI::MPI_Fortran) + list(APPEND NCDIAG_Targets + ${app_name}.x) +endforeach() + +# Build serial library and applications +if(ENABLE_NCDIAG_SERIAL) + set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/ncdiag_serial") + add_library(ncdiag_serial STATIC ${NCDIAG_SRC_lib}) + add_library(${PROJECT_NAME}::ncdiag_serial ALIAS ncdiag_serial) + set_target_properties(ncdiag_serial PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") + target_compile_definitions(ncdiag_serial PRIVATE "_REAL4_") + target_compile_definitions(ncdiag_serial PRIVATE "${debug_defs}") + target_link_libraries(ncdiag_serial PUBLIC NetCDF::NetCDF_Fortran) + target_include_directories(ncdiag_serial INTERFACE + $ + $) + list(APPEND NCDIAG_Targets + ncdiag_serial) + + set(app_name "ncdiag_cat_serial") + add_executable(${app_name}.x nc_diag_cat.F90) + add_dependencies(${app_name}.x ncdiag_serial) + target_link_libraries(${app_name}.x PUBLIC ncdiag_serial) + target_link_libraries(${app_name}.x PUBLIC NetCDF::NetCDF_Fortran) + list(APPEND NCDIAG_Targets + ${app_name}.x) + install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install( + TARGETS ${NCDIAG_Targets} + EXPORT ${PROJECT_NAME}Exports + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/ncdiag/cmake/FindNetCDF.cmake b/src/ncdiag/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/src/ncdiag/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation nor +# does it submit to any jurisdiction. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() diff --git a/src/ncdiag/cmake/PackageConfig.cmake.in b/src/ncdiag/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..216779d855 --- /dev/null +++ b/src/ncdiag/cmake/PackageConfig.cmake.in @@ -0,0 +1,18 @@ +@PACKAGE_INIT@ + +# * @PROJECT_NAME@::@PROJECT_NAME@ - library target +# * @PROJECT_NAME@::@PROJECT_NAME@_serial - serial library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include(CMakeFindDependencyMacro) + +find_dependency(NetCDF COMPONENTS Fortran) + +# Get the build type from real32 library target with dyanmic allocation +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"@PROJECT_VERSION@\")") diff --git a/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake b/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..be5556137f --- /dev/null +++ b/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,43 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions ") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake b/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..7339c76f99 --- /dev/null +++ b/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -ip -ipo -unroll -inline -no-heap-arrays") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags.cmake new file mode 100644 index 0000000000..2c1ea8ebba --- /dev/null +++ b/src/ncdiag/cmake/ncdiag_compiler_flags.cmake @@ -0,0 +1,15 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(compiler_flags_GNU_Fortran) +elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/src/ncdiag/ncdiag_files.cmake b/src/ncdiag/ncdiag_files.cmake new file mode 100644 index 0000000000..9c166de851 --- /dev/null +++ b/src/ncdiag/ncdiag_files.cmake @@ -0,0 +1,53 @@ +list(APPEND NCDIAG_SRC_lib +nc_diag_fson.f90 +nc_diag_read_mod.F90 +nc_diag_res.f90 +nc_diag_write_mod.F90 +ncd_kinds.F90 +ncdc_cli_process.F90 +ncdc_climsg.F90 +ncdc_data.F90 +ncdc_data_MPI.F90 +ncdc_dims.F90 +ncdc_metadata.F90 +ncdc_realloc.F90 +ncdc_state.F90 +ncdc_types.f90 +ncdc_vars.F90 +ncdf_path_m.F90 +ncdf_string_m.f90 +ncdf_value_m.f90 +ncdr_alloc_assert.f90 +ncdr_attrs.f90 +ncdr_attrs_fetch.f90 +ncdr_check.f90 +ncdr_climsg.F90 +ncdr_dims.f90 +ncdr_global_attrs.f90 +ncdr_global_attrs_fetch.f90 +ncdr_realloc_mod.F90 +ncdr_state.f90 +ncdr_types.f90 +ncdr_vars.f90 +ncdr_vars_fetch.f90 +ncdres_climsg.F90 +ncdw_chaninfo.F90 +ncdw_ciresize.F90 +ncdw_climsg.F90 +ncdw_data2d.F90 +ncdw_dresize.F90 +ncdw_lheader.F90 +ncdw_metadata.F90 +ncdw_mresize.F90 +ncdw_realloc.F90 +ncdw_state.f90 +ncdw_strarrutils.F90 +ncdw_types.F90 +ncdw_varattr.F90 +netcdf_unlimdims.F90 +) + +list(APPEND NCDIAG_SRC_app +nc_diag_cat.F90 +test_nc_unlimdims.F90 +) diff --git a/src/ncdiag/serial/CMakeLists.txt b/src/ncdiag/serial/CMakeLists.txt deleted file mode 100644 index d6abd87abf..0000000000 --- a/src/ncdiag/serial/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -if(BUILD_NCDIAG) - - if( NOT USE_BASELIBS ) - if( BUILD_NCDIAG_SERIAL ) - set(NCDIAG_SERIAL_MODULE_DIR ${PROJECT_BINARY_DIR}/include/ncdiag_serial) - # NetCDF-4 library - set(NCDIAG_SERIAL_INCS "${PROJECT_BINARY_DIR}/include/ncdiag_serial") - - include_directories( ${NETCDF_INCLUDE_DIRS} ${NCDIAG_SERIAL_INCS} ) - - # 32-bit reals, for now - add_definitions(-D_REAL4_) - - message("HEY!!! ncdiag flags are ${NCDIAG_Fortran_FLAGS}") - FILE(GLOB NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../*90 ) - set_source_files_properties( ${NCDIAG_SRC} PROPERTIES COMPILE_FLAGS ${NCDIAG_Fortran_FLAGS} ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/test_nc_unlimdims.F90 ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_cat.F90 ) - add_library(ncdiag_serial STATIC ${NCDIAG_SRC}) - set_target_properties( ncdiag_serial PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_SERIAL_MODULE_DIR} ) - add_executable(ncdiag_cat.x ${CMAKE_CURRENT_SOURCE_DIR}/../nc_diag_cat.F90 ) - set_target_properties( ncdiag_cat.x PROPERTIES COMPILE_FLAGS ${NCDIAG_Fortran_FLAGS} ) - set_target_properties( ncdiag_cat.x PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_SERIAL_MODULE_DIR} ) - target_link_libraries(ncdiag_cat.x ncdiag_serial ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${HDF5_Fortran_HL_LIBRARIES} ${HDF5_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${ZLIB_LIBRARIES}) - endif(BUILD_NCDIAG_SERIAL) - endif( NOT USE_BASELIBS ) -endif(BUILD_NCDIAG) - - - From fb803b0fb29a321a403706afb52aa3bfc91e5900 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 10 Feb 2021 18:09:27 -0500 Subject: [PATCH 03/58] build global_gsi.x. regional requires something from wrflib --- CMakeLists.txt | 24 +- cmake/FindNetCDF.cmake | 32 +- cmake/compiler_flags_GNU_Fortran.cmake | 2 +- src/CMakeLists.txt | 10 +- src/gsi/CMakeLists.txt | 285 ++++++----- src/gsi/gsi_files.cmake | 662 +++++++++++++++++++++++++ src/gsi/read_l2bufr_mod.f90 | 144 +++--- src/gsi/read_radar.f90 | 350 ++++++------- src/ncdiag/CMakeLists.txt | 2 +- 9 files changed, 1095 insertions(+), 416 deletions(-) create mode 100644 src/gsi/gsi_files.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 304cf97434..02709cfdc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15) project(GSI VERSION 1.0.0 - LANGUAGES Fortran) + LANGUAGES C Fortran) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) @@ -24,22 +24,32 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) -option(ENABLE_NCDIAG "Enable NetCDF diagnostic files" OFF) +option(BUILD_NCDIAG "Build and use inline NetCDF diagnostics library" ON) +option(BUILD_REGIONAL "Build Regional GSI" OFF) + +# Echo user options +message(STATUS "OPENMP ................. ${OPENMP}") +message(STATUS "BUILD_NCDIAG ........... ${BUILD_NCDIAG}") +message(STATUS "BUILD_REGIONAL ......... ${BUILD_REGIONAL}") # Dependencies find_package(MPI REQUIRED) find_package(NetCDF REQUIRED Fortran) -find_package(LAPACK QUIET) +find_package(LAPACK REQUIRED) if(OPENMP) find_package(OpenMP REQUIRED) endif() +# NetCDF Diagnostic IO library dependency +if(NOT BUILD_NCDIAG) + find_package(ncdiag REQUIRED) +endif() + # NCEPLibs dependencies find_package(bacio REQUIRED) find_package(sigio REQUIRED) find_package(sfcio REQUIRED) find_package(nemsio REQUIRED) -find_package(wrf_io REQUIRED) find_package(ncio REQUIRED) find_package(sp REQUIRED) find_package(ip REQUIRED) @@ -48,8 +58,12 @@ find_package(w3nco REQUIRED) find_package(bufr REQUIRED) find_package(crtm REQUIRED) +if(BUILD_REGIONAL) + find_package(wrf_io REQUIRED) +endif() + # Build components -#add_subdirectory(src) +add_subdirectory(src) #add_subdirectory(util) #add_subdirectory(unit-tests) #add_subdirectory(regression) diff --git a/cmake/FindNetCDF.cmake b/cmake/FindNetCDF.cmake index 1439ae8486..9e32378ff5 100644 --- a/cmake/FindNetCDF.cmake +++ b/cmake/FindNetCDF.cmake @@ -171,6 +171,21 @@ function(netcdf_config exec flag output_var) endif() endfunction() +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + ## Find libraries for each component set( NetCDF_LIBRARIES ) foreach( _comp IN LISTS _search_components ) @@ -228,6 +243,12 @@ foreach( _comp IN LISTS _search_components ) IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() endif() endif() endforeach() @@ -263,17 +284,6 @@ if (NetCDF_INCLUDE_DIRS) endif() endif () -## Detect additional package properties -netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) -if( NOT _val MATCHES "^(yes|no)$" ) - netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) -endif() -if( _val MATCHES "^(yes)$" ) - set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) -else() - set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) -endif() - ## Finalize find_package include(FindPackageHandleStandardArgs) diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake index 5e19e25453..be5556137f 100644 --- a/cmake/compiler_flags_GNU_Fortran.cmake +++ b/cmake/compiler_flags_GNU_Fortran.cmake @@ -2,7 +2,7 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none") #################################################################### # RELEASE FLAGS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87e2d0695f..4da2dd499e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,8 @@ -add_subdirectory(gsi) -#add_subdirectory(enkf) -#add_subdirectory(GSD) -if(ENABLE_NCDIAG) +if(BUILD_NCDIAG) add_subdirectory(ncdiag) endif() + +#add_subdirectory(GSD) + +add_subdirectory(gsi) +#add_subdirectory(enkf) diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index c44fb5b98b..6c4de7363f 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -1,154 +1,145 @@ -cmake_minimum_required(VERSION 2.8) -# need to set CMP0046 when using add_dependencies with cmake version 3.6.2 - if(crayComp) - cmake_policy(SET CMP0046 NEW) - endif() - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") -# get a list of all the fortran source files - file(GLOB GSIFORT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) -# get a list of all the c source files - file(GLOB GSI_C_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*c ) -# get a list of all cplr files - file(GLOB CLASS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/class*90 ) -# create a list of all corresponding stub files - string(REGEX REPLACE "class" "stub" STUB_SRC "${CLASS_SRC}") -# create a list of all corresponding class files - string(REGEX REPLACE "class" "cplr" CPLR_SRC "${CLASS_SRC}") +# Get the list of all source files +include(gsi_files.cmake) -# GSIMAIN_SRC is a list of Fortram main(s), to be used to define GSIEXEC, -# and to be excluded from GSI libraries. - set(GSIMAIN_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/gsimain.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/gsimod.F90 +# Include GSI ncdiag files if NetCDF Diagnostics is disabled +if(NOT BUILD_NCDIAG) + list(APPEND GSI_SRC_Fortran + ${GSI_SRC_ncdiag} ) - -# GSIUTIL_SRC is a list of all Fortran modules as *base level* utilities. -# This list can be extended to include any module, which depends (USEs) -# only on module(s) already included in this list, in one of CORE_LIBRARIES, -# or in one of system libraries. Any module dynamically depending on external -# libraries through configuration, such as WRF, NCDIAG, etc. should not be -# included. - - set(GSIUTIL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/mpeu_util.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/mpimod.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/mpeu_mpif.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/kinds.F90 - ) - -# GSIFORT_SRC is a list of all Fortran modules for GSI core implementations, -# after all configuration dependent code (some stub and cplr), base level -# utilities, the main are removed from the rest of source files - -# Remove CLASS_SRC list related STUB_SRC and CPLR_SRC, as configurable -# grid components - list( REMOVE_ITEM GSIFORT_SRC - ${STUB_SRC} - ${CPLR_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_REGIONAL.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_GFS.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/stub_nstmod.f90 - ${GSIUTIL_SRC} - ${GSIMAIN_SRC} +endif() + +# Collect files specific for each application +# Global GSI application +list(APPEND GSI_SRC_Fortran_global + ${GSI_SRC_Fortran} + ${GSI_SRC_class} + ${GSI_SRC_stub} + ${GSI_SRC_fixture_gfs} +) + +# Regional GSI application +list(APPEND GSI_SRC_Fortran_regional + ${GSI_SRC_Fortran} + ${GSI_SRC_class} + ${GSI_SRC_cplr} + ${GSI_SRC_fixture_regional} +) + +# Compiler options and definitions +list(APPEND GSI_C_DEFS + FortranByte=char + FortranInt=int + funder + "FortranLlong=long long" +) + +# Create object libraries for various components +# GSI_SRC_C files +add_library(gsi_c_obj OBJECT ${GSI_SRC_C}) +target_compile_definitions(gsi_c_obj PUBLIC ${GSI_C_DEFS}) + +# Create a library of GLOBAL GSI Fortran Objects +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi") +add_library(global_gsi_fortran_obj OBJECT ${GSI_SRC_Fortran_global}) +set_target_properties(global_gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(global_gsi_fortran_obj INTERFACE + $ + $) +list(APPEND GSI_LIB_Fortran_Targets + global_gsi_fortran_obj +) + +# Create a library of REGIONAL GSI Fortran objects +if(BUILD_REGIONAL) + set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi") + add_library(regional_gsi_fortran_obj OBJECT ${GSI_SRC_Fortran_regional}) + set_target_properties(regional_gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") + target_include_directories(regional_gsi_fortran_obj INTERFACE + $ + $) + list(APPEND GSI_LIB_Fortran_Targets + regional_gsi_fortran_obj ) - -# remove NCDIAG, if it is a component built somewhere else. - if( BUILD_NCDIAG ) - list( REMOVE_ITEM GSIFORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_read_mod.f90" ) - list( REMOVE_ITEM GSIFORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_write_mod.f90" ) - endif( BUILD_NCDIAG ) - -# The specific regional/WRF source files - if(USE_WRF) - list( APPEND GSIFORT_SRC - ${CPLR_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_REGIONAL.F90 - ) - endif() - -# The specific global source files - if(BUILD_GLOBAL) - list( APPEND GSIFORT_SRC - ${STUB_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_GFS.F90 - ) - endif(BUILD_GLOBAL) - -# set up the compiler flags - set_source_files_properties( ${GSIMAIN_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - set_source_files_properties( ${GSIFORT_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - set_source_files_properties( ${GSIUTIL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - set_source_files_properties( ${GSI_C_SRC} PROPERTIES COMPILE_FLAGS ${GSI_CFLAGS} ) - - set( GSICORE_SRC ${GSIFORT_SRC} ${GSI_C_SRC} ) - -# Add the include paths - message("MPI include PATH ${MPI_Fortran_INCLUDE_PATH}") - include_directories( ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS} "./" ) - -#define the name used for GSI Shared lib and add it with properties and include dirs - set(GSISHAREDLIB "gsilib_shrd${debug_suffix}" CACHE INTERNAL "") - add_library(${GSISHAREDLIB} STATIC ${GSIUTIL_SRC} ) - set_target_properties(${GSISHAREDLIB} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_include_directories(${GSISHAREDLIB} PUBLIC "${PROJECT_BINARY_DIR}/include") - -# Definte the base name of the executable - if(BUILD_PRODUCTION) - set(GSIBASE "global_gsi.x") - else() - if(BUILD_GLOBAL) - set(GSIBASE "gsi_global") - else() - set(GSIBASE "gsi") - endif() - set(GSISUFFIX ".x" CACHE INTERNAL "Executable suffix") +endif() + +# Link the Fortran targets with dependencies +foreach(lib ${GSI_LIB_Fortran_Targets}) + target_compile_definitions(${lib} PUBLIC "_REAL8_") + target_link_libraries(${lib} PUBLIC sigio::sigio) + target_link_libraries(${lib} PUBLIC sfcio::sfcio) + target_link_libraries(${lib} PUBLIC nemsio::nemsio) + target_link_libraries(${lib} PUBLIC ncio::ncio) + target_link_libraries(${lib} PUBLIC w3emc::w3emc_d) + target_link_libraries(${lib} PUBLIC crtm::crtm) + target_link_libraries(${lib} PUBLIC NetCDF::NetCDF_Fortran) + target_link_libraries(${lib} PUBLIC MPI::MPI_Fortran) + if(OpenMP_Fortran_FOUND) + target_link_libraries(${lib} PUBLIC OpenMP::OpenMP_Fortran) endif() - -# Set names, libs, and properties depending on if we are building with WRF or not - if(USE_WRF) - set(GSIEXEC "${GSIBASE}${debug_suffix}${GSISUFFIX}" CACHE INTERNAL "GSI Executable Name") - add_executable(${GSIEXEC} ${CMAKE_CURRENT_SOURCE_DIR}/gsimain.f90 ${CMAKE_CURRENT_SOURCE_DIR}/gsimod.F90 ) - set(GSILIB "gsilib_wrf${debug_suffix}" CACHE INTERNAL "") - add_library(${GSILIB} STATIC ${GSICORE_SRC} ) - set_target_properties(${GSILIB} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_include_directories(${GSILIB} PUBLIC "${PROJECT_BINARY_DIR}/include") - set_target_properties(${GSIEXEC} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_link_libraries( ${GSILIB} ${GSISHAREDLIB} ${wrflib} ) + if(BUILD_NCDIAG) + add_dependencies(${lib} ncdiag) endif() - - if(BUILD_GLOBAL) - set(GSIEXEC "${GSIBASE}${debug_suffix}${GSISUFFIX}" CACHE INTERNAL "GSI Executable Name") - add_executable( ${GSIEXEC} ${GSIMAIN_SRC} ) - set(GSILIB "gsilib_global${debug_suffix}" CACHE INTERNAL "") - set(WRF_LIBRARIES "") - add_library(${GSILIB} STATIC ${GSICORE_SRC} ) - target_link_libraries( ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(${GSILIB} ${GSISHAREDLIB} ) - target_link_libraries( ${GSISHAREDLIB} ${CORE_LIBRARIES}) - set_target_properties( ${GSILIB} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_include_directories( ${GSILIB} PUBLIC "${PROJECT_BINARY_DIR}/include") - set_target_properties(${GSIEXEC} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") + target_link_libraries(${lib} PUBLIC ncdiag::ncdiag) +endforeach() + +# Create a GLOBAL GSI library +add_library(global_gsi STATIC $ + $) +target_include_directories(global_gsi PUBLIC $ + $) + +# Create a REGIONAL GSI library +if(BUILD_REGIONAL) + add_library(regional_gsi STATIC $ + $) + target_include_directories(regional_gsi PUBLIC $ + $) +endif() + +# Create a GLOBAL GSI executable +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi") +add_executable(global_gsi.x ${GSI_SRC_main}) +add_dependencies(global_gsi.x global_gsi) +set_target_properties(global_gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_link_libraries(global_gsi.x PRIVATE global_gsi) +list(APPEND GSI_APP_Targets + global_gsi.x +) + +# Create a REGIONAL GSI executable +if(BUILD_REGIONAL) + set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi") + add_executable(regional_gsi.x ${GSI_SRC_main}) + add_dependencies(regional_gsi.x regional_gsi) + set_target_properties(regional_gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") + target_link_libraries(regional_gsi.x PRIVATE regional_gsi) + list(APPEND GSI_APP_Targets + regional_gsi.x + ) +endif() + +# Link the application targets with dependencies +foreach(app ${GSI_APP_Targets}) + target_link_libraries(${app} PUBLIC bacio::bacio_4) + target_link_libraries(${app} PUBLIC sigio::sigio) + target_link_libraries(${app} PUBLIC sfcio::sfcio) + target_link_libraries(${app} PUBLIC nemsio::nemsio) + target_link_libraries(${app} PUBLIC ncio::ncio) + target_link_libraries(${app} PUBLIC w3emc::w3emc_d) + target_link_libraries(${app} PUBLIC w3nco::w3nco_d) + target_link_libraries(${app} PUBLIC sp::sp_d) + target_link_libraries(${app} PUBLIC bufr::bufr_4_DA) + target_link_libraries(${app} PUBLIC crtm::crtm) + target_link_libraries(${app} PUBLIC ncdiag::ncdiag) + target_link_libraries(${app} PUBLIC NetCDF::NetCDF_Fortran) + target_link_libraries(${app} PUBLIC MPI::MPI_Fortran) + target_link_libraries(${app} PUBLIC ${LAPACK_LIBRARIES}) + if(OpenMP_Fortran_FOUND) + target_link_libraries(${app} PUBLIC OpenMP::OpenMP_Fortran) endif() +endforeach() - if( BUILD_NCDIAG ) - add_dependencies(${GSILIB} ${NCDIAG_LIBRARIES} ) - endif( BUILD_NCDIAG ) - add_dependencies(${GSILIB} ${GSISHAREDLIB} ) - -# Add dependencies if we are building the core libs or are just using pre-built libs - if(CORE_BUILT) - add_dependencies(${GSILIB} ${GSISHAREDLIB} ${CORE_BUILT} ) - add_dependencies(${GSISHAREDLIB} ${bacio} ${CORE_BUILT} ) - add_dependencies(${GSIEXEC} ${GSISHAREDLIB} ${GSILIB} ${CORE_BUILT} ) - else() - add_dependencies(${GSIEXEC} ${GSISHAREDLIB} ${GSILIB} ) - endif() -# Specify all the libraries to be linked into the executable - target_link_libraries(${GSIEXEC} ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ${WRF_LIBRARIES} - ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${HDF5_Fortran_HL_LIBRARIES} ${MPI_Fortran_LIBRARIES} - ${LAPACK_LIBRARIES} -L./ ${EXTRA_LINKER_FLAGS} ${HDF5_LIBRARIES} ${CURL_LIBRARIES} ${CORE_LIBRARIES} ${CORE_BUILT} - ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES} ${GSDCLOUD_LIBRARY} ${ZLIB_LIBRARIES} ${wrflib} ${EXTRA_LINKER_FLAGS} ${FV3GFS_NCIO_LIBRARIES}) - install(TARGETS ${GSIEXEC} - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/static) +# REGIONAL GSI Application specific library dependencies +if(BUILD_REGIONAL) + target_link_libraries(regional_gsi.x PUBLIC wrf_io::wrf_io) +endif() diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake new file mode 100644 index 0000000000..03e358a05a --- /dev/null +++ b/src/gsi/gsi_files.cmake @@ -0,0 +1,662 @@ +list(APPEND GSI_SRC_C +blockIO.c +) + +# Class files for WRF interfaces +list(APPEND GSI_SRC_class +class_get_pseudo_ensperts.f90 +class_get_wrf_mass_ensperts.f90 +class_get_wrf_nmm_ensperts.f90 +class_read_wrf_mass_files.f90 +class_read_wrf_mass_guess.f90 +class_read_wrf_nmm_files.f90 +class_read_wrf_nmm_guess.f90 +class_regional_io.f90 +class_wrf_binary_interface.f90 +class_wrf_netcdf_interface.f90 +class_wrwrfmassa.f90 +class_wrwrfnmma.f90 +) + +# Stubs for Global interface +list(APPEND GSI_SRC_stub +stub_get_pseudo_ensperts.f90 +stub_get_wrf_mass_ensperts.f90 +stub_get_wrf_nmm_ensperts.f90 +stub_read_wrf_mass_files.f90 +stub_read_wrf_mass_guess.f90 +stub_read_wrf_nmm_files.f90 +stub_read_wrf_nmm_guess.f90 +stub_regional_io.f90 +stub_wrf_binary_interface.f90 +stub_wrf_netcdf_interface.f90 +stub_wrwrfmassa.f90 +stub_wrwrfnmma.f90 +) + +list(APPEND GSI_SRC_cplr +cplr_get_pseudo_ensperts.f90 +cplr_get_wrf_mass_ensperts.f90 +cplr_get_wrf_nmm_ensperts.f90 +cplr_read_wrf_mass_files.f90 +cplr_read_wrf_mass_guess.f90 +cplr_read_wrf_nmm_files.f90 +cplr_read_wrf_nmm_guess.f90 +cplr_regional_io.f90 +cplr_wrf_binary_interface.f90 +cplr_wrf_netcdf_interface.f90 +cplr_wrwrfmassa.f90 +cplr_wrwrfnmma.f90 +) + +list(APPEND GSI_SRC_main +gsimain.f90 +gsimod.F90 +) + +list(APPEND GSI_SRC_ncdiag +nc_diag_read_mod.f90 +nc_diag_write_mod.f90 +) + +list(APPEND GSI_SRC_fixture_gfs +gsi_fixture_GFS.F90 +) + +list(APPEND GSI_SRC_fixture_regional +gsi_fixture_REGIONAL.F90 +) + +# All else Fortran sources that are not in above categories +list(APPEND GSI_SRC_Fortran +abstract_ensmod.f90 +adjtest.f90 +adjtest_obs.f90 +adjust_cloudobs_mod.f90 +aero_guess_at_obs_locations.f90 +aeroinfo.f90 +aircraftinfo.f90 +aircraftobsqc.f90 +anberror.f90 +anbkerror.f90 +aniso_ens_util.f90 +anisofilter.f90 +anisofilter_glb.f90 +antcorr_application.f90 +antest_maps0.f90 +antest_maps0_glb.f90 +atms_spatial_average_mod.f90 +balmod.f90 +berror.f90 +bias_predictors.f90 +bicg.f90 +bicglanczos.F90 +bkerror.f90 +bkgcov.f90 +bkgvar.f90 +bkgvar_rewgt.f90 +blacklist.f90 +blendmod.f90 +buddycheck_mod.f90 +calc_fov_conical.f90 +calc_fov_crosstrk.f90 +calctends.f90 +calctends_ad.f90 +calctends_no_ad.f90 +calctends_no_tl.f90 +calctends_tl.f90 +chemmod.f90 +class_get_fv3_regional_ensperts.f90 +cloud_efr_mod.f90 +clw_mod.f90 +cmaq_routines.f90 +co_mop_ak.f90 +coinfo.f90 +combine_radobs.f90 +compact_diffs.f90 +compute_derived.f90 +compute_fact10.f90 +compute_qvar3d.f90 +constants.f90 +control2model.f90 +control2model_ad.f90 +control2state.f90 +control2state_ad.f90 +control_vectors.f90 +convb_ps.f90 +convb_q.f90 +convb_t.f90 +convb_uv.f90 +converr.f90 +converr_ps.f90 +converr_pw.f90 +converr_q.f90 +converr_t.f90 +converr_uv.f90 +convinfo.f90 +convthin.f90 +convthin_time.f90 +correlated_obsmod.F90 +cplr_get_fv3_regional_ensperts.f90 +cplr_gfs_ensmod.f90 +cplr_gfs_nstmod.f90 +crtm_interface.f90 +cvsection.f90 +cwhydromod.f90 +derivsmod.f90 +deter_sfc_mod.f90 +dtast.f90 +egrid2agrid_mod.f90 +en_perts_io.f90 +enorm_state.f90 +ens_spread_mod.f90 +ensctl2model.f90 +ensctl2model_ad.f90 +ensctl2state.f90 +ensctl2state_ad.f90 +evaljgrad.f90 +evaljo.f90 +evalqlim.f90 +fgrid2agrid_mod.f90 +fill_mass_grid2.f90 +fill_nmm_grid2.f90 +fpvsx_ad.f90 +fv3_regional_interface.f90 +general_commvars_mod.f90 +general_read_fv3atm.f90 +general_read_gfsatm.f90 +general_read_nemsaero.f90 +general_read_nmmb.f90 +general_read_nmmb_radar.f90 +general_specmod.f90 +general_spectral_transforms.f90 +general_sub2grid_mod.f90 +general_tll2xy_mod.f90 +general_transform.f90 +general_write_gfsatm.f90 +genex_mod.f90 +gengrid_vars.f90 +genqsat.f90 +genstats_gps.f90 +gesinfo.F90 +get_derivatives.f90 +get_derivatives2.f90 +get_gefs_ensperts_dualres.f90 +get_gefs_for_regional.f90 +get_nmmb_ensperts.f90 +get_semimp_mats.f90 +getcount_bufr.f90 +getprs.f90 +getsiga.f90 +getuv.f90 +getvvel.f90 +gfs_stratosphere.f90 +glbsoi.f90 +grdcrd.f90 +gridmod.F90 +grtest.f90 +gscond_ad.f90 +gsd_terrain_match_surfTobs.f90 +gsd_update_mod.f90 +gsdcloudanalysis.F90 +gsdcloudanalysis4NMMB.F90 +gsdcloudanalysis4gfs.F90 +gsdcloudlib_pseudoq_mod.f90 +gsi_4dcouplermod.f90 +gsi_4dvar.f90 +gsi_aeroOper.F90 +gsi_bias.f90 +gsi_bundlemod.F90 +gsi_chemguess_mod.F90 +gsi_cldchOper.F90 +gsi_cldtotOper.F90 +gsi_colvkOper.F90 +gsi_dbzOper.F90 +gsi_dwOper.F90 +gsi_enscouplermod.f90 +gsi_gpsbendOper.F90 +gsi_gpsrefOper.F90 +gsi_gustOper.F90 +gsi_howvOper.F90 +gsi_io.f90 +gsi_lcbasOper.F90 +gsi_lightOper.F90 +gsi_lwcpOper.F90 +gsi_metguess_mod.F90 +gsi_mitmOper.F90 +gsi_mxtmOper.F90 +gsi_nemsio_mod.f90 +gsi_nstcouplermod.f90 +gsi_o3lOper.F90 +gsi_obOper.F90 +gsi_obOperTypeManager.F90 +gsi_ozOper.F90 +gsi_pblhOper.F90 +gsi_pcpOper.F90 +gsi_pm10Oper.F90 +gsi_pm2_5Oper.F90 +gsi_pmslOper.F90 +gsi_psOper.F90 +gsi_pwOper.F90 +gsi_qOper.F90 +gsi_radOper.F90 +gsi_rfv3io_mod.f90 +gsi_rwOper.F90 +gsi_spdOper.F90 +gsi_sstOper.F90 +gsi_swcpOper.F90 +gsi_tOper.F90 +gsi_tcamtOper.F90 +gsi_tcpOper.F90 +gsi_td2mOper.F90 +gsi_unformatted.F90 +gsi_uwnd10mOper.F90 +gsi_visOper.F90 +gsi_vwnd10mOper.F90 +gsi_wOper.F90 +gsi_wspd10mOper.F90 +gsisub.F90 +guess_grids.F90 +half_nmm_grid2.f90 +hilbert_curve.f90 +hybrid_ensemble_isotropic.F90 +hybrid_ensemble_parameters.f90 +inc2guess.f90 +init_jcdfi.f90 +insitu_info.f90 +intall.f90 +intaod.f90 +intcldch.f90 +intco.f90 +intdbz.f90 +intdw.f90 +intgps.f90 +intgust.f90 +inthowv.f90 +intjcmod.f90 +intjo.f90 +intlag.f90 +intlcbas.f90 +intlight.f90 +intlwcp.f90 +intmitm.f90 +intmxtm.f90 +intoz.f90 +intpblh.f90 +intpcp.f90 +intpm10.f90 +intpm2_5.f90 +intpmsl.f90 +intps.f90 +intpw.f90 +intq.f90 +intrad.f90 +intrp2a.f90 +intrp3oz.f90 +intrp_msk.f90 +intrw.f90 +intspd.f90 +intsst.f90 +intswcp.f90 +intt.f90 +inttcamt.f90 +inttcp.f90 +inttd2m.f90 +intuwnd10m.f90 +intvis.f90 +intvwnd10m.f90 +intw.f90 +intwspd10m.f90 +jcmod.f90 +jfunc.f90 +jgrad.f90 +kinds.F90 +lag_fields.f90 +lag_interp.f90 +lag_traj.f90 +lagmod.f90 +lanczos.F90 +lightinfo.f90 +logcldch_to_cldch.f90 +loglcbas_to_lcbas.f90 +logvis_to_vis.f90 +looplimits.f90 +m_aeroNode.F90 +m_aerolNode.F90 +m_berror_stats.f90 +m_berror_stats_reg.f90 +m_cldchNode.F90 +m_colvkNode.F90 +m_cvgridLookup.F90 +m_dbzNode.F90 +m_dgeevx.F90 +m_distance.f90 +m_dtime.F90 +m_dwNode.F90 +m_extOzone.F90 +m_find.f90 +m_gpsNode.F90 +m_gpsrhs.F90 +m_gsiBiases.f90 +m_gustNode.F90 +m_howvNode.F90 +m_lagNode.F90 +m_latlonRange.F90 +m_lcbasNode.F90 +m_lightNode.F90 +m_lwcpNode.F90 +m_mitmNode.F90 +m_mxtmNode.F90 +m_o3lNode.F90 +m_obsLList.F90 +m_obsNode.F90 +m_obsNodeTypeManager.F90 +m_obsdiagNode.F90 +m_obsdiags.F90 +m_ozNode.F90 +m_pblhNode.F90 +m_pcpNode.F90 +m_pm10Node.F90 +m_pm2_5Node.F90 +m_pmslNode.F90 +m_psNode.F90 +m_pwNode.F90 +m_qNode.F90 +m_radNode.F90 +m_rerank.f90 +m_rhs.F90 +m_rwNode.F90 +m_sortind.f90 +m_spdNode.F90 +m_sstNode.F90 +m_stats.f90 +m_stubTimer.f90 +m_swcpNode.F90 +m_tNode.F90 +m_tcamtNode.F90 +m_tcpNode.F90 +m_td2mNode.F90 +m_tick.F90 +m_uniq.f90 +m_uwnd10mNode.F90 +m_visNode.F90 +m_vwnd10mNode.F90 +m_wNode.F90 +m_wspd10mNode.F90 +mod_fv3_lola.f90 +mod_nmmb_to_a.f90 +mod_strong.f90 +mod_vtrans.f90 +mod_wrfmass_to_a.f90 +model_ad.F90 +model_tl.F90 +mp_compact_diffs_mod1.f90 +mp_compact_diffs_support.f90 +mpeu_util.F90 +mpeu_mpif.F90 +mpimod.F90 +mpl_allreduce.F90 +mpl_bcast.f90 +mrmsmod.f90 +native_endianness.f90 +ncepgfs_ghg.f90 +ncepgfs_io.f90 +ncepnems_io.f90 +netcdf_mod.f90 +netcdfgfs_io.f90 +nlmsas_ad.f90 +nltransf.f90 +normal_rh_to_q.f90 +nstio_module.f90 +obs_ferrscale.F90 +obs_para.f90 +obs_sensitivity.f90 +obserr_allsky_mw.f90 +observer.F90 +obsmod.F90 +omegas_ad.f90 +oneobmod.F90 +ozinfo.f90 +patch2grid_mod.f90 +pcgsoi.f90 +pcgsqrt.f90 +pcp_k.f90 +pcpinfo.f90 +penal.f90 +phil.f90 +phil0.f90 +phil1.f90 +phil2.f90 +pietc.f90 +plib8.f90 +pmat.f90 +pmat4.f90 +pmat6.f90 +polcarf.f90 +prad_bias.f90 +precond.f90 +precpd_ad.f90 +prewgt.f90 +prewgt_reg.f90 +projmethod_support.f90 +prt_guess.f90 +psichi2uv_reg.f90 +psichi2uvt_reg.f90 +psort.f90 +pvqc.f90 +pvqc_tables.f90 +q_diag.f90 +qcmod.f90 +qnewton3.f90 +radiance_mod.f90 +radinfo.f90 +raflib.f90 +rapidrefresh_cldsurf_mod.f90 +rdgrbsst.f90 +read_Lightning.f90 +read_NASA_LaRC_cloud.f90 +read_abi.f90 +read_aerosol.f90 +read_ahi.f90 +read_airs.f90 +read_amsr2.f90 +read_amsre.f90 +read_anowbufr.f90 +read_atms.f90 +read_avhrr.f90 +read_avhrr_navy.f90 +read_bufrtovs.f90 +read_co.f90 +read_cris.f90 +read_dbz_nc.f90 +read_dbz_netcdf.f90 +read_diag.f90 +read_files.f90 +read_fl_hdob.f90 +read_gfs_ozone_for_regional.f90 +read_gmi.f90 +read_goesglm.f90 +read_goesimg.f90 +read_goesimgr_skycover.f90 +read_goesndr.f90 +read_gps.f90 +read_guess.F90 +read_iasi.f90 +read_l2bufr_mod.f90 +read_lag.f90 +read_lidar.f90 +read_mitm_mxtm.f90 +read_modsbufr.f90 +read_nasa_larc.f90 +read_nsstbufr.f90 +read_obs.F90 +read_ozone.f90 +read_pblh.f90 +read_pcp.f90 +read_prepbufr.f90 +read_radar.f90 +read_radar_wind_ascii.f90 +read_radarref_mosaic.f90 +read_rapidscat.f90 +read_saphir.f90 +read_satmar.f90 +read_satwnd.f90 +read_seviri.f90 +read_sfcwnd.f90 +read_ssmi.f90 +read_ssmis.f90 +read_tcps.f90 +read_wcpbufr.f90 +reorg_metar_cloud.f90 +rfdpar.f90 +rsearch.F90 +rtlnmc_version3.f90 +rtma_comp_fact10.f90 +satthin.F90 +set_crtm_aerosolmod.f90 +set_crtm_cloudmod.f90 +setupaod.f90 +setupbend.f90 +setupcldch.f90 +setupcldtot.F90 +setupco.f90 +setupdbz.f90 +setupdbz_lib.f90 +setupdw.f90 +setupgust.f90 +setuphowv.f90 +setuplag.f90 +setuplcbas.f90 +setuplight.f90 +setuplwcp.f90 +setupmitm.f90 +setupmxtm.f90 +setupoz.f90 +setuppblh.f90 +setuppcp.f90 +setuppm10.f90 +setuppm2_5.f90 +setuppmsl.f90 +setupps.f90 +setuppw.f90 +setupq.f90 +setuprad.f90 +setupref.f90 +setuprhsall.f90 +setuprw.f90 +setupspd.f90 +setupsst.f90 +setupswcp.f90 +setupt.f90 +setuptcamt.f90 +setuptcp.f90 +setuptd2m.f90 +setupuwnd10m.f90 +setupvis.f90 +setupvwnd10m.f90 +setupw.f90 +setupwspd10m.f90 +sfc_model.f90 +sfcobsqc.f90 +simpin1.f90 +simpin1_init.f90 +smooth_polcarf.f90 +smoothrf.f90 +smoothwwrf.f90 +smoothzrf.f90 +sparsearr.f90 +sqrtmin.f90 +ssmis_spatial_average_mod.f90 +sst_retrieval.f90 +state_vectors.f90 +statsco.f90 +statsconv.f90 +statslight.f90 +statsoz.f90 +statspcp.f90 +statsrad.f90 +stop1.f90 +stpaod.f90 +stpcalc.f90 +stpcldch.f90 +stpco.f90 +stpdbz.f90 +stpdw.f90 +stpgps.f90 +stpgust.f90 +stphowv.f90 +stpjcmod.f90 +stpjo.f90 +stplcbas.f90 +stplight.f90 +stplwcp.f90 +stpmitm.f90 +stpmxtm.f90 +stpoz.f90 +stppblh.f90 +stppcp.f90 +stppm10.f90 +stppm2_5.f90 +stppmsl.f90 +stpps.f90 +stppw.f90 +stpq.f90 +stprad.f90 +stprw.f90 +stpspd.f90 +stpsst.f90 +stpswcp.f90 +stpt.f90 +stptcamt.f90 +stptcp.f90 +stptd2m.f90 +stpuwnd10m.f90 +stpvis.f90 +stpvwnd10m.f90 +stpw.f90 +stpwspd10m.f90 +strong_bal_correction.f90 +strong_baldiag_inc.f90 +strong_fast_global_mod.f90 +stub_ensmod.f90 +stub_pertmod.F90 +sub2fslab_mod.f90 +sumslightbias.f90 +support_2dvar.f90 +tcv_mod.f90 +tendsmod.f90 +test_obsens.f90 +timermod.f90 +tintrp2a.f90 +tintrp3.f90 +tpause.f90 +tpause_t.F90 +tune_pbl_height.f90 +turbl.f90 +turbl_ad.f90 +turbl_tl.f90 +turblmod.f90 +tv_to_tsen.f90 +unfill_mass_grid2.f90 +unfill_nmm_grid2.f90 +unhalf_nmm_grid2.f90 +update_guess.f90 +ut_gsibundle.F90 +vqc_int.f90 +vqc_setup.f90 +vqc_stp.f90 +wind_fft.f90 +windht.f90 +wrf_mass_guess_mod.f90 +wrf_params_mod.f90 +wrf_vars_mod.f90 +write_all.F90 +write_bkgvars_grid.f90 +write_incr.f90 +xhat_vordivmod.f90 +zrnmi_mod.f90 +) + +# Unused files +#stub_nstmod.f90 +#Nst_Var_ESMFMod.f90 diff --git a/src/gsi/read_l2bufr_mod.f90 b/src/gsi/read_l2bufr_mod.f90 index a124b75d3d..418bd3f20f 100644 --- a/src/gsi/read_l2bufr_mod.f90 +++ b/src/gsi/read_l2bufr_mod.f90 @@ -57,8 +57,8 @@ module read_l2bufr_mod public :: invtllv,radar_sites,radar_box,radar_rmesh,radar_zmesh integer(i_kind) minnum - real(r_kind) del_azimuth,del_elev,del_range,del_time,elev_angle_max,range_max,radar_rmesh,radar_zmesh - logical l2superob_only,radar_sites,radar_box + real(r_kind) del_azimuth,del_elev,del_range,del_time,elev_angle_max,range_max,radar_rmesh,radar_zmesh + logical l2superob_only,radar_sites,radar_box contains @@ -94,10 +94,10 @@ subroutine initialize_superob_radar minnum=50 range_max=100000._r_kind ! (100km) l2superob_only=.false. - radar_sites=.false. - radar_box=.false. - radar_rmesh=10._r_kind - radar_zmesh=500._r_kind + radar_sites=.false. + radar_box=.false. + radar_rmesh=10._r_kind + radar_zmesh=500._r_kind end subroutine initialize_superob_radar subroutine radar_bufr_read_all(npe,mype) @@ -138,17 +138,17 @@ subroutine radar_bufr_read_all(npe,mype) use qcmod, only: vadwnd_l2rw_qc use oneobmod, only: lsingleradar,singleradar use mpeu_util, only: IndexSet, IndexSort - use file_utility, only : get_lun - use constants, only: pi,rearth_equator - use mpeu_util, only: gettablesize,gettable - use gridmod, only: txy2ll + use file_utility, only : get_lun + use constants, only: pi,rearth_equator + use mpeu_util, only: gettablesize,gettable + use gridmod, only: txy2ll use gsi_io, only: verbose implicit none integer(i_kind),intent(in):: npe,mype integer(i_kind),parameter:: max_num_radars=150 - integer(i_kind),parameter:: maxobs=2e8 + integer(i_kind),parameter:: maxobs=2e8 integer(i_kind),parameter:: n_gates_max=4000 real(r_kind),parameter:: four_thirds = 4.0_r_kind / 3.0_r_kind real(r_kind),parameter:: r8 = 8.0_r_kind @@ -173,10 +173,10 @@ subroutine radar_bufr_read_all(npe,mype) integer(i_kind) nsuper,nsuperall integer(i_kind) nthisrad,nthisbins integer(i_kind) idups,idups0 - integer(i_kind) radar_count,radar_true,ntot,nlevz - real(r_kind) dx,dy - real(r_kind) halfpi,twopi,rkm2dg,delat,dgv,rlat_min,rlon_min,dlat_grid,dlon_grid - integer(i_kind) mlat,mlonx,ilev,ilat,ilon + integer(i_kind) radar_count,radar_true,ntot,nlevz + real(r_kind) dx,dy + real(r_kind) halfpi,twopi,rkm2dg,delat,dgv,rlat_min,rlon_min,dlat_grid,dlon_grid + integer(i_kind) mlat,mlonx,ilev,ilat,ilon integer(i_kind) nradials_in,nradials_fail_angmax,nradials_fail_time,nradials_fail_elb integer(i_kind) nradials_in1,nradials_fail_angmax1,nradials_fail_time1,nradials_fail_elb1 integer(i_kind) nobs_in,nobs_badvr,nobs_badsr,nobs_lrbin,nobs_hrbin,nrange_max,irad @@ -240,26 +240,26 @@ subroutine radar_bufr_read_all(npe,mype) equivalence(master_stn_table(1),cmaster_stn_table) equivalence (chdr,hdr(1)) equivalence (chdr2,hdr2(1)) - character(len=*),parameter:: tbname='SUPEROB_RADAR::' + character(len=*),parameter:: tbname='SUPEROB_RADAR::' logical rite,print_verbose - logical lradar - character(len=256),allocatable,dimension(:):: rtable - character(4),allocatable,dimension(:):: rsite - integer(i_kind),allocatable,dimension(:):: ruse - + logical lradar + character(len=256),allocatable,dimension(:):: rtable + character(4),allocatable,dimension(:):: rsite + integer(i_kind),allocatable,dimension(:):: ruse + print_verbose=.false. if(verbose) print_verbose=.true. - if (radar_sites) then + if (radar_sites) then open(666,file=trim('gsiparm.anl'),form='formatted') call gettablesize(tbname,666,ntot,radar_count) - allocate(rtable(radar_count),rsite(radar_count),ruse(radar_count)) - call gettable(tbname,666,ntot,radar_count,rtable) - do i=1,radar_count - read(rtable(i),*) rsite(i),ruse(i) - if (mype==0) write(*,'(A10,X,A4,X,I)'),"Radar sites usage: ",rsite(i),ruse(i) - end do - end if + allocate(rtable(radar_count),rsite(radar_count),ruse(radar_count)) + call gettable(tbname,666,ntot,radar_count,rtable) + do i=1,radar_count + read(rtable(i),*) rsite(i),ruse(i) + if (mype==0) write(*,'(A10,X,A4,X,I2)'),"Radar sites usage: ",rsite(i),ruse(i) + end do + end if ! define infile if using either option for radial winds. do i=1,ndat if(trim(dtype(i))=='rw'.and.trim(dsis(i))=='l2rw'.and.vadwnd_l2rw_qc)then @@ -274,10 +274,10 @@ subroutine radar_bufr_read_all(npe,mype) end do if(mype==0) write(6,*)'RADAR_BUFR_READ_ALL: radial wind infile for superobbing = ',infile if (infile=='') then - if(mype==0) write(6,*) '***WARNING*** NOT USING ANY RADIAL WIND OBSERVATIONS!!!' - return ! Go back to gsisub if nothing to do. + if(mype==0) write(6,*) '***WARNING*** NOT USING ANY RADIAL WIND OBSERVATIONS!!!' + return ! Go back to gsisub if nothing to do. end if - + rad_per_meter= one/rearth erad = rearth nazbin=nint(r360/del_azimuth) @@ -299,7 +299,7 @@ subroutine radar_bufr_read_all(npe,mype) rite = .false. if (mype==0) rite=.true. - + ! Open bufr file with openbf to initialize bufr table, etc in bufrlib inbufr=10 open(inbufr,file=infile,form='unformatted') @@ -326,9 +326,9 @@ subroutine radar_bufr_read_all(npe,mype) idate5(5)=0 ! minutes call w3fs21(idate5,nminref) -! Do an initial read of a bit of data to infer what multiplying factor is for -! radial distance. There is a possible ambiguity, where the scaling is either -! 125 or 250. If the minimum difference between gate distances is 2, then factor +! Do an initial read of a bit of data to infer what multiplying factor is for +! radial distance. There is a possible ambiguity, where the scaling is either +! 125 or 250. If the minimum difference between gate distances is 2, then factor ! is 125, if = 1 then factor is 250. idups=0 @@ -363,14 +363,14 @@ subroutine radar_bufr_read_all(npe,mype) t=(real(nminthis-nminref,r_kind)+real(nint(hdr2(12)),r_kind)*rinv60)*rinv60 if(abs(t)>del_time) cycle nobs_in=nobs_in+n_gates - stn_id=chdr2 - radar_true=0 - if (radar_sites) then - do i=1,radar_count - if (trim(stn_id) .eq. trim(rsite(i)) .and. ruse(i) == 1 ) radar_true=1 - end do - if (radar_true == 0) cycle - end if + stn_id=chdr2 + radar_true=0 + if (radar_sites) then + do i=1,radar_count + if (trim(stn_id) .eq. trim(rsite(i)) .and. ruse(i) == 1 ) radar_true=1 + end do + if (radar_true == 0) cycle + end if ibyte=index(cstn_id_table,stn_id) if(ibyte==0) then num_radars=num_radars+1 @@ -477,11 +477,11 @@ subroutine radar_bufr_read_all(npe,mype) nrange_max=0 nthisrad=nrbin*nazbin*nelbin nthisbins=6*nthisrad - if (radar_box) then + if (radar_box) then twopi = two*pi rkm2dg = 360.0_r_kind/(twopi*rearth_equator)*1.e3_r_kind - dlat_grid = 5.0_r_kind - dlon_grid = 5.0_r_kind + dlat_grid = 5.0_r_kind + dlon_grid = 5.0_r_kind halfpi = half*pi dx=radar_rmesh*rkm2dg dy=dx @@ -545,17 +545,17 @@ subroutine radar_bufr_read_all(npe,mype) nradials_fail_elb=nradials_fail_elb+1 cycle end if - stn_id=chdr + stn_id=chdr ibyte=index(cmaster_stn_table,stn_id) - if (radar_sites) then - radar_true=0 - do i=1,radar_count - if (trim(stn_id) == trim(rsite(i)) .and. ruse(i) == 1) radar_true=1 - end do - if (radar_true == 0) then - cycle - end if - end if + if (radar_sites) then + radar_true=0 + do i=1,radar_count + if (trim(stn_id) == trim(rsite(i)) .and. ruse(i) == 1) radar_true=1 + end do + if (radar_true == 0) then + cycle + end if + end if if(ibyte==0) then write(6,*) ' index error in radar_bufr_read_all -- program stops -- ',ibyte,stn_id call stop2(99) @@ -588,7 +588,7 @@ subroutine radar_bufr_read_all(npe,mype) cycle end if - if (.not.radar_box) then + if (.not.radar_box) then iloc=nrbin*(nazbin*(ielbin-1)+(iazbin-1))+irbin bins(1,iloc,krad)=bins(1,iloc,krad)+range bins(2,iloc,krad)=bins(2,iloc,krad)+stn_az @@ -597,7 +597,7 @@ subroutine radar_bufr_read_all(npe,mype) bins(5,iloc,krad)=bins(5,iloc,krad)+rwnd(2,i)**2 bins(6,iloc,krad)=bins(6,iloc,krad)+t ibins(iloc,krad)=ibins(iloc,krad)+1 - else + else this_stalat=master_lat_table(krad) if(abs(this_stalat)>r89_5) cycle this_stalon=master_lon_table(krad) @@ -665,12 +665,12 @@ subroutine radar_bufr_read_all(npe,mype) caz1=clat0*caz0/clat1 saz1=saz0*cdlon-caz0*sdlon*slat0 corrected_azimuth=atan2(saz1,caz1)*rad2deg - rlat_min=this_stalat-2.5_r_kind - rlon_min=this_stalon-2.5_r_kind + rlat_min=this_stalat-2.5_r_kind + rlon_min=this_stalon-2.5_r_kind ilev=ceiling(thishgt/radar_zmesh) ilat=ceiling((thislat-rlat_min)/delat) - ilon=ceiling((thislon-rlon_min)/(dlon_grid/mlonx)) - iloc=mlat*(mlonx*(ilev-1)+ilon)+ilat + ilon=ceiling((thislon-rlon_min)/(dlon_grid/mlonx)) + iloc=mlat*(mlonx*(ilev-1)+ilon)+ilat bins(1,iloc,krad)=bins(1,iloc,krad)+range bins(2,iloc,krad)=bins(2,iloc,krad)+stn_az bins(3,iloc,krad)=bins(3,iloc,krad)+stn_el @@ -707,7 +707,7 @@ subroutine radar_bufr_read_all(npe,mype) call mpi_reduce(timemin,timemin1,1,mpi_real8,mpi_min,0,mpi_comm_world,ierror) if(mype==0 ) then - + allocate(icount(num_radars_0)) if(rite)write(6,*)'RADAR_BUFR_READ_ALL: num_radars_0 = ',num_radars_0 do irad=1,num_radars_0 @@ -762,7 +762,7 @@ subroutine radar_bufr_read_all(npe,mype) mpi_real16,0,mpi_comm_world,ierror) endif if(mype == 0)then - + ! Create superobs and write out. nsuper=0 vrmax=-huge(vrmax) @@ -792,7 +792,7 @@ subroutine radar_bufr_read_all(npe,mype) if(ibins2(iii,krad) < minnum) cycle thiscount=one_quad/real(ibins2(iii,krad),r_quad) - if (radar_box) then + if (radar_box) then do i=1,6 binsx(i)=bins_work(i,iii,1) end do @@ -817,7 +817,7 @@ subroutine radar_bufr_read_all(npe,mype) errmin=min(errmin,thiserr) thistime=binsx(6) - else + else do i=1,6 binsx(i)=bins_work(i,iii,1) end do @@ -841,11 +841,11 @@ subroutine radar_bufr_read_all(npe,mype) errmax=max(errmax,thiserr) errmin=min(errmin,thiserr) thistime=binsx(6) - end if + end if ! Compute obs height here ! Use 4/3rds rule to get elevation of radar beam -! (if local temperature, moisture available, then vertical position +! (if local temperature, moisture available, then vertical position ! might be estimated with greater accuracy by ray tracing ) aactual=erad+this_stahgt @@ -859,7 +859,7 @@ subroutine radar_bufr_read_all(npe,mype) epsh=(thisrange*thisrange-ha*ha)/(r8*aactual) h=ha-epsh thishgt=this_stahgt+h - + ! Get corrected tilt angle celev=celev0 selev=selev0 @@ -937,7 +937,7 @@ subroutine radar_bufr_read_all(npe,mype) call mpi_finalize(ierror) stop end if - if (radar_sites) deallocate(rtable,rsite,ruse) + if (radar_sites) deallocate(rtable,rsite,ruse) end subroutine radar_bufr_read_all @@ -945,7 +945,7 @@ end subroutine radar_bufr_read_all SUBROUTINE tllv(ALM,APH,TLMO,CTPH0,STPH0,TLM,TPH) !$$$ subprogram documentation block ! . . . -! subprogram: tllv +! subprogram: tllv ! ! prgrmmr: ! diff --git a/src/gsi/read_radar.f90 b/src/gsi/read_radar.f90 index 7493e5d71c..257bd8e1c4 100644 --- a/src/gsi/read_radar.f90 +++ b/src/gsi/read_radar.f90 @@ -28,7 +28,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! 2006-02-03 derber - modify for new obs control and obs count ! 2006-02-08 derber - modify to use new convinfo module ! 2006-02-24 derber - modify to take advantage of convinfo module -! 2006-04-21 parrish - modify to use level 2, 2.5, and/or 3 radar wind +! 2006-04-21 parrish - modify to use level 2, 2.5, and/or 3 radar wind ! superobs, with qc based on vad wind data. ! 2006-05-23 parrish - interpolate model elevation to vad wind site ! 2006-07-28 derber - use r1000 from constants @@ -52,12 +52,12 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! 2012-04-28 s.liu - use new VAD wind ! 2012-11-12 s.liu - add new VAD wind flag ! 2013-01-26 parrish - change from grdcrd to grdcrd1 (to allow successful debug compile on WCOSS) -! 2013-05-07 tong - add reading tdr superobs data +! 2013-05-07 tong - add reading tdr superobs data ! 2013-05-22 tong - Modified the criteria of seperating fore and aft sweeps for TDR NOAA/FRENCH antenna ! 2015-02-23 Rancic/Thomas - add thin4d to time window logical ! 2015-10-01 guo - consolidate use of ob location (in deg) -! 2016-12-21 lippi/carley - add logic to run l2rw loop (==0) or run loop for l3rw and l2_5rw (==1,2) -! to help fix a multiple data read bug (when l2rwbufr and radarbufr were both +! 2016-12-21 lippi/carley - add logic to run l2rw loop (==0) or run loop for l3rw and l2_5rw (==1,2) +! to help fix a multiple data read bug (when l2rwbufr and radarbufr were both ! listed in the OBS_INPUT table) and for added flexibility for experimental setups. ! 2018-02-15 wu - add code for fv3_regional option ! 2020-05-04 wu - no rotate_wind for fv3_regional @@ -100,8 +100,8 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu use deter_sfc_mod, only: deter_sfc2,deter_zsfc_model use mpimod, only: npe use gsi_io, only: verbose - implicit none - + implicit none + ! Declare passed variables character(len=*),intent(in ) :: obstype,infile character(len=20),intent(in ) :: sis @@ -138,13 +138,13 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! Declare local variables logical good,outside,good0,lexist1,lexist2 - + character(10) date character(80) hdrstr(2),datstr(2) character(8) subset,subset_check(3) character(30) outmessage character(255) filename - + integer(i_kind) lnbufr,i,j,k,maxobs,icntpnt,iiout,n,istop integer(i_kind) nmrecs,ibadazm,ibadtilt,ibadrange,ibadwnd,ibaddist,ibadheight,ibadvad,kthin integer(i_kind) iyr,imo,idy,ihr,imn,isc,ithin @@ -155,7 +155,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu integer(i_kind) nreal,nchanl,ilat,ilon,ikx integer(i_kind),dimension(5):: idate5 integer(i_kind) ivad,ivadz,nvad,idomsfc - + real(r_kind) timeb,rmesh,usage,ff10,sfcr,skint,t4dv,t4dvo,toff real(r_kind) eradkm,dlat_earth,dlon_earth real(r_kind) dlat_earth_deg,dlon_earth_deg @@ -164,10 +164,10 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu real(r_kind) rwnd,azm,height,error,wqm real(r_kind) azm_earth,cosazm_earth,sinazm_earth,cosazm,sinazm real(r_kind):: zsges - + real(r_kind),dimension(maxdat):: cdata real(r_kind),allocatable,dimension(:,:):: cdata_all - + real(r_double) rstation_id real(r_double),dimension(12):: hdr character(8) cstaid @@ -177,7 +177,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu real(r_double),dimension(7,maxlevs):: radar_obs real(r_double),dimension(4,maxlevs):: vad_obs real(r_double),dimension(2,maxlevs):: fcst_obs - + character(8) vadid(maxvad) real(r_kind) vadlat(maxvad),vadlon(maxvad),vadqm(maxvad,maxvadbins) real(r_kind) vadu(maxvad,maxvadbins),vadv(maxvad,maxvadbins) @@ -242,7 +242,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu real(r_kind) tdrele1,tdrele2,tdrele3 integer(i_kind) nswp,firstbeam,nforeswp,naftswp,nfore,naft,nswptype,irec logical foreswp,aftswp - + data lnbufr/10/ data hdrstr(1) / 'CLAT CLON SELV ANEL YEAR MNTH DAYS HOUR MINU MGPT' / data hdrstr(2) / 'PTID YEAR MNTH DAYS HOUR MINU SECO CLAT CLON HSMSL ANAZ ANEL' / @@ -251,7 +251,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu data ithin / -9 / data rmesh / -99.999_r_kind / - logical print_verbose + logical print_verbose !*********************************************************************************** print_verbose=.false. if(verbose)print_verbose=.true. @@ -316,7 +316,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu vadqmmax=-huge(vadqmmax) vadqmmin=huge(vadqmmin) -! First read in all vad winds so can use vad wind quality marks to decide +! First read in all vad winds so can use vad wind quality marks to decide ! which radar data to keep ! Open, then read bufr data @@ -339,7 +339,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu newvad=.true. exit loop0 end if - end if + end if ! End of bufr read loop end do loop0 @@ -357,7 +357,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call time_4dvar(idate,toff) write(date,'( i10)') idate - read (date,'(i4,3i2)') iy,im,idd,ihh + read (date,'(i4,3i2)') iy,im,idd,ihh if(print_verbose) & write(6,*)'READ_RADAR: first read vad winds--use vad quality marks to qc 2.5/3 radar winds' @@ -375,7 +375,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call ufbint(lnbufr,hdr,7,1,levs,'SID XOB YOB DHR TYP SAID TSB') kx=nint(hdr(5)) if(kx /= 224) cycle loop1 ! for now just hardwire vad wind type - + ! write(6,*)'new vad::',newvad, hdr(7) if(.not.newvad .and. hdr(7)==2) cycle loop1 if(newvad .and. hdr(7)/=2) cycle loop1 @@ -396,7 +396,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu if (t4dvwinlen) cycle loop1 ! outside time window else timeb=hdr(4) - if(abs(timeb) > ctwind(ikx) .or. abs(timeb) > half) cycle loop1 ! outside time window + if(abs(timeb) > ctwind(ikx) .or. abs(timeb) > half) cycle loop1 ! outside time window endif ! Create table of vad lat-lons and quality marks in 500m increments @@ -446,8 +446,8 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu uob=vad_obs(3,k) vob=vad_obs(4,k) if(newvad) then - diffuu=uob-fcst_obs(1,k) - diffvv=vob-fcst_obs(2,k) + diffuu=uob-fcst_obs(1,k) + diffvv=vob-fcst_obs(2,k) if(sqrt(diffuu**2+diffvv**2)>10.0) cycle if(abs(diffvv)>8.0) cycle if(abs(diffvv)>5.0.and.zob<5000.0) cycle @@ -463,7 +463,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu vadv(ivad,ivadz)=vadv(ivad,ivadz)+vob vadcount(ivad,ivadz)=vadcount(ivad,ivadz)+one end do - + ! End of bufr read loop end do loop1 @@ -486,7 +486,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu end do end if if(print_verbose)write(6,*)' errzmax=',errzmax - + ! Allocate thinning grids around each radar ! space needed is nvad*max_rrr*max_rrr*8*max_zzz ! @@ -494,14 +494,14 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! maxvadbins=20 ! nvad=150 ! space=150*20*20*8*20 = 64000*150=9600000 peanuts - + allocate(nobs_box(max_rrr,8*max_rrr,maxvadbins,nvad)) nobs_box=0 ! Set level2_5 to 0. Then loop over routine twice, first looking for ! level 2.5 data, and setting level2_5=count of 2.5 data for any 2.5 data ! available that passes the vad tests. The second pass puts in level 3 -! data where it is available and no level 2.5 data was saved/available +! data where it is available and no level 2.5 data was saved/available ! (level2_5=0) vadfit2=zero @@ -519,14 +519,14 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu level3_tossed_by_2_5=0 subset_check(1)='NC006002' subset_check(2)='NC006001' - + ! First process any level 2 superobs. ! Initialize variables. ikx=0 do i=1,nconvtype if(trim(ioctype(i)) == trim(obstype))ikx = i end do - + timemax=-huge(timemax) timemin=huge(timemin) errmax=-huge(errmax) @@ -576,7 +576,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu dlon_earth_deg = dlon_earth dlat_earth = dlat_earth * deg2rad dlon_earth = dlon_earth * deg2rad - + if(regional)then call tll2xy(dlon_earth,dlat_earth,dlon,dlat,outside) if (outside) cycle @@ -590,7 +590,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call grdcrd1(dlat,rlats,nlat,1) call grdcrd1(dlon,rlons,nlon,1) endif - + clon=cos(dlon_earth) slon=sin(dlon_earth) clat=cos(dlat_earth) @@ -605,7 +605,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu (sin(vadlon(k))*slon+cos(vadlon(k))*clon) cdist=max(-one,min(cdist,one)) dist=rad2deg*acos(cdist) - + if(dist < 0.2_r_kind) then ivad=k exit @@ -616,7 +616,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu novadmatch=novadmatch+1 cycle end if - + vadlon_earth=vadlon(ivad) vadlat_earth=vadlat(ivad) if(regional)then @@ -653,7 +653,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu dlon_earth=thislon if(dlon_earth>=r360) dlon_earth=dlon_earth-r360 if(dlon_earthzero) errmin=min(error,errmin) - + ! Perform limited qc based on azimuth angle, radial wind ! speed, distance from radar site, elevation of radar, ! height of observation, observation error, and goodness of fit to vad wind @@ -772,8 +772,8 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu end if call deter_sfc2(dlat_earth,dlon_earth,t4dv,idomsfc,skint,ff10,sfcr) - - LEVEL_TWO_READ: if(loop==0 .and. sis=='l2rw') then + + LEVEL_TWO_READ: if(loop==0 .and. sis=='l2rw') then cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude @@ -781,7 +781,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu cdata(5) = rwnd ! wind obs (m/s) cdata(6) = azm*deg2rad ! azimuth angle (radians) cdata(7) = t4dv ! obs time (hour) - cdata(8) = ikx ! type + cdata(8) = ikx ! type cdata(9) = tiltangle ! tilt angle (radians) cdata(10)= staheight ! station elevation (m) cdata(11)= rstation_id ! station id @@ -806,7 +806,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu cdata_all(i,ndata)=cdata(i) end do END IF LEVEL_TWO_READ - + else notgood = notgood + 1 end if @@ -815,7 +815,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu close(lnbufr) ! A simple unformatted fortran file should not be mixed with a bufr I/O - LEVEL_TWO_READ_2: if(loop==0 .and. sis=='l2rw') then + LEVEL_TWO_READ_2: if(loop==0 .and. sis=='l2rw') then write(6,*)'READ_RADAR: ',trim(outmessage),' reached eof on 2/2.5/3 superob radar file' write(6,*)'READ_RADAR: nsuper2_in,nsuper2_kept=',nsuper2_in,nsuper2_kept write(6,*)'READ_RADAR: # no vad match =',novadmatch @@ -827,7 +827,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu write(6,*)'READ_RADAR: # bad obshgts =',ibadheight write(6,*)'READ_RADAR: # bad errors =',ibaderror write(6,*)'READ_RADAR: # bad vadwnd =',ibadvad - write(6,*)'READ_RADAR: # bad fit =',ibadfit + write(6,*)'READ_RADAR: # bad fit =',ibadfit write(6,*)'READ_RADAR: # num thinned =',kthin write(6,*)'READ_RADAR: # notgood0 =',notgood0 write(6,*)'READ_RADAR: # notgood =',notgood @@ -852,7 +852,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu nsuper2_5_kept=0 nsuper3_kept=0 do loop=1,2 - + numhits=0 ibadazm=0 ibadwnd=0 @@ -870,7 +870,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu notgood0=0 ! dist2_5max=-huge(dist2_5max) ! dist2_5min=huge(dist2_5min) - + if(loop==1) outmessage='level 2.5 superobs:' if(loop==2) outmessage='level 3 superobs:' @@ -880,19 +880,19 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu idate5(4) = ihh ! hour idate5(5) = 0 ! minute call w3fs21(idate5,mincy) - + nmrecs=0 - + ! Open, then read bufr data open(lnbufr,file=trim(infile),form='unformatted') - + call openbf(lnbufr,'IN',lnbufr) call datelen(10) call readmg(lnbufr,subset,idate,iret) if(iret==0) then - + ! Big loop over bufr file - + loop2: do call readsb(lnbufr,iret) if(iret/=0) then @@ -906,11 +906,11 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu cycle loop2 end if nmrecs = nmrecs+1 - - + + ! Read header. Extract station infomration call ufbint(lnbufr,hdr,10,1,levs,hdrstr(1)) - + ! rstation_id=hdr(1) !station id write(cstaid,'(2i4)')idint(hdr(1)),idint(hdr(2)) if(cstaid(1:1)==' ')cstaid(1:1)='S' @@ -918,10 +918,10 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu dlon_earth=hdr(2) !station lon (degrees) if (dlon_earth>=r360) dlon_earth=dlon_earth-r360 if (dlon_earth230.0_r_kind .and. & dlat_earth <54.0_r_kind)then cycle loop2 @@ -930,7 +930,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu end if dlat_earth = dlat_earth * deg2rad dlon_earth = dlon_earth * deg2rad - + if(regional)then call tll2xy(dlon_earth,dlat_earth,dlon,dlat,outside) if (outside) cycle loop2 @@ -944,14 +944,14 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call grdcrd1(dlat,rlats,nlat,1) call grdcrd1(dlon,rlons,nlon,1) endif - + clon=cos(dlon_earth) slon=sin(dlon_earth) clat=cos(dlat_earth) slat=sin(dlat_earth) staheight=hdr(3) !station elevation tiltangle=hdr(4)*deg2rad - + ! Find vad wind match ivad=0 do k=1,nvad @@ -959,7 +959,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu (sin(vadlon(k))*slon+cos(vadlon(k))*clon) cdist=max(-one,min(cdist,one)) dist=rad2deg*acos(cdist) - + if(dist < 0.2_r_kind) then ivad=k exit @@ -970,7 +970,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu novadmatch=novadmatch+1 cycle loop2 end if - + vadlon_earth=vadlon(ivad) vadlat_earth=vadlat(ivad) if(regional)then @@ -986,16 +986,16 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call grdcrd1(dlatvad,rlats,nlat,1) call grdcrd1(dlonvad,rlons,nlon,1) endif - + ! Get model terrain at VAD wind location call deter_zsfc_model(dlatvad,dlonvad,zsges) - + iyr = hdr(5) imo = hdr(6) idy = hdr(7) ihr = hdr(8) imn = hdr(9) - + idate5(1) = iyr idate5(2) = imo idate5(3) = idy @@ -1013,12 +1013,12 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu else timeb = real(minobs-mincy,r_kind)*r60inv ! if (abs(timeb)>twind .or. abs(timeb) > ctwind(ikx)) then - if (abs(timeb)>half .or. abs(timeb) > ctwind(ikx)) then + if (abs(timeb)>half .or. abs(timeb) > ctwind(ikx)) then ! write(6,*)'READ_RADAR: time outside window ',timeb,' skip this obs' cycle loop2 endif endif - + ! Go through the data levels call ufbint(lnbufr,radar_obs,7,maxlevs,levs,datstr(1)) if(levs>maxlevs) then @@ -1026,7 +1026,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu 'number of levs=',levs,' > maxlevs=',maxlevs call stop2(84) endif - + numcut=0 do k=1,levs if(loop==1) nsuper2_5_in=nsuper2_5_in+1 @@ -1040,7 +1040,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu numcut=numcut+1 cycle end if - + ! Exclude data if it does not fall within time window if (l4dvar.or.l4densvar) then if (t4dvowinlen) cycle @@ -1053,11 +1053,11 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu cycle end if end if - + ! Get observation (lon,lat). Compute distance from radar. if(radar_obs(3,k)>=r360) radar_obs(3,k)=radar_obs(3,k)-r360 if(radar_obs(3,k)max_rrr) cycle - + ! Set observation "type" to be function of distance from radar kxadd=nint(dist*one_tenth) kx=kx0+kxadd - + ! Extract radial wind data height= radar_obs(4,k) rwnd = radar_obs(5,k) @@ -1104,9 +1104,9 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu iaaa=iaaa+1 iaaamax=max(iaaamax,iaaa) iaaamin=min(iaaamin,iaaa) - + error = erradar_inflate*radar_obs(7,k) - + ! Increase error for lev2.5 and lev3 if (wrf_nmm_regional.or.nems_nmmb_regional.or.cmaq_regional.or.wrf_mass_regional & .or. fv3_regional ) then @@ -1117,11 +1117,11 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu end if errmax=max(error,errmax) if(radar_obs(7,k)>zero) errmin=min(error,errmin) - + ! Perform limited qc based on azimuth angle, radial wind ! speed, distance from radar site, elevation of radar, ! height of observation, observation error. - + good0=.true. if(abs(azm)>r400) then ibadazm=ibadazm+1; good0=.false. @@ -1149,7 +1149,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu notgood0=notgood0+1 cycle else - + ! Check against vad wind quality mark ivadz=nint(height/dzvad) if(ivadz>maxvadbins.or.ivadz<1) then @@ -1181,7 +1181,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ibadvad=ibadvad+1 ; good=.false. end if end if - + ! If data is good, load into output array if(good) then if(loop==1.and.ivad>0) then @@ -1200,9 +1200,9 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu if(ncnumgrp(ikx) > 0 )then ! cross validation on if(mod(ndata,ncnumgrp(ikx))== ncgroup(ikx)-1)usage=ncmiter(ikx) end if - + call deter_sfc2(dlat_earth,dlon_earth,t4dv,idomsfc,skint,ff10,sfcr) - + cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude @@ -1210,7 +1210,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu cdata(5) = rwnd ! wind obs (m/s) cdata(6) = azm*deg2rad ! azimuth angle (radians) cdata(7) = t4dvo ! obs time (hour) - cdata(8) = ikx ! type + cdata(8) = ikx ! type cdata(9) = tiltangle ! tilt angle (radians) cdata(10)= staheight ! station elevation (m) cdata(11)= rstation_id ! station id @@ -1229,30 +1229,30 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu else cdata(22)=three end if - + do i=1,maxdat cdata_all(i,ndata)=cdata(i) end do - + else notgood = notgood + 1 end if - + ! End of k loop over levs end do - + ! End of bufr read loop end do loop2 end if - + ! Normal exit ! Close unit to bufr file call closbf(lnbufr) - - + + write(6,*)'READ_RADAR: ',trim(outmessage),' reached eof on 2.5/3 superob radar file.' - + if(loop==1) write(6,*)'READ_RADAR: nsuper2_5_in,nsuper2_5_kept=',nsuper2_5_in,nsuper2_5_kept if(loop==2) write(6,*)'READ_RADAR: nsuper3_in,nsuper3_kept=',nsuper3_in,nsuper3_kept write(6,*)'READ_RADAR: # no vad match =',novadmatch @@ -1264,7 +1264,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu write(6,*)'READ_RADAR: # bad obshgts =',ibadheight write(6,*)'READ_RADAR: # bad errors =',ibaderror write(6,*)'READ_RADAR: # bad vadwnd =',ibadvad - write(6,*)'READ_RADAR: # bad fit =',ibadfit + write(6,*)'READ_RADAR: # bad fit =',ibadfit write(6,*)'READ_RADAR: # num thinned =',kthin write(6,*)'READ_RADAR: # notgood0 =',notgood0 write(6,*)'READ_RADAR: # notgood =',notgood @@ -1273,7 +1273,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu write(6,*)'READ_RADAR: errmin,max =',errmin,errmax write(6,*)'READ_RADAR: dlatmin,max,dlonmin,max=',dlatmin,dlatmax,dlonmin,dlonmax write(6,*)'READ_RADAR: iaaamin,max,8*max_rrr =',iaaamin,iaaamax,8*max_rrr - + end do ! end bigger loop over first level 2.5, then level 3 radar data END IF LEVEL_THREE_READ @@ -1417,14 +1417,14 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu this_stalon,this_stahgt,azm0,elev0,range0,thisvr,rotang nread=nread+1 - + idate5(1) = iyr idate5(2) = imo idate5(3) = idy idate5(4) = ihr idate5(5) = imn call w3fs21(idate5,minobs) - + t4dv=real(minobs-iwinbgn,r_kind)*r60inv if (l4dvar.or.l4densvar) then if (t4dvwinlen) cycle loop3 @@ -1436,7 +1436,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu timemax=max(timemax,timeo) timemin=min(timemin,timeo) - + rlon0=deg2rad*this_stalon this_stalatr=this_stalat*deg2rad clat0=cos(this_stalatr) ; slat0=sin(this_stalatr) @@ -1448,7 +1448,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu if(abs(thistilt)>r75)then ibadtilt=ibadtilt+1; cycle loop3 endif - + staheight=this_stahgt if(staheight<-r1000.or.staheight>r50000) then ibadstaheight=ibadstaheight+1; cycle loop3 @@ -1459,7 +1459,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu selev0=sin(thistiltr) ; celev0=cos(thistiltr) a43=four_thirds*aactual - + call getvrlocalinfo(thisrange,thisazimuth,this_stahgt,aactual,a43,selev0,celev0, & rlon0,clat0,slat0,r8,r89_5,nsubzero,ii,z(ii),elev(ii),elat8(ii), & elon8(ii),glob_azimuth8(ii)) @@ -1647,7 +1647,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu if(ncnumgrp(ikx) > 0 )then ! cross validation on if(mod(ndata,ncnumgrp(ikx))== ncgroup(ikx)-1)usage=ncmiter(ikx) end if - + call deter_zsfc_model(dlat,dlon,zsges) ! Get information from surface file necessary for conventional data here @@ -1683,7 +1683,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu else notgood = notgood + 1 end if ! if(good) - + end do loop3! end of loop, reading records of data close(25) @@ -1723,7 +1723,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! Big loop over bufr file - loop5: do + loop5: do call readsb(lnbufr,iret) if(iret/=0) then call readmg(lnbufr,subset,idate,iret) @@ -1788,7 +1788,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! Big loop over bufr file - loop4: do + loop4: do call readsb(lnbufr,iret) if(iret/=0) then call readmg(lnbufr,subset,idate,iret) @@ -1820,9 +1820,9 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu endif kx=990+nint(hdr(1)) - + if(nmrecs==1)print *,'Antenna ID:', hdr(1),cstaid - + iyr = hdr(2) imo = hdr(3) idy = hdr(4) @@ -1880,7 +1880,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu tdrele2 = hdr(12) if(nswptype == 0)then tdrele3 = hdr(12) - end if + end if firstbeam = 1 endif @@ -1890,7 +1890,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu tdrele3 = hdr(12) if(firstbeam > 0 .and. tdrele2>=tdrele1 .and. tdrele2>=tdrele3 .and. tdrele2 > r60 & - .and. irec > r150)then + .and. irec > r150)then if(foreswp) then foreswp = .false. aftswp = .true. @@ -1902,7 +1902,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu nforeswp = nforeswp+1 irec=0 endif - + nswp = nswp+1 endif @@ -1981,7 +1981,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu end do ! Further process tail Doppler radar Vr data - iimax=max(iimax,ii) + iimax=max(iimax,ii) if( ii > 0 )then dlat_earth=this_stalat !station lat (degrees) @@ -1990,7 +1990,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu if (dlon_earth Date: Thu, 11 Feb 2021 17:21:31 +0000 Subject: [PATCH 04/58] wcoss_d build --- CMakeLists.txt | 5 ++- modulefiles/modulefile.ProdGSI.wcoss_d | 56 +++++++++++++++----------- src/gsi/CMakeLists.txt | 1 + 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02709cfdc4..d6a4072af8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(GSI list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) -include(${PROJECT_NAME}_compiler_flags) +include(gsi_compiler_flags) include(GNUInstallDirs) if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") @@ -62,6 +62,9 @@ if(BUILD_REGIONAL) find_package(wrf_io REQUIRED) endif() +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + # Build components add_subdirectory(src) #add_subdirectory(util) diff --git a/modulefiles/modulefile.ProdGSI.wcoss_d b/modulefiles/modulefile.ProdGSI.wcoss_d index bd2ce7009c..c957219440 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_d +++ b/modulefiles/modulefile.ProdGSI.wcoss_d @@ -8,44 +8,52 @@ ##} #module-whatis " NOAA-EMC/GSI whatis description" -set COMP ifort -set COMP_MPI mpiifort - -set C_COMP icc - -# Known conflicts +# Load hpc-stack +module use /usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack +module load hpc/1.1.0 # Load pe environment module load lsf/10.1 # Load Intel Compiler Suite -module load ips/18.0.1.163 +module load hpc-ips/18.0.1.163 # Load Intel mpi -module load impi/18.0.1 +module load hpc-impi/18.0.1 -# Load production utilities -module load prod_util/1.1.5 +# Load jasper, zlib and png +module load jasper/2.0.22 +module load zlib/1.2.11 +module load png/1.6.35 + +# Load HDF5 and netcdf +module load hdf5/1.10.6 +module load netcdf/4.7.4 # Load nceplibs modules -module load bufr/11.3.0 -module load ip/3.0.2 -module load nemsio/2.2.4 -module load sfcio/1.0.0 -module load sigio/2.1.0 -module load sp/2.0.3 -module load w3nco/2.2.0 -module load w3emc/2.4.0 -module load bacio/2.0.3 +module load bacio/2.4.1 +module load w3nco/2.4.1 +module load bufr/11.4.0 +module load ip/3.3.3 +module load nemsio/2.5.2 +module load sfcio/1.4.1 +module load sigio/2.3.2 +module load sp/2.3.3 +module load w3emc/2.7.3 module load crtm/2.3.0 +setenv CRTM_FIX /gpfs/dell1/nco/ops/nwprod/lib/crtm/v2.3.0/fix -# Load cmake -module load cmake/3.10.0 +# Load production utilities +module load prod_util/1.2.2 # Load python module load python/3.6.3 -# Load netcdf and hdf -module load NetCDF-parallel/4.7.4 -module load HDF5-parallel/1.10.6 +# Load cmake +module load cmake/3.16.2 +setenv CMAKE_C_COMPILER mpiicc +setenv CMAKE_CXX_COMPILER mpiicpc +setenv CMAKE_Fortran_COMPILER mpiifort + +# Known conflicts diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 6c4de7363f..c220a10861 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -65,6 +65,7 @@ endif() # Link the Fortran targets with dependencies foreach(lib ${GSI_LIB_Fortran_Targets}) target_compile_definitions(${lib} PUBLIC "_REAL8_") + target_link_libraries(${lib} PUBLIC bacio::bacio_4) target_link_libraries(${lib} PUBLIC sigio::sigio) target_link_libraries(${lib} PUBLIC sfcio::sfcio) target_link_libraries(${lib} PUBLIC nemsio::nemsio) From f8ca333d39c5abc26bc021fe66b1e8133df338f6 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 11 Feb 2021 14:15:25 -0500 Subject: [PATCH 05/58] hierarchy of compiler flags --- CMakeLists.txt | 2 +- ...piler_flags.cmake => compiler_flags.cmake} | 12 ++++++ cmake/compiler_flags_GNU_C.cmake | 40 +++++++++++++++++ cmake/compiler_flags_GNU_Fortran.cmake | 2 +- src/gsi/CMakeLists.txt | 5 +++ src/gsi/cmake/compiler_flags_GNU_C.cmake | 40 +++++++++++++++++ .../cmake/compiler_flags_GNU_Fortran.cmake | 43 +++++++++++++++++++ .../cmake/compiler_flags_Intel_Fortran.cmake | 41 ++++++++++++++++++ src/gsi/cmake/gsiapp_compiler_flags.cmake | 27 ++++++++++++ 9 files changed, 210 insertions(+), 2 deletions(-) rename cmake/{gsi_compiler_flags.cmake => compiler_flags.cmake} (55%) create mode 100644 cmake/compiler_flags_GNU_C.cmake create mode 100644 src/gsi/cmake/compiler_flags_GNU_C.cmake create mode 100644 src/gsi/cmake/compiler_flags_GNU_Fortran.cmake create mode 100644 src/gsi/cmake/compiler_flags_Intel_Fortran.cmake create mode 100644 src/gsi/cmake/gsiapp_compiler_flags.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d6a4072af8..691a0a4898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(GSI list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) -include(gsi_compiler_flags) +include(compiler_flags) include(GNUInstallDirs) if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") diff --git a/cmake/gsi_compiler_flags.cmake b/cmake/compiler_flags.cmake similarity index 55% rename from cmake/gsi_compiler_flags.cmake rename to cmake/compiler_flags.cmake index 2c1ea8ebba..601e619ca5 100644 --- a/cmake/gsi_compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -13,3 +13,15 @@ elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") else() message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(compiler_flags_GNU_C) +elseif( CMAKE_C_COMPILER_ID MATCHES "Intel") + include(compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/cmake/compiler_flags_GNU_C.cmake b/cmake/compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..e79145242e --- /dev/null +++ b/cmake/compiler_flags_GNU_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake index be5556137f..5203d50656 100644 --- a/cmake/compiler_flags_GNU_Fortran.cmake +++ b/cmake/compiler_flags_GNU_Fortran.cmake @@ -8,7 +8,7 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-lengt # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions ") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions") #################################################################### # DEBUG FLAGS diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index c220a10861..651ee584de 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -1,3 +1,8 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +# Get compiler flags for the GSI application +include(gsiapp_compiler_flags) + # Get the list of all source files include(gsi_files.cmake) diff --git a/src/gsi/cmake/compiler_flags_GNU_C.cmake b/src/gsi/cmake/compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..49f629ff04 --- /dev/null +++ b/src/gsi/cmake/compiler_flags_GNU_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/gsi/cmake/compiler_flags_GNU_Fortran.cmake b/src/gsi/cmake/compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..a23c0962dc --- /dev/null +++ b/src/gsi/cmake/compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,43 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..7339c76f99 --- /dev/null +++ b/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -ip -ipo -unroll -inline -no-heap-arrays") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/src/gsi/cmake/gsiapp_compiler_flags.cmake b/src/gsi/cmake/gsiapp_compiler_flags.cmake new file mode 100644 index 0000000000..601e619ca5 --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags.cmake @@ -0,0 +1,27 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(compiler_flags_GNU_Fortran) +elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(compiler_flags_GNU_C) +elseif( CMAKE_C_COMPILER_ID MATCHES "Intel") + include(compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() From e9b065263d797f2337c5906253f7cef24095cc6a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 11 Feb 2021 15:25:45 -0500 Subject: [PATCH 06/58] Update Intel Fortran flags --- CMakeLists.txt | 4 ++++ src/gsi/cmake/compiler_flags_Intel_Fortran.cmake | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 691a0a4898..6faef82e94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,10 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Produ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") endif() +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") endif() diff --git a/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake index 7339c76f99..672f1baae1 100644 --- a/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake +++ b/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake @@ -2,13 +2,13 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -convert big_endian -implicitnone") #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") #################################################################### # DEBUG FLAGS @@ -20,7 +20,7 @@ set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 - # PRODUCTION FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -ip -ipo -unroll -inline -no-heap-arrays") +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") #################################################################### # LINK FLAGS From 4e2f4363c98ffc3bed9b93392ee044ed8b45a1eb Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 11 Feb 2021 16:35:36 -0500 Subject: [PATCH 07/58] order of includes matter --- CMakeLists.txt | 11 ++++++++++- cmake/compiler_flags.cmake | 4 ++-- cmake/compiler_flags_GNU_Fortran.cmake | 4 ++-- src/gsi/cmake/gsiapp_compiler_flags.cmake | 16 ++++++---------- ...C.cmake => gsiapp_compiler_flags_GNU_C.cmake} | 0 ...e => gsiapp_compiler_flags_GNU_Fortran.cmake} | 10 +++++----- ...=> gsiapp_compiler_flags_Intel_Fortran.cmake} | 0 7 files changed, 25 insertions(+), 20 deletions(-) rename src/gsi/cmake/{compiler_flags_GNU_C.cmake => gsiapp_compiler_flags_GNU_C.cmake} (100%) rename src/gsi/cmake/{compiler_flags_GNU_Fortran.cmake => gsiapp_compiler_flags_GNU_Fortran.cmake} (77%) rename src/gsi/cmake/{compiler_flags_Intel_Fortran.cmake => gsiapp_compiler_flags_Intel_Fortran.cmake} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6faef82e94..f55f90c907 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,18 +28,27 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) option(BUILD_NCDIAG "Build and use inline NetCDF diagnostics library" ON) option(BUILD_REGIONAL "Build Regional GSI" OFF) # Echo user options message(STATUS "OPENMP ................. ${OPENMP}") +message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") message(STATUS "BUILD_NCDIAG ........... ${BUILD_NCDIAG}") message(STATUS "BUILD_REGIONAL ......... ${BUILD_REGIONAL}") # Dependencies +if(ENABLE_MKL) + find_package(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + find_package(LAPACK REQUIRED) +endif() find_package(MPI REQUIRED) find_package(NetCDF REQUIRED Fortran) -find_package(LAPACK REQUIRED) if(OPENMP) find_package(OpenMP REQUIRED) endif() diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index 601e619ca5..08256026be 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -8,7 +8,7 @@ endif() if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") include(compiler_flags_GNU_Fortran) -elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") include(compiler_flags_Intel_Fortran) else() message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") @@ -20,7 +20,7 @@ endif() if(CMAKE_C_COMPILER_ID MATCHES "GNU") include(compiler_flags_GNU_C) -elseif( CMAKE_C_COMPILER_ID MATCHES "Intel") +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") include(compiler_flags_Intel_C) else() message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake index 5203d50656..8090f8bf12 100644 --- a/cmake/compiler_flags_GNU_Fortran.cmake +++ b/cmake/compiler_flags_GNU_Fortran.cmake @@ -8,13 +8,13 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-lengt # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") #################################################################### # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") #################################################################### # PRODUCTION FLAGS diff --git a/src/gsi/cmake/gsiapp_compiler_flags.cmake b/src/gsi/cmake/gsiapp_compiler_flags.cmake index 601e619ca5..c8a0f37ae4 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags.cmake @@ -1,15 +1,11 @@ -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") - add_definitions(-DNDEBUG) -endif() - ####################################################################################### # Fortran ####################################################################################### if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - include(compiler_flags_GNU_Fortran) -elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - include(compiler_flags_Intel_Fortran) + include(gsiapp_compiler_flags_GNU_Fortran) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(gsiapp_compiler_flags_Intel_Fortran) else() message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") endif() @@ -19,9 +15,9 @@ endif() ####################################################################################### if(CMAKE_C_COMPILER_ID MATCHES "GNU") - include(compiler_flags_GNU_C) -elseif( CMAKE_C_COMPILER_ID MATCHES "Intel") - include(compiler_flags_Intel_C) + include(gsiapp_compiler_flags_GNU_C) +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + include(gsiapp_compiler_flags_Intel_C) else() message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") endif() diff --git a/src/gsi/cmake/compiler_flags_GNU_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake similarity index 100% rename from src/gsi/cmake/compiler_flags_GNU_C.cmake rename to src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake diff --git a/src/gsi/cmake/compiler_flags_GNU_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake similarity index 77% rename from src/gsi/cmake/compiler_flags_GNU_Fortran.cmake rename to src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake index a23c0962dc..8861c51715 100644 --- a/src/gsi/cmake/compiler_flags_GNU_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake @@ -2,31 +2,31 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -fno-second-underscore -ffast-math") #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "") +set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}") #################################################################### # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "") +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}") #################################################################### # PRODUCTION FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_PRODUCTION "") +set(CMAKE_Fortran_FLAGS_PRODUCTION "${CMAKE_Fortran_FLAGS_PRODUCTION}") #################################################################### # LINK FLAGS #################################################################### -set(CMAKE_Fortran_LINK_FLAGS "") +set(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS}") #################################################################### # FLAGS FOR AUTOPROFILING diff --git a/src/gsi/cmake/compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake similarity index 100% rename from src/gsi/cmake/compiler_flags_Intel_Fortran.cmake rename to src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake From ffc1067c9ee7e637426e815e57ef0d5b2a7bf7c4 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 12 Feb 2021 20:09:38 -0500 Subject: [PATCH 08/58] install built library and executable for GSI --- src/gsi/CMakeLists.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 651ee584de..9d6c00cddd 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -80,7 +80,7 @@ foreach(lib ${GSI_LIB_Fortran_Targets}) target_link_libraries(${lib} PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(${lib} PUBLIC MPI::MPI_Fortran) if(OpenMP_Fortran_FOUND) - target_link_libraries(${lib} PUBLIC OpenMP::OpenMP_Fortran) + target_link_libraries(${lib} PRIVATE OpenMP::OpenMP_Fortran) endif() if(BUILD_NCDIAG) add_dependencies(${lib} ncdiag) @@ -91,15 +91,21 @@ endforeach() # Create a GLOBAL GSI library add_library(global_gsi STATIC $ $) +add_library(${PROJECT_NAME}::global_gsi ALIAS global_gsi) target_include_directories(global_gsi PUBLIC $ $) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) +list(APPEND GSI_LIB_Targets global_gsi) # Create a REGIONAL GSI library if(BUILD_REGIONAL) add_library(regional_gsi STATIC $ $) + add_library(${PROJECT_NAME}::regional_gsi ALIAS regional_gsi) target_include_directories(regional_gsi PUBLIC $ $) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + list(APPEND GSI_LIB_Targets regional_gsi) endif() # Create a GLOBAL GSI executable @@ -141,7 +147,7 @@ foreach(app ${GSI_APP_Targets}) target_link_libraries(${app} PUBLIC MPI::MPI_Fortran) target_link_libraries(${app} PUBLIC ${LAPACK_LIBRARIES}) if(OpenMP_Fortran_FOUND) - target_link_libraries(${app} PUBLIC OpenMP::OpenMP_Fortran) + target_link_libraries(${app} PRIVATE OpenMP::OpenMP_Fortran) endif() endforeach() @@ -149,3 +155,10 @@ endforeach() if(BUILD_REGIONAL) target_link_libraries(regional_gsi.x PUBLIC wrf_io::wrf_io) endif() + +install( + TARGETS ${GSI_LIB_Targets} ${GSI_APP_Targets} + EXPORT ${PROJECT_NAME}Exports + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) From 07fb370d66b0040d0d40035e3a9b9306bb867635 Mon Sep 17 00:00:00 2001 From: "russ.treadon" Date: Mon, 15 Feb 2021 16:25:12 +0000 Subject: [PATCH 09/58] Issue #112: update intel fortran flags, add intel c flags, replace fv3gfs_ncio with ncio module, replace bufr_4_DA with bufr_d --- cmake/compiler_flags_Intel_C.cmake | 40 +++++++++++++++++++ cmake/compiler_flags_Intel_Fortran.cmake | 6 +-- src/gsi/CMakeLists.txt | 2 +- .../cmake/gsiapp_compiler_flags_Intel_C.cmake | 40 +++++++++++++++++++ src/gsi/cplr_gfs_ensmod.f90 | 2 +- src/gsi/general_read_gfsatm.f90 | 2 +- src/gsi/gesinfo.F90 | 2 +- src/gsi/get_gefs_for_regional.f90 | 2 +- src/gsi/gfs_stratosphere.f90 | 4 +- src/gsi/netcdfgfs_io.f90 | 16 ++++---- src/gsi/read_files.f90 | 2 +- src/gsi/read_gfs_ozone_for_regional.f90 | 2 +- .../cmake/compiler_flags_Intel_Fortran.cmake | 6 +-- 13 files changed, 103 insertions(+), 23 deletions(-) create mode 100644 cmake/compiler_flags_Intel_C.cmake create mode 100644 src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake diff --git a/cmake/compiler_flags_Intel_C.cmake b/cmake/compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..e79145242e --- /dev/null +++ b/cmake/compiler_flags_Intel_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/cmake/compiler_flags_Intel_Fortran.cmake b/cmake/compiler_flags_Intel_Fortran.cmake index 7339c76f99..48f94f45a1 100644 --- a/cmake/compiler_flags_Intel_Fortran.cmake +++ b/cmake/compiler_flags_Intel_Fortran.cmake @@ -2,13 +2,13 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -assume byterecl -convert big_endian -implicitnone") #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") #################################################################### # DEBUG FLAGS @@ -20,7 +20,7 @@ set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 - # PRODUCTION FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -ip -ipo -unroll -inline -no-heap-arrays") +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") #################################################################### # LINK FLAGS diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 9d6c00cddd..b6ff4d5902 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -140,7 +140,7 @@ foreach(app ${GSI_APP_Targets}) target_link_libraries(${app} PUBLIC w3emc::w3emc_d) target_link_libraries(${app} PUBLIC w3nco::w3nco_d) target_link_libraries(${app} PUBLIC sp::sp_d) - target_link_libraries(${app} PUBLIC bufr::bufr_4_DA) + target_link_libraries(${app} PUBLIC bufr::bufr_d) target_link_libraries(${app} PUBLIC crtm::crtm) target_link_libraries(${app} PUBLIC ncdiag::ncdiag) target_link_libraries(${app} PUBLIC NetCDF::NetCDF_Fortran) diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..49f629ff04 --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/gsi/cplr_gfs_ensmod.f90 b/src/gsi/cplr_gfs_ensmod.f90 index d9614b83aa..7b27ca79d5 100644 --- a/src/gsi/cplr_gfs_ensmod.f90 +++ b/src/gsi/cplr_gfs_ensmod.f90 @@ -1034,7 +1034,7 @@ subroutine parallel_read_gfsnc_state_(en_full,m_cvars2d,m_cvars3d,nlon,nlat,nsig use constants, only: r60,r3600,zero,one,half,pi,deg2rad use control_vectors, only: cvars2d,cvars3d,nc2d,nc3d use general_sub2grid_mod, only: sub2grid_info - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata implicit none diff --git a/src/gsi/general_read_gfsatm.f90 b/src/gsi/general_read_gfsatm.f90 index fb7c568b33..34835ed9b2 100755 --- a/src/gsi/general_read_gfsatm.f90 +++ b/src/gsi/general_read_gfsatm.f90 @@ -1668,7 +1668,7 @@ subroutine general_read_gfsatm_nc(grd,sp_a,filename,uvflag,vordivflag,zflag, & use constants, only: two,pi,half,deg2rad,r60,r3600 use gsi_bundlemod, only: gsi_bundle use gsi_bundlemod, only: gsi_bundlegetpointer - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata,get_idate_from_time_units use gfsreadmod, only: general_reload diff --git a/src/gsi/gesinfo.F90 b/src/gsi/gesinfo.F90 index 48757c2135..d869b49684 100644 --- a/src/gsi/gesinfo.F90 +++ b/src/gsi/gesinfo.F90 @@ -84,7 +84,7 @@ subroutine gesinfo sigio_sropen use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_getheadvar - use module_fv3gfs_ncio, only: Dimension, Dataset, open_dataset, get_dim, & + use module_ncio, only: Dimension, Dataset, open_dataset, get_dim, & read_vardata, get_idate_from_time_units,& read_attribute, close_dataset diff --git a/src/gsi/get_gefs_for_regional.f90 b/src/gsi/get_gefs_for_regional.f90 index b2e8b3089a..7c2922cdb0 100644 --- a/src/gsi/get_gefs_for_regional.f90 +++ b/src/gsi/get_gefs_for_regional.f90 @@ -78,7 +78,7 @@ subroutine get_gefs_for_regional use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dimension, Dataset, open_dataset, get_dim, & + use module_ncio, only: Dimension, Dataset, open_dataset, get_dim, & read_vardata, get_idate_from_time_units,& read_attribute, close_dataset use get_wrf_mass_ensperts_mod, only: get_wrf_mass_ensperts_class diff --git a/src/gsi/gfs_stratosphere.f90 b/src/gsi/gfs_stratosphere.f90 index 4a855673a2..22581b2db0 100644 --- a/src/gsi/gfs_stratosphere.f90 +++ b/src/gsi/gfs_stratosphere.f90 @@ -181,7 +181,7 @@ subroutine mix_gfs_nmmb_vcoords(deta1 ,aeta1 ,eta1 ,deta2 ,aeta2 ,eta2 ,pdtop,pt use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dataset, Dimension, get_dim, read_vardata,& + use module_ncio, only: Dataset, Dimension, get_dim, read_vardata,& open_dataset, close_dataset, read_attribute,& get_idate_from_time_units @@ -900,7 +900,7 @@ subroutine add_gfs_stratosphere use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dataset,Dimension,open_dataset,close_dataset,& + use module_ncio, only: Dataset,Dimension,open_dataset,close_dataset,& read_attribute,get_dim,read_vardata,& get_idate_from_time_units diff --git a/src/gsi/netcdfgfs_io.f90 b/src/gsi/netcdfgfs_io.f90 index eb90b7d142..b9631d7e15 100644 --- a/src/gsi/netcdfgfs_io.f90 +++ b/src/gsi/netcdfgfs_io.f90 @@ -31,7 +31,7 @@ module netcdfgfs_io ! machine: ! ! NOTE: This module adds capability to read netCDF FV3 first guess files -! and to write netCDF FV3 analysis files using the fv3gfs_ncio interface +! and to write netCDF FV3 analysis files using the ncio interface ! Using this is controled by a namelist argument "use_gfs_ncio" ! ! @@ -390,7 +390,7 @@ subroutine read_atm_ (grd,filename,sp_a,uvflag,vordivflag,zflag, & use general_specmod, only: spec_vars use general_sub2grid_mod, only: sub2grid_info use mpimod, only: npe,mpi_comm_world,ierror,mpi_rtype,mype - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& quantize_data,close_dataset, get_dim, read_vardata, get_idate_from_time_units use egrid2agrid_mod,only: g_egrid2agrid,g_create_egrid2agrid,egrid2agrid_parm,destroy_egrid2agrid use constants, only: two,pi,half,deg2rad @@ -863,7 +863,7 @@ subroutine read_sfc_(sfct,soil_moi,sno,soil_temp,veg_frac,fact10,sfc_rough, & use gridmod, only: nlat_sfc,nlon_sfc use guess_grids, only: nfldsfc,ifilesfc use constants, only: zero,two - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata, get_idate_from_time_units implicit none @@ -1197,7 +1197,7 @@ subroutine read_sfc_anl_(isli_anl) use kinds, only: r_kind,i_kind,r_single use gridmod, only: nlat,nlon use constants, only: zero - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata, get_idate_from_time_units implicit none @@ -1356,7 +1356,7 @@ subroutine read_nst_ (tref,dt_cool,z_c,dt_warm,z_w,c_0,c_d,w_0,w_d) use gridmod, only: nlat_sfc,nlon_sfc use constants, only: zero,two use guess_grids, only: nfldnst,ifilenst - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata, get_idate_from_time_units implicit none @@ -1597,7 +1597,7 @@ subroutine write_atm_ (grd,sp_a,filename,mype_out,gfs_bundle,ibin) use cloud_efr_mod, only: cloud_calc_gfs use netcdf, only: nf90_max_name - use module_fv3gfs_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& + use module_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& read_attribute, write_attribute,get_dim, create_dataset, write_vardata, read_vardata,& get_idate_from_time_units,quantize_data,get_time_units_from_idate,has_attr,has_var use ncepnems_io, only: error_msg @@ -2303,7 +2303,7 @@ subroutine write_sfc_ (filename,mype_sfc,dsfct) use constants, only: zero use netcdf, only: nf90_max_name - use module_fv3gfs_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& + use module_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& get_dim, create_dataset, write_vardata, read_vardata,& get_time_units_from_idate, write_attribute @@ -2511,7 +2511,7 @@ subroutine write_sfc_nst_ (mype_so,dsfct) use gsi_nstcouplermod, only: nst_gsi,zsea1,zsea2 use gridmod, only: rlats,rlons,rlats_sfc,rlons_sfc - use module_fv3gfs_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& + use module_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& get_dim, create_dataset, write_vardata, read_vardata,& get_time_units_from_idate, write_attribute use netcdf, only: nf90_max_name diff --git a/src/gsi/read_files.f90 b/src/gsi/read_files.f90 index 5fa4119c7b..ac07efa61d 100644 --- a/src/gsi/read_files.f90 +++ b/src/gsi/read_files.f90 @@ -98,7 +98,7 @@ subroutine read_files(mype) use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_getheadvar use read_obsmod, only: gsi_inquire use gsi_io, only: verbose - use module_fv3gfs_ncio, only: Dataset, Dimension, open_dataset, get_dim, & + use module_ncio, only: Dataset, Dimension, open_dataset, get_dim, & read_vardata, get_idate_from_time_units, & close_dataset use chemmod, only: lread_ext_aerosol diff --git a/src/gsi/read_gfs_ozone_for_regional.f90 b/src/gsi/read_gfs_ozone_for_regional.f90 index 8b2b9ffcb2..5b6acce30b 100644 --- a/src/gsi/read_gfs_ozone_for_regional.f90 +++ b/src/gsi/read_gfs_ozone_for_regional.f90 @@ -66,7 +66,7 @@ subroutine read_gfs_ozone_for_regional use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dataset, Dimension, get_dim, read_vardata,& + use module_ncio, only: Dataset, Dimension, get_dim, read_vardata,& open_dataset, close_dataset, read_attribute,& get_idate_from_time_units diff --git a/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake b/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake index 7339c76f99..672f1baae1 100644 --- a/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake +++ b/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake @@ -2,13 +2,13 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -convert big_endian -implicitnone") #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") #################################################################### # DEBUG FLAGS @@ -20,7 +20,7 @@ set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 - # PRODUCTION FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -ip -ipo -unroll -inline -no-heap-arrays") +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") #################################################################### # LINK FLAGS From 0dc2ac4fafa7d43c20bcbe063d9b0d8f4c56d99a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 17 Feb 2022 12:20:07 -0500 Subject: [PATCH 10/58] updates for GNU v10 --- cmake/compiler_flags_GNU_Fortran.cmake | 4 ++++ src/gsi/gsi_files.cmake | 5 +++++ src/gsi/hdraobmod.f90 | 8 ++++---- src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake index 8090f8bf12..10f0667660 100644 --- a/cmake/compiler_flags_GNU_Fortran.cmake +++ b/cmake/compiler_flags_GNU_Fortran.cmake @@ -4,6 +4,10 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none") +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + #################################################################### # RELEASE FLAGS #################################################################### diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake index 03e358a05a..da5b590699 100644 --- a/src/gsi/gsi_files.cmake +++ b/src/gsi/gsi_files.cmake @@ -146,6 +146,7 @@ cwhydromod.f90 derivsmod.f90 deter_sfc_mod.f90 dtast.f90 +directDA_radaruse_mod.f90 egrid2agrid_mod.f90 en_perts_io.f90 enorm_state.f90 @@ -258,6 +259,7 @@ gsi_wspd10mOper.F90 gsisub.F90 guess_grids.F90 half_nmm_grid2.f90 +hdraobmod.f90 hilbert_curve.f90 hybrid_ensemble_isotropic.F90 hybrid_ensemble_parameters.f90 @@ -448,6 +450,9 @@ pvqc_tables.f90 q_diag.f90 qcmod.f90 qnewton3.f90 +radarZ_global_module.f90 +radarZ_interface.f90 +radarZ_module.f90 radiance_mod.f90 radinfo.f90 raflib.f90 diff --git a/src/gsi/hdraobmod.f90 b/src/gsi/hdraobmod.f90 index fe96c63ab2..4e4aee9d3a 100644 --- a/src/gsi/hdraobmod.f90 +++ b/src/gsi/hdraobmod.f90 @@ -976,7 +976,7 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(19,iout)=stnelev ! station elevation (m) cdata_all(20,iout)=levdat(2,k) ! observation height (m) cdata_all(21,iout)=zz ! terrain height at ob location - cdata_all(22,iout)='88888888' ! provider name + cdata_all(22,iout)=88888888 ! provider name cdata_all(23,iout)='HDRAOB' ! subprovider name cdata_all(24,iout)=2 ! cat cdata_all(25,iout)=var_jb(3,k) ! non linear qc for T @@ -1075,7 +1075,7 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(19,iout)=dlon_earth_deg ! earth relative longitude (degrees) cdata_all(20,iout)=dlat_earth_deg ! earth relative latitude (degrees) cdata_all(21,iout)=zz ! terrain height at ob location - cdata_all(22,iout)='88888888' ! provider name + cdata_all(22,iout)=88888888 ! provider name cdata_all(23,iout)='HDRAOB' ! subprovider name cdata_all(24,iout)=2 ! cat cdata_all(25,iout)=var_jb(5,k) ! non linear qc parameter @@ -1157,7 +1157,7 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(17,iout)=stnelev ! station elevation (m) cdata_all(18,iout)=levdat(2,k) ! observation height (m) cdata_all(19,iout)=zz ! terrain height at ob location - cdata_all(20,iout)='88888888' ! provider name + cdata_all(20,iout)=88888888 ! provider name cdata_all(21,iout)='HDRAOB' ! subprovider name cdata_all(22,iout)=2 ! cat cdata_all(23,iout)=var_jb(2,k) ! non linear qc b parameter @@ -1222,7 +1222,7 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(15,iout)=dlat_earth_deg ! earth relative latitude (degrees) cdata_all(16,iout)=stnelev ! station elevation (m) cdata_all(17,iout)=zz ! terrain height at ob location - cdata_all(18,iout)='88888888' ! provider name + cdata_all(18,iout)=88888888 ! provider name cdata_all(19,iout)='HDRAOB' ! subprovider name cdata_all(20,iout)=var_jb(1,k) ! non linear qc b parameter if(perturb_obs)cdata_all(21,iout)=ran01dom()*perturb_fact ! ps perturbation diff --git a/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake b/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake index be5556137f..9216ce10c7 100644 --- a/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake +++ b/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake @@ -4,6 +4,10 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none") +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + #################################################################### # RELEASE FLAGS #################################################################### From d8612dbf0693c83d93721b453fc1988b0dba772a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 17 Feb 2022 15:37:06 -0500 Subject: [PATCH 11/58] add missing files in gsi_files.cmake --- CMakeLists.txt | 2 +- modulefiles/modulefile.ProdGSI.orion | 5 ++-- src/gsi/CMakeLists.txt | 2 +- src/gsi/gsi_files.cmake | 3 +++ util/CMakeLists.txt | 35 ++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 util/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index f55f90c907..f2c7038cb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ find_package(ncio REQUIRED) find_package(sp REQUIRED) find_package(ip REQUIRED) find_package(w3emc REQUIRED) -find_package(w3nco REQUIRED) +#find_package(w3nco REQUIRED) find_package(bufr REQUIRED) find_package(crtm REQUIRED) diff --git a/modulefiles/modulefile.ProdGSI.orion b/modulefiles/modulefile.ProdGSI.orion index 238887a9f5..bc224df54b 100644 --- a/modulefiles/modulefile.ProdGSI.orion +++ b/modulefiles/modulefile.ProdGSI.orion @@ -42,8 +42,9 @@ module load nemsio/2.5.2 module load sfcio/1.4.1 module load sigio/2.3.2 module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 +module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 module load netcdf/4.7.4 +module load ncio/1.0.0 +module load wrf_io/1.2.0 diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index b6ff4d5902..1d23fc6a11 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -138,7 +138,7 @@ foreach(app ${GSI_APP_Targets}) target_link_libraries(${app} PUBLIC nemsio::nemsio) target_link_libraries(${app} PUBLIC ncio::ncio) target_link_libraries(${app} PUBLIC w3emc::w3emc_d) - target_link_libraries(${app} PUBLIC w3nco::w3nco_d) +# target_link_libraries(${app} PUBLIC w3nco::w3nco_d) target_link_libraries(${app} PUBLIC sp::sp_d) target_link_libraries(${app} PUBLIC bufr::bufr_d) target_link_libraries(${app} PUBLIC crtm::crtm) diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake index da5b590699..29fdf7b95d 100644 --- a/src/gsi/gsi_files.cmake +++ b/src/gsi/gsi_files.cmake @@ -502,6 +502,7 @@ read_prepbufr.f90 read_radar.f90 read_radar_wind_ascii.f90 read_radarref_mosaic.f90 +read_radarref_mosaic_directDA.f90 read_rapidscat.f90 read_saphir.f90 read_satmar.f90 @@ -511,6 +512,7 @@ read_sfcwnd.f90 read_ssmi.f90 read_ssmis.f90 read_tcps.f90 +read_viirs.f90 read_wcpbufr.f90 reorg_metar_cloud.f90 rfdpar.f90 @@ -657,6 +659,7 @@ wrf_params_mod.f90 wrf_vars_mod.f90 write_all.F90 write_bkgvars_grid.f90 +write_fv3_spread.f90 write_incr.f90 xhat_vordivmod.f90 zrnmi_mod.f90 diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 0000000000..3dfb278e82 --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,35 @@ +add_subdirectory(AeroDA) +add_subdirectory(Analysis_Utilities) +add_subdirectory(Baseline) +add_subdirectory(bufr_tools) +add_subdirectory(CMakeLists.txt) +add_subdirectory(Config) +add_subdirectory(Conventional_Monitor) +add_subdirectory(Correlated_Obs) +add_subdirectory(DTC) +add_subdirectory(EFSOI_Utilities) +add_subdirectory(EnKF) +add_subdirectory(Fit2Obs_Scorecard) +add_subdirectory(FOV_utilities) +add_subdirectory(GEN_BE_V2.0) +add_subdirectory(global_angupdate) +add_subdirectory(GMI_BUFR_gen) +add_subdirectory(gsienvreport.sh) +add_subdirectory(Minimization_Monitor) +add_subdirectory(Misc) +add_subdirectory(MODIS_AOD) +add_subdirectory(NCEP_bkerror) +add_subdirectory(NCEPgsi_Coupler) +add_subdirectory(ndate) +add_subdirectory(netcdf_io) +add_subdirectory(NMC_Bkerror) +add_subdirectory(Ozone_Monitor) +add_subdirectory(python_utilities) +add_subdirectory(Radar_Monitor) +add_subdirectory(radar_process) +add_subdirectory(Radiance_bias_correction_Utilities) +add_subdirectory(Radiance_Monitor) +add_subdirectory(Radiance_Utilities) +add_subdirectory(README) +add_subdirectory(Single_Observation) +add_subdirectory(zero_biascoeff) From b1a0590200200a96229dcfdcbc60b12991b0db19 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 24 Feb 2022 14:26:53 -0500 Subject: [PATCH 12/58] build works with GNU for GSI library and apps. Install creates package config --- .gitignore | 4 ++ CMakeLists.txt | 2 +- src/gsi/CMakeLists.txt | 33 ++++++++++++- src/gsi/cmake/PackageConfig.cmake.in | 55 ++++++++++++++++++++++ src/gsi/cplr_get_fv3_regional_ensperts.f90 | 1 + src/gsi/gsi_rfv3io_mod.f90 | 19 ++++---- src/gsi/hdraobmod.f90 | 22 +++++---- 7 files changed, 117 insertions(+), 19 deletions(-) create mode 100644 src/gsi/cmake/PackageConfig.cmake.in diff --git a/.gitignore b/.gitignore index 4d3244a698..052a014b7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ build*/ +install*/ .*.swp +*.[aox] +*.mod +.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index f2c7038cb8..5bfec659b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(GSI +project(gsi VERSION 1.0.0 LANGUAGES C Fortran) diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 1d23fc6a11..a92e0cac5b 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -156,9 +156,38 @@ if(BUILD_REGIONAL) target_link_libraries(regional_gsi.x PUBLIC wrf_io::wrf_io) endif() +# Install executable targets +install(TARGETS ${GSI_APP_Targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Install library archive targets install( - TARGETS ${GSI_LIB_Targets} ${GSI_APP_Targets} + TARGETS ${GSI_LIB_Targets} EXPORT ${PROJECT_NAME}Exports - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +### Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..854213b3fd --- /dev/null +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -0,0 +1,55 @@ +@PACKAGE_INIT@ + +#@PROJECT_NAME@-config.cmake +# +# Imported interface targets provided: +# * @PROJECT_NAME@::global_gsi - global GSI library target +# * @PROJECT_NAME@::regional_gsi - global GSI library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") +include(CMakeFindDependencyMacro) + +find_dependency(MPI) +find_dependency(NetCDF COMPONENTS Fortran) + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF +if(@ENABLE_MKL@) + find_dependency(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + find_dependency(LAPACK REQUIRED) +endif() + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without OpenMP +if(@OPENMP@) + find_dependency(OpenMP COMPONENTS Fortran) +endif() + +find_dependency(bacio REQUIRED) +find_dependency(sigio REQUIRED) +find_dependency(sfcio REQUIRED) +find_dependency(nemsio REQUIRED) +find_dependency(ncio REQUIRED) +find_dependency(sp REQUIRED) +find_dependency(ip REQUIRED) +find_dependency(w3emc REQUIRED) +find_dependency(bufr REQUIRED) +find_dependency(crtm REQUIRED) + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -DBUILD_REGIONAL=ON|OFF +if(@BUILD_REGIONAL@) + find_dependency(wrf_io REQUIRED) +endif() + +# Get the build type from library target +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") + diff --git a/src/gsi/cplr_get_fv3_regional_ensperts.f90 b/src/gsi/cplr_get_fv3_regional_ensperts.f90 index b54f727b71..98feb46202 100644 --- a/src/gsi/cplr_get_fv3_regional_ensperts.f90 +++ b/src/gsi/cplr_get_fv3_regional_ensperts.f90 @@ -567,6 +567,7 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g use gsi_rfv3io_mod, only: gsi_fv3ncdf_readuv_v1 use gsi_rfv3io_mod, only: gsi_fv3ncdf2d_read_v1 use directDA_radaruse_mod, only: l_use_dbz_directDA + use gsi_bundlemod, only: gsi_bundle use gsi_bundlemod, only: gsi_gridcreate use gsi_bundlemod, only: gsi_grid use gsi_bundlemod, only: gsi_bundlecreate,gsi_bundledestroy diff --git a/src/gsi/gsi_rfv3io_mod.f90 b/src/gsi/gsi_rfv3io_mod.f90 index 496370e7c5..bc2b4ed1f6 100644 --- a/src/gsi/gsi_rfv3io_mod.f90 +++ b/src/gsi/gsi_rfv3io_mod.f90 @@ -79,14 +79,17 @@ module gsi_rfv3io_mod type(sub2grid_info) :: grd_fv3lam_tracer_ionouv type(sub2grid_info) :: grd_fv3lam_uv integer(i_kind) ,parameter:: ndynvarslist=13, ntracerslist=8 - character(len=max_varname_length), parameter :: vardynvars(ndynvarslist) =(/"u","v","u_w","u_s", & - "v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"/) - character(len=max_varname_length), parameter :: vartracers(ntracerslist) =(/'q','oz', & - 'ql','qi','qr','qs','qg','qnr'/) - character(len=max_varname_length), parameter :: varfv3name(15) =(/'u','v','W','T','delp','sphum','o3mr', & - 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'/) - character(len=max_varname_length), parameter :: vgsiname(15) =(/'u','v','w','tsen','delp','q','oz', & - 'ql','qi','qr','qs','qg','qnr','ps','delzinc'/) + character(len=max_varname_length), dimension(ndynvarslist), parameter :: & + vardynvars = [character(len=max_varname_length) :: & + "u","v","u_w","u_s","v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"] + character(len=max_varname_length), dimension(ntracerslist), parameter :: & + vartracers = [character(len=max_varname_length) :: & + 'q','oz','ql','qi','qr','qs','qg','qnr'] + character(len=max_varname_length), dimension(15), parameter :: & + varfv3name = [character(len=max_varname_length) :: & + 'u','v','W','T','delp','sphum','o3mr','liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'], & + vgsiname = [character(len=max_varname_length) :: & + 'u','v','w','tsen','delp','q','oz','ql','qi','qr','qs','qg','qnr','ps','delzinc'] character(len=max_varname_length),dimension(:),allocatable:: name_metvars2d character(len=max_varname_length),dimension(:),allocatable:: name_metvars3d diff --git a/src/gsi/hdraobmod.f90 b/src/gsi/hdraobmod.f90 index 4e4aee9d3a..507ef52c24 100644 --- a/src/gsi/hdraobmod.f90 +++ b/src/gsi/hdraobmod.f90 @@ -143,6 +143,7 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& character(10) date character(8) subset character(8) c_station_id,id_station + character(8) c_prvstg,c_sprvstg ! character(8) stnid character(8) stntype @@ -198,11 +199,14 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& real(r_double),dimension(2,maxlevs):: levdat real(r_double),dimension(8,maxlevs):: var_jb,obserr real(r_double),dimension(8,maxlevs):: obsdat + real(r_double) :: r_prvstg,r_sprvstg logical newstation,toocold ! equivalence to handle character names + equivalence(r_prvstg,c_prvstg) + equivalence(r_sprvstg,c_sprvstg) equivalence(rstation_id,c_station_id) equivalence(r_station,id_station) @@ -220,6 +224,8 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& print_verbose=.false. if(verbose) print_verbose=.true. + c_prvstg = '88888888' + c_sprvstg ='HDRAOB' ! Initialize variables @@ -976,8 +982,8 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(19,iout)=stnelev ! station elevation (m) cdata_all(20,iout)=levdat(2,k) ! observation height (m) cdata_all(21,iout)=zz ! terrain height at ob location - cdata_all(22,iout)=88888888 ! provider name - cdata_all(23,iout)='HDRAOB' ! subprovider name + cdata_all(22,iout)=r_prvstg ! provider name + cdata_all(23,iout)=r_sprvstg ! subprovider name cdata_all(24,iout)=2 ! cat cdata_all(25,iout)=var_jb(3,k) ! non linear qc for T if(perturb_obs)cdata_all(nreal,iout)=ran01dom()*perturb_fact ! t perturbation @@ -1075,8 +1081,8 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(19,iout)=dlon_earth_deg ! earth relative longitude (degrees) cdata_all(20,iout)=dlat_earth_deg ! earth relative latitude (degrees) cdata_all(21,iout)=zz ! terrain height at ob location - cdata_all(22,iout)=88888888 ! provider name - cdata_all(23,iout)='HDRAOB' ! subprovider name + cdata_all(22,iout)=r_prvstg ! provider name + cdata_all(23,iout)=r_sprvstg ! subprovider name cdata_all(24,iout)=2 ! cat cdata_all(25,iout)=var_jb(5,k) ! non linear qc parameter cdata_all(26,iout)=one ! hilbert curve weight, modified later @@ -1157,8 +1163,8 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(17,iout)=stnelev ! station elevation (m) cdata_all(18,iout)=levdat(2,k) ! observation height (m) cdata_all(19,iout)=zz ! terrain height at ob location - cdata_all(20,iout)=88888888 ! provider name - cdata_all(21,iout)='HDRAOB' ! subprovider name + cdata_all(20,iout)=r_prvstg ! provider name + cdata_all(21,iout)=r_sprvstg ! subprovider name cdata_all(22,iout)=2 ! cat cdata_all(23,iout)=var_jb(2,k) ! non linear qc b parameter if(perturb_obs)cdata_all(24,iout)=ran01dom()*perturb_fact ! q perturbation @@ -1222,8 +1228,8 @@ subroutine read_hdraob(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& cdata_all(15,iout)=dlat_earth_deg ! earth relative latitude (degrees) cdata_all(16,iout)=stnelev ! station elevation (m) cdata_all(17,iout)=zz ! terrain height at ob location - cdata_all(18,iout)=88888888 ! provider name - cdata_all(19,iout)='HDRAOB' ! subprovider name + cdata_all(18,iout)=r_prvstg ! provider name + cdata_all(19,iout)=r_sprvstg ! subprovider name cdata_all(20,iout)=var_jb(1,k) ! non linear qc b parameter if(perturb_obs)cdata_all(21,iout)=ran01dom()*perturb_fact ! ps perturbation if (twodvar_regional) & From 6056d487f3152496431eb3f6deb5902603a3acca Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 24 Feb 2022 15:25:04 -0500 Subject: [PATCH 13/58] gsi is its own project now --- CMakeLists.txt | 44 -------- cmake/compiler_flags_GNU_Fortran.cmake | 2 +- cmake/compiler_flags_Intel_Fortran.cmake | 6 +- src/CMakeLists.txt | 4 +- src/gsi/CMakeLists.txt | 105 ++++++++++++++++-- .../cmake/gsiapp_compiler_flags_GNU_C.cmake | 2 +- .../gsiapp_compiler_flags_GNU_Fortran.cmake | 16 ++- .../cmake/gsiapp_compiler_flags_Intel_C.cmake | 4 +- .../gsiapp_compiler_flags_Intel_Fortran.cmake | 2 +- src/ncdiag/CMakeLists.txt | 2 +- 10 files changed, 115 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bfec659b5..f7d748cbe8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,54 +29,10 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) -option(BUILD_NCDIAG "Build and use inline NetCDF diagnostics library" ON) -option(BUILD_REGIONAL "Build Regional GSI" OFF) # Echo user options message(STATUS "OPENMP ................. ${OPENMP}") message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "BUILD_NCDIAG ........... ${BUILD_NCDIAG}") -message(STATUS "BUILD_REGIONAL ......... ${BUILD_REGIONAL}") - -# Dependencies -if(ENABLE_MKL) - find_package(MKL QUIET) -endif() -if(MKL_FOUND) - set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) -else() - find_package(LAPACK REQUIRED) -endif() -find_package(MPI REQUIRED) -find_package(NetCDF REQUIRED Fortran) -if(OPENMP) - find_package(OpenMP REQUIRED) -endif() - -# NetCDF Diagnostic IO library dependency -if(NOT BUILD_NCDIAG) - find_package(ncdiag REQUIRED) -endif() - -# NCEPLibs dependencies -find_package(bacio REQUIRED) -find_package(sigio REQUIRED) -find_package(sfcio REQUIRED) -find_package(nemsio REQUIRED) -find_package(ncio REQUIRED) -find_package(sp REQUIRED) -find_package(ip REQUIRED) -find_package(w3emc REQUIRED) -#find_package(w3nco REQUIRED) -find_package(bufr REQUIRED) -find_package(crtm REQUIRED) - -if(BUILD_REGIONAL) - find_package(wrf_io REQUIRED) -endif() - -# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 -target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) # Build components add_subdirectory(src) diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake index 10f0667660..b61ddbd9cf 100644 --- a/cmake/compiler_flags_GNU_Fortran.cmake +++ b/cmake/compiler_flags_GNU_Fortran.cmake @@ -2,7 +2,7 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") diff --git a/cmake/compiler_flags_Intel_Fortran.cmake b/cmake/compiler_flags_Intel_Fortran.cmake index 48f94f45a1..449229bb8f 100644 --- a/cmake/compiler_flags_Intel_Fortran.cmake +++ b/cmake/compiler_flags_Intel_Fortran.cmake @@ -2,13 +2,13 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -assume byterecl -convert big_endian -implicitnone") +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") #################################################################### # DEBUG FLAGS @@ -20,7 +20,7 @@ set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 - # PRODUCTION FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3") #################################################################### # LINK FLAGS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4da2dd499e..54c462ef7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,4 @@ -if(BUILD_NCDIAG) - add_subdirectory(ncdiag) -endif() +add_subdirectory(ncdiag) #add_subdirectory(GSD) diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index a92e0cac5b..c1cb718856 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -1,3 +1,84 @@ +cmake_minimum_required(VERSION 3.15) + +project(gsi + VERSION 1.0.0 + LANGUAGES C Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(compiler_flags) +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") +endif() + +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +option(USE_NCDIAG "Use NetCDF diagnostics library" ON) +option(BUILD_GSI_REGIONAL "Build Regional GSI" OFF) + +# Echo user options +message(STATUS "OPENMP ................. ${OPENMP}") +message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "USE_NCDIAG ............. ${USE_NCDIAG}") +message(STATUS "BUILD_GSI_REGIONAL ..... ${BUILD_GSI_REGIONAL}") + +# Dependencies +if(ENABLE_MKL) + find_package(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + find_package(LAPACK REQUIRED) +endif() +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() + +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(ip REQUIRED) +find_package(w3emc REQUIRED) +find_package(bufr REQUIRED) +find_package(crtm REQUIRED) + +if(BUILD_GSI_REGIONAL) + find_package(wrf_io REQUIRED) +endif() + +# NetCDF Diagnostic IO library dependency +if(USE_NCDIAG) + if(NOT TARGET ncdiag::ncdiag) + find_package(ncdiag REQUIRED) + endif() +endif() + +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # Get compiler flags for the GSI application @@ -7,7 +88,7 @@ include(gsiapp_compiler_flags) include(gsi_files.cmake) # Include GSI ncdiag files if NetCDF Diagnostics is disabled -if(NOT BUILD_NCDIAG) +if(NOT USE_NCDIAG) list(APPEND GSI_SRC_Fortran ${GSI_SRC_ncdiag} ) @@ -55,7 +136,7 @@ list(APPEND GSI_LIB_Fortran_Targets ) # Create a library of REGIONAL GSI Fortran objects -if(BUILD_REGIONAL) +if(BUILD_GSI_REGIONAL) set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi") add_library(regional_gsi_fortran_obj OBJECT ${GSI_SRC_Fortran_regional}) set_target_properties(regional_gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") @@ -82,10 +163,13 @@ foreach(lib ${GSI_LIB_Fortran_Targets}) if(OpenMP_Fortran_FOUND) target_link_libraries(${lib} PRIVATE OpenMP::OpenMP_Fortran) endif() - if(BUILD_NCDIAG) - add_dependencies(${lib} ncdiag) + if(USE_NCDIAG) + if(TARGET ncdiag::ncdiag) + add_dependencies(${lib} ncdiag::ncdiag) + add_library(ncdiag::ncdiag ALIAS ncdiag) + endif() + target_link_libraries(${lib} PUBLIC ncdiag::ncdiag) endif() - target_link_libraries(${lib} PUBLIC ncdiag::ncdiag) endforeach() # Create a GLOBAL GSI library @@ -98,7 +182,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi DESTINATION ${C list(APPEND GSI_LIB_Targets global_gsi) # Create a REGIONAL GSI library -if(BUILD_REGIONAL) +if(BUILD_GSI_REGIONAL) add_library(regional_gsi STATIC $ $) add_library(${PROJECT_NAME}::regional_gsi ALIAS regional_gsi) @@ -119,7 +203,7 @@ list(APPEND GSI_APP_Targets ) # Create a REGIONAL GSI executable -if(BUILD_REGIONAL) +if(BUILD_GSI_REGIONAL) set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi") add_executable(regional_gsi.x ${GSI_SRC_main}) add_dependencies(regional_gsi.x regional_gsi) @@ -138,11 +222,12 @@ foreach(app ${GSI_APP_Targets}) target_link_libraries(${app} PUBLIC nemsio::nemsio) target_link_libraries(${app} PUBLIC ncio::ncio) target_link_libraries(${app} PUBLIC w3emc::w3emc_d) -# target_link_libraries(${app} PUBLIC w3nco::w3nco_d) target_link_libraries(${app} PUBLIC sp::sp_d) target_link_libraries(${app} PUBLIC bufr::bufr_d) target_link_libraries(${app} PUBLIC crtm::crtm) - target_link_libraries(${app} PUBLIC ncdiag::ncdiag) + if(USE_NCDIAG) + target_link_libraries(${app} PUBLIC ncdiag::ncdiag) + endif() target_link_libraries(${app} PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(${app} PUBLIC MPI::MPI_Fortran) target_link_libraries(${app} PUBLIC ${LAPACK_LIBRARIES}) @@ -152,7 +237,7 @@ foreach(app ${GSI_APP_Targets}) endforeach() # REGIONAL GSI Application specific library dependencies -if(BUILD_REGIONAL) +if(BUILD_GSI_REGIONAL) target_link_libraries(regional_gsi.x PUBLIC wrf_io::wrf_io) endif() diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake index 49f629ff04..2db1baf7b3 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake @@ -2,7 +2,7 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") #################################################################### # RELEASE FLAGS diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake index 8861c51715..807d031e44 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake @@ -2,37 +2,41 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -fno-second-underscore -ffast-math") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none -fconvert=big-endian -fno-second-underscore -ffast-math") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") #################################################################### # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") #################################################################### # PRODUCTION FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_PRODUCTION "${CMAKE_Fortran_FLAGS_PRODUCTION}") +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") #################################################################### # LINK FLAGS #################################################################### -set(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS}") +set(CMAKE_Fortran_LINK_FLAGS "") #################################################################### # FLAGS FOR AUTOPROFILING #################################################################### -set(Fortran_AUTOPROFILING_FLAGS "") +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") #################################################################### diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake index 49f629ff04..e79145242e 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake @@ -2,7 +2,7 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") #################################################################### # RELEASE FLAGS @@ -14,7 +14,7 @@ set(CMAKE_C_FLAGS_RELEASE "") # DEBUG FLAGS #################################################################### -set(CMAKE_C_FLAGS_DEBUG "") +set(CMAKE_C_FLAGS_DEBUG "-Wall") #################################################################### # PRODUCTION FLAGS diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake index 672f1baae1..c4783799e2 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake @@ -2,7 +2,7 @@ # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -convert big_endian -implicitnone") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -assume byterecl -convert big_endian -implicitnone") #################################################################### # RELEASE FLAGS diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index 851ea2c059..d10e4e6f70 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -28,7 +28,7 @@ find_package(MPI REQUIRED) find_package(NetCDF REQUIRED COMPONENTS Fortran) # Echo user options -message(STATUS "ENABLE_NCDIAG_SERIAL .. ${ENABLE_NCDIAG_SERIAL}") +message(STATUS "ENABLE_NCDIAG_SERIAL ... ${ENABLE_NCDIAG_SERIAL}") # Get list of files include(ncdiag_files.cmake) From a1ce87c705b142f4762c543bf37e47828882566f Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 25 Feb 2022 16:36:15 -0500 Subject: [PATCH 14/58] build GSI and EnKF GFS flavors --- src/CMakeLists.txt | 6 +- src/enkf/CMakeLists.txt | 299 +++++++++++++----- src/enkf/cmake/PackageConfig.cmake.in | 61 ++++ src/enkf/cmake/enkfapp_compiler_flags.cmake | 23 ++ .../cmake/enkfapp_compiler_flags_GNU_C.cmake | 40 +++ .../enkfapp_compiler_flags_GNU_Fortran.cmake | 47 +++ .../enkfapp_compiler_flags_Intel_C.cmake | 40 +++ ...enkfapp_compiler_flags_Intel_Fortran.cmake | 41 +++ src/enkf/enkf_files.cmake | 65 ++++ src/enkf/gridinfo_gfs.f90 | 4 +- src/enkf/gridio_gfs.f90 | 48 +-- src/gsi/CMakeLists.txt | 235 ++++++-------- src/gsi/cmake/PackageConfig.cmake.in | 24 +- src/gsi/gsi_files.cmake | 6 +- src/ncdiag/cmake/ncdiag_compiler_flags.cmake | 4 +- ...> ncdiag_compiler_flags_GNU_Fortran.cmake} | 0 ...ncdiag_compiler_flags_Intel_Fortran.cmake} | 0 17 files changed, 676 insertions(+), 267 deletions(-) create mode 100644 src/enkf/cmake/PackageConfig.cmake.in create mode 100644 src/enkf/cmake/enkfapp_compiler_flags.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake create mode 100644 src/enkf/enkf_files.cmake rename src/ncdiag/cmake/{compiler_flags_GNU_Fortran.cmake => ncdiag_compiler_flags_GNU_Fortran.cmake} (100%) rename src/ncdiag/cmake/{compiler_flags_Intel_Fortran.cmake => ncdiag_compiler_flags_Intel_Fortran.cmake} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54c462ef7e..c730e35d94 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,4 @@ -add_subdirectory(ncdiag) - #add_subdirectory(GSD) - +add_subdirectory(ncdiag) add_subdirectory(gsi) -#add_subdirectory(enkf) +add_subdirectory(enkf) diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index 394c6b52b5..a005498164 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -1,83 +1,220 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_ENKF) - enable_language (Fortran) - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - - if(BUILD_PRODUCTION) - set(ENKF_SUFFIX "gfs") - set(ENKF_BASE "global_enkf.x") - elseif(BUILD_WRF) - set(ENKF_SUFFIX "wrf") - set(ENKF_BASE "enkf_wrf") - elseif(BUILD_GFS) - set(ENKF_SUFFIX "gfs") - set(ENKF_BASE "enkf_gfs") - elseif(BUILD_NMMB) - set(ENKF_SUFFIX "nmmb") - set(ENKF_BASE "enkf_nmmb") - elseif(BUILD_FV3reg) - set(ENKF_SUFFIX "fv3reg") - set(ENKF_BASE "enkf_fv3reg") - set(ENKF_extra_src1 read_fv3reg_restarts.f90 write_fv3reg_restarts.f90) - else() - set(ENKF_SUFFIX "wrf") - set(ENKF_BASE "enkf_wrf") +cmake_minimum_required(VERSION 3.15) + +project(enkf + VERSION 1.0.0 + LANGUAGES C Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") +endif() + +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +option(USE_NCDIAG "Use NetCDF diagnostics library" ON) + +set(ENKF_APP "GFS" CACHE STRING "Choose the EnKF Application.") +set_property(CACHE ENKF_APP PROPERTY STRINGS "GFS" "WRF" "NMMB" "FV3REG") + +# Echo user options +message(STATUS "OPENMP ................. ${OPENMP}") +message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "USE_NCDIAG ............. ${USE_NCDIAG}") +message(STATUS "ENKF_APP ............... ${ENKF_APP}") + +# Dependencies +if(ENABLE_MKL) + find_package(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + set(ENABLE_MKL OFF CACHE INTERNAL "Disable MKL since it was NOT FOUND") + find_package(LAPACK REQUIRED) +endif() +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() + +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(ip REQUIRED) +find_package(w3emc REQUIRED) +find_package(bufr REQUIRED) +find_package(crtm REQUIRED) +if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") + find_package(wrf_io REQUIRED) +endif() + +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + +# NetCDF Diagnostic IO library dependency +if(USE_NCDIAG) + if(NOT TARGET ncdiag) + find_package(ncdiag REQUIRED) endif() - set(ENKF_EXTRA_SRCS ${ENKF_extra_src1} gridio_${ENKF_SUFFIX}.f90 ) - add_library( MODS1 OBJECT gridinfo_${ENKF_SUFFIX}.f90 ) - add_library( MODS2 OBJECT ${ENKF_EXTRA_SRCS} ) - - set(ENKFMOD_SRCS - netcdf_io_wrf.f90 params.f90 covlocal.f90 fftpack.f90 genqsat1.f90 mpisetup.f90 rnorm.f90 - sorting.f90 specmod.f90 reducedgrid.f90 readozobs.f90 readsatobs.f90 readconvobs.f90 - write_logfile.f90 kdtree2.f90 mpi_readobs.f90 enkf_obsmod.f90 statevec.f90 controlvec.f90 - observer_${ENKF_SUFFIX}.f90 gridio_${ENKF_SUFFIX}.f90 gridinfo_${ENKF_SUFFIX}.f90 expand_ens.f90 - ${ENKF_extra_src1} - ) - set(ENKF_SRCS - innovstats.f90 - enkf.f90 - read_locinfo.f90 - enkf_main.f90 - inflation.f90 - letkf.f90 - quicksort.f90 - radbias.f90 - loadbal.f90 - smooth_${ENKF_SUFFIX}.f90 - gridio_${ENKF_SUFFIX}.f90 - gridinfo_${ENKF_SUFFIX}.f90 - enkf_obs_sensitivity.f90 - ) -# if( (NOT HOST-WCOSS_C) AND (NOT HOST-WCOSS_D) ) -# find_package( LAPACK REQUIRED ) -# endif() - - add_definitions(${MPI_Fortran_FLAGS}) - - include_directories(${CMAKE_CURRENT_BINARY_DIR} "${PROJECT_BINARY_DIR}/include/wrf" "${PROJECT_BINARY_DIR}/include/global" ${CMAKE_CURRENT_BINARY_DIR}/.. ${MPI_Fortran_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS} ${FV3GFS_NCIO_INCS}) - link_directories(${MPI_Fortran_LIBRARIES}) - - set_source_files_properties( ${ENKF_SRCS} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - set_source_files_properties( ${ENKFMOD_SRCS} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - set_source_files_properties( ${ENKF_EXTRA_SRCS} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - - add_library(enkfdeplib STATIC ${ENKFMOD_SRCS} ) - add_library(enkflib STATIC ${ENKF_SRCS} $ $ ) - add_dependencies(enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(MODS1 enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(MODS2 MODS1 enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(enkflib enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - set(ENKFEXEC "${ENKF_BASE}${debug_suffix}${GSISUFFIX}" CACHE INTERNAL "ENKF Executable name") - add_executable(${ENKFEXEC} enkf_main.f90) - target_link_libraries(${ENKFEXEC} enkflib enkfdeplib ${GSILIB} ${GSISHAREDLIB} ${CORE_LIBRARIES} - ${MPI_Fortran_LIBRARIES} ${LAPACK_LIBRARIES} ${CORE_LIBRARIES} ${CORE_BUILT} - ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES} - ${EXTRA_LINKER_FLAGS} ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES}) - install(TARGETS ${ENKFEXEC} enkfdeplib enkflib - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/static) endif() + +if(NOT TARGET gsi) + find_package(gsi REQUIRED) +endif() + +# Get compiler flags for the GSI application +include(enkfapp_compiler_flags) + +# Get the list of all source files +include(enkf_files.cmake) + +# Collect common files for EnKF Fortran library +list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_srcs}) + +# Collect files for specific EnKF Application +if(ENKF_APP MATCHES "GFS") # GFS application + list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_gfs}) +elseif(ENKF_APP MATCHES "WRF") # WRF application + list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_wrf}) +elseif(ENKF_APP MATCHES "NMMB") # NMMB application + list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_nmmb}) +elseif(ENKF_APP MATCHES "FV3REG") # WRF application + list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_fv3reg}) +endif() + +# Create a library of EnKF Fortran Objects +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/enkf") +add_library(enkf_fortran_obj OBJECT ${EnKF_SRC_Fortran}) +set_target_properties(enkf_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(enkf_fortran_obj INTERFACE + $ + $) + +# Link the Fortran targets with dependencies +target_link_libraries(enkf_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(enkf_fortran_obj PUBLIC MPI::MPI_Fortran) +target_link_libraries(enkf_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(enkf_fortran_obj PUBLIC bacio::bacio_4) +target_link_libraries(enkf_fortran_obj PUBLIC sigio::sigio) +target_link_libraries(enkf_fortran_obj PUBLIC sfcio::sfcio) +target_link_libraries(enkf_fortran_obj PUBLIC nemsio::nemsio) +target_link_libraries(enkf_fortran_obj PUBLIC ncio::ncio) +target_link_libraries(enkf_fortran_obj PUBLIC w3emc::w3emc_d) +target_link_libraries(enkf_fortran_obj PUBLIC crtm::crtm) +if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") + target_link_libraries(enkf_fortran_obj PUBLIC wrf_io::wrf_io) +endif() +if(USE_NCDIAG) + if(TARGET ncdiag) + add_dependencies(enkf_fortran_obj ncdiag) + endif() + target_link_libraries(enkf_fortran_obj PUBLIC ncdiag::ncdiag) +endif() +if(TARGET gsi) + add_dependencies(enkf_fortran_obj gsi) +endif() +target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enkf_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Create a EnKF library +add_library(enkf STATIC $) +add_library(${PROJECT_NAME}::enkf ALIAS enkf) +target_include_directories(enkf PUBLIC $ + $) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/enkf DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +# Create a EnKF executable +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/enkf") +add_executable(enkf.x ${EnKF_SRC_main}) +add_dependencies(enkf.x enkf) +set_target_properties(enkf.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_link_libraries(enkf.x PRIVATE enkf) + +# Link the application targets with dependencies +target_link_libraries(enkf.x PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(enkf.x PUBLIC MPI::MPI_Fortran) +target_link_libraries(enkf.x PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(enkf.x PUBLIC bacio::bacio_4) +target_link_libraries(enkf.x PUBLIC sigio::sigio) +target_link_libraries(enkf.x PUBLIC sfcio::sfcio) +target_link_libraries(enkf.x PUBLIC nemsio::nemsio) +target_link_libraries(enkf.x PUBLIC ncio::ncio) +target_link_libraries(enkf.x PUBLIC w3emc::w3emc_d) +target_link_libraries(enkf.x PUBLIC sp::sp_d) +target_link_libraries(enkf.x PUBLIC bufr::bufr_d) +target_link_libraries(enkf.x PUBLIC crtm::crtm) +if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") + target_link_libraries(enkf_fortran_obj PUBLIC wrf_io::wrf_io) +endif() +if(USE_NCDIAG) + target_link_libraries(enkf.x PUBLIC ncdiag::ncdiag) +endif() +target_link_libraries(enkf.x PUBLIC gsi::gsi) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enkf.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS enkf.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Install library archive targets +install( + TARGETS enkf + EXPORT ${PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +### Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/enkf/cmake/PackageConfig.cmake.in b/src/enkf/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..58468ae7d2 --- /dev/null +++ b/src/enkf/cmake/PackageConfig.cmake.in @@ -0,0 +1,61 @@ +@PACKAGE_INIT@ + +#@PROJECT_NAME@-config.cmake +# +# Imported interface targets provided: +# * @PROJECT_NAME@::enkf - EnKF library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") +include(CMakeFindDependencyMacro) + +# Set the EnKF Application this library is built for +set(ENKF_APP @ENKF_APP@) + +find_dependency(MPI) +find_dependency(NetCDF COMPONENTS Fortran) + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF +if(@ENABLE_MKL@) + find_dependency(MKL) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +endif() +if(NOT @ENABLE_MKL@) + find_dependency(LAPACK REQUIRED) +endif() + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without OpenMP +if(@OPENMP@) + find_dependency(OpenMP COMPONENTS Fortran) +endif() + +find_dependency(bacio REQUIRED) +find_dependency(sigio REQUIRED) +find_dependency(sfcio REQUIRED) +find_dependency(nemsio REQUIRED) +find_dependency(ncio REQUIRED) +find_dependency(sp REQUIRED) +find_dependency(ip REQUIRED) +find_dependency(w3emc REQUIRED) +find_dependency(bufr REQUIRED) +find_dependency(crtm REQUIRED) + +if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") + find_dependency(wrf_io REQUIRED) +endif() + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -USE_NCDIAG=ON|OFF +#if(@USE_NCDIAG@) +# find_dependency(ncdiag REQUIRED) +#endif() + +# Get the build type from library target +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") +message(STATUS "FindENKF defines targets:") +message(STATUS " - ENKF_APP [${ENKF_APP}]") diff --git a/src/enkf/cmake/enkfapp_compiler_flags.cmake b/src/enkf/cmake/enkfapp_compiler_flags.cmake new file mode 100644 index 0000000000..66cfe4e2a3 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags.cmake @@ -0,0 +1,23 @@ +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(enkfapp_compiler_flags_GNU_Fortran) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(enkfapp_compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(enkfapp_compiler_flags_GNU_C) +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + include(enkfapp_compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..2db1baf7b3 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..37b5e01881 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,47 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none -fconvert=big-endian -fno-second-underscore -ffast-math") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "-finstrument-functions") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..e79145242e --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..c4783799e2 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -assume byterecl -convert big_endian -implicitnone") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/src/enkf/enkf_files.cmake b/src/enkf/enkf_files.cmake new file mode 100644 index 0000000000..d7e03f0659 --- /dev/null +++ b/src/enkf/enkf_files.cmake @@ -0,0 +1,65 @@ +list(APPEND EnKF_SRC_main + enkf_main.f90) + +list(APPEND EnKF_SRC_srcs + controlvec.f90 + covlocal.f90 + enkf.f90 + enkf_obs_sensitivity.f90 + enkf_obsmod.f90 + expand_ens.f90 + fftpack.f90 + genqsat1.f90 + inflation.f90 + innovstats.f90 + kdtree2.f90 + letkf.f90 + loadbal.f90 + mpi_readobs.f90 + mpisetup.f90 + netcdf_io_wrf.f90 + params.f90 + quicksort.f90 + radbias.f90 + read_locinfo.f90 + readconvobs.f90 + readozobs.f90 + readsatobs.f90 + reducedgrid.f90 + rnorm.f90 + sorting.f90 + specmod.f90 + statevec.f90 + write_logfile.f90) + +list(APPEND EnKF_SRC_gfs + gridinfo_gfs.f90 + gridio_gfs.f90 + observer_gfs.f90 + smooth_gfs.f90) + +list(APPEND EnKF_SRC_wrf + gridinfo_wrf.f90 + gridio_wrf.f90 + observer_reg.f90 + smooth_wrf.f90) + +list(APPEND EnKF_SRC_nmmb + gridinfo_nmmb.f90 + gridio_nmmb.f90 + observer_reg.f90 + smooth_nmmb.f90) + +list(APPEND EnKF_SRC_fv3reg + gridinfo_fv3reg.f90 + gridio_fv3reg.f90 + observer_fv3reg.f90 + read_fv3reg_restarts.f90 + smooth_fv3reg.f90 + write_fv3reg_restarts.f90) + +#Unused files +#specmod_shtns.f90 -- This is a faster alternative to specmod.f90 +#specmod_splib.f90 -- This is a copy of specmod.f90 +#observer_nmmb.f90 -- This is soft-linked to observer_reg.f90 +#observer_wrf.f90 -- This is soft-linked to observer_reg.f90 diff --git a/src/enkf/gridinfo_gfs.f90 b/src/enkf/gridinfo_gfs.f90 index 7fdb2f67b0..c2e2b10f57 100644 --- a/src/enkf/gridinfo_gfs.f90 +++ b/src/enkf/gridinfo_gfs.f90 @@ -78,8 +78,8 @@ subroutine getgridinfo(fileprefix, reducedgrid) use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,& nemsio_readrecv,nemsio_init, nemsio_realkind -use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata +use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata implicit none type(Dataset) :: dset diff --git a/src/enkf/gridio_gfs.f90 b/src/enkf/gridio_gfs.f90 index 8a6bd12507..fe5199e395 100644 --- a/src/enkf/gridio_gfs.f90 +++ b/src/enkf/gridio_gfs.f90 @@ -61,8 +61,8 @@ module gridio subroutine readgriddata_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,ntimes, & fileprefixes,filesfcprefixes,reducedgrid,grdin,qsat) - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - quantize_data,read_attribute, close_dataset, get_dim, read_vardata + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + quantize_data,read_attribute, close_dataset, get_dim, read_vardata implicit none character(len=max_varname_length), dimension(n2d), intent(in) :: vars2d @@ -423,8 +423,8 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes, use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - quantize_data,read_attribute, close_dataset, get_dim, read_vardata + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + quantize_data,read_attribute, close_dataset, get_dim, read_vardata implicit none integer, intent(in) :: nanal1,nanal2 @@ -1032,11 +1032,11 @@ end subroutine readgriddata subroutine writegriddata_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,no_inflate_flag) use netcdf - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr use constants, only: grav, zero use params, only: nbackgrounds,anlfileprefixes,fgfileprefixes,reducedgrid,& nccompress @@ -1842,11 +1842,11 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,grdin,n nemsio_readrec,nemsio_writerec,nemsio_intkind,nemsio_charkind,& nemsio_getheadvar,nemsio_realkind,nemsio_getfilehead,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr use constants, only: grav use params, only: nbackgrounds,anlfileprefixes,fgfileprefixes,reducedgrid,& nccompress,write_ensmean @@ -3308,11 +3308,11 @@ subroutine writeincrement(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,grdin, datestring,nhr_anal,write_ensmean use constants, only: grav use mpi - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr implicit none integer, intent(in) :: nanal1,nanal2 @@ -3711,11 +3711,11 @@ subroutine writeincrement_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,no_inflate datestring,nhr_anal use constants, only: grav use mpi - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr implicit none character(len=max_varname_length), dimension(n2d), intent(in) :: vars2d diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index c1cb718856..4aa6aa850e 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -7,7 +7,6 @@ project(gsi list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) -include(compiler_flags) include(GNUInstallDirs) if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") @@ -30,13 +29,15 @@ endif() option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) option(USE_NCDIAG "Use NetCDF diagnostics library" ON) -option(BUILD_GSI_REGIONAL "Build Regional GSI" OFF) + +set(GSI_APP "GFS" CACHE STRING "Choose the GSI Application.") +set_property(CACHE GSI_APP PROPERTY STRINGS "GFS" "Regional") # Echo user options message(STATUS "OPENMP ................. ${OPENMP}") message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") message(STATUS "USE_NCDIAG ............. ${USE_NCDIAG}") -message(STATUS "BUILD_GSI_REGIONAL ..... ${BUILD_GSI_REGIONAL}") +message(STATUS "GSI_APP ................ ${GSI_APP}") # Dependencies if(ENABLE_MKL) @@ -45,6 +46,7 @@ endif() if(MKL_FOUND) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) else() + set(ENABLE_MKL OFF CACHE INTERNAL "Disable MKL since it was NOT FOUND") find_package(LAPACK REQUIRED) endif() find_package(MPI REQUIRED) @@ -64,189 +66,138 @@ find_package(ip REQUIRED) find_package(w3emc REQUIRED) find_package(bufr REQUIRED) find_package(crtm REQUIRED) - -if(BUILD_GSI_REGIONAL) +if(GSI_APP MATCHES "Regional") find_package(wrf_io REQUIRED) endif() +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + # NetCDF Diagnostic IO library dependency if(USE_NCDIAG) - if(NOT TARGET ncdiag::ncdiag) + if(NOT TARGET ncdiag) find_package(ncdiag REQUIRED) endif() endif() -# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 -target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - # Get compiler flags for the GSI application include(gsiapp_compiler_flags) # Get the list of all source files include(gsi_files.cmake) +# Collect common files for GSI Fortran library +list(APPEND GSI_SRC_Fortran + ${GSI_SRC_srcs} + ${GSI_SRC_class}) + +# Collect files for specific GSI Application +if(GSI_APP MATCHES "GFS") # GFS GSI application +list(APPEND GSI_SRC_Fortran + ${GSI_SRC_gfs_stub} + ${GSI_SRC_fixture_gfs}) +elseif(GSI_APP MATCHES "Regional") # Regional GSI application + list(APPEND GSI_SRC_Fortran + ${GSI_SRC_regional_cplr} + ${GSI_SRC_fixture_regional}) +endif() + # Include GSI ncdiag files if NetCDF Diagnostics is disabled if(NOT USE_NCDIAG) list(APPEND GSI_SRC_Fortran - ${GSI_SRC_ncdiag} - ) + ${GSI_SRC_ncdiag}) endif() -# Collect files specific for each application -# Global GSI application -list(APPEND GSI_SRC_Fortran_global - ${GSI_SRC_Fortran} - ${GSI_SRC_class} - ${GSI_SRC_stub} - ${GSI_SRC_fixture_gfs} -) - -# Regional GSI application -list(APPEND GSI_SRC_Fortran_regional - ${GSI_SRC_Fortran} - ${GSI_SRC_class} - ${GSI_SRC_cplr} - ${GSI_SRC_fixture_regional} -) - # Compiler options and definitions list(APPEND GSI_C_DEFS FortranByte=char FortranInt=int funder - "FortranLlong=long long" -) + "FortranLlong=long long") # Create object libraries for various components -# GSI_SRC_C files +# Create a library of GSI C Objects add_library(gsi_c_obj OBJECT ${GSI_SRC_C}) target_compile_definitions(gsi_c_obj PUBLIC ${GSI_C_DEFS}) -# Create a library of GLOBAL GSI Fortran Objects -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi") -add_library(global_gsi_fortran_obj OBJECT ${GSI_SRC_Fortran_global}) -set_target_properties(global_gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_include_directories(global_gsi_fortran_obj INTERFACE +# Create a library of GSI Fortran Objects +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsi") +add_library(gsi_fortran_obj OBJECT ${GSI_SRC_Fortran}) +set_target_properties(gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(gsi_fortran_obj INTERFACE $ - $) -list(APPEND GSI_LIB_Fortran_Targets - global_gsi_fortran_obj -) - -# Create a library of REGIONAL GSI Fortran objects -if(BUILD_GSI_REGIONAL) - set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi") - add_library(regional_gsi_fortran_obj OBJECT ${GSI_SRC_Fortran_regional}) - set_target_properties(regional_gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") - target_include_directories(regional_gsi_fortran_obj INTERFACE - $ - $) - list(APPEND GSI_LIB_Fortran_Targets - regional_gsi_fortran_obj - ) -endif() + $) # Link the Fortran targets with dependencies -foreach(lib ${GSI_LIB_Fortran_Targets}) - target_compile_definitions(${lib} PUBLIC "_REAL8_") - target_link_libraries(${lib} PUBLIC bacio::bacio_4) - target_link_libraries(${lib} PUBLIC sigio::sigio) - target_link_libraries(${lib} PUBLIC sfcio::sfcio) - target_link_libraries(${lib} PUBLIC nemsio::nemsio) - target_link_libraries(${lib} PUBLIC ncio::ncio) - target_link_libraries(${lib} PUBLIC w3emc::w3emc_d) - target_link_libraries(${lib} PUBLIC crtm::crtm) - target_link_libraries(${lib} PUBLIC NetCDF::NetCDF_Fortran) - target_link_libraries(${lib} PUBLIC MPI::MPI_Fortran) - if(OpenMP_Fortran_FOUND) - target_link_libraries(${lib} PRIVATE OpenMP::OpenMP_Fortran) - endif() - if(USE_NCDIAG) - if(TARGET ncdiag::ncdiag) - add_dependencies(${lib} ncdiag::ncdiag) - add_library(ncdiag::ncdiag ALIAS ncdiag) - endif() - target_link_libraries(${lib} PUBLIC ncdiag::ncdiag) +target_compile_definitions(gsi_fortran_obj PUBLIC "_REAL8_") +target_link_libraries(gsi_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(gsi_fortran_obj PUBLIC MPI::MPI_Fortran) +target_link_libraries(gsi_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(gsi_fortran_obj PUBLIC bacio::bacio_4) +target_link_libraries(gsi_fortran_obj PUBLIC sigio::sigio) +target_link_libraries(gsi_fortran_obj PUBLIC sfcio::sfcio) +target_link_libraries(gsi_fortran_obj PUBLIC nemsio::nemsio) +target_link_libraries(gsi_fortran_obj PUBLIC ncio::ncio) +target_link_libraries(gsi_fortran_obj PUBLIC w3emc::w3emc_d) +target_link_libraries(gsi_fortran_obj PUBLIC crtm::crtm) +if(GSI_APP MATCHES "Regional") + target_link_libraries(gsi_fortran_obj PUBLIC wrf_io::wrf_io) +endif() +if(USE_NCDIAG) + if(TARGET ncdiag) + add_dependencies(gsi_fortran_obj ncdiag) + add_library(ncdiag::ncdiag ALIAS ncdiag) endif() -endforeach() - -# Create a GLOBAL GSI library -add_library(global_gsi STATIC $ - $) -add_library(${PROJECT_NAME}::global_gsi ALIAS global_gsi) -target_include_directories(global_gsi PUBLIC $ - $) -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) -list(APPEND GSI_LIB_Targets global_gsi) - -# Create a REGIONAL GSI library -if(BUILD_GSI_REGIONAL) - add_library(regional_gsi STATIC $ - $) - add_library(${PROJECT_NAME}::regional_gsi ALIAS regional_gsi) - target_include_directories(regional_gsi PUBLIC $ - $) - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) - list(APPEND GSI_LIB_Targets regional_gsi) + target_link_libraries(gsi_fortran_obj PUBLIC ncdiag::ncdiag) endif() - -# Create a GLOBAL GSI executable -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/global_gsi") -add_executable(global_gsi.x ${GSI_SRC_main}) -add_dependencies(global_gsi.x global_gsi) -set_target_properties(global_gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_link_libraries(global_gsi.x PRIVATE global_gsi) -list(APPEND GSI_APP_Targets - global_gsi.x -) - -# Create a REGIONAL GSI executable -if(BUILD_GSI_REGIONAL) - set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/regional_gsi") - add_executable(regional_gsi.x ${GSI_SRC_main}) - add_dependencies(regional_gsi.x regional_gsi) - set_target_properties(regional_gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") - target_link_libraries(regional_gsi.x PRIVATE regional_gsi) - list(APPEND GSI_APP_Targets - regional_gsi.x - ) +if(OpenMP_Fortran_FOUND) + target_link_libraries(gsi_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) endif() -# Link the application targets with dependencies -foreach(app ${GSI_APP_Targets}) - target_link_libraries(${app} PUBLIC bacio::bacio_4) - target_link_libraries(${app} PUBLIC sigio::sigio) - target_link_libraries(${app} PUBLIC sfcio::sfcio) - target_link_libraries(${app} PUBLIC nemsio::nemsio) - target_link_libraries(${app} PUBLIC ncio::ncio) - target_link_libraries(${app} PUBLIC w3emc::w3emc_d) - target_link_libraries(${app} PUBLIC sp::sp_d) - target_link_libraries(${app} PUBLIC bufr::bufr_d) - target_link_libraries(${app} PUBLIC crtm::crtm) - if(USE_NCDIAG) - target_link_libraries(${app} PUBLIC ncdiag::ncdiag) - endif() - target_link_libraries(${app} PUBLIC NetCDF::NetCDF_Fortran) - target_link_libraries(${app} PUBLIC MPI::MPI_Fortran) - target_link_libraries(${app} PUBLIC ${LAPACK_LIBRARIES}) - if(OpenMP_Fortran_FOUND) - target_link_libraries(${app} PRIVATE OpenMP::OpenMP_Fortran) - endif() -endforeach() +# Create a GSI library +add_library(gsi STATIC $ + $) +add_library(${PROJECT_NAME}::gsi ALIAS gsi) +target_include_directories(gsi PUBLIC $ + $) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +# Create a GSI executable +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsi") +add_executable(gsi.x ${GSI_SRC_main}) +add_dependencies(gsi.x gsi) +set_target_properties(gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_link_libraries(gsi.x PRIVATE gsi) -# REGIONAL GSI Application specific library dependencies -if(BUILD_GSI_REGIONAL) - target_link_libraries(regional_gsi.x PUBLIC wrf_io::wrf_io) +# Link the application targets with dependencies +target_link_libraries(gsi.x PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(gsi.x PUBLIC MPI::MPI_Fortran) +target_link_libraries(gsi.x PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(gsi.x PUBLIC bacio::bacio_4) +target_link_libraries(gsi.x PUBLIC sigio::sigio) +target_link_libraries(gsi.x PUBLIC sfcio::sfcio) +target_link_libraries(gsi.x PUBLIC nemsio::nemsio) +target_link_libraries(gsi.x PUBLIC ncio::ncio) +target_link_libraries(gsi.x PUBLIC w3emc::w3emc_d) +target_link_libraries(gsi.x PUBLIC sp::sp_d) +target_link_libraries(gsi.x PUBLIC bufr::bufr_d) +target_link_libraries(gsi.x PUBLIC crtm::crtm) +if(GSI_APP MATCHES "Regional") + target_link_libraries(gsi.x PUBLIC wrf_io::wrf_io) +endif() +if(USE_NCDIAG) + target_link_libraries(gsi.x PUBLIC ncdiag::ncdiag) +endif() +if(OpenMP_Fortran_FOUND) + target_link_libraries(gsi.x PRIVATE OpenMP::OpenMP_Fortran) endif() # Install executable targets -install(TARGETS ${GSI_APP_Targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS gsi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # Install library archive targets install( - TARGETS ${GSI_LIB_Targets} + TARGETS gsi EXPORT ${PROJECT_NAME}Exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in index 854213b3fd..7476954aa2 100644 --- a/src/gsi/cmake/PackageConfig.cmake.in +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -3,24 +3,25 @@ #@PROJECT_NAME@-config.cmake # # Imported interface targets provided: -# * @PROJECT_NAME@::global_gsi - global GSI library target -# * @PROJECT_NAME@::regional_gsi - global GSI library target +# * @PROJECT_NAME@::gsi - GSI library target # Include targets file. This will create IMPORTED target @PROJECT_NAME@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) +# Set the GSI Application this library is built for +set(GSI_APP @GSI_APP@) + find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) # ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF if(@ENABLE_MKL@) - find_dependency(MKL QUIET) -endif() -if(MKL_FOUND) + find_dependency(MKL) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) -else() +endif() +if(NOT @ENABLE_MKL@) find_dependency(LAPACK REQUIRED) endif() @@ -40,11 +41,15 @@ find_dependency(w3emc REQUIRED) find_dependency(bufr REQUIRED) find_dependency(crtm REQUIRED) -# ON|OFF implies @PROJECT_NAME@ was compiled with/without -DBUILD_REGIONAL=ON|OFF -if(@BUILD_REGIONAL@) +if(GSI_APP MATCHES "Regional") find_dependency(wrf_io REQUIRED) endif() +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -USE_NCDIAG=ON|OFF +#if(@USE_NCDIAG@) +# find_dependency(ncdiag REQUIRED) +#endif() + # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -52,4 +57,5 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") - +message(STATUS "FindGSI defines targets:") +message(STATUS " - GSI_APP [${GSI_APP}]") diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake index 29fdf7b95d..516a06ed27 100644 --- a/src/gsi/gsi_files.cmake +++ b/src/gsi/gsi_files.cmake @@ -19,7 +19,7 @@ class_wrwrfnmma.f90 ) # Stubs for Global interface -list(APPEND GSI_SRC_stub +list(APPEND GSI_SRC_gfs_stub stub_get_pseudo_ensperts.f90 stub_get_wrf_mass_ensperts.f90 stub_get_wrf_nmm_ensperts.f90 @@ -34,7 +34,7 @@ stub_wrwrfmassa.f90 stub_wrwrfnmma.f90 ) -list(APPEND GSI_SRC_cplr +list(APPEND GSI_SRC_regional_cplr cplr_get_pseudo_ensperts.f90 cplr_get_wrf_mass_ensperts.f90 cplr_get_wrf_nmm_ensperts.f90 @@ -68,7 +68,7 @@ gsi_fixture_REGIONAL.F90 ) # All else Fortran sources that are not in above categories -list(APPEND GSI_SRC_Fortran +list(APPEND GSI_SRC_srcs abstract_ensmod.f90 adjtest.f90 adjtest_obs.f90 diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags.cmake index 2c1ea8ebba..c61631da53 100644 --- a/src/ncdiag/cmake/ncdiag_compiler_flags.cmake +++ b/src/ncdiag/cmake/ncdiag_compiler_flags.cmake @@ -7,9 +7,9 @@ endif() ####################################################################################### if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - include(compiler_flags_GNU_Fortran) + include(ncdiag_compiler_flags_GNU_Fortran) elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - include(compiler_flags_Intel_Fortran) + include(ncdiag_compiler_flags_Intel_Fortran) else() message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") endif() diff --git a/src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake similarity index 100% rename from src/ncdiag/cmake/compiler_flags_GNU_Fortran.cmake rename to src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake diff --git a/src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake similarity index 100% rename from src/ncdiag/cmake/compiler_flags_Intel_Fortran.cmake rename to src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake From 14ef66d70826812bf5efea35cdedc0d2064a5406 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 25 Feb 2022 17:35:38 -0500 Subject: [PATCH 15/58] ncdiag, gsi and enkf can be now built independently --- src/enkf/cmake/FindNetCDF.cmake | 347 ++++++++++++++++++++++++++++++++ src/gsi/cmake/FindNetCDF.cmake | 347 ++++++++++++++++++++++++++++++++ 2 files changed, 694 insertions(+) create mode 100644 src/enkf/cmake/FindNetCDF.cmake create mode 100644 src/gsi/cmake/FindNetCDF.cmake diff --git a/src/enkf/cmake/FindNetCDF.cmake b/src/enkf/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/src/enkf/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation nor +# does it submit to any jurisdiction. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() diff --git a/src/gsi/cmake/FindNetCDF.cmake b/src/gsi/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/src/gsi/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation nor +# does it submit to any jurisdiction. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() From 6fae4be1395df0d1179be6a9aa63105306d5bd33 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 1 Mar 2022 20:01:52 -0500 Subject: [PATCH 16/58] build all (except Monitoring) utilities --- CMakeLists.txt | 2 +- src/gsi/CMakeLists.txt | 28 +- util/AeroDA/CMakeLists.txt | 1 + .../calc_increment_ens.fd/CMakeLists.txt | 43 +- util/Analysis_Utilities/CMakeLists.txt | 1 + .../read_diag/CMakeLists.txt | 40 +- util/Analysis_Utilities/read_diag/kinds.F90 | 39 ++ util/CMakeLists.txt | 119 +++- util/Correlated_Obs/CMakeLists.txt | 135 ++--- util/EFSOI_Utilities/CMakeLists.txt | 1 + util/EFSOI_Utilities/src/CMakeLists.txt | 87 ++- util/EFSOI_Utilities/src/gridio_efsoi.f90 | 518 +++++++++--------- util/EnKF/CMakeLists.txt | 2 + util/EnKF/arw/CMakeLists.txt | 1 + util/EnKF/arw/src/CMakeLists.txt | 25 +- .../src/enspreproc_regional.fd/CMakeLists.txt | 63 ++- .../src/initialens_regional.fd/CMakeLists.txt | 60 +- util/EnKF/gfs/CMakeLists.txt | 1 + util/EnKF/gfs/src/CMakeLists.txt | 41 +- .../EnKF/gfs/src/adderrspec.fd/CMakeLists.txt | 28 +- util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt | 26 +- .../src/calc_increment_ens.fd/CMakeLists.txt | 42 +- .../calc_increment_ens_ncio.fd/CMakeLists.txt | 41 +- .../gfs_ncio_interface.f90 | 2 +- .../src/calc_increment_ncio.fd/CMakeLists.txt | 21 +- .../calc_increment_ncio.f90 | 16 +- .../calc_increment_serial.fd/CMakeLists.txt | 38 +- .../gfs/src/getnstensmeanp.fd/CMakeLists.txt | 25 +- .../gfs/src/getsfcensmeanp.fd/CMakeLists.txt | 26 +- .../src/getsfcensmeanp.fd/getsfcensmeanp.f90 | 8 +- .../src/getsfcnstensupdp.fd/CMakeLists.txt | 38 +- .../getsigensmeanp_smooth.fd/CMakeLists.txt | 30 +- .../getsigensmeanp_smooth_ncep.f90 | 10 +- .../gfs/src/getsigensstatp.fd/CMakeLists.txt | 29 +- .../src/getsigensstatp.fd/getsigensstatp.f90 | 16 +- util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt | 20 +- util/EnKF/gfs/src/preproc/CMakeLists.txt | 38 +- .../src/recenterens_ncio.fd/CMakeLists.txt | 27 +- .../recenterens_ncio.fd/recenterens_ncio.f90 | 12 +- .../recenterncio_hybgain.fd/CMakeLists.txt | 27 +- .../recenterncio_hybgain.f90 | 18 +- .../recenternemsiop_hybgain.fd/CMakeLists.txt | 23 +- .../gfs/src/recentersigp.fd/CMakeLists.txt | 26 +- .../gfs/src/recentersigp.fd/recentersigp.f90 | 8 +- util/bufr_tools/CMakeLists.txt | 86 ++- util/cmake/FindNetCDF.cmake | 347 ++++++++++++ util/cmake/gsiutils_compiler_flags.cmake | 27 + .../cmake/gsiutils_compiler_flags_GNU_C.cmake | 40 ++ .../gsiutils_compiler_flags_GNU_Fortran.cmake | 56 ++ .../gsiutils_compiler_flags_Intel_C.cmake | 40 ++ ...siutils_compiler_flags_Intel_Fortran.cmake | 51 ++ util/ndate/CMakeLists.txt | 11 +- util/netcdf_io/CMakeLists.txt | 25 +- .../netcdf_io/calc_analysis.fd/CMakeLists.txt | 37 +- util/netcdf_io/calc_analysis.fd/inc2anl.f90 | 8 +- util/netcdf_io/calc_analysis.fd/init_io.f90 | 4 +- .../calc_analysis.fd/vars_calc_analysis.f90 | 2 +- util/netcdf_io/interp_inc.fd/CMakeLists.txt | 30 +- util/netcdf_io/interp_inc.fd/driver.f90 | 106 ++-- util/radar_process/CMakeLists.txt | 2 + util/radar_process/radialwind/CMakeLists.txt | 31 +- .../radar_process/reflectivity/CMakeLists.txt | 38 +- util/radar_process/reflectivity/kinds.F90 | 39 ++ .../reflectivity/write_bufr_ref.f90 | 3 +- util/zero_biascoeff/CMakeLists.txt | 36 +- 65 files changed, 1907 insertions(+), 914 deletions(-) create mode 100644 util/AeroDA/CMakeLists.txt create mode 100644 util/Analysis_Utilities/CMakeLists.txt create mode 100644 util/Analysis_Utilities/read_diag/kinds.F90 create mode 100644 util/EFSOI_Utilities/CMakeLists.txt create mode 100644 util/EnKF/CMakeLists.txt create mode 100644 util/EnKF/arw/CMakeLists.txt create mode 100644 util/EnKF/gfs/CMakeLists.txt create mode 100644 util/cmake/FindNetCDF.cmake create mode 100644 util/cmake/gsiutils_compiler_flags.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_GNU_C.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_Intel_C.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake create mode 100644 util/radar_process/CMakeLists.txt create mode 100644 util/radar_process/reflectivity/kinds.F90 diff --git a/CMakeLists.txt b/CMakeLists.txt index f7d748cbe8..7304f9fdde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,6 @@ message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") # Build components add_subdirectory(src) -#add_subdirectory(util) +add_subdirectory(util) #add_subdirectory(unit-tests) #add_subdirectory(regression) diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 4aa6aa850e..5ac972474d 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -170,23 +170,23 @@ set_target_properties(gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") target_link_libraries(gsi.x PRIVATE gsi) # Link the application targets with dependencies -target_link_libraries(gsi.x PUBLIC NetCDF::NetCDF_Fortran) -target_link_libraries(gsi.x PUBLIC MPI::MPI_Fortran) -target_link_libraries(gsi.x PUBLIC ${LAPACK_LIBRARIES}) -target_link_libraries(gsi.x PUBLIC bacio::bacio_4) -target_link_libraries(gsi.x PUBLIC sigio::sigio) -target_link_libraries(gsi.x PUBLIC sfcio::sfcio) -target_link_libraries(gsi.x PUBLIC nemsio::nemsio) -target_link_libraries(gsi.x PUBLIC ncio::ncio) -target_link_libraries(gsi.x PUBLIC w3emc::w3emc_d) -target_link_libraries(gsi.x PUBLIC sp::sp_d) -target_link_libraries(gsi.x PUBLIC bufr::bufr_d) -target_link_libraries(gsi.x PUBLIC crtm::crtm) +target_link_libraries(gsi.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(gsi.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(gsi.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(gsi.x PRIVATE bacio::bacio_4) +target_link_libraries(gsi.x PRIVATE sigio::sigio) +target_link_libraries(gsi.x PRIVATE sfcio::sfcio) +target_link_libraries(gsi.x PRIVATE nemsio::nemsio) +target_link_libraries(gsi.x PRIVATE ncio::ncio) +target_link_libraries(gsi.x PRIVATE w3emc::w3emc_d) +target_link_libraries(gsi.x PRIVATE sp::sp_d) +target_link_libraries(gsi.x PRIVATE bufr::bufr_d) +target_link_libraries(gsi.x PRIVATE crtm::crtm) if(GSI_APP MATCHES "Regional") - target_link_libraries(gsi.x PUBLIC wrf_io::wrf_io) + target_link_libraries(gsi.x PRIVATE wrf_io::wrf_io) endif() if(USE_NCDIAG) - target_link_libraries(gsi.x PUBLIC ncdiag::ncdiag) + target_link_libraries(gsi.x PRIVATE ncdiag::ncdiag) endif() if(OpenMP_Fortran_FOUND) target_link_libraries(gsi.x PRIVATE OpenMP::OpenMP_Fortran) diff --git a/util/AeroDA/CMakeLists.txt b/util/AeroDA/CMakeLists.txt new file mode 100644 index 0000000000..59b3a34005 --- /dev/null +++ b/util/AeroDA/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(calc_increment_ens.fd) diff --git a/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt b/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt index c01e2529a7..4ada1e6fbf 100644 --- a/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt +++ b/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt @@ -1,14 +1,31 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL_COM) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_increment_ens_aero") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_increment_ens_aero.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ens_aero.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_increment_ens_aero.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - target_link_libraries( calc_increment_ens_aero.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment_interface.f90 + configure + constants.f90 + fv3_interface.f90 + gfs_nems_interface.f90 + kinds.f90 + namelist_def.f90 + pmain.f90 + variable_interface.f90) + +add_executable(calc_increment_ens_aero.x ${SRCS}) +target_compile_definitions(calc_increment_ens_aero.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_ens_aero.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ens_aero.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_increment_ens_aero.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_ens_aero.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calc_increment_ens_aero.x PRIVATE nemsio::nemsio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(calc_increment_ens_aero.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS calc_increment_ens_aero.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/Analysis_Utilities/CMakeLists.txt b/util/Analysis_Utilities/CMakeLists.txt new file mode 100644 index 0000000000..d21fdeae15 --- /dev/null +++ b/util/Analysis_Utilities/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(read_diag) diff --git a/util/Analysis_Utilities/read_diag/CMakeLists.txt b/util/Analysis_Utilities/read_diag/CMakeLists.txt index 0b2c61d48a..4130c809cc 100644 --- a/util/Analysis_Utilities/read_diag/CMakeLists.txt +++ b/util/Analysis_Utilities/read_diag/CMakeLists.txt @@ -1,13 +1,27 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - - add_executable(read_diag_conv.x read_diag_conv.f90 ) - set_target_properties( read_diag_conv.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( read_diag_conv.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(read_diag_conv.x ${GSILIB} ) - - add_executable(read_diag_rad.x read_diag_rad.f90 ) - set_target_properties( read_diag_rad.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( read_diag_rad.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(read_diag_rad.x ${GSILIB} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/read_diag") +add_library(kinds_obj OBJECT kinds.F90) +set_target_properties(kinds_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(kinds_obj INTERFACE + $) + +add_executable(read_diag_conv.x read_diag_conv.f90) +add_executable(read_diag_rad.x read_diag_rad.f90) + +list(APPEND _targets + read_diag_conv.x + read_diag_rad.x) + +foreach(_tgt ${_targets}) + add_dependencies(${_tgt} kinds_obj) + target_compile_definitions(${_tgt} PRIVATE "_REAL8_") + target_include_directories(${_tgt} PRIVATE $) +endforeach() + +# Install executable targets +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Analysis_Utilities/read_diag/kinds.F90 b/util/Analysis_Utilities/read_diag/kinds.F90 new file mode 100644 index 0000000000..ac3a0903bf --- /dev/null +++ b/util/Analysis_Utilities/read_diag/kinds.F90 @@ -0,0 +1,39 @@ +module kinds +! Stripped down version of gsi/kinds.F90 for this utility +! This is to avoid building and depending on the entire GSI compiled library + implicit none + + public i_kind, i_byte, i_short, i_long, i_llong + public r_kind, r_single, r_double, r_quad + + private + integer, parameter :: default_integer = 3 ! 1=byte, + ! 2=short, + ! 3=long, + ! 4=llong + integer, parameter :: i_byte = selected_int_kind(1) ! byte integer + integer, parameter :: i_short = selected_int_kind(4) ! short integer + integer, parameter :: i_long = selected_int_kind(8) ! long integer + integer, parameter :: llong_t = selected_int_kind(16) ! llong integer + integer, parameter :: i_llong = max( llong_t, i_long ) + integer, parameter, dimension(4) :: integer_types = (/ & + i_byte, i_short, i_long, i_llong /) + integer, parameter :: i_kind = integer_types( default_integer ) + +#ifdef _REAL4_ + integer, parameter :: default_real = 1 ! 1=single +#elseif _REAL8_ + integer, parameter :: default_real = 2 ! 2=double +#elseif _REAL16_ + integer, parameter :: default_real = 3 ! 3=quad +#else + integer, parameter :: default_real = 1 ! 1=single +#endif + integer, parameter :: r_single = selected_real_kind(6) ! single precision + integer, parameter :: r_double = selected_real_kind(15) ! double precision + integer, parameter :: quad_t = selected_real_kind(20) ! quad precision + integer, parameter :: r_quad = max( quad_t, r_double ) + integer, parameter, dimension(3) :: & + real_kinds = (/ r_single, r_double, r_quad /) + integer, parameter :: r_kind = real_kinds( default_real ) +end module kinds diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 3dfb278e82..dd16fa74bf 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -1,35 +1,104 @@ +cmake_minimum_required(VERSION 3.15) + +project(gsiutils + VERSION 1.0.0 + LANGUAGES C Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") +endif() + +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +option(USE_NCDIAG "Use NetCDF diagnostics library" ON) + +set(GSI_APP "GFS" CACHE STRING "Choose the GSI Application.") +set_property(CACHE GSI_APP PROPERTY STRINGS "GFS" "Regional") + +# Echo user options +message(STATUS "OPENMP ................. ${OPENMP}") +message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") + +# Dependencies +if(ENABLE_MKL) + find_package(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + set(ENABLE_MKL OFF CACHE INTERNAL "Disable MKL since it was NOT FOUND") + find_package(LAPACK REQUIRED) +endif() +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() + +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(ip REQUIRED) +find_package(w3emc REQUIRED) +find_package(bufr REQUIRED) +find_package(crtm REQUIRED) + +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + +# Get compiler flags for the utilities +include(gsiutils_compiler_flags) + add_subdirectory(AeroDA) add_subdirectory(Analysis_Utilities) -add_subdirectory(Baseline) add_subdirectory(bufr_tools) -add_subdirectory(CMakeLists.txt) -add_subdirectory(Config) -add_subdirectory(Conventional_Monitor) +#add_subdirectory(Conventional_Monitor) add_subdirectory(Correlated_Obs) -add_subdirectory(DTC) add_subdirectory(EFSOI_Utilities) add_subdirectory(EnKF) -add_subdirectory(Fit2Obs_Scorecard) -add_subdirectory(FOV_utilities) -add_subdirectory(GEN_BE_V2.0) -add_subdirectory(global_angupdate) -add_subdirectory(GMI_BUFR_gen) -add_subdirectory(gsienvreport.sh) -add_subdirectory(Minimization_Monitor) -add_subdirectory(Misc) -add_subdirectory(MODIS_AOD) -add_subdirectory(NCEP_bkerror) -add_subdirectory(NCEPgsi_Coupler) add_subdirectory(ndate) add_subdirectory(netcdf_io) -add_subdirectory(NMC_Bkerror) -add_subdirectory(Ozone_Monitor) -add_subdirectory(python_utilities) -add_subdirectory(Radar_Monitor) +#add_subdirectory(Ozone_Monitor) add_subdirectory(radar_process) -add_subdirectory(Radiance_bias_correction_Utilities) -add_subdirectory(Radiance_Monitor) -add_subdirectory(Radiance_Utilities) -add_subdirectory(README) -add_subdirectory(Single_Observation) +#add_subdirectory(Radiance_Monitor) add_subdirectory(zero_biascoeff) + +# These utilities do not have CMake builds +# Some are used occasionally e.g. NMC_Bkerror +# Some are really really old and likely unusable today e.g. Config +#add_subdirectory(Config) +#add_subdirectory(FOV_utilities) +#add_subdirectory(GEN_BE_V2.0) +#add_subdirectory(global_angupdate) +#add_subdirectory(GMI_BUFR_gen) +#add_subdirectory(Minimization_Monitor) +#add_subdirectory(Misc) +#add_subdirectory(MODIS_AOD) +#add_subdirectory(NCEP_bkerror) +#add_subdirectory(NCEPgsi_Coupler) +#add_subdirectory(NMC_Bkerror) +#add_subdirectory(Radiance_bias_correction_Utilities) +#add_subdirectory(Radiance_Utilities) +#add_subdirectory(Single_Observation) diff --git a/util/Correlated_Obs/CMakeLists.txt b/util/Correlated_Obs/CMakeLists.txt index 28137ad946..8c0c91a346 100644 --- a/util/Correlated_Obs/CMakeLists.txt +++ b/util/Correlated_Obs/CMakeLists.txt @@ -1,92 +1,47 @@ -cmake_minimum_required(VERSION 2.6) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - find_package(OpenMP) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Theia.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - find_package(MPI REQUIRED) - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( NetCDF REQUIRED) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/libsrc/ncdiag") - set(BUILD_NCDIAG ON) - add_subdirectory(${PROJECT_SOURCE_DIR}/../../src/ncdiag ${PROJECT_BINARY_DIR}/libsrc/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() - set(COV_CALC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/cov_calc.f90 ${CMAKE_CURRENT_SOURCE_DIR}/cconstants.f90 ${CMAKE_CURRENT_SOURCE_DIR}/ckinds.f90 ${CMAKE_CURRENT_SOURCE_DIR}/matrix_tools.f90 ${CMAKE_CURRENT_SOURCE_DIR}/obs_tools.f90 ${CMAKE_CURRENT_SOURCE_DIR}/pairs.f90 ${CMAKE_CURRENT_SOURCE_DIR}/readsatobs.f90 ${CMAKE_CURRENT_SOURCE_DIR}/read_diag.f90 ) -message("HEY!! openmp flag is ${OpenMP_Fortran_FLAGS} and libraries are ${OpenMP_Fortran_LIBRARIES}") -#message("HEY!! coreincs is ${CORE_INCS}") -message("ncdiag is ${NCDIAG_LIBRARIES}") - set_source_files_properties( ${COV_CALC_SRC} PROPERTIES COMPILE_FLAGS ${COV_CALC_FLAGS} ) - add_executable(cov_calc ${COV_CALC_SRC} ) - add_dependencies(cov_calc ${NCDIAG_LIBRARIES}) - set_target_properties( cov_calc PROPERTIES COMPILE_FLAGS ${COV_CALC_FLAGS} ) - include_directories( ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS}) -# target_link_libraries( cov_calc ${W3NCO_LIBRARY} ) - target_link_libraries( cov_calc ${OpenMP_Fortran_LIBRARIES} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_COV_CALC) -# add_dependencies( cov_calc ${W3NCO_LIBRARY} ) -# add_dependencies( cov_calc ${OpenMP_Fortran_LIBRARIES} ) - endif() +if(NOT TARGET ncdiag) + find_package(ncdiag REQUIRED) +endif() + +list(APPEND SRCS + cconstants.f90 + ckinds.f90 + matrix_tools.f90 + obs_tools.f90 + pairs.f90 + readsatobs.f90 + read_diag.f90) + +# Create cov_calc library +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/cov_calc") +add_library(cov_calc OBJECT ${SRCS}) +set_target_properties(cov_calc PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(cov_calc INTERFACE $) + +target_link_libraries(cov_calc PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(cov_calc PUBLIC MPI::MPI_Fortran) +target_link_libraries(cov_calc PUBLIC ${LAPACK_LIBRARIES}) +if(TARGET ncdiag) + add_dependencies(cov_calc ncdiag) + add_library(ncdiag::ncdiag ALIAS ncdiag) +endif() +target_link_libraries(cov_calc PUBLIC ncdiag::ncdiag) +if(OpenMP_Fortran_FOUND) + target_link_libraries(cov_calc PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Create cov_calc.x executable +add_executable(cov_calc.x cov_calc.f90) +add_dependencies(cov_calc.x cov_calc) +target_link_libraries(cov_calc.x PRIVATE cov_calc) +if(OpenMP_Fortran_FOUND) + target_link_libraries(cov_calc.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS cov_calc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EFSOI_Utilities/CMakeLists.txt b/util/EFSOI_Utilities/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/EFSOI_Utilities/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 49d2a8fdee..988bd92453 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -1,21 +1,80 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_EFSOI) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +if(NOT TARGET enkf) + find_package(enkf QUIET) +endif() + +if(NOT enkf_FOUND) + message(STATUS "EnKF library was not found. Disable EFSOI utilities") + return() +endif() + +if(NOT ENKF_APP MATCHES "GFS") + message(STATUS "Incompatible EnKF = ${ENKF_APP}. Disable EFSOI utilities") + return() +endif() + +if(NOT TARGET gsi) + find_package(gsi REQUIRED) +endif() - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90) +if(NOT GFS_APP MATCHES "GFS") + message(STATUS "Incompatible GFS = ${GFS_APP}. Disable EFSOI utilities") + return() +endif() + +if(NOT TARGET ncdiag) + find_package(ncdiag REQUIRED) +endif() - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - - add_executable(global_efsoi.x ${LOCAL_SRC} ) - - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OMPFLAG}" ) - - include_directories(${CMAKE_CURRENT_BINARY_DIR} "${PROJECT_BINARY_DIR}/include/global" ${CMAKE_CURRENT_BINARY_DIR}/.. ${MPI_Fortran_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS} ${FV3GFS_NCIO_INCS}) +list(APPEND SRCS + efsoi.f90 + efsoi_main.f90 + gridio_efsoi.f90 + loadbal_efsoi.f90 + loc_advection.f90 + scatter_chunks_efsoi.f90 + statevec_efsoi.f90) - target_link_libraries( global_efsoi.x enkflib enkfdeplib ${GSILIB} ${GSISHAREDLIB} ${CORE_LIBRARIES} - ${MPI_Fortran_LIBRARIES} ${LAPACK_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} - ${FV3GFS_NCIO_LIBRARIES} - ${EXTRA_LINKER_FLAGS} ${GSI_LDFLAGS} ${CORE_BUILT} ${CORE_LIBRARIES} ${CORE_BUILT} ${NCDIAG_LIBRARIES}) +add_executable(global_efsoi.x ${SRCS}) + +if(TARGET ncdiag) + add_dependencies(global_efsoi.x ncdiag) endif() +if(TARGET gsi) + add_dependencies(global_efsoi.x gsi) +endif() +if(TARGET gsi) + add_dependencies(global_efsoi.x enkf) +endif() + +target_compile_definitions(global_efsoi.x PRIVATE "_REAL8_") + +# Link the application targets with dependencies +target_link_libraries(global_efsoi.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(global_efsoi.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(global_efsoi.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(global_efsoi.x PRIVATE bacio::bacio_4) +target_link_libraries(global_efsoi.x PRIVATE sigio::sigio) +target_link_libraries(global_efsoi.x PRIVATE sfcio::sfcio) +target_link_libraries(global_efsoi.x PRIVATE nemsio::nemsio) +target_link_libraries(global_efsoi.x PRIVATE ncio::ncio) +target_link_libraries(global_efsoi.x PRIVATE w3emc::w3emc_d) +target_link_libraries(global_efsoi.x PRIVATE sp::sp_d) +target_link_libraries(global_efsoi.x PRIVATE bufr::bufr_d) +target_link_libraries(global_efsoi.x PRIVATE crtm::crtm) +target_link_libraries(global_efsoi.x PRIVATE ncdiag::ncdiag) +target_link_libraries(global_efsoi.x PRIVATE gsi::gsi) +target_link_libraries(global_efsoi.x PRIVATE enkf::enkf) +if(OpenMP_Fortran_FOUND) + target_link_libraries(global_efsoi.x PRIVATE OpenMP::OpenMP_Fortran) +endif() +# Install executable targets +install(TARGETS global_efsoi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EFSOI_Utilities/src/gridio_efsoi.f90 b/util/EFSOI_Utilities/src/gridio_efsoi.f90 index 4687522c67..437089b1a1 100644 --- a/util/EFSOI_Utilities/src/gridio_efsoi.f90 +++ b/util/EFSOI_Utilities/src/gridio_efsoi.f90 @@ -13,7 +13,7 @@ module gridio_efsoi ! prgmmr: eichmann, lin org: emc date: 2021-02-04 ! ! abstract: I/O for ensemble member files. -! +! ! Public Functions: ! readgriddata_efsoi ! @@ -30,10 +30,10 @@ module gridio_efsoi ! 2016-04-20 Modify to handle the updated nemsio sig file (P, DP, DPDT ! removed) ! 2016-11-29 shlyaeva: Add reading/calculating tsen, qi, ql. Pass filenames and -! hours to read routine to read separately state and control files. +! hours to read routine to read separately state and control files. ! Pass levels and dimenstions to read/write routines (dealing with ! prse: nlevs + 1 levels). Pass "reducedgrid" parameter. -! 2017-06-14 Adding functionality to optionally write non-inflated ensembles, +! 2017-06-14 Adding functionality to optionally write non-inflated ensembles, ! a required input for EFSO calculations ! 2018-05-24 Pruning available EnKF nemsio read functionality for EFSOI ! application. Add additional routines to compute EFSOI relevant @@ -47,8 +47,8 @@ module gridio_efsoi ! !$$$ use constants, only: zero,one,cp,fv,rd,tiny_r_kind,max_varname_length,t0c,r0_05,constants_initialized, & - tref,pref,hvap - + tref,pref,hvap + use params, only: nlons,nlats,nlevs,use_gfs_nemsio,pseudo_rh, & cliptracers,datapath,imp_physics,use_gfs_ncio,cnvw_option, & nanals, & @@ -68,9 +68,9 @@ module gridio_efsoi lonsperlat, nlonsfull use mpisetup, only: nproc, numproc - - use mpimod, only: mpi_comm_world, mpi_sum, mpi_real4, mpi_real8, mpi_rtype - + + use mpimod, only: mpi_comm_world, mpi_sum, mpi_real4, mpi_real8, mpi_rtype + use mpeu_util, only: getindex use nemsio_module use loadbal_efsoi, only: numptsperproc, indxproc, npts_max @@ -94,64 +94,64 @@ subroutine get_weight() use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - quantize_data, read_attribute, close_dataset, get_dim, read_vardata - - implicit none - - character(len=500) :: filename - - real(r_kind), dimension(npts,nlevs+1) :: pressi - real(r_single), dimension(npts) :: tmpgrd + + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + quantize_data, read_attribute, close_dataset, get_dim, read_vardata + + implicit none + + character(len=500) :: filename + + real(r_kind), dimension(npts,nlevs+1) :: pressi + real(r_single), dimension(npts) :: tmpgrd type(nemsio_gfile) :: gfile real(nemsio_realkind), dimension(nlons*nlats) :: nems_wrk real(r_kind), dimension(nlons*nlats) :: psfc - real(r_single),allocatable,dimension(:,:,:) :: nems_vcoord - real(r_kind), allocatable, dimension(:) :: ak,bk - real(r_kind) :: sumcoslat - - integer(i_kind) :: nlevsin,nlonsin,nlatsin,idvc - integer(i_kind) :: i,j,k,iret!iunitsig,iret - - ! for netcdf handling - type(Dataset) :: dset - type(Dimension) :: londim,latdim,levdim + real(r_single),allocatable,dimension(:,:,:) :: nems_vcoord + real(r_kind), allocatable, dimension(:) :: ak,bk + real(r_kind) :: sumcoslat + + integer(i_kind) :: nlevsin,nlonsin,nlatsin,idvc + integer(i_kind) :: i,j,k,iret!iunitsig,iret + + ! for netcdf handling + type(Dataset) :: dset + type(Dimension) :: londim,latdim,levdim integer(i_kind) :: iunitsig type(sigio_head) :: sighead type(sigio_data) :: sigdata real(r_kind), allocatable, dimension(:) :: psg real(r_kind), dimension(ndimspec) :: vrtspec - real(r_single), allocatable, dimension(:,:) :: values_2d - integer(i_kind) :: ierr - - + real(r_single), allocatable, dimension(:,:) :: values_2d + integer(i_kind) :: ierr + + iunitsig = 77 ! ============================================================ - ! Read analysis data + ! Read analysis data ! ================================== ! update ncio !if (nproc .eq. 0) then filename = trim(adjustl(datapath))//trim(adjustl(andataname)) if (nproc == 0) print *,'reading analysis file: ',filename - ! --- nemsio data ------------------------------------------------- + ! --- nemsio data ------------------------------------------------- if (use_gfs_nemsio) then call nemsio_init(iret=iret) if(iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_init,iret=',iret call stop2(23) end if - + call nemsio_open(gfile,filename,'READ',iret=iret) - + if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_open,iret=',iret call stop2(23) endif - + call nemsio_getfilehead(gfile,iret=iret, dimx=nlonsin, dimy=nlatsin,& dimz=nlevsin,idvc=idvc) if (nlons /= nlonsin .or. nlats /= nlatsin .or. nlevs /= nlevsin) then @@ -160,21 +160,21 @@ subroutine get_weight() print *,'got',nlonsin,nlatsin,nlevsin call stop2(23) end if - - - ! --- NetCDF data ------------------------------------------------- + + + ! --- NetCDF data ------------------------------------------------- else if (use_gfs_ncio) then - + dset = open_dataset(filename) - + londim = get_dim(dset,'grid_xt'); nlonsin = londim%len latdim = get_dim(dset,'grid_yt'); nlatsin = latdim%len levdim = get_dim(dset,'pfull'); nlevsin = levdim%len idvc=2 - - - ! --- Other data ------------------------------------------------- + + + ! --- Other data ------------------------------------------------- else call sigio_srohdc(iunitsig,trim(filename), & sighead,sigdata,iret) @@ -183,17 +183,17 @@ subroutine get_weight() call stop2(23) end if endif - + !endif - ! ============================================================ - + ! ============================================================ + allocate(ak(nlevs+1)) allocate(bk(nlevs+1)) - allocate(psg(nlons*nlats)) - allocate(weight(npts,nlevs)) - allocate(grweight(npts)) - - + allocate(psg(nlons*nlats)) + allocate(weight(npts,nlevs)) + allocate(grweight(npts)) + + if (.not. constants_initialized) then print *,'constants not initialized (with init_constants, init_constants_derived)' call stop2(23) @@ -201,70 +201,70 @@ subroutine get_weight() ! calculate weight on the grid point sumcoslat = zero - + ! if(reducedgrid) then k=0 - do i=1,nlats - do j=1,lonsperlat(i) - k=k+1 - grweight(k) = cos(gaulats(i)) * real(nlonsfull,r_kind) & - / real(lonsperlat(i),r_kind) - sumcoslat = sumcoslat + grweight(k) - end do - end do - - ! else - ! do i=1,nlons*nlats - ! grweight(i) = cos(latsgrd(i)) - ! sumcoslat = sumcoslat + grweight(i) - ! end do - ! end if - - sumcoslat = 1.0_r_kind / sumcoslat + do i=1,nlats + do j=1,lonsperlat(i) + k=k+1 + grweight(k) = cos(gaulats(i)) * real(nlonsfull,r_kind) & + / real(lonsperlat(i),r_kind) + sumcoslat = sumcoslat + grweight(k) + end do + end do + + ! else + ! do i=1,nlons*nlats + ! grweight(i) = cos(latsgrd(i)) + ! sumcoslat = sumcoslat + grweight(i) + ! end do + ! end if + + sumcoslat = 1.0_r_kind / sumcoslat grweight(:) = sqrt(grweight(:)*sumcoslat) - + ! ==================================================== ! Extract surface pressure in pa ! to aid in quantifying mass ! ======================================== - ! === Option ONE, nemsio === - if (use_gfs_nemsio) then - + ! === Option ONE, nemsio === + if (use_gfs_nemsio) then + call nemsio_readrecv(gfile,'pres','sfc',1,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(ps), iret=',iret call stop2(23) endif - + ! Assign surface pressure in pa - psfc = nems_wrk + psfc = nems_wrk ! Extract surface pressure ! on reduced gaussian grid call regtoreduced(psfc,tmpgrd) - ! calculate half level pressures + ! calculate half level pressures if (allocated(nems_vcoord)) deallocate(nems_vcoord) - + allocate(nems_vcoord(nlevs+1,3,2)) call nemsio_getfilehead(gfile,iret=iret,vcoord=nems_vcoord) - + if ( iret /= 0 ) then write(6,*)' gridio: ***ERROR*** problem reading header ', & 'vcoord, Status = ',iret call stop2(99) - endif - + endif + if ( idvc == 0 ) then ! sigma coordinate, old file format. ak = zero bk = nems_vcoord(1:nlevs+1,1,1) else if ( idvc == 1 ) then ! sigma coordinate ak = zero bk = nems_vcoord(1:nlevs+1,2,1) - + else if ( idvc == 2 .or. idvc == 3 ) then ! hybrid coordinate - + ! AFE ak = nems_vcoord(1:nlevs+1,1,1) ! AFE ak = nems_vcoord(1:nlevs+1,2,1) ak = 0.01_r_kind*nems_vcoord(1:nlevs+1,1,1) ! convert to mb @@ -273,46 +273,46 @@ subroutine get_weight() write(6,*)'gridio: ***ERROR*** INVALID value for idvc=',idvc call stop2(85) end if - - !==> pressure at interfaces. - do k=1,nlevs+1 - pressi(:,k)=ak(k)+bk(k)*tmpgrd - end do - deallocate(ak,bk) - - ! === Option TWO, NetCDF === + + !==> pressure at interfaces. + do k=1,nlevs+1 + pressi(:,k)=ak(k)+bk(k)*tmpgrd + end do + deallocate(ak,bk) + + ! === Option TWO, NetCDF === else if (use_gfs_ncio) then - + call mpi_barrier(mpi_comm_world,ierr) call read_vardata(dset, 'pressfc', values_2d,errcode=iret) - + if (iret /= 0) then print *,'error reading ps' call stop2(31) endif - + psg = 0.01_r_kind*reshape(values_2d,(/nlons*nlats/)) - + ! Extract surface pressure ! on reduced gaussian grid - call regtoreduced(psg,tmpgrd) - + call regtoreduced(psg,tmpgrd) + call read_attribute(dset, 'ak', ak) call read_attribute(dset, 'bk', bk) - + ! pressure at interfaces do k=1,nlevs+1 pressi(:,k) = 0.01_r_kind*ak(nlevs-k+2)+bk(nlevs-k+2)*tmpgrd - + if (nproc == 0) print *,'netcdf, min/max pressi',k,minval(pressi(:,k)),maxval(pressi(:,k)) enddo - - deallocate(ak,bk,values_2d) - - ! === Option THREE, other === + + deallocate(ak,bk,values_2d) + + ! === Option THREE, other === else - + vrtspec = sigdata%ps call sptez_s(vrtspec,psg,1) !==> input psg is ln(ps) in centibars - convert to ps in millibars. @@ -336,94 +336,94 @@ subroutine get_weight() pressi(:,k)=ak(k)+bk(k)*psg print *,'sigio, min/max pressi',k,minval(pressi(:,k)),maxval(pressi(:,k)) enddo - + deallocate(ak,bk) - + endif - + if (use_gfs_nemsio) call nemsio_close(gfile,iret=iret) - if (use_gfs_ncio) call close_dataset(dset) - - !$omp parallel do private(k) shared(weight,pressi,grweight,nlevs) - do k=1,nlevs - ! sqrt(dp)*sqrt(area) - weight(:,k)=sqrt( (pressi(:,k)-pressi(:,k+1))/tmpgrd(:))*grweight(:) + if (use_gfs_ncio) call close_dataset(dset) + + !$omp parallel do private(k) shared(weight,pressi,grweight,nlevs) + do k=1,nlevs + ! sqrt(dp)*sqrt(area) + weight(:,k)=sqrt( (pressi(:,k)-pressi(:,k+1))/tmpgrd(:))*grweight(:) end do !$omp end parallel do - - - - - - return - + + + + + + return + end subroutine get_weight - - - - - - - - - subroutine destroy_weight - implicit none - if(allocated(weight)) deallocate(weight) - if(allocated(grweight)) deallocate(grweight) - end subroutine destroy_weight - - - - - - subroutine divide_weight(grdin) - implicit none - real(r_single), dimension(npts_max,ncdim), intent(inout) :: grdin - real(r_single) cptr,qweight,rdtrpr - integer(i_kind) :: k,npt - cptr = real(sqrt(tref/cp),r_kind) - qweight = real(sqrt(cp*tref/wmoist)/hvap,r_kind) - rdtrpr = real(sqrt(pref/(rd*tref)),r_kind) - do npt=1,numptsperproc(nproc+1) - do k=1,nlevs - grdin(npt,k) = grdin(npt,k) / weight(indxproc(nproc+1,npt),k) - grdin(npt,nlevs+k) = grdin(npt,nlevs+k) / weight(indxproc(nproc+1,npt),k) - grdin(npt,2*nlevs+k) = grdin(npt,2*nlevs+k) * cptr / weight(indxproc(nproc+1,npt),k) - if (nvars .gt. 3) then - grdin(npt,3*nlevs+k) = grdin(npt,3*nlevs+k) * qweight / weight(indxproc(nproc+1,npt),k) - end if - end do + + + + + + + + + subroutine destroy_weight + implicit none + if(allocated(weight)) deallocate(weight) + if(allocated(grweight)) deallocate(grweight) + end subroutine destroy_weight + + + + + + subroutine divide_weight(grdin) + implicit none + real(r_single), dimension(npts_max,ncdim), intent(inout) :: grdin + real(r_single) cptr,qweight,rdtrpr + integer(i_kind) :: k,npt + cptr = real(sqrt(tref/cp),r_kind) + qweight = real(sqrt(cp*tref/wmoist)/hvap,r_kind) + rdtrpr = real(sqrt(pref/(rd*tref)),r_kind) + do npt=1,numptsperproc(nproc+1) + do k=1,nlevs + grdin(npt,k) = grdin(npt,k) / weight(indxproc(nproc+1,npt),k) + grdin(npt,nlevs+k) = grdin(npt,nlevs+k) / weight(indxproc(nproc+1,npt),k) + grdin(npt,2*nlevs+k) = grdin(npt,2*nlevs+k) * cptr / weight(indxproc(nproc+1,npt),k) + if (nvars .gt. 3) then + grdin(npt,3*nlevs+k) = grdin(npt,3*nlevs+k) * qweight / weight(indxproc(nproc+1,npt),k) + end if + end do ! AFE the indexing schema needs to be cleaned up -! grdin(npt,nvars*nlevs+1) = grdin(npt,nvars*nlevs+1) & - grdin(npt,ncdim) = grdin(npt,ncdim) & - & * rdtrpr / grweight(indxproc(nproc+1,npt)) - end do - return - end subroutine divide_weight +! grdin(npt,nvars*nlevs+1) = grdin(npt,nvars*nlevs+1) & + grdin(npt,ncdim) = grdin(npt,ncdim) & + & * rdtrpr / grweight(indxproc(nproc+1,npt)) + end do + return + end subroutine divide_weight subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal,ft,hr,infilename) - + use sigio_module, only: sigio_head, sigio_data, sigio_sclose, sigio_sropen, & sigio_srohdc, sigio_sclose, sigio_aldata, sigio_axdata - + use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata - + + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata + implicit none integer, intent(in), optional :: nanal integer, intent(in), optional :: ft integer, intent(in), optional :: hr - - character(len=100), intent(in), optional :: infilename + + character(len=100), intent(in), optional :: infilename integer, intent(in) :: mode character(len=max_varname_length), dimension(n2d), intent(in) :: vars2d character(len=max_varname_length), dimension(n3d), intent(in) :: vars3d @@ -440,7 +440,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal real(r_kind), dimension(nlons*nlats) :: ug,vg real(r_single), dimension(npts,nlevs) :: tv, q, tv_to_t real(r_kind), allocatable, dimension(:) :: psg - + real(r_single),allocatable,dimension(:,:,:) :: nems_vcoord real(nemsio_realkind), dimension(nlons*nlats) :: nems_wrk,nems_wrk2 type(nemsio_gfile) :: gfile @@ -449,20 +449,20 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal integer(i_kind) :: ps_ind integer(i_kind) :: k,iret,idvc,nlonsin,nlatsin,nlevsin - + character(len=10) :: fileformat integer(i_kind) :: iunitsig type(sigio_head) :: sighead type(sigio_data) :: sigdata type(Dataset) :: dset - type(Dimension) :: londim,latdim,levdim - real(r_kind), dimension(ndimspec) :: vrtspec,divspec + type(Dimension) :: londim,latdim,levdim + real(r_kind), dimension(ndimspec) :: vrtspec,divspec real(r_single), allocatable, dimension(:,:,:) :: ug3d,vg3d real(r_single), allocatable, dimension(:,:) :: values_2d integer(i_kind) :: nb,ne - + iunitsig = 77 nb = 1 ne = 1 @@ -481,7 +481,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal else charnanal = 'ensmean' endif - endif + endif ! ====================================== if (use_gfs_nemsio) then @@ -496,7 +496,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! === EFSOI filename construction ============= if(forecast_impact) then - + if(mode == read_ensmean_forecast) then filename = trim(adjustl(datapath))//"gdas.t"//charhr//"z.atmf"//charft// & "."//trim(adjustl(charnanal))//trim(fileformat) @@ -526,7 +526,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal print *,'This mode is not supported: mode=',mode call stop2(23) end if - endif + endif ! --------------------------------------------! ! Read in state vector from file and transform! @@ -536,16 +536,16 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal if (nproc == 0) print *,'reading state vector file: ',filename - if (use_gfs_nemsio) then - + if (use_gfs_nemsio) then + call nemsio_init(iret=iret) if(iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_init, iret=',iret call stop2(23) end if - + call nemsio_open(gfile,filename,'READ',iret=iret) - + if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_open, iret=',iret call stop2(23) @@ -559,17 +559,17 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal call stop2(23) end if - else if (use_gfs_ncio) then + else if (use_gfs_ncio) then dset = open_dataset(filename) - + londim = get_dim(dset,'grid_xt'); nlonsin = londim%len latdim = get_dim(dset,'grid_yt'); nlatsin = latdim%len levdim = get_dim(dset,'pfull'); nlevsin = levdim%len idvc=2 - + else - + call sigio_srohdc(iunitsig,trim(filename), & sighead,sigdata,iret) if (iret /= 0) then @@ -577,13 +577,13 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal call stop2(23) end if endif - - + + cptr = sqrt(cp/tref) qweight = sqrt(wmoist/(cp*tref))*hvap rdtrpr = sqrt(rd*tref)/pref - + u_ind = getindex(vars3d, 'u') !< indices in the state var arrays v_ind = getindex(vars3d, 'v') ! U and V (3D) tv_ind = getindex(vars3d, 'tv') ! Tv (3D) @@ -591,17 +591,17 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ps_ind = getindex(vars2d, 'ps') ! Ps (2D) - + if (.not. isinitialized) call init_spec_vars(nlons,nlats,ntrunc,4) allocate(psg(nlons*nlats)) - - + + ! ====================================================== ! Get surface pressure ! ==================== if (use_gfs_nemsio) then - + call nemsio_readrecv(gfile,'pres','sfc',1,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(ps), iret=',iret @@ -609,7 +609,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal endif psg = 0.01_r_kind*nems_wrk ! convert ps to millibars. - ! + ! if (allocated(nems_vcoord)) deallocate(nems_vcoord) allocate(nems_vcoord(nlevs+1,3,2)) call nemsio_getfilehead(gfile,iret=iret,vcoord=nems_vcoord) @@ -618,128 +618,128 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal 'vcoord, Status = ',iret call stop2(99) endif - + else if (use_gfs_ncio) then - + call read_vardata(dset, 'pressfc', values_2d,errcode=iret) if (iret /= 0) then print *,'error reading ps' call stop2(31) endif - psg = 0.01_r_kind*reshape(values_2d,(/nlons*nlats/)) - + psg = 0.01_r_kind*reshape(values_2d,(/nlons*nlats/)) + else vrtspec = sigdata%ps call sptez_s(vrtspec,psg,1) !==> input psg is ln(ps) in centibars - convert to ps in millibars. psg = 10._r_kind*exp(psg) - endif - - - - ! ============================================================================= + endif + + + + ! ============================================================================= ! get U,V,temp,q,ps on gaussian grid. ! ===================================== ! u is first nlevs, v is second, t is third, then tracers. if (use_gfs_nemsio) then - + do k=1,nlevs - + ! Get u-wind call nemsio_readrecv(gfile,'ugrd','mid layer',k,nems_wrk,iret=iret) - + if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(ugrd), iret=',iret call stop2(23) endif - + ug = nems_wrk - + ! Get v-wind call nemsio_readrecv(gfile,'vgrd','mid layer',k,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(vgrd), iret=',iret call stop2(23) endif - + vg = nems_wrk - + if (u_ind > 0) call copytogrdin(ug,grdin(:,levels(u_ind-1) + k)) if (v_ind > 0) call copytogrdin(vg,grdin(:,levels(v_ind-1) + k)) - - + + ! Transformation to EFSOI relevant quantities ! Assign weighted kinetic energy components. There ! are no unit/metric differences for the kinetic component grdin(:,levels(u_ind-1) + k) = weight(:,k) * grdin(:,levels(u_ind-1) + k) grdin(:,levels(v_ind-1) + k) = weight(:,k) * grdin(:,levels(v_ind-1) + k) - + call nemsio_readrecv(gfile,'tmp','mid layer',k,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(tmp), iret=',iret call stop2(23) endif - + call nemsio_readrecv(gfile,'spfh','mid layer',k,nems_wrk2,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(spfh), iret=',iret call stop2(23) endif - + ug = nems_wrk vg = nems_wrk2 - + call copytogrdin(ug,tv(:,k)) call copytogrdin(vg, q(:,k)) ! Transformation to EFSOI relevant quantities ! Mass component quantities tv(:,k) = cptr * weight(:,k) * tv(:,k) - + ! Moisture component transormation to EFSOI ! relevant quantities q(:,k) = qweight * weight(:,k) * q(:,k) tv_to_t(:,k) = ( one / (one + q(:,k)*0.61_r_kind) ) - + ! Approximate the necessary transformation ! of virtual temperature to temperature tv(:,k) = tv(:,k) * tv_to_t(:,k) - + if (tv_ind > 0) grdin(:,levels(tv_ind-1)+k) = tv(:,k) if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) enddo - + else if (use_gfs_ncio) then - + ! ==== Get U and V ======================================== call read_vardata(dset, 'ugrd', ug3d,errcode=iret) - + if (iret /= 0) then print *,'error reading ugrd' call stop2(22) endif - + call read_vardata(dset, 'vgrd', vg3d,errcode=iret) if (iret /= 0) then print *,'error reading vgrd' call stop2(23) endif - + do k=1,nlevs ug = reshape(ug3d(:,:,nlevs-k+1),(/nlons*nlats/)) vg = reshape(vg3d(:,:,nlevs-k+1),(/nlons*nlats/)) - + if (u_ind > 0) call copytogrdin(ug,grdin(:,levels(u_ind-1) + k)) if (v_ind > 0) call copytogrdin(vg,grdin(:,levels(v_ind-1) + k)) - + ! Transformation to EFSOI relevant quantities ! Assign weighted kinetic energy components. There ! are no unit/metric differences for the kinetic component grdin(:,levels(u_ind-1) + k) = weight(:,k) * grdin(:,levels(u_ind-1) + k) - grdin(:,levels(v_ind-1) + k) = weight(:,k) * grdin(:,levels(v_ind-1) + k) - + grdin(:,levels(v_ind-1) + k) = weight(:,k) * grdin(:,levels(v_ind-1) + k) + ! calculate vertical integral of mass flux div (ps tendency) ! this variable is analyzed in order to enforce mass balance in the analysis !if (pst_ind > 0) then @@ -749,36 +749,36 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! call sptez_s(divspec,vmassdiv(:,k),1) ! divspec to divgrd !endif enddo - - - + + + ! ==== Get T and Q =========================================== call read_vardata(dset,'tmp', ug3d,errcode=iret) - + if (iret /= 0) then print *,'error reading tmp' call stop2(24) endif - + call read_vardata(dset,'spfh', vg3d,errcode=iret) - + if (iret /= 0) then print *,'error reading spfh' call stop2(25) - endif - + endif + do k=1,nlevs ug = reshape(ug3d(:,:,nlevs-k+1),(/nlons*nlats/)) vg = reshape(vg3d(:,:,nlevs-k+1),(/nlons*nlats/)) - + !if (tsen_ind > 0) call copytogrdin(ug,grdin(:,levels(tsen_ind-1)+k,nb,ne)) - + call copytogrdin(vg, q(:,k)) - + ug = ug * ( 1.0 + fv*vg ) ! convert T to Tv - ! + ! call copytogrdin(ug,tv(:,k)) - + ! Transformation to EFSOI relevant quantities ! Mass component quantities tv(:,k) = cptr * weight(:,k) * tv(:,k) @@ -786,20 +786,20 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! relevant quantities q(:,k) = qweight * weight(:,k) * q(:,k) tv_to_t(:,k) = ( one / (one + q(:,k)*0.61_r_kind) ) - + ! Approximate the necessary transformation ! of virtual temperature to temperature tv(:,k) = tv(:,k) * tv_to_t(:,k) - + if (tv_ind > 0) grdin(:,levels(tv_ind-1)+k) = tv(:,k) if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) enddo - + deallocate(ug3d,vg3d) - + else - - ! $omp parallel do private(k,ug,vg,divspec,vrtspec) + + ! $omp parallel do private(k,ug,vg,divspec,vrtspec) ! shared(sigdata,pressi,vmassdiv,grdin,tv,q,cw,u_ind,v_ind,pst_ind,q_ind,tsen_ind,cw_ind,qi_ind,ql_ind) do k=1,nlevs @@ -824,11 +824,11 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal divspec = sigdata%t(:,k) call sptez_s(divspec,ug,1) call copytogrdin(ug,tv(:,k)) - + divspec = sigdata%q(:,k,1) call sptez_s(divspec,vg,1) call copytogrdin(vg,q(:,k)) - + ! Transformation to EFSOI relevant quantities ! Mass component quantities tv(:,k) = cptr * weight(:,k) * tv(:,k) @@ -836,20 +836,20 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! relevant quantities q(:,k) = qweight * weight(:,k) * q(:,k) tv_to_t(:,k) = ( one / (one + q(:,k)*0.61_r_kind) ) - + ! Approximate the necessary transformation ! of virtual temperature to temperature tv(:,k) = tv(:,k) * tv_to_t(:,k) - + if (tv_ind > 0) grdin(:,levels(tv_ind-1)+k) = tv(:,k) - if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) - + if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) + enddo endif - + ! ============================================================= - ! surface pressure + ! surface pressure ! ================ if (ps_ind > 0) then call copytogrdin(psg,grdin(:,levels(n3d) + ps_ind)) @@ -858,16 +858,16 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! Transformation to EFSOI relevant quantities ! Surface pressure contribution grdin(:,levels(n3d) + ps_ind) = rdtrpr * grweight(:) * 100._r_kind * grdin(:,levels(n3d) + ps_ind) - + deallocate(psg) - + if (use_gfs_nemsio) call nemsio_close(gfile,iret=iret) if (use_gfs_ncio) call close_dataset(dset) return - + contains - + ! copying to grdin (calling regtoreduced if reduced grid) subroutine copytogrdin(field, grdin) implicit none diff --git a/util/EnKF/CMakeLists.txt b/util/EnKF/CMakeLists.txt new file mode 100644 index 0000000000..607b4b32e8 --- /dev/null +++ b/util/EnKF/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(arw) +add_subdirectory(gfs) diff --git a/util/EnKF/arw/CMakeLists.txt b/util/EnKF/arw/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/EnKF/arw/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/EnKF/arw/src/CMakeLists.txt b/util/EnKF/arw/src/CMakeLists.txt index 5fbc72f9ac..b414940f30 100644 --- a/util/EnKF/arw/src/CMakeLists.txt +++ b/util/EnKF/arw/src/CMakeLists.txt @@ -1,8 +1,23 @@ -cmake_minimum_required(VERSION 2.6) +# These utilities require the Regional GSI to be compiled and available as a library. - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/util/include") - set(UTIL_INC ${CMAKE_Fortran_MODULE_DIRECTORY}) +if(NOT TARGET gsi) + find_package(gsi QUIET) +endif() - add_subdirectory(enspreproc_regional.fd) - add_subdirectory(initialens_regional.fd) +if(NOT gsi_FOUND) + message(STATUS "GSI library was not found. Disable EnKF ARW utilities") + return() +endif() + +if(NOT GSI_APP MATCHES "Regional") + message(STATUS "Incompatible GSI = ${GSI_APP}, Disable EnKF ARW utilities") + return() +endif() + +if(NOT TARGET ncdiag) + find_package(ncdiag REQUIRED) +endif() + +add_subdirectory(enspreproc_regional.fd) +add_subdirectory(initialens_regional.fd) diff --git a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt index e7f1eafe0a..2b2e4bda13 100644 --- a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt @@ -1,13 +1,50 @@ -cmake_minimum_required(VERSION 2.6) - set(GSI_Fortran_FLAGS_LOCAL "${GSI_Fortran_FLAGS} -DWRF") - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90 ${CMAKE_CURRENT_SOURCE_DIR}/*.F90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS_LOCAL} ) - include_directories( ${PROJECT_BINARY_DIR}/include ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS} ) - - add_executable(enspreproc.x ${LOCAL_SRC} ) - set_target_properties( enspreproc.x PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS_LOCAL} ) - target_link_libraries(enspreproc.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ${WRF_LIBRARIES} - ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} - ${LAPACK_LIBRARIES} -L./ ${EXTRA_LINKER_FLAGS} ${CORE_LIBRARIES} ${CORE_BUILT} - ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES} ${wrflib} ${FV3GFS_NCIO_LIBRARIES} ) - add_dependencies(enspreproc.x ${GSILIB}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + get_gefs_for_regional_enspro.f90 + gfsp2wrfg.f90 + guess_grids_enspro.f90 + read_wrf_mass_guess4ens.F90 + wrf_netcdf_interface4ens.F90) + +add_executable(enspreproc.x ${SRCS}) + +if(TARGET ncdiag) + add_dependencies(enspreproc.x ncdiag) +endif() + +if(TARGET gsi) + add_dependencies(enspreproc.x gsi) +endif() + +target_compile_definitions(enspreproc.x PRIVATE "WRF") + +target_link_libraries(enspreproc.x PRIVATE gsi::gsi) + +# Link the application targets with dependencies +target_link_libraries(enspreproc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(enspreproc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(enspreproc.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(enspreproc.x PRIVATE bacio::bacio_4) +target_link_libraries(enspreproc.x PRIVATE sigio::sigio) +target_link_libraries(enspreproc.x PRIVATE sfcio::sfcio) +target_link_libraries(enspreproc.x PRIVATE nemsio::nemsio) +target_link_libraries(enspreproc.x PRIVATE ncio::ncio) +target_link_libraries(enspreproc.x PRIVATE w3emc::w3emc_d) +target_link_libraries(enspreproc.x PRIVATE sp::sp_d) +target_link_libraries(enspreproc.x PRIVATE bufr::bufr_d) +target_link_libraries(enspreproc.x PRIVATE crtm::crtm) +target_link_libraries(enspreproc.x PRIVATE wrf_io::wrf_io) +target_link_libraries(enspreproc.x PRIVATE ncdiag::ncdiag) +target_link_libraries(enspreproc.x PRIVATE gsi::gsi) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enspreproc.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS enspreproc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt index 0e2de4f991..85f21e7030 100644 --- a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt @@ -1,12 +1,48 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - include_directories( "${PROJECT_BINARY_DIR}/include" ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - - add_executable(initialens.x ${LOCAL_SRC} ) - set_target_properties( initialens.x PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - target_link_libraries( initialens.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ${WRF_LIBRARIES} - ${NETCDF_Fortran_LIBRARIES} ${MPI_Fortran_LIBRARIES} - -L./ ${EXTRA_LINKER_FLAGS} ${CORE_LIBRARIES} ${CORE_BUILT} - ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES} ${wrflib} ) - add_dependencies(initialens.x ${GSILIB}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + initial_arw_ens.f90 + read_netcdf_mass.f90 + update_netcdf_mass.f90) + +add_executable(initialens.x ${SRCS}) + +if(TARGET ncdiag) + add_dependencies(initialens.x ncdiag) +endif() + +if(TARGET gsi) + add_dependencies(initialens.x gsi) +endif() + +target_compile_definitions(initialens.x PRIVATE "WRF") + +target_link_libraries(initialens.x PRIVATE gsi::gsi) + +# Link the application targets with dependencies +target_link_libraries(initialens.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(initialens.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(initialens.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(initialens.x PRIVATE bacio::bacio_4) +target_link_libraries(initialens.x PRIVATE sigio::sigio) +target_link_libraries(initialens.x PRIVATE sfcio::sfcio) +target_link_libraries(initialens.x PRIVATE nemsio::nemsio) +target_link_libraries(initialens.x PRIVATE ncio::ncio) +target_link_libraries(initialens.x PRIVATE w3emc::w3emc_d) +target_link_libraries(initialens.x PRIVATE sp::sp_d) +target_link_libraries(initialens.x PRIVATE bufr::bufr_d) +target_link_libraries(initialens.x PRIVATE crtm::crtm) +target_link_libraries(initialens.x PRIVATE wrf_io::wrf_io) +target_link_libraries(initialens.x PRIVATE ncdiag::ncdiag) +target_link_libraries(initialens.x PRIVATE gsi::gsi) +if(OpenMP_Fortran_FOUND) + target_link_libraries(initialens.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS initialens.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/CMakeLists.txt b/util/EnKF/gfs/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/EnKF/gfs/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/EnKF/gfs/src/CMakeLists.txt b/util/EnKF/gfs/src/CMakeLists.txt index 31ae3c1dd9..f656e18275 100644 --- a/util/EnKF/gfs/src/CMakeLists.txt +++ b/util/EnKF/gfs/src/CMakeLists.txt @@ -1,23 +1,22 @@ -cmake_minimum_required(VERSION 2.6) -MACRO(SUBDIRLIST result curdir) - FILE(GLOB children RELATIVE ${curdir} ${curdir}/*.fd) - SET(dirlist "") - FOREACH(child ${children}) - IF(IS_DIRECTORY ${curdir}/${child}) - LIST(APPEND dirlist ${child}) - ENDIF() - ENDFOREACH() - SET(${result} ${dirlist}) -ENDMACRO() +add_subdirectory(adderrspec.fd) +add_subdirectory(adjustps.fd) +add_subdirectory(calc_increment_ens.fd) +add_subdirectory(calc_increment_ens_ncio.fd) +add_subdirectory(calc_increment_ncio.fd) +add_subdirectory(calc_increment_serial.fd) +add_subdirectory(getnstensmeanp.fd) +add_subdirectory(getsfcensmeanp.fd) +add_subdirectory(getsfcnstensupdp.fd) +add_subdirectory(getsigensmeanp_smooth.fd) +add_subdirectory(getsigensstatp.fd) +add_subdirectory(gribmean.fd) +add_subdirectory(recenterens_ncio.fd) +add_subdirectory(recenterncio_hybgain.fd) +add_subdirectory(recenternemsiop_hybgain.fd) +add_subdirectory(recentersigp.fd) -if(BUILD_UTIL) - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/util/include") - set(UTIL_INC ${CMAKE_Fortran_MODULE_DIRECTORY}) - - SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) - foreach(dir ${SUBDIRS}) - message("Configuring utility in ${dir}") - add_subdirectory(${dir}) - endforeach() -endif(BUILD_UTIL) +# This code is outdated +#add_subdirectory(preproc) +# These do not have any CMakeLists.txt and thus are not built +#add_subdirectory(misc) diff --git a/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt b/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt index 842712da0c..d7a39cb69c 100644 --- a/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt @@ -1,10 +1,20 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(adderrspec.x ${LOCAL_SRC} ) - set_target_properties( adderrspec.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( adderrspec.x ${W3EMC4INC} ${SIGIOINC} ${NEMSIOINC} ) - target_link_libraries( adderrspec.x ${SP_4_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SIGIO_LIBRARY} ${MPI_Fortran_LIBRARIES} ${W3EMC_4_LIBRARY} ${W3NCO_4_LIBRARY} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(adderrspec.x adderrspec_nmcmeth_ncep_spec.f90) +target_link_libraries(adderrspec.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(adderrspec.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(adderrspec.x PRIVATE bacio::bacio_4) +target_link_libraries(adderrspec.x PRIVATE sigio::sigio) +target_link_libraries(adderrspec.x PRIVATE nemsio::nemsio) +target_link_libraries(adderrspec.x PRIVATE w3emc::w3emc_d) +target_link_libraries(adderrspec.x PRIVATE sp::sp_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(adderrspec.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS adderrspec.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt b/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt index 32f6b7decc..c4494f8ead 100644 --- a/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(adjustps.x ${LOCAL_SRC} ) - set_target_properties( adjustps.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS}) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ) - target_link_libraries( adjustps.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(adjustps.x adjustps.f90) +target_link_libraries(adjustps.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(adjustps.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(adjustps.x PRIVATE bacio::bacio_4) +target_link_libraries(adjustps.x PRIVATE nemsio::nemsio) +target_link_libraries(adjustps.x PRIVATE w3emc::w3emc_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(adjustps.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS adjustps.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt index e063902e14..b532fc9bfc 100644 --- a/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt @@ -1,14 +1,30 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_increment_ens") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_increment_ens.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ens.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_increment_ens.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - target_link_libraries( calc_increment_ens.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment_interface.f90 + constants.f90 + fv3_interface.f90 + gfs_nems_interface.f90 + kinds.f90 + namelist_def.f90 + pmain.f90 + variable_interface.f90) + +add_executable(calc_increment_ens.x ${SRCS}) +target_compile_definitions(calc_increment_ens.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_ens.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ens.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_increment_ens.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_ens.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calc_increment_ens.x PRIVATE nemsio::nemsio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(calc_increment_ens.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS calc_increment_ens.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt index 5854233ffa..4888660645 100644 --- a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_increment_ens_ncio") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_increment_ens_ncio.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ens_ncio.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_increment_ens_ncio.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( calc_increment_ens_ncio.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment_interface.f90 + constants.f90 + fv3_interface.f90 + gfs_ncio_interface.f90 + kinds.f90 + namelist_def.f90 + pmain.f90) + +add_executable(calc_increment_ens_ncio.x ${SRCS}) +target_compile_definitions(calc_increment_ens_ncio.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_ens_ncio.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE ncio::ncio) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE w3emc::w3emc_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(calc_increment_ens_ncio.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS calc_increment_ens_ncio.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 index ddabc66a40..7ea5fc8989 100644 --- a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 +++ b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 @@ -39,7 +39,7 @@ module gfs_ncio_interface !----------------------------------------------------------------------- use namelist_def - use module_fv3gfs_ncio + use module_ncio !----------------------------------------------------------------------- diff --git a/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt index 716d9019e9..f0bdc763fe 100644 --- a/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - add_executable(calc_increment_ncio.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ncio.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( calc_increment_ncio.x ${CORE_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(calc_increment_ncio.x calc_increment_ncio.f90) +target_link_libraries(calc_increment_ncio.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ncio.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS calc_increment_ncio.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 b/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 index 4928a62e6c..d8377ab1a2 100755 --- a/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 +++ b/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 @@ -20,7 +20,7 @@ PROGRAM calc_increment_ncio ! output files: filename_inc (3rd command line arg) ! 4th command line arg is logical for controlling whether microphysics -! increment is computed. +! increment is computed. ! 5th command line arg is logical for controlling whether delz ! increment should be computed ! 6th command line arg is logical for controlling whether humidity @@ -38,10 +38,10 @@ PROGRAM calc_increment_ncio ! !$$$ - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, & - read_vardata, write_attribute, write_vardata, & - has_var, has_attr, get_dim + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, & + read_vardata, write_attribute, write_vardata, & + has_var, has_attr, get_dim use netcdf implicit none @@ -69,7 +69,7 @@ PROGRAM calc_increment_ncio rd = 2.8705e+2 rv = 4.6150e+2 - fv = rv/rd-1. ! used in virtual temperature equation + fv = rv/rd-1. ! used in virtual temperature equation grav = 9.80665 ! damp humidity increments between these two levels if taper_strat=T ak_bot = 10000. ! units Pa @@ -336,7 +336,7 @@ PROGRAM calc_increment_ncio values_3d_inc(:,nlats:1:-1,:) = taper_vert*(values_3d_anal - values_3d_fg) else values_3d_inc(:,nlats:1:-1,:) = values_3d_anal - values_3d_fg - endif + endif call write_ncdata3d(values_3d_inc,ncvarname,nlons,nlats,nlevs,ncfileid,dimid_3d) endif endif ! ndims == 4 @@ -362,7 +362,7 @@ PROGRAM calc_increment_ncio call read_vardata(dset_fg,'pressfc',ps_fg) call read_vardata(dset_anal,'pressfc',ps_anal) tmp_fg = tmp_fg * ( 1.0 + fv*q_fg ) ! convert T to Tv - tmp_anal = tmp_anal * ( 1.0 + fv*q_anal ) + tmp_anal = tmp_anal * ( 1.0 + fv*q_anal ) allocate(delzb(nlons,nlats,nlevs)) allocate(delza(nlons,nlats,nlevs)) delzb = (rd/grav)*tmp_fg diff --git a/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt index 406281cd3a..77dcc79a7f 100644 --- a/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt @@ -1,13 +1,27 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - add_executable(calc_increment_serial.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_serial.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ) - target_link_libraries( calc_increment_serial.x ${CORE_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - add_dependencies( calc_increment_serial.x enkfdeplib enkflib ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment.f90 + calc_increment_interface.f90 + constants.f90 + fv3_interface.f90 + gfs_nems_interface.f90 + kinds.f90 + namelist_def.f90 + variable_interface.f90) + +add_executable(calc_increment_serial.x ${SRCS}) +target_compile_definitions(calc_increment_serial.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_serial.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_serial.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_serial.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calc_increment_serial.x PRIVATE nemsio::nemsio) + +# Install executable targets +install(TARGETS calc_increment_serial.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + diff --git a/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt index 5bdfe3299d..29d7f18cdb 100644 --- a/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt @@ -1,12 +1,15 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(getnstensmeanp.x ${LOCAL_SRC} ) - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/getnstensmeanp") - set_target_properties( getnstensmeanp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( getnstensmeanp.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ) - target_link_libraries( getnstensmeanp.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(getnstensmeanp.x getnstensmeanp.f90 nstio_module.f90) +target_link_libraries(getnstensmeanp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getnstensmeanp.x PRIVATE bacio::bacio_4) +target_link_libraries(getnstensmeanp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getnstensmeanp.x PRIVATE nemsio::nemsio) + +# Install executable targets +install(TARGETS getnstensmeanp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt index 9750cbc97c..544d395bd3 100644 --- a/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable( getsfcensmeanp.x ${LOCAL_SRC} ) - set_target_properties( getsfcensmeanp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ${SFCIOINC} ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( getsfcensmeanp.x ${FV3GFS_NCIO_LIBRARIES} ${BACIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SFCIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(getsfcensmeanp.x getsfcensmeanp.f90) +target_link_libraries(getsfcensmeanp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsfcensmeanp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsfcensmeanp.x PRIVATE bacio::bacio_4) +target_link_libraries(getsfcensmeanp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsfcensmeanp.x PRIVATE nemsio::nemsio) +target_link_libraries(getsfcensmeanp.x PRIVATE sfcio::sfcio) +target_link_libraries(getsfcensmeanp.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS getsfcensmeanp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 b/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 index d73f74b75a..2589a08603 100644 --- a/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 +++ b/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 @@ -25,10 +25,10 @@ program getsfcensmeanp use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_readrec,& nemsio_writerec,nemsio_readrecv,nemsio_writerecv - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, & - read_vardata, write_attribute, write_vardata, & - get_dim + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, & + read_vardata, write_attribute, write_vardata, & + get_dim implicit none diff --git a/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt index e88f495651..0080d12a28 100644 --- a/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt @@ -1,13 +1,27 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.F90 ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/getsfcnstensupdp") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(getsfcnstensupdp.x ${LOCAL_SRC} ) - set_target_properties( getsfcnstensupdp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( getsfcnstensupdp.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC}/getsfcnstensupdp ${SFCIOINC} ${NEMSIOINC} ${MPI_Fortran_INCLUDE_PATH} ) - target_link_libraries( getsfcnstensupdp.x ${SFCIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${SP_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + constants.f90 + getsfcnstensupdp.f90 + grdcrd.f90 + intrp_msk.f90 + kinds.F90 + nstio_module.f90) + +add_executable(getsfcnstensupdp.x ${SRCS}) +target_compile_definitions(getsfcnstensupdp.x PRIVATE "_REAL8_") +target_link_libraries(getsfcnstensupdp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsfcnstensupdp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsfcnstensupdp.x PRIVATE bacio::bacio_4) +target_link_libraries(getsfcnstensupdp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsfcnstensupdp.x PRIVATE nemsio::nemsio) +target_link_libraries(getsfcnstensupdp.x PRIVATE sfcio::sfcio) +target_link_libraries(getsfcnstensupdp.x PRIVATE sp::sp_4) + +# Install executable targets +install(TARGETS getsfcnstensupdp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt index ce102ee833..d0d240653b 100644 --- a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt @@ -1,13 +1,19 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - - set(LOCAL_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone ${OpenMP_Fortran_FLAGS}" ) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${LOCAL_Fortran_FLAGS} ) - add_executable(getsigensmeanp_smooth.x ${LOCAL_SRC} ) - set_target_properties( getsigensmeanp_smooth.x PROPERTIES COMPILE_FLAGS ${LOCAL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ${SIGIOINC} ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( getsigensmeanp_smooth.x ${FV3GFS_NCIO_LIBRARIES} ${BACIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SIGIO_LIBRARY} ${W3NCO_4_LIBRARY} ${SP_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) - +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(getsigensmeanp_smooth.x getsigensmeanp_smooth_ncep.f90) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE bacio::bacio_4) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE nemsio::nemsio) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE sp::sp_4) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE sigio::sigio) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS getsigensmeanp_smooth.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 index cb622350b1..74038e464b 100644 --- a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 +++ b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 @@ -27,10 +27,10 @@ program getsigensmeanp_smooth use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_charkind8, & nemsio_readrec,nemsio_writerec, & nemsio_readrecv,nemsio_writerecv - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data, has_var + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data, has_var implicit none @@ -99,7 +99,7 @@ program getsigensmeanp_smooth filenameout = trim(adjustl(datapath)) // trim(adjustl(filenameout)) ! if a 5th arg present, it's a filename to write out ensemble spread ! (only used for ncio) - if (nargs() > 5) then + if (iargc() > 5) then call getarg(5,filenameoutsprd) write_spread_ncio = .true. if (mype == 0) print *,'computing ensemble spread' diff --git a/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt index dfbf5ca596..8dd1b97674 100644 --- a/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt @@ -1,11 +1,20 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(getsigensstatp.x ${LOCAL_SRC} ) - set_target_properties( getsigensstatp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - message(" hey, incl dirs are ${MPI_Fortran_INCLUDE_PATH} ") - include_directories( ${NETCDF_INCLUDE_DIRS} ${SIGIOINC} ${NEMSIOINC} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( getsigensstatp.x ${SIGIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SP_4_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(getsigensstatp.x getsigensstatp.f90) +target_link_libraries(getsigensstatp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsigensstatp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsigensstatp.x PRIVATE bacio::bacio_4) +target_link_libraries(getsigensstatp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsigensstatp.x PRIVATE nemsio::nemsio) +target_link_libraries(getsigensstatp.x PRIVATE sp::sp_4) +target_link_libraries(getsigensstatp.x PRIVATE sigio::sigio) +target_link_libraries(getsigensstatp.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS getsigensstatp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + diff --git a/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 b/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 index 197740ef7b..9126578c3f 100644 --- a/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 +++ b/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 @@ -15,7 +15,7 @@ program getsigensstatp ! ! program history log: ! 2014-08-23 Initial version. -! 2018-07-21 Add hydrometeor (optional) +! 2018-07-21 Add hydrometeor (optional) ! ! usage: ! input files: @@ -34,10 +34,10 @@ program getsigensstatp use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close, & nemsio_gfile,nemsio_getfilehead,nemsio_charkind8, & nemsio_readrec,nemsio_readrecv - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none @@ -46,7 +46,7 @@ program getsigensstatp integer,parameter :: iunit=21 integer,parameter :: idrt=4 ! Declare externals - external :: w3tagb, splat, sptez, sptezv, mpi_allreduce, w3tage + external :: w3tagb, splat, sptez, sptezv, w3tage character(nemsio_charkind8) :: dtype character(len=3) :: charnanal character(len=500) :: filenamein,datapath,filepref @@ -276,7 +276,7 @@ program getsigensstatp call nemsio_readrecv(gfile,'spfh', 'mid layer',k,rwork_mem(:,krecq), iret=iret) call nemsio_readrecv(gfile,'o3mr', 'mid layer',k,rwork_mem(:,krecoz), iret=iret) call nemsio_readrecv(gfile,'clwmr','mid layer',k,rwork_mem(:,kreccwmr),iret=iret) - ! if ( do_icmr ) call nemsio_readrecv(gfile,'icmr', 'mid layer',k,rwork_mem(:,krecicmr),iret=iret) + ! if ( do_icmr ) call nemsio_readrecv(gfile,'icmr', 'mid layer',k,rwork_mem(:,krecicmr),iret=iret) if ( do_hydro ) then call nemsio_readrecv(gfile,'icmr', 'mid layer',k,rwork_mem(:,krecicmr), iret=iret) call nemsio_readrecv(gfile,'rwmr', 'mid layer',k,rwork_mem(:,krecrwmr), iret=iret) @@ -288,7 +288,7 @@ program getsigensstatp call nemsio_close(gfile,iret=iret) elseif ( ncio ) then - call read_vardata(dset,'pressfc',values_2d) + call read_vardata(dset,'pressfc',values_2d) rwork_mem(:,1) = reshape(values_2d,(/npts/)) deallocate(values_2d) call read_vardata(dset,'ugrd',values_3d) diff --git a/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt b/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt index 2b3a51f4c7..dd89073517 100644 --- a/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt @@ -1,9 +1,13 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(gribmean.x ${LOCAL_SRC} ) - set_target_properties( gribmean.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - target_link_libraries( gribmean.x ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(gribmean.x gribmean.f90) +target_link_libraries(gribmean.x PRIVATE bacio::bacio_4) +target_link_libraries(gribmean.x PRIVATE w3emc::w3emc_d) + +# Install executable targets +install(TARGETS gribmean.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/preproc/CMakeLists.txt b/util/EnKF/gfs/src/preproc/CMakeLists.txt index 6ae2f24f93..65955d93dd 100644 --- a/util/EnKF/gfs/src/preproc/CMakeLists.txt +++ b/util/EnKF/gfs/src/preproc/CMakeLists.txt @@ -1,11 +1,29 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/preproc") - add_executable(preproc.x ${LOCAL_SRC} ) - set_target_properties( preproc.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( preproc.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - include_directories( ${SIGIOINC} ) - target_link_libraries( preproc.x ${SIGIO_LIBRARY} ) - +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(controlpreproc.x controlpreproc.f90) +add_executable(ensincpreproc.x ensincpreproc.f90) +add_executable(enspreproc.x enspreproc.f90) + +list(APPEND _targets + controlpreproc.x + ensincpreproc.x + enspreproc.x) + +foreach(_tgt ${_targets}) + target_link_libraries(${_tgt} PRIVATE sp::sp_4) + target_link_libraries(${_tgt} PRIVATE sigio::sigio) + if(OpenMP_Fortran_FOUND) + target_link_libraries(${_tgt} PRIVATE OpenMP::OpenMP_Fortran) + endif() +endforeach() + +target_link_libraries(ensincpreproc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(enspreproc.x PRIVATE MPI::MPI_Fortran) + +# Install executable targets +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt b/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt index 7e347146f2..0457c131da 100644 --- a/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt @@ -1,10 +1,19 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recenterens_ncio.x ${LOCAL_SRC} ) - set_target_properties( recenterens_ncio.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NETCDF_INCLUDES} ${FV3GFS_NCIO_INCS}) - target_link_libraries( recenterens_ncio.x ${FV3GFS_NCIO_LIBRARIES} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recenterens_ncio.x recenterens_ncio.f90) +target_link_libraries(recenterens_ncio.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(recenterens_ncio.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recenterens_ncio.x PRIVATE bacio::bacio_4) +target_link_libraries(recenterens_ncio.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recenterens_ncio.x PRIVATE ncio::ncio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(recenterens_ncio.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS recenterens_ncio.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 b/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 index 6afbb572eb..eb7f3c6472 100644 --- a/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 +++ b/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 @@ -25,10 +25,10 @@ program recenterens_ncio ! !$$$ - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, has_var, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, has_var, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none @@ -113,7 +113,7 @@ program recenterens_ncio if (ndims == 3 .and. trim(dseti%variables(nvar)%name) /= 'hgtsfc') then ! pressfc if (mype == 0) print *,'recentering ',& - trim(dseti%variables(nvar)%name) + trim(dseti%variables(nvar)%name) call read_vardata(dseti,trim(dseti%variables(nvar)%name),values_2d_i) call read_vardata(dsetmi,trim(dseti%variables(nvar)%name),values_2d_mi) call read_vardata(dsetmo,trim(dseti%variables(nvar)%name),values_2d_mo) @@ -135,7 +135,7 @@ program recenterens_ncio call write_vardata(dseto,trim(dseti%variables(nvar)%name),values_2d) else if (ndims == 4) then if (mype == 0) print *,'recentering ',& - trim(dseti%variables(nvar)%name) + trim(dseti%variables(nvar)%name) call read_vardata(dseti,trim(dseti%variables(nvar)%name),values_3d_i) call read_vardata(dsetmi,trim(dseti%variables(nvar)%name),values_3d_mi) call read_vardata(dsetmo,trim(dseti%variables(nvar)%name),values_3d_mo) diff --git a/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt b/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt index 79199d143f..5c69d9171e 100644 --- a/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt @@ -1,10 +1,19 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recenterncio_hybgain.x ${LOCAL_SRC} ) - set_target_properties( recenterncio_hybgain.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( recenterncio_hybgain.x ${FV3GFS_NCIO_LIBRARIES} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recenterncio_hybgain.x recenterncio_hybgain.f90) +target_link_libraries(recenterncio_hybgain.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(recenterncio_hybgain.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recenterncio_hybgain.x PRIVATE bacio::bacio_4) +target_link_libraries(recenterncio_hybgain.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recenterncio_hybgain.x PRIVATE ncio::ncio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(recenterncio_hybgain.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS recenterncio_hybgain.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 b/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 index 5ab94f071c..51823f56e4 100644 --- a/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 +++ b/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 @@ -6,7 +6,7 @@ program recenterncio_hybgain ! prgmmr: whitaker org: esrl/psd date: 2009-02-23 ! ! abstract: Recenter ensemble analysis files about new -! mean, computed from blended 3DVar and EnKF increments +! mean, computed from blended 3DVar and EnKF increments ! (optionally applying RTPS inflation). ! ! program history log: @@ -23,10 +23,10 @@ program recenterncio_hybgain ! !$$$ - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none @@ -45,7 +45,7 @@ program recenterncio_hybgain real alpha,beta,rtps,infmin,infmax,clip real(4),allocatable,dimension(:,:) :: values_2d_varanal,values_2d_enkfanal,& values_2d_varfg,values_2d_enkffg,values_2d_anal,& - values_2d,asprd_2d,fsprd_2d,inf_2d,values_2d_tmp + values_2d,asprd_2d,fsprd_2d,inf_2d,values_2d_tmp real(4),allocatable,dimension(:,:,:) :: values_3d_varanal,values_3d_enkfanal,& values_3d_varfg,values_3d_enkffg,values_3d_anal,& values_3d,asprd_3d,fsprd_3d,inf_3d,values_3d_tmp @@ -207,7 +207,7 @@ program recenterncio_hybgain ! blended analysis values_2d_anal = values_2d_enkffg + beta*(values_2d_enkfanal-values_2d_enkffg) if (alpha > 0) & - values_2d_anal = values_2d_anal + alpha*(values_2d_varanal-values_2d_varfg) + values_2d_anal = values_2d_anal + alpha*(values_2d_varanal-values_2d_varfg) ! recentered ensemble member if (rtps > 0) then ! RTPS inflation call read_vardata(dset_fsprd,trim(dset_enkffg%variables(nvar)%name),fsprd_2d) @@ -261,9 +261,9 @@ program recenterncio_hybgain call read_vardata(dset_enkfanal,trim(dset_enkffg%variables(nvar)%name),values_3d_enkfanal) call read_vardata(dseti,trim(dset_enkffg%variables(nvar)%name),values_3d) ! blended analysis - values_3d_anal = values_3d_enkffg + beta*(values_3d_enkfanal-values_3d_enkffg) + values_3d_anal = values_3d_enkffg + beta*(values_3d_enkfanal-values_3d_enkffg) if (alpha > 0) & - values_3d_anal = values_3d_anal + alpha*(values_3d_varanal-values_3d_varfg) + values_3d_anal = values_3d_anal + alpha*(values_3d_varanal-values_3d_varfg) ! recentered ensemble member if (rtps > 0) then ! RTPS inflation call read_vardata(dset_fsprd,trim(dset_enkffg%variables(nvar)%name),fsprd_3d) diff --git a/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt b/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt index 1566b60fbf..a8062246f6 100644 --- a/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt @@ -1,10 +1,15 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recenternemsiop_hybgain.x ${LOCAL_SRC} ) - set_target_properties( recenternemsiop_hybgain.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${SIGIOINC} ${NEMSIOINC} ) - target_link_libraries( recenternemsiop_hybgain.x ${SIGIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recenternemsiop_hybgain.x recenternemsiop_hybgain.f90) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE bacio::bacio_4) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE nemsio::nemsio) + +# Install executable targets +install(TARGETS recenternemsiop_hybgain.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt b/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt index 5c5537a2ef..333c95b1d4 100644 --- a/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recentersigp.x ${LOCAL_SRC} ) - set_target_properties( recentersigp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ${SIGIOINC} ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( recentersigp.x ${FV3GFS_NCIO_LIBRARIES} ${SIGIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recentersigp.x recentersigp.f90) +target_link_libraries(recentersigp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(recentersigp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recentersigp.x PRIVATE bacio::bacio_4) +target_link_libraries(recentersigp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recentersigp.x PRIVATE nemsio::nemsio) +target_link_libraries(recentersigp.x PRIVATE sigio::sigio) +target_link_libraries(recentersigp.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS recentersigp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 b/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 index 321845bf35..5a94f2f26b 100644 --- a/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 +++ b/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 @@ -28,10 +28,10 @@ program recentersigp use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_readrec,& nemsio_writerec,nemsio_readrecv,nemsio_writerecv,nemsio_getrechead - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, has_var, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, has_var, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none diff --git a/util/bufr_tools/CMakeLists.txt b/util/bufr_tools/CMakeLists.txt index 093c19ea4f..41ed4d4f8e 100644 --- a/util/bufr_tools/CMakeLists.txt +++ b/util/bufr_tools/CMakeLists.txt @@ -1,50 +1,36 @@ -cmake_minimum_required(VERSION 2.6) -# set(CMAKE_Fortran_LIB_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -# - - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - - add_executable(bufr_append_sample.x bufr_append_sample.f90 ) - set_target_properties( bufr_append_sample.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_append_sample.x ${BUFR_LIBRARY} ) - - add_executable(bufr_decode_sample.x bufr_decode_sample.f90 ) - set_target_properties( bufr_decode_sample.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_decode_sample.x ${BUFR_LIBRARY} ) - - add_executable(bufr_encode_sample.x bufr_encode_sample.f90 ) - set_target_properties( bufr_encode_sample.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_encode_sample.x ${BUFR_LIBRARY} ) - - add_executable(bufr_decode_radiance.x bufr_decode_radiance.f90 ) - set_target_properties( bufr_decode_radiance.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_decode_radiance.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_decode_all.x prepbufr_decode_all.f90 ) - set_target_properties( prepbufr_decode_all.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_decode_all.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_encode_surface.x prepbufr_encode_surface.f90 ) - set_target_properties( prepbufr_encode_surface.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_encode_surface.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_encode_upperair.x prepbufr_encode_upperair.f90 ) - set_target_properties( prepbufr_encode_upperair.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_encode_upperair.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_inventory.x prepbufr_inventory.f90 ) - set_target_properties( prepbufr_inventory.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_inventory.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_append_retrieve.x prepbufr_append_retrieve.f90 ) - set_target_properties( prepbufr_append_retrieve.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_append_retrieve.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_append_surface.x prepbufr_append_surface.f90 ) - set_target_properties( prepbufr_append_surface.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_append_surface.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_append_upperair.x prepbufr_append_upperair.f90 ) - set_target_properties( prepbufr_append_upperair.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_append_upperair.x ${BUFR_LIBRARY} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +add_executable(bufr_append_sample.x bufr_append_sample.f90) +add_executable(bufr_decode_sample.x bufr_decode_sample.f90) +add_executable(bufr_encode_sample.x bufr_encode_sample.f90) +add_executable(bufr_decode_radiance.x bufr_decode_radiance.f90) +add_executable(prepbufr_decode_all.x prepbufr_decode_all.f90) +add_executable(prepbufr_encode_surface.x prepbufr_encode_surface.f90) +add_executable(prepbufr_encode_upperair.x prepbufr_encode_upperair.f90) +add_executable(prepbufr_inventory.x prepbufr_inventory.f90) +add_executable(prepbufr_append_retrieve.x prepbufr_append_retrieve.f90) +add_executable(prepbufr_append_surface.x prepbufr_append_surface.f90) +add_executable(prepbufr_append_upperair.x prepbufr_append_upperair.f90) + +list(APPEND _targets + bufr_append_sample.x + bufr_decode_sample.x + bufr_encode_sample.x + bufr_decode_radiance.x + prepbufr_decode_all.x + prepbufr_encode_surface.x + prepbufr_encode_upperair.x + prepbufr_inventory.x + prepbufr_append_retrieve.x + prepbufr_append_surface.x + prepbufr_append_upperair.x) + +foreach(_tgt ${_targets}) + target_link_libraries(${_tgt} PRIVATE bufr::bufr_d) +endforeach() + +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/cmake/FindNetCDF.cmake b/util/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/util/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation nor +# does it submit to any jurisdiction. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() diff --git a/util/cmake/gsiutils_compiler_flags.cmake b/util/cmake/gsiutils_compiler_flags.cmake new file mode 100644 index 0000000000..1fe8e99370 --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags.cmake @@ -0,0 +1,27 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(gsiutils_compiler_flags_GNU_Fortran) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(gsiutils_compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(gsiutils_compiler_flags_GNU_C) +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + include(gsiutils_compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/util/cmake/gsiutils_compiler_flags_GNU_C.cmake b/util/cmake/gsiutils_compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..e79145242e --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_GNU_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..eb3a3c86ae --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,56 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + +# From setGNUFlags.cmake +# RELEASE OR PRODUCTION +#set(UTIL_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") +#set(UTIL_COM_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") + +# DEBUG +#set(UTIL_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") +#set(UTIL_COM_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -funroll-all-loops -finline-functions") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/util/cmake/gsiutils_compiler_flags_Intel_C.cmake b/util/cmake/gsiutils_compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..e79145242e --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_Intel_C.cmake @@ -0,0 +1,40 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_PRODUCTION "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..4a895df8e8 --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,51 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback -implicitnone") + + +# From setIntelFlags.cmake +# Production/Release +#set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DWRF -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") +#set(UTIL_COM_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone" CACHE INTERNAL "") + +# Debug +#set(UTIL_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") +#set(UTIL_COM_Fortran_FLAGS "-O0 -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian" CACHE INTERNAL "") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn all -heap-arrays -fpe-all=0 -fpe:0 -check all -debug full -fp-model strict") + +#################################################################### +# PRODUCTION FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/util/ndate/CMakeLists.txt b/util/ndate/CMakeLists.txt index 70b3d1ad3c..b31bb218d7 100644 --- a/util/ndate/CMakeLists.txt +++ b/util/ndate/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 2.6) +add_executable(ndate.x ndate.f) +target_link_libraries(ndate.x PRIVATE bacio::bacio_4) +target_link_libraries(ndate.x PRIVATE w3emc::w3emc_4) - set( NDATE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/ndate.f ) - set_source_files_properties( ${NDATE_SRC} PROPERTIES COMPILE_FLAGS ${NDATE_Fortran_FLAGS} ) - - add_executable( ndate.x ${NDATE_SRC} ) - target_link_libraries( ndate.x ${W3NCO_4_LIBRARY} ) +# Install executable targets +install(TARGETS ndate.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/netcdf_io/CMakeLists.txt b/util/netcdf_io/CMakeLists.txt index c878bb13f7..1a35d90a46 100644 --- a/util/netcdf_io/CMakeLists.txt +++ b/util/netcdf_io/CMakeLists.txt @@ -1,23 +1,2 @@ -cmake_minimum_required(VERSION 2.6) -MACRO(SUBDIRLIST result curdir) - FILE(GLOB children RELATIVE ${curdir} ${curdir}/*.fd) - SET(dirlist "") - FOREACH(child ${children}) - IF(IS_DIRECTORY ${curdir}/${child}) - LIST(APPEND dirlist ${child}) - ENDIF() - ENDFOREACH() - SET(${result} ${dirlist}) -ENDMACRO() - -if(BUILD_NCIO_UTIL) - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/util/include") - set(UTIL_INC ${CMAKE_Fortran_MODULE_DIRECTORY}) - - SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) - foreach(dir ${SUBDIRS}) - message("Configuring utility in ${dir}") - add_subdirectory(${dir}) - endforeach() -endif(BUILD_NCIO_UTIL) - +add_subdirectory(calc_analysis.fd) +add_subdirectory(interp_inc.fd) diff --git a/util/netcdf_io/calc_analysis.fd/CMakeLists.txt b/util/netcdf_io/calc_analysis.fd/CMakeLists.txt index 45d7484741..a017efbbd6 100644 --- a/util/netcdf_io/calc_analysis.fd/CMakeLists.txt +++ b/util/netcdf_io/calc_analysis.fd/CMakeLists.txt @@ -1,13 +1,26 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_NCIO_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_analysis") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_analysis.x ${LOCAL_SRC} ) - set_target_properties( calc_analysis.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_analysis.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( calc_analysis.x ${FV3GFS_NCIO_LIBRARIES} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + inc2anl.f90 + init_calc_analysis.f90 + init_io.f90 + main.f90 + vars_calc_analysis.f90) + +add_executable(calc_analysis.x ${SRCS}) +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/calc_analysis") +set_target_properties(calc_analysis.x PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) +target_include_directories(calc_analysis.x INTERFACE $) +target_link_libraries(calc_analysis.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_analysis.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_analysis.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_analysis.x PRIVATE nemsio::nemsio) +target_link_libraries(calc_analysis.x PRIVATE ncio::ncio) +target_link_libraries(calc_analysis.x PRIVATE w3emc::w3emc_d) + +# Install executable targets +install(TARGETS calc_analysis.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/netcdf_io/calc_analysis.fd/inc2anl.f90 b/util/netcdf_io/calc_analysis.fd/inc2anl.f90 index f18aace835..0ec6fa7bed 100644 --- a/util/netcdf_io/calc_analysis.fd/inc2anl.f90 +++ b/util/netcdf_io/calc_analysis.fd/inc2anl.f90 @@ -81,7 +81,7 @@ subroutine close_files ! close netCDF files before ending program !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! use vars_calc_analysis, only: fcstncfile, anlncfile - use module_fv3gfs_ncio, only: close_dataset + use module_ncio, only: close_dataset implicit none call close_dataset(fcstncfile) @@ -99,7 +99,7 @@ subroutine copy_ges_to_anl(varname) use vars_calc_analysis, only: fcstncfile, anlncfile, & nlat, nlon, nlev, anlfile, use_nemsio_anl, & mype, levpe - use module_fv3gfs_ncio, only: Dataset, read_vardata, write_vardata, & + use module_ncio, only: Dataset, read_vardata, write_vardata, & open_dataset, close_dataset, has_var use nemsio_module implicit none @@ -176,7 +176,7 @@ subroutine add_increment(fcstvar, incvar) use vars_calc_analysis, only: fcstncfile, anlncfile, incr_file,& nlat, nlon, nlev, anlfile, use_nemsio_anl, & levpe, mype - use module_fv3gfs_ncio, only: Dataset, read_vardata, write_vardata, & + use module_ncio, only: Dataset, read_vardata, write_vardata, & open_dataset, close_dataset, has_var use nemsio_module implicit none @@ -232,7 +232,7 @@ subroutine add_psfc_increment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! use vars_calc_analysis, only: fcstncfile, anlncfile, nlat, nlon, incr_file,& use_nemsio_anl, anlfile, nlev - use module_fv3gfs_ncio, only: Dataset, open_dataset, close_dataset,& + use module_ncio, only: Dataset, open_dataset, close_dataset,& read_vardata, write_vardata, read_attribute use nemsio_module implicit none diff --git a/util/netcdf_io/calc_analysis.fd/init_io.f90 b/util/netcdf_io/calc_analysis.fd/init_io.f90 index aa7e0f10c7..dbc6885f3c 100644 --- a/util/netcdf_io/calc_analysis.fd/init_io.f90 +++ b/util/netcdf_io/calc_analysis.fd/init_io.f90 @@ -26,7 +26,7 @@ subroutine init_read_bg idate6, nlon, nlat, nlev, & use_nemsio_anl, lats, lons, vcoord, & mype, npes, levpe - use module_fv3gfs_ncio, only: Dimension, open_dataset, get_dim,& + use module_ncio, only: Dimension, open_dataset, get_dim,& get_idate_from_time_units, & read_vardata, read_attribute implicit none @@ -84,7 +84,7 @@ subroutine init_write_anl fhr, nfhour, nfminute, nfsecondn, nfsecondd,& use_nemsio_anl, anlncfile, fcstncfile,& nlon, nlat, nlev, lats, lons, vcoord, mype - use module_fv3gfs_ncio, only: create_dataset, get_time_units_from_idate,& + use module_ncio, only: create_dataset, get_time_units_from_idate,& write_vardata, write_attribute use netcdf, only: nf90_max_name use nemsio_module diff --git a/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 b/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 index 770783ebb0..c02ffd5aee 100644 --- a/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 +++ b/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 @@ -9,7 +9,7 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! module vars_calc_analysis use nemsio_module, only: nemsio_gfile - use module_fv3gfs_ncio, only: Dataset + use module_ncio, only: Dataset implicit none private diff --git a/util/netcdf_io/interp_inc.fd/CMakeLists.txt b/util/netcdf_io/interp_inc.fd/CMakeLists.txt index 5881fbf229..19e89c06ec 100644 --- a/util/netcdf_io/interp_inc.fd/CMakeLists.txt +++ b/util/netcdf_io/interp_inc.fd/CMakeLists.txt @@ -1,13 +1,19 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_NCIO_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/interp_inc") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(interp_inc.x ${LOCAL_SRC} ) - set_target_properties( interp_inc.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( interp_inc.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH}) - target_link_libraries( interp_inc.x ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${IP_LIBRARY} ${SP_LIBRARY}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(interp_inc.x driver.f90) +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/interp_inc") +set_target_properties(interp_inc.x PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) +target_include_directories(interp_inc.x INTERFACE $) +target_link_libraries(interp_inc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(interp_inc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(interp_inc.x PRIVATE w3emc::w3emc_d) +target_link_libraries(interp_inc.x PRIVATE sp::sp_d) +target_link_libraries(interp_inc.x PRIVATE ip::ip_d) + +# Install executable targets +install(TARGETS interp_inc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/netcdf_io/interp_inc.fd/driver.f90 b/util/netcdf_io/interp_inc.fd/driver.f90 index 6c146f3d06..3a660015ad 100644 --- a/util/netcdf_io/interp_inc.fd/driver.f90 +++ b/util/netcdf_io/interp_inc.fd/driver.f90 @@ -30,11 +30,11 @@ program interp_inc integer, parameter :: num_recs = 9 ! Declare externals - external :: w3tagb, netcdf_err, splat, ipolatev, & - mpi_send, ipolates, mpi_recv, w3tage + external :: w3tagb, netcdf_err, splat, ipolatev, ipolates, w3tage + character(len=128) :: outfile, infile - character(len=11) :: records(num_recs) + character(len=11) :: records(num_recs) integer :: i, j, mi, iret, mo, rec integer :: lon_in, lat_in @@ -113,88 +113,88 @@ program interp_inc call mpi_barrier(mpi_comm_world, mpierr) if (mype == 0) then print*,'- OPEN OUTPUT FILE: ', trim(outfile) - + error = nf90_create(outfile, cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=ncid_out) call netcdf_err(error, 'CREATING FILE='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'lon', lon_out, dim_lon_out) call netcdf_err(error, 'defining dimension lon for file='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'lat', lat_out, dim_lat_out) call netcdf_err(error, 'defining dimension lat for file='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'lev', lev, dim_lev_out) call netcdf_err(error, 'defining dimension lev for file='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'ilev', ilev, dim_ilev_out) call netcdf_err(error, 'defining dimension ilev for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'lon', nf90_double, (/dim_lon_out/), id_lon_out) call netcdf_err(error, 'defining variable lon for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, id_lon_out, "units", "degrees_east") call netcdf_err(error, 'define lon attribute for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'lat', nf90_double, (/dim_lat_out/), id_lat_out) call netcdf_err(error, 'defining varable lat for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, id_lat_out, "units", "degrees_north") call netcdf_err(error, 'defining lat att for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'lev', nf90_float, (/dim_lev_out/), id_lev_out) call netcdf_err(error, 'defining variable lev for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'pfull', nf90_float, (/dim_lev_out/), id_pfull_out) call netcdf_err(error, 'defining variable pfull for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'ilev', nf90_float, (/dim_ilev_out/), id_ilev_out) call netcdf_err(error, 'defining variable ilev for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'hyai', nf90_float, (/dim_ilev_out/), id_hyai_out) call netcdf_err(error, 'defining variable hyai for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'hybi', nf90_float, (/dim_ilev_out/), id_hybi_out) call netcdf_err(error, 'defining variable hybi for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'u_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_u_inc_out) call netcdf_err(error, 'defining variable u_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'v_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_v_inc_out) call netcdf_err(error, 'defining variable v_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'delp_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_delp_inc_out) call netcdf_err(error, 'defining variable delp_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'delz_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_delz_inc_out) call netcdf_err(error, 'defining variable delz_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'T_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_t_inc_out) call netcdf_err(error, 'defining variable t_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'sphum_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_sphum_inc_out) call netcdf_err(error, 'defining variable sphum_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'liq_wat_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_liq_wat_inc_out) call netcdf_err(error, 'defining variable liq_wat_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'o3mr_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_o3mr_inc_out) call netcdf_err(error, 'defining variable o3mr_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'icmr_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_icmr_inc_out) call netcdf_err(error, 'defining variable icmr_inc for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, nf90_global, 'source', 'GSI') call netcdf_err(error, 'defining source attribute for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, nf90_global, 'comment', 'interpolated global analysis increment') call netcdf_err(error, 'defining comment attribute for file='//trim(outfile) ) - + error = nf90_enddef(ncid_out, header_buffer_val, 4,0,4) call netcdf_err(error, 'end meta define for file='//trim(outfile) ) end if !----------------------------------------------------------------- -! Compute latitude and longitude of output grid. +! Compute latitude and longitude of output grid. !----------------------------------------------------------------- allocate(latitude_out(lat_out)) @@ -336,13 +336,13 @@ program interp_inc if (mype == rec) then print*,'- PROCESS RECORD: ', trim(records(rec)) - + error = nf90_inq_varid(ncid_in, trim(records(rec)), id_var) call netcdf_err(error, 'inquiring ' // trim(records(rec)) // ' id for file='//trim(infile) ) error = nf90_get_var(ncid_in, id_var, dummy_in) call netcdf_err(error, 'reading ' // trim(records(rec)) // ' for file='//trim(infile) ) - - + + ip = 0 ! bilinear ipopt = 0 ibi = 0 @@ -354,7 +354,7 @@ program interp_inc lo = 0 go = 0.0_8 gi = reshape (dummy_in, (/mi, lev/)) - + if (trim(records(rec)) .eq. 'u_inc') then ! do u_inc,v_inc at the same time error = nf90_inq_varid(ncid_in, 'v_inc', id_var) @@ -414,7 +414,7 @@ program interp_inc error = nf90_put_var(ncid_out, id_var, dummy_out) call netcdf_err(error, 'writing v_inc for file='//trim(outfile) ) endif - endif + endif enddo ! records error = nf90_close(ncid_in) @@ -433,55 +433,55 @@ program interp_inc if (mype == 0) then print*,"- WRITE OUTPUT FILE: ", trim(outfile) - + ! lev - + allocate(levs(lev)) do j = 1, lev levs(j) = j enddo - + error = nf90_put_var(ncid_out, id_lev_out, levs) call netcdf_err(error, 'writing levs for file='//trim(outfile) ) - + ! pfull - + error = nf90_put_var(ncid_out, id_pfull_out, levs) call netcdf_err(error, 'writing pfull for file='//trim(outfile) ) - + deallocate (levs) allocate (levs(ilev)) do j = 1, ilev levs(j) = j enddo - + ! ilev - + error = nf90_put_var(ncid_out, id_ilev_out, levs) call netcdf_err(error, 'writing ilev for file='//trim(outfile) ) - + ! hyai - + error = nf90_put_var(ncid_out, id_hyai_out, levs) call netcdf_err(error, 'writing hyai for file='//trim(outfile) ) - + ! hybi - + error = nf90_put_var(ncid_out, id_hybi_out, levs) call netcdf_err(error, 'writing hybi for file='//trim(outfile) ) - + ! latitude - + error = nf90_put_var(ncid_out, id_lat_out, latitude_out) call netcdf_err(error, 'writing latitude for file='//trim(outfile) ) - + ! longitude - + error = nf90_put_var(ncid_out, id_lon_out, longitude_out) call netcdf_err(error, 'writing longitude for file='//trim(outfile) ) - + deallocate(levs) - + error = nf90_close(ncid_out) end if diff --git a/util/radar_process/CMakeLists.txt b/util/radar_process/CMakeLists.txt new file mode 100644 index 0000000000..27b86b61ba --- /dev/null +++ b/util/radar_process/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(radialwind) +add_subdirectory(reflectivity) diff --git a/util/radar_process/radialwind/CMakeLists.txt b/util/radar_process/radialwind/CMakeLists.txt index cf5069b6bd..e32fb89025 100644 --- a/util/radar_process/radialwind/CMakeLists.txt +++ b/util/radar_process/radialwind/CMakeLists.txt @@ -1,17 +1,20 @@ -cmake_minimum_required(VERSION 2.6) -# set(CMAKE_Fortran_LIB_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -# - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - add_executable(bufr_decode_l2rwbufr.x bufr_decode_l2rwbufr.f90 ) - set_target_properties( bufr_decode_l2rwbufr.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_decode_l2rwbufr.x ${BUFR_LIBRARY} ) +add_executable(bufr_decode_l2rwbufr.x bufr_decode_l2rwbufr.f90) +add_executable(bufr_encode_l2rwbufr.x bufr_encode_l2rwbufr.f90) +add_executable(bufr_encode_radarbufr.x bufr_encode_radarbufr.f90) - add_executable(bufr_encode_l2rwbufr.x bufr_encode_l2rwbufr.f90 ) - set_target_properties( bufr_encode_l2rwbufr.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_encode_l2rwbufr.x ${BUFR_LIBRARY} ) +list(APPEND _targets + bufr_decode_l2rwbufr.x + bufr_encode_l2rwbufr.x + bufr_encode_radarbufr.x) - add_executable(bufr_encode_radarbufr.x bufr_encode_radarbufr.f90 ) - set_target_properties( bufr_encode_radarbufr.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_encode_radarbufr.x ${BUFR_LIBRARY} ) +foreach(_tgt ${_targets}) + target_link_libraries(${_tgt} PRIVATE bufr::bufr_d) +endforeach() + +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/radar_process/reflectivity/CMakeLists.txt b/util/radar_process/reflectivity/CMakeLists.txt index 85922a290e..83710ad1d4 100644 --- a/util/radar_process/reflectivity/CMakeLists.txt +++ b/util/radar_process/reflectivity/CMakeLists.txt @@ -1,9 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - include_directories( ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - - add_executable(process_NSSL_mosaic.x ${LOCAL_SRC} ) - add_dependencies(process_NSSL_mosaic.x ${GSILIB} ${GSISHAREDLIB} ) - set_target_properties( process_NSSL_mosaic.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( process_NSSL_mosaic.x ${GSISHAREDLIB} ${BUFR_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + kinds.F90 + nc_subs.f90 + read_nssl_binary.f90 + write_bufr_ref.f90) + +# Create library +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/process_NSSL_mosaic") +add_library(process_NSSL_mosaic OBJECT ${SRCS}) +set_target_properties(process_NSSL_mosaic PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(process_NSSL_mosaic INTERFACE $) + +target_link_libraries(process_NSSL_mosaic PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(process_NSSL_mosaic PUBLIC MPI::MPI_Fortran) +target_link_libraries(process_NSSL_mosaic PUBLIC bufr::bufr_d) + +# Create process_NSSL_mosaic.x executable +add_executable(process_NSSL_mosaic.x process_NSSL_mosaic.f90) +add_dependencies(process_NSSL_mosaic.x process_NSSL_mosaic) +target_link_libraries(process_NSSL_mosaic.x PRIVATE process_NSSL_mosaic) + +# Install executable targets +install(TARGETS process_NSSL_mosaic.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/radar_process/reflectivity/kinds.F90 b/util/radar_process/reflectivity/kinds.F90 new file mode 100644 index 0000000000..ac3a0903bf --- /dev/null +++ b/util/radar_process/reflectivity/kinds.F90 @@ -0,0 +1,39 @@ +module kinds +! Stripped down version of gsi/kinds.F90 for this utility +! This is to avoid building and depending on the entire GSI compiled library + implicit none + + public i_kind, i_byte, i_short, i_long, i_llong + public r_kind, r_single, r_double, r_quad + + private + integer, parameter :: default_integer = 3 ! 1=byte, + ! 2=short, + ! 3=long, + ! 4=llong + integer, parameter :: i_byte = selected_int_kind(1) ! byte integer + integer, parameter :: i_short = selected_int_kind(4) ! short integer + integer, parameter :: i_long = selected_int_kind(8) ! long integer + integer, parameter :: llong_t = selected_int_kind(16) ! llong integer + integer, parameter :: i_llong = max( llong_t, i_long ) + integer, parameter, dimension(4) :: integer_types = (/ & + i_byte, i_short, i_long, i_llong /) + integer, parameter :: i_kind = integer_types( default_integer ) + +#ifdef _REAL4_ + integer, parameter :: default_real = 1 ! 1=single +#elseif _REAL8_ + integer, parameter :: default_real = 2 ! 2=double +#elseif _REAL16_ + integer, parameter :: default_real = 3 ! 3=quad +#else + integer, parameter :: default_real = 1 ! 1=single +#endif + integer, parameter :: r_single = selected_real_kind(6) ! single precision + integer, parameter :: r_double = selected_real_kind(15) ! double precision + integer, parameter :: quad_t = selected_real_kind(20) ! quad precision + integer, parameter :: r_quad = max( quad_t, r_double ) + integer, parameter, dimension(3) :: & + real_kinds = (/ r_single, r_double, r_quad /) + integer, parameter :: r_kind = real_kinds( default_real ) +end module kinds diff --git a/util/radar_process/reflectivity/write_bufr_ref.f90 b/util/radar_process/reflectivity/write_bufr_ref.f90 index 08a3c1784a..d9874729e8 100644 --- a/util/radar_process/reflectivity/write_bufr_ref.f90 +++ b/util/radar_process/reflectivity/write_bufr_ref.f90 @@ -18,10 +18,11 @@ subroutine write_bufr_nsslref(maxlvl,nlon,nlat,numref,ref3d_column,idate) ! machine: linux ! !$$$ - use constants, only: zero, one use kinds, only: r_kind,i_kind implicit none + real(r_kind), parameter :: zero = 0.0_r_kind + real(r_kind), parameter :: one = 1.0_r_kind REAL(r_kind) :: ref3d_column(maxlvl+2,nlon*nlat) ! 3D reflectivity in column real(r_kind) :: hdr(5),obs(1,35) character(80):: hdrstr='SID XOB YOB DHR TYP' diff --git a/util/zero_biascoeff/CMakeLists.txt b/util/zero_biascoeff/CMakeLists.txt index 066397f6ea..deeba6732b 100644 --- a/util/zero_biascoeff/CMakeLists.txt +++ b/util/zero_biascoeff/CMakeLists.txt @@ -1,30 +1,10 @@ -# Setup the minimum version required of CMake to generate the Makefile -# Raises a FATAL_ERROR if version < 2.8 -cmake_minimum_required (VERSION 2.8 FATAL_ERROR) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() -# Project name and LANGUAGE -project (zero_biascoeff Fortran) +add_executable(zero_biascoeff.x zero_biascoeff.f90) -# Where are the additional libraries installed? Note: provide includes -# path here, subsequent checks will resolve everything else -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/modules/" ) - -# Fortran compiler flags -if (CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - set(CMAKE_Fortran_FLAGS "-g -C -traceback -warn all") -elseif (CMAKE_Fortran_COMPILER_ID STREQUAL GNU) - set(CMAKE_Fortran_FLAGS "-g -W -fbounds-check -fbacktrace") -elseif (CMAKE_Fortran_COMPILER_ID STREQUAL Cray) - set(CMAKE_Fortran_FLAGS "-g -check all -traceback -warn") -else (CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - message(FATAL_ERROR "Unsupported compiler ${CMAKE_Fortran_COMPILER_ID}, Abort!") -endif (CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - -# Lists -# Setup the list of source files -set( ZERO_BIASCOEFF_SOURCES - zero_biascoeff.f90 -) - -# ${PROJECT_NAME} refers to Learn_CMake -add_executable( ${PROJECT_NAME}.x ${ZERO_BIASCOEFF_SOURCES} ) +# Install executable targets +install(TARGETS zero_biascoeff.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) From af184225b1cf363223e2f7cd2dc3c593c81dc791 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 1 Mar 2022 21:51:19 -0500 Subject: [PATCH 17/58] update logic when GSI and EnKF are not found for utilities --- util/EFSOI_Utilities/src/CMakeLists.txt | 11 +++++------ util/EnKF/arw/src/CMakeLists.txt | 9 ++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 988bd92453..872108a540 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -6,11 +6,10 @@ endif() if(NOT TARGET enkf) find_package(enkf QUIET) -endif() - -if(NOT enkf_FOUND) - message(STATUS "EnKF library was not found. Disable EFSOI utilities") - return() + if(NOT enkf_FOUND) + message(STATUS "EnKF library was not found. Disable EFSOI utilities") + return() + endif() endif() if(NOT ENKF_APP MATCHES "GFS") @@ -50,7 +49,7 @@ if(TARGET gsi) add_dependencies(global_efsoi.x gsi) endif() -if(TARGET gsi) +if(TARGET enkf) add_dependencies(global_efsoi.x enkf) endif() diff --git a/util/EnKF/arw/src/CMakeLists.txt b/util/EnKF/arw/src/CMakeLists.txt index b414940f30..2bc10f1e1c 100644 --- a/util/EnKF/arw/src/CMakeLists.txt +++ b/util/EnKF/arw/src/CMakeLists.txt @@ -2,11 +2,10 @@ if(NOT TARGET gsi) find_package(gsi QUIET) -endif() - -if(NOT gsi_FOUND) - message(STATUS "GSI library was not found. Disable EnKF ARW utilities") - return() + if(NOT gsi_FOUND) + message(STATUS "GSI library was not found. Disable EnKF ARW utilities") + return() + endif() endif() if(NOT GSI_APP MATCHES "Regional") From 3d4ee20ec74d643536e77eae699785bf5205d198 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 1 Mar 2022 23:39:15 -0500 Subject: [PATCH 18/58] build mods for Orion --- src/enkf/CMakeLists.txt | 56 +++++++------- src/gsi/CMakeLists.txt | 2 +- ush/build_all_cmake.sh | 39 ++++++++-- util/EFSOI_Utilities/src/CMakeLists.txt | 81 ++++++++++++++------- util/netcdf_io/interp_inc.fd/CMakeLists.txt | 2 +- 5 files changed, 117 insertions(+), 63 deletions(-) diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index a005498164..9900312579 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -118,6 +118,16 @@ target_include_directories(enkf_fortran_obj INTERFACE $) # Link the Fortran targets with dependencies +if(TARGET gsi) + add_dependencies(enkf_fortran_obj gsi) +endif() +if(USE_NCDIAG) + if(TARGET ncdiag) + add_dependencies(enkf_fortran_obj ncdiag) + endif() + target_link_libraries(enkf_fortran_obj PUBLIC ncdiag::ncdiag) +endif() +target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) target_link_libraries(enkf_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(enkf_fortran_obj PUBLIC MPI::MPI_Fortran) target_link_libraries(enkf_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) @@ -131,16 +141,6 @@ target_link_libraries(enkf_fortran_obj PUBLIC crtm::crtm) if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") target_link_libraries(enkf_fortran_obj PUBLIC wrf_io::wrf_io) endif() -if(USE_NCDIAG) - if(TARGET ncdiag) - add_dependencies(enkf_fortran_obj ncdiag) - endif() - target_link_libraries(enkf_fortran_obj PUBLIC ncdiag::ncdiag) -endif() -if(TARGET gsi) - add_dependencies(enkf_fortran_obj gsi) -endif() -target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) if(OpenMP_Fortran_FOUND) target_link_libraries(enkf_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) endif() @@ -160,25 +160,25 @@ set_target_properties(enkf.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}" target_link_libraries(enkf.x PRIVATE enkf) # Link the application targets with dependencies -target_link_libraries(enkf.x PUBLIC NetCDF::NetCDF_Fortran) -target_link_libraries(enkf.x PUBLIC MPI::MPI_Fortran) -target_link_libraries(enkf.x PUBLIC ${LAPACK_LIBRARIES}) -target_link_libraries(enkf.x PUBLIC bacio::bacio_4) -target_link_libraries(enkf.x PUBLIC sigio::sigio) -target_link_libraries(enkf.x PUBLIC sfcio::sfcio) -target_link_libraries(enkf.x PUBLIC nemsio::nemsio) -target_link_libraries(enkf.x PUBLIC ncio::ncio) -target_link_libraries(enkf.x PUBLIC w3emc::w3emc_d) -target_link_libraries(enkf.x PUBLIC sp::sp_d) -target_link_libraries(enkf.x PUBLIC bufr::bufr_d) -target_link_libraries(enkf.x PUBLIC crtm::crtm) -if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") - target_link_libraries(enkf_fortran_obj PUBLIC wrf_io::wrf_io) -endif() +target_link_libraries(enkf.x PRIVATE gsi::gsi) if(USE_NCDIAG) - target_link_libraries(enkf.x PUBLIC ncdiag::ncdiag) + target_link_libraries(enkf.x PRIVATE ncdiag::ncdiag) +endif() +target_link_libraries(enkf.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(enkf.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(enkf.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(enkf.x PRIVATE bacio::bacio_4) +target_link_libraries(enkf.x PRIVATE sigio::sigio) +target_link_libraries(enkf.x PRIVATE sfcio::sfcio) +target_link_libraries(enkf.x PRIVATE nemsio::nemsio) +target_link_libraries(enkf.x PRIVATE ncio::ncio) +target_link_libraries(enkf.x PRIVATE w3emc::w3emc_d) +target_link_libraries(enkf.x PRIVATE sp::sp_d) +target_link_libraries(enkf.x PRIVATE bufr::bufr_d) +target_link_libraries(enkf.x PRIVATE crtm::crtm) +if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") + target_link_libraries(enkf_fortran_obj PRIVATE wrf_io::wrf_io) endif() -target_link_libraries(enkf.x PUBLIC gsi::gsi) if(OpenMP_Fortran_FOUND) target_link_libraries(enkf.x PRIVATE OpenMP::OpenMP_Fortran) endif() @@ -195,7 +195,7 @@ install( ### Package config include(CMakePackageConfigHelpers) -set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export(EXPORT ${PROJECT_NAME}Exports NAMESPACE ${PROJECT_NAME}:: diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 5ac972474d..ae3048fff9 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -204,7 +204,7 @@ install( ### Package config include(CMakePackageConfigHelpers) -set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export(EXPORT ${PROJECT_NAME}Exports NAMESPACE ${PROJECT_NAME}:: diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index c3c12d808b..1d2fdeefe1 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -16,7 +16,7 @@ if [ $mode = NCO ]; then $dir_root/ush/prune_4nco_global.sh prune fi - +set +x # Initialize and load modules if [[ -d /dcom && -d /hwrf ]] ; then . /usrx/local/Modules/3.2.10/init/sh @@ -49,7 +49,7 @@ elif [[ -d /discover ]] ; then build_type=0 export SPACK_ROOT=/discover/nobackup/mapotts1/spack export PATH=$PATH:$SPACK_ROOT/bin - . $SPACK_ROOT/share/spack/setup-env.sh + . $SPACK_ROOT/share/spack/setup-env.sh elif [[ -d /work ]]; then . $MODULESHOME/init/sh target=orion @@ -59,6 +59,7 @@ else echo "unknown target = $target" exit 9 fi +set -x dir_modules=$dir_root/modulefiles if [ ! -d $dir_modules ]; then @@ -71,6 +72,7 @@ rm -rf $dir_root/build mkdir -p $dir_root/build cd $dir_root/build +set +x if [ $target = wcoss_d ]; then module purge module use -a $dir_modules @@ -98,16 +100,29 @@ elif [ $target = acorn ]; then source /apps/prod/lmodules/startLmod module use $dir_modules module load modulefile.ProdGSI.$target -else +else module purge source $dir_modules/modulefile.ProdGSI.$target fi +set -x -if [ $build_type = PRODUCTION -o $build_type = DEBUG ] ; then - cmake -DBUILD_UTIL=ON -DBUILD_NCDIAG_SERIAL=ON -DCMAKE_BUILD_TYPE=$build_type -DBUILD_CORELIBS=OFF .. -else - cmake .. -fi +cmake_opts="" +cmake_opts+=" -DCMAKE_BUILD_TYPE=$build_type" + +# Install destination for built executables, libraries, CMake Package config +cmake_opts+=" -DCMAKE_INSTALL_PREFIX=$dir_root/install" + +# NCO wants executables in `exec`, not the standard `bin` +cmake_opts+=" -DCMAKE_INSTALL_BINDIR=exec" + +# By default; build the global applications +cmake_opts+=" -DGSI_APP=GFS -DENKF_APP=GFS" + +# Valid combination of applications are: +# Global : -DGSI_APP=GFS -DENKF_APP=GFS +# Regional: -DGSI_APP=Regional -DENKF_APP=WRF|NMMB|FV3REG + +cmake $cmake_opts $dir_root # Build apps. Echo extra printout for NCO build if [ $mode = NCO ]; then @@ -117,6 +132,14 @@ else fi rc=$? +# Install the built package +make install + +# move the installed executables for NCO +if [ $mode = NCO ]; then + mv $dir_root/install/exec/* $dir_root/exec/ +fi + # If NCO build is successful, remove build directory if [ $mode = NCO -a $rc -eq 0 ]; then rm -rf $dir_root/build diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 872108a540..91427b7012 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -32,48 +32,79 @@ endif() list(APPEND SRCS efsoi.f90 - efsoi_main.f90 gridio_efsoi.f90 loadbal_efsoi.f90 loc_advection.f90 scatter_chunks_efsoi.f90 statevec_efsoi.f90) -add_executable(global_efsoi.x ${SRCS}) +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/efsoi") +add_library(efsoi_objs OBJECT ${SRCS}) +set_target_properties(efsoi_objs PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(efsoi_objs INTERFACE $) if(TARGET ncdiag) - add_dependencies(global_efsoi.x ncdiag) + add_dependencies(efsoi_objs ncdiag) endif() - if(TARGET gsi) - add_dependencies(global_efsoi.x gsi) + add_dependencies(efsoi_objs gsi) endif() - if(TARGET enkf) - add_dependencies(global_efsoi.x enkf) + add_dependencies(efsoi_objs enkf) +endif() + +target_compile_definitions(efsoi_objs PRIVATE "_REAL8_") + +target_link_libraries(efsoi_objs PUBLIC enkf::enkf) +target_link_libraries(efsoi_objs PUBLIC gsi::gsi) +target_link_libraries(efsoi_objs PUBLIC ncdiag::ncdiag) +target_link_libraries(efsoi_objs PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(efsoi_objs PUBLIC MPI::MPI_Fortran) +target_link_libraries(efsoi_objs PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(efsoi_objs PUBLIC bacio::bacio_4) +target_link_libraries(efsoi_objs PUBLIC sigio::sigio) +target_link_libraries(efsoi_objs PUBLIC sfcio::sfcio) +target_link_libraries(efsoi_objs PUBLIC nemsio::nemsio) +target_link_libraries(efsoi_objs PUBLIC ncio::ncio) +target_link_libraries(efsoi_objs PUBLIC w3emc::w3emc_d) +target_link_libraries(efsoi_objs PUBLIC sp::sp_d) +target_link_libraries(efsoi_objs PUBLIC bufr::bufr_d) +target_link_libraries(efsoi_objs PUBLIC crtm::crtm) +if(OpenMP_Fortran_FOUND) + target_link_libraries(efsoi_objs PRIVATE OpenMP::OpenMP_Fortran) endif() -target_compile_definitions(global_efsoi.x PRIVATE "_REAL8_") +add_library(efsoi STATIC $) +target_include_directories(efsoi PUBLIC $ + $) + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/efsoi") +add_executable(efsoi.x efsoi_main.f90) +add_dependencies(efsoi.x efsoi) +set_target_properties(efsoi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_link_libraries(efsoi.x PRIVATE efsoi) + +target_compile_definitions(efsoi.x PRIVATE "_REAL8_") # Link the application targets with dependencies -target_link_libraries(global_efsoi.x PRIVATE NetCDF::NetCDF_Fortran) -target_link_libraries(global_efsoi.x PRIVATE MPI::MPI_Fortran) -target_link_libraries(global_efsoi.x PRIVATE ${LAPACK_LIBRARIES}) -target_link_libraries(global_efsoi.x PRIVATE bacio::bacio_4) -target_link_libraries(global_efsoi.x PRIVATE sigio::sigio) -target_link_libraries(global_efsoi.x PRIVATE sfcio::sfcio) -target_link_libraries(global_efsoi.x PRIVATE nemsio::nemsio) -target_link_libraries(global_efsoi.x PRIVATE ncio::ncio) -target_link_libraries(global_efsoi.x PRIVATE w3emc::w3emc_d) -target_link_libraries(global_efsoi.x PRIVATE sp::sp_d) -target_link_libraries(global_efsoi.x PRIVATE bufr::bufr_d) -target_link_libraries(global_efsoi.x PRIVATE crtm::crtm) -target_link_libraries(global_efsoi.x PRIVATE ncdiag::ncdiag) -target_link_libraries(global_efsoi.x PRIVATE gsi::gsi) -target_link_libraries(global_efsoi.x PRIVATE enkf::enkf) +target_link_libraries(efsoi.x PRIVATE enkf::enkf) +target_link_libraries(efsoi.x PRIVATE gsi::gsi) +target_link_libraries(efsoi.x PRIVATE ncdiag::ncdiag) +target_link_libraries(efsoi.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(efsoi.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(efsoi.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(efsoi.x PRIVATE bacio::bacio_4) +target_link_libraries(efsoi.x PRIVATE sigio::sigio) +target_link_libraries(efsoi.x PRIVATE sfcio::sfcio) +target_link_libraries(efsoi.x PRIVATE nemsio::nemsio) +target_link_libraries(efsoi.x PRIVATE ncio::ncio) +target_link_libraries(efsoi.x PRIVATE w3emc::w3emc_d) +target_link_libraries(efsoi.x PRIVATE sp::sp_d) +target_link_libraries(efsoi.x PRIVATE bufr::bufr_d) +target_link_libraries(efsoi.x PRIVATE crtm::crtm) if(OpenMP_Fortran_FOUND) - target_link_libraries(global_efsoi.x PRIVATE OpenMP::OpenMP_Fortran) + target_link_libraries(efsoi.x PRIVATE OpenMP::OpenMP_Fortran) endif() # Install executable targets -install(TARGETS global_efsoi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS efsoi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/netcdf_io/interp_inc.fd/CMakeLists.txt b/util/netcdf_io/interp_inc.fd/CMakeLists.txt index 19e89c06ec..3b58c64dc9 100644 --- a/util/netcdf_io/interp_inc.fd/CMakeLists.txt +++ b/util/netcdf_io/interp_inc.fd/CMakeLists.txt @@ -11,8 +11,8 @@ target_include_directories(interp_inc.x INTERFACE $ Date: Wed, 2 Mar 2022 13:59:32 -0500 Subject: [PATCH 19/58] make messages identify their origin --- src/enkf/CMakeLists.txt | 10 +++++----- src/enkf/gridinfo_fv3reg.f90 | 10 +++++++--- src/gsi/CMakeLists.txt | 11 ++++++----- util/CMakeLists.txt | 15 ++++++++++++--- util/EFSOI_Utilities/src/CMakeLists.txt | 6 +++--- util/EnKF/arw/src/CMakeLists.txt | 4 ++-- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index 9900312579..4993a74817 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -34,10 +34,10 @@ set(ENKF_APP "GFS" CACHE STRING "Choose the EnKF Application.") set_property(CACHE ENKF_APP PROPERTY STRINGS "GFS" "WRF" "NMMB" "FV3REG") # Echo user options -message(STATUS "OPENMP ................. ${OPENMP}") -message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "USE_NCDIAG ............. ${USE_NCDIAG}") -message(STATUS "ENKF_APP ............... ${ENKF_APP}") +message(STATUS "EnKF: OPENMP ................. ${OPENMP}") +message(STATUS "EnKF: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "EnKF: USE_NCDIAG ............. ${USE_NCDIAG}") +message(STATUS "EnKF: ENKF_APP ............... ${ENKF_APP}") # Dependencies if(ENABLE_MKL) @@ -46,7 +46,7 @@ endif() if(MKL_FOUND) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) else() - set(ENABLE_MKL OFF CACHE INTERNAL "Disable MKL since it was NOT FOUND") + set(ENABLE_MKL OFF CACHE INTERNAL "EnKF: Disable MKL since it was NOT FOUND") find_package(LAPACK REQUIRED) endif() find_package(MPI REQUIRED) diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index 9e1f3310ed..772e6cf9b2 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -68,9 +68,13 @@ module gridinfo integer,public :: npts integer,public :: ntrunc ! supported variable names in anavinfo -character(len=max_varname_length),public, dimension(15) :: vars3d_supported = (/'u ', 'v ', 'w ', 't ', 'q ', 'oz ', 'cw ', 'tsen', 'prse', & - 'ql ', 'qi ', 'qr', 'qs', 'qg', 'qnr'/) -character(len=max_varname_length),public, dimension(3) :: vars2d_supported = (/'ps ', 'pst', 'sst' /) +character(len=max_varname_length),public, dimension(15) :: & + vars3d_supported = [character(len=max_varname_length) :: & + 'u', 'v', 'w', 't', 'q', 'oz', 'cw', 'tsen', 'prse', & + 'ql', 'qi', 'qr', 'qs', 'qg', 'qnr'] +character(len=max_varname_length),public, dimension(3) :: & + vars2d_supported = [character(len=max_varname_length) :: & + 'ps', 'pst', 'sst'] ! supported variable names in anavinfo real(r_single), allocatable, dimension(:) :: ak,bk,eta1_ll,eta2_ll contains diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index ae3048fff9..45a3c9ab74 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -34,10 +34,10 @@ set(GSI_APP "GFS" CACHE STRING "Choose the GSI Application.") set_property(CACHE GSI_APP PROPERTY STRINGS "GFS" "Regional") # Echo user options -message(STATUS "OPENMP ................. ${OPENMP}") -message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "USE_NCDIAG ............. ${USE_NCDIAG}") -message(STATUS "GSI_APP ................ ${GSI_APP}") +message(STATUS "GSI: OPENMP ................. ${OPENMP}") +message(STATUS "GSI: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "GSI: USE_NCDIAG ............. ${USE_NCDIAG}") +message(STATUS "GSI: GSI_APP ................ ${GSI_APP}") # Dependencies if(ENABLE_MKL) @@ -46,7 +46,7 @@ endif() if(MKL_FOUND) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) else() - set(ENABLE_MKL OFF CACHE INTERNAL "Disable MKL since it was NOT FOUND") + set(ENABLE_MKL OFF CACHE INTERNAL "GSI: Disable MKL since it was NOT FOUND") find_package(LAPACK REQUIRED) endif() find_package(MPI REQUIRED) @@ -130,6 +130,7 @@ target_include_directories(gsi_fortran_obj INTERFACE # Link the Fortran targets with dependencies target_compile_definitions(gsi_fortran_obj PUBLIC "_REAL8_") +target_compile_definitions(gsi_fortran_obj PUBLIC "POUND_FOR_STRINGIFY") target_link_libraries(gsi_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(gsi_fortran_obj PUBLIC MPI::MPI_Fortran) target_link_libraries(gsi_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index dd16fa74bf..ce082c7797 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -33,9 +33,15 @@ option(USE_NCDIAG "Use NetCDF diagnostics library" ON) set(GSI_APP "GFS" CACHE STRING "Choose the GSI Application.") set_property(CACHE GSI_APP PROPERTY STRINGS "GFS" "Regional") +set(ENKF_APP "GFS" CACHE STRING "Choose the GSI Application.") +set_property(CACHE ENKF_APP PROPERTY STRINGS "GFS" "Regional") + # Echo user options -message(STATUS "OPENMP ................. ${OPENMP}") -message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "GSI Utils: OPENMP ................. ${OPENMP}") +message(STATUS "GSI Utils: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "GSI Utils: USE_NCDIAG ............. ${USE_NCDIAG}") +message(STATUS "GSI Utils: GSI_APP ................ ${GSI_APP}") +message(STATUS "GSI Utils: ENKF_APP ............... ${ENKF_APP}") # Dependencies if(ENABLE_MKL) @@ -44,7 +50,7 @@ endif() if(MKL_FOUND) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) else() - set(ENABLE_MKL OFF CACHE INTERNAL "Disable MKL since it was NOT FOUND") + set(ENABLE_MKL OFF CACHE INTERNAL "GSI Utils: Disable MKL since it was NOT FOUND") find_package(LAPACK REQUIRED) endif() find_package(MPI REQUIRED) @@ -64,6 +70,9 @@ find_package(ip REQUIRED) find_package(w3emc REQUIRED) find_package(bufr REQUIRED) find_package(crtm REQUIRED) +if(GSI_APP MATCHES "Regional") + find_package(wrf_io REQUIRED) +endif() # See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 91427b7012..83fccf9d6a 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -7,13 +7,13 @@ endif() if(NOT TARGET enkf) find_package(enkf QUIET) if(NOT enkf_FOUND) - message(STATUS "EnKF library was not found. Disable EFSOI utilities") + message(STATUS "EFSOI: EnKF library was not found. Disable EFSOI utilities") return() endif() endif() if(NOT ENKF_APP MATCHES "GFS") - message(STATUS "Incompatible EnKF = ${ENKF_APP}. Disable EFSOI utilities") + message(STATUS "EFSOI: Incompatible EnKF = ${ENKF_APP}. Disable EFSOI utilities") return() endif() @@ -22,7 +22,7 @@ if(NOT TARGET gsi) endif() if(NOT GFS_APP MATCHES "GFS") - message(STATUS "Incompatible GFS = ${GFS_APP}. Disable EFSOI utilities") + message(STATUS "EFSOI: Incompatible GFS = ${GFS_APP}. Disable EFSOI utilities") return() endif() diff --git a/util/EnKF/arw/src/CMakeLists.txt b/util/EnKF/arw/src/CMakeLists.txt index 2bc10f1e1c..8695611c98 100644 --- a/util/EnKF/arw/src/CMakeLists.txt +++ b/util/EnKF/arw/src/CMakeLists.txt @@ -3,13 +3,13 @@ if(NOT TARGET gsi) find_package(gsi QUIET) if(NOT gsi_FOUND) - message(STATUS "GSI library was not found. Disable EnKF ARW utilities") + message(STATUS "GSI Utils: GSI library was not found. Disable EnKF ARW utilities") return() endif() endif() if(NOT GSI_APP MATCHES "Regional") - message(STATUS "Incompatible GSI = ${GSI_APP}, Disable EnKF ARW utilities") + message(STATUS "GSI Utils: Incompatible GSI = ${GSI_APP}, Disable EnKF ARW utilities") return() endif() From c6e7092025a3da7174197751bd28e1c466b98df6 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 3 Mar 2022 13:35:08 -0500 Subject: [PATCH 20/58] promote Release instead of Production --- CMakeLists.txt | 6 +-- cmake/compiler_flags.cmake | 27 ----------- cmake/compiler_flags_GNU_C.cmake | 40 ---------------- cmake/compiler_flags_GNU_Fortran.cmake | 47 ------------------- cmake/compiler_flags_Intel_C.cmake | 40 ---------------- cmake/compiler_flags_Intel_Fortran.cmake | 41 ---------------- src/enkf/CMakeLists.txt | 4 +- .../cmake/enkfapp_compiler_flags_GNU_C.cmake | 6 --- .../enkfapp_compiler_flags_GNU_Fortran.cmake | 8 +--- .../enkfapp_compiler_flags_Intel_C.cmake | 6 --- ...enkfapp_compiler_flags_Intel_Fortran.cmake | 6 --- src/gsi/CMakeLists.txt | 10 ++-- .../cmake/gsiapp_compiler_flags_GNU_C.cmake | 6 --- .../gsiapp_compiler_flags_GNU_Fortran.cmake | 8 +--- .../cmake/gsiapp_compiler_flags_Intel_C.cmake | 6 --- .../gsiapp_compiler_flags_Intel_Fortran.cmake | 6 --- src/gsi/gsi_files.cmake | 6 +++ src/ncdiag/CMakeLists.txt | 4 +- .../ncdiag_compiler_flags_GNU_Fortran.cmake | 8 +--- .../ncdiag_compiler_flags_Intel_Fortran.cmake | 6 --- ush/build_all_cmake.sh | 2 +- util/CMakeLists.txt | 4 +- .../cmake/gsiutils_compiler_flags_GNU_C.cmake | 6 --- .../gsiutils_compiler_flags_GNU_Fortran.cmake | 17 +------ .../gsiutils_compiler_flags_Intel_C.cmake | 6 --- ...siutils_compiler_flags_Intel_Fortran.cmake | 16 ------- 26 files changed, 27 insertions(+), 315 deletions(-) delete mode 100644 cmake/compiler_flags.cmake delete mode 100644 cmake/compiler_flags_GNU_C.cmake delete mode 100644 cmake/compiler_flags_GNU_Fortran.cmake delete mode 100644 cmake/compiler_flags_Intel_C.cmake delete mode 100644 cmake/compiler_flags_Intel_Fortran.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7304f9fdde..87ac98cd73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,15 @@ project(gsi list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) -include(compiler_flags) +#include(compiler_flags) include(GNUInstallDirs) -if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake deleted file mode 100644 index 08256026be..0000000000 --- a/cmake/compiler_flags.cmake +++ /dev/null @@ -1,27 +0,0 @@ -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") - add_definitions(-DNDEBUG) -endif() - -####################################################################################### -# Fortran -####################################################################################### - -if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - include(compiler_flags_GNU_Fortran) -elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - include(compiler_flags_Intel_Fortran) -else() - message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") -endif() - -####################################################################################### -# C -####################################################################################### - -if(CMAKE_C_COMPILER_ID MATCHES "GNU") - include(compiler_flags_GNU_C) -elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") - include(compiler_flags_Intel_C) -else() - message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") -endif() diff --git a/cmake/compiler_flags_GNU_C.cmake b/cmake/compiler_flags_GNU_C.cmake deleted file mode 100644 index e79145242e..0000000000 --- a/cmake/compiler_flags_GNU_C.cmake +++ /dev/null @@ -1,40 +0,0 @@ -#################################################################### -# FLAGS COMMON TO ALL BUILD TYPES -#################################################################### - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") - -#################################################################### -# RELEASE FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_RELEASE "") - -#################################################################### -# DEBUG FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_DEBUG "-Wall") - -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - -#################################################################### -# LINK FLAGS -#################################################################### - -set(CMAKE_C_LINK_FLAGS "") - -#################################################################### -# FLAGS FOR AUTOPROFILING -#################################################################### - -set(C_AUTOPROFILING_FLAGS "") - -#################################################################### - -# Meaning of flags -# ---------------- diff --git a/cmake/compiler_flags_GNU_Fortran.cmake b/cmake/compiler_flags_GNU_Fortran.cmake deleted file mode 100644 index b61ddbd9cf..0000000000 --- a/cmake/compiler_flags_GNU_Fortran.cmake +++ /dev/null @@ -1,47 +0,0 @@ -#################################################################### -# FLAGS COMMON TO ALL BUILD TYPES -#################################################################### - -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") - -if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") -endif() - -#################################################################### -# RELEASE FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_RELEASE "-O3") - -#################################################################### -# DEBUG FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") - -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") - -#################################################################### -# LINK FLAGS -#################################################################### - -set(CMAKE_Fortran_LINK_FLAGS "") - -#################################################################### -# FLAGS FOR AUTOPROFILING -#################################################################### - -set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") - -#################################################################### - -# Meaning of flags -# ---------------- -# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) -# -funroll-all-loops : Unroll all loops -# -fcheck=bounds : Bounds checking diff --git a/cmake/compiler_flags_Intel_C.cmake b/cmake/compiler_flags_Intel_C.cmake deleted file mode 100644 index e79145242e..0000000000 --- a/cmake/compiler_flags_Intel_C.cmake +++ /dev/null @@ -1,40 +0,0 @@ -#################################################################### -# FLAGS COMMON TO ALL BUILD TYPES -#################################################################### - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") - -#################################################################### -# RELEASE FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_RELEASE "") - -#################################################################### -# DEBUG FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_DEBUG "-Wall") - -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - -#################################################################### -# LINK FLAGS -#################################################################### - -set(CMAKE_C_LINK_FLAGS "") - -#################################################################### -# FLAGS FOR AUTOPROFILING -#################################################################### - -set(C_AUTOPROFILING_FLAGS "") - -#################################################################### - -# Meaning of flags -# ---------------- diff --git a/cmake/compiler_flags_Intel_Fortran.cmake b/cmake/compiler_flags_Intel_Fortran.cmake deleted file mode 100644 index 449229bb8f..0000000000 --- a/cmake/compiler_flags_Intel_Fortran.cmake +++ /dev/null @@ -1,41 +0,0 @@ -#################################################################### -# FLAGS COMMON TO ALL BUILD TYPES -#################################################################### - -set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback") - -#################################################################### -# RELEASE FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_RELEASE "-O3") - -#################################################################### -# DEBUG FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") - -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3") - -#################################################################### -# LINK FLAGS -#################################################################### - -set(CMAKE_Fortran_LINK_FLAGS "") - -#################################################################### -# FLAGS FOR AUTOPROFILING -#################################################################### - -set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") - -#################################################################### - -# Meaning of flags -# ---------------- -# todo diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index 4993a74817..6bc2b3698e 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -9,12 +9,12 @@ set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) include(GNUInstallDirs) -if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake index 2db1baf7b3..31135cb0a8 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake @@ -16,12 +16,6 @@ set(CMAKE_C_FLAGS_RELEASE "") set(CMAKE_C_FLAGS_DEBUG "") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake index 37b5e01881..1b57e9c1bb 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake @@ -12,7 +12,7 @@ endif() # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3") +set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -funroll-all-loops -finline-functions") #################################################################### # DEBUG FLAGS @@ -20,12 +20,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake index e79145242e..ed5d63d1de 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake @@ -16,12 +16,6 @@ set(CMAKE_C_FLAGS_RELEASE "") set(CMAKE_C_FLAGS_DEBUG "-Wall") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake index c4783799e2..87864efe5a 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake @@ -16,12 +16,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 45a3c9ab74..c45f50deb2 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -9,12 +9,12 @@ set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) include(GNUInstallDirs) -if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") @@ -130,7 +130,10 @@ target_include_directories(gsi_fortran_obj INTERFACE # Link the Fortran targets with dependencies target_compile_definitions(gsi_fortran_obj PUBLIC "_REAL8_") -target_compile_definitions(gsi_fortran_obj PUBLIC "POUND_FOR_STRINGIFY") +if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$") + target_compile_definitions(gsi_fortran_obj PUBLIC "POUND_FOR_STRINGIFY") +endif() +target_include_directories(gsi_fortran_obj PUBLIC $) target_link_libraries(gsi_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(gsi_fortran_obj PUBLIC MPI::MPI_Fortran) target_link_libraries(gsi_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) @@ -161,6 +164,7 @@ add_library(gsi STATIC $ add_library(${PROJECT_NAME}::gsi ALIAS gsi) target_include_directories(gsi PUBLIC $ $) +target_include_directories(gsi PUBLIC $) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) # Create a GSI executable diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake index 2db1baf7b3..31135cb0a8 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake @@ -16,12 +16,6 @@ set(CMAKE_C_FLAGS_RELEASE "") set(CMAKE_C_FLAGS_DEBUG "") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake index 807d031e44..f321c685ae 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake @@ -12,7 +12,7 @@ endif() # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3") +set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -frecord-marker=4 -funroll-loops -fno-range-check") #################################################################### # DEBUG FLAGS @@ -20,12 +20,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake index e79145242e..ed5d63d1de 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake @@ -16,12 +16,6 @@ set(CMAKE_C_FLAGS_RELEASE "") set(CMAKE_C_FLAGS_DEBUG "-Wall") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake index c4783799e2..87864efe5a 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake @@ -16,12 +16,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake index 516a06ed27..6725b99d86 100644 --- a/src/gsi/gsi_files.cmake +++ b/src/gsi/gsi_files.cmake @@ -67,6 +67,12 @@ list(APPEND GSI_SRC_fixture_regional gsi_fixture_REGIONAL.F90 ) +# List of all includes/headers in Fortran sources +list(APPEND GSI_SRC_hdr +myassert.H +mytrace.H +) + # All else Fortran sources that are not in above categories list(APPEND GSI_SRC_srcs abstract_ensmod.f90 diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index d10e4e6f70..dbd0b60e0f 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -9,12 +9,12 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(${PROJECT_NAME}_compiler_flags) include(GNUInstallDirs) -if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake index 9216ce10c7..be9368ad6a 100644 --- a/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake +++ b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake @@ -12,7 +12,7 @@ endif() # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions ") +set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -funroll-all-loops -finline-functions ") #################################################################### # DEBUG FLAGS @@ -20,12 +20,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions ") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fcheck=bounds -ffpe-trap=invalid,zero,overflow") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -funroll-all-loops -finline-functions") - #################################################################### # LINK FLAGS #################################################################### diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake index 672f1baae1..a25d6cc301 100644 --- a/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake +++ b/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake @@ -16,12 +16,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -fp-model strict") - #################################################################### # LINK FLAGS #################################################################### diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index 1d2fdeefe1..7e67ee45cc 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -5,7 +5,7 @@ set -ex cd .. pwd=$(pwd) -build_type=${1:-'PRODUCTION'} +build_type=${1:-'Release'} dir_root=${2:-$pwd} mode=${3:-'EMC'} diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index ce082c7797..4c5871ace3 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -9,12 +9,12 @@ set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) include(GNUInstallDirs) -if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|Production)$") +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Production") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") diff --git a/util/cmake/gsiutils_compiler_flags_GNU_C.cmake b/util/cmake/gsiutils_compiler_flags_GNU_C.cmake index e79145242e..ed5d63d1de 100644 --- a/util/cmake/gsiutils_compiler_flags_GNU_C.cmake +++ b/util/cmake/gsiutils_compiler_flags_GNU_C.cmake @@ -16,12 +16,6 @@ set(CMAKE_C_FLAGS_RELEASE "") set(CMAKE_C_FLAGS_DEBUG "-Wall") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - #################################################################### # LINK FLAGS #################################################################### diff --git a/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake index eb3a3c86ae..6b2f64f116 100644 --- a/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake +++ b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake @@ -8,20 +8,11 @@ if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") endif() -# From setGNUFlags.cmake -# RELEASE OR PRODUCTION -#set(UTIL_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") -#set(UTIL_COM_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - -# DEBUG -#set(UTIL_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") -#set(UTIL_COM_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - #################################################################### # RELEASE FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_RELEASE "-O3") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions") #################################################################### # DEBUG FLAGS @@ -29,12 +20,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3 -funroll-all-loops -finline-functions") - #################################################################### # LINK FLAGS #################################################################### diff --git a/util/cmake/gsiutils_compiler_flags_Intel_C.cmake b/util/cmake/gsiutils_compiler_flags_Intel_C.cmake index e79145242e..ed5d63d1de 100644 --- a/util/cmake/gsiutils_compiler_flags_Intel_C.cmake +++ b/util/cmake/gsiutils_compiler_flags_Intel_C.cmake @@ -16,12 +16,6 @@ set(CMAKE_C_FLAGS_RELEASE "") set(CMAKE_C_FLAGS_DEBUG "-Wall") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_C_FLAGS_PRODUCTION "") - #################################################################### # LINK FLAGS #################################################################### diff --git a/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake index 4a895df8e8..e2de8c9fec 100644 --- a/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake +++ b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake @@ -4,16 +4,6 @@ set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback -implicitnone") - -# From setIntelFlags.cmake -# Production/Release -#set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DWRF -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -#set(UTIL_COM_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone" CACHE INTERNAL "") - -# Debug -#set(UTIL_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -#set(UTIL_COM_Fortran_FLAGS "-O0 -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian" CACHE INTERNAL "") - #################################################################### # RELEASE FLAGS #################################################################### @@ -26,12 +16,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn all -heap-arrays -fpe-all=0 -fpe:0 -check all -debug full -fp-model strict") -#################################################################### -# PRODUCTION FLAGS -#################################################################### - -set(CMAKE_Fortran_FLAGS_PRODUCTION "-O3") - #################################################################### # LINK FLAGS #################################################################### From 5add43f7582efb8f33ed74ae1c2cd5ce8d97bcf1 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 3 Mar 2022 15:35:52 -0500 Subject: [PATCH 21/58] add -DNDEBUG flags for gsi and enkf --- CMakeLists.txt | 1 - src/enkf/cmake/enkfapp_compiler_flags.cmake | 4 ++++ src/gsi/cmake/gsiapp_compiler_flags.cmake | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87ac98cd73..ca47abb017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ project(gsi list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) -#include(compiler_flags) include(GNUInstallDirs) if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") diff --git a/src/enkf/cmake/enkfapp_compiler_flags.cmake b/src/enkf/cmake/enkfapp_compiler_flags.cmake index 66cfe4e2a3..2a7d5e2cc9 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags.cmake @@ -1,3 +1,7 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + ####################################################################################### # Fortran ####################################################################################### diff --git a/src/gsi/cmake/gsiapp_compiler_flags.cmake b/src/gsi/cmake/gsiapp_compiler_flags.cmake index c8a0f37ae4..bd38b729da 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags.cmake @@ -1,3 +1,7 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + ####################################################################################### # Fortran ####################################################################################### From ceb6a0cbeb8edb7633b97312f9f0755e54e0f2f3 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 3 Mar 2022 16:22:08 -0500 Subject: [PATCH 22/58] revert whitespace differences that were unintended --- util/EFSOI_Utilities/src/gridio_efsoi.f90 | 510 +++++++++--------- .../calc_increment_ncio.f90 | 8 +- .../src/getsigensstatp.fd/getsigensstatp.f90 | 6 +- .../recenterens_ncio.fd/recenterens_ncio.f90 | 4 +- .../recenterncio_hybgain.f90 | 10 +- util/netcdf_io/interp_inc.fd/driver.f90 | 106 ++-- 6 files changed, 322 insertions(+), 322 deletions(-) diff --git a/util/EFSOI_Utilities/src/gridio_efsoi.f90 b/util/EFSOI_Utilities/src/gridio_efsoi.f90 index 437089b1a1..d7930fa09b 100644 --- a/util/EFSOI_Utilities/src/gridio_efsoi.f90 +++ b/util/EFSOI_Utilities/src/gridio_efsoi.f90 @@ -13,7 +13,7 @@ module gridio_efsoi ! prgmmr: eichmann, lin org: emc date: 2021-02-04 ! ! abstract: I/O for ensemble member files. -! +! ! Public Functions: ! readgriddata_efsoi ! @@ -30,10 +30,10 @@ module gridio_efsoi ! 2016-04-20 Modify to handle the updated nemsio sig file (P, DP, DPDT ! removed) ! 2016-11-29 shlyaeva: Add reading/calculating tsen, qi, ql. Pass filenames and -! hours to read routine to read separately state and control files. +! hours to read routine to read separately state and control files. ! Pass levels and dimenstions to read/write routines (dealing with ! prse: nlevs + 1 levels). Pass "reducedgrid" parameter. -! 2017-06-14 Adding functionality to optionally write non-inflated ensembles, +! 2017-06-14 Adding functionality to optionally write non-inflated ensembles, ! a required input for EFSO calculations ! 2018-05-24 Pruning available EnKF nemsio read functionality for EFSOI ! application. Add additional routines to compute EFSOI relevant @@ -47,8 +47,8 @@ module gridio_efsoi ! !$$$ use constants, only: zero,one,cp,fv,rd,tiny_r_kind,max_varname_length,t0c,r0_05,constants_initialized, & - tref,pref,hvap - + tref,pref,hvap + use params, only: nlons,nlats,nlevs,use_gfs_nemsio,pseudo_rh, & cliptracers,datapath,imp_physics,use_gfs_ncio,cnvw_option, & nanals, & @@ -68,9 +68,9 @@ module gridio_efsoi lonsperlat, nlonsfull use mpisetup, only: nproc, numproc - - use mpimod, only: mpi_comm_world, mpi_sum, mpi_real4, mpi_real8, mpi_rtype - + + use mpimod, only: mpi_comm_world, mpi_sum, mpi_real4, mpi_real8, mpi_rtype + use mpeu_util, only: getindex use nemsio_module use loadbal_efsoi, only: numptsperproc, indxproc, npts_max @@ -94,64 +94,64 @@ subroutine get_weight() use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& quantize_data, read_attribute, close_dataset, get_dim, read_vardata - - implicit none - - character(len=500) :: filename - - real(r_kind), dimension(npts,nlevs+1) :: pressi - real(r_single), dimension(npts) :: tmpgrd + + implicit none + + character(len=500) :: filename + + real(r_kind), dimension(npts,nlevs+1) :: pressi + real(r_single), dimension(npts) :: tmpgrd type(nemsio_gfile) :: gfile real(nemsio_realkind), dimension(nlons*nlats) :: nems_wrk real(r_kind), dimension(nlons*nlats) :: psfc - real(r_single),allocatable,dimension(:,:,:) :: nems_vcoord - real(r_kind), allocatable, dimension(:) :: ak,bk - real(r_kind) :: sumcoslat - - integer(i_kind) :: nlevsin,nlonsin,nlatsin,idvc - integer(i_kind) :: i,j,k,iret!iunitsig,iret - - ! for netcdf handling - type(Dataset) :: dset - type(Dimension) :: londim,latdim,levdim + real(r_single),allocatable,dimension(:,:,:) :: nems_vcoord + real(r_kind), allocatable, dimension(:) :: ak,bk + real(r_kind) :: sumcoslat + + integer(i_kind) :: nlevsin,nlonsin,nlatsin,idvc + integer(i_kind) :: i,j,k,iret!iunitsig,iret + + ! for netcdf handling + type(Dataset) :: dset + type(Dimension) :: londim,latdim,levdim integer(i_kind) :: iunitsig type(sigio_head) :: sighead type(sigio_data) :: sigdata real(r_kind), allocatable, dimension(:) :: psg real(r_kind), dimension(ndimspec) :: vrtspec - real(r_single), allocatable, dimension(:,:) :: values_2d - integer(i_kind) :: ierr - - + real(r_single), allocatable, dimension(:,:) :: values_2d + integer(i_kind) :: ierr + + iunitsig = 77 ! ============================================================ - ! Read analysis data + ! Read analysis data ! ================================== ! update ncio !if (nproc .eq. 0) then filename = trim(adjustl(datapath))//trim(adjustl(andataname)) if (nproc == 0) print *,'reading analysis file: ',filename - ! --- nemsio data ------------------------------------------------- + ! --- nemsio data ------------------------------------------------- if (use_gfs_nemsio) then call nemsio_init(iret=iret) if(iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_init,iret=',iret call stop2(23) end if - + call nemsio_open(gfile,filename,'READ',iret=iret) - + if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_open,iret=',iret call stop2(23) endif - + call nemsio_getfilehead(gfile,iret=iret, dimx=nlonsin, dimy=nlatsin,& dimz=nlevsin,idvc=idvc) if (nlons /= nlonsin .or. nlats /= nlatsin .or. nlevs /= nlevsin) then @@ -160,21 +160,21 @@ subroutine get_weight() print *,'got',nlonsin,nlatsin,nlevsin call stop2(23) end if - - - ! --- NetCDF data ------------------------------------------------- + + + ! --- NetCDF data ------------------------------------------------- else if (use_gfs_ncio) then - + dset = open_dataset(filename) - + londim = get_dim(dset,'grid_xt'); nlonsin = londim%len latdim = get_dim(dset,'grid_yt'); nlatsin = latdim%len levdim = get_dim(dset,'pfull'); nlevsin = levdim%len idvc=2 - - - ! --- Other data ------------------------------------------------- + + + ! --- Other data ------------------------------------------------- else call sigio_srohdc(iunitsig,trim(filename), & sighead,sigdata,iret) @@ -183,17 +183,17 @@ subroutine get_weight() call stop2(23) end if endif - + !endif - ! ============================================================ - + ! ============================================================ + allocate(ak(nlevs+1)) allocate(bk(nlevs+1)) - allocate(psg(nlons*nlats)) - allocate(weight(npts,nlevs)) - allocate(grweight(npts)) - - + allocate(psg(nlons*nlats)) + allocate(weight(npts,nlevs)) + allocate(grweight(npts)) + + if (.not. constants_initialized) then print *,'constants not initialized (with init_constants, init_constants_derived)' call stop2(23) @@ -201,70 +201,70 @@ subroutine get_weight() ! calculate weight on the grid point sumcoslat = zero - + ! if(reducedgrid) then k=0 - do i=1,nlats - do j=1,lonsperlat(i) - k=k+1 - grweight(k) = cos(gaulats(i)) * real(nlonsfull,r_kind) & - / real(lonsperlat(i),r_kind) - sumcoslat = sumcoslat + grweight(k) - end do - end do - - ! else - ! do i=1,nlons*nlats - ! grweight(i) = cos(latsgrd(i)) - ! sumcoslat = sumcoslat + grweight(i) - ! end do - ! end if - - sumcoslat = 1.0_r_kind / sumcoslat + do i=1,nlats + do j=1,lonsperlat(i) + k=k+1 + grweight(k) = cos(gaulats(i)) * real(nlonsfull,r_kind) & + / real(lonsperlat(i),r_kind) + sumcoslat = sumcoslat + grweight(k) + end do + end do + + ! else + ! do i=1,nlons*nlats + ! grweight(i) = cos(latsgrd(i)) + ! sumcoslat = sumcoslat + grweight(i) + ! end do + ! end if + + sumcoslat = 1.0_r_kind / sumcoslat grweight(:) = sqrt(grweight(:)*sumcoslat) - + ! ==================================================== ! Extract surface pressure in pa ! to aid in quantifying mass ! ======================================== - ! === Option ONE, nemsio === - if (use_gfs_nemsio) then - + ! === Option ONE, nemsio === + if (use_gfs_nemsio) then + call nemsio_readrecv(gfile,'pres','sfc',1,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(ps), iret=',iret call stop2(23) endif - + ! Assign surface pressure in pa - psfc = nems_wrk + psfc = nems_wrk ! Extract surface pressure ! on reduced gaussian grid call regtoreduced(psfc,tmpgrd) - ! calculate half level pressures + ! calculate half level pressures if (allocated(nems_vcoord)) deallocate(nems_vcoord) - + allocate(nems_vcoord(nlevs+1,3,2)) call nemsio_getfilehead(gfile,iret=iret,vcoord=nems_vcoord) - + if ( iret /= 0 ) then write(6,*)' gridio: ***ERROR*** problem reading header ', & 'vcoord, Status = ',iret call stop2(99) - endif - + endif + if ( idvc == 0 ) then ! sigma coordinate, old file format. ak = zero bk = nems_vcoord(1:nlevs+1,1,1) else if ( idvc == 1 ) then ! sigma coordinate ak = zero bk = nems_vcoord(1:nlevs+1,2,1) - + else if ( idvc == 2 .or. idvc == 3 ) then ! hybrid coordinate - + ! AFE ak = nems_vcoord(1:nlevs+1,1,1) ! AFE ak = nems_vcoord(1:nlevs+1,2,1) ak = 0.01_r_kind*nems_vcoord(1:nlevs+1,1,1) ! convert to mb @@ -273,46 +273,46 @@ subroutine get_weight() write(6,*)'gridio: ***ERROR*** INVALID value for idvc=',idvc call stop2(85) end if - - !==> pressure at interfaces. - do k=1,nlevs+1 - pressi(:,k)=ak(k)+bk(k)*tmpgrd - end do - deallocate(ak,bk) - - ! === Option TWO, NetCDF === + + !==> pressure at interfaces. + do k=1,nlevs+1 + pressi(:,k)=ak(k)+bk(k)*tmpgrd + end do + deallocate(ak,bk) + + ! === Option TWO, NetCDF === else if (use_gfs_ncio) then - + call mpi_barrier(mpi_comm_world,ierr) call read_vardata(dset, 'pressfc', values_2d,errcode=iret) - + if (iret /= 0) then print *,'error reading ps' call stop2(31) endif - + psg = 0.01_r_kind*reshape(values_2d,(/nlons*nlats/)) - + ! Extract surface pressure ! on reduced gaussian grid - call regtoreduced(psg,tmpgrd) - + call regtoreduced(psg,tmpgrd) + call read_attribute(dset, 'ak', ak) call read_attribute(dset, 'bk', bk) - + ! pressure at interfaces do k=1,nlevs+1 pressi(:,k) = 0.01_r_kind*ak(nlevs-k+2)+bk(nlevs-k+2)*tmpgrd - + if (nproc == 0) print *,'netcdf, min/max pressi',k,minval(pressi(:,k)),maxval(pressi(:,k)) enddo - - deallocate(ak,bk,values_2d) - - ! === Option THREE, other === + + deallocate(ak,bk,values_2d) + + ! === Option THREE, other === else - + vrtspec = sigdata%ps call sptez_s(vrtspec,psg,1) !==> input psg is ln(ps) in centibars - convert to ps in millibars. @@ -336,94 +336,94 @@ subroutine get_weight() pressi(:,k)=ak(k)+bk(k)*psg print *,'sigio, min/max pressi',k,minval(pressi(:,k)),maxval(pressi(:,k)) enddo - + deallocate(ak,bk) - + endif - + if (use_gfs_nemsio) call nemsio_close(gfile,iret=iret) - if (use_gfs_ncio) call close_dataset(dset) - - !$omp parallel do private(k) shared(weight,pressi,grweight,nlevs) - do k=1,nlevs - ! sqrt(dp)*sqrt(area) - weight(:,k)=sqrt( (pressi(:,k)-pressi(:,k+1))/tmpgrd(:))*grweight(:) + if (use_gfs_ncio) call close_dataset(dset) + + !$omp parallel do private(k) shared(weight,pressi,grweight,nlevs) + do k=1,nlevs + ! sqrt(dp)*sqrt(area) + weight(:,k)=sqrt( (pressi(:,k)-pressi(:,k+1))/tmpgrd(:))*grweight(:) end do !$omp end parallel do + + + + - - - - - - return - + + return + end subroutine get_weight - - - - - - - - - subroutine destroy_weight - implicit none - if(allocated(weight)) deallocate(weight) - if(allocated(grweight)) deallocate(grweight) - end subroutine destroy_weight - - - - - - subroutine divide_weight(grdin) - implicit none - real(r_single), dimension(npts_max,ncdim), intent(inout) :: grdin - real(r_single) cptr,qweight,rdtrpr - integer(i_kind) :: k,npt - cptr = real(sqrt(tref/cp),r_kind) - qweight = real(sqrt(cp*tref/wmoist)/hvap,r_kind) - rdtrpr = real(sqrt(pref/(rd*tref)),r_kind) - do npt=1,numptsperproc(nproc+1) - do k=1,nlevs - grdin(npt,k) = grdin(npt,k) / weight(indxproc(nproc+1,npt),k) - grdin(npt,nlevs+k) = grdin(npt,nlevs+k) / weight(indxproc(nproc+1,npt),k) - grdin(npt,2*nlevs+k) = grdin(npt,2*nlevs+k) * cptr / weight(indxproc(nproc+1,npt),k) - if (nvars .gt. 3) then - grdin(npt,3*nlevs+k) = grdin(npt,3*nlevs+k) * qweight / weight(indxproc(nproc+1,npt),k) - end if - end do + + + + + + + + + subroutine destroy_weight + implicit none + if(allocated(weight)) deallocate(weight) + if(allocated(grweight)) deallocate(grweight) + end subroutine destroy_weight + + + + + + subroutine divide_weight(grdin) + implicit none + real(r_single), dimension(npts_max,ncdim), intent(inout) :: grdin + real(r_single) cptr,qweight,rdtrpr + integer(i_kind) :: k,npt + cptr = real(sqrt(tref/cp),r_kind) + qweight = real(sqrt(cp*tref/wmoist)/hvap,r_kind) + rdtrpr = real(sqrt(pref/(rd*tref)),r_kind) + do npt=1,numptsperproc(nproc+1) + do k=1,nlevs + grdin(npt,k) = grdin(npt,k) / weight(indxproc(nproc+1,npt),k) + grdin(npt,nlevs+k) = grdin(npt,nlevs+k) / weight(indxproc(nproc+1,npt),k) + grdin(npt,2*nlevs+k) = grdin(npt,2*nlevs+k) * cptr / weight(indxproc(nproc+1,npt),k) + if (nvars .gt. 3) then + grdin(npt,3*nlevs+k) = grdin(npt,3*nlevs+k) * qweight / weight(indxproc(nproc+1,npt),k) + end if + end do ! AFE the indexing schema needs to be cleaned up -! grdin(npt,nvars*nlevs+1) = grdin(npt,nvars*nlevs+1) & - grdin(npt,ncdim) = grdin(npt,ncdim) & - & * rdtrpr / grweight(indxproc(nproc+1,npt)) - end do - return - end subroutine divide_weight +! grdin(npt,nvars*nlevs+1) = grdin(npt,nvars*nlevs+1) & + grdin(npt,ncdim) = grdin(npt,ncdim) & + & * rdtrpr / grweight(indxproc(nproc+1,npt)) + end do + return + end subroutine divide_weight subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal,ft,hr,infilename) - + use sigio_module, only: sigio_head, sigio_data, sigio_sclose, sigio_sropen, & sigio_srohdc, sigio_sclose, sigio_aldata, sigio_axdata - + use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& read_attribute, close_dataset, get_dim, read_vardata - + implicit none integer, intent(in), optional :: nanal integer, intent(in), optional :: ft integer, intent(in), optional :: hr - - character(len=100), intent(in), optional :: infilename + + character(len=100), intent(in), optional :: infilename integer, intent(in) :: mode character(len=max_varname_length), dimension(n2d), intent(in) :: vars2d character(len=max_varname_length), dimension(n3d), intent(in) :: vars3d @@ -440,7 +440,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal real(r_kind), dimension(nlons*nlats) :: ug,vg real(r_single), dimension(npts,nlevs) :: tv, q, tv_to_t real(r_kind), allocatable, dimension(:) :: psg - + real(r_single),allocatable,dimension(:,:,:) :: nems_vcoord real(nemsio_realkind), dimension(nlons*nlats) :: nems_wrk,nems_wrk2 type(nemsio_gfile) :: gfile @@ -449,20 +449,20 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal integer(i_kind) :: ps_ind integer(i_kind) :: k,iret,idvc,nlonsin,nlatsin,nlevsin - + character(len=10) :: fileformat integer(i_kind) :: iunitsig type(sigio_head) :: sighead type(sigio_data) :: sigdata type(Dataset) :: dset - type(Dimension) :: londim,latdim,levdim - real(r_kind), dimension(ndimspec) :: vrtspec,divspec + type(Dimension) :: londim,latdim,levdim + real(r_kind), dimension(ndimspec) :: vrtspec,divspec real(r_single), allocatable, dimension(:,:,:) :: ug3d,vg3d real(r_single), allocatable, dimension(:,:) :: values_2d integer(i_kind) :: nb,ne - + iunitsig = 77 nb = 1 ne = 1 @@ -481,7 +481,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal else charnanal = 'ensmean' endif - endif + endif ! ====================================== if (use_gfs_nemsio) then @@ -496,7 +496,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! === EFSOI filename construction ============= if(forecast_impact) then - + if(mode == read_ensmean_forecast) then filename = trim(adjustl(datapath))//"gdas.t"//charhr//"z.atmf"//charft// & "."//trim(adjustl(charnanal))//trim(fileformat) @@ -526,7 +526,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal print *,'This mode is not supported: mode=',mode call stop2(23) end if - endif + endif ! --------------------------------------------! ! Read in state vector from file and transform! @@ -536,16 +536,16 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal if (nproc == 0) print *,'reading state vector file: ',filename - if (use_gfs_nemsio) then - + if (use_gfs_nemsio) then + call nemsio_init(iret=iret) if(iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_init, iret=',iret call stop2(23) end if - + call nemsio_open(gfile,filename,'READ',iret=iret) - + if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_open, iret=',iret call stop2(23) @@ -559,17 +559,17 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal call stop2(23) end if - else if (use_gfs_ncio) then + else if (use_gfs_ncio) then dset = open_dataset(filename) - + londim = get_dim(dset,'grid_xt'); nlonsin = londim%len latdim = get_dim(dset,'grid_yt'); nlatsin = latdim%len levdim = get_dim(dset,'pfull'); nlevsin = levdim%len idvc=2 - + else - + call sigio_srohdc(iunitsig,trim(filename), & sighead,sigdata,iret) if (iret /= 0) then @@ -577,13 +577,13 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal call stop2(23) end if endif - - + + cptr = sqrt(cp/tref) qweight = sqrt(wmoist/(cp*tref))*hvap rdtrpr = sqrt(rd*tref)/pref - + u_ind = getindex(vars3d, 'u') !< indices in the state var arrays v_ind = getindex(vars3d, 'v') ! U and V (3D) tv_ind = getindex(vars3d, 'tv') ! Tv (3D) @@ -591,17 +591,17 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ps_ind = getindex(vars2d, 'ps') ! Ps (2D) - + if (.not. isinitialized) call init_spec_vars(nlons,nlats,ntrunc,4) allocate(psg(nlons*nlats)) - - + + ! ====================================================== ! Get surface pressure ! ==================== if (use_gfs_nemsio) then - + call nemsio_readrecv(gfile,'pres','sfc',1,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(ps), iret=',iret @@ -609,7 +609,7 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal endif psg = 0.01_r_kind*nems_wrk ! convert ps to millibars. - ! + ! if (allocated(nems_vcoord)) deallocate(nems_vcoord) allocate(nems_vcoord(nlevs+1,3,2)) call nemsio_getfilehead(gfile,iret=iret,vcoord=nems_vcoord) @@ -618,128 +618,128 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal 'vcoord, Status = ',iret call stop2(99) endif - + else if (use_gfs_ncio) then - + call read_vardata(dset, 'pressfc', values_2d,errcode=iret) if (iret /= 0) then print *,'error reading ps' call stop2(31) endif - psg = 0.01_r_kind*reshape(values_2d,(/nlons*nlats/)) - + psg = 0.01_r_kind*reshape(values_2d,(/nlons*nlats/)) + else vrtspec = sigdata%ps call sptez_s(vrtspec,psg,1) !==> input psg is ln(ps) in centibars - convert to ps in millibars. psg = 10._r_kind*exp(psg) - endif - - - - ! ============================================================================= + endif + + + + ! ============================================================================= ! get U,V,temp,q,ps on gaussian grid. ! ===================================== ! u is first nlevs, v is second, t is third, then tracers. if (use_gfs_nemsio) then - + do k=1,nlevs - + ! Get u-wind call nemsio_readrecv(gfile,'ugrd','mid layer',k,nems_wrk,iret=iret) - + if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(ugrd), iret=',iret call stop2(23) endif - + ug = nems_wrk - + ! Get v-wind call nemsio_readrecv(gfile,'vgrd','mid layer',k,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(vgrd), iret=',iret call stop2(23) endif - + vg = nems_wrk - + if (u_ind > 0) call copytogrdin(ug,grdin(:,levels(u_ind-1) + k)) if (v_ind > 0) call copytogrdin(vg,grdin(:,levels(v_ind-1) + k)) - - + + ! Transformation to EFSOI relevant quantities ! Assign weighted kinetic energy components. There ! are no unit/metric differences for the kinetic component grdin(:,levels(u_ind-1) + k) = weight(:,k) * grdin(:,levels(u_ind-1) + k) grdin(:,levels(v_ind-1) + k) = weight(:,k) * grdin(:,levels(v_ind-1) + k) - + call nemsio_readrecv(gfile,'tmp','mid layer',k,nems_wrk,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(tmp), iret=',iret call stop2(23) endif - + call nemsio_readrecv(gfile,'spfh','mid layer',k,nems_wrk2,iret=iret) if (iret/=0) then write(6,*)'gridio/readgriddata_efsoi: GFS: problem with nemsio_readrecv(spfh), iret=',iret call stop2(23) endif - + ug = nems_wrk vg = nems_wrk2 - + call copytogrdin(ug,tv(:,k)) call copytogrdin(vg, q(:,k)) ! Transformation to EFSOI relevant quantities ! Mass component quantities tv(:,k) = cptr * weight(:,k) * tv(:,k) - + ! Moisture component transormation to EFSOI ! relevant quantities q(:,k) = qweight * weight(:,k) * q(:,k) tv_to_t(:,k) = ( one / (one + q(:,k)*0.61_r_kind) ) - + ! Approximate the necessary transformation ! of virtual temperature to temperature tv(:,k) = tv(:,k) * tv_to_t(:,k) - + if (tv_ind > 0) grdin(:,levels(tv_ind-1)+k) = tv(:,k) if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) enddo - + else if (use_gfs_ncio) then - + ! ==== Get U and V ======================================== call read_vardata(dset, 'ugrd', ug3d,errcode=iret) - + if (iret /= 0) then print *,'error reading ugrd' call stop2(22) endif - + call read_vardata(dset, 'vgrd', vg3d,errcode=iret) if (iret /= 0) then print *,'error reading vgrd' call stop2(23) endif - + do k=1,nlevs ug = reshape(ug3d(:,:,nlevs-k+1),(/nlons*nlats/)) vg = reshape(vg3d(:,:,nlevs-k+1),(/nlons*nlats/)) - + if (u_ind > 0) call copytogrdin(ug,grdin(:,levels(u_ind-1) + k)) if (v_ind > 0) call copytogrdin(vg,grdin(:,levels(v_ind-1) + k)) - + ! Transformation to EFSOI relevant quantities ! Assign weighted kinetic energy components. There ! are no unit/metric differences for the kinetic component grdin(:,levels(u_ind-1) + k) = weight(:,k) * grdin(:,levels(u_ind-1) + k) - grdin(:,levels(v_ind-1) + k) = weight(:,k) * grdin(:,levels(v_ind-1) + k) - + grdin(:,levels(v_ind-1) + k) = weight(:,k) * grdin(:,levels(v_ind-1) + k) + ! calculate vertical integral of mass flux div (ps tendency) ! this variable is analyzed in order to enforce mass balance in the analysis !if (pst_ind > 0) then @@ -749,36 +749,36 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! call sptez_s(divspec,vmassdiv(:,k),1) ! divspec to divgrd !endif enddo - - - + + + ! ==== Get T and Q =========================================== call read_vardata(dset,'tmp', ug3d,errcode=iret) - + if (iret /= 0) then print *,'error reading tmp' call stop2(24) endif - + call read_vardata(dset,'spfh', vg3d,errcode=iret) - + if (iret /= 0) then print *,'error reading spfh' call stop2(25) - endif - + endif + do k=1,nlevs ug = reshape(ug3d(:,:,nlevs-k+1),(/nlons*nlats/)) vg = reshape(vg3d(:,:,nlevs-k+1),(/nlons*nlats/)) - + !if (tsen_ind > 0) call copytogrdin(ug,grdin(:,levels(tsen_ind-1)+k,nb,ne)) - + call copytogrdin(vg, q(:,k)) - + ug = ug * ( 1.0 + fv*vg ) ! convert T to Tv - ! + ! call copytogrdin(ug,tv(:,k)) - + ! Transformation to EFSOI relevant quantities ! Mass component quantities tv(:,k) = cptr * weight(:,k) * tv(:,k) @@ -786,20 +786,20 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! relevant quantities q(:,k) = qweight * weight(:,k) * q(:,k) tv_to_t(:,k) = ( one / (one + q(:,k)*0.61_r_kind) ) - + ! Approximate the necessary transformation ! of virtual temperature to temperature tv(:,k) = tv(:,k) * tv_to_t(:,k) - + if (tv_ind > 0) grdin(:,levels(tv_ind-1)+k) = tv(:,k) if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) enddo - + deallocate(ug3d,vg3d) - + else - - ! $omp parallel do private(k,ug,vg,divspec,vrtspec) + + ! $omp parallel do private(k,ug,vg,divspec,vrtspec) ! shared(sigdata,pressi,vmassdiv,grdin,tv,q,cw,u_ind,v_ind,pst_ind,q_ind,tsen_ind,cw_ind,qi_ind,ql_ind) do k=1,nlevs @@ -824,11 +824,11 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal divspec = sigdata%t(:,k) call sptez_s(divspec,ug,1) call copytogrdin(ug,tv(:,k)) - + divspec = sigdata%q(:,k,1) call sptez_s(divspec,vg,1) call copytogrdin(vg,q(:,k)) - + ! Transformation to EFSOI relevant quantities ! Mass component quantities tv(:,k) = cptr * weight(:,k) * tv(:,k) @@ -836,20 +836,20 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! relevant quantities q(:,k) = qweight * weight(:,k) * q(:,k) tv_to_t(:,k) = ( one / (one + q(:,k)*0.61_r_kind) ) - + ! Approximate the necessary transformation ! of virtual temperature to temperature tv(:,k) = tv(:,k) * tv_to_t(:,k) - + if (tv_ind > 0) grdin(:,levels(tv_ind-1)+k) = tv(:,k) - if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) - + if (q_ind > 0) grdin(:,levels( q_ind-1)+k) = q(:,k) + enddo endif - + ! ============================================================= - ! surface pressure + ! surface pressure ! ================ if (ps_ind > 0) then call copytogrdin(psg,grdin(:,levels(n3d) + ps_ind)) @@ -858,16 +858,16 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal ! Transformation to EFSOI relevant quantities ! Surface pressure contribution grdin(:,levels(n3d) + ps_ind) = rdtrpr * grweight(:) * 100._r_kind * grdin(:,levels(n3d) + ps_ind) - + deallocate(psg) - + if (use_gfs_nemsio) call nemsio_close(gfile,iret=iret) if (use_gfs_ncio) call close_dataset(dset) return - + contains - + ! copying to grdin (calling regtoreduced if reduced grid) subroutine copytogrdin(field, grdin) implicit none diff --git a/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 b/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 index d8377ab1a2..1bbdfb1b99 100755 --- a/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 +++ b/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 @@ -20,7 +20,7 @@ PROGRAM calc_increment_ncio ! output files: filename_inc (3rd command line arg) ! 4th command line arg is logical for controlling whether microphysics -! increment is computed. +! increment is computed. ! 5th command line arg is logical for controlling whether delz ! increment should be computed ! 6th command line arg is logical for controlling whether humidity @@ -69,7 +69,7 @@ PROGRAM calc_increment_ncio rd = 2.8705e+2 rv = 4.6150e+2 - fv = rv/rd-1. ! used in virtual temperature equation + fv = rv/rd-1. ! used in virtual temperature equation grav = 9.80665 ! damp humidity increments between these two levels if taper_strat=T ak_bot = 10000. ! units Pa @@ -336,7 +336,7 @@ PROGRAM calc_increment_ncio values_3d_inc(:,nlats:1:-1,:) = taper_vert*(values_3d_anal - values_3d_fg) else values_3d_inc(:,nlats:1:-1,:) = values_3d_anal - values_3d_fg - endif + endif call write_ncdata3d(values_3d_inc,ncvarname,nlons,nlats,nlevs,ncfileid,dimid_3d) endif endif ! ndims == 4 @@ -362,7 +362,7 @@ PROGRAM calc_increment_ncio call read_vardata(dset_fg,'pressfc',ps_fg) call read_vardata(dset_anal,'pressfc',ps_anal) tmp_fg = tmp_fg * ( 1.0 + fv*q_fg ) ! convert T to Tv - tmp_anal = tmp_anal * ( 1.0 + fv*q_anal ) + tmp_anal = tmp_anal * ( 1.0 + fv*q_anal ) allocate(delzb(nlons,nlats,nlevs)) allocate(delza(nlons,nlats,nlevs)) delzb = (rd/grav)*tmp_fg diff --git a/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 b/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 index 9126578c3f..efe496f547 100644 --- a/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 +++ b/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 @@ -15,7 +15,7 @@ program getsigensstatp ! ! program history log: ! 2014-08-23 Initial version. -! 2018-07-21 Add hydrometeor (optional) +! 2018-07-21 Add hydrometeor (optional) ! ! usage: ! input files: @@ -276,7 +276,7 @@ program getsigensstatp call nemsio_readrecv(gfile,'spfh', 'mid layer',k,rwork_mem(:,krecq), iret=iret) call nemsio_readrecv(gfile,'o3mr', 'mid layer',k,rwork_mem(:,krecoz), iret=iret) call nemsio_readrecv(gfile,'clwmr','mid layer',k,rwork_mem(:,kreccwmr),iret=iret) - ! if ( do_icmr ) call nemsio_readrecv(gfile,'icmr', 'mid layer',k,rwork_mem(:,krecicmr),iret=iret) + ! if ( do_icmr ) call nemsio_readrecv(gfile,'icmr', 'mid layer',k,rwork_mem(:,krecicmr),iret=iret) if ( do_hydro ) then call nemsio_readrecv(gfile,'icmr', 'mid layer',k,rwork_mem(:,krecicmr), iret=iret) call nemsio_readrecv(gfile,'rwmr', 'mid layer',k,rwork_mem(:,krecrwmr), iret=iret) @@ -288,7 +288,7 @@ program getsigensstatp call nemsio_close(gfile,iret=iret) elseif ( ncio ) then - call read_vardata(dset,'pressfc',values_2d) + call read_vardata(dset,'pressfc',values_2d) rwork_mem(:,1) = reshape(values_2d,(/npts/)) deallocate(values_2d) call read_vardata(dset,'ugrd',values_3d) diff --git a/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 b/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 index eb7f3c6472..2e194ed76c 100644 --- a/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 +++ b/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 @@ -113,7 +113,7 @@ program recenterens_ncio if (ndims == 3 .and. trim(dseti%variables(nvar)%name) /= 'hgtsfc') then ! pressfc if (mype == 0) print *,'recentering ',& - trim(dseti%variables(nvar)%name) + trim(dseti%variables(nvar)%name) call read_vardata(dseti,trim(dseti%variables(nvar)%name),values_2d_i) call read_vardata(dsetmi,trim(dseti%variables(nvar)%name),values_2d_mi) call read_vardata(dsetmo,trim(dseti%variables(nvar)%name),values_2d_mo) @@ -135,7 +135,7 @@ program recenterens_ncio call write_vardata(dseto,trim(dseti%variables(nvar)%name),values_2d) else if (ndims == 4) then if (mype == 0) print *,'recentering ',& - trim(dseti%variables(nvar)%name) + trim(dseti%variables(nvar)%name) call read_vardata(dseti,trim(dseti%variables(nvar)%name),values_3d_i) call read_vardata(dsetmi,trim(dseti%variables(nvar)%name),values_3d_mi) call read_vardata(dsetmo,trim(dseti%variables(nvar)%name),values_3d_mo) diff --git a/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 b/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 index 51823f56e4..1384e3ccfb 100644 --- a/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 +++ b/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 @@ -6,7 +6,7 @@ program recenterncio_hybgain ! prgmmr: whitaker org: esrl/psd date: 2009-02-23 ! ! abstract: Recenter ensemble analysis files about new -! mean, computed from blended 3DVar and EnKF increments +! mean, computed from blended 3DVar and EnKF increments ! (optionally applying RTPS inflation). ! ! program history log: @@ -45,7 +45,7 @@ program recenterncio_hybgain real alpha,beta,rtps,infmin,infmax,clip real(4),allocatable,dimension(:,:) :: values_2d_varanal,values_2d_enkfanal,& values_2d_varfg,values_2d_enkffg,values_2d_anal,& - values_2d,asprd_2d,fsprd_2d,inf_2d,values_2d_tmp + values_2d,asprd_2d,fsprd_2d,inf_2d,values_2d_tmp real(4),allocatable,dimension(:,:,:) :: values_3d_varanal,values_3d_enkfanal,& values_3d_varfg,values_3d_enkffg,values_3d_anal,& values_3d,asprd_3d,fsprd_3d,inf_3d,values_3d_tmp @@ -207,7 +207,7 @@ program recenterncio_hybgain ! blended analysis values_2d_anal = values_2d_enkffg + beta*(values_2d_enkfanal-values_2d_enkffg) if (alpha > 0) & - values_2d_anal = values_2d_anal + alpha*(values_2d_varanal-values_2d_varfg) + values_2d_anal = values_2d_anal + alpha*(values_2d_varanal-values_2d_varfg) ! recentered ensemble member if (rtps > 0) then ! RTPS inflation call read_vardata(dset_fsprd,trim(dset_enkffg%variables(nvar)%name),fsprd_2d) @@ -261,9 +261,9 @@ program recenterncio_hybgain call read_vardata(dset_enkfanal,trim(dset_enkffg%variables(nvar)%name),values_3d_enkfanal) call read_vardata(dseti,trim(dset_enkffg%variables(nvar)%name),values_3d) ! blended analysis - values_3d_anal = values_3d_enkffg + beta*(values_3d_enkfanal-values_3d_enkffg) + values_3d_anal = values_3d_enkffg + beta*(values_3d_enkfanal-values_3d_enkffg) if (alpha > 0) & - values_3d_anal = values_3d_anal + alpha*(values_3d_varanal-values_3d_varfg) + values_3d_anal = values_3d_anal + alpha*(values_3d_varanal-values_3d_varfg) ! recentered ensemble member if (rtps > 0) then ! RTPS inflation call read_vardata(dset_fsprd,trim(dset_enkffg%variables(nvar)%name),fsprd_3d) diff --git a/util/netcdf_io/interp_inc.fd/driver.f90 b/util/netcdf_io/interp_inc.fd/driver.f90 index 3a660015ad..23bfcb44c6 100644 --- a/util/netcdf_io/interp_inc.fd/driver.f90 +++ b/util/netcdf_io/interp_inc.fd/driver.f90 @@ -30,11 +30,11 @@ program interp_inc integer, parameter :: num_recs = 9 ! Declare externals - external :: w3tagb, netcdf_err, splat, ipolatev, ipolates, w3tage - + external :: w3tagb, netcdf_err, splat, ipolatev, & + ipolates, w3tage character(len=128) :: outfile, infile - character(len=11) :: records(num_recs) + character(len=11) :: records(num_recs) integer :: i, j, mi, iret, mo, rec integer :: lon_in, lat_in @@ -113,88 +113,88 @@ program interp_inc call mpi_barrier(mpi_comm_world, mpierr) if (mype == 0) then print*,'- OPEN OUTPUT FILE: ', trim(outfile) - + error = nf90_create(outfile, cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=ncid_out) call netcdf_err(error, 'CREATING FILE='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'lon', lon_out, dim_lon_out) call netcdf_err(error, 'defining dimension lon for file='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'lat', lat_out, dim_lat_out) call netcdf_err(error, 'defining dimension lat for file='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'lev', lev, dim_lev_out) call netcdf_err(error, 'defining dimension lev for file='//trim(outfile) ) - + error = nf90_def_dim(ncid_out, 'ilev', ilev, dim_ilev_out) call netcdf_err(error, 'defining dimension ilev for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'lon', nf90_double, (/dim_lon_out/), id_lon_out) call netcdf_err(error, 'defining variable lon for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, id_lon_out, "units", "degrees_east") call netcdf_err(error, 'define lon attribute for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'lat', nf90_double, (/dim_lat_out/), id_lat_out) call netcdf_err(error, 'defining varable lat for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, id_lat_out, "units", "degrees_north") call netcdf_err(error, 'defining lat att for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'lev', nf90_float, (/dim_lev_out/), id_lev_out) call netcdf_err(error, 'defining variable lev for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'pfull', nf90_float, (/dim_lev_out/), id_pfull_out) call netcdf_err(error, 'defining variable pfull for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'ilev', nf90_float, (/dim_ilev_out/), id_ilev_out) call netcdf_err(error, 'defining variable ilev for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'hyai', nf90_float, (/dim_ilev_out/), id_hyai_out) call netcdf_err(error, 'defining variable hyai for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'hybi', nf90_float, (/dim_ilev_out/), id_hybi_out) call netcdf_err(error, 'defining variable hybi for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'u_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_u_inc_out) call netcdf_err(error, 'defining variable u_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'v_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_v_inc_out) call netcdf_err(error, 'defining variable v_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'delp_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_delp_inc_out) call netcdf_err(error, 'defining variable delp_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'delz_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_delz_inc_out) call netcdf_err(error, 'defining variable delz_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'T_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_t_inc_out) call netcdf_err(error, 'defining variable t_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'sphum_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_sphum_inc_out) call netcdf_err(error, 'defining variable sphum_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'liq_wat_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_liq_wat_inc_out) call netcdf_err(error, 'defining variable liq_wat_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'o3mr_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_o3mr_inc_out) call netcdf_err(error, 'defining variable o3mr_inc for file='//trim(outfile) ) - + error = nf90_def_var(ncid_out, 'icmr_inc', nf90_float, (/dim_lon_out,dim_lat_out,dim_lev_out/), id_icmr_inc_out) call netcdf_err(error, 'defining variable icmr_inc for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, nf90_global, 'source', 'GSI') call netcdf_err(error, 'defining source attribute for file='//trim(outfile) ) - + error = nf90_put_att(ncid_out, nf90_global, 'comment', 'interpolated global analysis increment') call netcdf_err(error, 'defining comment attribute for file='//trim(outfile) ) - + error = nf90_enddef(ncid_out, header_buffer_val, 4,0,4) call netcdf_err(error, 'end meta define for file='//trim(outfile) ) end if !----------------------------------------------------------------- -! Compute latitude and longitude of output grid. +! Compute latitude and longitude of output grid. !----------------------------------------------------------------- allocate(latitude_out(lat_out)) @@ -336,13 +336,13 @@ program interp_inc if (mype == rec) then print*,'- PROCESS RECORD: ', trim(records(rec)) - + error = nf90_inq_varid(ncid_in, trim(records(rec)), id_var) call netcdf_err(error, 'inquiring ' // trim(records(rec)) // ' id for file='//trim(infile) ) error = nf90_get_var(ncid_in, id_var, dummy_in) call netcdf_err(error, 'reading ' // trim(records(rec)) // ' for file='//trim(infile) ) - - + + ip = 0 ! bilinear ipopt = 0 ibi = 0 @@ -354,7 +354,7 @@ program interp_inc lo = 0 go = 0.0_8 gi = reshape (dummy_in, (/mi, lev/)) - + if (trim(records(rec)) .eq. 'u_inc') then ! do u_inc,v_inc at the same time error = nf90_inq_varid(ncid_in, 'v_inc', id_var) @@ -414,7 +414,7 @@ program interp_inc error = nf90_put_var(ncid_out, id_var, dummy_out) call netcdf_err(error, 'writing v_inc for file='//trim(outfile) ) endif - endif + endif enddo ! records error = nf90_close(ncid_in) @@ -433,55 +433,55 @@ program interp_inc if (mype == 0) then print*,"- WRITE OUTPUT FILE: ", trim(outfile) - + ! lev - + allocate(levs(lev)) do j = 1, lev levs(j) = j enddo - + error = nf90_put_var(ncid_out, id_lev_out, levs) call netcdf_err(error, 'writing levs for file='//trim(outfile) ) - + ! pfull - + error = nf90_put_var(ncid_out, id_pfull_out, levs) call netcdf_err(error, 'writing pfull for file='//trim(outfile) ) - + deallocate (levs) allocate (levs(ilev)) do j = 1, ilev levs(j) = j enddo - + ! ilev - + error = nf90_put_var(ncid_out, id_ilev_out, levs) call netcdf_err(error, 'writing ilev for file='//trim(outfile) ) - + ! hyai - + error = nf90_put_var(ncid_out, id_hyai_out, levs) call netcdf_err(error, 'writing hyai for file='//trim(outfile) ) - + ! hybi - + error = nf90_put_var(ncid_out, id_hybi_out, levs) call netcdf_err(error, 'writing hybi for file='//trim(outfile) ) - + ! latitude - + error = nf90_put_var(ncid_out, id_lat_out, latitude_out) call netcdf_err(error, 'writing latitude for file='//trim(outfile) ) - + ! longitude - + error = nf90_put_var(ncid_out, id_lon_out, longitude_out) call netcdf_err(error, 'writing longitude for file='//trim(outfile) ) - + deallocate(levs) - + error = nf90_close(ncid_out) end if From 91fb0ac41e28acc18f9e5419f48a9977ec5193b0 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 3 Mar 2022 22:35:37 -0500 Subject: [PATCH 23/58] remove obsolete cmake/Modules directory --- cmake/Modules/FindBACIO.cmake | 55 - cmake/Modules/FindBUFR.cmake | 60 - cmake/Modules/FindBaselibs.cmake | 68 - cmake/Modules/FindCORELIBS.cmake | 287 ---- cmake/Modules/FindCRTM.cmake | 81 - cmake/Modules/FindGSICONTROL.cmake | 54 - cmake/Modules/FindHDF5.cmake | 24 - cmake/Modules/FindIP.cmake | 83 - cmake/Modules/FindMPI.cmake | 18 - cmake/Modules/FindNDATE.cmake | 13 - cmake/Modules/FindNEMSIO.cmake | 72 - cmake/Modules/FindSFCIO.cmake | 75 - cmake/Modules/FindSIGIO.cmake | 76 - cmake/Modules/FindSP.cmake | 83 - cmake/Modules/FindW3EMC.cmake | 124 -- cmake/Modules/FindW3NCO.cmake | 81 - cmake/Modules/FindWRF.cmake | 36 - .../NewCMake/CMakeParseArguments.cmake | 11 - cmake/Modules/NewCMake/FindHDF5.cmake | 934 ---------- cmake/Modules/NewCMake/FindMPI.cmake | 1514 ----------------- .../NewCMake/FindMPI/fortranparam_mpi.f90.in | 4 - cmake/Modules/NewCMake/FindMPI/libver_mpi.c | 19 - .../NewCMake/FindMPI/libver_mpi.f90.in | 7 - cmake/Modules/NewCMake/FindMPI/mpiver.f90.in | 10 - cmake/Modules/NewCMake/FindMPI/test_mpi.c | 37 - .../Modules/NewCMake/FindMPI/test_mpi.f90.in | 6 - .../FindPackageHandleStandardArgs.cmake | 386 ----- .../Modules/NewCMake/FindPackageMessage.cmake | 47 - .../SelectLibraryConfigurations.cmake | 70 - cmake/Modules/findHelpers.cmake | 173 -- cmake/Modules/platforms/Acorn.cmake | 13 - cmake/Modules/platforms/Cheyenne.cmake | 24 - cmake/Modules/platforms/Discover.cmake | 55 - cmake/Modules/platforms/Gaea.cmake | 14 - cmake/Modules/platforms/Generic.cmake | 25 - cmake/Modules/platforms/Hera.cmake | 42 - cmake/Modules/platforms/Jet.cmake | 42 - cmake/Modules/platforms/Orion.cmake | 42 - cmake/Modules/platforms/S4.cmake | 10 - cmake/Modules/platforms/WCOSS-C.cmake | 60 - cmake/Modules/platforms/WCOSS-D.cmake | 48 - cmake/Modules/platforms/WCOSS.cmake | 61 - cmake/Modules/setGNUFlags.cmake | 66 - cmake/Modules/setHOST.cmake | 105 -- cmake/Modules/setIntelFlags.cmake | 94 - cmake/Modules/setPGIFlags.cmake | 78 - cmake/Modules/setPlatformVariables.cmake | 12 - 47 files changed, 5299 deletions(-) delete mode 100644 cmake/Modules/FindBACIO.cmake delete mode 100644 cmake/Modules/FindBUFR.cmake delete mode 100644 cmake/Modules/FindBaselibs.cmake delete mode 100644 cmake/Modules/FindCORELIBS.cmake delete mode 100644 cmake/Modules/FindCRTM.cmake delete mode 100644 cmake/Modules/FindGSICONTROL.cmake delete mode 100644 cmake/Modules/FindHDF5.cmake delete mode 100644 cmake/Modules/FindIP.cmake delete mode 100644 cmake/Modules/FindMPI.cmake delete mode 100644 cmake/Modules/FindNDATE.cmake delete mode 100644 cmake/Modules/FindNEMSIO.cmake delete mode 100644 cmake/Modules/FindSFCIO.cmake delete mode 100644 cmake/Modules/FindSIGIO.cmake delete mode 100644 cmake/Modules/FindSP.cmake delete mode 100644 cmake/Modules/FindW3EMC.cmake delete mode 100644 cmake/Modules/FindW3NCO.cmake delete mode 100644 cmake/Modules/FindWRF.cmake delete mode 100644 cmake/Modules/NewCMake/CMakeParseArguments.cmake delete mode 100644 cmake/Modules/NewCMake/FindHDF5.cmake delete mode 100644 cmake/Modules/NewCMake/FindMPI.cmake delete mode 100644 cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.c delete mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/mpiver.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.c delete mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake delete mode 100644 cmake/Modules/NewCMake/FindPackageMessage.cmake delete mode 100644 cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake delete mode 100644 cmake/Modules/findHelpers.cmake delete mode 100644 cmake/Modules/platforms/Acorn.cmake delete mode 100644 cmake/Modules/platforms/Cheyenne.cmake delete mode 100644 cmake/Modules/platforms/Discover.cmake delete mode 100644 cmake/Modules/platforms/Gaea.cmake delete mode 100644 cmake/Modules/platforms/Generic.cmake delete mode 100644 cmake/Modules/platforms/Hera.cmake delete mode 100644 cmake/Modules/platforms/Jet.cmake delete mode 100644 cmake/Modules/platforms/Orion.cmake delete mode 100644 cmake/Modules/platforms/S4.cmake delete mode 100644 cmake/Modules/platforms/WCOSS-C.cmake delete mode 100644 cmake/Modules/platforms/WCOSS-D.cmake delete mode 100644 cmake/Modules/platforms/WCOSS.cmake delete mode 100644 cmake/Modules/setGNUFlags.cmake delete mode 100644 cmake/Modules/setHOST.cmake delete mode 100644 cmake/Modules/setIntelFlags.cmake delete mode 100644 cmake/Modules/setPGIFlags.cmake delete mode 100644 cmake/Modules/setPlatformVariables.cmake diff --git a/cmake/Modules/FindBACIO.cmake b/cmake/Modules/FindBACIO.cmake deleted file mode 100644 index 04410f631e..0000000000 --- a/cmake/Modules/FindBACIO.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{BACIO_VER}) - set(BACIO_VER $ENV{BACIO_VER}) - STRING(REGEX REPLACE "v" "" BACIO_VER ${BACIO_VER}) -endif() -if(NOT BUILD_BACIO ) - if(DEFINED ENV{BACIO_LIB4}) - set(BACIO_LIBRARY $ENV{BACIO_LIB4} ) - else() - find_library( BACIO_LIBRARY - NAMES libbacio.a libbacio_4.a libbacio_v${BACIO_VER}_4.a - HINTS $ENV{COREPATH}/lib /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/bacio/v${BACIO_VER} - ${COREPATH}/bacio/v${BACIO_VER}/intel - ${COREPATH}/bacio/v${BACIO_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH} - ) - message("Found BACIO library ${BACIO_LIBRARY}") - endif() -endif() -if( NOT BACIO_LIBRARY ) # didn't find the library, so build it from source - message("Could not find BACIO library, so building from libsrc") - if( DEFINED ENV{BACIO_SRC} ) - set( BACIO_DIR $ENV{BACIO_SRC} CACHE STRING "BACIO Source Directory" ) - else() - findSrc( "bacio" BACIO_VER BACIO_DIR ) - set(BACIOINC "${CMAKE_BINARY_DIR}/include") - endif() - set( libsuffix "_v${BACIO_VER}${debug_suffix}" ) - set( bacio "bacio${libsuffix}") - set( BUILD_BACIO "ON" CACHE INTERNAL "Build Bacio library" ) - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/bacio) - set( BACIO_LIBRARY ${bacio} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${BACIO_LIBRARY} ) - else() - set( CORE_BUILT ${BACIO_LIBRARY} ) - endif() -else( NOT BACIO_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${BACIO_LIBRARY} ) - else() - set( CORE_LIBRARIES ${BACIO_LIBRARY} ) - endif() -endif( NOT BACIO_LIBRARY ) - -set( BACIO_LIBRARY_PATH ${BACIO_LIBRARY} CACHE STRING "BACIO Library Location" ) - diff --git a/cmake/Modules/FindBUFR.cmake b/cmake/Modules/FindBUFR.cmake deleted file mode 100644 index a2d70b92bd..0000000000 --- a/cmake/Modules/FindBUFR.cmake +++ /dev/null @@ -1,60 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{BUFR_VER}) - set(BUFR_VER $ENV{BUFR_VER}) - STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_BUFR ) - if(DEFINED ENV{BUFR_LIBd_DA} ) - set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) - message("BUFR library ${BUFR_LIBRARY} set via Environment variable") - else() - find_library( BUFR_LIBRARY - NAMES libbufr.a libbufr_d_64.a libbufr_i4r8.a libbufr_v${BUFR_VER}_d_64.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/bufr/v${BUFR_VER} - ${COREPATH}/bufr/v${BUFR_VER}/intel - ${COREPATH}/bufr/v${BUFR_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( bufr "bufr_v${BUFR_VER}") - message("Found BUFR library ${BUFR_LIBRARY}") - endif() -endif() -if( NOT BUFR_LIBRARY ) # didn't find the library, so build it from source - message("Could not find BUFR library, so building from libsrc") - if( NOT DEFINED ENV{BUFR_SRC} ) - findSrc( "bufr" BUFR_VER BUFR_DIR ) - else() - set( BUFR_DIR "$ENV{BUFR_SRC}/libsrc" CACHE STRING "BUFR Source Location") - endif() - set( libsuffix "_v${BUFR_VER}${debug_suffix}" ) - set( BUFR_LIBRARY "${LIBRARY_OUTPUT_PATH}/libbufr${libsuffix}.a" CACHE STRING "BUFR Library" ) - set( bufr "bufr${libsuffix}") - set( BUILD_BUFR "ON" CACHE INTERNAL "Build the BUFR library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/bufr) - set( BUFR_LIBRARY ${bufr} ) - - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${BUFR_LIBRARY} ) - else() - set( CORE_BUILT ${BUFR_LIBRARY} ) - endif() -else( NOT BUFR_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${BUFR_LIBRARY} ) - else() - set( CORE_LIBRARIES ${BUFR_LIBRARY} ) - endif() -endif() -set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) - diff --git a/cmake/Modules/FindBaselibs.cmake b/cmake/Modules/FindBaselibs.cmake deleted file mode 100644 index 793cb9a5d4..0000000000 --- a/cmake/Modules/FindBaselibs.cmake +++ /dev/null @@ -1,68 +0,0 @@ -if (NOT BASEDIR) - if(${COMPILER_TYPE} STREQUAL "intel" ) - string(REGEX MATCH "mpt" MPT ${MPI_Fortran_INCLUDE_PATH}) - string(REGEX MATCH "impi" IMPI ${MPI_Fortran_INCLUDE_PATH}) - message("REGEX returns ${MPT} ") - if( MPT MATCHES "mpt" ) - message("setting mpt paths ") - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_15.0.2.164-mpt_2.14/Linux") - elseif( IMPI MATCHES "impi" ) - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_16.0.3.210-intelmpi_5.1.3.210/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() - if(${COMPILER_TYPE} STREQUAL "gnu" ) - string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) - message("REGEX returns ${OPENMPI} ") - if( OPENMPI MATCHES "openmpi" ) - message("setting openmpi paths ") - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-4_0_8/x86_64-unknown-linux-gnu/gfortran_7.2.0-openmpi_3.0.0/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() - if(${COMPILER_TYPE} STREQUAL "pgi" ) - string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) - if( OPENMPI MATCHES "openmpi" ) - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_1/x86_64-unknown-linux-gnu/pgfortran_16.5-openmpi_1.10.3/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() -endif () -if (ESMA_SDF) - message (FATAL_ERROR "ERROR: -hdf option was thought to be obsolete when CMake was crafted.") -endif () - -link_directories (${BASEDIR}/lib) - -#------------------------------------------------------------------ -# netcdf -# The following command provides the list of libraries that netcdf -# uses. Unfortunately it also includes the library path and "-l" -# prefixes, which CMake handles in a different manner. So we need so -# strip off that item from the list -execute_process ( - COMMAND ${BASEDIR}/bin/nf-config --flibs - OUTPUT_VARIABLE LIB_NETCDF - ) - -string(REGEX MATCHALL " -l[^ ]*" _full_libs "${LIB_NETCDF}") -set (NETCDF_LIBRARIES) -foreach (lib ${_full_libs}) - string (REPLACE "-l" "" _tmp ${lib}) - string (STRIP ${_tmp} _tmp) - list (APPEND NETCDF_LIBRARIES ${_tmp}) -endforeach() -#------------------------------------------------------------------ - -list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/netcdf) -list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/hdf5) - -message(STATUS "NETCDF_INCLUDES: ${NETCDF_INCLUDES}") -message(STATUS "NETCDF_LIBRARIES: ${NETCDF_LIBRARIES}") - diff --git a/cmake/Modules/FindCORELIBS.cmake b/cmake/Modules/FindCORELIBS.cmake deleted file mode 100644 index 9aab567113..0000000000 --- a/cmake/Modules/FindCORELIBS.cmake +++ /dev/null @@ -1,287 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{BUFR_VER}) - set(BUFR_VER $ENV{BUFR_VER}) - STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) -endif() -if(DEFINED ENV{NEMSIO_VER}) - set(NEMSIO_VER $ENV{NEMSIO_VER}) - STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) -endif() -if(DEFINED ENV{SFCIO_VER}) - set(SFCIO_VER $ENV{SFCIO_VER}) - STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) -endif() -if(DEFINED ENV{SIGIO_VER}) - set(SIGIO_VER $ENV{SIGIO_VER}) - STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) -endif() -if(DEFINED ENV{SP_VER}) - set(SP_VER $ENV{SP_VER}) - STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) -endif() -if(DEFINED ENV{W3EMC_VER}) - set(W3EMC_VER $ENV{W3EMC_VER}) - STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) -endif() -if(DEFINED ENV{W3NCO_VER}) - set(W3NCO_VER $ENV{W3NCO_VER}) - STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) -endif() - -set (CORE_DEPS " ") -set( NO_DEFAULT_PATH ) -if(NOT BUILD_EMC ) - if(DEFINED ENV{W3EMC_LIBd} ) - set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) - set(W3EMCINC $ENV{W3EMC_INCd} ) - else() - find_path( W3EMCINC - NAMES mersenne_twister.mod - HINTS - $ENV{COREPATH}/lib/incmod/w3emc_4 - $ENV{COREPATH}/include - /usr/local/jcsda/nwprod_gdas_2014/lib/lib/incmod/w3emc_4 - ${COREPATH}/w3emc/v${W3EMC_VER}/incmod/w3emc_v${W3EMC_VER}_d - ${COREPATH}/w3emc/v${W3EMC_VER}/intel/w3emc_v${W3EMC_VER}_d - ) - find_library( W3EMC_LIBRARY - NAMES libw3emc_4.a libw3emc_i4r8.a libw3emc_v${W3EMC_VER}_d.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/w3emc/v${W3EMC_VER} - ${COREPATH}/w3emc/v${W3EMC_VER}/intel - PATH_SUFFIXES - lib - ) - message("Found W3EMC library ${W3EMC_LIBRARY}") - endif() -else() - set( libsuffix "_v${W3EMC_VER}${debug_suffix}" ) - set( W3EMC_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3emc${libsuffix}.a" CACHE STRING "W3EMC Library" ) - set( w3emc "w3emc${libsuffix}") - if( DEFINED ENV{W3EMC_SRC} ) - set( W3EMC_DIR $ENV{W3EMC_SRC} CACHE STRING "W3EMC Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "w3emc" W3EMC_VER W3EMC_DIR ) - endif() - endif() -endif() -if(NOT BUILD_NCO ) - if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) - else() - find_library( W3NCO_LIBRARY - NAMES libw3nco_v${W3NCO_VER}_d.a libw3nco_d.a libw3nco_i4r8.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/w3nco/v${W3NCO_VER} - ${COREPATH}/w3nco/v${W3NCO_VER}/intel - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - message("Found W3NCO library ${W3NCO_LIBRARY}") - endif() -else() - if( DEFINED ENV{W3NCO_SRC} ) - set( W3NCO_DIR $ENV{W3NCO_SRC} CACHE STRING "W3NCO Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "w3nco" W3NCO_VER W3NCO_DIR ) - endif() - endif() - set( libsuffix "_v${W3NCO_VER}${debug_suffix}" ) - set( W3NCO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3nco${libsuffix}.a" CACHE STRING "W3NCO Library" ) - set( w3nco "w3nco${libsuffix}") -endif() -if(NOT BUILD_BUFR ) - if(DEFINED ENV{BUFR_LIBd_DA} ) - set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) - else() - find_library( BUFR_LIBRARY - NAMES libbufr.a libbufr_d_64.a libbufr_i4r8.a libbufr_v${BUFR_VER}_d_64.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/bufr/v${BUFR_VER} - ${COREPATH}/bufr/v${BUFR_VER}/intel - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( bufr "bufr_v${BUFR_VER}") - message("Found BUFR library ${BUFR_LIBRARY}") - endif() -else() - if( DEFINED ENV{BUFR_SRC} ) - set( BUFR_DIR $ENV{BUFR_SRC} CACHE STRING "BUFR Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "bufr" BUFR_VER BUFR_DIR ) - endif() - endif() - set( libsuffix "_v${BUFR_VER}${debug_suffix}" ) - set( BUFR_LIBRARY "${LIBRARY_OUTPUT_PATH}/libbufr${libsuffix}.a" CACHE STRING "BUFR Library" ) - set( bufr "bufr${libsuffix}") -endif() -if(NOT BUILD_SFCIO ) - if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) - set(SFCIOINC $ENV{SFCIO_INC4} ) - else() - findInc( sfcio SFCIO_VER SFCIOINC ) - find_library( SFCIO_LIBRARY - NAMES libsfcio.a libsfcio_4.a libsfcio_i4r4.a libsfcio_v${SFCIO_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sfcio/v${SFCIO_VER} - ${COREPATH}/sfcio/v${SFCIO_VER}/intel - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sfcio "sfcio_v${SFCIO_VER}_4") - message("Found SFCIO library ${SFCIO_LIBRARY}") - endif() -else() - if( DEFINED ENV{SFCIO_SRC} ) - set( SFCIO_DIR $ENV{SFCIO_SRC} CACHE STRING "SFCIO Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "sfcio" SFCIO_VER SFCIO_DIR ) - endif() - endif() - set( libsuffix "_v${SFCIO_VER}${debug_suffix}" ) - set( SFCIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsfcio${libsuffix}.a" CACHE STRING "SFCIO Library" ) - set( sfcio "sfcio${libsuffix}") -endif() -if(NOT BUILD_SIGIO ) - if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) - set(SIGIOINC $ENV{SIGIO_INC4} ) - else() - findInc( sigio SIGIO_VER SIGIOINC ) - message("SIGIOINC is ${SIGIOINC}") - find_library( SIGIO_LIBRARY - NAMES libsigio.a libsigio_4.a libsigio_i4r4.a libsigio_v${SIGIO_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sigio/v${SIGIO_VER} - ${COREPATH}/sigio/v${SIGIO_VER}/intel - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sigio "sigio_v${SIGIO_VER}_4") - message("Found SIGIO library ${SIGIO_LIBRARY}") - endif() -else() - if( DEFINED ENV{SIGIO_SRC} ) - set( SIGIO_DIR $ENV{SIGIO_SRC} CACHE STRING "SIGIO Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "sigio" SIGIO_VER SIGIO_DIR ) - endif() - endif() - set( libsuffix "_v${SIGIO_VER}${debug_suffix}" ) - set( SIGIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsigio${libsuffix}.a" CACHE STRING "SIGIO Library" ) - set( sigio "sigio${libsuffix}") - set( CORE_DEPS "${CORE_DEPS} ${baseName}" ) -endif() -if(NOT BUILD_NEMSIO ) - if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) - set(NEMSIOINC $ENV{NEMSIO_INC} ) - else() - findInc( nemsio NEMSIO_VER NEMSIOINC ) - find_library( NEMSIO_LIBRARY - NAMES libnemsio.a libnemsio_v${NEMSIO_VER}.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/nemsio/v${NEMSIO_VER} - ${COREPATH}/nemsio/v${NEMSIO_VER}/intel - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( nemsio "nemsio_v${NEMSIO_VER}") - message("Found NEMSIO library ${NEMSIO_LIBRARY}") - endif() -else() - if( DEFINED ENV{NEMSIO_SRC} ) - set( NEMSIO_DIR $ENV{NEMSIO_SRC} CACHE STRING "NEMSIO Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "nemsio" NEMSIO_VER NEMSIO_DIR ) - endif() - endif() - set( libsuffix "_v${NEMSIO_VER}${debug_suffix}" ) - set( NEMSIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libnemsio${libsuffix}.a" CACHE STRING "NEMSIO Library" ) - set( nemsio "nemsio${libsuffix}") -endif() -if(NOT BUILD_SP ) - if(DEFINED ENV{SP_LIBd} ) - set(SP_LIBRARY $ENV{SP_LIBd} ) - else() - find_library( SP_LIBRARY - NAMES libsp_d.a libsp_i4r8.a libsp_v${SP_VER}_d.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sp/v${SP_VER} - ${COREPATH}/sp/v${SP_VER}/intel - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sp "sp_v${SP_VER}_d") - message("Found SP library ${SP_LIBRARY}") - endif() -else() - if( DEFINED ENV{SP_SRC} ) - set( SP_DIR $ENV{SP_SRC} CACHE STRING "SP Source Directory" ) - else() - if( FIND_SRC ) - findSrc( "sp" SP_VER SP_DIR ) - endif() - endif() - set( libsuffix "_v${SP_VER}${debug_suffix}" ) - set( SP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp${libsuffix}.a" CACHE STRING "SP Library" ) - set( sp "sp${libsuffix}") -endif() - -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} - ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} - ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) - list( APPEND CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) -else() - set( CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} - ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} - ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) -endif() - -set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) - -set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) -set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) - -set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) -set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) - -set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) - -set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) -set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) - -set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) -set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) - -set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) - diff --git a/cmake/Modules/FindCRTM.cmake b/cmake/Modules/FindCRTM.cmake deleted file mode 100644 index ee982c1499..0000000000 --- a/cmake/Modules/FindCRTM.cmake +++ /dev/null @@ -1,81 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{CRTM_VER}) - set(CRTM_VER $ENV{CRTM_VER}) - STRING(REGEX REPLACE "v" "" CRTM_VER ${CRTM_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_CRTM ) - if(DEFINED ENV{CRTM_LIB} ) - set(CRTM_LIBRARY $ENV{CRTM_LIB} ) - set(CRTMINC $ENV{CRTM_INC} ) - message("CRTM library ${CRTM_LIBRARY} set via Environment variable") - else() - findInc( crtm CRTM_VER CRTMINC ) - find_library( CRTM_LIBRARY - NAMES libcrtm_v${CRTM_VER}.a libcrtm.a libCRTM.a - HINTS - /usr/local/jcsda/nwprod_gdas_2014/lib - ${CRTM_BASE} - ${CRTM_BASE}/lib - ${CRTM_BASE}/${CRTM_VER} - ${CRTM_BASE}/${CRTM_VER}/lib - ${CRTM_BASE}/v${CRTM_VER}/intel - ${CRTM_BASE}/v${CRTM_VER}/ips/${COMPILER_VERSION} - ${COREPATH}/v${CRTM_VER}/ips/${COMPILER_VERSION} - ${COREPATH} - ${COREPATH}/lib - $ENV{COREPATH} - $ENV{COREPATH}/lib - $ENV{COREPATH}/include - ${CORECRTM}/crtm/${CRTM_VER} - /nwprod2/lib/crtm/v${CRTM_VER} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( crtm "crtm_v${CRTM_VER}") - message("Found CRTM library ${CRTM_LIBRARY}") - endif() -endif() -if( NOT CRTM_LIBRARY ) # didn't find the library, so build it from source - message("Could not find CRTM library, so building from libsrc") - if( NOT DEFINED ENV{CRTM_SRC} ) - findSrc( "crtm" CRTM_VER CRTM_DIR ) - set(CRTMINC "${CMAKE_BINARY_DIR}/include") - else() - set( CRTM_DIR "$ENV{CRTM_SRC}/libsrc" CACHE STRING "CRTM Source Location") - set(CRTMINC "${CORECRTM}/crtm/${CRTM_VER}/incmod/crtm_v${CRTM_VER}") - endif() - set( libsuffix "_v${CRTM_VER}${debug_suffix}" ) - set( CRTM_LIBRARY "${LIBRARY_OUTPUT_PATH}/libcrtm${libsuffix}.a" CACHE STRING "CRTM Library" ) - set( crtm "crtm${libsuffix}") - set( BUILD_CRTM "ON" CACHE INTERNAL "Build the CRTM library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/crtm) - set( CRTM_LIBRARY ${crtm} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${CRTM_LIBRARY} ) - else() - set( CORE_BUILT ${CRTM_LIBRARY} ) - endif() -else( NOT CRTM_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${CRTM_LIBRARY} ) - else() - set( CORE_LIBRARIES ${CRTM_LIBRARY} ) - endif() -endif( NOT CRTM_LIBRARY ) - -if( CORE_INCS ) - list( APPEND CORE_INCS ${CRTMINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${CRTMINC} ) -endif() - -set( CRTM_LIBRARY_PATH ${CRTM_LIBRARY} CACHE STRING "CRTM Library Location" ) -set( CRTM_INCLUDE_PATH ${CRTMINC} CACHE STRING "CRTM Include Location" ) - diff --git a/cmake/Modules/FindGSICONTROL.cmake b/cmake/Modules/FindGSICONTROL.cmake deleted file mode 100644 index 3e4bd7d7dc..0000000000 --- a/cmake/Modules/FindGSICONTROL.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# - Find the Control version of GSI to use for regression testing - -set( NO_DEFAULT_PATH ) -message("Control path is ${CONTROLPATH}") -find_file( CONTROL_EXE - NAMES gsi.x global_gsi ${GSIEXEC} - HINTS - ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - $ENV{CONTROLPATH} - $ENV{CONTROLPATH}/bin - $ENV{CONTROLPATH}/exec - $ENV{CONTROLPATH}/src - ${CMAKE_SOURCE_DIR}/../trunk/src - ${CMAKE_SOURCE_DIR}/../../trunk/src - ${PROJECT_BINARY_DIR}/../build-trunk/bin - /da/save/Michael.Lueken/svn1/build/bin - /da/save/Michael.Lueken/svn1/src - /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src - /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin - /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec - - ${NO_DEFAULT_PATH}) - -set( GSICONTROL ${CONTROL_EXE} CACHE STRING "GSI control executable for regression testing" FORCE ) - -find_file( ENKF_CONTROL_EXE - NAMES enkf_gfs.x global_enkf ${ENKFEXEC} - HINTS - ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - $ENV{CONTROLPATH} - $ENV{CONTROLPATH}/bin - $ENV{CONTROLPATH}/exec - ${CMAKE_SOURCE_DIR}/../trunk/src/enkf - ${PROJECT_BINARY_DIR}/../build-trunk/bin - $ENV{CONTROLPATH}/enkf - $ENV{CONTROLPATH}/src/enkf - /da/save/Michael.Lueken/svn1/build/bin - /da/save/Michael.Lueken/svn1/src/enkf - /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src/enkf - /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin - /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec - - ${NO_DEFAULT_PATH}) - -set( ENKFCONTROL ${ENKF_CONTROL_EXE} CACHE STRING "ENKF control executable for regression testing" FORCE ) - diff --git a/cmake/Modules/FindHDF5.cmake b/cmake/Modules/FindHDF5.cmake deleted file mode 100644 index 78e3db3678..0000000000 --- a/cmake/Modules/FindHDF5.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# This extends CMake's FindHDF5.cmake to add support to include MPI include -# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON -# (BUG #0014363). - -# include the default FindHDF5.cmake. -#if(CMAKE_VERSION VERSION_LESS 3.6.1) -if(CMAKE_VERSION VERSION_GREATER 3.0 ) - include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindHDF5.cmake) -else() - include(${CMAKE_ROOT}/Modules/FindHDF5.cmake) -endif() -#endif() - -if(HDF5_FOUND AND (HDF5_IS_PARALLEL OR HDF5_ENABLE_PARALLEL)) - if(MPI_C_INCLUDE_PATH) - list(APPEND HDF5_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH}) - endif() - if(MPI_C_LIBRARIES) - list(APPEND HDF5_LIBRARIES ${MPI_C_LIBRARIES}) - endif() - if(MPI_CXX_LIBRARIES) - list(APPEND HDF5_LIBRARIES ${MPI_CXX_LIBRARIES}) - endif() -endif() diff --git a/cmake/Modules/FindIP.cmake b/cmake/Modules/FindIP.cmake deleted file mode 100644 index 26ec21704e..0000000000 --- a/cmake/Modules/FindIP.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{IP_VER}) - set(IP_VER $ENV{IP_VER}) - STRING(REGEX REPLACE "v" "" IP_VER ${IP_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_IP ) - if(DEFINED ENV{IP_LIBd} ) - set(IP_LIBRARY $ENV{IP_LIBd} ) - message("IP library ${IP_LIBRARY} set via Environment variable") - else() - find_library( IP_LIBRARY - NAMES libip_d.a libip_i4r8.a libip_v${IP_VER}_d.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/ip/v${IP_VER} - ${COREPATH}/ip/v${IP_VER}/intel - ${COREPATH}/ip/v${IP_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( ip "ip_v${IP_VER}_d") - message("Found IP library ${IP_LIBRARY}") - endif() - if(DEFINED ENV{IP_LIB4} ) - set(IP_4_LIBRARY $ENV{IP_LIB4} ) - message("IP 4 library ${IP_4_LIBRARY} set via Environment variable") - else() - find_library( IP_4_LIBRARY - NAMES libip_4.a libip_i4r4.a libip_v${IP_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/ip/v${IP_VER} - ${COREPATH}/ip/v${IP_VER}/intel - ${COREPATH}/ip/v${IP_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( ip "ip_v${IP_VER}_4") - message("Found IP_4 library ${IP_4_LIBRARY}") - endif() -endif() -if( NOT IP_LIBRARY ) # didn't find the library, so build it from source - message("Could not find IP library, so building from libsrc") - if( NOT DEFINED ENV{IP_SRC} ) - findSrc( "ip" IP_VER IP_DIR ) - else() - set( IP_DIR "$ENV{IP_SRC}/libsrc" CACHE STRING "IP Source Location") - endif() - set( libsuffix "_v${IP_VER}${debug_suffix}" ) - set( IP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libip${libsuffix}.a" CACHE STRING "IP Library" ) - set( IP_4_LIBRARY "${LIBRARY_OUTPUT_PATH}/libip_4${libsuffix}.a" CACHE STRING "IP_4 Library" ) - set( ip "ip${libsuffix}") - set( ip4 "ip_4${libsuffix}") - set( BUILD_IP "ON" CACHE INTERNAL "Build the IP library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/ip) - set( IP_LIBRARY ${ip} ) - set( IP_4_LIBRARY ${ip4} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${IP_LIBRARY} ) - else() - set( CORE_BUILT ${IP_LIBRARY} ) - endif() -else( NOT IP_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${IP_LIBRARY} ) - else() - set( CORE_LIBRARIES ${IP_LIBRARY} ) - endif() -endif( NOT IP_LIBRARY ) - - -set( IP_LIBRARY_PATH ${IP_LIBRARY} CACHE STRING "IP Library Location" ) -set( IP_4_LIBRARY_PATH ${IP_4_LIBRARY} CACHE STRING "IP_4 Library Location" ) - diff --git a/cmake/Modules/FindMPI.cmake b/cmake/Modules/FindMPI.cmake deleted file mode 100644 index 8e0a0c95ba..0000000000 --- a/cmake/Modules/FindMPI.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# This extends CMake's FindHDF5.cmake to add support to include MPI include -# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON -# (BUG #0014363). - -# include the default FindMPI.cmake. -if(CMAKE_VERSION VERSION_LESS 3.1) - include(${CMAKE_ROOT}/Modules/FindMPI.cmake) -elseif(CMAKE_VERSION VERSION_LESS 3.6) - message("Using new FindMPI") - include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindMPI.cmake) -# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") -else() - message("Using installed FindMPI") - include(${CMAKE_ROOT}/Modules/FindMPI.cmake) -# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") - message("include dirs are ${MPI_Fortran_INCLUDE_DIRS}") - message("include PATH ${MPI_Fortran_INCLUDE_PATH}") -endif() diff --git a/cmake/Modules/FindNDATE.cmake b/cmake/Modules/FindNDATE.cmake deleted file mode 100644 index 44bf4f1cd5..0000000000 --- a/cmake/Modules/FindNDATE.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# - Find the NDATE utility or build it - -set( NO_DEFAULT_PATH ) -if(DEFINED ENV{NDATE}) - set(NDATE $ENV{NDATE} ) -else() - find_file( NDATE - NAMES ndate.x ndate - HINTS - /nwprod/util/exec - $ENV{NWPROD}/util/exec - ${NO_DEFAULT_PATH}) -endif() diff --git a/cmake/Modules/FindNEMSIO.cmake b/cmake/Modules/FindNEMSIO.cmake deleted file mode 100644 index 1263fc516a..0000000000 --- a/cmake/Modules/FindNEMSIO.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{NEMSIO_VER}) - set(NEMSIO_VER $ENV{NEMSIO_VER}) - STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_NEMSIO ) - if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) - set(NEMSIOINC $ENV{NEMSIO_INC} ) - message("NEMSIO library ${NEMSIO_LIBRARY} set via Environment variable") - else() - findInc( nemsio NEMSIO_VER NEMSIOINC ) - find_library( NEMSIO_LIBRARY - NAMES libnemsio_v${NEMSIO_VER}.a libnemsio.a libNEMSIO.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/nemsio/v${NEMSIO_VER} - ${COREPATH}/nemsio/v${NEMSIO_VER}/intel - ${COREPATH}/nemsio/v${NEMSIO_VER}//ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION} - ${COREPATH}/nemsio/v${NEMSIO_VER}//ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( nemsio "nemsio_v${NEMSIO_VER}") - message("Found NEMSIO library ${NEMSIO_LIBRARY}") - endif() -endif() -if( NOT NEMSIO_LIBRARY ) # didn't find the library, so build it from source - message("Could not find NEMSIO library, so building from libsrc") - if( NOT DEFINED ENV{NEMSIO_SRC} ) - findSrc( "nemsio" NEMSIO_VER NEMSIO_DIR ) - set(NEMSIOINC "${CMAKE_BINARY_DIR}/include") - else() - set( NEMSIO_DIR "$ENV{NEMSIO_SRC}/libsrc" CACHE STRING "NEMSIO Source Location") - set(NEMSIOINC "${CORENEMSIO}/nemsio/${NEMSIO_VER}/incmod/nemsio_v${NEMSIO_VER}") - endif() - set( libsuffix "_v${NEMSIO_VER}${debug_suffix}" ) - set( NEMSIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libnemsio${libsuffix}.a" CACHE STRING "NEMSIO Library" ) - set( nemsio "nemsio${libsuffix}") - set( BUILD_NEMSIO "ON" CACHE INTERNAL "Build the NEMSIO library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/nemsio) - set( NEMSIO_LIBRARY ${nemsio} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${NEMSIO_LIBRARY} ) - else() - set( CORE_BUILT ${NEMSIO_LIBRARY} ) - endif() -else( NOT NEMSIO_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${NEMSIO_LIBRARY} ) - else() - set( CORE_LIBRARIES ${NEMSIO_LIBRARY} ) - endif() -endif( NOT NEMSIO_LIBRARY ) - -if( CORE_INCS ) - list( APPEND CORE_INCS ${NEMSIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${NEMSIOINC} ) -endif() - -set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) -set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) - diff --git a/cmake/Modules/FindSFCIO.cmake b/cmake/Modules/FindSFCIO.cmake deleted file mode 100644 index 09d4366d66..0000000000 --- a/cmake/Modules/FindSFCIO.cmake +++ /dev/null @@ -1,75 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{SFCIO_VER}) - set(SFCIO_VER $ENV{SFCIO_VER}) - STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SFCIO ) - if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) - set(SFCIOINC $ENV{SFCIO_INC4} ) - message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") - elseif(DEFINED ENV{SFCIO_LIB} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB} ) - set(SFCIOINC $ENV{SFCIO_INC} ) - message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") - else() - findInc( sfcio SFCIO_VER SFCIOINC ) - find_library( SFCIO_LIBRARY - NAMES libsfcio.a libsfcio_4.a libsfcio_i4r4.a libsfcio_v${SFCIO_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sfcio/v${SFCIO_VER} - ${COREPATH}/sfcio/v${SFCIO_VER}/intel - ${COREPATH}/sfcio/v${SFCIO_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sfcio "sfcio_v${SFCIO_VER}") - message("Found SFCIO library ${SFCIO_LIBRARY}") - endif() -endif() -if( NOT SFCIO_LIBRARY ) # didn't find the library, so build it from source - message("Could not find SFCIO library, so building from libsrc") - if( NOT DEFINED ENV{SFCIO_SRC} ) - findSrc( "sfcio" SFCIO_VER SFCIO_DIR ) - set(SFCIOINC "${CMAKE_BINARY_DIR}/include") - else() - set( SFCIO_DIR "$ENV{SFCIO_SRC}/libsrc" CACHE STRING "SFCIO Source Location") - set(SFCIOINC "${CORESFCIO}/sfcio/${SFCIO_VER}/incmod/sfcio_v${SFCIO_VER}") - endif() - set( libsuffix "_v${SFCIO_VER}${debug_suffix}" ) - set( SFCIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsfcio${libsuffix}.a" CACHE STRING "SFCIO Library" ) - set( sfcio "sfcio${libsuffix}") - set( BUILD_SFCIO "ON" CACHE INTERNAL "Build the SFCIO library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/sfcio) - set( SFCIO_LIBRARY ${sfcio} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${SFCIO_LIBRARY} ) - else() - set( CORE_BUILT ${SFCIO_LIBRARY} ) - endif() -else( NOT SFCIO_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ) - else() - set( CORE_LIBRARIES ${SFCIO_LIBRARY} ) - endif() -endif( NOT SFCIO_LIBRARY ) - -if( CORE_INCS ) - list( APPEND CORE_INCS ${SFCIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ) -endif() - -set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) -set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) - diff --git a/cmake/Modules/FindSIGIO.cmake b/cmake/Modules/FindSIGIO.cmake deleted file mode 100644 index d504f53a81..0000000000 --- a/cmake/Modules/FindSIGIO.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{SIGIO_VER}) - set(SIGIO_VER $ENV{SIGIO_VER}) - STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SIGIO ) - if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) - set(SIGIOINC $ENV{SIGIO_INC4} ) - message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") - elseif(DEFINED ENV{SIGIO_LIB} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB} ) - set(SIGIOINC $ENV{SIGIO_INC} ) - message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") - else() - findInc( sigio SIGIO_VER SIGIOINC ) - find_library( SIGIO_LIBRARY - NAMES libsigio.a libsigio_4.a libsigio_i4r4.a libsigio_v${SIGIO_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sigio/v${SIGIO_VER} - ${COREPATH}/sigio/v${SIGIO_VER}/intel - ${COREPATH}/sigio/v${SIGIO_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sigio "sigio_v${SIGIO_VER}") - message("Found SIGIO library ${SIGIO_LIBRARY}") - endif() -endif() -if( NOT SIGIO_LIBRARY ) # didn't find the library, so build it from source - message("Could not find SIGIO library, so building from libsrc") - if( NOT DEFINED ENV{SIGIO_SRC} ) - findSrc( "sigio" SIGIO_VER SIGIO_DIR ) - set(SIGIOINC "${CMAKE_BINARY_DIR}/include") - else() - set( SIGIO_DIR "$ENV{SIGIO_SRC}/libsrc" CACHE STRING "SIGIO Source Location") - set(SIGIOINC "${CORESIGIO}/sigio/${SIGIO_VER}/incmod/sigio_v${SIGIO_VER}") - endif() - set( libsuffix "_v${SIGIO_VER}${debug_suffix}" ) - set( SIGIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsigio${libsuffix}.a" CACHE STRING "SIGIO Library" ) - set( sigio "sigio${libsuffix}") - set( BUILD_SIGIO "ON" CACHE INTERNAL "Build the SIGIO library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/sigio) - set( SIGIO_LIBRARY ${sigio} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${SIGIO_LIBRARY} ) - else() - set( CORE_BUILT ${SIGIO_LIBRARY} ) - endif() -else( NOT SIGIO_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SIGIO_LIBRARY} ) - else() - set( CORE_LIBRARIES ${SIGIO_LIBRARY} ) - endif() -endif( NOT SIGIO_LIBRARY ) - -if( CORE_INCS ) - list( APPEND CORE_INCS ${SIGIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SIGIOINC} ) -endif() - - -set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) -set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) - diff --git a/cmake/Modules/FindSP.cmake b/cmake/Modules/FindSP.cmake deleted file mode 100644 index b5fba97341..0000000000 --- a/cmake/Modules/FindSP.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{SP_VER}) - set(SP_VER $ENV{SP_VER}) - STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SP ) - if(DEFINED ENV{SP_LIBd} ) - set(SP_LIBRARY $ENV{SP_LIBd} ) - message("SP library ${SP_LIBRARY} set via Environment variable") - else() - find_library( SP_LIBRARY - NAMES libsp_d.a libsp_i4r8.a libsp_v${SP_VER}_d.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sp/v${SP_VER} - ${COREPATH}/sp/v${SP_VER}/intel - ${COREPATH}/sp/v${SP_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sp "sp_v${SP_VER}_d") - message("Found SP library ${SP_LIBRARY}") - endif() - if(DEFINED ENV{SP_LIB4} ) - set(SP_4_LIBRARY $ENV{SP_LIB4} ) - message("SP library ${SP_4_LIBRARY} set via Environment variable") - else() - find_library( SP_4_LIBRARY - NAMES libsp_4.a libsp_i4r4.a libsp_v${SP_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/sp/v${SP_VER} - ${COREPATH}/sp/v${SP_VER}/intel - ${COREPATH}/sp/v${SP_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - set( sp "sp_v${SP_VER}_4") - message("Found SP_4 library ${SP_4_LIBRARY}") - endif() -endif() -if( NOT SP_LIBRARY ) # didn't find the library, so build it from source - message("Could not find SP library, so building from libsrc") - if( NOT DEFINED ENV{SP_SRC} ) - findSrc( "sp" SP_VER SP_DIR ) - else() - set( SP_DIR "$ENV{SP_SRC}/libsrc" CACHE STRING "SP Source Location") - endif() - set( libsuffix "_v${SP_VER}${debug_suffix}" ) - set( SP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp${libsuffix}.a" CACHE STRING "SP Library" ) - set( SP_4_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp_4${libsuffix}.a" CACHE STRING "SP_4 Library" ) - set( sp "sp${libsuffix}") - set( sp4 "sp_4${libsuffix}") - set( BUILD_SP "ON" CACHE INTERNAL "Build the SP library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/sp) - set( SP_LIBRARY ${sp} ) - set( SP_4_LIBRARY ${sp4} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${SP_LIBRARY} ) - else() - set( CORE_BUILT ${SP_LIBRARY} ) - endif() -else( NOT SP_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SP_LIBRARY} ) - else() - set( CORE_LIBRARIES ${SP_LIBRARY} ) - endif() -endif( NOT SP_LIBRARY ) - - -set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) -set( SP_4_LIBRARY_PATH ${SP_4_LIBRARY} CACHE STRING "SP_4 Library Location" ) - diff --git a/cmake/Modules/FindW3EMC.cmake b/cmake/Modules/FindW3EMC.cmake deleted file mode 100644 index 3cbce42a6d..0000000000 --- a/cmake/Modules/FindW3EMC.cmake +++ /dev/null @@ -1,124 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{W3EMC_VER}) - set(W3EMC_VER $ENV{W3EMC_VER}) - set(W3EMCINC $ENV{W3EMC_INCd} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) -endif() -if(DEFINED ENV{W3EMC_LIBd}) - set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) - set(W3EMCINC $ENV{W3EMC_INCd} ) - set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - message("Setting W3EMC library via environment variable ${W3EMC_LIBRARY}") -endif() - -set( NO_DEFAULT_PATH ) -if((NOT BUILD_W3EMC ) AND ( NOT DEFINED W3EMC_LIBRARY )) - if(DEFINED ENV{W3EMC_LIB} ) - set(W3EMC_LIBRARY $ENV{W3EMC_LIB} ) - set(W3EMCINC $ENV{W3EMC_INC} ) - set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - message("W3EMC library ${W3EMC_LIBRARY} set via Environment variable") - message("W3EMC_4 library ${W3EMC_4_LIBRARY} set via Environment variable") - else() - find_path( W3EMCINC - NAMES mersenne_twister.mod - HINTS - $ENV{COREPATH}/lib/incmod/w3emc_d - $ENV{COREPATH}/include - /usr/local/jcsda/nwprod_gdas_2014/lib/incmod/w3emc_d - ${COREPATH}/w3emc/v${W3EMC_VER}/incmod/w3emc_v${W3EMC_VER}_d - ${COREPATH}/w3emc/v${W3EMC_VER}/intel/w3emc_v${W3EMC_VER}_d - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_d - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_d - ) - find_path( W3EMC4INC - NAMES mersenne_twister.mod - HINTS - $ENV{COREPATH}/lib/incmod/w3emc_4 - $ENV{COREPATH}/include - /usr/local/jcsda/nwprod_gdas_2014/lib/incmod/w3emc_4 - ${COREPATH}/w3emc/v${W3EMC_VER}/incmod/w3emc_v${W3EMC_VER}_4 - ${COREPATH}/w3emc/v${W3EMC_VER}/intel/w3emc_v${W3EMC_VER}_4 - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_4 - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_4 - ) - find_library( W3EMC_LIBRARY - NAMES libw3emc_d.a libw3emc_v${W3EMC_VER}_d.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014 - ${COREPATH}/w3emc/v${W3EMC_VER} - ${COREPATH}/w3emc/v${W3EMC_VER}/intel - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION} - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - find_library( W3EMC_4_LIBRARY - NAMES libw3emc_4.a libw3emc_i4r4.a libw3emc_v${W3EMC_VER}_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014 - ${COREPATH}/w3emc/v${W3EMC_VER} - ${COREPATH}/w3emc/v${W3EMC_VER}/intel - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION} - ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - message("Found W3EMC_4 library ${W3EMC_4_LIBRARY}") - endif() -endif() -if( NOT W3EMC_LIBRARY ) # didn't find the library, so build it from source - message("Could not find W3EMC library, so building from libsrc") - if( NOT DEFINED ENV{W3EMC_SRC} ) - findSrc( "w3emc" W3EMC_VER W3EMC_DIR ) - set(W3EMCINC "${CMAKE_BINARY_DIR}/include" CACHE STRING "W3EMC Include Directory") - set(W3EMC4INC "${CMAKE_BINARY_DIR}/include" CACHE STRING "W3EMC4 Include Directory") - else() - set( W3EMC_DIR "$ENV{W3EMC_SRC}/libsrc" CACHE STRING "W3EMC Source Location") - endif() - set( libsuffix "_v${W3EMC_VER}${debug_suffix}" ) - set( W3EMC_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3emc${libsuffix}.a" CACHE STRING "W3EMC Library" ) - set( w3emc "w3emc${libsuffix}") - set( w3emc4 "w3emc_4${libsuffix}") - set( BUILD_W3EMC "ON" CACHE INTERNAL "Build the W3EMC library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/w3emc) - set( W3EMC_LIBRARY ${w3emc} ) - set( W3EMC_4_LIBRARY ${w3emc} ) - set(W3EMCINC "${CMAKE_BINARY_DIR}/include" CACHE STRING "W3EMC Include Directory") - set(W3EMC4INC ${CMAKE_INCLUDE_4_OUTPUT_DIRECTORY} CACHE STRING "W3EMC4 Include Directory") - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${W3EMC_LIBRARY} ) - list( APPEND CORE_BUILT ${W3EMC_4_LIBRARY} ) - else() - set( CORE_BUILT ${W3EMC_LIBRARY} ) - set( CORE_BUILT ${W3EMC_4_LIBRARY} ) - endif() -else( NOT W3EMC_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${W3EMC_LIBRARY} ) - else() - set( CORE_LIBRARIES ${W3EMC_LIBRARY} ) - endif() -endif( NOT W3EMC_LIBRARY ) - -if( CORE_INCS ) - list( APPEND CORE_INCS ${W3EMCINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${W3EMCINC} ) -endif() - -set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) -set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) -set( W3EMC_4_LIBRARY_PATH ${W3EMC_4_LIBRARY} CACHE STRING "W3EMC_4 Library Location" ) -set( W3EMC_INCLUDE_4_PATH ${W3EMC4INC} CACHE STRING "W3EMC_4 Include Location" ) - diff --git a/cmake/Modules/FindW3NCO.cmake b/cmake/Modules/FindW3NCO.cmake deleted file mode 100644 index aef2126c8f..0000000000 --- a/cmake/Modules/FindW3NCO.cmake +++ /dev/null @@ -1,81 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -include(findHelpers) -if(DEFINED ENV{W3NCO_VER}) - set(W3NCO_VER $ENV{W3NCO_VER}) - STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_W3NCO ) - if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) - set(W3NCO_4_LIBRARY $ENV{W3NCO_LIB4} ) - message("W3NCO library ${W3NCO_LIBRARY} set via Environment variable") - message("W3NCO_4 library ${W3NCO_4_LIBRARY} set via Environment variable") - else() - find_library( W3NCO_LIBRARY - NAMES libw3nco_v${W3NCO_VER}_d.a libw3nco_d.a libw3nco_i4r8.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/w3nco/v${W3NCO_VER} - ${COREPATH}/w3nco/v${W3NCO_VER}/intel - ${COREPATH}/w3nco/v${W3NCO_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - message("Found W3NCO library ${W3NCO_LIBRARY}") - set( w3nco ${W3NCO_LIBRARY}) - - find_library( W3NCO_4_LIBRARY - NAMES libw3nco_v${W3NCO_VER}_4.a libw3nco_4.a - HINTS - $ENV{COREPATH}/lib - /usr/local/jcsda/nwprod_gdas_2014/lib - ${COREPATH}/w3nco/v${W3NCO_VER} - ${COREPATH}/w3nco/v${W3NCO_VER}/intel - ${COREPATH}/w3nco/v${W3NCO_VER}/ips/${COMPILER_VERSION} - PATH_SUFFIXES - lib - ${NO_DEFAULT_PATH}) - message("Found W3NCO_4 library ${W3NCO_4_LIBRARY}") - set( w3nco4 ${W3NCO_4_LIBRARY}) - endif() -endif() -if( NOT W3NCO_LIBRARY ) # didn't find the library, so build it from source - message("Could not find W3NCO library, so building from libsrc") - if( NOT DEFINED ENV{W3NCO_SRC} ) - findSrc( "w3nco" W3NCO_VER W3NCO_DIR ) - else() - set( W3NCO_DIR "$ENV{W3NCO_SRC}/libsrc" CACHE STRING "W3NCO Source Location") - endif() - set( libsuffix "_v${W3NCO_VER}${debug_suffix}" ) - set( W3NCO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3nco${libsuffix}.a" CACHE STRING "W3NCO Library" ) - set( w3nco "w3nco${libsuffix}") - set( w3nco4 "w3nco_4${libsuffix}") - set( BUILD_W3NCO "ON" CACHE INTERNAL "Build the W3NCO library") - add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/w3nco) - set( W3NCO_LIBRARY ${w3nco} ) - set( W3NCO_4_LIBRARY ${w3nco4} ) - if( CORE_BUILT ) - list( APPEND CORE_BUILT ${W3NCO_LIBRARY} ) - list( APPEND CORE_BUILT ${W3NCO_4_LIBRARY} ) - else() - set( CORE_BUILT ${W3NCO_LIBRARY} ) - set( CORE_BUILT ${W3NCO_4_LIBRARY} ) - endif() -else( NOT W3NCO_LIBRARY ) - if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${W3NCO_LIBRARY} ) - else() - set( CORE_LIBRARIES ${W3NCO_LIBRARY} ) - endif() -endif( NOT W3NCO_LIBRARY ) - -set( W3NCO_DIR ${CMAKE_SOURCE_DIR}/libsrc/w3nco CACHE STRING "W3NCO Source Location") -set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) - diff --git a/cmake/Modules/FindWRF.cmake b/cmake/Modules/FindWRF.cmake deleted file mode 100644 index 43faf46643..0000000000 --- a/cmake/Modules/FindWRF.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# - Find the WRF modules - -set( NO_DEFAULT_PATH ) -find_library( IOINT_LIB - NAMES libwrfio_int.a - HINTS - ${WRFPATH}/external/io_int - $ENV{WRFPATH}/external/io_int - /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_int - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_int - ${NO_DEFAULT_PATH}) - -find_library( WRFNETCDF_LIB - NAMES libwrfio_nf.a - HINTS - ${WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf - $ENV{WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_netcdf - ${NO_DEFAULT_PATH}) -find_file( FRAMEPACK - NAMES pack_utils.o - HINTS - ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame - ${NO_DEFAULT_PATH}) -find_file( FRAMEMODULE - NAMES module_machine.o - HINTS - ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame - ${NO_DEFAULT_PATH}) - -set( WRF_LIBRARIES ${IOINT_LIB} ${WRFNETCDF_LIB} ${FRAMEPACK} ${FRAMEMODULE} ) - diff --git a/cmake/Modules/NewCMake/CMakeParseArguments.cmake b/cmake/Modules/NewCMake/CMakeParseArguments.cmake deleted file mode 100644 index 7ee2bbacef..0000000000 --- a/cmake/Modules/NewCMake/CMakeParseArguments.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CMakeParseArguments -# ------------------- -# -# This module once implemented the :command:`cmake_parse_arguments` command -# that is now implemented natively by CMake. It is now an empty placeholder -# for compatibility with projects that include it to get the command from -# CMake 3.4 and lower. diff --git a/cmake/Modules/NewCMake/FindHDF5.cmake b/cmake/Modules/NewCMake/FindHDF5.cmake deleted file mode 100644 index fd8891cf20..0000000000 --- a/cmake/Modules/NewCMake/FindHDF5.cmake +++ /dev/null @@ -1,934 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindHDF5 -# -------- -# -# Find HDF5, a library for reading and writing self describing array data. -# -# -# -# This module invokes the HDF5 wrapper compiler that should be installed -# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper -# compiler is called either h5cc or h5pcc. If this succeeds, the module -# will then call the compiler with the -show argument to see what flags -# are used when compiling an HDF5 client application. -# -# The module will optionally accept the COMPONENTS argument. If no -# COMPONENTS are specified, then the find module will default to finding -# only the HDF5 C library. If one or more COMPONENTS are specified, the -# module will attempt to find the language bindings for the specified -# components. The only valid components are C, CXX, Fortran, HL, and -# Fortran_HL. If the COMPONENTS argument is not given, the module will -# attempt to find only the C bindings. -# -# This module will read the variable -# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a -# static link to a dynamic link for HDF5 and all of it's dependencies. -# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES -# variable is set before the call to find_package. -# -# To provide the module with a hint about where to find your HDF5 -# installation, you can set the environment variable HDF5_ROOT. The -# Find module will then look in this path when searching for HDF5 -# executables, paths, and libraries. -# -# Both the serial and parallel HDF5 wrappers are considered and the first -# directory to contain either one will be used. In the event that both appear -# in the same directory the serial version is preferentially selected. This -# behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to -# true. -# -# In addition to finding the includes and libraries required to compile -# an HDF5 client application, this module also makes an effort to find -# tools that come with the HDF5 distribution that may be useful for -# regression testing. -# -# This module will define the following variables: -# -# :: -# -# HDF5_FOUND - true if HDF5 was found on the system -# HDF5_VERSION - HDF5 version in format Major.Minor.Release -# HDF5_INCLUDE_DIRS - Location of the hdf5 includes -# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) -# HDF5_DEFINITIONS - Required compiler definitions for HDF5 -# HDF5_LIBRARIES - Required libraries for all requested bindings -# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all -# bindings, if the HL component is enabled -# -# Available components are: C CXX Fortran and HL. For each enabled language -# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially -# HDF5_${LANG}_DEFINITIONS, will be defined. -# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will -# also be defined. With all components enabled, the following variables will be defined: -# -# :: -# -# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings -# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings -# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings -# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings -# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings -# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings -# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings -# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings -# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings -# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings -# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran -# bindings. -# -# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support -# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler -# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler -# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler -# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler -# which is also the HDF5 wrapper -# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ -# compiler which is also -# the HDF5 wrapper -# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary -# Fortran compiler which -# is also the HDF5 wrapper -# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool -# -# The following variable can be set to guide the search for HDF5 libraries and includes: -# -# ``HDF5_ROOT`` -# Specify the path to the HDF5 installation to use. -# -# ``HDF5_FIND_DEBUG`` -# Set to a true value to get some extra debugging output. -# -# ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` -# Set to a true value to skip trying to find ``hdf5-config.cmake``. - -# This module is maintained by Will Dicharry . - -include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -# List of the valid HDF5 components -set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) - -# Validate the list of find components. -if(NOT HDF5_FIND_COMPONENTS) - set(HDF5_LANGUAGE_BINDINGS "C") -else() - set(HDF5_LANGUAGE_BINDINGS) - # add the extra specified components, ensuring that they are valid. - set(FIND_HL OFF) - foreach(component IN LISTS HDF5_FIND_COMPONENTS) - list(FIND HDF5_VALID_LANGUAGE_BINDINGS ${component} component_location) - if(NOT component_location EQUAL -1) - list(APPEND HDF5_LANGUAGE_BINDINGS ${component}) - elseif(component STREQUAL "HL") - set(FIND_HL ON) - elseif(component STREQUAL "Fortran_HL") # only for compatibility - list(APPEND HDF5_LANGUAGE_BINDINGS Fortran) - set(FIND_HL ON) - set(HDF5_FIND_REQUIRED_Fortran_HL False) - set(HDF5_FIND_REQUIRED_Fortran True) - set(HDF5_FIND_REQUIRED_HL True) - else() - message(FATAL_ERROR "${component} is not a valid HDF5 component.") - endif() - endforeach() - if(NOT HDF5_LANGUAGE_BINDINGS) - get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(__lang IN LISTS __langs) - if(__lang MATCHES "^(C|CXX|Fortran)$") - list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) - endif() - endforeach() - endif() - list(REMOVE_ITEM HDF5_FIND_COMPONENTS Fortran_HL) # replaced by Fortran and HL - list(REMOVE_DUPLICATES HDF5_LANGUAGE_BINDINGS) -endif() - -# Determine whether to search for serial or parallel executable first -if(HDF5_PREFER_PARALLEL) - set(HDF5_C_COMPILER_NAMES h5pcc h5cc) - set(HDF5_CXX_COMPILER_NAMES h5pc++ h5c++) - set(HDF5_Fortran_COMPILER_NAMES h5pfc h5fc) -else() - set(HDF5_C_COMPILER_NAMES h5cc h5pcc) - set(HDF5_CXX_COMPILER_NAMES h5c++ h5pc++) - set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc) -endif() - -# We may have picked up some duplicates in various lists during the above -# process for the language bindings (both the C and C++ bindings depend on -# libz for example). Remove the duplicates. It appears that the default -# CMake behavior is to remove duplicates from the end of a list. However, -# for link lines, this is incorrect since unresolved symbols are searched -# for down the link line. Therefore, we reverse the list, remove the -# duplicates, and then reverse it again to get the duplicates removed from -# the beginning. -macro(_HDF5_remove_duplicates_from_beginning _list_name) - if(${_list_name}) - list(REVERSE ${_list_name}) - list(REMOVE_DUPLICATES ${_list_name}) - list(REVERSE ${_list_name}) - endif() -endmacro() - - -# Test first if the current compilers automatically wrap HDF5 - -function(_HDF5_test_regular_compiler_C success version is_parallel) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_c) - set(test_file ${scratch_directory}/cmake_hdf5_test.c) - file(WRITE ${test_file} - "#include \n" - "#include \n" - "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" - "#ifdef H5_HAVE_PARALLEL\n" - "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" - "#endif\n" - "int main(int argc, char **argv) {\n" - " int require = 0;\n" - " require += info_ver[argc];\n" - "#ifdef H5_HAVE_PARALLEL\n" - " require += info_parallel[argc];\n" - "#endif\n" - " hid_t fid;\n" - " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" - " return 0;\n" - "}") - try_compile(${success} ${scratch_directory} ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_c - ) - endif() - if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS - REGEX "^INFO:" - ) - string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_STRINGS}" - ) - set(${version} ${CMAKE_MATCH_1}) - if(CMAKE_MATCH_3) - set(${version} ${HDF5_C_VERSION}.${CMAKE_MATCH_3}) - endif() - set(${version} ${${version}} PARENT_SCOPE) - - if(INFO_STRINGS MATCHES "INFO:PARALLEL") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - -function(_HDF5_test_regular_compiler_CXX success version is_parallel) - set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_cxx) - set(test_file ${scratch_directory}/cmake_hdf5_test.cxx) - file(WRITE ${test_file} - "#include \n" - "#ifndef H5_NO_NAMESPACE\n" - "using namespace H5;\n" - "#endif\n" - "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" - "#ifdef H5_HAVE_PARALLEL\n" - "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" - "#endif\n" - "int main(int argc, char **argv) {\n" - " int require = 0;\n" - " require += info_ver[argc];\n" - "#ifdef H5_HAVE_PARALLEL\n" - " require += info_parallel[argc];\n" - "#endif\n" - " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" - " return 0;\n" - "}") - try_compile(${success} ${scratch_directory} ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_cxx - ) - endif() - if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS - REGEX "^INFO:" - ) - string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_STRINGS}" - ) - set(${version} ${CMAKE_MATCH_1}) - if(CMAKE_MATCH_3) - set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3}) - endif() - set(${version} ${${version}} PARENT_SCOPE) - - if(INFO_STRINGS MATCHES "INFO:PARALLEL") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - -function(_HDF5_test_regular_compiler_Fortran success is_parallel) - if(NOT ${success}) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - set(test_file ${scratch_directory}/cmake_hdf5_test.f90) - file(WRITE ${test_file} - "program hdf5_hello\n" - " use hdf5\n" - " use h5lt\n" - " use h5ds\n" - " integer error\n" - " call h5open_f(error)\n" - " call h5close_f(error)\n" - "end\n") - try_compile(${success} ${scratch_directory} ${test_file}) - if(${success}) - execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig - OUTPUT_VARIABLE config_output - ERROR_VARIABLE config_error - RESULT_VARIABLE config_result - ) - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() - endif() -endfunction() - -# Invoke the HDF5 wrapper compiler. The compiler return value is stored to the -# return_value argument, the text output is stored to the output variable. -macro( _HDF5_invoke_compiler language output return_value version is_parallel) - set(${version}) - if(HDF5_USE_STATIC_LIBRARIES) - set(lib_type_args -noshlib) - else() - set(lib_type_args -shlib) - endif() - set(scratch_dir ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if("${language}" STREQUAL "C") - set(test_file ${scratch_dir}/cmake_hdf5_test.c) - elseif("${language}" STREQUAL "CXX") - set(test_file ${scratch_dir}/cmake_hdf5_test.cxx) - elseif("${language}" STREQUAL "Fortran") - set(test_file ${scratch_dir}/cmake_hdf5_test.f90) - endif() - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -show ${lib_type_args} ${test_file} - OUTPUT_VARIABLE ${output} - RETURN_VALUE ${return_value} - ) - if(NOT ${${return_value}} EQUAL 0) - message(STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") - endif() - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -showconfig - OUTPUT_VARIABLE config_output - RETURN_VALUE config_return - ) - if(NOT ${return_value} EQUAL 0) - message( STATUS - "Unable to determine HDF5 ${language} version from HDF5 wrapper.") - endif() - string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}") - if(version_match) - string(REPLACE "HDF5 Version: " "" ${version} "${version_match}") - string(REPLACE "-patch" "." ${version} "${${version}}") - endif() - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE) - else() - set(${is_parallel} FALSE) - endif() -endmacro() - -# Parse a compile line for definitions, includes, library paths, and libraries. -macro( _HDF5_parse_compile_line - compile_line_var - include_paths - definitions - library_paths - libraries - libraries_hl) - - separate_arguments(_HDF5_COMPILE_ARGS UNIX_COMMAND "${${compile_line_var}}") - - foreach(arg IN LISTS _HDF5_COMPILE_ARGS) - if("${arg}" MATCHES "^-I(.*)$") - # include directory - list(APPEND ${include_paths} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-D(.*)$") - # compile definition - list(APPEND ${definitions} "-D${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-L(.*)$") - # library search path - list(APPEND ${library_paths} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-l(hdf5.*hl.*)$") - # library name (hl) - list(APPEND ${libraries_hl} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-l(.*)$") - # library name - list(APPEND ${libraries} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.(a|so|dylib|sl|lib)$") - # library file - if(NOT EXISTS "${arg}") - continue() - endif() - get_filename_component(_HDF5_LPATH "${arg}" DIRECTORY) - get_filename_component(_HDF5_LNAME "${arg}" NAME_WE) - string(REGEX REPLACE "^lib" "" _HDF5_LNAME "${_HDF5_LNAME}") - list(APPEND ${library_paths} "${_HDF5_LPATH}") - if(_HDF5_LNAME MATCHES "hdf5.*hl") - list(APPEND ${libraries_hl} "${_HDF5_LNAME}") - else() - list(APPEND ${libraries} "${_HDF5_LNAME}") - endif() - endif() - endforeach() -endmacro() - -# Select a preferred imported configuration from a target -function(_HDF5_select_imported_config target imported_conf) - # We will first assign the value to a local variable _imported_conf, then assign - # it to the function argument at the end. - get_target_property(_imported_conf ${target} MAP_IMPORTED_CONFIG_${CMAKE_BUILD_TYPE}) - if (NOT _imported_conf) - # Get available imported configurations by examining target properties - get_target_property(_imported_conf ${target} IMPORTED_CONFIGURATIONS) - if(HDF5_FIND_DEBUG) - message(STATUS "Found imported configurations: ${_imported_conf}") - endif() - # Find the imported configuration that we prefer. - # We do this by making list of configurations in order of preference, - # starting with ${CMAKE_BUILD_TYPE} and ending with the first imported_conf - set(_preferred_confs ${CMAKE_BUILD_TYPE}) - list(GET _imported_conf 0 _fallback_conf) - list(APPEND _preferred_confs RELWITHDEBINFO RELEASE DEBUG ${_fallback_conf}) - if(HDF5_FIND_DEBUG) - message(STATUS "Start search through imported configurations in the following order: ${_preferred_confs}") - endif() - # Now find the first of these that is present in imported_conf - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) # support IN_LISTS - foreach (_conf IN LISTS _preferred_confs) - if (${_conf} IN_LIST _imported_conf) - set(_imported_conf ${_conf}) - break() - endif() - endforeach() - cmake_policy(POP) - endif() - if(HDF5_FIND_DEBUG) - message(STATUS "Selected imported configuration: ${_imported_conf}") - endif() - # assign value to function argument - set(${imported_conf} ${_imported_conf} PARENT_SCOPE) -endfunction() - - -if(NOT HDF5_ROOT) - set(HDF5_ROOT $ENV{HDF5_ROOT}) -endif() -if(HDF5_ROOT) - set(_HDF5_SEARCH_OPTS NO_DEFAULT_PATH) -else() - set(_HDF5_SEARCH_OPTS) -endif() - -# Try to find HDF5 using an installed hdf5-config.cmake -if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) - find_package(HDF5 QUIET NO_MODULE - HINTS ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS} - ) - if( HDF5_FOUND) - if(HDF5_FIND_DEBUG) - message(STATUS "Found HDF5 at ${HDF5_DIR} via NO_MODULE. Now trying to extract locations etc.") - endif() - set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) - set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) - set(HDF5_LIBRARIES) - if (NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) - # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc - set(_target_prefix "hdf5::") - endif() - set(HDF5_C_TARGET ${_target_prefix}hdf5) - set(HDF5_C_HL_TARGET ${_target_prefix}hdf5_hl) - set(HDF5_CXX_TARGET ${_target_prefix}hdf5_cpp) - set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) - set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) - set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) - set(HDF5_DEFINITIONS "") - if(HDF5_USE_STATIC_LIBRARIES) - set(_suffix "-static") - else() - set(_suffix "-shared") - endif() - foreach(_lang ${HDF5_LANGUAGE_BINDINGS}) - - #Older versions of hdf5 don't have a static/shared suffix so - #if we detect that occurrence clear the suffix - if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix}) - if(NOT TARGET ${HDF5_${_lang}_TARGET}) - #cant find this component with or without the suffix - #so bail out, and let the following locate HDF5 - set(HDF5_FOUND FALSE) - break() - endif() - set(_suffix "") - endif() - - if(HDF5_FIND_DEBUG) - message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") - endif() - # Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib. - _HDF5_select_imported_config(${HDF5_${_lang}_TARGET}${_suffix} _hdf5_imported_conf) - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) - if (NOT _hdf5_lang_location) - # no import lib, just try LOCATION - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) - if (NOT _hdf5_lang_location) - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) - endif() - endif() - if( _hdf5_lang_location ) - set(HDF5_${_lang}_LIBRARY ${_hdf5_lang_location}) - list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) - set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) - set(HDF5_${_lang}_FOUND True) - endif() - if(FIND_HL) - get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) - if (NOT _hdf5_lang_hl_location) - get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) - if (NOT _hdf5_hl_lang_location) - get_target_property(_hdf5_hl_lang_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) - endif() - endif() - if( _hdf5_lang_hl_location ) - set(HDF5_${_lang}_HL_LIBRARY ${_hdf5_lang_hl_location}) - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) - set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) - set(HDF5_HL_FOUND True) - endif() - unset(_hdf5_lang_hl_location) - endif() - unset(_hdf5_imported_conf) - unset(_hdf5_lang_location) - endforeach() - endif() -endif() - -if(NOT HDF5_FOUND) - set(_HDF5_NEED_TO_SEARCH False) - set(HDF5_COMPILER_NO_INTERROGATE True) - # Only search for languages we've enabled - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # First check to see if our regular compiler is one of wrappers - if(__lang STREQUAL "C") - _HDF5_test_regular_compiler_C( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_VERSION - HDF5_${__lang}_IS_PARALLEL) - elseif(__lang STREQUAL "CXX") - _HDF5_test_regular_compiler_CXX( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_VERSION - HDF5_${__lang}_IS_PARALLEL) - elseif(__lang STREQUAL "Fortran") - _HDF5_test_regular_compiler_Fortran( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_IS_PARALLEL) - else() - continue() - endif() - if(HDF5_${__lang}_COMPILER_NO_INTERROGATE) - message(STATUS "HDF5: Using hdf5 compiler wrapper for all ${__lang} compiling") - set(HDF5_${__lang}_FOUND True) - set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE - "${CMAKE_${__lang}_COMPILER}" - CACHE FILEPATH "HDF5 ${__lang} compiler wrapper") - set(HDF5_${__lang}_DEFINITIONS) - set(HDF5_${__lang}_INCLUDE_DIRS) - set(HDF5_${__lang}_LIBRARIES) - set(HDF5_${__lang}_HL_LIBRARIES) - - mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE) - - set(HDF5_${__lang}_FOUND True) - set(HDF5_HL_FOUND True) - else() - set(HDF5_COMPILER_NO_INTERROGATE False) - # If this language isn't using the wrapper, then try to seed the - # search options with the wrapper - find_program(HDF5_${__lang}_COMPILER_EXECUTABLE - NAMES ${HDF5_${__lang}_COMPILER_NAMES} NAMES_PER_DIR - HINTS ${HDF5_ROOT} - PATH_SUFFIXES bin Bin - DOC "HDF5 ${__lang} Wrapper compiler. Used only to detect HDF5 compile flags." - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced( HDF5_${__lang}_COMPILER_EXECUTABLE ) - unset(HDF5_${__lang}_COMPILER_NAMES) - - if(HDF5_${__lang}_COMPILER_EXECUTABLE) - _HDF5_invoke_compiler(${__lang} HDF5_${__lang}_COMPILE_LINE - HDF5_${__lang}_RETURN_VALUE HDF5_${__lang}_VERSION HDF5_${__lang}_IS_PARALLEL) - if(HDF5_${__lang}_RETURN_VALUE EQUAL 0) - message(STATUS "HDF5: Using hdf5 compiler wrapper to determine ${__lang} configuration") - _HDF5_parse_compile_line( HDF5_${__lang}_COMPILE_LINE - HDF5_${__lang}_INCLUDE_DIRS - HDF5_${__lang}_DEFINITIONS - HDF5_${__lang}_LIBRARY_DIRS - HDF5_${__lang}_LIBRARY_NAMES - HDF5_${__lang}_HL_LIBRARY_NAMES - ) - set(HDF5_${__lang}_LIBRARIES) - - foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES) - set(_HDF5_SEARCH_NAMES_LOCAL) - if("x${L}" MATCHES "hdf5") - # hdf5 library - set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) - if(HDF5_USE_STATIC_LIBRARIES) - if(WIN32) - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) - else() - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) - endif() - endif() - else() - # external library - set(_HDF5_SEARCH_OPTS_LOCAL) - endif() - find_library(HDF5_${__lang}_LIBRARY_${L} - NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR - HINTS ${HDF5_${__lang}_LIBRARY_DIRS} - ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS_LOCAL} - ) - unset(_HDF5_SEARCH_OPTS_LOCAL) - unset(_HDF5_SEARCH_NAMES_LOCAL) - if(HDF5_${__lang}_LIBRARY_${L}) - list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) - else() - list(APPEND HDF5_${__lang}_LIBRARIES ${L}) - endif() - endforeach() - if(FIND_HL) - set(HDF5_${__lang}_HL_LIBRARIES) - foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) - set(_HDF5_SEARCH_NAMES_LOCAL) - if("x${L}" MATCHES "hdf5") - # hdf5 library - set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) - if(HDF5_USE_STATIC_LIBRARIES) - if(WIN32) - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) - else() - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) - endif() - endif() - else() - # external library - set(_HDF5_SEARCH_OPTS_LOCAL) - endif() - find_library(HDF5_${__lang}_LIBRARY_${L} - NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR - HINTS ${HDF5_${__lang}_LIBRARY_DIRS} - ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS_LOCAL} - ) - unset(_HDF5_SEARCH_OPTS_LOCAL) - unset(_HDF5_SEARCH_NAMES_LOCAL) - if(HDF5_${__lang}_LIBRARY_${L}) - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) - else() - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${L}) - endif() - endforeach() - set(HDF5_HL_FOUND True) - endif() - - set(HDF5_${__lang}_FOUND True) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_HL_LIBRARIES) - else() - set(_HDF5_NEED_TO_SEARCH True) - endif() - else() - set(_HDF5_NEED_TO_SEARCH True) - endif() - endif() - if(HDF5_${__lang}_VERSION) - if(NOT HDF5_VERSION) - set(HDF5_VERSION ${HDF5_${__lang}_VERSION}) - elseif(NOT HDF5_VERSION VERSION_EQUAL HDF5_${__lang}_VERSION) - message(WARNING "HDF5 Version found for language ${__lang}, ${HDF5_${__lang}_VERSION} is different than previously found version ${HDF5_VERSION}") - endif() - endif() - if(DEFINED HDF5_${__lang}_IS_PARALLEL) - if(NOT DEFINED HDF5_IS_PARALLEL) - set(HDF5_IS_PARALLEL ${HDF5_${__lang}_IS_PARALLEL}) - elseif(NOT HDF5_IS_PARALLEL AND HDF5_${__lang}_IS_PARALLEL) - message(WARNING "HDF5 found for language ${__lang} is parallel but previously found language is not parallel.") - elseif(HDF5_IS_PARALLEL AND NOT HDF5_${__lang}_IS_PARALLEL) - message(WARNING "HDF5 found for language ${__lang} is not parallel but previously found language is parallel.") - endif() - endif() - endforeach() -else() - set(_HDF5_NEED_TO_SEARCH True) -endif() - -if(NOT HDF5_FOUND AND HDF5_COMPILER_NO_INTERROGATE) - # No arguments necessary, all languages can use the compiler wrappers - set(HDF5_FOUND True) - set(HDF5_METHOD "Included by compiler wrappers") - set(HDF5_REQUIRED_VARS HDF5_METHOD) -elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH) - # Compiler wrappers aren't being used by the build but were found and used - # to determine necessary include and library flags - set(HDF5_INCLUDE_DIRS) - set(HDF5_LIBRARIES) - set(HDF5_HL_LIBRARIES) - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - if(HDF5_${__lang}_FOUND) - if(NOT HDF5_${__lang}_COMPILER_NO_INTERROGATE) - list(APPEND HDF5_DEFINITIONS ${HDF5_${__lang}_DEFINITIONS}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIRS}) - list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) - if(FIND_HL) - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) - endif() - endif() - endif() - endforeach() - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) - set(HDF5_FOUND True) - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES) - if(FIND_HL) - list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) - endif() -endif() - -find_program( HDF5_DIFF_EXECUTABLE - NAMES h5diff - HINTS ${HDF5_ROOT} - PATH_SUFFIXES bin Bin - ${_HDF5_SEARCH_OPTS} - DOC "HDF5 file differencing tool." ) -mark_as_advanced( HDF5_DIFF_EXECUTABLE ) - -if( NOT HDF5_FOUND ) - # seed the initial lists of libraries to find with items we know we need - set(HDF5_C_LIBRARY_NAMES hdf5) - set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl) - - set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES}) - set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES}) - - set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES}) - set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES}) - - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # find the HDF5 include directories - if("${__lang}" STREQUAL "Fortran") - set(HDF5_INCLUDE_FILENAME hdf5.mod) - elseif("${__lang}" STREQUAL "CXX") - set(HDF5_INCLUDE_FILENAME H5Cpp.h) - else() - set(HDF5_INCLUDE_FILENAME hdf5.h) - endif() - - find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} - HINTS ${HDF5_ROOT} - PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR) - # set the _DIRS variable as this is what the user will normally use - set(HDF5_${__lang}_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) - - # find the HDF5 libraries - foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES) - if(HDF5_USE_STATIC_LIBRARIES) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG - lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug - lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_D-static ${LIB}_debug-static ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a lib${LIB} lib${LIB}-static.a ${LIB}-static) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) - if(WIN32) - list(APPEND HDF5_DEFINITIONS "-DH5_BUILT_AS_DYNAMIC_LIB") - endif() - endif() - find_library(HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - if(HDF5_${__lang}_LIBRARIES) - set(HDF5_${__lang}_FOUND True) - endif() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) - - if(FIND_HL) - foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) - if(HDF5_USE_STATIC_LIBRARIES) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG - lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug - lib${LIB}d-static.a lib${LIB}_debug-static.a lib${LIB}d-static lib${LIB}_D-static lib${LIB}_debug-static ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a lib${LIB}-static) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) - endif() - find_library(HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) - endif() - endforeach() - if(FIND_HL AND HDF5_HL_LIBRARIES) - set(HDF5_HL_FOUND True) - endif() - - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) - - # If the HDF5 include directory was found, open H5pubconf.h to determine if - # HDF5 was compiled with parallel IO support - set( HDF5_IS_PARALLEL FALSE ) - set( HDF5_VERSION "" ) - foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) - foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h") - if( EXISTS "${_hdr}" ) - file( STRINGS "${_hdr}" - HDF5_HAVE_PARALLEL_DEFINE - REGEX "HAVE_PARALLEL 1" ) - if( HDF5_HAVE_PARALLEL_DEFINE ) - set( HDF5_IS_PARALLEL TRUE ) - endif() - unset(HDF5_HAVE_PARALLEL_DEFINE) - - file( STRINGS "${_hdr}" - HDF5_VERSION_DEFINE - REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" ) - if( "${HDF5_VERSION_DEFINE}" MATCHES - "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?\"" ) - set( HDF5_VERSION "${CMAKE_MATCH_1}" ) - if( CMAKE_MATCH_3 ) - set( HDF5_VERSION ${HDF5_VERSION}.${CMAKE_MATCH_3}) - endif() - endif() - unset(HDF5_VERSION_DEFINE) - endif() - endforeach() - endforeach() - set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL - "HDF5 library compiled with parallel IO support" ) - mark_as_advanced( HDF5_IS_PARALLEL ) - - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) - if(FIND_HL) - list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) - endif() -endif() - -# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of -# HDF5_INCLUDE_DIRS -if( HDF5_INCLUDE_DIRS ) - set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) -endif() - -# If HDF5_REQUIRED_VARS is empty at this point, then it's likely that -# something external is trying to explicitly pass already found -# locations -if(NOT HDF5_REQUIRED_VARS) - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) -endif() - -find_package_handle_standard_args(HDF5 - REQUIRED_VARS ${HDF5_REQUIRED_VARS} - VERSION_VAR HDF5_VERSION - HANDLE_COMPONENTS -) - -unset(_HDF5_SEARCH_OPTS) - -if( HDF5_FOUND AND NOT HDF5_DIR) - # hide HDF5_DIR for the non-advanced user to avoid confusion with - # HDF5_DIR-NOT_FOUND while HDF5 was found. - mark_as_advanced(HDF5_DIR) -endif() - -if (HDF5_FIND_DEBUG) - message(STATUS "HDF5_DIR: ${HDF5_DIR}") - message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") - message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") - message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") - message(STATUS "HDF5_HL_LIBRARIES: ${HDF5_HL_LIBRARIES}") - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}") - message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}") - message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}") - message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}") - message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}") - message(STATUS "HDF5_${__lang}_HL_LIBRARY: ${HDF5_${__lang}_HL_LIBRARY}") - message(STATUS "HDF5_${__lang}_HL_LIBRARIES: ${HDF5_${__lang}_HL_LIBRARIES}") - endforeach() -endif() diff --git a/cmake/Modules/NewCMake/FindMPI.cmake b/cmake/Modules/NewCMake/FindMPI.cmake deleted file mode 100644 index 5cd2a2afe7..0000000000 --- a/cmake/Modules/NewCMake/FindMPI.cmake +++ /dev/null @@ -1,1514 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindMPI -# ------- -# -# Find a Message Passing Interface (MPI) implementation. -# -# The Message Passing Interface (MPI) is a library used to write -# high-performance distributed-memory parallel applications, and is -# typically deployed on a cluster. MPI is a standard interface (defined -# by the MPI forum) for which many implementations are available. -# -# Variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. -# Each of these controls the various MPI languages to search for. -# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the -# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API -# that was removed again in MPI-3. -# -# Depending on the enabled components the following variables will be set: -# -# ``MPI_FOUND`` -# Variable indicating that MPI settings for all requested languages have been found. -# If no components are specified, this is true if MPI settings for all enabled languages -# were detected. Note that the ``MPICXX`` component does not affect this variable. -# ``MPI_VERSION`` -# Minimal version of MPI detected among the requested languages, or all enabled languages -# if no components were specified. -# -# This module will set the following variables per language in your -# project, where ```` is one of C, CXX, or Fortran: -# -# ``MPI__FOUND`` -# Variable indicating the MPI settings for ```` were found and that -# simple MPI test programs compile with the provided settings. -# ``MPI__COMPILER`` -# MPI compiler for ```` if such a program exists. -# ``MPI__COMPILE_OPTIONS`` -# Compilation options for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__COMPILE_DEFINITIONS`` -# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__INCLUDE_DIRS`` -# Include path(s) for MPI header. -# ``MPI__LINK_FLAGS`` -# Linker flags for MPI programs. -# ``MPI__LIBRARIES`` -# All libraries to link MPI programs against. -# -# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: -# -# ``MPI::MPI_`` -# Target for using MPI from ````. -# -# The following variables indicating which bindings are present will be defined: -# -# ``MPI_MPICXX_FOUND`` -# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). -# ``MPI_Fortran_HAVE_F77_HEADER`` -# True if the Fortran 77 header ``mpif.h`` is available. -# ``MPI_Fortran_HAVE_F90_MODULE`` -# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). -# ``MPI_Fortran_HAVE_F08_MODULE`` -# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). -# -# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version -# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. -# -# ``MPI__VERSION_MAJOR`` -# Major version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION_MINOR`` -# Minor version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION`` -# MPI version implemented for ```` by the MPI distribution. -# -# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards -# always have required this binding to work in both C and C++ code. -# -# For running MPI programs, the module sets the following variables -# -# ``MPIEXEC_EXECUTABLE`` -# Executable for running MPI programs, if such exists. -# ``MPIEXEC_NUMPROC_FLAG`` -# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. -# ``MPIEXEC_MAX_NUMPROCS`` -# Number of MPI processors to utilize. Defaults to the number -# of processors detected on the host system. -# ``MPIEXEC_PREFLAGS`` -# Flags to pass to ``mpiexec`` directly before the executable to run. -# ``MPIEXEC_POSTFLAGS`` -# Flags to pass to ``mpiexec`` after other flags. -# -# Variables for locating MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# This module performs a three step search for an MPI implementation: -# -# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a -# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. -# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. -# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. -# Currently, only Microsoft MPI and MPICH2 on Windows are supported. -# -# For controlling the second step, the following variables may be set: -# -# ``MPI__COMPILER`` -# Search for the specified compiler wrapper and use it. -# ``MPI__COMPILER_FLAGS`` -# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers -# support linking debug or tracing libraries if a specific flag is passed and this variable -# may be used to obtain them. -# ``MPI_COMPILER_FLAGS`` -# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. -# Empty by default. -# ``MPI_EXECUTABLE_SUFFIX`` -# A suffix which is appended to all names that are being looked for. For instance you may set this -# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. -# -# In order to control the guessing step, the following variable may be set: -# -# ``MPI_GUESS_LIBRARY_NAME`` -# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. -# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. -# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. -# -# Each of the search steps may be skipped with the following control variables: -# -# ``MPI_ASSUME_NO_BUILTIN_MPI`` -# If true, the module assumes that the compiler itself does not provide an MPI implementation and -# skips to step 2. -# ``MPI_SKIP_COMPILER_WRAPPER`` -# If true, no compiler wrapper will be searched for. -# ``MPI_SKIP_GUESSING`` -# If true, the guessing step will be skipped. -# -# Additionally, the following control variable is available to change search behavior: -# -# ``MPI_CXX_SKIP_MPICXX`` -# Add some definitions that will disable the MPI-2 C++ bindings. -# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, -# for example MVAPICH or Intel MPI. -# -# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to -# the module did not work and even a simple MPI test program failed to compile. -# -# If all of these parameters were not sufficient to find the right MPI implementation, a user may -# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` -# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. -# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the -# settings in the cache. -# -# Cache variables for MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. -# For C and CXX: -# -# ``MPI__HEADER_DIR`` -# Location of the ``mpi.h`` header on disk. -# -# For Fortran: -# -# ``MPI_Fortran_F77_HEADER_DIR`` -# Location of the Fortran 77 header ``mpif.h``, if it exists. -# ``MPI_Fortran_MODULE_DIR`` -# Location of the ``mpi`` or ``mpi_f08`` modules, if available. -# -# For all languages the following variables are additionally considered: -# -# ``MPI__ADDITIONAL_INCLUDE_DIRS`` -# A :ref:`;-list ` of paths needed in addition to the normal include directories. -# ``MPI__INCLUDE_DIR`` -# Path variables for include folders referred to by ````. -# ``MPI__ADDITIONAL_INCLUDE_VARS`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: -# -# ``MPI__LIBRARY`` -# The location of a library called ```` for use with MPI. -# ``MPI__LIB_NAMES`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# Usage of mpiexec -# ^^^^^^^^^^^^^^^^ -# -# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically -# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: -# -# :: -# -# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} -# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS -# -# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to -# pass to the MPI program. -# -# Advanced variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module can perform some advanced feature detections upon explicit request. -# -# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. -# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. -# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. -# You should only enable these detections if you absolutely need the information. -# -# If the following variables are set to true, the respective search will be performed: -# -# ``MPI_DETERMINE_Fortran_CAPABILITIES`` -# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and -# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` -# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and -# ``F08_MODULE``. -# ``MPI_DETERMINE_LIBRARY_VERSION`` -# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. -# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. -# Note that the return value is entirely implementation defined. This information might be used to identify -# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# For backward compatibility with older versions of FindMPI, these -# variables are set, but deprecated: -# -# :: -# -# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY -# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS -# MPI_LIBRARIES -# -# In new projects, please use the ``MPI__XXX`` equivalents. -# Additionally, the following variables are deprecated: -# -# ``MPI__COMPILE_FLAGS`` -# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. -# ``MPI__INCLUDE_PATH`` -# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. -# ``MPIEXEC`` -# Use ``MPIEXEC_EXECUTABLE`` instead. - -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -# Generic compiler names -set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) -set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ - mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) -set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r - mpif90 mpif90_r mpf90 mpf90_r - mpif77 mpif77_r mpf77 mpf77_r - mpifc) - -# GNU compiler names -set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) -set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) -set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r - mpig77 mpig77_r mpg77 mpg77_r) - -# Intel MPI compiler names on Windows -if(WIN32) - list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) - list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) - list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) - - # Intel MPI compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) - - # Intel MPI compiler names for MSMPI - set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) - set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) -else() - # Intel compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) -endif() - -# PGI compiler names -set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) -set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) -set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) - -# XLC MPI Compiler names -set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) -set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC - mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) -set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r - mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r - mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r - mpixlf mpixlf_r mpxlf mpxlf_r) - -# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, -# attempt all of them. -# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper -# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI -# controls its settings via the I_MPI_CC environment variables if the generic name is being used. -# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to -# pick up the right settings for it. -foreach (LANG IN ITEMS C CXX Fortran) - set(_MPI_${LANG}_COMPILER_NAMES "") - foreach (id IN ITEMS GNU Intel MSVC PGI XL) - if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - endif() - unset(_MPI_${id}_${LANG}_COMPILER_NAMES) - endforeach() - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) -endforeach() - -# Names to try for mpiexec -# Only mpiexec commands are guaranteed to behave as described in the standard, -# mpirun commands are not covered by the standard in any way whatsoever. -# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. -# srun -n X is however a valid command, so it behaves 'like' mpiexec. -set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) - -unset(_MPIEXEC_NAMES) -foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) - list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") -endforeach() -unset(_MPIEXEC_NAMES_BASE) - -function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) - if(DEFINED MPI_${LANG}_COMPILER_FLAGS) -# separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS "${MPI_${LANG}_COMPILER_FLAGS}") - else() - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") - endif() - execute_process( - COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} - OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE WRAPPER_RETURN) - # Some compiler wrappers will yield spurious zero return values, for example - # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared - # library that has invalid or missing version information there would be warning - # messages emitted by ld.so in the compiler output. In either case, we'll treat - # the output as invalid. - if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") - set(WRAPPER_RETURN 255) - endif() - # Ensure that no error output might be passed upwards. - if(NOT WRAPPER_RETURN EQUAL 0) - unset(WRAPPER_OUTPUT) - endif() - set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) - set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) -endfunction() - -function (_MPI_interrogate_compiler lang) - unset(MPI_COMPILE_CMDLINE) - unset(MPI_LINK_CMDLINE) - - unset(MPI_COMPILE_OPTIONS_WORK) - unset(MPI_COMPILE_DEFINITIONS_WORK) - unset(MPI_INCLUDE_DIRS_WORK) - unset(MPI_LINK_FLAGS_WORK) - unset(MPI_LIB_NAMES_WORK) - unset(MPI_LIB_FULLPATHS_WORK) - - # Check whether the -showme:compile option works. This indicates that we have either Open MPI - # or a newer version of LAM/MPI, and implies that -showme:link will also work. - # Open MPI also supports -show, but separates linker and compiler information - _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - - # MPICH and MVAPICH offer -compile-info and -link-info. - # For modern versions, both do the same as -show. However, for old versions, they do differ - # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the - # removed MPI C++ bindings. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - endif() - - # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the - # -showme commands are more specialized. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - # Older versions of LAM/MPI have "-showme". Open MPI also supports this. - # Unknown to MPICH, MVAPICH and Intel MPI. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) - # Cannot interrogate this compiler, so exit. - set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) - return() - endif() - unset(MPI_COMPILER_RETURN) - - # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE - # into MPI_LINK_CMDLINE, if we didn't find the link line. - if (NOT DEFINED MPI_LINK_CMDLINE) - set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") - endif() - - # At this point, we obtained some output from a compiler wrapper that works. - # We'll now try to parse it into variables with meaning to us. - if("${LANG}" STREQUAL "Fortran") - # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting - # out of a symlink command for mpif.h, the actual compiler command and a deletion of the - # created symlink. We need to detect that case, remember the include path and drop the - # symlink/deletion operation to obtain the link/compile lines we'd usually expect. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") - get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - endif() - - # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command - # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. - if(UNIX) - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - - # Extract compile options from the compile command line. - string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) - string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") - # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries - # themselves were built with this flag. However, this flag is unrelated to using MPI, and - # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore - # produce inconsistent results with the regularly flags. - # Similarly, aliasing flags do not belong into our flag array. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") - list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") - endif() - endforeach() - - # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. - string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) - string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") - endif() - endforeach() - - # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:incdirs. - if (NOT MPI_ALL_INCLUDE_PATHS) - _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) - if(MPI_INCDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) - string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) - list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") - endforeach() - - # Extract linker paths from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:libdirs. - if (NOT MPI_ALL_LINK_PATHS) - _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) - if(MPI_LIBDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) - string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") - string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") - get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") - endforeach() - - # Extract linker flags from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) - string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) - # MPI might be marked to build with non-executable stacks but this should not propagate. - if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") - if (MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") - else() - set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") - endif() - endif() - endforeach() - - # Extract the set of libraries to link against from the link command - # line - string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - - if(WIN32) - # A compiler wrapper on Windows will just have the name of the - # library to link on its link line, potentially with a full path - string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - else() - # On UNIX platforms, archive libraries can be given with full path. - string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - endif() - - # An MPI compiler wrapper could have its MPI libraries in the implictly - # linked directories of the compiler itself. - if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") - endif() - - # Determine full path names for all of the libraries that one needs - # to link against in an MPI program - unset(MPI_PLAIN_LIB_NAMES_WORK) - foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${MPI_LINK_DIRECTORIES_WORK} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - - # Deal with the libraries given with full path next - unset(MPI_DIRECT_LIB_NAMES_WORK) - foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) - list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_PATH} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - if(MPI_DIRECT_LIB_NAMES_WORK) - set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") - endif() - - # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to - # link it in that case. -lpthread is covered by the normal library treatment on the other hand. - if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") - list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") - if(MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " -pthread") - else() - set(MPI_LINK_FLAGS_WORK "-pthread") - endif() - endif() - - if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}") - endif() - if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) - list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_EXTRA_LIB_NAMES) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}") - endif() - - # If we found MPI, set up all of the appropriate cache entries - if(NOT MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) - endif() - if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) - endif() - if(NOT MPI_${LANG}_LINK_FLAGS) - set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) - endif() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) -endfunction() - -function(_MPI_guess_settings LANG) - set(MPI_GUESS_FOUND FALSE) - # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. - if(WIN32) - # MSMPI - - # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, - # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers - # or import libraries and vice versa. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") - # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed - # Microsoft MPI. - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") - else() - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") - endif() - - find_library(MPI_msmpi_LIBRARY - NAMES msmpi - HINTS ${MPI_MSMPI_LIB_PATH} - DOC "Location of the msmpi library for Microsoft MPI") - mark_as_advanced(MPI_msmpi_LIBRARY) - - if(MPI_msmpi_LIBRARY) - # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way - # MSMPI can be used and therefore that header has to be present. - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) - unset(MPI_MSMPI_INC_DIR) - endif() - - # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, - # thus it might be present or provided by the user. Figuring out which is supported is done later on. - # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. - # Should a user be employing PGI or have built its own set and provided it via cache variables, the - # splitting routine would have located the module files. - - # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran - # we need some extra library to glue Fortran support together: - # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names - # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran - # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit - # has both variants available. - # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is - # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), - # it's passed immediately after the string address. - - # To summarize: - # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention - # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention - # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention - # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention - # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. - - # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas - # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran - # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - - # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). - - # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. - # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and - # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. - if ("${LANG}" STREQUAL "Fortran") - set(MPI_MSMPI_CALLINGCONVS c) - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) - list(APPEND MPI_MSMPI_CALLINGCONVS s) - endif() - foreach(mpistrlenpos IN ITEMS e m) - foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) - find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY - NAMES msmpif${mpistrlenpos}${mpicallingconv} - HINTS "${MPI_MSMPI_LIB_PATH}" - DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") - mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) - endforeach() - endforeach() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - - # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value - # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. - find_path(MPI_mpifptr_INCLUDE_DIR - NAMES "mpifptr.h" - HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" - DOC "Location of the mpifptr.h extra header for Microsoft MPI") - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) - else() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - endif() - mark_as_advanced(MPI_${LANG}_LIB_NAMES) - set(MPI_GUESS_FOUND TRUE) - endif() - endif() - - # At this point there's not many MPIs that we could still consider. - # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. - # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") - set(MPI_MPICH_PREFIX_PATHS - "$ENV{ProgramW6432}/MPICH2/lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" - ) - - # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first - find_library(MPI_mpi_LIBRARY - NAMES mpi - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_mpi_LIBRARY) - # If we found mpi.lib, we detect the rest of MPICH2 - if(MPI_mpi_LIBRARY) - set(MPI_MPICH_LIB_NAMES "mpi") - # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. - # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. - if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) - find_library(MPI_cxx_LIBRARY - NAMES cxx - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_cxx_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "cxx") - # For Fortran, MPICH2 provides three different libraries: - # fmpich2.lib which uses uppercase symbols and cdecl, - # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), - # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. - # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also - # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one - # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation - elseif("${LANG}" STREQUAL "Fortran") - find_library(MPI_fmpich2_LIBRARY - NAMES fmpich2 - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2s_LIBRARY - NAMES fmpich2s - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2g_LIBRARY - NAMES fmpich2g - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") - endif() - - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - unset(MPI_MPICH_LIB_NAMES) - - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - # For MPICH2, the include folder would be in ../include relative to the library folder. - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) - if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - unset(MPI_MPICH_ROOT_DIR) - endif() - set(MPI_GUESS_FOUND TRUE) - endif() - unset(MPI_MPICH_PREFIX_PATHS) - endif() - endif() - set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) -endfunction() - -function(_MPI_adjust_compile_definitions LANG) - if("${LANG}" STREQUAL "CXX") - # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ - # bindings in MPI-2. - if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") - # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI - # OMPI_SKIP_MPICXX is being used in Open MPI - # _MPICC_H is being used for IBM Platform MPI - list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") - set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - endif() -endfunction() - -macro(_MPI_assemble_libraries LANG) - set(MPI_${LANG}_LIBRARIES "") - # Only for libraries do we need to check whether the compiler's linking stage is separate. - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) - foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) - endforeach() - endif() -endmacro() - -macro(_MPI_assemble_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_${LANG}_INCLUDE_DIRS "") - else() - set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") - if("${LANG}" MATCHES "(C|CXX)") - if(MPI_${LANG}_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - else() # Fortran - if(MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") - endif() - if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") - endif() - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}") - endforeach() - endif() - endif() -endmacro() - -function(_MPI_split_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - return() - endif() - # Backwards compatibility: Search INCLUDE_PATH if given. - if(MPI_${LANG}_INCLUDE_PATH) - list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") - endif() - - # We try to find the headers/modules among those paths (and system paths) - # For C/C++, we just need to have a look for mpi.h. - if("${LANG}" MATCHES "(C|CXX)") - find_path(MPI_${LANG}_HEADER_DIR "mpi.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - mark_as_advanced(MPI_${LANG}_HEADER_DIR) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - # Fortran is more complicated here: An implementation could provide - # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI - # only provides Fortran 77 and - if mpi.f90 is built - potentially - # a Fortran 90 module. - elseif("${LANG}" STREQUAL "Fortran") - find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - find_path(MPI_${LANG}_MODULE_DIR - NAMES "mpi.mod" "mpi_f08.mod" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS - "${MPI_${LANG}_F77_HEADER_DIR}" - "${MPI_${LANG}_MODULE_DIR}" - ) - endif() - mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) - endif() - # Remove duplicates and default system directories from the list. - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR}) - endforeach() - endif() - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) -endfunction() - -macro(_MPI_create_imported_target LANG) - if(NOT TARGET MPI::MPI_${LANG}) - add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) - endif() - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") - if(MPI_${LANG}_LINK_FLAGS) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") - endif() - # If the compiler links MPI implicitly, no libraries will be found as they're contained within - # CMAKE__IMPLICIT_LINK_LIBRARIES already. - if(MPI_${LANG}_LIBRARIES) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") - endif() - # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") -endmacro() - -function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) - set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") - set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/FindMPI") - set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") - unset(MPI_TEST_COMPILE_DEFINITIONS) - if("${LANG}" STREQUAL "Fortran") - if("${MODE}" STREQUAL "F90_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") - elseif("${MODE}" STREQUAL "F08_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") - else() # F77 header - set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") - endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") - elseif("${LANG}" STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") - if("${MODE}" STREQUAL "TEST_MPICXX") - set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) - endif() - else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") - endif() - if(RUN_BINARY) - try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) - set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) - else() - try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - COPY_FILE "${BIN_FILE}") - endif() -endfunction() - -macro(_MPI_check_lang_works LANG) - # For Fortran we may have by the MPI-3 standard an implementation that provides: - # - the mpi_f08 module - # - *both*, the mpi module and 'mpif.h' - # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. - if( NOT MPI_${LANG}_WORKS ) - if("${LANG}" STREQUAL "Fortran") - set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) - - set(MPI_${LANG}_WORKS FALSE) - - foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) - if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_${mpimethod} TRUE) - else() - set(MPI_${LANG}_HAVE_${mpimethod} FALSE) - endif() - endforeach() - # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. - # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. - unset(MPI_Fortran_INTEGER_LINE) - if(NOT MPI_${LANG}_WORKS) - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) - if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_F77_HEADER TRUE) - endif() - endif() - else() - _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) - # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't - # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. - set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") - endif() - endif() -endmacro() - -# Some systems install various MPI implementations in separate folders in some MPI prefix -# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. -macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) - if(EXISTS "${PREFIX_FOLDER}") - file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") - foreach(_MPI_folder_child IN LISTS _MPI_folder_children) - if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") - list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") - endif() - endforeach() - endif() -endmacro() - -set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_ROOT} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ - # We enumerate the subfolders and append each as a prefix - MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. - list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") - # FreeBSD ships mpich under the normal system paths - but available openmpi implementations - # will be found in /usr/local/mpi/ - MPI_search_mpi_prefix_folder("/usr/local/mpi") -endif() - -# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. -# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution -# ships an mpiexec program (mpirun executables are not regulated by the standard). -find_program(MPIEXEC_EXECUTABLE - NAMES ${_MPIEXEC_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${MPI_HINT_DIRS} - DOC "Executable for running MPI programs.") - -# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). -# This gives us a fairly reliable base directory to search for /bin /lib and /include from. -get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) -get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) - -# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to -# launch an MPI process using mpiexec if such a program exists. -set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") -set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") -set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") - -# Set the number of processes to the physical processor count -cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) -set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") -unset(_MPIEXEC_NUMPROCS) -mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) - -#============================================================================= -# Backward compatibility input hacks. Propagate the FindMPI hints to C and -# CXX if the respective new versions are not defined. Translate the old -# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. -# -# Once we find the new variables, we translate them back into their old -# equivalents below. -if(NOT MPI_IGNORE_LEGACY_VARIABLES) - foreach (LANG IN ITEMS C CXX) - # Old input variables. - set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) - - # Set new vars based on their old equivalents, if the new versions are not already set. - foreach (var ${_MPI_OLD_INPUT_VARS}) - if (NOT MPI_${LANG}_${var} AND MPI_${var}) - set(MPI_${LANG}_${var} "${MPI_${var}}") - endif() - endforeach() - - # Chop the old compile flags into options and definitions - - unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) - unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) - if(MPI_${LANG}_COMPILE_FLAGS) - separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") - foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") - list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") - else() - list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") - endif() - endforeach() - unset(MPI_SEPARATE_FLAGS) - endif() - - # If a list of libraries was given, we'll split it into new-style cache variables - unset(MPI_${LANG}_EXTRA_LIB_NAMES) - if(NOT MPI_${LANG}_LIB_NAMES) - foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) - if(_MPI_LIB) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) - get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) - list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endif() - endforeach() - endif() - endforeach() -endif() -#============================================================================= - -unset(MPI_VERSION) -unset(MPI_VERSION_MAJOR) -unset(MPI_VERSION_MINOR) - -unset(_MPI_MIN_VERSION) - -# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. -if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) - set(MPI_SKIP_COMPILER_WRAPPER TRUE) -endif() - -# This loop finds the compilers and sends them off for interrogation. -foreach(LANG IN ITEMS C CXX Fortran) - if(CMAKE_${LANG}_COMPILER_LOADED) - if(NOT MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(_MPI_FIND_${LANG} TRUE) - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - if(_MPI_FIND_${LANG}) - if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") - mark_as_advanced(MPI_CXX_SKIP_MPICXX) - endif() - if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) - set(MPI_${LANG}_TRIED_IMPLICIT FALSE) - set(MPI_${LANG}_WORKS_IMPLICIT FALSE) - if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) - # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. - # Cray PrgEnv. - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - - # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. - if(MPI_${LANG}_WORKS) - set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) - set(MPI_${LANG}_WORKS_IMPLICIT TRUE) - endif() - set(MPI_${LANG}_TRIED_IMPLICIT TRUE) - endif() - - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) - set(MPI_${LANG}_WRAPPER_FOUND FALSE) - set(MPI_PINNED_COMPILER FALSE) - - if(NOT MPI_SKIP_COMPILER_WRAPPER) - if(MPI_${LANG}_COMPILER) - # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. - if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") - # Get rid of our default list of names and just search for the name the user wants. - set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") - unset(MPI_${LANG}_COMPILER CACHE) - endif() - # If the user specifies a compiler, we don't want to try to search libraries either. - set(MPI_PINNED_COMPILER TRUE) - endif() - - # If we have an MPI base directory, we'll try all compiler names in that one first. - # This should prevent mixing different MPI environments - if(_MPI_BASE_DIR) - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${_MPI_BASE_DIR} - NO_DEFAULT_PATH - DOC "MPI compiler for ${LANG}" - ) - endif() - - # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), - # we shall try searching in the default paths. - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - DOC "MPI compiler for ${LANG}" - ) - - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_PINNED_COMPILER TRUE) - - # If we haven't made the implicit compiler test yet, perform it now. - if(NOT MPI_${LANG}_TRIED_IMPLICIT) - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - endif() - - # Should the MPI compiler not work implicitly for MPI, still interrogate it. - # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used - # directly during linkage instead of CMAKE__COMPILER will not work. - if(NOT MPI_${LANG}_WORKS) - set(MPI_${LANG}_WORKS_IMPLICIT FALSE) - _MPI_interrogate_compiler(${LANG}) - else() - set(MPI_${LANG}_WORKS_IMPLICIT TRUE) - endif() - elseif(MPI_${LANG}_COMPILER) - _MPI_interrogate_compiler(${LANG}) - endif() - endif() - - if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) - # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the - # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) - else() - _MPI_guess_settings(${LANG}) - endif() - endif() - endif() - endif() - - _MPI_split_include_dirs(${LANG}) - _MPI_assemble_include_dirs(${LANG}) - _MPI_assemble_libraries(${LANG}) - - _MPI_adjust_compile_definitions(${LANG}) - # We always create imported targets even if they're empty - _MPI_create_imported_target(${LANG}) - - if(NOT MPI_${LANG}_WORKS) - _MPI_check_lang_works(${LANG}) - endif() - - # Next, we'll initialize the MPI variables that have not been previously set. - set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) - if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) - endif() - mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS - MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) - - # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported - # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. - if(MPI_${LANG}_WORKS) - if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) - if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) - _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) - if(MPI_RESULT_${LANG}_test_mpi_MPICXX) - set(MPI_MPICXX_FOUND TRUE) - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - endif() - - # At this point, we know the bindings present but not the MPI version or anything else. - if(NOT DEFINED MPI_${LANG}_VERSION) - unset(MPI_${LANG}_VERSION_MAJOR) - unset(MPI_${LANG}_VERSION_MINOR) - endif() - set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) - - # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the - # Fortran parameters, since those depend on the method of consumption. - # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 - # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. - if("${LANG}" STREQUAL "Fortran") - if(MPI_${LANG}_HAVE_F08_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) - elseif(MPI_${LANG}_HAVE_F90_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) - else() - set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) - endif() - - # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION - # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not - # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. - if(NOT DEFINED MPI_${LANG}_VERSION) - _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) - if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) - file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. - # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING - # and might vary between the different methods of consumption. - if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) - foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) - if(MPI_${LANG}_HAVE_${mpimethod}) - set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) - set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) - _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) - if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND - NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") - if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES - ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") - if("${CMAKE_MATCH_1}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) - endif() - if("${CMAKE_MATCH_2}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) - endif() - endif() - endif() - endif() - endforeach() - set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) - endif() - else() - set(MPI_${LANG}_HIGHEST_METHOD normal) - - # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. - if(NOT DEFINED MPI_${LANG}_VERSION) - file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - unset(MPI_BIN_FOLDER) - - # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. - # The one remaining issue is to determine which MPI library is installed. - # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, - # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING - # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). - # It's also worth noting that the installed version string can depend on the language, or on the system the binary - # runs on if MPI is not statically linked. - if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) - _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) - if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND - "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") - string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" - MPI_${LANG}_LIBRARY_VERSION_STRING) - else() - set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") - endif() - endif() - endif() - - set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) - set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) - set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) - - unset(MPI_${LANG}_REQUIRED_VARS) - if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") - endforeach() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") - if("${LANG}" STREQUAL "Fortran") - # For Fortran we only need one of the module or header directories to have *some* support for MPI. - if(NOT MPI_${LANG}_MODULE_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") - endif() - if(NOT MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") - endif() - else() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") - endforeach() - endif() - # Append the works variable now. If the settings did not work, this will show up properly. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - else() - # If the compiler worked implicitly, use its path as output. - # Should the compiler variable be set, we also require it to work. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") - if(MPI_${LANG}_COMPILER) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - endif() - endif() - find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} - VERSION_VAR MPI_${LANG}_VERSION) - - if(DEFINED MPI_${LANG}_VERSION) - if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) - set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) - endif() - endif() - endif() -endforeach() - -unset(_MPI_REQ_VARS) -foreach(LANG IN ITEMS C CXX Fortran) - if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") - endif() -endforeach() - -if(MPICXX IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") -endif() - -find_package_handle_standard_args(MPI - REQUIRED_VARS ${_MPI_REQ_VARS} - VERSION_VAR ${_MPI_MIN_VERSION} - HANDLE_COMPONENTS) - -#============================================================================= -# More backward compatibility stuff - -# For compatibility reasons, we also define MPIEXEC -set(MPIEXEC "${MPIEXEC_EXECUTABLE}") - -# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. -foreach(LANG IN ITEMS C CXX Fortran) - if(MPI_${LANG}_FOUND) - set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") - unset(MPI_${LANG}_COMPILE_FLAGS) - if(MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_COMPILE_DEFINITIONS) - foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) - string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") - endforeach() - endif() - endif() -endforeach() - -# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. -# This mimics the behavior of the old language-oblivious FindMPI. -set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) -if (MPI_CXX_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_CXX_${var}}) - endforeach() -elseif (MPI_C_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_C_${var}}) - endforeach() -endif() - -# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. -if (MPI_LIBRARIES) - list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) - set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") - unset(MPI_LIBRARY_WORK) -else() - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") -endif() - -list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) -if (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") - list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) - set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") - unset(MPI_EXTRA_LIBRARY_WORK) -else() - set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") -endif() -set(MPI_IGNORE_LEGACY_VARIABLES TRUE) -#============================================================================= - -# unset these vars to cleanup namespace -unset(_MPI_OLD_VARS) -unset(_MPI_PREFIX_PATH) -unset(_MPI_BASE_DIR) -foreach (lang C CXX Fortran) - unset(_MPI_${LANG}_COMPILER_NAMES) -endforeach() - -cmake_policy(POP) diff --git a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in deleted file mode 100644 index 30f912c627..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in +++ /dev/null @@ -1,4 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']' - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c b/cmake/Modules/NewCMake/FindMPI/libver_mpi.c deleted file mode 100644 index be9d19d435..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#ifdef __cplusplus -#include -#else -#include -#endif - -int main(int argc, char* argv[]) -{ - char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING]; - int mpilibver_len; - MPI_Get_library_version(mpilibver_str, &mpilibver_len); -#ifdef __cplusplus - std::puts(mpilibver_str); -#else - puts(mpilibver_str); -#endif -} diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in deleted file mode 100644 index 7938587168..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in +++ /dev/null @@ -1,7 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str - integer(kind=MPI_INTEGER_KIND) :: ierror, reslen - call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror) - print *, mpilibver_str - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in b/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in deleted file mode 100644 index a254523853..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in +++ /dev/null @@ -1,10 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0') - character, dimension(17), parameter :: mpiver_str =& - (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', & - char(zero + MPI_VERSION), & - '.', & - char(zero + MPI_SUBVERSION), ']' /) - print *, mpiver_str - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.c b/cmake/Modules/NewCMake/FindMPI/test_mpi.c deleted file mode 100644 index b8a308a4b0..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/test_mpi.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -#ifdef __cplusplus -#include -#else -#include -#endif - -#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -const char mpiver_str[] = { 'I', 'N', - 'F', 'O', - ':', 'M', - 'P', 'I', - '-', 'V', - 'E', 'R', - '[', ('0' + MPI_VERSION), - '.', ('0' + MPI_SUBVERSION), - ']', '\0' }; -#endif - -int main(int argc, char* argv[]) -{ -#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -#ifdef __cplusplus - std::puts(mpiver_str); -#else - puts(mpiver_str); -#endif -#endif -#ifdef TEST_MPI_MPICXX - MPI::MPI_Init(&argc, &argv); - MPI::MPI_Finalize(); -#else - MPI_Init(&argc, &argv); - MPI_Finalize(); -#endif -} diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in deleted file mode 100644 index 4d43a04d65..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in +++ /dev/null @@ -1,6 +0,0 @@ - program hello - @MPI_Fortran_INCLUDE_LINE@ - integer@MPI_Fortran_INTEGER_LINE@ ierror - call MPI_INIT(ierror) - call MPI_FINALIZE(ierror) - end program diff --git a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake b/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake deleted file mode 100644 index 67f6bd6f2b..0000000000 --- a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake +++ /dev/null @@ -1,386 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindPackageHandleStandardArgs ------------------------------ - -This module provides a function intended to be used in :ref:`Find Modules` -implementing :command:`find_package()` calls. It handles the -``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. -It also sets the ``_FOUND`` variable. The package is -considered found if all variables listed contain valid results, e.g. -valid filepaths. - -.. command:: find_package_handle_standard_args - - There are two signatures:: - - find_package_handle_standard_args( - (DEFAULT_MSG|) - ... - ) - - find_package_handle_standard_args( - [FOUND_VAR ] - [REQUIRED_VARS ...] - [VERSION_VAR ] - [HANDLE_COMPONENTS] - [CONFIG_MODE] - [FAIL_MESSAGE ] - ) - - The ``_FOUND`` variable will be set to ``TRUE`` if all - the variables ``...`` are valid and any optional - constraints are satisfied, and ``FALSE`` otherwise. A success or - failure message may be displayed based on the results and on - whether the ``REQUIRED`` and/or ``QUIET`` option was given to - the :command:`find_package` call. - - The options are: - - ``(DEFAULT_MSG|)`` - In the simple signature this specifies the failure message. - Use ``DEFAULT_MSG`` to ask for a default message to be computed - (recommended). Not valid in the full signature. - - ``FOUND_VAR `` - Obsolete. Specifies either ``_FOUND`` or - ``_FOUND`` as the result variable. This exists only - for compatibility with older versions of CMake and is now ignored. - Result variables of both names are always set for compatibility. - - ``REQUIRED_VARS ...`` - Specify the variables which are required for this package. - These may be named in the generated failure message asking the - user to set the missing variable values. Therefore these should - typically be cache entries such as ``FOO_LIBRARY`` and not output - variables like ``FOO_LIBRARIES``. - - ``VERSION_VAR `` - Specify the name of a variable that holds the version of the package - that has been found. This version will be checked against the - (potentially) specified required version given to the - :command:`find_package` call, including its ``EXACT`` option. - The default messages include information about the required - version and the version which has been actually found, both - if the version is ok or not. - - ``HANDLE_COMPONENTS`` - Enable handling of package components. In this case, the command - will report which components have been found and which are missing, - and the ``_FOUND`` variable will be set to ``FALSE`` - if any of the required components (i.e. not the ones listed after - the ``OPTIONAL_COMPONENTS`` option of :command:`find_package`) are - missing. - - ``CONFIG_MODE`` - Specify that the calling find module is a wrapper around a - call to ``find_package( NO_MODULE)``. This implies - a ``VERSION_VAR`` value of ``_VERSION``. The command - will automatically check whether the package configuration file - was found. - - ``FAIL_MESSAGE `` - Specify a custom failure message instead of using the default - generated message. Not recommended. - -Example for the simple signature: - -.. code-block:: cmake - - find_package_handle_standard_args(LibXml2 DEFAULT_MSG - LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) - -The ``LibXml2`` package is considered to be found if both -``LIBXML2_LIBRARY`` and ``LIBXML2_INCLUDE_DIR`` are valid. -Then also ``LibXml2_FOUND`` is set to ``TRUE``. If it is not found -and ``REQUIRED`` was used, it fails with a -:command:`message(FATAL_ERROR)`, independent whether ``QUIET`` was -used or not. If it is found, success will be reported, including -the content of the first ````. On repeated CMake runs, -the same message will not be printed again. - -Example for the full signature: - -.. code-block:: cmake - - find_package_handle_standard_args(LibArchive - REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR - VERSION_VAR LibArchive_VERSION) - -In this case, the ``LibArchive`` package is considered to be found if -both ``LibArchive_LIBRARY`` and ``LibArchive_INCLUDE_DIR`` are valid. -Also the version of ``LibArchive`` will be checked by using the version -contained in ``LibArchive_VERSION``. Since no ``FAIL_MESSAGE`` is given, -the default messages will be printed. - -Another example for the full signature: - -.. code-block:: cmake - - find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) - find_package_handle_standard_args(Automoc4 CONFIG_MODE) - -In this case, a ``FindAutmoc4.cmake`` module wraps a call to -``find_package(Automoc4 NO_MODULE)`` and adds an additional search -directory for ``automoc4``. Then the call to -``find_package_handle_standard_args`` produces a proper success/failure -message. -#]=======================================================================] - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) - -# internal helper macro -macro(_FPHSA_FAILURE_MESSAGE _msg) - if (${_NAME}_FIND_REQUIRED) - message(FATAL_ERROR "${_msg}") - else () - if (NOT ${_NAME}_FIND_QUIETLY) - message(STATUS "${_msg}") - endif () - endif () -endmacro() - - -# internal helper macro to generate the failure message when used in CONFIG_MODE: -macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) - # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: - if(${_NAME}_CONFIG) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") - else() - # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. - # List them all in the error message: - if(${_NAME}_CONSIDERED_CONFIGS) - set(configsText "") - list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) - math(EXPR configsCount "${configsCount} - 1") - foreach(currentConfigIndex RANGE ${configsCount}) - list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) - list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - string(APPEND configsText " ${filename} (version ${version})\n") - endforeach() - if (${_NAME}_NOT_FOUND_MESSAGE) - string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") - endif() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") - - else() - # Simple case: No Config-file was found at all: - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") - endif() - endif() -endmacro() - - -function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) - -# Set up the arguments for `cmake_parse_arguments`. - set(options CONFIG_MODE HANDLE_COMPONENTS) - set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) - set(multiValueArgs REQUIRED_VARS) - -# Check whether we are in 'simple' or 'extended' mode: - set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) - list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) - - if(${INDEX} EQUAL -1) - set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) - set(FPHSA_REQUIRED_VARS ${ARGN}) - set(FPHSA_VERSION_VAR) - else() - cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) - - if(FPHSA_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") - endif() - - if(NOT FPHSA_FAIL_MESSAGE) - set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") - endif() - - # In config-mode, we rely on the variable _CONFIG, which is set by find_package() - # when it successfully found the config-file, including version checking: - if(FPHSA_CONFIG_MODE) - list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) - list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) - set(FPHSA_VERSION_VAR ${_NAME}_VERSION) - endif() - - if(NOT FPHSA_REQUIRED_VARS) - message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") - endif() - endif() - -# now that we collected all arguments, process them - - if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") - set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") - endif() - - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) - - string(TOUPPER ${_NAME} _NAME_UPPER) - string(TOLOWER ${_NAME} _NAME_LOWER) - - if(FPHSA_FOUND_VAR) - if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") - set(_FOUND_VAR ${FPHSA_FOUND_VAR}) - else() - message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") - endif() - else() - set(_FOUND_VAR ${_NAME_UPPER}_FOUND) - endif() - - # collect all variables which were not found, so they can be printed, so the - # user knows better what went wrong (#6375) - set(MISSING_VARS "") - set(DETAILS "") - # check if all passed variables are valid - set(FPHSA_FOUND_${_NAME} TRUE) - foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) - if(NOT ${_CURRENT_VAR}) - set(FPHSA_FOUND_${_NAME} FALSE) - string(APPEND MISSING_VARS " ${_CURRENT_VAR}") - else() - string(APPEND DETAILS "[${${_CURRENT_VAR}}]") - endif() - endforeach() - if(FPHSA_FOUND_${_NAME}) - set(${_NAME}_FOUND TRUE) - set(${_NAME_UPPER}_FOUND TRUE) - else() - set(${_NAME}_FOUND FALSE) - set(${_NAME_UPPER}_FOUND FALSE) - endif() - - # component handling - unset(FOUND_COMPONENTS_MSG) - unset(MISSING_COMPONENTS_MSG) - - if(FPHSA_HANDLE_COMPONENTS) - foreach(comp ${${_NAME}_FIND_COMPONENTS}) - if(${_NAME}_${comp}_FOUND) - - if(NOT DEFINED FOUND_COMPONENTS_MSG) - set(FOUND_COMPONENTS_MSG "found components: ") - endif() - string(APPEND FOUND_COMPONENTS_MSG " ${comp}") - - else() - - if(NOT DEFINED MISSING_COMPONENTS_MSG) - set(MISSING_COMPONENTS_MSG "missing components: ") - endif() - string(APPEND MISSING_COMPONENTS_MSG " ${comp}") - - if(${_NAME}_FIND_REQUIRED_${comp}) - set(${_NAME}_FOUND FALSE) - string(APPEND MISSING_VARS " ${comp}") - endif() - - endif() - endforeach() - set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") - string(APPEND DETAILS "[c${COMPONENT_MSG}]") - endif() - - # version handling: - set(VERSION_MSG "") - set(VERSION_OK TRUE) - - # check with DEFINED here as the requested or found version may be "0" - if (DEFINED ${_NAME}_FIND_VERSION) - if(DEFINED ${FPHSA_VERSION_VAR}) - set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - # count the dots in the version string - string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") - # add one dot because there is one dot more than there are components - string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) - if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) - # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT - # is at most 4 here. Therefore a simple lookup table is used. - if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) - set(_VERSION_REGEX "[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) - set(_VERSION_REGEX "[^.]*\\.[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") - else () - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") - endif () - string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") - unset(_VERSION_REGEX) - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - unset(_VERSION_HEAD) - else () - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - endif () - unset(_VERSION_DOTS) - - else() # minimum version specified: - if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () - endif() - - else() - - # if the package was not found, but a version was given, add that to the output: - if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") - else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") - endif() - - endif() - else () - # Check with DEFINED as the found version may be 0. - if(DEFINED ${FPHSA_VERSION_VAR}) - set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")") - endif() - endif () - - if(VERSION_OK) - string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]") - else() - set(${_NAME}_FOUND FALSE) - endif() - - - # print the result: - if (${_NAME}_FOUND) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") - else () - - if(FPHSA_CONFIG_MODE) - _FPHSA_HANDLE_FAILURE_CONFIG_MODE() - else() - if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") - else() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") - endif() - endif() - - endif () - - set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) - set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) -endfunction() diff --git a/cmake/Modules/NewCMake/FindPackageMessage.cmake b/cmake/Modules/NewCMake/FindPackageMessage.cmake deleted file mode 100644 index 6821cee4f7..0000000000 --- a/cmake/Modules/NewCMake/FindPackageMessage.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindPackageMessage -# ------------------ -# -# -# -# FIND_PACKAGE_MESSAGE( "message for user" "find result details") -# -# This macro is intended to be used in FindXXX.cmake modules files. It -# will print a message once for each unique find result. This is useful -# for telling the user where a package was found. The first argument -# specifies the name (XXX) of the package. The second argument -# specifies the message to display. The third argument lists details -# about the find result so that if they change the message will be -# displayed again. The macro also obeys the QUIET argument to the -# find_package command. -# -# Example: -# -# :: -# -# if(X11_FOUND) -# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" -# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") -# else() -# ... -# endif() - -function(FIND_PACKAGE_MESSAGE pkg msg details) - # Avoid printing a message repeatedly for the same find result. - if(NOT ${pkg}_FIND_QUIETLY) - string(REPLACE "\n" "" details "${details}") - set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) - if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") - # The message has not yet been printed. - message(STATUS "${msg}") - - # Save the find details in the cache to avoid printing the same - # message again. - set("${DETAILS_VAR}" "${details}" - CACHE INTERNAL "Details about finding ${pkg}") - endif() - endif() -endfunction() diff --git a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake b/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake deleted file mode 100644 index dce6f99262..0000000000 --- a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# SelectLibraryConfigurations -# --------------------------- -# -# -# -# select_library_configurations( basename ) -# -# This macro takes a library base name as an argument, and will choose -# good values for basename_LIBRARY, basename_LIBRARIES, -# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what -# has been found and set. If only basename_LIBRARY_RELEASE is defined, -# basename_LIBRARY will be set to the release value, and -# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND. -# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will -# take the debug value, and basename_LIBRARY_RELEASE will be set to -# basename_LIBRARY_RELEASE-NOTFOUND. -# -# If the generator supports configuration types, then basename_LIBRARY -# and basename_LIBRARIES will be set with debug and optimized flags -# specifying the library to be used for the given configuration. If no -# build type has been set or the generator in use does not support -# configuration types, then basename_LIBRARY and basename_LIBRARIES will -# take only the release value, or the debug value if the release one is -# not set. - -# This macro was adapted from the FindQt4 CMake module and is maintained by Will -# Dicharry . - -macro( select_library_configurations basename ) - if(NOT ${basename}_LIBRARY_RELEASE) - set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.") - endif() - if(NOT ${basename}_LIBRARY_DEBUG) - set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.") - endif() - - if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND - NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND - ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) ) - # if the generator supports configuration types or CMAKE_BUILD_TYPE - # is set, then set optimized and debug options. - set( ${basename}_LIBRARY "" ) - foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) - list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) - endforeach() - foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) - list( APPEND ${basename}_LIBRARY debug "${_libname}" ) - endforeach() - elseif( ${basename}_LIBRARY_RELEASE ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) - elseif( ${basename}_LIBRARY_DEBUG ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} ) - else() - set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND") - endif() - - set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) - - if( ${basename}_LIBRARY ) - set( ${basename}_FOUND TRUE ) - endif() - - mark_as_advanced( ${basename}_LIBRARY_RELEASE - ${basename}_LIBRARY_DEBUG - ) -endmacro() diff --git a/cmake/Modules/findHelpers.cmake b/cmake/Modules/findHelpers.cmake deleted file mode 100644 index 028957a0a6..0000000000 --- a/cmake/Modules/findHelpers.cmake +++ /dev/null @@ -1,173 +0,0 @@ -function (findSrc varName version varDir ) - if(EXISTS ${CMAKE_SOURCE_DIR}/libsrc/${varName}) - message("setting source for ${varName} to be in libsrc") - set( ${varDir} "${CMAKE_SOURCE_DIR}/libsrc/${varName}" PARENT_SCOPE) - set( ${varCacheName} "${CMAKE_SOURCE_DIR}/libsrc/${varName}" CACHE STRING "" FORCE ) - else() - set(searchName ${varName}_v${${version}}) - message("searching for source for ${searchName} in ${CRTM_BASE}") - string( TOLOWER ${varName} varNameLower ) - find_path( TMP_DIR - NAMES ${searchName} - HINTS - ${CMAKE_SOURCE_DIR}/../libs - ${CRTM_BASE}/${version} - ${CRTM_BASE}/${varName} - ${CRTM_BASE}/${varName}/${version} - ${CRTM_BASE}/${varNameLower} - ${CRTM_BASE}/${varNameLower}/${version} - ${COREPATH}/sorc - $ENV{${varDir}}/libsrc - $ENV{${varDir}}/lib/sorc - $ENV{CORPATH}/lib/sorc - ${CMAKE_SOURCE_DIR}/libsrc/${varName} - ) - if( NOT TMP_DIR ) - message("didn't find directory") - set(secondSearchName v${${version}}) - find_path( TMP2_DIR - NAMES ${secondSearchName} - HINTS - ${CRTM_BASE}/${varName} - ) - endif() - set( varCacheName "${varDir}_SRC" ) - file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/*.f*" "${TMP_DIR}/${varName}_v${${version}}/*.F*") - if( f_FILES ) - set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}" PARENT_SCOPE) - set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/src/*.f*" "${TMP_DIR}/${varName}_v${${version}}/src/*.F*") - if( f_FILES ) - set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/src" PARENT_SCOPE) - set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/src" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/libsrc/*.f*" "${TMP_DIR}/${varName}_v${${version}}/src/*.F*") - if( f_FILES ) - set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/libsrc" PARENT_SCOPE) - set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/libsrc" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/sorc/*.f*" "${TMP_DIR}/${varName}_v${${version}}/sorc/*.F*") - if( f_FILES ) - set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/sorc" PARENT_SCOPE) - set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/sorc" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc/*.f*" - "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc/*.F*") - if( f_FILES ) - set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc" PARENT_SCOPE) - set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${TMP2_DIR}/v${${version}}/src/*.f*" - "${TMP_DIR}/v${${version}}/src/*.F*") - if( f_FILES ) - set( ${varDir} "${TMP2_DIR}/v${${version}}/src" PARENT_SCOPE) - set( ${varCacheName} "${TMP2_DIR}/v${${version}}/src" CACHE STRING "" FORCE ) - endif() - endif() - endif() - endif() - endif() - endif() - if( NOT f_FILES ) # look for source that is of a different version - message("WARNING: Did not find ${${version}} of ${varName}, looking for alternates") - findOtherVersion( TMP_DIR ${varName} srcPath ${version} ) - file(GLOB f_FILES "${srcPath}/*.f*" "${srcPath}/*.F*") - if( f_FILES ) - set( ${varDir} "${srcPath}" PARENT_SCOPE) - set( ${varCacheName} "${srcPath}" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${srcPath}/src/*.f*" "${srcPath}/src/*.F*") - if( f_FILES ) - set( ${varDir} "${srcPath}/src" PARENT_SCOPE) - set( ${varCacheName} "${srcPath}/src" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${srcPath}/libsrc/*.f*" "${srcPath}/src/*.F*") - if( f_FILES ) - set( ${varDir} "${srcPath}/libsrc" PARENT_SCOPE) - set( ${varCacheName} "${srcPath}/libsrc" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${srcPath}/sorc/*.f*" "${srcPath}/sorc/*.F*") - if( f_FILES ) - set( ${varDir} "${srcPath}/sorc" PARENT_SCOPE) - set( ${varCacheName} "${srcPath}/sorc" CACHE STRING "" FORCE ) - else() - file(GLOB f_FILES "${srcPath}/sorc/libsrc/*.f*" - "${srcPath}/sorc/libsrc/*.F*") - if( f_FILES ) - set( ${varDir} "${srcPath}/sorc/libsrc" PARENT_SCOPE) - set( ${varCacheName} "${srcPath}/sorc/libsrc" CACHE STRING "" FORCE ) - endif() - endif() - endif() - endif() - endif() - endif() - endif() -endfunction() - -function (findInc incName version incFile ) - cmake_policy(SET CMP0011 NEW) - cmake_policy(SET CMP0009 NEW) - STRING(COMPARE EQUAL ${incFile} "CRTMINC" USECRTMBASE ) - if(( USECRTMBASE ) AND ( CRTM_BASE )) - execute_process(COMMAND find ${CRTM_BASE} -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) -# file(GLOB_RECURSE INCFILES ${CRTM_BASE}/*${CRTM_VER}*/*mod ) -# file(GLOB_RECURSE INCFILES2 ${CRTM_BASE}/crtm/*${CRTM_VER}*/*/*mod ) -# list(APPEND INCFILES ${INCFILES2} ) - else() - if(crayComp) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - execute_process(COMMAND find ${COREPATH}/${incName}/v${${version}}/intel -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - else() - execute_process(COMMAND find ${COREPATH}/${incName}/v${${version}}/cray -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - endif() - else() - execute_process(COMMAND find ${COREPATH}/${incName} -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - endif() - if( NOT (INCFILES) ) - execute_process(COMMAND find ${COREPATH}/sorc -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - endif() - endif() -# message("incfiles are ${INCFILES}") - if( INCFILES ) - string(REGEX REPLACE "\n" ";" INCFILES ${INCFILES} ) - endif() - foreach( INC_FILE in ${INCFILES} ) - string(REGEX MATCH ${${version}} MATCHFOUND ${INC_FILE} ) -# message("matchfound is ${MATCHFOUND}, version is ${${version}} for ${INC_FILE}") - if( MATCHFOUND ) - message("found ${INC_FILE}") - string(REGEX REPLACE "${incName}_module.mod" "" INCPATH ${INC_FILE} ) - set( ${incFile} ${INCPATH} PARENT_SCOPE ) - return() - endif() - endforeach() - file(GLOB_RECURSE INCFILES ${COREPATH}/${incName}_module.mod ) - list(LENGTH INCFILES numFiles) - if(numFiles EQUAL 1) - get_filename_component( INCPATH ${INCFILES} DIRECTORY ) - else() - foreach( INC_FILE in ${INCFILES} ) - get_filename_component( INCPATH ${INC_FILE} DIRECTORY ) -# message("WARNING: Did not find explicit version ${${version}} of ${incName} module, using un-versioned path") -# set( ${incFile} ${INCPATH} PARENT_SCOPE ) -# return() - endforeach() - endif() - set( ${incFile} ${INCPATH} PARENT_SCOPE ) -endfunction() - -function (findOtherVersion rootPath srcName srcPath newVer ) - file(GLOB SRCDIRS ${${rootPath}}/${srcName}* ) - foreach( SRC_DIR in ${SRCDIRS} ) - string(REGEX MATCH ${srcName} MATCHFOUND ${SRC_DIR} ) - if( MATCHFOUND ) - set( ${srcPath} ${SRC_DIR} PARENT_SCOPE ) - string(REGEX MATCH "[0-9].[0-9].[0-9]" ALTVER ${SRC_DIR} ) - message("Found ${ALTVER} of ${srcName}. Proceeding with Alternative") - set( ${newVer} ${ALTVER} PARENT_SCOPE ) - return() - endif() - endforeach() -endfunction() diff --git a/cmake/Modules/platforms/Acorn.cmake b/cmake/Modules/platforms/Acorn.cmake deleted file mode 100644 index 8bb4cb94da..0000000000 --- a/cmake/Modules/platforms/Acorn.cmake +++ /dev/null @@ -1,13 +0,0 @@ -macro (setAcorn) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -endmacro() diff --git a/cmake/Modules/platforms/Cheyenne.cmake b/cmake/Modules/platforms/Cheyenne.cmake deleted file mode 100644 index 54477168e8..0000000000 --- a/cmake/Modules/platforms/Cheyenne.cmake +++ /dev/null @@ -1,24 +0,0 @@ -macro (setCheyenne) - message("Setting paths for Cheyenne") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - - set(BUILD_CORELIBS "ON" ) - set(BUILD_UTIL "OFF" CACHE INTERNAL "" ) - set(BUILD_BUFR "ON" CACHE INTERNAL "") - set(BUILD_SFCIO "ON" CACHE INTERNAL "") - set(BUILD_SIGIO "ON" CACHE INTERNAL "") - set(BUILD_W3EMC "ON" CACHE INTERNAL "") - set(BUILD_W3NCO "ON" CACHE INTERNAL "") - set(BUILD_BACIO "ON" CACHE INTERNAL "") - set(BUILD_CRTM "ON" CACHE INTERNAL "") - set(BUILD_SP "ON" CACHE INTERNAL "") - set(BUILD_NEMSIO "ON" CACHE INTERNAL "") - set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) -endmacro() - diff --git a/cmake/Modules/platforms/Discover.cmake b/cmake/Modules/platforms/Discover.cmake deleted file mode 100644 index fe8a2dfc0e..0000000000 --- a/cmake/Modules/platforms/Discover.cmake +++ /dev/null @@ -1,55 +0,0 @@ -macro (setDiscover) - message("Setting paths for Discover") -# option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) -# option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(host "Discover" CACHE INTERNAL "") - - set(COREPATH $ENV{COREPATH} ) - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.1.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.2.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() - - if( ENV{BASEDIR} ) - set(BASEDIR $ENV{BASEDIR}/Linux CACHE INTERNAL "") - endif() - set(BUILD_CORELIBS "ON" CACHE INTERNAL "") - set(USE_WRF "OFF" CACHE INTERNAL "") - set(BUILD_GLOBAL "ON" CACHE INTERNAL "") - - set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) - -endmacro() - diff --git a/cmake/Modules/platforms/Gaea.cmake b/cmake/Modules/platforms/Gaea.cmake deleted file mode 100644 index d6929b8f03..0000000000 --- a/cmake/Modules/platforms/Gaea.cmake +++ /dev/null @@ -1,14 +0,0 @@ -macro (setGaea) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "-xCORE-AVX2" CACHE INTERNAL "Host Flag") # for Haswell (C4) - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${MKL_FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(BUILD_CORELIBS "OFF" ) -endmacro() diff --git a/cmake/Modules/platforms/Generic.cmake b/cmake/Modules/platforms/Generic.cmake deleted file mode 100644 index 24f40107d5..0000000000 --- a/cmake/Modules/platforms/Generic.cmake +++ /dev/null @@ -1,25 +0,0 @@ -macro (setGeneric) - message("Setting paths for Generic System") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - if(EXISTS /jetmon) - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required - else() - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required - endif() - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - - message("setting values for corelibs") - set(BUILD_BUFR "OFF" CACHE INTERNAL "Build the BUFR library" ) - set(BUILD_BACIO "OFF" CACHE INTERNAL "Build the BACIO library" ) - set(BUILD_SFCIO "OFF" CACHE INTERNAL "Build the SFCIO library" ) - set(BUILD_SIGIO "OFF" CACHE INTERNAL "Build the SIGIO library" ) - set(BUILD_NEMSIO "OFF" CACHE INTERNAL "Build the NEMSIO library" ) - set(BUILD_SP "OFF" CACHE INTERNAL "Build the SP library" ) - set(BUILD_CRTM "OFF" CACHE INTERNAL "Build the CRTM library" ) - set(BUILD_W3EMC "OFF" CACHE INTERNAL "Build the EMC library" ) - set(BUILD_W3NCO "OFF" CACHE INTERNAL "Build the EMC library" ) - set(BUILD_NCO "OFF" CACHE INTERNAL "Build the NCO library" ) -endmacro() diff --git a/cmake/Modules/platforms/Hera.cmake b/cmake/Modules/platforms/Hera.cmake deleted file mode 100644 index d8af27696c..0000000000 --- a/cmake/Modules/platforms/Hera.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setHERA) - message("Setting paths for HERA") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/Jet.cmake b/cmake/Modules/platforms/Jet.cmake deleted file mode 100644 index 824585e366..0000000000 --- a/cmake/Modules/platforms/Jet.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setJet) - message("Setting paths for Jet") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-axSSE4.2,AVX,CORE-AVX2" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/Orion.cmake b/cmake/Modules/platforms/Orion.cmake deleted file mode 100644 index 56ddd1f2c3..0000000000 --- a/cmake/Modules/platforms/Orion.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setOrion) - message("Setting paths for Orion") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/S4.cmake b/cmake/Modules/platforms/S4.cmake deleted file mode 100644 index 8c19f11a32..0000000000 --- a/cmake/Modules/platforms/S4.cmake +++ /dev/null @@ -1,10 +0,0 @@ -macro (setS4) - message("Setting paths for S4") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-march=ivybridge" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "OFF") -endmacro() diff --git a/cmake/Modules/platforms/WCOSS-C.cmake b/cmake/Modules/platforms/WCOSS-C.cmake deleted file mode 100644 index 1c9cf712cd..0000000000 --- a/cmake/Modules/platforms/WCOSS-C.cmake +++ /dev/null @@ -1,60 +0,0 @@ -macro (setWCOSS_C) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/gpfs/hps/nco/ops/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/gpfs/hps/nco/ops/nwprod/lib/crtm" ) - endif() - if( NOT DEFINED ENV{WRFPATH} ) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-intel" ) - else() - set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-cray" ) - endif() - else() - set(WRFPATH $ENV{WRFPATH} ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "11.0.1" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.2" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.2.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() diff --git a/cmake/Modules/platforms/WCOSS-D.cmake b/cmake/Modules/platforms/WCOSS-D.cmake deleted file mode 100644 index 19a853e609..0000000000 --- a/cmake/Modules/platforms/WCOSS-D.cmake +++ /dev/null @@ -1,48 +0,0 @@ -macro (setWCOSS_D) - message("Setting paths for Dell") - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "GSI Fortran Flags") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS} ${MKL_FLAG}" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "ENKF Fortran Flags") - - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/gpfs/dell1/nco/ops/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/gpfs/dell1/nco/ops/nwprod/lib/crtm" ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "11.3.0" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.5" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.3.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() diff --git a/cmake/Modules/platforms/WCOSS.cmake b/cmake/Modules/platforms/WCOSS.cmake deleted file mode 100644 index 81b1297392..0000000000 --- a/cmake/Modules/platforms/WCOSS.cmake +++ /dev/null @@ -1,61 +0,0 @@ -macro (setWCOSS) - message("Setting paths for WCOSS") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - #if ibmpe module is not loaded last, CMake tries to use intel mpi. Force use of ibmhpc - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set( MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -traceback -O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${HOST_FLAG} " CACHE INTERNAL "") - - set(MPI_Fortran_COMPILER /opt/ibmhpc/pe13010/base/bin/mpif90 CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - set(MPI_C_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicc CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - set(MPI_CXX_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicxx CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/nwprod2/lib" ) - endif() - if( NOT DEFINED ENV{WRFPATH} ) - set(WRFPATH "/nwprod/sorc/wrf_shared.fd" ) - else() - set(WRFPATH $ENV{WRFPATH} ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() - -endmacro() diff --git a/cmake/Modules/setGNUFlags.cmake b/cmake/Modules/setGNUFlags.cmake deleted file mode 100644 index e4ef2d9ade..0000000000 --- a/cmake/Modules/setGNUFlags.cmake +++ /dev/null @@ -1,66 +0,0 @@ -function (setGNU) - set(COMPILER_TYPE "gnu" CACHE INTERNAL "Compiler brand") - message("Setting GNU Compiler Flags") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set(GSI_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - set(BUFR_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -O3 -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BACIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -std=f2003 -fdollar-ok -O3 -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -O3 -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "") - set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") - else( ) #DEBUG - set(GSI_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -fbacktrace -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - set(BUFR_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -fbacktrace -g -fbacktrace -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BACIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -fbacktrace -std=f2003 -fdollar-ok -g -fbacktrace -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -g -fbacktrace -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -fbacktrace -Wl,-noinhibit-exec" CACHE INTERNAL "") - set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") - endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) -endfunction() - diff --git a/cmake/Modules/setHOST.cmake b/cmake/Modules/setHOST.cmake deleted file mode 100644 index 861e9fc636..0000000000 --- a/cmake/Modules/setHOST.cmake +++ /dev/null @@ -1,105 +0,0 @@ -macro( setHOST ) - site_name(HOSTNAME) - message("The hostname is ${HOSTNAME}" ) - string(REGEX MATCH "s4-" HOST-S4 ${HOSTNAME} ) - string(REGEX MATCH "gaea" HOST-Gaea ${HOSTNAME} ) - string(REGEX MATCH "hfe[0-9]" HOST-Hera ${HOSTNAME} ) - string(REGEX MATCH "Orion" HOST-Orion ${HOSTNAME} ) - if(EXISTS /jetmon) - set(HOST-Jet "True" ) - endif() - string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - if( HOST-WCOSS ) - message("host is WCOSS") - endif() - string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - if( NOT HOST-WCOSS ) # don't overwrite if we are on gyre - string(REGEX MATCH "t[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - endif() - string(REGEX MATCH "v[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus Phase 3 - string(REGEX MATCH "v[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - endif() - if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus/Phase 3.5 - string(REGEX MATCH "m[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - if( NOT HOST-WCOSS_D )# don't overwrite if we are on mars Phase 3 - string(REGEX MATCH "m[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - endif() - endif() - string(REGEX MATCH "llogin" HOST-WCOSS_C ${HOSTNAME} ) - if( NOT HOST-WCOSS_C )# don't overwrite if we are on luna - string(REGEX MATCH "slogin" HOST-WCOSS_C ${HOSTNAME} ) - endif() - string(REGEX MATCH "alogin01" HOST-Acorn ${HOSTNAME} ) - if( NOT HOST-Acorn )# don't overwrite if we are on node 1 - string(REGEX MATCH "alogin02" HOST-Acorn ${HOSTNAME} ) - endif() - string(REGEX MATCH "discover" HOST-Discover ${HOSTNAME} ) - string(REGEX MATCH "cheyenne" HOST-Cheyenne ${HOSTNAME} ) - message("done figuring out host--${HOSTNAME}") - if ( COMGSI ) - set( host "GENERIC" ) - set( HOST-Generic "TRUE" ) - setGeneric() - elseif(HOST-Jet) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "Jet" ) - set( HOST-Jet "TRUE" ) - setJet() - elseif( HOST-S4 ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "S4" ) - set( HOST-S4 "TRUE" ) - setS4() - elseif( HOST-WCOSS ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "WCOSS" ) - set( HOST-WCOSS "TRUE" ) - setWCOSS() - elseif( HOST-Hera ) - set( host "Hera" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setHERA() - set( HOST-Hera "TRUE" ) - elseif( HOST-Orion ) - set( host "Orion" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setOrion() - set( HOST-Orion "TRUE" ) - elseif( HOST-Gaea ) - set( host "Gaea" ) - option(BUILD_CORELIBS "Build the Core libraries " On) - setGaea() - set( HOST-Gaea "TRUE" ) - elseif( HOST-Cheyenne ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - set( host "Cheyenne" ) - setCheyenne() - set( HOST-Cheyenne "TRUE" ) - elseif( HOST-WCOSS_C ) - set( host "WCOSS_C" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS_C() - set( HOST-WCOSS_C "TRUE" ) - elseif( HOST-WCOSS_D ) - set( host "WCOSS_D" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS_D() - set( HOST-WCOSS_D "TRUE" ) - elseif( HOST-Discover ) - set(host "Discover" ) - setDiscover() - set( HOST-Discover "TRUE" ) - elseif( HOST-Acorn ) - set( host "Acorn" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setAcorn() - set( HOST-Acorn "TRUE" ) - else( ) - set( host "GENERIC" ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - setGeneric() - set( HOST-Generic "TRUE" ) - endif() - message("Host is set to ${host}") -endmacro() diff --git a/cmake/Modules/setIntelFlags.cmake b/cmake/Modules/setIntelFlags.cmake deleted file mode 100644 index 88e5061ffc..0000000000 --- a/cmake/Modules/setIntelFlags.cmake +++ /dev/null @@ -1,94 +0,0 @@ -set(intsize 4) -function(set_LIBRARY_UTIL_Intel) - set(BACIO_Fortran_FLAGS "-O3 -free -assume nocc_omp ${HOST_FLAG} " CACHE INTERNAL "" ) - set(BUFR_Fortran_FLAGS "-O2 -r8 -fp-model strict -traceback -O3 ${HOST_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(BUFR_C_FLAGS "-DSTATIC_ALLOCATION -DUNDERSCORE -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) - set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) - set (CRTM_Fortran_FLAGS " -O3 -convert big_endian -free -assume byterecl -fp-model source -traceback ${HOST_FLAG}" CACHE INTERNAL "" ) - set (NEMSIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SFCIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SIGIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_Fortran_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_Fortran_4_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_F77_FLAGS " -DLINUX -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3EMC_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3EMC_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_C_FLAGS "-O0 -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) - set (NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "" ) - set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) - set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DWRF -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone" CACHE INTERNAL "") -# set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian -D_REAL8_ -openmp -fpp -auto" CACHE INTERNAL "" ) - set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -# set(COV_CALC_FLAGS ${GSI_Intel_Platform_FLAGS} CACHE INTERNAL "Full GSI Fortran FLAGS" ) -endfunction(set_LIBRARY_UTIL_Intel) - -function(set_LIBRARY_UTIL_Debug_Intel) - set (BACIO_Fortran_FLAGS "-g -free -assume nocc_omp " CACHE INTERNAL "" ) - set(BUFR_Fortran_FLAGS " -c -g -traceback -O3 -axCORE-AVX2 -r8 " CACHE INTERNAL "" ) - set(BUFR_C_FLAGS "-g -traceback -DUNDERSCORE -O3 -axCORE-AVX2 -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) - set(CRTM_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SFCIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SIGIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_Fortran_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -r8 -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_Fortran_4_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_F77_FLAGS " -g -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3EMC_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3EMC_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(NEMSIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_C_FLAGS "-O0 -g -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) - set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) - set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) - set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O1 -g -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -Wl,-noinhibit-exec" CACHE INTERNAL "" ) - set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS "-O0 -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian" CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) -endfunction(set_LIBRARY_UTIL_Debug_Intel) - -function(set_GSI_ENKF_Intel) - #Common release/production flags - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) - set(GSI_Fortran_FLAGS "${GSI_Intel_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full GSI Fortran FLAGS" ) - set(ENKF_Fortran_FLAGS "${ENKF_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full ENKF Fortran FLAGS" ) - set(GSDCLOUD_Fortran_FLAGS "-O3 -convert big_endian" CACHE INTERNAL "") -endfunction(set_GSI_ENKF_Intel) - -function (set_GSI_ENKF_Debug_Intel) - set(GSI_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O0 -fp-model source -convert big_endian -assume byterecl -implicitnone -g -traceback -debug -ftrapuv -check all,noarg_temp_created -fp-stack-check -fstack-protector -warn all,nointerfaces -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") - set(ENKF_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug all -check all,noarg_temp_created -fp-model strict -convert big_endian -assume byterecl -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -convert big_endian" CACHE INTERNAL "") - #Common debug flags - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) -endfunction (set_GSI_ENKF_Debug_Intel) - -function (setIntel) - string(REPLACE "." ";" COMPILER_VERSION_LIST ${CMAKE_C_COMPILER_VERSION}) - list(GET COMPILER_VERSION_LIST 0 MAJOR_VERSION) - list(GET COMPILER_VERSION_LIST 1 MINOR_VERSION) - list(GET COMPILER_VERSION_LIST 2 PATCH_VERSION) - set(COMPILER_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" CACHE INTERNAL "Compiler Version") - set(COMPILER_TYPE "intel" CACHE INTERNAL "Compiler brand") - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION) - set(EXTRA_LINKER_FLAGS ${MKL_FLAG} CACHE INTERNAL "Extra Linker flags") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set_GSI_ENKF_Intel() - set_LIBRARY_UTIL_Intel() - else( ) #DEBUG flags - message("Building DEBUG version of GSI") - set( debug_suffix "_DBG" CACHE INTERNAL "" ) - set_GSI_ENKF_Debug_Intel() - set_LIBRARY_UTIL_Debug_Intel() - endif() -endfunction() - diff --git a/cmake/Modules/setPGIFlags.cmake b/cmake/Modules/setPGIFlags.cmake deleted file mode 100644 index 2088a7416d..0000000000 --- a/cmake/Modules/setPGIFlags.cmake +++ /dev/null @@ -1,78 +0,0 @@ -function (setPGI) - message("Setting PGI Compiler Flags") - set(COMPILER_TYPE "pgi" CACHE INTERNAL "Compiler brand") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set(CMAKE_Fortran_FLAGS_RELEASE "") - set(Fortran_FLAGS "" CACHE INTERNAL "") - set(GSI_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -O3 -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -O3 -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -O3 -byteswapio -fast" CACHE INTERNAL "") - - set(BUFR_Fortran_FLAGS "-O1 -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - - set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") - set(BACIO_Fortran_FLAGS " -O3 -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -O1 -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -O3 -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -O3 -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_4_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -O1 -byteswapio " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -DLINUX -O1 -byteswapio " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -O1 -D_REAL8_ -mp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 " CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 -byteswapio -mp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") - if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) - set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) - else() - set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) - endif() - else() - set(Fortran_FLAGS "" CACHE INTERNAL "") - set(GSI_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -traceback -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -g -traceback -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -g -traceback -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -g -traceback -byteswapio -fast" CACHE INTERNAL "") - - set(BUFR_Fortran_FLAGS "-g -traceback -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -traceback -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - - set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") - set(BACIO_Fortran_FLAGS " -g -traceback -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -traceback -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -g -traceback -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -g -traceback -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_4_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -g -traceback -D_REAL8_ -mp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -traceback " CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 -byteswapio -traceback -mp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") - if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) - set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) - else() - set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) - endif() - endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) -endfunction() diff --git a/cmake/Modules/setPlatformVariables.cmake b/cmake/Modules/setPlatformVariables.cmake deleted file mode 100644 index 9938e090f0..0000000000 --- a/cmake/Modules/setPlatformVariables.cmake +++ /dev/null @@ -1,12 +0,0 @@ -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Jet.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-C.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/S4.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Hera.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Orion.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Gaea.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Cheyenne.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Discover.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-D.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Acorn.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Generic.cmake) From 3e92d1b91c7ee109c42b6e22c6c0fbc104e2bba9 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 3 Mar 2022 22:37:37 -0500 Subject: [PATCH 24/58] remove top-level cmake/ directory --- CMakeLists.txt | 1 - cmake/FindNetCDF.cmake | 347 ----------------------------------------- 2 files changed, 348 deletions(-) delete mode 100644 cmake/FindNetCDF.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ca47abb017..8d80665ea0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ project(gsi VERSION 1.0.0 LANGUAGES C Fortran) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) include(GNUInstallDirs) diff --git a/cmake/FindNetCDF.cmake b/cmake/FindNetCDF.cmake deleted file mode 100644 index 9e32378ff5..0000000000 --- a/cmake/FindNetCDF.cmake +++ /dev/null @@ -1,347 +0,0 @@ -# (C) Copyright 2011- ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# In applying this licence, ECMWF does not waive the privileges and immunities -# granted to it by virtue of its status as an intergovernmental organisation nor -# does it submit to any jurisdiction. - -# Try to find NetCDF includes and library. -# Supports static and shared libaries and allows each component to be found in sepearte prefixes. -# -# This module defines -# -# - NetCDF_FOUND - System has NetCDF -# - NetCDF_INCLUDE_DIRS - the NetCDF include directories -# - NetCDF_VERSION - the version of NetCDF -# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found -# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf -# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support -# -# Deprecated Defines -# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. -# -# -# Following components are available: -# -# - C - C interface to NetCDF (netcdf) -# - CXX - CXX4 interface to NetCDF (netcdf_c++4) -# - Fortran - Fortran interface to NetCDF (netcdff) -# -# For each component the following are defined: -# -# - NetCDF__FOUND - whether the component is found -# - NetCDF__LIBRARIES - the libraries for the component -# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared -# - NetCDF__INCLUDE_DIRS - the include directories for specified component -# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() -# -# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) -# -# - NetCDF_ROOT - root of NetCDF installation -# - NetCDF_PATH - root of NetCDF installation -# -# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, -# set one of the following CMake or environment variables to point to the location: -# -# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR -# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR -# -# Notes: -# -# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. -# - These targets have all the knowledge of include directories and library search directories, and a single -# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is -# needed to build and link against NetCDF is, e.g.: -# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) -# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables -# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 -# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable -# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX -# - For compatibility, alternate capitalizations are supported but should not be used. -# - If no components are defined, all components will be searched -# - -list( APPEND _possible_components C CXX Fortran ) - -## Include names for each component -set( NetCDF_C_INCLUDE_NAME netcdf.h ) -set( NetCDF_CXX_INCLUDE_NAME netcdf ) -set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) - -## Library names for each component -set( NetCDF_C_LIBRARY_NAME netcdf ) -set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) -set( NetCDF_Fortran_LIBRARY_NAME netcdff ) - -## Enumerate search components -foreach( _comp ${_possible_components} ) - string( TOUPPER "${_comp}" _COMP ) - set( _arg_${_COMP} ${_comp} ) - set( _name_${_COMP} ${_comp} ) -endforeach() - -set( _search_components C) -foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) - string( TOUPPER "${_comp}" _COMP ) - set( _arg_${_COMP} ${_comp} ) - list( APPEND _search_components ${_name_${_COMP}} ) - if( NOT _name_${_COMP} ) - message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) - endif() -endforeach() -list( REMOVE_DUPLICATES _search_components ) - -## Search hints for finding include directories and libraries -foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) - foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) - foreach( _var IN ITEMS ROOT PATH ) - list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) - list(APPEND _include_search_hints - ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} - ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) - endforeach() - endforeach() -endforeach() -#Old-school HPC module env variable names -foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) - foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) - list(APPEND _search_hints ${${_name}} $ENV{${_name}}) - list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) - endforeach() -endforeach() - -## Find headers for each component -set(NetCDF_INCLUDE_DIRS) -set(_new_search_components) -foreach( _comp IN LISTS _search_components ) - if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) - list(APPEND _new_search_components ${_comp}) - endif() - find_file(NetCDF_${_comp}_INCLUDE_FILE - NAMES ${NetCDF_${_comp}_INCLUDE_NAME} - DOC "NetCDF ${_comp} include directory" - HINTS ${_include_search_hints} ${_search_hints} - PATH_SUFFIXES include include/netcdf - ) - mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) - message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") - if( NetCDF_${_comp}_INCLUDE_FILE ) - get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) - get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) - list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) - endif() -endforeach() -if(NetCDF_INCLUDE_DIRS) - list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) -endif() -set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) - -## Find n*-config executables for search components -foreach( _comp IN LISTS _search_components ) - if( _comp MATCHES "^(C)$" ) - set(_conf "c") - elseif( _comp MATCHES "^(Fortran)$" ) - set(_conf "f") - elseif( _comp MATCHES "^(CXX)$" ) - set(_conf "cxx4") - endif() - find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE - NAMES n${_conf}-config - HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} - PATH_SUFFIXES bin Bin ../bin ../../bin - DOC "NetCDF n${_conf}-config helper" ) - message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") -endforeach() - -set(_C_libs_flag --libs) -set(_Fortran_libs_flag --flibs) -set(_CXX_libs_flag --libs) -set(_C_includes_flag --includedir) -set(_Fortran_includes_flag --includedir) -set(_CXX_includes_flag --includedir) -function(netcdf_config exec flag output_var) - set(${output_var} False PARENT_SCOPE) - if( exec ) - execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) - if( _ret EQUAL 0 ) - string( STRIP ${_val} _val ) - set( ${output_var} ${_val} PARENT_SCOPE ) - endif() - endif() -endfunction() - -## Detect additional package properties -netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) -if( NOT _val MATCHES "^(yes|no)$" ) - netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) -endif() -if( _val MATCHES "^(yes)$" ) - set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) -else() - set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) -endif() - -if(NetCDF_PARALLEL) - find_package(MPI REQUIRED) -endif() - -## Find libraries for each component -set( NetCDF_LIBRARIES ) -foreach( _comp IN LISTS _search_components ) - string( TOUPPER "${_comp}" _COMP ) - - find_library( NetCDF_${_comp}_LIBRARY - NAMES ${NetCDF_${_comp}_LIBRARY_NAME} - DOC "NetCDF ${_comp} library" - HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} - PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) - mark_as_advanced( NetCDF_${_comp}_LIBRARY ) - get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) - set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) - message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") - - if( NetCDF_${_comp}_LIBRARY ) - if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) - set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) - set( _library_type STATIC) - else() - list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) - set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) - set( _library_type SHARED) - endif() - endif() - - #Use nc-config to set per-component LIBRARIES variable if possible - netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) - if( _val ) - set( NetCDF_${_comp}_LIBRARIES ${_val} ) - if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. - list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) - endif() - else() - set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) - if(NOT NetCDF_${_comp}_LIBRARY_SHARED) - message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") - endif() - endif() - - #Use nc-config to set per-component INCLUDE_DIRS variable if possible - netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) - if( _val ) - string( REPLACE " " ";" _val ${_val} ) - set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) - else() - set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) - endif() - - if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) - set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) - if (NOT TARGET NetCDF::NetCDF_${_comp}) - add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) - set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES - IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) - if( NOT _comp MATCHES "^(C)$" ) - target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) - endif() - if(MPI_${_comp}_FOUND) - target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) - endif() - endif() - endif() -endforeach() -if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) - list(REMOVE_DUPLICATES NetCDF_LIBRARIES) -endif() -set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) - -## Find version via netcdf-config if possible -if (NetCDF_INCLUDE_DIRS) - if( NetCDF_C_CONFIG_EXECUTABLE ) - netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) - if( _vers ) - string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) - endif() - else() - foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) - if( EXISTS "${_dir}/netcdf_meta.h" ) - file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines - REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") - string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") - string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") - string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") - string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") - set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") - unset(_netcdf_version_major) - unset(_netcdf_version_minor) - unset(_netcdf_version_patch) - unset(_netcdf_version_note) - unset(_netcdf_version_lines) - endif() - endforeach() - endif() -endif () - -## Finalize find_package -include(FindPackageHandleStandardArgs) - -if(NOT NetCDF_FOUND OR _new_search_components) - find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} - REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES - VERSION_VAR NetCDF_VERSION - HANDLE_COMPONENTS ) -endif() - -foreach( _comp IN LISTS _search_components ) - if( NetCDF_${_comp}_FOUND ) - #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries - set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) - #Set a per-package, per-component found variable to communicate between multiple calls to find_package() - set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) - endif() -endforeach() - -if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) - message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) - message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") - message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") - foreach( _comp IN LISTS _new_search_components ) - string( TOUPPER "${_comp}" _COMP ) - message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") - if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) - get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) - if( NetCDF_${_comp}_LIBRARY_SHARED ) - message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") - else() - message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") - endif() - endif() - endforeach() -endif() - -foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) - set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) - set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) - set( ${_prefix}_VERSION ${NetCDF_VERSION} ) - set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) - set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) - set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) - - foreach( _comp ${_search_components} ) - string( TOUPPER "${_comp}" _COMP ) - set( _arg_comp ${_arg_${_COMP}} ) - set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) - set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) - set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) - - set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) - set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) - set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) - - set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) - set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) - set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) - endforeach() -endforeach() From 7988b92bb395c038cbbc369ebdbcca2d41cb6278 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 4 Mar 2022 13:05:07 -0500 Subject: [PATCH 25/58] add host specific flags to module files --- modulefiles/modulefile.ProdGSI.acorn | 5 +++-- modulefiles/modulefile.ProdGSI.cheyenne | 4 ++++ modulefiles/modulefile.ProdGSI.discover | 5 +++++ modulefiles/modulefile.ProdGSI.gaea | 5 +++++ modulefiles/modulefile.ProdGSI.hera | 13 ++++++++++--- modulefiles/modulefile.ProdGSI.jet | 13 ++++++++++--- modulefiles/modulefile.ProdGSI.orion | 8 +++++++- modulefiles/modulefile.ProdGSI.s4 | 13 ++++++++++--- modulefiles/modulefile.ProdGSI.wcoss_c | 5 +++++ modulefiles/modulefile.ProdGSI.wcoss_d | 10 ++++++++-- 10 files changed, 67 insertions(+), 14 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.acorn b/modulefiles/modulefile.ProdGSI.acorn index 52b4afc341..2daa3a23d1 100644 --- a/modulefiles/modulefile.ProdGSI.acorn +++ b/modulefiles/modulefile.ProdGSI.acorn @@ -24,8 +24,9 @@ module load prod_util/2.0.4 module load sfcio/1.4.1 module load sigio/2.3.2 module load sp/2.3.3 -module load w3emc/2.7.3 -module load w3nco/2.4.1 +module load w3emc/2.9.1 +module load wrf_io/1.2.0 +module load ncio/1.0.0 module load cmake/3.18.4 module load git/2.29.0 diff --git a/modulefiles/modulefile.ProdGSI.cheyenne b/modulefiles/modulefile.ProdGSI.cheyenne index 211b681ad7..430f4fd7dc 100644 --- a/modulefiles/modulefile.ProdGSI.cheyenne +++ b/modulefiles/modulefile.ProdGSI.cheyenne @@ -13,4 +13,8 @@ module load mkl/2018.0.1 module load netcdf/4.5.0 module list +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + echo "done loading modules" diff --git a/modulefiles/modulefile.ProdGSI.discover b/modulefiles/modulefile.ProdGSI.discover index 2c6d32b661..4f4b04047f 100644 --- a/modulefiles/modulefile.ProdGSI.discover +++ b/modulefiles/modulefile.ProdGSI.discover @@ -13,3 +13,8 @@ module load other/comp/gcc-9.1 module load other/cmake-3.8.2 setenv BASEDIR /discover/nobackup/projects/gmao/share/gmao_ops/Baselibs/v5.1.3_build1/x86_64-unknown-linux-gnu/ifort_18.0.3.222-mpt_2.17 + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + diff --git a/modulefiles/modulefile.ProdGSI.gaea b/modulefiles/modulefile.ProdGSI.gaea index 163da2c707..91089895a1 100644 --- a/modulefiles/modulefile.ProdGSI.gaea +++ b/modulefiles/modulefile.ProdGSI.gaea @@ -58,3 +58,8 @@ module load crtm-intel/2.2.4 module load bacio-intel-sandybridge/2.0.2 setenv CRAYOS_VERSION $::env(CRAYPE_VERSION) #setenv CRAYOS_VERSION ${CRAYPE_VERSION} + +# Compiler flags specific to this platform +setenv CFLAGS "-xCORE-AVX2" +setenv FFLAGS "-xCORE-AVX2" + diff --git a/modulefiles/modulefile.ProdGSI.hera b/modulefiles/modulefile.ProdGSI.hera index aa158d2b89..6ed61c594a 100644 --- a/modulefiles/modulefile.ProdGSI.hera +++ b/modulefiles/modulefile.ProdGSI.hera @@ -30,6 +30,8 @@ module load anaconda/2.3.0 # Load production utilities module load prod_util/1.2.2 +module load netcdf/4.7.4 + # Load nceplibs module load bufr/11.4.0 module load ip/3.3.3 @@ -37,8 +39,13 @@ module load nemsio/2.5.2 module load sfcio/1.4.1 module load sigio/2.3.2 module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 +module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 -module load netcdf/4.7.4 +module load wrf_io/1.2.0 +module load ncio/1.0.0 + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + diff --git a/modulefiles/modulefile.ProdGSI.jet b/modulefiles/modulefile.ProdGSI.jet index 812b46fb0d..0152f51128 100644 --- a/modulefiles/modulefile.ProdGSI.jet +++ b/modulefiles/modulefile.ProdGSI.jet @@ -30,6 +30,8 @@ module load hpc-impi/2018.4.274 # Load production utilities module load prod_util/1.2.2 +module load netcdf/4.7.4 + # Load nceplibs module load bufr/11.4.0 module load ip/3.3.3 @@ -37,8 +39,13 @@ module load nemsio/2.5.2 module load sfcio/1.4.1 module load sigio/2.3.2 module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 +module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 -module load netcdf/4.7.4 +module load wrf_io/1.2.0 +module load ncio/1.0.0 + +# Compiler flags specific to this platform +setenv CFLAGS "-axSSE4.2,AVX,CORE-AVX2" +setenv FFLAGS "-axSSE4.2,AVX,CORE-AVX2" + diff --git a/modulefiles/modulefile.ProdGSI.orion b/modulefiles/modulefile.ProdGSI.orion index bc224df54b..921ac2b9f6 100644 --- a/modulefiles/modulefile.ProdGSI.orion +++ b/modulefiles/modulefile.ProdGSI.orion @@ -35,6 +35,8 @@ module load hpc-impi/2018.4 # Load production utilities module load prod_util/1.2.2 +module load netcdf/4.7.4 + # Load nceplibs module load bufr/11.4.0 module load ip/3.3.3 @@ -45,6 +47,10 @@ module load sp/2.3.3 module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 -module load netcdf/4.7.4 module load ncio/1.0.0 module load wrf_io/1.2.0 +module load ncio/1.0.0 + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" diff --git a/modulefiles/modulefile.ProdGSI.s4 b/modulefiles/modulefile.ProdGSI.s4 index 78064580e9..ff89074d2a 100644 --- a/modulefiles/modulefile.ProdGSI.s4 +++ b/modulefiles/modulefile.ProdGSI.s4 @@ -17,6 +17,8 @@ module load miniconda/3.8-s4 # Load production utilities module load prod_util/1.2.2 +module load netcdf/4.7.4 + # Load nceplibs module load bufr/11.4.0 module load ip/3.3.3 @@ -24,8 +26,13 @@ module load nemsio/2.5.2 module load sfcio/1.4.1 module load sigio/2.3.2 module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 +module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 -module load netcdf/4.7.4 +module load wrf_io/1.2.0 +module load ncio/1.0.0 + +# Compiler flags specific to this platform +setenv CFLAGS "-march=ivybridge" +setenv FFLAGS "-march=ivybridge" + diff --git a/modulefiles/modulefile.ProdGSI.wcoss_c b/modulefiles/modulefile.ProdGSI.wcoss_c index f02f4ded73..6d98a926f8 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_c +++ b/modulefiles/modulefile.ProdGSI.wcoss_c @@ -50,3 +50,8 @@ module load crtm-intel/2.3.0 # Loading python module load python/3.6.3 + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + diff --git a/modulefiles/modulefile.ProdGSI.wcoss_d b/modulefiles/modulefile.ProdGSI.wcoss_d index 1cd388d08f..5c2e32521e 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_d +++ b/modulefiles/modulefile.ProdGSI.wcoss_d @@ -10,6 +10,7 @@ setenv CRTM_FIX /gpfs/dell1/nco/ops/nwprod/lib/crtm/v2.3.0/fix + # Load cmake module load cmake/3.16.2 @@ -44,10 +45,15 @@ module load nemsio/2.5.2 module load sfcio/1.4.1 module load sp/2.3.3 module load sigio/2.3.2 -module load w3nco/2.4.1 -module load w3emc/2.7.3 +module load w3emc/2.9.1 module load crtm/2.3.0 +module load wrf_io/1.2.0 +module load ncio/1.0.0 # Load production utilities module load prod_util/1.2.2 +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + From 5ba199d43856afbe1371fe512908bb44e3c19693 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 4 Mar 2022 23:03:03 -0500 Subject: [PATCH 26/58] make packages more robust and handle transitive libraries once and done. --- src/enkf/CMakeLists.txt | 66 +- src/enkf/cmake/PackageConfig.cmake.in | 17 +- src/fv3gfs_ncio/CMakeLists.txt | 10 - src/fv3gfs_ncio/module_fv3gfs_ncio.f90 | 1338 ----------------- src/fv3gfs_ncio/quantize_data_code.f90 | 17 - src/fv3gfs_ncio/read_attribute_code.f90 | 35 - .../read_scalar_attribute_code.f90 | 31 - src/fv3gfs_ncio/read_vardata_code_1d.f90 | 75 - src/fv3gfs_ncio/read_vardata_code_2d.f90 | 81 - src/fv3gfs_ncio/read_vardata_code_3d.f90 | 85 -- src/fv3gfs_ncio/read_vardata_code_4d.f90 | 83 - src/fv3gfs_ncio/read_vardata_code_5d.f90 | 35 - src/fv3gfs_ncio/write_attribute_code.f90 | 37 - src/fv3gfs_ncio/write_vardata_code.f90 | 97 -- src/gsi/CMakeLists.txt | 77 +- src/gsi/cmake/PackageConfig.cmake.in | 10 +- src/ncdiag/CMakeLists.txt | 10 +- src/ncdiag/cmake/PackageConfig.cmake.in | 3 +- util/EFSOI_Utilities/src/CMakeLists.txt | 65 +- .../src/enspreproc_regional.fd/CMakeLists.txt | 24 +- .../src/initialens_regional.fd/CMakeLists.txt | 24 +- 21 files changed, 96 insertions(+), 2124 deletions(-) delete mode 100644 src/fv3gfs_ncio/CMakeLists.txt delete mode 100644 src/fv3gfs_ncio/module_fv3gfs_ncio.f90 delete mode 100644 src/fv3gfs_ncio/quantize_data_code.f90 delete mode 100644 src/fv3gfs_ncio/read_attribute_code.f90 delete mode 100644 src/fv3gfs_ncio/read_scalar_attribute_code.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_1d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_2d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_3d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_4d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_5d.f90 delete mode 100644 src/fv3gfs_ncio/write_attribute_code.f90 delete mode 100644 src/fv3gfs_ncio/write_vardata_code.f90 diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index 6bc2b3698e..b09cd74fbc 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -62,10 +62,7 @@ find_package(sfcio REQUIRED) find_package(nemsio REQUIRED) find_package(ncio REQUIRED) find_package(sp REQUIRED) -find_package(ip REQUIRED) find_package(w3emc REQUIRED) -find_package(bufr REQUIRED) -find_package(crtm REQUIRED) if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") find_package(wrf_io REQUIRED) endif() @@ -109,25 +106,23 @@ elseif(ENKF_APP MATCHES "FV3REG") # WRF application ${EnKF_SRC_fv3reg}) endif() -# Create a library of EnKF Fortran Objects +# Create a library of EnKF Fortran sources set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/enkf") add_library(enkf_fortran_obj OBJECT ${EnKF_SRC_Fortran}) set_target_properties(enkf_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_include_directories(enkf_fortran_obj INTERFACE - $ - $) - -# Link the Fortran targets with dependencies +target_include_directories(enkf_fortran_obj INTERFACE $ + $) +target_compile_definitions(enkf_fortran_obj PRIVATE "_REAL8_") if(TARGET gsi) add_dependencies(enkf_fortran_obj gsi) endif() +target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) if(USE_NCDIAG) if(TARGET ncdiag) add_dependencies(enkf_fortran_obj ncdiag) endif() target_link_libraries(enkf_fortran_obj PUBLIC ncdiag::ncdiag) endif() -target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) target_link_libraries(enkf_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(enkf_fortran_obj PUBLIC MPI::MPI_Fortran) target_link_libraries(enkf_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) @@ -137,63 +132,44 @@ target_link_libraries(enkf_fortran_obj PUBLIC sfcio::sfcio) target_link_libraries(enkf_fortran_obj PUBLIC nemsio::nemsio) target_link_libraries(enkf_fortran_obj PUBLIC ncio::ncio) target_link_libraries(enkf_fortran_obj PUBLIC w3emc::w3emc_d) -target_link_libraries(enkf_fortran_obj PUBLIC crtm::crtm) -if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") - target_link_libraries(enkf_fortran_obj PUBLIC wrf_io::wrf_io) -endif() +target_link_libraries(enkf_fortran_obj PUBLIC sp::sp_d) if(OpenMP_Fortran_FOUND) target_link_libraries(enkf_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) endif() -# Create a EnKF library -add_library(enkf STATIC $) +# Create the EnKF library +add_library(enkf STATIC) add_library(${PROJECT_NAME}::enkf ALIAS enkf) -target_include_directories(enkf PUBLIC $ +set_target_properties(enkf PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(enkf PUBLIC $ $) -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/enkf DESTINATION ${CMAKE_INSTALL_PREFIX}/include) +target_link_libraries(enkf PUBLIC enkf_fortran_obj) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enkf PRIVATE OpenMP::OpenMP_Fortran) +endif() -# Create a EnKF executable -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/enkf") +# Create the EnKF executable add_executable(enkf.x ${EnKF_SRC_main}) add_dependencies(enkf.x enkf) -set_target_properties(enkf.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") target_link_libraries(enkf.x PRIVATE enkf) - -# Link the application targets with dependencies -target_link_libraries(enkf.x PRIVATE gsi::gsi) -if(USE_NCDIAG) - target_link_libraries(enkf.x PRIVATE ncdiag::ncdiag) -endif() -target_link_libraries(enkf.x PRIVATE NetCDF::NetCDF_Fortran) -target_link_libraries(enkf.x PRIVATE MPI::MPI_Fortran) -target_link_libraries(enkf.x PRIVATE ${LAPACK_LIBRARIES}) -target_link_libraries(enkf.x PRIVATE bacio::bacio_4) -target_link_libraries(enkf.x PRIVATE sigio::sigio) -target_link_libraries(enkf.x PRIVATE sfcio::sfcio) -target_link_libraries(enkf.x PRIVATE nemsio::nemsio) -target_link_libraries(enkf.x PRIVATE ncio::ncio) -target_link_libraries(enkf.x PRIVATE w3emc::w3emc_d) -target_link_libraries(enkf.x PRIVATE sp::sp_d) -target_link_libraries(enkf.x PRIVATE bufr::bufr_d) -target_link_libraries(enkf.x PRIVATE crtm::crtm) -if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") - target_link_libraries(enkf_fortran_obj PRIVATE wrf_io::wrf_io) -endif() if(OpenMP_Fortran_FOUND) target_link_libraries(enkf.x PRIVATE OpenMP::OpenMP_Fortran) endif() +# Install Fortran modules +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + # Install executable targets install(TARGETS enkf.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -# Install library archive targets +# Install and export library targets install( - TARGETS enkf + TARGETS enkf_fortran_obj enkf EXPORT ${PROJECT_NAME}Exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -### Package config +# Package config include(CMakePackageConfigHelpers) set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) diff --git a/src/enkf/cmake/PackageConfig.cmake.in b/src/enkf/cmake/PackageConfig.cmake.in index 58468ae7d2..fbf4edf30a 100644 --- a/src/enkf/cmake/PackageConfig.cmake.in +++ b/src/enkf/cmake/PackageConfig.cmake.in @@ -10,8 +10,9 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) -# Set the EnKF Application this library is built for +# Set the EnKF configuration attributes set(ENKF_APP @ENKF_APP@) +set(ENKF_USE_NCDIAG @USE_NCDIAG@) find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) @@ -30,25 +31,24 @@ if(@OPENMP@) find_dependency(OpenMP COMPONENTS Fortran) endif() +find_dependency(gsi REQUIRED) + find_dependency(bacio REQUIRED) find_dependency(sigio REQUIRED) find_dependency(sfcio REQUIRED) find_dependency(nemsio REQUIRED) find_dependency(ncio REQUIRED) find_dependency(sp REQUIRED) -find_dependency(ip REQUIRED) find_dependency(w3emc REQUIRED) -find_dependency(bufr REQUIRED) -find_dependency(crtm REQUIRED) if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") find_dependency(wrf_io REQUIRED) endif() # ON|OFF implies @PROJECT_NAME@ was compiled with/without -USE_NCDIAG=ON|OFF -#if(@USE_NCDIAG@) -# find_dependency(ncdiag REQUIRED) -#endif() +if(ENKF_USE_NCDIAG) + find_dependency(ncdiag REQUIRED) +endif() # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -57,5 +57,6 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") -message(STATUS "FindENKF defines targets:") +message(STATUS "FindEnKF defines targets:") message(STATUS " - ENKF_APP [${ENKF_APP}]") +message(STATUS " - ENKF_USE_NCDIAG [${GSI_USE_NCDIAG}]") diff --git a/src/fv3gfs_ncio/CMakeLists.txt b/src/fv3gfs_ncio/CMakeLists.txt deleted file mode 100644 index 08474d7eba..0000000000 --- a/src/fv3gfs_ncio/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -if(BUILD_FV3GFS_NCIO) - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - # NetCDF-4 library - include_directories( ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS} ) - FILE(GLOB FV3GFS_NCIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/module_fv3gfs_ncio.f90 ) - set_source_files_properties( ${FV3GFS_NCIO_SRC} PROPERTIES COMPILE_FLAGS ${FV3GFS_NCIO_Fortran_FLAGS} ) - add_library(fv3gfs_ncio STATIC ${FV3GFS_NCIO_SRC}) -endif(BUILD_FV3GFS_NCIO) - diff --git a/src/fv3gfs_ncio/module_fv3gfs_ncio.f90 b/src/fv3gfs_ncio/module_fv3gfs_ncio.f90 deleted file mode 100644 index 51b901bf88..0000000000 --- a/src/fv3gfs_ncio/module_fv3gfs_ncio.f90 +++ /dev/null @@ -1,1338 +0,0 @@ -module module_fv3gfs_ncio -! module for reading/writing netcdf global lat/lon grid files output by FV3GFS. -! assumes netcdf classic data model, nf90_format_netcdf4_classic format. -! handles 32 and 64 bit real variables, 8, 16 and 32 bit integer -! variables and char variables. Variables can have up to 5 dimensions. -! jeff whitaker 201910 - - use netcdf - use mpi - - implicit none - private - - type Variable - integer varid ! netCDF variable ID - integer ndims ! number of dimensions - integer dtype ! netCDF data type - integer natts ! number of attributes - integer deflate_level ! compression level (if > 0) - logical shuffle ! shuffle filter? - logical hasunlim ! has an unlimited dim? - character(len=nf90_max_name) :: name ! variable name - integer, allocatable, dimension(:) :: dimids ! netCDF dimension IDs - ! indices into Dataset%dimensions for associated dimensions. - integer, allocatable, dimension(:) :: dimindxs - ! names of associated dimensions. - character(len=nf90_max_name), allocatable, dimension(:) :: dimnames - ! current dimension lengths (updated after every write_vardata call) - integer, allocatable, dimension(:) :: dimlens - integer, allocatable, dimension(:) :: chunksizes - end type Variable - type Dimension - integer dimid ! netCDF dimension ID - integer len ! dimension length (updated after every write_vardata call) - logical isunlimited ! unlimited? - character(len=nf90_max_name) :: name ! name of dimension - end type Dimension - type Dataset - integer :: ncid ! netCDF ID. - integer :: nvars ! number of variables in dataset - integer :: ndims ! number of dimensions in dataset - integer :: natts ! number of dataset (global) attributes - integer :: nunlimdim ! dimension ID for unlimited dimension - logical :: ishdf5 ! is underlying disk format HDF5? - logical :: isparallel ! was file opened for parallel I/O? - character(len=500) filename ! netCDF filename - ! array of Variable instances - type(Variable), allocatable, dimension(:) :: variables - ! array of Dimension instances - type(Dimension), allocatable, dimension(:) :: dimensions - end type Dataset - - interface read_vardata - module procedure read_vardata_1d_r4, read_vardata_2d_r4, read_vardata_3d_r4,& - read_vardata_4d_r4, read_vardata_5d_r4, & - read_vardata_1d_r8, read_vardata_2d_r8, read_vardata_3d_r8,& - read_vardata_4d_r8, read_vardata_5d_r8, & - read_vardata_1d_int, read_vardata_2d_int, & - read_vardata_3d_int, read_vardata_4d_int, read_vardata_5d_int, & - read_vardata_1d_short, read_vardata_2d_short, & - read_vardata_3d_short, read_vardata_4d_short, read_vardata_5d_short , & - read_vardata_1d_byte, read_vardata_2d_byte, & - read_vardata_3d_byte, read_vardata_4d_byte, read_vardata_5d_byte, & - read_vardata_1d_char, read_vardata_2d_char, & - read_vardata_3d_char, read_vardata_4d_char, read_vardata_5d_char - end interface - - interface write_vardata - module procedure write_vardata_1d_r4, write_vardata_2d_r4, write_vardata_3d_r4,& - write_vardata_4d_r4, write_vardata_1d_r8, write_vardata_2d_r8, write_vardata_3d_r8,& - write_vardata_4d_r8, write_vardata_1d_int, write_vardata_2d_int, & - write_vardata_3d_int, write_vardata_4d_int, & - write_vardata_5d_int, write_vardata_5d_r4, write_vardata_5d_r8, & - write_vardata_1d_short, write_vardata_2d_short, write_vardata_3d_short, & - write_vardata_4d_short, write_vardata_5d_short, & - write_vardata_1d_byte, write_vardata_2d_byte, write_vardata_3d_byte, & - write_vardata_4d_byte, write_vardata_5d_byte, & - write_vardata_1d_char, write_vardata_2d_char, write_vardata_3d_char, & - write_vardata_4d_char, write_vardata_5d_char - end interface - - interface read_attribute - module procedure read_attribute_r4_scalar, read_attribute_int_scalar,& - read_attribute_r8_scalar, read_attribute_r4_1d,& - read_attribute_int_1d, read_attribute_r8_1d, read_attribute_char, & - read_attribute_short_scalar, read_attribute_short_1d, & - read_attribute_byte_scalar, read_attribute_byte_1d - end interface - - interface write_attribute - module procedure write_attribute_r4_scalar, write_attribute_int_scalar,& - write_attribute_r8_scalar, write_attribute_r4_1d,& - write_attribute_int_1d, write_attribute_r8_1d, write_attribute_char, & - write_attribute_short_scalar, write_attribute_short_1d, & - write_attribute_byte_scalar, write_attribute_byte_1d - end interface - - interface quantize_data - module procedure quantize_data_2d, quantize_data_3d, quantize_data_4d - end interface - - public :: open_dataset, create_dataset, close_dataset, Dataset, Variable, Dimension, & - read_vardata, read_attribute, write_vardata, write_attribute, get_ndim, & - get_nvar, get_var, get_dim, get_idate_from_time_units, & - get_time_units_from_idate, quantize_data, has_var, has_attr - - contains - - subroutine nccheck(status,halt,fname) - ! check return code, print error message - implicit none - integer, intent (in) :: status - logical, intent(in), optional :: halt - character(len=*), intent(in), optional :: fname - logical stopit - if (present(halt)) then - stopit = halt - else - stopit = .true. - endif - if (status /= nf90_noerr) then - write(0,*) status, trim(nf90_strerror(status)) - if (present(fname)) then - write(0,*) trim(fname) - end if - if (stopit) stop 99 - end if - end subroutine nccheck - - function get_dim(dset, dimname) result(dim) - type(Dataset) :: dset - type(Dimension) :: dim - character(len=*), intent(in) :: dimname - integer ndim - ndim = get_ndim(dset, dimname) - dim = dset%dimensions(ndim) - end function get_dim - - integer function get_ndim(dset, dimname) - ! get dimension index given name - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: dimname - integer ndim - get_ndim = -1 - do ndim=1,dset%ndims - if (trim(dset%dimensions(ndim)%name) == trim(dimname)) then - get_ndim = ndim - exit - endif - enddo - end function get_ndim - - function get_var(dset, varname) result (var) - type(Dataset) :: dset - type(Variable) :: var - character(len=*) :: varname - integer nvar - nvar = get_nvar(dset, varname) - var = dset%variables(nvar) - end function get_var - - logical function has_var(dset, varname) - ! returns .true. is varname exists in dset, otherwise .false. - type(Dataset) :: dset - character(len=*) :: varname - integer nvar - nvar = get_nvar(dset, varname) - if (nvar > 0) then - has_var=.true. - else - has_var=.false. - endif - end function has_var - - logical function has_attr(dset, attname, varname) - ! returns .true. if attribute exists in dset, otherwise .false. - ! use optional kwarg varname to check for a variable attribute. - type(Dataset) :: dset - character(len=*) :: attname - character(len=*), optional :: varname - integer nvar, varid, ncerr - nvar = get_nvar(dset, varname) - if(present(varname))then - nvar = get_nvar(dset,varname) - if (nvar < 0) then - has_attr = .false. - return - endif - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_inquire_attribute(dset%ncid, varid, attname) - if (ncerr /= 0) then - has_attr=.false. - else - has_attr=.true. - endif - end function has_attr - - integer function get_nvar(dset,varname) - ! get variable index given name - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer nvar - get_nvar = -1 - do nvar=1,dset%nvars - if (trim(dset%variables(nvar)%name) == trim(varname)) then - get_nvar = nvar - exit - endif - enddo - end function get_nvar - - subroutine set_varunlimdimlens_(dset,errcode) - ! reset dimension length (dimlens) for unlim dim for all variables - type(Dataset), intent(inout) :: dset - integer, intent(out), optional :: errcode - integer ndim,n,nvar,ncerr - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - ! loop over all vars - do nvar=1,dset%nvars - ! does var have unlim dimension? - if (dset%variables(nvar)%hasunlim) then - ! loop over all var dimensions - do ndim=1,dset%variables(nvar)%ndims - n = dset%variables(nvar)%dimindxs(ndim) - ! n is the dimension index for this variable dimension - ! if this dim is unlimited, update dimlens entry - if (dset%dimensions(n)%isunlimited) then - ncerr = nf90_inquire_dimension(dset%ncid,& - dset%dimensions(n)%dimid, & - len=dset%variables(nvar)%dimlens(ndim)) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - return - else - call nccheck(ncerr) - endif - ! also update len attribute of Dimension object - dset%dimensions(n)%len = dset%variables(nvar)%dimlens(ndim) - endif - enddo - endif - enddo - end subroutine set_varunlimdimlens_ - - function open_dataset(filename,errcode,paropen, mpicomm) result(dset) - ! open existing dataset, create dataset object for reading netcdf file - ! if optional error return code errcode is not specified, - ! program will stop if a nonzero error code returned by the netcdf lib. - implicit none - character(len=*), intent(in) :: filename - type(Dataset) :: dset - integer, intent(out), optional :: errcode - logical, intent(in), optional :: paropen - integer, intent(in), optional :: mpicomm - integer ncerr,nunlimdim,ndim,nvar,n,formatnum - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(paropen)) then - if (paropen) then - dset%isparallel = .true. - else - dset%isparallel = .false. - end if - else - dset%isparallel = .false. - end if - ! open netcdf file, get info, populate Dataset object. - if (dset%isparallel) then - if (present(mpicomm)) then - ncerr = nf90_open(trim(filename), ior(NF90_NOWRITE, NF90_MPIIO), & - comm=mpicomm, info = mpi_info_null, ncid=dset%ncid) - else - ncerr = nf90_open(trim(filename), ior(NF90_NOWRITE, NF90_MPIIO), & - comm=mpi_comm_world, info = mpi_info_null, ncid=dset%ncid) - end if - else - ncerr = nf90_open(trim(filename), NF90_NOWRITE, ncid=dset%ncid) - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.,fname=filename) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - ncerr = nf90_inquire(dset%ncid, dset%ndims, dset%nvars, dset%natts, nunlimdim, formatnum=formatnum) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - if (formatnum == nf90_format_netcdf4 .or. formatnum == nf90_format_netcdf4_classic) then - dset%ishdf5 = .true. - else - dset%ishdf5 = .false. - endif - dset%filename = trim(filename) - allocate(dset%variables(dset%nvars)) - allocate(dset%dimensions(dset%ndims)) - do ndim=1,dset%ndims - dset%dimensions(ndim)%dimid = ndim - ncerr = nf90_inquire_dimension(dset%ncid, ndim, name=dset%dimensions(ndim)%name, & - len=dset%dimensions(ndim)%len) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - if (ndim == nunlimdim) then - dset%dimensions(ndim)%isunlimited = .true. - else - dset%dimensions(ndim)%isunlimited = .false. - endif - enddo - do nvar=1,dset%nvars - dset%variables(nvar)%hasunlim = .false. - dset%variables(nvar)%varid = nvar - ncerr = nf90_inquire_variable(dset%ncid, nvar,& - name=dset%variables(nvar)%name,& - natts=dset%variables(nvar)%natts,& - xtype=dset%variables(nvar)%dtype,& - ndims=dset%variables(nvar)%ndims) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - allocate(dset%variables(nvar)%dimids(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimindxs(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimlens(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%chunksizes(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimnames(dset%variables(nvar)%ndims)) - if (dset%ishdf5) then - ncerr = nf90_inquire_variable(dset%ncid, nvar,& - dimids=dset%variables(nvar)%dimids,& - deflate_level=dset%variables(nvar)%deflate_level,& - chunksizes=dset%variables(nvar)%chunksizes,& - shuffle=dset%variables(nvar)%shuffle) - else - ncerr = nf90_inquire_variable(dset%ncid, nvar,& - dimids=dset%variables(nvar)%dimids) - endif - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - do ndim=1,dset%variables(nvar)%ndims - do n=1,dset%ndims - if (dset%variables(nvar)%dimids(ndim) == dset%dimensions(n)%dimid) then - exit - endif - enddo - dset%variables(nvar)%dimindxs(ndim) = n - dset%variables(nvar)%dimlens(ndim) = dset%dimensions(n)%len - dset%variables(nvar)%dimnames(ndim) = dset%dimensions(n)%name - if (dset%dimensions(n)%isunlimited) then - dset%variables(nvar)%hasunlim = .true. - endif - enddo - enddo - end function open_dataset - - function create_dataset(filename, dsetin, copy_vardata, paropen, nocompress, mpicomm, errcode) result(dset) - ! create new dataset, using an existing dataset object to define - ! variables, dimensions and attributes. - ! If copy_vardata=T, all variable data (not just coordinate - ! variable data) is copied. Default is F (only coord var data - ! copied). - ! if optional nocompress=.true., outputfile will not use compression even if input file does - ! if optional error return code errcode is not specified, - ! program will stop if a nonzero error code returned by the netcdf lib. - implicit none - character(len=*), intent(in) :: filename - character(len=nf90_max_name) :: attname, varname - logical, intent(in), optional :: copy_vardata - type(Dataset) :: dset - type(Dataset), intent(in) :: dsetin - logical, intent(in), optional :: paropen - integer, intent(in), optional :: mpicomm - logical, intent(in), optional :: nocompress - integer, intent(out), optional :: errcode - integer ncerr,ndim,nvar,n,ishuffle,natt - logical copyd, coordvar, compress - real(8), allocatable, dimension(:) :: values_1d - real(8), allocatable, dimension(:,:) :: values_2d - real(8), allocatable, dimension(:,:,:) :: values_3d - real(8), allocatable, dimension(:,:,:,:) :: values_4d - real(8), allocatable, dimension(:,:,:,:,:) :: values_5d - integer, allocatable, dimension(:) :: ivalues_1d - integer, allocatable, dimension(:,:) :: ivalues_2d - integer, allocatable, dimension(:,:,:) :: ivalues_3d - integer, allocatable, dimension(:,:,:,:) :: ivalues_4d - integer, allocatable, dimension(:,:,:,:,:) :: ivalues_5d - character, allocatable, dimension(:) :: cvalues_1d - character, allocatable, dimension(:,:) :: cvalues_2d - character, allocatable, dimension(:,:,:) :: cvalues_3d - character, allocatable, dimension(:,:,:,:) :: cvalues_4d - character, allocatable, dimension(:,:,:,:,:) :: cvalues_5d - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(copy_vardata)) then - copyd = .true. ! copy all variable data - else - copyd = .false. ! only copy coordinate variable data - endif - if (present(paropen)) then - if (paropen) then - dset%isparallel = .true. - else - dset%isparallel = .false. - end if - else - dset%isparallel = .false. - end if - compress = .true. - if (present(nocompress)) then - if (nocompress) then - compress = .false. - end if - end if - ! create netcdf file - if (dsetin%ishdf5) then - if (dset%isparallel) then - if (present(mpicomm)) then - ncerr = nf90_create(trim(filename), & - cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=dset%ncid, & - comm = mpicomm, info = mpi_info_null) - else - ncerr = nf90_create(trim(filename), & - cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=dset%ncid, & - comm = mpi_comm_world, info = mpi_info_null) - end if - else - ncerr = nf90_create(trim(filename), & - cmode=IOR(IOR(NF90_CLOBBER,NF90_NETCDF4),NF90_CLASSIC_MODEL), & - !cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), & - ncid=dset%ncid) - end if - dset%ishdf5 = .true. - else - ncerr = nf90_create(trim(filename), & - cmode=IOR(IOR(NF90_CLOBBER,NF90_64BIT_OFFSET),NF90_SHARE), & - ncid=dset%ncid) - dset%ishdf5 = .false. - endif - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - ! copy global attributes - do natt=1,dsetin%natts - ncerr = nf90_inq_attname(dsetin%ncid, NF90_GLOBAL, natt, attname) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ncerr = nf90_copy_att(dsetin%ncid, NF90_GLOBAL, attname, dset%ncid, NF90_GLOBAL) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - enddo - dset%natts = dsetin%natts - dset%filename = trim(filename) - dset%ndims = dsetin%ndims - dset%nvars = dsetin%nvars - allocate(dset%variables(dsetin%nvars)) - allocate(dset%dimensions(dsetin%ndims)) - ! create dimensions - do ndim=1,dsetin%ndims - if (dsetin%dimensions(ndim)%isunlimited) then - ncerr = nf90_def_dim(dset%ncid, trim(dsetin%dimensions(ndim)%name), & - NF90_UNLIMITED, & - dset%dimensions(ndim)%dimid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - dset%dimensions(ndim)%isunlimited = .true. - dset%nunlimdim = ndim - dset%dimensions(ndim)%len = 0 - dset%dimensions(ndim)%name = trim(dsetin%dimensions(ndim)%name) - else - ncerr = nf90_def_dim(dset%ncid, trim(dsetin%dimensions(ndim)%name),& - dsetin%dimensions(ndim)%len, & - dset%dimensions(ndim)%dimid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - dset%dimensions(ndim)%len = dsetin%dimensions(ndim)%len - dset%dimensions(ndim)%isunlimited = .false. - dset%dimensions(ndim)%name = trim(dsetin%dimensions(ndim)%name) - endif - enddo - ! create variables - do nvar=1,dsetin%nvars - dset%variables(nvar)%hasunlim = .false. - dset%variables(nvar)%ndims = dsetin%variables(nvar)%ndims - allocate(dset%variables(nvar)%dimids(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimindxs(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimnames(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimlens(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%chunksizes(dset%variables(nvar)%ndims)) - dset%variables(nvar)%chunksizes = dsetin%variables(nvar)%chunksizes - do ndim=1,dset%variables(nvar)%ndims - do n=1,dset%ndims - if (trim(dsetin%variables(nvar)%dimnames(ndim)) == & - trim(dset%dimensions(n)%name)) then - exit - endif - enddo - dset%variables(nvar)%dimindxs(ndim) = n - dset%variables(nvar)%dimids(ndim) = dset%dimensions(n)%dimid - dset%variables(nvar)%dimlens(ndim) = dset%dimensions(n)%len - dset%variables(nvar)%dimnames(ndim) = dset%dimensions(n)%name - if (dset%dimensions(n)%isunlimited) then - dset%variables(nvar)%hasunlim = .true. - endif - enddo - dset%variables(nvar)%name = dsetin%variables(nvar)%name - dset%variables(nvar)%dtype = dsetin%variables(nvar)%dtype - if (maxval(dset%variables(nvar)%chunksizes) > 0 .and. dset%ishdf5) then - ! workaround for older versions of netcdf-fortran that don't - ! like zero chunksize to be specified. - ncerr = nf90_def_var(dset%ncid, & - trim(dset%variables(nvar)%name),& - dset%variables(nvar)%dtype, & - dset%variables(nvar)%dimids, & - dset%variables(nvar)%varid, & - chunksizes=dset%variables(nvar)%chunksizes) - else - ncerr = nf90_def_var(dset%ncid, & - trim(dset%variables(nvar)%name),& - dset%variables(nvar)%dtype, & - dset%variables(nvar)%dimids, & - dset%variables(nvar)%varid) - endif - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - if (dsetin%variables(nvar)%deflate_level > 0 .and. dset%ishdf5 .and. compress) then - if (dsetin%variables(nvar)%shuffle) then - ishuffle=1 - else - ishuffle=0 - endif - ncerr = nf90_def_var_deflate(dset%ncid, dset%variables(nvar)%varid,& - ishuffle,1,dsetin%variables(nvar)%deflate_level) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - dset%variables(nvar)%shuffle = dsetin%variables(nvar)%shuffle - dset%variables(nvar)%deflate_level = & - dsetin%variables(nvar)%deflate_level - endif - ! copy variable attributes - do natt=1,dsetin%variables(nvar)%natts - ncerr = nf90_inq_attname(dsetin%ncid, dsetin%variables(nvar)%varid, natt, attname) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - if (.not. compress) then - if (trim(attname) == 'max_abs_compression_error' & - .or. trim(attname) == 'nbits') then - cycle - end if - end if - ncerr = nf90_copy_att(dsetin%ncid, dsetin%variables(nvar)%varid, attname, dset%ncid, dset%variables(nvar)%varid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - enddo - enddo - ncerr = nf90_enddef(dset%ncid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ! copy variable data - ! assumes data is real (32 or 64 bit), or integer (16 or 32 bit) and 1-4d. - do nvar=1,dsetin%nvars - varname = trim(dsetin%variables(nvar)%name) - ! is this variable a coordinate variable? - coordvar = .false. - if (trim(varname) == 'lats' .or. trim(varname) == 'lons' .or. & - trim(varname) == 'lat' .or. trim(varname) == 'lon') then - coordvar = .true. - else - do ndim=1,dset%ndims - if (trim(varname) == trim(dset%dimensions(ndim)%name)) then - coordvar = .true. - endif - enddo - endif - ! if copy_data flag not given, and not a coordinate var, - ! skip to next var. - if (.not. coordvar .and. .not. copyd) cycle - ! real variable - if (dsetin%variables(nvar)%dtype == NF90_FLOAT .or.& - dsetin%variables(nvar)%dtype == NF90_DOUBLE) then - if (dsetin%variables(nvar)%ndims == 1) then - call read_vardata(dsetin, varname, values_1d) - call write_vardata(dset, varname, values_1d) - else if (dsetin%variables(nvar)%ndims == 2) then - call read_vardata(dsetin, varname, values_2d) - call write_vardata(dset, varname, values_2d) - else if (dsetin%variables(nvar)%ndims == 3) then - call read_vardata(dsetin, varname, values_3d) - call write_vardata(dset, varname, values_3d) - else if (dsetin%variables(nvar)%ndims == 4) then - call read_vardata(dsetin, varname, values_4d) - call write_vardata(dset, varname, values_4d) - else if (dsetin%variables(nvar)%ndims == 5) then - call read_vardata(dsetin, varname, values_5d) - call write_vardata(dset, varname, values_5d) - endif - ! integer var - elseif (dsetin%variables(nvar)%dtype == NF90_INT .or.& - dsetin%variables(nvar)%dtype == NF90_BYTE .or.& - dsetin%variables(nvar)%dtype == NF90_SHORT) then - if (dsetin%variables(nvar)%ndims == 1) then - call read_vardata(dsetin, varname, ivalues_1d) - call write_vardata(dset, varname, ivalues_1d) - else if (dsetin%variables(nvar)%ndims == 2) then - call read_vardata(dsetin, varname, ivalues_2d) - call write_vardata(dset, varname, ivalues_2d) - else if (dsetin%variables(nvar)%ndims == 3) then - call read_vardata(dsetin, varname, ivalues_3d) - call write_vardata(dset, varname, ivalues_3d) - else if (dsetin%variables(nvar)%ndims == 4) then - call read_vardata(dsetin, varname, ivalues_4d) - call write_vardata(dset, varname, ivalues_4d) - else if (dsetin%variables(nvar)%ndims == 5) then - call read_vardata(dsetin, varname, ivalues_5d) - call write_vardata(dset, varname, ivalues_5d) - endif - elseif (dsetin%variables(nvar)%dtype == NF90_CHAR) then - if (dsetin%variables(nvar)%ndims == 1) then - call read_vardata(dsetin, varname, cvalues_1d) - call write_vardata(dset, varname, cvalues_1d) - else if (dsetin%variables(nvar)%ndims == 2) then - call read_vardata(dsetin, varname, cvalues_2d) - call write_vardata(dset, varname, cvalues_2d) - else if (dsetin%variables(nvar)%ndims == 3) then - call read_vardata(dsetin, varname, cvalues_3d) - call write_vardata(dset, varname, cvalues_3d) - else if (dsetin%variables(nvar)%ndims == 4) then - call read_vardata(dsetin, varname, cvalues_4d) - call write_vardata(dset, varname, cvalues_4d) - else if (dsetin%variables(nvar)%ndims == 5) then - call read_vardata(dsetin, varname, cvalues_5d) - call write_vardata(dset, varname, cvalues_5d) - endif - else - print *,'not copying variable ',trim(adjustl(varname)),& - ' (unsupported data type or rank)' - endif - enddo - end function create_dataset - - subroutine close_dataset(dset,errcode) - ! close netcdf file, deallocate members of dataset object. - ! if optional error return code errcode is not specified, - ! program will stop if a nonzero error code returned by the netcdf lib. - type(Dataset), intent(inout) :: dset - integer, intent(out), optional :: errcode - integer ncerr, nvar - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - ncerr = nf90_close(ncid=dset%ncid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - do nvar=1,dset%nvars - deallocate(dset%variables(nvar)%dimids) - deallocate(dset%variables(nvar)%dimindxs) - deallocate(dset%variables(nvar)%dimlens) - deallocate(dset%variables(nvar)%chunksizes) - deallocate(dset%variables(nvar)%dimnames) - enddo - deallocate(dset%variables,dset%dimensions) - end subroutine close_dataset - - !subroutine read_vardata(dset,varname,values,nslice,slicedim,errcode) - ! read data from variable varname in dataset dset, return in it array values. - ! dset: Input dataset instance returned by open_dataset/create_dataset. - ! varname: Input string name of variable. - ! values: Array to hold variable data. Must be - ! an allocatable array with same rank - ! as variable varname (or 1 dimension less). - ! nslice: optional index along dimension slicedim - ! slicedim: optional, if nslice is set, index of which dimension to slice with - ! nslice, default is ndims - ! ncstart: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF read - ! nccount: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF read - ! errcode: optional error return code. If not specified, - ! program will stop if a nonzero error code returned - ! from netcdf library. - - !subroutine write_vardata(dset,varname,values,nslice,slicedim,errcode) - ! write data (in array values) to variable varname in dataset dset. - ! dset: Input dataset instance returned by open_dataset/create_dataset. - ! varname: Input string name of variable. - ! values: Array with variable data. Must be - ! an allocatable array with same rank - ! as variable varname (or 1 dimension less). - ! nslice: optional index along dimension slicedim - ! slicedim: optional, if nslice is set, index of which dimension to slice with - ! nslice, default is ndims - ! ncstart: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF write - ! nccount: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF write - ! errcode: optional error return code. If not specified, - ! program will stop if a nonzero error code returned - ! from netcdf library. - - !subroutine read_attribute(dset, attname, values, varname, errcode) - ! read attribute 'attname' return in 'values'. If optional - ! argument 'varname' is given, a variable attribute is returned. - ! if the attribute is a 1d array, values should be an allocatable 1d - ! array of the correct type. - - !subroutine write_attribute(dset, attname, values, varname, errcode) - ! write attribute 'attname' with data in 'values'. If optional - ! argument 'varname' is given, a variable attribute is written. - ! values can be a real(4), real(8), integer, string or 1d array. - - subroutine read_vardata_1d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_r4 - - subroutine read_vardata_2d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_r4 - - subroutine read_vardata_3d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_r4 - - subroutine read_vardata_4d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_r4 - - subroutine read_vardata_5d_r4(dset, varname, values, errcode) - real(4), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_r4 - - subroutine read_vardata_1d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_r8 - - subroutine read_vardata_2d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_r8 - - subroutine read_vardata_3d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_r8 - - subroutine read_vardata_4d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_r8 - - subroutine read_vardata_5d_r8(dset, varname, values, errcode) - real(8), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_r8 - - subroutine read_vardata_1d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_int - - subroutine read_vardata_2d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_int - - subroutine read_vardata_3d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_int - - subroutine read_vardata_4d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_int - - subroutine read_vardata_5d_int(dset, varname, values, errcode) - integer, allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_int - - subroutine read_vardata_1d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_short - - subroutine read_vardata_2d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_short - - subroutine read_vardata_3d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_short - - subroutine read_vardata_4d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_short - - subroutine read_vardata_5d_short(dset, varname, values, errcode) - integer(2), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_short - - subroutine read_vardata_1d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_byte - - subroutine read_vardata_2d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_byte - - subroutine read_vardata_3d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_byte - - subroutine read_vardata_4d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_byte - - subroutine read_vardata_5d_byte(dset, varname, values, errcode) - integer(1), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_byte - - subroutine read_vardata_1d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_char - - subroutine read_vardata_2d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_char - - subroutine read_vardata_3d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_char - - subroutine read_vardata_4d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_char - - subroutine read_vardata_5d_char(dset, varname, values, errcode) - character, allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_char - - subroutine write_vardata_1d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_r4 - - subroutine write_vardata_2d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_r4 - - subroutine write_vardata_3d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_r4 - - subroutine write_vardata_4d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_r4 - - subroutine write_vardata_5d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_r4 - - subroutine write_vardata_1d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_r8 - - subroutine write_vardata_2d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_r8 - - subroutine write_vardata_3d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_r8 - - subroutine write_vardata_4d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_r8 - - subroutine write_vardata_5d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_r8 - - subroutine write_vardata_1d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_int - - subroutine write_vardata_2d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_int - - subroutine write_vardata_3d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_int - - subroutine write_vardata_4d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_int - - subroutine write_vardata_5d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_int - - subroutine write_vardata_1d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_short - - subroutine write_vardata_2d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_short - - subroutine write_vardata_3d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_short - - subroutine write_vardata_4d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_short - - subroutine write_vardata_5d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_short - - subroutine write_vardata_1d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_byte - - subroutine write_vardata_2d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_byte - - subroutine write_vardata_3d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_byte - - subroutine write_vardata_4d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_byte - - subroutine write_vardata_5d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_byte - - subroutine write_vardata_1d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_char - - subroutine write_vardata_2d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_char - - subroutine write_vardata_3d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_char - - subroutine write_vardata_4d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_char - - subroutine write_vardata_5d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_char - - subroutine read_attribute_int_scalar(dset, attname, values, varname, errcode) - integer, intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_int_scalar - - subroutine read_attribute_short_scalar(dset, attname, values, varname, errcode) - integer(2), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_short_scalar - - subroutine read_attribute_byte_scalar(dset, attname, values, varname, errcode) - integer(1), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_byte_scalar - - subroutine read_attribute_r4_scalar(dset, attname, values, varname, errcode) - real(4), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_r4_scalar - - subroutine read_attribute_r8_scalar(dset, attname, values, varname, errcode) - real(8), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_r8_scalar - - subroutine read_attribute_r4_1d(dset, attname, values, varname, errcode) - real(4), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_r4_1d - - subroutine read_attribute_r8_1d(dset, attname, values, varname, errcode) - real(8), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_r8_1d - - subroutine read_attribute_int_1d(dset, attname, values, varname, errcode) - integer, intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_int_1d - - subroutine read_attribute_short_1d(dset, attname, values, varname, errcode) - integer(2), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_short_1d - - subroutine read_attribute_byte_1d(dset, attname, values, varname, errcode) - integer(1), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_byte_1d - - subroutine read_attribute_char(dset, attname, values, varname, errcode) - character(len=*), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_char - - subroutine write_attribute_int_scalar(dset, attname, values, varname, errcode) - integer, intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_int_scalar - - subroutine write_attribute_short_scalar(dset, attname, values, varname, errcode) - integer(2), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_short_scalar - - subroutine write_attribute_byte_scalar(dset, attname, values, varname, errcode) - integer(1), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_byte_scalar - - subroutine write_attribute_r4_scalar(dset, attname, values, varname, errcode) - real(4), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r4_scalar - - subroutine write_attribute_r8_scalar(dset, attname, values, varname, errcode) - real(8), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r8_scalar - - subroutine write_attribute_r4_1d(dset, attname, values, varname, errcode) - real(4), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r4_1d - - subroutine write_attribute_r8_1d(dset, attname, values, varname, errcode) - real(8), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r8_1d - - subroutine write_attribute_int_1d(dset, attname, values, varname, errcode) - integer, intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_int_1d - - subroutine write_attribute_short_1d(dset, attname, values, varname, errcode) - integer(2), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_short_1d - - subroutine write_attribute_byte_1d(dset, attname, values, varname, errcode) - integer(1), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_byte_1d - - subroutine write_attribute_char(dset, attname, values, varname, errcode) - character(len=*), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_char - - function get_idate_from_time_units(dset) result(idate) - ! return integer array with year,month,day,hour,minute,second - ! parsed from time units attribute. - type(Dataset), intent(in) :: dset - integer idate(6) - character(len=nf90_max_name) :: time_units - integer ipos1,ipos2 - call read_attribute(dset, 'units', time_units, 'time') - ipos1 = scan(time_units,"since",back=.true.)+1 - ipos2 = scan(time_units,"-",back=.false.)-1 - read(time_units(ipos1:ipos2),*) idate(1) - ipos1 = ipos2+2; ipos2=ipos1+1 - read(time_units(ipos1:ipos2),*) idate(2) - ipos1 = ipos2+2; ipos2=ipos1+1 - read(time_units(ipos1:ipos2),*) idate(3) - ipos1 = scan(time_units,":")-2 - ipos2 = ipos1+1 - read(time_units(ipos1:ipos2),*) idate(4) - ipos1 = ipos2+2 - ipos2 = ipos1+1 - read(time_units(ipos1:ipos2),*) idate(5) - ipos1 = ipos2+2 - ipos2 = ipos1+1 - read(time_units(ipos1:ipos2),*) idate(6) - end function get_idate_from_time_units - - function get_time_units_from_idate(idate, time_measure) result(time_units) - ! create time units attribute of form 'hours since YYYY-MM-DD HH:MM:SS' - ! from integer array with year,month,day,hour,minute,second - ! optional argument 'time_measure' can be used to change 'hours' to - ! 'days', 'minutes', 'seconds' etc. - character(len=*), intent(in), optional :: time_measure - integer, intent(in) :: idate(6) - character(len=12) :: timechar - character(len=nf90_max_name) :: time_units - if (present(time_measure)) then - timechar = trim(time_measure) - else - timechar = 'hours' - endif - write(time_units,101) idate -101 format(' since ',i4.4,'-',i2.2,'-',i2.2,' ',& - i2.2,':',i2.2,':',i2.2) - time_units = trim(adjustl(timechar))//time_units - end function get_time_units_from_idate - - subroutine quantize_data_2d(dataIn, dataOut, nbits, compress_err) - real(4), intent(in) :: dataIn(:,:) - real(4), intent(out) :: dataOut(:,:) - include "quantize_data_code.f90" - end subroutine quantize_data_2d - - subroutine quantize_data_3d(dataIn, dataOut, nbits, compress_err) - real(4), intent(in) :: dataIn(:,:,:) - real(4), intent(out) :: dataOut(:,:,:) - include "quantize_data_code.f90" - end subroutine quantize_data_3d - - subroutine quantize_data_4d(dataIn, dataOut, nbits, compress_err) - real(4), intent(in) :: dataIn(:,:,:,:) - real(4), intent(out) :: dataOut(:,:,:,:) - include "quantize_data_code.f90" - end subroutine quantize_data_4d - -end module module_fv3gfs_ncio diff --git a/src/fv3gfs_ncio/quantize_data_code.f90 b/src/fv3gfs_ncio/quantize_data_code.f90 deleted file mode 100644 index ece0f77463..0000000000 --- a/src/fv3gfs_ncio/quantize_data_code.f90 +++ /dev/null @@ -1,17 +0,0 @@ - integer, intent(in) :: nbits - real(4), intent(out) :: compress_err - real(4) dataMin, dataMax, scale_fact, offset - ! if nbits not between 1 and 31, don't do anything - if (nbits <= 0 .or. nbits > 31) then - dataOut = dataIn - compress_err = 0.0 - return - endif - dataMax = maxval(dataIn); dataMin = minval(dataIn) - ! convert data to 32 bit integers in range 0 to 2**nbits-1, then cast - ! cast back to 32 bit floats (data is then quantized in steps - ! proportional to 2**nbits so last 32-nbits in floating - ! point representation should be zero for efficient zlib compression). - scale_fact = (dataMax - dataMin) / (2**nbits-1); offset = dataMin - dataOut = scale_fact*(nint((dataIn - offset) / scale_fact)) + offset - compress_err = maxval(abs(dataIn-dataOut)) diff --git a/src/fv3gfs_ncio/read_attribute_code.f90 b/src/fv3gfs_ncio/read_attribute_code.f90 deleted file mode 100644 index 6a0bcffcd5..0000000000 --- a/src/fv3gfs_ncio/read_attribute_code.f90 +++ /dev/null @@ -1,35 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in), optional :: varname - character(len=*), intent(in) :: attname - integer, intent(out), optional :: errcode - integer ncerr, varid, nvar, nlen - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if(present(varname))then - nvar = get_nvar(dset,varname) - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_inquire_attribute(dset%ncid, varid, attname, len=nlen) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - if (allocated(values)) deallocate(values) - allocate(values(nlen)) - ncerr = nf90_get_att(dset%ncid, varid, trim(attname), values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_scalar_attribute_code.f90 b/src/fv3gfs_ncio/read_scalar_attribute_code.f90 deleted file mode 100644 index 2b8c6ce046..0000000000 --- a/src/fv3gfs_ncio/read_scalar_attribute_code.f90 +++ /dev/null @@ -1,31 +0,0 @@ - ! read attribute 'attname' return in 'values'. If optional - ! argument 'varname' is given, an variable attribute is returned. - ! if the attribute is an 1d array, values should be an allocatable 1d - ! array of the correct type. if values is allocated, it be deallocated - ! and reallocated. - type(Dataset), intent(in) :: dset - character(len=*), intent(in), optional :: varname - integer, intent(out), optional :: errcode - character(len=*), intent(in) :: attname - integer ncerr, varid, nvar - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if(present(varname))then - nvar = get_nvar(dset,varname) - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_get_att(dset%ncid, varid, trim(attname), values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - return - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_1d.f90 b/src/fv3gfs_ncio/read_vardata_code_1d.f90 deleted file mode 100644 index 1a92b7fc16..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_1d.f90 +++ /dev/null @@ -1,75 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, dimlen, ncount - integer, allocatable, dimension(:) :: start, count - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlen = dset%variables(nvar)%dimlens(n) - end if - end do - if (dset%variables(nvar)%ndims /= 1 .and. dset%variables(nvar)%ndims /= 2) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1))) - start(1)=ncstart(1); count(1)=nccount(1) - if (dset%variables(nvar)%ndims == 2) then - start(2)=1; count(2)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - if (dset%variables(nvar)%ndims == 2) then - allocate(values(dimlen)) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dset%variables(nvar)%dimlens(1))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_2d.f90 b/src/fv3gfs_ncio/read_vardata_code_2d.f90 deleted file mode 100644 index c0e62a6abb..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_2d.f90 +++ /dev/null @@ -1,81 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, ndim, ncount - integer, allocatable, dimension(:) :: start, count - integer :: dimlens(2) - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - if (dset%variables(nvar)%ndims /= 2 .and. dset%variables(nvar)%ndims /= 3) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1),nccount(2))) - start(1)=ncstart(1); count(1)=nccount(1) - start(2)=ncstart(2); count(2)=nccount(2) - if (dset%variables(nvar)%ndims == 3) then - start(3)=1; count(3)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - if (dset%variables(nvar)%ndims == 3) then - allocate(values(dimlens(1),dimlens(2))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dset%variables(nvar)%dimlens(1),dset%variables(nvar)%dimlens(2))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_3d.f90 b/src/fv3gfs_ncio/read_vardata_code_3d.f90 deleted file mode 100644 index cc426b2361..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_3d.f90 +++ /dev/null @@ -1,85 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, ndim, ncount - integer, allocatable, dimension(:) :: start, count - integer :: dimlens(3) - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - if (dset%variables(nvar)%ndims /= 3 .and. dset%variables(nvar)%ndims /= 4) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1),nccount(2),nccount(3))) - start(1)=ncstart(1); count(1)=nccount(1) - start(2)=ncstart(2); count(2)=nccount(2) - start(3)=ncstart(3); count(3)=nccount(3) - if (dset%variables(nvar)%ndims == 4) then - start(4)=1; count(4)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - if (dset%variables(nvar)%ndims == 4) then - allocate(values(dimlens(1),dimlens(2),dimlens(3))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dset%variables(nvar)%dimlens(1),& - dset%variables(nvar)%dimlens(2),& - dset%variables(nvar)%dimlens(3))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_4d.f90 b/src/fv3gfs_ncio/read_vardata_code_4d.f90 deleted file mode 100644 index fd3dd42153..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_4d.f90 +++ /dev/null @@ -1,83 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, ndim, ncount - integer, allocatable, dimension(:) :: start, count - integer :: dimlens(4) - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - if (dset%variables(nvar)%ndims /= 4 .and. dset%variables(nvar)%ndims /= 5) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1),nccount(2),nccount(3),nccount(4))) - start(1)=ncstart(1); count(1)=nccount(1) - start(2)=ncstart(2); count(2)=nccount(2) - start(3)=ncstart(3); count(3)=nccount(3) - start(4)=ncstart(4); count(4)=nccount(4) - if (dset%variables(nvar)%ndims == 5) then - start(5)=1; count(5)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dimlens(1),dimlens(2),dimlens(3),dimlens(4))) - if (dset%variables(nvar)%ndims == 5) then - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_5d.f90 b/src/fv3gfs_ncio/read_vardata_code_5d.f90 deleted file mode 100644 index ea9bd2e2cf..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_5d.f90 +++ /dev/null @@ -1,35 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(out), optional :: errcode - integer ncerr, nvar, n1,n2,n3,n4,n5 - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - nvar = get_nvar(dset,varname) - if (dset%variables(nvar)%ndims /= 5) then - if (return_errcode) then - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - n1 = dset%variables(nvar)%dimlens(1) - n2 = dset%variables(nvar)%dimlens(2) - n3 = dset%variables(nvar)%dimlens(3) - n4 = dset%variables(nvar)%dimlens(4) - n5 = dset%variables(nvar)%dimlens(5) - if (allocated(values)) deallocate(values) - allocate(values(n1,n2,n3,n4,n5)) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/write_attribute_code.f90 b/src/fv3gfs_ncio/write_attribute_code.f90 deleted file mode 100644 index c700a90dc2..0000000000 --- a/src/fv3gfs_ncio/write_attribute_code.f90 +++ /dev/null @@ -1,37 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in), optional :: varname - character(len=*), intent(in) :: attname - integer, intent(out), optional :: errcode - integer ncerr, varid, nvar - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if(present(varname))then - nvar = get_nvar(dset,varname) - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_redef(dset%ncid) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ncerr = nf90_put_att(dset%ncid, varid, trim(attname), values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - ncerr = nf90_enddef(dset%ncid) - return - else - call nccheck(ncerr) - ncerr = nf90_enddef(dset%ncid) - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/write_vardata_code.f90 b/src/fv3gfs_ncio/write_vardata_code.f90 deleted file mode 100644 index a6f8d4ffb8..0000000000 --- a/src/fv3gfs_ncio/write_vardata_code.f90 +++ /dev/null @@ -1,97 +0,0 @@ - type(Dataset), intent(inout) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(out), optional :: errcode - integer ncerr, nvar, ncount, ndim, nd, n - integer, allocatable, dimension(:) :: start, count, dimlens - logical is_slice - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - is_slice = .true. - else - ncount = 1 - is_slice = .false. - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - allocate(dimlens(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - - - ncerr = nf90_var_par_access(dset%ncid, dset%variables(nvar)%varid, nf90_collective) - if (is_slice) then - if (dset%variables(nvar)%ndims == 4) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=start,count=count) - else if (dset%variables(nvar)%ndims == 3) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=start,count=count) - else if (dset%variables(nvar)%ndims == 2) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=start,count=count) - else if (dset%variables(nvar)%ndims == 1) then - if (return_errcode) then - errcode = -1 - return - else - print *,'cannot write a slice to a 1d variable' - stop 99 - endif - else if (dset%variables(nvar)%ndims > 4) then - if (return_errcode) then - errcode = -1 - return - else - print *,'only variables up to 4d supported' - stop 99 - endif - endif - else if (present(ncstart) .and. present(nccount)) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=ncstart, count=nccount) - else - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid, values) - endif - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ! reset unlim dim size for all variables - if (dset%variables(nvar)%hasunlim) then - if (return_errcode) then - call set_varunlimdimlens_(dset,errcode) - else - call set_varunlimdimlens_(dset) - endif - endif diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index c45f50deb2..dd88d20cde 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -109,31 +109,29 @@ if(NOT USE_NCDIAG) endif() # Compiler options and definitions -list(APPEND GSI_C_DEFS +list(APPEND GSI_C_defs FortranByte=char FortranInt=int funder "FortranLlong=long long") -# Create object libraries for various components -# Create a library of GSI C Objects +list(APPEND GSI_Fortran_defs _REAL8_) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + list(APPEND GSI_Fortran_defs POUND_FOR_STRINGIFY) +endif() + +# Create a library of GSI C sources add_library(gsi_c_obj OBJECT ${GSI_SRC_C}) -target_compile_definitions(gsi_c_obj PUBLIC ${GSI_C_DEFS}) +target_compile_definitions(gsi_c_obj PRIVATE ${GSI_C_defs}) -# Create a library of GSI Fortran Objects +# Create a library of GSI Fortran sources set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsi") add_library(gsi_fortran_obj OBJECT ${GSI_SRC_Fortran}) set_target_properties(gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_include_directories(gsi_fortran_obj INTERFACE - $ - $) - -# Link the Fortran targets with dependencies -target_compile_definitions(gsi_fortran_obj PUBLIC "_REAL8_") -if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$") - target_compile_definitions(gsi_fortran_obj PUBLIC "POUND_FOR_STRINGIFY") -endif() -target_include_directories(gsi_fortran_obj PUBLIC $) +target_include_directories(gsi_fortran_obj INTERFACE $ + $ + $) +target_compile_definitions(gsi_fortran_obj PRIVATE ${GSI_Fortran_defs}) target_link_libraries(gsi_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(gsi_fortran_obj PUBLIC MPI::MPI_Fortran) target_link_libraries(gsi_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) @@ -143,6 +141,8 @@ target_link_libraries(gsi_fortran_obj PUBLIC sfcio::sfcio) target_link_libraries(gsi_fortran_obj PUBLIC nemsio::nemsio) target_link_libraries(gsi_fortran_obj PUBLIC ncio::ncio) target_link_libraries(gsi_fortran_obj PUBLIC w3emc::w3emc_d) +target_link_libraries(gsi_fortran_obj PUBLIC sp::sp_d) +target_link_libraries(gsi_fortran_obj PUBLIC bufr::bufr_d) target_link_libraries(gsi_fortran_obj PUBLIC crtm::crtm) if(GSI_APP MATCHES "Regional") target_link_libraries(gsi_fortran_obj PUBLIC wrf_io::wrf_io) @@ -158,56 +158,41 @@ if(OpenMP_Fortran_FOUND) target_link_libraries(gsi_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) endif() -# Create a GSI library -add_library(gsi STATIC $ - $) +# Create the GSI library +add_library(gsi STATIC) add_library(${PROJECT_NAME}::gsi ALIAS gsi) -target_include_directories(gsi PUBLIC $ +set_target_properties(gsi PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(gsi PUBLIC $ $) -target_include_directories(gsi PUBLIC $) -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/gsi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) +target_link_libraries(gsi PUBLIC gsi_c_obj) +target_link_libraries(gsi PUBLIC gsi_fortran_obj) +if(OpenMP_Fortran_FOUND) + target_link_libraries(gsi PRIVATE OpenMP::OpenMP_Fortran) +endif() -# Create a GSI executable -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsi") +# Create the GSI executable add_executable(gsi.x ${GSI_SRC_main}) add_dependencies(gsi.x gsi) set_target_properties(gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") target_link_libraries(gsi.x PRIVATE gsi) - -# Link the application targets with dependencies -target_link_libraries(gsi.x PRIVATE NetCDF::NetCDF_Fortran) -target_link_libraries(gsi.x PRIVATE MPI::MPI_Fortran) -target_link_libraries(gsi.x PRIVATE ${LAPACK_LIBRARIES}) -target_link_libraries(gsi.x PRIVATE bacio::bacio_4) -target_link_libraries(gsi.x PRIVATE sigio::sigio) -target_link_libraries(gsi.x PRIVATE sfcio::sfcio) -target_link_libraries(gsi.x PRIVATE nemsio::nemsio) -target_link_libraries(gsi.x PRIVATE ncio::ncio) -target_link_libraries(gsi.x PRIVATE w3emc::w3emc_d) -target_link_libraries(gsi.x PRIVATE sp::sp_d) -target_link_libraries(gsi.x PRIVATE bufr::bufr_d) -target_link_libraries(gsi.x PRIVATE crtm::crtm) -if(GSI_APP MATCHES "Regional") - target_link_libraries(gsi.x PRIVATE wrf_io::wrf_io) -endif() -if(USE_NCDIAG) - target_link_libraries(gsi.x PRIVATE ncdiag::ncdiag) -endif() if(OpenMP_Fortran_FOUND) target_link_libraries(gsi.x PRIVATE OpenMP::OpenMP_Fortran) endif() +# Install Fortran modules +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + # Install executable targets install(TARGETS gsi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -# Install library archive targets +# Install and export library targets install( - TARGETS gsi + TARGETS gsi_c_obj gsi_fortran_obj gsi EXPORT ${PROJECT_NAME}Exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -### Package config +# Package config include(CMakePackageConfigHelpers) set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in index 7476954aa2..4529a7ba31 100644 --- a/src/gsi/cmake/PackageConfig.cmake.in +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -10,8 +10,9 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) -# Set the GSI Application this library is built for +# Set the GSI configuration attributes set(GSI_APP @GSI_APP@) +set(GSI_USE_NCDIAG @USE_NCDIAG@) find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) @@ -46,9 +47,9 @@ if(GSI_APP MATCHES "Regional") endif() # ON|OFF implies @PROJECT_NAME@ was compiled with/without -USE_NCDIAG=ON|OFF -#if(@USE_NCDIAG@) -# find_dependency(ncdiag REQUIRED) -#endif() +if(GSI_USE_NCDIAG) + find_dependency(ncdiag) +endif() # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -59,3 +60,4 @@ get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindGSI defines targets:") message(STATUS " - GSI_APP [${GSI_APP}]") +message(STATUS " - GSI_USE_NCDIAG [${GSI_USE_NCDIAG}]") diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index dbd0b60e0f..e7c568db93 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -50,9 +50,8 @@ target_compile_definitions(ncdiag PRIVATE "USE_MPI") target_compile_definitions(ncdiag PRIVATE "${debug_defs}") target_link_libraries(ncdiag PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(ncdiag PUBLIC MPI::MPI_Fortran) -target_include_directories(ncdiag INTERFACE - $ - $) +target_include_directories(ncdiag PUBLIC $ + $) list(APPEND NCDIAG_Targets ncdiag) install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) @@ -79,9 +78,8 @@ if(ENABLE_NCDIAG_SERIAL) target_compile_definitions(ncdiag_serial PRIVATE "_REAL4_") target_compile_definitions(ncdiag_serial PRIVATE "${debug_defs}") target_link_libraries(ncdiag_serial PUBLIC NetCDF::NetCDF_Fortran) - target_include_directories(ncdiag_serial INTERFACE - $ - $) + target_include_directories(ncdiag_serial PUBLIC $ + $) list(APPEND NCDIAG_Targets ncdiag_serial) diff --git a/src/ncdiag/cmake/PackageConfig.cmake.in b/src/ncdiag/cmake/PackageConfig.cmake.in index 216779d855..ba16512dfc 100644 --- a/src/ncdiag/cmake/PackageConfig.cmake.in +++ b/src/ncdiag/cmake/PackageConfig.cmake.in @@ -7,7 +7,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include(CMakeFindDependencyMacro) -find_dependency(NetCDF COMPONENTS Fortran) +find_dependency(MPI REQUIRED) +find_dependency(NetCDF REQUIRED COMPONENTS Fortran) # Get the build type from real32 library target with dyanmic allocation get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 83fccf9d6a..1d810e7ced 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -7,13 +7,13 @@ endif() if(NOT TARGET enkf) find_package(enkf QUIET) if(NOT enkf_FOUND) - message(STATUS "EFSOI: EnKF library was not found. Disable EFSOI utilities") + message(STATUS "GSI Utils: EnKF library was not found. Disable EFSOI utilities") return() endif() endif() if(NOT ENKF_APP MATCHES "GFS") - message(STATUS "EFSOI: Incompatible EnKF = ${ENKF_APP}. Disable EFSOI utilities") + message(STATUS "GSI Utils: Incompatible EnKF = ${ENKF_APP}. Disable EFSOI utilities") return() endif() @@ -22,7 +22,7 @@ if(NOT TARGET gsi) endif() if(NOT GFS_APP MATCHES "GFS") - message(STATUS "EFSOI: Incompatible GFS = ${GFS_APP}. Disable EFSOI utilities") + message(STATUS "GSI Utils: Incompatible GFS = ${GFS_APP}. Disable EFSOI utilities") return() endif() @@ -32,63 +32,26 @@ endif() list(APPEND SRCS efsoi.f90 + efsoi_main.f90 gridio_efsoi.f90 loadbal_efsoi.f90 loc_advection.f90 scatter_chunks_efsoi.f90 statevec_efsoi.f90) -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/efsoi") -add_library(efsoi_objs OBJECT ${SRCS}) -set_target_properties(efsoi_objs PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_include_directories(efsoi_objs INTERFACE $) - -if(TARGET ncdiag) - add_dependencies(efsoi_objs ncdiag) -endif() -if(TARGET gsi) - add_dependencies(efsoi_objs gsi) -endif() +add_executable(efsoi.x ${SRCS}) +target_compile_definitions(efsoi.x PRIVATE "_REAL8_") if(TARGET enkf) - add_dependencies(efsoi_objs enkf) -endif() - -target_compile_definitions(efsoi_objs PRIVATE "_REAL8_") - -target_link_libraries(efsoi_objs PUBLIC enkf::enkf) -target_link_libraries(efsoi_objs PUBLIC gsi::gsi) -target_link_libraries(efsoi_objs PUBLIC ncdiag::ncdiag) -target_link_libraries(efsoi_objs PUBLIC NetCDF::NetCDF_Fortran) -target_link_libraries(efsoi_objs PUBLIC MPI::MPI_Fortran) -target_link_libraries(efsoi_objs PUBLIC ${LAPACK_LIBRARIES}) -target_link_libraries(efsoi_objs PUBLIC bacio::bacio_4) -target_link_libraries(efsoi_objs PUBLIC sigio::sigio) -target_link_libraries(efsoi_objs PUBLIC sfcio::sfcio) -target_link_libraries(efsoi_objs PUBLIC nemsio::nemsio) -target_link_libraries(efsoi_objs PUBLIC ncio::ncio) -target_link_libraries(efsoi_objs PUBLIC w3emc::w3emc_d) -target_link_libraries(efsoi_objs PUBLIC sp::sp_d) -target_link_libraries(efsoi_objs PUBLIC bufr::bufr_d) -target_link_libraries(efsoi_objs PUBLIC crtm::crtm) -if(OpenMP_Fortran_FOUND) - target_link_libraries(efsoi_objs PRIVATE OpenMP::OpenMP_Fortran) + add_dependencies(efsoi.x enkf) endif() - -add_library(efsoi STATIC $) -target_include_directories(efsoi PUBLIC $ - $) - -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/efsoi") -add_executable(efsoi.x efsoi_main.f90) -add_dependencies(efsoi.x efsoi) -set_target_properties(efsoi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_link_libraries(efsoi.x PRIVATE efsoi) - -target_compile_definitions(efsoi.x PRIVATE "_REAL8_") - -# Link the application targets with dependencies target_link_libraries(efsoi.x PRIVATE enkf::enkf) +if(TARGET gsi) + add_dependencies(efsoi.x gsi) +endif() target_link_libraries(efsoi.x PRIVATE gsi::gsi) +if(TARGET ncdiag) + add_dependencies(efsoi.x ncdiag) +endif() target_link_libraries(efsoi.x PRIVATE ncdiag::ncdiag) target_link_libraries(efsoi.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(efsoi.x PRIVATE MPI::MPI_Fortran) @@ -100,8 +63,6 @@ target_link_libraries(efsoi.x PRIVATE nemsio::nemsio) target_link_libraries(efsoi.x PRIVATE ncio::ncio) target_link_libraries(efsoi.x PRIVATE w3emc::w3emc_d) target_link_libraries(efsoi.x PRIVATE sp::sp_d) -target_link_libraries(efsoi.x PRIVATE bufr::bufr_d) -target_link_libraries(efsoi.x PRIVATE crtm::crtm) if(OpenMP_Fortran_FOUND) target_link_libraries(efsoi.x PRIVATE OpenMP::OpenMP_Fortran) endif() diff --git a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt index 2b2e4bda13..bc9a2b8bfe 100644 --- a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt @@ -12,35 +12,21 @@ list(APPEND SRCS wrf_netcdf_interface4ens.F90) add_executable(enspreproc.x ${SRCS}) - -if(TARGET ncdiag) - add_dependencies(enspreproc.x ncdiag) -endif() - +target_compile_definitions(enspreproc.x PRIVATE "WRF") if(TARGET gsi) add_dependencies(enspreproc.x gsi) endif() - -target_compile_definitions(enspreproc.x PRIVATE "WRF") - target_link_libraries(enspreproc.x PRIVATE gsi::gsi) - -# Link the application targets with dependencies +if(TARGET ncdiag) + add_dependencies(enspreproc.x ncdiag) +endif() +target_link_libraries(enspreproc.x PRIVATE ncdiag::ncdiag) target_link_libraries(enspreproc.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(enspreproc.x PRIVATE MPI::MPI_Fortran) target_link_libraries(enspreproc.x PRIVATE ${LAPACK_LIBRARIES}) target_link_libraries(enspreproc.x PRIVATE bacio::bacio_4) -target_link_libraries(enspreproc.x PRIVATE sigio::sigio) -target_link_libraries(enspreproc.x PRIVATE sfcio::sfcio) -target_link_libraries(enspreproc.x PRIVATE nemsio::nemsio) -target_link_libraries(enspreproc.x PRIVATE ncio::ncio) target_link_libraries(enspreproc.x PRIVATE w3emc::w3emc_d) -target_link_libraries(enspreproc.x PRIVATE sp::sp_d) -target_link_libraries(enspreproc.x PRIVATE bufr::bufr_d) -target_link_libraries(enspreproc.x PRIVATE crtm::crtm) target_link_libraries(enspreproc.x PRIVATE wrf_io::wrf_io) -target_link_libraries(enspreproc.x PRIVATE ncdiag::ncdiag) -target_link_libraries(enspreproc.x PRIVATE gsi::gsi) if(OpenMP_Fortran_FOUND) target_link_libraries(enspreproc.x PRIVATE OpenMP::OpenMP_Fortran) endif() diff --git a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt index 85f21e7030..dc1f52216e 100644 --- a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt @@ -10,35 +10,21 @@ list(APPEND SRCS update_netcdf_mass.f90) add_executable(initialens.x ${SRCS}) - -if(TARGET ncdiag) - add_dependencies(initialens.x ncdiag) -endif() - +target_compile_definitions(initialens.x PRIVATE "WRF") if(TARGET gsi) add_dependencies(initialens.x gsi) endif() - -target_compile_definitions(initialens.x PRIVATE "WRF") - target_link_libraries(initialens.x PRIVATE gsi::gsi) - -# Link the application targets with dependencies +if(TARGET ncdiag) + add_dependencies(initialens.x ncdiag) +endif() +target_link_libraries(initialens.x PRIVATE ncdiag::ncdiag) target_link_libraries(initialens.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(initialens.x PRIVATE MPI::MPI_Fortran) target_link_libraries(initialens.x PRIVATE ${LAPACK_LIBRARIES}) target_link_libraries(initialens.x PRIVATE bacio::bacio_4) -target_link_libraries(initialens.x PRIVATE sigio::sigio) -target_link_libraries(initialens.x PRIVATE sfcio::sfcio) -target_link_libraries(initialens.x PRIVATE nemsio::nemsio) -target_link_libraries(initialens.x PRIVATE ncio::ncio) target_link_libraries(initialens.x PRIVATE w3emc::w3emc_d) -target_link_libraries(initialens.x PRIVATE sp::sp_d) -target_link_libraries(initialens.x PRIVATE bufr::bufr_d) -target_link_libraries(initialens.x PRIVATE crtm::crtm) target_link_libraries(initialens.x PRIVATE wrf_io::wrf_io) -target_link_libraries(initialens.x PRIVATE ncdiag::ncdiag) -target_link_libraries(initialens.x PRIVATE gsi::gsi) if(OpenMP_Fortran_FOUND) target_link_libraries(initialens.x PRIVATE OpenMP::OpenMP_Fortran) endif() From f1469876eed299d2dcefd45b5037e47025feed7c Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 5 Mar 2022 18:20:20 -0500 Subject: [PATCH 27/58] add options for building different components. --- CMakeLists.txt | 18 ++- src/CMakeLists.txt | 23 +++- src/GSD/CMakeLists.txt | 2 + src/GSD/gsdcloud/CMakeLists.txt | 113 +++++++++++++++++- src/GSD/gsdcloud/cmake/PackageConfig.cmake.in | 19 +++ src/enkf/CMakeLists.txt | 31 ++--- src/enkf/cmake/PackageConfig.cmake.in | 6 +- src/gsi/CMakeLists.txt | 48 +++++--- src/gsi/cmake/PackageConfig.cmake.in | 6 +- src/ncdiag/CMakeLists.txt | 27 ++--- ush/build_all_cmake.sh | 6 +- util/CMakeLists.txt | 102 +++++++++++----- util/Correlated_Obs/CMakeLists.txt | 38 +++--- util/EFSOI_Utilities/CMakeLists.txt | 10 ++ util/EFSOI_Utilities/src/CMakeLists.txt | 34 ------ util/EnKF/CMakeLists.txt | 17 ++- util/EnKF/arw/src/CMakeLists.txt | 19 --- .../src/enspreproc_regional.fd/CMakeLists.txt | 5 - .../src/initialens_regional.fd/CMakeLists.txt | 5 - .../netcdf_io/calc_analysis.fd/CMakeLists.txt | 3 - util/netcdf_io/interp_inc.fd/CMakeLists.txt | 3 - .../radar_process/reflectivity/CMakeLists.txt | 18 +-- 22 files changed, 351 insertions(+), 202 deletions(-) create mode 100644 src/GSD/CMakeLists.txt create mode 100644 src/GSD/gsdcloud/cmake/PackageConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d80665ea0..aa99943aa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(gsi +project(GSIApp VERSION 1.0.0 LANGUAGES C Fortran) @@ -27,13 +27,27 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +option(BUILD_NCDIAG "Build GSI NetCDF Diagnostic Library" ON) +option(BUILD_GSDCLOUD "Build GSD Cloud Analysis Library" OFF) +option(BUILD_GSI "Build GSI" ON) +option(BUILD_ENKF "Build EnKF" ON) +option(BUILD_UTIL "Build Utilities" ON) # Echo user options message(STATUS "OPENMP ................. ${OPENMP}") message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "BUILD_NCDIAG ........... ${BUILD_NCDIAG}") +message(STATUS "BUILD_GSDCLOUD ......... ${BUILD_GSDCLOUD}") +message(STATUS "BUILD_GSI .............. ${BUILD_GSI}") +message(STATUS "BUILD_ENKF ............. ${BUILD_ENKF}") +message(STATUS "BUILD_UTIL ............. ${BUILD_UTIL}") # Build components add_subdirectory(src) -add_subdirectory(util) + +if(BUILD_UTIL) + add_subdirectory(util) +endif() + #add_subdirectory(unit-tests) #add_subdirectory(regression) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c730e35d94..04c58e2f67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,19 @@ -#add_subdirectory(GSD) -add_subdirectory(ncdiag) -add_subdirectory(gsi) -add_subdirectory(enkf) +if(BUILD_GSDCLOUD) + message(STATUS "Building GSD cloud analysis library") + add_subdirectory(GSD) +endif() + +if(BUILD_NCDIAG) + message(STATUS "Building GSI NetCDF diagnostic library") + add_subdirectory(ncdiag) +endif() + +if(BUILD_GSI) + message(STATUS "Building GSI") + add_subdirectory(gsi) +endif() + +if(BUILD_ENKF) + message(STATUS "Building EnKF") + add_subdirectory(enkf) +endif() diff --git a/src/GSD/CMakeLists.txt b/src/GSD/CMakeLists.txt new file mode 100644 index 0000000000..b0607b43e6 --- /dev/null +++ b/src/GSD/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(gsdcloud) +#add_subdirectory(gsdcloud4nmmb) # There is no CMakeLists.txt in gsdcloud4nmmb diff --git a/src/GSD/gsdcloud/CMakeLists.txt b/src/GSD/gsdcloud/CMakeLists.txt index 3b2ca84f12..bba48cdeb1 100644 --- a/src/GSD/gsdcloud/CMakeLists.txt +++ b/src/GSD/gsdcloud/CMakeLists.txt @@ -1,7 +1,108 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_GSDCLOUD_ARW) - file(GLOB GSDCLOUD_SRC ${GSDCLOUD_DIR}/*.f90) - set_source_files_properties( ${GSDCLOUD_SRC} COMPILE_FLAGS ${GSDCLOUD_Fortran_FLAGS}) - add_library( ${gsdcloud} STATIC ${GSDCLOUD_SRC} ) - set_target_properties( ${gsdcloud} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INCLUDE_OUTPUT_DIRECTORY} ) +cmake_minimum_required(VERSION 3.15) + +project(gsdcloud + VERSION 1.0.0 + LANGUAGES Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian") +endif() + +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +list(APPEND GSDCLOUD_SRC +ARPS_cldLib.f90 +BackgroundCld.f90 +BckgrndCC.f90 +PrecipMxr_radar.f90 +PrecipType.f90 +TempAdjust.f90 +adaslib.f90 +build_missing_REFcone.f90 +cloudCover_NESDIS.f90 +cloudCover_Surface.f90 +cloudCover_radar.f90 +cloudLWC.f90 +cloudLayers.f90 +cloudType.f90 +cloud_saturation.f90 +constants.f90 +convert_lghtn2ref.f90 +get_sfm_1d_gnl.f90 +hydro_mxr_thompson.f90 +kinds.f90 +map_ctp.f90 +map_ctp_lar.f90 +mthermo.f90 +pbl_height.f90 +pcp_mxr_ARPSlib.f90 +radar_ref2tten.f90 +read_Lightning_cld.f90 +read_NESDIS.f90 +read_Surface.f90 +read_nasalarc_cld.f90 +read_radar_ref.f90 +smooth.f90 +vinterp_radar_ref.f90 +) + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsdcloud") +add_library(gsdcloud STATIC ${GSDCLOUD_SRC}) +add_library(${PROJECT_NAME}::gsdcloud ALIAS gsdcloud) +set_target_properties(gsdcloud PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(gsdcloud PUBLIC $ + $) + +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +install(TARGETS gsdcloud + EXPORT ${PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/GSD/gsdcloud/cmake/PackageConfig.cmake.in b/src/GSD/gsdcloud/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..9e9d13e6a1 --- /dev/null +++ b/src/GSD/gsdcloud/cmake/PackageConfig.cmake.in @@ -0,0 +1,19 @@ +@PACKAGE_INIT@ + +#@PROJECT_NAME@-config.cmake +# +# Imported interface targets provided: +# * @PROJECT_NAME@::gsdcloud - gsdcloud library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") +include(CMakeFindDependencyMacro) + +# Get the build type from library target +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index b09cd74fbc..f87959aa6b 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -30,14 +30,14 @@ option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) option(USE_NCDIAG "Use NetCDF diagnostics library" ON) -set(ENKF_APP "GFS" CACHE STRING "Choose the EnKF Application.") -set_property(CACHE ENKF_APP PROPERTY STRINGS "GFS" "WRF" "NMMB" "FV3REG") +set(ENKF_MODE "GFS" CACHE STRING "Choose the EnKF Application.") +set_property(CACHE ENKF_MODE PROPERTY STRINGS "GFS" "WRF" "NMMB" "FV3REG") # Echo user options message(STATUS "EnKF: OPENMP ................. ${OPENMP}") message(STATUS "EnKF: ENABLE_MKL ............. ${ENABLE_MKL}") message(STATUS "EnKF: USE_NCDIAG ............. ${USE_NCDIAG}") -message(STATUS "EnKF: ENKF_APP ............... ${ENKF_APP}") +message(STATUS "EnKF: ENKF_MODE .............. ${ENKF_MODE}") # Dependencies if(ENABLE_MKL) @@ -63,7 +63,7 @@ find_package(nemsio REQUIRED) find_package(ncio REQUIRED) find_package(sp REQUIRED) find_package(w3emc REQUIRED) -if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") +if(ENKF_MODE MATCHES "^(WRF|NMMB|FV3REG)$") find_package(wrf_io REQUIRED) endif() @@ -92,16 +92,16 @@ list(APPEND EnKF_SRC_Fortran ${EnKF_SRC_srcs}) # Collect files for specific EnKF Application -if(ENKF_APP MATCHES "GFS") # GFS application +if(ENKF_MODE MATCHES "GFS") # GFS application list(APPEND EnKF_SRC_Fortran ${EnKF_SRC_gfs}) -elseif(ENKF_APP MATCHES "WRF") # WRF application +elseif(ENKF_MODE MATCHES "WRF") # WRF application list(APPEND EnKF_SRC_Fortran ${EnKF_SRC_wrf}) -elseif(ENKF_APP MATCHES "NMMB") # NMMB application +elseif(ENKF_MODE MATCHES "NMMB") # NMMB application list(APPEND EnKF_SRC_Fortran ${EnKF_SRC_nmmb}) -elseif(ENKF_APP MATCHES "FV3REG") # WRF application +elseif(ENKF_MODE MATCHES "FV3REG") # WRF application list(APPEND EnKF_SRC_Fortran ${EnKF_SRC_fv3reg}) endif() @@ -141,6 +141,7 @@ endif() add_library(enkf STATIC) add_library(${PROJECT_NAME}::enkf ALIAS enkf) set_target_properties(enkf PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +set_target_properties(enkf PROPERTIES MODE "${ENKF_MODE}") target_include_directories(enkf PUBLIC $ $) target_link_libraries(enkf PUBLIC enkf_fortran_obj) @@ -174,23 +175,23 @@ include(CMakePackageConfigHelpers) set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export(EXPORT ${PROJECT_NAME}Exports - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake) + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + DESTINATION ${CONFIG_INSTALL_DESTINATION}) write_basic_package_version_file( ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + DESTINATION ${CONFIG_INSTALL_DESTINATION}) install(EXPORT ${PROJECT_NAME}Exports - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/enkf/cmake/PackageConfig.cmake.in b/src/enkf/cmake/PackageConfig.cmake.in index fbf4edf30a..47e7e268df 100644 --- a/src/enkf/cmake/PackageConfig.cmake.in +++ b/src/enkf/cmake/PackageConfig.cmake.in @@ -11,7 +11,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) # Set the EnKF configuration attributes -set(ENKF_APP @ENKF_APP@) +set(ENKF_MODE @ENKF_MODE@) set(ENKF_USE_NCDIAG @USE_NCDIAG@) find_dependency(MPI) @@ -41,7 +41,7 @@ find_dependency(ncio REQUIRED) find_dependency(sp REQUIRED) find_dependency(w3emc REQUIRED) -if(ENKF_APP MATCHES "^(WRF|NMMB|FV3REG)$") +if(ENKF_MODE MATCHES "^(WRF|NMMB|FV3REG)$") find_dependency(wrf_io REQUIRED) endif() @@ -58,5 +58,5 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindEnKF defines targets:") -message(STATUS " - ENKF_APP [${ENKF_APP}]") +message(STATUS " - ENKF_MODE [${ENKF_MODE}]") message(STATUS " - ENKF_USE_NCDIAG [${GSI_USE_NCDIAG}]") diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index dd88d20cde..e90d4726bd 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -29,15 +29,17 @@ endif() option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) option(USE_NCDIAG "Use NetCDF diagnostics library" ON) +option(USE_GSDCLOUD "Use GSD Cloud Analysis library" OFF) -set(GSI_APP "GFS" CACHE STRING "Choose the GSI Application.") -set_property(CACHE GSI_APP PROPERTY STRINGS "GFS" "Regional") +set(GSI_MODE "GFS" CACHE STRING "Choose the GSI Application.") +set_property(CACHE GSI_MODE PROPERTY STRINGS "GFS" "Regional") # Echo user options message(STATUS "GSI: OPENMP ................. ${OPENMP}") message(STATUS "GSI: ENABLE_MKL ............. ${ENABLE_MKL}") message(STATUS "GSI: USE_NCDIAG ............. ${USE_NCDIAG}") -message(STATUS "GSI: GSI_APP ................ ${GSI_APP}") +message(STATUS "GSI: USE_GSDCLOUD ........... ${USE_GSDCLOUD}") +message(STATUS "GSI: GSI_MODE ............... ${GSI_MODE}") # Dependencies if(ENABLE_MKL) @@ -66,7 +68,7 @@ find_package(ip REQUIRED) find_package(w3emc REQUIRED) find_package(bufr REQUIRED) find_package(crtm REQUIRED) -if(GSI_APP MATCHES "Regional") +if(GSI_MODE MATCHES "Regional") find_package(wrf_io REQUIRED) endif() @@ -80,6 +82,13 @@ if(USE_NCDIAG) endif() endif() +# GSD Cloud Analysis library dependency +if(USE_GSDCLOUD) + if(NOT TARGET gsdcloud) + find_package(gsdcloud REQUIRED) + endif() +endif() + # Get compiler flags for the GSI application include(gsiapp_compiler_flags) @@ -92,11 +101,11 @@ list(APPEND GSI_SRC_Fortran ${GSI_SRC_class}) # Collect files for specific GSI Application -if(GSI_APP MATCHES "GFS") # GFS GSI application +if(GSI_MODE MATCHES "GFS") # GFS GSI application list(APPEND GSI_SRC_Fortran ${GSI_SRC_gfs_stub} ${GSI_SRC_fixture_gfs}) -elseif(GSI_APP MATCHES "Regional") # Regional GSI application +elseif(GSI_MODE MATCHES "Regional") # Regional GSI application list(APPEND GSI_SRC_Fortran ${GSI_SRC_regional_cplr} ${GSI_SRC_fixture_regional}) @@ -119,6 +128,9 @@ list(APPEND GSI_Fortran_defs _REAL8_) if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") list(APPEND GSI_Fortran_defs POUND_FOR_STRINGIFY) endif() +if(USE_GSDCLOUD) + list(APPEND GSI_Fortran_defs RR_CLOUDANALYSIS) +endif() # Create a library of GSI C sources add_library(gsi_c_obj OBJECT ${GSI_SRC_C}) @@ -144,7 +156,7 @@ target_link_libraries(gsi_fortran_obj PUBLIC w3emc::w3emc_d) target_link_libraries(gsi_fortran_obj PUBLIC sp::sp_d) target_link_libraries(gsi_fortran_obj PUBLIC bufr::bufr_d) target_link_libraries(gsi_fortran_obj PUBLIC crtm::crtm) -if(GSI_APP MATCHES "Regional") +if(GSI_MODE MATCHES "Regional") target_link_libraries(gsi_fortran_obj PUBLIC wrf_io::wrf_io) endif() if(USE_NCDIAG) @@ -154,6 +166,13 @@ if(USE_NCDIAG) endif() target_link_libraries(gsi_fortran_obj PUBLIC ncdiag::ncdiag) endif() +if(USE_GSDCLOUD) + if(TARGET gsdcloud) + add_dependencies(gsi_fortran_obj gsdcloud) + add_library(gsdcloud::gsdcloud ALIAS gsdcloud) + endif() + target_link_libraries(gsi_fortran_obj PUBLIC gsdcloud::gsdcloud) +endif() if(OpenMP_Fortran_FOUND) target_link_libraries(gsi_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) endif() @@ -162,6 +181,7 @@ endif() add_library(gsi STATIC) add_library(${PROJECT_NAME}::gsi ALIAS gsi) set_target_properties(gsi PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +set_target_properties(gsi PROPERTIES MODE "${GSI_MODE}") target_include_directories(gsi PUBLIC $ $) target_link_libraries(gsi PUBLIC gsi_c_obj) @@ -197,23 +217,23 @@ include(CMakePackageConfigHelpers) set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export(EXPORT ${PROJECT_NAME}Exports - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake) + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + DESTINATION ${CONFIG_INSTALL_DESTINATION}) write_basic_package_version_file( ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + DESTINATION ${CONFIG_INSTALL_DESTINATION}) install(EXPORT ${PROJECT_NAME}Exports - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in index 4529a7ba31..020ffaac88 100644 --- a/src/gsi/cmake/PackageConfig.cmake.in +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -11,7 +11,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) # Set the GSI configuration attributes -set(GSI_APP @GSI_APP@) +set(GSI_MODE @GSI_MODE@) set(GSI_USE_NCDIAG @USE_NCDIAG@) find_dependency(MPI) @@ -42,7 +42,7 @@ find_dependency(w3emc REQUIRED) find_dependency(bufr REQUIRED) find_dependency(crtm REQUIRED) -if(GSI_APP MATCHES "Regional") +if(GSI_MODE MATCHES "Regional") find_dependency(wrf_io REQUIRED) endif() @@ -59,5 +59,5 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindGSI defines targets:") -message(STATUS " - GSI_APP [${GSI_APP}]") +message(STATUS " - GSI_MODE [${GSI_MODE}]") message(STATUS " - GSI_USE_NCDIAG [${GSI_USE_NCDIAG}]") diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index e7c568db93..390d981145 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -52,8 +52,7 @@ target_link_libraries(ncdiag PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(ncdiag PUBLIC MPI::MPI_Fortran) target_include_directories(ncdiag PUBLIC $ $) -list(APPEND NCDIAG_Targets - ncdiag) +list(APPEND NCDIAG_Targets ncdiag) install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) # Build applications @@ -65,8 +64,7 @@ foreach(app ${NCDIAG_SRC_app}) target_link_libraries(${app_name}.x PUBLIC ncdiag) target_link_libraries(${app_name}.x PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(${app_name}.x PUBLIC MPI::MPI_Fortran) - list(APPEND NCDIAG_Targets - ${app_name}.x) + list(APPEND NCDIAG_Targets ${app_name}.x) endforeach() # Build serial library and applications @@ -80,16 +78,14 @@ if(ENABLE_NCDIAG_SERIAL) target_link_libraries(ncdiag_serial PUBLIC NetCDF::NetCDF_Fortran) target_include_directories(ncdiag_serial PUBLIC $ $) - list(APPEND NCDIAG_Targets - ncdiag_serial) + list(APPEND NCDIAG_Targets ncdiag_serial) set(app_name "ncdiag_cat_serial") add_executable(${app_name}.x nc_diag_cat.F90) add_dependencies(${app_name}.x ncdiag_serial) target_link_libraries(${app_name}.x PUBLIC ncdiag_serial) target_link_libraries(${app_name}.x PUBLIC NetCDF::NetCDF_Fortran) - list(APPEND NCDIAG_Targets - ${app_name}.x) + list(APPEND NCDIAG_Targets ${app_name}.x) install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) endif() @@ -100,27 +96,28 @@ install( LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +# Package config include(CMakePackageConfigHelpers) set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export(EXPORT ${PROJECT_NAME}Exports - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake) + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + DESTINATION ${CONFIG_INSTALL_DESTINATION}) write_basic_package_version_file( ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + DESTINATION ${CONFIG_INSTALL_DESTINATION}) install(EXPORT ${PROJECT_NAME}Exports - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME}-targets.cmake - DESTINATION ${CONFIG_INSTALL_DESTINATION}) + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index 7e67ee45cc..4cd3838f59 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -116,11 +116,11 @@ cmake_opts+=" -DCMAKE_INSTALL_PREFIX=$dir_root/install" cmake_opts+=" -DCMAKE_INSTALL_BINDIR=exec" # By default; build the global applications -cmake_opts+=" -DGSI_APP=GFS -DENKF_APP=GFS" +cmake_opts+=" -DGSI_MODE=GFS -DENKF_MODE=GFS" # Valid combination of applications are: -# Global : -DGSI_APP=GFS -DENKF_APP=GFS -# Regional: -DGSI_APP=Regional -DENKF_APP=WRF|NMMB|FV3REG +# Global : -DGSI_MODE=GFS -DENKF_MODE=GFS +# Regional: -DGSI_MODE=Regional -DENKF_MODE=WRF|NMMB|FV3REG cmake $cmake_opts $dir_root diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 4c5871ace3..ed481e07db 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -28,20 +28,28 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) -option(USE_NCDIAG "Use NetCDF diagnostics library" ON) -set(GSI_APP "GFS" CACHE STRING "Choose the GSI Application.") -set_property(CACHE GSI_APP PROPERTY STRINGS "GFS" "Regional") - -set(ENKF_APP "GFS" CACHE STRING "Choose the GSI Application.") -set_property(CACHE ENKF_APP PROPERTY STRINGS "GFS" "Regional") +# Build options +option(BUILD_AERODA_UTIL "Build Aerosol DA utilities" OFF) +option(BUILD_COV_CALC "Build Correlated Observation Error Utility" OFF) +option(BUILD_EFSOI_UTIL "Build EFSOI Utilities" OFF) +option(BUILD_ENKF_GFS "Build EnKF GFS Utilities" OFF) +option(BUILD_ENKF_ARW "Build EnKF ARW Utilities" OFF) +option(BUILD_MON_UTIL "Build Monitoring Utilities" OFF) +option(BUILD_NCIO_UTIL "Build NetCDF IO Utilities" OFF) +option(BUILD_UTIL_COM "Build community utilities" OFF) # Echo user options -message(STATUS "GSI Utils: OPENMP ................. ${OPENMP}") -message(STATUS "GSI Utils: ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "GSI Utils: USE_NCDIAG ............. ${USE_NCDIAG}") -message(STATUS "GSI Utils: GSI_APP ................ ${GSI_APP}") -message(STATUS "GSI Utils: ENKF_APP ............... ${ENKF_APP}") +message(STATUS "Utils: OPENMP ................. ${OPENMP}") +message(STATUS "Utils: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "Utils: BUILD_AERODA_UTIL ...... ${BUILD_AERODA_UTIL}") +message(STATUS "Utils: BUILD_COV_CALC ......... ${BUILD_COV_CALC}") +message(STATUS "Utils: BUILD_EFSOI_UTIL ....... ${BUILD_EFSOI_UTIL}") +message(STATUS "Utils: BUILD_ENKF_GFS ......... ${BUILD_ENKF_GFS}") +message(STATUS "Utils: BUILD_ENKF_ARW ......... ${BUILD_ENKF_ARW}") +message(STATUS "Utils: BUILD_MON_UTIL ......... ${BUILD_MON_UTIL}") +message(STATUS "Utils: BUILD_NCIO_UTIL ........ ${BUILD_NCIO_UTIL}") +message(STATUS "Utils: BUILD_UTIL_COM ......... ${BUILD_UTIL_COM}") # Dependencies if(ENABLE_MKL) @@ -59,6 +67,22 @@ if(OPENMP) find_package(OpenMP REQUIRED) endif() +if(NOT TARGET ncdiag) + find_package(ncdiag QUIET) +endif() + +if(TARGET gsi) + get_target_property(GSI_MODE gsi "MODE") +else() + find_package(gsi QUIET) +endif() + +if(TARGET enkf) + get_target_property(ENKF_MODE enkf "MODE") +else() + find_package(enkf QUIET) +endif() + # NCEPLibs dependencies find_package(bacio REQUIRED) find_package(sigio REQUIRED) @@ -69,10 +93,7 @@ find_package(sp REQUIRED) find_package(ip REQUIRED) find_package(w3emc REQUIRED) find_package(bufr REQUIRED) -find_package(crtm REQUIRED) -if(GSI_APP MATCHES "Regional") - find_package(wrf_io REQUIRED) -endif() +find_package(wrf_io QUIET) # See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) @@ -80,34 +101,55 @@ target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) # Get compiler flags for the utilities include(gsiutils_compiler_flags) -add_subdirectory(AeroDA) -add_subdirectory(Analysis_Utilities) -add_subdirectory(bufr_tools) -#add_subdirectory(Conventional_Monitor) -add_subdirectory(Correlated_Obs) -add_subdirectory(EFSOI_Utilities) -add_subdirectory(EnKF) +if(BUILD_AERODA_UTIL) + add_subdirectory(AeroDA) +endif() + +if(BUILD_COV_CALC) + add_subdirectory(Correlated_Obs) +endif() + +if(BUILD_EFSOI_UTIL) + add_subdirectory(EFSOI_Utilities) +endif() + +if(BUILD_ENKF_GFS OR BUILD_ENKF_ARW) + add_subdirectory(EnKF) +endif() + +if(BUILD_NCIO_UTIL) + add_subdirectory(netcdf_io) +endif() + +if(BUILD_UTIL_COM) + add_subdirectory(Analysis_Utilities) + add_subdirectory(bufr_tools) + add_subdirectory(radar_process) +endif() + add_subdirectory(ndate) -add_subdirectory(netcdf_io) -#add_subdirectory(Ozone_Monitor) -add_subdirectory(radar_process) -#add_subdirectory(Radiance_Monitor) add_subdirectory(zero_biascoeff) +if(BUILD_MON_UTIL) + message(FATAL_ERROR "CMake in the Monitoring utilities have not been updated") +# add_subdirectory(Conventional_Monitor) +# add_subdirectory(Ozone_Monitor) +# add_subdirectory(Radiance_Monitor) +endif() + # These utilities do not have CMake builds # Some are used occasionally e.g. NMC_Bkerror # Some are really really old and likely unusable today e.g. Config #add_subdirectory(Config) -#add_subdirectory(FOV_utilities) + #add_subdirectory(FOV_utilities) #add_subdirectory(GEN_BE_V2.0) #add_subdirectory(global_angupdate) #add_subdirectory(GMI_BUFR_gen) -#add_subdirectory(Minimization_Monitor) #add_subdirectory(Misc) #add_subdirectory(MODIS_AOD) #add_subdirectory(NCEP_bkerror) #add_subdirectory(NCEPgsi_Coupler) -#add_subdirectory(NMC_Bkerror) + #add_subdirectory(NMC_Bkerror) #add_subdirectory(Radiance_bias_correction_Utilities) #add_subdirectory(Radiance_Utilities) -#add_subdirectory(Single_Observation) + #add_subdirectory(Single_Observation) diff --git a/util/Correlated_Obs/CMakeLists.txt b/util/Correlated_Obs/CMakeLists.txt index 8c0c91a346..d6f015d479 100644 --- a/util/Correlated_Obs/CMakeLists.txt +++ b/util/Correlated_Obs/CMakeLists.txt @@ -1,44 +1,36 @@ +if(NOT TARGET ncdiag) + if(NOT ncdiag_FOUND) + message(STATUS "Utils: ncdiag library was not found. Disable Correlated Obs utility") + return() + endif() +endif() + if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() -if(NOT TARGET ncdiag) - find_package(ncdiag REQUIRED) -endif() - list(APPEND SRCS cconstants.f90 ckinds.f90 + cov_calc.f90 matrix_tools.f90 obs_tools.f90 pairs.f90 readsatobs.f90 read_diag.f90) -# Create cov_calc library -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/cov_calc") -add_library(cov_calc OBJECT ${SRCS}) -set_target_properties(cov_calc PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_include_directories(cov_calc INTERFACE $) - -target_link_libraries(cov_calc PUBLIC NetCDF::NetCDF_Fortran) -target_link_libraries(cov_calc PUBLIC MPI::MPI_Fortran) -target_link_libraries(cov_calc PUBLIC ${LAPACK_LIBRARIES}) +# Create cov_calc.x executable +add_executable(cov_calc.x ${SRCS}) +target_link_libraries(cov_calc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(cov_calc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(cov_calc.x PRIVATE ${LAPACK_LIBRARIES}) if(TARGET ncdiag) - add_dependencies(cov_calc ncdiag) + add_dependencies(cov_calc.x ncdiag) add_library(ncdiag::ncdiag ALIAS ncdiag) endif() -target_link_libraries(cov_calc PUBLIC ncdiag::ncdiag) -if(OpenMP_Fortran_FOUND) - target_link_libraries(cov_calc PRIVATE OpenMP::OpenMP_Fortran) -endif() - -# Create cov_calc.x executable -add_executable(cov_calc.x cov_calc.f90) -add_dependencies(cov_calc.x cov_calc) -target_link_libraries(cov_calc.x PRIVATE cov_calc) +target_link_libraries(cov_calc.x PRIVATE ncdiag::ncdiag) if(OpenMP_Fortran_FOUND) target_link_libraries(cov_calc.x PRIVATE OpenMP::OpenMP_Fortran) endif() diff --git a/util/EFSOI_Utilities/CMakeLists.txt b/util/EFSOI_Utilities/CMakeLists.txt index febd4f0ab6..1aec52ef07 100644 --- a/util/EFSOI_Utilities/CMakeLists.txt +++ b/util/EFSOI_Utilities/CMakeLists.txt @@ -1 +1,11 @@ +if(NOT TARGET enkf) + if(NOT enkf_FOUND) + message(FATAL_ERROR "Utils: EnKF library was not found for EFSOI utilities") + endif() +endif() + +if(NOT ENKF_MODE MATCHES "GFS") + message(FATAL_ERROR "Utils: Incompatible EnKF = ${ENKF_MODE} for EFSOI utilities") +endif() + add_subdirectory(src) diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 1d810e7ced..fd16d71bed 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -4,32 +4,6 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() -if(NOT TARGET enkf) - find_package(enkf QUIET) - if(NOT enkf_FOUND) - message(STATUS "GSI Utils: EnKF library was not found. Disable EFSOI utilities") - return() - endif() -endif() - -if(NOT ENKF_APP MATCHES "GFS") - message(STATUS "GSI Utils: Incompatible EnKF = ${ENKF_APP}. Disable EFSOI utilities") - return() -endif() - -if(NOT TARGET gsi) - find_package(gsi REQUIRED) -endif() - -if(NOT GFS_APP MATCHES "GFS") - message(STATUS "GSI Utils: Incompatible GFS = ${GFS_APP}. Disable EFSOI utilities") - return() -endif() - -if(NOT TARGET ncdiag) - find_package(ncdiag REQUIRED) -endif() - list(APPEND SRCS efsoi.f90 efsoi_main.f90 @@ -45,14 +19,6 @@ if(TARGET enkf) add_dependencies(efsoi.x enkf) endif() target_link_libraries(efsoi.x PRIVATE enkf::enkf) -if(TARGET gsi) - add_dependencies(efsoi.x gsi) -endif() -target_link_libraries(efsoi.x PRIVATE gsi::gsi) -if(TARGET ncdiag) - add_dependencies(efsoi.x ncdiag) -endif() -target_link_libraries(efsoi.x PRIVATE ncdiag::ncdiag) target_link_libraries(efsoi.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(efsoi.x PRIVATE MPI::MPI_Fortran) target_link_libraries(efsoi.x PRIVATE ${LAPACK_LIBRARIES}) diff --git a/util/EnKF/CMakeLists.txt b/util/EnKF/CMakeLists.txt index 607b4b32e8..8a73a74d3a 100644 --- a/util/EnKF/CMakeLists.txt +++ b/util/EnKF/CMakeLists.txt @@ -1,2 +1,15 @@ -add_subdirectory(arw) -add_subdirectory(gfs) +if(BUILD_ENKF_GFS) + add_subdirectory(gfs) +endif() + +if(BUILD_ENKF_ARW) + if(NOT TARGET gsi) + if(NOT gsi_FOUND) + message(FATAL_ERROR "Utils: GSI library was not found for EnKF ARW utilities") + endif() + endif() + if(NOT GSI_MODE MATCHES "Regional") + message(FATAL_ERROR "Utils: Incompatible GSI = ${GSI_MODE} for EnKF ARW utilities") + endif() + add_subdirectory(arw) +endif() diff --git a/util/EnKF/arw/src/CMakeLists.txt b/util/EnKF/arw/src/CMakeLists.txt index 8695611c98..cd78c072a9 100644 --- a/util/EnKF/arw/src/CMakeLists.txt +++ b/util/EnKF/arw/src/CMakeLists.txt @@ -1,22 +1,3 @@ -# These utilities require the Regional GSI to be compiled and available as a library. - -if(NOT TARGET gsi) - find_package(gsi QUIET) - if(NOT gsi_FOUND) - message(STATUS "GSI Utils: GSI library was not found. Disable EnKF ARW utilities") - return() - endif() -endif() - -if(NOT GSI_APP MATCHES "Regional") - message(STATUS "GSI Utils: Incompatible GSI = ${GSI_APP}, Disable EnKF ARW utilities") - return() -endif() - -if(NOT TARGET ncdiag) - find_package(ncdiag REQUIRED) -endif() - add_subdirectory(enspreproc_regional.fd) add_subdirectory(initialens_regional.fd) diff --git a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt index bc9a2b8bfe..efcb62e5f7 100644 --- a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt @@ -17,13 +17,8 @@ if(TARGET gsi) add_dependencies(enspreproc.x gsi) endif() target_link_libraries(enspreproc.x PRIVATE gsi::gsi) -if(TARGET ncdiag) - add_dependencies(enspreproc.x ncdiag) -endif() -target_link_libraries(enspreproc.x PRIVATE ncdiag::ncdiag) target_link_libraries(enspreproc.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(enspreproc.x PRIVATE MPI::MPI_Fortran) -target_link_libraries(enspreproc.x PRIVATE ${LAPACK_LIBRARIES}) target_link_libraries(enspreproc.x PRIVATE bacio::bacio_4) target_link_libraries(enspreproc.x PRIVATE w3emc::w3emc_d) target_link_libraries(enspreproc.x PRIVATE wrf_io::wrf_io) diff --git a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt index dc1f52216e..4a4968fee7 100644 --- a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt @@ -15,13 +15,8 @@ if(TARGET gsi) add_dependencies(initialens.x gsi) endif() target_link_libraries(initialens.x PRIVATE gsi::gsi) -if(TARGET ncdiag) - add_dependencies(initialens.x ncdiag) -endif() -target_link_libraries(initialens.x PRIVATE ncdiag::ncdiag) target_link_libraries(initialens.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(initialens.x PRIVATE MPI::MPI_Fortran) -target_link_libraries(initialens.x PRIVATE ${LAPACK_LIBRARIES}) target_link_libraries(initialens.x PRIVATE bacio::bacio_4) target_link_libraries(initialens.x PRIVATE w3emc::w3emc_d) target_link_libraries(initialens.x PRIVATE wrf_io::wrf_io) diff --git a/util/netcdf_io/calc_analysis.fd/CMakeLists.txt b/util/netcdf_io/calc_analysis.fd/CMakeLists.txt index a017efbbd6..7ebe050985 100644 --- a/util/netcdf_io/calc_analysis.fd/CMakeLists.txt +++ b/util/netcdf_io/calc_analysis.fd/CMakeLists.txt @@ -12,9 +12,6 @@ list(APPEND SRCS vars_calc_analysis.f90) add_executable(calc_analysis.x ${SRCS}) -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/calc_analysis") -set_target_properties(calc_analysis.x PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) -target_include_directories(calc_analysis.x INTERFACE $) target_link_libraries(calc_analysis.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(calc_analysis.x PRIVATE MPI::MPI_Fortran) target_link_libraries(calc_analysis.x PRIVATE bacio::bacio_4) diff --git a/util/netcdf_io/interp_inc.fd/CMakeLists.txt b/util/netcdf_io/interp_inc.fd/CMakeLists.txt index 3b58c64dc9..1c2d5af1d9 100644 --- a/util/netcdf_io/interp_inc.fd/CMakeLists.txt +++ b/util/netcdf_io/interp_inc.fd/CMakeLists.txt @@ -5,9 +5,6 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") endif() add_executable(interp_inc.x driver.f90) -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/interp_inc") -set_target_properties(interp_inc.x PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) -target_include_directories(interp_inc.x INTERFACE $) target_link_libraries(interp_inc.x PRIVATE NetCDF::NetCDF_Fortran) target_link_libraries(interp_inc.x PRIVATE MPI::MPI_Fortran) target_link_libraries(interp_inc.x PRIVATE w3emc::w3emc_d) diff --git a/util/radar_process/reflectivity/CMakeLists.txt b/util/radar_process/reflectivity/CMakeLists.txt index 83710ad1d4..7ede68d2a0 100644 --- a/util/radar_process/reflectivity/CMakeLists.txt +++ b/util/radar_process/reflectivity/CMakeLists.txt @@ -7,23 +7,15 @@ endif() list(APPEND SRCS kinds.F90 nc_subs.f90 + process_NSSL_mosaic.f90 read_nssl_binary.f90 write_bufr_ref.f90) -# Create library -set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/process_NSSL_mosaic") -add_library(process_NSSL_mosaic OBJECT ${SRCS}) -set_target_properties(process_NSSL_mosaic PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -target_include_directories(process_NSSL_mosaic INTERFACE $) - -target_link_libraries(process_NSSL_mosaic PUBLIC NetCDF::NetCDF_Fortran) -target_link_libraries(process_NSSL_mosaic PUBLIC MPI::MPI_Fortran) -target_link_libraries(process_NSSL_mosaic PUBLIC bufr::bufr_d) - # Create process_NSSL_mosaic.x executable -add_executable(process_NSSL_mosaic.x process_NSSL_mosaic.f90) -add_dependencies(process_NSSL_mosaic.x process_NSSL_mosaic) -target_link_libraries(process_NSSL_mosaic.x PRIVATE process_NSSL_mosaic) +add_executable(process_NSSL_mosaic.x ${SRCS}) +target_link_libraries(process_NSSL_mosaic.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(process_NSSL_mosaic.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(process_NSSL_mosaic.x PRIVATE bufr::bufr_d) # Install executable targets install(TARGETS process_NSSL_mosaic.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) From a7dd38066b3ce280e82de4cd50895c359c85cc9a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sun, 6 Mar 2022 22:02:11 -0500 Subject: [PATCH 28/58] add utilities that are used but did not have CMake builds --- util/CMakeLists.txt | 15 ++++---- util/FOV_utilities/CMakeLists.txt | 1 + util/FOV_utilities/sorc/CMakeLists.txt | 13 +++++++ util/NMC_Bkerror/CMakeLists.txt | 2 ++ util/NMC_Bkerror/sorc/CMakeLists.txt | 44 +++++++++++++++++++++++ util/NMC_Bkerror/sorc/initvars.f90 | 2 +- util/NMC_Bkerror/sorc_aero/CMakeLists.txt | 35 ++++++++++++++++++ util/Single_Observation/CMakeLists.txt | 12 +++++++ 8 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 util/FOV_utilities/CMakeLists.txt create mode 100644 util/FOV_utilities/sorc/CMakeLists.txt create mode 100644 util/NMC_Bkerror/CMakeLists.txt create mode 100644 util/NMC_Bkerror/sorc/CMakeLists.txt create mode 100644 util/NMC_Bkerror/sorc_aero/CMakeLists.txt create mode 100644 util/Single_Observation/CMakeLists.txt diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index ed481e07db..c1a92c0556 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -38,6 +38,7 @@ option(BUILD_ENKF_ARW "Build EnKF ARW Utilities" OFF) option(BUILD_MON_UTIL "Build Monitoring Utilities" OFF) option(BUILD_NCIO_UTIL "Build NetCDF IO Utilities" OFF) option(BUILD_UTIL_COM "Build community utilities" OFF) +option(BUILD_BKGERR_UTIL "Build Background Error Utilities" OFF) # Echo user options message(STATUS "Utils: OPENMP ................. ${OPENMP}") @@ -50,6 +51,7 @@ message(STATUS "Utils: BUILD_ENKF_ARW ......... ${BUILD_ENKF_ARW}") message(STATUS "Utils: BUILD_MON_UTIL ......... ${BUILD_MON_UTIL}") message(STATUS "Utils: BUILD_NCIO_UTIL ........ ${BUILD_NCIO_UTIL}") message(STATUS "Utils: BUILD_UTIL_COM ......... ${BUILD_UTIL_COM}") +message(STATUS "Utils: BUILD_BKGERR_UTIL ...... ${BUILD_BKGERR_UTIL}") # Dependencies if(ENABLE_MKL) @@ -127,6 +129,12 @@ if(BUILD_UTIL_COM) add_subdirectory(radar_process) endif() +if(BUILD_BKGERR_UTIL) + add_subdirectory(NMC_Bkerror) +endif() + +add_subdirectory(FOV_utilities) +add_subdirectory(Single_Observation) add_subdirectory(ndate) add_subdirectory(zero_biascoeff) @@ -137,11 +145,8 @@ if(BUILD_MON_UTIL) # add_subdirectory(Radiance_Monitor) endif() -# These utilities do not have CMake builds -# Some are used occasionally e.g. NMC_Bkerror -# Some are really really old and likely unusable today e.g. Config +# These utilities do not have CMake builds and are unlikely used or usable #add_subdirectory(Config) - #add_subdirectory(FOV_utilities) #add_subdirectory(GEN_BE_V2.0) #add_subdirectory(global_angupdate) #add_subdirectory(GMI_BUFR_gen) @@ -149,7 +154,5 @@ endif() #add_subdirectory(MODIS_AOD) #add_subdirectory(NCEP_bkerror) #add_subdirectory(NCEPgsi_Coupler) - #add_subdirectory(NMC_Bkerror) #add_subdirectory(Radiance_bias_correction_Utilities) #add_subdirectory(Radiance_Utilities) - #add_subdirectory(Single_Observation) diff --git a/util/FOV_utilities/CMakeLists.txt b/util/FOV_utilities/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/FOV_utilities/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/FOV_utilities/sorc/CMakeLists.txt b/util/FOV_utilities/sorc/CMakeLists.txt new file mode 100644 index 0000000000..d30f361882 --- /dev/null +++ b/util/FOV_utilities/sorc/CMakeLists.txt @@ -0,0 +1,13 @@ +list(APPEND SRCS +calc_fov_conical.f90 +calc_fov_crosstrk.f90 +constants.f90 +driver.f90 +kinds.F90) + +add_executable(fov_util.x ${SRCS}) +target_compile_definitions(fov_util.x PRIVATE "_REAL8_") + +# Install executable targets +install(TARGETS fov_util.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/NMC_Bkerror/CMakeLists.txt b/util/NMC_Bkerror/CMakeLists.txt new file mode 100644 index 0000000000..3e87e78e65 --- /dev/null +++ b/util/NMC_Bkerror/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(sorc) +add_subdirectory(sorc_aero) diff --git a/util/NMC_Bkerror/sorc/CMakeLists.txt b/util/NMC_Bkerror/sorc/CMakeLists.txt new file mode 100644 index 0000000000..6060ae1edc --- /dev/null +++ b/util/NMC_Bkerror/sorc/CMakeLists.txt @@ -0,0 +1,44 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") +endif() + +list(APPEND SRCS +balprojs.F90 +biascor.f90 +comm_mod.f90 +delvars.f90 +deter_subdomain.f90 +genqsat.f90 +getcases.f90 +grdsphdp.f90 +horizsc.f90 +init_commvars.f90 +initvars.f90 +isrchfge.f90 +kinds.f90 +mat.f90 +postmod.f90 +readpairs.f90 +smooth2d.f90 +smoothz.f90 +specgrid.f90 +sstmod.f90 +statsmain.f90 +variables.f90 +variances.f90 +variances3d.f90 +vertsc.f90) + +add_executable(calcstats.x ${SRCS}) +target_compile_definitions(calcstats.x PRIVATE "_LAPACK_") +target_link_libraries(calcstats.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calcstats.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(calcstats.x PRIVATE bacio::bacio_4) +target_link_libraries(calcstats.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calcstats.x PRIVATE sp::sp_4) +target_link_libraries(calcstats.x PRIVATE sigio::sigio) +target_link_libraries(calcstats.x PRIVATE nemsio::nemsio) + +install(TARGETS calcstats.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/NMC_Bkerror/sorc/initvars.f90 b/util/NMC_Bkerror/sorc/initvars.f90 index 8797baf65a..bc0fca444e 100644 --- a/util/NMC_Bkerror/sorc/initvars.f90 +++ b/util/NMC_Bkerror/sorc/initvars.f90 @@ -69,7 +69,7 @@ subroutine initvars(mype,npe) endif if (mype==0) write(6,*) 'INITVARS: DB_PREC = ',db_prec - if (scaling == .true.) then + if (scaling .eqv. .true.) then allocate (varscale(nsig)) open(12,file='scaling.txt',form='formatted') do k=1,nsig diff --git a/util/NMC_Bkerror/sorc_aero/CMakeLists.txt b/util/NMC_Bkerror/sorc_aero/CMakeLists.txt new file mode 100644 index 0000000000..ae48aa40a4 --- /dev/null +++ b/util/NMC_Bkerror/sorc_aero/CMakeLists.txt @@ -0,0 +1,35 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") +endif() + +list(APPEND SRCS +comm_mod.f90 +delvars_aerosol.f90 +deter_subdomain.f90 +getcases_nems.f90 +grdsphdp.f90 +horizsc_aerosol.f90 +init_commvars.f90 +initvars.f90 +kinds.F90 +mat.f90 +postmod.f90 +readpairs_aerosol.f90 +smoothz.f90 +specgrid.f90 +statsmain_aerosol.f90 +variables.f90 +variances_aerosol.f90 +vertsc_aerosol.f90) + +add_executable(calcstats_aero.x ${SRCS}) +target_link_libraries(calcstats_aero.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calcstats_aero.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(calcstats_aero.x PRIVATE bacio::bacio_4) +target_link_libraries(calcstats_aero.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calcstats_aero.x PRIVATE sp::sp_4) +target_link_libraries(calcstats_aero.x PRIVATE nemsio::nemsio) + +install(TARGETS calcstats_aero.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Single_Observation/CMakeLists.txt b/util/Single_Observation/CMakeLists.txt new file mode 100644 index 0000000000..eb54b0f86f --- /dev/null +++ b/util/Single_Observation/CMakeLists.txt @@ -0,0 +1,12 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -r8") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() + +add_executable(makeoneobbufr.x makeoneobbufr.f90) +target_link_libraries(makeoneobbufr.x PRIVATE bufr::bufr_d) + +# Install executable targets +install(TARGETS makeoneobbufr.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + From 1c342aa6f72b07c19de150b570f445922e605af6 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 12 Mar 2022 23:16:54 -0500 Subject: [PATCH 29/58] Revert "remove obsolete cmake/Modules directory" This reverts commit 91fb0ac41e28acc18f9e5419f48a9977ec5193b0. --- cmake/Modules/FindBACIO.cmake | 55 + cmake/Modules/FindBUFR.cmake | 60 + cmake/Modules/FindBaselibs.cmake | 68 + cmake/Modules/FindCORELIBS.cmake | 287 ++++ cmake/Modules/FindCRTM.cmake | 81 + cmake/Modules/FindGSICONTROL.cmake | 54 + cmake/Modules/FindHDF5.cmake | 24 + cmake/Modules/FindIP.cmake | 83 + cmake/Modules/FindMPI.cmake | 18 + cmake/Modules/FindNDATE.cmake | 13 + cmake/Modules/FindNEMSIO.cmake | 72 + cmake/Modules/FindSFCIO.cmake | 75 + cmake/Modules/FindSIGIO.cmake | 76 + cmake/Modules/FindSP.cmake | 83 + cmake/Modules/FindW3EMC.cmake | 124 ++ cmake/Modules/FindW3NCO.cmake | 81 + cmake/Modules/FindWRF.cmake | 36 + .../NewCMake/CMakeParseArguments.cmake | 11 + cmake/Modules/NewCMake/FindHDF5.cmake | 934 ++++++++++ cmake/Modules/NewCMake/FindMPI.cmake | 1514 +++++++++++++++++ .../NewCMake/FindMPI/fortranparam_mpi.f90.in | 4 + cmake/Modules/NewCMake/FindMPI/libver_mpi.c | 19 + .../NewCMake/FindMPI/libver_mpi.f90.in | 7 + cmake/Modules/NewCMake/FindMPI/mpiver.f90.in | 10 + cmake/Modules/NewCMake/FindMPI/test_mpi.c | 37 + .../Modules/NewCMake/FindMPI/test_mpi.f90.in | 6 + .../FindPackageHandleStandardArgs.cmake | 386 +++++ .../Modules/NewCMake/FindPackageMessage.cmake | 47 + .../SelectLibraryConfigurations.cmake | 70 + cmake/Modules/findHelpers.cmake | 173 ++ cmake/Modules/platforms/Acorn.cmake | 13 + cmake/Modules/platforms/Cheyenne.cmake | 24 + cmake/Modules/platforms/Discover.cmake | 55 + cmake/Modules/platforms/Gaea.cmake | 14 + cmake/Modules/platforms/Generic.cmake | 25 + cmake/Modules/platforms/Hera.cmake | 42 + cmake/Modules/platforms/Jet.cmake | 42 + cmake/Modules/platforms/Orion.cmake | 42 + cmake/Modules/platforms/S4.cmake | 10 + cmake/Modules/platforms/WCOSS-C.cmake | 60 + cmake/Modules/platforms/WCOSS-D.cmake | 48 + cmake/Modules/platforms/WCOSS.cmake | 61 + cmake/Modules/setGNUFlags.cmake | 66 + cmake/Modules/setHOST.cmake | 105 ++ cmake/Modules/setIntelFlags.cmake | 94 + cmake/Modules/setPGIFlags.cmake | 78 + cmake/Modules/setPlatformVariables.cmake | 12 + 47 files changed, 5299 insertions(+) create mode 100644 cmake/Modules/FindBACIO.cmake create mode 100644 cmake/Modules/FindBUFR.cmake create mode 100644 cmake/Modules/FindBaselibs.cmake create mode 100644 cmake/Modules/FindCORELIBS.cmake create mode 100644 cmake/Modules/FindCRTM.cmake create mode 100644 cmake/Modules/FindGSICONTROL.cmake create mode 100644 cmake/Modules/FindHDF5.cmake create mode 100644 cmake/Modules/FindIP.cmake create mode 100644 cmake/Modules/FindMPI.cmake create mode 100644 cmake/Modules/FindNDATE.cmake create mode 100644 cmake/Modules/FindNEMSIO.cmake create mode 100644 cmake/Modules/FindSFCIO.cmake create mode 100644 cmake/Modules/FindSIGIO.cmake create mode 100644 cmake/Modules/FindSP.cmake create mode 100644 cmake/Modules/FindW3EMC.cmake create mode 100644 cmake/Modules/FindW3NCO.cmake create mode 100644 cmake/Modules/FindWRF.cmake create mode 100644 cmake/Modules/NewCMake/CMakeParseArguments.cmake create mode 100644 cmake/Modules/NewCMake/FindHDF5.cmake create mode 100644 cmake/Modules/NewCMake/FindMPI.cmake create mode 100644 cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in create mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.c create mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in create mode 100644 cmake/Modules/NewCMake/FindMPI/mpiver.f90.in create mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.c create mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in create mode 100644 cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake create mode 100644 cmake/Modules/NewCMake/FindPackageMessage.cmake create mode 100644 cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake create mode 100644 cmake/Modules/findHelpers.cmake create mode 100644 cmake/Modules/platforms/Acorn.cmake create mode 100644 cmake/Modules/platforms/Cheyenne.cmake create mode 100644 cmake/Modules/platforms/Discover.cmake create mode 100644 cmake/Modules/platforms/Gaea.cmake create mode 100644 cmake/Modules/platforms/Generic.cmake create mode 100644 cmake/Modules/platforms/Hera.cmake create mode 100644 cmake/Modules/platforms/Jet.cmake create mode 100644 cmake/Modules/platforms/Orion.cmake create mode 100644 cmake/Modules/platforms/S4.cmake create mode 100644 cmake/Modules/platforms/WCOSS-C.cmake create mode 100644 cmake/Modules/platforms/WCOSS-D.cmake create mode 100644 cmake/Modules/platforms/WCOSS.cmake create mode 100644 cmake/Modules/setGNUFlags.cmake create mode 100644 cmake/Modules/setHOST.cmake create mode 100644 cmake/Modules/setIntelFlags.cmake create mode 100644 cmake/Modules/setPGIFlags.cmake create mode 100644 cmake/Modules/setPlatformVariables.cmake diff --git a/cmake/Modules/FindBACIO.cmake b/cmake/Modules/FindBACIO.cmake new file mode 100644 index 0000000000..04410f631e --- /dev/null +++ b/cmake/Modules/FindBACIO.cmake @@ -0,0 +1,55 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{BACIO_VER}) + set(BACIO_VER $ENV{BACIO_VER}) + STRING(REGEX REPLACE "v" "" BACIO_VER ${BACIO_VER}) +endif() +if(NOT BUILD_BACIO ) + if(DEFINED ENV{BACIO_LIB4}) + set(BACIO_LIBRARY $ENV{BACIO_LIB4} ) + else() + find_library( BACIO_LIBRARY + NAMES libbacio.a libbacio_4.a libbacio_v${BACIO_VER}_4.a + HINTS $ENV{COREPATH}/lib /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/bacio/v${BACIO_VER} + ${COREPATH}/bacio/v${BACIO_VER}/intel + ${COREPATH}/bacio/v${BACIO_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH} + ) + message("Found BACIO library ${BACIO_LIBRARY}") + endif() +endif() +if( NOT BACIO_LIBRARY ) # didn't find the library, so build it from source + message("Could not find BACIO library, so building from libsrc") + if( DEFINED ENV{BACIO_SRC} ) + set( BACIO_DIR $ENV{BACIO_SRC} CACHE STRING "BACIO Source Directory" ) + else() + findSrc( "bacio" BACIO_VER BACIO_DIR ) + set(BACIOINC "${CMAKE_BINARY_DIR}/include") + endif() + set( libsuffix "_v${BACIO_VER}${debug_suffix}" ) + set( bacio "bacio${libsuffix}") + set( BUILD_BACIO "ON" CACHE INTERNAL "Build Bacio library" ) + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/bacio) + set( BACIO_LIBRARY ${bacio} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${BACIO_LIBRARY} ) + else() + set( CORE_BUILT ${BACIO_LIBRARY} ) + endif() +else( NOT BACIO_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${BACIO_LIBRARY} ) + else() + set( CORE_LIBRARIES ${BACIO_LIBRARY} ) + endif() +endif( NOT BACIO_LIBRARY ) + +set( BACIO_LIBRARY_PATH ${BACIO_LIBRARY} CACHE STRING "BACIO Library Location" ) + diff --git a/cmake/Modules/FindBUFR.cmake b/cmake/Modules/FindBUFR.cmake new file mode 100644 index 0000000000..a2d70b92bd --- /dev/null +++ b/cmake/Modules/FindBUFR.cmake @@ -0,0 +1,60 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{BUFR_VER}) + set(BUFR_VER $ENV{BUFR_VER}) + STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_BUFR ) + if(DEFINED ENV{BUFR_LIBd_DA} ) + set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) + message("BUFR library ${BUFR_LIBRARY} set via Environment variable") + else() + find_library( BUFR_LIBRARY + NAMES libbufr.a libbufr_d_64.a libbufr_i4r8.a libbufr_v${BUFR_VER}_d_64.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/bufr/v${BUFR_VER} + ${COREPATH}/bufr/v${BUFR_VER}/intel + ${COREPATH}/bufr/v${BUFR_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( bufr "bufr_v${BUFR_VER}") + message("Found BUFR library ${BUFR_LIBRARY}") + endif() +endif() +if( NOT BUFR_LIBRARY ) # didn't find the library, so build it from source + message("Could not find BUFR library, so building from libsrc") + if( NOT DEFINED ENV{BUFR_SRC} ) + findSrc( "bufr" BUFR_VER BUFR_DIR ) + else() + set( BUFR_DIR "$ENV{BUFR_SRC}/libsrc" CACHE STRING "BUFR Source Location") + endif() + set( libsuffix "_v${BUFR_VER}${debug_suffix}" ) + set( BUFR_LIBRARY "${LIBRARY_OUTPUT_PATH}/libbufr${libsuffix}.a" CACHE STRING "BUFR Library" ) + set( bufr "bufr${libsuffix}") + set( BUILD_BUFR "ON" CACHE INTERNAL "Build the BUFR library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/bufr) + set( BUFR_LIBRARY ${bufr} ) + + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${BUFR_LIBRARY} ) + else() + set( CORE_BUILT ${BUFR_LIBRARY} ) + endif() +else( NOT BUFR_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${BUFR_LIBRARY} ) + else() + set( CORE_LIBRARIES ${BUFR_LIBRARY} ) + endif() +endif() +set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) + diff --git a/cmake/Modules/FindBaselibs.cmake b/cmake/Modules/FindBaselibs.cmake new file mode 100644 index 0000000000..793cb9a5d4 --- /dev/null +++ b/cmake/Modules/FindBaselibs.cmake @@ -0,0 +1,68 @@ +if (NOT BASEDIR) + if(${COMPILER_TYPE} STREQUAL "intel" ) + string(REGEX MATCH "mpt" MPT ${MPI_Fortran_INCLUDE_PATH}) + string(REGEX MATCH "impi" IMPI ${MPI_Fortran_INCLUDE_PATH}) + message("REGEX returns ${MPT} ") + if( MPT MATCHES "mpt" ) + message("setting mpt paths ") + set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_15.0.2.164-mpt_2.14/Linux") + elseif( IMPI MATCHES "impi" ) + set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_16.0.3.210-intelmpi_5.1.3.210/Linux") + else() + message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") + endif() + message("compiler version is ${COMPILER_VERSION}") + endif() + if(${COMPILER_TYPE} STREQUAL "gnu" ) + string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) + message("REGEX returns ${OPENMPI} ") + if( OPENMPI MATCHES "openmpi" ) + message("setting openmpi paths ") + set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-4_0_8/x86_64-unknown-linux-gnu/gfortran_7.2.0-openmpi_3.0.0/Linux") + else() + message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") + endif() + message("compiler version is ${COMPILER_VERSION}") + endif() + if(${COMPILER_TYPE} STREQUAL "pgi" ) + string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) + if( OPENMPI MATCHES "openmpi" ) + set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_1/x86_64-unknown-linux-gnu/pgfortran_16.5-openmpi_1.10.3/Linux") + else() + message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") + endif() + message("compiler version is ${COMPILER_VERSION}") + endif() +endif () +if (ESMA_SDF) + message (FATAL_ERROR "ERROR: -hdf option was thought to be obsolete when CMake was crafted.") +endif () + +link_directories (${BASEDIR}/lib) + +#------------------------------------------------------------------ +# netcdf +# The following command provides the list of libraries that netcdf +# uses. Unfortunately it also includes the library path and "-l" +# prefixes, which CMake handles in a different manner. So we need so +# strip off that item from the list +execute_process ( + COMMAND ${BASEDIR}/bin/nf-config --flibs + OUTPUT_VARIABLE LIB_NETCDF + ) + +string(REGEX MATCHALL " -l[^ ]*" _full_libs "${LIB_NETCDF}") +set (NETCDF_LIBRARIES) +foreach (lib ${_full_libs}) + string (REPLACE "-l" "" _tmp ${lib}) + string (STRIP ${_tmp} _tmp) + list (APPEND NETCDF_LIBRARIES ${_tmp}) +endforeach() +#------------------------------------------------------------------ + +list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/netcdf) +list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/hdf5) + +message(STATUS "NETCDF_INCLUDES: ${NETCDF_INCLUDES}") +message(STATUS "NETCDF_LIBRARIES: ${NETCDF_LIBRARIES}") + diff --git a/cmake/Modules/FindCORELIBS.cmake b/cmake/Modules/FindCORELIBS.cmake new file mode 100644 index 0000000000..9aab567113 --- /dev/null +++ b/cmake/Modules/FindCORELIBS.cmake @@ -0,0 +1,287 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{BUFR_VER}) + set(BUFR_VER $ENV{BUFR_VER}) + STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) +endif() +if(DEFINED ENV{NEMSIO_VER}) + set(NEMSIO_VER $ENV{NEMSIO_VER}) + STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) +endif() +if(DEFINED ENV{SFCIO_VER}) + set(SFCIO_VER $ENV{SFCIO_VER}) + STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) +endif() +if(DEFINED ENV{SIGIO_VER}) + set(SIGIO_VER $ENV{SIGIO_VER}) + STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) +endif() +if(DEFINED ENV{SP_VER}) + set(SP_VER $ENV{SP_VER}) + STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) +endif() +if(DEFINED ENV{W3EMC_VER}) + set(W3EMC_VER $ENV{W3EMC_VER}) + STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) +endif() +if(DEFINED ENV{W3NCO_VER}) + set(W3NCO_VER $ENV{W3NCO_VER}) + STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) +endif() + +set (CORE_DEPS " ") +set( NO_DEFAULT_PATH ) +if(NOT BUILD_EMC ) + if(DEFINED ENV{W3EMC_LIBd} ) + set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) + set(W3EMCINC $ENV{W3EMC_INCd} ) + else() + find_path( W3EMCINC + NAMES mersenne_twister.mod + HINTS + $ENV{COREPATH}/lib/incmod/w3emc_4 + $ENV{COREPATH}/include + /usr/local/jcsda/nwprod_gdas_2014/lib/lib/incmod/w3emc_4 + ${COREPATH}/w3emc/v${W3EMC_VER}/incmod/w3emc_v${W3EMC_VER}_d + ${COREPATH}/w3emc/v${W3EMC_VER}/intel/w3emc_v${W3EMC_VER}_d + ) + find_library( W3EMC_LIBRARY + NAMES libw3emc_4.a libw3emc_i4r8.a libw3emc_v${W3EMC_VER}_d.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/w3emc/v${W3EMC_VER} + ${COREPATH}/w3emc/v${W3EMC_VER}/intel + PATH_SUFFIXES + lib + ) + message("Found W3EMC library ${W3EMC_LIBRARY}") + endif() +else() + set( libsuffix "_v${W3EMC_VER}${debug_suffix}" ) + set( W3EMC_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3emc${libsuffix}.a" CACHE STRING "W3EMC Library" ) + set( w3emc "w3emc${libsuffix}") + if( DEFINED ENV{W3EMC_SRC} ) + set( W3EMC_DIR $ENV{W3EMC_SRC} CACHE STRING "W3EMC Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "w3emc" W3EMC_VER W3EMC_DIR ) + endif() + endif() +endif() +if(NOT BUILD_NCO ) + if(DEFINED ENV{W3NCO_LIBd} ) + set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) + else() + find_library( W3NCO_LIBRARY + NAMES libw3nco_v${W3NCO_VER}_d.a libw3nco_d.a libw3nco_i4r8.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/w3nco/v${W3NCO_VER} + ${COREPATH}/w3nco/v${W3NCO_VER}/intel + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + message("Found W3NCO library ${W3NCO_LIBRARY}") + endif() +else() + if( DEFINED ENV{W3NCO_SRC} ) + set( W3NCO_DIR $ENV{W3NCO_SRC} CACHE STRING "W3NCO Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "w3nco" W3NCO_VER W3NCO_DIR ) + endif() + endif() + set( libsuffix "_v${W3NCO_VER}${debug_suffix}" ) + set( W3NCO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3nco${libsuffix}.a" CACHE STRING "W3NCO Library" ) + set( w3nco "w3nco${libsuffix}") +endif() +if(NOT BUILD_BUFR ) + if(DEFINED ENV{BUFR_LIBd_DA} ) + set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) + else() + find_library( BUFR_LIBRARY + NAMES libbufr.a libbufr_d_64.a libbufr_i4r8.a libbufr_v${BUFR_VER}_d_64.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/bufr/v${BUFR_VER} + ${COREPATH}/bufr/v${BUFR_VER}/intel + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( bufr "bufr_v${BUFR_VER}") + message("Found BUFR library ${BUFR_LIBRARY}") + endif() +else() + if( DEFINED ENV{BUFR_SRC} ) + set( BUFR_DIR $ENV{BUFR_SRC} CACHE STRING "BUFR Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "bufr" BUFR_VER BUFR_DIR ) + endif() + endif() + set( libsuffix "_v${BUFR_VER}${debug_suffix}" ) + set( BUFR_LIBRARY "${LIBRARY_OUTPUT_PATH}/libbufr${libsuffix}.a" CACHE STRING "BUFR Library" ) + set( bufr "bufr${libsuffix}") +endif() +if(NOT BUILD_SFCIO ) + if(DEFINED ENV{SFCIO_LIB4} ) + set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) + set(SFCIOINC $ENV{SFCIO_INC4} ) + else() + findInc( sfcio SFCIO_VER SFCIOINC ) + find_library( SFCIO_LIBRARY + NAMES libsfcio.a libsfcio_4.a libsfcio_i4r4.a libsfcio_v${SFCIO_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sfcio/v${SFCIO_VER} + ${COREPATH}/sfcio/v${SFCIO_VER}/intel + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sfcio "sfcio_v${SFCIO_VER}_4") + message("Found SFCIO library ${SFCIO_LIBRARY}") + endif() +else() + if( DEFINED ENV{SFCIO_SRC} ) + set( SFCIO_DIR $ENV{SFCIO_SRC} CACHE STRING "SFCIO Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "sfcio" SFCIO_VER SFCIO_DIR ) + endif() + endif() + set( libsuffix "_v${SFCIO_VER}${debug_suffix}" ) + set( SFCIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsfcio${libsuffix}.a" CACHE STRING "SFCIO Library" ) + set( sfcio "sfcio${libsuffix}") +endif() +if(NOT BUILD_SIGIO ) + if(DEFINED ENV{SIGIO_LIB4} ) + set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) + set(SIGIOINC $ENV{SIGIO_INC4} ) + else() + findInc( sigio SIGIO_VER SIGIOINC ) + message("SIGIOINC is ${SIGIOINC}") + find_library( SIGIO_LIBRARY + NAMES libsigio.a libsigio_4.a libsigio_i4r4.a libsigio_v${SIGIO_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sigio/v${SIGIO_VER} + ${COREPATH}/sigio/v${SIGIO_VER}/intel + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sigio "sigio_v${SIGIO_VER}_4") + message("Found SIGIO library ${SIGIO_LIBRARY}") + endif() +else() + if( DEFINED ENV{SIGIO_SRC} ) + set( SIGIO_DIR $ENV{SIGIO_SRC} CACHE STRING "SIGIO Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "sigio" SIGIO_VER SIGIO_DIR ) + endif() + endif() + set( libsuffix "_v${SIGIO_VER}${debug_suffix}" ) + set( SIGIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsigio${libsuffix}.a" CACHE STRING "SIGIO Library" ) + set( sigio "sigio${libsuffix}") + set( CORE_DEPS "${CORE_DEPS} ${baseName}" ) +endif() +if(NOT BUILD_NEMSIO ) + if(DEFINED ENV{NEMSIO_LIB} ) + set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) + set(NEMSIOINC $ENV{NEMSIO_INC} ) + else() + findInc( nemsio NEMSIO_VER NEMSIOINC ) + find_library( NEMSIO_LIBRARY + NAMES libnemsio.a libnemsio_v${NEMSIO_VER}.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/nemsio/v${NEMSIO_VER} + ${COREPATH}/nemsio/v${NEMSIO_VER}/intel + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( nemsio "nemsio_v${NEMSIO_VER}") + message("Found NEMSIO library ${NEMSIO_LIBRARY}") + endif() +else() + if( DEFINED ENV{NEMSIO_SRC} ) + set( NEMSIO_DIR $ENV{NEMSIO_SRC} CACHE STRING "NEMSIO Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "nemsio" NEMSIO_VER NEMSIO_DIR ) + endif() + endif() + set( libsuffix "_v${NEMSIO_VER}${debug_suffix}" ) + set( NEMSIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libnemsio${libsuffix}.a" CACHE STRING "NEMSIO Library" ) + set( nemsio "nemsio${libsuffix}") +endif() +if(NOT BUILD_SP ) + if(DEFINED ENV{SP_LIBd} ) + set(SP_LIBRARY $ENV{SP_LIBd} ) + else() + find_library( SP_LIBRARY + NAMES libsp_d.a libsp_i4r8.a libsp_v${SP_VER}_d.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sp/v${SP_VER} + ${COREPATH}/sp/v${SP_VER}/intel + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sp "sp_v${SP_VER}_d") + message("Found SP library ${SP_LIBRARY}") + endif() +else() + if( DEFINED ENV{SP_SRC} ) + set( SP_DIR $ENV{SP_SRC} CACHE STRING "SP Source Directory" ) + else() + if( FIND_SRC ) + findSrc( "sp" SP_VER SP_DIR ) + endif() + endif() + set( libsuffix "_v${SP_VER}${debug_suffix}" ) + set( SP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp${libsuffix}.a" CACHE STRING "SP Library" ) + set( sp "sp${libsuffix}") +endif() + +if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} + ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} + ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) + list( APPEND CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) +else() + set( CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} + ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} + ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) + set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) +endif() + +set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) + +set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) +set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) + +set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) +set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) + +set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) + +set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) +set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) + +set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) +set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) + +set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) + diff --git a/cmake/Modules/FindCRTM.cmake b/cmake/Modules/FindCRTM.cmake new file mode 100644 index 0000000000..ee982c1499 --- /dev/null +++ b/cmake/Modules/FindCRTM.cmake @@ -0,0 +1,81 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{CRTM_VER}) + set(CRTM_VER $ENV{CRTM_VER}) + STRING(REGEX REPLACE "v" "" CRTM_VER ${CRTM_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_CRTM ) + if(DEFINED ENV{CRTM_LIB} ) + set(CRTM_LIBRARY $ENV{CRTM_LIB} ) + set(CRTMINC $ENV{CRTM_INC} ) + message("CRTM library ${CRTM_LIBRARY} set via Environment variable") + else() + findInc( crtm CRTM_VER CRTMINC ) + find_library( CRTM_LIBRARY + NAMES libcrtm_v${CRTM_VER}.a libcrtm.a libCRTM.a + HINTS + /usr/local/jcsda/nwprod_gdas_2014/lib + ${CRTM_BASE} + ${CRTM_BASE}/lib + ${CRTM_BASE}/${CRTM_VER} + ${CRTM_BASE}/${CRTM_VER}/lib + ${CRTM_BASE}/v${CRTM_VER}/intel + ${CRTM_BASE}/v${CRTM_VER}/ips/${COMPILER_VERSION} + ${COREPATH}/v${CRTM_VER}/ips/${COMPILER_VERSION} + ${COREPATH} + ${COREPATH}/lib + $ENV{COREPATH} + $ENV{COREPATH}/lib + $ENV{COREPATH}/include + ${CORECRTM}/crtm/${CRTM_VER} + /nwprod2/lib/crtm/v${CRTM_VER} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( crtm "crtm_v${CRTM_VER}") + message("Found CRTM library ${CRTM_LIBRARY}") + endif() +endif() +if( NOT CRTM_LIBRARY ) # didn't find the library, so build it from source + message("Could not find CRTM library, so building from libsrc") + if( NOT DEFINED ENV{CRTM_SRC} ) + findSrc( "crtm" CRTM_VER CRTM_DIR ) + set(CRTMINC "${CMAKE_BINARY_DIR}/include") + else() + set( CRTM_DIR "$ENV{CRTM_SRC}/libsrc" CACHE STRING "CRTM Source Location") + set(CRTMINC "${CORECRTM}/crtm/${CRTM_VER}/incmod/crtm_v${CRTM_VER}") + endif() + set( libsuffix "_v${CRTM_VER}${debug_suffix}" ) + set( CRTM_LIBRARY "${LIBRARY_OUTPUT_PATH}/libcrtm${libsuffix}.a" CACHE STRING "CRTM Library" ) + set( crtm "crtm${libsuffix}") + set( BUILD_CRTM "ON" CACHE INTERNAL "Build the CRTM library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/crtm) + set( CRTM_LIBRARY ${crtm} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${CRTM_LIBRARY} ) + else() + set( CORE_BUILT ${CRTM_LIBRARY} ) + endif() +else( NOT CRTM_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${CRTM_LIBRARY} ) + else() + set( CORE_LIBRARIES ${CRTM_LIBRARY} ) + endif() +endif( NOT CRTM_LIBRARY ) + +if( CORE_INCS ) + list( APPEND CORE_INCS ${CRTMINC} ) +else() + set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${CRTMINC} ) +endif() + +set( CRTM_LIBRARY_PATH ${CRTM_LIBRARY} CACHE STRING "CRTM Library Location" ) +set( CRTM_INCLUDE_PATH ${CRTMINC} CACHE STRING "CRTM Include Location" ) + diff --git a/cmake/Modules/FindGSICONTROL.cmake b/cmake/Modules/FindGSICONTROL.cmake new file mode 100644 index 0000000000..3e4bd7d7dc --- /dev/null +++ b/cmake/Modules/FindGSICONTROL.cmake @@ -0,0 +1,54 @@ +# - Find the Control version of GSI to use for regression testing + +set( NO_DEFAULT_PATH ) +message("Control path is ${CONTROLPATH}") +find_file( CONTROL_EXE + NAMES gsi.x global_gsi ${GSIEXEC} + HINTS + ${CONTROLPATH} + ${CONTROLPATH}/bin + ${CONTROLPATH}/exec + $ENV{CONTROLPATH} + $ENV{CONTROLPATH}/bin + $ENV{CONTROLPATH}/exec + $ENV{CONTROLPATH}/src + ${CMAKE_SOURCE_DIR}/../trunk/src + ${CMAKE_SOURCE_DIR}/../../trunk/src + ${PROJECT_BINARY_DIR}/../build-trunk/bin + /da/save/Michael.Lueken/svn1/build/bin + /da/save/Michael.Lueken/svn1/src + /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin + /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin + /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src + /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin + /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec + + ${NO_DEFAULT_PATH}) + +set( GSICONTROL ${CONTROL_EXE} CACHE STRING "GSI control executable for regression testing" FORCE ) + +find_file( ENKF_CONTROL_EXE + NAMES enkf_gfs.x global_enkf ${ENKFEXEC} + HINTS + ${CONTROLPATH} + ${CONTROLPATH}/bin + ${CONTROLPATH}/exec + $ENV{CONTROLPATH} + $ENV{CONTROLPATH}/bin + $ENV{CONTROLPATH}/exec + ${CMAKE_SOURCE_DIR}/../trunk/src/enkf + ${PROJECT_BINARY_DIR}/../build-trunk/bin + $ENV{CONTROLPATH}/enkf + $ENV{CONTROLPATH}/src/enkf + /da/save/Michael.Lueken/svn1/build/bin + /da/save/Michael.Lueken/svn1/src/enkf + /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin + /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin + /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src/enkf + /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin + /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec + + ${NO_DEFAULT_PATH}) + +set( ENKFCONTROL ${ENKF_CONTROL_EXE} CACHE STRING "ENKF control executable for regression testing" FORCE ) + diff --git a/cmake/Modules/FindHDF5.cmake b/cmake/Modules/FindHDF5.cmake new file mode 100644 index 0000000000..78e3db3678 --- /dev/null +++ b/cmake/Modules/FindHDF5.cmake @@ -0,0 +1,24 @@ +# This extends CMake's FindHDF5.cmake to add support to include MPI include +# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON +# (BUG #0014363). + +# include the default FindHDF5.cmake. +#if(CMAKE_VERSION VERSION_LESS 3.6.1) +if(CMAKE_VERSION VERSION_GREATER 3.0 ) + include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindHDF5.cmake) +else() + include(${CMAKE_ROOT}/Modules/FindHDF5.cmake) +endif() +#endif() + +if(HDF5_FOUND AND (HDF5_IS_PARALLEL OR HDF5_ENABLE_PARALLEL)) + if(MPI_C_INCLUDE_PATH) + list(APPEND HDF5_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH}) + endif() + if(MPI_C_LIBRARIES) + list(APPEND HDF5_LIBRARIES ${MPI_C_LIBRARIES}) + endif() + if(MPI_CXX_LIBRARIES) + list(APPEND HDF5_LIBRARIES ${MPI_CXX_LIBRARIES}) + endif() +endif() diff --git a/cmake/Modules/FindIP.cmake b/cmake/Modules/FindIP.cmake new file mode 100644 index 0000000000..26ec21704e --- /dev/null +++ b/cmake/Modules/FindIP.cmake @@ -0,0 +1,83 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{IP_VER}) + set(IP_VER $ENV{IP_VER}) + STRING(REGEX REPLACE "v" "" IP_VER ${IP_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_IP ) + if(DEFINED ENV{IP_LIBd} ) + set(IP_LIBRARY $ENV{IP_LIBd} ) + message("IP library ${IP_LIBRARY} set via Environment variable") + else() + find_library( IP_LIBRARY + NAMES libip_d.a libip_i4r8.a libip_v${IP_VER}_d.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/ip/v${IP_VER} + ${COREPATH}/ip/v${IP_VER}/intel + ${COREPATH}/ip/v${IP_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( ip "ip_v${IP_VER}_d") + message("Found IP library ${IP_LIBRARY}") + endif() + if(DEFINED ENV{IP_LIB4} ) + set(IP_4_LIBRARY $ENV{IP_LIB4} ) + message("IP 4 library ${IP_4_LIBRARY} set via Environment variable") + else() + find_library( IP_4_LIBRARY + NAMES libip_4.a libip_i4r4.a libip_v${IP_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/ip/v${IP_VER} + ${COREPATH}/ip/v${IP_VER}/intel + ${COREPATH}/ip/v${IP_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( ip "ip_v${IP_VER}_4") + message("Found IP_4 library ${IP_4_LIBRARY}") + endif() +endif() +if( NOT IP_LIBRARY ) # didn't find the library, so build it from source + message("Could not find IP library, so building from libsrc") + if( NOT DEFINED ENV{IP_SRC} ) + findSrc( "ip" IP_VER IP_DIR ) + else() + set( IP_DIR "$ENV{IP_SRC}/libsrc" CACHE STRING "IP Source Location") + endif() + set( libsuffix "_v${IP_VER}${debug_suffix}" ) + set( IP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libip${libsuffix}.a" CACHE STRING "IP Library" ) + set( IP_4_LIBRARY "${LIBRARY_OUTPUT_PATH}/libip_4${libsuffix}.a" CACHE STRING "IP_4 Library" ) + set( ip "ip${libsuffix}") + set( ip4 "ip_4${libsuffix}") + set( BUILD_IP "ON" CACHE INTERNAL "Build the IP library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/ip) + set( IP_LIBRARY ${ip} ) + set( IP_4_LIBRARY ${ip4} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${IP_LIBRARY} ) + else() + set( CORE_BUILT ${IP_LIBRARY} ) + endif() +else( NOT IP_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${IP_LIBRARY} ) + else() + set( CORE_LIBRARIES ${IP_LIBRARY} ) + endif() +endif( NOT IP_LIBRARY ) + + +set( IP_LIBRARY_PATH ${IP_LIBRARY} CACHE STRING "IP Library Location" ) +set( IP_4_LIBRARY_PATH ${IP_4_LIBRARY} CACHE STRING "IP_4 Library Location" ) + diff --git a/cmake/Modules/FindMPI.cmake b/cmake/Modules/FindMPI.cmake new file mode 100644 index 0000000000..8e0a0c95ba --- /dev/null +++ b/cmake/Modules/FindMPI.cmake @@ -0,0 +1,18 @@ +# This extends CMake's FindHDF5.cmake to add support to include MPI include +# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON +# (BUG #0014363). + +# include the default FindMPI.cmake. +if(CMAKE_VERSION VERSION_LESS 3.1) + include(${CMAKE_ROOT}/Modules/FindMPI.cmake) +elseif(CMAKE_VERSION VERSION_LESS 3.6) + message("Using new FindMPI") + include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindMPI.cmake) +# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") +else() + message("Using installed FindMPI") + include(${CMAKE_ROOT}/Modules/FindMPI.cmake) +# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") + message("include dirs are ${MPI_Fortran_INCLUDE_DIRS}") + message("include PATH ${MPI_Fortran_INCLUDE_PATH}") +endif() diff --git a/cmake/Modules/FindNDATE.cmake b/cmake/Modules/FindNDATE.cmake new file mode 100644 index 0000000000..44bf4f1cd5 --- /dev/null +++ b/cmake/Modules/FindNDATE.cmake @@ -0,0 +1,13 @@ +# - Find the NDATE utility or build it + +set( NO_DEFAULT_PATH ) +if(DEFINED ENV{NDATE}) + set(NDATE $ENV{NDATE} ) +else() + find_file( NDATE + NAMES ndate.x ndate + HINTS + /nwprod/util/exec + $ENV{NWPROD}/util/exec + ${NO_DEFAULT_PATH}) +endif() diff --git a/cmake/Modules/FindNEMSIO.cmake b/cmake/Modules/FindNEMSIO.cmake new file mode 100644 index 0000000000..1263fc516a --- /dev/null +++ b/cmake/Modules/FindNEMSIO.cmake @@ -0,0 +1,72 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{NEMSIO_VER}) + set(NEMSIO_VER $ENV{NEMSIO_VER}) + STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_NEMSIO ) + if(DEFINED ENV{NEMSIO_LIB} ) + set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) + set(NEMSIOINC $ENV{NEMSIO_INC} ) + message("NEMSIO library ${NEMSIO_LIBRARY} set via Environment variable") + else() + findInc( nemsio NEMSIO_VER NEMSIOINC ) + find_library( NEMSIO_LIBRARY + NAMES libnemsio_v${NEMSIO_VER}.a libnemsio.a libNEMSIO.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/nemsio/v${NEMSIO_VER} + ${COREPATH}/nemsio/v${NEMSIO_VER}/intel + ${COREPATH}/nemsio/v${NEMSIO_VER}//ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION} + ${COREPATH}/nemsio/v${NEMSIO_VER}//ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( nemsio "nemsio_v${NEMSIO_VER}") + message("Found NEMSIO library ${NEMSIO_LIBRARY}") + endif() +endif() +if( NOT NEMSIO_LIBRARY ) # didn't find the library, so build it from source + message("Could not find NEMSIO library, so building from libsrc") + if( NOT DEFINED ENV{NEMSIO_SRC} ) + findSrc( "nemsio" NEMSIO_VER NEMSIO_DIR ) + set(NEMSIOINC "${CMAKE_BINARY_DIR}/include") + else() + set( NEMSIO_DIR "$ENV{NEMSIO_SRC}/libsrc" CACHE STRING "NEMSIO Source Location") + set(NEMSIOINC "${CORENEMSIO}/nemsio/${NEMSIO_VER}/incmod/nemsio_v${NEMSIO_VER}") + endif() + set( libsuffix "_v${NEMSIO_VER}${debug_suffix}" ) + set( NEMSIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libnemsio${libsuffix}.a" CACHE STRING "NEMSIO Library" ) + set( nemsio "nemsio${libsuffix}") + set( BUILD_NEMSIO "ON" CACHE INTERNAL "Build the NEMSIO library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/nemsio) + set( NEMSIO_LIBRARY ${nemsio} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${NEMSIO_LIBRARY} ) + else() + set( CORE_BUILT ${NEMSIO_LIBRARY} ) + endif() +else( NOT NEMSIO_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${NEMSIO_LIBRARY} ) + else() + set( CORE_LIBRARIES ${NEMSIO_LIBRARY} ) + endif() +endif( NOT NEMSIO_LIBRARY ) + +if( CORE_INCS ) + list( APPEND CORE_INCS ${NEMSIOINC} ) +else() + set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${NEMSIOINC} ) +endif() + +set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) +set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) + diff --git a/cmake/Modules/FindSFCIO.cmake b/cmake/Modules/FindSFCIO.cmake new file mode 100644 index 0000000000..09d4366d66 --- /dev/null +++ b/cmake/Modules/FindSFCIO.cmake @@ -0,0 +1,75 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{SFCIO_VER}) + set(SFCIO_VER $ENV{SFCIO_VER}) + STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_SFCIO ) + if(DEFINED ENV{SFCIO_LIB4} ) + set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) + set(SFCIOINC $ENV{SFCIO_INC4} ) + message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") + elseif(DEFINED ENV{SFCIO_LIB} ) + set(SFCIO_LIBRARY $ENV{SFCIO_LIB} ) + set(SFCIOINC $ENV{SFCIO_INC} ) + message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") + else() + findInc( sfcio SFCIO_VER SFCIOINC ) + find_library( SFCIO_LIBRARY + NAMES libsfcio.a libsfcio_4.a libsfcio_i4r4.a libsfcio_v${SFCIO_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sfcio/v${SFCIO_VER} + ${COREPATH}/sfcio/v${SFCIO_VER}/intel + ${COREPATH}/sfcio/v${SFCIO_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sfcio "sfcio_v${SFCIO_VER}") + message("Found SFCIO library ${SFCIO_LIBRARY}") + endif() +endif() +if( NOT SFCIO_LIBRARY ) # didn't find the library, so build it from source + message("Could not find SFCIO library, so building from libsrc") + if( NOT DEFINED ENV{SFCIO_SRC} ) + findSrc( "sfcio" SFCIO_VER SFCIO_DIR ) + set(SFCIOINC "${CMAKE_BINARY_DIR}/include") + else() + set( SFCIO_DIR "$ENV{SFCIO_SRC}/libsrc" CACHE STRING "SFCIO Source Location") + set(SFCIOINC "${CORESFCIO}/sfcio/${SFCIO_VER}/incmod/sfcio_v${SFCIO_VER}") + endif() + set( libsuffix "_v${SFCIO_VER}${debug_suffix}" ) + set( SFCIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsfcio${libsuffix}.a" CACHE STRING "SFCIO Library" ) + set( sfcio "sfcio${libsuffix}") + set( BUILD_SFCIO "ON" CACHE INTERNAL "Build the SFCIO library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/sfcio) + set( SFCIO_LIBRARY ${sfcio} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${SFCIO_LIBRARY} ) + else() + set( CORE_BUILT ${SFCIO_LIBRARY} ) + endif() +else( NOT SFCIO_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ) + else() + set( CORE_LIBRARIES ${SFCIO_LIBRARY} ) + endif() +endif( NOT SFCIO_LIBRARY ) + +if( CORE_INCS ) + list( APPEND CORE_INCS ${SFCIOINC} ) +else() + set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ) +endif() + +set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) +set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) + diff --git a/cmake/Modules/FindSIGIO.cmake b/cmake/Modules/FindSIGIO.cmake new file mode 100644 index 0000000000..d504f53a81 --- /dev/null +++ b/cmake/Modules/FindSIGIO.cmake @@ -0,0 +1,76 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{SIGIO_VER}) + set(SIGIO_VER $ENV{SIGIO_VER}) + STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_SIGIO ) + if(DEFINED ENV{SIGIO_LIB4} ) + set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) + set(SIGIOINC $ENV{SIGIO_INC4} ) + message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") + elseif(DEFINED ENV{SIGIO_LIB} ) + set(SIGIO_LIBRARY $ENV{SIGIO_LIB} ) + set(SIGIOINC $ENV{SIGIO_INC} ) + message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") + else() + findInc( sigio SIGIO_VER SIGIOINC ) + find_library( SIGIO_LIBRARY + NAMES libsigio.a libsigio_4.a libsigio_i4r4.a libsigio_v${SIGIO_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sigio/v${SIGIO_VER} + ${COREPATH}/sigio/v${SIGIO_VER}/intel + ${COREPATH}/sigio/v${SIGIO_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sigio "sigio_v${SIGIO_VER}") + message("Found SIGIO library ${SIGIO_LIBRARY}") + endif() +endif() +if( NOT SIGIO_LIBRARY ) # didn't find the library, so build it from source + message("Could not find SIGIO library, so building from libsrc") + if( NOT DEFINED ENV{SIGIO_SRC} ) + findSrc( "sigio" SIGIO_VER SIGIO_DIR ) + set(SIGIOINC "${CMAKE_BINARY_DIR}/include") + else() + set( SIGIO_DIR "$ENV{SIGIO_SRC}/libsrc" CACHE STRING "SIGIO Source Location") + set(SIGIOINC "${CORESIGIO}/sigio/${SIGIO_VER}/incmod/sigio_v${SIGIO_VER}") + endif() + set( libsuffix "_v${SIGIO_VER}${debug_suffix}" ) + set( SIGIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsigio${libsuffix}.a" CACHE STRING "SIGIO Library" ) + set( sigio "sigio${libsuffix}") + set( BUILD_SIGIO "ON" CACHE INTERNAL "Build the SIGIO library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/sigio) + set( SIGIO_LIBRARY ${sigio} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${SIGIO_LIBRARY} ) + else() + set( CORE_BUILT ${SIGIO_LIBRARY} ) + endif() +else( NOT SIGIO_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${SIGIO_LIBRARY} ) + else() + set( CORE_LIBRARIES ${SIGIO_LIBRARY} ) + endif() +endif( NOT SIGIO_LIBRARY ) + +if( CORE_INCS ) + list( APPEND CORE_INCS ${SIGIOINC} ) +else() + set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SIGIOINC} ) +endif() + + +set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) +set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) + diff --git a/cmake/Modules/FindSP.cmake b/cmake/Modules/FindSP.cmake new file mode 100644 index 0000000000..b5fba97341 --- /dev/null +++ b/cmake/Modules/FindSP.cmake @@ -0,0 +1,83 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{SP_VER}) + set(SP_VER $ENV{SP_VER}) + STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_SP ) + if(DEFINED ENV{SP_LIBd} ) + set(SP_LIBRARY $ENV{SP_LIBd} ) + message("SP library ${SP_LIBRARY} set via Environment variable") + else() + find_library( SP_LIBRARY + NAMES libsp_d.a libsp_i4r8.a libsp_v${SP_VER}_d.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sp/v${SP_VER} + ${COREPATH}/sp/v${SP_VER}/intel + ${COREPATH}/sp/v${SP_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sp "sp_v${SP_VER}_d") + message("Found SP library ${SP_LIBRARY}") + endif() + if(DEFINED ENV{SP_LIB4} ) + set(SP_4_LIBRARY $ENV{SP_LIB4} ) + message("SP library ${SP_4_LIBRARY} set via Environment variable") + else() + find_library( SP_4_LIBRARY + NAMES libsp_4.a libsp_i4r4.a libsp_v${SP_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/sp/v${SP_VER} + ${COREPATH}/sp/v${SP_VER}/intel + ${COREPATH}/sp/v${SP_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + set( sp "sp_v${SP_VER}_4") + message("Found SP_4 library ${SP_4_LIBRARY}") + endif() +endif() +if( NOT SP_LIBRARY ) # didn't find the library, so build it from source + message("Could not find SP library, so building from libsrc") + if( NOT DEFINED ENV{SP_SRC} ) + findSrc( "sp" SP_VER SP_DIR ) + else() + set( SP_DIR "$ENV{SP_SRC}/libsrc" CACHE STRING "SP Source Location") + endif() + set( libsuffix "_v${SP_VER}${debug_suffix}" ) + set( SP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp${libsuffix}.a" CACHE STRING "SP Library" ) + set( SP_4_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp_4${libsuffix}.a" CACHE STRING "SP_4 Library" ) + set( sp "sp${libsuffix}") + set( sp4 "sp_4${libsuffix}") + set( BUILD_SP "ON" CACHE INTERNAL "Build the SP library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/sp) + set( SP_LIBRARY ${sp} ) + set( SP_4_LIBRARY ${sp4} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${SP_LIBRARY} ) + else() + set( CORE_BUILT ${SP_LIBRARY} ) + endif() +else( NOT SP_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${SP_LIBRARY} ) + else() + set( CORE_LIBRARIES ${SP_LIBRARY} ) + endif() +endif( NOT SP_LIBRARY ) + + +set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) +set( SP_4_LIBRARY_PATH ${SP_4_LIBRARY} CACHE STRING "SP_4 Library Location" ) + diff --git a/cmake/Modules/FindW3EMC.cmake b/cmake/Modules/FindW3EMC.cmake new file mode 100644 index 0000000000..3cbce42a6d --- /dev/null +++ b/cmake/Modules/FindW3EMC.cmake @@ -0,0 +1,124 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{W3EMC_VER}) + set(W3EMC_VER $ENV{W3EMC_VER}) + set(W3EMCINC $ENV{W3EMC_INCd} ) + set(W3EMC4INC $ENV{W3EMC_INC4} ) + STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) +endif() +if(DEFINED ENV{W3EMC_LIBd}) + set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) + set(W3EMCINC $ENV{W3EMC_INCd} ) + set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) + set(W3EMC4INC $ENV{W3EMC_INC4} ) + message("Setting W3EMC library via environment variable ${W3EMC_LIBRARY}") +endif() + +set( NO_DEFAULT_PATH ) +if((NOT BUILD_W3EMC ) AND ( NOT DEFINED W3EMC_LIBRARY )) + if(DEFINED ENV{W3EMC_LIB} ) + set(W3EMC_LIBRARY $ENV{W3EMC_LIB} ) + set(W3EMCINC $ENV{W3EMC_INC} ) + set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) + set(W3EMC4INC $ENV{W3EMC_INC4} ) + message("W3EMC library ${W3EMC_LIBRARY} set via Environment variable") + message("W3EMC_4 library ${W3EMC_4_LIBRARY} set via Environment variable") + else() + find_path( W3EMCINC + NAMES mersenne_twister.mod + HINTS + $ENV{COREPATH}/lib/incmod/w3emc_d + $ENV{COREPATH}/include + /usr/local/jcsda/nwprod_gdas_2014/lib/incmod/w3emc_d + ${COREPATH}/w3emc/v${W3EMC_VER}/incmod/w3emc_v${W3EMC_VER}_d + ${COREPATH}/w3emc/v${W3EMC_VER}/intel/w3emc_v${W3EMC_VER}_d + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_d + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_d + ) + find_path( W3EMC4INC + NAMES mersenne_twister.mod + HINTS + $ENV{COREPATH}/lib/incmod/w3emc_4 + $ENV{COREPATH}/include + /usr/local/jcsda/nwprod_gdas_2014/lib/incmod/w3emc_4 + ${COREPATH}/w3emc/v${W3EMC_VER}/incmod/w3emc_v${W3EMC_VER}_4 + ${COREPATH}/w3emc/v${W3EMC_VER}/intel/w3emc_v${W3EMC_VER}_4 + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_4 + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION}/include/w3emc_v${W3EMC_VER}_4 + ) + find_library( W3EMC_LIBRARY + NAMES libw3emc_d.a libw3emc_v${W3EMC_VER}_d.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014 + ${COREPATH}/w3emc/v${W3EMC_VER} + ${COREPATH}/w3emc/v${W3EMC_VER}/intel + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION} + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + find_library( W3EMC_4_LIBRARY + NAMES libw3emc_4.a libw3emc_i4r4.a libw3emc_v${W3EMC_VER}_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014 + ${COREPATH}/w3emc/v${W3EMC_VER} + ${COREPATH}/w3emc/v${W3EMC_VER}/intel + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/impi/${COMPILER_VERSION} + ${COREPATH}/w3emc/v${W3EMC_VER}/ips/${COMPILER_VERSION}/smpi/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + message("Found W3EMC_4 library ${W3EMC_4_LIBRARY}") + endif() +endif() +if( NOT W3EMC_LIBRARY ) # didn't find the library, so build it from source + message("Could not find W3EMC library, so building from libsrc") + if( NOT DEFINED ENV{W3EMC_SRC} ) + findSrc( "w3emc" W3EMC_VER W3EMC_DIR ) + set(W3EMCINC "${CMAKE_BINARY_DIR}/include" CACHE STRING "W3EMC Include Directory") + set(W3EMC4INC "${CMAKE_BINARY_DIR}/include" CACHE STRING "W3EMC4 Include Directory") + else() + set( W3EMC_DIR "$ENV{W3EMC_SRC}/libsrc" CACHE STRING "W3EMC Source Location") + endif() + set( libsuffix "_v${W3EMC_VER}${debug_suffix}" ) + set( W3EMC_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3emc${libsuffix}.a" CACHE STRING "W3EMC Library" ) + set( w3emc "w3emc${libsuffix}") + set( w3emc4 "w3emc_4${libsuffix}") + set( BUILD_W3EMC "ON" CACHE INTERNAL "Build the W3EMC library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/w3emc) + set( W3EMC_LIBRARY ${w3emc} ) + set( W3EMC_4_LIBRARY ${w3emc} ) + set(W3EMCINC "${CMAKE_BINARY_DIR}/include" CACHE STRING "W3EMC Include Directory") + set(W3EMC4INC ${CMAKE_INCLUDE_4_OUTPUT_DIRECTORY} CACHE STRING "W3EMC4 Include Directory") + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${W3EMC_LIBRARY} ) + list( APPEND CORE_BUILT ${W3EMC_4_LIBRARY} ) + else() + set( CORE_BUILT ${W3EMC_LIBRARY} ) + set( CORE_BUILT ${W3EMC_4_LIBRARY} ) + endif() +else( NOT W3EMC_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${W3EMC_LIBRARY} ) + else() + set( CORE_LIBRARIES ${W3EMC_LIBRARY} ) + endif() +endif( NOT W3EMC_LIBRARY ) + +if( CORE_INCS ) + list( APPEND CORE_INCS ${W3EMCINC} ) +else() + set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${W3EMCINC} ) +endif() + +set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) +set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) +set( W3EMC_4_LIBRARY_PATH ${W3EMC_4_LIBRARY} CACHE STRING "W3EMC_4 Library Location" ) +set( W3EMC_INCLUDE_4_PATH ${W3EMC4INC} CACHE STRING "W3EMC_4 Include Location" ) + diff --git a/cmake/Modules/FindW3NCO.cmake b/cmake/Modules/FindW3NCO.cmake new file mode 100644 index 0000000000..aef2126c8f --- /dev/null +++ b/cmake/Modules/FindW3NCO.cmake @@ -0,0 +1,81 @@ +# This module defines +# CORE_INCS +# List of include file paths for all required modules for GSI +# CORE_LIBRARIES +# Full list of libraries required to link GSI executable +include(findHelpers) +if(DEFINED ENV{W3NCO_VER}) + set(W3NCO_VER $ENV{W3NCO_VER}) + STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) +endif() + +set( NO_DEFAULT_PATH ) +if(NOT BUILD_W3NCO ) + if(DEFINED ENV{W3NCO_LIBd} ) + set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) + set(W3NCO_4_LIBRARY $ENV{W3NCO_LIB4} ) + message("W3NCO library ${W3NCO_LIBRARY} set via Environment variable") + message("W3NCO_4 library ${W3NCO_4_LIBRARY} set via Environment variable") + else() + find_library( W3NCO_LIBRARY + NAMES libw3nco_v${W3NCO_VER}_d.a libw3nco_d.a libw3nco_i4r8.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/w3nco/v${W3NCO_VER} + ${COREPATH}/w3nco/v${W3NCO_VER}/intel + ${COREPATH}/w3nco/v${W3NCO_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + message("Found W3NCO library ${W3NCO_LIBRARY}") + set( w3nco ${W3NCO_LIBRARY}) + + find_library( W3NCO_4_LIBRARY + NAMES libw3nco_v${W3NCO_VER}_4.a libw3nco_4.a + HINTS + $ENV{COREPATH}/lib + /usr/local/jcsda/nwprod_gdas_2014/lib + ${COREPATH}/w3nco/v${W3NCO_VER} + ${COREPATH}/w3nco/v${W3NCO_VER}/intel + ${COREPATH}/w3nco/v${W3NCO_VER}/ips/${COMPILER_VERSION} + PATH_SUFFIXES + lib + ${NO_DEFAULT_PATH}) + message("Found W3NCO_4 library ${W3NCO_4_LIBRARY}") + set( w3nco4 ${W3NCO_4_LIBRARY}) + endif() +endif() +if( NOT W3NCO_LIBRARY ) # didn't find the library, so build it from source + message("Could not find W3NCO library, so building from libsrc") + if( NOT DEFINED ENV{W3NCO_SRC} ) + findSrc( "w3nco" W3NCO_VER W3NCO_DIR ) + else() + set( W3NCO_DIR "$ENV{W3NCO_SRC}/libsrc" CACHE STRING "W3NCO Source Location") + endif() + set( libsuffix "_v${W3NCO_VER}${debug_suffix}" ) + set( W3NCO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3nco${libsuffix}.a" CACHE STRING "W3NCO Library" ) + set( w3nco "w3nco${libsuffix}") + set( w3nco4 "w3nco_4${libsuffix}") + set( BUILD_W3NCO "ON" CACHE INTERNAL "Build the W3NCO library") + add_subdirectory(${CMAKE_SOURCE_DIR}/libsrc/w3nco) + set( W3NCO_LIBRARY ${w3nco} ) + set( W3NCO_4_LIBRARY ${w3nco4} ) + if( CORE_BUILT ) + list( APPEND CORE_BUILT ${W3NCO_LIBRARY} ) + list( APPEND CORE_BUILT ${W3NCO_4_LIBRARY} ) + else() + set( CORE_BUILT ${W3NCO_LIBRARY} ) + set( CORE_BUILT ${W3NCO_4_LIBRARY} ) + endif() +else( NOT W3NCO_LIBRARY ) + if( CORE_LIBRARIES ) + list( APPEND CORE_LIBRARIES ${W3NCO_LIBRARY} ) + else() + set( CORE_LIBRARIES ${W3NCO_LIBRARY} ) + endif() +endif( NOT W3NCO_LIBRARY ) + +set( W3NCO_DIR ${CMAKE_SOURCE_DIR}/libsrc/w3nco CACHE STRING "W3NCO Source Location") +set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) + diff --git a/cmake/Modules/FindWRF.cmake b/cmake/Modules/FindWRF.cmake new file mode 100644 index 0000000000..43faf46643 --- /dev/null +++ b/cmake/Modules/FindWRF.cmake @@ -0,0 +1,36 @@ +# - Find the WRF modules + +set( NO_DEFAULT_PATH ) +find_library( IOINT_LIB + NAMES libwrfio_int.a + HINTS + ${WRFPATH}/external/io_int + $ENV{WRFPATH}/external/io_int + /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_int + /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_int + ${NO_DEFAULT_PATH}) + +find_library( WRFNETCDF_LIB + NAMES libwrfio_nf.a + HINTS + ${WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf + $ENV{WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf + /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_netcdf + ${NO_DEFAULT_PATH}) +find_file( FRAMEPACK + NAMES pack_utils.o + HINTS + ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame + $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame + /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame + ${NO_DEFAULT_PATH}) +find_file( FRAMEMODULE + NAMES module_machine.o + HINTS + ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame + $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame + /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame + ${NO_DEFAULT_PATH}) + +set( WRF_LIBRARIES ${IOINT_LIB} ${WRFNETCDF_LIB} ${FRAMEPACK} ${FRAMEMODULE} ) + diff --git a/cmake/Modules/NewCMake/CMakeParseArguments.cmake b/cmake/Modules/NewCMake/CMakeParseArguments.cmake new file mode 100644 index 0000000000..7ee2bbacef --- /dev/null +++ b/cmake/Modules/NewCMake/CMakeParseArguments.cmake @@ -0,0 +1,11 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CMakeParseArguments +# ------------------- +# +# This module once implemented the :command:`cmake_parse_arguments` command +# that is now implemented natively by CMake. It is now an empty placeholder +# for compatibility with projects that include it to get the command from +# CMake 3.4 and lower. diff --git a/cmake/Modules/NewCMake/FindHDF5.cmake b/cmake/Modules/NewCMake/FindHDF5.cmake new file mode 100644 index 0000000000..fd8891cf20 --- /dev/null +++ b/cmake/Modules/NewCMake/FindHDF5.cmake @@ -0,0 +1,934 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindHDF5 +# -------- +# +# Find HDF5, a library for reading and writing self describing array data. +# +# +# +# This module invokes the HDF5 wrapper compiler that should be installed +# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper +# compiler is called either h5cc or h5pcc. If this succeeds, the module +# will then call the compiler with the -show argument to see what flags +# are used when compiling an HDF5 client application. +# +# The module will optionally accept the COMPONENTS argument. If no +# COMPONENTS are specified, then the find module will default to finding +# only the HDF5 C library. If one or more COMPONENTS are specified, the +# module will attempt to find the language bindings for the specified +# components. The only valid components are C, CXX, Fortran, HL, and +# Fortran_HL. If the COMPONENTS argument is not given, the module will +# attempt to find only the C bindings. +# +# This module will read the variable +# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a +# static link to a dynamic link for HDF5 and all of it's dependencies. +# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES +# variable is set before the call to find_package. +# +# To provide the module with a hint about where to find your HDF5 +# installation, you can set the environment variable HDF5_ROOT. The +# Find module will then look in this path when searching for HDF5 +# executables, paths, and libraries. +# +# Both the serial and parallel HDF5 wrappers are considered and the first +# directory to contain either one will be used. In the event that both appear +# in the same directory the serial version is preferentially selected. This +# behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to +# true. +# +# In addition to finding the includes and libraries required to compile +# an HDF5 client application, this module also makes an effort to find +# tools that come with the HDF5 distribution that may be useful for +# regression testing. +# +# This module will define the following variables: +# +# :: +# +# HDF5_FOUND - true if HDF5 was found on the system +# HDF5_VERSION - HDF5 version in format Major.Minor.Release +# HDF5_INCLUDE_DIRS - Location of the hdf5 includes +# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) +# HDF5_DEFINITIONS - Required compiler definitions for HDF5 +# HDF5_LIBRARIES - Required libraries for all requested bindings +# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all +# bindings, if the HL component is enabled +# +# Available components are: C CXX Fortran and HL. For each enabled language +# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially +# HDF5_${LANG}_DEFINITIONS, will be defined. +# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will +# also be defined. With all components enabled, the following variables will be defined: +# +# :: +# +# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings +# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings +# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings +# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings +# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings +# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings +# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings +# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings +# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings +# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings +# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings +# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran +# bindings. +# +# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support +# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler +# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler +# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler +# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler +# which is also the HDF5 wrapper +# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ +# compiler which is also +# the HDF5 wrapper +# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary +# Fortran compiler which +# is also the HDF5 wrapper +# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool +# +# The following variable can be set to guide the search for HDF5 libraries and includes: +# +# ``HDF5_ROOT`` +# Specify the path to the HDF5 installation to use. +# +# ``HDF5_FIND_DEBUG`` +# Set to a true value to get some extra debugging output. +# +# ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` +# Set to a true value to skip trying to find ``hdf5-config.cmake``. + +# This module is maintained by Will Dicharry . + +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +# List of the valid HDF5 components +set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) + +# Validate the list of find components. +if(NOT HDF5_FIND_COMPONENTS) + set(HDF5_LANGUAGE_BINDINGS "C") +else() + set(HDF5_LANGUAGE_BINDINGS) + # add the extra specified components, ensuring that they are valid. + set(FIND_HL OFF) + foreach(component IN LISTS HDF5_FIND_COMPONENTS) + list(FIND HDF5_VALID_LANGUAGE_BINDINGS ${component} component_location) + if(NOT component_location EQUAL -1) + list(APPEND HDF5_LANGUAGE_BINDINGS ${component}) + elseif(component STREQUAL "HL") + set(FIND_HL ON) + elseif(component STREQUAL "Fortran_HL") # only for compatibility + list(APPEND HDF5_LANGUAGE_BINDINGS Fortran) + set(FIND_HL ON) + set(HDF5_FIND_REQUIRED_Fortran_HL False) + set(HDF5_FIND_REQUIRED_Fortran True) + set(HDF5_FIND_REQUIRED_HL True) + else() + message(FATAL_ERROR "${component} is not a valid HDF5 component.") + endif() + endforeach() + if(NOT HDF5_LANGUAGE_BINDINGS) + get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) + foreach(__lang IN LISTS __langs) + if(__lang MATCHES "^(C|CXX|Fortran)$") + list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) + endif() + endforeach() + endif() + list(REMOVE_ITEM HDF5_FIND_COMPONENTS Fortran_HL) # replaced by Fortran and HL + list(REMOVE_DUPLICATES HDF5_LANGUAGE_BINDINGS) +endif() + +# Determine whether to search for serial or parallel executable first +if(HDF5_PREFER_PARALLEL) + set(HDF5_C_COMPILER_NAMES h5pcc h5cc) + set(HDF5_CXX_COMPILER_NAMES h5pc++ h5c++) + set(HDF5_Fortran_COMPILER_NAMES h5pfc h5fc) +else() + set(HDF5_C_COMPILER_NAMES h5cc h5pcc) + set(HDF5_CXX_COMPILER_NAMES h5c++ h5pc++) + set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc) +endif() + +# We may have picked up some duplicates in various lists during the above +# process for the language bindings (both the C and C++ bindings depend on +# libz for example). Remove the duplicates. It appears that the default +# CMake behavior is to remove duplicates from the end of a list. However, +# for link lines, this is incorrect since unresolved symbols are searched +# for down the link line. Therefore, we reverse the list, remove the +# duplicates, and then reverse it again to get the duplicates removed from +# the beginning. +macro(_HDF5_remove_duplicates_from_beginning _list_name) + if(${_list_name}) + list(REVERSE ${_list_name}) + list(REMOVE_DUPLICATES ${_list_name}) + list(REVERSE ${_list_name}) + endif() +endmacro() + + +# Test first if the current compilers automatically wrap HDF5 + +function(_HDF5_test_regular_compiler_C success version is_parallel) + set(scratch_directory + ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) + if(NOT ${success} OR + NOT EXISTS ${scratch_directory}/compiler_has_h5_c) + set(test_file ${scratch_directory}/cmake_hdf5_test.c) + file(WRITE ${test_file} + "#include \n" + "#include \n" + "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" + "#ifdef H5_HAVE_PARALLEL\n" + "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" + "#endif\n" + "int main(int argc, char **argv) {\n" + " int require = 0;\n" + " require += info_ver[argc];\n" + "#ifdef H5_HAVE_PARALLEL\n" + " require += info_parallel[argc];\n" + "#endif\n" + " hid_t fid;\n" + " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" + " return 0;\n" + "}") + try_compile(${success} ${scratch_directory} ${test_file} + COPY_FILE ${scratch_directory}/compiler_has_h5_c + ) + endif() + if(${success}) + file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS + REGEX "^INFO:" + ) + string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" + INFO_VER "${INFO_STRINGS}" + ) + set(${version} ${CMAKE_MATCH_1}) + if(CMAKE_MATCH_3) + set(${version} ${HDF5_C_VERSION}.${CMAKE_MATCH_3}) + endif() + set(${version} ${${version}} PARENT_SCOPE) + + if(INFO_STRINGS MATCHES "INFO:PARALLEL") + set(${is_parallel} TRUE PARENT_SCOPE) + else() + set(${is_parallel} FALSE PARENT_SCOPE) + endif() + endif() +endfunction() + +function(_HDF5_test_regular_compiler_CXX success version is_parallel) + set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) + if(NOT ${success} OR + NOT EXISTS ${scratch_directory}/compiler_has_h5_cxx) + set(test_file ${scratch_directory}/cmake_hdf5_test.cxx) + file(WRITE ${test_file} + "#include \n" + "#ifndef H5_NO_NAMESPACE\n" + "using namespace H5;\n" + "#endif\n" + "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" + "#ifdef H5_HAVE_PARALLEL\n" + "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" + "#endif\n" + "int main(int argc, char **argv) {\n" + " int require = 0;\n" + " require += info_ver[argc];\n" + "#ifdef H5_HAVE_PARALLEL\n" + " require += info_parallel[argc];\n" + "#endif\n" + " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" + " return 0;\n" + "}") + try_compile(${success} ${scratch_directory} ${test_file} + COPY_FILE ${scratch_directory}/compiler_has_h5_cxx + ) + endif() + if(${success}) + file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS + REGEX "^INFO:" + ) + string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" + INFO_VER "${INFO_STRINGS}" + ) + set(${version} ${CMAKE_MATCH_1}) + if(CMAKE_MATCH_3) + set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3}) + endif() + set(${version} ${${version}} PARENT_SCOPE) + + if(INFO_STRINGS MATCHES "INFO:PARALLEL") + set(${is_parallel} TRUE PARENT_SCOPE) + else() + set(${is_parallel} FALSE PARENT_SCOPE) + endif() + endif() +endfunction() + +function(_HDF5_test_regular_compiler_Fortran success is_parallel) + if(NOT ${success}) + set(scratch_directory + ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) + set(test_file ${scratch_directory}/cmake_hdf5_test.f90) + file(WRITE ${test_file} + "program hdf5_hello\n" + " use hdf5\n" + " use h5lt\n" + " use h5ds\n" + " integer error\n" + " call h5open_f(error)\n" + " call h5close_f(error)\n" + "end\n") + try_compile(${success} ${scratch_directory} ${test_file}) + if(${success}) + execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig + OUTPUT_VARIABLE config_output + ERROR_VARIABLE config_error + RESULT_VARIABLE config_result + ) + if(config_output MATCHES "Parallel HDF5: yes") + set(${is_parallel} TRUE PARENT_SCOPE) + else() + set(${is_parallel} FALSE PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +# Invoke the HDF5 wrapper compiler. The compiler return value is stored to the +# return_value argument, the text output is stored to the output variable. +macro( _HDF5_invoke_compiler language output return_value version is_parallel) + set(${version}) + if(HDF5_USE_STATIC_LIBRARIES) + set(lib_type_args -noshlib) + else() + set(lib_type_args -shlib) + endif() + set(scratch_dir ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) + if("${language}" STREQUAL "C") + set(test_file ${scratch_dir}/cmake_hdf5_test.c) + elseif("${language}" STREQUAL "CXX") + set(test_file ${scratch_dir}/cmake_hdf5_test.cxx) + elseif("${language}" STREQUAL "Fortran") + set(test_file ${scratch_dir}/cmake_hdf5_test.f90) + endif() + exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} + ARGS -show ${lib_type_args} ${test_file} + OUTPUT_VARIABLE ${output} + RETURN_VALUE ${return_value} + ) + if(NOT ${${return_value}} EQUAL 0) + message(STATUS + "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") + endif() + exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} + ARGS -showconfig + OUTPUT_VARIABLE config_output + RETURN_VALUE config_return + ) + if(NOT ${return_value} EQUAL 0) + message( STATUS + "Unable to determine HDF5 ${language} version from HDF5 wrapper.") + endif() + string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}") + if(version_match) + string(REPLACE "HDF5 Version: " "" ${version} "${version_match}") + string(REPLACE "-patch" "." ${version} "${${version}}") + endif() + if(config_output MATCHES "Parallel HDF5: yes") + set(${is_parallel} TRUE) + else() + set(${is_parallel} FALSE) + endif() +endmacro() + +# Parse a compile line for definitions, includes, library paths, and libraries. +macro( _HDF5_parse_compile_line + compile_line_var + include_paths + definitions + library_paths + libraries + libraries_hl) + + separate_arguments(_HDF5_COMPILE_ARGS UNIX_COMMAND "${${compile_line_var}}") + + foreach(arg IN LISTS _HDF5_COMPILE_ARGS) + if("${arg}" MATCHES "^-I(.*)$") + # include directory + list(APPEND ${include_paths} "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-D(.*)$") + # compile definition + list(APPEND ${definitions} "-D${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-L(.*)$") + # library search path + list(APPEND ${library_paths} "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-l(hdf5.*hl.*)$") + # library name (hl) + list(APPEND ${libraries_hl} "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-l(.*)$") + # library name + list(APPEND ${libraries} "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.(a|so|dylib|sl|lib)$") + # library file + if(NOT EXISTS "${arg}") + continue() + endif() + get_filename_component(_HDF5_LPATH "${arg}" DIRECTORY) + get_filename_component(_HDF5_LNAME "${arg}" NAME_WE) + string(REGEX REPLACE "^lib" "" _HDF5_LNAME "${_HDF5_LNAME}") + list(APPEND ${library_paths} "${_HDF5_LPATH}") + if(_HDF5_LNAME MATCHES "hdf5.*hl") + list(APPEND ${libraries_hl} "${_HDF5_LNAME}") + else() + list(APPEND ${libraries} "${_HDF5_LNAME}") + endif() + endif() + endforeach() +endmacro() + +# Select a preferred imported configuration from a target +function(_HDF5_select_imported_config target imported_conf) + # We will first assign the value to a local variable _imported_conf, then assign + # it to the function argument at the end. + get_target_property(_imported_conf ${target} MAP_IMPORTED_CONFIG_${CMAKE_BUILD_TYPE}) + if (NOT _imported_conf) + # Get available imported configurations by examining target properties + get_target_property(_imported_conf ${target} IMPORTED_CONFIGURATIONS) + if(HDF5_FIND_DEBUG) + message(STATUS "Found imported configurations: ${_imported_conf}") + endif() + # Find the imported configuration that we prefer. + # We do this by making list of configurations in order of preference, + # starting with ${CMAKE_BUILD_TYPE} and ending with the first imported_conf + set(_preferred_confs ${CMAKE_BUILD_TYPE}) + list(GET _imported_conf 0 _fallback_conf) + list(APPEND _preferred_confs RELWITHDEBINFO RELEASE DEBUG ${_fallback_conf}) + if(HDF5_FIND_DEBUG) + message(STATUS "Start search through imported configurations in the following order: ${_preferred_confs}") + endif() + # Now find the first of these that is present in imported_conf + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) # support IN_LISTS + foreach (_conf IN LISTS _preferred_confs) + if (${_conf} IN_LIST _imported_conf) + set(_imported_conf ${_conf}) + break() + endif() + endforeach() + cmake_policy(POP) + endif() + if(HDF5_FIND_DEBUG) + message(STATUS "Selected imported configuration: ${_imported_conf}") + endif() + # assign value to function argument + set(${imported_conf} ${_imported_conf} PARENT_SCOPE) +endfunction() + + +if(NOT HDF5_ROOT) + set(HDF5_ROOT $ENV{HDF5_ROOT}) +endif() +if(HDF5_ROOT) + set(_HDF5_SEARCH_OPTS NO_DEFAULT_PATH) +else() + set(_HDF5_SEARCH_OPTS) +endif() + +# Try to find HDF5 using an installed hdf5-config.cmake +if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) + find_package(HDF5 QUIET NO_MODULE + HINTS ${HDF5_ROOT} + ${_HDF5_SEARCH_OPTS} + ) + if( HDF5_FOUND) + if(HDF5_FIND_DEBUG) + message(STATUS "Found HDF5 at ${HDF5_DIR} via NO_MODULE. Now trying to extract locations etc.") + endif() + set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) + set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) + set(HDF5_LIBRARIES) + if (NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) + # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc + set(_target_prefix "hdf5::") + endif() + set(HDF5_C_TARGET ${_target_prefix}hdf5) + set(HDF5_C_HL_TARGET ${_target_prefix}hdf5_hl) + set(HDF5_CXX_TARGET ${_target_prefix}hdf5_cpp) + set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) + set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) + set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) + set(HDF5_DEFINITIONS "") + if(HDF5_USE_STATIC_LIBRARIES) + set(_suffix "-static") + else() + set(_suffix "-shared") + endif() + foreach(_lang ${HDF5_LANGUAGE_BINDINGS}) + + #Older versions of hdf5 don't have a static/shared suffix so + #if we detect that occurrence clear the suffix + if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix}) + if(NOT TARGET ${HDF5_${_lang}_TARGET}) + #cant find this component with or without the suffix + #so bail out, and let the following locate HDF5 + set(HDF5_FOUND FALSE) + break() + endif() + set(_suffix "") + endif() + + if(HDF5_FIND_DEBUG) + message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") + endif() + # Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib. + _HDF5_select_imported_config(${HDF5_${_lang}_TARGET}${_suffix} _hdf5_imported_conf) + get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) + if (NOT _hdf5_lang_location) + # no import lib, just try LOCATION + get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) + if (NOT _hdf5_lang_location) + get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) + endif() + endif() + if( _hdf5_lang_location ) + set(HDF5_${_lang}_LIBRARY ${_hdf5_lang_location}) + list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) + set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) + set(HDF5_${_lang}_FOUND True) + endif() + if(FIND_HL) + get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) + if (NOT _hdf5_lang_hl_location) + get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) + if (NOT _hdf5_hl_lang_location) + get_target_property(_hdf5_hl_lang_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) + endif() + endif() + if( _hdf5_lang_hl_location ) + set(HDF5_${_lang}_HL_LIBRARY ${_hdf5_lang_hl_location}) + list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) + set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) + set(HDF5_HL_FOUND True) + endif() + unset(_hdf5_lang_hl_location) + endif() + unset(_hdf5_imported_conf) + unset(_hdf5_lang_location) + endforeach() + endif() +endif() + +if(NOT HDF5_FOUND) + set(_HDF5_NEED_TO_SEARCH False) + set(HDF5_COMPILER_NO_INTERROGATE True) + # Only search for languages we've enabled + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) + # First check to see if our regular compiler is one of wrappers + if(__lang STREQUAL "C") + _HDF5_test_regular_compiler_C( + HDF5_${__lang}_COMPILER_NO_INTERROGATE + HDF5_${__lang}_VERSION + HDF5_${__lang}_IS_PARALLEL) + elseif(__lang STREQUAL "CXX") + _HDF5_test_regular_compiler_CXX( + HDF5_${__lang}_COMPILER_NO_INTERROGATE + HDF5_${__lang}_VERSION + HDF5_${__lang}_IS_PARALLEL) + elseif(__lang STREQUAL "Fortran") + _HDF5_test_regular_compiler_Fortran( + HDF5_${__lang}_COMPILER_NO_INTERROGATE + HDF5_${__lang}_IS_PARALLEL) + else() + continue() + endif() + if(HDF5_${__lang}_COMPILER_NO_INTERROGATE) + message(STATUS "HDF5: Using hdf5 compiler wrapper for all ${__lang} compiling") + set(HDF5_${__lang}_FOUND True) + set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE + "${CMAKE_${__lang}_COMPILER}" + CACHE FILEPATH "HDF5 ${__lang} compiler wrapper") + set(HDF5_${__lang}_DEFINITIONS) + set(HDF5_${__lang}_INCLUDE_DIRS) + set(HDF5_${__lang}_LIBRARIES) + set(HDF5_${__lang}_HL_LIBRARIES) + + mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE) + + set(HDF5_${__lang}_FOUND True) + set(HDF5_HL_FOUND True) + else() + set(HDF5_COMPILER_NO_INTERROGATE False) + # If this language isn't using the wrapper, then try to seed the + # search options with the wrapper + find_program(HDF5_${__lang}_COMPILER_EXECUTABLE + NAMES ${HDF5_${__lang}_COMPILER_NAMES} NAMES_PER_DIR + HINTS ${HDF5_ROOT} + PATH_SUFFIXES bin Bin + DOC "HDF5 ${__lang} Wrapper compiler. Used only to detect HDF5 compile flags." + ${_HDF5_SEARCH_OPTS} + ) + mark_as_advanced( HDF5_${__lang}_COMPILER_EXECUTABLE ) + unset(HDF5_${__lang}_COMPILER_NAMES) + + if(HDF5_${__lang}_COMPILER_EXECUTABLE) + _HDF5_invoke_compiler(${__lang} HDF5_${__lang}_COMPILE_LINE + HDF5_${__lang}_RETURN_VALUE HDF5_${__lang}_VERSION HDF5_${__lang}_IS_PARALLEL) + if(HDF5_${__lang}_RETURN_VALUE EQUAL 0) + message(STATUS "HDF5: Using hdf5 compiler wrapper to determine ${__lang} configuration") + _HDF5_parse_compile_line( HDF5_${__lang}_COMPILE_LINE + HDF5_${__lang}_INCLUDE_DIRS + HDF5_${__lang}_DEFINITIONS + HDF5_${__lang}_LIBRARY_DIRS + HDF5_${__lang}_LIBRARY_NAMES + HDF5_${__lang}_HL_LIBRARY_NAMES + ) + set(HDF5_${__lang}_LIBRARIES) + + foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES) + set(_HDF5_SEARCH_NAMES_LOCAL) + if("x${L}" MATCHES "hdf5") + # hdf5 library + set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) + if(HDF5_USE_STATIC_LIBRARIES) + if(WIN32) + set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) + else() + set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) + endif() + endif() + else() + # external library + set(_HDF5_SEARCH_OPTS_LOCAL) + endif() + find_library(HDF5_${__lang}_LIBRARY_${L} + NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR + HINTS ${HDF5_${__lang}_LIBRARY_DIRS} + ${HDF5_ROOT} + ${_HDF5_SEARCH_OPTS_LOCAL} + ) + unset(_HDF5_SEARCH_OPTS_LOCAL) + unset(_HDF5_SEARCH_NAMES_LOCAL) + if(HDF5_${__lang}_LIBRARY_${L}) + list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) + else() + list(APPEND HDF5_${__lang}_LIBRARIES ${L}) + endif() + endforeach() + if(FIND_HL) + set(HDF5_${__lang}_HL_LIBRARIES) + foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) + set(_HDF5_SEARCH_NAMES_LOCAL) + if("x${L}" MATCHES "hdf5") + # hdf5 library + set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) + if(HDF5_USE_STATIC_LIBRARIES) + if(WIN32) + set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) + else() + set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) + endif() + endif() + else() + # external library + set(_HDF5_SEARCH_OPTS_LOCAL) + endif() + find_library(HDF5_${__lang}_LIBRARY_${L} + NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR + HINTS ${HDF5_${__lang}_LIBRARY_DIRS} + ${HDF5_ROOT} + ${_HDF5_SEARCH_OPTS_LOCAL} + ) + unset(_HDF5_SEARCH_OPTS_LOCAL) + unset(_HDF5_SEARCH_NAMES_LOCAL) + if(HDF5_${__lang}_LIBRARY_${L}) + list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) + else() + list(APPEND HDF5_${__lang}_HL_LIBRARIES ${L}) + endif() + endforeach() + set(HDF5_HL_FOUND True) + endif() + + set(HDF5_${__lang}_FOUND True) + _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) + _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) + _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) + _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_HL_LIBRARIES) + else() + set(_HDF5_NEED_TO_SEARCH True) + endif() + else() + set(_HDF5_NEED_TO_SEARCH True) + endif() + endif() + if(HDF5_${__lang}_VERSION) + if(NOT HDF5_VERSION) + set(HDF5_VERSION ${HDF5_${__lang}_VERSION}) + elseif(NOT HDF5_VERSION VERSION_EQUAL HDF5_${__lang}_VERSION) + message(WARNING "HDF5 Version found for language ${__lang}, ${HDF5_${__lang}_VERSION} is different than previously found version ${HDF5_VERSION}") + endif() + endif() + if(DEFINED HDF5_${__lang}_IS_PARALLEL) + if(NOT DEFINED HDF5_IS_PARALLEL) + set(HDF5_IS_PARALLEL ${HDF5_${__lang}_IS_PARALLEL}) + elseif(NOT HDF5_IS_PARALLEL AND HDF5_${__lang}_IS_PARALLEL) + message(WARNING "HDF5 found for language ${__lang} is parallel but previously found language is not parallel.") + elseif(HDF5_IS_PARALLEL AND NOT HDF5_${__lang}_IS_PARALLEL) + message(WARNING "HDF5 found for language ${__lang} is not parallel but previously found language is parallel.") + endif() + endif() + endforeach() +else() + set(_HDF5_NEED_TO_SEARCH True) +endif() + +if(NOT HDF5_FOUND AND HDF5_COMPILER_NO_INTERROGATE) + # No arguments necessary, all languages can use the compiler wrappers + set(HDF5_FOUND True) + set(HDF5_METHOD "Included by compiler wrappers") + set(HDF5_REQUIRED_VARS HDF5_METHOD) +elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH) + # Compiler wrappers aren't being used by the build but were found and used + # to determine necessary include and library flags + set(HDF5_INCLUDE_DIRS) + set(HDF5_LIBRARIES) + set(HDF5_HL_LIBRARIES) + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) + if(HDF5_${__lang}_FOUND) + if(NOT HDF5_${__lang}_COMPILER_NO_INTERROGATE) + list(APPEND HDF5_DEFINITIONS ${HDF5_${__lang}_DEFINITIONS}) + list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIRS}) + list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) + if(FIND_HL) + list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) + endif() + endif() + endif() + endforeach() + _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) + _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) + _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) + _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) + set(HDF5_FOUND True) + set(HDF5_REQUIRED_VARS HDF5_LIBRARIES) + if(FIND_HL) + list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) + endif() +endif() + +find_program( HDF5_DIFF_EXECUTABLE + NAMES h5diff + HINTS ${HDF5_ROOT} + PATH_SUFFIXES bin Bin + ${_HDF5_SEARCH_OPTS} + DOC "HDF5 file differencing tool." ) +mark_as_advanced( HDF5_DIFF_EXECUTABLE ) + +if( NOT HDF5_FOUND ) + # seed the initial lists of libraries to find with items we know we need + set(HDF5_C_LIBRARY_NAMES hdf5) + set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl) + + set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES}) + set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES}) + + set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES}) + set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES}) + + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) + # find the HDF5 include directories + if("${__lang}" STREQUAL "Fortran") + set(HDF5_INCLUDE_FILENAME hdf5.mod) + elseif("${__lang}" STREQUAL "CXX") + set(HDF5_INCLUDE_FILENAME H5Cpp.h) + else() + set(HDF5_INCLUDE_FILENAME hdf5.h) + endif() + + find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} + HINTS ${HDF5_ROOT} + PATHS $ENV{HOME}/.local/include + PATH_SUFFIXES include Include + ${_HDF5_SEARCH_OPTS} + ) + mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR) + # set the _DIRS variable as this is what the user will normally use + set(HDF5_${__lang}_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) + list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) + + # find the HDF5 libraries + foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES) + if(HDF5_USE_STATIC_LIBRARIES) + # According to bug 1643 on the CMake bug tracker, this is the + # preferred method for searching for a static library. + # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search + # first for the full static library name, but fall back to a + # generic search on the name if the static search fails. + set( THIS_LIBRARY_SEARCH_DEBUG + lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug + lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_D-static ${LIB}_debug-static ) + set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a lib${LIB} lib${LIB}-static.a ${LIB}-static) + else() + set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) + set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) + if(WIN32) + list(APPEND HDF5_DEFINITIONS "-DH5_BUILT_AS_DYNAMIC_LIB") + endif() + endif() + find_library(HDF5_${LIB}_LIBRARY_DEBUG + NAMES ${THIS_LIBRARY_SEARCH_DEBUG} + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + ${_HDF5_SEARCH_OPTS} + ) + find_library( HDF5_${LIB}_LIBRARY_RELEASE + NAMES ${THIS_LIBRARY_SEARCH_RELEASE} + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + ${_HDF5_SEARCH_OPTS} + ) + select_library_configurations( HDF5_${LIB} ) + list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) + endforeach() + if(HDF5_${__lang}_LIBRARIES) + set(HDF5_${__lang}_FOUND True) + endif() + + # Append the libraries for this language binding to the list of all + # required libraries. + list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) + + if(FIND_HL) + foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) + if(HDF5_USE_STATIC_LIBRARIES) + # According to bug 1643 on the CMake bug tracker, this is the + # preferred method for searching for a static library. + # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search + # first for the full static library name, but fall back to a + # generic search on the name if the static search fails. + set( THIS_LIBRARY_SEARCH_DEBUG + lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug + lib${LIB}d-static.a lib${LIB}_debug-static.a lib${LIB}d-static lib${LIB}_D-static lib${LIB}_debug-static ) + set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a lib${LIB}-static) + else() + set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) + set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) + endif() + find_library(HDF5_${LIB}_LIBRARY_DEBUG + NAMES ${THIS_LIBRARY_SEARCH_DEBUG} + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + ${_HDF5_SEARCH_OPTS} + ) + find_library( HDF5_${LIB}_LIBRARY_RELEASE + NAMES ${THIS_LIBRARY_SEARCH_RELEASE} + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + ${_HDF5_SEARCH_OPTS} + ) + select_library_configurations( HDF5_${LIB} ) + list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY}) + endforeach() + + # Append the libraries for this language binding to the list of all + # required libraries. + list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) + endif() + endforeach() + if(FIND_HL AND HDF5_HL_LIBRARIES) + set(HDF5_HL_FOUND True) + endif() + + _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) + _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) + _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) + _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) + + # If the HDF5 include directory was found, open H5pubconf.h to determine if + # HDF5 was compiled with parallel IO support + set( HDF5_IS_PARALLEL FALSE ) + set( HDF5_VERSION "" ) + foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) + foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h") + if( EXISTS "${_hdr}" ) + file( STRINGS "${_hdr}" + HDF5_HAVE_PARALLEL_DEFINE + REGEX "HAVE_PARALLEL 1" ) + if( HDF5_HAVE_PARALLEL_DEFINE ) + set( HDF5_IS_PARALLEL TRUE ) + endif() + unset(HDF5_HAVE_PARALLEL_DEFINE) + + file( STRINGS "${_hdr}" + HDF5_VERSION_DEFINE + REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" ) + if( "${HDF5_VERSION_DEFINE}" MATCHES + "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?\"" ) + set( HDF5_VERSION "${CMAKE_MATCH_1}" ) + if( CMAKE_MATCH_3 ) + set( HDF5_VERSION ${HDF5_VERSION}.${CMAKE_MATCH_3}) + endif() + endif() + unset(HDF5_VERSION_DEFINE) + endif() + endforeach() + endforeach() + set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL + "HDF5 library compiled with parallel IO support" ) + mark_as_advanced( HDF5_IS_PARALLEL ) + + set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) + if(FIND_HL) + list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) + endif() +endif() + +# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of +# HDF5_INCLUDE_DIRS +if( HDF5_INCLUDE_DIRS ) + set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) +endif() + +# If HDF5_REQUIRED_VARS is empty at this point, then it's likely that +# something external is trying to explicitly pass already found +# locations +if(NOT HDF5_REQUIRED_VARS) + set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) +endif() + +find_package_handle_standard_args(HDF5 + REQUIRED_VARS ${HDF5_REQUIRED_VARS} + VERSION_VAR HDF5_VERSION + HANDLE_COMPONENTS +) + +unset(_HDF5_SEARCH_OPTS) + +if( HDF5_FOUND AND NOT HDF5_DIR) + # hide HDF5_DIR for the non-advanced user to avoid confusion with + # HDF5_DIR-NOT_FOUND while HDF5 was found. + mark_as_advanced(HDF5_DIR) +endif() + +if (HDF5_FIND_DEBUG) + message(STATUS "HDF5_DIR: ${HDF5_DIR}") + message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") + message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") + message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") + message(STATUS "HDF5_HL_LIBRARIES: ${HDF5_HL_LIBRARIES}") + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) + message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}") + message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}") + message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}") + message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}") + message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}") + message(STATUS "HDF5_${__lang}_HL_LIBRARY: ${HDF5_${__lang}_HL_LIBRARY}") + message(STATUS "HDF5_${__lang}_HL_LIBRARIES: ${HDF5_${__lang}_HL_LIBRARIES}") + endforeach() +endif() diff --git a/cmake/Modules/NewCMake/FindMPI.cmake b/cmake/Modules/NewCMake/FindMPI.cmake new file mode 100644 index 0000000000..5cd2a2afe7 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI.cmake @@ -0,0 +1,1514 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindMPI +# ------- +# +# Find a Message Passing Interface (MPI) implementation. +# +# The Message Passing Interface (MPI) is a library used to write +# high-performance distributed-memory parallel applications, and is +# typically deployed on a cluster. MPI is a standard interface (defined +# by the MPI forum) for which many implementations are available. +# +# Variables for using MPI +# ^^^^^^^^^^^^^^^^^^^^^^^ +# +# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. +# Each of these controls the various MPI languages to search for. +# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the +# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API +# that was removed again in MPI-3. +# +# Depending on the enabled components the following variables will be set: +# +# ``MPI_FOUND`` +# Variable indicating that MPI settings for all requested languages have been found. +# If no components are specified, this is true if MPI settings for all enabled languages +# were detected. Note that the ``MPICXX`` component does not affect this variable. +# ``MPI_VERSION`` +# Minimal version of MPI detected among the requested languages, or all enabled languages +# if no components were specified. +# +# This module will set the following variables per language in your +# project, where ```` is one of C, CXX, or Fortran: +# +# ``MPI__FOUND`` +# Variable indicating the MPI settings for ```` were found and that +# simple MPI test programs compile with the provided settings. +# ``MPI__COMPILER`` +# MPI compiler for ```` if such a program exists. +# ``MPI__COMPILE_OPTIONS`` +# Compilation options for MPI programs in ````, given as a :ref:`;-list `. +# ``MPI__COMPILE_DEFINITIONS`` +# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. +# ``MPI__INCLUDE_DIRS`` +# Include path(s) for MPI header. +# ``MPI__LINK_FLAGS`` +# Linker flags for MPI programs. +# ``MPI__LIBRARIES`` +# All libraries to link MPI programs against. +# +# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: +# +# ``MPI::MPI_`` +# Target for using MPI from ````. +# +# The following variables indicating which bindings are present will be defined: +# +# ``MPI_MPICXX_FOUND`` +# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). +# ``MPI_Fortran_HAVE_F77_HEADER`` +# True if the Fortran 77 header ``mpif.h`` is available. +# ``MPI_Fortran_HAVE_F90_MODULE`` +# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). +# ``MPI_Fortran_HAVE_F08_MODULE`` +# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). +# +# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version +# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. +# +# ``MPI__VERSION_MAJOR`` +# Major version of MPI implemented for ```` by the MPI distribution. +# ``MPI__VERSION_MINOR`` +# Minor version of MPI implemented for ```` by the MPI distribution. +# ``MPI__VERSION`` +# MPI version implemented for ```` by the MPI distribution. +# +# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards +# always have required this binding to work in both C and C++ code. +# +# For running MPI programs, the module sets the following variables +# +# ``MPIEXEC_EXECUTABLE`` +# Executable for running MPI programs, if such exists. +# ``MPIEXEC_NUMPROC_FLAG`` +# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. +# ``MPIEXEC_MAX_NUMPROCS`` +# Number of MPI processors to utilize. Defaults to the number +# of processors detected on the host system. +# ``MPIEXEC_PREFLAGS`` +# Flags to pass to ``mpiexec`` directly before the executable to run. +# ``MPIEXEC_POSTFLAGS`` +# Flags to pass to ``mpiexec`` after other flags. +# +# Variables for locating MPI +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# This module performs a three step search for an MPI implementation: +# +# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a +# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. +# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. +# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. +# Currently, only Microsoft MPI and MPICH2 on Windows are supported. +# +# For controlling the second step, the following variables may be set: +# +# ``MPI__COMPILER`` +# Search for the specified compiler wrapper and use it. +# ``MPI__COMPILER_FLAGS`` +# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers +# support linking debug or tracing libraries if a specific flag is passed and this variable +# may be used to obtain them. +# ``MPI_COMPILER_FLAGS`` +# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. +# Empty by default. +# ``MPI_EXECUTABLE_SUFFIX`` +# A suffix which is appended to all names that are being looked for. For instance you may set this +# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. +# +# In order to control the guessing step, the following variable may be set: +# +# ``MPI_GUESS_LIBRARY_NAME`` +# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. +# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. +# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. +# +# Each of the search steps may be skipped with the following control variables: +# +# ``MPI_ASSUME_NO_BUILTIN_MPI`` +# If true, the module assumes that the compiler itself does not provide an MPI implementation and +# skips to step 2. +# ``MPI_SKIP_COMPILER_WRAPPER`` +# If true, no compiler wrapper will be searched for. +# ``MPI_SKIP_GUESSING`` +# If true, the guessing step will be skipped. +# +# Additionally, the following control variable is available to change search behavior: +# +# ``MPI_CXX_SKIP_MPICXX`` +# Add some definitions that will disable the MPI-2 C++ bindings. +# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, +# for example MVAPICH or Intel MPI. +# +# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to +# the module did not work and even a simple MPI test program failed to compile. +# +# If all of these parameters were not sufficient to find the right MPI implementation, a user may +# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` +# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. +# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the +# settings in the cache. +# +# Cache variables for MPI +# ^^^^^^^^^^^^^^^^^^^^^^^ +# +# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. +# For C and CXX: +# +# ``MPI__HEADER_DIR`` +# Location of the ``mpi.h`` header on disk. +# +# For Fortran: +# +# ``MPI_Fortran_F77_HEADER_DIR`` +# Location of the Fortran 77 header ``mpif.h``, if it exists. +# ``MPI_Fortran_MODULE_DIR`` +# Location of the ``mpi`` or ``mpi_f08`` modules, if available. +# +# For all languages the following variables are additionally considered: +# +# ``MPI__ADDITIONAL_INCLUDE_DIRS`` +# A :ref:`;-list ` of paths needed in addition to the normal include directories. +# ``MPI__INCLUDE_DIR`` +# Path variables for include folders referred to by ````. +# ``MPI__ADDITIONAL_INCLUDE_VARS`` +# A :ref:`;-list ` of ```` that will be added to the include locations of ````. +# +# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: +# +# ``MPI__LIBRARY`` +# The location of a library called ```` for use with MPI. +# ``MPI__LIB_NAMES`` +# A :ref:`;-list ` of ```` that will be added to the include locations of ````. +# +# Usage of mpiexec +# ^^^^^^^^^^^^^^^^ +# +# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically +# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: +# +# :: +# +# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} +# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS +# +# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to +# pass to the MPI program. +# +# Advanced variables for using MPI +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# The module can perform some advanced feature detections upon explicit request. +# +# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. +# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. +# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. +# You should only enable these detections if you absolutely need the information. +# +# If the following variables are set to true, the respective search will be performed: +# +# ``MPI_DETERMINE_Fortran_CAPABILITIES`` +# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and +# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` +# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and +# ``F08_MODULE``. +# ``MPI_DETERMINE_LIBRARY_VERSION`` +# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. +# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. +# Note that the return value is entirely implementation defined. This information might be used to identify +# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. +# +# Backward Compatibility +# ^^^^^^^^^^^^^^^^^^^^^^ +# +# For backward compatibility with older versions of FindMPI, these +# variables are set, but deprecated: +# +# :: +# +# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY +# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS +# MPI_LIBRARIES +# +# In new projects, please use the ``MPI__XXX`` equivalents. +# Additionally, the following variables are deprecated: +# +# ``MPI__COMPILE_FLAGS`` +# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. +# ``MPI__INCLUDE_PATH`` +# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. +# ``MPIEXEC`` +# Use ``MPIEXEC_EXECUTABLE`` instead. + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +# Generic compiler names +set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ + mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) +set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r + mpif90 mpif90_r mpf90 mpf90_r + mpif77 mpif77_r mpf77 mpf77_r + mpifc) + +# GNU compiler names +set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) +set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) +set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r + mpig77 mpig77_r mpg77 mpg77_r) + +# Intel MPI compiler names on Windows +if(WIN32) + list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) + list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) + list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) + + # Intel MPI compiler names + set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) + set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) + set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) + + # Intel MPI compiler names for MSMPI + set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) + set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) +else() + # Intel compiler names + set(_MPI_Intel_C_COMPILER_NAMES mpiicc) + set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) + set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) +endif() + +# PGI compiler names +set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) +set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) +set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) + +# XLC MPI Compiler names +set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) +set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC + mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) +set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r + mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r + mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r + mpixlf mpixlf_r mpxlf mpxlf_r) + +# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, +# attempt all of them. +# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper +# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI +# controls its settings via the I_MPI_CC environment variables if the generic name is being used. +# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to +# pick up the right settings for it. +foreach (LANG IN ITEMS C CXX Fortran) + set(_MPI_${LANG}_COMPILER_NAMES "") + foreach (id IN ITEMS GNU Intel MSVC PGI XL) + if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) + list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) + endif() + unset(_MPI_${id}_${LANG}_COMPILER_NAMES) + endforeach() + list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) + unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) +endforeach() + +# Names to try for mpiexec +# Only mpiexec commands are guaranteed to behave as described in the standard, +# mpirun commands are not covered by the standard in any way whatsoever. +# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. +# srun -n X is however a valid command, so it behaves 'like' mpiexec. +set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) + +unset(_MPIEXEC_NAMES) +foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) + list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") +endforeach() +unset(_MPIEXEC_NAMES_BASE) + +function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) + if(DEFINED MPI_${LANG}_COMPILER_FLAGS) +# separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") + separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS "${MPI_${LANG}_COMPILER_FLAGS}") + else() + separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") + endif() + execute_process( + COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} + OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE WRAPPER_RETURN) + # Some compiler wrappers will yield spurious zero return values, for example + # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared + # library that has invalid or missing version information there would be warning + # messages emitted by ld.so in the compiler output. In either case, we'll treat + # the output as invalid. + if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") + set(WRAPPER_RETURN 255) + endif() + # Ensure that no error output might be passed upwards. + if(NOT WRAPPER_RETURN EQUAL 0) + unset(WRAPPER_OUTPUT) + endif() + set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) + set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) +endfunction() + +function (_MPI_interrogate_compiler lang) + unset(MPI_COMPILE_CMDLINE) + unset(MPI_LINK_CMDLINE) + + unset(MPI_COMPILE_OPTIONS_WORK) + unset(MPI_COMPILE_DEFINITIONS_WORK) + unset(MPI_INCLUDE_DIRS_WORK) + unset(MPI_LINK_FLAGS_WORK) + unset(MPI_LIB_NAMES_WORK) + unset(MPI_LIB_FULLPATHS_WORK) + + # Check whether the -showme:compile option works. This indicates that we have either Open MPI + # or a newer version of LAM/MPI, and implies that -showme:link will also work. + # Open MPI also supports -show, but separates linker and compiler information + _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + if (MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) + + if (NOT MPI_COMPILER_RETURN EQUAL 0) + unset(MPI_COMPILE_CMDLINE) + endif() + endif() + + # MPICH and MVAPICH offer -compile-info and -link-info. + # For modern versions, both do the same as -show. However, for old versions, they do differ + # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the + # removed MPI C++ bindings. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) + + if (NOT MPI_COMPILER_RETURN EQUAL 0) + unset(MPI_COMPILE_CMDLINE) + endif() + endif() + endif() + + # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the + # -showme commands are more specialized. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() + + # Older versions of LAM/MPI have "-showme". Open MPI also supports this. + # Unknown to MPICH, MVAPICH and Intel MPI. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() + + if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) + # Cannot interrogate this compiler, so exit. + set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) + return() + endif() + unset(MPI_COMPILER_RETURN) + + # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE + # into MPI_LINK_CMDLINE, if we didn't find the link line. + if (NOT DEFINED MPI_LINK_CMDLINE) + set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") + endif() + + # At this point, we obtained some output from a compiler wrapper that works. + # We'll now try to parse it into variables with meaning to us. + if("${LANG}" STREQUAL "Fortran") + # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting + # out of a symlink command for mpif.h, the actual compiler command and a deletion of the + # created symlink. We need to detect that case, remember the include path and drop the + # symlink/deletion operation to obtain the link/compile lines we'd usually expect. + if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") + get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) + string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + endif() + endif() + + # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command + # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. + if(UNIX) + string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + endif() + + # Extract compile options from the compile command line. + string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") + + foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) + string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") + # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries + # themselves were built with this flag. However, this flag is unrelated to using MPI, and + # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore + # produce inconsistent results with the regularly flags. + # Similarly, aliasing flags do not belong into our flag array. + if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") + list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") + endif() + endforeach() + + # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. + string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") + + foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) + string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") + string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") + if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") + list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") + endif() + endforeach() + + # Extract include paths from compile command line + string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + + # If extracting failed to work, we'll try using -showme:incdirs. + if (NOT MPI_ALL_INCLUDE_PATHS) + _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) + if(MPI_INCDIRS_COMPILER_RETURN) + separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") + endif() + endif() + + foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) + string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) + list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") + endforeach() + + # Extract linker paths from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + + # If extracting failed to work, we'll try using -showme:libdirs. + if (NOT MPI_ALL_LINK_PATHS) + _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) + if(MPI_LIBDIRS_COMPILER_RETURN) + separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") + endif() + endif() + + foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) + string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") + string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") + get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) + list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") + endforeach() + + # Extract linker flags from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + + foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) + string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) + # MPI might be marked to build with non-executable stacks but this should not propagate. + if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") + if (MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") + else() + set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") + endif() + endif() + endforeach() + + # Extract the set of libraries to link against from the link command + # line + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) + string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + + if(WIN32) + # A compiler wrapper on Windows will just have the name of the + # library to link on its link line, potentially with a full path + string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) + string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + else() + # On UNIX platforms, archive libraries can be given with full path. + string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) + string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + endif() + + # An MPI compiler wrapper could have its MPI libraries in the implictly + # linked directories of the compiler itself. + if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) + list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") + endif() + + # Determine full path names for all of the libraries that one needs + # to link against in an MPI program + unset(MPI_PLAIN_LIB_NAMES_WORK) + foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${MPI_LINK_DIRECTORIES_WORK} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() + + # Deal with the libraries given with full path next + unset(MPI_DIRECT_LIB_NAMES_WORK) + foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) + list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_PATH} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() + if(MPI_DIRECT_LIB_NAMES_WORK) + set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") + endif() + + # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to + # link it in that case. -lpthread is covered by the normal library treatment on the other hand. + if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") + list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") + if(MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " -pthread") + else() + set(MPI_LINK_FLAGS_WORK "-pthread") + endif() + endif() + + if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) + list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}") + endif() + if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) + list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}") + endif() + if(MPI_${LANG}_EXTRA_LIB_NAMES) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}") + endif() + + # If we found MPI, set up all of the appropriate cache entries + if(NOT MPI_${LANG}_COMPILE_OPTIONS) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) + endif() + if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) + endif() + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) + endif() + if(NOT MPI_${LANG}_LINK_FLAGS) + set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) + endif() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) +endfunction() + +function(_MPI_guess_settings LANG) + set(MPI_GUESS_FOUND FALSE) + # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. + if(WIN32) + # MSMPI + + # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, + # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers + # or import libraries and vice versa. + if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") + # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed + # Microsoft MPI. + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") + set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") + else() + set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") + set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") + endif() + + find_library(MPI_msmpi_LIBRARY + NAMES msmpi + HINTS ${MPI_MSMPI_LIB_PATH} + DOC "Location of the msmpi library for Microsoft MPI") + mark_as_advanced(MPI_msmpi_LIBRARY) + + if(MPI_msmpi_LIBRARY) + # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way + # MSMPI can be used and therefore that header has to be present. + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) + unset(MPI_MSMPI_INC_DIR) + endif() + + # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, + # thus it might be present or provided by the user. Figuring out which is supported is done later on. + # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. + # Should a user be employing PGI or have built its own set and provided it via cache variables, the + # splitting routine would have located the module files. + + # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran + # we need some extra library to glue Fortran support together: + # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names + # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran + # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit + # has both variants available. + # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is + # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), + # it's passed immediately after the string address. + + # To summarize: + # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention + # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention + # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention + # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention + # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. + + # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas + # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran + # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - + # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). + + # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. + # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and + # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. + if ("${LANG}" STREQUAL "Fortran") + set(MPI_MSMPI_CALLINGCONVS c) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + list(APPEND MPI_MSMPI_CALLINGCONVS s) + endif() + foreach(mpistrlenpos IN ITEMS e m) + foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) + find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY + NAMES msmpif${mpistrlenpos}${mpicallingconv} + HINTS "${MPI_MSMPI_LIB_PATH}" + DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") + mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) + endforeach() + endforeach() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + + # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value + # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. + find_path(MPI_mpifptr_INCLUDE_DIR + NAMES "mpifptr.h" + HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" + DOC "Location of the mpifptr.h extra header for Microsoft MPI") + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) + endif() + mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) + else() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + endif() + mark_as_advanced(MPI_${LANG}_LIB_NAMES) + set(MPI_GUESS_FOUND TRUE) + endif() + endif() + + # At this point there's not many MPIs that we could still consider. + # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. + # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. + if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") + set(MPI_MPICH_PREFIX_PATHS + "$ENV{ProgramW6432}/MPICH2/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" + ) + + # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first + find_library(MPI_mpi_LIBRARY + NAMES mpi + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_mpi_LIBRARY) + # If we found mpi.lib, we detect the rest of MPICH2 + if(MPI_mpi_LIBRARY) + set(MPI_MPICH_LIB_NAMES "mpi") + # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. + # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. + if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) + find_library(MPI_cxx_LIBRARY + NAMES cxx + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_cxx_LIBRARY) + list(APPEND MPI_MPICH_LIB_NAMES "cxx") + # For Fortran, MPICH2 provides three different libraries: + # fmpich2.lib which uses uppercase symbols and cdecl, + # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), + # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. + # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also + # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one + # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation + elseif("${LANG}" STREQUAL "Fortran") + find_library(MPI_fmpich2_LIBRARY + NAMES fmpich2 + HINTS ${MPI_MPICH_PREFIX_PATHS}) + find_library(MPI_fmpich2s_LIBRARY + NAMES fmpich2s + HINTS ${MPI_MPICH_PREFIX_PATHS}) + find_library(MPI_fmpich2g_LIBRARY + NAMES fmpich2g + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) + list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") + endif() + + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + unset(MPI_MPICH_LIB_NAMES) + + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + # For MPICH2, the include folder would be in ../include relative to the library folder. + get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) + get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) + if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) + endif() + unset(MPI_MPICH_ROOT_DIR) + endif() + set(MPI_GUESS_FOUND TRUE) + endif() + unset(MPI_MPICH_PREFIX_PATHS) + endif() + endif() + set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) +endfunction() + +function(_MPI_adjust_compile_definitions LANG) + if("${LANG}" STREQUAL "CXX") + # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ + # bindings in MPI-2. + if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") + # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI + # OMPI_SKIP_MPICXX is being used in Open MPI + # _MPICC_H is being used for IBM Platform MPI + list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") + set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) + endif() + endif() +endfunction() + +macro(_MPI_assemble_libraries LANG) + set(MPI_${LANG}_LIBRARIES "") + # Only for libraries do we need to check whether the compiler's linking stage is separate. + if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) + foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) + endforeach() + endif() +endmacro() + +macro(_MPI_assemble_include_dirs LANG) + if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + set(MPI_${LANG}_INCLUDE_DIRS "") + else() + set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") + if("${LANG}" MATCHES "(C|CXX)") + if(MPI_${LANG}_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + else() # Fortran + if(MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") + endif() + if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") + endif() + endif() + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}") + endforeach() + endif() + endif() +endmacro() + +function(_MPI_split_include_dirs LANG) + if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + return() + endif() + # Backwards compatibility: Search INCLUDE_PATH if given. + if(MPI_${LANG}_INCLUDE_PATH) + list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") + endif() + + # We try to find the headers/modules among those paths (and system paths) + # For C/C++, we just need to have a look for mpi.h. + if("${LANG}" MATCHES "(C|CXX)") + find_path(MPI_${LANG}_HEADER_DIR "mpi.h" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + mark_as_advanced(MPI_${LANG}_HEADER_DIR) + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + # Fortran is more complicated here: An implementation could provide + # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI + # only provides Fortran 77 and - if mpi.f90 is built - potentially + # a Fortran 90 module. + elseif("${LANG}" STREQUAL "Fortran") + find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + find_path(MPI_${LANG}_MODULE_DIR + NAMES "mpi.mod" "mpi_f08.mod" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS + "${MPI_${LANG}_F77_HEADER_DIR}" + "${MPI_${LANG}_MODULE_DIR}" + ) + endif() + mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) + endif() + # Remove duplicates and default system directories from the list. + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR}) + endforeach() + endif() + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) +endfunction() + +macro(_MPI_create_imported_target LANG) + if(NOT TARGET MPI::MPI_${LANG}) + add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) + endif() + + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") + + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") + if(MPI_${LANG}_LINK_FLAGS) + set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") + endif() + # If the compiler links MPI implicitly, no libraries will be found as they're contained within + # CMAKE__IMPLICIT_LINK_LIBRARIES already. + if(MPI_${LANG}_LIBRARIES) + set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") + endif() + # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") +endmacro() + +function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) + set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") + set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/FindMPI") + set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") + unset(MPI_TEST_COMPILE_DEFINITIONS) + if("${LANG}" STREQUAL "Fortran") + if("${MODE}" STREQUAL "F90_MODULE") + set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") + elseif("${MODE}" STREQUAL "F08_MODULE") + set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") + else() # F77 header + set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") + endif() + configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) + set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") + elseif("${LANG}" STREQUAL "CXX") + configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) + set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") + if("${MODE}" STREQUAL "TEST_MPICXX") + set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) + endif() + else() # C + set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") + endif() + if(RUN_BINARY) + try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} + "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} + LINK_LIBRARIES MPI::MPI_${LANG} + RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) + set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) + else() + try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} + "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} + LINK_LIBRARIES MPI::MPI_${LANG} + COPY_FILE "${BIN_FILE}") + endif() +endfunction() + +macro(_MPI_check_lang_works LANG) + # For Fortran we may have by the MPI-3 standard an implementation that provides: + # - the mpi_f08 module + # - *both*, the mpi module and 'mpif.h' + # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. + if( NOT MPI_${LANG}_WORKS ) + if("${LANG}" STREQUAL "Fortran") + set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") + _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) + _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) + _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) + + set(MPI_${LANG}_WORKS FALSE) + + foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) + if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) + set(MPI_${LANG}_WORKS TRUE) + set(MPI_${LANG}_HAVE_${mpimethod} TRUE) + else() + set(MPI_${LANG}_HAVE_${mpimethod} FALSE) + endif() + endforeach() + # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. + # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. + unset(MPI_Fortran_INTEGER_LINE) + if(NOT MPI_${LANG}_WORKS) + _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) + if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) + set(MPI_${LANG}_WORKS TRUE) + set(MPI_${LANG}_HAVE_F77_HEADER TRUE) + endif() + endif() + else() + _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) + # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't + # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. + set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") + endif() + endif() +endmacro() + +# Some systems install various MPI implementations in separate folders in some MPI prefix +# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. +macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) + if(EXISTS "${PREFIX_FOLDER}") + file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") + foreach(_MPI_folder_child IN LISTS _MPI_folder_children) + if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") + list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") + endif() + endforeach() + endif() +endmacro() + +set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_ROOT} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) +if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ + # We enumerate the subfolders and append each as a prefix + MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") +elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. + list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") +elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") + # FreeBSD ships mpich under the normal system paths - but available openmpi implementations + # will be found in /usr/local/mpi/ + MPI_search_mpi_prefix_folder("/usr/local/mpi") +endif() + +# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. +# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution +# ships an mpiexec program (mpirun executables are not regulated by the standard). +find_program(MPIEXEC_EXECUTABLE + NAMES ${_MPIEXEC_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${MPI_HINT_DIRS} + DOC "Executable for running MPI programs.") + +# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). +# This gives us a fairly reliable base directory to search for /bin /lib and /include from. +get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) +get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) + +# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to +# launch an MPI process using mpiexec if such a program exists. +set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") +set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") +set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") + +# Set the number of processes to the physical processor count +cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) +set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") +unset(_MPIEXEC_NUMPROCS) +mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) + +#============================================================================= +# Backward compatibility input hacks. Propagate the FindMPI hints to C and +# CXX if the respective new versions are not defined. Translate the old +# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. +# +# Once we find the new variables, we translate them back into their old +# equivalents below. +if(NOT MPI_IGNORE_LEGACY_VARIABLES) + foreach (LANG IN ITEMS C CXX) + # Old input variables. + set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) + + # Set new vars based on their old equivalents, if the new versions are not already set. + foreach (var ${_MPI_OLD_INPUT_VARS}) + if (NOT MPI_${LANG}_${var} AND MPI_${var}) + set(MPI_${LANG}_${var} "${MPI_${var}}") + endif() + endforeach() + + # Chop the old compile flags into options and definitions + + unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) + unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) + if(MPI_${LANG}_COMPILE_FLAGS) + separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") + foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) + if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") + list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") + else() + list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") + endif() + endforeach() + unset(MPI_SEPARATE_FLAGS) + endif() + + # If a list of libraries was given, we'll split it into new-style cache variables + unset(MPI_${LANG}_EXTRA_LIB_NAMES) + if(NOT MPI_${LANG}_LIB_NAMES) + foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) + if(_MPI_LIB) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) + get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) + list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endif() + endforeach() + endif() + endforeach() +endif() +#============================================================================= + +unset(MPI_VERSION) +unset(MPI_VERSION_MAJOR) +unset(MPI_VERSION_MINOR) + +unset(_MPI_MIN_VERSION) + +# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. +if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) + set(MPI_SKIP_COMPILER_WRAPPER TRUE) +endif() + +# This loop finds the compilers and sends them off for interrogation. +foreach(LANG IN ITEMS C CXX Fortran) + if(CMAKE_${LANG}_COMPILER_LOADED) + if(NOT MPI_FIND_COMPONENTS) + set(_MPI_FIND_${LANG} TRUE) + elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) + set(_MPI_FIND_${LANG} TRUE) + elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) + set(_MPI_FIND_${LANG} TRUE) + else() + set(_MPI_FIND_${LANG} FALSE) + endif() + else() + set(_MPI_FIND_${LANG} FALSE) + endif() + if(_MPI_FIND_${LANG}) + if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) + set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") + mark_as_advanced(MPI_CXX_SKIP_MPICXX) + endif() + if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) + set(MPI_${LANG}_TRIED_IMPLICIT FALSE) + set(MPI_${LANG}_WORKS_IMPLICIT FALSE) + if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) + # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. + # Cray PrgEnv. + _MPI_create_imported_target(${LANG}) + _MPI_check_lang_works(${LANG}) + + # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. + if(MPI_${LANG}_WORKS) + set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) + set(MPI_${LANG}_WORKS_IMPLICIT TRUE) + endif() + set(MPI_${LANG}_TRIED_IMPLICIT TRUE) + endif() + + if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) + set(MPI_${LANG}_WRAPPER_FOUND FALSE) + set(MPI_PINNED_COMPILER FALSE) + + if(NOT MPI_SKIP_COMPILER_WRAPPER) + if(MPI_${LANG}_COMPILER) + # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. + if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") + # Get rid of our default list of names and just search for the name the user wants. + set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") + unset(MPI_${LANG}_COMPILER CACHE) + endif() + # If the user specifies a compiler, we don't want to try to search libraries either. + set(MPI_PINNED_COMPILER TRUE) + endif() + + # If we have an MPI base directory, we'll try all compiler names in that one first. + # This should prevent mixing different MPI environments + if(_MPI_BASE_DIR) + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${_MPI_BASE_DIR} + NO_DEFAULT_PATH + DOC "MPI compiler for ${LANG}" + ) + endif() + + # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), + # we shall try searching in the default paths. + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + DOC "MPI compiler for ${LANG}" + ) + + if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + set(MPI_PINNED_COMPILER TRUE) + + # If we haven't made the implicit compiler test yet, perform it now. + if(NOT MPI_${LANG}_TRIED_IMPLICIT) + _MPI_create_imported_target(${LANG}) + _MPI_check_lang_works(${LANG}) + endif() + + # Should the MPI compiler not work implicitly for MPI, still interrogate it. + # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used + # directly during linkage instead of CMAKE__COMPILER will not work. + if(NOT MPI_${LANG}_WORKS) + set(MPI_${LANG}_WORKS_IMPLICIT FALSE) + _MPI_interrogate_compiler(${LANG}) + else() + set(MPI_${LANG}_WORKS_IMPLICIT TRUE) + endif() + elseif(MPI_${LANG}_COMPILER) + _MPI_interrogate_compiler(${LANG}) + endif() + endif() + + if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) + # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the + # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. + if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) + set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) + else() + _MPI_guess_settings(${LANG}) + endif() + endif() + endif() + endif() + + _MPI_split_include_dirs(${LANG}) + _MPI_assemble_include_dirs(${LANG}) + _MPI_assemble_libraries(${LANG}) + + _MPI_adjust_compile_definitions(${LANG}) + # We always create imported targets even if they're empty + _MPI_create_imported_target(${LANG}) + + if(NOT MPI_${LANG}_WORKS) + _MPI_check_lang_works(${LANG}) + endif() + + # Next, we'll initialize the MPI variables that have not been previously set. + set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) + set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) + endif() + mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS + MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) + + # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported + # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. + if(MPI_${LANG}_WORKS) + if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) + if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) + _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) + if(MPI_RESULT_${LANG}_test_mpi_MPICXX) + set(MPI_MPICXX_FOUND TRUE) + else() + set(MPI_MPICXX_FOUND FALSE) + endif() + else() + set(MPI_MPICXX_FOUND FALSE) + endif() + endif() + + # At this point, we know the bindings present but not the MPI version or anything else. + if(NOT DEFINED MPI_${LANG}_VERSION) + unset(MPI_${LANG}_VERSION_MAJOR) + unset(MPI_${LANG}_VERSION_MINOR) + endif() + set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) + + # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the + # Fortran parameters, since those depend on the method of consumption. + # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 + # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. + if("${LANG}" STREQUAL "Fortran") + if(MPI_${LANG}_HAVE_F08_MODULE) + set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) + elseif(MPI_${LANG}_HAVE_F90_MODULE) + set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) + else() + set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) + endif() + + # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION + # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not + # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. + if(NOT DEFINED MPI_${LANG}_VERSION) + _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) + if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) + file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") + if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") + set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") + endif() + endif() + endif() + + # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. + # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING + # and might vary between the different methods of consumption. + if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) + foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) + if(MPI_${LANG}_HAVE_${mpimethod}) + set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) + set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) + _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) + if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND + NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") + if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES + ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") + if("${CMAKE_MATCH_1}" STREQUAL "T") + set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) + endif() + if("${CMAKE_MATCH_2}" STREQUAL "T") + set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) + endif() + endif() + endif() + endif() + endforeach() + set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) + endif() + else() + set(MPI_${LANG}_HIGHEST_METHOD normal) + + # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. + if(NOT DEFINED MPI_${LANG}_VERSION) + file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") + if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") + set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") + endif() + endif() + endif() + + unset(MPI_BIN_FOLDER) + + # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. + # The one remaining issue is to determine which MPI library is installed. + # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, + # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING + # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). + # It's also worth noting that the installed version string can depend on the language, or on the system the binary + # runs on if MPI is not statically linked. + if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) + _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) + if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND + "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") + string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" + MPI_${LANG}_LIBRARY_VERSION_STRING) + else() + set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") + endif() + endif() + endif() + + set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) + set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) + set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) + + unset(MPI_${LANG}_REQUIRED_VARS) + if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") + endforeach() + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") + if("${LANG}" STREQUAL "Fortran") + # For Fortran we only need one of the module or header directories to have *some* support for MPI. + if(NOT MPI_${LANG}_MODULE_DIR) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") + endif() + if(NOT MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") + endif() + else() + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") + endif() + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") + endforeach() + endif() + # Append the works variable now. If the settings did not work, this will show up properly. + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") + else() + # If the compiler worked implicitly, use its path as output. + # Should the compiler variable be set, we also require it to work. + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") + if(MPI_${LANG}_COMPILER) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") + endif() + endif() + find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} + VERSION_VAR MPI_${LANG}_VERSION) + + if(DEFINED MPI_${LANG}_VERSION) + if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) + set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) + endif() + endif() + endif() +endforeach() + +unset(_MPI_REQ_VARS) +foreach(LANG IN ITEMS C CXX Fortran) + if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) + list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") + endif() +endforeach() + +if(MPICXX IN_LIST MPI_FIND_COMPONENTS) + list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") +endif() + +find_package_handle_standard_args(MPI + REQUIRED_VARS ${_MPI_REQ_VARS} + VERSION_VAR ${_MPI_MIN_VERSION} + HANDLE_COMPONENTS) + +#============================================================================= +# More backward compatibility stuff + +# For compatibility reasons, we also define MPIEXEC +set(MPIEXEC "${MPIEXEC_EXECUTABLE}") + +# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. +foreach(LANG IN ITEMS C CXX Fortran) + if(MPI_${LANG}_FOUND) + set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") + unset(MPI_${LANG}_COMPILE_FLAGS) + if(MPI_${LANG}_COMPILE_OPTIONS) + set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") + endif() + if(MPI_${LANG}_COMPILE_DEFINITIONS) + foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) + string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") + endforeach() + endif() + endif() +endforeach() + +# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. +# This mimics the behavior of the old language-oblivious FindMPI. +set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) +if (MPI_CXX_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_CXX_${var}}) + endforeach() +elseif (MPI_C_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_C_${var}}) + endforeach() +endif() + +# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. +if (MPI_LIBRARIES) + list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) + set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") + unset(MPI_LIBRARY_WORK) +else() + set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") +endif() + +list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) +if (MPI_NUMLIBS GREATER 1) + set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") + list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) + set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") + unset(MPI_EXTRA_LIBRARY_WORK) +else() + set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") +endif() +set(MPI_IGNORE_LEGACY_VARIABLES TRUE) +#============================================================================= + +# unset these vars to cleanup namespace +unset(_MPI_OLD_VARS) +unset(_MPI_PREFIX_PATH) +unset(_MPI_BASE_DIR) +foreach (lang C CXX Fortran) + unset(_MPI_${LANG}_COMPILER_NAMES) +endforeach() + +cmake_policy(POP) diff --git a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in new file mode 100644 index 0000000000..30f912c627 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in @@ -0,0 +1,4 @@ + program mpi_ver + @MPI_Fortran_INCLUDE_LINE@ + print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']' + end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c b/cmake/Modules/NewCMake/FindMPI/libver_mpi.c new file mode 100644 index 0000000000..be9d19d435 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI/libver_mpi.c @@ -0,0 +1,19 @@ +#include + +#ifdef __cplusplus +#include +#else +#include +#endif + +int main(int argc, char* argv[]) +{ + char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING]; + int mpilibver_len; + MPI_Get_library_version(mpilibver_str, &mpilibver_len); +#ifdef __cplusplus + std::puts(mpilibver_str); +#else + puts(mpilibver_str); +#endif +} diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in new file mode 100644 index 0000000000..7938587168 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in @@ -0,0 +1,7 @@ + program mpi_ver + @MPI_Fortran_INCLUDE_LINE@ + character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str + integer(kind=MPI_INTEGER_KIND) :: ierror, reslen + call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror) + print *, mpilibver_str + end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in b/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in new file mode 100644 index 0000000000..a254523853 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in @@ -0,0 +1,10 @@ + program mpi_ver + @MPI_Fortran_INCLUDE_LINE@ + integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0') + character, dimension(17), parameter :: mpiver_str =& + (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', & + char(zero + MPI_VERSION), & + '.', & + char(zero + MPI_SUBVERSION), ']' /) + print *, mpiver_str + end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.c b/cmake/Modules/NewCMake/FindMPI/test_mpi.c new file mode 100644 index 0000000000..b8a308a4b0 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI/test_mpi.c @@ -0,0 +1,37 @@ +#include + +#ifdef __cplusplus +#include +#else +#include +#endif + +#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) +const char mpiver_str[] = { 'I', 'N', + 'F', 'O', + ':', 'M', + 'P', 'I', + '-', 'V', + 'E', 'R', + '[', ('0' + MPI_VERSION), + '.', ('0' + MPI_SUBVERSION), + ']', '\0' }; +#endif + +int main(int argc, char* argv[]) +{ +#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) +#ifdef __cplusplus + std::puts(mpiver_str); +#else + puts(mpiver_str); +#endif +#endif +#ifdef TEST_MPI_MPICXX + MPI::MPI_Init(&argc, &argv); + MPI::MPI_Finalize(); +#else + MPI_Init(&argc, &argv); + MPI_Finalize(); +#endif +} diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in new file mode 100644 index 0000000000..4d43a04d65 --- /dev/null +++ b/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in @@ -0,0 +1,6 @@ + program hello + @MPI_Fortran_INCLUDE_LINE@ + integer@MPI_Fortran_INTEGER_LINE@ ierror + call MPI_INIT(ierror) + call MPI_FINALIZE(ierror) + end program diff --git a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake b/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake new file mode 100644 index 0000000000..67f6bd6f2b --- /dev/null +++ b/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,386 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindPackageHandleStandardArgs +----------------------------- + +This module provides a function intended to be used in :ref:`Find Modules` +implementing :command:`find_package()` calls. It handles the +``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. +It also sets the ``_FOUND`` variable. The package is +considered found if all variables listed contain valid results, e.g. +valid filepaths. + +.. command:: find_package_handle_standard_args + + There are two signatures:: + + find_package_handle_standard_args( + (DEFAULT_MSG|) + ... + ) + + find_package_handle_standard_args( + [FOUND_VAR ] + [REQUIRED_VARS ...] + [VERSION_VAR ] + [HANDLE_COMPONENTS] + [CONFIG_MODE] + [FAIL_MESSAGE ] + ) + + The ``_FOUND`` variable will be set to ``TRUE`` if all + the variables ``...`` are valid and any optional + constraints are satisfied, and ``FALSE`` otherwise. A success or + failure message may be displayed based on the results and on + whether the ``REQUIRED`` and/or ``QUIET`` option was given to + the :command:`find_package` call. + + The options are: + + ``(DEFAULT_MSG|)`` + In the simple signature this specifies the failure message. + Use ``DEFAULT_MSG`` to ask for a default message to be computed + (recommended). Not valid in the full signature. + + ``FOUND_VAR `` + Obsolete. Specifies either ``_FOUND`` or + ``_FOUND`` as the result variable. This exists only + for compatibility with older versions of CMake and is now ignored. + Result variables of both names are always set for compatibility. + + ``REQUIRED_VARS ...`` + Specify the variables which are required for this package. + These may be named in the generated failure message asking the + user to set the missing variable values. Therefore these should + typically be cache entries such as ``FOO_LIBRARY`` and not output + variables like ``FOO_LIBRARIES``. + + ``VERSION_VAR `` + Specify the name of a variable that holds the version of the package + that has been found. This version will be checked against the + (potentially) specified required version given to the + :command:`find_package` call, including its ``EXACT`` option. + The default messages include information about the required + version and the version which has been actually found, both + if the version is ok or not. + + ``HANDLE_COMPONENTS`` + Enable handling of package components. In this case, the command + will report which components have been found and which are missing, + and the ``_FOUND`` variable will be set to ``FALSE`` + if any of the required components (i.e. not the ones listed after + the ``OPTIONAL_COMPONENTS`` option of :command:`find_package`) are + missing. + + ``CONFIG_MODE`` + Specify that the calling find module is a wrapper around a + call to ``find_package( NO_MODULE)``. This implies + a ``VERSION_VAR`` value of ``_VERSION``. The command + will automatically check whether the package configuration file + was found. + + ``FAIL_MESSAGE `` + Specify a custom failure message instead of using the default + generated message. Not recommended. + +Example for the simple signature: + +.. code-block:: cmake + + find_package_handle_standard_args(LibXml2 DEFAULT_MSG + LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) + +The ``LibXml2`` package is considered to be found if both +``LIBXML2_LIBRARY`` and ``LIBXML2_INCLUDE_DIR`` are valid. +Then also ``LibXml2_FOUND`` is set to ``TRUE``. If it is not found +and ``REQUIRED`` was used, it fails with a +:command:`message(FATAL_ERROR)`, independent whether ``QUIET`` was +used or not. If it is found, success will be reported, including +the content of the first ````. On repeated CMake runs, +the same message will not be printed again. + +Example for the full signature: + +.. code-block:: cmake + + find_package_handle_standard_args(LibArchive + REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR + VERSION_VAR LibArchive_VERSION) + +In this case, the ``LibArchive`` package is considered to be found if +both ``LibArchive_LIBRARY`` and ``LibArchive_INCLUDE_DIR`` are valid. +Also the version of ``LibArchive`` will be checked by using the version +contained in ``LibArchive_VERSION``. Since no ``FAIL_MESSAGE`` is given, +the default messages will be printed. + +Another example for the full signature: + +.. code-block:: cmake + + find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) + find_package_handle_standard_args(Automoc4 CONFIG_MODE) + +In this case, a ``FindAutmoc4.cmake`` module wraps a call to +``find_package(Automoc4 NO_MODULE)`` and adds an additional search +directory for ``automoc4``. Then the call to +``find_package_handle_standard_args`` produces a proper success/failure +message. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) + +# internal helper macro +macro(_FPHSA_FAILURE_MESSAGE _msg) + if (${_NAME}_FIND_REQUIRED) + message(FATAL_ERROR "${_msg}") + else () + if (NOT ${_NAME}_FIND_QUIETLY) + message(STATUS "${_msg}") + endif () + endif () +endmacro() + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + if(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + else() + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + if(${_NAME}_CONSIDERED_CONFIGS) + set(configsText "") + list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + math(EXPR configsCount "${configsCount} - 1") + foreach(currentConfigIndex RANGE ${configsCount}) + list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + string(APPEND configsText " ${filename} (version ${version})\n") + endforeach() + if (${_NAME}_NOT_FOUND_MESSAGE) + string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") + endif() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + + else() + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + endif() + endif() +endmacro() + + +function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + +# Set up the arguments for `cmake_parse_arguments`. + set(options CONFIG_MODE HANDLE_COMPONENTS) + set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) + set(multiValueArgs REQUIRED_VARS) + +# Check whether we are in 'simple' or 'extended' mode: + set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + if(${INDEX} EQUAL -1) + set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + set(FPHSA_REQUIRED_VARS ${ARGN}) + set(FPHSA_VERSION_VAR) + else() + cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + if(FPHSA_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + endif() + + if(NOT FPHSA_FAIL_MESSAGE) + set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + endif() + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + if(FPHSA_CONFIG_MODE) + list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + set(FPHSA_VERSION_VAR ${_NAME}_VERSION) + endif() + + if(NOT FPHSA_REQUIRED_VARS) + message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + endif() + endif() + +# now that we collected all arguments, process them + + if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") + set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + endif() + + list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + + string(TOUPPER ${_NAME} _NAME_UPPER) + string(TOLOWER ${_NAME} _NAME_LOWER) + + if(FPHSA_FOUND_VAR) + if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") + set(_FOUND_VAR ${FPHSA_FOUND_VAR}) + else() + message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") + endif() + else() + set(_FOUND_VAR ${_NAME_UPPER}_FOUND) + endif() + + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + set(MISSING_VARS "") + set(DETAILS "") + # check if all passed variables are valid + set(FPHSA_FOUND_${_NAME} TRUE) + foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) + if(NOT ${_CURRENT_VAR}) + set(FPHSA_FOUND_${_NAME} FALSE) + string(APPEND MISSING_VARS " ${_CURRENT_VAR}") + else() + string(APPEND DETAILS "[${${_CURRENT_VAR}}]") + endif() + endforeach() + if(FPHSA_FOUND_${_NAME}) + set(${_NAME}_FOUND TRUE) + set(${_NAME_UPPER}_FOUND TRUE) + else() + set(${_NAME}_FOUND FALSE) + set(${_NAME_UPPER}_FOUND FALSE) + endif() + + # component handling + unset(FOUND_COMPONENTS_MSG) + unset(MISSING_COMPONENTS_MSG) + + if(FPHSA_HANDLE_COMPONENTS) + foreach(comp ${${_NAME}_FIND_COMPONENTS}) + if(${_NAME}_${comp}_FOUND) + + if(NOT DEFINED FOUND_COMPONENTS_MSG) + set(FOUND_COMPONENTS_MSG "found components: ") + endif() + string(APPEND FOUND_COMPONENTS_MSG " ${comp}") + + else() + + if(NOT DEFINED MISSING_COMPONENTS_MSG) + set(MISSING_COMPONENTS_MSG "missing components: ") + endif() + string(APPEND MISSING_COMPONENTS_MSG " ${comp}") + + if(${_NAME}_FIND_REQUIRED_${comp}) + set(${_NAME}_FOUND FALSE) + string(APPEND MISSING_VARS " ${comp}") + endif() + + endif() + endforeach() + set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") + string(APPEND DETAILS "[c${COMPONENT_MSG}]") + endif() + + # version handling: + set(VERSION_MSG "") + set(VERSION_OK TRUE) + + # check with DEFINED here as the requested or found version may be "0" + if (DEFINED ${_NAME}_FIND_VERSION) + if(DEFINED ${FPHSA_VERSION_VAR}) + set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) + + if(${_NAME}_FIND_VERSION_EXACT) # exact version required + # count the dots in the version string + string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") + # add one dot because there is one dot more than there are components + string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) + if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) + # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT + # is at most 4 here. Therefore a simple lookup table is used. + if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) + set(_VERSION_REGEX "[^.]*") + elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) + set(_VERSION_REGEX "[^.]*\\.[^.]*") + elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) + set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") + else () + set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") + endif () + string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") + unset(_VERSION_REGEX) + if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) + set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") + endif () + unset(_VERSION_HEAD) + else () + if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) + set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") + endif () + endif () + unset(_VERSION_DOTS) + + else() # minimum version specified: + if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) + set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") + endif () + endif() + + else() + + # if the package was not found, but a version was given, add that to the output: + if(${_NAME}_FIND_VERSION_EXACT) + set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + else() + set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + endif() + + endif() + else () + # Check with DEFINED as the found version may be 0. + if(DEFINED ${FPHSA_VERSION_VAR}) + set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")") + endif() + endif () + + if(VERSION_OK) + string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]") + else() + set(${_NAME}_FOUND FALSE) + endif() + + + # print the result: + if (${_NAME}_FOUND) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") + else () + + if(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + else() + if(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + else() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") + endif() + endif() + + endif () + + set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) + set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) +endfunction() diff --git a/cmake/Modules/NewCMake/FindPackageMessage.cmake b/cmake/Modules/NewCMake/FindPackageMessage.cmake new file mode 100644 index 0000000000..6821cee4f7 --- /dev/null +++ b/cmake/Modules/NewCMake/FindPackageMessage.cmake @@ -0,0 +1,47 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindPackageMessage +# ------------------ +# +# +# +# FIND_PACKAGE_MESSAGE( "message for user" "find result details") +# +# This macro is intended to be used in FindXXX.cmake modules files. It +# will print a message once for each unique find result. This is useful +# for telling the user where a package was found. The first argument +# specifies the name (XXX) of the package. The second argument +# specifies the message to display. The third argument lists details +# about the find result so that if they change the message will be +# displayed again. The macro also obeys the QUIET argument to the +# find_package command. +# +# Example: +# +# :: +# +# if(X11_FOUND) +# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" +# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") +# else() +# ... +# endif() + +function(FIND_PACKAGE_MESSAGE pkg msg details) + # Avoid printing a message repeatedly for the same find result. + if(NOT ${pkg}_FIND_QUIETLY) + string(REPLACE "\n" "" details "${details}") + set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) + if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") + # The message has not yet been printed. + message(STATUS "${msg}") + + # Save the find details in the cache to avoid printing the same + # message again. + set("${DETAILS_VAR}" "${details}" + CACHE INTERNAL "Details about finding ${pkg}") + endif() + endif() +endfunction() diff --git a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake b/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake new file mode 100644 index 0000000000..dce6f99262 --- /dev/null +++ b/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake @@ -0,0 +1,70 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# SelectLibraryConfigurations +# --------------------------- +# +# +# +# select_library_configurations( basename ) +# +# This macro takes a library base name as an argument, and will choose +# good values for basename_LIBRARY, basename_LIBRARIES, +# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what +# has been found and set. If only basename_LIBRARY_RELEASE is defined, +# basename_LIBRARY will be set to the release value, and +# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND. +# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will +# take the debug value, and basename_LIBRARY_RELEASE will be set to +# basename_LIBRARY_RELEASE-NOTFOUND. +# +# If the generator supports configuration types, then basename_LIBRARY +# and basename_LIBRARIES will be set with debug and optimized flags +# specifying the library to be used for the given configuration. If no +# build type has been set or the generator in use does not support +# configuration types, then basename_LIBRARY and basename_LIBRARIES will +# take only the release value, or the debug value if the release one is +# not set. + +# This macro was adapted from the FindQt4 CMake module and is maintained by Will +# Dicharry . + +macro( select_library_configurations basename ) + if(NOT ${basename}_LIBRARY_RELEASE) + set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.") + endif() + if(NOT ${basename}_LIBRARY_DEBUG) + set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.") + endif() + + if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND + NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND + ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) ) + # if the generator supports configuration types or CMAKE_BUILD_TYPE + # is set, then set optimized and debug options. + set( ${basename}_LIBRARY "" ) + foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) + list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) + endforeach() + foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) + list( APPEND ${basename}_LIBRARY debug "${_libname}" ) + endforeach() + elseif( ${basename}_LIBRARY_RELEASE ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + elseif( ${basename}_LIBRARY_DEBUG ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} ) + else() + set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND") + endif() + + set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) + + if( ${basename}_LIBRARY ) + set( ${basename}_FOUND TRUE ) + endif() + + mark_as_advanced( ${basename}_LIBRARY_RELEASE + ${basename}_LIBRARY_DEBUG + ) +endmacro() diff --git a/cmake/Modules/findHelpers.cmake b/cmake/Modules/findHelpers.cmake new file mode 100644 index 0000000000..028957a0a6 --- /dev/null +++ b/cmake/Modules/findHelpers.cmake @@ -0,0 +1,173 @@ +function (findSrc varName version varDir ) + if(EXISTS ${CMAKE_SOURCE_DIR}/libsrc/${varName}) + message("setting source for ${varName} to be in libsrc") + set( ${varDir} "${CMAKE_SOURCE_DIR}/libsrc/${varName}" PARENT_SCOPE) + set( ${varCacheName} "${CMAKE_SOURCE_DIR}/libsrc/${varName}" CACHE STRING "" FORCE ) + else() + set(searchName ${varName}_v${${version}}) + message("searching for source for ${searchName} in ${CRTM_BASE}") + string( TOLOWER ${varName} varNameLower ) + find_path( TMP_DIR + NAMES ${searchName} + HINTS + ${CMAKE_SOURCE_DIR}/../libs + ${CRTM_BASE}/${version} + ${CRTM_BASE}/${varName} + ${CRTM_BASE}/${varName}/${version} + ${CRTM_BASE}/${varNameLower} + ${CRTM_BASE}/${varNameLower}/${version} + ${COREPATH}/sorc + $ENV{${varDir}}/libsrc + $ENV{${varDir}}/lib/sorc + $ENV{CORPATH}/lib/sorc + ${CMAKE_SOURCE_DIR}/libsrc/${varName} + ) + if( NOT TMP_DIR ) + message("didn't find directory") + set(secondSearchName v${${version}}) + find_path( TMP2_DIR + NAMES ${secondSearchName} + HINTS + ${CRTM_BASE}/${varName} + ) + endif() + set( varCacheName "${varDir}_SRC" ) + file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/*.f*" "${TMP_DIR}/${varName}_v${${version}}/*.F*") + if( f_FILES ) + set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}" PARENT_SCOPE) + set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/src/*.f*" "${TMP_DIR}/${varName}_v${${version}}/src/*.F*") + if( f_FILES ) + set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/src" PARENT_SCOPE) + set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/src" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/libsrc/*.f*" "${TMP_DIR}/${varName}_v${${version}}/src/*.F*") + if( f_FILES ) + set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/libsrc" PARENT_SCOPE) + set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/libsrc" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/sorc/*.f*" "${TMP_DIR}/${varName}_v${${version}}/sorc/*.F*") + if( f_FILES ) + set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/sorc" PARENT_SCOPE) + set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/sorc" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc/*.f*" + "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc/*.F*") + if( f_FILES ) + set( ${varDir} "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc" PARENT_SCOPE) + set( ${varCacheName} "${TMP_DIR}/${varName}_v${${version}}/sorc/libsrc" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${TMP2_DIR}/v${${version}}/src/*.f*" + "${TMP_DIR}/v${${version}}/src/*.F*") + if( f_FILES ) + set( ${varDir} "${TMP2_DIR}/v${${version}}/src" PARENT_SCOPE) + set( ${varCacheName} "${TMP2_DIR}/v${${version}}/src" CACHE STRING "" FORCE ) + endif() + endif() + endif() + endif() + endif() + endif() + if( NOT f_FILES ) # look for source that is of a different version + message("WARNING: Did not find ${${version}} of ${varName}, looking for alternates") + findOtherVersion( TMP_DIR ${varName} srcPath ${version} ) + file(GLOB f_FILES "${srcPath}/*.f*" "${srcPath}/*.F*") + if( f_FILES ) + set( ${varDir} "${srcPath}" PARENT_SCOPE) + set( ${varCacheName} "${srcPath}" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${srcPath}/src/*.f*" "${srcPath}/src/*.F*") + if( f_FILES ) + set( ${varDir} "${srcPath}/src" PARENT_SCOPE) + set( ${varCacheName} "${srcPath}/src" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${srcPath}/libsrc/*.f*" "${srcPath}/src/*.F*") + if( f_FILES ) + set( ${varDir} "${srcPath}/libsrc" PARENT_SCOPE) + set( ${varCacheName} "${srcPath}/libsrc" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${srcPath}/sorc/*.f*" "${srcPath}/sorc/*.F*") + if( f_FILES ) + set( ${varDir} "${srcPath}/sorc" PARENT_SCOPE) + set( ${varCacheName} "${srcPath}/sorc" CACHE STRING "" FORCE ) + else() + file(GLOB f_FILES "${srcPath}/sorc/libsrc/*.f*" + "${srcPath}/sorc/libsrc/*.F*") + if( f_FILES ) + set( ${varDir} "${srcPath}/sorc/libsrc" PARENT_SCOPE) + set( ${varCacheName} "${srcPath}/sorc/libsrc" CACHE STRING "" FORCE ) + endif() + endif() + endif() + endif() + endif() + endif() + endif() +endfunction() + +function (findInc incName version incFile ) + cmake_policy(SET CMP0011 NEW) + cmake_policy(SET CMP0009 NEW) + STRING(COMPARE EQUAL ${incFile} "CRTMINC" USECRTMBASE ) + if(( USECRTMBASE ) AND ( CRTM_BASE )) + execute_process(COMMAND find ${CRTM_BASE} -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) +# file(GLOB_RECURSE INCFILES ${CRTM_BASE}/*${CRTM_VER}*/*mod ) +# file(GLOB_RECURSE INCFILES2 ${CRTM_BASE}/crtm/*${CRTM_VER}*/*/*mod ) +# list(APPEND INCFILES ${INCFILES2} ) + else() + if(crayComp) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + execute_process(COMMAND find ${COREPATH}/${incName}/v${${version}}/intel -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) + else() + execute_process(COMMAND find ${COREPATH}/${incName}/v${${version}}/cray -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) + endif() + else() + execute_process(COMMAND find ${COREPATH}/${incName} -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) + endif() + if( NOT (INCFILES) ) + execute_process(COMMAND find ${COREPATH}/sorc -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) + endif() + endif() +# message("incfiles are ${INCFILES}") + if( INCFILES ) + string(REGEX REPLACE "\n" ";" INCFILES ${INCFILES} ) + endif() + foreach( INC_FILE in ${INCFILES} ) + string(REGEX MATCH ${${version}} MATCHFOUND ${INC_FILE} ) +# message("matchfound is ${MATCHFOUND}, version is ${${version}} for ${INC_FILE}") + if( MATCHFOUND ) + message("found ${INC_FILE}") + string(REGEX REPLACE "${incName}_module.mod" "" INCPATH ${INC_FILE} ) + set( ${incFile} ${INCPATH} PARENT_SCOPE ) + return() + endif() + endforeach() + file(GLOB_RECURSE INCFILES ${COREPATH}/${incName}_module.mod ) + list(LENGTH INCFILES numFiles) + if(numFiles EQUAL 1) + get_filename_component( INCPATH ${INCFILES} DIRECTORY ) + else() + foreach( INC_FILE in ${INCFILES} ) + get_filename_component( INCPATH ${INC_FILE} DIRECTORY ) +# message("WARNING: Did not find explicit version ${${version}} of ${incName} module, using un-versioned path") +# set( ${incFile} ${INCPATH} PARENT_SCOPE ) +# return() + endforeach() + endif() + set( ${incFile} ${INCPATH} PARENT_SCOPE ) +endfunction() + +function (findOtherVersion rootPath srcName srcPath newVer ) + file(GLOB SRCDIRS ${${rootPath}}/${srcName}* ) + foreach( SRC_DIR in ${SRCDIRS} ) + string(REGEX MATCH ${srcName} MATCHFOUND ${SRC_DIR} ) + if( MATCHFOUND ) + set( ${srcPath} ${SRC_DIR} PARENT_SCOPE ) + string(REGEX MATCH "[0-9].[0-9].[0-9]" ALTVER ${SRC_DIR} ) + message("Found ${ALTVER} of ${srcName}. Proceeding with Alternative") + set( ${newVer} ${ALTVER} PARENT_SCOPE ) + return() + endif() + endforeach() +endfunction() diff --git a/cmake/Modules/platforms/Acorn.cmake b/cmake/Modules/platforms/Acorn.cmake new file mode 100644 index 0000000000..8bb4cb94da --- /dev/null +++ b/cmake/Modules/platforms/Acorn.cmake @@ -0,0 +1,13 @@ +macro (setAcorn) + + message("Setting flags and paths for Cray") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) + set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) + + set(HOST_FLAG "" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") + set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") + set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") +endmacro() diff --git a/cmake/Modules/platforms/Cheyenne.cmake b/cmake/Modules/platforms/Cheyenne.cmake new file mode 100644 index 0000000000..54477168e8 --- /dev/null +++ b/cmake/Modules/platforms/Cheyenne.cmake @@ -0,0 +1,24 @@ +macro (setCheyenne) + message("Setting paths for Cheyenne") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + + set(BUILD_CORELIBS "ON" ) + set(BUILD_UTIL "OFF" CACHE INTERNAL "" ) + set(BUILD_BUFR "ON" CACHE INTERNAL "") + set(BUILD_SFCIO "ON" CACHE INTERNAL "") + set(BUILD_SIGIO "ON" CACHE INTERNAL "") + set(BUILD_W3EMC "ON" CACHE INTERNAL "") + set(BUILD_W3NCO "ON" CACHE INTERNAL "") + set(BUILD_BACIO "ON" CACHE INTERNAL "") + set(BUILD_CRTM "ON" CACHE INTERNAL "") + set(BUILD_SP "ON" CACHE INTERNAL "") + set(BUILD_NEMSIO "ON" CACHE INTERNAL "") + set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) +endmacro() + diff --git a/cmake/Modules/platforms/Discover.cmake b/cmake/Modules/platforms/Discover.cmake new file mode 100644 index 0000000000..fe8a2dfc0e --- /dev/null +++ b/cmake/Modules/platforms/Discover.cmake @@ -0,0 +1,55 @@ +macro (setDiscover) + message("Setting paths for Discover") +# option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) +# option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + set(HDF5_USE_STATIC_LIBRARIES "OFF") + + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + set(host "Discover" CACHE INTERNAL "") + + set(COREPATH $ENV{COREPATH} ) + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "10.2.5" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.1" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.1.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.2.0" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() + + if( ENV{BASEDIR} ) + set(BASEDIR $ENV{BASEDIR}/Linux CACHE INTERNAL "") + endif() + set(BUILD_CORELIBS "ON" CACHE INTERNAL "") + set(USE_WRF "OFF" CACHE INTERNAL "") + set(BUILD_GLOBAL "ON" CACHE INTERNAL "") + + set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) + +endmacro() + diff --git a/cmake/Modules/platforms/Gaea.cmake b/cmake/Modules/platforms/Gaea.cmake new file mode 100644 index 0000000000..d6929b8f03 --- /dev/null +++ b/cmake/Modules/platforms/Gaea.cmake @@ -0,0 +1,14 @@ +macro (setGaea) + + message("Setting flags and paths for Cray") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) + set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) + + set(HOST_FLAG "-xCORE-AVX2" CACHE INTERNAL "Host Flag") # for Haswell (C4) + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag" ) + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") + set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") + set(GSI_LDFLAGS "${MKL_FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") + set(BUILD_CORELIBS "OFF" ) +endmacro() diff --git a/cmake/Modules/platforms/Generic.cmake b/cmake/Modules/platforms/Generic.cmake new file mode 100644 index 0000000000..24f40107d5 --- /dev/null +++ b/cmake/Modules/platforms/Generic.cmake @@ -0,0 +1,25 @@ +macro (setGeneric) + message("Setting paths for Generic System") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + if(EXISTS /jetmon) + set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required + else() + set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required + endif() + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + + message("setting values for corelibs") + set(BUILD_BUFR "OFF" CACHE INTERNAL "Build the BUFR library" ) + set(BUILD_BACIO "OFF" CACHE INTERNAL "Build the BACIO library" ) + set(BUILD_SFCIO "OFF" CACHE INTERNAL "Build the SFCIO library" ) + set(BUILD_SIGIO "OFF" CACHE INTERNAL "Build the SIGIO library" ) + set(BUILD_NEMSIO "OFF" CACHE INTERNAL "Build the NEMSIO library" ) + set(BUILD_SP "OFF" CACHE INTERNAL "Build the SP library" ) + set(BUILD_CRTM "OFF" CACHE INTERNAL "Build the CRTM library" ) + set(BUILD_W3EMC "OFF" CACHE INTERNAL "Build the EMC library" ) + set(BUILD_W3NCO "OFF" CACHE INTERNAL "Build the EMC library" ) + set(BUILD_NCO "OFF" CACHE INTERNAL "Build the NCO library" ) +endmacro() diff --git a/cmake/Modules/platforms/Hera.cmake b/cmake/Modules/platforms/Hera.cmake new file mode 100644 index 0000000000..d8af27696c --- /dev/null +++ b/cmake/Modules/platforms/Hera.cmake @@ -0,0 +1,42 @@ +macro (setHERA) + message("Setting paths for HERA") + option(FIND_HDF5 "Try to Find HDF5 libraries" ON) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + set(HDF5_USE_STATIC_LIBRARIES "ON") + + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "10.2.5" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.1" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.0.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.0.5" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() +endmacro() + diff --git a/cmake/Modules/platforms/Jet.cmake b/cmake/Modules/platforms/Jet.cmake new file mode 100644 index 0000000000..824585e366 --- /dev/null +++ b/cmake/Modules/platforms/Jet.cmake @@ -0,0 +1,42 @@ +macro (setJet) + message("Setting paths for Jet") + option(FIND_HDF5 "Try to Find HDF5 libraries" ON) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + set(HOST_FLAG "-axSSE4.2,AVX,CORE-AVX2" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + set(HDF5_USE_STATIC_LIBRARIES "ON") + + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "10.2.5" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.1" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.0.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.0.5" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() +endmacro() + diff --git a/cmake/Modules/platforms/Orion.cmake b/cmake/Modules/platforms/Orion.cmake new file mode 100644 index 0000000000..56ddd1f2c3 --- /dev/null +++ b/cmake/Modules/platforms/Orion.cmake @@ -0,0 +1,42 @@ +macro (setOrion) + message("Setting paths for Orion") + option(FIND_HDF5 "Try to Find HDF5 libraries" ON) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + set(HDF5_USE_STATIC_LIBRARIES "ON") + + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "10.2.5" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.1" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.0.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.0.5" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() +endmacro() + diff --git a/cmake/Modules/platforms/S4.cmake b/cmake/Modules/platforms/S4.cmake new file mode 100644 index 0000000000..8c19f11a32 --- /dev/null +++ b/cmake/Modules/platforms/S4.cmake @@ -0,0 +1,10 @@ +macro (setS4) + message("Setting paths for S4") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + set(HOST_FLAG "-march=ivybridge" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") + set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") + set(HDF5_USE_STATIC_LIBRARIES "OFF") +endmacro() diff --git a/cmake/Modules/platforms/WCOSS-C.cmake b/cmake/Modules/platforms/WCOSS-C.cmake new file mode 100644 index 0000000000..1c9cf712cd --- /dev/null +++ b/cmake/Modules/platforms/WCOSS-C.cmake @@ -0,0 +1,60 @@ +macro (setWCOSS_C) + + message("Setting flags and paths for Cray") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) + set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) + + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") + set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") + set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") + if( NOT DEFINED ENV{COREPATH} ) + set(COREPATH "/gpfs/hps/nco/ops/nwprod/lib" ) + else() + set(COREPATH $ENV{COREPATH} ) + endif() + if( NOT DEFINED ENV{CRTM_INC} ) + set(CRTM_BASE "/gpfs/hps/nco/ops/nwprod/lib/crtm" ) + endif() + if( NOT DEFINED ENV{WRFPATH} ) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-intel" ) + else() + set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-cray" ) + endif() + else() + set(WRFPATH $ENV{WRFPATH} ) + endif() + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "11.0.1" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.2" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.0.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.2.0" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() +endmacro() diff --git a/cmake/Modules/platforms/WCOSS-D.cmake b/cmake/Modules/platforms/WCOSS-D.cmake new file mode 100644 index 0000000000..19a853e609 --- /dev/null +++ b/cmake/Modules/platforms/WCOSS-D.cmake @@ -0,0 +1,48 @@ +macro (setWCOSS_D) + message("Setting paths for Dell") + + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "GSI Fortran Flags") + set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS} ${MKL_FLAG}" CACHE INTERNAL "") + set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "ENKF Fortran Flags") + + if( NOT DEFINED ENV{COREPATH} ) + set(COREPATH "/gpfs/dell1/nco/ops/nwprod/lib" ) + else() + set(COREPATH $ENV{COREPATH} ) + endif() + if( NOT DEFINED ENV{CRTM_INC} ) + set(CRTM_BASE "/gpfs/dell1/nco/ops/nwprod/lib/crtm" ) + endif() + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "11.3.0" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.5" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.0.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.3.0" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() +endmacro() diff --git a/cmake/Modules/platforms/WCOSS.cmake b/cmake/Modules/platforms/WCOSS.cmake new file mode 100644 index 0000000000..81b1297392 --- /dev/null +++ b/cmake/Modules/platforms/WCOSS.cmake @@ -0,0 +1,61 @@ +macro (setWCOSS) + message("Setting paths for WCOSS") + option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) + option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) + set(HDF5_USE_STATIC_LIBRARIES "OFF") + + #if ibmpe module is not loaded last, CMake tries to use intel mpi. Force use of ibmhpc + set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") + set( MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") + set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -traceback -O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") + set(ENKF_Platform_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${HOST_FLAG} " CACHE INTERNAL "") + + set(MPI_Fortran_COMPILER /opt/ibmhpc/pe13010/base/bin/mpif90 CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) + set(MPI_C_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicc CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) + set(MPI_CXX_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicxx CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) + + if( NOT DEFINED ENV{COREPATH} ) + set(COREPATH "/nwprod/lib" ) + else() + set(COREPATH $ENV{COREPATH} ) + endif() + if( NOT DEFINED ENV{CRTM_INC} ) + set(CRTM_BASE "/nwprod2/lib" ) + endif() + if( NOT DEFINED ENV{WRFPATH} ) + set(WRFPATH "/nwprod/sorc/wrf_shared.fd" ) + else() + set(WRFPATH $ENV{WRFPATH} ) + endif() + if( NOT DEFINED ENV{NETCDF_VER} ) + set(NETCDF_VER "3.6.3" ) + endif() + if( NOT DEFINED ENV{BACIO_VER} ) + set(BACIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{BUFR_VER} ) + set(BUFR_VER "10.2.5" ) + endif() + if( NOT DEFINED ENV{CRTM_VER} ) + set(CRTM_VER "2.2.3" ) + endif() + if( NOT DEFINED ENV{NEMSIO_VER} ) + set(NEMSIO_VER "2.2.1" ) + endif() + if( NOT DEFINED ENV{SFCIO_VER} ) + set(SFCIO_VER "1.0.0" ) + endif() + if( NOT DEFINED ENV{SIGIO_VER} ) + set(SIGIO_VER "2.0.1" ) + endif() + if( NOT DEFINED ENV{SP_VER} ) + set(SP_VER "2.0.2" ) + endif() + if( NOT DEFINED ENV{W3EMC_VER} ) + set(W3EMC_VER "2.0.5" ) + endif() + if( NOT DEFINED ENV{W3NCO_VER} ) + set(W3NCO_VER "2.0.6" ) + endif() + +endmacro() diff --git a/cmake/Modules/setGNUFlags.cmake b/cmake/Modules/setGNUFlags.cmake new file mode 100644 index 0000000000..e4ef2d9ade --- /dev/null +++ b/cmake/Modules/setGNUFlags.cmake @@ -0,0 +1,66 @@ +function (setGNU) + set(COMPILER_TYPE "gnu" CACHE INTERNAL "Compiler brand") + message("Setting GNU Compiler Flags") + if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) + set(GSI_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") + set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") + set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) + set(ENKF_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(UTIL_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(UTIL_COM_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") + set(BUFR_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") + set(BUFR_C_FLAGS " -O3 -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) + set(BACIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(CRTM_Fortran_FLAGS " -g -std=f2003 -fdollar-ok -O3 -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") + set(NEMSIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(SIGIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(SFCIO_Fortran_FLAGS " -O3 -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(SP_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") + set(SP_Fortran_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") + set(SP_F77_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") + set(SP_F77_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") + set(W3EMC_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(W3EMC_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") + set(W3NCO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") + set(W3NCO_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") + set(W3NCO_C_FLAGS " -DLINUX -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(WRFLIB_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") + set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) + set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) + set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "") + set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") + set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") + else( ) #DEBUG + set(GSI_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") + set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") + set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -fbacktrace -Dfunder" CACHE INTERNAL "" ) + set(ENKF_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(UTIL_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(UTIL_COM_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") + set(BUFR_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") + set(BUFR_C_FLAGS " -g -fbacktrace -g -fbacktrace -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) + set(BACIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(CRTM_Fortran_FLAGS " -g -fbacktrace -std=f2003 -fdollar-ok -g -fbacktrace -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") + set(NEMSIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(SIGIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(SFCIO_Fortran_FLAGS " -g -fbacktrace -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(SP_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") + set(SP_Fortran_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") + set(SP_F77_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") + set(SP_F77_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") + set(W3EMC_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(W3EMC_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") + set(W3NCO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") + set(W3NCO_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") + set(W3NCO_C_FLAGS " -DLINUX -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") + set(WRFLIB_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") + set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) + set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) + set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -fbacktrace -Wl,-noinhibit-exec" CACHE INTERNAL "") + set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") + set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") + endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) +endfunction() + diff --git a/cmake/Modules/setHOST.cmake b/cmake/Modules/setHOST.cmake new file mode 100644 index 0000000000..861e9fc636 --- /dev/null +++ b/cmake/Modules/setHOST.cmake @@ -0,0 +1,105 @@ +macro( setHOST ) + site_name(HOSTNAME) + message("The hostname is ${HOSTNAME}" ) + string(REGEX MATCH "s4-" HOST-S4 ${HOSTNAME} ) + string(REGEX MATCH "gaea" HOST-Gaea ${HOSTNAME} ) + string(REGEX MATCH "hfe[0-9]" HOST-Hera ${HOSTNAME} ) + string(REGEX MATCH "Orion" HOST-Orion ${HOSTNAME} ) + if(EXISTS /jetmon) + set(HOST-Jet "True" ) + endif() + string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) + if( HOST-WCOSS ) + message("host is WCOSS") + endif() + string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) + if( NOT HOST-WCOSS ) # don't overwrite if we are on gyre + string(REGEX MATCH "t[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) + endif() + string(REGEX MATCH "v[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) + if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus Phase 3 + string(REGEX MATCH "v[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) + endif() + if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus/Phase 3.5 + string(REGEX MATCH "m[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) + if( NOT HOST-WCOSS_D )# don't overwrite if we are on mars Phase 3 + string(REGEX MATCH "m[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) + endif() + endif() + string(REGEX MATCH "llogin" HOST-WCOSS_C ${HOSTNAME} ) + if( NOT HOST-WCOSS_C )# don't overwrite if we are on luna + string(REGEX MATCH "slogin" HOST-WCOSS_C ${HOSTNAME} ) + endif() + string(REGEX MATCH "alogin01" HOST-Acorn ${HOSTNAME} ) + if( NOT HOST-Acorn )# don't overwrite if we are on node 1 + string(REGEX MATCH "alogin02" HOST-Acorn ${HOSTNAME} ) + endif() + string(REGEX MATCH "discover" HOST-Discover ${HOSTNAME} ) + string(REGEX MATCH "cheyenne" HOST-Cheyenne ${HOSTNAME} ) + message("done figuring out host--${HOSTNAME}") + if ( COMGSI ) + set( host "GENERIC" ) + set( HOST-Generic "TRUE" ) + setGeneric() + elseif(HOST-Jet) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + set( host "Jet" ) + set( HOST-Jet "TRUE" ) + setJet() + elseif( HOST-S4 ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + set( host "S4" ) + set( HOST-S4 "TRUE" ) + setS4() + elseif( HOST-WCOSS ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + set( host "WCOSS" ) + set( HOST-WCOSS "TRUE" ) + setWCOSS() + elseif( HOST-Hera ) + set( host "Hera" ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + setHERA() + set( HOST-Hera "TRUE" ) + elseif( HOST-Orion ) + set( host "Orion" ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + setOrion() + set( HOST-Orion "TRUE" ) + elseif( HOST-Gaea ) + set( host "Gaea" ) + option(BUILD_CORELIBS "Build the Core libraries " On) + setGaea() + set( HOST-Gaea "TRUE" ) + elseif( HOST-Cheyenne ) + option(BUILD_CORELIBS "Build the Core libraries " ON) + set( host "Cheyenne" ) + setCheyenne() + set( HOST-Cheyenne "TRUE" ) + elseif( HOST-WCOSS_C ) + set( host "WCOSS_C" ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + setWCOSS_C() + set( HOST-WCOSS_C "TRUE" ) + elseif( HOST-WCOSS_D ) + set( host "WCOSS_D" ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + setWCOSS_D() + set( HOST-WCOSS_D "TRUE" ) + elseif( HOST-Discover ) + set(host "Discover" ) + setDiscover() + set( HOST-Discover "TRUE" ) + elseif( HOST-Acorn ) + set( host "Acorn" ) + option(BUILD_CORELIBS "Build the Core libraries " OFF) + setAcorn() + set( HOST-Acorn "TRUE" ) + else( ) + set( host "GENERIC" ) + option(BUILD_CORELIBS "Build the Core libraries " ON) + setGeneric() + set( HOST-Generic "TRUE" ) + endif() + message("Host is set to ${host}") +endmacro() diff --git a/cmake/Modules/setIntelFlags.cmake b/cmake/Modules/setIntelFlags.cmake new file mode 100644 index 0000000000..88e5061ffc --- /dev/null +++ b/cmake/Modules/setIntelFlags.cmake @@ -0,0 +1,94 @@ +set(intsize 4) +function(set_LIBRARY_UTIL_Intel) + set(BACIO_Fortran_FLAGS "-O3 -free -assume nocc_omp ${HOST_FLAG} " CACHE INTERNAL "" ) + set(BUFR_Fortran_FLAGS "-O2 -r8 -fp-model strict -traceback -O3 ${HOST_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(BUFR_C_FLAGS "-DSTATIC_ALLOCATION -DUNDERSCORE -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) + set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) + set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") + set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) + set (CRTM_Fortran_FLAGS " -O3 -convert big_endian -free -assume byterecl -fp-model source -traceback ${HOST_FLAG}" CACHE INTERNAL "" ) + set (NEMSIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (SFCIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (SIGIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (SP_Fortran_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (SP_Fortran_4_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (SP_F77_FLAGS " -DLINUX -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (W3EMC_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (W3EMC_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (W3NCO_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (W3NCO_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set (W3NCO_C_FLAGS "-O0 -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) + set (NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "" ) + set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) + set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) + set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DWRF -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") + set(UTIL_COM_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone" CACHE INTERNAL "") +# set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian -D_REAL8_ -openmp -fpp -auto" CACHE INTERNAL "" ) + set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") +# set(COV_CALC_FLAGS ${GSI_Intel_Platform_FLAGS} CACHE INTERNAL "Full GSI Fortran FLAGS" ) +endfunction(set_LIBRARY_UTIL_Intel) + +function(set_LIBRARY_UTIL_Debug_Intel) + set (BACIO_Fortran_FLAGS "-g -free -assume nocc_omp " CACHE INTERNAL "" ) + set(BUFR_Fortran_FLAGS " -c -g -traceback -O3 -axCORE-AVX2 -r8 " CACHE INTERNAL "" ) + set(BUFR_C_FLAGS "-g -traceback -DUNDERSCORE -O3 -axCORE-AVX2 -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) + set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) + set(CRTM_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(SFCIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(SIGIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(SP_Fortran_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -r8 -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(SP_Fortran_4_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(SP_F77_FLAGS " -g -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(W3EMC_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(W3EMC_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(NEMSIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(W3NCO_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(W3NCO_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) + set(W3NCO_C_FLAGS "-O0 -g -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) + set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) + set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) + set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O1 -g -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") + set(NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -Wl,-noinhibit-exec" CACHE INTERNAL "" ) + set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) + set(UTIL_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") + set(UTIL_COM_Fortran_FLAGS "-O0 -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian" CACHE INTERNAL "") + set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) +endfunction(set_LIBRARY_UTIL_Debug_Intel) + +function(set_GSI_ENKF_Intel) + #Common release/production flags + set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) + set(GSI_Fortran_FLAGS "${GSI_Intel_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full GSI Fortran FLAGS" ) + set(ENKF_Fortran_FLAGS "${ENKF_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full ENKF Fortran FLAGS" ) + set(GSDCLOUD_Fortran_FLAGS "-O3 -convert big_endian" CACHE INTERNAL "") +endfunction(set_GSI_ENKF_Intel) + +function (set_GSI_ENKF_Debug_Intel) + set(GSI_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O0 -fp-model source -convert big_endian -assume byterecl -implicitnone -g -traceback -debug -ftrapuv -check all,noarg_temp_created -fp-stack-check -fstack-protector -warn all,nointerfaces -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") + set(ENKF_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug all -check all,noarg_temp_created -fp-model strict -convert big_endian -assume byterecl -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") + set(GSDCLOUD_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -convert big_endian" CACHE INTERNAL "") + #Common debug flags + set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) +endfunction (set_GSI_ENKF_Debug_Intel) + +function (setIntel) + string(REPLACE "." ";" COMPILER_VERSION_LIST ${CMAKE_C_COMPILER_VERSION}) + list(GET COMPILER_VERSION_LIST 0 MAJOR_VERSION) + list(GET COMPILER_VERSION_LIST 1 MINOR_VERSION) + list(GET COMPILER_VERSION_LIST 2 PATCH_VERSION) + set(COMPILER_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" CACHE INTERNAL "Compiler Version") + set(COMPILER_TYPE "intel" CACHE INTERNAL "Compiler brand") + STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE) + STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION) + set(EXTRA_LINKER_FLAGS ${MKL_FLAG} CACHE INTERNAL "Extra Linker flags") + if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) + set_GSI_ENKF_Intel() + set_LIBRARY_UTIL_Intel() + else( ) #DEBUG flags + message("Building DEBUG version of GSI") + set( debug_suffix "_DBG" CACHE INTERNAL "" ) + set_GSI_ENKF_Debug_Intel() + set_LIBRARY_UTIL_Debug_Intel() + endif() +endfunction() + diff --git a/cmake/Modules/setPGIFlags.cmake b/cmake/Modules/setPGIFlags.cmake new file mode 100644 index 0000000000..2088a7416d --- /dev/null +++ b/cmake/Modules/setPGIFlags.cmake @@ -0,0 +1,78 @@ +function (setPGI) + message("Setting PGI Compiler Flags") + set(COMPILER_TYPE "pgi" CACHE INTERNAL "Compiler brand") + if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) + set(CMAKE_Fortran_FLAGS_RELEASE "") + set(Fortran_FLAGS "" CACHE INTERNAL "") + set(GSI_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") + set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) + set(ENKF_Fortran_FLAGS " -O3 -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") + set(UTIL_Fortran_FLAGS " -O3 -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") + set(UTIL_COM_Fortran_FLAGS " -O3 -byteswapio -fast" CACHE INTERNAL "") + + set(BUFR_Fortran_FLAGS "-O1 -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") + set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") + set(BUFR_C_FLAGS " -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) + + set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") + set(BACIO_Fortran_FLAGS " -O3 -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") + set(CRTM_Fortran_FLAGS " -O1 -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") + set(NEMSIO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") + set(SIGIO_Fortran_FLAGS " -O3 -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") + set(SFCIO_Fortran_FLAGS " -O3 -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") + set(SP_Fortran_FLAGS " -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") + set(SP_Fortran_4_FLAGS " -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") + set(SP_F77_4_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") + set(SP_F77_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") + set(W3EMC_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") + set(W3EMC_4_Fortran_FLAGS " -O1 -byteswapio " CACHE INTERNAL "") + set(W3NCO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") + set(W3NCO_4_Fortran_FLAGS " -DLINUX -O1 -byteswapio " CACHE INTERNAL "") + set(W3NCO_C_FLAGS " -O1 -D_REAL8_ -mp" CACHE INTERNAL "") + set(WRFLIB_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") + set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 " CACHE INTERNAL "") + set(COV_CALC_FLAGS "-O3 -byteswapio -mp" CACHE INTERNAL "") + set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") + if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) + set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) + else() + set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) + endif() + else() + set(Fortran_FLAGS "" CACHE INTERNAL "") + set(GSI_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") + set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -traceback -Dfunder" CACHE INTERNAL "" ) + set(ENKF_Fortran_FLAGS " -g -traceback -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") + set(UTIL_Fortran_FLAGS " -g -traceback -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") + set(UTIL_COM_Fortran_FLAGS " -g -traceback -byteswapio -fast" CACHE INTERNAL "") + + set(BUFR_Fortran_FLAGS "-g -traceback -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") + set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") + set(BUFR_C_FLAGS " -g -traceback -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) + + set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") + set(BACIO_Fortran_FLAGS " -g -traceback -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") + set(CRTM_Fortran_FLAGS " -g -traceback -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") + set(NEMSIO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") + set(SIGIO_Fortran_FLAGS " -g -traceback -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") + set(SFCIO_Fortran_FLAGS " -g -traceback -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") + set(SP_Fortran_FLAGS " -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") + set(SP_Fortran_4_FLAGS " -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") + set(SP_F77_4_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") + set(SP_F77_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") + set(W3EMC_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") + set(W3EMC_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") + set(W3NCO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") + set(W3NCO_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") + set(W3NCO_C_FLAGS " -DLINUX -g -traceback -D_REAL8_ -mp" CACHE INTERNAL "") + set(WRFLIB_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") + set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -traceback " CACHE INTERNAL "") + set(COV_CALC_FLAGS "-O3 -byteswapio -traceback -mp" CACHE INTERNAL "") + set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") + if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) + set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) + else() + set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) + endif() + endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) +endfunction() diff --git a/cmake/Modules/setPlatformVariables.cmake b/cmake/Modules/setPlatformVariables.cmake new file mode 100644 index 0000000000..9938e090f0 --- /dev/null +++ b/cmake/Modules/setPlatformVariables.cmake @@ -0,0 +1,12 @@ +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Jet.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-C.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/S4.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Hera.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Orion.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Gaea.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Cheyenne.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Discover.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-D.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Acorn.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/platforms/Generic.cmake) From b71ab3ad5725d741b5d93070d236a00afe4abd87 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 16 Mar 2022 22:57:28 -0400 Subject: [PATCH 30/58] ncdiag is a requirement since the stubs are obsolete --- src/enkf/CMakeLists.txt | 15 --------------- src/enkf/cmake/PackageConfig.cmake.in | 25 +++---------------------- src/gsi/CMakeLists.txt | 26 +++++++------------------- src/gsi/cmake/PackageConfig.cmake.in | 15 +++++---------- src/gsi/gsi_files.cmake | 8 +++----- 5 files changed, 18 insertions(+), 71 deletions(-) diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index f87959aa6b..a73b0d5faf 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -28,7 +28,6 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) -option(USE_NCDIAG "Use NetCDF diagnostics library" ON) set(ENKF_MODE "GFS" CACHE STRING "Choose the EnKF Application.") set_property(CACHE ENKF_MODE PROPERTY STRINGS "GFS" "WRF" "NMMB" "FV3REG") @@ -36,7 +35,6 @@ set_property(CACHE ENKF_MODE PROPERTY STRINGS "GFS" "WRF" "NMMB" "FV3REG") # Echo user options message(STATUS "EnKF: OPENMP ................. ${OPENMP}") message(STATUS "EnKF: ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "EnKF: USE_NCDIAG ............. ${USE_NCDIAG}") message(STATUS "EnKF: ENKF_MODE .............. ${ENKF_MODE}") # Dependencies @@ -70,13 +68,6 @@ endif() # See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) -# NetCDF Diagnostic IO library dependency -if(USE_NCDIAG) - if(NOT TARGET ncdiag) - find_package(ncdiag REQUIRED) - endif() -endif() - if(NOT TARGET gsi) find_package(gsi REQUIRED) endif() @@ -117,12 +108,6 @@ if(TARGET gsi) add_dependencies(enkf_fortran_obj gsi) endif() target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) -if(USE_NCDIAG) - if(TARGET ncdiag) - add_dependencies(enkf_fortran_obj ncdiag) - endif() - target_link_libraries(enkf_fortran_obj PUBLIC ncdiag::ncdiag) -endif() target_link_libraries(enkf_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(enkf_fortran_obj PUBLIC MPI::MPI_Fortran) target_link_libraries(enkf_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) diff --git a/src/enkf/cmake/PackageConfig.cmake.in b/src/enkf/cmake/PackageConfig.cmake.in index 47e7e268df..115e41b283 100644 --- a/src/enkf/cmake/PackageConfig.cmake.in +++ b/src/enkf/cmake/PackageConfig.cmake.in @@ -10,9 +10,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) -# Set the EnKF configuration attributes -set(ENKF_MODE @ENKF_MODE@) -set(ENKF_USE_NCDIAG @USE_NCDIAG@) +# Get the ENKF_MODE attribute +get_target_property(mode @PROJECT_NAME@::@PROJECT_NAME@ MODE) find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) @@ -33,23 +32,6 @@ endif() find_dependency(gsi REQUIRED) -find_dependency(bacio REQUIRED) -find_dependency(sigio REQUIRED) -find_dependency(sfcio REQUIRED) -find_dependency(nemsio REQUIRED) -find_dependency(ncio REQUIRED) -find_dependency(sp REQUIRED) -find_dependency(w3emc REQUIRED) - -if(ENKF_MODE MATCHES "^(WRF|NMMB|FV3REG)$") - find_dependency(wrf_io REQUIRED) -endif() - -# ON|OFF implies @PROJECT_NAME@ was compiled with/without -USE_NCDIAG=ON|OFF -if(ENKF_USE_NCDIAG) - find_dependency(ncdiag REQUIRED) -endif() - # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -58,5 +40,4 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindEnKF defines targets:") -message(STATUS " - ENKF_MODE [${ENKF_MODE}]") -message(STATUS " - ENKF_USE_NCDIAG [${GSI_USE_NCDIAG}]") +message(STATUS " - ENKF_MODE [${mode}]") diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index e90d4726bd..3aa0548a0e 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -28,7 +28,6 @@ endif() # User options option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) -option(USE_NCDIAG "Use NetCDF diagnostics library" ON) option(USE_GSDCLOUD "Use GSD Cloud Analysis library" OFF) set(GSI_MODE "GFS" CACHE STRING "Choose the GSI Application.") @@ -37,7 +36,6 @@ set_property(CACHE GSI_MODE PROPERTY STRINGS "GFS" "Regional") # Echo user options message(STATUS "GSI: OPENMP ................. ${OPENMP}") message(STATUS "GSI: ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "GSI: USE_NCDIAG ............. ${USE_NCDIAG}") message(STATUS "GSI: USE_GSDCLOUD ........... ${USE_GSDCLOUD}") message(STATUS "GSI: GSI_MODE ............... ${GSI_MODE}") @@ -76,10 +74,8 @@ endif() target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) # NetCDF Diagnostic IO library dependency -if(USE_NCDIAG) - if(NOT TARGET ncdiag) - find_package(ncdiag REQUIRED) - endif() +if(NOT TARGET ncdiag) + find_package(ncdiag REQUIRED) endif() # GSD Cloud Analysis library dependency @@ -102,7 +98,7 @@ list(APPEND GSI_SRC_Fortran # Collect files for specific GSI Application if(GSI_MODE MATCHES "GFS") # GFS GSI application -list(APPEND GSI_SRC_Fortran + list(APPEND GSI_SRC_Fortran ${GSI_SRC_gfs_stub} ${GSI_SRC_fixture_gfs}) elseif(GSI_MODE MATCHES "Regional") # Regional GSI application @@ -111,12 +107,6 @@ elseif(GSI_MODE MATCHES "Regional") # Regional GSI application ${GSI_SRC_fixture_regional}) endif() -# Include GSI ncdiag files if NetCDF Diagnostics is disabled -if(NOT USE_NCDIAG) - list(APPEND GSI_SRC_Fortran - ${GSI_SRC_ncdiag}) -endif() - # Compiler options and definitions list(APPEND GSI_C_defs FortranByte=char @@ -159,13 +149,11 @@ target_link_libraries(gsi_fortran_obj PUBLIC crtm::crtm) if(GSI_MODE MATCHES "Regional") target_link_libraries(gsi_fortran_obj PUBLIC wrf_io::wrf_io) endif() -if(USE_NCDIAG) - if(TARGET ncdiag) - add_dependencies(gsi_fortran_obj ncdiag) - add_library(ncdiag::ncdiag ALIAS ncdiag) - endif() - target_link_libraries(gsi_fortran_obj PUBLIC ncdiag::ncdiag) +if(TARGET ncdiag) + add_dependencies(gsi_fortran_obj ncdiag) + add_library(ncdiag::ncdiag ALIAS ncdiag) endif() +target_link_libraries(gsi_fortran_obj PUBLIC ncdiag::ncdiag) if(USE_GSDCLOUD) if(TARGET gsdcloud) add_dependencies(gsi_fortran_obj gsdcloud) diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in index 020ffaac88..597a10cb95 100644 --- a/src/gsi/cmake/PackageConfig.cmake.in +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -10,9 +10,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) -# Set the GSI configuration attributes -set(GSI_MODE @GSI_MODE@) -set(GSI_USE_NCDIAG @USE_NCDIAG@) +# Get the GSI_MODE attribute +get_target_property(mode @PROJECT_NAME@::@PROJECT_NAME@ MODE) find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) @@ -42,14 +41,11 @@ find_dependency(w3emc REQUIRED) find_dependency(bufr REQUIRED) find_dependency(crtm REQUIRED) -if(GSI_MODE MATCHES "Regional") +if(${mode} MATCHES "Regional") find_dependency(wrf_io REQUIRED) endif() -# ON|OFF implies @PROJECT_NAME@ was compiled with/without -USE_NCDIAG=ON|OFF -if(GSI_USE_NCDIAG) - find_dependency(ncdiag) -endif() +find_dependency(ncdiag REQUIRED) # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -59,5 +55,4 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindGSI defines targets:") -message(STATUS " - GSI_MODE [${GSI_MODE}]") -message(STATUS " - GSI_USE_NCDIAG [${GSI_USE_NCDIAG}]") +message(STATUS " - GSI_MODE [${mode}]") diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake index 6725b99d86..15630a3b73 100644 --- a/src/gsi/gsi_files.cmake +++ b/src/gsi/gsi_files.cmake @@ -54,11 +54,6 @@ gsimain.f90 gsimod.F90 ) -list(APPEND GSI_SRC_ncdiag -nc_diag_read_mod.f90 -nc_diag_write_mod.f90 -) - list(APPEND GSI_SRC_fixture_gfs gsi_fixture_GFS.F90 ) @@ -672,5 +667,8 @@ zrnmi_mod.f90 ) # Unused files +#nc_diag_read_mod.f90 +#nc_diag_write_mod.f90 #stub_nstmod.f90 #Nst_Var_ESMFMod.f90 + From 0d42d9d2dfb503db75c60483c14b3e6e2fec1f38 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 17 Mar 2022 22:30:14 -0400 Subject: [PATCH 31/58] add FindMKL.cmake. Remove finding ncdiag from gsi as a dependency. --- CMakeLists.txt | 2 +- modulefiles/modulefile.ProdGSI.hera | 2 +- src/enkf/CMakeLists.txt | 3 +- src/enkf/cmake/FindMKL.cmake | 91 +++++++++++++++++++++++++++ src/enkf/cmake/PackageConfig.cmake.in | 10 +-- src/gsi/CMakeLists.txt | 7 +-- src/gsi/cmake/FindMKL.cmake | 91 +++++++++++++++++++++++++++ src/gsi/cmake/PackageConfig.cmake.in | 12 ++-- src/ncdiag/CMakeLists.txt | 2 +- util/CMakeLists.txt | 2 +- util/Correlated_Obs/CMakeLists.txt | 1 - util/cmake/FindMKL.cmake | 91 +++++++++++++++++++++++++++ 12 files changed, 293 insertions(+), 21 deletions(-) create mode 100644 src/enkf/cmake/FindMKL.cmake create mode 100644 src/gsi/cmake/FindMKL.cmake create mode 100644 util/cmake/FindMKL.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index aa99943aa8..d6c26c1174 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.20) project(GSIApp VERSION 1.0.0 diff --git a/modulefiles/modulefile.ProdGSI.hera b/modulefiles/modulefile.ProdGSI.hera index 6ed61c594a..b2a68d99c7 100644 --- a/modulefiles/modulefile.ProdGSI.hera +++ b/modulefiles/modulefile.ProdGSI.hera @@ -12,7 +12,7 @@ setenv CRTM_FIX /scratch2/NCEPDEV/nwprod/NCEPLIBS/fix/crtm_v2.3.0 # Load cmake module use -a /contrib/cmake/modulefiles -module load cmake/3.16.1 +module load cmake/3.20.1 # Load hpc-stack module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index a73b0d5faf..5a2ab509e6 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) project(enkf VERSION 1.0.0 @@ -126,7 +126,6 @@ endif() add_library(enkf STATIC) add_library(${PROJECT_NAME}::enkf ALIAS enkf) set_target_properties(enkf PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -set_target_properties(enkf PROPERTIES MODE "${ENKF_MODE}") target_include_directories(enkf PUBLIC $ $) target_link_libraries(enkf PUBLIC enkf_fortran_obj) diff --git a/src/enkf/cmake/FindMKL.cmake b/src/enkf/cmake/FindMKL.cmake new file mode 100644 index 0000000000..09a1feb7d2 --- /dev/null +++ b/src/enkf/cmake/FindMKL.cmake @@ -0,0 +1,91 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +# - Try to find MKL +# Once done this will define +# +# MKL_FOUND - system has Intel MKL +# MKL_INCLUDE_DIRS - the MKL include directories +# MKL_LIBRARIES - link these to use MKL +# +# The following paths will be searched with priority if set in CMake or env +# +# MKLROOT - root directory of the MKL installation +# MKL_PATH - root directory of the MKL installation +# MKL_ROOT - root directory of the MKL installation + +option( MKL_PARALLEL "if mkl shoudl be parallel" OFF ) + +if( MKL_PARALLEL ) + + set( __mkl_lib_par MKL_LIB_INTEL_THREAD ) + set( __mkl_lib_name mkl_intel_thread ) + + find_package(Threads) + +else() + + set( __mkl_lib_par MKL_LIB_SEQUENTIAL ) + set( __mkl_lib_name mkl_sequential ) + +endif() + +# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env +find_path(MKL_INCLUDE_DIR mkl.h + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES include NO_DEFAULT_PATH) + +find_path(MKL_INCLUDE_DIR mkl.h + PATH_SUFFIXES include) + +if( MKL_INCLUDE_DIR ) # use include dir to find libs + + set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) + + if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set( __pathsuffix "lib/intel64") + set( __libsfx _lp64 ) + else() + set( __pathsuffix "lib/ia32") + set( __libsfx "" ) + endif() + + find_library( MKL_LIB_INTEL + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_intel${__libsfx} ) + + find_library( ${__mkl_lib_par} + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES ${__mkl_lib_name} ) + + find_library( MKL_LIB_CORE + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_core ) + + if( MKL_PARALLEL ) + find_library( MKL_LIB_IOMP5 + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES iomp5 ) + endif() + + if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE ) + set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} ) + endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( MKL DEFAULT_MSG + MKL_LIBRARIES MKL_INCLUDE_DIRS ) + +mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE ) diff --git a/src/enkf/cmake/PackageConfig.cmake.in b/src/enkf/cmake/PackageConfig.cmake.in index 115e41b283..c4062dd09c 100644 --- a/src/enkf/cmake/PackageConfig.cmake.in +++ b/src/enkf/cmake/PackageConfig.cmake.in @@ -11,14 +11,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) # Get the ENKF_MODE attribute -get_target_property(mode @PROJECT_NAME@::@PROJECT_NAME@ MODE) +-set(ENKF_MODE @ENKF_MODE@) find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) # ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF if(@ENABLE_MKL@) - find_dependency(MKL) + find_dependency(MKL REQUIRED) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) endif() if(NOT @ENABLE_MKL@) @@ -30,7 +30,9 @@ if(@OPENMP@) find_dependency(OpenMP COMPONENTS Fortran) endif() -find_dependency(gsi REQUIRED) +# This gives more trouble since GSIApp is a nested project of projects +# and targets are built in the GSIApp project +#find_dependency(gsi REQUIRED) # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -40,4 +42,4 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindEnKF defines targets:") -message(STATUS " - ENKF_MODE [${mode}]") +message(STATUS " - ENKF_MODE [${ENKF_MODE}]") diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index 3aa0548a0e..bad2d32f1f 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) project(gsi VERSION 1.0.0 @@ -41,7 +41,7 @@ message(STATUS "GSI: GSI_MODE ............... ${GSI_MODE}") # Dependencies if(ENABLE_MKL) - find_package(MKL QUIET) + find_package(MKL) endif() if(MKL_FOUND) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) @@ -151,13 +151,11 @@ if(GSI_MODE MATCHES "Regional") endif() if(TARGET ncdiag) add_dependencies(gsi_fortran_obj ncdiag) - add_library(ncdiag::ncdiag ALIAS ncdiag) endif() target_link_libraries(gsi_fortran_obj PUBLIC ncdiag::ncdiag) if(USE_GSDCLOUD) if(TARGET gsdcloud) add_dependencies(gsi_fortran_obj gsdcloud) - add_library(gsdcloud::gsdcloud ALIAS gsdcloud) endif() target_link_libraries(gsi_fortran_obj PUBLIC gsdcloud::gsdcloud) endif() @@ -169,7 +167,6 @@ endif() add_library(gsi STATIC) add_library(${PROJECT_NAME}::gsi ALIAS gsi) set_target_properties(gsi PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") -set_target_properties(gsi PROPERTIES MODE "${GSI_MODE}") target_include_directories(gsi PUBLIC $ $) target_link_libraries(gsi PUBLIC gsi_c_obj) diff --git a/src/gsi/cmake/FindMKL.cmake b/src/gsi/cmake/FindMKL.cmake new file mode 100644 index 0000000000..09a1feb7d2 --- /dev/null +++ b/src/gsi/cmake/FindMKL.cmake @@ -0,0 +1,91 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +# - Try to find MKL +# Once done this will define +# +# MKL_FOUND - system has Intel MKL +# MKL_INCLUDE_DIRS - the MKL include directories +# MKL_LIBRARIES - link these to use MKL +# +# The following paths will be searched with priority if set in CMake or env +# +# MKLROOT - root directory of the MKL installation +# MKL_PATH - root directory of the MKL installation +# MKL_ROOT - root directory of the MKL installation + +option( MKL_PARALLEL "if mkl shoudl be parallel" OFF ) + +if( MKL_PARALLEL ) + + set( __mkl_lib_par MKL_LIB_INTEL_THREAD ) + set( __mkl_lib_name mkl_intel_thread ) + + find_package(Threads) + +else() + + set( __mkl_lib_par MKL_LIB_SEQUENTIAL ) + set( __mkl_lib_name mkl_sequential ) + +endif() + +# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env +find_path(MKL_INCLUDE_DIR mkl.h + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES include NO_DEFAULT_PATH) + +find_path(MKL_INCLUDE_DIR mkl.h + PATH_SUFFIXES include) + +if( MKL_INCLUDE_DIR ) # use include dir to find libs + + set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) + + if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set( __pathsuffix "lib/intel64") + set( __libsfx _lp64 ) + else() + set( __pathsuffix "lib/ia32") + set( __libsfx "" ) + endif() + + find_library( MKL_LIB_INTEL + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_intel${__libsfx} ) + + find_library( ${__mkl_lib_par} + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES ${__mkl_lib_name} ) + + find_library( MKL_LIB_CORE + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_core ) + + if( MKL_PARALLEL ) + find_library( MKL_LIB_IOMP5 + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES iomp5 ) + endif() + + if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE ) + set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} ) + endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( MKL DEFAULT_MSG + MKL_LIBRARIES MKL_INCLUDE_DIRS ) + +mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE ) diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in index 597a10cb95..1c5816e2b6 100644 --- a/src/gsi/cmake/PackageConfig.cmake.in +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -11,14 +11,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") include(CMakeFindDependencyMacro) # Get the GSI_MODE attribute -get_target_property(mode @PROJECT_NAME@::@PROJECT_NAME@ MODE) +set(GSI_MODE @GSI_MODE@) find_dependency(MPI) find_dependency(NetCDF COMPONENTS Fortran) # ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF if(@ENABLE_MKL@) - find_dependency(MKL) + find_dependency(MKL REQUIRED) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) endif() if(NOT @ENABLE_MKL@) @@ -41,11 +41,13 @@ find_dependency(w3emc REQUIRED) find_dependency(bufr REQUIRED) find_dependency(crtm REQUIRED) -if(${mode} MATCHES "Regional") +if(${GSI_MODE} MATCHES "Regional") find_dependency(wrf_io REQUIRED) endif() -find_dependency(ncdiag REQUIRED) +# This gives more trouble since GSIApp is a nested project of projects +# and targets are built in the GSIApp project +#find_dependency(ncdiag REQUIRED) # Get the build type from library target get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) @@ -55,4 +57,4 @@ check_required_components("@PROJECT_NAME@") get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") message(STATUS "FindGSI defines targets:") -message(STATUS " - GSI_MODE [${mode}]") +message(STATUS " - GSI_MODE [${GSI_MODE}]") diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index 390d981145..f74fc1aeee 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) project(ncdiag VERSION 1.0.0 diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index c1a92c0556..a74f18933e 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.19) project(gsiutils VERSION 1.0.0 diff --git a/util/Correlated_Obs/CMakeLists.txt b/util/Correlated_Obs/CMakeLists.txt index d6f015d479..1c9b23ac9a 100644 --- a/util/Correlated_Obs/CMakeLists.txt +++ b/util/Correlated_Obs/CMakeLists.txt @@ -28,7 +28,6 @@ target_link_libraries(cov_calc.x PRIVATE MPI::MPI_Fortran) target_link_libraries(cov_calc.x PRIVATE ${LAPACK_LIBRARIES}) if(TARGET ncdiag) add_dependencies(cov_calc.x ncdiag) - add_library(ncdiag::ncdiag ALIAS ncdiag) endif() target_link_libraries(cov_calc.x PRIVATE ncdiag::ncdiag) if(OpenMP_Fortran_FOUND) diff --git a/util/cmake/FindMKL.cmake b/util/cmake/FindMKL.cmake new file mode 100644 index 0000000000..09a1feb7d2 --- /dev/null +++ b/util/cmake/FindMKL.cmake @@ -0,0 +1,91 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +# - Try to find MKL +# Once done this will define +# +# MKL_FOUND - system has Intel MKL +# MKL_INCLUDE_DIRS - the MKL include directories +# MKL_LIBRARIES - link these to use MKL +# +# The following paths will be searched with priority if set in CMake or env +# +# MKLROOT - root directory of the MKL installation +# MKL_PATH - root directory of the MKL installation +# MKL_ROOT - root directory of the MKL installation + +option( MKL_PARALLEL "if mkl shoudl be parallel" OFF ) + +if( MKL_PARALLEL ) + + set( __mkl_lib_par MKL_LIB_INTEL_THREAD ) + set( __mkl_lib_name mkl_intel_thread ) + + find_package(Threads) + +else() + + set( __mkl_lib_par MKL_LIB_SEQUENTIAL ) + set( __mkl_lib_name mkl_sequential ) + +endif() + +# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env +find_path(MKL_INCLUDE_DIR mkl.h + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES include NO_DEFAULT_PATH) + +find_path(MKL_INCLUDE_DIR mkl.h + PATH_SUFFIXES include) + +if( MKL_INCLUDE_DIR ) # use include dir to find libs + + set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) + + if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set( __pathsuffix "lib/intel64") + set( __libsfx _lp64 ) + else() + set( __pathsuffix "lib/ia32") + set( __libsfx "" ) + endif() + + find_library( MKL_LIB_INTEL + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_intel${__libsfx} ) + + find_library( ${__mkl_lib_par} + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES ${__mkl_lib_name} ) + + find_library( MKL_LIB_CORE + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_core ) + + if( MKL_PARALLEL ) + find_library( MKL_LIB_IOMP5 + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES iomp5 ) + endif() + + if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE ) + set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} ) + endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( MKL DEFAULT_MSG + MKL_LIBRARIES MKL_INCLUDE_DIRS ) + +mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE ) From 4c05f5f61b7465a9167bb1b3d80c77566135307a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 18 Mar 2022 12:28:39 +0000 Subject: [PATCH 32/58] Build changes for WCOSS Dell --- modulefiles/modulefile.ProdGSI.wcoss_d | 8 ++++---- ush/build_all_cmake.sh | 4 ++++ util/CMakeLists.txt | 8 ++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.wcoss_d b/modulefiles/modulefile.ProdGSI.wcoss_d index 5c2e32521e..2596255906 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_d +++ b/modulefiles/modulefile.ProdGSI.wcoss_d @@ -11,9 +11,6 @@ setenv CRTM_FIX /gpfs/dell1/nco/ops/nwprod/lib/crtm/v2.3.0/fix -# Load cmake -module load cmake/3.16.2 - # Load python module load python/3.6.3 @@ -21,6 +18,9 @@ module load python/3.6.3 module use /usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack module load hpc/1.1.0 +# Load cmake +module load cmake/3.20.0 + # Load pe environment module load lsf/10.1 @@ -34,7 +34,7 @@ module load zlib/1.2.11 module load png/1.6.35 # Load HDF5 and netcdf -module load hdf5/1.10.6 +#module load hdf5/1.10.6 module load netcdf/4.7.4 # Load nceplibs diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index 4cd3838f59..50301224d7 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -104,6 +104,7 @@ else module purge source $dir_modules/modulefile.ProdGSI.$target fi +module list set -x cmake_opts="" @@ -118,6 +119,9 @@ cmake_opts+=" -DCMAKE_INSTALL_BINDIR=exec" # By default; build the global applications cmake_opts+=" -DGSI_MODE=GFS -DENKF_MODE=GFS" +# Build utilities: +cmake_opts+=" -DBUILD_COV_CALC=ON -DBUILD_ENKF_GFS=ON -DBUILD_EFSOI_UTIL=ON" + # Valid combination of applications are: # Global : -DGSI_MODE=GFS -DENKF_MODE=GFS # Regional: -DGSI_MODE=Regional -DENKF_MODE=WRF|NMMB|FV3REG diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index a74f18933e..9d61ea617b 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -73,15 +73,11 @@ if(NOT TARGET ncdiag) find_package(ncdiag QUIET) endif() -if(TARGET gsi) - get_target_property(GSI_MODE gsi "MODE") -else() +if(NOT TARGET gsi) find_package(gsi QUIET) endif() -if(TARGET enkf) - get_target_property(ENKF_MODE enkf "MODE") -else() +if(NOT TARGET enkf) find_package(enkf QUIET) endif() From e780f863956111b43daf96d6f2d313078c66e122 Mon Sep 17 00:00:00 2001 From: MichaelLueken-NOAA <63728921+MichaelLueken-NOAA@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:10:05 -0400 Subject: [PATCH 33/58] Make necessary changes to allow feature/cmake-refactor to run regression tests: (#1) Changes from @MichaelLueken-NOAA on setting up offline regression testing. --- regression/multi_regression.sh | 4 ++-- regression/regression_var.out | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 regression/regression_var.out diff --git a/regression/multi_regression.sh b/regression/multi_regression.sh index da6fcb8d46..106bfcf3ad 100755 --- a/regression/multi_regression.sh +++ b/regression/multi_regression.sh @@ -34,14 +34,14 @@ regtests_debug="global_T62 netcdf_fv3_regional hwrf_nmm_d2 hwrf_nmm_d3 + rtma + global_enkf_T62 global_C96_fv3aero global_C96_fv3aerorad" # Choose which regression test to run; by default, run all regtests=${1:-$regtests_all} -echo "`pwd`/regression_var.sh" > regression_var.out - for regtest in $regtests; do rm -f ${regtest}.out echo "Launching regression test: $regtest" diff --git a/regression/regression_var.out b/regression/regression_var.out new file mode 100644 index 0000000000..aee78a93a2 --- /dev/null +++ b/regression/regression_var.out @@ -0,0 +1 @@ +/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/regression/regression_var.sh WCOSS_D /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/.. /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/build /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/install/exec/gsi.x /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/install/exec/enkf.x /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin/gsi.x /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin/enkf_gfs.x 1 From 1502f2e6b8f6f55761b8e62c2b256fa3d7c13691 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 25 Mar 2022 19:44:18 -0400 Subject: [PATCH 34/58] Build conventional monitoring utilities. There is a lot of repeated code in these and could benefit from making a library rather than copy/paste of the same code for each utility. --- util/CMakeLists.txt | 13 +-- util/Conventional_Monitor/CMakeLists.txt | 107 +----------------- .../image_gen/CMakeLists.txt | 1 + .../image_gen/exec/.gitignore | 2 - .../image_gen/sorc/CMakeLists.txt | 5 + .../sorc/conmon_read_ps_IG.fd/CMakeLists.txt | 36 ++++-- .../sorc/conmon_read_ps_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_pw_IG.fd/CMakeLists.txt | 39 +++++-- .../sorc/conmon_read_pw_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_q_IG.fd/CMakeLists.txt | 39 +++++-- .../sorc/conmon_read_q_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_t_IG.fd/CMakeLists.txt | 39 +++++-- .../sorc/conmon_read_t_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_uv_IG.fd/CMakeLists.txt | 40 +++++-- .../sorc/conmon_read_uv_IG.fd/convinfo.f90 | 2 +- .../nwprod/CMakeLists.txt | 1 + .../nwprod/conmon_shared/CMakeLists.txt | 1 + .../nwprod/conmon_shared/exec/.gitignore | 2 - .../conmon_shared/modulefiles/cray/CMonBuild | 21 ---- .../conmon_shared/modulefiles/theia/CMonBuild | 17 --- .../conmon_shared/modulefiles/wcoss/CMonBuild | 18 --- .../nwprod/conmon_shared/sorc/CMakeLists.txt | 6 + .../sorc/conmon_grads_lev.fd/CMakeLists.txt | 39 ++++--- .../conmon_grads_lev.fd/conmon_read_diag.F90 | 42 +++---- .../sorc/conmon_grads_lev.fd/grads_lev.f90 | 2 +- .../conmon_grads_mandlev.fd/CMakeLists.txt | 41 ++++--- .../conmon_read_diag.F90 | 42 +++---- .../conmon_grads_mandlev.fd/grads_mandlev.f90 | 5 +- .../sorc/conmon_grads_sfc.fd/CMakeLists.txt | 41 ++++--- .../conmon_grads_sfc.fd/conmon_read_diag.F90 | 42 +++---- .../sorc/conmon_grads_sfc.fd/grads_sfc.f90 | 2 +- .../conmon_grads_sfctime.fd/CMakeLists.txt | 52 +++++---- .../conmon_read_diag.F90 | 42 +++---- .../conmon_grads_sfctime.fd/grads_sfctime.f90 | 74 ++++++------ .../sorc/conmon_grads_sig.fd/CMakeLists.txt | 43 ++++--- .../conmon_grads_sig.fd/conmon_read_diag.F90 | 42 +++---- .../sorc/conmon_grads_sig.fd/grads_sig.f90 | 56 ++++----- .../sorc/conmon_time.fd/CMakeLists.txt | 44 ++++--- .../sorc/conmon_time.fd/conmon_read_diag.F90 | 42 +++---- .../sorc/conmon_time.fd/process_time_data.f90 | 10 +- 40 files changed, 530 insertions(+), 528 deletions(-) create mode 100644 util/Conventional_Monitor/image_gen/CMakeLists.txt delete mode 100644 util/Conventional_Monitor/image_gen/exec/.gitignore create mode 100644 util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt create mode 100644 util/Conventional_Monitor/nwprod/CMakeLists.txt create mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild create mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 9d61ea617b..f6833f47de 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -129,18 +129,17 @@ if(BUILD_BKGERR_UTIL) add_subdirectory(NMC_Bkerror) endif() -add_subdirectory(FOV_utilities) -add_subdirectory(Single_Observation) -add_subdirectory(ndate) -add_subdirectory(zero_biascoeff) - if(BUILD_MON_UTIL) - message(FATAL_ERROR "CMake in the Monitoring utilities have not been updated") -# add_subdirectory(Conventional_Monitor) + add_subdirectory(Conventional_Monitor) # add_subdirectory(Ozone_Monitor) # add_subdirectory(Radiance_Monitor) endif() +add_subdirectory(FOV_utilities) +add_subdirectory(Single_Observation) +add_subdirectory(ndate) +add_subdirectory(zero_biascoeff) + # These utilities do not have CMake builds and are unlikely used or usable #add_subdirectory(Config) #add_subdirectory(GEN_BE_V2.0) diff --git a/util/Conventional_Monitor/CMakeLists.txt b/util/Conventional_Monitor/CMakeLists.txt index 9b66fa9a7e..9767e0cb3c 100644 --- a/util/Conventional_Monitor/CMakeLists.txt +++ b/util/Conventional_Monitor/CMakeLists.txt @@ -1,105 +1,2 @@ -cmake_minimum_required(VERSION 2.8) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - - cmake_policy(SET CMP0009 NEW) - cmake_policy(SET CMP0054 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") - - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( W3NCO ) - - set (CMAKE_Fortran_INC_FLAGS "-I ./ -I ${CORE_INCS} -I ${NETCDF_INCLUDE_DIRS} ") - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -endif() - -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_lev.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sfc.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sig.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_time.fd) -add_subdirectory(image_gen/sorc/conmon_read_ps_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_pw_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_q_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_t_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_uv_IG.fd) +add_subdirectory(nwprod) +add_subdirectory(image_gen) diff --git a/util/Conventional_Monitor/image_gen/CMakeLists.txt b/util/Conventional_Monitor/image_gen/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Conventional_Monitor/image_gen/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Conventional_Monitor/image_gen/exec/.gitignore b/util/Conventional_Monitor/image_gen/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Conventional_Monitor/image_gen/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt new file mode 100644 index 0000000000..3029d34e02 --- /dev/null +++ b/util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(conmon_read_ps_IG.fd) +add_subdirectory(conmon_read_pw_IG.fd) +add_subdirectory(conmon_read_q_IG.fd) +add_subdirectory(conmon_read_t_IG.fd) +add_subdirectory(conmon_read_uv_IG.fd) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt index fd28c786f1..723322320a 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt @@ -1,15 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_PS_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_PS_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_PS_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_PS_IG_Fortran_FLAGS} ) - add_executable(conmon_read_ps_IG.x ${CONMON_READ_PS_IG_SRC} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_target_properties( conmon_read_ps_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_PS_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_ps.f90 + read_ps.f90 + read_ps_mor.f90 + rm_dups.f90 +) - target_link_libraries( conmon_read_ps_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_ps_IG.x ${W3NCO_4_LIBRARY} ) - endif() +add_executable(conmon_read_ps_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_ps_IG.x ncdiag) +endif() +target_compile_definitions(conmon_read_ps_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_ps_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_ps_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_ps_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_ps_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_ps_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt index b3e1a7be2e..0c7ccc2202 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_PW_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_PW_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_PW_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_PW_IG_Fortran_FLAGS} ) - add_executable(conmon_read_pw_IG.x ${CONMON_READ_PW_IG_SRC} ) - set_target_properties( conmon_read_pw_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_PW_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_pw_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_pw_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_pw.f90 + read_pw.f90 + read_pw_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_pw_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_pw_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_pw_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_pw_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_pw_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_pw_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_pw_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_pw_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt index c5c45259bb..4d5496df06 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_Q_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_Q_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_Q_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_Q_IG_Fortran_FLAGS} ) - add_executable(conmon_read_q_IG.x ${CONMON_READ_Q_IG_SRC} ) - set_target_properties( conmon_read_q_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_Q_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_q_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_q_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_q.f90 + read_q.f90 + read_q_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_q_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_q_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_q_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_q_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_q_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_q_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_q_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_q_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt index 9ae4052a0a..0e57ee9f63 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_T_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_T_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_T_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_T_IG_Fortran_FLAGS} ) - add_executable(conmon_read_t_IG.x ${CONMON_READ_T_IG_SRC} ) - set_target_properties( conmon_read_t_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_T_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_t_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_t_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_t.f90 + read_t.f90 + read_t_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_t_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_t_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_t_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_t_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_t_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_t_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_t_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_t_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt index e74138958c..5120d849ca 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt @@ -1,12 +1,30 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_UV_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_UV_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_UV_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_UV_IG_Fortran_FLAGS} ) - add_executable(conmon_read_uv_IG.x ${CONMON_READ_UV_IG_SRC} ) - set_target_properties( conmon_read_uv_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_UV_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_uv_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_uv_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + histgramuv.f90 + mainread_uv.f90 + read_uv.f90 + read_uv_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_uv_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_uv_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_uv_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_uv_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_uv_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_uv_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_uv_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_uv_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/nwprod/CMakeLists.txt b/util/Conventional_Monitor/nwprod/CMakeLists.txt new file mode 100644 index 0000000000..11bdb4b87c --- /dev/null +++ b/util/Conventional_Monitor/nwprod/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(conmon_shared) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore b/util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild b/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild deleted file mode 100644 index 0dfad2c3b1..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild +++ /dev/null @@ -1,21 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS cmon build" -} - -module-whatis "Set environment variables for WCOSS cmon build" - - -module load intel -module load w3nco-intel - -set ver 2.0.4 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" -setenv CHECK_LIBS "/gpfs/hps/nco/ops/nwprod/spa_util/check_libs.bash" - - diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild b/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild deleted file mode 100644 index 29b99fa3c7..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild +++ /dev/null @@ -1,17 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for THEIA cmon build" -} - -module-whatis "Set environment variables for THEIA cmon build" - -module load intel - -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" - -setenv W3NCO_LIB4 "-L/scratch3/NCEPDEV/nwprod/lib -lw3nco_4" diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild b/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild deleted file mode 100644 index ff2d51fb86..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS cmon build" -} - -module-whatis "Set environment variables for WCOSS cmon build" - -set ver 2.0.4 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" -setenv CHECK_LIBS "/nwprod/spa_util/check_libs.bash" -module load ics -module load w3nco - diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt new file mode 100644 index 0000000000..33eafda0c8 --- /dev/null +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(conmon_grads_lev.fd) +add_subdirectory(conmon_grads_mandlev.fd) +add_subdirectory(conmon_grads_sfc.fd) +add_subdirectory(conmon_grads_sfctime.fd) +add_subdirectory(conmon_grads_sig.fd) +add_subdirectory(conmon_time.fd) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt index 4dd79690f4..d53b99c4a8 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt @@ -1,19 +1,30 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_GRADS_LEV_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_LEV_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_lev ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_LEV_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_LEV_Fortran_FLAGS} ) - add_executable(conmon_grads_lev.x ${CONMON_GRADS_LEV_SRC} ) - set_target_properties( conmon_grads_lev.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_LEV_Fortran_FLAGS} ) - set_target_properties( conmon_grads_lev.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_lev.f90 + kinds.F90 + maingrads_lev.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) +add_executable(conmon_grads_lev.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_lev.x ncdiag) +endif() - target_link_libraries( conmon_grads_lev.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +target_compile_definitions(conmon_grads_lev.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_lev.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_lev.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_lev.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_lev.x PRIVATE w3emc::w3emc_4) - if(BUILD_W3NCO) - add_dependencies( conmon_grads_lev.x ${W3NCO_4_LIBRARY} ) - endif() +# Install executable targets +install(TARGETS conmon_grads_lev.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 index c537af29aa..04ae4668bd 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 @@ -73,7 +73,7 @@ subroutine grads_lev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt index 5184f30514..916b99ce6e 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt @@ -1,19 +1,30 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_GRADS_MANDLEV_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_MANDLEV_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_mandlev ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_MANDLEV_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_MANDLEV_Fortran_FLAGS} ) - add_executable(conmon_grads_mandlev.x ${CONMON_GRADS_MANDLEV_SRC} ) - set_target_properties( conmon_grads_mandlev.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_MANDLEV_Fortran_FLAGS} ) - set_target_properties( conmon_grads_mandlev.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_mandlev.f90 + kinds.F90 + maingrads_mandlev.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_grads_mandlev.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +add_executable(conmon_grads_mandlev.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_mandlev.x ncdiag) +endif() - if(BUILD_W3NCO) - add_dependencies( conmon_grads_mandlev.x ${W3NCO_4_LIBRARY} ) - endif() +target_compile_definitions(conmon_grads_mandlev.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_mandlev.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_mandlev.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_mandlev.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_mandlev.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_mandlev.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 index 00542bd878..68a63ea3a1 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 @@ -28,6 +28,7 @@ subroutine grads_mandlev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& real(4) rlat,rlon,rp character(3) subtype,run character(8) stid + integer ifileo character(ifileo) :: fileo character(30) :: files,filegrads character(8) :: stidend @@ -35,7 +36,7 @@ subroutine grads_mandlev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& real*4 :: rtim,xlat0,xlon0 character(30) :: filein, file_nobs - integer :: ifileo,i,j,ii,k,nreal_m2,ctr,obs_ctr + integer :: i,j,ii,k,nreal_m2,ctr,obs_ctr integer :: ilat,ilon,ipres,itime,iweight,ndup integer(4) :: isubtype @@ -66,7 +67,7 @@ subroutine grads_mandlev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt index 40641e359a..1535bd6813 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt @@ -1,17 +1,30 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_GRADS_SFC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_SFC_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_sfc ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_SFC_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFC_Fortran_FLAGS} ) - add_executable(conmon_grads_sfc.x ${CONMON_GRADS_SFC_SRC} ) - set_target_properties( conmon_grads_sfc.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFC_Fortran_FLAGS} ) - set_target_properties( conmon_grads_sfc.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_sfc.f90 + kinds.F90 + maingrads_sfc.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_grads_sfc.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_grads_sfc.x ${W3NCO_4_LIBRARY} ) - endif() +add_executable(conmon_grads_sfc.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_sfc.x ncdiag) +endif() + +target_compile_definitions(conmon_grads_sfc.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_sfc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_sfc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_sfc.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_sfc.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_sfc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 index a6a005cf25..acec4a60d9 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 @@ -56,7 +56,7 @@ subroutine grads_sfc(fileo,ifileo,nobs,nreal,iscater,igrads,isubtype,subtype,lis obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt index 71e1356662..c01c38b0f7 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt @@ -1,24 +1,30 @@ -cmake_minimum_required(VERSION 2.6) - - file(GLOB CONMON_GRADS_SFCTIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - - set(CONMON_GRADS_SFCTIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_sfctime ) - - set_source_files_properties( ${CONMON_GRADS_SFCTIME_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFCTIME_Fortran_FLAGS} ) - - add_executable(conmon_grads_sfctime.x ${CONMON_GRADS_SFCTIME_SRC} ) - - set_target_properties( conmon_grads_sfctime.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFCTIME_Fortran_FLAGS} ) - set_target_properties( conmon_grads_sfctime.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_grads_sfctime.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - - if(BUILD_W3NCO) - add_dependencies( conmon_grads_sfctime.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_sfctime.f90 + kinds.F90 + maingrads_sfctime.f90 + rm_dups.f90 +) + +add_executable(conmon_grads_sfctime.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_sfctime.x ncdiag) +endif() + +target_compile_definitions(conmon_grads_sfctime.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_sfctime.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_sfctime.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_sfctime.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_sfctime.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_sfctime.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 index 4f52806b66..c306eab118 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 @@ -1,7 +1,7 @@ !--------------------------------------------------------------------------------- ! grads_sfctime ! -! Read in data from the .tmp file, arrange by level and write into +! Read in data from the .tmp file, arrange by level and write into ! the GrADS data files (one for scatter plots, and one for horizontal plots) ! depending on the iscater and igrads parameters. !--------------------------------------------------------------------------------- @@ -13,7 +13,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& use data implicit none - + type(list_node_t), pointer :: list type(list_node_t), pointer :: next => null() type(data_ptr) :: ptr @@ -31,8 +31,8 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& integer,dimension(nlev) :: ndata !----------------------------------------------------------------------------- - ! The tobs, rlat, rlon, stid variables were all originally dimensioned to - ! arrays of 10000 (tobs 2nd dimension, all others are 1-d arrays). This is + ! The tobs, rlat, rlon, stid variables were all originally dimensioned to + ! arrays of 10000 (tobs 2nd dimension, all others are 1-d arrays). This is ! dangerous because hard limits are essentially time bombs, and exceeding ! them results in a seg fault. ! @@ -42,10 +42,10 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& ! determined to be in the cnvstat for the input type and subtype. So it's ! not logically possible that the necessary dimension for these variables ! will exceed the input nobs value. Indeed in my tests the resulting used - ! portion of the dimension is 25%-35% of the nobs value, once duplicates and - ! data that does not conform to the available pressure levels are tossed out. - ! So it makes more sense to dynamically allocate these vars to the value of - ! nobs rather than arbitrarily select 10000 and find out the hard way that + ! portion of the dimension is 25%-35% of the nobs value, once duplicates and + ! data that does not conform to the available pressure levels are tossed out. + ! So it makes more sense to dynamically allocate these vars to the value of + ! nobs rather than arbitrarily select 10000 and find out the hard way that ! that was insufficient. real(4),allocatable,dimension(:,:,:) :: tobs @@ -57,7 +57,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& integer :: nlfag,nflag0,nlev0,getlev real(4) :: rmiss,rtim,xlat0,xlon0,rtime integer :: first, second - + integer nt,k,i,ii,j,nflag,obs_ctr integer ilat,ilon,ipres,itime,iweight,ndup @@ -67,13 +67,13 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& print *, '---> grads_sfctime' ndata=0 - if( nobs > 0 ) then + if( nobs > 0 ) then print *,'fileo =',fileo print *,'nobs =',nobs print *,'nreal = ', nreal allocate( tobs(nreal-4,nobs,nlev) ) - tobs = rmiss + tobs = rmiss allocate( rlat(nobs) ) allocate( rlon(nobs) ) @@ -91,7 +91,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -119,10 +119,10 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& print *, 'end scatter file generation' - if( igrads == 1 ) then + if( igrads == 1 ) then filegrads=trim(fileo)//'_'//trim(subtype)//'.grads.'//trim(run) - open(21,file=filegrads,form='unformatted',status='new') ! open output file + open(21,file=filegrads,form='unformatted',status='new') ! open output file print *, 'filegrads = ', filegrads ilat = idx_obs_lat -2 ! modified position of lat @@ -132,13 +132,13 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& iweight = idx_rwgt -2 ! modofied position of weight !-------------------------------- - ! remove duplicate data + ! remove duplicate data ! call rm_dups( rdiag_m2,nobs,nreal-2,ilat,ilon,ipres,itime,iweight,ndup ) !------------------------------------------------------------------------ - ! As best I can tell this section is functioning as intended, which I + ! As best I can tell this section is functioning as intended, which I ! also assume to be correct. I made no changes to the logic though I did ! change rdiag to rdiag_m2 to make it more clear that this process is ! shaving off the first 2 rdiag values (lat & lon). @@ -146,9 +146,9 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& ! It's a white-hot mess but the intent is to group the same station's data ! in the tobs (:,:,:) array and keep the middle dimension in sync with the ! rlat(:), rlon(:), and stid(:) arrays. I insterted a whole bunch of - ! diagnostics and that appears to be working correctly. I question the - ! location of the ii incrementation, but tobs is set to rmiss so any gaps - ! (and there are some) should come out as rmiss. + ! diagnostics and that appears to be working correctly. I question the + ! location of the ii incrementation, but tobs is set to rmiss so any gaps + ! (and there are some) should come out as rmiss. ! ii=0 do i=1,nobs @@ -162,7 +162,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& k=getlev( rtime,plev,nlev ) if(k /=0) then - tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,i) + tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,i) ndata(k)=ndata(k)+1 endif @@ -174,18 +174,18 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& rtime=rdiag_m2(itime,j) k=getlev( rtime,plev,nlev ) - + if(k /=0) then - tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,j) + tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,j) rdiag_m2(iweight,j)=-rdiag_m2(iweight,j) ndata(k)=ndata(k)+1 endif endif enddo - endif + endif enddo - + print *,'final ii, nobs =',ii,nobs ! ################################################################################ @@ -201,23 +201,23 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& ! the data file, reducing the output data file size by ~90%, and always ! using an nt value of 1 in the GrADS scripts. Simple is better. ! - ! NOTE Further: Per Su the idea behind the nlev arrangment is + ! NOTE Further: Per Su the idea behind the nlev arrangment is ! "... I try to plot the point which close to analysis time. There - ! are multiple observations (every 30 minutes or every hour) for the six + ! are multiple observations (every 30 minutes or every hour) for the six ! hour window (-3.0 to 3.0 relative to analysis time), so I divided time ! -2.5,-2.0,-1.5,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0,2.5." ! ! Generally I see that the nt ends up as either 1 or 6. Either way ! things can be simplified by writing only the nt step data into the ! output file, not creating the nt_{type}_00.yyyymmddcc file at all, - ! and always sending GrADS a nt value of 1. + ! and always sending GrADS a nt value of 1. ! ################################################################################ - + nt=maxloc(ndata,dim=1) - k=nt + k=nt print *, 'using ndata max value of nt = ', nt - + nflag=1 rtim=0.0 nlev0=1 @@ -236,8 +236,8 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& xlon0=0.0 nflag0=0 stidend=' ' - write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 - + write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 + close(21) print *, 'wrote ii tobs to file ', ii @@ -256,7 +256,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& end if print *, '<--- grads_sfctime' - return + return end @@ -269,7 +269,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& function getlev( p1,plev,nlevs ) implicit none - + real*4 p1 real*4,dimension(nlevs) :: plev integer getlev,ii,nlevs @@ -279,11 +279,11 @@ function getlev( p1,plev,nlevs ) do ii=1,nlevs if(p1 <= plev(ii)) then getlev=ii - return + return endif enddo - return + return end - + diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt index c989043c7a..42f1367e65 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt @@ -1,19 +1,32 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_GRADS_SIG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_SIG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_sig ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_SIG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SIG_Fortran_FLAGS} ) - add_executable(conmon_grads_sig.x ${CONMON_GRADS_SIG_SRC} ) - set_target_properties( conmon_grads_sig.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SIG_Fortran_FLAGS} ) - set_target_properties( conmon_grads_sig.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_sig.f90 + kinds.F90 + maingrads_sig.f90 + read_conv2grads.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_grads_sig.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +add_executable(conmon_grads_sig.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_sig.x ncdiag) +endif() + +target_compile_definitions(conmon_grads_sig.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_sig.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_sig.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_sig.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_sig.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_sig.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - if(BUILD_W3NCO) - add_dependencies( conmon_grads_sig.x ${W3NCO_4_LIBRARY} ) - endif() diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 index b07dc632a3..3b4561e838 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 @@ -1,7 +1,7 @@ !----------------------------------------------------------- ! grads_sig ! -! Read uv data from the .tmp file and write it to the +! Read uv data from the .tmp file and write it to the ! scatter and horiz GrADS data files. !----------------------------------------------------------- @@ -14,9 +14,9 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s type(list_node_t), pointer :: list type(list_node_t), pointer :: next => null() - type(data_ptr) :: ptr + type(data_ptr) :: ptr - integer ifileo + integer ifileo real(4),allocatable,dimension(:,:) :: rdiag_m2 character(8),allocatable,dimension(:) :: cdiag real(4),dimension(nlev) :: plev @@ -31,7 +31,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s real(4) :: rtim,xlat0,xlon0 integer(4):: isubtype,ctr,nreal_m2 integer i,j,k,ilat,ilon,ipres,itime,iweight,ndup,nflag - + stdid=' ' nflag0=0 @@ -39,20 +39,20 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s xlat0=0.0 xlon0=0.0 nlev0=0 - + print *, '--> BEGIN grads_sig.x' - print *, ' ' + print *, ' ' print *, 'inputs to grads_sig.x =' print *, 'fileo = ',fileo print *, 'ifileo = ',ifileo print *, 'nobs = ',nobs print *, 'nreal = ',nreal - print *, 'nlev = ',nlev - print *, 'plev = ',plev - print *, 'iscater = ',iscater - print *, 'igrads = ',igrads - print *, 'isubtype = ',isubtype - print *, 'subtype = ',subtype + print *, 'nlev = ',nlev + print *, 'plev = ',plev + print *, 'iscater = ',iscater + print *, 'igrads = ',igrads + print *, 'isubtype = ',isubtype + print *, 'subtype = ',subtype if( nobs > 0 ) then @@ -70,7 +70,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -109,7 +109,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ! write horiz grads data file and avoid trying ! to write output if nobs == 0. Seg faults are uncool. ! - if (igrads ==1 .AND. nobs > 0) then + if (igrads ==1 .AND. nobs > 0) then filegrads=trim(fileo)//'_'//trim(subtype)//'.grads.'//trim(run) open(21,file=filegrads,form='unformatted',status='new') ! open output file @@ -117,13 +117,13 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ilon = idx_obs_lon -2 ! modified position of lon ipres = idx_pres -2 ! modified position of pressure itime = idx_time -2 ! modified position of relative time - iweight = idx_rwgt -2 ! modofied position of weight + iweight = idx_rwgt -2 ! modofied position of weight !------------------------------------------ ! rm duplicate data ! call rm_dups( rdiag_m2,nobs,nreal_m2,ilat,ilon,ipres,itime,iweight,ndup ) - + ctr=0 do i=1,nobs if(rdiag_m2(iweight,i) >0.0 ) then @@ -140,18 +140,18 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ! note this writes the rdiag_m2 record starting at station ! elevation; lat and lon are written in the line above with the ! station id info - write(21) plev(k),rdiag_m2(3:nreal_m2,i) + write(21) plev(k),rdiag_m2(3:nreal_m2,i) ctr = ctr + 1 - endif + endif endif enddo - + !-------------------------- ! write EOF marker stidend=' ' - write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 - + write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 + close(21) print *, 'num recs written to GrADS file = ', ctr @@ -170,7 +170,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s print *, 'exiting grads_sig, nobs = ', nobs end if - return + return end @@ -179,11 +179,11 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ! ! Determines appropriate match of p1 value to plev array. ! -! Note that values within +/- 5 of a specific plev array -! are determined to be a match. +! Note that values within +/- 5 of a specific plev array +! are determined to be a match. !============================================================ function getpro(p1,plev,nlevs) - + implicit none real*4 p1 @@ -196,14 +196,14 @@ function getpro(p1,plev,nlevs) do ii=1,nlevs np=int(plev(ii)) dp=abs(ip-np) - + if(dp <=5) then getpro=ii return endif enddo - return + return end - + diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt index 627129f2db..41d0d74928 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt @@ -1,19 +1,33 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_time ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_TIME_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_TIME_Fortran_FLAGS} ) - add_executable(conmon_time.x ${CONMON_TIME_SRC} ) - set_target_properties( conmon_time.x PROPERTIES COMPILE_FLAGS ${CONMON_TIME_Fortran_FLAGS} ) - set_target_properties( conmon_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + convinfo2.f90 + data_mod.f90 + generic_list.f90 + kinds.F90 + mainconv_time.f90 + process_time_data.f90 + stas2ctl.f90 + stas_time.f90 + stas_time_gps.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_time.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +add_executable(conmon_time.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_time.x ncdiag) +endif() - if(BUILD_W3NCO) - add_dependencies( conmon_time.x ${W3NCO_4_LIBRARY} ) - endif() +target_compile_definitions(conmon_time.x PRIVATE "_REAL8_") +target_link_libraries(conmon_time.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_time.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_time.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 index bc7c6ae5ec..68a4701b99 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 @@ -315,7 +315,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case ps' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -340,7 +340,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case q' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -365,7 +365,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case t' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -389,7 +389,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case uv' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -412,7 +412,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & case ( 'gps' ) print *, ' select, case gps' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) From 3db55b6acc9d9a6015e48e4a21bee29834245395 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 26 Mar 2022 14:42:19 -0400 Subject: [PATCH 35/58] Build Radiance and Ozone monitoring utilities. There is a lot of repeated code in these and could benefit from making a library rather than copy/paste of the same code for each utility. --- util/CMakeLists.txt | 4 +- util/Conventional_Monitor/CMakeLists.txt | 2 +- util/Ozone_Monitor/CMakeLists.txt | 97 +--------------- util/Ozone_Monitor/data_xtrct/CMakeLists.txt | 1 + util/Ozone_Monitor/data_xtrct/exec/.gitignore | 2 - .../data_xtrct/sorc/CMakeLists.txt | 1 + .../sorc/make_base.fd/CMakeLists.txt | 28 ++--- .../data_xtrct/sorc/make_base.fd/makefile | 44 -------- util/Ozone_Monitor/nwprod/CMakeLists.txt | 1 + .../nwprod/oznmon_shared/CMakeLists.txt | 1 + .../nwprod/oznmon_shared/exec/.gitignore | 2 - .../modulefiles/cray/OznMonBuild | 18 --- .../modulefiles/dell/OznMonBuild | 18 --- .../modulefiles/theia/OznMonBuild | 20 ---- .../modulefiles/wcoss/OznMonBuild | 18 --- .../nwprod/oznmon_shared/sorc/CMakeLists.txt | 2 + .../sorc/oznmon_horiz.fd/CMakeLists.txt | 39 ++++--- .../sorc/oznmon_horiz.fd/oznmon_read_diag.f90 | 4 +- .../sorc/oznmon_time.fd/CMakeLists.txt | 41 ++++--- .../sorc/oznmon_time.fd/oznmon_read_diag.f90 | 4 +- .../sorc/oznmon_time.fd/time.f90 | 6 +- util/Radiance_Monitor/CMakeLists.txt | 106 +----------------- .../data_extract/CMakeLists.txt | 1 + .../data_extract/exec/.gitignore | 2 - .../data_extract/sorc/CMakeLists.txt | 2 + .../sorc/radmon_mk_base.fd/CMakeLists.txt | 28 ++--- .../sorc/radmon_mk_base.fd/makefile | 44 -------- .../sorc/radmon_validate_tm.fd/CMakeLists.txt | 34 +++--- .../sorc/radmon_validate_tm.fd/makefile | 62 ---------- .../Radiance_Monitor/image_gen/CMakeLists.txt | 1 + .../image_gen/exec/.gitignore | 2 - .../image_gen/src/CMakeLists.txt | 5 + .../src/radmon_ig_angle.fd/CMakeLists.txt | 31 ++--- .../src/radmon_ig_angle.fd/angle.f90 | 2 +- .../src/radmon_ig_bcoef.fd/CMakeLists.txt | 31 ++--- .../src/radmon_ig_bcoef.fd/bcoef.f90 | 6 +- .../src/radmon_ig_horiz.fd/CMakeLists.txt | 41 ++++--- .../src/radmon_ig_summary.fd/CMakeLists.txt | 31 ++--- .../src/radmon_ig_summary.fd/summary.f90 | 6 +- .../src/radmon_ig_time.fd/CMakeLists.txt | 31 ++--- .../image_gen/src/radmon_ig_time.fd/time.f90 | 6 +- util/Radiance_Monitor/nwprod/CMakeLists.txt | 1 + .../nwprod/radmon_shared/CMakeLists.txt | 1 + .../nwprod/radmon_shared/sorc/CMakeLists.txt | 4 + .../sorc/verf_radang.fd/CMakeLists.txt | 40 ++++--- .../sorc/verf_radbcoef.fd/CMakeLists.txt | 40 ++++--- .../sorc/verf_radbcor.fd/CMakeLists.txt | 41 ++++--- .../sorc/verf_radtime.fd/CMakeLists.txt | 44 +++++--- 48 files changed, 367 insertions(+), 629 deletions(-) create mode 100644 util/Ozone_Monitor/data_xtrct/CMakeLists.txt delete mode 100644 util/Ozone_Monitor/data_xtrct/exec/.gitignore create mode 100644 util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt delete mode 100755 util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile create mode 100644 util/Ozone_Monitor/nwprod/CMakeLists.txt create mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild create mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt create mode 100644 util/Radiance_Monitor/data_extract/CMakeLists.txt delete mode 100644 util/Radiance_Monitor/data_extract/exec/.gitignore create mode 100644 util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt delete mode 100755 util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile delete mode 100755 util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile create mode 100644 util/Radiance_Monitor/image_gen/CMakeLists.txt delete mode 100644 util/Radiance_Monitor/image_gen/exec/.gitignore create mode 100644 util/Radiance_Monitor/image_gen/src/CMakeLists.txt create mode 100644 util/Radiance_Monitor/nwprod/CMakeLists.txt create mode 100644 util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt create mode 100644 util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index f6833f47de..99c6335daa 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -131,8 +131,8 @@ endif() if(BUILD_MON_UTIL) add_subdirectory(Conventional_Monitor) -# add_subdirectory(Ozone_Monitor) -# add_subdirectory(Radiance_Monitor) + add_subdirectory(Ozone_Monitor) + add_subdirectory(Radiance_Monitor) endif() add_subdirectory(FOV_utilities) diff --git a/util/Conventional_Monitor/CMakeLists.txt b/util/Conventional_Monitor/CMakeLists.txt index 9767e0cb3c..efeab15bba 100644 --- a/util/Conventional_Monitor/CMakeLists.txt +++ b/util/Conventional_Monitor/CMakeLists.txt @@ -1,2 +1,2 @@ -add_subdirectory(nwprod) add_subdirectory(image_gen) +add_subdirectory(nwprod) diff --git a/util/Ozone_Monitor/CMakeLists.txt b/util/Ozone_Monitor/CMakeLists.txt index 1b4acf7c40..9e3df48cc5 100644 --- a/util/Ozone_Monitor/CMakeLists.txt +++ b/util/Ozone_Monitor/CMakeLists.txt @@ -1,95 +1,2 @@ -cmake_minimum_required(VERSION 2.8) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - - cmake_policy(SET CMP0009 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") - - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package( W3NCO ) - - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -endif() - -add_subdirectory(nwprod/oznmon_shared/sorc/oznmon_horiz.fd) -add_subdirectory(nwprod/oznmon_shared/sorc/oznmon_time.fd) -add_subdirectory(data_xtrct/sorc/make_base.fd) +add_subdirectory(data_xtrct) +add_subdirectory(nwprod) diff --git a/util/Ozone_Monitor/data_xtrct/CMakeLists.txt b/util/Ozone_Monitor/data_xtrct/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Ozone_Monitor/data_xtrct/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Ozone_Monitor/data_xtrct/exec/.gitignore b/util/Ozone_Monitor/data_xtrct/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Ozone_Monitor/data_xtrct/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt b/util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt new file mode 100644 index 0000000000..efe47a7d32 --- /dev/null +++ b/util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(make_base.fd) diff --git a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt b/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt index 68e1da7c6c..ec8490a912 100644 --- a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt +++ b/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt @@ -1,14 +1,16 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB OZNMON_MAKE_BASE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(OZNMON_MAKE_BASE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 ") - set_source_files_properties( ${OZNMON_MAKE_BASE_SRC} PROPERTIES COMPILE_FLAGS ${OZNMON_MAKE_BASE_Fortran_FLAGS} ) - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/oznmon_make_base ) - add_executable(oznmon_make_base.x ${OZNMON_MAKE_BASE_SRC} ) - set_target_properties( oznmon_make_base.x PROPERTIES COMPILE_FLAGS ${OZNMON_MAKE_BASE_Fortran_FLAGS} ) - set_target_properties( oznmon_make_base.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( oznmon_make_base.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( oznmon_make_base.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + make_base.f90 +) + +add_executable(oznmon_make_base.x ${SRCS}) +target_link_libraries(oznmon_make_base.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS oznmon_make_base.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile b/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile deleted file mode 100755 index 292875a047..0000000000 --- a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile +++ /dev/null @@ -1,44 +0,0 @@ -# ***************************************************************** -# makefile -# -# Make the make_base executable. The executable will construct -# base history files for each entry in the SATYPE list from the -# time data files (*.ieee_d) for the specified source (suffix). -# -# This is not normally necessary for RadMon users unless you want -# to use the automated validation mechanism. -# ***************************************************************** - -BINDIR = $(dir_root)/exec - -LIBS = $(W3NCO_LIB4) - -OBJS = make_base.o - -# -# ***************************************************************** -# - -CMD = oznmon_make_base.x - -all: $(CMD) - -clean: - rm -f *.o - rm -f *.mod - rm -f oznmon_make_base.x - -check_prereqs: - /nwprod/spa_util/check_libs.bash $(LIBS) - -install: - cp -f $(CMD) $(BINDIR)/. - -debug: FFLAGS = $(D_FFLAGS) -debug: $(CMD) - -$(CMD): $(OBJS) - $(CF) $(FFLAGS) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS) - -make_base.o : make_base.f90 - $(CF) $(FFLAGS) -c $(*).f90 diff --git a/util/Ozone_Monitor/nwprod/CMakeLists.txt b/util/Ozone_Monitor/nwprod/CMakeLists.txt new file mode 100644 index 0000000000..0fd3ef9eac --- /dev/null +++ b/util/Ozone_Monitor/nwprod/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(oznmon_shared) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore b/util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild deleted file mode 100644 index 94ac5cfdbc..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS(cray) ozmon build" -} - -module-whatis "Set environment variables for WCOSS(cray) ozmon build" - -set ver 2.0.2 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl" - -setenv D_FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -debug" -module load intel -module load w3nco-intel/2.0.6 - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild deleted file mode 100644 index ea48fbadd6..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS(dell) ozmon build" -} - -module-whatis "Set environment variables for WCOSS(dell) ozmon build" - -set ver 2.0.2 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl" - -setenv D_FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -debug" -module load ips/18.0.1.163 -module load w3nco/2.0.6 - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild deleted file mode 100644 index 2b619e9a88..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild +++ /dev/null @@ -1,20 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for THEIA OzoMon build" -} - -module-whatis "Set environment variables for THEIA OzoMon build" - -set ver 2.0.2 - -module load intel - -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" - -setenv W3NCO_LIB4 "-L/scratch3/NCEPDEV/nwprod/lib -lw3nco_4" - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild deleted file mode 100644 index 2c251a0cd9..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS(ibm) ozmon build" -} - -module-whatis "Set environment variables for WCOSS(ibm) ozmon build" - -set ver 2.0.0 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl" - -setenv D_FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -debug" -module load ics -module load w3nco - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt new file mode 100644 index 0000000000..c341723f17 --- /dev/null +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(oznmon_horiz.fd) +add_subdirectory(oznmon_time.fd) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt index fa8c7e459f..3d7e5fb7a1 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt @@ -1,14 +1,27 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB OZNMON_HORIZ_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(OZNMON_HORIZ_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 ") - set_source_files_properties( ${OZNMON_HORIZ_SRC} PROPERTIES COMPILE_FLAGS ${OZNMON_HORIZ_Fortran_FLAGS} ) - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/oznmon_horiz ) - add_executable(oznmon_horiz.x ${OZNMON_HORIZ_SRC} ) - set_target_properties( oznmon_horiz.x PROPERTIES COMPILE_FLAGS ${OZNMON_HORIZ_Fortran_FLAGS} ) - set_target_properties( oznmon_horiz.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( oznmon_horiz.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_W3NCO) - add_dependencies( oznmon_horiz.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + create_ctl_horiz.f90 + horiz.f90 + kinds.f90 + oznmon_read_diag.f90 +) + +add_executable(oznmon_horiz.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(oznmon_horiz.x ncdiag) +endif() + +target_compile_definitions(oznmon_horiz.x PRIVATE "_REAL8_") +target_link_libraries(oznmon_horiz.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(oznmon_horiz.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(oznmon_horiz.x PRIVATE ncdiag::ncdiag) +target_link_libraries(oznmon_horiz.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS oznmon_horiz.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 index 8feb261ca4..7dadde2e87 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 @@ -642,7 +642,7 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext nlevs = header_fix%nlevs - if( ncdiag_open_status(cur_idx)%nc_read == .true. ) then + if( ncdiag_open_status(cur_idx)%nc_read .eqv. .true. ) then iflag = -1 else iflag = 0 @@ -965,7 +965,7 @@ logical function verify_var_name_nc( test_name ) end if end do - if( verify_var_name_nc == .false. ) then + if( verify_var_name_nc .eqv. .false. ) then do k=1,num_vars if( test_name == var_names(k) ) then verify_var_name_nc = .true. diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt index c957a0a243..dd5d973bad 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB OZNMON_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(OZNMON_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/oznmon_time ) - set_source_files_properties( ${OZNMON_TIME_SRC} PROPERTIES COMPILE_FLAGS ${OZNMON_TIME_Fortran_FLAGS} ) - add_executable(oznmon_time.x ${OZNMON_TIME_SRC} ) - set_target_properties( oznmon_time.x PROPERTIES COMPILE_FLAGS ${OZNMON_TIME_Fortran_FLAGS} ) - set_target_properties( oznmon_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( oznmon_time.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_W3NCO) - add_dependencies( oznmon_time.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + create_ctl_time.f90 + kinds.f90 + oznmon_read_diag.f90 + time.f90 + valid.f90 +) + +add_executable(oznmon_time.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(oznmon_time.x ncdiag) +endif() + +target_compile_definitions(oznmon_time.x PRIVATE "_REAL8_") +target_link_libraries(oznmon_time.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(oznmon_time.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(oznmon_time.x PRIVATE ncdiag::ncdiag) +target_link_libraries(oznmon_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS oznmon_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 index 8feb261ca4..7dadde2e87 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 @@ -642,7 +642,7 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext nlevs = header_fix%nlevs - if( ncdiag_open_status(cur_idx)%nc_read == .true. ) then + if( ncdiag_open_status(cur_idx)%nc_read .eqv. .true. ) then iflag = -1 else iflag = 0 @@ -965,7 +965,7 @@ logical function verify_var_name_nc( test_name ) end if end do - if( verify_var_name_nc == .false. ) then + if( verify_var_name_nc .eqv. .false. ) then do k=1,num_vars if( test_name == var_names(k) ) then verify_var_name_nc = .true. diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 index 15d70cbaa2..66d08dba37 100755 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 @@ -329,7 +329,7 @@ program main end do ! Do validation - if( validate == .TRUE. ) then + if( validate .eqv. .TRUE. ) then call load_base( satname, ier ) write(6,*) 'ier from load_base = ', ier @@ -344,7 +344,7 @@ program main do j=1,n_levs if ( use(j,k) > 0.0 ) then - if( validate == .TRUE. .AND. ier >= 0 ) then + if( validate .eqv. .TRUE. .AND. ier >= 0 ) then pbound = 0.00 call validate_penalty( j, k, penalty(j,k), valid_penalty, pbound, iret ) @@ -369,7 +369,7 @@ program main endif end do - if( validate == .TRUE. ) then + if( validate .eqv. .TRUE. ) then close( lupen ) close( lucnt ) endif diff --git a/util/Radiance_Monitor/CMakeLists.txt b/util/Radiance_Monitor/CMakeLists.txt index 1bc451ea68..9c0124048d 100644 --- a/util/Radiance_Monitor/CMakeLists.txt +++ b/util/Radiance_Monitor/CMakeLists.txt @@ -1,103 +1,3 @@ -cmake_minimum_required(VERSION 2.8) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - - cmake_policy(SET CMP0009 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") - - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package( W3NCO ) - - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -endif() - -add_subdirectory(nwprod/radmon_shared/sorc/verf_radang.fd) -add_subdirectory(nwprod/radmon_shared/sorc/verf_radbcoef.fd) -add_subdirectory(nwprod/radmon_shared/sorc/verf_radbcor.fd) -add_subdirectory(nwprod/radmon_shared/sorc/verf_radtime.fd) -add_subdirectory(data_extract/sorc/radmon_mk_base.fd) -add_subdirectory(data_extract/sorc/radmon_validate_tm.fd) -add_subdirectory(image_gen/src/radmon_ig_angle.fd) -add_subdirectory(image_gen/src/radmon_ig_bcoef.fd) -add_subdirectory(image_gen/src/radmon_ig_horiz.fd) -add_subdirectory(image_gen/src/radmon_ig_summary.fd) -add_subdirectory(image_gen/src/radmon_ig_time.fd) +add_subdirectory(data_extract) +add_subdirectory(image_gen) +add_subdirectory(nwprod) diff --git a/util/Radiance_Monitor/data_extract/CMakeLists.txt b/util/Radiance_Monitor/data_extract/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Radiance_Monitor/data_extract/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Radiance_Monitor/data_extract/exec/.gitignore b/util/Radiance_Monitor/data_extract/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Radiance_Monitor/data_extract/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt b/util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt new file mode 100644 index 0000000000..f1f7ac2f14 --- /dev/null +++ b/util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(radmon_mk_base.fd) +add_subdirectory(radmon_validate_tm.fd) diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt b/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt index 7089ff1134..d60ba7d539 100644 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt @@ -1,14 +1,16 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_MK_BASE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_MK_BASE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_mk_base ) - set_source_files_properties( ${RADMON_MK_BASE_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_MK_BASE_Fortran_FLAGS} ) - add_executable(radmon_mk_base.x ${RADMON_MK_BASE_SRC} ) - set_target_properties( radmon_mk_base.x PROPERTIES COMPILE_FLAGS ${RADMON_MK_BASE_Fortran_FLAGS} ) - set_target_properties( radmon_mk_base.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_mk_base.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_mk_base.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + make_base.f90 +) + +add_executable(radmon_make_base.x ${SRCS}) +target_link_libraries(radmon_make_base.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_make_base.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile b/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile deleted file mode 100755 index 05519c047f..0000000000 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile +++ /dev/null @@ -1,44 +0,0 @@ -# ***************************************************************** -# makefile -# -# Make the make_base executable. The executable will construct -# base history files for each entry in the SATYPE list from the -# time data files (*.ieee_d) for the specified source (suffix). -# -# This is not normally necessary for RadMon users unless you want -# to use the automated validation mechanism. -# ***************************************************************** - -BINDIR = ../../exec - -LIBS = $(W3NCO_LIB4) - -OBJS = make_base.o - -# -# ***************************************************************** -# - -CMD = make_base - -all: $(CMD) - -clean: - rm -f *.o - rm -f *.mod - rm -f make_base - -check_prereqs: - /nwprod/spa_util/check_libs.bash $(LIBS) - -install: - cp -f $(CMD) $(BINDIR)/. - -debug: FFLAGS = $(D_FFLAGS) -debug: $(CMD) - -$(CMD): $(OBJS) - $(CF) $(FFLAGS) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS) - -make_base.o : make_base.f90 - $(CF) $(FFLAGS) -c $(*).f90 diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt b/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt index be546a9601..d1f9128c2e 100644 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt @@ -1,14 +1,22 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_VALIDATE_TM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_VALIDATE_TM_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_validate_tm.x ) - set_source_files_properties( ${RADMON_VALIDATE_TM_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_VALIDATE_TM_Fortran_FLAGS} ) - add_executable(radmon_validate_tm.x ${RADMON_VALIDATE_TM_SRC} ) - set_target_properties( radmon_validate_tm.x PROPERTIES COMPILE_FLAGS ${RADMON_VALIDATE_TM_Fortran_FLAGS} ) - set_target_properties( radmon_validate_tm.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_validate_tm.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_validate_tm.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + bad_chan.f90 + bad_penalty.f90 + kinds.F90 + low_count.f90 + valid.f90 + validate_time.f90 +) + +add_executable(radmon_validate_tm.x ${SRCS}) +target_compile_definitions(radmon_validate_tm.x PRIVATE "_REAL8_") +target_link_libraries(radmon_validate_tm.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_validate_tm.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile b/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile deleted file mode 100755 index afd5e05958..0000000000 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile +++ /dev/null @@ -1,62 +0,0 @@ -# ***************************************************************** -# makefile -# -# Make the validate_time.x executable. This is not normally needed -# for normal use. It re-validates data in an extracted *.ieee_d -# file, applying a different set of historic base files in the -# validation. -# -# If needed, run make on this directory and move the executable -# over to the data_extract/exec directory. -# -# ***************************************************************** - -BINDIR = ../../exec - -LIBS = $(W3NCO_LIB4) - -OBJS = kinds.o bad_obs.o bad_penalty.o bad_chan.o valid.o \ - validate_time.o - -# -# ***************************************************************** -# - -CMD = validate_time.x - -all: $(CMD) - -clean: - rm -f *.o - rm -f *.mod - rm -f validate_time.x - -check_prereqs: - /nwprod/spa_util/check_libs.bash $(LIBS) - -install: - cp -f $(CMD) $(BINDIR)/ - -debug: FFLAGS = $(D_FFLAGS) -debug: $(CMD) - -$(CMD): $(OBJS) - $(CF) $(FFLAGS) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS) - -bad_obs.o : bad_obs.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -bad_penalty.o : bad_penalty.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -bad_chan.o : bad_chan.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -valid.o : valid.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -validate_time.o : validate_time.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -kinds.o : kinds.F90 - $(CF) $(FFLAGS) -c $(*).F90 diff --git a/util/Radiance_Monitor/image_gen/CMakeLists.txt b/util/Radiance_Monitor/image_gen/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/Radiance_Monitor/image_gen/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/Radiance_Monitor/image_gen/exec/.gitignore b/util/Radiance_Monitor/image_gen/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Radiance_Monitor/image_gen/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Radiance_Monitor/image_gen/src/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/CMakeLists.txt new file mode 100644 index 0000000000..a54d0f787b --- /dev/null +++ b/util/Radiance_Monitor/image_gen/src/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(radmon_ig_angle.fd) +add_subdirectory(radmon_ig_bcoef.fd) +add_subdirectory(radmon_ig_horiz.fd) +add_subdirectory(radmon_ig_summary.fd) +add_subdirectory(radmon_ig_time.fd) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt index 44fcad0750..ede288d254 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_IG_ANGLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_ANGLE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_angle ) - set_source_files_properties( ${RADMON_IG_ANGLE_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_ANGLE_Fortran_FLAGS} ) - add_executable(radmon_ig_angle.x ${RADMON_IG_ANGLE_SRC} ) - set_target_properties( radmon_ig_angle.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_ANGLE_Fortran_FLAGS} ) - set_target_properties( radmon_ig_angle.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_angle.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_angle.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + angle.f90 + avgsdv.f90 +) + +add_executable(radmon_ig_angle.x ${SRCS}) + +target_compile_definitions(radmon_ig_angle.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_angle.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_angle.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 index 02cced14d7..24e394d694 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 @@ -363,7 +363,7 @@ program angle inquire(file=data_file, exist=exist) write( 6,* ) 'data_file : ', data_file, 'exist = ', exist - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then ! write( 6,* ) 'reading data file: ', data_file open(ldname,file=data_file,form='unformatted') diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt index ca50c08216..f16f518a6f 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_IG_BCOEF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_BCOEF_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_bcoef ) - set_source_files_properties( ${RADMON_IG_BCOEF_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_BCOEF_Fortran_FLAGS} ) - add_executable(radmon_ig_bcoef.x ${RADMON_IG_BCOEF_SRC} ) - set_target_properties( radmon_ig_bcoef.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_BCOEF_Fortran_FLAGS} ) - set_target_properties( radmon_ig_bcoef.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_bcoef.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_bcoef.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + bcoef.f90 +) + +add_executable(radmon_ig_bcoef.x ${SRCS}) + +target_compile_definitions(radmon_ig_bcoef.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_bcoef.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_bcoef.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 index c70fac7c13..24fb4b60bc 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 @@ -18,7 +18,9 @@ program bcoef ! but not bcoef. !************************************************************************ - use IFPORT +! use IFPORT +! Intel® Fortran includes functions and subroutines that ease porting of code to or from a PC, or allow you to write code on a PC that is compatible with other platforms. The portability library is called LIBIFPORT.LIB (Windows*) or libifport.a (Linux* and macOS*). Frequently used functions are included in a portability module called IFPORT. +! What functionality from IFPORT library is being used here and why? implicit none @@ -174,7 +176,7 @@ program bcoef inquire(file=data_file, exist=exist) ! write(6,*) 'data_file,exist = ', data_file, ' ', exist - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') read(ldname) (penalty(jj),jj=1,nchanl) ! write(6,*) 'penalty(1) = ', penalty(1) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt index d74885b276..b50bf7fe47 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_HORIZ_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_HORIZ_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_horiz ) - set_source_files_properties( ${RADMON_HORIZ_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_HORIZ_Fortran_FLAGS} ) - add_executable(radmon_ig_horiz.x ${RADMON_HORIZ_SRC} ) - set_target_properties( radmon_ig_horiz.x PROPERTIES COMPILE_FLAGS ${RADMON_HORIZ_Fortran_FLAGS} ) - set_target_properties( radmon_ig_horiz.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_ig_horiz.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_horiz.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + create_ctl_horiz.f90 + horiz.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 + update_ctl_horiz.f90 +) + +add_executable(radmon_ig_horiz.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_ig_horiz.x ncdiag) +endif() + +target_compile_definitions(radmon_ig_horiz.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_horiz.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_ig_horiz.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_ig_horiz.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_ig_horiz.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_horiz.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt index dde3b66137..aa69a48b99 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_IG_SUMMARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_SUMMARY_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_summary ) - set_source_files_properties( ${RADMON_IG_SUMMARY_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_SUMMARY_Fortran_FLAGS} ) - add_executable(radmon_ig_summary.x ${RADMON_IG_SUMMARY_SRC} ) - set_target_properties( radmon_ig_summary.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_SUMMARY_Fortran_FLAGS} ) - set_target_properties( radmon_ig_summary.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_summary.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_summary.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + summary.f90 +) + +add_executable(radmon_ig_summary.x ${SRCS}) + +target_compile_definitions(radmon_ig_summary.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_summary.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_summary.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 index f857c4d149..531f4bd4ec 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 @@ -15,7 +15,9 @@ program summary ! !************************************************************************ - use IFPORT +! use IFPORT +! Intel® Fortran includes functions and subroutines that ease porting of code to or from a PC, or allow you to write code on a PC that is compatible with other platforms. The portability library is called LIBIFPORT.LIB (Windows*) or libifport.a (Linux* and macOS*). Frequently used functions are included in a portability module called IFPORT. +! What functionality from IFPORT library is being used here and why? implicit none @@ -142,7 +144,7 @@ program summary inquire(file=data_file, exist=exist) - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') read(ldname) ((cnt(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) read(ldname) ((pen(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt index a14d8566e6..390308fd26 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_IG_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_time ) - set_source_files_properties( ${RADMON_IG_TIME_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_TIME_Fortran_FLAGS} ) - add_executable(radmon_ig_time.x ${RADMON_IG_TIME_SRC} ) - set_target_properties( radmon_ig_time.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_TIME_Fortran_FLAGS} ) - set_target_properties( radmon_ig_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_time.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_time.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + time.f90 +) + +add_executable(radmon_ig_time.x ${SRCS}) + +target_compile_definitions(radmon_ig_time.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 index 9b964de02c..4e7df16eb5 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 @@ -15,7 +15,9 @@ program gatime ! one entry for a given channel per line. !************************************************************************ - use IFPORT +! use IFPORT +! Intel® Fortran includes functions and subroutines that ease porting of code to or from a PC, or allow you to write code on a PC that is compatible with other platforms. The portability library is called LIBIFPORT.LIB (Windows*) or libifport.a (Linux* and macOS*). Frequently used functions are included in a portability module called IFPORT. +! What functionality from IFPORT library is being used here and why? implicit none @@ -147,7 +149,7 @@ program gatime inquire(file=data_file, exist=exist) - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') read(ldname) ((cnt(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) read(ldname) ((pen(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) diff --git a/util/Radiance_Monitor/nwprod/CMakeLists.txt b/util/Radiance_Monitor/nwprod/CMakeLists.txt new file mode 100644 index 0000000000..067d9346e4 --- /dev/null +++ b/util/Radiance_Monitor/nwprod/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(radmon_shared) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt new file mode 100644 index 0000000000..b08f886e6b --- /dev/null +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(verf_radang.fd) +add_subdirectory(verf_radbcoef.fd) +add_subdirectory(verf_radbcor.fd) +add_subdirectory(verf_radtime.fd) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt index 19aba63061..7cf902a8e1 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt @@ -1,14 +1,28 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_ANGLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_ANGLE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_angle ) - set_source_files_properties( ${RADMON_ANGLE_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_ANGLE_Fortran_FLAGS} ) - add_executable(radmon_angle.x ${RADMON_ANGLE_SRC} ) - set_target_properties( radmon_angle.x PROPERTIES COMPILE_FLAGS ${RADMON_ANGLE_Fortran_FLAGS} ) - set_target_properties( radmon_angle.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_angle.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( radmon_angle.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + angle_bias.f90 + create_ctl_angle.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 +) + +add_executable(radmon_angle.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_angle.x ncdiag) +endif() + +target_compile_definitions(radmon_angle.x PRIVATE "_REAL8_") +target_link_libraries(radmon_angle.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_angle.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_angle.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_angle.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_angle.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt index 5068244458..6fc89645dd 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt @@ -1,14 +1,28 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_BCOEF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_BCOEF_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_bcoef ) - set_source_files_properties( ${RADMON_BCOEF_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_BCOEF_Fortran_FLAGS} ) - add_executable(radmon_bcoef.x ${RADMON_BCOEF_SRC} ) - set_target_properties( radmon_bcoef.x PROPERTIES COMPILE_FLAGS ${RADMON_BCOEF_Fortran_FLAGS} ) - set_target_properties( radmon_bcoef.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_bcoef.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_W3NCO) - add_dependencies( radmon_bcoef.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + bcoef.f90 + create_ctl_bcoef.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 +) + +add_executable(radmon_bcoef.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_bcoef.x ncdiag) +endif() + +target_compile_definitions(radmon_bcoef.x PRIVATE "_REAL8_") +target_link_libraries(radmon_bcoef.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_bcoef.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_bcoef.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_bcoef.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_bcoef.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt index 59ac8532da..4872ecbd35 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_BCOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_BCOR_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_bcor ) - set_source_files_properties( ${RADMON_BCOR_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_BCOR_Fortran_FLAGS} ) - add_executable(radmon_bcor.x ${RADMON_BCOR_SRC} ) - set_target_properties( radmon_bcor.x PROPERTIES COMPILE_FLAGS ${RADMON_BCOR_Fortran_FLAGS} ) - set_target_properties( radmon_bcor.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_bcor.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( radmon_bcor.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + bcor.f90 + create_ctl_bcor.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 +) + +add_executable(radmon_bcor.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_bcor.x ncdiag) +endif() + +target_compile_definitions(radmon_bcor.x PRIVATE "_REAL8_") +target_link_libraries(radmon_bcor.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_bcor.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_bcor.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_bcor.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_bcor.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt index 3bb4e4b2ec..93c9518563 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt @@ -1,14 +1,32 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB RADMON_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_time ) - set_source_files_properties( ${RADMON_TIME_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_TIME_Fortran_FLAGS} ) - add_executable(radmon_time.x ${RADMON_TIME_SRC} ) - set_target_properties( radmon_time.x PROPERTIES COMPILE_FLAGS ${RADMON_TIME_Fortran_FLAGS} ) - set_target_properties( radmon_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_time.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_W3NCO) - add_dependencies( radmon_time.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + bad_chan.f90 + bad_penalty.f90 + create_ctl_time.f90 + kinds.F90 + low_count.f90 + read_diag.f90 + sparsearr.f90 + time.f90 + valid.f90 +) + +add_executable(radmon_time.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_time.x ncdiag) +endif() + +target_compile_definitions(radmon_time.x PRIVATE "_REAL8_") +target_link_libraries(radmon_time.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_time.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_time.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) From 353769f34ad1b4dfe495f27e979bef88f1d816f0 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 26 Mar 2022 15:01:36 -0400 Subject: [PATCH 36/58] retain trailing white spaces to minimize diffs --- .../conmon_grads_sfctime.fd/grads_sfctime.f90 | 72 +++++++++---------- .../sorc/conmon_grads_sig.fd/grads_sig.f90 | 56 +++++++-------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 index c306eab118..bbcde658ea 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 @@ -1,7 +1,7 @@ !--------------------------------------------------------------------------------- ! grads_sfctime ! -! Read in data from the .tmp file, arrange by level and write into +! Read in data from the .tmp file, arrange by level and write into ! the GrADS data files (one for scatter plots, and one for horizontal plots) ! depending on the iscater and igrads parameters. !--------------------------------------------------------------------------------- @@ -13,7 +13,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& use data implicit none - + type(list_node_t), pointer :: list type(list_node_t), pointer :: next => null() type(data_ptr) :: ptr @@ -31,8 +31,8 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& integer,dimension(nlev) :: ndata !----------------------------------------------------------------------------- - ! The tobs, rlat, rlon, stid variables were all originally dimensioned to - ! arrays of 10000 (tobs 2nd dimension, all others are 1-d arrays). This is + ! The tobs, rlat, rlon, stid variables were all originally dimensioned to + ! arrays of 10000 (tobs 2nd dimension, all others are 1-d arrays). This is ! dangerous because hard limits are essentially time bombs, and exceeding ! them results in a seg fault. ! @@ -42,10 +42,10 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& ! determined to be in the cnvstat for the input type and subtype. So it's ! not logically possible that the necessary dimension for these variables ! will exceed the input nobs value. Indeed in my tests the resulting used - ! portion of the dimension is 25%-35% of the nobs value, once duplicates and - ! data that does not conform to the available pressure levels are tossed out. - ! So it makes more sense to dynamically allocate these vars to the value of - ! nobs rather than arbitrarily select 10000 and find out the hard way that + ! portion of the dimension is 25%-35% of the nobs value, once duplicates and + ! data that does not conform to the available pressure levels are tossed out. + ! So it makes more sense to dynamically allocate these vars to the value of + ! nobs rather than arbitrarily select 10000 and find out the hard way that ! that was insufficient. real(4),allocatable,dimension(:,:,:) :: tobs @@ -57,7 +57,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& integer :: nlfag,nflag0,nlev0,getlev real(4) :: rmiss,rtim,xlat0,xlon0,rtime integer :: first, second - + integer nt,k,i,ii,j,nflag,obs_ctr integer ilat,ilon,ipres,itime,iweight,ndup @@ -67,13 +67,13 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& print *, '---> grads_sfctime' ndata=0 - if( nobs > 0 ) then + if( nobs > 0 ) then print *,'fileo =',fileo print *,'nobs =',nobs print *,'nreal = ', nreal allocate( tobs(nreal-4,nobs,nlev) ) - tobs = rmiss + tobs = rmiss allocate( rlat(nobs) ) allocate( rlon(nobs) ) @@ -119,10 +119,10 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& print *, 'end scatter file generation' - if( igrads == 1 ) then + if( igrads == 1 ) then filegrads=trim(fileo)//'_'//trim(subtype)//'.grads.'//trim(run) - open(21,file=filegrads,form='unformatted',status='new') ! open output file + open(21,file=filegrads,form='unformatted',status='new') ! open output file print *, 'filegrads = ', filegrads ilat = idx_obs_lat -2 ! modified position of lat @@ -132,13 +132,13 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& iweight = idx_rwgt -2 ! modofied position of weight !-------------------------------- - ! remove duplicate data + ! remove duplicate data ! call rm_dups( rdiag_m2,nobs,nreal-2,ilat,ilon,ipres,itime,iweight,ndup ) !------------------------------------------------------------------------ - ! As best I can tell this section is functioning as intended, which I + ! As best I can tell this section is functioning as intended, which I ! also assume to be correct. I made no changes to the logic though I did ! change rdiag to rdiag_m2 to make it more clear that this process is ! shaving off the first 2 rdiag values (lat & lon). @@ -146,9 +146,9 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& ! It's a white-hot mess but the intent is to group the same station's data ! in the tobs (:,:,:) array and keep the middle dimension in sync with the ! rlat(:), rlon(:), and stid(:) arrays. I insterted a whole bunch of - ! diagnostics and that appears to be working correctly. I question the - ! location of the ii incrementation, but tobs is set to rmiss so any gaps - ! (and there are some) should come out as rmiss. + ! diagnostics and that appears to be working correctly. I question the + ! location of the ii incrementation, but tobs is set to rmiss so any gaps + ! (and there are some) should come out as rmiss. ! ii=0 do i=1,nobs @@ -162,7 +162,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& k=getlev( rtime,plev,nlev ) if(k /=0) then - tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,i) + tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,i) ndata(k)=ndata(k)+1 endif @@ -174,18 +174,18 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& rtime=rdiag_m2(itime,j) k=getlev( rtime,plev,nlev ) - + if(k /=0) then - tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,j) + tobs(1:nreal-4,ii,k)=rdiag_m2(3:nreal-2,j) rdiag_m2(iweight,j)=-rdiag_m2(iweight,j) ndata(k)=ndata(k)+1 endif endif enddo - endif + endif enddo - + print *,'final ii, nobs =',ii,nobs ! ################################################################################ @@ -201,23 +201,23 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& ! the data file, reducing the output data file size by ~90%, and always ! using an nt value of 1 in the GrADS scripts. Simple is better. ! - ! NOTE Further: Per Su the idea behind the nlev arrangment is + ! NOTE Further: Per Su the idea behind the nlev arrangment is ! "... I try to plot the point which close to analysis time. There - ! are multiple observations (every 30 minutes or every hour) for the six + ! are multiple observations (every 30 minutes or every hour) for the six ! hour window (-3.0 to 3.0 relative to analysis time), so I divided time ! -2.5,-2.0,-1.5,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0,2.5." ! ! Generally I see that the nt ends up as either 1 or 6. Either way ! things can be simplified by writing only the nt step data into the ! output file, not creating the nt_{type}_00.yyyymmddcc file at all, - ! and always sending GrADS a nt value of 1. + ! and always sending GrADS a nt value of 1. ! ################################################################################ - + nt=maxloc(ndata,dim=1) - k=nt + k=nt print *, 'using ndata max value of nt = ', nt - + nflag=1 rtim=0.0 nlev0=1 @@ -236,8 +236,8 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& xlon0=0.0 nflag0=0 stidend=' ' - write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 - + write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 + close(21) print *, 'wrote ii tobs to file ', ii @@ -256,7 +256,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& end if print *, '<--- grads_sfctime' - return + return end @@ -269,7 +269,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& function getlev( p1,plev,nlevs ) implicit none - + real*4 p1 real*4,dimension(nlevs) :: plev integer getlev,ii,nlevs @@ -279,11 +279,11 @@ function getlev( p1,plev,nlevs ) do ii=1,nlevs if(p1 <= plev(ii)) then getlev=ii - return + return endif enddo - return + return end - + diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 index 3b4561e838..66ee7da3d3 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 @@ -1,7 +1,7 @@ !----------------------------------------------------------- ! grads_sig ! -! Read uv data from the .tmp file and write it to the +! Read uv data from the .tmp file and write it to the ! scatter and horiz GrADS data files. !----------------------------------------------------------- @@ -14,9 +14,9 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s type(list_node_t), pointer :: list type(list_node_t), pointer :: next => null() - type(data_ptr) :: ptr + type(data_ptr) :: ptr - integer ifileo + integer ifileo real(4),allocatable,dimension(:,:) :: rdiag_m2 character(8),allocatable,dimension(:) :: cdiag real(4),dimension(nlev) :: plev @@ -31,7 +31,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s real(4) :: rtim,xlat0,xlon0 integer(4):: isubtype,ctr,nreal_m2 integer i,j,k,ilat,ilon,ipres,itime,iweight,ndup,nflag - + stdid=' ' nflag0=0 @@ -39,20 +39,20 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s xlat0=0.0 xlon0=0.0 nlev0=0 - + print *, '--> BEGIN grads_sig.x' - print *, ' ' + print *, ' ' print *, 'inputs to grads_sig.x =' print *, 'fileo = ',fileo print *, 'ifileo = ',ifileo print *, 'nobs = ',nobs print *, 'nreal = ',nreal - print *, 'nlev = ',nlev - print *, 'plev = ',plev - print *, 'iscater = ',iscater - print *, 'igrads = ',igrads - print *, 'isubtype = ',isubtype - print *, 'subtype = ',subtype + print *, 'nlev = ',nlev + print *, 'plev = ',plev + print *, 'iscater = ',iscater + print *, 'igrads = ',igrads + print *, 'isubtype = ',isubtype + print *, 'subtype = ',subtype if( nobs > 0 ) then @@ -70,7 +70,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s obs_ctr = 0 next => list - do while ( associated( next ) .eqv. .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -109,7 +109,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ! write horiz grads data file and avoid trying ! to write output if nobs == 0. Seg faults are uncool. ! - if (igrads ==1 .AND. nobs > 0) then + if (igrads ==1 .AND. nobs > 0) then filegrads=trim(fileo)//'_'//trim(subtype)//'.grads.'//trim(run) open(21,file=filegrads,form='unformatted',status='new') ! open output file @@ -117,13 +117,13 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ilon = idx_obs_lon -2 ! modified position of lon ipres = idx_pres -2 ! modified position of pressure itime = idx_time -2 ! modified position of relative time - iweight = idx_rwgt -2 ! modofied position of weight + iweight = idx_rwgt -2 ! modofied position of weight !------------------------------------------ ! rm duplicate data ! call rm_dups( rdiag_m2,nobs,nreal_m2,ilat,ilon,ipres,itime,iweight,ndup ) - + ctr=0 do i=1,nobs if(rdiag_m2(iweight,i) >0.0 ) then @@ -140,18 +140,18 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ! note this writes the rdiag_m2 record starting at station ! elevation; lat and lon are written in the line above with the ! station id info - write(21) plev(k),rdiag_m2(3:nreal_m2,i) + write(21) plev(k),rdiag_m2(3:nreal_m2,i) ctr = ctr + 1 - endif + endif endif enddo - + !-------------------------- ! write EOF marker stidend=' ' - write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 - + write(21) stidend,xlat0,xlon0,rtim,nlev0,nflag0 + close(21) print *, 'num recs written to GrADS file = ', ctr @@ -170,7 +170,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s print *, 'exiting grads_sig, nobs = ', nobs end if - return + return end @@ -179,11 +179,11 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s ! ! Determines appropriate match of p1 value to plev array. ! -! Note that values within +/- 5 of a specific plev array -! are determined to be a match. +! Note that values within +/- 5 of a specific plev array +! are determined to be a match. !============================================================ function getpro(p1,plev,nlevs) - + implicit none real*4 p1 @@ -196,14 +196,14 @@ function getpro(p1,plev,nlevs) do ii=1,nlevs np=int(plev(ii)) dp=abs(ip-np) - + if(dp <=5) then getpro=ii return endif enddo - return + return end - + From 8c937ff921fc5bd3acfd729e73e3d8f8db11f915 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 26 Mar 2022 15:44:59 -0400 Subject: [PATCH 37/58] add place-holder for regression testing --- CMakeLists.txt | 3 ++- regression/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 regression/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index d6c26c1174..1e82d5278e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,5 +49,6 @@ if(BUILD_UTIL) add_subdirectory(util) endif() +add_subdirectory(regression) + #add_subdirectory(unit-tests) -#add_subdirectory(regression) diff --git a/regression/CMakeLists.txt b/regression/CMakeLists.txt new file mode 100644 index 0000000000..65c0e49833 --- /dev/null +++ b/regression/CMakeLists.txt @@ -0,0 +1 @@ +# Place-holder for regression testing of the GSI and EnKF From 50a6b3b6d39795d0716471417359c7622ca3262a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sun, 27 Mar 2022 17:31:18 -0400 Subject: [PATCH 38/58] remove dependency on NDATE from regression tests. Use Unix date instead. --- regression/arw_netcdf.sh | 2 +- regression/global_4denvar_T126.sh | 2 +- regression/global_4dvar_T62.sh | 2 +- regression/global_C96_fv3aero.sh | 2 +- regression/global_C96_fv3aerorad.sh | 2 +- regression/global_T62.sh | 2 +- regression/global_T62_ozonly.sh | 2 +- regression/global_enkf_T62.sh | 2 +- regression/global_fv3_4denvar_C192.sh | 2 +- regression/global_fv3_4denvar_T126.sh | 2 +- regression/global_hybrid_T126.sh | 2 +- regression/global_lanczos_T62.sh | 2 +- regression/global_nemsio_T62.sh | 2 +- regression/hwrf_nmm_d2.sh | 2 +- regression/hwrf_nmm_d3.sh | 2 +- regression/nmm_binary.sh | 2 +- regression/nmm_netcdf.sh | 2 +- regression/nmmb_nems_4denvar.sh | 2 +- regression/regression_var.sh | 9 +-------- regression/rtma.sh | 2 +- 20 files changed, 20 insertions(+), 27 deletions(-) diff --git a/regression/arw_netcdf.sh b/regression/arw_netcdf.sh index 5cccfab459..555625e9b6 100755 --- a/regression/arw_netcdf.sh +++ b/regression/arw_netcdf.sh @@ -56,7 +56,7 @@ ncp=/bin/cp # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files sdate=`echo $arw_netcdf_adate |cut -c1-8` -odate=`$ndate +6 $arw_netcdf_adate` +odate=`date +%Y%m%d%H -d "${arw_netcdf_adate:0:8} ${arw_netcdf_adate:8:2} + 6 hours"` hha=`echo $arw_netcdf_adate | cut -c9-10` hho=`echo $odate | cut -c9-10` prefixo=ndas.t${hho}z diff --git a/regression/global_4denvar_T126.sh b/regression/global_4denvar_T126.sh index 02ca7f8e54..fd6bbf9b69 100755 --- a/regression/global_4denvar_T126.sh +++ b/regression/global_4denvar_T126.sh @@ -72,7 +72,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_4denvar_T126_adate` +gdate=`date +%Y%m%d%H -d "${global_4denvar_T126_adate:0:8} ${global_4denvar_T126_adate:8:2} - 6 hours"` yyg=`echo $gdate | cut -c1-8` hhg=`echo $gdate | cut -c9-10` yya=`echo $global_4denvar_T126_adate | cut -c1-8` diff --git a/regression/global_4dvar_T62.sh b/regression/global_4dvar_T62.sh index 795008c04b..46aed61319 100755 --- a/regression/global_4dvar_T62.sh +++ b/regression/global_4dvar_T62.sh @@ -49,7 +49,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_4dvar_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_4dvar_T62_adate:0:8} ${global_4dvar_T62_adate:8:2} - 6 hours"` hha=`echo $global_4dvar_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z diff --git a/regression/global_C96_fv3aero.sh b/regression/global_C96_fv3aero.sh index 006c87fbe3..438cd6dc0e 100755 --- a/regression/global_C96_fv3aero.sh +++ b/regression/global_C96_fv3aero.sh @@ -29,7 +29,7 @@ ncp=/bin/cp # for guess and observation data files PDY=`echo $global_C96_fv3aero_adate | cut -c1-8` cyc=`echo $global_C96_fv3aero_adate | cut -c9-10` -gdate=`$ndate -06 $global_C96_fv3aero_adate` +gdate=`date +%Y%m%d%H -d "${global_C96_fv3aero_adate:0:8} ${global_C96_fv3aero_adate:8:2} - 6 hours"` gPDY=`echo $gdate | cut -c1-8` gcyc=`echo $gdate | cut -c9-10` hha=`echo $global_C96_fv3aero_adate | cut -c9-10` diff --git a/regression/global_C96_fv3aerorad.sh b/regression/global_C96_fv3aerorad.sh index 14a7d58bd1..6e990be1be 100755 --- a/regression/global_C96_fv3aerorad.sh +++ b/regression/global_C96_fv3aerorad.sh @@ -28,7 +28,7 @@ ncpl="ln -fs" # for guess and observation data files PDY=`echo $global_C96_fv3aerorad_adate | cut -c1-8` cyc=`echo $global_C96_fv3aerorad_adate | cut -c9-10` -gdate=`$ndate -06 $global_C96_fv3aerorad_adate` +gdate=`date +%Y%m%d%H -d "${global_C96_fv3aerorad_adate:0:8} ${global_C96_fv3aerorad_adate:8:2} - 6 hours"` gPDY=`echo $gdate | cut -c1-8` gcyc=`echo $gdate | cut -c9-10` hha=`echo $global_C96_fv3aerorad_adate | cut -c9-10` diff --git a/regression/global_T62.sh b/regression/global_T62.sh index fded077a26..06c0ddeacb 100755 --- a/regression/global_T62.sh +++ b/regression/global_T62.sh @@ -69,7 +69,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_T62_adate:0:8} ${global_T62_adate:8:2} - 6 hours"` hha=`echo $global_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z. diff --git a/regression/global_T62_ozonly.sh b/regression/global_T62_ozonly.sh index 4d2ee6a4d6..6f2119fd3c 100755 --- a/regression/global_T62_ozonly.sh +++ b/regression/global_T62_ozonly.sh @@ -69,7 +69,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_T62_adate:0:8} ${global_T62_adate:8:2} - 6 hours"` hha=`echo $global_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z. diff --git a/regression/global_enkf_T62.sh b/regression/global_enkf_T62.sh index 23b4026884..3ddc18ba0c 100755 --- a/regression/global_enkf_T62.sh +++ b/regression/global_enkf_T62.sh @@ -59,7 +59,7 @@ fi # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files export adate=$global_enkf_T62_adate -gdate=`$ndate -06 $global_enkf_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_enkf_T62_adate:0:8} ${global_enkf_T62_adate:8:2} - 6 hours"` yyg=`echo $gdate | cut -c1-8` hhg=`echo $gdate | cut -c9-10` yya=`echo $global_enkf_T62_adate | cut -c1-8` diff --git a/regression/global_fv3_4denvar_C192.sh b/regression/global_fv3_4denvar_C192.sh index ffc9a2ba79..27c6f2798d 100755 --- a/regression/global_fv3_4denvar_C192.sh +++ b/regression/global_fv3_4denvar_C192.sh @@ -81,7 +81,7 @@ ENSEND=20 # for guess and observation data files PDY=`echo $global_fv3_4denvar_C192_adate | cut -c1-8` cyc=`echo $global_fv3_4denvar_C192_adate | cut -c9-10` -GDATE=`$ndate -06 $global_fv3_4denvar_C192_adate` +GDATE=`date +%Y%m%d%H -d "${global_fv3_4denvar_C192_adate:0:8} ${global_fv3_4denvar_C192_adate:8:2} - 6 hours"` gPDY=`echo $GDATE | cut -c1-8` gcyc=`echo $GDATE | cut -c9-10` diff --git a/regression/global_fv3_4denvar_T126.sh b/regression/global_fv3_4denvar_T126.sh index 0f79fabe3e..3bcff2b674 100755 --- a/regression/global_fv3_4denvar_T126.sh +++ b/regression/global_fv3_4denvar_T126.sh @@ -77,7 +77,7 @@ ENSEND=20 # for guess and observation data files PDY=`echo $global_fv3_4denvar_T126_adate | cut -c1-8` cyc=`echo $global_fv3_4denvar_T126_adate | cut -c9-10` -GDATE=`$ndate -06 $global_fv3_4denvar_T126_adate` +GDATE=`date +%Y%m%d%H -d "${global_fv3_4denvar_T126_adate:0:8} ${global_fv3_4denvar_T126_adate:8:2} - 6 hours"` gPDY=`echo $GDATE | cut -c1-8` gcyc=`echo $GDATE | cut -c9-10` diff --git a/regression/global_hybrid_T126.sh b/regression/global_hybrid_T126.sh index 82d10e0852..6472a84911 100755 --- a/regression/global_hybrid_T126.sh +++ b/regression/global_hybrid_T126.sh @@ -68,7 +68,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_hybrid_T126_adate` +gdate=`date +%Y%m%d%H -d "${global_hybrid_T126_adate:0:8} ${global_hybrid_T126_adate:8:2} - 6 hours"` yyg=`echo $gdate | cut -c1-8` hhg=`echo $gdate | cut -c9-10` yya=`echo $global_hybrid_T126_adate | cut -c1-8` diff --git a/regression/global_lanczos_T62.sh b/regression/global_lanczos_T62.sh index 3b8b0876d4..55014a58f0 100755 --- a/regression/global_lanczos_T62.sh +++ b/regression/global_lanczos_T62.sh @@ -44,7 +44,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_lanczos_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_lanczos_T62_adate:0:8} ${global_lanczos_T62_adate:8:2} - 6 hours"` hha=`echo $global_lanczos_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z diff --git a/regression/global_nemsio_T62.sh b/regression/global_nemsio_T62.sh index f597c6420a..8278bb3655 100755 --- a/regression/global_nemsio_T62.sh +++ b/regression/global_nemsio_T62.sh @@ -45,7 +45,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_nemsio_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_nemsio_T62_adate:0:8} ${global_nemsio_T62_adate:8:2} - 6 hours"` hha=`echo $global_nemsio_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z diff --git a/regression/hwrf_nmm_d2.sh b/regression/hwrf_nmm_d2.sh index 26536062d7..ba7ae25521 100755 --- a/regression/hwrf_nmm_d2.sh +++ b/regression/hwrf_nmm_d2.sh @@ -56,7 +56,7 @@ export NLON=$(( NX2 - 1 )) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $adate` +gdate=`date +%Y%m%d%H -d "${adate:0:8} ${adate:8:2} - 6 hours"` hha=`echo $adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefixa=gfs.t${hha}z diff --git a/regression/hwrf_nmm_d3.sh b/regression/hwrf_nmm_d3.sh index 2c015db0d6..bde43050a8 100755 --- a/regression/hwrf_nmm_d3.sh +++ b/regression/hwrf_nmm_d3.sh @@ -56,7 +56,7 @@ export NLON=$(( NX3 - 1 )) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $adate` +gdate=`date +%Y%m%d%H -d "${adate:0:8} ${adate:8:2} - 6 hours"` hha=`echo $adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefixa=gfs.t${hha}z diff --git a/regression/nmm_binary.sh b/regression/nmm_binary.sh index 4dcbcf5d70..abd4507283 100755 --- a/regression/nmm_binary.sh +++ b/regression/nmm_binary.sh @@ -55,7 +55,7 @@ ncp=/bin/cp # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files sdate=`echo $nmm_binary_adate |cut -c1-8` -odate=`$ndate +12 $nmm_binary_adate` +odate=`date +%Y%m%d%H -d "${nmm_binary_adate:0:8} ${nmm_binary_adate:8:2} + 12 hours"` hha=`echo $nmm_binary_adate | cut -c9-10` hho=`echo $odate | cut -c9-10` prefixo=ndas.t${hho}z diff --git a/regression/nmm_netcdf.sh b/regression/nmm_netcdf.sh index 5d3e478cb8..a1e6879104 100755 --- a/regression/nmm_netcdf.sh +++ b/regression/nmm_netcdf.sh @@ -58,7 +58,7 @@ ncp=/bin/cp # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files sdate=`echo $nmm_netcdf_adate |cut -c1-8` -odate=`$ndate +12 $nmm_netcdf_adate` +odate=`date +%Y%m%d%H -d "${nmm_netcdf_adate:0:8} ${nmm_netcdf_adate:8:2} + 12 hours"` hha=`echo $nmm_netcdf_adate | cut -c9-10` hho=`echo $odate | cut -c9-10` prefixo=ndas.t${hho}z diff --git a/regression/nmmb_nems_4denvar.sh b/regression/nmmb_nems_4denvar.sh index 0f1e4594ac..56c23a2140 100755 --- a/regression/nmmb_nems_4denvar.sh +++ b/regression/nmmb_nems_4denvar.sh @@ -213,7 +213,7 @@ cp $nmmb_nems_4denvar_ges/rtma2p5.t00z.p_rejectlist ./p_rejectlist cp $nmmb_nems_4denvar_ges/rtma2p5.t00z.q_rejectlist ./q_rejectlist ##### connect with gefs ensemble ################# -#gdate=`/nwprod/util/exec/ndate -6 $adate` +#gdate=`date +%Y%m%d%H -d "${adate:0:8} ${adate:8:2} - 6 hours"` #cycg=`echo $gdate | cut -c9-10` ls $nmmb_nems_4denvar_ges/sfg_2015060918_fhr06_ensmean > filelist06 #typeset -Z2 nsum diff --git a/regression/regression_var.sh b/regression/regression_var.sh index 37096edde1..5d3d33a766 100755 --- a/regression/regression_var.sh +++ b/regression/regression_var.sh @@ -44,7 +44,7 @@ if [ -z ${machine+x} ]; then export machine="WCOSS_C" elif [ -d /gpfs/dell1/ptmp ]; then # venus or mars export machine="WCOSS_D" -elif [ -d /discover/nobackup ]; then # NCCS Discover + elif [ -d /discover/nobackup ]; then # NCCS Discover export machine="Discover" fi else echo "machine is set to '$machine'"; @@ -60,7 +60,6 @@ case $machine in export fixcrtm="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/fix_update" export casesdir="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/CASES" - export ndate=${NDATE:-"$builddir/bin/ndate.x"} export check_resource="yes" @@ -82,7 +81,6 @@ case $machine in export fixcrtm="/da/save/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" export casesdir="/da/noscrub/Michael.Lueken/CASES" - export ndate="/nwprod/util/exec/ndate" export check_resource="yes" @@ -99,7 +97,6 @@ case $machine in export fixcrtm="/glade/p/ral/jntp/tools/crtm/2.2.3/fix_update" export casesdir="/glade/p/ral/jntp/tools/CASES" - export ndate="$builddir/bin/ndate.x" export check_resource="no" export accnt="p48503002" @@ -123,7 +120,6 @@ case $machine in export fixcrtm="/scratch1/NCEPDEV/da/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" export casesdir="/scratch1/NCEPDEV/da/Michael.Lueken/noscrub/CASES" - export ndate=$NDATE export check_resource="no" @@ -140,7 +136,6 @@ case $machine in export ptmp=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp export fixcrtm="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" export casesdir="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CASES" - export ndate=$NDATE export check_resource="no" export accnt="nesdis-rdo2" @@ -175,7 +170,6 @@ case $machine in export fixcrtm="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CRTM_REL-2.2.3/fix_update" export casesdir="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CASES" - export ndate=$NDATE export check_resource="no" @@ -191,7 +185,6 @@ case $machine in export noscrub=$basedir export fixcrtm="/discover/nobackup/projects/gmao/share/gmao_ops/fvInput_4dvar/gsi/etc/fix_ncep20170329/REL-2.2.3-r60152_local-rev_1/CRTM_Coeffs/$endianness" export casesdir="/discover/nobackup/projects/gmao/obsdev/wrmccart/NCEP_regression/CASES" - export ndate="/home/pchakrab/.local/bin/ndate" export check_resource="no" export accnt="g0613" export queue="compute" diff --git a/regression/rtma.sh b/regression/rtma.sh index a189411926..a28402012a 100755 --- a/regression/rtma.sh +++ b/regression/rtma.sh @@ -37,7 +37,7 @@ ncp=/bin/cp # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -12 $rtma_adate` +gdate=`date +%Y%m%d%H -d "${rtma_adate:0:8} ${rtma_adate:8:2} - 12 hours"` cya=`echo $rtma_adate | cut -c9-10` cyg=`echo $rtma_adate | cut -c9-10` cymd=`echo $rtma_adate | cut -c1-8` From e624bdf032b2de0ec3c8e3f32a5efb502f6f69e7 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 28 Mar 2022 18:45:33 -0400 Subject: [PATCH 39/58] reinstate regression testing via ctest. --- CMakeLists.txt | 7 +- regression/CMakeLists.txt | 76 +++++++- regression/regression_driver.sh | 8 +- regression/regression_var.sh | 302 ++++++++++++++++---------------- 4 files changed, 235 insertions(+), 158 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e82d5278e..8573b6a1b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ project(GSIApp set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) +enable_testing() include(GNUInstallDirs) if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") @@ -32,6 +33,7 @@ option(BUILD_GSDCLOUD "Build GSD Cloud Analysis Library" OFF) option(BUILD_GSI "Build GSI" ON) option(BUILD_ENKF "Build EnKF" ON) option(BUILD_UTIL "Build Utilities" ON) +option(BUILD_REG_TESTING "Build the Regression Testing Suite" OFF) # Echo user options message(STATUS "OPENMP ................. ${OPENMP}") @@ -41,6 +43,7 @@ message(STATUS "BUILD_GSDCLOUD ......... ${BUILD_GSDCLOUD}") message(STATUS "BUILD_GSI .............. ${BUILD_GSI}") message(STATUS "BUILD_ENKF ............. ${BUILD_ENKF}") message(STATUS "BUILD_UTIL ............. ${BUILD_UTIL}") +message(STATUS "BUILD_REG_TESTING ...... ${BUILD_REG_TESTING}") # Build components add_subdirectory(src) @@ -49,6 +52,8 @@ if(BUILD_UTIL) add_subdirectory(util) endif() -add_subdirectory(regression) +if(BUILD_REG_TESTING) + add_subdirectory(regression) +endif() #add_subdirectory(unit-tests) diff --git a/regression/CMakeLists.txt b/regression/CMakeLists.txt index 65c0e49833..f47e94415d 100644 --- a/regression/CMakeLists.txt +++ b/regression/CMakeLists.txt @@ -1 +1,75 @@ -# Place-holder for regression testing of the GSI and EnKF +# Find the GSI and EnKF control executables +find_program(GSICONTROLEXEC + NAMES gsi.x + HINTS ${CONTROLPATH} + ${CONTROLPATH}/bin + ${CONTROLPATH}/exec + ${GSICONTROLPATH} + ${GSICONTROLPATH}/bin + ${GSICONTROLPATH}/exec + ENV ${CONTROLPATH} + ENV ${CONTROLPATH}/bin + ENV ${CONTROLPATH}/exec + ENV ${GSICONTROLPATH} + ENV ${GSICONTROLPATH}/bin + ENV ${GSICONTROLPATH}/exec + NO_DEFAULT_PATH +) + +if (GSICONTROLEXEC_FOUND) + message(STATUS "RT: Control GSIexec Found: ${GSICONTROLEXEC}") +else() + message(WARNING "RT: Control GSIexec Not Found, GSI Regression Tests Disabled!") +endif() + +find_program(ENKFCONTROLEXEC + NAMES enkf.x + HINTS ${CONTROLPATH} + ${CONTROLPATH}/bin + ${CONTROLPATH}/exec + ${ENKFCONTROLPATH} + ${ENKFCONTROLPATH}/bin + ${ENKFCONTROLPATH}/exec + ENV ${CONTROLPATH} + ENV ${CONTROLPATH}/bin + ENV ${CONTROLPATH}/exec + ENV ${ENKFCONTROLPATH} + ENV ${ENKFCONTROLPATH}/bin + ENV ${ENKFCONTROLPATH}/exec + NO_DEFAULT_PATH +) + +if (ENKFCONTROLEXEC_FOUND) + message(STATUS "RT: Control EnKFexec Found: ${ENKFCONTROLEXEC}") +else() + message(WARNING "RT: Control EnKFexec Not Found, EnKF Regression Tests Disabled!") +endif() + +# If neither are found, nothing to do; simply return +if(NOT (GSICONTROLEXEC_FOUND AND ENKFCONTROLEXEC_FOUND)) + message(WARNING "RT: Regression Tests Disabled!") + return() +endif() + +# Create regression_var.out file +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/regression_var.out" "${CMAKE_CURRENT_SOURCE_DIR}/regression_var.sh ${PROJECT_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/src/gsi/gsi.x ${PROJECT_BINARY_DIR}/src/enkf/enkf.x ${GSICONTROLEXEC} ${ENKFCONTROLEXEC}") + +list(APPEND REG_TEST_NAMES + global_T62 global_T62_ozonly global_4dvar_T62 global_4denvar_T126 + global_fv3_4denvar_T126 global_fv3_4denvar_C192 global_lanczos_T62 + arw_netcdf arw_binary nmm_binary nmm_netcdf + nmmb_nems_4denvar + hwrf_nmm_d2 hwrf_nmm_d3 + rtma + global_enkf_T62 + netcdf_fv3_regional + global_C96_fv3aero global_C96_fv3aerorad +) + +# Run each regression test; one at a time +foreach(REG_TEST ${REG_TEST_NAMES}) + add_test(NAME ${REG_TEST} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND regression_driver.sh ${REG_TEST} ${CMAKE_CURRENT_BINARY_DIR}) +endforeach(REG_TEST) +set_tests_properties(${REG_TEST_NAMES} PROPERTIES TIMEOUT 86400) diff --git a/regression/regression_driver.sh b/regression/regression_driver.sh index 8b35ff67df..08f0154819 100755 --- a/regression/regression_driver.sh +++ b/regression/regression_driver.sh @@ -8,10 +8,10 @@ export regtest=$1 # source the necessary files to setup if [ "$#" -eq 2 ]; then export regdir=$2 - . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9 }' $regdir/regression_var.out) + . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8 }' $regdir/regression_var.out) else export regdir=$(pwd) - . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9 }' regression_var.out) + . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8 }' regression_var.out) fi export scripts=${scripts_updat:-$scripts} @@ -20,10 +20,10 @@ export scripts=${scripts_updat:-$scripts} # allow regression tests to be set by environment variable if [ -z "$RSTART" ]; then export RSTART=1 -fi +fi if [ -z "$REND" ]; then export REND=4 -fi +fi # Launch the individual control and update runs, one-after-another for jn in `seq ${RSTART} ${REND}`; do diff --git a/regression/regression_var.sh b/regression/regression_var.sh index 5d3d33a766..0620aec5dd 100755 --- a/regression/regression_var.sh +++ b/regression/regression_var.sh @@ -4,22 +4,20 @@ # To run with hybrid ensemble option on, change HYBENS_GLOBAL and/or HYBENS_REGIONAL from "false" to "true". # These are located at the end of this script. -if [ "$#" = 8 ] ; then - export machine=$1 - export basedir=$2 - export builddir=$3 - export gsisrc=$4 - export gsiexec_updat=$5 - export enkfexec_updat=$6 - export gsiexec_contrl=$7 - export enkfexec_contrl=$8 +if [ "$#" = 7 ] ; then + export basedir=$1 + export builddir=$2 + export gsisrc=$3 + export gsiexec_updat=$4 + export enkfexec_updat=$5 + export gsiexec_contrl=$6 + export enkfexec_contrl=$7 export fixgsi="$gsisrc/fix" export scripts="$gsisrc/regression" export ush="$gsisrc/ush" export cmaketest="true" export clean="false" export ptmpName=`echo $builddir | sed -e "s/\//_/g"` - echo $ptmpName else # Name of the branch being tested updat="XXXXXXXX" @@ -28,10 +26,11 @@ else export clean="false" export ptmpName="" fi + echo "beginning regression_var.sh, machine is $machine" # If we don't know already determine what machine are we on: -if [ -z ${machine+x} ]; then - echo "machine is unset"; +if [ -z ${machine+x} ]; then + echo "machine is unset"; if [ -d /da ]; then # WCOSS export machine="WCOSS" elif [ -d /glade/scratch ]; then # Cheyenne @@ -47,149 +46,148 @@ if [ -z ${machine+x} ]; then elif [ -d /discover/nobackup ]; then # NCCS Discover export machine="Discover" fi -else echo "machine is set to '$machine'"; +else + echo "machine is set to '$machine'"; fi case $machine in - WCOSS_D) - export noscrub=/gpfs/dell2/emc/modeling/noscrub/$LOGNAME - export group="dev" - export queue="dev" - - export ptmp="/gpfs/dell2/ptmp/$LOGNAME/$ptmpName" - - export fixcrtm="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/fix_update" - export casesdir="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/CASES" - - export check_resource="yes" - - export accnt="" - ;; - WCOSS) - if [ -d /da/noscrub/$LOGNAME ]; then - export noscrub=/da/noscrub/$LOGNAME - elif [ -d /global/noscrub/$LOGNAME ]; then - export noscrub=/global/noscrub/$LOGNAME - fi - if [[ "$cmaketest" = "false" ]]; then - export basedir="/global/save/$LOGNAME/gsi" - fi - export group="dev" - export queue="dev" - - export ptmp="/ptmpp1/$LOGNAME/$ptmpName" - - export fixcrtm="/da/save/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" - export casesdir="/da/noscrub/Michael.Lueken/CASES" - - export check_resource="yes" - - export accnt="" - ;; - Cheyenne) - export queue="economy" - export noscrub="/glade/scratch/$LOGNAME" - export group="global" - if [[ "$cmaketest" = "false" ]]; then - export basedir="/glade/scratch/$LOGNAME/gsi" - fi - export ptmp="/glade/scratch/$LOGNAME/$ptmpName" - - export fixcrtm="/glade/p/ral/jntp/tools/crtm/2.2.3/fix_update" - export casesdir="/glade/p/ral/jntp/tools/CASES" - - export check_resource="no" - export accnt="p48503002" - ;; - Hera) - if [ -d /scratch1/NCEPDEV/da/$LOGNAME ]; then - export noscrub="/scratch1/NCEPDEV/da/$LOGNAME/noscrub" - elif [ -d /scratch1/NCEPDEV/global/$LOGNAME ]; then - export noscrub="/scratch1/NCEPDEV/global/$LOGNAME/noscrub" - elif [ -d /scratch2/BMC/gsienkf/$LOGNAME ]; then - export noscrub="/scratch2/BMC/gsienkf/$LOGNAME" - fi - - export group="global" - export queue="batch" - if [[ "$cmaketest" = "false" ]]; then - export basedir="/scratch1/NCEPDEV/da/$LOGNAME/git/gsi" - fi - - export ptmp="/scratch1/NCEPDEV/stmp2/$LOGNAME/$ptmpName" - - export fixcrtm="/scratch1/NCEPDEV/da/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" - export casesdir="/scratch1/NCEPDEV/da/Michael.Lueken/noscrub/CASES" - - export check_resource="no" - - export accnt="da-cpu" - - # On Hera, there are no scrubbers to remove old contents from stmp* directories. - # After completion of regression tests, will remove the regression test subdirecories - export clean=".true." - ;; - Jet) - - set -x - export noscrub=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/noscrub - export ptmp=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp - export fixcrtm="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" - export casesdir="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CASES" - export check_resource="no" - export accnt="nesdis-rdo2" - - export group="global" - export queue="batch" - if [[ "$cmaketest" = "false" ]]; then - export basedir="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/gsi" - fi - - export ptmp="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp/$ptmpName" - - # On Jet, there are no scrubbers to remove old contents from stmp* directories. - # After completion of regression tests, will remove the regression test subdirecories - export clean=".true." - set +x - ;; - WCOSS_C) - if [ -d /gpfs/hps3/emc/global/noscrub/$LOGNAME ]; then - export noscrub="/gpfs/hps3/emc/global/noscrub/$LOGNAME" - elif [ -d /gpfs/hps3/emc/da/noscrub/$LOGNAME ]; then - export noscrub="/gpfs/hps3/emc/da/noscrub/$LOGNAME" - elif [ -d /gpfs/hps3/emc/hwrf/noscrub/$LOGNAME ]; then - export noscrub="/gpfs/hps3/emc/hwrf/noscrub/$LOGNAME" - fi - if [[ "$cmaketest" = "false" ]]; then - export basedir="/gpfs/hps3/emc/global/noscrub/$LOGNAME/svn/gsi" - fi - export group="dev" - export queue="dev" - - export ptmp="/gpfs/hps/ptmp/$LOGNAME/$ptmpName" - - export fixcrtm="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CRTM_REL-2.2.3/fix_update" - export casesdir="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CASES" - - export check_resource="no" - - export accnt="" - ;; - Discover) - if [[ "$cmaketest" = "false" ]]; then - echo "Regression tests on Discover need to be run via ctest" - exit 1 - fi - export ptmp=$basedir - export ptmp=$basedir - export noscrub=$basedir - export fixcrtm="/discover/nobackup/projects/gmao/share/gmao_ops/fvInput_4dvar/gsi/etc/fix_ncep20170329/REL-2.2.3-r60152_local-rev_1/CRTM_Coeffs/$endianness" - export casesdir="/discover/nobackup/projects/gmao/obsdev/wrmccart/NCEP_regression/CASES" - export check_resource="no" - export accnt="g0613" - export queue="compute" - export clean=".false." - ;; + WCOSS_D) + export noscrub=/gpfs/dell2/emc/modeling/noscrub/$LOGNAME + export group="dev" + export queue="dev" + + export ptmp="/gpfs/dell2/ptmp/$LOGNAME/$ptmpName" + + export fixcrtm="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/fix_update" + export casesdir="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/CASES" + + export check_resource="yes" + + export accnt="" + ;; + WCOSS) + if [ -d /da/noscrub/$LOGNAME ]; then + export noscrub=/da/noscrub/$LOGNAME + elif [ -d /global/noscrub/$LOGNAME ]; then + export noscrub=/global/noscrub/$LOGNAME + fi + if [[ "$cmaketest" = "false" ]]; then + export basedir="/global/save/$LOGNAME/gsi" + fi + export group="dev" + export queue="dev" + + export ptmp="/ptmpp1/$LOGNAME/$ptmpName" + + export fixcrtm="/da/save/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" + export casesdir="/da/noscrub/Michael.Lueken/CASES" + + export check_resource="yes" + + export accnt="" + ;; + Cheyenne) + export queue="economy" + export noscrub="/glade/scratch/$LOGNAME" + export group="global" + if [[ "$cmaketest" = "false" ]]; then + export basedir="/glade/scratch/$LOGNAME/gsi" + fi + export ptmp="/glade/scratch/$LOGNAME/$ptmpName" + + export fixcrtm="/glade/p/ral/jntp/tools/crtm/2.2.3/fix_update" + export casesdir="/glade/p/ral/jntp/tools/CASES" + + export check_resource="no" + export accnt="p48503002" + ;; + Hera) + if [ -d /scratch1/NCEPDEV/da/$LOGNAME ]; then + export noscrub="/scratch1/NCEPDEV/da/$LOGNAME/noscrub" + elif [ -d /scratch1/NCEPDEV/global/$LOGNAME ]; then + export noscrub="/scratch1/NCEPDEV/global/$LOGNAME/noscrub" + elif [ -d /scratch2/BMC/gsienkf/$LOGNAME ]; then + export noscrub="/scratch2/BMC/gsienkf/$LOGNAME" + fi + + export group="global" + export queue="batch" + if [[ "$cmaketest" = "false" ]]; then + export basedir="/scratch1/NCEPDEV/da/$LOGNAME/git/gsi" + fi + + export ptmp="/scratch1/NCEPDEV/stmp2/$LOGNAME/$ptmpName" + + export fixcrtm="/scratch1/NCEPDEV/da/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" + export casesdir="/scratch1/NCEPDEV/da/Michael.Lueken/noscrub/CASES" + + export check_resource="no" + + export accnt="da-cpu" + + # On Hera, there are no scrubbers to remove old contents from stmp* directories. + # After completion of regression tests, will remove the regression test subdirecories + export clean=".true." + ;; + Jet) + + export noscrub=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/noscrub + export ptmp=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp + export fixcrtm="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" + export casesdir="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CASES" + export check_resource="no" + export accnt="nesdis-rdo2" + + export group="global" + export queue="batch" + if [[ "$cmaketest" = "false" ]]; then + export basedir="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/gsi" + fi + + export ptmp="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp/$ptmpName" + + # On Jet, there are no scrubbers to remove old contents from stmp* directories. + # After completion of regression tests, will remove the regression test subdirecories + export clean=".true." + ;; + WCOSS_C) + if [ -d /gpfs/hps3/emc/global/noscrub/$LOGNAME ]; then + export noscrub="/gpfs/hps3/emc/global/noscrub/$LOGNAME" + elif [ -d /gpfs/hps3/emc/da/noscrub/$LOGNAME ]; then + export noscrub="/gpfs/hps3/emc/da/noscrub/$LOGNAME" + elif [ -d /gpfs/hps3/emc/hwrf/noscrub/$LOGNAME ]; then + export noscrub="/gpfs/hps3/emc/hwrf/noscrub/$LOGNAME" + fi + if [[ "$cmaketest" = "false" ]]; then + export basedir="/gpfs/hps3/emc/global/noscrub/$LOGNAME/svn/gsi" + fi + export group="dev" + export queue="dev" + + export ptmp="/gpfs/hps/ptmp/$LOGNAME/$ptmpName" + + export fixcrtm="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CRTM_REL-2.2.3/fix_update" + export casesdir="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CASES" + + export check_resource="no" + + export accnt="" + ;; + Discover) + if [[ "$cmaketest" = "false" ]]; then + echo "Regression tests on Discover need to be run via ctest" + exit 1 + fi + export ptmp=$basedir + export ptmp=$basedir + export noscrub=$basedir + export fixcrtm="/discover/nobackup/projects/gmao/share/gmao_ops/fvInput_4dvar/gsi/etc/fix_ncep20170329/REL-2.2.3-r60152_local-rev_1/CRTM_Coeffs/$endianness" + export casesdir="/discover/nobackup/projects/gmao/obsdev/wrmccart/NCEP_regression/CASES" + export check_resource="no" + export accnt="g0613" + export queue="compute" + export clean=".false." + ;; esac if [[ "$cmaketest" = "false" ]]; then From f4f4c9527d1bc26778cee2d3118d0d5cb12f38fc Mon Sep 17 00:00:00 2001 From: Christopher Harrop <35781497+christopherwharrop-noaa@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:38:14 -0600 Subject: [PATCH 40/58] Fix duplicate definition of MPI variables (#3) * Fix duplicate definition of MPI variables * Replace "include mpif.h" with "use mpi" --- src/enkf/gridinfo_fv3reg.f90 | 3 ++- src/enkf/mpisetup.f90 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index 772e6cf9b2..0825b3a631 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -42,7 +42,8 @@ module gridinfo ! !$$$ -use mpisetup, only: nproc, mpi_integer, mpi_real4, mpi_comm_world +use mpi +use mpisetup, only: nproc use params, only: datapath,nlevs,nlons,nlats,use_gfs_nemsio, fgfileprefixes, & fv3fixpath, nx_res,ny_res, ntiles use kinds, only: r_kind, i_kind, r_double, r_single diff --git a/src/enkf/mpisetup.f90 b/src/enkf/mpisetup.f90 index 9b2841e6d9..7bea689451 100644 --- a/src/enkf/mpisetup.f90 +++ b/src/enkf/mpisetup.f90 @@ -27,9 +27,9 @@ module mpisetup !$$$ use kinds, only: r_kind, r_single, r_double +use mpi implicit none ! mpi definitions. -include 'mpif.h' integer numproc, nproc, numproc_shm, nproc_shm integer mpi_comm_shmem, mpi_comm_shmemroot integer mpi_status(mpi_status_size) From 259879502546bf433df0e3b99e8ebec482afe28f Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 29 Mar 2022 21:38:32 +0000 Subject: [PATCH 41/58] minor update to EnKF/CMakeLists.txt --- src/enkf/CMakeLists.txt | 15 ++------------- src/enkf/enkf_files.cmake | 8 ++++---- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index 5a2ab509e6..a009957d75 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -83,19 +83,8 @@ list(APPEND EnKF_SRC_Fortran ${EnKF_SRC_srcs}) # Collect files for specific EnKF Application -if(ENKF_MODE MATCHES "GFS") # GFS application - list(APPEND EnKF_SRC_Fortran - ${EnKF_SRC_gfs}) -elseif(ENKF_MODE MATCHES "WRF") # WRF application - list(APPEND EnKF_SRC_Fortran - ${EnKF_SRC_wrf}) -elseif(ENKF_MODE MATCHES "NMMB") # NMMB application - list(APPEND EnKF_SRC_Fortran - ${EnKF_SRC_nmmb}) -elseif(ENKF_MODE MATCHES "FV3REG") # WRF application - list(APPEND EnKF_SRC_Fortran - ${EnKF_SRC_fv3reg}) -endif() +list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_${ENKF_MODE}}) # Create a library of EnKF Fortran sources set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/enkf") diff --git a/src/enkf/enkf_files.cmake b/src/enkf/enkf_files.cmake index d7e03f0659..907e0495c5 100644 --- a/src/enkf/enkf_files.cmake +++ b/src/enkf/enkf_files.cmake @@ -32,25 +32,25 @@ list(APPEND EnKF_SRC_srcs statevec.f90 write_logfile.f90) -list(APPEND EnKF_SRC_gfs +list(APPEND EnKF_SRC_GFS gridinfo_gfs.f90 gridio_gfs.f90 observer_gfs.f90 smooth_gfs.f90) -list(APPEND EnKF_SRC_wrf +list(APPEND EnKF_SRC_WRF gridinfo_wrf.f90 gridio_wrf.f90 observer_reg.f90 smooth_wrf.f90) -list(APPEND EnKF_SRC_nmmb +list(APPEND EnKF_SRC_NMMB gridinfo_nmmb.f90 gridio_nmmb.f90 observer_reg.f90 smooth_nmmb.f90) -list(APPEND EnKF_SRC_fv3reg +list(APPEND EnKF_SRC_FV3REG gridinfo_fv3reg.f90 gridio_fv3reg.f90 observer_fv3reg.f90 From a49adfadefe043ca268a500f86f63a674533f1c9 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 30 Mar 2022 01:57:04 +0000 Subject: [PATCH 42/58] reinstate regression tests w/ ctest --- regression/.gitignore | 1 + regression/CMakeLists.txt | 89 +++++++++++++++++++---------------- regression/regression_var.out | 1 - regression/regression_var.sh | 47 +++++++++--------- src/enkf/gridinfo_fv3reg.f90 | 3 +- src/enkf/mpisetup.f90 | 2 +- ush/build_all_cmake.sh | 12 +++-- 7 files changed, 86 insertions(+), 69 deletions(-) create mode 100644 regression/.gitignore delete mode 100644 regression/regression_var.out diff --git a/regression/.gitignore b/regression/.gitignore new file mode 100644 index 0000000000..f47cb2045f --- /dev/null +++ b/regression/.gitignore @@ -0,0 +1 @@ +*.out diff --git a/regression/CMakeLists.txt b/regression/CMakeLists.txt index f47e94415d..5082de2a0b 100644 --- a/regression/CMakeLists.txt +++ b/regression/CMakeLists.txt @@ -1,75 +1,82 @@ # Find the GSI and EnKF control executables find_program(GSICONTROLEXEC NAMES gsi.x - HINTS ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - ${GSICONTROLPATH} - ${GSICONTROLPATH}/bin - ${GSICONTROLPATH}/exec - ENV ${CONTROLPATH} - ENV ${CONTROLPATH}/bin - ENV ${CONTROLPATH}/exec - ENV ${GSICONTROLPATH} - ENV ${GSICONTROLPATH}/bin - ENV ${GSICONTROLPATH}/exec + PATHS ${CONTROLPATH} ENV CONTROLPATH + ${GSICONTROLPATH} ENV GSICONTROLPATH + PATH_SUFFIXES bin exec + DOC "Searching for gsi.x" NO_DEFAULT_PATH ) -if (GSICONTROLEXEC_FOUND) +if (GSICONTROLEXEC) message(STATUS "RT: Control GSIexec Found: ${GSICONTROLEXEC}") else() message(WARNING "RT: Control GSIexec Not Found, GSI Regression Tests Disabled!") endif() find_program(ENKFCONTROLEXEC - NAMES enkf.x - HINTS ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - ${ENKFCONTROLPATH} - ${ENKFCONTROLPATH}/bin - ${ENKFCONTROLPATH}/exec - ENV ${CONTROLPATH} - ENV ${CONTROLPATH}/bin - ENV ${CONTROLPATH}/exec - ENV ${ENKFCONTROLPATH} - ENV ${ENKFCONTROLPATH}/bin - ENV ${ENKFCONTROLPATH}/exec + NAMES enkf.x enkf_gfs.x + PATHS ${CONTROLPATH} ENV CONTROLPATH + ${ENKFCONTROLPATH} ENV ENKFCONTROLPATH + PATH_SUFFIXES bin exec + DOC "Searching for enkf.x" NO_DEFAULT_PATH ) -if (ENKFCONTROLEXEC_FOUND) +if (ENKFCONTROLEXEC) message(STATUS "RT: Control EnKFexec Found: ${ENKFCONTROLEXEC}") else() message(WARNING "RT: Control EnKFexec Not Found, EnKF Regression Tests Disabled!") endif() # If neither are found, nothing to do; simply return -if(NOT (GSICONTROLEXEC_FOUND AND ENKFCONTROLEXEC_FOUND)) - message(WARNING "RT: Regression Tests Disabled!") +if(NOT (GSICONTROLEXEC AND ENKFCONTROLEXEC)) + message(WARNING "RT: Unable to find Control Executables. Regression Tests Disabled!") + set(BUILD_REG_TESTING OFF CACHE BOOL "Regression testing disabled" FORCE) return() endif() -# Create regression_var.out file -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/regression_var.out" "${CMAKE_CURRENT_SOURCE_DIR}/regression_var.sh ${PROJECT_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/src/gsi/gsi.x ${PROJECT_BINARY_DIR}/src/enkf/enkf.x ${GSICONTROLEXEC} ${ENKFCONTROLEXEC}") - -list(APPEND REG_TEST_NAMES +# GSI regression test names +list(APPEND GSI_REG_TEST_NAMES global_T62 global_T62_ozonly global_4dvar_T62 global_4denvar_T126 global_fv3_4denvar_T126 global_fv3_4denvar_C192 global_lanczos_T62 arw_netcdf arw_binary nmm_binary nmm_netcdf nmmb_nems_4denvar hwrf_nmm_d2 hwrf_nmm_d3 rtma - global_enkf_T62 netcdf_fv3_regional global_C96_fv3aero global_C96_fv3aerorad ) -# Run each regression test; one at a time -foreach(REG_TEST ${REG_TEST_NAMES}) - add_test(NAME ${REG_TEST} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND regression_driver.sh ${REG_TEST} ${CMAKE_CURRENT_BINARY_DIR}) -endforeach(REG_TEST) -set_tests_properties(${REG_TEST_NAMES} PROPERTIES TIMEOUT 86400) +# EnKF regression test names +list(APPEND ENKF_REG_TEST_NAMES + global_enkf_T62 +) + +# Add GSI regression tests to list of tests +if(GSICONTROLEXEC) + list(APPEND REG_TEST_NAMES ${GSI_REG_TEST_NAMES}) +endif() + +# Add EnKF regression tests to list of tests +if(ENKFCONTROLEXEC) + list(APPEND REG_TEST_NAMES ${ENKF_REG_TEST_NAMES}) +endif() + +# Names of the GSI and EnKF executables from this build +set(GSIUPDATEEXEC ${PROJECT_BINARY_DIR}/src/gsi/gsi.x) +set(ENKFUPDATEEXEC ${PROJECT_BINARY_DIR}/src/enkf/enkf.x) + +# Create Regression tests if list is not empty +if(REG_TEST_NAMES) + # Create regression_var.out file + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/regression_var.out" "${CMAKE_CURRENT_SOURCE_DIR}/regression_var.sh ${PROJECT_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${GSIUPDATEEXEC} ${ENKFUPDATEEXEC} ${GSICONTROLEXEC} ${ENKFCONTROLEXEC}") + + # Run each regression test; one at a time + foreach(REG_TEST ${REG_TEST_NAMES}) + add_test(NAME ${REG_TEST} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND regression_driver.sh ${REG_TEST} ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(${REG_TEST} PROPERTIES TIMEOUT 86400) + endforeach(REG_TEST) +endif() diff --git a/regression/regression_var.out b/regression/regression_var.out deleted file mode 100644 index aee78a93a2..0000000000 --- a/regression/regression_var.out +++ /dev/null @@ -1 +0,0 @@ -/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/regression/regression_var.sh WCOSS_D /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/.. /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/build /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/install/exec/gsi.x /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/update/install/exec/enkf.x /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin/gsi.x /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin/enkf_gfs.x 1 diff --git a/regression/regression_var.sh b/regression/regression_var.sh index 0620aec5dd..4951ab31f5 100755 --- a/regression/regression_var.sh +++ b/regression/regression_var.sh @@ -27,28 +27,29 @@ else export ptmpName="" fi -echo "beginning regression_var.sh, machine is $machine" -# If we don't know already determine what machine are we on: -if [ -z ${machine+x} ]; then - echo "machine is unset"; - if [ -d /da ]; then # WCOSS - export machine="WCOSS" - elif [ -d /glade/scratch ]; then # Cheyenne - export machine="Cheyenne" - elif [ -d /scratch1/NCEPDEV/da ]; then # Hera - export machine="Hera" - elif [ -d /lfs1/NCEPDEV ]; then # Jet - export machine="Jet" - elif [ -d /gpfs/hps/ptmp ]; then # LUNA or SURGE - export machine="WCOSS_C" - elif [ -d /gpfs/dell1/ptmp ]; then # venus or mars - export machine="WCOSS_D" - elif [ -d /discover/nobackup ]; then # NCCS Discover - export machine="Discover" - fi -else - echo "machine is set to '$machine'"; +# Determine the machine +if [[ -d /dcom && -d /hwrf ]]; then # WCOSS + export machine="WCOSS" +elif [[ -d /glade ]]; then # Cheyenne + export machine="Cheyenne" +elif [[ -d /scratch1 ]]; then # Hera + export machine="Hera" +elif [[ -d /jetmon ]]; then # Jet + export machine="Jet" +elif [[ -d /cm ]]; then # LUNA or SURGE + export machine="WCOSS_C" +elif [[ -d /ioddev_dell ]]; then # venus or mars + export machine="WCOSS_D" +elif [[ -d /discover ]]; then # NCCS Discover + export machine="Discover" +elif [[ -d /sw/gaea ]]; then # Gaea + export machine="Gaea" +elif [[ -d /data/prod ]]; then # S4 + export machine="S4" +elif [[ -d /work ]]; then # Orion + export machine="Orion" fi +echo "Running Regression Tests on '$machine'"; case $machine in WCOSS_D) @@ -188,6 +189,10 @@ case $machine in export queue="compute" export clean=".false." ;; + *) + echo "Regression tests are not setup on '$machine', ABORT!" + exit 1 + ;; esac if [[ "$cmaketest" = "false" ]]; then diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index 0825b3a631..772e6cf9b2 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -42,8 +42,7 @@ module gridinfo ! !$$$ -use mpi -use mpisetup, only: nproc +use mpisetup, only: nproc, mpi_integer, mpi_real4, mpi_comm_world use params, only: datapath,nlevs,nlons,nlats,use_gfs_nemsio, fgfileprefixes, & fv3fixpath, nx_res,ny_res, ntiles use kinds, only: r_kind, i_kind, r_double, r_single diff --git a/src/enkf/mpisetup.f90 b/src/enkf/mpisetup.f90 index 7bea689451..9b2841e6d9 100644 --- a/src/enkf/mpisetup.f90 +++ b/src/enkf/mpisetup.f90 @@ -27,9 +27,9 @@ module mpisetup !$$$ use kinds, only: r_kind, r_single, r_double -use mpi implicit none ! mpi definitions. +include 'mpif.h' integer numproc, nproc, numproc_shm, nproc_shm integer mpi_comm_shmem, mpi_comm_shmemroot integer mpi_status(mpi_status_size) diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index 50301224d7..16f7a946ef 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -22,15 +22,18 @@ if [[ -d /dcom && -d /hwrf ]] ; then . /usrx/local/Modules/3.2.10/init/sh target=wcoss . $MODULESHOME/init/sh + CONTROLPATH="/da/save/Michael.Lueken/svn1/build" elif [[ -d /cm ]] ; then . $MODULESHOME/init/sh target=wcoss_c elif [[ -d /ioddev_dell ]]; then . $MODULESHOME/init/sh target=wcoss_d + CONTROLPATH="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build" elif [[ -d /scratch1 ]] ; then . /apps/lmod/lmod/init/sh target=hera + CONTROLPATH="/scratch1/NCEPDEV/da/Michael.Lueken/svn1/build" elif [[ -d /data/prod ]] ; then . /usr/share/lmod/lmod/init/sh target=s4 @@ -116,11 +119,14 @@ cmake_opts+=" -DCMAKE_INSTALL_PREFIX=$dir_root/install" # NCO wants executables in `exec`, not the standard `bin` cmake_opts+=" -DCMAKE_INSTALL_BINDIR=exec" -# By default; build the global applications -cmake_opts+=" -DGSI_MODE=GFS -DENKF_MODE=GFS" +# By default; build the Regional GSI and Global EnKF applications +cmake_opts+=" -DGSI_MODE=Regional -DENKF_MODE=GFS" # Build utilities: -cmake_opts+=" -DBUILD_COV_CALC=ON -DBUILD_ENKF_GFS=ON -DBUILD_EFSOI_UTIL=ON" +cmake_opts+=" -DBUILD_COV_CALC=ON -DBUILD_ENKF_GFS=ON -DBUILD_EFSOI_UTIL=ON -DBUILD_MON_UTIL=ON" + +# Build regression test +cmake_opts+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=${CONTROLPATH:-}" # Valid combination of applications are: # Global : -DGSI_MODE=GFS -DENKF_MODE=GFS From 616267e0756c41cb55f3cf54fa533e79ebb2128c Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 31 Mar 2022 11:55:37 -0400 Subject: [PATCH 43/58] remove stale cmake/Modules --- cmake/Modules/FindBACIO.cmake | 22 - cmake/Modules/FindBUFR.cmake | 24 - cmake/Modules/FindBaselibs.cmake | 68 - cmake/Modules/FindCORELIBS.cmake | 156 -- cmake/Modules/FindCRTM.cmake | 33 - cmake/Modules/FindGSICONTROL.cmake | 54 - cmake/Modules/FindHDF5.cmake | 24 - cmake/Modules/FindIP.cmake | 31 - cmake/Modules/FindMPI.cmake | 18 - cmake/Modules/FindNDATE.cmake | 13 - cmake/Modules/FindNEMSIO.cmake | 33 - cmake/Modules/FindSFCIO.cmake | 37 - cmake/Modules/FindSIGIO.cmake | 38 - cmake/Modules/FindSP.cmake | 31 - cmake/Modules/FindW3EMC.cmake | 47 - cmake/Modules/FindW3NCO.cmake | 27 - cmake/Modules/FindWRF.cmake | 36 - .../NewCMake/CMakeParseArguments.cmake | 11 - cmake/Modules/NewCMake/FindHDF5.cmake | 934 ---------- cmake/Modules/NewCMake/FindMPI.cmake | 1514 ----------------- .../NewCMake/FindMPI/fortranparam_mpi.f90.in | 4 - cmake/Modules/NewCMake/FindMPI/libver_mpi.c | 19 - .../NewCMake/FindMPI/libver_mpi.f90.in | 7 - cmake/Modules/NewCMake/FindMPI/mpiver.f90.in | 10 - cmake/Modules/NewCMake/FindMPI/test_mpi.c | 37 - .../Modules/NewCMake/FindMPI/test_mpi.f90.in | 6 - .../FindPackageHandleStandardArgs.cmake | 386 ----- .../Modules/NewCMake/FindPackageMessage.cmake | 47 - .../SelectLibraryConfigurations.cmake | 70 - cmake/Modules/platforms/Acorn.cmake | 13 - cmake/Modules/platforms/Cheyenne.cmake | 24 - cmake/Modules/platforms/Discover.cmake | 55 - cmake/Modules/platforms/Gaea.cmake | 14 - cmake/Modules/platforms/Generic.cmake | 25 - cmake/Modules/platforms/Hera.cmake | 42 - cmake/Modules/platforms/Jet.cmake | 42 - cmake/Modules/platforms/Orion.cmake | 42 - cmake/Modules/platforms/S4.cmake | 10 - cmake/Modules/platforms/WCOSS-C.cmake | 60 - cmake/Modules/platforms/WCOSS-D.cmake | 48 - cmake/Modules/platforms/WCOSS.cmake | 61 - cmake/Modules/setGNUFlags.cmake | 66 - cmake/Modules/setHOST.cmake | 105 -- cmake/Modules/setIntelFlags.cmake | 94 - cmake/Modules/setPGIFlags.cmake | 78 - cmake/Modules/setPlatformVariables.cmake | 12 - 46 files changed, 4528 deletions(-) delete mode 100644 cmake/Modules/FindBACIO.cmake delete mode 100644 cmake/Modules/FindBUFR.cmake delete mode 100644 cmake/Modules/FindBaselibs.cmake delete mode 100644 cmake/Modules/FindCORELIBS.cmake delete mode 100644 cmake/Modules/FindCRTM.cmake delete mode 100644 cmake/Modules/FindGSICONTROL.cmake delete mode 100644 cmake/Modules/FindHDF5.cmake delete mode 100644 cmake/Modules/FindIP.cmake delete mode 100644 cmake/Modules/FindMPI.cmake delete mode 100644 cmake/Modules/FindNDATE.cmake delete mode 100644 cmake/Modules/FindNEMSIO.cmake delete mode 100644 cmake/Modules/FindSFCIO.cmake delete mode 100644 cmake/Modules/FindSIGIO.cmake delete mode 100644 cmake/Modules/FindSP.cmake delete mode 100644 cmake/Modules/FindW3EMC.cmake delete mode 100644 cmake/Modules/FindW3NCO.cmake delete mode 100644 cmake/Modules/FindWRF.cmake delete mode 100644 cmake/Modules/NewCMake/CMakeParseArguments.cmake delete mode 100644 cmake/Modules/NewCMake/FindHDF5.cmake delete mode 100644 cmake/Modules/NewCMake/FindMPI.cmake delete mode 100644 cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.c delete mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/mpiver.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.c delete mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake delete mode 100644 cmake/Modules/NewCMake/FindPackageMessage.cmake delete mode 100644 cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake delete mode 100644 cmake/Modules/platforms/Acorn.cmake delete mode 100644 cmake/Modules/platforms/Cheyenne.cmake delete mode 100644 cmake/Modules/platforms/Discover.cmake delete mode 100644 cmake/Modules/platforms/Gaea.cmake delete mode 100644 cmake/Modules/platforms/Generic.cmake delete mode 100644 cmake/Modules/platforms/Hera.cmake delete mode 100644 cmake/Modules/platforms/Jet.cmake delete mode 100644 cmake/Modules/platforms/Orion.cmake delete mode 100644 cmake/Modules/platforms/S4.cmake delete mode 100644 cmake/Modules/platforms/WCOSS-C.cmake delete mode 100644 cmake/Modules/platforms/WCOSS-D.cmake delete mode 100644 cmake/Modules/platforms/WCOSS.cmake delete mode 100644 cmake/Modules/setGNUFlags.cmake delete mode 100644 cmake/Modules/setHOST.cmake delete mode 100644 cmake/Modules/setIntelFlags.cmake delete mode 100644 cmake/Modules/setPGIFlags.cmake delete mode 100644 cmake/Modules/setPlatformVariables.cmake diff --git a/cmake/Modules/FindBACIO.cmake b/cmake/Modules/FindBACIO.cmake deleted file mode 100644 index 205f7d3157..0000000000 --- a/cmake/Modules/FindBACIO.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{BACIO_VER}) - set(BACIO_VER $ENV{BACIO_VER}) - STRING(REGEX REPLACE "v" "" BACIO_VER ${BACIO_VER}) -endif() -if(NOT BUILD_BACIO ) - if(DEFINED ENV{BACIO_LIB4}) - set(BACIO_LIBRARY $ENV{BACIO_LIB4} ) - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${BACIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${BACIO_LIBRARY} ) -endif() - -set( BACIO_LIBRARY_PATH ${BACIO_LIBRARY} CACHE STRING "BACIO Library Location" ) - diff --git a/cmake/Modules/FindBUFR.cmake b/cmake/Modules/FindBUFR.cmake deleted file mode 100644 index ce6da34e71..0000000000 --- a/cmake/Modules/FindBUFR.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{BUFR_VER}) - set(BUFR_VER $ENV{BUFR_VER}) - STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_BUFR ) - if(DEFINED ENV{BUFR_LIBd_DA} ) - set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) - message("BUFR library ${BUFR_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${BUFR_LIBRARY} ) -else() - set( CORE_LIBRARIES ${BUFR_LIBRARY} ) -endif() -set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) - diff --git a/cmake/Modules/FindBaselibs.cmake b/cmake/Modules/FindBaselibs.cmake deleted file mode 100644 index 793cb9a5d4..0000000000 --- a/cmake/Modules/FindBaselibs.cmake +++ /dev/null @@ -1,68 +0,0 @@ -if (NOT BASEDIR) - if(${COMPILER_TYPE} STREQUAL "intel" ) - string(REGEX MATCH "mpt" MPT ${MPI_Fortran_INCLUDE_PATH}) - string(REGEX MATCH "impi" IMPI ${MPI_Fortran_INCLUDE_PATH}) - message("REGEX returns ${MPT} ") - if( MPT MATCHES "mpt" ) - message("setting mpt paths ") - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_15.0.2.164-mpt_2.14/Linux") - elseif( IMPI MATCHES "impi" ) - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_16.0.3.210-intelmpi_5.1.3.210/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() - if(${COMPILER_TYPE} STREQUAL "gnu" ) - string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) - message("REGEX returns ${OPENMPI} ") - if( OPENMPI MATCHES "openmpi" ) - message("setting openmpi paths ") - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-4_0_8/x86_64-unknown-linux-gnu/gfortran_7.2.0-openmpi_3.0.0/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() - if(${COMPILER_TYPE} STREQUAL "pgi" ) - string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) - if( OPENMPI MATCHES "openmpi" ) - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_1/x86_64-unknown-linux-gnu/pgfortran_16.5-openmpi_1.10.3/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() -endif () -if (ESMA_SDF) - message (FATAL_ERROR "ERROR: -hdf option was thought to be obsolete when CMake was crafted.") -endif () - -link_directories (${BASEDIR}/lib) - -#------------------------------------------------------------------ -# netcdf -# The following command provides the list of libraries that netcdf -# uses. Unfortunately it also includes the library path and "-l" -# prefixes, which CMake handles in a different manner. So we need so -# strip off that item from the list -execute_process ( - COMMAND ${BASEDIR}/bin/nf-config --flibs - OUTPUT_VARIABLE LIB_NETCDF - ) - -string(REGEX MATCHALL " -l[^ ]*" _full_libs "${LIB_NETCDF}") -set (NETCDF_LIBRARIES) -foreach (lib ${_full_libs}) - string (REPLACE "-l" "" _tmp ${lib}) - string (STRIP ${_tmp} _tmp) - list (APPEND NETCDF_LIBRARIES ${_tmp}) -endforeach() -#------------------------------------------------------------------ - -list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/netcdf) -list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/hdf5) - -message(STATUS "NETCDF_INCLUDES: ${NETCDF_INCLUDES}") -message(STATUS "NETCDF_LIBRARIES: ${NETCDF_LIBRARIES}") - diff --git a/cmake/Modules/FindCORELIBS.cmake b/cmake/Modules/FindCORELIBS.cmake deleted file mode 100644 index f653f758dc..0000000000 --- a/cmake/Modules/FindCORELIBS.cmake +++ /dev/null @@ -1,156 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{BUFR_VER}) - set(BUFR_VER $ENV{BUFR_VER}) - STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) -endif() -if(DEFINED ENV{NEMSIO_VER}) - set(NEMSIO_VER $ENV{NEMSIO_VER}) - STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) -endif() -if(DEFINED ENV{SFCIO_VER}) - set(SFCIO_VER $ENV{SFCIO_VER}) - STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) -endif() -if(DEFINED ENV{SIGIO_VER}) - set(SIGIO_VER $ENV{SIGIO_VER}) - STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) -endif() -if(DEFINED ENV{SP_VER}) - set(SP_VER $ENV{SP_VER}) - STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) -endif() -if(DEFINED ENV{W3EMC_VER}) - set(W3EMC_VER $ENV{W3EMC_VER}) - STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) -endif() -if(DEFINED ENV{W3NCO_VER}) - set(W3NCO_VER $ENV{W3NCO_VER}) - STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) -endif() - -set (CORE_DEPS " ") -set( NO_DEFAULT_PATH ) -if(NOT BUILD_EMC ) - if(DEFINED ENV{W3EMC_LIBd} ) - set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) - set(W3EMCINC $ENV{W3EMC_INCd} ) - endif() -else() - set( libsuffix "_v${W3EMC_VER}${debug_suffix}" ) - set( W3EMC_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3emc${libsuffix}.a" CACHE STRING "W3EMC Library" ) - set( w3emc "w3emc${libsuffix}") - if( DEFINED ENV{W3EMC_SRC} ) - set( W3EMC_DIR $ENV{W3EMC_SRC} CACHE STRING "W3EMC Source Directory" ) - endif() -endif() -if(NOT BUILD_NCO ) - if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) - endif() -else() - if( DEFINED ENV{W3NCO_SRC} ) - set( W3NCO_DIR $ENV{W3NCO_SRC} CACHE STRING "W3NCO Source Directory" ) - endif() - set( libsuffix "_v${W3NCO_VER}${debug_suffix}" ) - set( W3NCO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3nco${libsuffix}.a" CACHE STRING "W3NCO Library" ) - set( w3nco "w3nco${libsuffix}") -endif() -if(NOT BUILD_BUFR ) - if(DEFINED ENV{BUFR_LIBd_DA} ) - set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) - endif() -else() - if( DEFINED ENV{BUFR_SRC} ) - set( BUFR_DIR $ENV{BUFR_SRC} CACHE STRING "BUFR Source Directory" ) - endif() - set( libsuffix "_v${BUFR_VER}${debug_suffix}" ) - set( BUFR_LIBRARY "${LIBRARY_OUTPUT_PATH}/libbufr${libsuffix}.a" CACHE STRING "BUFR Library" ) - set( bufr "bufr${libsuffix}") -endif() -if(NOT BUILD_SFCIO ) - if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) - set(SFCIOINC $ENV{SFCIO_INC4} ) - endif() -else() - if( DEFINED ENV{SFCIO_SRC} ) - set( SFCIO_DIR $ENV{SFCIO_SRC} CACHE STRING "SFCIO Source Directory" ) - endif() - set( libsuffix "_v${SFCIO_VER}${debug_suffix}" ) - set( SFCIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsfcio${libsuffix}.a" CACHE STRING "SFCIO Library" ) - set( sfcio "sfcio${libsuffix}") -endif() -if(NOT BUILD_SIGIO ) - if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) - set(SIGIOINC $ENV{SIGIO_INC4} ) - endif() -else() - if( DEFINED ENV{SIGIO_SRC} ) - set( SIGIO_DIR $ENV{SIGIO_SRC} CACHE STRING "SIGIO Source Directory" ) - endif() - set( libsuffix "_v${SIGIO_VER}${debug_suffix}" ) - set( SIGIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsigio${libsuffix}.a" CACHE STRING "SIGIO Library" ) - set( sigio "sigio${libsuffix}") - set( CORE_DEPS "${CORE_DEPS} ${baseName}" ) -endif() -if(NOT BUILD_NEMSIO ) - if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) - set(NEMSIOINC $ENV{NEMSIO_INC} ) - endif() -else() - if( DEFINED ENV{NEMSIO_SRC} ) - set( NEMSIO_DIR $ENV{NEMSIO_SRC} CACHE STRING "NEMSIO Source Directory" ) - endif() - set( libsuffix "_v${NEMSIO_VER}${debug_suffix}" ) - set( NEMSIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libnemsio${libsuffix}.a" CACHE STRING "NEMSIO Library" ) - set( nemsio "nemsio${libsuffix}") -endif() -if(NOT BUILD_SP ) - if(DEFINED ENV{SP_LIBd} ) - set(SP_LIBRARY $ENV{SP_LIBd} ) - endif() -else() - if( DEFINED ENV{SP_SRC} ) - set( SP_DIR $ENV{SP_SRC} CACHE STRING "SP Source Directory" ) - endif() - set( libsuffix "_v${SP_VER}${debug_suffix}" ) - set( SP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp${libsuffix}.a" CACHE STRING "SP Library" ) - set( sp "sp${libsuffix}") -endif() - -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} - ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} - ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) - list( APPEND CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) -else() - set( CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} - ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} - ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) -endif() - -set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) - -set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) -set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) - -set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) -set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) - -set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) - -set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) -set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) - -set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) -set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) - -set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) - diff --git a/cmake/Modules/FindCRTM.cmake b/cmake/Modules/FindCRTM.cmake deleted file mode 100644 index 41de09bba9..0000000000 --- a/cmake/Modules/FindCRTM.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{CRTM_VER}) - set(CRTM_VER $ENV{CRTM_VER}) - STRING(REGEX REPLACE "v" "" CRTM_VER ${CRTM_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_CRTM ) - if(DEFINED ENV{CRTM_LIB} ) - set(CRTM_LIBRARY $ENV{CRTM_LIB} ) - set(CRTMINC $ENV{CRTM_INC} ) - message("CRTM library ${CRTM_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${CRTM_LIBRARY} ) -else() - set( CORE_LIBRARIES ${CRTM_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${CRTMINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${CRTMINC} ) -endif() - -set( CRTM_LIBRARY_PATH ${CRTM_LIBRARY} CACHE STRING "CRTM Library Location" ) -set( CRTM_INCLUDE_PATH ${CRTMINC} CACHE STRING "CRTM Include Location" ) - diff --git a/cmake/Modules/FindGSICONTROL.cmake b/cmake/Modules/FindGSICONTROL.cmake deleted file mode 100644 index 3e4bd7d7dc..0000000000 --- a/cmake/Modules/FindGSICONTROL.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# - Find the Control version of GSI to use for regression testing - -set( NO_DEFAULT_PATH ) -message("Control path is ${CONTROLPATH}") -find_file( CONTROL_EXE - NAMES gsi.x global_gsi ${GSIEXEC} - HINTS - ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - $ENV{CONTROLPATH} - $ENV{CONTROLPATH}/bin - $ENV{CONTROLPATH}/exec - $ENV{CONTROLPATH}/src - ${CMAKE_SOURCE_DIR}/../trunk/src - ${CMAKE_SOURCE_DIR}/../../trunk/src - ${PROJECT_BINARY_DIR}/../build-trunk/bin - /da/save/Michael.Lueken/svn1/build/bin - /da/save/Michael.Lueken/svn1/src - /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src - /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin - /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec - - ${NO_DEFAULT_PATH}) - -set( GSICONTROL ${CONTROL_EXE} CACHE STRING "GSI control executable for regression testing" FORCE ) - -find_file( ENKF_CONTROL_EXE - NAMES enkf_gfs.x global_enkf ${ENKFEXEC} - HINTS - ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - $ENV{CONTROLPATH} - $ENV{CONTROLPATH}/bin - $ENV{CONTROLPATH}/exec - ${CMAKE_SOURCE_DIR}/../trunk/src/enkf - ${PROJECT_BINARY_DIR}/../build-trunk/bin - $ENV{CONTROLPATH}/enkf - $ENV{CONTROLPATH}/src/enkf - /da/save/Michael.Lueken/svn1/build/bin - /da/save/Michael.Lueken/svn1/src/enkf - /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src/enkf - /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin - /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec - - ${NO_DEFAULT_PATH}) - -set( ENKFCONTROL ${ENKF_CONTROL_EXE} CACHE STRING "ENKF control executable for regression testing" FORCE ) - diff --git a/cmake/Modules/FindHDF5.cmake b/cmake/Modules/FindHDF5.cmake deleted file mode 100644 index 78e3db3678..0000000000 --- a/cmake/Modules/FindHDF5.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# This extends CMake's FindHDF5.cmake to add support to include MPI include -# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON -# (BUG #0014363). - -# include the default FindHDF5.cmake. -#if(CMAKE_VERSION VERSION_LESS 3.6.1) -if(CMAKE_VERSION VERSION_GREATER 3.0 ) - include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindHDF5.cmake) -else() - include(${CMAKE_ROOT}/Modules/FindHDF5.cmake) -endif() -#endif() - -if(HDF5_FOUND AND (HDF5_IS_PARALLEL OR HDF5_ENABLE_PARALLEL)) - if(MPI_C_INCLUDE_PATH) - list(APPEND HDF5_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH}) - endif() - if(MPI_C_LIBRARIES) - list(APPEND HDF5_LIBRARIES ${MPI_C_LIBRARIES}) - endif() - if(MPI_CXX_LIBRARIES) - list(APPEND HDF5_LIBRARIES ${MPI_CXX_LIBRARIES}) - endif() -endif() diff --git a/cmake/Modules/FindIP.cmake b/cmake/Modules/FindIP.cmake deleted file mode 100644 index baec28d683..0000000000 --- a/cmake/Modules/FindIP.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{IP_VER}) - set(IP_VER $ENV{IP_VER}) - STRING(REGEX REPLACE "v" "" IP_VER ${IP_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_IP ) - if(DEFINED ENV{IP_LIBd} ) - set(IP_LIBRARY $ENV{IP_LIBd} ) - message("IP library ${IP_LIBRARY} set via Environment variable") - endif() - if(DEFINED ENV{IP_LIB4} ) - set(IP_4_LIBRARY $ENV{IP_LIB4} ) - message("IP 4 library ${IP_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${IP_LIBRARY} ) -else() - set( CORE_LIBRARIES ${IP_LIBRARY} ) -endif() - - -set( IP_LIBRARY_PATH ${IP_LIBRARY} CACHE STRING "IP Library Location" ) -set( IP_4_LIBRARY_PATH ${IP_4_LIBRARY} CACHE STRING "IP_4 Library Location" ) - diff --git a/cmake/Modules/FindMPI.cmake b/cmake/Modules/FindMPI.cmake deleted file mode 100644 index 8e0a0c95ba..0000000000 --- a/cmake/Modules/FindMPI.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# This extends CMake's FindHDF5.cmake to add support to include MPI include -# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON -# (BUG #0014363). - -# include the default FindMPI.cmake. -if(CMAKE_VERSION VERSION_LESS 3.1) - include(${CMAKE_ROOT}/Modules/FindMPI.cmake) -elseif(CMAKE_VERSION VERSION_LESS 3.6) - message("Using new FindMPI") - include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindMPI.cmake) -# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") -else() - message("Using installed FindMPI") - include(${CMAKE_ROOT}/Modules/FindMPI.cmake) -# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") - message("include dirs are ${MPI_Fortran_INCLUDE_DIRS}") - message("include PATH ${MPI_Fortran_INCLUDE_PATH}") -endif() diff --git a/cmake/Modules/FindNDATE.cmake b/cmake/Modules/FindNDATE.cmake deleted file mode 100644 index 44bf4f1cd5..0000000000 --- a/cmake/Modules/FindNDATE.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# - Find the NDATE utility or build it - -set( NO_DEFAULT_PATH ) -if(DEFINED ENV{NDATE}) - set(NDATE $ENV{NDATE} ) -else() - find_file( NDATE - NAMES ndate.x ndate - HINTS - /nwprod/util/exec - $ENV{NWPROD}/util/exec - ${NO_DEFAULT_PATH}) -endif() diff --git a/cmake/Modules/FindNEMSIO.cmake b/cmake/Modules/FindNEMSIO.cmake deleted file mode 100644 index d5550bb530..0000000000 --- a/cmake/Modules/FindNEMSIO.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{NEMSIO_VER}) - set(NEMSIO_VER $ENV{NEMSIO_VER}) - STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_NEMSIO ) - if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) - set(NEMSIOINC $ENV{NEMSIO_INC} ) - message("NEMSIO library ${NEMSIO_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${NEMSIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${NEMSIO_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${NEMSIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${NEMSIOINC} ) -endif() - -set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) -set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) - diff --git a/cmake/Modules/FindSFCIO.cmake b/cmake/Modules/FindSFCIO.cmake deleted file mode 100644 index c137e1ca16..0000000000 --- a/cmake/Modules/FindSFCIO.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{SFCIO_VER}) - set(SFCIO_VER $ENV{SFCIO_VER}) - STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SFCIO ) - if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) - set(SFCIOINC $ENV{SFCIO_INC4} ) - message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") - elseif(DEFINED ENV{SFCIO_LIB} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB} ) - set(SFCIOINC $ENV{SFCIO_INC} ) - message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${SFCIO_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${SFCIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ) -endif() - -set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) -set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) - diff --git a/cmake/Modules/FindSIGIO.cmake b/cmake/Modules/FindSIGIO.cmake deleted file mode 100644 index 026c1f7921..0000000000 --- a/cmake/Modules/FindSIGIO.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{SIGIO_VER}) - set(SIGIO_VER $ENV{SIGIO_VER}) - STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SIGIO ) - if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) - set(SIGIOINC $ENV{SIGIO_INC4} ) - message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") - elseif(DEFINED ENV{SIGIO_LIB} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB} ) - set(SIGIOINC $ENV{SIGIO_INC} ) - message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SIGIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${SIGIO_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${SIGIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SIGIOINC} ) -endif() - - -set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) -set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) - diff --git a/cmake/Modules/FindSP.cmake b/cmake/Modules/FindSP.cmake deleted file mode 100644 index 2844870a93..0000000000 --- a/cmake/Modules/FindSP.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{SP_VER}) - set(SP_VER $ENV{SP_VER}) - STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SP ) - if(DEFINED ENV{SP_LIBd} ) - set(SP_LIBRARY $ENV{SP_LIBd} ) - message("SP library ${SP_LIBRARY} set via Environment variable") - endif() - if(DEFINED ENV{SP_LIB4} ) - set(SP_4_LIBRARY $ENV{SP_LIB4} ) - message("SP library ${SP_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SP_LIBRARY} ) -else() - set( CORE_LIBRARIES ${SP_LIBRARY} ) -endif() - - -set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) -set( SP_4_LIBRARY_PATH ${SP_4_LIBRARY} CACHE STRING "SP_4 Library Location" ) - diff --git a/cmake/Modules/FindW3EMC.cmake b/cmake/Modules/FindW3EMC.cmake deleted file mode 100644 index b87b4e7129..0000000000 --- a/cmake/Modules/FindW3EMC.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{W3EMC_VER}) - set(W3EMC_VER $ENV{W3EMC_VER}) - set(W3EMCINC $ENV{W3EMC_INCd} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) -endif() -if(DEFINED ENV{W3EMC_LIBd}) - set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) - set(W3EMCINC $ENV{W3EMC_INCd} ) - set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - message("Setting W3EMC library via environment variable ${W3EMC_LIBRARY}") -endif() - -set( NO_DEFAULT_PATH ) -if((NOT BUILD_W3EMC ) AND ( NOT DEFINED W3EMC_LIBRARY )) - if(DEFINED ENV{W3EMC_LIB} ) - set(W3EMC_LIBRARY $ENV{W3EMC_LIB} ) - set(W3EMCINC $ENV{W3EMC_INC} ) - set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - message("W3EMC library ${W3EMC_LIBRARY} set via Environment variable") - message("W3EMC_4 library ${W3EMC_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${W3EMC_LIBRARY} ) -else() - set( CORE_LIBRARIES ${W3EMC_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${W3EMCINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${W3EMCINC} ) -endif() - -set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) -set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) -set( W3EMC_4_LIBRARY_PATH ${W3EMC_4_LIBRARY} CACHE STRING "W3EMC_4 Library Location" ) -set( W3EMC_INCLUDE_4_PATH ${W3EMC4INC} CACHE STRING "W3EMC_4 Include Location" ) - diff --git a/cmake/Modules/FindW3NCO.cmake b/cmake/Modules/FindW3NCO.cmake deleted file mode 100644 index 0bdc184cc7..0000000000 --- a/cmake/Modules/FindW3NCO.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{W3NCO_VER}) - set(W3NCO_VER $ENV{W3NCO_VER}) - STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_W3NCO ) - if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) - set(W3NCO_4_LIBRARY $ENV{W3NCO_LIB4} ) - message("W3NCO library ${W3NCO_LIBRARY} set via Environment variable") - message("W3NCO_4 library ${W3NCO_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${W3NCO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${W3NCO_LIBRARY} ) -endif() - -set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) - diff --git a/cmake/Modules/FindWRF.cmake b/cmake/Modules/FindWRF.cmake deleted file mode 100644 index 43faf46643..0000000000 --- a/cmake/Modules/FindWRF.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# - Find the WRF modules - -set( NO_DEFAULT_PATH ) -find_library( IOINT_LIB - NAMES libwrfio_int.a - HINTS - ${WRFPATH}/external/io_int - $ENV{WRFPATH}/external/io_int - /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_int - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_int - ${NO_DEFAULT_PATH}) - -find_library( WRFNETCDF_LIB - NAMES libwrfio_nf.a - HINTS - ${WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf - $ENV{WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_netcdf - ${NO_DEFAULT_PATH}) -find_file( FRAMEPACK - NAMES pack_utils.o - HINTS - ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame - ${NO_DEFAULT_PATH}) -find_file( FRAMEMODULE - NAMES module_machine.o - HINTS - ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame - ${NO_DEFAULT_PATH}) - -set( WRF_LIBRARIES ${IOINT_LIB} ${WRFNETCDF_LIB} ${FRAMEPACK} ${FRAMEMODULE} ) - diff --git a/cmake/Modules/NewCMake/CMakeParseArguments.cmake b/cmake/Modules/NewCMake/CMakeParseArguments.cmake deleted file mode 100644 index 7ee2bbacef..0000000000 --- a/cmake/Modules/NewCMake/CMakeParseArguments.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CMakeParseArguments -# ------------------- -# -# This module once implemented the :command:`cmake_parse_arguments` command -# that is now implemented natively by CMake. It is now an empty placeholder -# for compatibility with projects that include it to get the command from -# CMake 3.4 and lower. diff --git a/cmake/Modules/NewCMake/FindHDF5.cmake b/cmake/Modules/NewCMake/FindHDF5.cmake deleted file mode 100644 index fd8891cf20..0000000000 --- a/cmake/Modules/NewCMake/FindHDF5.cmake +++ /dev/null @@ -1,934 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindHDF5 -# -------- -# -# Find HDF5, a library for reading and writing self describing array data. -# -# -# -# This module invokes the HDF5 wrapper compiler that should be installed -# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper -# compiler is called either h5cc or h5pcc. If this succeeds, the module -# will then call the compiler with the -show argument to see what flags -# are used when compiling an HDF5 client application. -# -# The module will optionally accept the COMPONENTS argument. If no -# COMPONENTS are specified, then the find module will default to finding -# only the HDF5 C library. If one or more COMPONENTS are specified, the -# module will attempt to find the language bindings for the specified -# components. The only valid components are C, CXX, Fortran, HL, and -# Fortran_HL. If the COMPONENTS argument is not given, the module will -# attempt to find only the C bindings. -# -# This module will read the variable -# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a -# static link to a dynamic link for HDF5 and all of it's dependencies. -# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES -# variable is set before the call to find_package. -# -# To provide the module with a hint about where to find your HDF5 -# installation, you can set the environment variable HDF5_ROOT. The -# Find module will then look in this path when searching for HDF5 -# executables, paths, and libraries. -# -# Both the serial and parallel HDF5 wrappers are considered and the first -# directory to contain either one will be used. In the event that both appear -# in the same directory the serial version is preferentially selected. This -# behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to -# true. -# -# In addition to finding the includes and libraries required to compile -# an HDF5 client application, this module also makes an effort to find -# tools that come with the HDF5 distribution that may be useful for -# regression testing. -# -# This module will define the following variables: -# -# :: -# -# HDF5_FOUND - true if HDF5 was found on the system -# HDF5_VERSION - HDF5 version in format Major.Minor.Release -# HDF5_INCLUDE_DIRS - Location of the hdf5 includes -# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) -# HDF5_DEFINITIONS - Required compiler definitions for HDF5 -# HDF5_LIBRARIES - Required libraries for all requested bindings -# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all -# bindings, if the HL component is enabled -# -# Available components are: C CXX Fortran and HL. For each enabled language -# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially -# HDF5_${LANG}_DEFINITIONS, will be defined. -# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will -# also be defined. With all components enabled, the following variables will be defined: -# -# :: -# -# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings -# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings -# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings -# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings -# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings -# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings -# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings -# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings -# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings -# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings -# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran -# bindings. -# -# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support -# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler -# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler -# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler -# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler -# which is also the HDF5 wrapper -# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ -# compiler which is also -# the HDF5 wrapper -# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary -# Fortran compiler which -# is also the HDF5 wrapper -# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool -# -# The following variable can be set to guide the search for HDF5 libraries and includes: -# -# ``HDF5_ROOT`` -# Specify the path to the HDF5 installation to use. -# -# ``HDF5_FIND_DEBUG`` -# Set to a true value to get some extra debugging output. -# -# ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` -# Set to a true value to skip trying to find ``hdf5-config.cmake``. - -# This module is maintained by Will Dicharry . - -include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -# List of the valid HDF5 components -set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) - -# Validate the list of find components. -if(NOT HDF5_FIND_COMPONENTS) - set(HDF5_LANGUAGE_BINDINGS "C") -else() - set(HDF5_LANGUAGE_BINDINGS) - # add the extra specified components, ensuring that they are valid. - set(FIND_HL OFF) - foreach(component IN LISTS HDF5_FIND_COMPONENTS) - list(FIND HDF5_VALID_LANGUAGE_BINDINGS ${component} component_location) - if(NOT component_location EQUAL -1) - list(APPEND HDF5_LANGUAGE_BINDINGS ${component}) - elseif(component STREQUAL "HL") - set(FIND_HL ON) - elseif(component STREQUAL "Fortran_HL") # only for compatibility - list(APPEND HDF5_LANGUAGE_BINDINGS Fortran) - set(FIND_HL ON) - set(HDF5_FIND_REQUIRED_Fortran_HL False) - set(HDF5_FIND_REQUIRED_Fortran True) - set(HDF5_FIND_REQUIRED_HL True) - else() - message(FATAL_ERROR "${component} is not a valid HDF5 component.") - endif() - endforeach() - if(NOT HDF5_LANGUAGE_BINDINGS) - get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(__lang IN LISTS __langs) - if(__lang MATCHES "^(C|CXX|Fortran)$") - list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) - endif() - endforeach() - endif() - list(REMOVE_ITEM HDF5_FIND_COMPONENTS Fortran_HL) # replaced by Fortran and HL - list(REMOVE_DUPLICATES HDF5_LANGUAGE_BINDINGS) -endif() - -# Determine whether to search for serial or parallel executable first -if(HDF5_PREFER_PARALLEL) - set(HDF5_C_COMPILER_NAMES h5pcc h5cc) - set(HDF5_CXX_COMPILER_NAMES h5pc++ h5c++) - set(HDF5_Fortran_COMPILER_NAMES h5pfc h5fc) -else() - set(HDF5_C_COMPILER_NAMES h5cc h5pcc) - set(HDF5_CXX_COMPILER_NAMES h5c++ h5pc++) - set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc) -endif() - -# We may have picked up some duplicates in various lists during the above -# process for the language bindings (both the C and C++ bindings depend on -# libz for example). Remove the duplicates. It appears that the default -# CMake behavior is to remove duplicates from the end of a list. However, -# for link lines, this is incorrect since unresolved symbols are searched -# for down the link line. Therefore, we reverse the list, remove the -# duplicates, and then reverse it again to get the duplicates removed from -# the beginning. -macro(_HDF5_remove_duplicates_from_beginning _list_name) - if(${_list_name}) - list(REVERSE ${_list_name}) - list(REMOVE_DUPLICATES ${_list_name}) - list(REVERSE ${_list_name}) - endif() -endmacro() - - -# Test first if the current compilers automatically wrap HDF5 - -function(_HDF5_test_regular_compiler_C success version is_parallel) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_c) - set(test_file ${scratch_directory}/cmake_hdf5_test.c) - file(WRITE ${test_file} - "#include \n" - "#include \n" - "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" - "#ifdef H5_HAVE_PARALLEL\n" - "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" - "#endif\n" - "int main(int argc, char **argv) {\n" - " int require = 0;\n" - " require += info_ver[argc];\n" - "#ifdef H5_HAVE_PARALLEL\n" - " require += info_parallel[argc];\n" - "#endif\n" - " hid_t fid;\n" - " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" - " return 0;\n" - "}") - try_compile(${success} ${scratch_directory} ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_c - ) - endif() - if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS - REGEX "^INFO:" - ) - string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_STRINGS}" - ) - set(${version} ${CMAKE_MATCH_1}) - if(CMAKE_MATCH_3) - set(${version} ${HDF5_C_VERSION}.${CMAKE_MATCH_3}) - endif() - set(${version} ${${version}} PARENT_SCOPE) - - if(INFO_STRINGS MATCHES "INFO:PARALLEL") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - -function(_HDF5_test_regular_compiler_CXX success version is_parallel) - set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_cxx) - set(test_file ${scratch_directory}/cmake_hdf5_test.cxx) - file(WRITE ${test_file} - "#include \n" - "#ifndef H5_NO_NAMESPACE\n" - "using namespace H5;\n" - "#endif\n" - "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" - "#ifdef H5_HAVE_PARALLEL\n" - "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" - "#endif\n" - "int main(int argc, char **argv) {\n" - " int require = 0;\n" - " require += info_ver[argc];\n" - "#ifdef H5_HAVE_PARALLEL\n" - " require += info_parallel[argc];\n" - "#endif\n" - " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" - " return 0;\n" - "}") - try_compile(${success} ${scratch_directory} ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_cxx - ) - endif() - if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS - REGEX "^INFO:" - ) - string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_STRINGS}" - ) - set(${version} ${CMAKE_MATCH_1}) - if(CMAKE_MATCH_3) - set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3}) - endif() - set(${version} ${${version}} PARENT_SCOPE) - - if(INFO_STRINGS MATCHES "INFO:PARALLEL") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - -function(_HDF5_test_regular_compiler_Fortran success is_parallel) - if(NOT ${success}) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - set(test_file ${scratch_directory}/cmake_hdf5_test.f90) - file(WRITE ${test_file} - "program hdf5_hello\n" - " use hdf5\n" - " use h5lt\n" - " use h5ds\n" - " integer error\n" - " call h5open_f(error)\n" - " call h5close_f(error)\n" - "end\n") - try_compile(${success} ${scratch_directory} ${test_file}) - if(${success}) - execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig - OUTPUT_VARIABLE config_output - ERROR_VARIABLE config_error - RESULT_VARIABLE config_result - ) - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() - endif() -endfunction() - -# Invoke the HDF5 wrapper compiler. The compiler return value is stored to the -# return_value argument, the text output is stored to the output variable. -macro( _HDF5_invoke_compiler language output return_value version is_parallel) - set(${version}) - if(HDF5_USE_STATIC_LIBRARIES) - set(lib_type_args -noshlib) - else() - set(lib_type_args -shlib) - endif() - set(scratch_dir ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if("${language}" STREQUAL "C") - set(test_file ${scratch_dir}/cmake_hdf5_test.c) - elseif("${language}" STREQUAL "CXX") - set(test_file ${scratch_dir}/cmake_hdf5_test.cxx) - elseif("${language}" STREQUAL "Fortran") - set(test_file ${scratch_dir}/cmake_hdf5_test.f90) - endif() - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -show ${lib_type_args} ${test_file} - OUTPUT_VARIABLE ${output} - RETURN_VALUE ${return_value} - ) - if(NOT ${${return_value}} EQUAL 0) - message(STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") - endif() - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -showconfig - OUTPUT_VARIABLE config_output - RETURN_VALUE config_return - ) - if(NOT ${return_value} EQUAL 0) - message( STATUS - "Unable to determine HDF5 ${language} version from HDF5 wrapper.") - endif() - string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}") - if(version_match) - string(REPLACE "HDF5 Version: " "" ${version} "${version_match}") - string(REPLACE "-patch" "." ${version} "${${version}}") - endif() - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE) - else() - set(${is_parallel} FALSE) - endif() -endmacro() - -# Parse a compile line for definitions, includes, library paths, and libraries. -macro( _HDF5_parse_compile_line - compile_line_var - include_paths - definitions - library_paths - libraries - libraries_hl) - - separate_arguments(_HDF5_COMPILE_ARGS UNIX_COMMAND "${${compile_line_var}}") - - foreach(arg IN LISTS _HDF5_COMPILE_ARGS) - if("${arg}" MATCHES "^-I(.*)$") - # include directory - list(APPEND ${include_paths} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-D(.*)$") - # compile definition - list(APPEND ${definitions} "-D${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-L(.*)$") - # library search path - list(APPEND ${library_paths} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-l(hdf5.*hl.*)$") - # library name (hl) - list(APPEND ${libraries_hl} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-l(.*)$") - # library name - list(APPEND ${libraries} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.(a|so|dylib|sl|lib)$") - # library file - if(NOT EXISTS "${arg}") - continue() - endif() - get_filename_component(_HDF5_LPATH "${arg}" DIRECTORY) - get_filename_component(_HDF5_LNAME "${arg}" NAME_WE) - string(REGEX REPLACE "^lib" "" _HDF5_LNAME "${_HDF5_LNAME}") - list(APPEND ${library_paths} "${_HDF5_LPATH}") - if(_HDF5_LNAME MATCHES "hdf5.*hl") - list(APPEND ${libraries_hl} "${_HDF5_LNAME}") - else() - list(APPEND ${libraries} "${_HDF5_LNAME}") - endif() - endif() - endforeach() -endmacro() - -# Select a preferred imported configuration from a target -function(_HDF5_select_imported_config target imported_conf) - # We will first assign the value to a local variable _imported_conf, then assign - # it to the function argument at the end. - get_target_property(_imported_conf ${target} MAP_IMPORTED_CONFIG_${CMAKE_BUILD_TYPE}) - if (NOT _imported_conf) - # Get available imported configurations by examining target properties - get_target_property(_imported_conf ${target} IMPORTED_CONFIGURATIONS) - if(HDF5_FIND_DEBUG) - message(STATUS "Found imported configurations: ${_imported_conf}") - endif() - # Find the imported configuration that we prefer. - # We do this by making list of configurations in order of preference, - # starting with ${CMAKE_BUILD_TYPE} and ending with the first imported_conf - set(_preferred_confs ${CMAKE_BUILD_TYPE}) - list(GET _imported_conf 0 _fallback_conf) - list(APPEND _preferred_confs RELWITHDEBINFO RELEASE DEBUG ${_fallback_conf}) - if(HDF5_FIND_DEBUG) - message(STATUS "Start search through imported configurations in the following order: ${_preferred_confs}") - endif() - # Now find the first of these that is present in imported_conf - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) # support IN_LISTS - foreach (_conf IN LISTS _preferred_confs) - if (${_conf} IN_LIST _imported_conf) - set(_imported_conf ${_conf}) - break() - endif() - endforeach() - cmake_policy(POP) - endif() - if(HDF5_FIND_DEBUG) - message(STATUS "Selected imported configuration: ${_imported_conf}") - endif() - # assign value to function argument - set(${imported_conf} ${_imported_conf} PARENT_SCOPE) -endfunction() - - -if(NOT HDF5_ROOT) - set(HDF5_ROOT $ENV{HDF5_ROOT}) -endif() -if(HDF5_ROOT) - set(_HDF5_SEARCH_OPTS NO_DEFAULT_PATH) -else() - set(_HDF5_SEARCH_OPTS) -endif() - -# Try to find HDF5 using an installed hdf5-config.cmake -if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) - find_package(HDF5 QUIET NO_MODULE - HINTS ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS} - ) - if( HDF5_FOUND) - if(HDF5_FIND_DEBUG) - message(STATUS "Found HDF5 at ${HDF5_DIR} via NO_MODULE. Now trying to extract locations etc.") - endif() - set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) - set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) - set(HDF5_LIBRARIES) - if (NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) - # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc - set(_target_prefix "hdf5::") - endif() - set(HDF5_C_TARGET ${_target_prefix}hdf5) - set(HDF5_C_HL_TARGET ${_target_prefix}hdf5_hl) - set(HDF5_CXX_TARGET ${_target_prefix}hdf5_cpp) - set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) - set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) - set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) - set(HDF5_DEFINITIONS "") - if(HDF5_USE_STATIC_LIBRARIES) - set(_suffix "-static") - else() - set(_suffix "-shared") - endif() - foreach(_lang ${HDF5_LANGUAGE_BINDINGS}) - - #Older versions of hdf5 don't have a static/shared suffix so - #if we detect that occurrence clear the suffix - if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix}) - if(NOT TARGET ${HDF5_${_lang}_TARGET}) - #cant find this component with or without the suffix - #so bail out, and let the following locate HDF5 - set(HDF5_FOUND FALSE) - break() - endif() - set(_suffix "") - endif() - - if(HDF5_FIND_DEBUG) - message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") - endif() - # Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib. - _HDF5_select_imported_config(${HDF5_${_lang}_TARGET}${_suffix} _hdf5_imported_conf) - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) - if (NOT _hdf5_lang_location) - # no import lib, just try LOCATION - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) - if (NOT _hdf5_lang_location) - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) - endif() - endif() - if( _hdf5_lang_location ) - set(HDF5_${_lang}_LIBRARY ${_hdf5_lang_location}) - list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) - set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) - set(HDF5_${_lang}_FOUND True) - endif() - if(FIND_HL) - get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) - if (NOT _hdf5_lang_hl_location) - get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) - if (NOT _hdf5_hl_lang_location) - get_target_property(_hdf5_hl_lang_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) - endif() - endif() - if( _hdf5_lang_hl_location ) - set(HDF5_${_lang}_HL_LIBRARY ${_hdf5_lang_hl_location}) - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) - set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) - set(HDF5_HL_FOUND True) - endif() - unset(_hdf5_lang_hl_location) - endif() - unset(_hdf5_imported_conf) - unset(_hdf5_lang_location) - endforeach() - endif() -endif() - -if(NOT HDF5_FOUND) - set(_HDF5_NEED_TO_SEARCH False) - set(HDF5_COMPILER_NO_INTERROGATE True) - # Only search for languages we've enabled - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # First check to see if our regular compiler is one of wrappers - if(__lang STREQUAL "C") - _HDF5_test_regular_compiler_C( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_VERSION - HDF5_${__lang}_IS_PARALLEL) - elseif(__lang STREQUAL "CXX") - _HDF5_test_regular_compiler_CXX( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_VERSION - HDF5_${__lang}_IS_PARALLEL) - elseif(__lang STREQUAL "Fortran") - _HDF5_test_regular_compiler_Fortran( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_IS_PARALLEL) - else() - continue() - endif() - if(HDF5_${__lang}_COMPILER_NO_INTERROGATE) - message(STATUS "HDF5: Using hdf5 compiler wrapper for all ${__lang} compiling") - set(HDF5_${__lang}_FOUND True) - set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE - "${CMAKE_${__lang}_COMPILER}" - CACHE FILEPATH "HDF5 ${__lang} compiler wrapper") - set(HDF5_${__lang}_DEFINITIONS) - set(HDF5_${__lang}_INCLUDE_DIRS) - set(HDF5_${__lang}_LIBRARIES) - set(HDF5_${__lang}_HL_LIBRARIES) - - mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE) - - set(HDF5_${__lang}_FOUND True) - set(HDF5_HL_FOUND True) - else() - set(HDF5_COMPILER_NO_INTERROGATE False) - # If this language isn't using the wrapper, then try to seed the - # search options with the wrapper - find_program(HDF5_${__lang}_COMPILER_EXECUTABLE - NAMES ${HDF5_${__lang}_COMPILER_NAMES} NAMES_PER_DIR - HINTS ${HDF5_ROOT} - PATH_SUFFIXES bin Bin - DOC "HDF5 ${__lang} Wrapper compiler. Used only to detect HDF5 compile flags." - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced( HDF5_${__lang}_COMPILER_EXECUTABLE ) - unset(HDF5_${__lang}_COMPILER_NAMES) - - if(HDF5_${__lang}_COMPILER_EXECUTABLE) - _HDF5_invoke_compiler(${__lang} HDF5_${__lang}_COMPILE_LINE - HDF5_${__lang}_RETURN_VALUE HDF5_${__lang}_VERSION HDF5_${__lang}_IS_PARALLEL) - if(HDF5_${__lang}_RETURN_VALUE EQUAL 0) - message(STATUS "HDF5: Using hdf5 compiler wrapper to determine ${__lang} configuration") - _HDF5_parse_compile_line( HDF5_${__lang}_COMPILE_LINE - HDF5_${__lang}_INCLUDE_DIRS - HDF5_${__lang}_DEFINITIONS - HDF5_${__lang}_LIBRARY_DIRS - HDF5_${__lang}_LIBRARY_NAMES - HDF5_${__lang}_HL_LIBRARY_NAMES - ) - set(HDF5_${__lang}_LIBRARIES) - - foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES) - set(_HDF5_SEARCH_NAMES_LOCAL) - if("x${L}" MATCHES "hdf5") - # hdf5 library - set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) - if(HDF5_USE_STATIC_LIBRARIES) - if(WIN32) - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) - else() - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) - endif() - endif() - else() - # external library - set(_HDF5_SEARCH_OPTS_LOCAL) - endif() - find_library(HDF5_${__lang}_LIBRARY_${L} - NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR - HINTS ${HDF5_${__lang}_LIBRARY_DIRS} - ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS_LOCAL} - ) - unset(_HDF5_SEARCH_OPTS_LOCAL) - unset(_HDF5_SEARCH_NAMES_LOCAL) - if(HDF5_${__lang}_LIBRARY_${L}) - list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) - else() - list(APPEND HDF5_${__lang}_LIBRARIES ${L}) - endif() - endforeach() - if(FIND_HL) - set(HDF5_${__lang}_HL_LIBRARIES) - foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) - set(_HDF5_SEARCH_NAMES_LOCAL) - if("x${L}" MATCHES "hdf5") - # hdf5 library - set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) - if(HDF5_USE_STATIC_LIBRARIES) - if(WIN32) - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) - else() - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) - endif() - endif() - else() - # external library - set(_HDF5_SEARCH_OPTS_LOCAL) - endif() - find_library(HDF5_${__lang}_LIBRARY_${L} - NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR - HINTS ${HDF5_${__lang}_LIBRARY_DIRS} - ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS_LOCAL} - ) - unset(_HDF5_SEARCH_OPTS_LOCAL) - unset(_HDF5_SEARCH_NAMES_LOCAL) - if(HDF5_${__lang}_LIBRARY_${L}) - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) - else() - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${L}) - endif() - endforeach() - set(HDF5_HL_FOUND True) - endif() - - set(HDF5_${__lang}_FOUND True) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_HL_LIBRARIES) - else() - set(_HDF5_NEED_TO_SEARCH True) - endif() - else() - set(_HDF5_NEED_TO_SEARCH True) - endif() - endif() - if(HDF5_${__lang}_VERSION) - if(NOT HDF5_VERSION) - set(HDF5_VERSION ${HDF5_${__lang}_VERSION}) - elseif(NOT HDF5_VERSION VERSION_EQUAL HDF5_${__lang}_VERSION) - message(WARNING "HDF5 Version found for language ${__lang}, ${HDF5_${__lang}_VERSION} is different than previously found version ${HDF5_VERSION}") - endif() - endif() - if(DEFINED HDF5_${__lang}_IS_PARALLEL) - if(NOT DEFINED HDF5_IS_PARALLEL) - set(HDF5_IS_PARALLEL ${HDF5_${__lang}_IS_PARALLEL}) - elseif(NOT HDF5_IS_PARALLEL AND HDF5_${__lang}_IS_PARALLEL) - message(WARNING "HDF5 found for language ${__lang} is parallel but previously found language is not parallel.") - elseif(HDF5_IS_PARALLEL AND NOT HDF5_${__lang}_IS_PARALLEL) - message(WARNING "HDF5 found for language ${__lang} is not parallel but previously found language is parallel.") - endif() - endif() - endforeach() -else() - set(_HDF5_NEED_TO_SEARCH True) -endif() - -if(NOT HDF5_FOUND AND HDF5_COMPILER_NO_INTERROGATE) - # No arguments necessary, all languages can use the compiler wrappers - set(HDF5_FOUND True) - set(HDF5_METHOD "Included by compiler wrappers") - set(HDF5_REQUIRED_VARS HDF5_METHOD) -elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH) - # Compiler wrappers aren't being used by the build but were found and used - # to determine necessary include and library flags - set(HDF5_INCLUDE_DIRS) - set(HDF5_LIBRARIES) - set(HDF5_HL_LIBRARIES) - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - if(HDF5_${__lang}_FOUND) - if(NOT HDF5_${__lang}_COMPILER_NO_INTERROGATE) - list(APPEND HDF5_DEFINITIONS ${HDF5_${__lang}_DEFINITIONS}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIRS}) - list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) - if(FIND_HL) - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) - endif() - endif() - endif() - endforeach() - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) - set(HDF5_FOUND True) - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES) - if(FIND_HL) - list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) - endif() -endif() - -find_program( HDF5_DIFF_EXECUTABLE - NAMES h5diff - HINTS ${HDF5_ROOT} - PATH_SUFFIXES bin Bin - ${_HDF5_SEARCH_OPTS} - DOC "HDF5 file differencing tool." ) -mark_as_advanced( HDF5_DIFF_EXECUTABLE ) - -if( NOT HDF5_FOUND ) - # seed the initial lists of libraries to find with items we know we need - set(HDF5_C_LIBRARY_NAMES hdf5) - set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl) - - set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES}) - set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES}) - - set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES}) - set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES}) - - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # find the HDF5 include directories - if("${__lang}" STREQUAL "Fortran") - set(HDF5_INCLUDE_FILENAME hdf5.mod) - elseif("${__lang}" STREQUAL "CXX") - set(HDF5_INCLUDE_FILENAME H5Cpp.h) - else() - set(HDF5_INCLUDE_FILENAME hdf5.h) - endif() - - find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} - HINTS ${HDF5_ROOT} - PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR) - # set the _DIRS variable as this is what the user will normally use - set(HDF5_${__lang}_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) - - # find the HDF5 libraries - foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES) - if(HDF5_USE_STATIC_LIBRARIES) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG - lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug - lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_D-static ${LIB}_debug-static ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a lib${LIB} lib${LIB}-static.a ${LIB}-static) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) - if(WIN32) - list(APPEND HDF5_DEFINITIONS "-DH5_BUILT_AS_DYNAMIC_LIB") - endif() - endif() - find_library(HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - if(HDF5_${__lang}_LIBRARIES) - set(HDF5_${__lang}_FOUND True) - endif() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) - - if(FIND_HL) - foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) - if(HDF5_USE_STATIC_LIBRARIES) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG - lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug - lib${LIB}d-static.a lib${LIB}_debug-static.a lib${LIB}d-static lib${LIB}_D-static lib${LIB}_debug-static ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a lib${LIB}-static) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) - endif() - find_library(HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) - endif() - endforeach() - if(FIND_HL AND HDF5_HL_LIBRARIES) - set(HDF5_HL_FOUND True) - endif() - - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) - - # If the HDF5 include directory was found, open H5pubconf.h to determine if - # HDF5 was compiled with parallel IO support - set( HDF5_IS_PARALLEL FALSE ) - set( HDF5_VERSION "" ) - foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) - foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h") - if( EXISTS "${_hdr}" ) - file( STRINGS "${_hdr}" - HDF5_HAVE_PARALLEL_DEFINE - REGEX "HAVE_PARALLEL 1" ) - if( HDF5_HAVE_PARALLEL_DEFINE ) - set( HDF5_IS_PARALLEL TRUE ) - endif() - unset(HDF5_HAVE_PARALLEL_DEFINE) - - file( STRINGS "${_hdr}" - HDF5_VERSION_DEFINE - REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" ) - if( "${HDF5_VERSION_DEFINE}" MATCHES - "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?\"" ) - set( HDF5_VERSION "${CMAKE_MATCH_1}" ) - if( CMAKE_MATCH_3 ) - set( HDF5_VERSION ${HDF5_VERSION}.${CMAKE_MATCH_3}) - endif() - endif() - unset(HDF5_VERSION_DEFINE) - endif() - endforeach() - endforeach() - set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL - "HDF5 library compiled with parallel IO support" ) - mark_as_advanced( HDF5_IS_PARALLEL ) - - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) - if(FIND_HL) - list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) - endif() -endif() - -# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of -# HDF5_INCLUDE_DIRS -if( HDF5_INCLUDE_DIRS ) - set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) -endif() - -# If HDF5_REQUIRED_VARS is empty at this point, then it's likely that -# something external is trying to explicitly pass already found -# locations -if(NOT HDF5_REQUIRED_VARS) - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) -endif() - -find_package_handle_standard_args(HDF5 - REQUIRED_VARS ${HDF5_REQUIRED_VARS} - VERSION_VAR HDF5_VERSION - HANDLE_COMPONENTS -) - -unset(_HDF5_SEARCH_OPTS) - -if( HDF5_FOUND AND NOT HDF5_DIR) - # hide HDF5_DIR for the non-advanced user to avoid confusion with - # HDF5_DIR-NOT_FOUND while HDF5 was found. - mark_as_advanced(HDF5_DIR) -endif() - -if (HDF5_FIND_DEBUG) - message(STATUS "HDF5_DIR: ${HDF5_DIR}") - message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") - message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") - message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") - message(STATUS "HDF5_HL_LIBRARIES: ${HDF5_HL_LIBRARIES}") - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}") - message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}") - message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}") - message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}") - message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}") - message(STATUS "HDF5_${__lang}_HL_LIBRARY: ${HDF5_${__lang}_HL_LIBRARY}") - message(STATUS "HDF5_${__lang}_HL_LIBRARIES: ${HDF5_${__lang}_HL_LIBRARIES}") - endforeach() -endif() diff --git a/cmake/Modules/NewCMake/FindMPI.cmake b/cmake/Modules/NewCMake/FindMPI.cmake deleted file mode 100644 index 5cd2a2afe7..0000000000 --- a/cmake/Modules/NewCMake/FindMPI.cmake +++ /dev/null @@ -1,1514 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindMPI -# ------- -# -# Find a Message Passing Interface (MPI) implementation. -# -# The Message Passing Interface (MPI) is a library used to write -# high-performance distributed-memory parallel applications, and is -# typically deployed on a cluster. MPI is a standard interface (defined -# by the MPI forum) for which many implementations are available. -# -# Variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. -# Each of these controls the various MPI languages to search for. -# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the -# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API -# that was removed again in MPI-3. -# -# Depending on the enabled components the following variables will be set: -# -# ``MPI_FOUND`` -# Variable indicating that MPI settings for all requested languages have been found. -# If no components are specified, this is true if MPI settings for all enabled languages -# were detected. Note that the ``MPICXX`` component does not affect this variable. -# ``MPI_VERSION`` -# Minimal version of MPI detected among the requested languages, or all enabled languages -# if no components were specified. -# -# This module will set the following variables per language in your -# project, where ```` is one of C, CXX, or Fortran: -# -# ``MPI__FOUND`` -# Variable indicating the MPI settings for ```` were found and that -# simple MPI test programs compile with the provided settings. -# ``MPI__COMPILER`` -# MPI compiler for ```` if such a program exists. -# ``MPI__COMPILE_OPTIONS`` -# Compilation options for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__COMPILE_DEFINITIONS`` -# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__INCLUDE_DIRS`` -# Include path(s) for MPI header. -# ``MPI__LINK_FLAGS`` -# Linker flags for MPI programs. -# ``MPI__LIBRARIES`` -# All libraries to link MPI programs against. -# -# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: -# -# ``MPI::MPI_`` -# Target for using MPI from ````. -# -# The following variables indicating which bindings are present will be defined: -# -# ``MPI_MPICXX_FOUND`` -# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). -# ``MPI_Fortran_HAVE_F77_HEADER`` -# True if the Fortran 77 header ``mpif.h`` is available. -# ``MPI_Fortran_HAVE_F90_MODULE`` -# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). -# ``MPI_Fortran_HAVE_F08_MODULE`` -# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). -# -# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version -# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. -# -# ``MPI__VERSION_MAJOR`` -# Major version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION_MINOR`` -# Minor version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION`` -# MPI version implemented for ```` by the MPI distribution. -# -# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards -# always have required this binding to work in both C and C++ code. -# -# For running MPI programs, the module sets the following variables -# -# ``MPIEXEC_EXECUTABLE`` -# Executable for running MPI programs, if such exists. -# ``MPIEXEC_NUMPROC_FLAG`` -# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. -# ``MPIEXEC_MAX_NUMPROCS`` -# Number of MPI processors to utilize. Defaults to the number -# of processors detected on the host system. -# ``MPIEXEC_PREFLAGS`` -# Flags to pass to ``mpiexec`` directly before the executable to run. -# ``MPIEXEC_POSTFLAGS`` -# Flags to pass to ``mpiexec`` after other flags. -# -# Variables for locating MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# This module performs a three step search for an MPI implementation: -# -# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a -# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. -# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. -# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. -# Currently, only Microsoft MPI and MPICH2 on Windows are supported. -# -# For controlling the second step, the following variables may be set: -# -# ``MPI__COMPILER`` -# Search for the specified compiler wrapper and use it. -# ``MPI__COMPILER_FLAGS`` -# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers -# support linking debug or tracing libraries if a specific flag is passed and this variable -# may be used to obtain them. -# ``MPI_COMPILER_FLAGS`` -# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. -# Empty by default. -# ``MPI_EXECUTABLE_SUFFIX`` -# A suffix which is appended to all names that are being looked for. For instance you may set this -# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. -# -# In order to control the guessing step, the following variable may be set: -# -# ``MPI_GUESS_LIBRARY_NAME`` -# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. -# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. -# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. -# -# Each of the search steps may be skipped with the following control variables: -# -# ``MPI_ASSUME_NO_BUILTIN_MPI`` -# If true, the module assumes that the compiler itself does not provide an MPI implementation and -# skips to step 2. -# ``MPI_SKIP_COMPILER_WRAPPER`` -# If true, no compiler wrapper will be searched for. -# ``MPI_SKIP_GUESSING`` -# If true, the guessing step will be skipped. -# -# Additionally, the following control variable is available to change search behavior: -# -# ``MPI_CXX_SKIP_MPICXX`` -# Add some definitions that will disable the MPI-2 C++ bindings. -# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, -# for example MVAPICH or Intel MPI. -# -# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to -# the module did not work and even a simple MPI test program failed to compile. -# -# If all of these parameters were not sufficient to find the right MPI implementation, a user may -# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` -# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. -# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the -# settings in the cache. -# -# Cache variables for MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. -# For C and CXX: -# -# ``MPI__HEADER_DIR`` -# Location of the ``mpi.h`` header on disk. -# -# For Fortran: -# -# ``MPI_Fortran_F77_HEADER_DIR`` -# Location of the Fortran 77 header ``mpif.h``, if it exists. -# ``MPI_Fortran_MODULE_DIR`` -# Location of the ``mpi`` or ``mpi_f08`` modules, if available. -# -# For all languages the following variables are additionally considered: -# -# ``MPI__ADDITIONAL_INCLUDE_DIRS`` -# A :ref:`;-list ` of paths needed in addition to the normal include directories. -# ``MPI__INCLUDE_DIR`` -# Path variables for include folders referred to by ````. -# ``MPI__ADDITIONAL_INCLUDE_VARS`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: -# -# ``MPI__LIBRARY`` -# The location of a library called ```` for use with MPI. -# ``MPI__LIB_NAMES`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# Usage of mpiexec -# ^^^^^^^^^^^^^^^^ -# -# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically -# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: -# -# :: -# -# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} -# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS -# -# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to -# pass to the MPI program. -# -# Advanced variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module can perform some advanced feature detections upon explicit request. -# -# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. -# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. -# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. -# You should only enable these detections if you absolutely need the information. -# -# If the following variables are set to true, the respective search will be performed: -# -# ``MPI_DETERMINE_Fortran_CAPABILITIES`` -# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and -# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` -# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and -# ``F08_MODULE``. -# ``MPI_DETERMINE_LIBRARY_VERSION`` -# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. -# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. -# Note that the return value is entirely implementation defined. This information might be used to identify -# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# For backward compatibility with older versions of FindMPI, these -# variables are set, but deprecated: -# -# :: -# -# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY -# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS -# MPI_LIBRARIES -# -# In new projects, please use the ``MPI__XXX`` equivalents. -# Additionally, the following variables are deprecated: -# -# ``MPI__COMPILE_FLAGS`` -# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. -# ``MPI__INCLUDE_PATH`` -# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. -# ``MPIEXEC`` -# Use ``MPIEXEC_EXECUTABLE`` instead. - -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -# Generic compiler names -set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) -set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ - mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) -set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r - mpif90 mpif90_r mpf90 mpf90_r - mpif77 mpif77_r mpf77 mpf77_r - mpifc) - -# GNU compiler names -set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) -set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) -set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r - mpig77 mpig77_r mpg77 mpg77_r) - -# Intel MPI compiler names on Windows -if(WIN32) - list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) - list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) - list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) - - # Intel MPI compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) - - # Intel MPI compiler names for MSMPI - set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) - set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) -else() - # Intel compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) -endif() - -# PGI compiler names -set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) -set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) -set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) - -# XLC MPI Compiler names -set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) -set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC - mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) -set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r - mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r - mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r - mpixlf mpixlf_r mpxlf mpxlf_r) - -# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, -# attempt all of them. -# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper -# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI -# controls its settings via the I_MPI_CC environment variables if the generic name is being used. -# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to -# pick up the right settings for it. -foreach (LANG IN ITEMS C CXX Fortran) - set(_MPI_${LANG}_COMPILER_NAMES "") - foreach (id IN ITEMS GNU Intel MSVC PGI XL) - if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - endif() - unset(_MPI_${id}_${LANG}_COMPILER_NAMES) - endforeach() - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) -endforeach() - -# Names to try for mpiexec -# Only mpiexec commands are guaranteed to behave as described in the standard, -# mpirun commands are not covered by the standard in any way whatsoever. -# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. -# srun -n X is however a valid command, so it behaves 'like' mpiexec. -set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) - -unset(_MPIEXEC_NAMES) -foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) - list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") -endforeach() -unset(_MPIEXEC_NAMES_BASE) - -function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) - if(DEFINED MPI_${LANG}_COMPILER_FLAGS) -# separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS "${MPI_${LANG}_COMPILER_FLAGS}") - else() - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") - endif() - execute_process( - COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} - OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE WRAPPER_RETURN) - # Some compiler wrappers will yield spurious zero return values, for example - # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared - # library that has invalid or missing version information there would be warning - # messages emitted by ld.so in the compiler output. In either case, we'll treat - # the output as invalid. - if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") - set(WRAPPER_RETURN 255) - endif() - # Ensure that no error output might be passed upwards. - if(NOT WRAPPER_RETURN EQUAL 0) - unset(WRAPPER_OUTPUT) - endif() - set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) - set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) -endfunction() - -function (_MPI_interrogate_compiler lang) - unset(MPI_COMPILE_CMDLINE) - unset(MPI_LINK_CMDLINE) - - unset(MPI_COMPILE_OPTIONS_WORK) - unset(MPI_COMPILE_DEFINITIONS_WORK) - unset(MPI_INCLUDE_DIRS_WORK) - unset(MPI_LINK_FLAGS_WORK) - unset(MPI_LIB_NAMES_WORK) - unset(MPI_LIB_FULLPATHS_WORK) - - # Check whether the -showme:compile option works. This indicates that we have either Open MPI - # or a newer version of LAM/MPI, and implies that -showme:link will also work. - # Open MPI also supports -show, but separates linker and compiler information - _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - - # MPICH and MVAPICH offer -compile-info and -link-info. - # For modern versions, both do the same as -show. However, for old versions, they do differ - # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the - # removed MPI C++ bindings. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - endif() - - # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the - # -showme commands are more specialized. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - # Older versions of LAM/MPI have "-showme". Open MPI also supports this. - # Unknown to MPICH, MVAPICH and Intel MPI. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) - # Cannot interrogate this compiler, so exit. - set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) - return() - endif() - unset(MPI_COMPILER_RETURN) - - # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE - # into MPI_LINK_CMDLINE, if we didn't find the link line. - if (NOT DEFINED MPI_LINK_CMDLINE) - set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") - endif() - - # At this point, we obtained some output from a compiler wrapper that works. - # We'll now try to parse it into variables with meaning to us. - if("${LANG}" STREQUAL "Fortran") - # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting - # out of a symlink command for mpif.h, the actual compiler command and a deletion of the - # created symlink. We need to detect that case, remember the include path and drop the - # symlink/deletion operation to obtain the link/compile lines we'd usually expect. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") - get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - endif() - - # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command - # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. - if(UNIX) - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - - # Extract compile options from the compile command line. - string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) - string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") - # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries - # themselves were built with this flag. However, this flag is unrelated to using MPI, and - # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore - # produce inconsistent results with the regularly flags. - # Similarly, aliasing flags do not belong into our flag array. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") - list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") - endif() - endforeach() - - # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. - string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) - string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") - endif() - endforeach() - - # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:incdirs. - if (NOT MPI_ALL_INCLUDE_PATHS) - _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) - if(MPI_INCDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) - string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) - list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") - endforeach() - - # Extract linker paths from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:libdirs. - if (NOT MPI_ALL_LINK_PATHS) - _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) - if(MPI_LIBDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) - string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") - string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") - get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") - endforeach() - - # Extract linker flags from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) - string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) - # MPI might be marked to build with non-executable stacks but this should not propagate. - if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") - if (MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") - else() - set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") - endif() - endif() - endforeach() - - # Extract the set of libraries to link against from the link command - # line - string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - - if(WIN32) - # A compiler wrapper on Windows will just have the name of the - # library to link on its link line, potentially with a full path - string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - else() - # On UNIX platforms, archive libraries can be given with full path. - string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - endif() - - # An MPI compiler wrapper could have its MPI libraries in the implictly - # linked directories of the compiler itself. - if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") - endif() - - # Determine full path names for all of the libraries that one needs - # to link against in an MPI program - unset(MPI_PLAIN_LIB_NAMES_WORK) - foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${MPI_LINK_DIRECTORIES_WORK} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - - # Deal with the libraries given with full path next - unset(MPI_DIRECT_LIB_NAMES_WORK) - foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) - list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_PATH} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - if(MPI_DIRECT_LIB_NAMES_WORK) - set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") - endif() - - # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to - # link it in that case. -lpthread is covered by the normal library treatment on the other hand. - if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") - list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") - if(MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " -pthread") - else() - set(MPI_LINK_FLAGS_WORK "-pthread") - endif() - endif() - - if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}") - endif() - if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) - list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_EXTRA_LIB_NAMES) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}") - endif() - - # If we found MPI, set up all of the appropriate cache entries - if(NOT MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) - endif() - if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) - endif() - if(NOT MPI_${LANG}_LINK_FLAGS) - set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) - endif() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) -endfunction() - -function(_MPI_guess_settings LANG) - set(MPI_GUESS_FOUND FALSE) - # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. - if(WIN32) - # MSMPI - - # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, - # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers - # or import libraries and vice versa. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") - # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed - # Microsoft MPI. - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") - else() - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") - endif() - - find_library(MPI_msmpi_LIBRARY - NAMES msmpi - HINTS ${MPI_MSMPI_LIB_PATH} - DOC "Location of the msmpi library for Microsoft MPI") - mark_as_advanced(MPI_msmpi_LIBRARY) - - if(MPI_msmpi_LIBRARY) - # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way - # MSMPI can be used and therefore that header has to be present. - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) - unset(MPI_MSMPI_INC_DIR) - endif() - - # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, - # thus it might be present or provided by the user. Figuring out which is supported is done later on. - # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. - # Should a user be employing PGI or have built its own set and provided it via cache variables, the - # splitting routine would have located the module files. - - # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran - # we need some extra library to glue Fortran support together: - # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names - # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran - # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit - # has both variants available. - # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is - # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), - # it's passed immediately after the string address. - - # To summarize: - # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention - # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention - # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention - # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention - # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. - - # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas - # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran - # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - - # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). - - # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. - # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and - # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. - if ("${LANG}" STREQUAL "Fortran") - set(MPI_MSMPI_CALLINGCONVS c) - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) - list(APPEND MPI_MSMPI_CALLINGCONVS s) - endif() - foreach(mpistrlenpos IN ITEMS e m) - foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) - find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY - NAMES msmpif${mpistrlenpos}${mpicallingconv} - HINTS "${MPI_MSMPI_LIB_PATH}" - DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") - mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) - endforeach() - endforeach() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - - # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value - # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. - find_path(MPI_mpifptr_INCLUDE_DIR - NAMES "mpifptr.h" - HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" - DOC "Location of the mpifptr.h extra header for Microsoft MPI") - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) - else() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - endif() - mark_as_advanced(MPI_${LANG}_LIB_NAMES) - set(MPI_GUESS_FOUND TRUE) - endif() - endif() - - # At this point there's not many MPIs that we could still consider. - # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. - # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") - set(MPI_MPICH_PREFIX_PATHS - "$ENV{ProgramW6432}/MPICH2/lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" - ) - - # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first - find_library(MPI_mpi_LIBRARY - NAMES mpi - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_mpi_LIBRARY) - # If we found mpi.lib, we detect the rest of MPICH2 - if(MPI_mpi_LIBRARY) - set(MPI_MPICH_LIB_NAMES "mpi") - # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. - # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. - if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) - find_library(MPI_cxx_LIBRARY - NAMES cxx - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_cxx_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "cxx") - # For Fortran, MPICH2 provides three different libraries: - # fmpich2.lib which uses uppercase symbols and cdecl, - # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), - # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. - # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also - # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one - # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation - elseif("${LANG}" STREQUAL "Fortran") - find_library(MPI_fmpich2_LIBRARY - NAMES fmpich2 - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2s_LIBRARY - NAMES fmpich2s - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2g_LIBRARY - NAMES fmpich2g - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") - endif() - - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - unset(MPI_MPICH_LIB_NAMES) - - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - # For MPICH2, the include folder would be in ../include relative to the library folder. - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) - if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - unset(MPI_MPICH_ROOT_DIR) - endif() - set(MPI_GUESS_FOUND TRUE) - endif() - unset(MPI_MPICH_PREFIX_PATHS) - endif() - endif() - set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) -endfunction() - -function(_MPI_adjust_compile_definitions LANG) - if("${LANG}" STREQUAL "CXX") - # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ - # bindings in MPI-2. - if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") - # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI - # OMPI_SKIP_MPICXX is being used in Open MPI - # _MPICC_H is being used for IBM Platform MPI - list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") - set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - endif() -endfunction() - -macro(_MPI_assemble_libraries LANG) - set(MPI_${LANG}_LIBRARIES "") - # Only for libraries do we need to check whether the compiler's linking stage is separate. - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) - foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) - endforeach() - endif() -endmacro() - -macro(_MPI_assemble_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_${LANG}_INCLUDE_DIRS "") - else() - set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") - if("${LANG}" MATCHES "(C|CXX)") - if(MPI_${LANG}_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - else() # Fortran - if(MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") - endif() - if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") - endif() - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}") - endforeach() - endif() - endif() -endmacro() - -function(_MPI_split_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - return() - endif() - # Backwards compatibility: Search INCLUDE_PATH if given. - if(MPI_${LANG}_INCLUDE_PATH) - list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") - endif() - - # We try to find the headers/modules among those paths (and system paths) - # For C/C++, we just need to have a look for mpi.h. - if("${LANG}" MATCHES "(C|CXX)") - find_path(MPI_${LANG}_HEADER_DIR "mpi.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - mark_as_advanced(MPI_${LANG}_HEADER_DIR) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - # Fortran is more complicated here: An implementation could provide - # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI - # only provides Fortran 77 and - if mpi.f90 is built - potentially - # a Fortran 90 module. - elseif("${LANG}" STREQUAL "Fortran") - find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - find_path(MPI_${LANG}_MODULE_DIR - NAMES "mpi.mod" "mpi_f08.mod" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS - "${MPI_${LANG}_F77_HEADER_DIR}" - "${MPI_${LANG}_MODULE_DIR}" - ) - endif() - mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) - endif() - # Remove duplicates and default system directories from the list. - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR}) - endforeach() - endif() - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) -endfunction() - -macro(_MPI_create_imported_target LANG) - if(NOT TARGET MPI::MPI_${LANG}) - add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) - endif() - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") - if(MPI_${LANG}_LINK_FLAGS) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") - endif() - # If the compiler links MPI implicitly, no libraries will be found as they're contained within - # CMAKE__IMPLICIT_LINK_LIBRARIES already. - if(MPI_${LANG}_LIBRARIES) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") - endif() - # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") -endmacro() - -function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) - set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") - set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/FindMPI") - set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") - unset(MPI_TEST_COMPILE_DEFINITIONS) - if("${LANG}" STREQUAL "Fortran") - if("${MODE}" STREQUAL "F90_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") - elseif("${MODE}" STREQUAL "F08_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") - else() # F77 header - set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") - endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") - elseif("${LANG}" STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") - if("${MODE}" STREQUAL "TEST_MPICXX") - set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) - endif() - else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") - endif() - if(RUN_BINARY) - try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) - set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) - else() - try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - COPY_FILE "${BIN_FILE}") - endif() -endfunction() - -macro(_MPI_check_lang_works LANG) - # For Fortran we may have by the MPI-3 standard an implementation that provides: - # - the mpi_f08 module - # - *both*, the mpi module and 'mpif.h' - # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. - if( NOT MPI_${LANG}_WORKS ) - if("${LANG}" STREQUAL "Fortran") - set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) - - set(MPI_${LANG}_WORKS FALSE) - - foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) - if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_${mpimethod} TRUE) - else() - set(MPI_${LANG}_HAVE_${mpimethod} FALSE) - endif() - endforeach() - # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. - # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. - unset(MPI_Fortran_INTEGER_LINE) - if(NOT MPI_${LANG}_WORKS) - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) - if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_F77_HEADER TRUE) - endif() - endif() - else() - _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) - # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't - # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. - set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") - endif() - endif() -endmacro() - -# Some systems install various MPI implementations in separate folders in some MPI prefix -# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. -macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) - if(EXISTS "${PREFIX_FOLDER}") - file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") - foreach(_MPI_folder_child IN LISTS _MPI_folder_children) - if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") - list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") - endif() - endforeach() - endif() -endmacro() - -set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_ROOT} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ - # We enumerate the subfolders and append each as a prefix - MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. - list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") - # FreeBSD ships mpich under the normal system paths - but available openmpi implementations - # will be found in /usr/local/mpi/ - MPI_search_mpi_prefix_folder("/usr/local/mpi") -endif() - -# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. -# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution -# ships an mpiexec program (mpirun executables are not regulated by the standard). -find_program(MPIEXEC_EXECUTABLE - NAMES ${_MPIEXEC_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${MPI_HINT_DIRS} - DOC "Executable for running MPI programs.") - -# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). -# This gives us a fairly reliable base directory to search for /bin /lib and /include from. -get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) -get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) - -# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to -# launch an MPI process using mpiexec if such a program exists. -set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") -set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") -set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") - -# Set the number of processes to the physical processor count -cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) -set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") -unset(_MPIEXEC_NUMPROCS) -mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) - -#============================================================================= -# Backward compatibility input hacks. Propagate the FindMPI hints to C and -# CXX if the respective new versions are not defined. Translate the old -# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. -# -# Once we find the new variables, we translate them back into their old -# equivalents below. -if(NOT MPI_IGNORE_LEGACY_VARIABLES) - foreach (LANG IN ITEMS C CXX) - # Old input variables. - set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) - - # Set new vars based on their old equivalents, if the new versions are not already set. - foreach (var ${_MPI_OLD_INPUT_VARS}) - if (NOT MPI_${LANG}_${var} AND MPI_${var}) - set(MPI_${LANG}_${var} "${MPI_${var}}") - endif() - endforeach() - - # Chop the old compile flags into options and definitions - - unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) - unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) - if(MPI_${LANG}_COMPILE_FLAGS) - separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") - foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") - list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") - else() - list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") - endif() - endforeach() - unset(MPI_SEPARATE_FLAGS) - endif() - - # If a list of libraries was given, we'll split it into new-style cache variables - unset(MPI_${LANG}_EXTRA_LIB_NAMES) - if(NOT MPI_${LANG}_LIB_NAMES) - foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) - if(_MPI_LIB) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) - get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) - list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endif() - endforeach() - endif() - endforeach() -endif() -#============================================================================= - -unset(MPI_VERSION) -unset(MPI_VERSION_MAJOR) -unset(MPI_VERSION_MINOR) - -unset(_MPI_MIN_VERSION) - -# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. -if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) - set(MPI_SKIP_COMPILER_WRAPPER TRUE) -endif() - -# This loop finds the compilers and sends them off for interrogation. -foreach(LANG IN ITEMS C CXX Fortran) - if(CMAKE_${LANG}_COMPILER_LOADED) - if(NOT MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(_MPI_FIND_${LANG} TRUE) - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - if(_MPI_FIND_${LANG}) - if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") - mark_as_advanced(MPI_CXX_SKIP_MPICXX) - endif() - if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) - set(MPI_${LANG}_TRIED_IMPLICIT FALSE) - set(MPI_${LANG}_WORKS_IMPLICIT FALSE) - if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) - # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. - # Cray PrgEnv. - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - - # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. - if(MPI_${LANG}_WORKS) - set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) - set(MPI_${LANG}_WORKS_IMPLICIT TRUE) - endif() - set(MPI_${LANG}_TRIED_IMPLICIT TRUE) - endif() - - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) - set(MPI_${LANG}_WRAPPER_FOUND FALSE) - set(MPI_PINNED_COMPILER FALSE) - - if(NOT MPI_SKIP_COMPILER_WRAPPER) - if(MPI_${LANG}_COMPILER) - # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. - if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") - # Get rid of our default list of names and just search for the name the user wants. - set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") - unset(MPI_${LANG}_COMPILER CACHE) - endif() - # If the user specifies a compiler, we don't want to try to search libraries either. - set(MPI_PINNED_COMPILER TRUE) - endif() - - # If we have an MPI base directory, we'll try all compiler names in that one first. - # This should prevent mixing different MPI environments - if(_MPI_BASE_DIR) - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${_MPI_BASE_DIR} - NO_DEFAULT_PATH - DOC "MPI compiler for ${LANG}" - ) - endif() - - # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), - # we shall try searching in the default paths. - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - DOC "MPI compiler for ${LANG}" - ) - - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_PINNED_COMPILER TRUE) - - # If we haven't made the implicit compiler test yet, perform it now. - if(NOT MPI_${LANG}_TRIED_IMPLICIT) - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - endif() - - # Should the MPI compiler not work implicitly for MPI, still interrogate it. - # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used - # directly during linkage instead of CMAKE__COMPILER will not work. - if(NOT MPI_${LANG}_WORKS) - set(MPI_${LANG}_WORKS_IMPLICIT FALSE) - _MPI_interrogate_compiler(${LANG}) - else() - set(MPI_${LANG}_WORKS_IMPLICIT TRUE) - endif() - elseif(MPI_${LANG}_COMPILER) - _MPI_interrogate_compiler(${LANG}) - endif() - endif() - - if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) - # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the - # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) - else() - _MPI_guess_settings(${LANG}) - endif() - endif() - endif() - endif() - - _MPI_split_include_dirs(${LANG}) - _MPI_assemble_include_dirs(${LANG}) - _MPI_assemble_libraries(${LANG}) - - _MPI_adjust_compile_definitions(${LANG}) - # We always create imported targets even if they're empty - _MPI_create_imported_target(${LANG}) - - if(NOT MPI_${LANG}_WORKS) - _MPI_check_lang_works(${LANG}) - endif() - - # Next, we'll initialize the MPI variables that have not been previously set. - set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) - if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) - endif() - mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS - MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) - - # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported - # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. - if(MPI_${LANG}_WORKS) - if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) - if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) - _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) - if(MPI_RESULT_${LANG}_test_mpi_MPICXX) - set(MPI_MPICXX_FOUND TRUE) - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - endif() - - # At this point, we know the bindings present but not the MPI version or anything else. - if(NOT DEFINED MPI_${LANG}_VERSION) - unset(MPI_${LANG}_VERSION_MAJOR) - unset(MPI_${LANG}_VERSION_MINOR) - endif() - set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) - - # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the - # Fortran parameters, since those depend on the method of consumption. - # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 - # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. - if("${LANG}" STREQUAL "Fortran") - if(MPI_${LANG}_HAVE_F08_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) - elseif(MPI_${LANG}_HAVE_F90_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) - else() - set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) - endif() - - # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION - # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not - # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. - if(NOT DEFINED MPI_${LANG}_VERSION) - _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) - if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) - file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. - # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING - # and might vary between the different methods of consumption. - if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) - foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) - if(MPI_${LANG}_HAVE_${mpimethod}) - set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) - set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) - _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) - if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND - NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") - if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES - ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") - if("${CMAKE_MATCH_1}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) - endif() - if("${CMAKE_MATCH_2}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) - endif() - endif() - endif() - endif() - endforeach() - set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) - endif() - else() - set(MPI_${LANG}_HIGHEST_METHOD normal) - - # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. - if(NOT DEFINED MPI_${LANG}_VERSION) - file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - unset(MPI_BIN_FOLDER) - - # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. - # The one remaining issue is to determine which MPI library is installed. - # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, - # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING - # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). - # It's also worth noting that the installed version string can depend on the language, or on the system the binary - # runs on if MPI is not statically linked. - if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) - _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) - if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND - "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") - string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" - MPI_${LANG}_LIBRARY_VERSION_STRING) - else() - set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") - endif() - endif() - endif() - - set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) - set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) - set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) - - unset(MPI_${LANG}_REQUIRED_VARS) - if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") - endforeach() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") - if("${LANG}" STREQUAL "Fortran") - # For Fortran we only need one of the module or header directories to have *some* support for MPI. - if(NOT MPI_${LANG}_MODULE_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") - endif() - if(NOT MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") - endif() - else() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") - endforeach() - endif() - # Append the works variable now. If the settings did not work, this will show up properly. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - else() - # If the compiler worked implicitly, use its path as output. - # Should the compiler variable be set, we also require it to work. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") - if(MPI_${LANG}_COMPILER) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - endif() - endif() - find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} - VERSION_VAR MPI_${LANG}_VERSION) - - if(DEFINED MPI_${LANG}_VERSION) - if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) - set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) - endif() - endif() - endif() -endforeach() - -unset(_MPI_REQ_VARS) -foreach(LANG IN ITEMS C CXX Fortran) - if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") - endif() -endforeach() - -if(MPICXX IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") -endif() - -find_package_handle_standard_args(MPI - REQUIRED_VARS ${_MPI_REQ_VARS} - VERSION_VAR ${_MPI_MIN_VERSION} - HANDLE_COMPONENTS) - -#============================================================================= -# More backward compatibility stuff - -# For compatibility reasons, we also define MPIEXEC -set(MPIEXEC "${MPIEXEC_EXECUTABLE}") - -# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. -foreach(LANG IN ITEMS C CXX Fortran) - if(MPI_${LANG}_FOUND) - set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") - unset(MPI_${LANG}_COMPILE_FLAGS) - if(MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_COMPILE_DEFINITIONS) - foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) - string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") - endforeach() - endif() - endif() -endforeach() - -# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. -# This mimics the behavior of the old language-oblivious FindMPI. -set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) -if (MPI_CXX_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_CXX_${var}}) - endforeach() -elseif (MPI_C_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_C_${var}}) - endforeach() -endif() - -# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. -if (MPI_LIBRARIES) - list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) - set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") - unset(MPI_LIBRARY_WORK) -else() - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") -endif() - -list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) -if (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") - list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) - set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") - unset(MPI_EXTRA_LIBRARY_WORK) -else() - set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") -endif() -set(MPI_IGNORE_LEGACY_VARIABLES TRUE) -#============================================================================= - -# unset these vars to cleanup namespace -unset(_MPI_OLD_VARS) -unset(_MPI_PREFIX_PATH) -unset(_MPI_BASE_DIR) -foreach (lang C CXX Fortran) - unset(_MPI_${LANG}_COMPILER_NAMES) -endforeach() - -cmake_policy(POP) diff --git a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in deleted file mode 100644 index 30f912c627..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in +++ /dev/null @@ -1,4 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']' - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c b/cmake/Modules/NewCMake/FindMPI/libver_mpi.c deleted file mode 100644 index be9d19d435..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#ifdef __cplusplus -#include -#else -#include -#endif - -int main(int argc, char* argv[]) -{ - char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING]; - int mpilibver_len; - MPI_Get_library_version(mpilibver_str, &mpilibver_len); -#ifdef __cplusplus - std::puts(mpilibver_str); -#else - puts(mpilibver_str); -#endif -} diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in deleted file mode 100644 index 7938587168..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in +++ /dev/null @@ -1,7 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str - integer(kind=MPI_INTEGER_KIND) :: ierror, reslen - call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror) - print *, mpilibver_str - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in b/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in deleted file mode 100644 index a254523853..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in +++ /dev/null @@ -1,10 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0') - character, dimension(17), parameter :: mpiver_str =& - (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', & - char(zero + MPI_VERSION), & - '.', & - char(zero + MPI_SUBVERSION), ']' /) - print *, mpiver_str - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.c b/cmake/Modules/NewCMake/FindMPI/test_mpi.c deleted file mode 100644 index b8a308a4b0..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/test_mpi.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -#ifdef __cplusplus -#include -#else -#include -#endif - -#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -const char mpiver_str[] = { 'I', 'N', - 'F', 'O', - ':', 'M', - 'P', 'I', - '-', 'V', - 'E', 'R', - '[', ('0' + MPI_VERSION), - '.', ('0' + MPI_SUBVERSION), - ']', '\0' }; -#endif - -int main(int argc, char* argv[]) -{ -#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -#ifdef __cplusplus - std::puts(mpiver_str); -#else - puts(mpiver_str); -#endif -#endif -#ifdef TEST_MPI_MPICXX - MPI::MPI_Init(&argc, &argv); - MPI::MPI_Finalize(); -#else - MPI_Init(&argc, &argv); - MPI_Finalize(); -#endif -} diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in deleted file mode 100644 index 4d43a04d65..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in +++ /dev/null @@ -1,6 +0,0 @@ - program hello - @MPI_Fortran_INCLUDE_LINE@ - integer@MPI_Fortran_INTEGER_LINE@ ierror - call MPI_INIT(ierror) - call MPI_FINALIZE(ierror) - end program diff --git a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake b/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake deleted file mode 100644 index 67f6bd6f2b..0000000000 --- a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake +++ /dev/null @@ -1,386 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindPackageHandleStandardArgs ------------------------------ - -This module provides a function intended to be used in :ref:`Find Modules` -implementing :command:`find_package()` calls. It handles the -``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. -It also sets the ``_FOUND`` variable. The package is -considered found if all variables listed contain valid results, e.g. -valid filepaths. - -.. command:: find_package_handle_standard_args - - There are two signatures:: - - find_package_handle_standard_args( - (DEFAULT_MSG|) - ... - ) - - find_package_handle_standard_args( - [FOUND_VAR ] - [REQUIRED_VARS ...] - [VERSION_VAR ] - [HANDLE_COMPONENTS] - [CONFIG_MODE] - [FAIL_MESSAGE ] - ) - - The ``_FOUND`` variable will be set to ``TRUE`` if all - the variables ``...`` are valid and any optional - constraints are satisfied, and ``FALSE`` otherwise. A success or - failure message may be displayed based on the results and on - whether the ``REQUIRED`` and/or ``QUIET`` option was given to - the :command:`find_package` call. - - The options are: - - ``(DEFAULT_MSG|)`` - In the simple signature this specifies the failure message. - Use ``DEFAULT_MSG`` to ask for a default message to be computed - (recommended). Not valid in the full signature. - - ``FOUND_VAR `` - Obsolete. Specifies either ``_FOUND`` or - ``_FOUND`` as the result variable. This exists only - for compatibility with older versions of CMake and is now ignored. - Result variables of both names are always set for compatibility. - - ``REQUIRED_VARS ...`` - Specify the variables which are required for this package. - These may be named in the generated failure message asking the - user to set the missing variable values. Therefore these should - typically be cache entries such as ``FOO_LIBRARY`` and not output - variables like ``FOO_LIBRARIES``. - - ``VERSION_VAR `` - Specify the name of a variable that holds the version of the package - that has been found. This version will be checked against the - (potentially) specified required version given to the - :command:`find_package` call, including its ``EXACT`` option. - The default messages include information about the required - version and the version which has been actually found, both - if the version is ok or not. - - ``HANDLE_COMPONENTS`` - Enable handling of package components. In this case, the command - will report which components have been found and which are missing, - and the ``_FOUND`` variable will be set to ``FALSE`` - if any of the required components (i.e. not the ones listed after - the ``OPTIONAL_COMPONENTS`` option of :command:`find_package`) are - missing. - - ``CONFIG_MODE`` - Specify that the calling find module is a wrapper around a - call to ``find_package( NO_MODULE)``. This implies - a ``VERSION_VAR`` value of ``_VERSION``. The command - will automatically check whether the package configuration file - was found. - - ``FAIL_MESSAGE `` - Specify a custom failure message instead of using the default - generated message. Not recommended. - -Example for the simple signature: - -.. code-block:: cmake - - find_package_handle_standard_args(LibXml2 DEFAULT_MSG - LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) - -The ``LibXml2`` package is considered to be found if both -``LIBXML2_LIBRARY`` and ``LIBXML2_INCLUDE_DIR`` are valid. -Then also ``LibXml2_FOUND`` is set to ``TRUE``. If it is not found -and ``REQUIRED`` was used, it fails with a -:command:`message(FATAL_ERROR)`, independent whether ``QUIET`` was -used or not. If it is found, success will be reported, including -the content of the first ````. On repeated CMake runs, -the same message will not be printed again. - -Example for the full signature: - -.. code-block:: cmake - - find_package_handle_standard_args(LibArchive - REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR - VERSION_VAR LibArchive_VERSION) - -In this case, the ``LibArchive`` package is considered to be found if -both ``LibArchive_LIBRARY`` and ``LibArchive_INCLUDE_DIR`` are valid. -Also the version of ``LibArchive`` will be checked by using the version -contained in ``LibArchive_VERSION``. Since no ``FAIL_MESSAGE`` is given, -the default messages will be printed. - -Another example for the full signature: - -.. code-block:: cmake - - find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) - find_package_handle_standard_args(Automoc4 CONFIG_MODE) - -In this case, a ``FindAutmoc4.cmake`` module wraps a call to -``find_package(Automoc4 NO_MODULE)`` and adds an additional search -directory for ``automoc4``. Then the call to -``find_package_handle_standard_args`` produces a proper success/failure -message. -#]=======================================================================] - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) - -# internal helper macro -macro(_FPHSA_FAILURE_MESSAGE _msg) - if (${_NAME}_FIND_REQUIRED) - message(FATAL_ERROR "${_msg}") - else () - if (NOT ${_NAME}_FIND_QUIETLY) - message(STATUS "${_msg}") - endif () - endif () -endmacro() - - -# internal helper macro to generate the failure message when used in CONFIG_MODE: -macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) - # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: - if(${_NAME}_CONFIG) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") - else() - # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. - # List them all in the error message: - if(${_NAME}_CONSIDERED_CONFIGS) - set(configsText "") - list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) - math(EXPR configsCount "${configsCount} - 1") - foreach(currentConfigIndex RANGE ${configsCount}) - list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) - list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - string(APPEND configsText " ${filename} (version ${version})\n") - endforeach() - if (${_NAME}_NOT_FOUND_MESSAGE) - string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") - endif() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") - - else() - # Simple case: No Config-file was found at all: - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") - endif() - endif() -endmacro() - - -function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) - -# Set up the arguments for `cmake_parse_arguments`. - set(options CONFIG_MODE HANDLE_COMPONENTS) - set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) - set(multiValueArgs REQUIRED_VARS) - -# Check whether we are in 'simple' or 'extended' mode: - set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) - list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) - - if(${INDEX} EQUAL -1) - set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) - set(FPHSA_REQUIRED_VARS ${ARGN}) - set(FPHSA_VERSION_VAR) - else() - cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) - - if(FPHSA_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") - endif() - - if(NOT FPHSA_FAIL_MESSAGE) - set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") - endif() - - # In config-mode, we rely on the variable _CONFIG, which is set by find_package() - # when it successfully found the config-file, including version checking: - if(FPHSA_CONFIG_MODE) - list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) - list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) - set(FPHSA_VERSION_VAR ${_NAME}_VERSION) - endif() - - if(NOT FPHSA_REQUIRED_VARS) - message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") - endif() - endif() - -# now that we collected all arguments, process them - - if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") - set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") - endif() - - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) - - string(TOUPPER ${_NAME} _NAME_UPPER) - string(TOLOWER ${_NAME} _NAME_LOWER) - - if(FPHSA_FOUND_VAR) - if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") - set(_FOUND_VAR ${FPHSA_FOUND_VAR}) - else() - message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") - endif() - else() - set(_FOUND_VAR ${_NAME_UPPER}_FOUND) - endif() - - # collect all variables which were not found, so they can be printed, so the - # user knows better what went wrong (#6375) - set(MISSING_VARS "") - set(DETAILS "") - # check if all passed variables are valid - set(FPHSA_FOUND_${_NAME} TRUE) - foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) - if(NOT ${_CURRENT_VAR}) - set(FPHSA_FOUND_${_NAME} FALSE) - string(APPEND MISSING_VARS " ${_CURRENT_VAR}") - else() - string(APPEND DETAILS "[${${_CURRENT_VAR}}]") - endif() - endforeach() - if(FPHSA_FOUND_${_NAME}) - set(${_NAME}_FOUND TRUE) - set(${_NAME_UPPER}_FOUND TRUE) - else() - set(${_NAME}_FOUND FALSE) - set(${_NAME_UPPER}_FOUND FALSE) - endif() - - # component handling - unset(FOUND_COMPONENTS_MSG) - unset(MISSING_COMPONENTS_MSG) - - if(FPHSA_HANDLE_COMPONENTS) - foreach(comp ${${_NAME}_FIND_COMPONENTS}) - if(${_NAME}_${comp}_FOUND) - - if(NOT DEFINED FOUND_COMPONENTS_MSG) - set(FOUND_COMPONENTS_MSG "found components: ") - endif() - string(APPEND FOUND_COMPONENTS_MSG " ${comp}") - - else() - - if(NOT DEFINED MISSING_COMPONENTS_MSG) - set(MISSING_COMPONENTS_MSG "missing components: ") - endif() - string(APPEND MISSING_COMPONENTS_MSG " ${comp}") - - if(${_NAME}_FIND_REQUIRED_${comp}) - set(${_NAME}_FOUND FALSE) - string(APPEND MISSING_VARS " ${comp}") - endif() - - endif() - endforeach() - set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") - string(APPEND DETAILS "[c${COMPONENT_MSG}]") - endif() - - # version handling: - set(VERSION_MSG "") - set(VERSION_OK TRUE) - - # check with DEFINED here as the requested or found version may be "0" - if (DEFINED ${_NAME}_FIND_VERSION) - if(DEFINED ${FPHSA_VERSION_VAR}) - set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - # count the dots in the version string - string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") - # add one dot because there is one dot more than there are components - string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) - if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) - # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT - # is at most 4 here. Therefore a simple lookup table is used. - if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) - set(_VERSION_REGEX "[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) - set(_VERSION_REGEX "[^.]*\\.[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") - else () - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") - endif () - string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") - unset(_VERSION_REGEX) - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - unset(_VERSION_HEAD) - else () - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - endif () - unset(_VERSION_DOTS) - - else() # minimum version specified: - if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () - endif() - - else() - - # if the package was not found, but a version was given, add that to the output: - if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") - else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") - endif() - - endif() - else () - # Check with DEFINED as the found version may be 0. - if(DEFINED ${FPHSA_VERSION_VAR}) - set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")") - endif() - endif () - - if(VERSION_OK) - string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]") - else() - set(${_NAME}_FOUND FALSE) - endif() - - - # print the result: - if (${_NAME}_FOUND) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") - else () - - if(FPHSA_CONFIG_MODE) - _FPHSA_HANDLE_FAILURE_CONFIG_MODE() - else() - if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") - else() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") - endif() - endif() - - endif () - - set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) - set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) -endfunction() diff --git a/cmake/Modules/NewCMake/FindPackageMessage.cmake b/cmake/Modules/NewCMake/FindPackageMessage.cmake deleted file mode 100644 index 6821cee4f7..0000000000 --- a/cmake/Modules/NewCMake/FindPackageMessage.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindPackageMessage -# ------------------ -# -# -# -# FIND_PACKAGE_MESSAGE( "message for user" "find result details") -# -# This macro is intended to be used in FindXXX.cmake modules files. It -# will print a message once for each unique find result. This is useful -# for telling the user where a package was found. The first argument -# specifies the name (XXX) of the package. The second argument -# specifies the message to display. The third argument lists details -# about the find result so that if they change the message will be -# displayed again. The macro also obeys the QUIET argument to the -# find_package command. -# -# Example: -# -# :: -# -# if(X11_FOUND) -# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" -# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") -# else() -# ... -# endif() - -function(FIND_PACKAGE_MESSAGE pkg msg details) - # Avoid printing a message repeatedly for the same find result. - if(NOT ${pkg}_FIND_QUIETLY) - string(REPLACE "\n" "" details "${details}") - set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) - if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") - # The message has not yet been printed. - message(STATUS "${msg}") - - # Save the find details in the cache to avoid printing the same - # message again. - set("${DETAILS_VAR}" "${details}" - CACHE INTERNAL "Details about finding ${pkg}") - endif() - endif() -endfunction() diff --git a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake b/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake deleted file mode 100644 index dce6f99262..0000000000 --- a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# SelectLibraryConfigurations -# --------------------------- -# -# -# -# select_library_configurations( basename ) -# -# This macro takes a library base name as an argument, and will choose -# good values for basename_LIBRARY, basename_LIBRARIES, -# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what -# has been found and set. If only basename_LIBRARY_RELEASE is defined, -# basename_LIBRARY will be set to the release value, and -# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND. -# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will -# take the debug value, and basename_LIBRARY_RELEASE will be set to -# basename_LIBRARY_RELEASE-NOTFOUND. -# -# If the generator supports configuration types, then basename_LIBRARY -# and basename_LIBRARIES will be set with debug and optimized flags -# specifying the library to be used for the given configuration. If no -# build type has been set or the generator in use does not support -# configuration types, then basename_LIBRARY and basename_LIBRARIES will -# take only the release value, or the debug value if the release one is -# not set. - -# This macro was adapted from the FindQt4 CMake module and is maintained by Will -# Dicharry . - -macro( select_library_configurations basename ) - if(NOT ${basename}_LIBRARY_RELEASE) - set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.") - endif() - if(NOT ${basename}_LIBRARY_DEBUG) - set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.") - endif() - - if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND - NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND - ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) ) - # if the generator supports configuration types or CMAKE_BUILD_TYPE - # is set, then set optimized and debug options. - set( ${basename}_LIBRARY "" ) - foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) - list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) - endforeach() - foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) - list( APPEND ${basename}_LIBRARY debug "${_libname}" ) - endforeach() - elseif( ${basename}_LIBRARY_RELEASE ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) - elseif( ${basename}_LIBRARY_DEBUG ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} ) - else() - set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND") - endif() - - set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) - - if( ${basename}_LIBRARY ) - set( ${basename}_FOUND TRUE ) - endif() - - mark_as_advanced( ${basename}_LIBRARY_RELEASE - ${basename}_LIBRARY_DEBUG - ) -endmacro() diff --git a/cmake/Modules/platforms/Acorn.cmake b/cmake/Modules/platforms/Acorn.cmake deleted file mode 100644 index 8bb4cb94da..0000000000 --- a/cmake/Modules/platforms/Acorn.cmake +++ /dev/null @@ -1,13 +0,0 @@ -macro (setAcorn) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -endmacro() diff --git a/cmake/Modules/platforms/Cheyenne.cmake b/cmake/Modules/platforms/Cheyenne.cmake deleted file mode 100644 index 54477168e8..0000000000 --- a/cmake/Modules/platforms/Cheyenne.cmake +++ /dev/null @@ -1,24 +0,0 @@ -macro (setCheyenne) - message("Setting paths for Cheyenne") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - - set(BUILD_CORELIBS "ON" ) - set(BUILD_UTIL "OFF" CACHE INTERNAL "" ) - set(BUILD_BUFR "ON" CACHE INTERNAL "") - set(BUILD_SFCIO "ON" CACHE INTERNAL "") - set(BUILD_SIGIO "ON" CACHE INTERNAL "") - set(BUILD_W3EMC "ON" CACHE INTERNAL "") - set(BUILD_W3NCO "ON" CACHE INTERNAL "") - set(BUILD_BACIO "ON" CACHE INTERNAL "") - set(BUILD_CRTM "ON" CACHE INTERNAL "") - set(BUILD_SP "ON" CACHE INTERNAL "") - set(BUILD_NEMSIO "ON" CACHE INTERNAL "") - set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) -endmacro() - diff --git a/cmake/Modules/platforms/Discover.cmake b/cmake/Modules/platforms/Discover.cmake deleted file mode 100644 index fe8a2dfc0e..0000000000 --- a/cmake/Modules/platforms/Discover.cmake +++ /dev/null @@ -1,55 +0,0 @@ -macro (setDiscover) - message("Setting paths for Discover") -# option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) -# option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(host "Discover" CACHE INTERNAL "") - - set(COREPATH $ENV{COREPATH} ) - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.1.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.2.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() - - if( ENV{BASEDIR} ) - set(BASEDIR $ENV{BASEDIR}/Linux CACHE INTERNAL "") - endif() - set(BUILD_CORELIBS "ON" CACHE INTERNAL "") - set(USE_WRF "OFF" CACHE INTERNAL "") - set(BUILD_GLOBAL "ON" CACHE INTERNAL "") - - set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) - -endmacro() - diff --git a/cmake/Modules/platforms/Gaea.cmake b/cmake/Modules/platforms/Gaea.cmake deleted file mode 100644 index d6929b8f03..0000000000 --- a/cmake/Modules/platforms/Gaea.cmake +++ /dev/null @@ -1,14 +0,0 @@ -macro (setGaea) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "-xCORE-AVX2" CACHE INTERNAL "Host Flag") # for Haswell (C4) - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${MKL_FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(BUILD_CORELIBS "OFF" ) -endmacro() diff --git a/cmake/Modules/platforms/Generic.cmake b/cmake/Modules/platforms/Generic.cmake deleted file mode 100644 index 24f40107d5..0000000000 --- a/cmake/Modules/platforms/Generic.cmake +++ /dev/null @@ -1,25 +0,0 @@ -macro (setGeneric) - message("Setting paths for Generic System") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - if(EXISTS /jetmon) - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required - else() - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required - endif() - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - - message("setting values for corelibs") - set(BUILD_BUFR "OFF" CACHE INTERNAL "Build the BUFR library" ) - set(BUILD_BACIO "OFF" CACHE INTERNAL "Build the BACIO library" ) - set(BUILD_SFCIO "OFF" CACHE INTERNAL "Build the SFCIO library" ) - set(BUILD_SIGIO "OFF" CACHE INTERNAL "Build the SIGIO library" ) - set(BUILD_NEMSIO "OFF" CACHE INTERNAL "Build the NEMSIO library" ) - set(BUILD_SP "OFF" CACHE INTERNAL "Build the SP library" ) - set(BUILD_CRTM "OFF" CACHE INTERNAL "Build the CRTM library" ) - set(BUILD_W3EMC "OFF" CACHE INTERNAL "Build the EMC library" ) - set(BUILD_W3NCO "OFF" CACHE INTERNAL "Build the EMC library" ) - set(BUILD_NCO "OFF" CACHE INTERNAL "Build the NCO library" ) -endmacro() diff --git a/cmake/Modules/platforms/Hera.cmake b/cmake/Modules/platforms/Hera.cmake deleted file mode 100644 index d8af27696c..0000000000 --- a/cmake/Modules/platforms/Hera.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setHERA) - message("Setting paths for HERA") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/Jet.cmake b/cmake/Modules/platforms/Jet.cmake deleted file mode 100644 index 824585e366..0000000000 --- a/cmake/Modules/platforms/Jet.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setJet) - message("Setting paths for Jet") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-axSSE4.2,AVX,CORE-AVX2" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/Orion.cmake b/cmake/Modules/platforms/Orion.cmake deleted file mode 100644 index 56ddd1f2c3..0000000000 --- a/cmake/Modules/platforms/Orion.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setOrion) - message("Setting paths for Orion") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/S4.cmake b/cmake/Modules/platforms/S4.cmake deleted file mode 100644 index 8c19f11a32..0000000000 --- a/cmake/Modules/platforms/S4.cmake +++ /dev/null @@ -1,10 +0,0 @@ -macro (setS4) - message("Setting paths for S4") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-march=ivybridge" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "OFF") -endmacro() diff --git a/cmake/Modules/platforms/WCOSS-C.cmake b/cmake/Modules/platforms/WCOSS-C.cmake deleted file mode 100644 index 1c9cf712cd..0000000000 --- a/cmake/Modules/platforms/WCOSS-C.cmake +++ /dev/null @@ -1,60 +0,0 @@ -macro (setWCOSS_C) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/gpfs/hps/nco/ops/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/gpfs/hps/nco/ops/nwprod/lib/crtm" ) - endif() - if( NOT DEFINED ENV{WRFPATH} ) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-intel" ) - else() - set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-cray" ) - endif() - else() - set(WRFPATH $ENV{WRFPATH} ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "11.0.1" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.2" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.2.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() diff --git a/cmake/Modules/platforms/WCOSS-D.cmake b/cmake/Modules/platforms/WCOSS-D.cmake deleted file mode 100644 index 19a853e609..0000000000 --- a/cmake/Modules/platforms/WCOSS-D.cmake +++ /dev/null @@ -1,48 +0,0 @@ -macro (setWCOSS_D) - message("Setting paths for Dell") - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "GSI Fortran Flags") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS} ${MKL_FLAG}" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "ENKF Fortran Flags") - - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/gpfs/dell1/nco/ops/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/gpfs/dell1/nco/ops/nwprod/lib/crtm" ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "11.3.0" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.5" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.3.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() diff --git a/cmake/Modules/platforms/WCOSS.cmake b/cmake/Modules/platforms/WCOSS.cmake deleted file mode 100644 index 81b1297392..0000000000 --- a/cmake/Modules/platforms/WCOSS.cmake +++ /dev/null @@ -1,61 +0,0 @@ -macro (setWCOSS) - message("Setting paths for WCOSS") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - #if ibmpe module is not loaded last, CMake tries to use intel mpi. Force use of ibmhpc - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set( MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -traceback -O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${HOST_FLAG} " CACHE INTERNAL "") - - set(MPI_Fortran_COMPILER /opt/ibmhpc/pe13010/base/bin/mpif90 CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - set(MPI_C_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicc CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - set(MPI_CXX_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicxx CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/nwprod2/lib" ) - endif() - if( NOT DEFINED ENV{WRFPATH} ) - set(WRFPATH "/nwprod/sorc/wrf_shared.fd" ) - else() - set(WRFPATH $ENV{WRFPATH} ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() - -endmacro() diff --git a/cmake/Modules/setGNUFlags.cmake b/cmake/Modules/setGNUFlags.cmake deleted file mode 100644 index e4ef2d9ade..0000000000 --- a/cmake/Modules/setGNUFlags.cmake +++ /dev/null @@ -1,66 +0,0 @@ -function (setGNU) - set(COMPILER_TYPE "gnu" CACHE INTERNAL "Compiler brand") - message("Setting GNU Compiler Flags") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set(GSI_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - set(BUFR_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -O3 -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BACIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -std=f2003 -fdollar-ok -O3 -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -O3 -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "") - set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") - else( ) #DEBUG - set(GSI_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -fbacktrace -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - set(BUFR_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -fbacktrace -g -fbacktrace -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BACIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -fbacktrace -std=f2003 -fdollar-ok -g -fbacktrace -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -g -fbacktrace -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -fbacktrace -Wl,-noinhibit-exec" CACHE INTERNAL "") - set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") - endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) -endfunction() - diff --git a/cmake/Modules/setHOST.cmake b/cmake/Modules/setHOST.cmake deleted file mode 100644 index 861e9fc636..0000000000 --- a/cmake/Modules/setHOST.cmake +++ /dev/null @@ -1,105 +0,0 @@ -macro( setHOST ) - site_name(HOSTNAME) - message("The hostname is ${HOSTNAME}" ) - string(REGEX MATCH "s4-" HOST-S4 ${HOSTNAME} ) - string(REGEX MATCH "gaea" HOST-Gaea ${HOSTNAME} ) - string(REGEX MATCH "hfe[0-9]" HOST-Hera ${HOSTNAME} ) - string(REGEX MATCH "Orion" HOST-Orion ${HOSTNAME} ) - if(EXISTS /jetmon) - set(HOST-Jet "True" ) - endif() - string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - if( HOST-WCOSS ) - message("host is WCOSS") - endif() - string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - if( NOT HOST-WCOSS ) # don't overwrite if we are on gyre - string(REGEX MATCH "t[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - endif() - string(REGEX MATCH "v[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus Phase 3 - string(REGEX MATCH "v[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - endif() - if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus/Phase 3.5 - string(REGEX MATCH "m[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - if( NOT HOST-WCOSS_D )# don't overwrite if we are on mars Phase 3 - string(REGEX MATCH "m[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - endif() - endif() - string(REGEX MATCH "llogin" HOST-WCOSS_C ${HOSTNAME} ) - if( NOT HOST-WCOSS_C )# don't overwrite if we are on luna - string(REGEX MATCH "slogin" HOST-WCOSS_C ${HOSTNAME} ) - endif() - string(REGEX MATCH "alogin01" HOST-Acorn ${HOSTNAME} ) - if( NOT HOST-Acorn )# don't overwrite if we are on node 1 - string(REGEX MATCH "alogin02" HOST-Acorn ${HOSTNAME} ) - endif() - string(REGEX MATCH "discover" HOST-Discover ${HOSTNAME} ) - string(REGEX MATCH "cheyenne" HOST-Cheyenne ${HOSTNAME} ) - message("done figuring out host--${HOSTNAME}") - if ( COMGSI ) - set( host "GENERIC" ) - set( HOST-Generic "TRUE" ) - setGeneric() - elseif(HOST-Jet) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "Jet" ) - set( HOST-Jet "TRUE" ) - setJet() - elseif( HOST-S4 ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "S4" ) - set( HOST-S4 "TRUE" ) - setS4() - elseif( HOST-WCOSS ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "WCOSS" ) - set( HOST-WCOSS "TRUE" ) - setWCOSS() - elseif( HOST-Hera ) - set( host "Hera" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setHERA() - set( HOST-Hera "TRUE" ) - elseif( HOST-Orion ) - set( host "Orion" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setOrion() - set( HOST-Orion "TRUE" ) - elseif( HOST-Gaea ) - set( host "Gaea" ) - option(BUILD_CORELIBS "Build the Core libraries " On) - setGaea() - set( HOST-Gaea "TRUE" ) - elseif( HOST-Cheyenne ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - set( host "Cheyenne" ) - setCheyenne() - set( HOST-Cheyenne "TRUE" ) - elseif( HOST-WCOSS_C ) - set( host "WCOSS_C" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS_C() - set( HOST-WCOSS_C "TRUE" ) - elseif( HOST-WCOSS_D ) - set( host "WCOSS_D" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS_D() - set( HOST-WCOSS_D "TRUE" ) - elseif( HOST-Discover ) - set(host "Discover" ) - setDiscover() - set( HOST-Discover "TRUE" ) - elseif( HOST-Acorn ) - set( host "Acorn" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setAcorn() - set( HOST-Acorn "TRUE" ) - else( ) - set( host "GENERIC" ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - setGeneric() - set( HOST-Generic "TRUE" ) - endif() - message("Host is set to ${host}") -endmacro() diff --git a/cmake/Modules/setIntelFlags.cmake b/cmake/Modules/setIntelFlags.cmake deleted file mode 100644 index 88e5061ffc..0000000000 --- a/cmake/Modules/setIntelFlags.cmake +++ /dev/null @@ -1,94 +0,0 @@ -set(intsize 4) -function(set_LIBRARY_UTIL_Intel) - set(BACIO_Fortran_FLAGS "-O3 -free -assume nocc_omp ${HOST_FLAG} " CACHE INTERNAL "" ) - set(BUFR_Fortran_FLAGS "-O2 -r8 -fp-model strict -traceback -O3 ${HOST_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(BUFR_C_FLAGS "-DSTATIC_ALLOCATION -DUNDERSCORE -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) - set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) - set (CRTM_Fortran_FLAGS " -O3 -convert big_endian -free -assume byterecl -fp-model source -traceback ${HOST_FLAG}" CACHE INTERNAL "" ) - set (NEMSIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SFCIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SIGIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_Fortran_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_Fortran_4_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_F77_FLAGS " -DLINUX -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3EMC_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3EMC_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_C_FLAGS "-O0 -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) - set (NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "" ) - set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) - set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DWRF -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone" CACHE INTERNAL "") -# set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian -D_REAL8_ -openmp -fpp -auto" CACHE INTERNAL "" ) - set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -# set(COV_CALC_FLAGS ${GSI_Intel_Platform_FLAGS} CACHE INTERNAL "Full GSI Fortran FLAGS" ) -endfunction(set_LIBRARY_UTIL_Intel) - -function(set_LIBRARY_UTIL_Debug_Intel) - set (BACIO_Fortran_FLAGS "-g -free -assume nocc_omp " CACHE INTERNAL "" ) - set(BUFR_Fortran_FLAGS " -c -g -traceback -O3 -axCORE-AVX2 -r8 " CACHE INTERNAL "" ) - set(BUFR_C_FLAGS "-g -traceback -DUNDERSCORE -O3 -axCORE-AVX2 -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) - set(CRTM_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SFCIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SIGIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_Fortran_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -r8 -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_Fortran_4_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_F77_FLAGS " -g -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3EMC_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3EMC_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(NEMSIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_C_FLAGS "-O0 -g -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) - set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) - set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) - set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O1 -g -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -Wl,-noinhibit-exec" CACHE INTERNAL "" ) - set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS "-O0 -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian" CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) -endfunction(set_LIBRARY_UTIL_Debug_Intel) - -function(set_GSI_ENKF_Intel) - #Common release/production flags - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) - set(GSI_Fortran_FLAGS "${GSI_Intel_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full GSI Fortran FLAGS" ) - set(ENKF_Fortran_FLAGS "${ENKF_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full ENKF Fortran FLAGS" ) - set(GSDCLOUD_Fortran_FLAGS "-O3 -convert big_endian" CACHE INTERNAL "") -endfunction(set_GSI_ENKF_Intel) - -function (set_GSI_ENKF_Debug_Intel) - set(GSI_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O0 -fp-model source -convert big_endian -assume byterecl -implicitnone -g -traceback -debug -ftrapuv -check all,noarg_temp_created -fp-stack-check -fstack-protector -warn all,nointerfaces -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") - set(ENKF_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug all -check all,noarg_temp_created -fp-model strict -convert big_endian -assume byterecl -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -convert big_endian" CACHE INTERNAL "") - #Common debug flags - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) -endfunction (set_GSI_ENKF_Debug_Intel) - -function (setIntel) - string(REPLACE "." ";" COMPILER_VERSION_LIST ${CMAKE_C_COMPILER_VERSION}) - list(GET COMPILER_VERSION_LIST 0 MAJOR_VERSION) - list(GET COMPILER_VERSION_LIST 1 MINOR_VERSION) - list(GET COMPILER_VERSION_LIST 2 PATCH_VERSION) - set(COMPILER_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" CACHE INTERNAL "Compiler Version") - set(COMPILER_TYPE "intel" CACHE INTERNAL "Compiler brand") - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION) - set(EXTRA_LINKER_FLAGS ${MKL_FLAG} CACHE INTERNAL "Extra Linker flags") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set_GSI_ENKF_Intel() - set_LIBRARY_UTIL_Intel() - else( ) #DEBUG flags - message("Building DEBUG version of GSI") - set( debug_suffix "_DBG" CACHE INTERNAL "" ) - set_GSI_ENKF_Debug_Intel() - set_LIBRARY_UTIL_Debug_Intel() - endif() -endfunction() - diff --git a/cmake/Modules/setPGIFlags.cmake b/cmake/Modules/setPGIFlags.cmake deleted file mode 100644 index 2088a7416d..0000000000 --- a/cmake/Modules/setPGIFlags.cmake +++ /dev/null @@ -1,78 +0,0 @@ -function (setPGI) - message("Setting PGI Compiler Flags") - set(COMPILER_TYPE "pgi" CACHE INTERNAL "Compiler brand") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set(CMAKE_Fortran_FLAGS_RELEASE "") - set(Fortran_FLAGS "" CACHE INTERNAL "") - set(GSI_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -O3 -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -O3 -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -O3 -byteswapio -fast" CACHE INTERNAL "") - - set(BUFR_Fortran_FLAGS "-O1 -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - - set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") - set(BACIO_Fortran_FLAGS " -O3 -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -O1 -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -O3 -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -O3 -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_4_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -O1 -byteswapio " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -DLINUX -O1 -byteswapio " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -O1 -D_REAL8_ -mp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 " CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 -byteswapio -mp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") - if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) - set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) - else() - set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) - endif() - else() - set(Fortran_FLAGS "" CACHE INTERNAL "") - set(GSI_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -traceback -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -g -traceback -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -g -traceback -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -g -traceback -byteswapio -fast" CACHE INTERNAL "") - - set(BUFR_Fortran_FLAGS "-g -traceback -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -traceback -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - - set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") - set(BACIO_Fortran_FLAGS " -g -traceback -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -traceback -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -g -traceback -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -g -traceback -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_4_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -g -traceback -D_REAL8_ -mp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -traceback " CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 -byteswapio -traceback -mp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") - if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) - set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) - else() - set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) - endif() - endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) -endfunction() diff --git a/cmake/Modules/setPlatformVariables.cmake b/cmake/Modules/setPlatformVariables.cmake deleted file mode 100644 index 9938e090f0..0000000000 --- a/cmake/Modules/setPlatformVariables.cmake +++ /dev/null @@ -1,12 +0,0 @@ -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Jet.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-C.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/S4.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Hera.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Orion.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Gaea.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Cheyenne.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Discover.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-D.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Acorn.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Generic.cmake) From 6beeec261b00c7fe8075d51e0f2971e4584f8b56 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 31 Mar 2022 11:56:23 -0400 Subject: [PATCH 44/58] remove broken Debug CPP definitions from ncdiag library --- src/ncdiag/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index f74fc1aeee..6c3c287185 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -33,21 +33,12 @@ message(STATUS "ENABLE_NCDIAG_SERIAL ... ${ENABLE_NCDIAG_SERIAL}") # Get list of files include(ncdiag_files.cmake) -if(CMAKE_BUILD_TYPE MATCHES "^(Debug)$") - list(APPEND debug_defs - DEBUG - _DEBUG_MEM_ - ERROR_TRACEBACK - ) -endif() - set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/ncdiag") add_library(ncdiag STATIC ${NCDIAG_SRC_lib}) add_library(${PROJECT_NAME}::ncdiag ALIAS ncdiag) set_target_properties(ncdiag PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") target_compile_definitions(ncdiag PRIVATE "_REAL4_") target_compile_definitions(ncdiag PRIVATE "USE_MPI") -target_compile_definitions(ncdiag PRIVATE "${debug_defs}") target_link_libraries(ncdiag PUBLIC NetCDF::NetCDF_Fortran) target_link_libraries(ncdiag PUBLIC MPI::MPI_Fortran) target_include_directories(ncdiag PUBLIC $ @@ -74,7 +65,6 @@ if(ENABLE_NCDIAG_SERIAL) add_library(${PROJECT_NAME}::ncdiag_serial ALIAS ncdiag_serial) set_target_properties(ncdiag_serial PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") target_compile_definitions(ncdiag_serial PRIVATE "_REAL4_") - target_compile_definitions(ncdiag_serial PRIVATE "${debug_defs}") target_link_libraries(ncdiag_serial PUBLIC NetCDF::NetCDF_Fortran) target_include_directories(ncdiag_serial PUBLIC $ $) From 98e6cbf2e5c16f87fc0335bf47442c7d67dec462 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 31 Mar 2022 13:54:51 -0400 Subject: [PATCH 45/58] Build with GNU and CMAKE_BUILD_TYPE=Debug --- .../enkfapp_compiler_flags_GNU_Fortran.cmake | 2 +- .../gsiapp_compiler_flags_GNU_Fortran.cmake | 2 +- .../ncdiag_compiler_flags_GNU_Fortran.cmake | 2 +- util/CMakeLists.txt | 1 - .../gsiutils_compiler_flags_GNU_Fortran.cmake | 2 +- util/ndate/CMakeLists.txt | 7 - util/ndate/ndate.f | 147 ------------------ 7 files changed, 4 insertions(+), 159 deletions(-) delete mode 100644 util/ndate/CMakeLists.txt delete mode 100644 util/ndate/ndate.f diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake index 1b57e9c1bb..bf6e937882 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake @@ -18,7 +18,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -funroll-all-loops -finline-functions") # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") #################################################################### # LINK FLAGS diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake index f321c685ae..6faa0def20 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake @@ -18,7 +18,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -frecord-marker=4 -funroll-loops -fno-range # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") #################################################################### # LINK FLAGS diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake index be9368ad6a..b057c72026 100644 --- a/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake +++ b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake @@ -18,7 +18,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -funroll-all-loops -finline-functions ") # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") #################################################################### # LINK FLAGS diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 99c6335daa..d98eaaf33f 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -137,7 +137,6 @@ endif() add_subdirectory(FOV_utilities) add_subdirectory(Single_Observation) -add_subdirectory(ndate) add_subdirectory(zero_biascoeff) # These utilities do not have CMake builds and are unlikely used or usable diff --git a/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake index 6b2f64f116..85c24004c9 100644 --- a/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake +++ b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake @@ -18,7 +18,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions") # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -static -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") #################################################################### # LINK FLAGS diff --git a/util/ndate/CMakeLists.txt b/util/ndate/CMakeLists.txt deleted file mode 100644 index b31bb218d7..0000000000 --- a/util/ndate/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(ndate.x ndate.f) -target_link_libraries(ndate.x PRIVATE bacio::bacio_4) -target_link_libraries(ndate.x PRIVATE w3emc::w3emc_4) - -# Install executable targets -install(TARGETS ndate.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - diff --git a/util/ndate/ndate.f b/util/ndate/ndate.f deleted file mode 100644 index 8f02a738b3..0000000000 --- a/util/ndate/ndate.f +++ /dev/null @@ -1,147 +0,0 @@ - PROGRAM NDATE -C$$$ MAIN PROGRAM DOCUMENTATION BLOCK -C -C MAIN PROGRAM: NDATE COMPUTE VERIFYING DATE -C PRGMMR: IREDELL ORG: NP23 DATE: 1998-08-18 -C -C ABSTRACT: PROGRAM TO COMPUTE VERIFYING DATE -C GIVEN THE FORECAST HOUR AND THE INITIAL DATE. -C -C PROGRAM HISTORY LOG: -C 95-02-28 IREDELL -C 97-09-22 IREDELL 4-DIGIT YEAR ALLOWED; 2-DIGIT YEAR STANDARDIZED -C 98-03-25 IREDELL 4-DIGIT YEAR FOR ALL DATES. A 2-DIGIT YEAR WILL -C BE INTERPRETED AS A YEAR IN THE FIRST CENTURY -C WHICH SHOULD BE ALL RIGHT BEFORE THE YEAR 2000. -C STANDARD ERROR WARNINGS WILL BE GIVEN FOR SUCH -C DATES UNTIL 1 SEPT 1998 AFTER WHICH NDATE ABORTS. -C NDATE WILL ALSO ABORT AFTER 1 SEPT 1998 IF THE -C NOW IRRELEVANT -Y OPTION IS INVOKED. -C THE NEW Y2K-COMPLIANT W3LIB PACKAGE IS USED. -C 1998-08-17 IREDELL DROP-DEAD DATE RESET TO 1 SEPT 1999 -C 1999-01-26 VUONG CHANGED TO USE 4-DIGIT YEAR AS STANDARDIZED FOR -C ALL DATES AND CONVERTED TO IBM RS/6000 SP AND -C MODIFIED PROGRAM TO CALL ROUTINE GETARG INSTEAD OF -C USING SUBROUTINE GETARG AS A FUNCTION. -C 1999-09-02 IREDELL UNDID RESTRICTION ON FORECAST HOUR -C -C USAGE: ndate [fhour [idate]] -C INPUT ARGUMENT LIST -C FHOUR - FORECAST HOUR (MAY BE NEGATIVE) -C FHOUR DEFAULTS TO ZERO. -C IDATE - INITIAL DATE IN YYYYMMDDHH FORMAT. -C IDATE DEFAULTS TO THE CURRENT UTC DATE AND HOUR. -C FIRST CENTURY DATES WILL CAUSE ABORT AFTER 1 SEPT 1999. -C OUTPUT ARGUMENT LIST: -C NDATE - VERIFYING DATE IN YYYYMMDDHH FORMAT. -C EXIT STATES: -C 0 - SUCCESS -C 1 - FAILURE; INVALID ARGUMENT -C 2 - FAILURE; INCORRECT NUMBER OF ARGUMENTS -C -C SUBPROGRAMS CALLED: -C IARGC GET NUMBER OF ARGUMENTS -C GETARG GET ARGUMENT -C W3DIFDAT RETURN A TIME INTERVAL BETWEEN TWO DATES -C W3MOVDAT RETURN A DATE FROM A TIME INTERVAL AND DATE -C W3PRADAT FORMAT A DATE AND TIME INTO CHARACTERS -C W3UTCDAT RETURN THE UTC DATE AND TIME -C ERRMSG WRITE A MESSAGE TO STDERR -C EXIT EXIT PROGRAM -C -C ATTRIBUTES: -C LANGUAGE: FORTRAN 90 -C -C$$$ - CHARACTER*256 CARG,CFMT - INTEGER*4 IARG,LARG,NCARG,NARG,IARGC - INTEGER IDAT(8),JDAT(8) - REAL RINC(5) - LOGICAL W3VALDAT -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C GET AND CHECK OPTIONAL ARGUMENTS - NARG=IARGC() - IARG=1 - LSTOPT=0 - DOWHILE(IARG.LE.NARG.AND.LSTOPT.EQ.0) - CALL GETARG(IARG,CARG) - LARG=LEN_TRIM(CARG) - IARG=IARG+1 - IF(CARG(1:1).NE.'-'.OR. - & (CARG(2:2).GE.'0'.AND.CARG(2:2).LE.'9')) THEN - LSTOPT=1 - IARG=IARG-1 - ELSEIF(LARG.EQ.1) THEN - CALL ERRMSG('ndate: Invalid option -') - CALL EUSAGE - CALL ERREXIT(1) - ELSE - L=2 - DOWHILE(L.LE.LARG) - IF(CARG(L:L).EQ.'-') THEN - LSTOPT=1 - ELSE - CALL ERRMSG('ndate: Invalid option '//CARG(L:L)) - CALL EUSAGE - CALL ERREXIT(1) - ENDIF - L=L+1 - ENDDO - ENDIF - ENDDO -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C CHECK NUMBER OF ARGUMENTS - MARG=NARG-IARG+1 - IF(MARG.GT.2) THEN - CALL ERRMSG('ndate: Incorrect number of arguments') - CALL EUSAGE - CALL ERREXIT(2) - ENDIF -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C GET AND CHECK FIRST ARGUMENT (HOUR INCREMENT) - IF(MARG.GE.1) THEN - CALL GETARG(IARG,CARG) - NCARG=LEN_TRIM(CARG) - WRITE(CFMT,'("(I",I2,")")') NCARG - READ(CARG,CFMT,IOSTAT=IRET) IHOUR - IF(IRET.NE.0) THEN - CALL ERRMSG('ndate: Noninteger forecast hour '//CARG(1:NCARG)) - CALL EUSAGE - CALL ERREXIT(1) - ENDIF - ELSE - IHOUR=0 - ENDIF - RINC=0 - RINC(2)=IHOUR -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C GET AND CHECK SECOND ARGUMENT (INITIAL DATE) - IF(MARG.GE.2) THEN - CALL GETARG(IARG+1,CARG) - NCARG=LEN_TRIM(CARG) - WRITE(CFMT,'("(I",I2,",3I2)")') NCARG-6 - IDAT=0 - READ(CARG,CFMT,IOSTAT=IRET) IDAT(1),IDAT(2),IDAT(3),IDAT(5) - IF(IRET.NE.0.OR..NOT.W3VALDAT(IDAT)) THEN - CALL ERRMSG('ndate: Invalid date '//CARG(1:NCARG)) - CALL EUSAGE - CALL ERREXIT(1) - ENDIF - ELSE - CALL W3UTCDAT(IDAT) - ENDIF -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C COMPUTE AND PRINT NEW DATE - CALL W3MOVDAT(RINC,IDAT,JDAT) - ND=LOG10(JDAT(1)+0.5)+1 - WRITE(CFMT,'("(I",I2,",3I2.2)")') ND - PRINT CFMT,JDAT(1),JDAT(2),JDAT(3),JDAT(5) -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CONTAINS -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C WRITE USAGE - SUBROUTINE EUSAGE - CALL ERRMSG('Usage: ndate [fhour [idate]]') - ENDSUBROUTINE -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDPROGRAM From 99563462978c3bd2e4b6ef4c2c73d1d63d2a2889 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 31 Mar 2022 14:28:24 -0400 Subject: [PATCH 46/58] make DEBUG Intel flags consistent --- src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake | 2 +- src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake | 2 +- util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake index 87864efe5a..8ba2887da8 100644 --- a/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake @@ -14,7 +14,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fp-model source -debug -ftrapuv -warn all,nointerfaces -check all,noarg_temp_created -fp-stack-check -fstack-protector") #################################################################### # LINK FLAGS diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake index 87864efe5a..8ba2887da8 100644 --- a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake @@ -14,7 +14,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fp-model source -debug -ftrapuv -warn all,nointerfaces -check all,noarg_temp_created -fp-stack-check -fstack-protector") #################################################################### # LINK FLAGS diff --git a/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake index e2de8c9fec..5325a6ac2c 100644 --- a/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake +++ b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake @@ -14,7 +14,7 @@ set(CMAKE_Fortran_FLAGS_RELEASE "-O3") # DEBUG FLAGS #################################################################### -set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn all -heap-arrays -fpe-all=0 -fpe:0 -check all -debug full -fp-model strict") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fp-model source -debug -ftrapuv -warn all,nointerfaces -check all,noarg_temp_created -fp-stack-check -fstack-protector") #################################################################### # LINK FLAGS From 49487f9575c79034f5da6ad53e96bdc416c8bb0c Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 31 Mar 2022 18:57:14 +0000 Subject: [PATCH 47/58] allow users to provide CMAKE_OPTS without having to edit the script --- ush/build_all_cmake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index 16f7a946ef..6d1b8dfce0 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -110,7 +110,7 @@ fi module list set -x -cmake_opts="" +cmake_opts="${CMAKE_OPTS:-}" cmake_opts+=" -DCMAKE_BUILD_TYPE=$build_type" # Install destination for built executables, libraries, CMake Package config From d9fc845e2a2e44a53077ebffebc2497680ac2146 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 31 Mar 2022 23:33:43 -0400 Subject: [PATCH 48/58] make util build options consistent --- INSTALL.md | 115 +++++++++++++++++++++++++++++++ README.cmake | 145 --------------------------------------- ush/build_all_cmake.sh | 6 +- util/CMakeLists.txt | 47 ++++++------- util/EnKF/CMakeLists.txt | 4 +- 5 files changed, 142 insertions(+), 175 deletions(-) create mode 100644 INSTALL.md delete mode 100644 README.cmake diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000000..1fb01a6d8c --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,115 @@ +## Build and Install Instructions +--- + +### Prerequisites +A supported C and Fortran compiler (see table below). Other versions may work, in particular if close to the versions listed below. + +| Compiler vendor | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| Intel | 18.0.3.222 and above | +| GNU | 10.3.0 and above | + +A supported MPI library (see table below). Other versions may work, in particular if close to the versions listed below. + +| MPI library | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| MPICH | 3.3.1 and above | +| Open MPI | 3.1.5 and above | +| Intel MPI | 2018.0.4 and above | + +Third-party libraries (TPL) compiled with the same compiler and MPI library (where applicable). + +| Library | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| CMake | 3.20.1 and above | +| HDF5 | 1.10.4 and above | +| NetCDF-C | 4.7.3 and above | +| NetCDF-Fortran | 4.5.2 and above | + +NCEP Libraries (NCEPLibs) compiled with the same compiler and MPI library (where applicable). + +| Library | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| BUFR | 11.4.0 and above | +| CRTM | 2.3.0 and above | +| IP | 3.3.3 and above | +| SP | 2.3.3 and above | +| BACIO | 2.4.1 and above | +| W3EMC | 2.9.1 and above | +| SIGIO | 2.3.2 and above | +| SFCIO | 1.4.1 and above | +| NEMSIO | 2.5.2 and above | +| NCIO | 1.0.0 and above | +| WRF_IO | 1.2.0 and above | + +### Building the GSI + +`CMake` employs an out-of-source build. Create a directory for configuring the build and cd into it: + +```bash +mkdir -p build && cd build +``` + +Set the compilers, if needed, to match those being used for compiling the TPL and NCEPLibs listed above: `CC` and `FC` environment variables can be used to point to the desired C and Fortran compilers. + +Execute `cmake` from inside your build directory. + +```bash +cmake -DCMAKE_INSTALL_PREFIX= /path/to/GSI-source +``` + +If the dependencies are not located in a path recognized by `cmake` e.g. `/usr/local`, it may be necessary to provide the appropriate environment variables e.g. `` or `CMAKE_PREFIX_PATH` so that `cmake` is able to locate these dependencies. + +The installation prefix for GSI is provided by the `cmake` command-line argument `-DCMAKE_INSTALL_PREFIX=` + +To build and install: + +``` +make -j +make install +``` + +### CMake Options + +CMake allows for various options that can be specified on the command line via `-DCMAKE_OPTION=VALUE` or from within the ccmake gui. The list of options currently available is as follows: + +| Option | Description (Default) | +|---------------------|--------------------------------------------------------| +| `OPENMP` | Enable OpenMP Threading (`OFF`) | +| `ENABLE_MKL` | Use MKL (`ON`), If not found use LAPACK | +| `BUILD_NCDIAG` | Build GSI NetCDF Diagnostics Library (`ON`) | +| `BUILD_GSDCLOUD` | Build GSD Cloud Library (`OFF`) | +| `BUILD_GSI` | Build GSI library and executable (`ON`) | +| `BUILD_ENKF` | Build EnKF library and executable (`ON`) | +| `BUILD_REG_TESTING` | Enable Regression Testing (`ON`) | +| `BUILD_UTIL` | Build Utilities (`ON`) | +| `BUILD_UTIL_AERODA` | Build Aerosol DA utility (`OFF`) | +| `BUILD_UTIL_COV_CALC` | Build Correlated Obs. Error utility (`OFF`) | +| `BUILD_UTIL_EFSOI` | Build Ensemble FSOI application (`OFF`) | +| `BUILD_UTIL_ENKF_GFS` | Build GFS ensemble utilities (`OFF`) | +| `BUILD_UTIL_ENKF_ARW` | Build ARW ensemble utilities (`OFF`) | +| `BUILD_UTIL_MON` | Build Observation Monitoring utilities (`OFF`) | +| `BUILD_UTIL_NCIO` | Build NetCDF IO utilities (`OFF`) | +| `BUILD_UTIL_COM` | Build Miscellaneous community utilities (`ON`) | +| `BUILD_UTIL_BKGERR` | Build Background Error utility (`OFF`) | + +The flavor of GSI and EnKF can be defined with the use of the following options: + +| CMake Option | Description (Default) | Valid Options | +|---------------------|------------------------------|--------------------------------| +| `GSI_MODE` | GSI application mode (`GFS`) | `GFS`, `Regional` | +| `ENKF_MODE` | EnKF application mode (`GFS`)| `GFS`, `WRF`, `NMMB`, `FV3REG` | + +### Regression Testing + +When Regression tests are enabled (`-DBUILD_REG_TESTING=ON`), it is necessary to provide +the path to search for the control GSI and EnKF executables. This can be provided with the option `CONTROLPATH`. Other search variables are `GSICONTROLPATH` or `ENKFCONTROLPATH` for GSI and EnKF control executables respectively. + +If the control executables are not found, the Regression tests will be disabled. + +Once the build is complete and control executables have been found, regression testing can be launched from the build directory by executing: +```bash +ctest +``` + +Refer to the `ctest` manual for more information on `ctest` framework. diff --git a/README.cmake b/README.cmake deleted file mode 100644 index 52779c300d..0000000000 --- a/README.cmake +++ /dev/null @@ -1,145 +0,0 @@ -Quick start-- - -load desired compilers (intel recommended), desired mpi libraries/compilers, netcdf library (and hdf5 library for netcdf4) - -skip the following section unless you are compiling on a different machine or wish to link in special libraries ----------------------------------- -If not on WCOSS, Theia, or S4, ensure that the environment flags CC, CXX, and FC all point to to the C, C++, and Fortran compilers respectively - -If building on a machine other than WCOSS, Theia, or S4, several additional environment variables need to be set-- - COREPATH should be set to the root path where the core libraries are located (i.e. /nwprod/lib ) - WRFPATH should be set to the root path where WRF is install (i.e. /nwprod/sorc/wrf_shared.f ) - If libraries are in these locations, they should all be found once these environment variables are set. Please note that this is all done - automatically on WCOSS, Theia, and S4. - - Alternatively, any (or every) core library can also be specified via environment variable. So, if a desired library is in an unusual location - such as a user's home directory, it can be found by specifying the location like-- - export CRTM_LIB=/home/myname/MyCRTM/libcrtm.a (for csh and tcsh-- setenv CRTM_LIB /home/myname/MyCRTM/libcrtm.a ) - other library environment variable names are BACIO_LIB, BUFR_LIB, NEMSIO_LIB, SIGIO_LIB, SFCIO_LIB, SP_LIB, W3NCO_LIB W3EMC_LIB ---------------------------------- - - -Create a build directory somewhere outside the source tree. -cd to the build directory -run-- - - cmake (path-to-source-tree) - make -j 8 - -The above should find all the dependent libraries (tested on wcoss, theia and s4) and build the base gsi executable which will be -called gsi.x and located in the (build-dir)/bin directory. - ----- - -Detailed instructions - -CMake allows for various options that can be specified on the command line or from within the ccmake gui. The list of options -currently available is as follows-- - -BUILD_ENKF -- will build the enkf executable (default is ON) -BUILD_CORELIBS -- will attempt to find the source and build all the core libraries (nemsio, sigio, sfcio, sp, bacio, bufr, w3emc, w3nco crtm) -BUILD_GLOBAL -- will build GSI without WRF dependencies (default is OFF) -USE_WRF -- will build GSI with WRF dependencies (default is ON) -BUILD_REG_TESTING -- will build GSI with regression testing built in (default is ON) -BUILD_GFS -- will build ENKF using GFS (default is ON) -BUILD_WRF -- will build ENKF using WRF (default is OFF) -BUILD_NMMB -- will build ENKF using NMMB (default is OFF) - -If CMake cannot find the source for a given library (should not be a problem on WCOSS, Theia, or S4), the location may be specified via -environment variable. The names of those variables is as follows-- - BACIO_SRC - CRTM_SRC - BUFR_SRC - NEMSIO_SRC - SIGIO_SRC - SFCIO_SRC - SP_SRC - W3NCO_SRC - W3EMC_SRC -If specified, these variables should point to the the actual directory containing the source (i.e. export BACIO_SRC=/nwprod2/lib/bacio/v2.0.2/src ) -If the modules for the libraries are loaded on WCOSS, they will automatically be detected by CMake - -If BUILD_CORELIBS is turned on, individual libraries can be turned off using -BUILD_CRTM -BUILD_SIGIO -BUILD_SFCIO -BUILD_NEMSIO -BUILD_SP -BUILD_BUFR -BUILD_BACIO -BUILD_NCO -BUILD_EMC - -An example of configuring the GSI model to compile along with all the core libraries and the ENKF executable using WRF would be as follows - -cmake -DBUILD_WRF=ON -DBUILD_CORELIBS=ON (path-to-source-tree) - -Building only the GSI, ENKF and CRTM executables/library can be done as follows-- - -cmake -DBUILD_ENKF=ON -DBUILD_CORELIBS=ON -DBUILD_BACIO=OFF -DBUILD_SP=OFF -DBUILD_NEMSIO=OFF -DBUILD_NCO=OFF -DBUILD_EMC=OFF -DBUILD_SFCIO=OFF -DBUILD_SIGIO=OFF -DBUILD_BUFR=OFF (path-to-source-tree) - -If the core libraries desired are not located in the traditional paths, a hint can be provided to cmake via the environment variable $COREPATH. Similarly, -the environment variable $WRFPATH can give cmake a hint to find the WRF libraries and associated files (pack_utils.o, module_machine.o) - -------------- - -Using the ccmake utility - -ccmake is a text-based front end to cmake. It can be launched with the same syntax as cmake, but will provide the user with feedback and requests for more -instructions. A typical usage would be as follows-- - -from the build directory-- - -ccmake (path_to_source_tree) - -(from the menu at the bottom--press c to configure) - -Some stdout will show up on the screen and the menu will offer "Press [e] to exit help" -Press e - -Press c to configure - -(the above steps might have to be repeated) - -With no errors, the " Press [g] to generate and exit" option should show up in the menu section -Press g to generate a CMakeCache.txt file - -This should exit ccmake and leave you in the build directory. -Type make -j n to commence the parallel build (where n is the number of cores to use) -- 4 may be around the maximum number that can be utilized currently - ------ - -Background on cmake and associated files---- - -cmake and ccmake create a file called "CMakeCache.txt" and a directory called CMakeFiles in the build directory. -The CMakeCache.txt file can be edited using a text editor or by re-running ccmake and changing some of the configurations there. -In some cases, cmake will not be able to "re-find" various libraries because of conflicts in the CMakeFiles directory. If this appears to be -happening, remove CMakeCache.txt and CMakeFiles and re-run cmake/ccmake with a fresh set of requested options. - -It is also important to note that when run from the build directory, cmake will not modify any source files and it is safe to delete the entire build -tree and start over at any time. The GSI cmake build system has also been set up not to allow for in-source builds. - -Once cmake or ccmake have been run initially by pointing to the source tree, ccmake can be re-run with "ccmake ." -When run in this fashion, it will simply read the CMakeCache.txt file and allow a user to edit the desired options - ------ - -Regression Testing on WCOSS and Theia - -CMake will attempt to locate a control executable (gsi.x or global_gsi) somewhere in your source code treee. It is currently designed to look in -your source tree (up to two levels above the branch) as well as in Michael Lueken's directory. If it cannot find an executable, you can still -define the location inside the CMakeCache.txt file in your build directory. The name of the variable is GSICONTROL and it needs a full path to -the executable. - -Once a control has been found and the build is complete, regression testing can be launched by running "make test" or "ctest" from the build directory. -When run as simply "make test" or "ctest", the tests will run one at a time. However, the tests can be launched in parallel by adding the "-j N" argument -as such-- - make test "ARGS= -j N" - ctest -j N - -where N is the number of parallel jobs desired. Similarly, individual regression tests may be run by specifying them via the -I parameter. -For example, - - make test "ARGS= -I 12" - -will run only the hwrf_nmm_d2 test. See "man ctest" for further details. diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh index 6d1b8dfce0..42bc2c246e 100755 --- a/ush/build_all_cmake.sh +++ b/ush/build_all_cmake.sh @@ -123,15 +123,11 @@ cmake_opts+=" -DCMAKE_INSTALL_BINDIR=exec" cmake_opts+=" -DGSI_MODE=Regional -DENKF_MODE=GFS" # Build utilities: -cmake_opts+=" -DBUILD_COV_CALC=ON -DBUILD_ENKF_GFS=ON -DBUILD_EFSOI_UTIL=ON -DBUILD_MON_UTIL=ON" +cmake_opts+=" -DBUILD_UTIL_COV_CALC=ON -DBUILD_UTIL_ENKF_GFS=ON -DBUILD_UTIL_EFSOIL=ON -DBUILD_UTIL_MON=ON" # Build regression test cmake_opts+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=${CONTROLPATH:-}" -# Valid combination of applications are: -# Global : -DGSI_MODE=GFS -DENKF_MODE=GFS -# Regional: -DGSI_MODE=Regional -DENKF_MODE=WRF|NMMB|FV3REG - cmake $cmake_opts $dir_root # Build apps. Echo extra printout for NCO build diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index d98eaaf33f..9a1257bbee 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -30,28 +30,28 @@ option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) # Build options -option(BUILD_AERODA_UTIL "Build Aerosol DA utilities" OFF) -option(BUILD_COV_CALC "Build Correlated Observation Error Utility" OFF) -option(BUILD_EFSOI_UTIL "Build EFSOI Utilities" OFF) -option(BUILD_ENKF_GFS "Build EnKF GFS Utilities" OFF) -option(BUILD_ENKF_ARW "Build EnKF ARW Utilities" OFF) -option(BUILD_MON_UTIL "Build Monitoring Utilities" OFF) -option(BUILD_NCIO_UTIL "Build NetCDF IO Utilities" OFF) +option(BUILD_UTIL_AERODA "Build Aerosol DA utilities" OFF) +option(BUILD_UTIL_COV_CALC "Build Correlated Observation Error Utility" OFF) +option(BUILD_UTIL_EFSOI "Build EFSOI Utilities" OFF) +option(BUILD_UTIL_ENKF_GFS "Build EnKF GFS Utilities" OFF) +option(BUILD_UTIL_ENKF_ARW "Build EnKF ARW Utilities" OFF) +option(BUILD_UTIL_MON "Build Monitoring Utilities" OFF) +option(BUILD_UTIL_NCIO "Build NetCDF IO Utilities" OFF) option(BUILD_UTIL_COM "Build community utilities" OFF) -option(BUILD_BKGERR_UTIL "Build Background Error Utilities" OFF) +option(BUILD_UTIL_BKGERR "Build Background Error Utilities" OFF) # Echo user options message(STATUS "Utils: OPENMP ................. ${OPENMP}") message(STATUS "Utils: ENABLE_MKL ............. ${ENABLE_MKL}") -message(STATUS "Utils: BUILD_AERODA_UTIL ...... ${BUILD_AERODA_UTIL}") -message(STATUS "Utils: BUILD_COV_CALC ......... ${BUILD_COV_CALC}") -message(STATUS "Utils: BUILD_EFSOI_UTIL ....... ${BUILD_EFSOI_UTIL}") -message(STATUS "Utils: BUILD_ENKF_GFS ......... ${BUILD_ENKF_GFS}") -message(STATUS "Utils: BUILD_ENKF_ARW ......... ${BUILD_ENKF_ARW}") -message(STATUS "Utils: BUILD_MON_UTIL ......... ${BUILD_MON_UTIL}") -message(STATUS "Utils: BUILD_NCIO_UTIL ........ ${BUILD_NCIO_UTIL}") +message(STATUS "Utils: BUILD_UTIL_AERODA ...... ${BUILD_UTIL_AERODA}") +message(STATUS "Utils: BUILD_UTIL_COV_CALC .... ${BUILD_UTIL_COV_CALC}") +message(STATUS "Utils: BUILD_UTIL_EFSOI ....... ${BUILD_UTIL_EFSOI}") +message(STATUS "Utils: BUILD_UTIL_ENKF_GFS .... ${BUILD_UTIL_ENKF_GFS}") +message(STATUS "Utils: BUILD_UTIL_ENKF_ARW .... ${BUILD_UTIL_ENKF_ARW}") +message(STATUS "Utils: BUILD_UTIL_MON ......... ${BUILD_UTIL_MON}") +message(STATUS "Utils: BUILD_UTIL_NCIO ........ ${BUILD_UTIL_NCIO}") message(STATUS "Utils: BUILD_UTIL_COM ......... ${BUILD_UTIL_COM}") -message(STATUS "Utils: BUILD_BKGERR_UTIL ...... ${BUILD_BKGERR_UTIL}") +message(STATUS "Utils: BUILD_UTIL_BKGERR ...... ${BUILD_UTIL_BKGERR}") # Dependencies if(ENABLE_MKL) @@ -99,23 +99,23 @@ target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) # Get compiler flags for the utilities include(gsiutils_compiler_flags) -if(BUILD_AERODA_UTIL) +if(BUILD_UTIL_AERODA) add_subdirectory(AeroDA) endif() -if(BUILD_COV_CALC) +if(BUILD_UTIL_COV_CALC) add_subdirectory(Correlated_Obs) endif() -if(BUILD_EFSOI_UTIL) +if(BUILD_UTIL_EFSOI) add_subdirectory(EFSOI_Utilities) endif() -if(BUILD_ENKF_GFS OR BUILD_ENKF_ARW) +if(BUILD_UTIL_ENKF_GFS OR BUILD_UTIL_ENKF_ARW) add_subdirectory(EnKF) endif() -if(BUILD_NCIO_UTIL) +if(BUILD_UTIL_NCIO) add_subdirectory(netcdf_io) endif() @@ -125,16 +125,17 @@ if(BUILD_UTIL_COM) add_subdirectory(radar_process) endif() -if(BUILD_BKGERR_UTIL) +if(BUILD_UTIL_BKGERR) add_subdirectory(NMC_Bkerror) endif() -if(BUILD_MON_UTIL) +if(BUILD_UTIL_MON) add_subdirectory(Conventional_Monitor) add_subdirectory(Ozone_Monitor) add_subdirectory(Radiance_Monitor) endif() +# These don't fall into any category add_subdirectory(FOV_utilities) add_subdirectory(Single_Observation) add_subdirectory(zero_biascoeff) diff --git a/util/EnKF/CMakeLists.txt b/util/EnKF/CMakeLists.txt index 8a73a74d3a..e3ef438102 100644 --- a/util/EnKF/CMakeLists.txt +++ b/util/EnKF/CMakeLists.txt @@ -1,8 +1,8 @@ -if(BUILD_ENKF_GFS) +if(BUILD_UTIL_ENKF_GFS) add_subdirectory(gfs) endif() -if(BUILD_ENKF_ARW) +if(BUILD_UTIL_ENKF_ARW) if(NOT TARGET gsi) if(NOT gsi_FOUND) message(FATAL_ERROR "Utils: GSI library was not found for EnKF ARW utilities") From eb0a1e2fad6fcb246b0247faf05ef1e48c84b2a3 Mon Sep 17 00:00:00 2001 From: Christopher Harrop <35781497+christopherwharrop-noaa@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:14:14 -0600 Subject: [PATCH 49/58] Fix logical comparison bug caught by Gnu build (#4) --- src/enkf/gridio_fv3reg.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/enkf/gridio_fv3reg.f90 b/src/enkf/gridio_fv3reg.f90 index 0dd03dfb82..55494ee0c3 100644 --- a/src/enkf/gridio_fv3reg.f90 +++ b/src/enkf/gridio_fv3reg.f90 @@ -227,7 +227,7 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f endif - if (tv_ind > 0.or.tsen_ind) then + if (tv_ind > 0.or.tsen_ind > 0) then allocate(tsenworkvar3d(nx_res,ny_res,nlevs)) varstrname = 'T' call read_fv3_restart_data3d(varstrname,fv3filename,file_id,tsenworkvar3d) From f480914c41806e280cab9622993286102bee4f12 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 6 Apr 2022 16:38:14 -0400 Subject: [PATCH 50/58] bugfix for cheyenne --- src/enkf/gridinfo_fv3reg.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index 772e6cf9b2..0825b3a631 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -42,7 +42,8 @@ module gridinfo ! !$$$ -use mpisetup, only: nproc, mpi_integer, mpi_real4, mpi_comm_world +use mpi +use mpisetup, only: nproc use params, only: datapath,nlevs,nlons,nlats,use_gfs_nemsio, fgfileprefixes, & fv3fixpath, nx_res,ny_res, ntiles use kinds, only: r_kind, i_kind, r_double, r_single From 091927370f3228369d81fc286fecc9c53f0c9a96 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 6 Apr 2022 17:08:01 -0400 Subject: [PATCH 51/58] fix logical comparison --- src/enkf/gridio_fv3reg.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/enkf/gridio_fv3reg.f90 b/src/enkf/gridio_fv3reg.f90 index 930264bc26..c7a300da68 100644 --- a/src/enkf/gridio_fv3reg.f90 +++ b/src/enkf/gridio_fv3reg.f90 @@ -259,7 +259,7 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f endif - if (tv_ind > 0.or.tsen_ind) then + if (tv_ind > 0 .or. tsen_ind > 0) then allocate(tsenworkvar3d(nx_res,ny_res,nlevs)) varstrname = 'T' call fv3lamfile%get_idfn(varstrname,file_id,fv3filename) From dabbce1b72050bd5de6d7fd72a0b20e40cada2a6 Mon Sep 17 00:00:00 2001 From: "Ming.Hu" Date: Fri, 8 Apr 2022 05:33:00 +0000 Subject: [PATCH 52/58] Sync rrfs and cmake-refactor branch --- src/gsi/cplr_read_wrf_mass_guess.f90 | 22 ++- src/gsi/cplr_wrwrfmassa.f90 | 74 ++++++-- src/gsi/gsd_update_mod.f90 | 25 ++- src/gsi/gsi_rfv3io_mod.f90 | 256 ++++++++++++++++++++++----- src/gsi/setupt.f90 | 23 ++- src/gsi/unfill_mass_grid2.f90 | 73 ++++++++ src/gsi/update_guess.f90 | 6 +- 7 files changed, 377 insertions(+), 102 deletions(-) diff --git a/src/gsi/cplr_read_wrf_mass_guess.f90 b/src/gsi/cplr_read_wrf_mass_guess.f90 index 3df389bcba..9bdd7997c2 100644 --- a/src/gsi/cplr_read_wrf_mass_guess.f90 +++ b/src/gsi/cplr_read_wrf_mass_guess.f90 @@ -170,7 +170,7 @@ subroutine read_wrf_mass_binary_guess_wrf(this,mype) integer(i_kind) n_actual_clouds real(r_kind), pointer :: ges_ps_it (:,: )=>NULL() - real(r_kind), pointer :: ges_th2_it(:,: )=>NULL() + real(r_kind), pointer :: ges_t2m_it(:,: )=>NULL() real(r_kind), pointer :: ges_q2_it (:,: )=>NULL() real(r_kind), pointer :: ges_tsk_it(:,: )=>NULL() real(r_kind), pointer :: ges_soilt1_it(:,:)=>NULL() @@ -291,8 +291,8 @@ subroutine read_wrf_mass_binary_guess_wrf(this,mype) if (ier/=0) call die(trim(myname),'cannot get pointers for met-fields, ier =',ier) if (l_gsd_soilTQ_nudge .or.i_use_2mt4b>0) then - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'th2m', ges_th2_it,istatus );ier=ier+istatus - if (ier/=0) call die(trim(myname),'cannot get pointers for th2m, ier=',ier) + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 't2m', ges_t2m_it,istatus );ier=ier+istatus + if (ier/=0) call die(trim(myname),'cannot get pointers for t2m, ier=',ier) endif if (l_gsd_soilTQ_nudge) then @@ -1188,10 +1188,14 @@ subroutine read_wrf_mass_binary_guess_wrf(this,mype) ges_xlat(j,i,it)=real(all_loc(j,i,i_xlat),r_kind)/rad2deg_single endif if(l_gsd_soilTQ_nudge) then - ges_th2_it(j,i)=real(all_loc(j,i,i_th2),r_kind) ges_tsk_it(j,i)=real(all_loc(j,i,i_tsk),r_kind) ges_soilt1_it(j,i)=real(all_loc(j,i,i_soilt1),r_kind) endif + if(i_use_2mt4b > 0 ) then + ges_t2m_it(j,i)=real(all_loc(j,i,i_th2),r_kind) + ! convert from potential to sensible temperature + ges_t2m_it(j,i)=ges_t2m_it(j,i)*(ges_ps_it(j,i)/r100)**rd_over_cp_mass + endif if(i_use_2mq4b>0) then ges_q2_it(j,i)=real(all_loc(j,i,i_q2),r_kind) ! Convert 2m guess mixing ratio to specific humidity @@ -1449,7 +1453,7 @@ subroutine read_wrf_mass_netcdf_guess_wrf(this,mype) real(r_kind) :: ges_rho, tsn real(r_kind), pointer :: ges_ps_it (:,: )=>NULL() - real(r_kind), pointer :: ges_th2_it(:,: )=>NULL() + real(r_kind), pointer :: ges_t2m_it(:,: )=>NULL() real(r_kind), pointer :: ges_q2_it (:,: )=>NULL() real(r_kind), pointer :: ges_tsk_it(:,: )=>NULL() real(r_kind), pointer :: ges_soilt1_it(:,:)=>NULL() @@ -1933,8 +1937,8 @@ subroutine read_wrf_mass_netcdf_guess_wrf(this,mype) if (ier/=0) call die(trim(myname),'cannot get pointers for q2m, ier =',ier) endif if (i_use_2mt4b > 0) then - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'th2m',ges_th2_it, istatus );ier=ier+istatus - if (ier/=0) call die(trim(myname),'cannot get pointers for th2m,ier =',ier) + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 't2m',ges_t2m_it, istatus );ier=ier+istatus + if (ier/=0) call die(trim(myname),'cannot get pointers for t2m,ier =',ier) endif if (l_gsd_soilTQ_nudge) then call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'tskn',ges_tsk_it, istatus );ier=ier+istatus @@ -2251,7 +2255,9 @@ subroutine read_wrf_mass_netcdf_guess_wrf(this,mype) sno(j,i,it)=real(all_loc(j,i,i_0+i_sno),r_kind) sfc_rough(j,i,it)=rough_default if(i_use_2mt4b > 0 ) then - ges_th2_it(j,i)=real(all_loc(j,i,i_0+i_th2),r_kind) + ges_t2m_it(j,i)=real(all_loc(j,i,i_0+i_th2),r_kind) + ! convert from potential to sensible temperature + ges_t2m_it(j,i)=ges_t2m_it(j,i)*(ges_ps_it(j,i)/r100)**rd_over_cp_mass endif ! for GSD soil nudging if(l_gsd_soilTQ_nudge) then diff --git a/src/gsi/cplr_wrwrfmassa.f90 b/src/gsi/cplr_wrwrfmassa.f90 index c1848f8a59..ba987fc6fb 100644 --- a/src/gsi/cplr_wrwrfmassa.f90 +++ b/src/gsi/cplr_wrwrfmassa.f90 @@ -89,7 +89,7 @@ subroutine wrwrfmassa_binary_wrf(this,mype) use constants, only: soilmoistmin use gsi_io, only: lendian_in,verbose use rapidrefresh_cldsurf_mod, only: l_hydrometeor_bkio,l_gsd_soilTQ_nudge,& - i_use_2mq4b + i_use_2mq4b,i_use_2mt4b use wrf_mass_guess_mod, only: destroy_cld_grids use gsi_bundlemod, only: GSI_BundleGetPointer use gsi_metguess_mod, only: gsi_metguess_get,GSI_MetGuess_Bundle @@ -156,7 +156,7 @@ subroutine wrwrfmassa_binary_wrf(this,mype) real(r_kind), pointer :: ges_ps(:,:)=>NULL() real(r_kind), pointer :: ges_tsk(:,:)=>NULL() - real(r_kind), pointer :: ges_th2(:,:)=>NULL() + real(r_kind), pointer :: ges_t2m(:,:)=>NULL() real(r_kind), pointer :: ges_q2(:,:)=>NULL() real(r_kind), pointer :: ges_soilt1(:,:)=>NULL() real(r_kind), pointer :: ges_tslb_it(:,:,:)=>NULL() @@ -751,8 +751,6 @@ subroutine wrwrfmassa_binary_wrf(this,mype) end do end do ier=0 - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'th2m', ges_th2, istatus );ier=ier+istatus - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'q2m' , ges_q2, istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'tsoil', ges_soilt1, istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'tskn' , ges_tsk , istatus );ier=ier+istatus if (ier/=0) then ! doesn't have to die - code can be generalized to bypass missing vars @@ -764,12 +762,23 @@ subroutine wrwrfmassa_binary_wrf(this,mype) do j=1,lat1 jp1=j+1 all_loc(j,i,i_tsk)=ges_tsk(jp1,ip1) - all_loc(j,i,i_th2)=ges_th2(jp1,ip1) all_loc(j,i,i_soilt1)=ges_soilt1(jp1,ip1) end do end do endif ! l_gsd_soilTQ_nudge + if(i_use_2mt4b > 0 ) then + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 't2m', ges_t2m, istatus );ier=ier+istatus + do i=1,lon1 + ip1=i+1 + do j=1,lat1 + ! Convert 2m sensible T to potential T + jp1=j+1 + all_loc(j,i,i_th2)=ges_t2m(jp1,ip1)*(r100/ges_ps(jp1,ip1))**rd_over_cp_mass + end do + end do + endif if (i_use_2mq4b > 0) then + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'q2m' , ges_q2, istatus );ier=ier+istatus do i=1,lon1 ip1=i+1 do j=1,lat1 @@ -1882,6 +1891,7 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) ! Declare local parameters character(len=*),parameter::myname='wrwrfmassa_netcdf' real(r_kind),parameter:: r225=225.0_r_kind + integer, parameter :: nlvl_qcheck=3 real(r_kind),parameter:: D608=0.608_r_kind ! Declare local variables @@ -1890,8 +1900,10 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) real(r_single),allocatable::all_loc(:,:,:) real(r_single),allocatable::strp(:) real(r_single),allocatable::landmask(:),snow(:),seaice(:),t1st2d(:),pt2t(:) + real(r_single),allocatable::qs1st2d(:,:),sfcprs(:) + real(r_kind),allocatable::tmp2da(:,:),tmp2db(:,:),tmp2dc(:,:) character(6) filename - integer(i_kind) i,j,k,kt,kq,ku,kv,it,i_psfc,i_t,i_q,i_u,i_v,i_w,i_dbz + integer(i_kind) i,j,k,kt,kq,ku,kv,it,i_psfc,i_t,i_q,i_u,i_v,i_w,i_dbz,ij integer(i_kind) i_qc,i_qi,i_qr,i_qs,i_qg,i_qnr,i_qni,i_qnc integer(i_kind) kqc,kqi,kqr,kqs,kqg,kqnr,kqni,kqnc,i_tt,ktt,kw,kdbz integer(i_kind) i_sst,i_skt,i_th2,i_q2,i_soilt1,i_tslb,i_smois,ktslb,ksmois @@ -1911,7 +1923,7 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) real(r_kind), pointer :: ges_ps(:,: )=>NULL() real(r_kind), pointer :: ges_tsk(:,:)=>NULL() - real(r_kind), pointer :: ges_th2(:,:)=>NULL() + real(r_kind), pointer :: ges_t2m(:,:)=>NULL() real(r_kind), pointer :: ges_q2(:,:)=>NULL() real(r_kind), pointer :: ges_soilt1(:,:)=>NULL() real(r_kind), pointer :: ges_tslb_it(:,:,:)=>NULL() @@ -2095,6 +2107,8 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) if(mype==0) then allocate(landmask(im*jm),snow(im*jm),seaice(im*jm)) allocate(t1st2d(im*jm),pt2t(im*jm)) + allocate(qs1st2d(im*jm,nlvl_qcheck)) + allocate(sfcprs(im*jm)) endif if(mype == 0) write(6,*)' at 2 in wrwrfmassa' @@ -2373,8 +2387,7 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) call unfill_mass_grid2t(tempa,im,jm,temp1) write(lendian_out)temp1 do i=1,im*jm - work_prsl = one_tenth*(aeta1_ll(1)*(temp1(i)/r100-pt_ll)+aeta2_ll(1)+pt_ll) - pt2t(i) = (work_prsl/r100)**rd_over_cp_mass + sfcprs(i) = temp1(i) enddo end if @@ -2399,11 +2412,29 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) end do call unfill_mass_grid2t(tempa,im,jm,temp1) write(lendian_out)temp1 - if(k==1) then - do i=1,im*jm - t1st2d(i)=temp1(i)*pt2t(i) ! convert potential to sensible T - end do - pt2t=t1st2d ! save a copy + if(k>=1 .and. k<=nlvl_qcheck) then + ! calculate moisture saturation at model 1st level + allocate(tmp2da(im,jm),tmp2db(im,jm),tmp2dc(im,jm)) + ij=0 + do j=1,jm + do i=1,im + ij=ij+1 + work_prsl = one_tenth*(aeta1_ll(k)*(sfcprs(ij)/r100-pt_ll)+aeta2_ll(k)+pt_ll) + tmp2dc(i,j)=work_prsl ! pressure + tmp2db(i,j)=temp1(ij)*(work_prsl/r100)**rd_over_cp_mass ! T in K + if(k==1) t1st2d(ij) = tmp2db(i,j) + enddo + enddo + call genqsat(tmp2da,tmp2db,tmp2dc,im,jm,1,.false.,0) + ij=0 + do j=1,jm + do i=1,im + ij=ij+1 + qs1st2d(ij,k)=tmp2da(i,j) ! moisture saturation + enddo + enddo + deallocate(tmp2da,tmp2db,tmp2dc) + if(k==1) pt2t=t1st2d ! save a copy endif end if end do @@ -2421,7 +2452,11 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) do i=1,iglobal tempa(i)=tempa(i)-tempb(i) end do - call unfill_mass_grid2t(tempa,im,jm,temp1) + if(k>=1 .and. k<=nlvl_qcheck) then + call unfill_mass_grid2t_drycheck(tempa,im,jm,temp1,qs1st2d(:,k)) + else + call unfill_mass_grid2t(tempa,im,jm,temp1) + endif write(lendian_out)temp1 end if end do @@ -2528,14 +2563,15 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) endif ! l_gsd_soilTQ_nudge if(i_use_2mt4b > 0 ) then - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'th2m', ges_th2,istatus );ier=ier+istatus + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 't2m', ges_t2m,istatus );ier=ier+istatus if (ier/=0) then ! doesn't have to die - code can be generalized to bypass write(6,*)'wrwrfmassa_netcdf: getpointer failed, cannot retrieve th2' call stop2(999) endif +! convert to potential T do i=1,lon2 do j=1,lat2 - all_loc(j,i,i_th2)=ges_th2(j,i) + all_loc(j,i,i_th2)=ges_t2m(j,i)*(r100/ges_ps(j,i))**rd_over_cp_mass end do end do endif @@ -2709,7 +2745,7 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) end do write(6,*)' at 10.13 in wrwrfmassa,max,min(tempa)=', & maxval(tempa),minval(tempa) - call unfill_mass_grid2t(tempa,im,jm,temp1) + call unfill_mass_grid2t_drycheck(tempa,im,jm,temp1,qs1st2d(:,1)) write(6,*)' at 10.14 in wrwrfmassa,max,min(temp1)=', & maxval(temp1),minval(temp1) write(lendian_out)temp1 @@ -3015,6 +3051,8 @@ subroutine wrwrfmassa_netcdf_wrf(this,mype) deallocate(seaice) deallocate(t1st2d) deallocate(pt2t) + deallocate(qs1st2d) + deallocate(sfcprs) endif end subroutine wrwrfmassa_netcdf_wrf diff --git a/src/gsi/gsd_update_mod.f90 b/src/gsi/gsd_update_mod.f90 index 59e04ff46c..8c251bc6c9 100644 --- a/src/gsi/gsd_update_mod.f90 +++ b/src/gsi/gsd_update_mod.f90 @@ -15,7 +15,7 @@ module gsd_update_mod ! subroutines included: ! sub gsd_update_soil_tq - change surface and soil based on analysis increment ! sub gsd_limit_ocean_q - limits to analysis increments over oceans -! sub gsd_update_th2 - adjust 2-m t based on analysis increment +! sub gsd_update_t2m - adjust 2-m t based on analysis increment ! sub gsd_update_q2 - adjust 2-m q based on analysis increment ! ! Variable Definitions: @@ -30,7 +30,7 @@ module gsd_update_mod ! set subroutines to public public :: gsd_update_soil_tq public :: gsd_limit_ocean_q - public :: gsd_update_th2 + public :: gsd_update_t2m public :: gsd_update_q2 public :: gsd_gen_coast_prox ! set passed variables to public @@ -487,10 +487,10 @@ subroutine gsd_limit_ocean_q(qinc,it) deallocate(rhgues) end subroutine gsd_limit_ocean_q -subroutine gsd_update_th2(tinc,it) +subroutine gsd_update_t2m(tinc,it) !$$$ subprogram documentation block ! . . . . -! subprogram: gsd_update_th2 adjust 2-m t based on analysis increment +! subprogram: gsd_update_t2m adjust 2-m t based on analysis increment ! prgmmr: Hu org: GSD date: 2011-10-04 ! ! abstract: This routine does the following things: @@ -516,7 +516,8 @@ subroutine gsd_update_th2(tinc,it) use jfunc, only: tsensible use constants, only: zero,one,fv,rd_over_cp_mass,one_tenth use gridmod, only: lat2,lon2,aeta1_ll,pt_ll,aeta2_ll -! use guess_grids, only: nfldsig + use guess_grids, only:ges_prsi + use constants, only: half implicit none @@ -530,14 +531,14 @@ subroutine gsd_update_th2(tinc,it) real(r_kind) :: dth2, work_prsl,work_prslk real(r_kind),dimension(:,: ),pointer:: ges_ps =>NULL() - real(r_kind),dimension(:,: ),pointer:: ges_th2=>NULL() + real(r_kind),dimension(:,: ),pointer:: ges_t2m=>NULL() real(r_kind),dimension(:,:,:),pointer:: ges_q =>NULL() !******************************************************************************* ! ! 2-m temperature ! do it=1,nfldsig - call gsi_bundlegetpointer(gsi_metguess_bundle(it),'th2m',ges_th2,ier) + call gsi_bundlegetpointer(gsi_metguess_bundle(it),'t2m',ges_t2m,ier) if(ier/=0) return call gsi_bundlegetpointer(gsi_metguess_bundle(it),'ps',ges_ps,ier) if(ier/=0) return @@ -552,17 +553,15 @@ subroutine gsd_update_th2(tinc,it) if(ihaveq/=0) cycle dth2=tinc(i,j)/(one+fv*ges_q(i,j,1)) endif -! Convert sensible temperature to potential temperature - work_prsl = one_tenth*(aeta1_ll(1)*(r10*ges_ps(i,j)-pt_ll)+ & - aeta2_ll(1) + pt_ll) - work_prslk = (work_prsl/r100)**rd_over_cp_mass - ges_th2(i,j) = ges_th2(i,j) + dth2/work_prslk + +! do not need to convert sensible temperature to potential temperature + ges_t2m(i,j) = ges_t2m(i,j) + dth2 end do end do ! end do return -end subroutine gsd_update_th2 +end subroutine gsd_update_t2m subroutine gsd_update_q2(qinc,it) !$$$ subprogram documentation block diff --git a/src/gsi/gsi_rfv3io_mod.f90 b/src/gsi/gsi_rfv3io_mod.f90 index bc2b4ed1f6..1876027cef 100644 --- a/src/gsi/gsi_rfv3io_mod.f90 +++ b/src/gsi/gsi_rfv3io_mod.f90 @@ -29,6 +29,7 @@ module gsi_rfv3io_mod ! sub gsi_fv3ncdf_writeps ! sub gsi_fv3ncdf_write ! sub gsi_fv3ncdf_write_v1 +! sub gsi_fv3ncdf2d_write ! sub check ! ! variable definitions: @@ -45,6 +46,7 @@ module gsi_rfv3io_mod use gsi_bundlemod, only : gsi_bundle use general_sub2grid_mod, only: sub2grid_info use gridmod, only: fv3_io_layout_y + use rapidrefresh_cldsurf_mod, only: i_use_2mq4b,i_use_2mt4b implicit none public type_fv3regfilenameg public bg_fv3regfilenameg @@ -79,17 +81,14 @@ module gsi_rfv3io_mod type(sub2grid_info) :: grd_fv3lam_tracer_ionouv type(sub2grid_info) :: grd_fv3lam_uv integer(i_kind) ,parameter:: ndynvarslist=13, ntracerslist=8 - character(len=max_varname_length), dimension(ndynvarslist), parameter :: & - vardynvars = [character(len=max_varname_length) :: & - "u","v","u_w","u_s","v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"] - character(len=max_varname_length), dimension(ntracerslist), parameter :: & - vartracers = [character(len=max_varname_length) :: & - 'q','oz','ql','qi','qr','qs','qg','qnr'] - character(len=max_varname_length), dimension(15), parameter :: & - varfv3name = [character(len=max_varname_length) :: & - 'u','v','W','T','delp','sphum','o3mr','liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'], & - vgsiname = [character(len=max_varname_length) :: & - 'u','v','w','tsen','delp','q','oz','ql','qi','qr','qs','qg','qnr','ps','delzinc'] + character(len=max_varname_length), parameter :: vardynvars(ndynvarslist) =(/"u","v","u_w","u_s", & + "v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"/) + character(len=max_varname_length), parameter :: vartracers(ntracerslist) =(/'q','oz', & + 'ql','qi','qr','qs','qg','qnr'/) + character(len=max_varname_length), parameter :: varfv3name(15) =(/'u','v','W','T','delp','sphum','o3mr', & + 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'/) + character(len=max_varname_length), parameter :: vgsiname(15) =(/'u','v','w','tsen','delp','q','oz', & + 'ql','qi','qr','qs','qg','qnr','ps','delzinc'/) character(len=max_varname_length),dimension(:),allocatable:: name_metvars2d character(len=max_varname_length),dimension(:),allocatable:: name_metvars3d @@ -109,7 +108,7 @@ module gsi_rfv3io_mod public :: mype_u,mype_v,mype_t,mype_q,mype_p,mype_oz,mype_ql public :: mype_qi,mype_qr,mype_qs,mype_qg,mype_qnr,mype_w public :: k_slmsk,k_tsea,k_vfrac,k_vtype,k_stype,k_zorl,k_smc,k_stc - public :: k_snwdph,k_f10m,mype_2d,n2d,k_orog,k_psfc + public :: k_snwdph,k_f10m,mype_2d,n2d,k_orog,k_psfc,k_t2m,k_q2m public :: ijns,ijns2d,displss,displss2d,ijnz,displsz_g public :: fv3lam_io_dynmetvars3d_nouv,fv3lam_io_tracermetvars3d_nouv public :: fv3lam_io_dynmetvars2d_nouv,fv3lam_io_tracermetvars2d_nouv @@ -118,7 +117,7 @@ module gsi_rfv3io_mod integer(i_kind) mype_qi,mype_qr,mype_qs,mype_qg,mype_qnr,mype_w integer(i_kind) k_slmsk,k_tsea,k_vfrac,k_vtype,k_stype,k_zorl,k_smc,k_stc - integer(i_kind) k_snwdph,k_f10m,mype_2d,n2d,k_orog,k_psfc + integer(i_kind) k_snwdph,k_f10m,mype_2d,n2d,k_orog,k_psfc,k_t2m,k_q2m parameter( & k_f10m =1, & !fact10 k_stype=2, & !soil_type @@ -130,8 +129,10 @@ module gsi_rfv3io_mod k_stc =8, & !soil_temp k_smc =9, & !soil_moi k_slmsk=10, & !isli - k_orog =11, & !terrain - n2d=11 ) + k_t2m =11, & ! 2 m T + k_q2m =12, & ! 2 m Q + k_orog =13, & !terrain + n2d=13 ) logical :: grid_reverse_flag character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_io_dynmetvars3d_nouv ! copy of cvars3d excluding uv 3-d fields @@ -711,7 +712,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) use mpimod, only: mpi_comm_world use guess_grids, only:ges_prsi use gridmod, only: lat2,lon2,nsig,ijn,eta1_ll,eta2_ll,ijn_s - use constants, only: one,fv + use constants, only: one,fv,rd_over_cp_mass,r10,r1000 use gsi_metguess_mod, only: gsi_metguess_bundle use gsi_bundlemod, only: gsi_bundleinquire, gsi_bundlegetpointer use gsi_bundlemod, only: gsi_bundlecreate,gsi_bundledestroy @@ -743,6 +744,8 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) real(r_kind),dimension(:,:,:),pointer::ges_tv=>NULL() real(r_kind),dimension(:,:,:),pointer::ges_tsen_readin=>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_delp =>NULL() + real(r_kind),dimension(:,:),pointer::ges_t2m=>NULL() + real(r_kind),dimension(:,:),pointer::ges_q2m=>NULL() real(r_kind),dimension(:,:,:),pointer::ges_ql=>NULL() real(r_kind),dimension(:,:,:),pointer::ges_qi=>NULL() @@ -887,6 +890,10 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) ntracerio2d=ntracerio2d+1 else if(trim(vartem)=='z') then write(6,*)'the metvarname ',trim(vartem),' will be dealt separately' + else if(trim(vartem)=='t2m') then + !write(6,*)'the metvarname ',trim(vartem),' will be dealt separately' + else if(trim(vartem)=='q2m') then + !write(6,*)'the metvarname ',trim(vartem),' will be dealt separately' else write(6,*)'the metvarname2 ',trim(vartem),' has not been considered yet, stop' call stop2(333) @@ -901,7 +908,8 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) jtracer=0 do i=1,size(name_metvars2d) vartem=trim(name_metvars2d(i)) - if(.not.( (trim(vartem)=='ps'.and.fv3sar_bg_opt==0).or.(trim(vartem)=="z"))) then !z is treated separately + if(.not.( (trim(vartem)=='ps'.and.fv3sar_bg_opt==0).or.(trim(vartem)=="z") & + .or.(trim(vartem)=="t2m").or.(trim(vartem)=="q2m"))) then !z is treated separately if (ifindstrloc(vardynvars,trim(vartem)) > 0) then jdynvar=jdynvar+1 fv3lam_io_dynmetvars2d_nouv(jdynvar)=trim(vartem) @@ -1020,8 +1028,15 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qnr',ges_qnr ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'w' , ges_w ,istatus );ier=ier+istatus end if - if (ier/=0) call die(trim(myname),'cannot get pointers for fv3 met-fields, ier =',ier) + + if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then + call GSI_BundleGetPointer (GSI_MetGuess_Bundle(it),'q2m',ges_q2m,istatus ); ier=ier+istatus + if (ier/=0) call die(trim(myname),'cannot get pointers for q2m, ier=',ier) + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it),'t2m',ges_t2m, istatus );ier=ier+istatus + if (ier/=0) call die(trim(myname),'cannot get pointers for t2m,ier=',ier) + endif + if( fv3sar_bg_opt == 0) then call gsi_fv3ncdf_readuv(grd_fv3lam_uv,ges_u,ges_v,fv3filenamegin) else @@ -1074,7 +1089,13 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) endif - call gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) + call gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z,ges_t2m,ges_q2m) + + if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then +! do not need to convert t2m to potentional T in ges_t2m +! Convert 2m guess mixing ratio to specific humidity + ges_q2m = ges_q2m/(one+ges_q2m) + endif if (l_use_dbz_directDA ) then if( fv3sar_bg_opt == 0) then @@ -1092,7 +1113,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) end subroutine read_fv3_netcdf_guess -subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) +subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z,ges_t2m,ges_q2m) !$$$ subprogram documentation block ! . . . . ! subprogram: gsi_fv3ncdf2d_read @@ -1128,6 +1149,8 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) integer(i_kind),intent(in) :: it real(r_kind),intent(in),dimension(:,:),pointer::ges_z + real(r_kind),intent(in),dimension(:,:),pointer::ges_t2m + real(r_kind),intent(in),dimension(:,:),pointer::ges_q2m type (type_fv3regfilenameg),intent(in) :: fv3filenamegin character(len=max_varname_length) :: name integer(i_kind),allocatable,dimension(:):: dim_id,dim @@ -1206,6 +1229,10 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) k=k_smc else if( trim(name)=='SLMSK'.or.trim(name)=='slmsk' ) then k=k_slmsk + else if( trim(name)=='T2M'.or.trim(name)=='t2m' ) then + k=k_t2m + else if( trim(name)=='Q2M'.or.trim(name)=='q2m' ) then + k=k_q2m else cycle endif @@ -1214,41 +1241,27 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) write(*,*) "wrong dimension number ndim =",ndim call stop2(119) endif - if(allocated(dim_id )) deallocate(dim_id ) - allocate(dim_id(ndim)) if(fv3_io_layout_y > 1) then do nio=0,fv3_io_layout_y-1 - iret=nf90_inquire_variable(gfile_loc_layout(nio),i,dimids=dim_id) if(allocated(sfc )) deallocate(sfc ) - if(dim(dim_id(1)) == nx .and. dim(dim_id(2))==ny_layout_len(nio)) then if(ndim >=3) then - allocate(sfc(dim(dim_id(1)),dim(dim_id(2)),dim(dim_id(3)))) + allocate(sfc(nx,ny_layout_len(nio),1)) iret=nf90_get_var(gfile_loc_layout(nio),i,sfc) else if (ndim == 2) then - allocate(sfc(dim(dim_id(1)),dim(dim_id(2)),1)) + allocate(sfc(nx,ny_layout_len(nio),1)) iret=nf90_get_var(gfile_loc_layout(nio),i,sfc(:,:,1)) endif - else - write(*,*) "Mismatch dimension in surfacei reading:",nx,ny_layout_len(nio),dim(dim_id(1)),dim(dim_id(2)) - call stop2(119) - endif sfc_fulldomain(:,ny_layout_b(nio):ny_layout_e(nio))=sfc(:,:,1) enddo else - iret=nf90_inquire_variable(gfile_loc,i,dimids=dim_id) if(allocated(sfc )) deallocate(sfc ) - if(dim(dim_id(1)) == nx .and. dim(dim_id(2))==ny) then if(ndim >=3) then !the block of 10 lines is compied from GSL gsi. - allocate(sfc(dim(dim_id(1)),dim(dim_id(2)),dim(dim_id(3)))) + allocate(sfc(nx,ny,1)) iret=nf90_get_var(gfile_loc,i,sfc) else if (ndim == 2) then - allocate(sfc(dim(dim_id(1)),dim(dim_id(2)),1)) + allocate(sfc(nx,ny,1)) iret=nf90_get_var(gfile_loc,i,sfc(:,:,1)) endif - else - write(*,*) "Mismatch dimension in surfacei reading:",nx,ny,dim(dim_id(1)),dim(dim_id(2)) - call stop2(119) - endif sfc_fulldomain(:,:)=sfc(:,:,1) endif call fv3_h_to_ll(sfc_fulldomain,a,nx,ny,nxa,nya,grid_reverse_flag) @@ -1308,19 +1321,15 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) iret=nf90_inquire_variable(gfile_loc,k,name,len) if(trim(name)=='PHIS' .or. trim(name)=='phis' ) then iret=nf90_inquire_variable(gfile_loc,k,ndims=ndim) - if(allocated(dim_id )) deallocate(dim_id ) - allocate(dim_id(ndim)) if(fv3_io_layout_y > 1) then do nio=0,fv3_io_layout_y-1 - iret=nf90_inquire_variable(gfile_loc_layout(nio),k,dimids=dim_id) if(allocated(sfc1 )) deallocate(sfc1 ) - allocate(sfc1(dim(dim_id(1)),dim(dim_id(2))) ) + allocate(sfc1(nx,ny_layout_len(nio)) ) iret=nf90_get_var(gfile_loc_layout(nio),k,sfc1) sfc_fulldomain(:,ny_layout_b(nio):ny_layout_e(nio))=sfc1 enddo else - iret=nf90_inquire_variable(gfile_loc,k,dimids=dim_id) - allocate(sfc1(dim(dim_id(1)),dim(dim_id(2))) ) + allocate(sfc1(nx,ny) ) iret=nf90_get_var(gfile_loc,k,sfc1) sfc_fulldomain=sfc1 endif @@ -1351,7 +1360,7 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) end do end do - deallocate (dim_id,sfc,sfc1,dim) + deallocate (sfc,sfc1,dim) deallocate (sfc_fulldomain) endif ! mype @@ -1373,6 +1382,10 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z) soil_moi(:,:,it)=sfcn2d(:,:,k_smc) ges_z(:,:)=sfcn2d(:,:,k_orog)/grav isli(:,:,it)=nint(sfcn2d(:,:,k_slmsk)) + if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then + ges_t2m(:,:)=sfcn2d(:,:,k_t2m) + ges_q2m(:,:)=sfcn2d(:,:,k_q2m) + endif deallocate (sfcn2d,a) return end subroutine gsi_fv3ncdf2d_read @@ -2046,6 +2059,8 @@ subroutine wrfv3_netcdf(fv3filenamegin) use directDA_radaruse_mod, only: l_use_dbz_directDA use directDA_radaruse_mod, only: l_cvpnr, cvpnr_pval use gridmod, only: eta1_ll,eta2_ll + use constants, only: one,rd_over_cp_mass,r10,r1000 + use mpimod, only: mype implicit none @@ -2059,6 +2074,8 @@ subroutine wrfv3_netcdf(fv3filenamegin) real(r_kind),pointer,dimension(:,:,:):: ges_u =>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_v =>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_q =>NULL() + real(r_kind),pointer,dimension(:,: ):: ges_t2m =>NULL() + real(r_kind),pointer,dimension(:,: ):: ges_q2m =>NULL() integer(i_kind) i,k @@ -2094,6 +2111,11 @@ subroutine wrfv3_netcdf(fv3filenamegin) call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qnr',ges_qnr,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'w' , ges_w ,istatus);ier=ier+istatus end if + if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then + call GSI_BundleGetPointer (GSI_MetGuess_Bundle(it),'q2m',ges_q2m,istatus); ier=ier+istatus + call GSI_BundleGetPointer (GSI_MetGuess_Bundle(it),'t2m',ges_t2m,istatus );ier=ier+istatus + endif + if(l_reg_update_hydro_delz) then allocate(ges_delzinc(lat2,lon2,nsig)) do k=1,nsig @@ -2150,8 +2172,13 @@ subroutine wrfv3_netcdf(fv3filenamegin) ! write out if (ier/=0) call die('get ges','cannot get pointers for fv3 met-fields, ier =',ier) - add_saved=.true. + if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then +! do not need to convert t2m from potentional T to T in ges_t2m +! Convert 2m guess specific humidity to mixing ratio + ges_q2m = ges_q2m/(one-ges_q2m) + endif + add_saved=.true. ! write out if(fv3sar_bg_opt == 0) then call gsi_fv3ncdf_write(grd_fv3lam_dynvar_ionouv,gsibundle_fv3lam_dynvar_nouv,& @@ -2168,6 +2195,12 @@ subroutine wrfv3_netcdf(fv3filenamegin) add_saved,fv3filenamegin%tracers,fv3filenamegin) call gsi_fv3ncdf_writeuv_v1(grd_fv3lam_uv,ges_u,ges_v,add_saved,fv3filenamegin) endif + + if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then + call gsi_fv3ncdf_write_sfc(fv3filenamegin,'t2m',ges_t2m,add_saved) + call gsi_fv3ncdf_write_sfc(fv3filenamegin,'q2m',ges_q2m,add_saved) + endif + if(allocated(g_prsi)) deallocate(g_prsi) deallocate(ny_layout_len) @@ -2594,6 +2627,136 @@ subroutine gsi_fv3ncdf_writeuv_v1(grd_uv,ges_u,ges_v,add_saved,fv3filenamegin) end subroutine gsi_fv3ncdf_writeuv_v1 +subroutine gsi_fv3ncdf_write_sfc(fv3filenamegin,varname,var,add_saved) +!$$$ subprogram documentation block +! . . . . +! subprogram: gsi_fv3ncdf_write_sfc +! pgrmmr: wu +! +! abstract: +! +! program history log: +! 2022-02-25 Hu write surface fields +! input argument list: +! +! output argument list: +! +! attributes: +! language: f90 +! machine: +! +!$$$ end documentation block + + use mpimod, only: ierror,mpi_comm_world,npe,mpi_rtype,mype + use gridmod, only: lat1,lon1,lat2,lon2,nlat,nlon + use gridmod, only: ijn,displs_g,itotsub,iglobal + use gridmod, only: nlon_regional,nlat_regional + use mod_fv3_lola, only: fv3_ll_to_h,fv3_h_to_ll + use general_commvars_mod, only: ltosi,ltosj + use netcdf, only: nf90_open,nf90_close + use netcdf, only: nf90_write,nf90_inq_varid + use netcdf, only: nf90_put_var,nf90_get_var + use gridmod, only: strip + implicit none + + real(r_kind) ,intent(in ) :: var(lat2,lon2) + logical ,intent(in ) :: add_saved + character(*) ,intent(in ) :: varname + type (type_fv3regfilenameg),intent (in) :: fv3filenamegin + + integer(i_kind) :: VarId,gfile_loc + integer(i_kind) i,j,mm1 + real(r_kind),allocatable,dimension(:):: work + real(r_kind),allocatable,dimension(:,:):: work_sub,work_a + real(r_kind),allocatable,dimension(:,:):: work_b + real(r_kind),allocatable,dimension(:,:):: workb2,worka2 + character(len=80) :: filename + +! for io_layout > 1 + real(r_kind),allocatable,dimension(:,:):: work_b_layout + integer(i_kind) :: nio + integer(i_kind),allocatable :: gfile_loc_layout(:) + character(len=180) :: filename_layout + + filename=trim(fv3filenamegin%sfcdata) + + mm1=mype+1 + allocate(work(max(iglobal,itotsub)),work_sub(lat1,lon1)) + call strip(var,work_sub) + call mpi_gatherv(work_sub,ijn(mm1),mpi_rtype, & + work,ijn,displs_g,mpi_rtype,0,mpi_comm_world,ierror) + deallocate(work_sub) + + if(mype==0) then + allocate( work_a(nlat,nlon)) + do i=1,iglobal + work_a(ltosi(i),ltosj(i))=work(i) + end do + allocate( work_b(nlon_regional,nlat_regional)) + + + if(fv3_io_layout_y > 1) then + allocate(gfile_loc_layout(0:fv3_io_layout_y-1)) + do nio=0,fv3_io_layout_y-1 + write(filename_layout,'(a,a,I4.4)') trim(filename),'.',nio + call check(nf90_open(trim(filename_layout),nf90_write,gfile_loc_layout(nio)) ) + enddo + gfile_loc=gfile_loc_layout(0) + else + call check( nf90_open(trim(filename),nf90_write,gfile_loc) ) + endif + call check( nf90_inq_varid(gfile_loc,trim(varname),VarId) ) + + if(add_saved)then + allocate( workb2(nlon_regional,nlat_regional)) + allocate( worka2(nlat,nlon)) +!!!!!!!! read in guess !!!!!!!!!!!!!! + + if(fv3_io_layout_y > 1) then + do nio=0,fv3_io_layout_y-1 + allocate(work_b_layout(nlon_regional,ny_layout_len(nio))) + call check(nf90_get_var(gfile_loc_layout(nio),VarId,work_b_layout) ) + work_b(:,ny_layout_b(nio):ny_layout_e(nio))=work_b_layout + deallocate(work_b_layout) + enddo + else + call check( nf90_get_var(gfile_loc,VarId,work_b) ) + endif + call fv3_h_to_ll(work_b,worka2,nlon_regional,nlat_regional,nlon,nlat,grid_reverse_flag) +!!!!!!! analysis_inc work_a + work_a(:,:)=work_a(:,:)-worka2(:,:) + call fv3_ll_to_h(work_a,workb2,nlon,nlat,nlon_regional,nlat_regional,grid_reverse_flag) + work_b(:,:)=work_b(:,:)+workb2(:,:) + deallocate(worka2,workb2) + else + call fv3_ll_to_h(work_a,work_b,nlon,nlat,nlon_regional,nlat_regional,grid_reverse_flag) + endif + + if(fv3_io_layout_y > 1) then + do nio=0,fv3_io_layout_y-1 + allocate(work_b_layout(nlon_regional,ny_layout_len(nio))) + work_b_layout=work_b(:,ny_layout_b(nio):ny_layout_e(nio)) + call check( nf90_put_var(gfile_loc_layout(nio),VarId,work_b_layout) ) + deallocate(work_b_layout) + enddo + else + call check( nf90_put_var(gfile_loc,VarId,work_b) ) + endif + + if(fv3_io_layout_y > 1) then + do nio=0,fv3_io_layout_y-1 + call check(nf90_close(gfile_loc_layout(nio))) + enddo + deallocate(gfile_loc_layout) + else + call check(nf90_close(gfile_loc)) + endif + deallocate(work_b,work_a) + end if !mype_io + + deallocate(work) + +end subroutine gsi_fv3ncdf_write_sfc subroutine gsi_fv3ncdf_write(grd_ionouv,cstate_nouv,add_saved,filenamein,fv3filenamegin) !$$$ subprogram documentation block @@ -3487,5 +3650,4 @@ function ifindstrloc(str_array,strin) enddo end function ifindstrloc - end module gsi_rfv3io_mod diff --git a/src/gsi/setupt.f90 b/src/gsi/setupt.f90 index e7e73d82c3..d1cdb43978 100644 --- a/src/gsi/setupt.f90 +++ b/src/gsi/setupt.f90 @@ -334,7 +334,7 @@ subroutine setupt(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,conv_diagsav real(r_kind),allocatable,dimension(:,:,:,:) :: ges_tv real(r_kind),allocatable,dimension(:,:,:,:) :: ges_q real(r_kind),allocatable,dimension(:,:,: ) :: ges_q2 - real(r_kind),allocatable,dimension(:,:,: ) :: ges_th2 + real(r_kind),allocatable,dimension(:,:,: ) :: ges_t2m logical:: l_pbl_pseudo_itype integer(i_kind):: ich0 @@ -742,10 +742,8 @@ subroutine setupt(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,conv_diagsav if(i_coastline==1 .or. i_coastline==3) then ! Interpolate guess th 2m to observation location and time - call tintrp2a11_csln(ges_th2,tges2m,tges2m_water,dlat,dlon,dtime,hrdifsig,& + call tintrp2a11_csln(ges_t2m,tges2m,tges2m_water,dlat,dlon,dtime,hrdifsig,& mype,nfldsig) - tges2m=tges2m*(r10*psges/r1000)**rd_over_cp_mass ! convert to sensible T - tges2m_water=tges2m_water*(r10*psges/r1000)**rd_over_cp_mass ! convert to sensible T if(iqtflg)then call tintrp2a11_csln(ges_q2,qges2m,qges2m_water,dlat,dlon,dtime,hrdifsig,& mype,nfldsig) @@ -755,9 +753,8 @@ subroutine setupt(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,conv_diagsav if( abs(tob-tges2m) > abs(tob-tges2m_water)) tges2m=tges2m_water else ! Interpolate guess th 2m to observation location and time - call tintrp2a11(ges_th2,tges2m,dlat,dlon,dtime,hrdifsig,& + call tintrp2a11(ges_t2m,tges2m,dlat,dlon,dtime,hrdifsig,& mype,nfldsig) - tges2m=tges2m*(r10*psges/r1000)**rd_over_cp_mass ! convert to sensible T if(iqtflg)then call tintrp2a11(ges_q2,qges2m,dlat,dlon,dtime,hrdifsig,& mype,nfldsig) @@ -1413,19 +1410,19 @@ subroutine init_vars_ call stop2(999) endif if(i_use_2mt4b>0) then -! get th2m ... - varname='th2m' +! get t2m ... + varname='t2m' call gsi_bundlegetpointer(gsi_metguess_bundle(1),trim(varname),rank2,istatus) if (istatus==0) then - if(allocated(ges_th2))then + if(allocated(ges_t2m))then write(6,*) trim(myname), ': ', trim(varname), ' already incorrectly alloc ' call stop2(999) endif - allocate(ges_th2(size(rank2,1),size(rank2,2),nfldsig)) - ges_th2(:,:,1)=rank2 + allocate(ges_t2m(size(rank2,1),size(rank2,2),nfldsig)) + ges_t2m(:,:,1)=rank2 do ifld=2,nfldsig call gsi_bundlegetpointer(gsi_metguess_bundle(ifld),trim(varname),rank2,istatus) - ges_th2(:,:,ifld)=rank2 + ges_t2m(:,:,ifld)=rank2 enddo else write(6,*) trim(myname),': ', trim(varname), ' not found in met bundle, ier= ',istatus @@ -1835,7 +1832,7 @@ subroutine final_vars_ if(allocated(ges_u )) deallocate(ges_u ) if(allocated(ges_ps)) deallocate(ges_ps) if(allocated(ges_q2)) deallocate(ges_q2) - if(allocated(ges_th2)) deallocate(ges_th2) + if(allocated(ges_t2m)) deallocate(ges_t2m) end subroutine final_vars_ end subroutine setupt diff --git a/src/gsi/unfill_mass_grid2.f90 b/src/gsi/unfill_mass_grid2.f90 index 0bd02ad289..f2ee99baa2 100644 --- a/src/gsi/unfill_mass_grid2.f90 +++ b/src/gsi/unfill_mass_grid2.f90 @@ -307,3 +307,76 @@ subroutine unfill_mass_grid2t_ldmk(gout,nx,ny,gin,landmask, & end subroutine unfill_mass_grid2t_ldmk +subroutine unfill_mass_grid2t_drycheck(gout,nx,ny,gin,qs) +!$$$ subprogram documentation block +! . . . . +! subprogram: unfill_mass_grid2t opposite of fill_mass_grid2 +! prgmmr: parrish org: np22 date: 2004-06-22 +! +! abstract: This is almost the reverse of subroutine fill_mass_grid2t. +! The input field is an analyis increment on an unstaggered +! A grid. The result is added to the preexisting contents of gout. +! +! program history log: +! 2004-07-16 parrish +! 2013-10-25 todling - reposition ltosi and others to commvars +! 2019-10-30 Hu Code for check q2 +! +! input argument list: +! gout - input A-grid (reorganized for distibution to local domains) +! gin - preexisting input values to be added to on C-grid +! nx,ny - input grid dimensions +! +! output argument list: +! gin - output result on C grid +! +! attributes: +! language: f90 +! machine: ibm RS/6000 SP +! +!$$$ + use kinds, only: r_single,i_kind + use gridmod, only: itotsub,iglobal + use general_commvars_mod, only: ltosi,ltosj + use mod_wrfmass_to_a, only: wrfmass_a_to_h4 + use gridmod, only: nlon, nlat + + implicit none + + integer(i_kind), intent(in ) :: nx,ny + real(r_single) , intent(in ) :: gout(itotsub) + real(r_single) , intent(inout) :: gin(nx,ny) + real(r_single) , intent(in ) :: qs(nx,ny) + + real(r_single) ba(nlon,nlat) + real(r_single) b(nx,ny) + integer(i_kind) i,j + real(r_single) :: rh + + do i=1,iglobal + ba(ltosj(i),ltosi(i))=gout(i) + end do + + if(nlon == nx .and. nlat == ny) then + b=ba + else + call wrfmass_a_to_h4(ba,b) + endif + +! Mass grids--just copy + do j=1,ny + do i=1,nx + rh=gin(i,j)/max(1.0e-4_r_single,qs(i,j))*100.0_r_single + if(rh < 4.0_r_single .and. b(i,j) < 0.0_r_single) then +! write(*,'(a,2I4,f6.2,3f8.4)') 'dry air becomes dryer=',i,j,rh,qs(i,j)*1000.0,b(i,j)*1000.0,gin(i,j)*1000.0 + else + gin(i,j)=b(i,j)+gin(i,j) + if( gin(i,j) < 1.0e-12_r_single) then + gin(i,j) = qs(i,j)*0.01_r_single +! write(*,'(a,2I4,3f8.4)') 'reset negative analysis moisture to 1%=',i,j,qs(i,j)*1000.0,gin(i,j)*1000.0 + endif + endif + end do + end do + +end subroutine unfill_mass_grid2t_drycheck diff --git a/src/gsi/update_guess.f90 b/src/gsi/update_guess.f90 index a66495bc27..a90e7a19d6 100644 --- a/src/gsi/update_guess.f90 +++ b/src/gsi/update_guess.f90 @@ -136,7 +136,7 @@ subroutine update_guess(sval,sbias) use rapidrefresh_cldsurf_mod, only: l_gsd_limit_ocean_q,l_gsd_soilTQ_nudge use rapidrefresh_cldsurf_mod, only: i_use_2mq4b,i_use_2mt4b use gsd_update_mod, only: gsd_limit_ocean_q,gsd_update_soil_tq,& - gsd_update_th2,gsd_update_q2 + gsd_update_t2m,gsd_update_q2 use qcmod, only: pvis,pcldch,vis_thres,cldch_thres use obsmod, only: l_wcp_cwm use directDA_radaruse_mod, only: l_use_cvpqx, l_use_dbz_directDA @@ -460,8 +460,8 @@ subroutine update_guess(sval,sbias) tinc_1st(i,j)=p_tv(i,j,1) end do end do - call gsd_update_th2(tinc_1st,it) - endif ! l_gsd_th2_adjust + call gsd_update_t2m(tinc_1st,it) + endif ! l_gsd_t2m_adjust if (i_use_2mq4b > 0 .and. is_q>0) then do j=1,lon2 do i=1,lat2 From 23fa07d106920bf057a25fc850774717937d1602 Mon Sep 17 00:00:00 2001 From: hu5970 Date: Fri, 15 Apr 2022 13:42:02 -0500 Subject: [PATCH 53/58] Bug fix to fv3lam IO when reads 2D fields on Orion/Wcoss. --- src/gsi/gsi_rfv3io_mod.f90 | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/gsi/gsi_rfv3io_mod.f90 b/src/gsi/gsi_rfv3io_mod.f90 index 1876027cef..16522bbd19 100644 --- a/src/gsi/gsi_rfv3io_mod.f90 +++ b/src/gsi/gsi_rfv3io_mod.f90 @@ -1243,25 +1243,23 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z,ges_t2m,ges_q2m) endif if(fv3_io_layout_y > 1) then do nio=0,fv3_io_layout_y-1 - if(allocated(sfc )) deallocate(sfc ) - if(ndim >=3) then - allocate(sfc(nx,ny_layout_len(nio),1)) - iret=nf90_get_var(gfile_loc_layout(nio),i,sfc) - else if (ndim == 2) then - allocate(sfc(nx,ny_layout_len(nio),1)) - iret=nf90_get_var(gfile_loc_layout(nio),i,sfc(:,:,1)) - endif - sfc_fulldomain(:,ny_layout_b(nio):ny_layout_e(nio))=sfc(:,:,1) + if(allocated(sfc )) deallocate(sfc ) + allocate(sfc(nx,ny_layout_len(nio),1)) + if(ndim >=3) then + iret=nf90_get_var(gfile_loc_layout(nio),i,sfc) + else if (ndim == 2) then + iret=nf90_get_var(gfile_loc_layout(nio),i,sfc(:,:,1)) + endif + sfc_fulldomain(:,ny_layout_b(nio):ny_layout_e(nio))=sfc(:,:,1) enddo else if(allocated(sfc )) deallocate(sfc ) - if(ndim >=3) then !the block of 10 lines is compied from GSL gsi. - allocate(sfc(nx,ny,1)) - iret=nf90_get_var(gfile_loc,i,sfc) - else if (ndim == 2) then - allocate(sfc(nx,ny,1)) - iret=nf90_get_var(gfile_loc,i,sfc(:,:,1)) - endif + allocate(sfc(nx,ny,1)) + if(ndim >=3) then !the block of 10 lines is compied from GSL gsi. + iret=nf90_get_var(gfile_loc,i,sfc) + else if (ndim == 2) then + iret=nf90_get_var(gfile_loc,i,sfc(:,:,1)) + endif sfc_fulldomain(:,:)=sfc(:,:,1) endif call fv3_h_to_ll(sfc_fulldomain,a,nx,ny,nxa,nya,grid_reverse_flag) @@ -1329,6 +1327,7 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z,ges_t2m,ges_q2m) sfc_fulldomain(:,ny_layout_b(nio):ny_layout_e(nio))=sfc1 enddo else + if(allocated(sfc1 )) deallocate(sfc1 ) allocate(sfc1(nx,ny) ) iret=nf90_get_var(gfile_loc,k,sfc1) sfc_fulldomain=sfc1 @@ -1360,8 +1359,10 @@ subroutine gsi_fv3ncdf2d_read(fv3filenamegin,it,ges_z,ges_t2m,ges_q2m) end do end do - deallocate (sfc,sfc1,dim) - deallocate (sfc_fulldomain) + if(allocated(sfc)) deallocate (sfc) + if(allocated(sfc1)) deallocate (sfc1) + if(allocated(dim)) deallocate (dim) + if(allocated(sfc_fulldomain)) deallocate (sfc_fulldomain) endif ! mype From b7cc318e30d610a809e072e9ca15303406c6ecd0 Mon Sep 17 00:00:00 2001 From: "Ming.Hu" Date: Mon, 25 Apr 2022 17:42:27 +0000 Subject: [PATCH 54/58] Merged code from EMC GSI PR 364: onvert the global 127-L BE vertical length scale unit for regional DA --- src/gsi/balmod.f90 | 16 +++++++++++++--- src/gsi/m_berror_stats_reg.f90 | 30 +++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/gsi/balmod.f90 b/src/gsi/balmod.f90 index 22297ac4a2..4989dc80e2 100644 --- a/src/gsi/balmod.f90 +++ b/src/gsi/balmod.f90 @@ -907,6 +907,8 @@ subroutine locatelat_reg(mype) ! 2005-03-28 wu - replace mlath with mlat ! 2005-04-22 treadon - change berror file to 4-byte reals ! 2005-06-06 wu - setup f1 for balance projection (st->t) when fstat=.true. +! 2022-04-20 x.zhang - add switch (usenewgfsberror)for no need to convert +! the unit of clat for using global 127-L BE in regional DA ! ! input argument list: ! mype - mpi task id @@ -924,6 +926,7 @@ subroutine locatelat_reg(mype) use gridmod, only: nlon,nlat,lat2,lon2,istart,jstart,region_lat use m_berror_stats, only: berror_stats use constants, only: deg2rad,one + use m_berror_stats, only: usenewgfsberror implicit none ! Declare passed variables @@ -946,9 +949,16 @@ subroutine locatelat_reg(mype) allocate( clat_avn(mlat), clat_avn4(mlat) ) read(lunin)clat_avn4 close(lunin) - do i=1,mlat - clat_avn(i)=clat_avn4(i)*deg2rad - end do + if (usenewgfsberror) then +! 'The unit of clat from global BE is radian, do not need to convert' + do i=1,mlat + clat_avn(i)=clat_avn4(i) + end do + else + do i=1,mlat + clat_avn(i)=clat_avn4(i)*deg2rad + end do + end if deallocate(clat_avn4) diff --git a/src/gsi/m_berror_stats_reg.f90 b/src/gsi/m_berror_stats_reg.f90 index 2d79213b3c..6fb95dbb50 100644 --- a/src/gsi/m_berror_stats_reg.f90 +++ b/src/gsi/m_berror_stats_reg.f90 @@ -40,6 +40,10 @@ module m_berror_stats_reg ! configurable m_berror_stats::berror_stats, for the ! filename. This ensure the consistency, as well as the ! reconfigurability of this variable through the GSI. +! 20Apr22 - x.zhang - add variable dlsig_glb for calculating the delta +! sigma from the global 127-L BE,which is used to +! convert the grid unit of vertical length scale (vz) from +! 1/layer to the unit of 1/sigma. !EOP ___________________________________________________________________ character(len=*),parameter :: myname='m_berror_stats_reg' @@ -55,6 +59,7 @@ module m_berror_stats_reg integer(i_kind),allocatable,dimension(:):: lsig real(r_kind),allocatable,dimension(:):: coef1,coef2 + real(r_kind),allocatable,dimension(:):: dlsig_glb contains !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -150,6 +155,8 @@ subroutine berror_read_bal_reg(msig,mlat,agvi,bvi,wgvi,mype,unit) ! 25Feb10 - Zhu - extracted from rdgstat_reg ! - change the structure of error file ! - make changes for generalized control variables +! 20Apr22 - x.zhang - add the code to calculate the delta sigma from the +! global 127-L BE !EOP ___________________________________________________________________ character(len=*),parameter :: myname_=myname//'::berror_read_bal_reg' @@ -208,6 +215,17 @@ subroutine berror_read_bal_reg(msig,mlat,agvi,bvi,wgvi,mype,unit) rlsigo(k)=log(sigma_avn(k)) enddo +! compute delta sigma of global level + if(usenewgfsberror)then + allocate(dlsig_glb(msig)) + dlsig_glb(1)=log(sigma_avn(1))-log(sigma_avn(2)) + do k=2,msig-1 + dlsig_glb(k)=half*(log(sigma_avn(k-1))-log(sigma_avn(k+1))) + enddo + dlsig_glb(msig)=log(sigma_avn(msig-1))-log(sigma_avn(msig)) + end if +! + allocate(lsig(nsig),coef1(nsig),coef2(nsig)) do k=1,nsig if(rlsig(k)>=rlsigo(1))then @@ -344,6 +362,8 @@ subroutine berror_read_wgt_reg(msig,mlat,corz,corp,hwll,hwllp,vz,rlsig,varq,qopt ! - which can be tuned in sub prewgt_reg.f90. ! - extra caution required for using logarithmic transformation ! 2018-10-22 CAPS(C.Liu) - add w +! 20Apr22 x.zhang - Add the code to convert the unit of global 127-L BE +! vertical length scale from 1/layer to 1/sigma ! !EOP ___________________________________________________________________ @@ -502,12 +522,16 @@ subroutine berror_read_wgt_reg(msig,mlat,corz,corp,hwll,hwllp,vz,rlsig,varq,qopt if(usenewgfsberror)then do i=1,mlat hwll_tmp(i,k,n)=hwll_avn(i,k) - vz_tmp(k,i,n)=vztdq_avn(i,k) + +! convert global BE vz from the unit of 1/layer to 1/sigma + vz_tmp(k,i,n)=vztdq_avn(i,k)/dlsig_glb(k) end do hwll_tmp(0,k,n)=hwll_avn(1,k) hwll_tmp(mlat+1,k,n)=hwll_avn(mlat,k) - vz_tmp(k,0,n)=vztdq_avn(1,k) - vz_tmp(k,mlat+1,n)=vztdq_avn(mlat,k) + +! convert global BE vz from the unit of 1/layer to 1/sigma + vz_tmp(k,0,n)=vztdq_avn(1,k)/dlsig_glb(k) + vz_tmp(k,mlat+1,n)=vztdq_avn(mlat,k)/dlsig_glb(k) else do i=0,mlat+1 hwll_tmp(i,k,n)=hwll_avn(i,k) From 5ad029c687460c2d89e4f0c206b443bceeaa93fd Mon Sep 17 00:00:00 2001 From: "Ming.Hu" Date: Wed, 27 Apr 2022 19:24:58 +0000 Subject: [PATCH 55/58] Merge Yongming's GSI code for dbz direct analysis and fv3lam ensemble parallel IO --- src/gsi/cplr_get_fv3_regional_ensperts.f90 | 534 +++++++++++++++++++- src/gsi/gsi_rfv3io_mod.f90 | 548 +++++++++++++++++++-- src/gsi/setupdbz.f90 | 9 + 3 files changed, 1040 insertions(+), 51 deletions(-) diff --git a/src/gsi/cplr_get_fv3_regional_ensperts.f90 b/src/gsi/cplr_get_fv3_regional_ensperts.f90 index 98feb46202..f5afabc974 100644 --- a/src/gsi/cplr_get_fv3_regional_ensperts.f90 +++ b/src/gsi/cplr_get_fv3_regional_ensperts.f90 @@ -8,12 +8,16 @@ module get_fv3_regional_ensperts_mod procedure, pass(this) :: get_fv3_regional_ensperts => get_fv3_regional_ensperts_run procedure, pass(this) :: ens_spread_dualres_regional => ens_spread_dualres_regional_fv3_regional procedure, pass(this) :: general_read_fv3_regional + procedure, pass(this) :: general_read_fv3_regional_parallelIO + procedure, pass(this) :: parallel_read_fv3_step2 + procedure, nopass :: fill_regional_2d end type get_fv3_regional_ensperts_class - type(sub2grid_info):: grd_fv3lam_ens_dynvar_io_nouv,grd_fv3lam_ens_tracer_io_nouv,grd_fv3lam_ens_uv + type(sub2grid_info):: grd_fv3lam_ens_dynvar_io_nouv,grd_fv3lam_ens_tracer_io_nouv,grd_fv3lam_ens_uv,grd_fv3lam_ens_phyvar_io_nouv character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_ens_io_dynmetvars3d_nouv ! copy of cvars3d excluding uv 3-d fields character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_ens_io_tracermetvars3d_nouv ! copy of cvars3d excluding uv 3-d fields + character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_ens_io_phymetvars3d_nouv character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_ens_io_dynmetvars2d_nouv character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_ens_io_tracermetvars2d_nouv contains @@ -34,6 +38,9 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) ! ! 2021-08-10 lei - modify for fv3-lam ensemble spread output ! 2021-11-01 lei - modify for fv3-lam parallel IO + ! 2022-04-01 Yongming Wang and X. Wang - add ensemble parallel IO capability for hybrid EnVar + ! for both radar and conventional DA + ! poc: xuguang.wang@ou.edu ! input argument list: ! ! output argument list: @@ -46,8 +53,8 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) use kinds, only: r_kind,i_kind,r_single use constants, only: zero,one,half,zero_single,rd_over_cp,one_tenth - use mpimod, only: mpi_comm_world,ierror,mype - use hybrid_ensemble_parameters, only: n_ens,grd_ens + use mpimod, only: mpi_comm_world,ierror,mype,npe + use hybrid_ensemble_parameters, only: n_ens,grd_ens,ens_fast_read use hybrid_ensemble_parameters, only: ntlevs_ens,ensemble_path use control_vectors, only: cvars2d,cvars3d,nc2d,nc3d use gsi_bundlemod, only: gsi_bundlecreate @@ -63,9 +70,11 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) use directDA_radaruse_mod, only: l_use_dbz_directDA use directDA_radaruse_mod, only: l_cvpnr use general_sub2grid_mod, only: sub2grid_info,general_sub2grid_create_info - use gridmod,only: regional use gsi_rfv3io_mod, only: fv3lam_io_dynmetvars3d_nouv,fv3lam_io_tracermetvars3d_nouv use gsi_rfv3io_mod, only: fv3lam_io_dynmetvars2d_nouv,fv3lam_io_tracermetvars2d_nouv + use gsi_rfv3io_mod, only: fv3lam_io_phymetvars3d_nouv + use obsmod, only: if_model_dbz + use gridmod, only: regional implicit none @@ -76,7 +85,11 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig):: u,v,tv,oz,rh real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2):: ps - real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig)::w,ql,qi,qr,qg,qs,qnr + real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig)::w,ql,qi,qr,qg,qs,qnr,dbz + real(r_kind),dimension(:,:,:),allocatable :: gg_u,gg_v,gg_tv,gg_rh + real(r_kind),dimension(:,:,:),allocatable :: gg_w,gg_dbz,gg_qr,gg_qs, & + gg_qi,gg_qg,gg_oz,gg_cwmr + real(r_kind),dimension(:,:),allocatable :: gg_ps real(r_single),pointer,dimension(:,:,:):: w3 =>NULL() real(r_single),pointer,dimension(:,:):: w2 =>NULL() @@ -93,9 +106,9 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) integer(i_kind):: i,j,k,n,mm1,istatus integer(i_kind):: ndynvario2d,ntracerio2d - integer(r_kind):: ndynvario3d,ntracerio3d + integer(r_kind):: ndynvario3d,ntracerio3d,nphyvario3d integer(i_kind):: inner_vars,numfields - integer(i_kind):: ilev,ic2,ic3 + integer(i_kind):: ilev,ic2,ic3,iope integer(i_kind):: m @@ -109,8 +122,10 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) !clt setup varnames for IO ndynvario2d=0 ntracerio2d=0 + nphyvario3d=0 ndynvario3d=size(fv3lam_io_dynmetvars3d_nouv) ntracerio3d=size(fv3lam_io_tracermetvars3d_nouv) + nphyvario3d=size(fv3lam_io_phymetvars3d_nouv) if (allocated(fv3lam_io_dynmetvars2d_nouv))then ndynvario2d=size(fv3lam_io_dynmetvars2d_nouv) endif @@ -118,9 +133,13 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) ntracerio2d=size(fv3lam_io_tracermetvars2d_nouv) endif allocate(fv3lam_ens_io_dynmetvars3d_nouv(ndynvario3d)) + if( nphyvario3d > 0 )& + allocate(fv3lam_ens_io_phymetvars3d_nouv(nphyvario3d)) allocate(fv3lam_ens_io_tracermetvars3d_nouv(ndynvario3d)) fv3lam_ens_io_dynmetvars3d_nouv=fv3lam_io_dynmetvars3d_nouv fv3lam_ens_io_tracermetvars3d_nouv=fv3lam_io_tracermetvars3d_nouv + if( nphyvario3d > 0 )& + fv3lam_ens_io_phymetvars3d_nouv=fv3lam_io_phymetvars3d_nouv if (ndynvario2d > 0 ) then allocate(fv3lam_ens_io_dynmetvars2d_nouv(ndynvario2d)) fv3lam_ens_io_dynmetvars2d_nouv=fv3lam_io_dynmetvars2d_nouv @@ -152,6 +171,24 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) call general_sub2grid_create_info(grd_fv3lam_ens_dynvar_io_nouv,inner_vars,grd_ens%nlat,& grd_ens%nlon,grd_ens%nsig,numfields,regional,names=names,lnames=lnames) + if( nphyvario3d > 0 )then + inner_vars=1 + numfields=inner_vars*(nphyvario3d*grd_ens%nsig) + deallocate(lnames,names) + allocate(lnames(1,numfields),names(1,numfields)) + ilev=1 + do i=1,nphyvario3d + do k=1,grd_ens%nsig + lnames(1,ilev)=k + names(1,ilev)=fv3lam_ens_io_phymetvars3d_nouv(i) + ilev=ilev+1 + enddo + enddo + + call general_sub2grid_create_info(grd_fv3lam_ens_phyvar_io_nouv,inner_vars,grd_ens%nlat,& + grd_ens%nlon,grd_ens%nsig,numfields,regional,names=names,lnames=lnames) + end if + inner_vars=1 numfields=inner_vars*(ntracerio3d*grd_ens%nsig+ntracerio2d) deallocate(lnames,names) @@ -237,27 +274,127 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) mm1=mype+1 kap1=rd_over_cp+one kapr=one/rd_over_cp + + if( ens_fast_read ) then + if(n_ens>npe) then + ens_fast_read=.false. +130 format('Disabling ens_fast_read because number of ensemble members (',I0,') is greater than number of MPI ranks (',I0,').') + if(mype==0) then + write(6,130) n_ens,npe + endif + endif + endif ! ens_fast_read + + if(ens_fast_read .and. mype==0) then + write(6,'(I0,A)') mype,': will read ensemble data in parallel (ens_fast_read=.true.)' + endif + + ! + ! LOOP OVER ENSEMBLE MEMBERS + if( ens_fast_read )then + do n=1,n_ens + write(ensfilenam_str,22) trim(adjustl(ensemble_path)),ens_fhrlevs(m),n +22 format(a,'fv3SAR',i2.2,'_ens_mem',i3.3) + iope=(n-1)*npe/n_ens + ! DEFINE INPUT FILE NAME + fv3_filename%grid_spec=trim(ensfilenam_str)//'-fv3_grid_spec' + fv3_filename%ak_bk=trim(ensfilenam_str)//'-fv3_akbk' + fv3_filename%dynvars=trim(ensfilenam_str)//'-fv3_dynvars' + fv3_filename%tracers=trim(ensfilenam_str)//"-fv3_tracer" + fv3_filename%phyvars=trim(ensfilenam_str)//'-fv3_phyvars' + fv3_filename%sfcdata=trim(ensfilenam_str)//"-fv3_sfcdata" + fv3_filename%couplerres=trim(ensfilenam_str)//"-coupler.res" + + + if( mype==iope) then + allocate(gg_u(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_v(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_tv(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_rh(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_oz(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_ps(grd_ens%nlat,grd_ens%nlon)) + if (.not. if_model_dbz ) then + call this%general_read_fv3_regional_parallelIO(iope,fv3_filename,gg_ps,gg_u,gg_v,gg_tv,gg_rh,gg_oz) + else + allocate(gg_w(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_dbz(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_qr(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_qs(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_qi(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_qg(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + allocate(gg_cwmr(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig)) + call this%general_read_fv3_regional_parallelIO(iope,fv3_filename,gg_ps,gg_u,gg_v,gg_tv,gg_rh,gg_oz, & + g_ql=gg_cwmr,g_qi=gg_qi,g_qr=gg_qr,g_qs=gg_qs,g_qg=gg_qg,g_w=gg_w,g_dbz=gg_dbz) + write(6,*)'Check-dBZ',maxval(gg_dbz),minval(gg_dbz) + end if + end if + end do + if(mype==0) then + write(6,'(I0,A)') mype,': reading ensemble data in parallel is done (ens_fast_read=.true.)' + endif + end if + call MPI_Barrier(mpi_comm_world,ierror) + ! ! LOOP OVER ENSEMBLE MEMBERS do n=1,n_ens write(ensfilenam_str,22) trim(adjustl(ensemble_path)),ens_fhrlevs(m),n -22 format(a,'fv3SAR',i2.2,'_ens_mem',i3.3) ! DEFINE INPUT FILE NAME fv3_filename%grid_spec=trim(ensfilenam_str)//'-fv3_grid_spec' !exmaple thinktobe fv3_filename%ak_bk=trim(ensfilenam_str)//'-fv3_akbk' fv3_filename%dynvars=trim(ensfilenam_str)//'-fv3_dynvars' fv3_filename%tracers=trim(ensfilenam_str)//"-fv3_tracer" + fv3_filename%phyvars=trim(ensfilenam_str)//'-fv3_phyvars' fv3_filename%sfcdata=trim(ensfilenam_str)//"-fv3_sfcdata" fv3_filename%couplerres=trim(ensfilenam_str)//"-coupler.res" + + ! ! READ ENEMBLE MEMBERS DATA if (mype == 0) write(6,'(a,a)') & 'CALL READ_FV3_REGIONAL_ENSPERTS FOR ENS DATA with the filename str : ',trim(ensfilenam_str) - if (.not.l_use_dbz_directDA ) then ! Read additional hydrometers and w for dirZDA - call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz) - else - call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, & - g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w) + if( .not. ens_fast_read )then + if (.not. (l_use_dbz_directDA .or. if_model_dbz) ) then ! Read additional hydrometers and w for dirZDA + call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz) + else + if( l_use_dbz_directDA ) then + call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, & + g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w) + else if( if_model_dbz )then + call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, & + g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_dbz=dbz) + end if + end if + end if + + if( ens_fast_read )then + iope=(n-1)*npe/n_ens + if(mype==iope) then + write(0,'(I0,A,I0,A)') mype,': scatter member ',n,' to other ranks...' + if( if_model_dbz )then + call this%parallel_read_fv3_step2(mype,iope,& + g_ps=ps,g_u=u,g_v=v,g_tv=tv,g_rh=rh,g_ql=ql,& + g_oz=oz,g_w=w,g_qr=qr,g_qs=qs,g_qi=qi,g_qg=qg,g_dbz=dbz,& + gg_ps=gg_ps,gg_tv=gg_tv,gg_u=gg_u,gg_v=gg_v,& + gg_rh=gg_rh,gg_w=gg_w,gg_dbz=gg_dbz,gg_qr=gg_qr,& + gg_qs=gg_qs,gg_qi=gg_qi,gg_qg=gg_qg,gg_ql=gg_cwmr) + else + call this%parallel_read_fv3_step2(mype,iope,& + g_ps=ps,g_u=u,g_v=v,g_tv=tv,g_rh=rh,g_ql=ql,g_oz=oz, & + gg_ps=gg_ps,gg_tv=gg_tv,gg_u=gg_u,gg_v=gg_v,gg_rh=gg_rh) + end if + else + if( if_model_dbz )then + call this%parallel_read_fv3_step2(mype,iope,& + g_ps=ps,g_u=u,g_v=v,g_tv=tv,g_rh=rh,g_ql=ql,& + g_oz=oz,g_w=w,g_qr=qr,g_qs=qs,g_qi=qi,g_qg=qg,g_dbz=dbz) + else + call this%parallel_read_fv3_step2(mype,iope,& + g_ps=ps,g_u=u,g_v=v,g_tv=tv,g_rh=rh,g_ql=ql,g_oz=oz) + endif + endif + + call MPI_Barrier(mpi_comm_world,ierror) end if ! SAVE ENSEMBLE MEMBER DATA IN COLUMN VECTOR @@ -415,6 +552,16 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) end do end do end do + + case('dbz','DBZ') + do k=1,grd_ens%nsig + do i=1,grd_ens%lon2 + do j=1,grd_ens%lat2 + w3(j,i,k) = dbz(j,i,k) + x3(j,i,k)=x3(j,i,k)+dbz(j,i,k) + end do + end do + end do end select @@ -522,9 +669,344 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar) call stop2(555) end subroutine get_fv3_regional_ensperts_run + + subroutine general_read_fv3_regional_parallelIO(this,iope,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g_rh,g_oz, & + g_ql,g_qi,g_qr,g_qs,g_qg,g_qnr,g_w,g_dbz) + !$$$ subprogram documentation block + ! first compied from general_read_arw_regional . . . . + ! subprogram: general_read_fv3_regional read fv3sar model ensemble members + ! prgmmr: Ting org: emc/ncep date: 2018 + ! + ! abstract: read ensemble members from the fv3sar model in "restart" or "cold start" netcdf format + ! for use with hybrid ensemble option. + ! + ! program history log: + ! 2018- Ting - intial versions + ! 2022-04-01 Yongming Wang and X. Wang - read all fields for each member for + ! parallel ensemble IO capability + ! poc: xuguang.wang@ou.edu + ! + ! input argument list: + ! + ! output argument list: + ! + ! attributes: + ! language: f90 + ! machine: ibm RS/6000 SP + ! + !$$$ end documentation block + use netcdf, only: nf90_nowrite + use netcdf, only: nf90_open,nf90_close + use netcdf, only: nf90_inq_dimid,nf90_inquire_dimension + use netcdf, only: nf90_inq_varid,nf90_inquire_variable,nf90_get_var + use kinds, only: r_kind,r_single,i_kind + use gridmod, only: eta1_ll,eta2_ll + use constants, only: zero,one,fv,zero_single,one_tenth,h300 + use hybrid_ensemble_parameters, only: grd_ens,q_hyb_ens + use hybrid_ensemble_parameters, only: fv3sar_ensemble_opt + + use mpimod, only: mpi_comm_world,mpi_rtype,mype + use netcdf_mod, only: nc_check + use gsi_rfv3io_mod,only: type_fv3regfilenameg + use gsi_rfv3io_mod,only:n2d + use constants, only: half,zero + use gsi_rfv3io_mod, only: gsi_fv3ncdf_read + use gsi_rfv3io_mod, only: gsi_fv3ncdf_read_v1 + use gsi_rfv3io_mod, only: gsi_fv3ncdf_readuv + use gsi_rfv3io_mod, only: gsi_fv3ncdf_readuv_v1 + use gsi_rfv3io_mod, only: gsi_fv3ncdf2d_read_v1 + use directDA_radaruse_mod, only: l_use_dbz_directDA + use gsi_bundlemod, only: gsi_gridcreate + use gsi_bundlemod, only: gsi_grid + use gsi_bundlemod, only: gsi_bundlecreate,gsi_bundledestroy + use gsi_bundlemod, only: gsi_bundlegetvar + use obsmod, only: if_model_dbz + use directDA_radaruse_mod, only: l_use_cvpqx, cvpqx_pval, cld_nt_updt + use directDA_radaruse_mod, only: l_cvpnr, cvpnr_pval + use gsi_rfv3io_mod, only: gsi_fv3ncdf_read_ens_parallelIO,gsi_fv3ncdf_readuv_ens_parallelIO + + + + implicit none +! +! Declare passed variables + class(get_fv3_regional_ensperts_class), intent(inout) :: this + integer(i_kind), intent (in) :: iope + type (type_fv3regfilenameg) , intent (in) :: fv3_filenameginput + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig),intent(out)::g_u,g_v,g_tv,g_rh,g_oz + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig),optional,intent(out)::g_ql,g_qi,g_qr,g_dbz + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig),optional,intent(out)::g_qs,g_qg,g_qnr,g_w + + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon),intent(out):: g_ps + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig+1) ::g_prsi + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig) ::g_prsl ,g_tsen,g_q,g_delp +! +! Declare local parameters + real(r_kind),parameter:: r0_01 = 0.01_r_kind + real(r_kind),parameter:: r10 = 10.0_r_kind + real(r_kind),parameter:: r100 = 100.0_r_kind + ! +! Declare local variables + + integer(i_kind):: i,j,k,kp + + integer(i_kind) iderivative + + + logical ice + + character(len=24),parameter :: myname_ = 'general_read_fv3_regional' + + character(len=:),allocatable :: grid_spec !='fv3_grid_spec' + character(len=:),allocatable :: ak_bk !='fv3_akbk' + character(len=:),allocatable :: dynvars !='fv3_dynvars' + character(len=:),allocatable :: phyvars !='fv3_phyvars' + character(len=:),allocatable :: tracers !='fv3_tracer' + character(len=:),allocatable :: sfcdata !='fv3_sfcdata' + character(len=:),allocatable :: couplerres!='coupler.res' + integer (i_kind) ier,istatus + + + associate( this => this ) ! eliminates warning for unused dummy argument needed for binding + end associate + + + if( mype == iope )then + grid_spec=fv3_filenameginput%grid_spec + ak_bk=fv3_filenameginput%ak_bk + dynvars=fv3_filenameginput%dynvars + phyvars=fv3_filenameginput%phyvars + tracers=fv3_filenameginput%tracers + sfcdata=fv3_filenameginput%sfcdata + couplerres=fv3_filenameginput%couplerres + + if(fv3sar_ensemble_opt == 0 ) then + call gsi_fv3ncdf_readuv_ens_parallelIO(g_u,g_v,fv3_filenameginput,iope) + else + write(6,*) "Warning: we can only grab fields from restart files not cold start files for ensemble!" + !call gsi_fv3ncdf_readuv_v1(grd_fv3lam_ens_uv,g_u,g_v,fv3_filenameginput) + endif + + if(fv3sar_ensemble_opt == 0) then + if (if_model_dbz) then + call gsi_fv3ncdf_read_ens_parallelIO(fv3_filenameginput%dynvars,fv3_filenameginput,delp=g_delp,tsen=g_tsen,w=g_w,iope=iope) + call gsi_fv3ncdf_read_ens_parallelIO(fv3_filenameginput%tracers,fv3_filenameginput,q=g_q,oz=g_oz,ql=g_ql,qr=g_qr,& + qs=g_qs,qi=g_qi,qg=g_qg,iope=iope) + call gsi_fv3ncdf_read_ens_parallelIO(fv3_filenameginput%phyvars,fv3_filenameginput,dbz=g_dbz,iope=iope) + else + call gsi_fv3ncdf_read_ens_parallelIO(fv3_filenameginput%dynvars,fv3_filenameginput,delp=g_delp,tsen=g_tsen,iope=iope) + call gsi_fv3ncdf_read_ens_parallelIO(fv3_filenameginput%tracers,fv3_filenameginput,q=g_q,oz=g_oz,iope=iope) + end if + else + write(6,*) "Warning: we can only grab fields from restart files not cold start files for ensemble!" + !call gsi_fv3ncdf_read_v1(grd_fv3lam_ens_dynvar_io_nouv,gsibundle_fv3lam_ens_dynvar_nouv,& + ! fv3_filenameginput%dynvars,fv3_filenameginput) + !call gsi_fv3ncdf_read_v1(grd_fv3lam_ens_tracer_io_nouv,gsibundle_fv3lam_ens_tracer_nouv,& + ! fv3_filenameginput%tracers,fv3_filenameginput) + endif + + + if (fv3sar_ensemble_opt == 0) then + g_prsi(:,:,grd_ens%nsig+1)=eta1_ll(grd_ens%nsig+1) !thinkto be done , should use eta1_ll from ensemble grid + do i=grd_ens%nsig,1,-1 + g_prsi(:,:,i)=g_delp(:,:,i)*0.001_r_kind+g_prsi(:,:,i+1) + enddo + g_ps(:,:)=g_prsi(:,:,1) + + endif + + !! tsen2tv !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + do k=1,grd_ens%nsig + do j=1,grd_ens%nlon + do i=1,grd_ens%nlat + g_tv(i,j,k)=g_tsen(i,j,k)*(one+fv*g_q(i,j,k)) + enddo + enddo + enddo + if (.not.q_hyb_ens) then + ice=.true. + iderivative=0 + do k=1,grd_ens%nsig + kp=k+1 + do j=1,grd_ens%nlon + do i=1,grd_ens%nlat + g_prsl(i,j,k)=(g_prsi(i,j,k)+g_prsi(i,j,kp))*half + end do + end do + end do + call genqsat(g_rh,g_tsen(1,1,1),g_prsl(1,1,1),grd_ens%nlat,grd_ens%nlon,grd_ens%nsig,ice,iderivative) + do k=1,grd_ens%nsig + do j=1,grd_ens%nlon + do i=1,grd_ens%nlat + g_rh(i,j,k) = g_q(i,j,k)/g_rh(i,j,k) + end do + end do + end do + else + do k=1,grd_ens%nsig + do j=1,grd_ens%nlon + do i=1,grd_ens%nlat + g_rh(i,j,k) = g_q(i,j,k) + end do + end do + end do + end if + end if ! mype + + return + end subroutine general_read_fv3_regional_parallelIO + + subroutine parallel_read_fv3_step2(this,mype,iope, & + g_ps,g_u,g_v,g_tv,g_rh,g_ql,g_oz,g_w,g_qr,g_qs,g_qi,& + g_qg,g_dbz, & + gg_ps,gg_tv,gg_u,gg_v,gg_rh,gg_w,gg_dbz,gg_qr,& + gg_qs,gg_qi,gg_qg,gg_ql) + + !$$$ subprogram documentation block + ! . + ! subprogram: parallel_read_fv3_step2 distribute all fields into all tasks + ! prgmmr: Yongming Wang and X. Wang org: OU/MAP date: 2022-04-01 + ! + ! abstract: All fields have been read in by general_read_fv3_regional_parallelIO. + ! Different tasks contain the data from different members. + ! This program will divided the full-domain fields into subdomains + ! and assign them to all tasks. poc: xuguang.wang@ou.edu + ! + ! program history log: + ! + ! 2022-04-01 Yongming Wang and X. Wang - Changed from the code for WRF-ARW + ! + ! input argument list: + ! + ! output argument list: + ! + ! attributes: + ! language: f90 + ! machine: ibm RS/6000 SP + ! + !$$$ end documentation block + + use hybrid_ensemble_parameters, only: grd_ens + use mpimod, only: mpi_comm_world,ierror,mpi_rtype + use kinds, only: r_kind,r_single,i_kind + use gridmod,only: itotsub + + implicit none + + ! + ! Declare passed variables + class(get_fv3_regional_ensperts_class), intent(inout) :: this + real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig),intent(out):: & + g_u,g_v,g_tv,g_rh,g_ql,g_oz + real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig),intent(out),optional::& + g_w,g_qr,g_qs,g_qi,g_qg,g_dbz + integer(i_kind), intent(in) :: mype, iope + real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2),intent(out):: g_ps + + ! The gg_ arrays are only sent by the rank doing I/O (mype==iope) + real(r_kind),optional,dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig) :: & + gg_u,gg_v,gg_tv,gg_rh + real(r_kind),optional,dimension(grd_ens%nlat,grd_ens%nlon,grd_ens%nsig) :: & + gg_w,gg_dbz,gg_qr,gg_qs,gg_qi,gg_qg,gg_ql + real(r_kind),optional,dimension(grd_ens%nlat,grd_ens%nlon):: gg_ps + + ! Declare local variables + real(r_kind),allocatable,dimension(:):: wrk_send_2d + integer(i_kind) :: k + + ! transfer data from root to subdomains on each task + ! scatterv used, since full grids exist only on root task. + allocate(wrk_send_2d(grd_ens%itotsub)) + ! first PS (output from fill_regional_2d is a column vector with a halo) + if(mype==iope) call this%fill_regional_2d(gg_ps,wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_ps,grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + ! then TV,U,V,RH + do k=1,grd_ens%nsig + if (mype==iope) then + call this%fill_regional_2d(gg_tv(:,:,k),wrk_send_2d) + endif + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_tv(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_u(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_u(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_v(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_v(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_rh(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_rh(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if( present(g_dbz) )then + if (mype==iope) call this%fill_regional_2d(gg_w(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_w(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_dbz(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype,& + g_dbz(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_qr(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype,& + g_qr(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_qs(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype,& + g_qs(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_qi(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype,& + g_qi(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_qg(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype, & + g_qg(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + if (mype==iope) call this%fill_regional_2d(gg_ql(1,1,k),wrk_send_2d) + call mpi_scatterv(wrk_send_2d,grd_ens%ijn_s,grd_ens%displs_s,mpi_rtype,& + g_ql(1,1,k),grd_ens%ijn_s(mype+1),mpi_rtype,iope,mpi_comm_world,ierror) + end if + enddo + ! for now, don't do anything with oz, cwmr + ! g_oz = 0. + ! if( .not. present(g_dbz) )g_ql = 0. + deallocate(wrk_send_2d) + end subroutine parallel_read_fv3_step2 + + subroutine fill_regional_2d(fld_in,fld_out) + !$$$ subprogram documentation block + ! . . . . + ! subprogram: fill_regional_2d + ! prgmmr: mizzi org: ncar/mmm date: 2010-08-11 + ! + ! abstract: create a column vector for the subdomain (including halo) + ! from global 2d grid. + ! + ! + ! program history log: + ! 2010-08-11 parrish, initial documentation + ! 2012-03-12 whitaker, remove nx,ny,itotsub from argument list. + ! + ! input argument list: + ! + ! output argument list: + ! + ! attributes: + ! language: f90 + ! machine: ibm RS/6000 SP + ! + !$$$ end documentation block + use kinds, only: r_kind,i_kind + use hybrid_ensemble_parameters, only: grd_ens + implicit none + real(r_kind),dimension(grd_ens%nlat,grd_ens%nlon)::fld_in + real(r_kind),dimension(grd_ens%itotsub)::fld_out + integer(i_kind):: i,j,k + do k=1,grd_ens%itotsub + i=grd_ens%ltosj_s(k) + j=grd_ens%ltosi_s(k) + fld_out(k)=fld_in(j,i) + enddo + return + end subroutine fill_regional_2d + subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g_rh,g_oz, & - g_ql,g_qi,g_qr,g_qs,g_qg,g_qnr,g_w) + g_ql,g_qi,g_qr,g_qs,g_qg,g_qnr,g_w,g_dbz) !$$$ subprogram documentation block ! first compied from general_read_arw_regional . . . . ! subprogram: general_read_fv3_regional read fv3sar model ensemble members @@ -535,6 +1017,8 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g ! ! program history log: ! 2018- Ting - intial versions + ! 2022-04-01 Yongming Wang and X. Wang - read in reflectivity for direct radar + ! reflectivity assimilation for hybrid EnVar, poc: xuguang.wang@ou.edu ! ! input argument list: ! @@ -567,7 +1051,6 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g use gsi_rfv3io_mod, only: gsi_fv3ncdf_readuv_v1 use gsi_rfv3io_mod, only: gsi_fv3ncdf2d_read_v1 use directDA_radaruse_mod, only: l_use_dbz_directDA - use gsi_bundlemod, only: gsi_bundle use gsi_bundlemod, only: gsi_gridcreate use gsi_bundlemod, only: gsi_grid use gsi_bundlemod, only: gsi_bundlecreate,gsi_bundledestroy @@ -575,6 +1058,7 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g use hybrid_ensemble_parameters, only: grd_ens use directDA_radaruse_mod, only: l_use_cvpqx, cvpqx_pval, cld_nt_updt use directDA_radaruse_mod, only: l_cvpnr, cvpnr_pval + use obsmod, only:if_model_dbz @@ -584,7 +1068,7 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g class(get_fv3_regional_ensperts_class), intent(inout) :: this type (type_fv3regfilenameg) , intent (in) :: fv3_filenameginput real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig),intent(out)::g_u,g_v,g_tv,g_rh,g_oz - real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig),optional,intent(out)::g_ql,g_qi,g_qr + real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig),optional,intent(out)::g_ql,g_qi,g_qr,g_dbz real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2,grd_ens%nsig),optional,intent(out)::g_qs,g_qg,g_qnr,g_w real(r_kind),dimension(grd_ens%lat2,grd_ens%lon2),intent(out):: g_ps @@ -607,12 +1091,14 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g character(len=24),parameter :: myname_ = 'general_read_fv3_regional' type(gsi_bundle) :: gsibundle_fv3lam_ens_dynvar_nouv + type(gsi_bundle) :: gsibundle_fv3lam_ens_phyvar_nouv type(gsi_bundle) :: gsibundle_fv3lam_ens_tracer_nouv type(gsi_grid):: grid_ens character(len=:),allocatable :: grid_spec !='fv3_grid_spec' character(len=:),allocatable :: ak_bk !='fv3_akbk' character(len=:),allocatable :: dynvars !='fv3_dynvars' + character(len=:),allocatable :: phyvars !='fv3_phyvars' character(len=:),allocatable :: tracers !='fv3_tracer' character(len=:),allocatable :: sfcdata !='fv3_sfcdata' character(len=:),allocatable :: couplerres!='coupler.res' @@ -628,6 +1114,7 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g grid_spec=fv3_filenameginput%grid_spec ak_bk=fv3_filenameginput%ak_bk dynvars=fv3_filenameginput%dynvars + phyvars=fv3_filenameginput%phyvars tracers=fv3_filenameginput%tracers sfcdata=fv3_filenameginput%sfcdata couplerres=fv3_filenameginput%couplerres @@ -652,10 +1139,12 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g names3d=fv3lam_ens_io_tracermetvars3d_nouv) endif - + if(allocated(fv3lam_ens_io_phymetvars3d_nouv))then + call gsi_bundlecreate(gsibundle_fv3lam_ens_phyvar_nouv,grid_ens,'gsibundle_fv3lam_ens_phyvar_nouv',istatus, & + names3d=fv3lam_ens_io_phymetvars3d_nouv) + end if - if(fv3sar_ensemble_opt == 0 ) then call gsi_fv3ncdf_readuv(grd_fv3lam_ens_uv,g_u,g_v,fv3_filenameginput) else @@ -666,6 +1155,9 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g fv3_filenameginput%dynvars,fv3_filenameginput) call gsi_fv3ncdf_read(grd_fv3lam_ens_tracer_io_nouv,gsibundle_fv3lam_ens_tracer_nouv,& fv3_filenameginput%tracers,fv3_filenameginput) + if( if_model_dbz )& + call gsi_fv3ncdf_read(grd_fv3lam_ens_phyvar_io_nouv,gsibundle_fv3lam_ens_phyvar_nouv,& + fv3_filenameginput%phyvars,fv3_filenameginput) else call gsi_fv3ncdf_read_v1(grd_fv3lam_ens_dynvar_io_nouv,gsibundle_fv3lam_ens_dynvar_nouv,& fv3_filenameginput%dynvars,fv3_filenameginput) @@ -676,14 +1168,17 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_dynvar_nouv, 'tsen' ,g_tsen ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'q' ,g_q ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'oz' ,g_oz ,istatus );ier=ier+istatus - if (l_use_dbz_directDA) then + if (l_use_dbz_directDA .or. if_model_dbz) then call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'ql' ,g_ql ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'qi' ,g_qi ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'qr' ,g_qr ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'qs' ,g_qs ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'qg' ,g_qg ,istatus );ier=ier+istatus + if (l_use_dbz_directDA) & call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_tracer_nouv, 'qnr',g_qnr ,istatus );ier=ier+istatus call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_dynvar_nouv, 'w' , g_w ,istatus );ier=ier+istatus + if( if_model_dbz )& + call GSI_Bundlegetvar ( gsibundle_fv3lam_ens_phyvar_nouv, 'dbz' , g_dbz ,istatus );ier=ier+istatus end if @@ -785,6 +1280,7 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g enddo enddo call gsi_bundledestroy(gsibundle_fv3lam_ens_dynvar_nouv) + call gsi_bundledestroy(gsibundle_fv3lam_ens_phyvar_nouv) call gsi_bundledestroy(gsibundle_fv3lam_ens_tracer_nouv) diff --git a/src/gsi/gsi_rfv3io_mod.f90 b/src/gsi/gsi_rfv3io_mod.f90 index 16522bbd19..3090d2800b 100644 --- a/src/gsi/gsi_rfv3io_mod.f90 +++ b/src/gsi/gsi_rfv3io_mod.f90 @@ -58,6 +58,7 @@ module gsi_rfv3io_mod character(len=:),allocatable :: ak_bk !='fv3_akbk' character(len=:),allocatable :: dynvars !='fv3_dynvars' character(len=:),allocatable :: tracers !='fv3_tracer' + character(len=:),allocatable :: phyvars !='fv3_phyvars' character(len=:),allocatable :: sfcdata !='fv3_sfcdata' character(len=:),allocatable :: couplerres!='coupler.res' contains @@ -79,16 +80,18 @@ module gsi_rfv3io_mod real(r_kind),dimension(:,:,: ),allocatable:: ges_delp_bg type(sub2grid_info) :: grd_fv3lam_dynvar_ionouv type(sub2grid_info) :: grd_fv3lam_tracer_ionouv + type(sub2grid_info) :: grd_fv3lam_phyvar_ionouv type(sub2grid_info) :: grd_fv3lam_uv - integer(i_kind) ,parameter:: ndynvarslist=13, ntracerslist=8 + integer(i_kind) ,parameter:: ndynvarslist=13, ntracerslist=8, nphyvarslist=1 character(len=max_varname_length), parameter :: vardynvars(ndynvarslist) =(/"u","v","u_w","u_s", & "v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"/) character(len=max_varname_length), parameter :: vartracers(ntracerslist) =(/'q','oz', & 'ql','qi','qr','qs','qg','qnr'/) - character(len=max_varname_length), parameter :: varfv3name(15) =(/'u','v','W','T','delp','sphum','o3mr', & - 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'/) - character(len=max_varname_length), parameter :: vgsiname(15) =(/'u','v','w','tsen','delp','q','oz', & - 'ql','qi','qr','qs','qg','qnr','ps','delzinc'/) + character(len=max_varname_length), parameter :: varphyvars(nphyvarslist) =(/'dbz'/) + character(len=max_varname_length), parameter :: varfv3name(16) =(/'u','v','W','T','delp','sphum','o3mr', & + 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ref_f3d','ps','DZ'/) + character(len=max_varname_length), parameter :: vgsiname(16) =(/'u','v','w','tsen','delp','q','oz', & + 'ql','qi','qr','qs','qg','qnr','dbz','ps','delzinc'/) character(len=max_varname_length),dimension(:),allocatable:: name_metvars2d character(len=max_varname_length),dimension(:),allocatable:: name_metvars3d @@ -100,6 +103,8 @@ module gsi_rfv3io_mod public :: gsi_fv3ncdf_read_v1 public :: gsi_fv3ncdf_readuv public :: gsi_fv3ncdf_readuv_v1 + public :: gsi_fv3ncdf_read_ens_parallelIO + public :: gsi_fv3ncdf_readuv_ens_parallelIO public :: read_fv3_files public :: read_fv3_netcdf_guess public :: wrfv3_netcdf @@ -112,6 +117,7 @@ module gsi_rfv3io_mod public :: ijns,ijns2d,displss,displss2d,ijnz,displsz_g public :: fv3lam_io_dynmetvars3d_nouv,fv3lam_io_tracermetvars3d_nouv public :: fv3lam_io_dynmetvars2d_nouv,fv3lam_io_tracermetvars2d_nouv + public :: fv3lam_io_phymetvars3d_nouv integer(i_kind) mype_u,mype_v,mype_t,mype_q,mype_p,mype_delz,mype_oz,mype_ql integer(i_kind) mype_qi,mype_qr,mype_qs,mype_qg,mype_qnr,mype_w @@ -138,6 +144,7 @@ module gsi_rfv3io_mod ! copy of cvars3d excluding uv 3-d fields character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_io_tracermetvars3d_nouv ! copy of cvars3d excluding uv 3-d fields + character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_io_phymetvars3d_nouv character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_io_dynmetvars2d_nouv ! copy of cvars3d excluding uv 3-d fields character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_io_tracermetvars2d_nouv @@ -146,16 +153,18 @@ module gsi_rfv3io_mod !to define names in gsibundle character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_names_gsibundle_tracer_nouv !to define names in gsibundle + character(len=max_varname_length),allocatable,dimension(:) :: fv3lam_names_gsibundle_phyvar_nouv type(gsi_bundle):: gsibundle_fv3lam_dynvar_nouv type(gsi_bundle):: gsibundle_fv3lam_tracer_nouv + type(gsi_bundle):: gsibundle_fv3lam_phyvar_nouv contains subroutine fv3regfilename_init(this,grid_spec_input,ak_bk_input,dynvars_input, & - tracers_input,sfcdata_input,couplerres_input) + phyvars_input,tracers_input,sfcdata_input,couplerres_input) implicit None class(type_fv3regfilenameg),intent(inout):: this character(*),optional :: grid_spec_input,ak_bk_input,dynvars_input, & - tracers_input,sfcdata_input,couplerres_input + tracers_input,sfcdata_input,couplerres_input,phyvars_input if(present(grid_spec_input))then this%grid_spec=grid_spec_input @@ -179,6 +188,12 @@ subroutine fv3regfilename_init(this,grid_spec_input,ak_bk_input,dynvars_input, & else this%tracers='fv3_tracer' endif + if(present(phyvars_input))then + + this%phyvars=phyvars_input + else + this%phyvars='fv3_phyvars' + endif if(present(sfcdata_input))then this%sfcdata=sfcdata_input @@ -725,6 +740,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) use gridmod,only: regional use gridmod,only: l_reg_update_hydro_delz use gridmod, only: grd_a + use obsmod,only: if_model_dbz use mpimod, only: mype use gsi_metguess_mod, only: gsi_metguess_get @@ -755,14 +771,15 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) real(r_kind),dimension(:,:,:),pointer::ges_qg=>NULL() real(r_kind),dimension(:,:,:),pointer::ges_qnr=>NULL() real(r_kind),dimension(:,:,:),pointer::ges_w=>NULL() + real(r_kind),dimension(:,:,:),pointer::ges_dbz=>NULL() character(len=max_varname_length) :: vartem="" character(len=64),dimension(:,:),allocatable:: names !to be same as in the grid the dummy sub2grid_info character(len=64),dimension(:,:),allocatable:: uvnames integer(i_kind),dimension(:,:),allocatable:: lnames integer(i_kind),dimension(:,:),allocatable:: uvlnames integer(i_kind):: inner_vars,numfields - integer(i_kind):: ndynvario2d,ntracerio2d,ilev,jdynvar,jtracer - integer(r_kind):: iuv,ndynvario3d,ntracerio3d + integer(i_kind):: ndynvario2d,ntracerio2d,ilev,jdynvar,jtracer,jphyvar + integer(r_kind):: iuv,ndynvario3d,ntracerio3d,nphyvario3d !clt this block is still maintained for they would be needed for a certain 2d fields IO mype_2d=mod(1,npe) @@ -807,6 +824,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) iuv=0 ndynvario3d=0 ntracerio3d=0 + nphyvario3d=0 do i=1,size(name_metvars3d) vartem=trim(name_metvars3d(i)) if(trim(vartem)=='u'.or.trim(vartem)=='v') then @@ -817,6 +835,8 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) ndynvario3d=ndynvario3d+1 else if (ifindstrloc(vartracers,trim(vartem))> 0) then ntracerio3d=ntracerio3d+1 + else if (ifindstrloc(varphyvars,trim(vartem))> 0) then + nphyvario3d=nphyvario3d+1 else write(6,*)'the metvarname1 ',trim(vartem),' has not been considered yet, stop' call stop2(333) @@ -824,7 +844,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) endif ! iqr is the inital qr, need not to be in IO endif end do - if (iuv /= 2.or. ndynvario3d<=0.or.ntracerio3d<=0 ) then + if (iuv /= 2.or. ndynvario3d<=0.or.ntracerio3d<=0.or.nphyvario3d<=0 ) then write(6,*)"the set up for met variable is not as expected, abort" call stop2(222) endif @@ -837,9 +857,11 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) if (l_reg_update_hydro_delz.and.fv3sar_bg_opt==0) ndynvario3d=ndynvario3d+1 ! for delzinc allocate(fv3lam_io_dynmetvars3d_nouv(ndynvario3d)) allocate(fv3lam_io_tracermetvars3d_nouv(ntracerio3d)) + allocate(fv3lam_io_phymetvars3d_nouv(nphyvario3d)) jdynvar=0 jtracer=0 + jphyvar=0 do i=1,size(name_metvars3d) vartem=trim(name_metvars3d(i)) if(.not.(trim(vartem)=='u'.or.trim(vartem)=='v'.or.trim(vartem)=='iqr')) then @@ -851,10 +873,13 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) jdynvar=jdynvar+1 fv3lam_io_dynmetvars3d_nouv(jdynvar)=trim(vartem) endif - else if (ifindstrloc(vartracers,trim(vartem)) > 0) then + else if (ifindstrloc(vartracers,trim(vartem)) > 0) then jtracer=jtracer+1 fv3lam_io_tracermetvars3d_nouv(jtracer)=trim(vartem) - else + else if (ifindstrloc(varphyvars,trim(vartem)) > 0) then + jphyvar=jphyvar+1 + fv3lam_io_phymetvars3d_nouv(jphyvar)=trim(vartem) + else write(6,*)'the metvarname ',vartem,' is not expected, stop' call flush(6) call stop2(333) @@ -869,7 +894,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) jdynvar=jdynvar+1 fv3lam_io_dynmetvars3d_nouv(jdynvar)="delzinc" endif - if(jdynvar /= ndynvario3d.or.jtracer /= ntracerio3d ) then + if(jdynvar /= ndynvario3d.or.jtracer /= ntracerio3d.or.jphyvar /= nphyvario3d ) then write(6,*)'ndynvario3d is not as expected, stop' call flush(6) call stop2(333) @@ -877,6 +902,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) if(mype == 0) then write(6,*) ' fv3lam_io_dynmetvars3d_nouv is ',(trim(fv3lam_io_dynmetvars3d_nouv(i)),i=1,ndynvario3d) write(6,*) ' fv3lam_io_tracermevars3d_nouv is ',(trim(fv3lam_io_tracermetvars3d_nouv(i)),i=1,ntracerio3d) + write(6,*) ' fv3lam_io_phymetvars3d_nouv is ',(trim(fv3lam_io_phymetvars3d_nouv(i)),i=1,nphyvario3d) endif ndynvario2d=0 @@ -947,6 +973,8 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) names3d=fv3lam_io_tracermetvars3d_nouv) ntracerio2d=0 endif + call gsi_bundlecreate(gsibundle_fv3lam_phyvar_nouv,GSI_MetGuess_Bundle(it)%grid,'gsibundle_fv3lam_phyvar_nouv',istatus, & + names3d=fv3lam_io_phymetvars3d_nouv) @@ -987,6 +1015,20 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) enddo call general_sub2grid_create_info(grd_fv3lam_tracer_ionouv,inner_vars,grd_a%nlat,& grd_a%nlon,grd_a%nsig,numfields,regional,names=names,lnames=lnames) + inner_vars=1 + numfields=inner_vars*(nphyvario3d*grd_a%nsig) + deallocate(lnames,names) + allocate(lnames(1,numfields),names(1,numfields)) + ilev=1 + do i=1,nphyvario3d + do k=1,grd_a%nsig + lnames(1,ilev)=k + names(1,ilev)=trim(fv3lam_io_phymetvars3d_nouv(i)) + ilev=ilev+1 + enddo + enddo + call general_sub2grid_create_info(grd_fv3lam_phyvar_ionouv,inner_vars,grd_a%nlat,& + grd_a%nlon,grd_a%nsig,numfields,regional,names=names,lnames=lnames) inner_vars=2 numfields=grd_a%nsig @@ -1018,15 +1060,19 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'tv' ,ges_tv ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'q' ,ges_q ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'oz' ,ges_oz ,istatus );ier=ier+istatus - if (l_use_dbz_directDA) then + if (l_use_dbz_directDA .or. if_model_dbz) then call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'ql' ,ges_ql ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qi' ,ges_qi ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qr' ,ges_qr ,istatus );ier=ier+istatus - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'iqr' ,ges_iqr ,istatus );ier=ier+istatus + if (l_use_dbz_directDA) then + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'iqr' ,ges_iqr ,istatus );ier=ier+istatus + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qnr',ges_qnr ,istatus );ier=ier+istatus + end if call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qs' ,ges_qs ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qg' ,ges_qg ,istatus );ier=ier+istatus - call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qnr',ges_qnr ,istatus );ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'w' , ges_w ,istatus );ier=ier+istatus + if(if_model_dbz) & + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'dbz' , ges_dbz ,istatus );ier=ier+istatus end if if (ier/=0) call die(trim(myname),'cannot get pointers for fv3 met-fields, ier =',ier) @@ -1045,6 +1091,7 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) if( fv3sar_bg_opt == 0) then call gsi_fv3ncdf_read(grd_fv3lam_dynvar_ionouv,gsibundle_fv3lam_dynvar_nouv,fv3filenamegin%dynvars,fv3filenamegin) call gsi_fv3ncdf_read(grd_fv3lam_tracer_ionouv,gsibundle_fv3lam_tracer_nouv,fv3filenamegin%tracers,fv3filenamegin) + call gsi_fv3ncdf_read(grd_fv3lam_phyvar_ionouv,gsibundle_fv3lam_phyvar_nouv,fv3filenamegin%phyvars,fv3filenamegin) else call gsi_fv3ncdf_read_v1(grd_fv3lam_dynvar_ionouv,gsibundle_fv3lam_dynvar_nouv,fv3filenamegin%dynvars,fv3filenamegin) call gsi_fv3ncdf_read_v1(grd_fv3lam_tracer_ionouv,gsibundle_fv3lam_tracer_nouv,fv3filenamegin%tracers,fv3filenamegin) @@ -1056,7 +1103,9 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) endif call gsi_copy_bundle(gsibundle_fv3lam_dynvar_nouv,GSI_MetGuess_Bundle(it)) call gsi_copy_bundle(gsibundle_fv3lam_tracer_nouv,GSI_MetGuess_Bundle(it)) + call gsi_copy_bundle(gsibundle_fv3lam_phyvar_nouv,GSI_MetGuess_Bundle(it)) call GSI_BundleGetPointer ( gsibundle_fv3lam_dynvar_nouv, 'tsen' ,ges_tsen_readin ,istatus );ier=ier+istatus + !! tsen2tv !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! do k=1,nsig do j=1,lon2 @@ -1490,6 +1539,212 @@ subroutine gsi_fv3ncdf2d_read_v1(filenamein,varname,varname2,work_sub,mype_io) return end subroutine gsi_fv3ncdf2d_read_v1 +subroutine gsi_fv3ncdf_read_ens_parallelIO(filenamein,fv3filenamegin, & + delp,tsen,w,q,oz,ql,qr,qs,qi,qg,dbz,iope) +!$$$ subprogram documentation block +! . . . . +! subprogram: gsi_fv3ncdf_read +! prgmmr: wu org: np22 date: 2017-10-10 +! lei re-write for parallelization date: 2021-09-29 +! 2022-04-01 Yongming Wang and X. Wang, FV3LAM interface for ensemble +! parallel IO for hybrid EnVar, poc: xuguang.wang@ou.edu +! +! abstract: read in fields excluding u and v +! program history log: +! +! input argument list: +! filenamein - file name to read from +! iope - pe to read in the field +! +! +! attributes: +! language: f90 +! machine: ibm RS/6000 SP +! +!$$$ end documentation block + + + use kinds, only: r_kind,i_kind + use mpimod, only: mpi_comm_world,mpi_rtype,mype + use mpimod, only: MPI_INFO_NULL + use netcdf, only: nf90_open,nf90_close,nf90_get_var,nf90_noerr + use netcdf, only: nf90_nowrite,nf90_inquire,nf90_inquire_dimension + use netcdf, only: nf90_inquire_variable + use netcdf, only: nf90_inq_varid + use gridmod, only: nsig,nlon,nlat + use mod_fv3_lola, only: fv3_h_to_ll + use gsi_bundlemod, only: gsi_bundle + use general_sub2grid_mod, only: sub2grid_info,general_grid2sub + + implicit none + character(*),intent(in):: filenamein + type (type_fv3regfilenameg),intent(in) ::fv3filenamegin + integer(i_kind) ,intent(in ) :: iope + real(r_kind),allocatable,dimension(:,:):: uu2d, uu2d_tmp + real(r_kind),allocatable,dimension(:):: wrk_send_2d + real(r_kind),dimension(nlat,nlon,nsig):: hwork + real(r_kind),dimension(nlat,nlon,nsig),intent(out),optional:: delp,tsen,w,q,oz,ql,qr,qs,qi,qg,dbz + character(len=max_varname_length) :: varname,vgsiname + character(len=max_varname_length) :: name + character(len=max_varname_length), allocatable,dimension(:) :: varname_files + + integer(i_kind) nlatcase,nloncase,nxcase,nycase,countloc(3),startloc(3),countloc_tmp(3),startloc_tmp(3) + integer(i_kind) ilev,ilevtot,inative,ivar + integer(i_kind) kbgn,kend + integer(i_kind) gfile_loc,iret,var_id + integer(i_kind) nz,nzp1,mm1 +! for io_layout > 1 + real(r_kind),allocatable,dimension(:,:):: uu2d_layout + integer(i_kind) :: nio + integer(i_kind),allocatable :: gfile_loc_layout(:) + character(len=180) :: filename_layout + + mm1=mype+1 + nloncase=nlon + nlatcase=nlat + nxcase=nx + nycase=ny + kbgn=1 + kend=nsig + + if( mype == iope )then + allocate(uu2d(nxcase,nycase)) + if( present(delp).or.present(tsen).or.present(w) )then ! dynvars + if( present(w) )then + allocate(varname_files(3)) + varname_files = (/'T','delp','W'/) + else + allocate(varname_files(2)) + varname_files = (/'T','delp'/) + end if + end if + if( present(q).or.present(ql).or.present(qr) )then ! tracers + if(present(qr))then + allocate(varname_files(7)) + varname_files = (/'sphum','o3mr','liq_wat','ice_wat','rainwat','snowwat','graupel'/) + else + allocate(varname_files(2)) + varname_files = (/'sphum','o3mr'/) + end if + end if + if( present(dbz) )then ! phyvars: dbz + allocate(varname_files(1)) + varname_files = (/'ref_f3d'/) + end if + + if(fv3_io_layout_y > 1) then + allocate(gfile_loc_layout(0:fv3_io_layout_y-1)) + do nio=0,fv3_io_layout_y-1 + write(filename_layout,'(a,a,I4.4)') trim(filenamein),'.',nio + iret=nf90_open(filename_layout,nf90_nowrite,gfile_loc_layout(nio),comm=mpi_comm_world,info=MPI_INFO_NULL) !clt + if(iret/=nf90_noerr) then + write(6,*)' gsi_fv3ncdf_read: problem opening ',trim(filename_layout),gfile_loc_layout(nio),', Status = ',iret + call flush(6) + call stop2(333) + endif + enddo + else + iret=nf90_open(filenamein,nf90_nowrite,gfile_loc) + if(iret/=nf90_noerr) then + write(6,*)' gsi_fv3ncdf_read: problem opening ',trim(filenamein),gfile_loc,', Status = ',iret + call flush(6) + call stop2(333) + endif + endif + do ivar = 1, size(varname_files) + do ilevtot=kbgn,kend + ilev=ilevtot + nz=nsig + nzp1=nz+1 + inative=nzp1-ilev + startloc=(/1,1,inative/) + countloc=(/nxcase,nycase,1/) + varname = varname_files(ivar) + ! Variable ref_f3d in phy_data.nc has a smaller domain size than + ! dynvariables and tracers as well as a reversed order in vertical + if ( trim(adjustl(varname)) == 'ref_f3d' )then + allocate(uu2d_tmp(nxcase,nycase)) + startloc_tmp=(/1,1,ilev/) + countloc_tmp=(/nxcase,nycase,1/) + end if + + if(fv3_io_layout_y > 1) then + do nio=0,fv3_io_layout_y-1 + countloc=(/nxcase,ny_layout_len(nio),1/) + allocate(uu2d_layout(nxcase,ny_layout_len(nio))) + iret=nf90_inq_varid(gfile_loc_layout(nio),trim(adjustl(varname)),var_id) + iret=nf90_get_var(gfile_loc_layout(nio),var_id,uu2d_layout,start=startloc,count=countloc) + uu2d(:,ny_layout_b(nio):ny_layout_e(nio))=uu2d_layout + deallocate(uu2d_layout) + enddo + else + iret=nf90_inq_varid(gfile_loc,trim(adjustl(varname)),var_id) + if ( trim(adjustl(varname)) == 'ref_f3d' )then + uu2d = 0.0_r_kind + iret=nf90_get_var(gfile_loc,var_id,uu2d_tmp,start=startloc_tmp,count=countloc_tmp) + where(uu2d_tmp < 0.0_r_kind) + uu2d_tmp = 0.0_r_kind + endwhere + uu2d(4:nxcase-3,4:nycase-3) = uu2d_tmp + deallocate(uu2d_tmp) + else + iret=nf90_get_var(gfile_loc,var_id,uu2d,start=startloc,count=countloc) + end if + endif + + call fv3_h_to_ll(uu2d,hwork(:,:,ilevtot),nxcase,nycase,nloncase,nlatcase,grid_reverse_flag) + enddo ! ilevtot + if( present(delp).or.present(tsen).or.present(w) )then ! dynvars + if(ivar == 1)then + tsen = hwork + else if(ivar == 2)then + delp = hwork + end if + if( present(w) .and. ivar == 3 )then + w = hwork + end if + end if + if( present(q).or.present(ql).or.present(qr) )then ! tracers + if(ivar == 1)then + q = hwork + else if(ivar == 2)then + oz = hwork + end if + if(present(qr))then + if(ivar == 3)then + ql = hwork + else if(ivar == 4)then + qi = hwork + else if(ivar == 5)then + qr = hwork + else if(ivar == 6)then + qs = hwork + else if(ivar == 7)then + qg = hwork + end if + end if + end if + if( present(dbz) )then ! phyvars: dbz + dbz = hwork + end if + + end do + + if(fv3_io_layout_y > 1) then + do nio=1,fv3_io_layout_y-1 + iret=nf90_close(gfile_loc_layout(nio)) + enddo + deallocate(gfile_loc_layout) + else + iret=nf90_close(gfile_loc) + endif + + deallocate (uu2d,varname_files) + end if + + return +end subroutine gsi_fv3ncdf_read_ens_parallelIO + subroutine gsi_fv3ncdf_read(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) !$$$ subprogram documentation block ! . . . . @@ -1497,6 +1752,10 @@ subroutine gsi_fv3ncdf_read(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) ! prgmmr: wu org: np22 date: 2017-10-10 ! lei re-write for parallelization date: 2021-09-29 ! similar for horizontal recurisve filtering +! 2022-04-01, Yongming Wang and X. Wang, read in reflectivity background for +! direct radar reflectivity assimilation +! poc: xuguang.wang@ou.edu +! ! abstract: read in fields excluding u and v ! program history log: ! @@ -1532,14 +1791,14 @@ subroutine gsi_fv3ncdf_read(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) type(gsi_bundle),intent(inout) :: cstate_nouv character(*),intent(in):: filenamein type (type_fv3regfilenameg),intent(in) ::fv3filenamegin - real(r_kind),allocatable,dimension(:,:):: uu2d + real(r_kind),allocatable,dimension(:,:):: uu2d,uu2d_tmp real(r_kind),dimension(1,grd_ionouv%nlat,grd_ionouv%nlon,grd_ionouv%kbegin_loc:grd_ionouv%kend_alloc):: hwork character(len=max_varname_length) :: varname,vgsiname character(len=max_varname_length) :: name - character(len=max_varname_length) :: filenamein2 + character(len=max_varname_length*2) :: filenamein2 - integer(i_kind) nlatcase,nloncase,nxcase,nycase,countloc(3),startloc(3) + integer(i_kind) nlatcase,nloncase,nxcase,nycase,countloc(3),startloc(3),countloc_tmp(3),startloc_tmp(3) integer(i_kind) ilev,ilevtot,inative integer(i_kind) kbgn,kend integer(i_kind) gfile_loc,iret,var_id @@ -1585,6 +1844,8 @@ subroutine gsi_fv3ncdf_read(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) name=trim(varname) if(trim(filenamein) /= trim(filenamein2)) then write(6,*)'filenamein and filenamein2 are not the same as expected, stop' + write(6,*)'filenamein is',filenamein + write(6,*)'filenamein2 is',filenamein2 call flush(6) call stop2(333) endif @@ -1594,6 +1855,13 @@ subroutine gsi_fv3ncdf_read(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) inative=nzp1-ilev startloc=(/1,1,inative/) countloc=(/nxcase,nycase,1/) + ! Variable ref_f3d in phy_data.nc has a smaller domain size than + ! dynvariables and tracers as well as a reversed order in vertical + if ( trim(adjustl(varname)) == 'ref_f3d' )then + allocate(uu2d_tmp(nxcase-6,nycase-6)) + startloc_tmp=(/1,1,ilev/) + countloc_tmp=(/nxcase-6,nycase-6,1/) + end if if(fv3_io_layout_y > 1) then do nio=0,fv3_io_layout_y-1 @@ -1606,7 +1874,18 @@ subroutine gsi_fv3ncdf_read(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) enddo else iret=nf90_inq_varid(gfile_loc,trim(adjustl(varname)),var_id) - iret=nf90_get_var(gfile_loc,var_id,uu2d,start=startloc,count=countloc) + if ( trim(adjustl(varname)) == 'ref_f3d' )then + uu2d = 0.0_r_kind + iret=nf90_get_var(gfile_loc,var_id,uu2d_tmp,start=startloc_tmp,count=countloc_tmp) + where(uu2d_tmp < 0.0_r_kind) + uu2d_tmp = 0.0_r_kind + endwhere + + uu2d(4:nxcase-3,4:nycase-3) = uu2d_tmp + deallocate(uu2d_tmp) + else + iret=nf90_get_var(gfile_loc,var_id,uu2d,start=startloc,count=countloc) + end if endif call fv3_h_to_ll(uu2d,hwork(1,:,:,ilevtot),nxcase,nycase,nloncase,nlatcase,grid_reverse_flag) @@ -1673,7 +1952,7 @@ subroutine gsi_fv3ncdf_read_v1(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) type(gsi_bundle),intent(inout) :: cstate_nouv real(r_kind),allocatable,dimension(:,:):: uu2d real(r_kind),dimension(1,grd_ionouv%nlat,grd_ionouv%nlon,grd_ionouv%kbegin_loc:grd_ionouv%kend_alloc):: hwork - character(len=max_varname_length) :: filenamein2 + character(len=max_varname_length*2) :: filenamein2 character(len=max_varname_length) :: varname,vgsiname @@ -1735,6 +2014,174 @@ subroutine gsi_fv3ncdf_read_v1(grd_ionouv,cstate_nouv,filenamein,fv3filenamegin) return end subroutine gsi_fv3ncdf_read_v1 +subroutine gsi_fv3ncdf_readuv_ens_parallelIO(ges_u,ges_v,fv3filenamegin,iope) +!$$$ subprogram documentation block +! . . . . +! subprogram: gsi_fv3ncdf_readuv +! prgmmr: wu w org: np22 date: 2017-11-22 +! 2022-04-01 Yongming Wang and X. Wang, FV3LAM interface for ensemble +! parallel IO for hybrid EnVar, poc: xuguang.wang@ou.edu +! +! abstract: read in a field from a netcdf FV3 file in mype_u,mype_v +! then scatter the field to each PE +! program history log: +! +! input argument list: +! +! output argument list: +! ges_u - output sub domain u field +! ges_v - output sub domain v field +! +! attributes: +! language: f90 +! machine: ibm RS/6000 SP +! +!$$$ end documentation block + use kinds, only: r_kind,i_kind + use mpimod, only: mpi_comm_world,mpi_rtype,mype,mpi_info_null + use gridmod, only: nsig,nlon,nlat + use netcdf, only: nf90_open,nf90_close,nf90_get_var,nf90_noerr + use netcdf, only: nf90_nowrite,nf90_inquire,nf90_inquire_dimension + use netcdf, only: nf90_inquire_variable + use netcdf, only: nf90_inq_varid + use mod_fv3_lola, only: fv3_h_to_ll,fv3uv2earth + use general_sub2grid_mod, only: sub2grid_info,general_grid2sub + + implicit none + real(r_kind) ,intent(out ) :: ges_u(nlat,nlon,nsig) + real(r_kind) ,intent(out ) :: ges_v(nlat,nlon,nsig) + type (type_fv3regfilenameg),intent (in) :: fv3filenamegin + integer(i_kind), intent(in) :: iope + real(r_kind),dimension(2,nlat,nlon,nsig):: hwork + character(:), allocatable:: filenamein + real(r_kind),allocatable,dimension(:,:):: u2d,v2d + real(r_kind),allocatable,dimension(:,:):: uc2d,vc2d + character(len=max_varname_length) :: varname,vgsiname + real(r_kind),allocatable,dimension(:,:,:,:):: worksub + integer(i_kind) u_grd_VarId,v_grd_VarId + integer(i_kind) nlatcase,nloncase + integer(i_kind) nxcase,nycase + integer(i_kind) u_countloc(3),u_startloc(3),v_countloc(3),v_startloc(3) + integer(i_kind) inative,ilev,ilevtot + integer(i_kind) kbgn,kend + + integer(i_kind) gfile_loc,iret + integer(i_kind) nz,nzp1,mm1 + +! for fv3_io_layout_y > 1 + real(r_kind),allocatable,dimension(:,:):: u2d_layout,v2d_layout + integer(i_kind) :: nio + integer(i_kind),allocatable :: gfile_loc_layout(:) + character(len=180) :: filename_layout + + mm1=mype+1 + nloncase=nlon + nlatcase=nlat + nxcase=nx + nycase=ny + kbgn=1 + kend=nsig + if( mype == iope )then + allocate(u2d(nxcase,nycase+1)) + allocate(v2d(nxcase+1,nycase)) + allocate(uc2d(nxcase,nycase)) + allocate(vc2d(nxcase,nycase)) + filenamein=fv3filenamegin%dynvars + + if(fv3_io_layout_y > 1) then + allocate(gfile_loc_layout(0:fv3_io_layout_y-1)) + do nio=0,fv3_io_layout_y-1 + write(filename_layout,'(a,a,I4.4)') trim(filenamein),".",nio + iret=nf90_open(filename_layout,nf90_nowrite,gfile_loc_layout(nio),comm=mpi_comm_world,info=MPI_INFO_NULL) + if(iret/=nf90_noerr) then + write(6,*)'problem opening6 ',trim(filename_layout),gfile_loc_layout(nio),', Status = ',iret + call flush(6) + call stop2(333) + endif + enddo + else + iret=nf90_open(filenamein,nf90_nowrite,gfile_loc) + if(iret/=nf90_noerr) then + write(6,*)' problem opening6 ',trim(filenamein),', Status = ',iret + call flush(6) + call stop2(333) + endif + endif + do ilevtot=kbgn,kend + ilev=ilevtot + nz=nsig + nzp1=nz+1 + inative=nzp1-ilev + u_countloc=(/nxcase,nycase+1,1/) + v_countloc=(/nxcase+1,nycase,1/) + u_startloc=(/1,1,inative/) + v_startloc=(/1,1,inative/) + + if(fv3_io_layout_y > 1) then + do nio=0,fv3_io_layout_y-1 + u_countloc=(/nxcase,ny_layout_len(nio)+1,1/) + allocate(u2d_layout(nxcase,ny_layout_len(nio)+1)) + call check( nf90_inq_varid(gfile_loc_layout(nio),'u',u_grd_VarId) ) + iret=nf90_get_var(gfile_loc_layout(nio),u_grd_VarId,u2d_layout,start=u_startloc,count=u_countloc) + u2d(:,ny_layout_b(nio):ny_layout_e(nio))=u2d_layout(:,1:ny_layout_len(nio)) + if(nio==fv3_io_layout_y-1) u2d(:,ny_layout_e(nio)+1)=u2d_layout(:,ny_layout_len(nio)+1) + deallocate(u2d_layout) + + v_countloc=(/nxcase+1,ny_layout_len(nio),1/) + allocate(v2d_layout(nxcase+1,ny_layout_len(nio))) + call check( nf90_inq_varid(gfile_loc_layout(nio),'v',v_grd_VarId) ) + iret=nf90_get_var(gfile_loc_layout(nio),v_grd_VarId,v2d_layout,start=v_startloc,count=v_countloc) + v2d(:,ny_layout_b(nio):ny_layout_e(nio))=v2d_layout + deallocate(v2d_layout) + enddo + else + call check( nf90_inq_varid(gfile_loc,'u',u_grd_VarId) ) + iret=nf90_get_var(gfile_loc,u_grd_VarId,u2d,start=u_startloc,count=u_countloc) + call check( nf90_inq_varid(gfile_loc,'v',v_grd_VarId) ) + iret=nf90_get_var(gfile_loc,v_grd_VarId,v2d,start=v_startloc,count=v_countloc) + endif + + if(.not.grid_reverse_flag) then + call reverse_grid_r_uv (u2d,nxcase,nycase+1,1) + call reverse_grid_r_uv (v2d,nxcase+1,nycase,1) + endif + call fv3uv2earth(u2d(:,:),v2d(:,:),nxcase,nycase,uc2d,vc2d) + + ! NOTE on transfor to earth u/v: + ! The u and v before transferring need to be in E-W/N-S grid, which is + ! defined as reversed grid here because it is revered from map view. + ! + ! Have set the following flag for grid orientation + ! grid_reverse_flag=true: E-W/N-S grid + ! grid_reverse_flag=false: W-E/S-N grid + ! + ! So for preparing the wind transferring, need to reverse the grid from + ! W-E/S-N grid to E-W/N-S grid when grid_reverse_flag=false: + ! + ! if(.not.grid_reverse_flag) call reverse_grid_r_uv + ! + ! and the last input parameter for fv3_h_to_ll is alway true: + ! + ! + call fv3_h_to_ll(uc2d,hwork(1,:,:,ilevtot),nxcase,nycase,nloncase,nlatcase,.true.) + call fv3_h_to_ll(vc2d,hwork(2,:,:,ilevtot),nxcase,nycase,nloncase,nlatcase,.true.) + enddo ! i + + if(fv3_io_layout_y > 1) then + do nio=0,fv3_io_layout_y-1 + iret=nf90_close(gfile_loc_layout(nio)) + enddo + deallocate(gfile_loc_layout) + else + iret=nf90_close(gfile_loc) + endif + deallocate(u2d,v2d,uc2d,vc2d) + ges_u = hwork(1,:,:,:) + ges_v = hwork(2,:,:,:) + end if ! mype + +end subroutine gsi_fv3ncdf_readuv_ens_parallelIO + subroutine gsi_fv3ncdf_readuv(grd_uv,ges_u,ges_v,fv3filenamegin) !$$$ subprogram documentation block ! . . . . @@ -1774,7 +2221,7 @@ subroutine gsi_fv3ncdf_readuv(grd_uv,ges_u,ges_v,fv3filenamegin) character(:), allocatable:: filenamein real(r_kind),allocatable,dimension(:,:):: u2d,v2d real(r_kind),allocatable,dimension(:,:):: uc2d,vc2d - character(len=max_varname_length) :: filenamein2 + character(len=max_varname_length*2) :: filenamein2 character(len=max_varname_length) :: varname,vgsiname real(r_kind),allocatable,dimension(:,:,:,:):: worksub integer(i_kind) u_grd_VarId,v_grd_VarId @@ -1830,7 +2277,9 @@ subroutine gsi_fv3ncdf_readuv(grd_uv,ges_u,ges_v,fv3filenamegin) vgsiname=grd_uv%names(1,ilevtot) call getfv3lamfilevname(vgsiname,fv3filenamegin,filenamein2,varname) if(trim(filenamein) /= trim(filenamein2)) then - write(6,*)'filenamein and filenamein2 are not the same as expected, stop' + write(6,*)'uv: filenamein and filenamein2 are not the same as expected, stop' + write(6,*)'filenamein is',filenamein + write(6,*)'filenamein2 is',filenamein2 call flush(6) call stop2(333) endif @@ -1950,7 +2399,7 @@ subroutine gsi_fv3ncdf_readuv_v1(grd_uv,ges_u,ges_v,fv3filenamegin) real(r_kind),allocatable,dimension(:,:):: us2d,vw2d real(r_kind),allocatable,dimension(:,:):: uorv2d real(r_kind),allocatable,dimension(:,:,:,:):: worksub - character(len=max_varname_length) :: filenamein2 + character(len=max_varname_length*2) :: filenamein2 character(len=max_varname_length) :: varname integer(i_kind) nlatcase,nloncase integer(i_kind) kbgn,kend @@ -2062,6 +2511,7 @@ subroutine wrfv3_netcdf(fv3filenamegin) use gridmod, only: eta1_ll,eta2_ll use constants, only: one,rd_over_cp_mass,r10,r1000 use mpimod, only: mype + use obsmod, only: if_model_dbz implicit none @@ -2087,6 +2537,7 @@ subroutine wrfv3_netcdf(fv3filenamegin) real(r_kind),pointer,dimension(:,:,:):: ges_qg =>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_qnr =>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_w =>NULL() + real(r_kind),pointer,dimension(:,:,:):: ges_dbz =>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_delzinc =>NULL() real(r_kind),pointer,dimension(:,:,:):: ges_delp =>NULL() real(r_kind),dimension(:,: ),allocatable:: ges_ps_write @@ -2103,14 +2554,17 @@ subroutine wrfv3_netcdf(fv3filenamegin) call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'u' , ges_u ,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'v' , ges_v ,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'q' ,ges_q ,istatus);ier=ier+istatus - if (l_use_dbz_directDA) then + if (l_use_dbz_directDA .or. if_model_dbz) then call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'ql' ,ges_ql ,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qi' ,ges_qi ,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qr' ,ges_qr ,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qs' ,ges_qs ,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qg' ,ges_qg ,istatus);ier=ier+istatus + if (l_use_dbz_directDA) & call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'qnr',ges_qnr,istatus);ier=ier+istatus call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'w' , ges_w ,istatus);ier=ier+istatus + if( if_model_dbz )& + call GSI_BundleGetPointer ( GSI_MetGuess_Bundle(it), 'dbz' , ges_dbz ,istatus);ier=ier+istatus end if if(i_use_2mq4b > 0 .and. i_use_2mt4b > 0 ) then call GSI_BundleGetPointer (GSI_MetGuess_Bundle(it),'q2m',ges_q2m,istatus); ier=ier+istatus @@ -2145,6 +2599,7 @@ subroutine wrfv3_netcdf(fv3filenamegin) call gsi_copy_bundle(GSI_MetGuess_Bundle(it),gsibundle_fv3lam_dynvar_nouv) call gsi_copy_bundle(GSI_MetGuess_Bundle(it),gsibundle_fv3lam_tracer_nouv) + call gsi_copy_bundle(GSI_MetGuess_Bundle(it),gsibundle_fv3lam_phyvar_nouv) call gsi_bundleputvar (gsibundle_fv3lam_dynvar_nouv,'tsen',ges_tsen(:,:,:,it),istatus) if( fv3sar_bg_opt == 0) then call GSI_BundleGetPointer ( gsibundle_fv3lam_dynvar_nouv, 'delp' ,ges_delp ,istatus );ier=ier+istatus @@ -2180,12 +2635,15 @@ subroutine wrfv3_netcdf(fv3filenamegin) endif add_saved=.true. + ! write out if(fv3sar_bg_opt == 0) then call gsi_fv3ncdf_write(grd_fv3lam_dynvar_ionouv,gsibundle_fv3lam_dynvar_nouv,& add_saved,fv3filenamegin%dynvars,fv3filenamegin) call gsi_fv3ncdf_write(grd_fv3lam_tracer_ionouv,gsibundle_fv3lam_tracer_nouv, & add_saved,fv3filenamegin%tracers,fv3filenamegin) + call gsi_fv3ncdf_write(grd_fv3lam_phyvar_ionouv,gsibundle_fv3lam_phyvar_nouv,& + add_saved,fv3filenamegin%phyvars,fv3filenamegin) call gsi_fv3ncdf_writeuv(grd_fv3lam_uv,ges_u,ges_v,add_saved,fv3filenamegin) @@ -2799,16 +3257,16 @@ subroutine gsi_fv3ncdf_write(grd_ionouv,cstate_nouv,add_saved,filenamein,fv3file character(len=:), allocatable, intent(in) :: filenamein type (type_fv3regfilenameg),intent (in) :: fv3filenamegin real(r_kind),dimension(1,grd_ionouv%nlat,grd_ionouv%nlon,grd_ionouv%kbegin_loc:grd_ionouv%kend_alloc):: hwork - character(len=max_varname_length) :: filenamein2 + character(len=max_varname_length*2) :: filenamein2 character(len=max_varname_length) :: varname,vgsiname - integer(i_kind) nlatcase,nloncase,nxcase,nycase,countloc(3),startloc(3) + integer(i_kind) nlatcase,nloncase,nxcase,nycase,countloc(3),startloc(3),countloc_tmp(3),startloc_tmp(3) integer(i_kind) kbgn,kend integer(i_kind) inative,ilev,ilevtot integer(i_kind) :: VarId,gfile_loc integer(i_kind) mm1,nzp1 real(r_kind),allocatable,dimension(:,:):: work_a - real(r_kind),allocatable,dimension(:,:):: work_b + real(r_kind),allocatable,dimension(:,:):: work_b,work_b_tmp real(r_kind),allocatable,dimension(:,:):: workb2,worka2 ! for io_layout > 1 @@ -2860,6 +3318,12 @@ subroutine gsi_fv3ncdf_write(grd_ionouv,cstate_nouv,add_saved,filenamein,fv3file work_a=hwork(1,:,:,ilevtot) + if( trim(varname) == 'ref_f3d' )then + allocate(work_b_tmp(nlon_regional-6,nlat_regional-6)) + countloc_tmp=(/nxcase-6,nycase-6,1/) + startloc_tmp=(/1,1,ilev/) + end if + call check( nf90_inq_varid(gfile_loc,trim(varname),VarId) ) @@ -2890,7 +3354,16 @@ subroutine gsi_fv3ncdf_write(grd_ionouv,cstate_nouv,add_saved,filenamein,fv3file deallocate(work_b_layout) enddo else - call check( nf90_get_var(gfile_loc,VarId,work_b,start = startloc, count = countloc) ) + if( trim(varname) == 'ref_f3d' )then + work_b = 0.0_r_kind + call check( nf90_get_var(gfile_loc,VarId,work_b_tmp,start = startloc_tmp, count = countloc_tmp) ) + where(work_b_tmp < 0.0_r_kind) + work_b_tmp = 0.0_r_kind + end where + work_b(4:nxcase-3,4:nycase-3) = work_b_tmp + else + call check( nf90_get_var(gfile_loc,VarId,work_b,start = startloc, count = countloc) ) + end if endif call fv3_h_to_ll(work_b(:,:),worka2,nlon_regional,nlat_regional,nloncase,nlatcase,grid_reverse_flag) !!!!!!!! analysis_inc: work_a !!!!!!!!!!!!!!!! @@ -2910,7 +3383,16 @@ subroutine gsi_fv3ncdf_write(grd_ionouv,cstate_nouv,add_saved,filenamein,fv3file deallocate(work_b_layout) enddo else - call check( nf90_put_var(gfile_loc,VarId,work_b, start = startloc, count = countloc) ) + if( trim(varname) == 'ref_f3d' )then + work_b_tmp = work_b(4:nxcase-3,4:nycase-3) + where(work_b_tmp < 0.0_r_kind) + work_b_tmp = 0.0_r_kind + end where + call check( nf90_put_var(gfile_loc,VarId,work_b_tmp, start = startloc_tmp, count = countloc_tmp) ) + deallocate(work_b_tmp) + else + call check( nf90_put_var(gfile_loc,VarId,work_b, start = startloc, count = countloc) ) + end if endif enddo !ilevtotl loop @@ -2977,7 +3459,7 @@ subroutine gsi_fv3ncdf_write_v1(grd_ionouv,cstate_nouv,add_saved,filenamein,fv3f character(*),intent(in):: filenamein type (type_fv3regfilenameg),intent (in) :: fv3filenamegin real(r_kind),dimension(1,grd_ionouv%nlat,grd_ionouv%nlon,grd_ionouv%kbegin_loc:grd_ionouv%kend_alloc):: hwork - character(len=max_varname_length) :: filenamein2 + character(len=max_varname_length*2) :: filenamein2 integer(i_kind) kbgn,kend integer(i_kind) inative,ilev,ilevtot @@ -3617,7 +4099,7 @@ subroutine getfv3lamfilevname(vgsinamein,fv3filenamegref,filenameout,vname) type (type_fv3regfilenameg),intent (in) :: fv3filenamegref character(len=*):: vgsinamein character(len=*),intent(out):: vname - character(len=*),intent(out):: filenameout + character(len=*),intent(inout):: filenameout if (ifindstrloc(vgsiname,vgsinamein)<= 0) then write(6,*)'the name ',vgsinamein ,'cannot be treated correctly in getfv3lamfilevname,stop' call stop2(333) @@ -3626,6 +4108,8 @@ subroutine getfv3lamfilevname(vgsinamein,fv3filenamegref,filenameout,vname) filenameout=fv3filenamegref%dynvars else if(ifindstrloc(vartracers,vgsinamein)> 0 ) then filenameout=fv3filenamegref%tracers + else if(ifindstrloc(varphyvars,vgsinamein)> 0) then + filenameout=fv3filenamegref%phyvars else write(6,*)'the filename corresponding to var ',trim(vgsinamein),' is not found, stop ' call stop2(333) diff --git a/src/gsi/setupdbz.f90 b/src/gsi/setupdbz.f90 index 9bbf5ed34b..a7f7ba52e1 100644 --- a/src/gsi/setupdbz.f90 +++ b/src/gsi/setupdbz.f90 @@ -94,6 +94,8 @@ subroutine setupdbz(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,radardbz_d ! for variational DA applications ! - modified jacobian terms to prevent possible ! coding errors +! 2022-04-01 Yongming Wang and X. Wang, enable direct reflectivity assimilation method in Wang and Wang (2017, MWR) +! for FV3LAM, poc: xuguang.wang@ou.edu ! ! input argument list: ! lunin - unit from which to read observations @@ -1451,6 +1453,12 @@ subroutine setupdbz(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,radardbz_d ! Write information to diagnostic file if(radardbz_diagsave .and. ii>0 )then + if( .not. l_use_dbz_directDA )then + write(7)'dbz',nchar,nreal,ii,mype,ioff0 + write(7)cdiagbuf(1:ii),rdiagbuf(:,1:ii) + deallocate(cdiagbuf,rdiagbuf) + else + write(string,600) jiter 600 format('radardbz_',i2.2) diag_file=trim(dirname) // trim(string) @@ -1476,6 +1484,7 @@ subroutine setupdbz(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,radardbz_d write(lu_diag)cdiagbuf(1:ii),rdiagbuf(:,1:ii) deallocate(cdiagbuf,rdiagbuf) close(lu_diag) + end if end if write(6,*)'mype, irefsmlobs,irejrefsmlobs are ',mype,' ',irefsmlobs, ' ',irejrefsmlobs ! close(52) !simulated obs From 588ce984482945bb6ef6a3ca9c1a5667f0425ad7 Mon Sep 17 00:00:00 2001 From: "Ming.Hu" Date: Thu, 28 Apr 2022 23:21:03 +0000 Subject: [PATCH 56/58] Merge Yongming's EnKF code for dbz direct analysis --- src/enkf/enkf.f90 | 37 ++++++++-- src/enkf/gridinfo_fv3reg.f90 | 4 +- src/enkf/gridio_fv3reg.f90 | 138 ++++++++++++++++++++++++++++------- 3 files changed, 144 insertions(+), 35 deletions(-) diff --git a/src/enkf/enkf.f90 b/src/enkf/enkf.f90 index c117e4ba56..b7a670fbbd 100644 --- a/src/enkf/enkf.f90 +++ b/src/enkf/enkf.f90 @@ -97,6 +97,8 @@ module enkf ! used to be the same) and the "chunks" come from loadbal ! 2018-05-31: whitaker: add modulated ensemble model-space vertical ! localization (neigv>0) and denkf option. +! 2022-04-01: Yongming Wang and X. Wang: Fix spurious analysis increments when assimilating reflectivity +! poc: xuguang.wang@ou.edu ! ! attributes: ! language: f95 @@ -182,7 +184,7 @@ subroutine enkf_update() integer(i_kind) ierr ! kd-tree search results type(kdtree2_result),dimension(:),allocatable :: sresults1,sresults2 -integer(i_kind) nanal,nn,nnn,nobm,nsame,nn1,nn2,oz_ind,nlev +integer(i_kind) nanal,nn,nnn,nobm,nsame,nn1,nn2,oz_ind,nlev,dbz_ind real(r_single),dimension(nlevs_pres):: taperv logical lastiter, kdgrid, kdobs @@ -609,6 +611,7 @@ subroutine enkf_update() nn2 = ncdim end if if (nf2 > 0) then + dbz_ind = getindex(cvars3d, 'dbz') !$omp parallel do schedule(dynamic,1) private(ii,i,nb,obt,nn,nnn,nlev,lnsig,kfgain,ens_tmp,taper1,taper3,taperv) do ii=1,nf2 ! loop over nearby horiz grid points do nb=1,nbackgrounds ! loop over background time levels @@ -628,8 +631,13 @@ subroutine enkf_update() ! (through hpfhtcon) kfgain=taper1*sum(ens_tmp*anal_obtmp_modens) ! update mean. - ensmean_chunk(i,nn,nb) = ensmean_chunk(i,nn,nb) + & - kfgain*obinc_tmp + if ( (nn .ge. (dbz_ind-1)*nlevs+1 .and. nn .le. (dbz_ind-1)*nlevs+nlevs) )then + ensmean_chunk(i,nn,nb) = MAX(ensmean_chunk(i,nn,nb) + & + kfgain*obinc_tmp,0.0) + else + ensmean_chunk(i,nn,nb) = ensmean_chunk(i,nn,nb) + & + kfgain*obinc_tmp + end if ! update perturbations. anal_chunk(:,i,nn,nb) = anal_chunk(:,i,nn,nb) + & kfgain*obganl(:) @@ -652,7 +660,11 @@ subroutine enkf_update() ! (through hpfhtcon) kfgain=taperv(nnn)*sum(anal_chunk(:,i,nn,nb)*anal_obtmp) ! update mean. - ensmean_chunk(i,nn,nb) = ensmean_chunk(i,nn,nb) + kfgain*obinc_tmp + if ( (nn .ge. (dbz_ind-1)*nlevs+1 .and. nn .le. (dbz_ind-1)*nlevs+nlevs) )then + ensmean_chunk(i,nn,nb) = MAX(ensmean_chunk(i,nn,nb) + kfgain*obinc_tmp,0.0) + else + ensmean_chunk(i,nn,nb) = ensmean_chunk(i,nn,nb) + kfgain*obinc_tmp + end if ! update perturbations. anal_chunk(:,i,nn,nb) = anal_chunk(:,i,nn,nb) + kfgain*obganl(:) end if @@ -681,7 +693,13 @@ subroutine enkf_update() taper(obt*obtimelinv)* & sum(anal_obchunk_modens(:,nob2)*anal_obtmp_modens)*hpfhtcon ! update mean. - ensmean_obchunk(nob2) = ensmean_obchunk(nob2) + kfgain*obinc_tmp + nob3 = indxproc_obs(nproc+1,nob2) + if(TRIM(obtype(nob3)) .eq. 'dbz' ) then + ensmean_obchunk(nob2) = MAX((ensmean_obchunk(nob2) + & + kfgain*obinc_tmp),zero) + else + ensmean_obchunk(nob2) = ensmean_obchunk(nob2) + kfgain*obinc_tmp + end if ! update perturbations. anal_obchunk(:,nob2) = anal_obchunk(:,nob2) + kfgain*obganl anal_obchunk_modens(:,nob2) = anal_obchunk_modens(:,nob2) + kfgain*obganl_modens @@ -707,7 +725,13 @@ subroutine enkf_update() taper(lnsig*lnsiglinv)*taper(obt*obtimelinv)* & sum(anal_obchunk(:,nob2)*anal_obtmp)*hpfhtcon ! update mean. - ensmean_obchunk(nob2) = ensmean_obchunk(nob2) + kfgain*obinc_tmp + nob3 = indxproc_obs(nproc+1,nob2) + if(TRIM(obtype(nob3)) .eq. 'dbz' ) then + ensmean_obchunk(nob2) = MAX((ensmean_obchunk(nob2) + & + kfgain*obinc_tmp),zero) + else + ensmean_obchunk(nob2) = ensmean_obchunk(nob2) + kfgain*obinc_tmp + end if ! update perturbations. anal_obchunk(:,nob2) = anal_obchunk(:,nob2) + kfgain*obganl ! recompute ob space spread ratio for unassimlated obs @@ -758,6 +782,7 @@ subroutine enkf_update() tend = mpi_wtime() if (nproc .eq. 0) then write(6,8003) niter,'timing on proc',nproc,' = ',tend-tbegin,t2,t3,t4,t5,t6,nrej + if(allocated(assimltd_flag))deallocate(assimltd_flag) allocate(assimltd_flag(nobstot)) assimltd_flag = 99999 if (iassim_order == 2) then diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index e1db4a1023..43a13c2d7a 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -69,10 +69,10 @@ module gridinfo integer,public :: npts integer,public :: ntrunc ! supported variable names in anavinfo -character(len=max_varname_length),public, dimension(15) :: & +character(len=max_varname_length),public, dimension(16) :: & vars3d_supported = [character(len=max_varname_length) :: & 'u', 'v', 'w', 't', 'q', 'oz', 'cw', 'tsen', 'prse', & - 'ql', 'qi', 'qr', 'qs', 'qg', 'qnr'] + 'ql', 'qi', 'qr', 'qs', 'qg', 'qnr','dbz'] character(len=max_varname_length),public, dimension(3) :: & vars2d_supported = [character(len=max_varname_length) :: & 'ps', 'pst', 'sst'] diff --git a/src/enkf/gridio_fv3reg.f90 b/src/enkf/gridio_fv3reg.f90 index c7a300da68..1101b948ae 100644 --- a/src/enkf/gridio_fv3reg.f90 +++ b/src/enkf/gridio_fv3reg.f90 @@ -54,15 +54,16 @@ module gridio !------------------------------------------------------------------------- - integer(i_kind) ,parameter:: ndynvarslist=6, ntracerslist=8 + integer(i_kind) ,parameter:: ndynvarslist=6, ntracerslist=8,nphysicslist=1 character(len=max_varname_length), parameter :: vardynvars(ndynvarslist) =(/"u","v", & "T","W","DZ","delp"/) character(len=max_varname_length), parameter :: vartracers(ntracerslist) =(/'sphum','o3mr', & 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc'/) + character(len=max_varname_length), parameter :: varphysics(nphysicslist) =(/'ref_f3d'/) type type_fv3lamfile logical l_filecombined - character(len=max_varname_length), dimension(2):: fv3lamfilename - integer (i_kind), dimension(2):: fv3lam_fileid(2) + character(len=max_varname_length), dimension(3):: fv3lamfilename + integer (i_kind), dimension(3):: fv3lam_fileid contains procedure, pass(this) :: setupfile => type_bound_setupfile procedure, pass(this):: get_idfn => type_bound_getidfn @@ -90,15 +91,14 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f real(r_double), dimension(npts,nlevs,ntimes,nanal2-nanal1+1), intent(out) :: qsat - ! Define local variables character(len=500) :: filename - character(len=:),allocatable :: fv3filename,fv3filename1 + character(len=:),allocatable :: fv3filename,fv3filename1,fv3filename2 character(len=7) :: charnanal - integer(i_kind) file_id,file_id1 + integer(i_kind) file_id,file_id1,file_id2 real(r_single), dimension(:,:,:), allocatable ::workvar3d,uworkvar3d,& vworkvar3d,tvworkvar3d,tsenworkvar3d,& - workprsi,qworkvar3d,wworkvar3d + workprsi,qworkvar3d,workvar3d_tmp real(r_double),dimension(:,:,:),allocatable:: qsatworkvar3d real(r_single), dimension(:,:), allocatable ::pswork @@ -113,6 +113,7 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f integer :: nlevsp1 integer :: i,j, k,nn,ntile,nn_tile0, nb,nanal,ne integer :: u_ind, v_ind, tv_ind,tsen_ind, q_ind, oz_ind + integer :: dbz_ind integer :: w_ind, ql_ind, qi_ind, qr_ind, qs_ind, qg_ind, qnr_ind integer :: ps_ind, sst_ind integer :: tmp_ind,ifile @@ -137,6 +138,7 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f qs_ind = getindex(vars3d, 'qs') ! Q snow (3D) qg_ind = getindex(vars3d, 'qg') ! Q graupel (3D) qnr_ind = getindex(vars3d, 'qnr') ! N rain (3D) + dbz_ind = getindex(vars3d, 'dbz') ! Reflectivity (3D) ps_ind = getindex(vars2d, 'ps') ! Ps (2D) sst_ind = getindex(vars2d, 'sst') ! SST (2D) @@ -181,8 +183,19 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f fv3filename1=trim(adjustl(filename))//"_tracer" call nc_check( nf90_open(trim(adjustl(fv3filename1)),nf90_nowrite,file_id1),& myname_,'open: '//trim(adjustl(fv3filename1)) ) - call fv3lamfile%setupfile(fileid1=file_id,fv3fn1=trim(adjustl(fv3filename)) , & + if(dbz_ind > 0) then + fv3filename2=trim(adjustl(filename))//"_phyvar" + call nc_check( nf90_open(trim(adjustl(fv3filename2)),nf90_nowrite,file_id2),& + myname_,'open: '//trim(adjustl(fv3filename2)) ) + endif + if(dbz_ind > 0) then + call fv3lamfile%setupfile(fileid1=file_id,fv3fn1=trim(adjustl(fv3filename)) , & + fileid2=file_id1,fv3fn2=trim(adjustl(fv3filename1)), & + fileid3=file_id2,fv3fn3=trim(adjustl(fv3filename2)) ) + else + call fv3lamfile%setupfile(fileid1=file_id,fv3fn1=trim(adjustl(fv3filename)) , & fileid2=file_id1,fv3fn2=trim(adjustl(fv3filename1)) ) + endif endif @@ -237,16 +250,15 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f endif if (w_ind > 0) then - allocate(wworkvar3d(nx_res,ny_res,nlevs)) varstrname = 'W' call fv3lamfile%get_idfn(varstrname,file_id,fv3filename) - call read_fv3_restart_data3d(varstrname,fv3filename,file_id,wworkvar3d) + call read_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d) do k=1,nlevs nn = nn_tile0 do j=1,ny_res do i=1,nx_res nn=nn+1 - vargrid(nn,levels(w_ind-1)+k,nb,ne)=wworkvar3d(i,j,k) + vargrid(nn,levels(w_ind-1)+k,nb,ne)=workvar3d(i,j,k) enddo enddo enddo @@ -255,7 +267,6 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f write(6,*) 'READFVregional : w ', & & k, minval(vargrid(:,k,nb,ne)), maxval(vargrid(:,k,nb,ne)) enddo - deallocate(wworkvar3d) endif @@ -467,6 +478,34 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f enddo endif + if (dbz_ind > 0) then + allocate(workvar3d_tmp(nx_res-6,ny_res-6,nlevs)) + varstrname = 'ref_f3d' + call fv3lamfile%get_idfn(varstrname,file_id,fv3filename) + call read_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d_tmp) + workvar3d = 0.0_r_kind + workvar3d(4:nx_res-3,4:ny_res-3,1:nlevs)=workvar3d_tmp + deallocate(workvar3d_tmp) + where( workvar3d < 0.0_r_kind ) + workvar3d = 0.0_r_kind + end where + do k=1,nlevs + nn = nn_tile0 + do j=1,ny_res + do i=1,nx_res + nn=nn+1 + vargrid(nn,levels(dbz_ind-1)+k,nb,ne)=workvar3d(i,j,nlevs+1-k) + enddo + enddo + enddo + do k = levels(dbz_ind-1)+1, levels(dbz_ind) + if (nproc .eq. 0) & + write(6,*) 'READFVregional : dbz ', & + & k, minval(vargrid(:,k,nb,ne)), maxval(vargrid(:,k,nb,ne)) + enddo + + endif + ! set SST to zero for now if (sst_ind > 0) then @@ -542,7 +581,8 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f call nc_check( nf90_close(file_id),& myname_,'close '//trim(filename) ) else - do ifile=1,2 + do ifile=1,3 + if(dbz_ind <= 0 .and. ifile == 3) cycle file_id=fv3lamfile%fv3lam_fileid(ifile) filename=fv3lamfile%fv3lamfilename(ifile) call nc_check( nf90_close(file_id),& @@ -594,19 +634,19 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid !---------------------------------------------------------------------- ! Define variables computed within subroutine character(len=500) :: filename - character(len=:),allocatable :: fv3filename,fv3filename1 + character(len=:),allocatable :: fv3filename,fv3filename1,fv3filename2 character(len=7) :: charnanal !---------------------------------------------------------------------- - integer(i_kind) :: u_ind, v_ind, tv_ind, tsen_ind,q_ind, ps_ind,oz_ind + integer(i_kind) :: u_ind, v_ind, tv_ind, tsen_ind,q_ind, ps_ind,oz_ind,dbz_ind integer(i_kind) :: w_ind, cw_ind, ph_ind integer(i_kind) :: ql_ind, qi_ind, qr_ind, qs_ind, qg_ind, qnr_ind - integer(i_kind) file_id,file_id1 + integer(i_kind) file_id,file_id1,file_id2 real(r_single), dimension(:,:), allocatable ::pswork real(r_single), dimension(:,:,:), allocatable ::workvar3d,workinc3d,workinc3d2,uworkvar3d,& vworkvar3d,tvworkvar3d,tsenworkvar3d,& - workprsi,qworkvar3d,wworkvar3d + workprsi,qworkvar3d,workvar3d_tmp real(r_single) :: clip @@ -647,6 +687,7 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid qs_ind = getindex(vars3d, 'qs') ! QS (3D) for FV3 qg_ind = getindex(vars3d, 'qg') ! QG (3D) for FV3 qnr_ind = getindex(vars3d, 'qnr') ! QNR (3D) for FV3 + dbz_ind = getindex(vars3d, 'dbz') ! Reflectivity (3D) ps_ind = getindex(vars2d, 'ps') ! Ps (2D) @@ -693,6 +734,15 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid myname_,'open: '//trim(adjustl(fv3filename1)) ) call fv3lamfile%setupfile(fileid1=file_id,fv3fn1=trim(adjustl(fv3filename)) , & fileid2=file_id1,fv3fn2=trim(adjustl(fv3filename1)) ) + + if(dbz_ind > 0) then + call fv3lamfile%setupfile(fileid1=file_id,fv3fn1=trim(adjustl(fv3filename)) , & + fileid2=file_id1,fv3fn2=trim(adjustl(fv3filename1)), & + fileid3=file_id2,fv3fn3=trim(adjustl(fv3filename2)) ) + else + call fv3lamfile%setupfile(fileid1=file_id,fv3fn1=trim(adjustl(fv3filename)) , & + fileid2=file_id1,fv3fn2=trim(adjustl(fv3filename1)) ) + endif endif @@ -748,10 +798,9 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid if (w_ind > 0) then varstrname = 'W' - allocate(wworkvar3d(nx_res,ny_res,nlevs)) call fv3lamfile%get_idfn(varstrname,file_id,fv3filename) - call read_fv3_restart_data3d(varstrname,fv3filename,file_id,wworkvar3d) + call read_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d) do k=1,nlevs nn = nn_tile0 do j=1,ny_res @@ -761,11 +810,9 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid enddo enddo enddo - wworkvar3d(1:nx_res,:,:)=wworkvar3d(1:nx_res,:,:)+workinc3d - wworkvar3d(nx_res+1,:,:)=wworkvar3d(nx_res,:,:) - call write_fv3_restart_data3d(varstrname,fv3filename,file_id,wworkvar3d) + workvar3d=workvar3d+workinc3d + call write_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d) - deallocate(wworkvar3d) endif if (tv_ind > 0.or.tsen_ind>0 ) then @@ -1001,6 +1048,37 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid end if call write_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d) + endif + if (dbz_ind > 0) then + varstrname = 'ref_f3d' + allocate(workvar3d_tmp(nx_res-6,ny_res-6,nlevs)) + varstrname = 'ref_f3d' + call fv3lamfile%get_idfn(varstrname,file_id,fv3filename) + call read_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d_tmp) + + workvar3d = 0.0_r_kind + workvar3d(4:nx_res-3,4:ny_res-3,1:nlevs)=workvar3d_tmp + where( workvar3d < 0.0_r_kind ) + workvar3d = 0.0_r_kind + end where + do k=1,nlevs + nn = nn_tile0 + do j=1,ny_res + do i=1,nx_res + nn=nn+1 + workinc3d(i,j,nlevs+1-k)=vargrid(nn,levels(dbz_ind-1)+k,nb,ne) + enddo + enddo + enddo + workvar3d=workvar3d+workinc3d + workvar3d_tmp = workvar3d(4:nx_res-3,4:ny_res-3,1:nlevs) + where( workvar3d_tmp < 0.0_r_kind ) + workvar3d_tmp = 0.0_r_kind + end where + call write_fv3_restart_data3d(varstrname,fv3filename,file_id,workvar3d_tmp) + + deallocate(workvar3d_tmp) + endif if (ps_ind > 0) then @@ -1049,7 +1127,8 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,vargrid call nc_check( nf90_close(file_id),& myname_,'close '//trim(filename) ) else - do ifile=1,2 + do ifile=1,3 + if(dbz_ind <= 0 .and. ifile == 3) cycle file_id=fv3lamfile%fv3lam_fileid(ifile) filename=fv3lamfile%fv3lamfilename(ifile) call nc_check( nf90_close(file_id),& @@ -1146,18 +1225,20 @@ subroutine writegriddata_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,no_inflate_ real(r_single), dimension(npts,ndim,nbackgrounds,1), intent(inout) :: grdin logical, intent(in) :: no_inflate_flag end subroutine writegriddata_pnc - subroutine type_bound_setupfile(this,fileid1,fv3fn1,fileid2,fv3fn2) + subroutine type_bound_setupfile(this,fileid1,fv3fn1,fileid2,fv3fn2,fileid3,fv3fn3) class (type_fv3lamfile) :: this integer(i_kind) fileid1 - integer(i_kind), optional :: fileid2 + integer(i_kind), optional :: fileid2,fileid3 character(len=*)::fv3fn1 - character(len=*),optional ::fv3fn2 + character(len=*),optional ::fv3fn2,fv3fn3 if (present (fileid2)) then this%l_filecombined=.false. this%fv3lamfilename(1)=trim(fv3fn1) this%fv3lamfilename(2)=trim(fv3fn2) + this%fv3lamfilename(3)=trim(fv3fn3) this%fv3lam_fileid(1)=fileid1 this%fv3lam_fileid(2)=fileid2 + this%fv3lam_fileid(3)=fileid3 else this%l_filecombined=.true. this%fv3lamfilename(1)=fv3fn1 @@ -1175,6 +1256,9 @@ subroutine type_bound_getidfn(this,vnamloc,fileid,fv3fn) else if(ifindstrloc(vartracers,vnamloc)> 0) then fv3fn=trim(this%fv3lamfilename(2)) fileid=this%fv3lam_fileid(2) + else if(ifindstrloc(varphysics,vnamloc)> 0) then + fv3fn=trim(this%fv3lamfilename(3)) + fileid=this%fv3lam_fileid(3) else write(6,*)"the varname ",trim(vnamloc)," is not recognized in the ype_bound_getidfn, stop" call stop2(23) From ce547a20c4b51bbfd12130b34e5bb61f21a76e52 Mon Sep 17 00:00:00 2001 From: David Dowell Date: Thu, 26 May 2022 20:33:48 +0000 Subject: [PATCH 57/58] Changes needed to run OU-MAP GSI-EnKF assimilation of reflectivity observations, in a second step after EnKF assimilation of conventional observations. --- src/enkf/gridio_fv3reg.f90 | 6 ++++-- src/gsi/gsi_dbzOper.F90 | 28 +++++++++++++++++++++++++++- src/gsi/setupdbz.f90 | 21 +++++++++++++++------ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/enkf/gridio_fv3reg.f90 b/src/enkf/gridio_fv3reg.f90 index 1101b948ae..f116aa65f9 100644 --- a/src/enkf/gridio_fv3reg.f90 +++ b/src/enkf/gridio_fv3reg.f90 @@ -1235,10 +1235,12 @@ subroutine type_bound_setupfile(this,fileid1,fv3fn1,fileid2,fv3fn2,fileid3,fv3fn this%l_filecombined=.false. this%fv3lamfilename(1)=trim(fv3fn1) this%fv3lamfilename(2)=trim(fv3fn2) - this%fv3lamfilename(3)=trim(fv3fn3) this%fv3lam_fileid(1)=fileid1 this%fv3lam_fileid(2)=fileid2 - this%fv3lam_fileid(3)=fileid3 + if (present (fileid3)) then + this%fv3lamfilename(3)=trim(fv3fn3) + this%fv3lam_fileid(3)=fileid3 + endif else this%l_filecombined=.true. this%fv3lamfilename(1)=fv3fn1 diff --git a/src/gsi/gsi_dbzOper.F90 b/src/gsi/gsi_dbzOper.F90 index 74d9bdf65d..661d4b9fe0 100644 --- a/src/gsi/gsi_dbzOper.F90 +++ b/src/gsi/gsi_dbzOper.F90 @@ -83,6 +83,10 @@ subroutine setup_(self, lunin, mype, is, nobs, init_pass,last_pass) use jfunc , only: jiter use mpeu_util, only: die + + use directDA_radaruse_mod, only: l_use_dbz_directDA + use obsmod, only: dirname, ianldate + implicit none class(dbzOper ), intent(inout):: self integer(i_kind), intent(in):: lunin @@ -99,8 +103,30 @@ subroutine setup_(self, lunin, mype, is, nobs, init_pass,last_pass) character(len=len_isis ):: isis integer(i_kind):: nreal,nchanl,ier,nele logical:: diagsave + integer(i_kind):: lu_diag + character(128):: diag_file + character(80):: string + + if(nobs == 0) then + + if(mype == 0) then + write(6,*) 'init_pass = ', init_pass + write(6,*) 'l_use_dbz_directDA = ', l_use_dbz_directDA + endif - if(nobs == 0) return + if( (mype == 0) .and. init_pass .and. (.not. l_use_dbz_directDA) ) then + write(string,600) jiter +600 format('radardbz_',i2.2) + diag_file=trim(dirname) // trim(string) + write(6,*) 'write ianldate to ', diag_file + open(newunit=lu_diag,file=trim(diag_file),form='unformatted',status='unknown',position='rewind') + write(lu_diag) ianldate + close(lu_diag) + endif + + return + + endif read(lunin,iostat=ier) obstype,isis,nreal,nchanl if(ier/=0) call die(myname_,'read(obstype,...), iostat =',ier) diff --git a/src/gsi/setupdbz.f90 b/src/gsi/setupdbz.f90 index a7f7ba52e1..4499cd3449 100644 --- a/src/gsi/setupdbz.f90 +++ b/src/gsi/setupdbz.f90 @@ -1453,11 +1453,19 @@ subroutine setupdbz(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,radardbz_d ! Write information to diagnostic file if(radardbz_diagsave .and. ii>0 )then - if( .not. l_use_dbz_directDA )then - write(7)'dbz',nchar,nreal,ii,mype,ioff0 - write(7)cdiagbuf(1:ii),rdiagbuf(:,1:ii) - deallocate(cdiagbuf,rdiagbuf) - else +! DCD 25 May 2022: When the following if test returns "true", reflectivity diagnostics are written to +! the same diag file as for the conventional observations. However, separate conventional and reflectivity +! diagnostic files are what we typically want for EnKF assimilation, i.e., conventional observations +! are assimilated in the first execution of EnKF and then reflectivity observations are assimilated +! in a second execution of EnKF. It's unclear why the following if test appears +! in the EMC master GSI. For now, I've commented out this if test so that we'll always have +! the separate conventional and reflectivity diag files needed for a two-step EnKF analysis. + +! if( .not. l_use_dbz_directDA )then +! write(7)'dbz',nchar,nreal,ii,mype,ioff0 +! write(7)cdiagbuf(1:ii),rdiagbuf(:,1:ii) +! deallocate(cdiagbuf,rdiagbuf) +! else write(string,600) jiter 600 format('radardbz_',i2.2) @@ -1472,6 +1480,7 @@ subroutine setupdbz(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,radardbz_d open(lu_diag,file=trim(diag_file),form='unformatted',status='unknown',position='rewind') endif endif + if(init_pass .and. mype == 0) then if ( .not. l_use_dbz_directDA ) then ! EnKF uses these diagnostics and EnKF uses single OBS file for now. write(lu_diag) ianldate ! So do not write analysis date for binary in case of using direct reflectivity DA. @@ -1484,7 +1493,7 @@ subroutine setupdbz(obsLL,odiagLL,lunin,mype,bwork,awork,nele,nobs,is,radardbz_d write(lu_diag)cdiagbuf(1:ii),rdiagbuf(:,1:ii) deallocate(cdiagbuf,rdiagbuf) close(lu_diag) - end if + ! end if end if write(6,*)'mype, irefsmlobs,irejrefsmlobs are ',mype,' ',irefsmlobs, ' ',irejrefsmlobs ! close(52) !simulated obs From 8f4a81cfa9ec6e5294ee96a2035efc536eac720c Mon Sep 17 00:00:00 2001 From: David Dowell Date: Tue, 21 Jun 2022 15:47:53 +0000 Subject: [PATCH 58/58] Changes that allow GSI EnVar assimilation of conventional observations to work, when there is no need to input dbz from th FV3 physics file. --- src/gsi/gsi_rfv3io_mod.f90 | 44 +++++++++++++++++++++++--------------- src/gsi/gsimod.F90 | 2 +- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/gsi/gsi_rfv3io_mod.f90 b/src/gsi/gsi_rfv3io_mod.f90 index 3090d2800b..4b55a4aed4 100644 --- a/src/gsi/gsi_rfv3io_mod.f90 +++ b/src/gsi/gsi_rfv3io_mod.f90 @@ -844,10 +844,14 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) endif ! iqr is the inital qr, need not to be in IO endif end do - if (iuv /= 2.or. ndynvario3d<=0.or.ntracerio3d<=0.or.nphyvario3d<=0 ) then + if (iuv /= 2.or. ndynvario3d<=0.or.ntracerio3d<=0) then write(6,*)"the set up for met variable is not as expected, abort" call stop2(222) endif + if (if_model_dbz.and.nphyvario3d<=0 ) then + write(6,*)"the set up for physics met variable is not as expected, abort" + call stop2(222) + endif if (fv3sar_bg_opt == 0.and.ifindstrloc(name_metvars3d,'delp') <= 0)then ndynvario3d=ndynvario3d+1 ! for delp endif @@ -1015,20 +1019,22 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) enddo call general_sub2grid_create_info(grd_fv3lam_tracer_ionouv,inner_vars,grd_a%nlat,& grd_a%nlon,grd_a%nsig,numfields,regional,names=names,lnames=lnames) - inner_vars=1 - numfields=inner_vars*(nphyvario3d*grd_a%nsig) - deallocate(lnames,names) - allocate(lnames(1,numfields),names(1,numfields)) - ilev=1 - do i=1,nphyvario3d - do k=1,grd_a%nsig - lnames(1,ilev)=k - names(1,ilev)=trim(fv3lam_io_phymetvars3d_nouv(i)) - ilev=ilev+1 + if (nphyvario3d > 0) then + inner_vars=1 + numfields=inner_vars*(nphyvario3d*grd_a%nsig) + deallocate(lnames,names) + allocate(lnames(1,numfields),names(1,numfields)) + ilev=1 + do i=1,nphyvario3d + do k=1,grd_a%nsig + lnames(1,ilev)=k + names(1,ilev)=trim(fv3lam_io_phymetvars3d_nouv(i)) + ilev=ilev+1 + enddo enddo - enddo - call general_sub2grid_create_info(grd_fv3lam_phyvar_ionouv,inner_vars,grd_a%nlat,& - grd_a%nlon,grd_a%nsig,numfields,regional,names=names,lnames=lnames) + call general_sub2grid_create_info(grd_fv3lam_phyvar_ionouv,inner_vars,grd_a%nlat,& + grd_a%nlon,grd_a%nsig,numfields,regional,names=names,lnames=lnames) + endif inner_vars=2 numfields=grd_a%nsig @@ -1091,7 +1097,9 @@ subroutine read_fv3_netcdf_guess(fv3filenamegin) if( fv3sar_bg_opt == 0) then call gsi_fv3ncdf_read(grd_fv3lam_dynvar_ionouv,gsibundle_fv3lam_dynvar_nouv,fv3filenamegin%dynvars,fv3filenamegin) call gsi_fv3ncdf_read(grd_fv3lam_tracer_ionouv,gsibundle_fv3lam_tracer_nouv,fv3filenamegin%tracers,fv3filenamegin) - call gsi_fv3ncdf_read(grd_fv3lam_phyvar_ionouv,gsibundle_fv3lam_phyvar_nouv,fv3filenamegin%phyvars,fv3filenamegin) + if (nphyvario3d > 0) then + call gsi_fv3ncdf_read(grd_fv3lam_phyvar_ionouv,gsibundle_fv3lam_phyvar_nouv,fv3filenamegin%phyvars,fv3filenamegin) + endif else call gsi_fv3ncdf_read_v1(grd_fv3lam_dynvar_ionouv,gsibundle_fv3lam_dynvar_nouv,fv3filenamegin%dynvars,fv3filenamegin) call gsi_fv3ncdf_read_v1(grd_fv3lam_tracer_ionouv,gsibundle_fv3lam_tracer_nouv,fv3filenamegin%tracers,fv3filenamegin) @@ -2642,8 +2650,10 @@ subroutine wrfv3_netcdf(fv3filenamegin) add_saved,fv3filenamegin%dynvars,fv3filenamegin) call gsi_fv3ncdf_write(grd_fv3lam_tracer_ionouv,gsibundle_fv3lam_tracer_nouv, & add_saved,fv3filenamegin%tracers,fv3filenamegin) - call gsi_fv3ncdf_write(grd_fv3lam_phyvar_ionouv,gsibundle_fv3lam_phyvar_nouv,& - add_saved,fv3filenamegin%phyvars,fv3filenamegin) + if (if_model_dbz) then + call gsi_fv3ncdf_write(grd_fv3lam_phyvar_ionouv,gsibundle_fv3lam_phyvar_nouv,& + add_saved,fv3filenamegin%phyvars,fv3filenamegin) + endif call gsi_fv3ncdf_writeuv(grd_fv3lam_uv,ges_u,ges_v,add_saved,fv3filenamegin) diff --git a/src/gsi/gsimod.F90 b/src/gsi/gsimod.F90 index 7177719fde..af864b022f 100644 --- a/src/gsi/gsimod.F90 +++ b/src/gsi/gsimod.F90 @@ -1934,7 +1934,7 @@ subroutine gsimain_initialize ! skipped in case of direct reflectivity DA because it works in Envar and hybrid if ( .not.l_use_rw_columntilt .or. .not.l_use_dbz_directDA) then do i=1,ndat - if ( index(dtype(i), 'dbz') /= 0 )then + if ( if_model_dbz .and. ( index(dtype(i), 'dbz') /= 0 ) ) then write(6,*)'beta_s0 needs to be set to zero in this GSI version, when reflectivity is directly assimilated. & Static B extended for radar reflectivity assimilation will be included in future version.' call stop2(8888)