From 369cc60d9e52a7b32bde6430afbb9ce5a08a7515 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 9 Feb 2021 14:43:48 -0500 Subject: [PATCH 01/76] 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 2603bc76d..304cf9743 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 000000000..5e19e2545 --- /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 000000000..7339c76f9 --- /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 000000000..2c1ea8ebb --- /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 000000000..87e2d0695 --- /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/76] 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 043545c73..e8d639836 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 000000000..9e32378ff --- /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 000000000..216779d85 --- /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 000000000..be5556137 --- /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 000000000..7339c76f9 --- /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 000000000..2c1ea8ebb --- /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 000000000..9c166de85 --- /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 d6abd87ab..000000000 --- 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/76] 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 304cf9743..02709cfdc 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 1439ae848..9e32378ff 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 5e19e2545..be5556137 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 87e2d0695..4da2dd499 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 c44fb5b98..6c4de7363 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 000000000..03e358a05 --- /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 a124b75d3..418bd3f20 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 7493e5d71..257bd8e1c 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/76] 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 02709cfdc..d6a4072af 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 bd2ce7009..c95721944 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 6c4de7363..c220a1086 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/76] 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 d6a4072af..691a0a489 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 2c1ea8ebb..601e619ca 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 000000000..e79145242 --- /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 be5556137..5203d5065 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 c220a1086..651ee584d 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 000000000..49f629ff0 --- /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 000000000..a23c0962d --- /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 000000000..7339c76f9 --- /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 000000000..601e619ca --- /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/76] 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 691a0a489..6faef82e9 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 7339c76f9..672f1baae 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/76] 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 6faef82e9..f55f90c90 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 601e619ca..08256026b 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 5203d5065..8090f8bf1 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 601e619ca..c8a0f37ae 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 a23c0962d..8861c5171 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/76] 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 651ee584d..9d6c00cdd 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/76] 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 000000000..e79145242 --- /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 7339c76f9..48f94f45a 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 9d6c00cdd..b6ff4d590 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 000000000..49f629ff0 --- /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 d9614b83a..7b27ca79d 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 fb7c568b3..34835ed9b 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 48757c213..d869b4968 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 b2e8b3089..7c2922cdb 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 4a855673a..22581b2db 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 eb90b7d14..b9631d7e1 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 5fa4119c7..ac07efa61 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 8b2b9ffcb..5b6acce30 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 7339c76f9..672f1baae 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/76] 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 8090f8bf1..10f066766 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 03e358a05..da5b59069 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 fe96c63ab..4e4aee9d3 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 be5556137..9216ce10c 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/76] 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 f55f90c90..f2c7038cb 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 238887a9f..bc224df54 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 b6ff4d590..1d23fc6a1 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 da5b59069..29fdf7b95 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 000000000..3dfb278e8 --- /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/76] 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 4d3244a69..052a014b7 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 f2c7038cb..5bfec659b 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 1d23fc6a1..a92e0cac5 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 000000000..854213b3f --- /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 b54f727b7..98feb4620 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 496370e7c..bc2b4ed1f 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 4e4aee9d3..507ef52c2 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/76] 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 5bfec659b..f7d748cbe 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 10f066766..b61ddbd9c 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 48f94f45a..449229bb8 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 4da2dd499..54c462ef7 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 a92e0cac5..c1cb71885 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 49f629ff0..2db1baf7b 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 8861c5171..807d031e4 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 49f629ff0..e79145242 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 672f1baae..c4783799e 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 851ea2c05..d10e4e6f7 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/76] 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 54c462ef7..c730e35d9 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 394c6b52b..a00549816 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 000000000..58468ae7d --- /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 000000000..66cfe4e2a --- /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 000000000..2db1baf7b --- /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 000000000..37b5e0188 --- /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 000000000..e79145242 --- /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 000000000..c4783799e --- /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 000000000..d7e03f065 --- /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 7fdb2f67b..c2e2b10f5 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 8a6bd1250..fe5199e39 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 c1cb71885..4aa6aa850 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 854213b3f..7476954aa 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 29fdf7b95..516a06ed2 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 2c1ea8ebb..c61631da5 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/76] 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 000000000..9e32378ff --- /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 000000000..9e32378ff --- /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/76] 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 f7d748cbe..7304f9fdd 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 4aa6aa850..5ac972474 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 000000000..59b3a3400 --- /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 c01e2529a..4ada1e6fb 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 000000000..d21fdeae1 --- /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 0b2c61d48..4130c809c 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 000000000..ac3a0903b --- /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 3dfb278e8..dd16fa74b 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 28137ad94..8c0c91a34 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 000000000..febd4f0ab --- /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 49d2a8fde..988bd9245 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 4687522c6..437089b1a 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 000000000..607b4b32e --- /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 000000000..febd4f0ab --- /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 5fbc72f9a..b414940f3 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 e7f1eafe0..2b2e4bda1 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 0e2de4f99..85f21e703 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 000000000..febd4f0ab --- /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 31ae3c1dd..f656e1827 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 842712da0..d7a39cb69 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 32f6b7dec..c4494f8ea 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 e063902e1..b532fc9bf 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 5854233ff..488866064 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 ddabc66a4..7ea5fc898 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 716d9019e..f0bdc763f 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 4928a62e6..d8377ab1a 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 406281cd3..77dcc79a7 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 5bdfe3299..29d7f18cd 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 9750cbc97..544d395bd 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 d73f74b75..2589a0860 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 e88f49565..0080d12a2 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 ce102ee83..d0d240653 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 cb622350b..74038e464 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 dfbf5ca59..8dd1b9767 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 197740ef7..9126578c3 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 2b3a51f4c..dd8907351 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 6ae2f24f9..65955d93d 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 7e347146f..0457c131d 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 6afbb572e..eb7f3c647 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 79199d143..5c69d9171 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 5ab94f071..51823f56e 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 1566b60fb..a8062246f 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 5c5537a2e..333c95b1d 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 321845bf3..5a94f2f26 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 093c19ea4..41ed4d4f8 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 000000000..9e32378ff --- /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 000000000..1fe8e9937 --- /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 000000000..e79145242 --- /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 000000000..eb3a3c86a --- /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 000000000..e79145242 --- /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 000000000..4a895df8e --- /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 70b3d1ad3..b31bb218d 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 c878bb13f..1a35d90a4 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 45d748474..a017efbbd 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 f18aace83..0ec6fa7be 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 aa7e0f10c..dbc6885f3 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 770783ebb..c02ffd5ae 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 5881fbf22..19e89c06e 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 6c146f3d0..3a660015a 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 000000000..27b86b61b --- /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 cf5069b6b..e32fb8902 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 85922a290..83710ad1d 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 000000000..ac3a0903b --- /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 08a3c1784..d9874729e 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 066397f6e..deeba6732 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/76] 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 988bd9245..872108a54 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 b414940f3..2bc10f1e1 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/76] 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 a00549816..990031257 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 5ac972474..ae3048fff 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 c3c12d808..1d2fdeefe 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 872108a54..91427b701 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 19e89c06e..3b58c64dc 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/76] 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 990031257..4993a7481 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 9e1f3310e..772e6cf9b 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 ae3048fff..45a3c9ab7 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 dd16fa74b..ce082c779 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 91427b701..83fccf9d6 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 2bc10f1e1..8695611c9 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/76] 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 7304f9fdd..87ac98cd7 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 08256026b..000000000 --- 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 e79145242..000000000 --- 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 b61ddbd9c..000000000 --- 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 e79145242..000000000 --- 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 449229bb8..000000000 --- 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 4993a7481..6bc2b3698 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 2db1baf7b..31135cb0a 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 37b5e0188..1b57e9c1b 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 e79145242..ed5d63d1d 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 c4783799e..87864efe5 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 45a3c9ab7..c45f50deb 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 2db1baf7b..31135cb0a 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 807d031e4..f321c685a 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 e79145242..ed5d63d1d 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 c4783799e..87864efe5 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 516a06ed2..6725b99d8 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 d10e4e6f7..dbd0b60e0 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 9216ce10c..be9368ad6 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 672f1baae..a25d6cc30 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 1d2fdeefe..7e67ee45c 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 ce082c779..4c5871ace 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 e79145242..ed5d63d1d 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 eb3a3c86a..6b2f64f11 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 e79145242..ed5d63d1d 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 4a895df8e..e2de8c9fe 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/76] 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 87ac98cd7..ca47abb01 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 66cfe4e2a..2a7d5e2cc 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 c8a0f37ae..bd38b729d 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/76] 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 437089b1a..d7930fa09 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 d8377ab1a..1bbdfb1b9 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 9126578c3..efe496f54 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 eb7f3c647..2e194ed76 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 51823f56e..1384e3ccf 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 3a660015a..23bfcb44c 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/76] 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 04410f631..000000000 --- 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 a2d70b92b..000000000 --- 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 793cb9a5d..000000000 --- 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 9aab56711..000000000 --- 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 ee982c149..000000000 --- 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 3e4bd7d7d..000000000 --- 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 78e3db367..000000000 --- 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 26ec21704..000000000 --- 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 8e0a0c95b..000000000 --- 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 44bf4f1cd..000000000 --- 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 1263fc516..000000000 --- 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 09d4366d6..000000000 --- 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 d504f53a8..000000000 --- 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 b5fba9734..000000000 --- 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 3cbce42a6..000000000 --- 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 aef2126c8..000000000 --- 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 43faf4664..000000000 --- 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 7ee2bbace..000000000 --- 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 fd8891cf2..000000000 --- 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 5cd2a2afe..000000000 --- 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 30f912c62..000000000 --- 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 be9d19d43..000000000 --- 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 793858716..000000000 --- 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 a25452385..000000000 --- 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 b8a308a4b..000000000 --- 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 4d43a04d6..000000000 --- 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 67f6bd6f2..000000000 --- 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 6821cee4f..000000000 --- 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 dce6f9926..000000000 --- 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 028957a0a..000000000 --- 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 8bb4cb94d..000000000 --- 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 54477168e..000000000 --- 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 fe8a2dfc0..000000000 --- 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 d6929b8f0..000000000 --- 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 24f40107d..000000000 --- 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 d8af27696..000000000 --- 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 824585e36..000000000 --- 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 56ddd1f2c..000000000 --- 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 8c19f11a3..000000000 --- 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 1c9cf712c..000000000 --- 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 19a853e60..000000000 --- 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 81b129739..000000000 --- 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 e4ef2d9ad..000000000 --- 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 861e9fc63..000000000 --- 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 88e5061ff..000000000 --- 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 2088a7416..000000000 --- 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 9938e090f..000000000 --- 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/76] 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 ca47abb01..8d80665ea 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 9e32378ff..000000000 --- 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/76] 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 52b4afc34..2daa3a23d 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 211b681ad..430f4fd7d 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 2c6d32b66..4f4b04047 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 163da2c70..91089895a 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 aa158d2b8..6ed61c594 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 812b46fb0..0152f5112 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 bc224df54..921ac2b9f 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 78064580e..ff89074d2 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 f02f4ded7..6d98a926f 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 1cd388d08..5c2e32521 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/76] 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 6bc2b3698..b09cd74fb 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 58468ae7d..fbf4edf30 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 08474d7eb..000000000 --- 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 51b901bf8..000000000 --- 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 ece0f7746..000000000 --- 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 6a0bcffcd..000000000 --- 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 2b8c6ce04..000000000 --- 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 1a92b7fc1..000000000 --- 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 c0e62a6ab..000000000 --- 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 cc426b236..000000000 --- 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 fd3dd4215..000000000 --- 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 ea9bd2e2c..000000000 --- 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 c700a90dc..000000000 --- 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 a6f8d4ffb..000000000 --- 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 c45f50deb..dd88d20cd 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 7476954aa..4529a7ba3 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 dbd0b60e0..e7c568db9 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 216779d85..ba16512df 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 83fccf9d6..1d810e7ce 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 2b2e4bda1..bc9a2b8bf 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 85f21e703..dc1f52216 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/76] 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 8d80665ea..aa99943aa 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 c730e35d9..04c58e2f6 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 000000000..b0607b43e --- /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 3b2ca84f1..bba48cdeb 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 000000000..9e9d13e6a --- /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 b09cd74fb..f87959aa6 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 fbf4edf30..47e7e268d 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 dd88d20cd..e90d4726b 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 4529a7ba3..020ffaac8 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 e7c568db9..390d98114 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 7e67ee45c..4cd3838f5 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 4c5871ace..ed481e07d 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 8c0c91a34..d6f015d47 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 febd4f0ab..1aec52ef0 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 1d810e7ce..fd16d71be 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 607b4b32e..8a73a74d3 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 8695611c9..cd78c072a 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 bc9a2b8bf..efcb62e5f 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 dc1f52216..4a4968fee 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 a017efbbd..7ebe05098 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 3b58c64dc..1c2d5af1d 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 83710ad1d..7ede68d2a 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/76] 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 ed481e07d..c1a92c055 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 000000000..ddf939af1 --- /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 000000000..d30f36188 --- /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 000000000..3e87e78e6 --- /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 000000000..6060ae1ed --- /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 8797baf65..bc0fca444 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 000000000..ae48aa40a --- /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 000000000..eb54b0f86 --- /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/76] 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 000000000..04410f631 --- /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 000000000..a2d70b92b --- /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 000000000..793cb9a5d --- /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 000000000..9aab56711 --- /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 000000000..ee982c149 --- /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 000000000..3e4bd7d7d --- /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 000000000..78e3db367 --- /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 000000000..26ec21704 --- /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 000000000..8e0a0c95b --- /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 000000000..44bf4f1cd --- /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 000000000..1263fc516 --- /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 000000000..09d4366d6 --- /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 000000000..d504f53a8 --- /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 000000000..b5fba9734 --- /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 000000000..3cbce42a6 --- /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 000000000..aef2126c8 --- /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 000000000..43faf4664 --- /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 000000000..7ee2bbace --- /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 000000000..fd8891cf2 --- /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 000000000..5cd2a2afe --- /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 000000000..30f912c62 --- /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 000000000..be9d19d43 --- /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 000000000..793858716 --- /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 000000000..a25452385 --- /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 000000000..b8a308a4b --- /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 000000000..4d43a04d6 --- /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 000000000..67f6bd6f2 --- /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 000000000..6821cee4f --- /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 000000000..dce6f9926 --- /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 000000000..028957a0a --- /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 000000000..8bb4cb94d --- /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 000000000..54477168e --- /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 000000000..fe8a2dfc0 --- /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 000000000..d6929b8f0 --- /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 000000000..24f40107d --- /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 000000000..d8af27696 --- /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 000000000..824585e36 --- /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 000000000..56ddd1f2c --- /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 000000000..8c19f11a3 --- /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 000000000..1c9cf712c --- /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 000000000..19a853e60 --- /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 000000000..81b129739 --- /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 000000000..e4ef2d9ad --- /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 000000000..861e9fc63 --- /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 000000000..88e5061ff --- /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 000000000..2088a7416 --- /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 000000000..9938e090f --- /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/76] 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 f87959aa6..a73b0d5fa 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 47e7e268d..115e41b28 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 e90d4726b..3aa0548a0 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 020ffaac8..597a10cb9 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 6725b99d8..15630a3b7 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/76] 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 aa99943aa..d6c26c117 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 6ed61c594..b2a68d99c 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 a73b0d5fa..5a2ab509e 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 000000000..09a1feb7d --- /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 115e41b28..c4062dd09 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 3aa0548a0..bad2d32f1 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 000000000..09a1feb7d --- /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 597a10cb9..1c5816e2b 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 390d98114..f74fc1aee 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 c1a92c055..a74f18933 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 d6f015d47..1c9b23ac9 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 000000000..09a1feb7d --- /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/76] 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 5c2e32521..259625590 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 4cd3838f5..50301224d 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 a74f18933..9d61ea617 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/76] 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 da6fcb8d4..106bfcf3a 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 000000000..aee78a93a --- /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/76] 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 9d61ea617..f6833f47d 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 9b66fa9a7..9767e0cb3 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 000000000..ddf939af1 --- /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 d6b7ef32c..000000000 --- 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 000000000..3029d34e0 --- /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 fd28c786f..723322320 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 63a749f7a..a16a81a85 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 b3e1a7be2..0c7ccc220 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 63a749f7a..a16a81a85 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 c5c45259b..4d5496df0 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 63a749f7a..a16a81a85 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 9ae4052a0..0e57ee9f6 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 63a749f7a..a16a81a85 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 e74138958..5120d849c 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 63a749f7a..a16a81a85 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 000000000..11bdb4b87 --- /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 000000000..ddf939af1 --- /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 d6b7ef32c..000000000 --- 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 0dfad2c3b..000000000 --- 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 29b99fa3c..000000000 --- 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 ff2d51fb8..000000000 --- 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 000000000..33eafda0c --- /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 4dd79690f..d53b99c4a 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 0b7afcf06..add99d171 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 c537af29a..04ae4668b 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 5184f3051..916b99ce6 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 0b7afcf06..add99d171 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 00542bd87..68a63ea3a 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 40641e359..1535bd681 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 0b7afcf06..add99d171 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 a6a005cf2..acec4a60d 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 71e135666..c01c38b0f 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 0b7afcf06..add99d171 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 4f52806b6..c306eab11 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 c989043c7..42f1367e6 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 0b7afcf06..add99d171 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 b07dc632a..3b4561e83 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 627129f2d..41d0d7492 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 0b7afcf06..add99d171 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 bc7c6ae5e..68a4701b9 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/76] 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 f6833f47d..99c6335da 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 9767e0cb3..efeab15bb 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 1b4acf7c4..9e3df48cc 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 000000000..ddf939af1 --- /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 d6b7ef32c..000000000 --- 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 000000000..efe47a7d3 --- /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 68e1da7c6..ec8490a91 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 292875a04..000000000 --- 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 000000000..0fd3ef9ea --- /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 000000000..ddf939af1 --- /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 d6b7ef32c..000000000 --- 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 94ac5cfdb..000000000 --- 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 ea48fbadd..000000000 --- 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 2b619e9a8..000000000 --- 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 2c251a0cd..000000000 --- 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 000000000..c341723f1 --- /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 fa8c7e459..3d7e5fb7a 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 8feb261ca..7dadde2e8 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 c957a0a24..dd5d973ba 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 8feb261ca..7dadde2e8 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 15d70cbaa..66d08dba3 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 1bc451ea6..9c0124048 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 000000000..ddf939af1 --- /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 d6b7ef32c..000000000 --- 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 000000000..f1f7ac2f1 --- /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 7089ff113..d60ba7d53 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 05519c047..000000000 --- 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 be546a960..d1f9128c2 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 afd5e0595..000000000 --- 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 000000000..febd4f0ab --- /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 d6b7ef32c..000000000 --- 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 000000000..a54d0f787 --- /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 44fcad075..ede288d25 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 02cced14d..24e394d69 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 ca50c0821..f16f518a6 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 c70fac7c1..24fb4b60b 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 d74885b27..b50bf7fe4 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 dde3b6613..aa69a48b9 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 f857c4d14..531f4bd4e 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 a14d8566e..390308fd2 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 9b964de02..4e7df16eb 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 000000000..067d9346e --- /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 000000000..ddf939af1 --- /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 000000000..b08f886e6 --- /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 19aba6306..7cf902a8e 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 506824445..6fc89645d 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 59ac8532d..4872ecbd3 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 3bb4e4b2e..93c951856 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/76] 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 c306eab11..bbcde658e 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 3b4561e83..66ee7da3d 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/76] 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 d6c26c117..1e82d5278 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 000000000..65c0e4983 --- /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/76] 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 5cccfab45..555625e9b 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 02ca7f8e5..fd6bbf9b6 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 795008c04..46aed6131 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 006c87fbe..438cd6dc0 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 14a7d58bd..6e990be1b 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 fded077a2..06c0ddeac 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 4d2ee6a4d..6f2119fd3 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 23b402688..3ddc18ba0 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 ffc9a2ba7..27c6f2798 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 0f79fabe3..3bcff2b67 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 82d10e085..6472a8491 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 3b8b0876d..55014a58f 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 f597c6420..8278bb365 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 26536062d..ba7ae2552 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 2c015db0d..bde43050a 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 4dcbcf5d7..abd450728 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 5d3e478cb..a1e687910 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 0f1e4594a..56c23a214 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 37096edde..5d3d33a76 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 a18941192..a28402012 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/76] 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 1e82d5278..8573b6a1b 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 65c0e4983..f47e94415 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 8b35ff67d..08f015481 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 5d3d33a76..0620aec5d 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/76] 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 772e6cf9b..0825b3a63 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 9b2841e6d..7bea68945 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/76] 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 5a2ab509e..a009957d7 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 d7e03f065..907e0495c 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/76] 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 000000000..f47cb2045 --- /dev/null +++ b/regression/.gitignore @@ -0,0 +1 @@ +*.out diff --git a/regression/CMakeLists.txt b/regression/CMakeLists.txt index f47e94415..5082de2a0 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 aee78a93a..000000000 --- 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 0620aec5d..4951ab31f 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 0825b3a63..772e6cf9b 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 7bea68945..9b2841e6d 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 50301224d..16f7a946e 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/76] 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 205f7d315..000000000 --- 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 ce6da34e7..000000000 --- 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 793cb9a5d..000000000 --- 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 f653f758d..000000000 --- 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 41de09bba..000000000 --- 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 3e4bd7d7d..000000000 --- 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 78e3db367..000000000 --- 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 baec28d68..000000000 --- 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 8e0a0c95b..000000000 --- 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 44bf4f1cd..000000000 --- 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 d5550bb53..000000000 --- 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 c137e1ca1..000000000 --- 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 026c1f792..000000000 --- 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 2844870a9..000000000 --- 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 b87b4e712..000000000 --- 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 0bdc184cc..000000000 --- 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 43faf4664..000000000 --- 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 7ee2bbace..000000000 --- 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 fd8891cf2..000000000 --- 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 5cd2a2afe..000000000 --- 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 30f912c62..000000000 --- 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 be9d19d43..000000000 --- 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 793858716..000000000 --- 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 a25452385..000000000 --- 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 b8a308a4b..000000000 --- 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 4d43a04d6..000000000 --- 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 67f6bd6f2..000000000 --- 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 6821cee4f..000000000 --- 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 dce6f9926..000000000 --- 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 8bb4cb94d..000000000 --- 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 54477168e..000000000 --- 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 fe8a2dfc0..000000000 --- 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 d6929b8f0..000000000 --- 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 24f40107d..000000000 --- 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 d8af27696..000000000 --- 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 824585e36..000000000 --- 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 56ddd1f2c..000000000 --- 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 8c19f11a3..000000000 --- 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 1c9cf712c..000000000 --- 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 19a853e60..000000000 --- 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 81b129739..000000000 --- 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 e4ef2d9ad..000000000 --- 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 861e9fc63..000000000 --- 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 88e5061ff..000000000 --- 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 2088a7416..000000000 --- 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 9938e090f..000000000 --- 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/76] 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 f74fc1aee..6c3c28718 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/76] 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 1b57e9c1b..bf6e93788 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 f321c685a..6faa0def2 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 be9368ad6..b057c7202 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 99c6335da..d98eaaf33 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 6b2f64f11..85c24004c 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 b31bb218d..000000000 --- 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 8f02a738b..000000000 --- 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/76] 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 87864efe5..8ba2887da 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 87864efe5..8ba2887da 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 e2de8c9fe..5325a6ac2 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/76] 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 16f7a946e..6d1b8dfce 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/76] 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 000000000..1fb01a6d8 --- /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 52779c300..000000000 --- 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 6d1b8dfce..42bc2c246 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 d98eaaf33..9a1257bbe 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 8a73a74d3..e3ef43810 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/76] 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 0dd03dfb8..55494ee0c 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/76] 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 772e6cf9b..0825b3a63 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/76] 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 930264bc2..c7a300da6 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 130d66373c2a9764d75acc79302d3c3cd7a4e9af Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 14 Apr 2022 15:12:33 -0400 Subject: [PATCH 52/76] build cleanly --- modulefiles/modulefile.ProdGSI.hera.gnu | 51 ++++++ ...GSI.hera => modulefile.ProdGSI.hera.intel} | 0 ....wcoss_c => modulefile.ProdGSI.wcoss_cray} | 0 ...oss_d => modulefile.ProdGSI.wcoss_dell_p3} | 0 ush/build.sh | 58 +++++++ ush/build_all_cmake.sh | 154 ------------------ ush/detect_machine.sh | 117 +++++++++++++ ush/module-setup.sh | 123 ++++++++++++++ 8 files changed, 349 insertions(+), 154 deletions(-) create mode 100644 modulefiles/modulefile.ProdGSI.hera.gnu rename modulefiles/{modulefile.ProdGSI.hera => modulefile.ProdGSI.hera.intel} (100%) rename modulefiles/{modulefile.ProdGSI.wcoss_c => modulefile.ProdGSI.wcoss_cray} (100%) rename modulefiles/{modulefile.ProdGSI.wcoss_d => modulefile.ProdGSI.wcoss_dell_p3} (100%) create mode 100755 ush/build.sh delete mode 100755 ush/build_all_cmake.sh create mode 100755 ush/detect_machine.sh create mode 100755 ush/module-setup.sh diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu b/modulefiles/modulefile.ProdGSI.hera.gnu new file mode 100644 index 000000000..a46d9d4b4 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.hera.gnu @@ -0,0 +1,51 @@ +#%Module###################################################################### +# NOAA-EMC/GSI +#_____________________________________________________ +#proc ModulesHelp { } { +#puts stderr "Set environment variables for NOAA-EMC/GSI" +#puts stderr "This module initializes the environment " +#puts stderr "for the Intel Compiler Suite $version\n" +##} +#module-whatis " NOAA-EMC/GSI whatis description" + +setenv CRTM_FIX /scratch2/NCEPDEV/nwprod/NCEPLIBS/fix/crtm_v2.3.0 + +# Load cmake +module use -a /contrib/cmake/modulefiles +module load cmake/3.20.1 + +# Load hpc-stack +module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack +module load hpc/1.1.0 + +# Load GNU compiler and mpi +module load hpc-gnu/9.2.0 +module load hpc-mpich/3.3.2 + +# Load python +# Note: anaconda/2.3.0 requires intel be loaded prior to anaconda +module use -a /contrib/anaconda/modulefiles +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 +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.9.1 +module load bacio/2.4.1 +module load crtm/2.3.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.hera b/modulefiles/modulefile.ProdGSI.hera.intel similarity index 100% rename from modulefiles/modulefile.ProdGSI.hera rename to modulefiles/modulefile.ProdGSI.hera.intel diff --git a/modulefiles/modulefile.ProdGSI.wcoss_c b/modulefiles/modulefile.ProdGSI.wcoss_cray similarity index 100% rename from modulefiles/modulefile.ProdGSI.wcoss_c rename to modulefiles/modulefile.ProdGSI.wcoss_cray diff --git a/modulefiles/modulefile.ProdGSI.wcoss_d b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 similarity index 100% rename from modulefiles/modulefile.ProdGSI.wcoss_d rename to modulefiles/modulefile.ProdGSI.wcoss_dell_p3 diff --git a/ush/build.sh b/ush/build.sh new file mode 100755 index 000000000..48fbac9d9 --- /dev/null +++ b/ush/build.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -eu + +if [[ $(uname -s) == Darwin ]]; then + readonly DIR_ROOT=$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) +else + readonly DIR_ROOT=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) +fi + +BUILD_TYPE=${1:-${BUILD_TYPE:-"Release"}} +CMAKE_OPTS="${2:-${CMAKE_OPTS:-}}" +COMPILER=${3:-${COMPILER:-"intel"}} + +# Detect machine +source $DIR_ROOT/detect_machine.sh + +# Load modules +source $DIR_ROOT/ush/module-setup.sh +module use $DIR_ROOT/modulefiles +module load modulefile.ProdGSI.$MACHINE_ID +module list + +# Set CONTROLPATH variables for Regression testing on supported MACHINE_ID +if [[ $MACHINE_ID = wcoss ]] ; then + CONTROLPATH="/da/save/Michael.Lueken/svn1/build" +elif [[ $MACHINE_ID = wcoss_dell_p3 ]] ; then + CONTROLPATH="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build" +elif [[ $MACHINE_ID = hera.intel ]] ; then + CONTROLPATH="/scratch1/NCEPDEV/da/Michael.Lueken/svn1/build" +fi + +# Collect BUILD Options +CMAKE_OPTS+=" -DCMAKE_BUILD_TYPE=$BUILD_TYPE" + +# Install destination for built executables, libraries, CMake Package config +CMAKE_OPTS+=" -DCMAKE_INSTALL_PREFIX=$DIR_ROOT/install" + +# By default; build the Regional GSI and Global EnKF applications +CMAKE_OPTS+=" -DGSI_MODE=Regional -DENKF_MODE=GFS" + +# Build utilities +CMAKE_OPTS+=" -DBUILD_UTIL_COV_CALC=ON -DBUILD_UTIL_ENKF_GFS=ON -DBUILD_UTIL_EFSOIL=ON -DBUILD_UTIL_MON=ON" + +# Build regression test +[[ -n $CONTROLPATH ]] || CMAKE_OPTS+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=$CONTROLPATH" + +rm -rf $DIR_ROOT/build +mkdir -p $DIR_ROOT/build +cd $DIR_ROOT/build + +cmake $CMAKE_OPTS $DIR_ROOT + +make -j ${BUILD_JOBS:-8} VERBOSE=${BUILD_VERBOSE:-} + +make install + +exit diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh deleted file mode 100755 index 42bc2c246..000000000 --- a/ush/build_all_cmake.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/sh - -set -ex - -cd .. -pwd=$(pwd) - -build_type=${1:-'Release'} -dir_root=${2:-$pwd} -mode=${3:-'EMC'} - - -# If NCO build, prune directories and files before build -if [ $mode = NCO ]; then - cd $dir_root/ush - $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 - 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 -elif [[ -d /jetmon ]] ; then - . $MODULESHOME/init/sh - target=jet -elif [[ -d /glade ]] ; then - . $MODULESHOME/init/sh - target=cheyenne -elif [[ -d /sw/gaea ]] ; then - . /opt/cray/pe/modules/3.2.10.5/init/sh - target=gaea -elif [[ -d /discover ]] ; then -# . /opt/cray/pe/modules/3.2.10.5/init/sh - target=discover - build_type=0 - export SPACK_ROOT=/discover/nobackup/mapotts1/spack - export PATH=$PATH:$SPACK_ROOT/bin - . $SPACK_ROOT/share/spack/setup-env.sh -elif [[ -d /work ]]; then - . $MODULESHOME/init/sh - target=orion -elif [[ -d /lfs/h1 ]] ; then - target=acorn -else - echo "unknown target = $target" - exit 9 -fi -set -x - -dir_modules=$dir_root/modulefiles -if [ ! -d $dir_modules ]; then - echo "modulefiles does not exist in $dir_modules" - exit 10 -fi -[ -d $dir_root/exec ] || mkdir -p $dir_root/exec - -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 - module load modulefile.ProdGSI.$target -elif [ $target = wcoss -o $target = gaea ]; then - module purge - module load $dir_modules/modulefile.ProdGSI.$target -elif [ $target = hera -o $target = orion -o $target = s4 ]; then - module purge - module use $dir_modules - module load modulefile.ProdGSI.$target -elif [ $target = jet ]; then - module purge - module use $dir_modules - module load modulefile.ProdGSI.$target -elif [ $target = cheyenne ]; then - module purge - source $dir_modules/modulefile.ProdGSI.$target -elif [ $target = wcoss_c ]; then - module purge - module load $dir_modules/modulefile.ProdGSI.$target -elif [ $target = discover ]; then - module load $dir_modules/modulefile.ProdGSI.$target -elif [ $target = acorn ]; then - source /apps/prod/lmodules/startLmod - module use $dir_modules - module load modulefile.ProdGSI.$target -else - module purge - source $dir_modules/modulefile.ProdGSI.$target -fi -module list -set -x - -cmake_opts="${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 Regional GSI and Global EnKF applications -cmake_opts+=" -DGSI_MODE=Regional -DENKF_MODE=GFS" - -# Build utilities: -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:-}" - -cmake $cmake_opts $dir_root - -# Build apps. Echo extra printout for NCO build -if [ $mode = NCO ]; then - make VERBOSE=1 -j 8 -else - make -j 8 -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 -fi - -exit diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh new file mode 100755 index 000000000..4524687d6 --- /dev/null +++ b/ush/detect_machine.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +case $(hostname -f) in + + llogin1) MACHINE_ID=wcoss_c ;; ### luna + llogin2) MACHINE_ID=wcoss_c ;; ### luna + llogin3) MACHINE_ID=wcoss_c ;; ### luna + + slogin1) MACHINE_ID=wcoss_c ;; ### surge + slogin2) MACHINE_ID=wcoss_c ;; ### surge + slogin3) MACHINE_ID=wcoss_c ;; ### surge + + v71a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus + v71a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus + v71a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus + v72a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus + v72a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus + v72a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus + + m71a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + m71a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + m71a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + m72a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + m72a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + m72a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + + alogin01.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + alogin02.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + adecflow01.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + adecflow02.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + + gaea9) MACHINE_ID=gaea ;; ### gaea9 + gaea10) MACHINE_ID=gaea ;; ### gaea10 + gaea11) MACHINE_ID=gaea ;; ### gaea11 + gaea12) MACHINE_ID=gaea ;; ### gaea12 + gaea13) MACHINE_ID=gaea ;; ### gaea13 + gaea14) MACHINE_ID=gaea ;; ### gaea14 + gaea15) MACHINE_ID=gaea ;; ### gaea15 + gaea16) MACHINE_ID=gaea ;; ### gaea16 + gaea9.ncrc.gov) MACHINE_ID=gaea ;; ### gaea9 + gaea10.ncrc.gov) MACHINE_ID=gaea ;; ### gaea10 + gaea11.ncrc.gov) MACHINE_ID=gaea ;; ### gaea11 + gaea12.ncrc.gov) MACHINE_ID=gaea ;; ### gaea12 + gaea13.ncrc.gov) MACHINE_ID=gaea ;; ### gaea13 + gaea14.ncrc.gov) MACHINE_ID=gaea ;; ### gaea14 + gaea15.ncrc.gov) MACHINE_ID=gaea ;; ### gaea15 + gaea16.ncrc.gov) MACHINE_ID=gaea ;; ### gaea16 + + hfe01) MACHINE_ID=hera ;; ### hera01 + hfe02) MACHINE_ID=hera ;; ### hera02 + hfe03) MACHINE_ID=hera ;; ### hera03 + hfe04) MACHINE_ID=hera ;; ### hera04 + hfe05) MACHINE_ID=hera ;; ### hera05 + hfe06) MACHINE_ID=hera ;; ### hera06 + hfe07) MACHINE_ID=hera ;; ### hera07 + hfe08) MACHINE_ID=hera ;; ### hera08 + hfe09) MACHINE_ID=hera ;; ### hera09 + hfe10) MACHINE_ID=hera ;; ### hera10 + hfe11) MACHINE_ID=hera ;; ### hera11 + hfe12) MACHINE_ID=hera ;; ### hera12 + hecflow01) MACHINE_ID=hera ;; ### heraecflow01 + + s4-submit.ssec.wisc.edu) MACHINE_ID=s4 ;; ### s4 + + fe1) MACHINE_ID=jet ;; ### jet01 + fe2) MACHINE_ID=jet ;; ### jet02 + fe3) MACHINE_ID=jet ;; ### jet03 + fe4) MACHINE_ID=jet ;; ### jet04 + fe5) MACHINE_ID=jet ;; ### jet05 + fe6) MACHINE_ID=jet ;; ### jet06 + fe7) MACHINE_ID=jet ;; ### jet07 + fe8) MACHINE_ID=jet ;; ### jet08 + tfe1) MACHINE_ID=jet ;; ### jet09 + tfe2) MACHINE_ID=jet ;; ### jet10 + + Orion-login-1.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion1 + Orion-login-2.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion2 + Orion-login-3.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion3 + Orion-login-4.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion4 + + cheyenne1.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + cheyenne2.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne2 + cheyenne3.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne3 + cheyenne4.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne4 + cheyenne5.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne5 + cheyenne6.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne6 + cheyenne1.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + cheyenne2.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne2 + cheyenne3.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne3 + cheyenne4.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne4 + cheyenne5.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne5 + cheyenne6.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne6 + chadmin1.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + chadmin2.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + chadmin3.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + chadmin4.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + chadmin5.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + chadmin6.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + + login1.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede1 + login2.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede2 + login3.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede3 + login4.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede4 + + login01.expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1 + login02.expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse2 + + discover.nccs.nasa.gov) MACHINE_ID=discover ;; ### discover +esac + +# Overwrite auto-detect with RT_MACHINE if set +MACHINE_ID=${MACHINE:-${MACHINE_ID}} + +# Append compiler (only on machines that have multiple compilers) +if [ $MACHINE_ID = hera ]; then + MACHINE_ID=${MACHINE_ID}.${COMPILER} +fi diff --git a/ush/module-setup.sh b/ush/module-setup.sh new file mode 100755 index 000000000..433022cff --- /dev/null +++ b/ush/module-setup.sh @@ -0,0 +1,123 @@ +#!/bin/bash +set -eu + +if [[ $MACHINE_ID = jet* ]] ; then + # We are on NOAA Jet + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /apps/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = hera* ]] ; then + # We are on NOAA Hera + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /apps/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = orion* ]] ; then + # We are on Orion + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /apps/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = s4* ]] ; then + # We are on SSEC Wisconsin S4 + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /usr/share/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = wcoss_cray ]] ; then + # We are on NOAA Luna or Surge + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /opt/modules/default/init/bash + fi + module purge + # Workaround until module issues are fixed: + unset _LMFILES_ + unset LOADEDMODULES + module use /opt/modulefiles + module use /opt/cray/ari/modulefiles + module use /opt/cray/craype/default/alt-modulefiles + module use /opt/cray/alt-modulefiles + module use /gpfs/hps/nco/ops/nwprod/modulefiles + module use /gpfs/hps/nco/ops/nwprod/lib/modulefiles + module use /usrx/local/prod/modulefiles + +elif [[ $MACHINE_ID = wcoss_dell_p3 ]] ; then + # We are on NOAA Mars or Venus + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /usrx/local/prod/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = cheyenne* ]] ; then + # We are on NCAR Cheyenne + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /glade/u/apps/ch/modulefiles/default/localinit/localinit.sh + fi + module purge + +elif [[ $MACHINE_ID = stampede* ]] ; then + # We are on TACC Stampede + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /opt/apps/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = gaea* ]] ; then + # We are on GAEA. + if ( ! eval module help > /dev/null 2>&1 ) ; then + # We cannot simply load the module command. The GAEA + # /etc/profile modifies a number of module-related variables + # before loading the module command. Without those variables, + # the module command fails. Hence we actually have to source + # /etc/profile here. + source /etc/profile + __ms_source_etc_profile=yes + else + __ms_source_etc_profile=no + fi + module purge + # clean up after purge + unset _LMFILES_ + unset _LMFILES_000 + unset _LMFILES_001 + unset LOADEDMODULES + module load modules + if [[ -d /opt/cray/ari/modulefiles ]] ; then + module use -a /opt/cray/ari/modulefiles + fi + if [[ -d /opt/cray/pe/ari/modulefiles ]] ; then + module use -a /opt/cray/pe/ari/modulefiles + fi + if [[ -d /opt/cray/pe/craype/default/modulefiles ]] ; then + module use -a /opt/cray/pe/craype/default/modulefiles + fi + if [[ -s /etc/opt/cray/pe/admin-pe/site-config ]] ; then + source /etc/opt/cray/pe/admin-pe/site-config + fi + if [[ "$__ms_source_etc_profile" == yes ]] ; then + source /etc/profile + unset __ms_source_etc_profile + fi + +elif [[ $MACHINE_ID = expanse* ]]; then + # We are on SDSC Expanse + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /etc/profile.d/modules.sh + fi + module purge + module load slurm/expanse/20.02.3 + +elif [[ $MACHINE_ID = discover* ]]; then + # We are on NCCS discover + export SPACK_ROOT=/discover/nobackup/mapotts1/spack + export PATH=$PATH:$SPACK_ROOT/bin + . $SPACK_ROOT/share/spack/setup-env.sh + +else + echo WARNING: UNKNOWN PLATFORM 1>&2 +fi From 0949382c2cc200e5ce8c4c9245eadc23dc1e7880 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 15 Apr 2022 10:10:15 -0400 Subject: [PATCH 53/76] fix improper character array allocation in fv3reg --- src/enkf/CMakeLists.txt | 8 +++++++- src/enkf/gridio_fv3reg.f90 | 10 ++++++---- src/gsi/CMakeLists.txt | 8 +++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index a009957d7..907f0c2de 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -29,8 +29,14 @@ endif() option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +set(ENKF_VALID_MODES "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") +set_property(CACHE ENKF_MODE PROPERTY STRINGS ${ENKF_VALID_MODES}) + +# Ensure valid ENKF_MODE is selected +if(NOT ENKF_MODE IN_LIST ENKF_VALID_MODES) + message(FATAL_ERROR "ENKF_MODE must be one of ${ENKF_VALID_MODES}") +endif() # Echo user options message(STATUS "EnKF: OPENMP ................. ${OPENMP}") diff --git a/src/enkf/gridio_fv3reg.f90 b/src/enkf/gridio_fv3reg.f90 index c7a300da6..0b780b992 100644 --- a/src/enkf/gridio_fv3reg.f90 +++ b/src/enkf/gridio_fv3reg.f90 @@ -55,10 +55,12 @@ module gridio !------------------------------------------------------------------------- integer(i_kind) ,parameter:: ndynvarslist=6, ntracerslist=8 - 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, dimension(ndynvarslist) :: & + vardynvars = [character(len=max_varname_length) :: & + 'u', 'v', 'T', 'W', 'DZ', 'delp'] + character(len=max_varname_length), parameter, dimension(ntracerslist) :: & + vartracers = [character(len=max_varname_length) :: & + 'sphum','o3mr', 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc'] type type_fv3lamfile logical l_filecombined character(len=max_varname_length), dimension(2):: fv3lamfilename diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index bad2d32f1..6d1273a39 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -30,8 +30,14 @@ option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) option(USE_GSDCLOUD "Use GSD Cloud Analysis library" OFF) +set(GSI_VALID_MODES "GFS" "Regional") set(GSI_MODE "GFS" CACHE STRING "Choose the GSI Application.") -set_property(CACHE GSI_MODE PROPERTY STRINGS "GFS" "Regional") +set_property(CACHE GSI_MODE PROPERTY STRINGS ${GSI_VALID_MODES}) + +# Ensure valid GSI_MODE is selected +if(NOT GSI_MODE IN_LIST GSI_VALID_MODES) + message(FATAL_ERROR "GSI_MODE must be one of ${GSI_VALID_MODES}") +endif() # Echo user options message(STATUS "GSI: OPENMP ................. ${OPENMP}") From ec3b2f0d40c1a7f0476176630f64a9301e468395 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 15 Apr 2022 10:52:04 -0400 Subject: [PATCH 54/76] cleanup the build script to allow substantial user control --- .gitignore | 4 +++ modulefiles/modulefile.ProdGSI.hera.gnu | 13 ++----- ush/build.sh | 47 ++++++++++++++----------- ush/detect_machine.sh | 6 +++- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 052a014b7..6d3ff505a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ install*/ *.[aox] *.mod .DS_Store + +log* +build.log* +install.log* diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu b/modulefiles/modulefile.ProdGSI.hera.gnu index a46d9d4b4..c01b84580 100644 --- a/modulefiles/modulefile.ProdGSI.hera.gnu +++ b/modulefiles/modulefile.ProdGSI.hera.gnu @@ -22,10 +22,8 @@ module load hpc/1.1.0 module load hpc-gnu/9.2.0 module load hpc-mpich/3.3.2 -# Load python -# Note: anaconda/2.3.0 requires intel be loaded prior to anaconda -module use -a /contrib/anaconda/modulefiles -module load anaconda/2.3.0 +# Use Intel MKL +setenv MKLROOT "/apps/oneapi/mkl/2022.0.2" # Load production utilities module load prod_util/1.2.2 @@ -33,7 +31,7 @@ module load prod_util/1.2.2 module load netcdf/4.7.4 # Load nceplibs -module load bufr/11.4.0 +module load bufr/11.5.0 module load ip/3.3.3 module load nemsio/2.5.2 module load sfcio/1.4.1 @@ -44,8 +42,3 @@ module load bacio/2.4.1 module load crtm/2.3.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/ush/build.sh b/ush/build.sh index 48fbac9d9..f124fcef5 100755 --- a/ush/build.sh +++ b/ush/build.sh @@ -2,18 +2,22 @@ set -eu -if [[ $(uname -s) == Darwin ]]; then - readonly DIR_ROOT=$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) -else - readonly DIR_ROOT=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) -fi +# Get the root of the cloned GSI directory +readonly DIR_ROOT=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) + +# User Options +BUILD_TYPE=${BUILD_TYPE:-"Release"} +CMAKE_OPTS=${CMAKE_OPTS:-} +COMPILER=${COMPILER:-"intel"} +BUILD_DIR=${BUILD_DIR:-"${DIR_ROOT}/build"} +INSTALL_PREFIX=${INSTALL_PREFIX:-"${DIR_ROOT}/install"} +GSI_MODE=${GSI_MODE:-"Regional"} # By default build Regional GSI (for regression testing) +ENKF_MODE=${ENKF_MODE:-"GFS"} # By default build Global EnKF (for regression testing) -BUILD_TYPE=${1:-${BUILD_TYPE:-"Release"}} -CMAKE_OPTS="${2:-${CMAKE_OPTS:-}}" -COMPILER=${3:-${COMPILER:-"intel"}} +#==============================================================================# -# Detect machine -source $DIR_ROOT/detect_machine.sh +# Detect machine (sets MACHINE_ID) +source $DIR_ROOT/ush/detect_machine.sh # Load modules source $DIR_ROOT/ush/module-setup.sh @@ -34,25 +38,26 @@ fi CMAKE_OPTS+=" -DCMAKE_BUILD_TYPE=$BUILD_TYPE" # Install destination for built executables, libraries, CMake Package config -CMAKE_OPTS+=" -DCMAKE_INSTALL_PREFIX=$DIR_ROOT/install" +CMAKE_OPTS+=" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" -# By default; build the Regional GSI and Global EnKF applications -CMAKE_OPTS+=" -DGSI_MODE=Regional -DENKF_MODE=GFS" +# Configure for GSI and EnKF +CMAKE_OPTS+=" -DGSI_MODE=$GSI_MODE -DENKF_MODE=${ENKF_MODE}" # Build utilities -CMAKE_OPTS+=" -DBUILD_UTIL_COV_CALC=ON -DBUILD_UTIL_ENKF_GFS=ON -DBUILD_UTIL_EFSOIL=ON -DBUILD_UTIL_MON=ON" +CMAKE_OPTS+=" -DBUILD_UTIL_COV_CALC=ON -DBUILD_UTIL_ENKF_GFS=ON -DBUILD_UTIL_EFSOI=ON -DBUILD_UTIL_MON=ON" -# Build regression test -[[ -n $CONTROLPATH ]] || CMAKE_OPTS+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=$CONTROLPATH" +# Build regression test (on supported MACHINE_ID where CONTROLPATH exists) +[[ -n ${CONTROLPATH:-""} ]] && CMAKE_OPTS+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=$CONTROLPATH" -rm -rf $DIR_ROOT/build -mkdir -p $DIR_ROOT/build -cd $DIR_ROOT/build +# Re-use or create a new BUILD_DIR (Default: create new BUILD_DIR) +[[ ${BUILD_CLEAN:-"YES"} =~ [yYtT] ]] && rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR && cd $BUILD_DIR +# Configure, build, install +set -x cmake $CMAKE_OPTS $DIR_ROOT - make -j ${BUILD_JOBS:-8} VERBOSE=${BUILD_VERBOSE:-} - make install +set +x exit diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh index 4524687d6..bef443a3b 100755 --- a/ush/detect_machine.sh +++ b/ush/detect_machine.sh @@ -105,7 +105,11 @@ case $(hostname -f) in login01.expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1 login02.expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse2 - discover.nccs.nasa.gov) MACHINE_ID=discover ;; ### discover + discover31.prv.cube) MACHINE_ID=discover ;; ### discover + discover32.prv.cube) MACHINE_ID=discover ;; ### discover + discover33.prv.cube) MACHINE_ID=discover ;; ### discover + discover34.prv.cube) MACHINE_ID=discover ;; ### discover + discover35.prv.cube) MACHINE_ID=discover ;; ### discover esac # Overwrite auto-detect with RT_MACHINE if set From 8ad8f465e1f430c32455b9059126537d07ee2e62 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 16 Apr 2022 03:41:23 -0400 Subject: [PATCH 55/76] add wrapper for NCO build script. Address GFS adaptation for NCO requirement of "pruning" Add BUILD_UTIL_ALL option for convenience --- .gitignore | 1 + ush/build.sh | 8 ++-- ush/build_4nco_global.sh | 37 ++++++++++++++++++ ush/prune_4nco_global.sh | 8 ++-- util/CMakeLists.txt | 27 +++++++++++-- util/EnKF/CMakeLists.txt | 3 ++ util/EnKF/gfs/src/CMakeLists.txt | 67 ++++++++++++++++++++++++-------- 7 files changed, 124 insertions(+), 27 deletions(-) create mode 100755 ush/build_4nco_global.sh diff --git a/.gitignore b/.gitignore index 6d3ff505a..2fe2cc641 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ install*/ *.mod .DS_Store +nohup.out log* build.log* install.log* diff --git a/ush/build.sh b/ush/build.sh index f124fcef5..45b37a75e 100755 --- a/ush/build.sh +++ b/ush/build.sh @@ -13,6 +13,8 @@ BUILD_DIR=${BUILD_DIR:-"${DIR_ROOT}/build"} INSTALL_PREFIX=${INSTALL_PREFIX:-"${DIR_ROOT}/install"} GSI_MODE=${GSI_MODE:-"Regional"} # By default build Regional GSI (for regression testing) ENKF_MODE=${ENKF_MODE:-"GFS"} # By default build Global EnKF (for regression testing) +UTIL_OPTS=${UTIL_OPTS:-"-DBUILD_UTIL_ALL=ON"} # By default build all GFS utilities +REGRESSION_TESTS=${REGRESSION_TESTS:-"YES"} # Build regression test suite #==============================================================================# @@ -44,10 +46,10 @@ CMAKE_OPTS+=" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" CMAKE_OPTS+=" -DGSI_MODE=$GSI_MODE -DENKF_MODE=${ENKF_MODE}" # Build utilities -CMAKE_OPTS+=" -DBUILD_UTIL_COV_CALC=ON -DBUILD_UTIL_ENKF_GFS=ON -DBUILD_UTIL_EFSOI=ON -DBUILD_UTIL_MON=ON" +[[ -n ${UTIL_OPTS:-""} ]] && CMAKE_OPTS+=" $UTIL_OPTS" -# Build regression test (on supported MACHINE_ID where CONTROLPATH exists) -[[ -n ${CONTROLPATH:-""} ]] && CMAKE_OPTS+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=$CONTROLPATH" +# Build regression test suite (on supported MACHINE_ID where CONTROLPATH exists) +[[ ${REGRESSION_TESTS} =~ [yYtT] ]] && CMAKE_OPTS+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=${CONTROLPATH:-}" # Re-use or create a new BUILD_DIR (Default: create new BUILD_DIR) [[ ${BUILD_CLEAN:-"YES"} =~ [yYtT] ]] && rm -rf $BUILD_DIR diff --git a/ush/build_4nco_global.sh b/ush/build_4nco_global.sh new file mode 100755 index 000000000..9908c73c9 --- /dev/null +++ b/ush/build_4nco_global.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# This is a wrapper script for building the GFS version of GSI for NCO +# It sets the explicit values that are passed to the general build script + +set -eu + +# Get the root of the cloned GSI directory +readonly DIR_ROOT=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) + +# Set NCO explicit variables +export BUILD_TYPE="Release" +export BUILD_VERBOSE="YES" +export BUILD_DIR="$DIR_ROOT/build_4nco" +export INSTALL_PREFIX="$DIR_ROOT/install_4nco" + +export GSI_MODE="GFS" +export ENKF_MODE="GFS" +export REGRESSION_TESTS="NO" +export UTIL_OPTS="-DBUILD_UTIL_ENKF_GFS=ON" + +# Prune the directory structure per NCO liking +$DIR_ROOT/ush/prune_4nco_global.sh prune + +# Call the general build script from ush/build.sh +$DIR_ROOT/ush/build.sh +rc=$? +[[ $rc -ne 0 ]] && (echo "Error in build.sh; ABORT!"; exit $rc) + +# NCO "installs" binaries in $DIR_ROOT/exec +[[ -d $DIR_ROOT/exec ]] && rm -rf $DIR_ROOT/exec +mv $INSTALL_PREFIX/bin $DIR_ROOT/exec + +# Clean up build and install directories +#rm -rf $BUILD_DIR $INSTALL_PREFIX + +exit diff --git a/ush/prune_4nco_global.sh b/ush/prune_4nco_global.sh index 699064a61..5a1c7848f 100755 --- a/ush/prune_4nco_global.sh +++ b/ush/prune_4nco_global.sh @@ -34,8 +34,8 @@ fi # Set root directory -cd .. -topdir=$(pwd) +readonly topdir=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) +cd $topdir echo " " echo "Execute git $string in $topdir" @@ -107,7 +107,7 @@ done # Process ush directories and files cd $topdir/ush -rlist="build.comgsi EnKF com Get_Initial_Files gfs_truncate_enkf llsub para refactor_4nco_global run_arw rungsi sub" +rlist="build.comgsi Get_Initial_Files gfs_truncate_enkf llsub para refactor_4nco_global run_arw rungsi sub" for type in $rlist; do git $string ${type}* rc=$? @@ -128,7 +128,7 @@ done # Process util directories and files cd $topdir/util -rlist="Aero Analysis_Utilities Baseline Config Correlated_Obs DTC EFSOI FOV GEN_BE_V2.0 GMI_BUFR MODIS_AOD Misc NCEP NMC_Bkerror README Radar_Monitor Radiance_bias_correction_Utilities Radiance_Utilities Single_Observation bufr_tools global_angupdate gsienvreport.sh ndate python_utilities radar_process zero_biascoeff" +rlist="Aero Analysis_Utilities Baseline Config Correlated_Obs DTC EFSOI FOV GEN_BE_V2.0 GMI_BUFR MODIS_AOD Misc NCEP NMC_Bkerror README Radar_Monitor Radiance_bias_correction_Utilities Radiance_Utilities Single_Observation bufr_tools global_angupdate gsienvreport.sh python_utilities radar_process zero_biascoeff" for type in $rlist; do git $string ${type}* rc=$? diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 9a1257bbe..4a1a5e8de 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -30,6 +30,7 @@ option(OPENMP "Enable OpenMP Threading" OFF) option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) # Build options +option(BUILD_UTIL_ALL "Build all 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) @@ -39,6 +40,22 @@ 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_UTIL_BKGERR "Build Background Error Utilities" OFF) +option(BUILD_UTIL_ETC "Build Miscellaneous Utilities" OFF) + +# If building all utils, then force all options to ON +# Exception is BUILD_UTIL_ENKF_ARW, since it is incompatible with GSI_MODE=GFS +if (BUILD_UTIL_ALL) + set(BUILD_UTIL_AERODA ON CACHE BOOL "Build Aerosol DA utilities" FORCE) + set(BUILD_UTIL_COV_CALC ON CACHE BOOL "Build Correlated Observation Error Utility" FORCE) + set(BUILD_UTIL_EFSOI ON CACHE BOOL "Build EFSOI Utilities" FORCE) + set(BUILD_UTIL_ENKF_GFS ON CACHE BOOL "Build EnKF GFS Utilities" FORCE) + set(BUILD_UTIL_ENKF_ARW OFF CACHE BOOL "Build EnKF ARW Utilities" FORCE) + set(BUILD_UTIL_MON ON CACHE BOOL "Build Monitoring Utilities" FORCE) + set(BUILD_UTIL_NCIO ON CACHE BOOL "Build NetCDF IO Utilities" FORCE) + set(BUILD_UTIL_COM ON CACHE BOOL "Build community utilities" FORCE) + set(BUILD_UTIL_BKGERR ON CACHE BOOL "Build Background Error Utilities" FORCE) + set(BUILD_UTIL_ETC ON CACHE BOOL "Build Miscellaneous Utilities" FORCE) +endif() # Echo user options message(STATUS "Utils: OPENMP ................. ${OPENMP}") @@ -52,6 +69,7 @@ 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_UTIL_BKGERR ...... ${BUILD_UTIL_BKGERR}") +message(STATUS "Utils: BUILD_UTIL_ETC ......... ${BUILD_UTIL_ETC}") # Dependencies if(ENABLE_MKL) @@ -135,10 +153,11 @@ if(BUILD_UTIL_MON) add_subdirectory(Radiance_Monitor) endif() -# These don't fall into any category -add_subdirectory(FOV_utilities) -add_subdirectory(Single_Observation) -add_subdirectory(zero_biascoeff) +if(BUILD_UTIL_ETC) + add_subdirectory(FOV_utilities) + add_subdirectory(Single_Observation) + add_subdirectory(zero_biascoeff) +endif() # These utilities do not have CMake builds and are unlikely used or usable #add_subdirectory(Config) diff --git a/util/EnKF/CMakeLists.txt b/util/EnKF/CMakeLists.txt index e3ef43810..69aed1b9f 100644 --- a/util/EnKF/CMakeLists.txt +++ b/util/EnKF/CMakeLists.txt @@ -1,7 +1,10 @@ +# No utility code here depends on the GSI library if(BUILD_UTIL_ENKF_GFS) add_subdirectory(gfs) endif() +# Utility code here depends on the GSI library +# Specifically GSI_MODE=Regional if(BUILD_UTIL_ENKF_ARW) if(NOT TARGET gsi) if(NOT gsi_FOUND) diff --git a/util/EnKF/gfs/src/CMakeLists.txt b/util/EnKF/gfs/src/CMakeLists.txt index f656e1827..94298fab4 100644 --- a/util/EnKF/gfs/src/CMakeLists.txt +++ b/util/EnKF/gfs/src/CMakeLists.txt @@ -1,19 +1,54 @@ -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) +# The GFS group "prunes" before building for Ops. +# These checks ensure the build does not fail when directories are missing. +# Some of these utilities are deprecated and should be removed. +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/adderrspec.fd) + add_subdirectory(adderrspec.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/adjustps.fd) + add_subdirectory(adjustps.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_ens.fd) + add_subdirectory(calc_increment_ens.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_ens_ncio.fd) + add_subdirectory(calc_increment_ens_ncio.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_ncio.fd) + add_subdirectory(calc_increment_ncio.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_serial.fd) + add_subdirectory(calc_increment_serial.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getnstensmeanp.fd) + add_subdirectory(getnstensmeanp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsfcensmeanp.fd) + add_subdirectory(getsfcensmeanp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsfcnstensupdp.fd) + add_subdirectory(getsfcnstensupdp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsigensmeanp_smooth.fd) + add_subdirectory(getsigensmeanp_smooth.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsigensstatp.fd) + add_subdirectory(getsigensstatp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gribmean.fd) + add_subdirectory(gribmean.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recenterens_ncio.fd) + add_subdirectory(recenterens_ncio.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recenterncio_hybgain.fd) + add_subdirectory(recenterncio_hybgain.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recenternemsiop_hybgain.fd) + add_subdirectory(recenternemsiop_hybgain.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recentersigp.fd) + add_subdirectory(recentersigp.fd) +endif() # This code is outdated #add_subdirectory(preproc) From a485320b2b1d984129be05516fae0ec3d708b160 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Sat, 16 Apr 2022 03:47:01 -0400 Subject: [PATCH 56/76] update INSTALL.md to add BUILD_UTIL_ALL option --- .gitignore | 1 + INSTALL.md | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2fe2cc641..69d5565ea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ install*/ *.[aox] *.mod .DS_Store +exec/ nohup.out log* diff --git a/INSTALL.md b/INSTALL.md index 1fb01a6d8..3e573c9ef 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -83,6 +83,7 @@ CMake allows for various options that can be specified on the command line via ` | `BUILD_ENKF` | Build EnKF library and executable (`ON`) | | `BUILD_REG_TESTING` | Enable Regression Testing (`ON`) | | `BUILD_UTIL` | Build Utilities (`ON`) | +| `BUILD_UTIL_ALL` | Build All Utilities (`OFF`) | | `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`) | @@ -90,8 +91,9 @@ CMake allows for various options that can be specified on the command line via ` | `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_COM` | Build Miscellaneous community utilities (`OFF`) | | `BUILD_UTIL_BKGERR` | Build Background Error utility (`OFF`) | +| `BUILD_UTIL_ETC` | Build Miscellaneous utilities (`OFF`) | The flavor of GSI and EnKF can be defined with the use of the following options: From f13c3adbb6281798e9b7ac193ab7483fb8e56f7b Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 18 Apr 2022 11:20:20 -0400 Subject: [PATCH 57/76] trap pruning error --- ush/build_4nco_global.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ush/build_4nco_global.sh b/ush/build_4nco_global.sh index 9908c73c9..03569d024 100755 --- a/ush/build_4nco_global.sh +++ b/ush/build_4nco_global.sh @@ -21,6 +21,8 @@ export UTIL_OPTS="-DBUILD_UTIL_ENKF_GFS=ON" # Prune the directory structure per NCO liking $DIR_ROOT/ush/prune_4nco_global.sh prune +rc=$? +[[ $rc -ne 0 ]] && (echo "Error in prune_4nco_global.sh; ABORT!"; exit $rc) # Call the general build script from ush/build.sh $DIR_ROOT/ush/build.sh @@ -32,6 +34,6 @@ rc=$? mv $INSTALL_PREFIX/bin $DIR_ROOT/exec # Clean up build and install directories -#rm -rf $BUILD_DIR $INSTALL_PREFIX +rm -rf $BUILD_DIR $INSTALL_PREFIX exit From 4414236f0a744f5fb84cf55206fe16bf2abd5df7 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 21 Apr 2022 12:59:43 -0400 Subject: [PATCH 58/76] fix the error with machine_id for cray and dell --- ush/detect_machine.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh index bef443a3b..72f43a238 100755 --- a/ush/detect_machine.sh +++ b/ush/detect_machine.sh @@ -2,27 +2,27 @@ case $(hostname -f) in - llogin1) MACHINE_ID=wcoss_c ;; ### luna - llogin2) MACHINE_ID=wcoss_c ;; ### luna - llogin3) MACHINE_ID=wcoss_c ;; ### luna - - slogin1) MACHINE_ID=wcoss_c ;; ### surge - slogin2) MACHINE_ID=wcoss_c ;; ### surge - slogin3) MACHINE_ID=wcoss_c ;; ### surge - - v71a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus - v71a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus - v71a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus - v72a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus - v72a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus - v72a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### venus - - m71a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars - m71a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars - m71a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars - m72a1.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars - m72a2.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars - m72a3.ncep.noaa.gov) MACHINE_ID=wcoss_d ;; ### mars + llogin1) MACHINE_ID=wcoss_cray ;; ### luna + llogin2) MACHINE_ID=wcoss_cray ;; ### luna + llogin3) MACHINE_ID=wcoss_cray ;; ### luna + + slogin1) MACHINE_ID=wcoss_cray ;; ### surge + slogin2) MACHINE_ID=wcoss_cray ;; ### surge + slogin3) MACHINE_ID=wcoss_cray ;; ### surge + + v71a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + v71a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + v71a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + v72a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + v72a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + v72a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + + m71a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + m71a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + m71a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + m72a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + m72a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + m72a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars alogin01.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn alogin02.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn From fa9d3dbb4694bc867de55569ba89321ff40e4440 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 21 Apr 2022 13:45:19 -0400 Subject: [PATCH 59/76] fix the error with machine_id for cray and dell --- ush/sub_wcoss_c | 2 +- ush/sub_wcoss_d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ush/sub_wcoss_c b/ush/sub_wcoss_c index d41dc7e78..831e0a10f 100755 --- a/ush/sub_wcoss_c +++ b/ush/sub_wcoss_c @@ -263,7 +263,7 @@ else fi echo "module purge" >> $cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.wcoss_c" >> $cfile +echo "module load modulefile.ProdGSI.wcoss_cray" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/ush/sub_wcoss_d b/ush/sub_wcoss_d index 9390f971c..818f0d6a0 100755 --- a/ush/sub_wcoss_d +++ b/ush/sub_wcoss_d @@ -312,7 +312,7 @@ echo "" >>$cfile echo ". $MODULESHOME/init/bash" >> $cfile echo "module purge" >> $cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.wcoss_d" >> $cfile +echo "module load modulefile.ProdGSI.wcoss_dell_p3" >> $cfile echo "module list" >> $cfile echo "" >>$cfile From 0f07820024874cf586dac63ec30bfbf5c56a7af3 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 25 Apr 2022 11:27:09 -0400 Subject: [PATCH 60/76] update cmake version in orion modulefile --- modulefiles/modulefile.ProdGSI.orion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modulefiles/modulefile.ProdGSI.orion b/modulefiles/modulefile.ProdGSI.orion index 921ac2b9f..5b65c80b9 100644 --- a/modulefiles/modulefile.ProdGSI.orion +++ b/modulefiles/modulefile.ProdGSI.orion @@ -11,7 +11,7 @@ setenv CRTM_FIX /apps/contrib/NCEPLIBS/orion/fix/crtm_v2.3.0 # Load cmake -module load cmake/3.17.3 +module load cmake/3.22.1 # Load python module load python/3.7.5 From d43e359a576b76fc2f50e636039bbd956ad56f59 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 26 Apr 2022 16:12:25 -0400 Subject: [PATCH 61/76] update ncio to v1.1.0 --- modulefiles/modulefile.ProdGSI.hera.gnu | 2 +- modulefiles/modulefile.ProdGSI.hera.intel | 2 +- modulefiles/modulefile.ProdGSI.jet | 2 +- modulefiles/modulefile.ProdGSI.orion | 3 +-- modulefiles/modulefile.ProdGSI.s4 | 2 +- modulefiles/modulefile.ProdGSI.wcoss_dell_p3 | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu b/modulefiles/modulefile.ProdGSI.hera.gnu index c01b84580..0c3c7cba4 100644 --- a/modulefiles/modulefile.ProdGSI.hera.gnu +++ b/modulefiles/modulefile.ProdGSI.hera.gnu @@ -41,4 +41,4 @@ module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 module load wrf_io/1.2.0 -module load ncio/1.0.0 +module load ncio/1.1.0 diff --git a/modulefiles/modulefile.ProdGSI.hera.intel b/modulefiles/modulefile.ProdGSI.hera.intel index b2a68d99c..48735412a 100644 --- a/modulefiles/modulefile.ProdGSI.hera.intel +++ b/modulefiles/modulefile.ProdGSI.hera.intel @@ -43,7 +43,7 @@ module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 module load wrf_io/1.2.0 -module load ncio/1.0.0 +module load ncio/1.1.0 # Compiler flags specific to this platform setenv CFLAGS "-xHOST" diff --git a/modulefiles/modulefile.ProdGSI.jet b/modulefiles/modulefile.ProdGSI.jet index 0152f5112..c8a214626 100644 --- a/modulefiles/modulefile.ProdGSI.jet +++ b/modulefiles/modulefile.ProdGSI.jet @@ -43,7 +43,7 @@ module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 module load wrf_io/1.2.0 -module load ncio/1.0.0 +module load ncio/1.1.0 # Compiler flags specific to this platform setenv CFLAGS "-axSSE4.2,AVX,CORE-AVX2" diff --git a/modulefiles/modulefile.ProdGSI.orion b/modulefiles/modulefile.ProdGSI.orion index 5b65c80b9..575783785 100644 --- a/modulefiles/modulefile.ProdGSI.orion +++ b/modulefiles/modulefile.ProdGSI.orion @@ -47,9 +47,8 @@ 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 ncio/1.0.0 +module load ncio/1.1.0 module load wrf_io/1.2.0 -module load ncio/1.0.0 # Compiler flags specific to this platform setenv CFLAGS "-xHOST" diff --git a/modulefiles/modulefile.ProdGSI.s4 b/modulefiles/modulefile.ProdGSI.s4 index ff89074d2..4b0e35d2b 100644 --- a/modulefiles/modulefile.ProdGSI.s4 +++ b/modulefiles/modulefile.ProdGSI.s4 @@ -30,7 +30,7 @@ module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 module load wrf_io/1.2.0 -module load ncio/1.0.0 +module load ncio/1.1.0 # Compiler flags specific to this platform setenv CFLAGS "-march=ivybridge" diff --git a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 index 259625590..9dfd2cbb3 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 +++ b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 @@ -48,7 +48,7 @@ module load sigio/2.3.2 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 +module load ncio/1.1.0 # Load production utilities module load prod_util/1.2.2 From 75149d0cc5c143356c6e7fbadd77dba4d28ad7ee Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 26 Apr 2022 17:51:06 -0400 Subject: [PATCH 62/76] consolidate common modulefiles in a modulefile.ProdGSI.common --- modulefiles/modulefile.ProdGSI.common | 44 ++++++++++++++++++++ modulefiles/modulefile.ProdGSI.hera.gnu | 19 +-------- modulefiles/modulefile.ProdGSI.hera.intel | 19 +-------- modulefiles/modulefile.ProdGSI.jet | 19 +-------- modulefiles/modulefile.ProdGSI.orion | 19 +-------- modulefiles/modulefile.ProdGSI.s4 | 19 +-------- modulefiles/modulefile.ProdGSI.wcoss_dell_p3 | 21 +--------- 7 files changed, 56 insertions(+), 104 deletions(-) create mode 100644 modulefiles/modulefile.ProdGSI.common diff --git a/modulefiles/modulefile.ProdGSI.common b/modulefiles/modulefile.ProdGSI.common new file mode 100644 index 000000000..0c3c7cba4 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.common @@ -0,0 +1,44 @@ +#%Module###################################################################### +# NOAA-EMC/GSI +#_____________________________________________________ +#proc ModulesHelp { } { +#puts stderr "Set environment variables for NOAA-EMC/GSI" +#puts stderr "This module initializes the environment " +#puts stderr "for the Intel Compiler Suite $version\n" +##} +#module-whatis " NOAA-EMC/GSI whatis description" + +setenv CRTM_FIX /scratch2/NCEPDEV/nwprod/NCEPLIBS/fix/crtm_v2.3.0 + +# Load cmake +module use -a /contrib/cmake/modulefiles +module load cmake/3.20.1 + +# Load hpc-stack +module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack +module load hpc/1.1.0 + +# Load GNU compiler and mpi +module load hpc-gnu/9.2.0 +module load hpc-mpich/3.3.2 + +# Use Intel MKL +setenv MKLROOT "/apps/oneapi/mkl/2022.0.2" + +# Load production utilities +module load prod_util/1.2.2 + +module load netcdf/4.7.4 + +# Load nceplibs +module load bufr/11.5.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.9.1 +module load bacio/2.4.1 +module load crtm/2.3.0 +module load wrf_io/1.2.0 +module load ncio/1.1.0 diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu b/modulefiles/modulefile.ProdGSI.hera.gnu index 0c3c7cba4..90de3a8e3 100644 --- a/modulefiles/modulefile.ProdGSI.hera.gnu +++ b/modulefiles/modulefile.ProdGSI.hera.gnu @@ -25,20 +25,5 @@ module load hpc-mpich/3.3.2 # Use Intel MKL setenv MKLROOT "/apps/oneapi/mkl/2022.0.2" -# Load production utilities -module load prod_util/1.2.2 - -module load netcdf/4.7.4 - -# Load nceplibs -module load bufr/11.5.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.9.1 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load wrf_io/1.2.0 -module load ncio/1.1.0 +# Load the dependency libraries +module load modulefile.ProdGSI.common diff --git a/modulefiles/modulefile.ProdGSI.hera.intel b/modulefiles/modulefile.ProdGSI.hera.intel index 48735412a..193237c88 100644 --- a/modulefiles/modulefile.ProdGSI.hera.intel +++ b/modulefiles/modulefile.ProdGSI.hera.intel @@ -27,23 +27,8 @@ module load hpc-impi/2018.0.4 module use -a /contrib/anaconda/modulefiles 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 -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.9.1 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load wrf_io/1.2.0 -module load ncio/1.1.0 +# Load the dependency libraries +module load modulefile.ProdGSI.common # Compiler flags specific to this platform setenv CFLAGS "-xHOST" diff --git a/modulefiles/modulefile.ProdGSI.jet b/modulefiles/modulefile.ProdGSI.jet index c8a214626..7b58643ff 100644 --- a/modulefiles/modulefile.ProdGSI.jet +++ b/modulefiles/modulefile.ProdGSI.jet @@ -27,23 +27,8 @@ module load hpc/1.1.0 module load hpc-intel/18.0.5.274 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 -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.9.1 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load wrf_io/1.2.0 -module load ncio/1.1.0 +# Load the dependency libraries +module load modulefile.ProdGSI.common # Compiler flags specific to this platform setenv CFLAGS "-axSSE4.2,AVX,CORE-AVX2" diff --git a/modulefiles/modulefile.ProdGSI.orion b/modulefiles/modulefile.ProdGSI.orion index 575783785..dd623209e 100644 --- a/modulefiles/modulefile.ProdGSI.orion +++ b/modulefiles/modulefile.ProdGSI.orion @@ -32,23 +32,8 @@ module unload mkl/2020.2 module load mkl/2018.4 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 -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.9.1 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load ncio/1.1.0 -module load wrf_io/1.2.0 +# Load the dependency libraries +module load modulefile.ProdGSI.common # Compiler flags specific to this platform setenv CFLAGS "-xHOST" diff --git a/modulefiles/modulefile.ProdGSI.s4 b/modulefiles/modulefile.ProdGSI.s4 index 4b0e35d2b..4ae823bac 100644 --- a/modulefiles/modulefile.ProdGSI.s4 +++ b/modulefiles/modulefile.ProdGSI.s4 @@ -14,23 +14,8 @@ module load hpc-impi/18.0.4 # Load python 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 -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.9.1 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load wrf_io/1.2.0 -module load ncio/1.1.0 +# Load the dependency libraries +module load modulefile.ProdGSI.common # Compiler flags specific to this platform setenv CFLAGS "-march=ivybridge" diff --git a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 index 9dfd2cbb3..66fe764a0 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 +++ b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 @@ -33,25 +33,8 @@ 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 -module load bacio/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 sp/2.3.3 -module load sigio/2.3.2 -module load w3emc/2.9.1 -module load crtm/2.3.0 -module load wrf_io/1.2.0 -module load ncio/1.1.0 - -# Load production utilities -module load prod_util/1.2.2 +# Load the dependency libraries +module load modulefile.ProdGSI.common # Compiler flags specific to this platform setenv CFLAGS "-xHOST" From 051fcdcaf967469b7f4a4950f994e6776c6d0142 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 26 Apr 2022 19:04:19 -0400 Subject: [PATCH 63/76] add intel and gnu modulefiles for Cheyenne from Chris Harrop --- modulefiles/modulefile.ProdGSI.cheyenne | 20 ------------- modulefiles/modulefile.ProdGSI.cheyenne.gnu | 27 +++++++++++++++++ modulefiles/modulefile.ProdGSI.cheyenne.intel | 30 +++++++++++++++++++ ush/detect_machine.sh | 2 +- 4 files changed, 58 insertions(+), 21 deletions(-) delete mode 100644 modulefiles/modulefile.ProdGSI.cheyenne create mode 100644 modulefiles/modulefile.ProdGSI.cheyenne.gnu create mode 100644 modulefiles/modulefile.ProdGSI.cheyenne.intel diff --git a/modulefiles/modulefile.ProdGSI.cheyenne b/modulefiles/modulefile.ProdGSI.cheyenne deleted file mode 100644 index 430f4fd7d..000000000 --- a/modulefiles/modulefile.ProdGSI.cheyenne +++ /dev/null @@ -1,20 +0,0 @@ -#%Module###################################################################### -## Mark.Potts@noaa.gov -## NOAA/NWS/NCEP/EMC -## NOAA-EMC/GSI -##_____________________________________________________ - -module purge -module load ncarenv/1.2 -module load cmake/3.9.1 -module load intel/18.0.1 -module load impi/2018.1.163 -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.cheyenne.gnu b/modulefiles/modulefile.ProdGSI.cheyenne.gnu new file mode 100644 index 000000000..31ba3d0fa --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.cheyenne.gnu @@ -0,0 +1,27 @@ +#%Module###################################################################### +# NOAA-EMC/GSI +#_____________________________________________________ +#proc ModulesHelp { } { +#puts stderr "Set environment variables for NOAA-EMC/GSI" +#puts stderr "This module initializes the environment " +#puts stderr "for the Intel Compiler Suite $version\n" +##} +#module-whatis " NOAA-EMC/GSI whatis description" + +module load cmake/3.22.0 +module load python/3.7.9 +module load ncarenv/1.3 +module load gnu/10.1.0 +module load mpt/2.22 +module load ncarcompilers/0.5.0 +module unload netcdf + +module use /glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack +module load hpc/1.2.0 +module load hpc-gnu/10.1.0 +module load hpc-mpt/2.22 + +setenv MKLROOT /glade/u/apps/opt/intel/2021.2/mkl/latest + +module load modulefile.ProdGSI.common + diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.intel b/modulefiles/modulefile.ProdGSI.cheyenne.intel new file mode 100644 index 000000000..0bb8f30fd --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.cheyenne.intel @@ -0,0 +1,30 @@ +#%Module###################################################################### +# NOAA-EMC/GSI +#_____________________________________________________ +#proc ModulesHelp { } { +#puts stderr "Set environment variables for NOAA-EMC/GSI" +#puts stderr "This module initializes the environment " +#puts stderr "for the Intel Compiler Suite $version\n" +##} +#module-whatis " NOAA-EMC/GSI whatis description" + + +module load cmake/3.22.0 +module load python/3.7.9 +module load ncarenv/1.3 +module load intel/2021.2 +module load mpt/2.22 +module load ncarcompilers/0.5.0 + +module use /glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack +module load hpc/1.2.0 +module load hpc-intel/2021.2 +module load hpc-mpt/2.22 +module load mkl/2021.2 + +module load modulefile.ProdGSI.common + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh index 72f43a238..f1e8df8a5 100755 --- a/ush/detect_machine.sh +++ b/ush/detect_machine.sh @@ -116,6 +116,6 @@ esac MACHINE_ID=${MACHINE:-${MACHINE_ID}} # Append compiler (only on machines that have multiple compilers) -if [ $MACHINE_ID = hera ]; then +if [ $MACHINE_ID = hera ] || [ $MACHINE_ID = cheyenne ]; then MACHINE_ID=${MACHINE_ID}.${COMPILER} fi From 60b0bc463f82910ba3a2623bfa94e78fe48c5cc0 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 26 Apr 2022 19:19:08 -0400 Subject: [PATCH 64/76] retain only common modules in modulefile.ProdGSI.common; --- modulefiles/modulefile.ProdGSI.common | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.common b/modulefiles/modulefile.ProdGSI.common index 0c3c7cba4..651b9ef6f 100644 --- a/modulefiles/modulefile.ProdGSI.common +++ b/modulefiles/modulefile.ProdGSI.common @@ -1,30 +1,3 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -setenv CRTM_FIX /scratch2/NCEPDEV/nwprod/NCEPLIBS/fix/crtm_v2.3.0 - -# Load cmake -module use -a /contrib/cmake/modulefiles -module load cmake/3.20.1 - -# Load hpc-stack -module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load GNU compiler and mpi -module load hpc-gnu/9.2.0 -module load hpc-mpich/3.3.2 - -# Use Intel MKL -setenv MKLROOT "/apps/oneapi/mkl/2022.0.2" - # Load production utilities module load prod_util/1.2.2 From 4d13aa3356ba9ab39f36cd9f55af886995164258 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 26 Apr 2022 22:20:35 -0400 Subject: [PATCH 65/76] add missing #%Module in the common modulefile --- modulefiles/modulefile.ProdGSI.common | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modulefiles/modulefile.ProdGSI.common b/modulefiles/modulefile.ProdGSI.common index 651b9ef6f..9d48d01b7 100644 --- a/modulefiles/modulefile.ProdGSI.common +++ b/modulefiles/modulefile.ProdGSI.common @@ -1,3 +1,5 @@ +#%Module + # Load production utilities module load prod_util/1.2.2 From d30dc95992d1bb3e8ab7dca85910039a3a398914 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 27 Apr 2022 11:35:34 -0400 Subject: [PATCH 66/76] revert back to ncio/1.0.0 --- modulefiles/modulefile.ProdGSI.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modulefiles/modulefile.ProdGSI.common b/modulefiles/modulefile.ProdGSI.common index 651b9ef6f..1b03cd825 100644 --- a/modulefiles/modulefile.ProdGSI.common +++ b/modulefiles/modulefile.ProdGSI.common @@ -14,4 +14,4 @@ module load w3emc/2.9.1 module load bacio/2.4.1 module load crtm/2.3.0 module load wrf_io/1.2.0 -module load ncio/1.1.0 +module load ncio/1.0.0 From 71ceb08f1c8c19895bc8732f8eb03ba3fc2bb1f4 Mon Sep 17 00:00:00 2001 From: Christopher Harrop <35781497+christopherwharrop-noaa@users.noreply.github.com> Date: Wed, 27 Apr 2022 15:44:30 -0600 Subject: [PATCH 67/76] Fixes for Cheyenne and Jet (#5) * Fix duplicate MPI definitions in EFSOI exposed by Cheyenne build Set CC, FC, CXX explicitly for Cheyenne GNU to avoid use of incorrect MPI module. Update w3emc to version 2.9.2. * Fix MPI API call bug that passed mpi_status type instead of a status variable * Revert version of w3emc and update cmake version for Jet --- modulefiles/modulefile.ProdGSI.cheyenne.gnu | 3 +++ modulefiles/modulefile.ProdGSI.jet | 2 +- util/EFSOI_Utilities/src/efsoi.f90 | 9 +++++---- util/EFSOI_Utilities/src/efsoi_main.f90 | 4 ++-- util/EFSOI_Utilities/src/loadbal_efsoi.f90 | 6 ++++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.gnu b/modulefiles/modulefile.ProdGSI.cheyenne.gnu index 31ba3d0fa..7cb59ccbf 100644 --- a/modulefiles/modulefile.ProdGSI.cheyenne.gnu +++ b/modulefiles/modulefile.ProdGSI.cheyenne.gnu @@ -25,3 +25,6 @@ setenv MKLROOT /glade/u/apps/opt/intel/2021.2/mkl/latest module load modulefile.ProdGSI.common +setenv CC mpicc +setenv FC mpif90 +setenv CXX mpicxx diff --git a/modulefiles/modulefile.ProdGSI.jet b/modulefiles/modulefile.ProdGSI.jet index 7b58643ff..db6940b0b 100644 --- a/modulefiles/modulefile.ProdGSI.jet +++ b/modulefiles/modulefile.ProdGSI.jet @@ -13,7 +13,7 @@ setenv CRTM_FIX /lfs4/HFIP/hfv3gfs/glopara/crtm_v2.3.0 # Load cmake -module load cmake/3.16.1 +module load cmake/3.20.1 # Load python module use /contrib/anaconda/modulefiles diff --git a/util/EFSOI_Utilities/src/efsoi.f90 b/util/EFSOI_Utilities/src/efsoi.f90 index 8dbf386ef..4565eb8a0 100644 --- a/util/EFSOI_Utilities/src/efsoi.f90 +++ b/util/EFSOI_Utilities/src/efsoi.f90 @@ -33,9 +33,10 @@ module efsoi ! !$$$ -use mpisetup +use mpi +use mpisetup, only: nproc, numproc, mpi_realkind use covlocal, only: taper -use kinds, only: r_double, i_kind, r_kind +use kinds, only: r_single, r_double, i_kind, r_kind use kdtree2_module, only: kdtree2_r_nearest, kdtree2_result use loadbal_efsoi, only: numptsperproc, indxproc, lnp_chunk, kdtree_grid, & iprocob, indxob_chunk, anal_obchunk_prior, numobsperproc, & @@ -76,7 +77,7 @@ subroutine efsoi_update() integer(i_kind) :: nnpt, nsame, nskip, ngrd1 integer(i_kind) :: ierr logical :: kdgrid - +integer status(MPI_STATUS_SIZE) if (.not. constants_initialized) then print *,'constants not initialized (with init_constants, init_constants_derived)' @@ -304,7 +305,7 @@ subroutine efsoi_update() allocate(buffertmp(nanals,nobs_max)) do np=1,numproc-1 call mpi_recv(buffertmp,numobsperproc(np+1)*nanals,mpi_real4,np, & - 1,mpi_comm_world,mpi_status,ierr) + 1,mpi_comm_world,status,ierr) do nob1=1,numobsperproc(np+1) nob2 = indxproc_obs(np+1,nob1) anal_ob_post(:,nob2) = buffertmp(:,nob1) diff --git a/util/EFSOI_Utilities/src/efsoi_main.f90 b/util/EFSOI_Utilities/src/efsoi_main.f90 index e4e630744..6482f4c94 100644 --- a/util/EFSOI_Utilities/src/efsoi_main.f90 +++ b/util/EFSOI_Utilities/src/efsoi_main.f90 @@ -57,8 +57,8 @@ program efsoi_main ! applying enkf namelist apparatus use params, only : read_namelist,nanals ! mpi functions and variables. - use mpisetup, only: mpi_initialize, mpi_initialize_io, mpi_cleanup, nproc, & - mpi_wtime, mpi_comm_world + use mpi + use mpisetup, only: mpi_initialize, mpi_initialize_io, mpi_cleanup, nproc ! model state vector use statevec_efsoi, only: read_state_efsoi, statevec_cleanup_efsoi, init_statevec_efsoi ! load balancing diff --git a/util/EFSOI_Utilities/src/loadbal_efsoi.f90 b/util/EFSOI_Utilities/src/loadbal_efsoi.f90 index 4ba46a476..e44281727 100644 --- a/util/EFSOI_Utilities/src/loadbal_efsoi.f90 +++ b/util/EFSOI_Utilities/src/loadbal_efsoi.f90 @@ -91,7 +91,8 @@ module loadbal_efsoi ! !$$$ -use mpisetup +use mpi +use mpisetup, only: nproc, numproc use params, only: datapath, nanals, simple_partition, & corrlengthnh, corrlengthsh, corrlengthtr, lupd_obspace_serial,& efsoi_flag @@ -136,6 +137,7 @@ subroutine load_balance_efsoi() integer(i_kind) np,i,n,nn,nob1,nob2,ierr real(r_double) t1 logical test_loadbal +integer status(MPI_STATUS_SIZE) ! partition state vector for using Grahams rule.. ! ("When a new job arrives, allocate it to the server @@ -292,7 +294,7 @@ subroutine load_balance_efsoi() else ! recv one large message on each task. call mpi_recv(anal_obchunk_prior,nobs_max*nanals,mpi_real4,0, & - 1,mpi_comm_world,mpi_status,ierr) + 1,mpi_comm_world,status,ierr) end if call mpi_barrier(mpi_comm_world, ierr) if(nproc == 0) print *,'... took ',mpi_wtime()-t1,' secs' From 6fdfbdb4f7ed3759a00fac58fbe05b5e5f33864b Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Fri, 29 Apr 2022 15:50:25 -0400 Subject: [PATCH 68/76] remove build.comgsi as it is unlikely to work with the current refactor. Use the `build.sh` instead --- ush/build.comgsi | 174 --------------------------------------- ush/prune_4nco_global.sh | 2 +- 2 files changed, 1 insertion(+), 175 deletions(-) delete mode 100755 ush/build.comgsi diff --git a/ush/build.comgsi b/ush/build.comgsi deleted file mode 100755 index 319d0121f..000000000 --- a/ush/build.comgsi +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/sh -# common modules to compile GSI/EnKF: -# Jet: source /home/rtrr/PARM_EXEC/modulefiles/modulefile.jet.GSI_UPP_WRF -# Theia: source /home/rtrr/PARM_EXEC/modulefiles/modulefile.theia.GSI_UPP_WRF -# Cheyenne: source /glade/p/ral/jntp/gge/modulefiles/modulefile.cheyenne.GSI_UPP_WRF -# -# build commands: -# cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON path_to_GSI -# cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_UTIL_COM=ON -DBUILD_ENKF_PREPROCESS_ARW=ON path_to_GSI" -# (for global: cmake -DCOMGSI=ON -DENKF_MODE=GFS path_to_GSI) -# make -j8 -# - -dir_root=$(pwd) - -################# Hera #################### -if [[ "`grep -i "hera" /etc/hosts | head -n1`" != "" ]] ; then - source /etc/profile.d/modules.sh - module purge - module load cmake/3.20.1 - module load intel/18.0.5.274 - module load impi/2018.0.4 - module load netcdf/4.7.0 - - module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/18.0.5.274 - module load hpc-impi/2018.0.4 - 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 w3nco/2.4.1 - module load w3emc/2.7.3 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load wrf_io/1.2.0 - -################# Jet #################### -elif [[ -d /jetmon ]] ; then - source /etc/profile.d/modules.sh - module purge - module load cmake/3.16.1 - module load intel/18.0.5.274 - module load impi/2018.4.274 - module load szip/2.1 - module load hdf5parallel/1.10.6 - module load netcdf-hdf5parallel/4.7.4 - module load pnetcdf/1.11.2 - module load nco/4.9.1 - - module use /lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/18.0.5.274 - module load hpc-impi/2018.4.274 - module load bufr/11.4.0 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load ip/3.3.3 - module load nemsio/2.5.2 - module load sp/2.3.3 - module load w3emc/2.7.3 - module load w3nco/2.4.1 - module load sfcio/1.4.1 - module load sigio/2.3.2 - module load wrf_io/1.2.0 - -################# Cheyenne #################### -elif [[ -d /glade ]] ; then - source /etc/profile.d/modules.sh - module purge - module load intel/18.0.5 ncarenv ncarcompilers - module load impi/2018.4.274 - module load mkl/2018.0.5 - module load netcdf/4.7.4 - - module use /glade/p/ral/jntp/gge/hpc-stacks/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/18.0.5 - module load hpc-impi/2018.4.274 - module load bufr/11.5.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 w3nco/2.4.1 - module load w3emc/2.7.3 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load wrf_io/1.2.0 - module load cmake/3.18.2 - -################# Orion #################### -elif [[ -d /work/noaa ]] ; then ### orion - module purge - module load intel/2018.4 - module load impi/2018.4 - module load netcdf/4.7.2 - - module use /apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/2018.4 - module load hpc-impi/2018.4 - 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 w3nco/2.4.1 - module load w3emc/2.7.3 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load wrf_io/1.2.0 - module load cmake - -################# Generic #################### -else - echo -e "\nunknown machine" - echo "Please modify build.comgsi at this location" - echo "to load required modules" - ##follow the above examples and delete the following "exit 9" to go forward - exit 9 - source /etc/profile.d/modules.sh - #load modules from the NOAA hpc-stack -fi - -## if NETCDF4 is set to 0 or 1, unset it -if [[ "$NETCDF4" == "1" ]] || [[ "$NETCDF4" == "0" ]]; then - unset NETCDF4 -fi - -set -x -rm -rf $dir_root/build -mkdir -p $dir_root/build -cd $dir_root/build -set +x - - -echo "compiled at the node:" >> output.log -hostname >> output.log -module list >> output.log -echo -e "\nThe branch name:" >> output.log -git branch | grep "*" >> output.log -echo -e "\nThe commit ID:" >> output.log -git log -1 | head -n1 >> output.log -echo -e "\ngit status:" >> output.log -git status >> output.log -echo -e "\nCompiling commands:" >> output.log -echo " cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON .." >> output.log -echo " make -j8" >> output.log -cat output.log - - -cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON .. 2>&1 | tee output.cmake -make -j 8 2>&1 | tee output.compile - -###aftermath -commitID=`git log -1 | head -n1 |cut -c8-15` -repoName=`git config --get remote.origin.url | cut -d: -f2` -repoName=${repoName//\//:} -datestamp=`date +%Y%m%d` -cd bin -ln -sf gsi.x gsi.x_${repoName}_${datestamp}_${commitID} -ln -sf enkf_wrf.x enkf_wrf.x_${repoName}_${datestamp}_${commitID} -ln -sf enspreproc.x enspreproc.x_${repoName}_${datestamp}_${commitID} -###mv $dir_root/build $dir_root/build_$commitID - -echo -e "\n\nAll build results are at ./build/ \n\n" - -exit diff --git a/ush/prune_4nco_global.sh b/ush/prune_4nco_global.sh index 5a1c7848f..ec69fd4cd 100755 --- a/ush/prune_4nco_global.sh +++ b/ush/prune_4nco_global.sh @@ -107,7 +107,7 @@ done # Process ush directories and files cd $topdir/ush -rlist="build.comgsi Get_Initial_Files gfs_truncate_enkf llsub para refactor_4nco_global run_arw rungsi sub" +rlist="Get_Initial_Files gfs_truncate_enkf llsub para refactor_4nco_global run_arw rungsi sub" for type in $rlist; do git $string ${type}* rc=$? From eaa9fe751473c6b811a7112f7806f40a52d67a64 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 9 May 2022 22:08:13 -0400 Subject: [PATCH 69/76] Keeping up with #369, where only some of the modulefiles were updated to lua. --- modulefiles/modulefile.ProdGSI.common.lua | 36 +++++++++++ modulefiles/modulefile.ProdGSI.hera.gnu | 29 --------- modulefiles/modulefile.ProdGSI.hera.gnu.lua | 22 +++++++ modulefiles/modulefile.ProdGSI.hera.intel | 36 ----------- modulefiles/modulefile.ProdGSI.hera.intel.lua | 28 +++++++++ modulefiles/modulefile.ProdGSI.hera.lua | 63 ------------------- modulefiles/modulefile.ProdGSI.orion | 40 ------------ modulefiles/modulefile.ProdGSI.orion.lua | 45 ++----------- modulefiles/modulefile.ProdGSI.wcoss2.lua | 28 +-------- 9 files changed, 93 insertions(+), 234 deletions(-) create mode 100644 modulefiles/modulefile.ProdGSI.common.lua delete mode 100644 modulefiles/modulefile.ProdGSI.hera.gnu create mode 100644 modulefiles/modulefile.ProdGSI.hera.gnu.lua delete mode 100644 modulefiles/modulefile.ProdGSI.hera.intel create mode 100644 modulefiles/modulefile.ProdGSI.hera.intel.lua delete mode 100644 modulefiles/modulefile.ProdGSI.hera.lua delete mode 100644 modulefiles/modulefile.ProdGSI.orion diff --git a/modulefiles/modulefile.ProdGSI.common.lua b/modulefiles/modulefile.ProdGSI.common.lua new file mode 100644 index 000000000..6177ebaf4 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.common.lua @@ -0,0 +1,36 @@ +help([[ +Load common modules to build GSI on all machines +]]) + +prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" + +netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" + +bufr_ver=os.getenv("bufr_ver") or "11.5.0" +bacio_ver=os.getenv("bacio_ver") or "2.4.1" +w3emc_ver=os.getenv("w3emc_ver") or "2.9.1" +sp_ver=os.getenv("sp_ver") or "2.3.3" +sp_ver=os.getenv("ip_ver") or "3.3.3" +sigio_ver=os.getenv("sigio_ver") or "2.3.2" +sigio_ver=os.getenv("sfcio_ver") or "1.4.1" +sigio_ver=os.getenv("nemsio_ver") or "2.5.2" +sigio_ver=os.getenv("wrf_io_ver") or "1.2.0" +sigio_ver=os.getenv("ncio_ver") or "1.0.2" +sigio_ver=os.getenv("crtm_ver") or "2.3.0" + +load(pathJoin("prod_util", prod_util_ver)) + +load(pathJoin("netcdf", netcdf_ver)) + +load(pathJoin("bufr", bufr_ver)) +load(pathJoin("bacio", bacio_ver)) +load(pathJoin("w3emc", w3emc_ver)) +load(pathJoin("sp", sp_ver)) +load(pathJoin("ip", ip_ver)) +load(pathJoin("sigio", sigio_ver)) +load(pathJoin("sfcio", sfcio_ver)) +load(pathJoin("nemsio", nemsio_ver)) +load(pathJoin("wrf_io", wrf_io_ver)) +load(pathJoin("ncio", ncio_ver)) +load(pathJoin("crtm", crtm_ver)) + diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu b/modulefiles/modulefile.ProdGSI.hera.gnu deleted file mode 100644 index 90de3a8e3..000000000 --- a/modulefiles/modulefile.ProdGSI.hera.gnu +++ /dev/null @@ -1,29 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -setenv CRTM_FIX /scratch2/NCEPDEV/nwprod/NCEPLIBS/fix/crtm_v2.3.0 - -# Load cmake -module use -a /contrib/cmake/modulefiles -module load cmake/3.20.1 - -# Load hpc-stack -module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load GNU compiler and mpi -module load hpc-gnu/9.2.0 -module load hpc-mpich/3.3.2 - -# Use Intel MKL -setenv MKLROOT "/apps/oneapi/mkl/2022.0.2" - -# Load the dependency libraries -module load modulefile.ProdGSI.common diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu.lua b/modulefiles/modulefile.ProdGSI.hera.gnu.lua new file mode 100644 index 000000000..4c8f9864d --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.hera.gnu.lua @@ -0,0 +1,22 @@ +help([[ +]]) + +prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") + +hpc_ver=os.getenv("hpc_ver") or "1.1.0" +load(pathJoin("hpc", hpc_ver)) + +hpc_intel_ver=os.getenv("hpc_gnu_ver") or "9.2.0" +load(pathJoin("hpc-gnu", hpc_gnu_ver)) + +impi_ver=os.getenv("hpc_mpich_ver") or "3.3.2" +load(pathJoin("hpc-mpich", hpc_mpich_ver)) + +cmake_ver=os.getenv("cmake_ver") or "3.20.1" +load(pathJoin("cmake", cmake_ver)) + +load("modulefile.ProdGSI.common") + +pushenv("MKLROOT", "/apps/oneapi/mkl/2022.0.2") + +whatis("Description: GSI environment on Hera with GNU Compilers") diff --git a/modulefiles/modulefile.ProdGSI.hera.intel b/modulefiles/modulefile.ProdGSI.hera.intel deleted file mode 100644 index 193237c88..000000000 --- a/modulefiles/modulefile.ProdGSI.hera.intel +++ /dev/null @@ -1,36 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -setenv CRTM_FIX /scratch2/NCEPDEV/nwprod/NCEPLIBS/fix/crtm_v2.3.0 - -# Load cmake -module use -a /contrib/cmake/modulefiles -module load cmake/3.20.1 - -# Load hpc-stack -module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load intel compiler and mpi -module load hpc-intel/18.0.5.274 -module load hpc-impi/2018.0.4 - -# Load python -# Note: anaconda/2.3.0 requires intel be loaded prior to anaconda -module use -a /contrib/anaconda/modulefiles -module load anaconda/2.3.0 - -# Load the dependency libraries -module load modulefile.ProdGSI.common - -# Compiler flags specific to this platform -setenv CFLAGS "-xHOST" -setenv FFLAGS "-xHOST" - diff --git a/modulefiles/modulefile.ProdGSI.hera.intel.lua b/modulefiles/modulefile.ProdGSI.hera.intel.lua new file mode 100644 index 000000000..788568891 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.hera.intel.lua @@ -0,0 +1,28 @@ +help([[ +]]) + +prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") + +hpc_ver=os.getenv("hpc_ver") or "1.1.0" +load(pathJoin("hpc", hpc_ver)) + +hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" +load(pathJoin("hpc-intel", hpc_intel_ver)) + +impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" +load(pathJoin("hpc-impi", hpc_impi_ver)) + +cmake_ver=os.getenv("cmake_ver") or "3.20.1" +load(pathJoin("cmake", cmake_ver)) + +prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") + +anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" +load(pathJoin("anaconda", anaconda_ver)) + +load("modulefile.ProdGSI.common") + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on Hera with Intel Compilers") diff --git a/modulefiles/modulefile.ProdGSI.hera.lua b/modulefiles/modulefile.ProdGSI.hera.lua deleted file mode 100644 index ff73a3c51..000000000 --- a/modulefiles/modulefile.ProdGSI.hera.lua +++ /dev/null @@ -1,63 +0,0 @@ -help([[ -Load environment to compile GSI on Hera -]]) - -prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") - -hpc_ver=os.getenv("hpc_ver") or "1.1.0" -load(pathJoin("hpc", hpc_ver)) - -hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" -load(pathJoin("hpc-intel", hpc_intel_ver)) - -impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" -load(pathJoin("hpc-impi", hpc_impi_ver)) - -cmake_ver=os.getenv("cmake_ver") or "3.16.1" -load(pathJoin("cmake", cmake_ver)) - -prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") - -anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" -load(pathJoin("anaconda", anaconda_ver)) - -prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" -load(pathJoin("prod_util", prod_util_ver)) - -bufr_ver=os.getenv("bufr_ver") or "11.4.0" -load(pathJoin("bufr", bufr_ver)) - -ip_ver=os.getenv("ip_ver") or "3.3.3" -load(pathJoin("ip", ip_ver)) - -nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" -load(pathJoin("nemsio", nemsio_ver)) - -sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" -load(pathJoin("sfcio", sfcio_ver)) - -sigio_ver=os.getenv("sigio_ver") or "2.3.2" -load(pathJoin("sigio", sigio_ver)) - -sp_ver=os.getenv("sp_ver") or "2.3.3" -load(pathJoin("sp", sp_ver)) - -w3nco_ver=os.getenv("w3nco_ver") or "2.4.1" -load(pathJoin("w3nco", w3nco_ver)) - -w3emc_ver=os.getenv("w3emc_ver") or "2.9.2" -load(pathJoin("w3emc", w3emc_ver)) - -bacio_ver=os.getenv("bacio_ver") or "2.4.1" -load(pathJoin("bacio", bacio_ver)) - -crtm_ver=os.getenv("crtm_ver") or "2.3.0" -load(pathJoin("crtm", crtm_ver)) - -netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -load(pathJoin("netcdf", netcdf_ver)) - -wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" -load(pathJoin("wrf_io", wrf_io_ver)) - -whatis("Description: GSI build environment") diff --git a/modulefiles/modulefile.ProdGSI.orion b/modulefiles/modulefile.ProdGSI.orion deleted file mode 100644 index dd623209e..000000000 --- a/modulefiles/modulefile.ProdGSI.orion +++ /dev/null @@ -1,40 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -setenv CRTM_FIX /apps/contrib/NCEPLIBS/orion/fix/crtm_v2.3.0 - -# Load cmake -module load cmake/3.22.1 - -# Load python -module load python/3.7.5 - -# Load hpc-stack -module use /apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load intel compiler and mpi -# -# Note: hpc-intel/2018.4 erroneously loads mkl/2020.2. hpc-stack -# PR 173 submitted to resolves this. Until then, unload mkl/2020.2 -# after loading hpc-intel/2018.4 and load mkl/2018.4 to ensure -# consistency -# -module load hpc-intel/2018.4 -module unload mkl/2020.2 -module load mkl/2018.4 -module load hpc-impi/2018.4 - -# Load the dependency libraries -module load modulefile.ProdGSI.common - -# Compiler flags specific to this platform -setenv CFLAGS "-xHOST" -setenv FFLAGS "-xHOST" diff --git a/modulefiles/modulefile.ProdGSI.orion.lua b/modulefiles/modulefile.ProdGSI.orion.lua index 9f20e325e..66d11f34e 100644 --- a/modulefiles/modulefile.ProdGSI.orion.lua +++ b/modulefiles/modulefile.ProdGSI.orion.lua @@ -1,5 +1,4 @@ help([[ -Load environment to compile GSI on Orion ]]) prepend_path("MODULEPATH", "/apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack") @@ -13,49 +12,15 @@ load(pathJoin("hpc-intel", hpc_intel_ver)) impi_ver=os.getenv("hpc_impi_ver") or "2018.4" load(pathJoin("hpc-impi", hpc_impi_ver)) -cmake_ver=os.getenv("cmake_ver") or "3.17.3" +cmake_ver=os.getenv("cmake_ver") or "3.22.1" load(pathJoin("cmake", cmake_ver)) python_ver=os.getenv("python_ver") or "3.7.5" load(pathJoin("python", python_ver)) -prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" -load(pathJoin("prod_util", prod_util_ver)) +load("modulefile.ProdGSI.common") -bufr_ver=os.getenv("bufr_ver") or "11.4.0" -load(pathJoin("bufr", bufr_ver)) +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") -ip_ver=os.getenv("ip_ver") or "3.3.3" -load(pathJoin("ip", ip_ver)) - -nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" -load(pathJoin("nemsio", nemsio_ver)) - -sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" -load(pathJoin("sfcio", sfcio_ver)) - -sigio_ver=os.getenv("sigio_ver") or "2.3.2" -load(pathJoin("sigio", sigio_ver)) - -sp_ver=os.getenv("sp_ver") or "2.3.3" -load(pathJoin("sp", sp_ver)) - -w3nco_ver=os.getenv("w3nco_ver") or "2.4.1" -load(pathJoin("w3nco", w3nco_ver)) - -w3emc_ver=os.getenv("w3emc_ver") or "2.9.2" -load(pathJoin("w3emc", w3emc_ver)) - -bacio_ver=os.getenv("bacio_ver") or "2.4.1" -load(pathJoin("bacio", bacio_ver)) - -crtm_ver=os.getenv("crtm_ver") or "2.3.0" -load(pathJoin("crtm", crtm_ver)) - -netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -load(pathJoin("netcdf", netcdf_ver)) - -wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" -load(pathJoin("wrf_io", wrf_io_ver)) - -whatis("Description: GSI build environment") +whatis("Description: GSI environment on Orion with Intel Compilers") diff --git a/modulefiles/modulefile.ProdGSI.wcoss2.lua b/modulefiles/modulefile.ProdGSI.wcoss2.lua index c61bdc0f8..c6d55df59 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss2.lua +++ b/modulefiles/modulefile.ProdGSI.wcoss2.lua @@ -8,19 +8,6 @@ local craype_ver=os.getenv("craype_ver") or "2.7.8" local cray_mpich_ver=os.getenv("cray_mpich_ver") or "8.1.7" local cmake_ver= os.getenv("cmake_ver") or "3.20.2" local python_ver=os.getenv("python_ver") or "3.8.6" -local bacio_ver=os.getenv("bacio_ver") or "2.4.1" -local bufr_ver= os.getenv("bufr_ver") or "11.5.0" -local crtm_ver=os.getenv("crtm_ver") or "2.3.0" -local ip_ver=os.getenv("ip_ver") or "3.3.3" -local nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" -local prod_util_ver= os.getenv("prod_util_ver") or "2.0.10" -local sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" -local sigio_ver=os.getenv("sigio_ver") or "2.3.2" -local sp_ver=os.getenv("sp_ver") or "2.3.3" -local w3emc_ver=os.getenv("w3emc_ver") or "2.9.2" -local w3nco_ver=os.getenv("w3nco_ver") or "2.4.1" -local netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -local wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" load(pathJoin("PrgEnv-intel", PrgEnv_intel_ver)) load(pathJoin("intel", intel_ver)) @@ -28,18 +15,7 @@ load(pathJoin("craype", craype_ver)) load(pathJoin("cray-mpich", cray_mpich_ver)) load(pathJoin("cmake", cmake_ver)) load(pathJoin("python", python_ver)) -load(pathJoin("bacio", bacio_ver)) -load(pathJoin("bufr", bufr_ver)) -load(pathJoin("crtm", crtm_ver)) -load(pathJoin("ip", ip_ver)) -load(pathJoin("nemsio", nemsio_ver)) -load(pathJoin("prod_util", prod_util_ver)) -load(pathJoin("sfcio", sfcio_ver)) -load(pathJoin("sigio", sigio_ver)) -load(pathJoin("sp", sp_ver)) -load(pathJoin("w3emc", w3emc_ver)) -load(pathJoin("w3nco", w3nco_ver)) -load(pathJoin("netcdf", netcdf_ver)) -load(pathJoin("wrf_io", wrf_io_ver)) + +load("modulefile.ProdGSI.common") whatis("Description: GSI run environment") From 4aff636f4e22ce1b87c912153729e2d000471e13 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 9 May 2022 22:50:28 -0400 Subject: [PATCH 70/76] convert remaining modulefiles to lua. --- modulefiles/modulefile.ProdGSI.cheyenne.gnu | 30 ------------- .../modulefile.ProdGSI.cheyenne.gnu.lua | 26 ++++++++++++ modulefiles/modulefile.ProdGSI.cheyenne.intel | 30 ------------- .../modulefile.ProdGSI.cheyenne.intel.lua | 23 ++++++++++ modulefiles/modulefile.ProdGSI.common | 19 --------- modulefiles/modulefile.ProdGSI.hera.gnu.lua | 12 +++--- modulefiles/modulefile.ProdGSI.hera.intel.lua | 14 +++---- modulefiles/modulefile.ProdGSI.jet | 36 ---------------- modulefiles/modulefile.ProdGSI.jet.lua | 21 ++++++++++ modulefiles/modulefile.ProdGSI.orion.lua | 15 +++---- modulefiles/modulefile.ProdGSI.s4 | 23 ---------- modulefiles/modulefile.ProdGSI.s4.lua | 23 ++++++++++ modulefiles/modulefile.ProdGSI.wcoss2.lua | 3 +- modulefiles/modulefile.ProdGSI.wcoss_dell_p3 | 42 ------------------- .../modulefile.ProdGSI.wcoss_dell_p3.lua | 33 +++++++++++++++ 15 files changed, 144 insertions(+), 206 deletions(-) delete mode 100644 modulefiles/modulefile.ProdGSI.cheyenne.gnu create mode 100644 modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua delete mode 100644 modulefiles/modulefile.ProdGSI.cheyenne.intel create mode 100644 modulefiles/modulefile.ProdGSI.cheyenne.intel.lua delete mode 100644 modulefiles/modulefile.ProdGSI.common delete mode 100644 modulefiles/modulefile.ProdGSI.jet create mode 100644 modulefiles/modulefile.ProdGSI.jet.lua delete mode 100644 modulefiles/modulefile.ProdGSI.s4 create mode 100644 modulefiles/modulefile.ProdGSI.s4.lua delete mode 100644 modulefiles/modulefile.ProdGSI.wcoss_dell_p3 create mode 100644 modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.gnu b/modulefiles/modulefile.ProdGSI.cheyenne.gnu deleted file mode 100644 index 7cb59ccbf..000000000 --- a/modulefiles/modulefile.ProdGSI.cheyenne.gnu +++ /dev/null @@ -1,30 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -module load cmake/3.22.0 -module load python/3.7.9 -module load ncarenv/1.3 -module load gnu/10.1.0 -module load mpt/2.22 -module load ncarcompilers/0.5.0 -module unload netcdf - -module use /glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack -module load hpc/1.2.0 -module load hpc-gnu/10.1.0 -module load hpc-mpt/2.22 - -setenv MKLROOT /glade/u/apps/opt/intel/2021.2/mkl/latest - -module load modulefile.ProdGSI.common - -setenv CC mpicc -setenv FC mpif90 -setenv CXX mpicxx diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua b/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua new file mode 100644 index 000000000..68ca6fa08 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua @@ -0,0 +1,26 @@ +help([[ +]]) + +load("cmake/3.22.0") +load("python/3.7.9") +load("ncarenv/1.3") +load("gnu/10.1.0") +load("mpt/2.22") +load("ncarcompilers/0.5.0") +unload("netcdf") + +prepend_path("MODULEPATH", "/glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack") + +load("hpc/1.2.0") +load("hpc-gnu/10.1.0") +load("hpc-mpt/2.22") + +load("modulefile.ProdGSI.common") + +pushenv("MKLROOT", "/glade/u/apps/opt/intel/2021.2/mkl/latest") + +pushenv("CC", "mpicc") +pushenv("FC", "mpif90") +pushenv("CXX", "mpicxx") + +whatis("Description: GSI environment on Cheyenne with GNU Compilers") diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.intel b/modulefiles/modulefile.ProdGSI.cheyenne.intel deleted file mode 100644 index 0bb8f30fd..000000000 --- a/modulefiles/modulefile.ProdGSI.cheyenne.intel +++ /dev/null @@ -1,30 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - - -module load cmake/3.22.0 -module load python/3.7.9 -module load ncarenv/1.3 -module load intel/2021.2 -module load mpt/2.22 -module load ncarcompilers/0.5.0 - -module use /glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack -module load hpc/1.2.0 -module load hpc-intel/2021.2 -module load hpc-mpt/2.22 -module load mkl/2021.2 - -module load modulefile.ProdGSI.common - -# Compiler flags specific to this platform -setenv CFLAGS "-xHOST" -setenv FFLAGS "-xHOST" - diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua b/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua new file mode 100644 index 000000000..81ded1c27 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua @@ -0,0 +1,23 @@ +help([[ +]]) + +load("cmake/3.22.0") +load("python/3.7.9") +load("ncarenv/1.3") +load("intel/2021.2") +load("mpt/2.22") +load("ncarcompilers/0.5.0") + +prepend_path("MODULEPATH", "/glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack") + +load("hpc/1.2.0") +load("hpc-intel/2021.2") +load("hpc-mpt/2.22") +load("mkl/2021.2") + +load("modulefile.ProdGSI.common") + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on Cheyenne with Intel Compilers") diff --git a/modulefiles/modulefile.ProdGSI.common b/modulefiles/modulefile.ProdGSI.common deleted file mode 100644 index 01200bb7b..000000000 --- a/modulefiles/modulefile.ProdGSI.common +++ /dev/null @@ -1,19 +0,0 @@ -#%Module - -# Load production utilities -module load prod_util/1.2.2 - -module load netcdf/4.7.4 - -# Load nceplibs -module load bufr/11.5.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.9.1 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load wrf_io/1.2.0 -module load ncio/1.0.0 diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu.lua b/modulefiles/modulefile.ProdGSI.hera.gnu.lua index 4c8f9864d..08243b038 100644 --- a/modulefiles/modulefile.ProdGSI.hera.gnu.lua +++ b/modulefiles/modulefile.ProdGSI.hera.gnu.lua @@ -3,16 +3,14 @@ help([[ prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") -hpc_ver=os.getenv("hpc_ver") or "1.1.0" -load(pathJoin("hpc", hpc_ver)) +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_gnu_ver") or "9.2.0" +local impi_ver=os.getenv("hpc_mpich_ver") or "3.3.2" +local cmake_ver=os.getenv("cmake_ver") or "3.20.1" -hpc_intel_ver=os.getenv("hpc_gnu_ver") or "9.2.0" +load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-gnu", hpc_gnu_ver)) - -impi_ver=os.getenv("hpc_mpich_ver") or "3.3.2" load(pathJoin("hpc-mpich", hpc_mpich_ver)) - -cmake_ver=os.getenv("cmake_ver") or "3.20.1" load(pathJoin("cmake", cmake_ver)) load("modulefile.ProdGSI.common") diff --git a/modulefiles/modulefile.ProdGSI.hera.intel.lua b/modulefiles/modulefile.ProdGSI.hera.intel.lua index 788568891..7d1fcb279 100644 --- a/modulefiles/modulefile.ProdGSI.hera.intel.lua +++ b/modulefiles/modulefile.ProdGSI.hera.intel.lua @@ -3,21 +3,19 @@ help([[ prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") -hpc_ver=os.getenv("hpc_ver") or "1.1.0" -load(pathJoin("hpc", hpc_ver)) +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" +local impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" +local cmake_ver=os.getenv("cmake_ver") or "3.20.1" +local anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" -hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" +load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-intel", hpc_intel_ver)) - -impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" load(pathJoin("hpc-impi", hpc_impi_ver)) - -cmake_ver=os.getenv("cmake_ver") or "3.20.1" load(pathJoin("cmake", cmake_ver)) prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") -anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" load(pathJoin("anaconda", anaconda_ver)) load("modulefile.ProdGSI.common") diff --git a/modulefiles/modulefile.ProdGSI.jet b/modulefiles/modulefile.ProdGSI.jet deleted file mode 100644 index db6940b0b..000000000 --- a/modulefiles/modulefile.ProdGSI.jet +++ /dev/null @@ -1,36 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" -# -# - -setenv CRTM_FIX /lfs4/HFIP/hfv3gfs/glopara/crtm_v2.3.0 - -# Load cmake -module load cmake/3.20.1 - -# Load python -module use /contrib/anaconda/modulefiles -module load anaconda/5.3.1 - -# Load hpc-stack -module use /lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack -module load hpc/1.1.0 - -# Load intel compiler and mpi -module load hpc-intel/18.0.5.274 -module load hpc-impi/2018.4.274 - -# Load the dependency libraries -module load modulefile.ProdGSI.common - -# 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.jet.lua b/modulefiles/modulefile.ProdGSI.jet.lua new file mode 100644 index 000000000..3dcf3428d --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.jet.lua @@ -0,0 +1,21 @@ +help([[ +]]) + +load("cmake/3.20.1") + +prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") + +load("anaconda/5.3.1") + +prepend_path("MODULEPATH", "/lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack") + +load("hpc/1.1.0") +load("hpc-intel/18.0.5.274") +load("hpc-impi/2018.4.274") + +load("modulefile.ProdGSI.common") + +pushenv("CFLAGS", "-axSSE4.2,AVX,CORE-AVX2") +pushenv("FFLAGS", "-axSSE4.2,AVX,CORE-AVX2") + +whatis("Description: GSI environment on Jet with Intel Compilers") diff --git a/modulefiles/modulefile.ProdGSI.orion.lua b/modulefiles/modulefile.ProdGSI.orion.lua index 66d11f34e..55612e7e5 100644 --- a/modulefiles/modulefile.ProdGSI.orion.lua +++ b/modulefiles/modulefile.ProdGSI.orion.lua @@ -3,19 +3,16 @@ help([[ prepend_path("MODULEPATH", "/apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack") -hpc_ver=os.getenv("hpc_ver") or "1.1.0" -load(pathJoin("hpc", hpc_ver)) +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_intel_ver") or "2018.4" +local impi_ver=os.getenv("hpc_impi_ver") or "2018.4" +local cmake_ver=os.getenv("cmake_ver") or "3.22.1" +local python_ver=os.getenv("python_ver") or "3.7.5" -hpc_intel_ver=os.getenv("hpc_intel_ver") or "2018.4" +load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-intel", hpc_intel_ver)) - -impi_ver=os.getenv("hpc_impi_ver") or "2018.4" load(pathJoin("hpc-impi", hpc_impi_ver)) - -cmake_ver=os.getenv("cmake_ver") or "3.22.1" load(pathJoin("cmake", cmake_ver)) - -python_ver=os.getenv("python_ver") or "3.7.5" load(pathJoin("python", python_ver)) load("modulefile.ProdGSI.common") diff --git a/modulefiles/modulefile.ProdGSI.s4 b/modulefiles/modulefile.ProdGSI.s4 deleted file mode 100644 index 4ae823bac..000000000 --- a/modulefiles/modulefile.ProdGSI.s4 +++ /dev/null @@ -1,23 +0,0 @@ -#%Module###################################################################### -## NOAA-EMC/GSI -##_____________________________________________________ - -setenv CRTM_FIX /data/prod/hpc-stack/fix/crtm/2.3.0 - -module load license_intel/S4 -module use /data/prod/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load intel compiler and mpi -module load hpc-intel/18.0.4 -module load hpc-impi/18.0.4 -# Load python -module load miniconda/3.8-s4 - -# Load the dependency libraries -module load modulefile.ProdGSI.common - -# Compiler flags specific to this platform -setenv CFLAGS "-march=ivybridge" -setenv FFLAGS "-march=ivybridge" - diff --git a/modulefiles/modulefile.ProdGSI.s4.lua b/modulefiles/modulefile.ProdGSI.s4.lua new file mode 100644 index 000000000..8c5a15dad --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.s4.lua @@ -0,0 +1,23 @@ +help([[ +]]) + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.4" +local impi_ver=os.getenv("hpc_impi_ver") or "18.0.4" +local miniconda_ver=os.getenv("miniconda_ver") or "3.8-s4" + +prepend_path("MODULEPATH", "/data/prod/hpc-stack/modulefiles/stack") + +load("license_intel/S4") +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-intel", hpc_intel_ver)) +load(pathJoin("hpc-impi", hpc_impi_ver)) + +load(pathJoin("miniconda", miniconda_ver)) + +load("modulefile.ProdGSI.common") + +pushenv("CFLAGS", "-march=ivybridge") +pushenv("FFLAGS", "-march=ivybridge") + +whatis("Description: GSI environment on S4 with Intel Compilers") diff --git a/modulefiles/modulefile.ProdGSI.wcoss2.lua b/modulefiles/modulefile.ProdGSI.wcoss2.lua index c6d55df59..925bbd23e 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss2.lua +++ b/modulefiles/modulefile.ProdGSI.wcoss2.lua @@ -1,5 +1,4 @@ help([[ -Load environment to run GSI on WCOSS2 ]]) local PrgEnv_intel_ver=os.getenv("PrgEnv_intel_ver") or "8.1.0" @@ -18,4 +17,4 @@ load(pathJoin("python", python_ver)) load("modulefile.ProdGSI.common") -whatis("Description: GSI run environment") +whatis("Description: GSI environment on WCOSS2") diff --git a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 deleted file mode 100644 index 66fe764a0..000000000 --- a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3 +++ /dev/null @@ -1,42 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -setenv CRTM_FIX /gpfs/dell1/nco/ops/nwprod/lib/crtm/v2.3.0/fix - - -# Load python -module load python/3.6.3 - -# Load hpc-stack -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 - -# Load intel compiler and mpi -module load hpc-ips/18.0.1.163 -module load hpc-impi/18.0.1 - -# Load jasper, zlib and png -module load jasper/2.0.22 -module load zlib/1.2.11 -module load png/1.6.35 - -# Load the dependency libraries -module load modulefile.ProdGSI.common - -# Compiler flags specific to this platform -setenv CFLAGS "-xHOST" -setenv FFLAGS "-xHOST" - diff --git a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua new file mode 100644 index 000000000..bb48d8524 --- /dev/null +++ b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua @@ -0,0 +1,33 @@ +help([[ +]]) + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_ips_ver") or "18.0.1.163" +local impi_ver=os.getenv("hpc_impi_ver") or "18.0.1" +local cmake_ver=os.getenv("cmake_ver") or "3.20.0" +local lsf_ver=os.getenv("lsf_ver") or "10.1" +local jasper_ver=os.getenv("jasper_ver") or "2.0.22" +local zlib_ver=os.getenv("zlib_ver") or "1.2.11" +local png_ver=os.getenv("png_ver") or "1.6.35" +local python_ver=os.getenv("python_ver") or "3.6.3" + +load(pathJoin("python", python_ver)) +load(pathJoin("lsf", lsf_ver)) +load(pathJoin("cmake", cmake_ver)) + +prepend_path("MODULEPATH", "/usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack") + +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-ips", hpc_ips_ver)) +load(pathJoin("hpc-impi", hpc_impi_ver)) + +load(pathJoin("jasper", jasper_ver)) +load(pathJoin("zlib", zlib_ver)) +load(pathJoin("png", png_ver)) + +load("modulefile.ProdGSI.common") + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on WCOSS Dell") From 01a1c95fe0ae611adf65a1c054e08c459d9b7441 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 9 May 2022 23:22:34 -0400 Subject: [PATCH 71/76] modulefile.ProdGSI.common.lua was buggy. a source code change slipped through via one of the many merged PRs --- modulefiles/modulefile.ProdGSI.common.lua | 26 +++++++++++------------ src/gsi/general_read_gfsatm.f90 | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.common.lua b/modulefiles/modulefile.ProdGSI.common.lua index 6177ebaf4..092fa9ab4 100644 --- a/modulefiles/modulefile.ProdGSI.common.lua +++ b/modulefiles/modulefile.ProdGSI.common.lua @@ -2,21 +2,21 @@ help([[ Load common modules to build GSI on all machines ]]) -prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" -netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" +local netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -bufr_ver=os.getenv("bufr_ver") or "11.5.0" -bacio_ver=os.getenv("bacio_ver") or "2.4.1" -w3emc_ver=os.getenv("w3emc_ver") or "2.9.1" -sp_ver=os.getenv("sp_ver") or "2.3.3" -sp_ver=os.getenv("ip_ver") or "3.3.3" -sigio_ver=os.getenv("sigio_ver") or "2.3.2" -sigio_ver=os.getenv("sfcio_ver") or "1.4.1" -sigio_ver=os.getenv("nemsio_ver") or "2.5.2" -sigio_ver=os.getenv("wrf_io_ver") or "1.2.0" -sigio_ver=os.getenv("ncio_ver") or "1.0.2" -sigio_ver=os.getenv("crtm_ver") or "2.3.0" +local bufr_ver=os.getenv("bufr_ver") or "11.5.0" +local bacio_ver=os.getenv("bacio_ver") or "2.4.1" +local w3emc_ver=os.getenv("w3emc_ver") or "2.9.1" +local sp_ver=os.getenv("sp_ver") or "2.3.3" +local ip_ver=os.getenv("ip_ver") or "3.3.3" +local sigio_ver=os.getenv("sigio_ver") or "2.3.2" +local sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" +local nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" +local wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" +local ncio_ver=os.getenv("ncio_ver") or "1.0.0" +local crtm_ver=os.getenv("crtm_ver") or "2.3.0" load(pathJoin("prod_util", prod_util_ver)) diff --git a/src/gsi/general_read_gfsatm.f90 b/src/gsi/general_read_gfsatm.f90 index 505b0591d..39db75db7 100755 --- a/src/gsi/general_read_gfsatm.f90 +++ b/src/gsi/general_read_gfsatm.f90 @@ -2616,8 +2616,8 @@ subroutine general_read_gfsatm_allhydro_nc(grd,sp_a,filename,uvflag,vordivflag,z 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,& - close_dataset, get_dim, read_vardata,get_idate_from_time_units + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + close_dataset, get_dim, read_vardata,get_idate_from_time_units use gfsreadmod, only: general_reload2 use ncepnems_io, only: imp_physics From cf89306a17cc15add33ba6599161db2907361681 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 10 May 2022 10:32:34 -0400 Subject: [PATCH 72/76] remove prod_util from common and load in the platform itself --- modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua | 3 +++ modulefiles/modulefile.ProdGSI.cheyenne.intel.lua | 3 +++ modulefiles/modulefile.ProdGSI.common.lua | 4 ---- modulefiles/modulefile.ProdGSI.hera.gnu.lua | 3 +++ modulefiles/modulefile.ProdGSI.hera.intel.lua | 3 +++ modulefiles/modulefile.ProdGSI.jet.lua | 3 +++ modulefiles/modulefile.ProdGSI.orion.lua | 3 +++ modulefiles/modulefile.ProdGSI.s4.lua | 3 +++ modulefiles/modulefile.ProdGSI.wcoss2.lua | 3 +++ modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua | 3 +++ 10 files changed, 27 insertions(+), 4 deletions(-) diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua b/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua index 68ca6fa08..3bc61b54c 100644 --- a/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua +++ b/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua @@ -17,6 +17,9 @@ load("hpc-mpt/2.22") load("modulefile.ProdGSI.common") +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +load(pathJoin("prod_util", prod_util_ver)) + pushenv("MKLROOT", "/glade/u/apps/opt/intel/2021.2/mkl/latest") pushenv("CC", "mpicc") diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua b/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua index 81ded1c27..cf8f231c8 100644 --- a/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua +++ b/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua @@ -17,6 +17,9 @@ load("mkl/2021.2") load("modulefile.ProdGSI.common") +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +load(pathJoin("prod_util", prod_util_ver)) + pushenv("CFLAGS", "-xHOST") pushenv("FFLAGS", "-xHOST") diff --git a/modulefiles/modulefile.ProdGSI.common.lua b/modulefiles/modulefile.ProdGSI.common.lua index 092fa9ab4..07442cbf2 100644 --- a/modulefiles/modulefile.ProdGSI.common.lua +++ b/modulefiles/modulefile.ProdGSI.common.lua @@ -2,8 +2,6 @@ help([[ Load common modules to build GSI on all machines ]]) -local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" - local netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" local bufr_ver=os.getenv("bufr_ver") or "11.5.0" @@ -18,8 +16,6 @@ local wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" local ncio_ver=os.getenv("ncio_ver") or "1.0.0" local crtm_ver=os.getenv("crtm_ver") or "2.3.0" -load(pathJoin("prod_util", prod_util_ver)) - load(pathJoin("netcdf", netcdf_ver)) load(pathJoin("bufr", bufr_ver)) diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu.lua b/modulefiles/modulefile.ProdGSI.hera.gnu.lua index 08243b038..145859893 100644 --- a/modulefiles/modulefile.ProdGSI.hera.gnu.lua +++ b/modulefiles/modulefile.ProdGSI.hera.gnu.lua @@ -7,6 +7,7 @@ local hpc_ver=os.getenv("hpc_ver") or "1.1.0" local hpc_intel_ver=os.getenv("hpc_gnu_ver") or "9.2.0" local impi_ver=os.getenv("hpc_mpich_ver") or "3.3.2" local cmake_ver=os.getenv("cmake_ver") or "3.20.1" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-gnu", hpc_gnu_ver)) @@ -15,6 +16,8 @@ load(pathJoin("cmake", cmake_ver)) load("modulefile.ProdGSI.common") +load(pathJoin("prod_util", prod_util_ver)) + pushenv("MKLROOT", "/apps/oneapi/mkl/2022.0.2") whatis("Description: GSI environment on Hera with GNU Compilers") diff --git a/modulefiles/modulefile.ProdGSI.hera.intel.lua b/modulefiles/modulefile.ProdGSI.hera.intel.lua index 7d1fcb279..35d50df06 100644 --- a/modulefiles/modulefile.ProdGSI.hera.intel.lua +++ b/modulefiles/modulefile.ProdGSI.hera.intel.lua @@ -8,6 +8,7 @@ local hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" local impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" local cmake_ver=os.getenv("cmake_ver") or "3.20.1" local anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-intel", hpc_intel_ver)) @@ -20,6 +21,8 @@ load(pathJoin("anaconda", anaconda_ver)) load("modulefile.ProdGSI.common") +load(pathJoin("prod_util", prod_util_ver)) + pushenv("CFLAGS", "-xHOST") pushenv("FFLAGS", "-xHOST") diff --git a/modulefiles/modulefile.ProdGSI.jet.lua b/modulefiles/modulefile.ProdGSI.jet.lua index 3dcf3428d..14a62aea6 100644 --- a/modulefiles/modulefile.ProdGSI.jet.lua +++ b/modulefiles/modulefile.ProdGSI.jet.lua @@ -15,6 +15,9 @@ load("hpc-impi/2018.4.274") load("modulefile.ProdGSI.common") +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +load(pathJoin("prod_util", prod_util_ver)) + pushenv("CFLAGS", "-axSSE4.2,AVX,CORE-AVX2") pushenv("FFLAGS", "-axSSE4.2,AVX,CORE-AVX2") diff --git a/modulefiles/modulefile.ProdGSI.orion.lua b/modulefiles/modulefile.ProdGSI.orion.lua index 55612e7e5..37e56308f 100644 --- a/modulefiles/modulefile.ProdGSI.orion.lua +++ b/modulefiles/modulefile.ProdGSI.orion.lua @@ -8,6 +8,7 @@ local hpc_intel_ver=os.getenv("hpc_intel_ver") or "2018.4" local impi_ver=os.getenv("hpc_impi_ver") or "2018.4" local cmake_ver=os.getenv("cmake_ver") or "3.22.1" local python_ver=os.getenv("python_ver") or "3.7.5" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-intel", hpc_intel_ver)) @@ -17,6 +18,8 @@ load(pathJoin("python", python_ver)) load("modulefile.ProdGSI.common") +load(pathJoin("prod_util", prod_util_ver)) + pushenv("CFLAGS", "-xHOST") pushenv("FFLAGS", "-xHOST") diff --git a/modulefiles/modulefile.ProdGSI.s4.lua b/modulefiles/modulefile.ProdGSI.s4.lua index 8c5a15dad..23983b8c8 100644 --- a/modulefiles/modulefile.ProdGSI.s4.lua +++ b/modulefiles/modulefile.ProdGSI.s4.lua @@ -5,6 +5,7 @@ local hpc_ver=os.getenv("hpc_ver") or "1.1.0" local hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.4" local impi_ver=os.getenv("hpc_impi_ver") or "18.0.4" local miniconda_ver=os.getenv("miniconda_ver") or "3.8-s4" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" prepend_path("MODULEPATH", "/data/prod/hpc-stack/modulefiles/stack") @@ -17,6 +18,8 @@ load(pathJoin("miniconda", miniconda_ver)) load("modulefile.ProdGSI.common") +load(pathJoin("prod_util", prod_util_ver)) + pushenv("CFLAGS", "-march=ivybridge") pushenv("FFLAGS", "-march=ivybridge") diff --git a/modulefiles/modulefile.ProdGSI.wcoss2.lua b/modulefiles/modulefile.ProdGSI.wcoss2.lua index 925bbd23e..29510e1eb 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss2.lua +++ b/modulefiles/modulefile.ProdGSI.wcoss2.lua @@ -7,6 +7,7 @@ local craype_ver=os.getenv("craype_ver") or "2.7.8" local cray_mpich_ver=os.getenv("cray_mpich_ver") or "8.1.7" local cmake_ver= os.getenv("cmake_ver") or "3.20.2" local python_ver=os.getenv("python_ver") or "3.8.6" +local prod_util_ver=os.getenv("prod_util_ver") or "2.0.10" load(pathJoin("PrgEnv-intel", PrgEnv_intel_ver)) load(pathJoin("intel", intel_ver)) @@ -15,6 +16,8 @@ load(pathJoin("cray-mpich", cray_mpich_ver)) load(pathJoin("cmake", cmake_ver)) load(pathJoin("python", python_ver)) +load(pathJoin("prod_util", prod_util_ver)) + load("modulefile.ProdGSI.common") whatis("Description: GSI environment on WCOSS2") diff --git a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua index bb48d8524..b8c3eb5e3 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua +++ b/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua @@ -10,6 +10,7 @@ local jasper_ver=os.getenv("jasper_ver") or "2.0.22" local zlib_ver=os.getenv("zlib_ver") or "1.2.11" local png_ver=os.getenv("png_ver") or "1.6.35" local python_ver=os.getenv("python_ver") or "3.6.3" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("python", python_ver)) load(pathJoin("lsf", lsf_ver)) @@ -27,6 +28,8 @@ load(pathJoin("png", png_ver)) load("modulefile.ProdGSI.common") +load(pathJoin("prod_util", prod_util_ver)) + pushenv("CFLAGS", "-xHOST") pushenv("FFLAGS", "-xHOST") From f62401dddc94a21d5cf391c50f00dc638e1e8ab7 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 10 May 2022 13:40:29 -0400 Subject: [PATCH 73/76] since we are changing modulefiles, make their names short and consistent with other applications --- ...odulefile.ProdGSI.cheyenne.gnu.lua => gsi_cheyenne.gnu.lua} | 2 +- ...efile.ProdGSI.cheyenne.intel.lua => gsi_cheyenne.intel.lua} | 2 +- modulefiles/{modulefile.ProdGSI.common.lua => gsi_common.lua} | 0 modulefiles/{modulefile.ProdGSI.discover => gsi_discover} | 0 modulefiles/{modulefile.ProdGSI.gaea => gsi_gaea} | 0 .../{modulefile.ProdGSI.hera.gnu.lua => gsi_hera.gnu.lua} | 2 +- .../{modulefile.ProdGSI.hera.intel.lua => gsi_hera.intel.lua} | 2 +- modulefiles/{modulefile.ProdGSI.jet.lua => gsi_jet.lua} | 2 +- modulefiles/{modulefile.ProdGSI.orion.lua => gsi_orion.lua} | 2 +- modulefiles/{modulefile.ProdGSI.s4.lua => gsi_s4.lua} | 2 +- modulefiles/{modulefile.ProdGSI.wcoss2.lua => gsi_wcoss2.lua} | 2 +- modulefiles/{modulefile.ProdGSI.wcoss_cray => gsi_wcoss_cray} | 0 ...ulefile.ProdGSI.wcoss_dell_p3.lua => gsi_wcoss_dell_p3.lua} | 2 +- ush/build.sh | 2 +- ush/sub_discover | 2 +- ush/sub_hera | 2 +- ush/sub_jet | 3 ++- ush/sub_wcoss_d | 2 +- 18 files changed, 15 insertions(+), 14 deletions(-) rename modulefiles/{modulefile.ProdGSI.cheyenne.gnu.lua => gsi_cheyenne.gnu.lua} (94%) rename modulefiles/{modulefile.ProdGSI.cheyenne.intel.lua => gsi_cheyenne.intel.lua} (94%) rename modulefiles/{modulefile.ProdGSI.common.lua => gsi_common.lua} (100%) rename modulefiles/{modulefile.ProdGSI.discover => gsi_discover} (100%) rename modulefiles/{modulefile.ProdGSI.gaea => gsi_gaea} (100%) rename modulefiles/{modulefile.ProdGSI.hera.gnu.lua => gsi_hera.gnu.lua} (95%) rename modulefiles/{modulefile.ProdGSI.hera.intel.lua => gsi_hera.intel.lua} (96%) rename modulefiles/{modulefile.ProdGSI.jet.lua => gsi_jet.lua} (94%) rename modulefiles/{modulefile.ProdGSI.orion.lua => gsi_orion.lua} (95%) rename modulefiles/{modulefile.ProdGSI.s4.lua => gsi_s4.lua} (95%) rename modulefiles/{modulefile.ProdGSI.wcoss2.lua => gsi_wcoss2.lua} (95%) rename modulefiles/{modulefile.ProdGSI.wcoss_cray => gsi_wcoss_cray} (100%) rename modulefiles/{modulefile.ProdGSI.wcoss_dell_p3.lua => gsi_wcoss_dell_p3.lua} (97%) diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua b/modulefiles/gsi_cheyenne.gnu.lua similarity index 94% rename from modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua rename to modulefiles/gsi_cheyenne.gnu.lua index 3bc61b54c..9cd033752 100644 --- a/modulefiles/modulefile.ProdGSI.cheyenne.gnu.lua +++ b/modulefiles/gsi_cheyenne.gnu.lua @@ -15,7 +15,7 @@ load("hpc/1.2.0") load("hpc-gnu/10.1.0") load("hpc-mpt/2.22") -load("modulefile.ProdGSI.common") +load("gsi_common") local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua b/modulefiles/gsi_cheyenne.intel.lua similarity index 94% rename from modulefiles/modulefile.ProdGSI.cheyenne.intel.lua rename to modulefiles/gsi_cheyenne.intel.lua index cf8f231c8..9a0c4f721 100644 --- a/modulefiles/modulefile.ProdGSI.cheyenne.intel.lua +++ b/modulefiles/gsi_cheyenne.intel.lua @@ -15,7 +15,7 @@ load("hpc-intel/2021.2") load("hpc-mpt/2.22") load("mkl/2021.2") -load("modulefile.ProdGSI.common") +load("gsi_common") local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.common.lua b/modulefiles/gsi_common.lua similarity index 100% rename from modulefiles/modulefile.ProdGSI.common.lua rename to modulefiles/gsi_common.lua diff --git a/modulefiles/modulefile.ProdGSI.discover b/modulefiles/gsi_discover similarity index 100% rename from modulefiles/modulefile.ProdGSI.discover rename to modulefiles/gsi_discover diff --git a/modulefiles/modulefile.ProdGSI.gaea b/modulefiles/gsi_gaea similarity index 100% rename from modulefiles/modulefile.ProdGSI.gaea rename to modulefiles/gsi_gaea diff --git a/modulefiles/modulefile.ProdGSI.hera.gnu.lua b/modulefiles/gsi_hera.gnu.lua similarity index 95% rename from modulefiles/modulefile.ProdGSI.hera.gnu.lua rename to modulefiles/gsi_hera.gnu.lua index 145859893..ddf96cc84 100644 --- a/modulefiles/modulefile.ProdGSI.hera.gnu.lua +++ b/modulefiles/gsi_hera.gnu.lua @@ -14,7 +14,7 @@ load(pathJoin("hpc-gnu", hpc_gnu_ver)) load(pathJoin("hpc-mpich", hpc_mpich_ver)) load(pathJoin("cmake", cmake_ver)) -load("modulefile.ProdGSI.common") +load("gsi_common") load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.hera.intel.lua b/modulefiles/gsi_hera.intel.lua similarity index 96% rename from modulefiles/modulefile.ProdGSI.hera.intel.lua rename to modulefiles/gsi_hera.intel.lua index 35d50df06..e1f45be71 100644 --- a/modulefiles/modulefile.ProdGSI.hera.intel.lua +++ b/modulefiles/gsi_hera.intel.lua @@ -19,7 +19,7 @@ prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") load(pathJoin("anaconda", anaconda_ver)) -load("modulefile.ProdGSI.common") +load("gsi_common") load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.jet.lua b/modulefiles/gsi_jet.lua similarity index 94% rename from modulefiles/modulefile.ProdGSI.jet.lua rename to modulefiles/gsi_jet.lua index 14a62aea6..df05f2947 100644 --- a/modulefiles/modulefile.ProdGSI.jet.lua +++ b/modulefiles/gsi_jet.lua @@ -13,7 +13,7 @@ load("hpc/1.1.0") load("hpc-intel/18.0.5.274") load("hpc-impi/2018.4.274") -load("modulefile.ProdGSI.common") +load("gsi_common") local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.orion.lua b/modulefiles/gsi_orion.lua similarity index 95% rename from modulefiles/modulefile.ProdGSI.orion.lua rename to modulefiles/gsi_orion.lua index 37e56308f..bfe4dcb40 100644 --- a/modulefiles/modulefile.ProdGSI.orion.lua +++ b/modulefiles/gsi_orion.lua @@ -16,7 +16,7 @@ load(pathJoin("hpc-impi", hpc_impi_ver)) load(pathJoin("cmake", cmake_ver)) load(pathJoin("python", python_ver)) -load("modulefile.ProdGSI.common") +load("gsi_common") load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.s4.lua b/modulefiles/gsi_s4.lua similarity index 95% rename from modulefiles/modulefile.ProdGSI.s4.lua rename to modulefiles/gsi_s4.lua index 23983b8c8..cf047aae9 100644 --- a/modulefiles/modulefile.ProdGSI.s4.lua +++ b/modulefiles/gsi_s4.lua @@ -16,7 +16,7 @@ load(pathJoin("hpc-impi", hpc_impi_ver)) load(pathJoin("miniconda", miniconda_ver)) -load("modulefile.ProdGSI.common") +load("gsi_common") load(pathJoin("prod_util", prod_util_ver)) diff --git a/modulefiles/modulefile.ProdGSI.wcoss2.lua b/modulefiles/gsi_wcoss2.lua similarity index 95% rename from modulefiles/modulefile.ProdGSI.wcoss2.lua rename to modulefiles/gsi_wcoss2.lua index 29510e1eb..138946252 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss2.lua +++ b/modulefiles/gsi_wcoss2.lua @@ -18,6 +18,6 @@ load(pathJoin("python", python_ver)) load(pathJoin("prod_util", prod_util_ver)) -load("modulefile.ProdGSI.common") +load("gsi_common") whatis("Description: GSI environment on WCOSS2") diff --git a/modulefiles/modulefile.ProdGSI.wcoss_cray b/modulefiles/gsi_wcoss_cray similarity index 100% rename from modulefiles/modulefile.ProdGSI.wcoss_cray rename to modulefiles/gsi_wcoss_cray diff --git a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua b/modulefiles/gsi_wcoss_dell_p3.lua similarity index 97% rename from modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua rename to modulefiles/gsi_wcoss_dell_p3.lua index b8c3eb5e3..aa1ddd646 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_dell_p3.lua +++ b/modulefiles/gsi_wcoss_dell_p3.lua @@ -26,7 +26,7 @@ load(pathJoin("jasper", jasper_ver)) load(pathJoin("zlib", zlib_ver)) load(pathJoin("png", png_ver)) -load("modulefile.ProdGSI.common") +load("gsi_common") load(pathJoin("prod_util", prod_util_ver)) diff --git a/ush/build.sh b/ush/build.sh index 45b37a75e..84423f6a5 100755 --- a/ush/build.sh +++ b/ush/build.sh @@ -24,7 +24,7 @@ source $DIR_ROOT/ush/detect_machine.sh # Load modules source $DIR_ROOT/ush/module-setup.sh module use $DIR_ROOT/modulefiles -module load modulefile.ProdGSI.$MACHINE_ID +module load gsi_$MACHINE_ID module list # Set CONTROLPATH variables for Regression testing on supported MACHINE_ID diff --git a/ush/sub_discover b/ush/sub_discover index 84b410be6..835cd37ac 100755 --- a/ush/sub_discover +++ b/ush/sub_discover @@ -130,7 +130,7 @@ echo "" >>$cfile echo ". "$(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9 }' $regdir/regression_var.out) >>$cfile echo "" >>$cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.discover" >> $cfile +echo "module load gsi_discover" >> $cfile echo "" >>$cfile echo "jobname=$jobname" >>$cfile echo "" >>$cfile diff --git a/ush/sub_hera b/ush/sub_hera index 7aabda3db..d90441719 100755 --- a/ush/sub_hera +++ b/ush/sub_hera @@ -138,7 +138,7 @@ echo "" >>$cfile echo ". /apps/lmod/lmod/init/sh" >> $cfile echo "module purge" >> $cfile echo "module use $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.hera" >> $cfile +echo "module load gsi_hera.intel" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/ush/sub_jet b/ush/sub_jet index df6a4779d..5bd9a6d68 100755 --- a/ush/sub_jet +++ b/ush/sub_jet @@ -131,7 +131,8 @@ echo "" >>$cfile echo ". /apps/lmod/lmod/init/sh" >> $cfile echo "module purge" >> $cfile -echo "source $gsisrc/modulefiles/modulefile.ProdGSI.jet" >> $cfile +echo "module use $gsisrc/modulefiles" >> $cfile +echo "module load gsi_jet" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/ush/sub_wcoss_d b/ush/sub_wcoss_d index 818f0d6a0..84a57226b 100755 --- a/ush/sub_wcoss_d +++ b/ush/sub_wcoss_d @@ -312,7 +312,7 @@ echo "" >>$cfile echo ". $MODULESHOME/init/bash" >> $cfile echo "module purge" >> $cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.wcoss_dell_p3" >> $cfile +echo "module load gsi_wcoss_dell_p3" >> $cfile echo "module list" >> $cfile echo "" >>$cfile From 701247a73b50899a31522f23a4245d45e4f52b54 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 11 May 2022 16:37:43 -0400 Subject: [PATCH 74/76] wcoss_dell_p3 cmake is from hpc-stack. Fix that. update detect_machine.sh and module-setup.sh for wcoss2. be smart in auto-detection. fix warnings in source codes. --- modulefiles/gsi_wcoss_dell_p3.lua | 3 +- src/ncdiag/ncdf_string_m.f90 | 4 +- ush/detect_machine.sh | 136 ++++++++--------------------- ush/module-setup.sh | 4 + util/NMC_Bkerror/sorc/mat.f90 | 8 +- util/NMC_Bkerror/sorc_aero/mat.f90 | 8 +- 6 files changed, 51 insertions(+), 112 deletions(-) diff --git a/modulefiles/gsi_wcoss_dell_p3.lua b/modulefiles/gsi_wcoss_dell_p3.lua index aa1ddd646..1db53e308 100644 --- a/modulefiles/gsi_wcoss_dell_p3.lua +++ b/modulefiles/gsi_wcoss_dell_p3.lua @@ -14,7 +14,6 @@ local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" load(pathJoin("python", python_ver)) load(pathJoin("lsf", lsf_ver)) -load(pathJoin("cmake", cmake_ver)) prepend_path("MODULEPATH", "/usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack") @@ -22,6 +21,8 @@ load(pathJoin("hpc", hpc_ver)) load(pathJoin("hpc-ips", hpc_ips_ver)) load(pathJoin("hpc-impi", hpc_impi_ver)) +load(pathJoin("cmake", cmake_ver)) + load(pathJoin("jasper", jasper_ver)) load(pathJoin("zlib", zlib_ver)) load(pathJoin("png", png_ver)) diff --git a/src/ncdiag/ncdf_string_m.f90 b/src/ncdiag/ncdf_string_m.f90 index 8c6a4e139..9f4e3321a 100644 --- a/src/ncdiag/ncdf_string_m.f90 +++ b/src/ncdiag/ncdf_string_m.f90 @@ -28,7 +28,7 @@ module ncdf_string_m private public :: ncdf_string, ncdf_string_create, ncdf_string_destroy, ncdf_ncdf_string_length, ncdf_string_append,& - ncdf_ncdf_string_clear + ncdf_string_clear public :: ncdf_string_equals, ncdf_string_copy integer, parameter :: BLOCK_SIZE = 32 @@ -172,7 +172,7 @@ end subroutine ncdf_append_char subroutine ncdf_copy_chars(this, to) type(ncdf_string), pointer :: this character(len = *), intent(inout) :: to - integer :: length + integer :: i, length length = min(ncdf_string_length(this), len(to)) diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh index f1e8df8a5..0eae636cb 100755 --- a/ush/detect_machine.sh +++ b/ush/detect_machine.sh @@ -2,117 +2,51 @@ case $(hostname -f) in - llogin1) MACHINE_ID=wcoss_cray ;; ### luna - llogin2) MACHINE_ID=wcoss_cray ;; ### luna - llogin3) MACHINE_ID=wcoss_cray ;; ### luna - - slogin1) MACHINE_ID=wcoss_cray ;; ### surge - slogin2) MACHINE_ID=wcoss_cray ;; ### surge - slogin3) MACHINE_ID=wcoss_cray ;; ### surge - - v71a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus - v71a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus - v71a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus - v72a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus - v72a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus - v72a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus - - m71a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars - m71a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars - m71a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars - m72a1.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars - m72a2.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars - m72a3.ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars - - alogin01.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn - alogin02.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn - adecflow01.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn - adecflow02.acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn - - gaea9) MACHINE_ID=gaea ;; ### gaea9 - gaea10) MACHINE_ID=gaea ;; ### gaea10 - gaea11) MACHINE_ID=gaea ;; ### gaea11 - gaea12) MACHINE_ID=gaea ;; ### gaea12 - gaea13) MACHINE_ID=gaea ;; ### gaea13 - gaea14) MACHINE_ID=gaea ;; ### gaea14 - gaea15) MACHINE_ID=gaea ;; ### gaea15 - gaea16) MACHINE_ID=gaea ;; ### gaea16 - gaea9.ncrc.gov) MACHINE_ID=gaea ;; ### gaea9 - gaea10.ncrc.gov) MACHINE_ID=gaea ;; ### gaea10 - gaea11.ncrc.gov) MACHINE_ID=gaea ;; ### gaea11 - gaea12.ncrc.gov) MACHINE_ID=gaea ;; ### gaea12 - gaea13.ncrc.gov) MACHINE_ID=gaea ;; ### gaea13 - gaea14.ncrc.gov) MACHINE_ID=gaea ;; ### gaea14 - gaea15.ncrc.gov) MACHINE_ID=gaea ;; ### gaea15 - gaea16.ncrc.gov) MACHINE_ID=gaea ;; ### gaea16 - - hfe01) MACHINE_ID=hera ;; ### hera01 - hfe02) MACHINE_ID=hera ;; ### hera02 - hfe03) MACHINE_ID=hera ;; ### hera03 - hfe04) MACHINE_ID=hera ;; ### hera04 - hfe05) MACHINE_ID=hera ;; ### hera05 - hfe06) MACHINE_ID=hera ;; ### hera06 - hfe07) MACHINE_ID=hera ;; ### hera07 - hfe08) MACHINE_ID=hera ;; ### hera08 - hfe09) MACHINE_ID=hera ;; ### hera09 - hfe10) MACHINE_ID=hera ;; ### hera10 - hfe11) MACHINE_ID=hera ;; ### hera11 - hfe12) MACHINE_ID=hera ;; ### hera12 - hecflow01) MACHINE_ID=hera ;; ### heraecflow01 + llogin[1-3]) MACHINE_ID=wcoss_cray ;; ### luna + slogin[1-3]) MACHINE_ID=wcoss_cray ;; ### surge + + m7[12]a[1-3].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + v7[12]a[1-3].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + m109a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars3.5 + m110a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars3.5 + v109a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus3.5 + v110a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus3.5 + + adecflow0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + alogin0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + clogin0[1-9].cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus01-9 + clogin10.cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus10 + dlogin0[1-9].dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood01-9 + dlogin10.dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood10 + + gaea9) MACHINE_ID=gaea ;; ### gaea9 + gaea1[0-6]) MACHINE_ID=gaea ;; ### gaea10-16 + gaea9.ncrc.gov) MACHINE_ID=gaea ;; ### gaea9 + gaea1[0-6].ncrc.gov) MACHINE_ID=gaea ;; ### gaea10-16 + + hfe0[1-9]) MACHINE_ID=hera ;; ### hera01-9 + hfe1[0-2]) MACHINE_ID=hera ;; ### hera10-12 + hecflow01) MACHINE_ID=hera ;; ### heraecflow01 s4-submit.ssec.wisc.edu) MACHINE_ID=s4 ;; ### s4 - fe1) MACHINE_ID=jet ;; ### jet01 - fe2) MACHINE_ID=jet ;; ### jet02 - fe3) MACHINE_ID=jet ;; ### jet03 - fe4) MACHINE_ID=jet ;; ### jet04 - fe5) MACHINE_ID=jet ;; ### jet05 - fe6) MACHINE_ID=jet ;; ### jet06 - fe7) MACHINE_ID=jet ;; ### jet07 - fe8) MACHINE_ID=jet ;; ### jet08 - tfe1) MACHINE_ID=jet ;; ### jet09 - tfe2) MACHINE_ID=jet ;; ### jet10 + fe[1-8]) MACHINE_ID=jet ;; ### jet01-8 + tfe[12]) MACHINE_ID=jet ;; ### tjet1-2 - Orion-login-1.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion1 - Orion-login-2.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion2 - Orion-login-3.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion3 - Orion-login-4.HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion4 + Orion-login-[1-4].HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion1-4 - cheyenne1.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - cheyenne2.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne2 - cheyenne3.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne3 - cheyenne4.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne4 - cheyenne5.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne5 - cheyenne6.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne6 - cheyenne1.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - cheyenne2.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne2 - cheyenne3.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne3 - cheyenne4.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne4 - cheyenne5.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne5 - cheyenne6.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne6 - chadmin1.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - chadmin2.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - chadmin3.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - chadmin4.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - chadmin5.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 - chadmin6.ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1 + cheyenne[1-6].cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1-6 + cheyenne[1-6].ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1-6 + chadmin[1-6].ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1-6 - login1.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede1 - login2.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede2 - login3.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede3 - login4.stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede4 + login[1-4].stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede1-4 - login01.expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1 - login02.expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse2 + login0[1-2].expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1-2 - discover31.prv.cube) MACHINE_ID=discover ;; ### discover - discover32.prv.cube) MACHINE_ID=discover ;; ### discover - discover33.prv.cube) MACHINE_ID=discover ;; ### discover - discover34.prv.cube) MACHINE_ID=discover ;; ### discover - discover35.prv.cube) MACHINE_ID=discover ;; ### discover + discover3[1-5].prv.cube) MACHINE_ID=discover ;; ### discover31-35 esac -# Overwrite auto-detect with RT_MACHINE if set +# Overwrite auto-detect with MACHINE if set MACHINE_ID=${MACHINE:-${MACHINE_ID}} # Append compiler (only on machines that have multiple compilers) diff --git a/ush/module-setup.sh b/ush/module-setup.sh index 433022cff..67821de82 100755 --- a/ush/module-setup.sh +++ b/ush/module-setup.sh @@ -53,6 +53,10 @@ elif [[ $MACHINE_ID = wcoss_dell_p3 ]] ; then fi module purge +elif [[ $MACHINE_ID = wcoss2 ]]; then + # We are on WCOSS2 + module reset + elif [[ $MACHINE_ID = cheyenne* ]] ; then # We are on NCAR Cheyenne if ( ! eval module help > /dev/null 2>&1 ) ; then diff --git a/util/NMC_Bkerror/sorc/mat.f90 b/util/NMC_Bkerror/sorc/mat.f90 index 2a1f09850..0544aa270 100644 --- a/util/NMC_Bkerror/sorc/mat.f90 +++ b/util/NMC_Bkerror/sorc/mat.f90 @@ -820,7 +820,7 @@ SUBROUTINE MULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE PRGV(D,M) - PARAMETER(CRIT=1.E-60) + PARAMETER(CRIT=1.E-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -2960,7 +2960,7 @@ SUBROUTINE DMULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE DPRGV(D,M) - PARAMETER(CRIT=1.D-60) + PARAMETER(CRIT=1.D-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -3195,7 +3195,7 @@ SUBROUTINE DTSINI TS(0,1)=T KSIG=-1 DO I=1,NI - IF(ABS(T).LE.1.E-60)THEN + IF(ABS(T).LE.1.E-37)THEN TS(I,1)=0 ELSE I2=I*2 @@ -3664,7 +3664,7 @@ SUBROUTINE DWRTM(A,MI,MJ,JCOLS,NA) J2=MIN(MJ,J1+JCOLS-1) PRINT'(8X,10(I3,9X))',(J,J=J1,J2) DO I=1,MI - PRINT'(1X,I3,10(1X,E11.5))',I,(A(I,J),J=J1,J2) + PRINT'(1X,I3,10(1X,E12.5))',I,(A(I,J),J=J1,J2) ENDDO PRINT'()' ENDDO diff --git a/util/NMC_Bkerror/sorc_aero/mat.f90 b/util/NMC_Bkerror/sorc_aero/mat.f90 index 2a1f09850..0544aa270 100644 --- a/util/NMC_Bkerror/sorc_aero/mat.f90 +++ b/util/NMC_Bkerror/sorc_aero/mat.f90 @@ -820,7 +820,7 @@ SUBROUTINE MULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE PRGV(D,M) - PARAMETER(CRIT=1.E-60) + PARAMETER(CRIT=1.E-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -2960,7 +2960,7 @@ SUBROUTINE DMULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE DPRGV(D,M) - PARAMETER(CRIT=1.D-60) + PARAMETER(CRIT=1.D-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -3195,7 +3195,7 @@ SUBROUTINE DTSINI TS(0,1)=T KSIG=-1 DO I=1,NI - IF(ABS(T).LE.1.E-60)THEN + IF(ABS(T).LE.1.E-37)THEN TS(I,1)=0 ELSE I2=I*2 @@ -3664,7 +3664,7 @@ SUBROUTINE DWRTM(A,MI,MJ,JCOLS,NA) J2=MIN(MJ,J1+JCOLS-1) PRINT'(8X,10(I3,9X))',(J,J=J1,J2) DO I=1,MI - PRINT'(1X,I3,10(1X,E11.5))',I,(A(I,J),J=J1,J2) + PRINT'(1X,I3,10(1X,E12.5))',I,(A(I,J),J=J1,J2) ENDDO PRINT'()' ENDDO From 0c04e95c10fc86c5ed2b6b458e4fd12df2c574aa Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 11 May 2022 20:58:08 +0000 Subject: [PATCH 75/76] protect against accidental commits of binaries --- .gitignore | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.gitignore b/.gitignore index 69d5565ea..07e383156 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,30 @@ install*/ *.mod .DS_Store exec/ +lib/ +lib64/ nohup.out log* build.log* install.log* + +# Ensure no one adds binary files to this repo. Not even by accident. +# over-riding this file can be done in the subdirectory +*.bin +*.nc* +*.tar* +*.tgz +*.gz +*.png +*.jp*g +*.tiff + +# Python related +_pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + From b600136cb5333c6ba152cfc9a0990fdfa9eff80a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Thu, 12 May 2022 15:13:15 -0400 Subject: [PATCH 76/76] explicitly use calls from MPI module --- src/enkf/gridinfo_fv3reg.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index e1db4a102..cdc56c99f 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -42,7 +42,7 @@ module gridinfo ! !$$$ -use mpi +use mpi, only: mpi_real4,mpi_comm_world use mpisetup, only: nproc use params, only: datapath,nlevs,nlons,nlats,use_gfs_nemsio, fgfileprefixes, & fv3fixpath, nx_res,ny_res, ntiles,l_fv3reg_filecombined