From 70e98cb91acb1cb5d45deb875194cc52b34d80ca Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Sun, 5 Jan 2020 20:54:39 -0700 Subject: [PATCH 1/6] Updates to support vs2019 and vcpkg. + Add some debug output to `CMakeAddFortranSubdirectory`. This should only be active if the local macro variable `verbose` is `true`. + Update `print_target_properties` to print target values related to file LOCATIONS. + Update how MPI is discovered for VS2019 builds that provide msmpi via vcpkg. Also add some debug prints that can optionally be enabled. Tested with MS-MPI 10.0. + Update `vendor_libraries` to correctly create imported targets for openblas for VS2019. openblas can be installed via vcpkg. + The f90sub Fortran package is built via CAFS under VS2019 (with MSYS2 MinGW's gfortran). Newer CMake (3.16.1) and MS-MPI (10.0) behave a little different that the older versions and extra logic was needed to correctly point to the MPI libraries. (Also, start using a target property to ensure the generated library is installed in the correct location.) + When TPLs are provided by vcpkg, we use a `CMAKE_TOOLCHAIN_FILE`. Ensure that this information is passed to the CAFS sub-project. + Remove unnecessary DLL_PUBLIC decoration from `fc_derivided_type.cc`. + Remove double underscores from CPP names in lapack_wrap. + Update the `quadrature/CMakeLists.txt` portions related to CAFS so they match the commands used in `FortranChecks`. --- CMakeLists.txt | 3 +- CMakeSettings.json | 33 ++++++ config/CMakeAddFortranSubdirectory.cmake | 25 ++-- config/compilerEnv.cmake | 22 ++-- config/print_target_properties.cmake | 15 +-- config/setupMPI.cmake | 138 +++++++++++++++++------ config/vendor_libraries.cmake | 35 +++++- src/FortranChecks/CMakeLists.txt | 21 ++-- src/FortranChecks/f90sub/CMakeLists.txt | 25 +++- src/FortranChecks/fc_derived_type.cc | 8 +- src/lapack_wrap/Blas.hh | 6 +- src/lapack_wrap/Blas_Prototypes.hh | 6 +- src/quadrature/CMakeLists.txt | 27 +++-- src/quadrature/ftest/CMakeLists.txt | 12 +- 14 files changed, 276 insertions(+), 100 deletions(-) create mode 100644 CMakeSettings.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6619d20780..33d14253cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,7 @@ # author Kelly Thompson # date 2010 April 28 # brief Instructions for building root level Makefile. -# note Copyright (C) 2016-2019 Triad National Security, LLC. -# All rights reserved. +# note Copyright (C) 2019 Triad National Security, LLC. All rights reserved. #------------------------------------------------------------------------------# # Build notes: diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000000..687ee73c7a --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,33 @@ +{ + "configurations": [ + { + "name": "x64-Debug", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "c:/work/vs2019-${name}/draco", + "installRoot": "c:/work/vs2019-${name}/install", + "cmakeCommandArgs": "", + "buildCommandArgs": "-verbosity:minimal -m:8", + "ctestCommandArgs": "-j 8 --output-on-failure", + "cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake", + "variables": [], + "cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe" + }, + { + "name": "x64-Release", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Release", + "buildRoot": "c:/work/vs2019-${name}/draco", + "installRoot": "c:/work/vs2019-${name}/install", + "cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe", + "cmakeCommandArgs": "", + "buildCommandArgs": "-verbosity:minimal -m:8", + "ctestCommandArgs": "-j 8 --output-on-failure", + "cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [], + "cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe" + } + ] +} \ No newline at end of file diff --git a/config/CMakeAddFortranSubdirectory.cmake b/config/CMakeAddFortranSubdirectory.cmake index 5f5689155a..82efeedc1b 100644 --- a/config/CMakeAddFortranSubdirectory.cmake +++ b/config/CMakeAddFortranSubdirectory.cmake @@ -25,11 +25,12 @@ # # cmake_add_fortran_subdirectory( # # name of subdirectory -# PROJECT # project name in subdir top CMakeLists.txt +# PROJECT # project name in subdirectories's top +# # CMakeLists.txt # # recommendation: use the same project name as # # listed in /CMakeLists.txt -# ARCHIVE_DIR # dir where project places .lib files -# RUNTIME_DIR # dir where project places .dll files +# ARCHIVE_DIR # directory where project places .lib files +# RUNTIME_DIR # directory where project places .dll files # LIBRARIES ... # names of library targets to import # TARGET_NAMES ...# target names assigned to the libraries listed # # above available in the primary project. @@ -401,16 +402,24 @@ endfunction() #-----------------------------------------------------------------------------# function( cafs_fix_mpi_library ) + set(verbose FALSE) + # MS-MPI and gfortran do not play nice together... if(WIN32) - + if(verbose) + message("CAFS: MPI_Fortran_LIBRARIES= ${MPI_Fortran_LIBRARIES}") + endif() if( NOT MPI_Fortran_LIBRARIES OR "${MPI_Fortran_LIBRARIES}" MATCHES "msmpi.lib" ) - # should be located at - # C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\[x86|x64] + # msmpi.lib should be located one of: + # - C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\[x86|x64] + # - %vcpkg%/installed/x64-windows/[debug]/lib if( MPI_msmpi_LIBRARY ) # FindMPI.cmake should have set $MPI_msmpi_LIBRARY. get_filename_component( MSMPI_SDK_DIR ${MPI_msmpi_LIBRARY} DIRECTORY) + if(verbose) + message("CAFS: MSMPI_SDK_DIR = ${MSMPI_SDK_DIR}") + endif() find_library( MPI_gfortran_LIBRARIES NAMES "libmsmpi.a" HINTS ${MSMPI_SDK_DIR} ) @@ -449,7 +458,9 @@ function( cafs_fix_mpi_library ) set( CMAKE_Fortran_${comp_opt} "${CMAKE_Fortran_${comp_opt}}" CACHE STRING "Compiler flags." FORCE ) endforeach() - + if(verbose) + message("CAFS: MPI_gfortran_LIBRARIES= ${MPI_gfortran_LIBRARIES}") + endif() endif(WIN32) endfunction(cafs_fix_mpi_library) diff --git a/config/compilerEnv.cmake b/config/compilerEnv.cmake index 9eac04364f..5c35582e7d 100644 --- a/config/compilerEnv.cmake +++ b/config/compilerEnv.cmake @@ -1,8 +1,7 @@ #-----------------------------*-cmake-*----------------------------------------# # file config/compilerEnv.cmake # brief Default CMake build parameters -# note Copyright (C) 2016-2019 Triad National Security, LLC. -# All rights reserved. +# note Copyright (C) 2019 Triad National Security, LLC. All rights reserved. #------------------------------------------------------------------------------# include_guard(GLOBAL) @@ -20,8 +19,10 @@ endif() # ---------------------------------------- if( DEFINED ENV{PAPI_HOME} ) set( HAVE_PAPI 1 CACHE BOOL "Is PAPI available on this machine?" ) - set( PAPI_INCLUDE $ENV{PAPI_INCLUDE} CACHE PATH "PAPI headers at this location" ) - set( PAPI_LIBRARY $ENV{PAPI_LIBDIR}/libpapi.so CACHE FILEPATH "PAPI library." ) + set( PAPI_INCLUDE $ENV{PAPI_INCLUDE} CACHE PATH + "PAPI headers at this location" ) + set( PAPI_LIBRARY $ENV{PAPI_LIBDIR}/libpapi.so CACHE FILEPATH + "PAPI library." ) endif() if( HAVE_PAPI ) @@ -567,22 +568,25 @@ macro(dbsSetupFortran) else() # If CMake doesn't know about a Fortran compiler, $ENV{FC}, then # also look for a compiler to use with CMakeAddFortranSubdirectory. - message( STATUS "Looking for CMakeAddFortranSubdirectory Fortran compiler...") + message( STATUS "Looking for CMakeAddFortranSubdirectory Fortran " + "compiler...") set( CAFS_Fortran_COMPILER "NOTFOUND" ) # Try to find a Fortran compiler (use MinGW gfortran for MSVC). find_program( CAFS_Fortran_COMPILER NAMES ${CAFS_Fortran_COMPILER} $ENV{CAFS_Fortran_COMPILER} gfortran PATHS + c:/msys64/mingw64/bin c:/MinGW/bin - c:/msys64/usr/bin - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MinGW;InstallLocation]/bin" ) + c:/msys64/usr/bin ) if( EXISTS ${CAFS_Fortran_COMPILER} ) set( HAVE_Fortran ON ) - message( STATUS "Looking for CMakeAddFortranSubdirectory Fortran compiler... found ${CAFS_Fortran_COMPILER}") + message( STATUS "Looking for CMakeAddFortranSubdirectory Fortran " + "compiler... found ${CAFS_Fortran_COMPILER}") else() - message( STATUS "Looking for CMakeAddFortranSubdirectory Fortran compiler... not found") + message( STATUS "Looking for CMakeAddFortranSubdirectory Fortran " + "compiler... not found") endif() endif() diff --git a/config/print_target_properties.cmake b/config/print_target_properties.cmake index 8a2b8b6a0f..8fcbdf24e1 100644 --- a/config/print_target_properties.cmake +++ b/config/print_target_properties.cmake @@ -59,28 +59,29 @@ function(echo_target tgt) # Convert command output into a CMake list string(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") string(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") + + list(REMOVE_DUPLICATES CMAKE_PROPERTY_LIST) foreach(prop ${CMAKE_PROPERTY_LIST}) # special cases first # Some targets aren't allowed: # Ref: https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i - if(prop STREQUAL "LOCATION" OR prop MATCHES "^LOCATION_" OR prop MATCHES "_LOCATION$") - continue() - elseif( prop MATCHES "" ) - continue() - endif() + #if(prop STREQUAL "LOCATION" OR prop MATCHES "^LOCATION_" OR prop MATCHES "_LOCATION$") + # continue() + #elseif( prop MATCHES "" ) + # continue() + #endif() if( ${prop} MATCHES "") foreach (c DEBUG RELEASE RELWITHDEBINFO MINSIZEREL) string(REPLACE "" "${c}" p ${prop}) - # message("prop ${p}") echo_target_property("${tgt}" "${p}") endforeach() + continue() endif() # everything else - # message("prop ${prop}") echo_target_property("${tgt}" "${prop}") endforeach() message("") diff --git a/config/setupMPI.cmake b/config/setupMPI.cmake index dca951a83f..2dafd52a20 100644 --- a/config/setupMPI.cmake +++ b/config/setupMPI.cmake @@ -177,10 +177,10 @@ endmacro() ##---------------------------------------------------------------------------## macro( query_topology ) - # These cmake commands, while useful, don't provide the topology detail that we - # are interested in (i.e. number of sockets per node). We could use the results - # of these queries to know if hyperthreading is enabled (if logical != physical - # cores) + # These cmake commands, while useful, don't provide the topology detail that + # we are interested in (i.e. number of sockets per node). We could use the + # results of these queries to know if hyper-threading is enabled (if logical + # != physical cores) # - cmake_host_system_information(RESULT MPI_PHYSICAL_CORES # QUERY NUMBER_OF_PHYSICAL_CORES) # - cmake_host_system_information(RESULT MPI_LOGICAL_CORES @@ -229,16 +229,16 @@ macro( query_topology ) "Number of cores per cpu" FORCE ) # - # Check for hyperthreading - This is important for reserving threads for + # Check for hyper-threading - This is important for reserving threads for # OpenMP tests... # math( EXPR MPI_MAX_NUMPROCS_PHYSICAL "${MPI_PHYSICAL_CORES} * ${MPI_CORES_PER_CPU}" ) if( "${MPI_MAX_NUMPROCS_PHYSICAL}" STREQUAL "${MPIEXEC_MAX_NUMPROCS}" ) - set( MPI_HYPERTHREADING "OFF" CACHE BOOL "Are we using hyperthreading?" + set( MPI_HYPERTHREADING "OFF" CACHE BOOL "Are we using hyper-threading?" FORCE ) else() - set( MPI_HYPERTHREADING "ON" CACHE BOOL "Are we using hyperthreading?" + set( MPI_HYPERTHREADING "ON" CACHE BOOL "Are we using hyper-threading?" FORCE ) endif() endmacro() @@ -269,7 +269,7 @@ macro( setupOpenMPI ) set( MPIEXEC_POSTFLAGS "-bind-to none ${runasroot}" CACHE STRING "extra mpirun flags (list)." FORCE) - # Find cores/cpu, cpu/node, hyperthreading + # Find cores/cpu, cpu/node, hyper-threading query_topology() # @@ -296,7 +296,7 @@ endmacro() ##---------------------------------------------------------------------------## macro( setupMpichMPI ) - # Find cores/cpu, cpu/node, hyperthreading + # Find cores/cpu, cpu/node, hyper-threading query_topology() endmacro() @@ -306,7 +306,7 @@ endmacro() ##---------------------------------------------------------------------------## macro( setupIntelMPI ) - # Find cores/cpu, cpu/node, hyperthreading + # Find cores/cpu, cpu/node, hyper-threading query_topology() endmacro() @@ -355,7 +355,7 @@ endmacro() ##---------------------------------------------------------------------------## macro( setupSpectrumMPI ) - # Find cores/cpu, cpu/node, hyperthreading + # Find cores/cpu, cpu/node, hyper-threading query_topology() # @@ -483,11 +483,41 @@ macro( setupMPILibrariesWindows ) if( NOT "${DRACO_C4}" STREQUAL "SCALAR" ) message(STATUS "Looking for MPI...") + set(MPI_ASSUME_NO_BUILTIN_MPI TRUE) + set(MPI_GUESS_LIBRARY_NAME "MSMPI") find_package( MPI QUIET ) + if( EXISTS "$ENV{MSMPI_INC}" ) + # if msmpi is installed via vcpkg, then use the vcpkg include path + # instead of the system one. + file(TO_CMAKE_PATH $ENV{MSMPI_INC} MSMPI_INC) + unset(tmp) + foreach( ipath ${MPI_C_INCLUDE_DIRS} ) + if( "${ipath}" STREQUAL "${MSMPI_INC}" ) + continue() + endif() + list(APPEND tmp ${ipath}) + endforeach() + set(MPI_C_INCLUDE_DIRS ${tmp}) + unset(tmp) + endif() + + if(verbose) + message(" + MPI_C_FOUND = ${MPI_C_FOUND} + MPIEXEC_EXECUTABLE = ${MPIEXEC_EXECUTABLE} + MPI_C_LIBRARIES = ${MPI_C_LIBRARIES} + MPI_CXX_LIBRARIES = ${MPI_CXX_LIBRARIES} + MPI_Fortran_LIBRARIES = ${MPI_Fortran_LIBRARIES} + MPI_C_LIB_NAMES = ${MPI_C_LIB_NAMES} + CMAKE_GENERATOR = ${CMAKE_GENERATOR} + MPI_C_INCLUDE_DIRS = ${MPI_C_INCLUDE_DIRS} + MPI_C_VERSION_MAJOR = ${MPI_C_VERSION_MAJOR}") + endif() + # If this macro is called from a MinGW builds system (for a CAFS - # subdirectory) and is trying to MS-MPI, the above check will fail (when - # cmake > 3.12). However, MS-MPI is known to be good when linking with + # subdirectory) and is trying to discover MS-MPI, the above check will fail + # (when CMake > 3.12). However, MS-MPI is known to be good when linking with # Visual Studio so override the 'failed' report. if( "${MPI_C_LIBRARIES}" MATCHES "msmpi" AND "${CMAKE_GENERATOR}" STREQUAL "MinGW Makefiles") @@ -496,6 +526,12 @@ macro( setupMPILibrariesWindows ) set( MPI_Fortran_FOUND TRUE ) endif() endif() + + if(verbose) + message(" + MPI_C_FOUND = ${MPI_C_FOUND} + MPI_Fortran_FOUND = ${MPI_Fortran_FOUND}") + endif() # For MS-MPI, mpifptr.h is architecture dependent. Figure out what arch this # is and save this path to MPI_Fortran_INCLUDE_PATH @@ -503,13 +539,21 @@ macro( setupMPILibrariesWindows ) if( first_c_mpi_library AND NOT MPI_Fortran_INCLUDE_PATH ) get_filename_component( MPI_Fortran_INCLUDE_PATH "${first_c_mpi_library}" DIRECTORY ) - string( REGEX REPLACE "[Ll]ib" "Include" MPI_Fortran_INCLUDE_PATH - ${MPI_Fortran_INCLUDE_PATH} ) - set( MPI_Fortran_INCLUDE_PATH - "${MPI_CXX_INCLUDE_PATH};${MPI_Fortran_INCLUDE_PATH}" - CACHE STRING "Location for MPI include files for Fortran.") + if(EXISTS "${MPI_Fortran_INCLUDE_PATH}/../include/mpifptr.h") + get_filename_component( MPI_Fortran_INCLUDE_PATH + "${MPI_Fortran_INCLUDE_PATH}/../include" REALPATH ) + elseif(EXISTS "${MPI_Fortran_INCLUDE_PATH}/../../include/mpifptr.h") + get_filename_component( MPI_Fortran_INCLUDE_PATH + "${MPI_Fortran_INCLUDE_PATH}/../../include" REALPATH ) + else() + string( REGEX REPLACE "[Ll]ib" "Include" MPI_Fortran_INCLUDE_PATH + ${MPI_Fortran_INCLUDE_PATH} ) + set( MPI_Fortran_INCLUDE_PATH + "${MPI_C_INCLUDE_PATH};${MPI_Fortran_INCLUDE_PATH}" + CACHE STRING "Location for MPI include files for Fortran.") + endif() if( verbose ) - message("MPI_Fortran_INCLUDE_PATH = ${MPI_Fortran_INCLUDE_PATH}") + message(" MPI_Fortran_INCLUDE_PATH = ${MPI_Fortran_INCLUDE_PATH}") endif() endif() @@ -522,26 +566,26 @@ macro( setupMPILibrariesWindows ) ERROR_VARIABLE DBS_MPI_VER_ERR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) + ERROR_STRIP_TRAILING_WHITESPACE ) if( "${DBS_MPI_VER_OUT}" MATCHES "Microsoft MPI Startup Program" ) string( REGEX REPLACE ".*Version ([0-9.]+).*" "\\1" DBS_MPI_VER "${DBS_MPI_VER_OUT}${DBS_MPI_VER_ERR}") - string( REGEX REPLACE ".*([0-9])[.]([0-9])[.]([0-9]+).*" "\\1" - DBS_MPI_VER_MAJOR ${DBS_MPI_VER} ) - string( REGEX REPLACE ".*([0-9])[.]([0-9])[.]([0-9]+).*" "\\2" - DBS_MPI_VER_MINOR ${DBS_MPI_VER} ) + string(REPLACE "." ";" DBS_MPI_VER ${DBS_MPI_VER}) + list(GET DBS_MPI_VER 0 DBS_MPI_VER_MAJOR) + list(GET DBS_MPI_VER 1 DBS_MPI_VER_MINOR) set( DBS_MPI_VER "${DBS_MPI_VER_MAJOR}.${DBS_MPI_VER_MINOR}") else() set(DBS_MPI_VER "5.0") endif() + if(verbose) + message(" DBS_MPI_VER = ${DBS_MPI_VER}") + endif() set_package_properties( MPI PROPERTIES URL "https://msdn.microsoft.com/en-us/library/bb524831%28v=vs.85%29.aspx" DESCRIPTION "Microsoft MPI" TYPE RECOMMENDED - PURPOSE "If not available, all Draco components will be built as scalar applications." - ) + PURPOSE "If not available, all Draco components will be built as scalar applications.") # Check flavor and add optional flags if("${MPIEXEC_EXECUTABLE}" MATCHES "Microsoft MPI") @@ -570,21 +614,21 @@ macro( setupMPILibrariesWindows ) set( MPI_CPUS_PER_NODE ${MPI_CPUS_PER_NODE} CACHE STRING "Number of multi-core CPUs per node" FORCE ) set( MPI_CORES_PER_CPU ${MPI_CORES_PER_CPU} CACHE STRING - "Number of cores per cpu" FORCE ) + "Number of cores per CPU" FORCE ) set( MPIEXEC_MAX_NUMPROCS ${MPIEXEC_MAX_NUMPROCS} CACHE STRING "Total number of available MPI ranks" FORCE ) - # Check for hyperthreading - This is important for reserving - # threads for OpenMP tests... + # Check for hyper-threading - This is important for reserving threads for + # OpenMP tests... math( EXPR MPI_MAX_NUMPROCS_PHYSICAL "${MPI_CPUS_PER_NODE} * ${MPI_CORES_PER_CPU}" ) if( "${MPI_MAX_NUMPROCS_PHYSICAL}" STREQUAL "${MPIEXEC_MAX_NUMPROCS}" ) set( MPI_HYPERTHREADING "OFF" CACHE BOOL - "Are we using hyperthreading?" FORCE ) + "Are we using hyper-threading?" FORCE ) else() set( MPI_HYPERTHREADING "ON" CACHE BOOL - "Are we using hyperthreading?" FORCE ) + "Are we using hyper-threading?" FORCE ) endif() set( MPIEXEC_OMP_POSTFLAGS "-exitcodes" @@ -599,6 +643,18 @@ macro( setupMPILibrariesWindows ) # Found MPI_C, but not MPI_CXX -- create a duplicate to satisfy link targets. if( TARGET MPI::MPI_C AND NOT TARGET MPI::MPI_CXX) + if(verbose) + message(" Found target MPI::MPI_C but not MPI::MPI_CXX + + set_target_properties(MPI::MPI_CXX PROPERTIES + IMPORTED_LOCATION_RELEASE \"${MPI_C_LIBRARIES}\" + IMPORTED_IMPLIB \"${MPI_C_LIBRARIES}\" + INTERFACE_INCLUDE_DIRECTORIES \"${MPI_C_INCLUDE_DIRS}\" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES \"CXX\" ) + ") + endif() + # Windows systems with dll libraries. add_library( MPI::MPI_CXX SHARED IMPORTED ) @@ -634,8 +690,12 @@ macro( setupMPILibrariesWindows ) # del msmpi.def # copy libmsmpi.a %MSMPI_LIB32%/libmsmpi.a - if( WIN32 AND DEFINED CMAKE_Fortran_COMPILER AND - TARGET MPI::MPI_Fortran ) + if( WIN32 AND DEFINED CMAKE_Fortran_COMPILER AND TARGET MPI::MPI_Fortran ) + + if(verbose) + message(" Win32 AND CMAKE_Fortran_COMPILER AND TARGET MPI::MPI_Fortran + ") + endif() # only do this if we are in a CMakeAddFortranSubdirectory directive when # the main Generator is Visual Studio and the Fortran subdirectory uses @@ -643,8 +703,7 @@ macro( setupMPILibrariesWindows ) # MS-MPI has an architecture specific include directory that FindMPI.cmake # doesn't seem to pickup correctly. Add it here. - get_target_property(mpilibdir MPI::MPI_Fortran - INTERFACE_LINK_LIBRARIES) + get_target_property(mpilibdir MPI::MPI_Fortran INTERFACE_LINK_LIBRARIES) get_target_property(mpiincdir MPI::MPI_Fortran INTERFACE_INCLUDE_DIRECTORIES) foreach( arch x86 x64 ) @@ -660,9 +719,16 @@ macro( setupMPILibrariesWindows ) # Reset the include directories for MPI::MPI_Fortran to pull in the extra # $arch locations (if any) + + list(REMOVE_DUPLICATES mpiincdir) set_target_properties(MPI::MPI_Fortran PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${mpiincdir}") + if(verbose) + message("set_target_properties(MPI::MPI_Fortran + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${mpiincdir}\")") + endif() + endif() if( ${MPI_C_FOUND} ) diff --git a/config/vendor_libraries.cmake b/config/vendor_libraries.cmake index 25a61fa4e1..ae9c14d699 100644 --- a/config/vendor_libraries.cmake +++ b/config/vendor_libraries.cmake @@ -224,13 +224,42 @@ macro( setupLAPACKLibraries ) set( lapack_url "http://www.openblas.net") add_library( lapack SHARED IMPORTED) add_library( blas SHARED IMPORTED) + if(WIN32) + string( REPLACE ".lib" ".dll" BLAS_openblas_LIBRARY_DLL_libdir + "${BLAS_openblas_LIBRARY}" ) + string( REPLACE "/lib/" "/bin/" BLAS_openblas_LIBRARY_DLL_bindir + "${BLAS_openblas_LIBRARY_DLL_libdir}" ) + if( EXISTS "${BLAS_openblas_LIBRARY_DLL_libdir}" ) + set( BLAS_openblas_LIBRARY_DLL + "${BLAS_openblas_LIBRARY_DLL_libdir}") + elseif( EXISTS "${BLAS_openblas_LIBRARY_DLL_bindir}" ) + set( BLAS_openblas_LIBRARY_DLL + "${BLAS_openblas_LIBRARY_DLL_bindir}") + else() + # only static libs available. + set( BLAS_openblas_LIBRARY_DLL "${BLAS_openblas_LIBRARY}") + endif() + set_target_properties( blas PROPERTIES - IMPORTED_LOCATION "${BLAS_openblas_LIBRARY}" + IMPORTED_LOCATION "${BLAS_openblas_LIBRARY_DLL}" + IMPORTED_IMPLIB "${BLAS_openblas_LIBRARY}" IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) set_target_properties( lapack PROPERTIES - IMPORTED_LOCATION "${BLAS_openblas_LIBRARY}" + IMPORTED_LOCATION "${BLAS_openblas_LIBRARY_DLL}" + IMPORTED_IMPLIB "${BLAS_openblas_LIBRARY}" IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) - message(STATUS "Looking for lapack (OpenBLAS)...found ${BLAS_openblas_LIBRARY}") + + else() + set_target_properties( blas PROPERTIES + IMPORTED_LOCATION "${BLAS_openblas_LIBRARY}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + set_target_properties( lapack PROPERTIES + IMPORTED_LOCATION "${BLAS_openblas_LIBRARY}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) + endif() + + message(STATUS "Looking for lapack (OpenBLAS)...found " + "${BLAS_openblas_LIBRARY}") else() message(STATUS "Looking for lapack (OpenBLAS)...NOTFOUND") endif() diff --git a/src/FortranChecks/CMakeLists.txt b/src/FortranChecks/CMakeLists.txt index c1cd08af7b..ab9dd8be01 100644 --- a/src/FortranChecks/CMakeLists.txt +++ b/src/FortranChecks/CMakeLists.txt @@ -15,7 +15,7 @@ project( FortranChecks CXX ) # name demangling unnecessary. # ---------------------------------------------------------------------------- # -# Source files +# Source files # ---------------------------------------------------------------------------- # file( GLOB Csources *.cc ) @@ -62,34 +62,41 @@ if( BUILD_TESTING ) # will need some of the current build system parameters: set( draco_DIR ${Draco_SOURCE_DIR}/config ) set( build_system_state -# "-DCMAKE_VERBOSE_MAKEFILE=TRUE" + # "-DCMAKE_VERBOSE_MAKEFILE=TRUE" "-DDRACO_C4=${DRACO_C4}" "-DDRACO_LIBRARY_TYPE=${DRACO_LIBRARY_TYPE}" "-DDraco_TPL_INCLUDE_DIRS=${tmp}" "-DPython_EXECUTABLE=${Python_EXECUTABLE}" "-DRANDOM123_INCLUDE_DIR=${RANDOM123_INCLUDE_DIR}" - "-Ddraco_DIR=${draco_DIR}" + "-Ddraco_DIR=${draco_DIR}" + "-DMPI_C_LIBRARIES=${MPI_C_LIBRARIES}" + "-DMPI_C_INCLUDE_DIRS=${MPI_C_INCLUDE_DIRS}" ) if( WIN32 ) # For Win32 builds, DLL and applications are built in the directory # specified by CMAKE_RUNTIME_OUTPUT_DIRECTORY. - set( build_system_state "${build_system_state};-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${Draco_BINARY_DIR}/\${CMAKE_BUILD_TYPE}" ) + list( APPEND build_system_state + "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${Draco_BINARY_DIR}/\${CMAKE_BUILD_TYPE}" ) + if(CMAKE_TOOLCHAIN_FILE) + list( APPEND build_system_state + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + endif() else() - set( build_system_state "${build_system_state};-DWITH_CUDA=${WITH_CUDA}" ) + list( APPEND build_system_state "-DWITH_CUDA=${WITH_CUDA}" ) endif() # CMake will put some run scripts in $build_dir/f90sub Another directory for # the build is generated at $build_dir/FortranChecks_f90sub_build-prefix cmake_add_fortran_subdirectory( f90sub # directory name - PROJECT FortranChecks_f90sub # project name in toplevel CMakeLists.txt + PROJECT FortranChecks_f90sub # project name in top level CMakeLists.txt # Creates target named 'FortranChecks_f90sub_build' ARCHIVE_DIR f90sub # .lib location relative to root binary tree RUNTIME_DIR f90sub # .dll location relative to root binary tree LIBRARIES rtt_FC_f90sub # Sub project will create a library with this name. # --> librtt_FC_f90.dll. TARGET_NAMES Lib_FC_f90sub - DEPENDS "Lib_FC_Derived_Type;Lib_dsxx" + DEPENDS "Lib_FC_Derived_Type;Lib_c4;Lib_dsxx" NO_EXTERNAL_INSTALL CMAKE_COMMAND_LINE "${build_system_state}" # VERBOSE diff --git a/src/FortranChecks/f90sub/CMakeLists.txt b/src/FortranChecks/f90sub/CMakeLists.txt index 0de14ca7e1..b0a25c1cee 100644 --- a/src/FortranChecks/f90sub/CMakeLists.txt +++ b/src/FortranChecks/f90sub/CMakeLists.txt @@ -2,12 +2,12 @@ # file FortranChecks/f90sub/CMakeLists.txt # author Kelly Thompson # date 2013 June 24 -# brief Generate build project files for fortran. +# brief Generate build project files for Fortran. # note Copyright (C) 2016-2019, Triad National Security, LLC. # All rights reserved. #------------------------------------------------------------------------------# cmake_minimum_required(VERSION 3.9.0) -project( FortranChecks_f90sub Fortran ) +project( FortranChecks_f90sub C Fortran ) # ---------------------------------------------------------------------------- # # Setup - For Generators other than "Unix Makefiles", this folder is parsed @@ -32,11 +32,11 @@ include( component_macros ) # manually find these libraries. # # Note: A more complex example of CMakeAddFortranSubdirectory can be found in -# jayenne/src/wedgehog/ftest. +# jayenne/src/api/ftest. if(NOT TARGET Lib_dsxx) # Rebuild the list Draco_TPL_INCLUDE_DIRS from the packed list (see - # wedgehog/CMakeLists.txt) by replacing triple underscores with a semicolon. + # api/CMakeLists.txt) by replacing triple underscores with a semicolon. # This must be done before calling find_package(draco) string( REGEX REPLACE "___" ";" cafs_Draco_TPL_INCLUDE_DIRS "${Draco_TPL_INCLUDE_DIRS}" ) @@ -47,6 +47,8 @@ if(NOT TARGET Lib_dsxx) ABSOLUTE ) cafs_create_imported_targets( Lib_dsxx "rtt_ds++" "${draco_BINARY_DIR}/src/ds++" CXX ) + cafs_create_imported_targets( Lib_c4 "rtt_c4" + "${draco_BINARY_DIR}/src/c4" CXX ) cafs_create_imported_targets( Lib_FC_Derived_Type "rtt_FC_Derived_Type" "${draco_BINARY_DIR}/src/FortranChecks" CXX ) @@ -63,7 +65,7 @@ if(NOT TARGET Lib_dsxx) include( compilerEnv ) dbsSetupFortran() # Vendors are not needed here, but I'm trying to follow the model found in - # wedgehog/ftest. I've included these here to ensure that the slave build can + # api/ftest. I've included these here to ensure that the slave build can # parse the find vendor scripts. include( vendor_libraries ) setupVendorLibraries() @@ -106,7 +108,14 @@ endif() # Xcode: Since cafs_create_imported_targets does not set all of the dependencies # between the imported libraries, we need to list them explicitly. -set(target_deps "Lib_FC_Derived_Type;Lib_dsxx;${MPI_Fortran_LIBRARIES}" ) +set(target_deps Lib_FC_Derived_Type;Lib_c4;Lib_dsxx) +if ( "${DRACO_C4}" STREQUAL "MPI") + if(MPI_gfortran_LIBRARIES) + list(APPEND target_deps ${MPI_gfortran_LIBRARIES}) + else() + list(APPEND target_deps ${MPI_Fortran_LIBRARIES}) + endif() +endif() add_component_library( TARGET Lib_FC_f90sub @@ -115,6 +124,10 @@ add_component_library( LINK_LANGUAGE "Fortran" TARGET_DEPS "${target_deps}" NOEXPORT ) +if( WIN32 ) + set_target_properties( Lib_FC_f90sub PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) +endif() #------------------------------------------------------------------------------# # End f90sub/CMakeLists.txt diff --git a/src/FortranChecks/fc_derived_type.cc b/src/FortranChecks/fc_derived_type.cc index 8109830699..5919e7449e 100644 --- a/src/FortranChecks/fc_derived_type.cc +++ b/src/FortranChecks/fc_derived_type.cc @@ -13,7 +13,7 @@ #include #include -/// Define the derived type as a C structure +//! Define the derived type as a C structure struct my_informative_type { double some_double; int some_int; @@ -23,9 +23,9 @@ struct my_informative_type { MG_Select some_enum; }; -// A simple function to test for valid values in a Fortran derived type -extern "C" DLL_PUBLIC_FC_Derived_Type void -rtt_test_derived_type(const my_informative_type &mit, int &error_code) { +//! A simple function to test for valid values in a Fortran derived type +extern "C" void rtt_test_derived_type(const my_informative_type &mit, + int &error_code) { std::cout << "In the C-interface, derived type has double = " << mit.some_double << std::endl << "int = " << mit.some_int << std::endl diff --git a/src/lapack_wrap/Blas.hh b/src/lapack_wrap/Blas.hh index 8c923ff0e0..c4c1ecced3 100644 --- a/src/lapack_wrap/Blas.hh +++ b/src/lapack_wrap/Blas.hh @@ -6,8 +6,8 @@ * All rights reserved. */ //---------------------------------------------------------------------------// -#ifndef __lapack_wrap_Blas_hh__ -#define __lapack_wrap_Blas_hh__ +#ifndef rtt_lapack_wrap_Blas_hh +#define rtt_lapack_wrap_Blas_hh #include "Blas_Prototypes.hh" #include "ds++/Assert.hh" @@ -252,7 +252,7 @@ inline T blas_nrm2(const std::vector &x, int increment_x) { } // end namespace rtt_lapack_wrap -#endif // __lapack_wrap_Blas_hh__ +#endif // rtt_lapack_wrap_Blas_hh //---------------------------------------------------------------------------// // end of lapack_wrap/Blas.hh diff --git a/src/lapack_wrap/Blas_Prototypes.hh b/src/lapack_wrap/Blas_Prototypes.hh index a9ae17f549..dbda380926 100644 --- a/src/lapack_wrap/Blas_Prototypes.hh +++ b/src/lapack_wrap/Blas_Prototypes.hh @@ -6,8 +6,8 @@ * All rights reserved. */ //---------------------------------------------------------------------------// -#ifndef __lapack_wrap_Blas_Prototypes_hh__ -#define __lapack_wrap_Blas_Prototypes_hh__ +#ifndef rtt_lapack_wrap_Blas_Prototypes_hh +#define rtt_lapack_wrap_Blas_Prototypes_hh #include @@ -36,7 +36,7 @@ double FC_GLOBAL(dnrm2, DNRM2)(int *, double *, int *); } // end of extern "C" -#endif // __lapack_wrap_Blas_Prototypes_hh__ +#endif // rtt_lapack_wrap_Blas_Prototypes_hh //---------------------------------------------------------------------------// // end of lapack_wrap/Blas_Prototypes.hh diff --git a/src/quadrature/CMakeLists.txt b/src/quadrature/CMakeLists.txt index 751ce28112..6fd5478c5b 100755 --- a/src/quadrature/CMakeLists.txt +++ b/src/quadrature/CMakeLists.txt @@ -65,30 +65,39 @@ if( BUILD_TESTING ) # will need some of the current build system parameters: set( draco_DIR ${Draco_SOURCE_DIR}/config ) set( build_system_state - "-Ddraco_DIR=${draco_DIR}" + # "-DCMAKE_VERBOSE_MAKEFILE=TRUE" + "-DDRACO_C4=${DRACO_C4}" "-DDRACO_LIBRARY_TYPE=${DRACO_LIBRARY_TYPE}" "-DDraco_TPL_INCLUDE_DIRS=${tmp}" - "-DCMAKE_VERBOSE_MAKEFILE=TRUE" - "-DDRACO_C4=${DRACO_C4}" + #"-DPython_EXECUTABLE=${Python_EXECUTABLE}" + #"-DRANDOM123_INCLUDE_DIR=${RANDOM123_INCLUDE_DIR}" + "-Ddraco_DIR=${draco_DIR}" + "-DMPI_C_LIBRARIES=${MPI_C_LIBRARIES}" + "-DMPI_C_INCLUDE_DIRS=${MPI_C_INCLUDE_DIRS}" ) if( WIN32 ) # For Win32 builds, DLL and applications are built in the directory # specified by CMAKE_RUNTIME_OUTPUT_DIRECTORY. - set( build_system_state "${build_system_state};-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${Draco_BINARY_DIR}/\${CMAKE_BUILD_TYPE}" ) + list( APPEND build_system_state + "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${Draco_BINARY_DIR}/\${CMAKE_BUILD_TYPE}" ) + if(CMAKE_TOOLCHAIN_FILE) + list( APPEND build_system_state + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + endif() else() - set( build_system_state "${build_system_state};-DWITH_CUDA=${WITH_CUDA}" ) + list( APPEND build_system_state "-DWITH_CUDA=${WITH_CUDA}" ) endif() cmake_add_fortran_subdirectory( ftest # directory name - PROJECT quadrature_ftest # project name in toplevel CMakeLists.txt + PROJECT quadrature_ftest # project name in top level CMakeLists.txt # Creates target named 'quadrature_ftest_build' ARCHIVE_DIR ftest # .lib location relative to root binary tree RUNTIME_DIR ftest # .dll location relative to root binary tree - LIBRARIES rtt_quadrature_ftest # new library will have this name. - # --> librtt_FC_f90.dll. + LIBRARIES rtt_quadrature_ftest # new library will have this name. + # --> librtt_quadrature_ftest.dll. TARGET_NAMES Lib_quadrature_ftest - DEPENDS "Lib_quadrature_test;Lib_quadrature;Lib_dsxx" + DEPENDS "Lib_quadrature_test;Lib_quadrature;Lib_c4;Lib_dsxx" NO_EXTERNAL_INSTALL CMAKE_COMMAND_LINE "${build_system_state}" # VERBOSE diff --git a/src/quadrature/ftest/CMakeLists.txt b/src/quadrature/ftest/CMakeLists.txt index 996a200b19..c7ab4108bc 100644 --- a/src/quadrature/ftest/CMakeLists.txt +++ b/src/quadrature/ftest/CMakeLists.txt @@ -7,7 +7,7 @@ # All rights reserved. #------------------------------------------------------------------------------# cmake_minimum_required(VERSION 3.9.0) -project( quadrature_ftest Fortran ) +project( quadrature_ftest C Fortran ) # ---------------------------------------------------------------------------- # # Setup - For Generators other than "Unix Makefiles", this folder is @@ -32,19 +32,23 @@ include( component_macros ) # manually find these libraries. # # Note: A more complex example of CMakeAddFortranSubdirectory can be -# found in jayenne/src/wedgehog/ftest. +# found in jayenne/src/api/ftest. if(NOT TARGET Lib_dsxx) # Rebuild the list Draco_TPL_INCLUDE_DIRS from the packed list (see - # wedgehog/CMakeLists.txt) by replacing triple underscores with a semicolon. + # api/CMakeLists.txt) by replacing triple underscores with a semicolon. # This must be done before calling find_package(draco) string( REGEX REPLACE "___" ";" cafs_Draco_TPL_INCLUDE_DIRS "${Draco_TPL_INCLUDE_DIRS}" ) include(CMakeAddFortranSubdirectory) - get_filename_component( draco_BINARY_DIR ${PROJECT_BINARY_DIR}/../../.. ABSOLUTE ) + + get_filename_component( draco_BINARY_DIR ${PROJECT_BINARY_DIR}/../../.. + ABSOLUTE ) cafs_create_imported_targets( Lib_dsxx "rtt_ds++" "${draco_BINARY_DIR}/src/ds++" CXX ) + cafs_create_imported_targets( Lib_c4 "rtt_c4" + "${draco_BINARY_DIR}/src/c4" CXX ) cafs_create_imported_targets( Lib_quadrature "rtt_quadrature" "${draco_BINARY_DIR}/src/quadrature" CXX ) cafs_create_imported_targets( Lib_quadrature_test From dcd9f98372b60eb84c6a9512bfc9a417ae9d70a4 Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Thu, 9 Jan 2020 16:56:55 -0700 Subject: [PATCH 2/6] Flatten pr 697 into one changeset. --- src/CMakeLists.txt | 1 + src/cdi/CDI.cc | 15 +++-- src/cdi/CDI.hh | 5 +- src/cdi/CPCommon.hh | 7 ++- src/cdi/CPEloss.hh | 44 +++++++++++++-- src/cdi_analytic/Analytic_CP_Eloss.cc | 16 +++--- src/cdi_analytic/Analytic_CP_Eloss.hh | 21 ++----- src/cdi_analytic/test/tstAnalytic_CP_Eloss.cc | 9 ++- src/ds++/DracoMath.hh | 56 +++++++++++++++++++ 9 files changed, 129 insertions(+), 45 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6470ace0f9..6df4cde93b 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,6 +88,7 @@ add_dir_if_exists( norms ) # needs c4 add_dir_if_exists( parser ) # needs units, c4, mesh_element add_dir_if_exists( roots ) # needs linear add_dir_if_exists( timestep ) # needs c4, ds++ +add_dir_if_exists( cdi_CPEloss ) # needs c4, ds++, cdi if( NOT DEFINED ENV{APPVEYOR} ) add_dir_if_exists( VendorChecks ) # needs c4 diff --git a/src/cdi/CDI.cc b/src/cdi/CDI.cc index 0486d7c70f..24b8c98281 100644 --- a/src/cdi/CDI.cc +++ b/src/cdi/CDI.cc @@ -886,7 +886,8 @@ void CDI::setCPEloss(const SP_CPEloss &spCPp) { // Store the particle / target pair CPEloss_map.emplace(std::make_pair( - std::make_pair(spCPp->getProjectileZAID(), spCPp->getTargetZAID()), + std::make_pair(spCPp->getProjectile().get_zaid(), + spCPp->getTarget().get_zaid()), CPElosses.size())); // assign the smart pointer @@ -1146,15 +1147,16 @@ CDI::SP_OdfmgOpacity CDI::odfmg(rtt_cdi::Model m, rtt_cdi::Reaction r) const { * * The appropriate charged particle eloss is returned for the given model/ trio. * - * \param m rtt_cdi::CPModel specifying the desired CP physics model + * \param mAC rtt_cdi::CPModelAngleCutoff specifying the desired angle cutoff. * \param pz int32_t specifying the desired particle type. * \param tz int32_t specifying the desired target type. */ -CDI::SP_CPEloss CDI::eloss(rtt_cdi::CPModel m, int32_t pz, int32_t tz) const { +CDI::SP_CPEloss CDI::eloss(rtt_cdi::CPModelAngleCutoff mAC, int32_t pz, + int32_t tz) const { map_it entry = CPEloss_map.find(std::make_pair(pz, tz)); Insist(entry != CPEloss_map.end(), "Undefined CPEloss!"); // Be sure model type is what the user expected. - Require(CPElosses[entry->second]->getModel() == m); + Require(CPElosses[entry->second]->getModelAngleCutoff() == mAC); return CPElosses[entry->second]; } @@ -1279,13 +1281,14 @@ bool CDI::isOdfmgOpacitySet(rtt_cdi::Model m, rtt_cdi::Reaction r) const { /*! * \brief Query to see if an odf multigroup opacity is set. */ -bool CDI::isCPElossSet(rtt_cdi::CPModel m, int32_t pz, int32_t tz) const { +bool CDI::isCPElossSet(rtt_cdi::CPModelAngleCutoff mAC, int32_t pz, + int32_t tz) const { // Look up this particle / target zaid pair in the stored map: map_it entry = CPEloss_map.find(std::make_pair(pz, tz)); // return true if particle/target pair is in map, and model matches input: return (entry != CPEloss_map.end() && - CPElosses[entry->second]->getModel() == m); + CPElosses[entry->second]->getModelAngleCutoff() == mAC); } /*! diff --git a/src/cdi/CDI.hh b/src/cdi/CDI.hh index f4d72d2ed7..26496f2e83 100644 --- a/src/cdi/CDI.hh +++ b/src/cdi/CDI.hh @@ -610,7 +610,7 @@ public: SP_GrayOpacity gray(rtt_cdi::Model m, rtt_cdi::Reaction r) const; SP_MultigroupOpacity mg(rtt_cdi::Model m, rtt_cdi::Reaction r) const; SP_OdfmgOpacity odfmg(rtt_cdi::Model m, rtt_cdi::Reaction r) const; - SP_CPEloss eloss(rtt_cdi::CPModel m, int32_t proj_zaid, + SP_CPEloss eloss(rtt_cdi::CPModelAngleCutoff mAC, int32_t proj_zaid, int32_t targ_zaid) const; SP_EoS eos(void) const; SP_EICoupling ei_coupling(void) const; @@ -675,7 +675,8 @@ public: bool isGrayOpacitySet(rtt_cdi::Model, rtt_cdi::Reaction) const; bool isMultigroupOpacitySet(rtt_cdi::Model, rtt_cdi::Reaction) const; bool isOdfmgOpacitySet(rtt_cdi::Model, rtt_cdi::Reaction) const; - bool isCPElossSet(rtt_cdi::CPModel, int32_t pz, int32_t tz) const; + bool isCPElossSet(rtt_cdi::CPModelAngleCutoff mAC, int32_t pz, + int32_t tz) const; bool isEoSSet() const; bool isEICouplingSet() const; diff --git a/src/cdi/CPCommon.hh b/src/cdi/CPCommon.hh index 256e1557cc..271e85abb0 100644 --- a/src/cdi/CPCommon.hh +++ b/src/cdi/CPCommon.hh @@ -20,9 +20,10 @@ namespace constants { unsigned int const num_CPModels(3); } // namespace constants -enum class CPModel { - ELOSS = 0, /*!< energy loss model */ - LA_SCATTERING = 1 /*!< large-angle scattering model */ +enum class CPModelAngleCutoff { + NONE = 0, /*!< no angle cutoff */ + TNBURN = 1 /*!< cutoff angle formula from "TN Burn Project: Minimum Impact + parameter Scattering Angle Cutoff/Nuclear Interactions */ }; enum class CPModelType { diff --git a/src/cdi/CPEloss.hh b/src/cdi/CPEloss.hh index f934ead03c..eafc19b6dc 100644 --- a/src/cdi/CPEloss.hh +++ b/src/cdi/CPEloss.hh @@ -34,6 +34,8 @@ namespace rtt_cdi { class CPEloss { public: + CPEloss(CParticle target_in, CParticle projectile_in) + : projectile(projectile_in), target(target_in) {} // ---------- // // Destructor // // ---------- // @@ -76,17 +78,18 @@ public: /*! * \brief Query to determine the target species type. */ - virtual int32_t getTargetZAID() const = 0; + //virtual int32_t getTargetZAID() const = 0; /*! * \brief Query to determine the transporting particle type. */ - virtual int32_t getProjectileZAID() const = 0; + //virtual int32_t getProjectileZAID() const = 0; /*! * \brief Query to determine the CP Model type. */ - virtual rtt_cdi::CPModel getModel() const = 0; + //virtual rtt_cdi::CPModel getModel() const = 0; + /*! * \brief Returns the name of the associated data file (if any). */ @@ -129,7 +132,40 @@ public: * \brief Returns the general Eloss model type (Analytic), * defined in the enum at the top of this file. */ - virtual rtt_cdi::CPModelType getModelType() const = 0; + //virtual rtt_cdi::CPModelType getModelType() const = 0; + + /*! + * \brief Query to determine the transporting particle type. + */ + CParticle getProjectile() const { return projectile; } + + /*! + * \brief Query to determine the target species type. + */ + CParticle getTarget() const { return target; } + + /*! + * \brief Query to determine the CP Model type. + */ + CPModelType getModelType() const { return model_type; } + + /*! + * \brief Query to determine the angle cutoff used by the CP model. + */ + CPModelAngleCutoff getModelAngleCutoff() const { return model_angle_cutoff; } + +protected: + // Particle being transported i.e. subject to energy loss + CParticle projectile; + + // Target particle + CParticle target; + + // CP Model type + CPModelType model_type; + + // CP Model angle cutoff + CPModelAngleCutoff model_angle_cutoff; }; } // namespace rtt_cdi diff --git a/src/cdi_analytic/Analytic_CP_Eloss.cc b/src/cdi_analytic/Analytic_CP_Eloss.cc index 19ae5ea609..435286daea 100644 --- a/src/cdi_analytic/Analytic_CP_Eloss.cc +++ b/src/cdi_analytic/Analytic_CP_Eloss.cc @@ -24,21 +24,21 @@ namespace rtt_cdi_analytic { * The reaction type for this instance of the class is determined by the * rtt_cdi::Reaction argument. * - * \param model_in shared_ptr to a derived + * \param[in] model_in shared_ptr to a derived * rtt_cdi_analytic::Analytic_Eloss_Model object - * \param target_zaid_in int32_t target particle zaid - * \param projectile_zaid_in int32_t transporting particle zaid + * \param[in] target_in int32_t target particle + * \param[in] projectile_in int32_t particle being transported */ Analytic_CP_Eloss::Analytic_CP_Eloss(SP_Analytic_Model model_in, - int32_t target_zaid_in, - int32_t projectile_zaid_in) - : analytic_model(model_in), projectile_zaid(projectile_zaid_in), - target_zaid(target_zaid_in) { + rtt_cdi::CParticle target_in, + rtt_cdi::CParticle projectile_in) + : rtt_cdi::CPEloss(target_in, projectile_in), analytic_model(model_in) { Ensure(analytic_model); + model_type = rtt_cdi::CPModelType::ANALYTIC_ETYPE; } //---------------------------------------------------------------------------// -// OPACITY INTERFACE FUNCTIONS +// ELOSS INTERFACE FUNCTIONS //---------------------------------------------------------------------------// /*! * \brief Return a scalar eloss given a scalar temperature, density, and diff --git a/src/cdi_analytic/Analytic_CP_Eloss.hh b/src/cdi_analytic/Analytic_CP_Eloss.hh index 2b6e0c3b96..f2b987e345 100644 --- a/src/cdi_analytic/Analytic_CP_Eloss.hh +++ b/src/cdi_analytic/Analytic_CP_Eloss.hh @@ -12,6 +12,7 @@ #define rtt_cdi_analytic_Analytic_CP_Eloss_hh #include "Analytic_Models.hh" +#include "cdi/CPCommon.hh" #include "cdi/CPEloss.hh" #include @@ -34,25 +35,20 @@ public: typedef std::shared_ptr SP_Analytic_Model; typedef std::vector sf_double; typedef std::string std_string; + typedef rtt_cdi::CParticle CParticle; private: // Analytic eloss model. SP_Analytic_Model analytic_model; - // Particle type being transported. - int32_t projectile_zaid; - - // Target species. - int32_t target_zaid; - // Data model (e.g. Eloss, large-angle scatter, etc.) // Currently only ELOSS is implemented. //rtt_cdi::CPModel cpmodel; public: // Constructor. - Analytic_CP_Eloss(SP_Analytic_Model model_in, int32_t target_zaid_in, - int32_t projectile_zaid_in); + Analytic_CP_Eloss(SP_Analytic_Model model_in, CParticle target_in, + CParticle projectile_in); // >>> ACCESSORS const_SP_Model get_Analytic_Model() const { return analytic_model; } @@ -66,15 +62,6 @@ public: //! Query to see if data is in tabular or functional form (false). bool data_in_tabular_form() const { return false; } - //! Query to determine the target species type. - int32_t getTargetZAID() const { return target_zaid; } - - //! Query to determine the transporting particle type. - int32_t getProjectileZAID() const { return projectile_zaid; } - - //! Return the model (energy loss) - rtt_cdi::CPModel getModel() const { return rtt_cdi::CPModel::ELOSS; } - // Get the name of the associated data file. inline std_string getDataFilename() const; diff --git a/src/cdi_analytic/test/tstAnalytic_CP_Eloss.cc b/src/cdi_analytic/test/tstAnalytic_CP_Eloss.cc index cf121a6d89..6d21e00f22 100644 --- a/src/cdi_analytic/test/tstAnalytic_CP_Eloss.cc +++ b/src/cdi_analytic/test/tstAnalytic_CP_Eloss.cc @@ -29,9 +29,9 @@ using rtt_cdi_analytic::Analytic_Eloss_Model; void KP_alpha_test(rtt_dsxx::UnitTest &ut) { // Deuterium: - int32_t target_in = 1002; + rtt_cdi::CParticle target_in(1002, 3.34358e-24); // Alpha particle: - int32_t projectile_in = 2004; + rtt_cdi::CParticle projectile_in(2004, 6.64424e-24); std::shared_ptr model_in( new rtt_cdi_analytic::Analytic_KP_Alpha_Eloss_Model()); @@ -41,7 +41,6 @@ void KP_alpha_test(rtt_dsxx::UnitTest &ut) { // Check that basic accessors return correct result: // Model type better be analytic: FAIL_IF_NOT(eloss_mod.getModelType() == rtt_cdi::CPModelType::ANALYTIC_ETYPE); - FAIL_IF_NOT(eloss_mod.getModel() == rtt_cdi::CPModel::ELOSS); // NOT tabular data FAIL_IF(eloss_mod.data_in_tabular_form()); @@ -56,8 +55,8 @@ void KP_alpha_test(rtt_dsxx::UnitTest &ut) { FAIL_IF_NOT(eloss_mod.getDataFilename().empty()); // Check that accessors return the correct target and projectile: - FAIL_IF_NOT(target_in == eloss_mod.getTargetZAID()); - FAIL_IF_NOT(projectile_in == eloss_mod.getProjectileZAID()); + FAIL_IF_NOT(target_in.get_zaid() == eloss_mod.getTarget().get_zaid()); + FAIL_IF_NOT(projectile_in.get_zaid() == eloss_mod.getProjectile().get_zaid()); // Get eloss values for some sample data: { diff --git a/src/ds++/DracoMath.hh b/src/ds++/DracoMath.hh index ddb77e137b..ba6724f40a 100644 --- a/src/ds++/DracoMath.hh +++ b/src/ds++/DracoMath.hh @@ -207,6 +207,62 @@ constexpr inline double linear_interpolate(double const x1, double const x2, return value; } +//---------------------------------------------------------------------------// +/*! + * \brief Do a 3D linear interpolation between vertices of a rectangular prism. + * + * Algorithm from wikipedia's Trilinear Interpolation article, hat tip to E. + * Norris for the reference. + * + * \param[in] x0 lower x coordinate of lattice + * \param[in] x1 upper x coordinate of lattic + * \param[in] y0 lower y coordinate of lattice + * \param[in] y1 upper y coordinate of lattice + * \param[in] z0 lower z coordinate of lattice + * \param[in] z1 upper z coordinate of lattic + * \param[in] f000 function at (x0,y0,z0) + * \param[in] f100 function at (x1,y0,z0) + * \param[in] f001 function at (x0,y0,z1) + * \param[in] f101 function at (x1,y0,z1) + * \param[in] f010 function at (x0,y1,z0) + * \param[in] f110 function at (x1,y1,z0) + * \param[in] f011 function at (x0,y1,z1) + * \param[in] f111 function at (x1,y1,z1) + * \param[in] x x coordinate of interpolation point + * \param[in] y y coordinate of interpolation point + * \param[in] z z coordinate of interpolation point + * \return The function value linearly interpolated to (x,y,z) + */ +inline double +linear_interpolate_3(double const x0, double const x1, double const y0, + double const y1, double const z0, double const z1, + double const f000, double const f100, double const f001, + double const f101, double const f010, double const f110, + double const f011, double const f111, double const x, + double const y, double const z) { + Require(std::abs(x1 - x0) > std::numeric_limits::epsilon()); + Require(std::abs(y1 - y0) > std::numeric_limits::epsilon()); + Require(std::abs(z1 - z0) > std::numeric_limits::epsilon()); + Require((x >= x0) && (x <= x1) && (y >= y0) && (y <= y1) && (z >= z0) && + (z <= z1)); + + double xd = (x - x0) / (x1 - x0); + double yd = (y - y0) / (y1 - y0); + double zd = (z - z0) / (z1 - z0); + + double f00 = f000 * (1. - xd) + f100 * xd; + double f01 = f001 * (1. - xd) + f101 * xd; + double f10 = f010 * (1. - xd) + f110 * xd; + double f11 = f011 * (1. - xd) + f111 * xd; + + double f0 = f00 * (1. - yd) + f10 * yd; + double f1 = f01 * (1. - yd) + f11 * yd; + + double f = f0 * (1. - zd) + f1 * zd; + + return f; +} + //----------------------------------------------------------------------------// /*! * \brief Fast ceiling of an integer division From 98a29f3911c38d38adb0c62139420c8088f00911 Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Mon, 13 Jan 2020 15:03:35 -0700 Subject: [PATCH 3/6] Add cdi_CPEloss directory. + Also remove duplicate linear_interpolate_3 function. --- src/cdi_CPEloss/CMakeLists.txt | 54 ++++ src/cdi_CPEloss/Tabular_CP_Eloss.cc | 316 ++++++++++++++++++++ src/cdi_CPEloss/Tabular_CP_Eloss.hh | 115 +++++++ src/cdi_CPEloss/test/001-H-001 | 72 +++++ src/cdi_CPEloss/test/CMakeLists.txt | 28 ++ src/cdi_CPEloss/test/tstTabular_CP_Eloss.cc | 113 +++++++ src/ds++/DracoMath.hh | 56 ---- 7 files changed, 698 insertions(+), 56 deletions(-) create mode 100644 src/cdi_CPEloss/CMakeLists.txt create mode 100644 src/cdi_CPEloss/Tabular_CP_Eloss.cc create mode 100644 src/cdi_CPEloss/Tabular_CP_Eloss.hh create mode 100755 src/cdi_CPEloss/test/001-H-001 create mode 100644 src/cdi_CPEloss/test/CMakeLists.txt create mode 100644 src/cdi_CPEloss/test/tstTabular_CP_Eloss.cc diff --git a/src/cdi_CPEloss/CMakeLists.txt b/src/cdi_CPEloss/CMakeLists.txt new file mode 100644 index 0000000000..97caaea89a --- /dev/null +++ b/src/cdi_CPEloss/CMakeLists.txt @@ -0,0 +1,54 @@ +#-----------------------------*-cmake-*----------------------------------------# +# file cdi_CPEloss/CMakeLists.txt +# author Ben. R. Ryan +# date 2019 Nov 4 +# brief Instructions for building cdi_eospac Makefiles. +# note Copyright (C) 2016-2019 Triad National Security, LLC. +# All rights reserved. +#------------------------------------------------------------------------------# +cmake_minimum_required(VERSION 3.9.0) +project( cdi_CPEloss CXX ) + +# ---------------------------------------------------------------------------- # +# Source files +# ---------------------------------------------------------------------------- # + +file( GLOB sources *.cc ) +file( GLOB headers *.hh ) + +# ---------------------------------------------------------------------------- # +# Build package library +# ---------------------------------------------------------------------------- # + +add_component_library( + TARGET Lib_cdi_CPEloss + TARGET_DEPS "Lib_cdi;Lib_units" + LIBRARY_NAME ${PROJECT_NAME} + SOURCES "${sources}" + HEADERS "${headers}" ) + +# ---------------------------------------------------------------------------- # +# Installation instructions +# ---------------------------------------------------------------------------- # + +install( TARGETS Lib_cdi_CPEloss EXPORT draco-targets DESTINATION + ${DBSCFGDIR}lib ) +install( FILES ${headers} DESTINATION ${DBSCFGDIR}include/cdi_CPEloss ) + +# ---------------------------------------------------------------------------- # +# Unit tests +# ---------------------------------------------------------------------------- # + +if( BUILD_TESTING ) + add_subdirectory( test ) +endif() + +# ---------------------------------------------------------------------------- # +# Autodoc +# ---------------------------------------------------------------------------- # + +process_autodoc_pages() + +# ---------------------------------------------------------------------------- # +# End cdi_CPEloss/CMakeLists.txt +# ---------------------------------------------------------------------------- # diff --git a/src/cdi_CPEloss/Tabular_CP_Eloss.cc b/src/cdi_CPEloss/Tabular_CP_Eloss.cc new file mode 100644 index 0000000000..3e03b728ca --- /dev/null +++ b/src/cdi_CPEloss/Tabular_CP_Eloss.cc @@ -0,0 +1,316 @@ +//----------------------------------*-C++-*----------------------------------// +/*! + * \file cdi_CPEloss/Tabular_CP_Eloss.cc + * \author Ben R. Ryan + * \date 2019 Nov 4 + * \brief Tabular_CP_Eloss member definitions. + * \note Copyright (C) 2016-2019 Triad National Security, LLC. + * All rights reserved. */ +//---------------------------------------------------------------------------// + +#include "Tabular_CP_Eloss.hh" +#include "ds++/DracoStrings.hh" + +namespace rtt_cdi_cpeloss { + +namespace stdex = std::experimental; +using std::experimental::basic_mdspan; +using std::experimental::dynamic_extent; +using std::experimental::extents; +using std::experimental::layout_left; + +//---------------------------------------------------------------------------// +/*! + * \brief Do a 3D linear interpolation between vertices of a rectangular prism. + * + * Algorithm from wikipedia's Trilinear Interpolation article, hat tip to E. + * Norris for the reference. + * + * \param[in] x0 lower x coordinate of lattice + * \param[in] x1 upper x coordinate of lattic + * \param[in] y0 lower y coordinate of lattice + * \param[in] y1 upper y coordinate of lattice + * \param[in] z0 lower z coordinate of lattice + * \param[in] z1 upper z coordinate of lattic + * \param[in] f000 function at (x0,y0,z0) + * \param[in] f100 function at (x1,y0,z0) + * \param[in] f001 function at (x0,y0,z1) + * \param[in] f101 function at (x1,y0,z1) + * \param[in] f010 function at (x0,y1,z0) + * \param[in] f110 function at (x1,y1,z0) + * \param[in] f011 function at (x0,y1,z1) + * \param[in] f111 function at (x1,y1,z1) + * \param[in] x x coordinate of interpolation point + * \param[in] y y coordinate of interpolation point + * \param[in] z z coordinate of interpolation point + * \return The function value linearly interpolated to (x,y,z) + */ +inline double +linear_interpolate_3(double const x0, double const x1, double const y0, + double const y1, double const z0, double const z1, + double const f000, double const f100, double const f001, + double const f101, double const f010, double const f110, + double const f011, double const f111, double const x, + double const y, double const z) { + Require(std::abs(x1 - x0) > std::numeric_limits::epsilon()); + Require(std::abs(y1 - y0) > std::numeric_limits::epsilon()); + Require(std::abs(z1 - z0) > std::numeric_limits::epsilon()); + Require((x >= x0) && (x <= x1) && (y >= y0) && (y <= y1) && (z >= z0) && + (z <= z1)); + + double xd = (x - x0) / (x1 - x0); + double yd = (y - y0) / (y1 - y0); + double zd = (z - z0) / (z1 - z0); + + double f00 = f000 * (1. - xd) + f100 * xd; + double f01 = f001 * (1. - xd) + f101 * xd; + double f10 = f010 * (1. - xd) + f110 * xd; + double f11 = f011 * (1. - xd) + f111 * xd; + + double f0 = f00 * (1. - yd) + f10 * yd; + double f1 = f01 * (1. - yd) + f11 * yd; + + double f = f0 * (1. - zd) + f1 * zd; + + return f; +} + +//---------------------------------------------------------------------------// +// CONSTRUCTORS +//---------------------------------------------------------------------------// +/*! + * \brief Constructor for an analytic tabular eloss model. + * + * This constructor builds an eloss model defined by the + * rtt_cdi_cpeloss::Tabular_Eloss_Model derived class argument. + * + * The path to an eloss datafile is passed to the constructor, + * which opens and parses the file. The file format is the usual + * LANL format for stopping powers. + * + * \param[in] filename_in path to eloss file + * \param[in] target_in target particle zaid + * \param[in] projectile_in transporting particle zaid + */ +Tabular_CP_Eloss::Tabular_CP_Eloss(std::string filename_in, + rtt_cdi::CParticle target_in, + rtt_cdi::CParticle projectile_in) + : rtt_cdi::CPEloss(target_in, projectile_in), filename(filename_in), + us(rtt_units::UnitSystemType().X4()), pc_cgs(us) { + using std::stod; + using std::stoi; + + model_type = rtt_cdi::CPModelType::TABULAR_ETYPE; + + file.open(filename); + Insist(file.is_open(), "Error opening DEDX file \"" + filename + "\""); + + constexpr uint32_t max_entries = + 6; // This is a statement about the file format, maximum of six entries per row. + + std::vector line_entries = read_line(); // ZAID + int32_t projectile_zaid_file = stoi(line_entries[0]); + Require(projectile.get_zaid() == projectile_zaid_file); + + skip_lines(1); // Z, A, mass + + line_entries = read_line(); // Number of bins for energy, density, temperature + Check(line_entries.size() >= 3); + n_energy = stoi(line_entries[0]); + n_density = stoi(line_entries[1]); + n_temperature = stoi(line_entries[2]); + + line_entries = + read_line(); // Bin spacing for energy, density, temperature (log) + Check(line_entries.size() >= 3); + d_log_energy = 1. / stod(line_entries[0]); + d_log_density = 1. / stod(line_entries[1]); + d_log_temperature = 1. / stod(line_entries[2]); + + // Get first energy support point + uint32_t nlines = (n_energy + max_entries - 1) / max_entries; + line_entries = read_line(); + min_log_energy = stod(line_entries[0]); + skip_lines(nlines - 1); + energies.resize(n_energy); + for (uint32_t n = 0; n < n_energy; n++) { + energies[n] = exp(min_log_energy + n * d_log_energy); + } + + // Get first density support point + nlines = (n_density + max_entries - 1) / max_entries; + line_entries = read_line(); + min_log_density = stod(line_entries[0]); + skip_lines(nlines - 1); + densities.resize(n_density); + for (uint32_t n = 0; n < n_density; n++) { + densities[n] = exp(min_log_density + n * d_log_density); + } + + // Get first temperature support point + nlines = (n_temperature + max_entries - 1) / max_entries; + line_entries = read_line(); + min_log_temperature = stod(line_entries[0]); + skip_lines(nlines - 1); + temperatures.resize(n_temperature); + for (uint32_t n = 0; n < n_temperature; n++) { + temperatures[n] = exp(min_log_temperature + n * d_log_temperature); + } + + std::vector stopping_data_1d(n_energy * n_density * n_temperature); + + bool target_found = false; + nlines = + (n_energy * n_density * n_temperature + max_entries - 1) / + max_entries; // The number of lines taken up by stopping power data for one target + if (target.get_zaid() == -1) { + // Target is free electrons + target_found = true; + uint32_t nentry = 0; + for (uint32_t n = 0; n < nlines; n++) { + line_entries = read_line(); + for (std::string entry : line_entries) { + stopping_data_1d[nentry++] = stod(entry); + } + } + } else { + // Skip electrons + skip_lines(nlines); + + // Find ion target, if it exists + const uint32_t n_target_ions = + stoi(read_line()[0]); // Number of target ions in file + for (uint32_t n_target_ion = 0; n_target_ion < n_target_ions; + n_target_ion++) { + int zaid_target_ion = stoi(read_line()[0]); // ZAID + read_line(); // Z, A, mass + if (zaid_target_ion == target.get_zaid()) { + // This is the requested target ion + target_found = true; + uint32_t nentry = 0; + for (uint32_t n = 0; n < nlines; n++) { + line_entries = read_line(); + for (std::string entry : line_entries) { + stopping_data_1d[nentry] = stod(entry); + nentry++; + } + } + break; + } else { + // This is not the requested target ion + skip_lines(nlines); + } + } + } + file.close(); + + Insist(target_found, "Error finding target ZAID \"" + + std::to_string(target.get_zaid()) + + "\" in DEDX file \"" + filename + "\""); + + stopping_data = + basic_mdspan, + layout_left>(stopping_data_1d.data(), n_energy, n_density, + n_temperature); + + // Convert units on table to match those of getEloss: + // energy: MeV -> cm/shk (using target particle mass) + double energy_cgs = exp(min_log_energy) * (1.e6 * 1.6021772e-12); + min_log_energy = log(sqrt(2. * energy_cgs / target.get_mass()) * 1.e-8); + d_log_energy = d_log_energy / 2.; + // density: cm^-3 -> g cm^-3 + min_log_density = log(exp(min_log_density) * target.get_mass()); + // temperature: keV -> keV + // Note that d log x = dx / x is not affected by unit conversion factors + for (auto &energy : energies) { + energy = + sqrt(2. * (energy * 1.e6 * 1.6021772e-12) / target.get_mass()) * 1.e-8; + } + for (auto &density : densities) { + density *= target.get_mass(); + } + + // Initialize table bounds + min_energy = exp(min_log_energy); + max_energy = exp(min_log_energy + d_log_energy * (n_energy)); + min_density = exp(min_log_density); + max_density = exp(min_log_density + d_log_density * (n_density)); + min_temperature = exp(min_log_temperature); + max_temperature = + exp(min_log_temperature + d_log_temperature * (n_temperature)); +} + +/*! + * \brief Read through the next nlines lines and ignore them. + * \param[in] nlines number of lines in file to skip + */ +void Tabular_CP_Eloss::skip_lines(uint32_t nlines) { + std::string line; + for (uint32_t nline = 0; nline < nlines; nline++) { + std::getline(file, line); + } +} + +/*! + * \brief Read a line from an eloss datafile and return as a vector of strings. + * \return entries the resulting vector of entries in the datafile line. + */ +std::vector const Tabular_CP_Eloss::read_line() { + std::string line; + std::getline(file, line); + return rtt_dsxx::tokenize(line); +} + +double Tabular_CP_Eloss::getEloss(const double temperature, + const double density, + const double partSpeed) const { + Require(temperature >= min_temperature); + Require(density >= min_density); + Require(partSpeed >= min_energy); + Require(temperature < max_temperature); + Require(density < max_density); + Require(partSpeed < max_energy); + + if (temperature < min_temperature || temperature > max_temperature || + density < min_density || density > max_density || + partSpeed < min_energy || partSpeed > max_energy) { + // Outside of the table + return 0.; + } + + const int pt0_energy = static_cast( + std::floor((log(partSpeed) - min_log_energy) / d_log_energy)); + int pt1_energy = pt0_energy + 1; + int pt0_density = static_cast( + std::floor((log(density) - min_log_density) / d_log_density)); + int pt1_density = pt0_density + 1; + int pt0_temperature = static_cast( + std::floor((log(temperature) - min_log_temperature) / d_log_temperature)); + int pt1_temperature = pt0_temperature + 1; + + const double x0 = exp(min_log_energy + pt0_energy * d_log_energy); + const double x1 = exp(min_log_energy + pt1_energy * d_log_energy); + const double y0 = exp(min_log_density + pt0_density * d_log_density); + const double y1 = exp(min_log_density + pt1_density * d_log_density); + const double z0 = + exp(min_log_temperature + pt0_temperature * d_log_temperature); + const double z1 = + exp(min_log_temperature + pt1_temperature * d_log_temperature); + + const double f000 = stopping_data(pt0_energy, pt0_density, pt0_temperature); + const double f100 = stopping_data(pt1_energy, pt0_density, pt0_temperature); + const double f001 = stopping_data(pt0_energy, pt0_density, pt1_temperature); + const double f101 = stopping_data(pt1_energy, pt0_density, pt1_temperature); + const double f010 = stopping_data(pt0_energy, pt1_density, pt0_temperature); + const double f110 = stopping_data(pt1_energy, pt1_density, pt0_temperature); + const double f011 = stopping_data(pt0_energy, pt1_density, pt1_temperature); + const double f111 = stopping_data(pt1_energy, pt1_density, pt1_temperature); + const double dedx = exp( + linear_interpolate_3(x0, x1, y0, y1, z0, z1, f000, f100, f001, f101, f010, + f110, f011, f111, partSpeed, density, temperature)); + const double number_density = density / target.get_mass(); + return dedx * 1000. * number_density * partSpeed; // MeV cm^2 -> keV shk^-1 +} + +} // namespace rtt_cdi_cpeloss diff --git a/src/cdi_CPEloss/Tabular_CP_Eloss.hh b/src/cdi_CPEloss/Tabular_CP_Eloss.hh new file mode 100644 index 0000000000..93ebd7f11d --- /dev/null +++ b/src/cdi_CPEloss/Tabular_CP_Eloss.hh @@ -0,0 +1,115 @@ +//----------------------------------*-C++-*----------------------------------// +/*! + * \file cdi_CPEloss/Tabular_CP_Eloss.hh + * \author Ben R. Ryan + * \date 2019 Nov 4 + * \brief Tabular_CP_Eloss class definition. + * \note Copyright (C) 2016-2019 Triad National Security, LLC. + * All rights reserved. */ +//---------------------------------------------------------------------------// + +#ifndef cdi_CPEloss_Tabular_CP_Eloss_hh +#define cdi_CPEloss_Tabular_CP_Eloss_hh + +#include "experimental/mdspan" +#include "cdi/CPCommon.hh" +#include "cdi/CPEloss.hh" +#include "ds++/Assert.hh" +#include "ds++/DracoMath.hh" +#include "units/PhysicalConstants.hh" +#include "units/UnitSystemType.hh" +#include +#include +#include + +namespace rtt_cdi_cpeloss { + +namespace stdex = std::experimental; + +//===========================================================================// +/*! + * \class Tabular_CP_Eloss + * + * \brief Derived rtt_cdi::CPEloss class for tabular eloss. + * This class implements the interface found in cdi/CPEloss.hh for + * the case where CP energy loss data is in tabular form, stored + * in a file. + * + */ +//===========================================================================// + +class Tabular_CP_Eloss : public rtt_cdi::CPEloss { +public: + typedef std::vector sf_double; + typedef stdex::extents + dynamic_extents_3; + +private: + const std::string filename; + std::ifstream file; + + rtt_units::UnitSystem us; + rtt_units::PhysicalConstants pc_cgs; + + uint32_t n_energy; //!< Number of gridpoints in projectile energy + uint32_t n_density; //!< Number of gridpoints in target density + uint32_t n_temperature; //!< Number of gridpoints in target temperature + double d_log_energy; //!< Log spacing of projectile energy gridpoints + double d_log_density; //!< Log spacing of target density gridpoints + double d_log_temperature; //!< Log spacing of target temperature gridpoints + double min_log_energy; //!< Log of minimum projectile energy + double min_log_density; //!< Log of minimum target density + double min_log_temperature; //!< Log of minimum target temperature + double min_energy; //!< Minimum target energy + double max_energy; //!< Maximum target energy + double min_density; //!< Minimum target density + double max_density; //!< Maximum target density + double min_temperature; //!< Minimum target temperature + double max_temperature; //!< Maximum target temperature + sf_double energies; //!< Vector of energy gridpoints + sf_double densities; //!< Vector of density gridpoints + sf_double temperatures; //!< Vector of temperature gridpoints + // Note that after unit conversions, *_energy is really *_speed + + // Storage for tabulated data + stdex::basic_mdspan + stopping_data; + + // Utility for skipping lines + void skip_lines(uint32_t nlines); + + // Utility for reading a line of an eloss file and as a vector of strings + std::vector const read_line(); + +public: + // Constructor + Tabular_CP_Eloss(std::string filename_in, rtt_cdi::CParticle target_in, + rtt_cdi::CParticle projectile_in); + + // >>> ACCESSORS + + double getEloss(const double temperature, const double density, + const double v0) const; + + bool data_in_tabular_form() const { return true; } + + inline std::string getDataFilename() const { return filename; } + + sf_double getTemperatureGrid() const { return temperatures; } + + sf_double getDensityGrid() const { return densities; } + + sf_double getEnergyGrid() const { return energies; } + + size_t getNumTemperatures() const { return n_temperature; } + + size_t getNumDensities() const { return n_density; } + + size_t getNumEnergies() const { return n_energy; } +}; + +} // namespace rtt_cdi_cpeloss + +#endif // cdi_CPEloss_Tabular_CP_Eloss_hh diff --git a/src/cdi_CPEloss/test/001-H-001 b/src/cdi_CPEloss/test/001-H-001 new file mode 100755 index 0000000000..09b2b2e54a --- /dev/null +++ b/src/cdi_CPEloss/test/001-H-001 @@ -0,0 +1,72 @@ + 1001 + 1.000000E+00 1.007276E+00 1.672396E-24 + 4 5 6 + 2.171472E-01 2.171472E-01 2.714341E-01 + -8.517193E+00 -3.912023E+00 6.931472E-01 5.298317E+00 + 4.835429E+01 5.295946E+01 5.756463E+01 6.216980E+01 6.677497E+01 + -1.151293E+01 -7.828789E+00 -4.144653E+00 -4.605170E-01 3.223619E+00 6.907755E+00 + -4.970910E+01 -4.860564E+01 -4.974515E+01 -5.360704E+01 -4.909185E+01 -5.208202E+01 + -5.187953E+01 -5.435042E+01 -4.886876E+01 -5.341335E+01 -5.609292E+01 -5.648963E+01 + -5.041871E+01 -5.502094E+01 -5.936870E+01 -6.081163E+01 -5.195689E+01 -5.656192E+01 + -6.115348E+01 -6.490320E+01 -4.381058E+01 -4.583777E+01 -4.911283E+01 -5.325567E+01 + -4.464702E+01 -4.811104E+01 -4.998487E+01 -5.371821E+01 -4.510906E+01 -4.966025E+01 + -5.252345E+01 -5.459297E+01 -4.671739E+01 -5.131970E+01 -5.567346E+01 -5.724128E+01 + -4.826901E+01 -5.287404E+01 -5.746567E+01 -6.121922E+01 -3.996789E+01 -4.449300E+01 + -4.872510E+01 -5.299615E+01 -4.057134E+01 -4.513624E+01 -4.923052E+01 -5.333258E+01 + -4.164509E+01 -4.623231E+01 -5.020211E+01 -5.384287E+01 -4.306873E+01 -4.767175E+01 + -5.208822E+01 -5.488694E+01 -4.459121E+01 -4.919626E+01 -5.378872E+01 -5.760224E+01 + 0.000000E+00 -4.385065E+01 -4.840836E+01 -5.278987E+01 0.000000E+00 -4.420157E+01 + -4.874594E+01 -5.305433E+01 0.000000E+00 -4.468494E+01 -4.922463E+01 -5.341436E+01 + 0.000000E+00 -4.532816E+01 -4.989961E+01 -5.397394E+01 0.000000E+00 -4.615198E+01 + -5.075145E+01 -5.501417E+01 0.000000E+00 0.000000E+00 -4.805924E+01 -5.260706E+01 + 0.000000E+00 0.000000E+00 -4.828748E+01 -5.282195E+01 0.000000E+00 0.000000E+00 + -4.857797E+01 -5.309453E+01 0.000000E+00 0.000000E+00 -4.895522E+01 -5.345985E+01 + 0.000000E+00 0.000000E+00 -4.941316E+01 -5.395343E+01 0.000000E+00 0.000000E+00 + -4.777662E+01 -5.237946E+01 0.000000E+00 0.000000E+00 -4.794437E+01 -5.254681E+01 + 0.000000E+00 0.000000E+00 -4.814543E+01 -5.274731E+01 0.000000E+00 0.000000E+00 + -4.839371E+01 -5.299495E+01 0.000000E+00 0.000000E+00 -4.870410E+01 -5.330533E+01 + 2 + 1001 + 1 1.007276E+00 1.672396E-24 + -4.857735E+01 -4.767447E+01 -4.717740E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -5.176538E+01 -4.896755E+01 -4.779620E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -5.631853E+01 -5.264521E+01 -4.933215E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -6.090166E+01 -5.719401E+01 -5.320821E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -6.512910E+01 -6.137194E+01 -5.715841E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -5.163221E+01 -5.135591E+01 -5.113954E+01 -5.095789E+01 0.000000E+00 0.000000E+00 + -5.213922E+01 -5.171510E+01 -5.141800E+01 -5.118437E+01 0.000000E+00 0.000000E+00 + -5.318258E+01 -5.228064E+01 -5.180523E+01 -5.147755E+01 0.000000E+00 0.000000E+00 + -5.637066E+01 -5.357591E+01 -5.244426E+01 -5.189350E+01 0.000000E+00 0.000000E+00 + -6.092108E+01 -5.725646E+01 -5.408364E+01 -5.260964E+01 0.000000E+00 0.000000E+00 + -5.580772E+01 -5.561951E+01 -5.546118E+01 -5.532450E+01 -5.520374E+01 -5.508168E+01 + -5.610727E+01 -5.586087E+01 -5.566335E+01 -5.549845E+01 -5.535631E+01 -5.521549E+01 + -5.653690E+01 -5.617968E+01 -5.591702E+01 -5.570917E+01 -5.553641E+01 -5.536999E+01 + -5.730165E+01 -5.665041E+01 -5.625775E+01 -5.597647E+01 -5.575623E+01 -5.555279E+01 + -5.953744E+01 -5.755491E+01 -5.677840E+01 -5.634236E+01 -5.603834E+01 -5.577650E+01 + -6.018269E+01 -6.003039E+01 -5.989826E+01 -5.978156E+01 -5.967707E+01 -5.958229E+01 + -6.041289E+01 -6.022468E+01 -6.006635E+01 -5.992969E+01 -5.980948E+01 -5.970198E+01 + -6.071244E+01 -6.046604E+01 -6.026852E+01 -6.010364E+01 -5.996214E+01 -5.983797E+01 + -6.114207E+01 -6.078485E+01 -6.052219E+01 -6.031436E+01 -6.014238E+01 -5.999541E+01 + -6.190682E+01 -6.125558E+01 -6.086292E+01 -6.058167E+01 -6.036240E+01 -6.018235E+01 + 1002 + 1 2.014102E+00 3.344042E-24 + -4.907260E+01 -4.827732E+01 -4.782467E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -5.192024E+01 -4.940434E+01 -4.840673E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -5.643790E+01 -5.278527E+01 -4.977505E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -6.103644E+01 -5.734334E+01 -5.352644E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -6.553815E+01 -6.182302E+01 -5.787268E+01 0.000000E+00 0.000000E+00 0.000000E+00 + -5.227664E+01 -5.201184E+01 -5.180262E+01 -5.162778E+01 0.000000E+00 0.000000E+00 + -5.275293E+01 -5.235545E+01 -5.207168E+01 -5.184850E+01 0.000000E+00 0.000000E+00 + -5.367779E+01 -5.288295E+01 -5.244089E+01 -5.213212E+01 0.000000E+00 0.000000E+00 + -5.652548E+01 -5.401083E+01 -5.303194E+01 -5.252930E+01 0.000000E+00 0.000000E+00 + -6.104251E+01 -5.739373E+01 -5.444447E+01 -5.319447E+01 0.000000E+00 0.000000E+00 + -5.646882E+01 -5.628600E+01 -5.613149E+01 -5.599769E+01 -5.587942E+01 -5.576556E+01 + -5.675750E+01 -5.652027E+01 -5.632867E+01 -5.616793E+01 -5.602918E+01 -5.589808E+01 + -5.716494E+01 -5.682677E+01 -5.657451E+01 -5.637323E+01 -5.620537E+01 -5.605087E+01 + -5.786180E+01 -5.727095E+01 -5.690121E+01 -5.663185E+01 -5.641940E+01 -5.623129E+01 + -5.978558E+01 -5.808307E+01 -5.738950E+01 -5.698160E+01 -5.669204E+01 -5.645151E+01 + -6.085025E+01 -6.070150E+01 -6.057204E+01 -6.045743E+01 -6.035462E+01 -6.026131E+01 + -6.107399E+01 -6.089117E+01 -6.073666E+01 -6.060287E+01 -6.048487E+01 -6.037925E+01 + -6.136267E+01 -6.112544E+01 -6.093384E+01 -6.077311E+01 -6.063467E+01 -6.051298E+01 + -6.177011E+01 -6.143194E+01 -6.117968E+01 -6.097841E+01 -6.081093E+01 -6.066739E+01 + -6.246697E+01 -6.187612E+01 -6.150638E+01 -6.123703E+01 -6.102505E+01 -6.085008E+01 diff --git a/src/cdi_CPEloss/test/CMakeLists.txt b/src/cdi_CPEloss/test/CMakeLists.txt new file mode 100644 index 0000000000..12e43eb5e6 --- /dev/null +++ b/src/cdi_CPEloss/test/CMakeLists.txt @@ -0,0 +1,28 @@ +#-----------------------------*-cmake-*----------------------------------------# +# file cdi_CPEloss/test/CMakeLists.txt +# author Ben. R. Ryan +# date 2019 Nov 4 +# brief Generate build project files for cdi_CPEloss/test. +# note Copyright (C) 2016-2019, Triad National Security, LLC. +# All rights reserved. +#------------------------------------------------------------------------------# +project( cdi_CPEloss_test CXX ) + +# ---------------------------------------------------------------------------- # +# Source files +# ---------------------------------------------------------------------------- # + +set( test_sources + tstTabular_CP_Eloss.cc ) + +# ---------------------------------------------------------------------------- # +# Build Unit tests +# ---------------------------------------------------------------------------- # + +add_scalar_tests( + SOURCES "${test_sources}" + DEPS "Lib_cdi_CPEloss" ) + +#------------------------------------------------------------------------------# +# End cdi_CPEloss/test/CMakeLists.txt +#------------------------------------------------------------------------------# diff --git a/src/cdi_CPEloss/test/tstTabular_CP_Eloss.cc b/src/cdi_CPEloss/test/tstTabular_CP_Eloss.cc new file mode 100644 index 0000000000..8cab679fd2 --- /dev/null +++ b/src/cdi_CPEloss/test/tstTabular_CP_Eloss.cc @@ -0,0 +1,113 @@ +//----------------------------------*-C++-*----------------------------------// +/*! + * \file cdi_CPEloss/test/tstTabular_CP_Eloss.cc + * \author Ben R. Ryan + * \date 2019 Nov 18 + * \brief Tabular_CP_Eloss test + * \note Copyright (C) 2016-2019 Triad National Security, LLC. + * All rights reserved. */ +//---------------------------------------------------------------------------// + +#include "cdi_CPEloss/Tabular_CP_Eloss.hh" +#include "cdi/CDI.hh" +#include "ds++/Release.hh" +#include "ds++/ScalarUnitTest.hh" +#include "ds++/dbc.hh" +#include + +using rtt_cdi::CDI; +using rtt_cdi_cpeloss::Tabular_CP_Eloss; + +//---------------------------------------------------------------------------// +// TESTS +//---------------------------------------------------------------------------// + +void dedx_table_test(rtt_dsxx::UnitTest &ut) { + + // Datatable filename + std::string filename_in = ut.getTestSourcePath() + "001-H-001"; + // Alpha particle target + rtt_cdi::CParticle target_in(1002, 3.34447643e-24); + // Proton projectile + rtt_cdi::CParticle projectile_in(1001, 1.6726219e-24); + + Tabular_CP_Eloss eloss_mod(filename_in, target_in, projectile_in); + + // Model type better be tabular: + FAIL_IF_NOT(eloss_mod.getModelType() == rtt_cdi::CPModelType::TABULAR_ETYPE); + + // Tabular data + FAIL_IF_NOT(eloss_mod.data_in_tabular_form()); + + // Check that grid accessors agree + FAIL_IF_NOT(eloss_mod.getTemperatureGrid().size() == + eloss_mod.getNumTemperatures()); + FAIL_IF_NOT(eloss_mod.getDensityGrid().size() == eloss_mod.getNumDensities()); + FAIL_IF_NOT(eloss_mod.getEnergyGrid().size() == eloss_mod.getNumEnergies()); + + // Check that class grid dimensions match file + FAIL_IF_NOT(eloss_mod.getNumEnergies() == 4); + FAIL_IF_NOT(eloss_mod.getNumDensities() == 5); + FAIL_IF_NOT(eloss_mod.getNumTemperatures() == 6); + + // Data file should not be empty + FAIL_IF(eloss_mod.getDataFilename().empty()); + + // Throw error if trying to read table out of bounds + try { + eloss_mod.getEloss(0, 0, 0); + FAILMSG("Require failed to fire with out-of-bounds table access."); + } catch (rtt_dsxx::assertion &) { + PASSMSG("Require fired for out-of-bounds table access."); + } + + // Get eloss value for almost first (1,1,1) grid point + { + double energy = 1.384272; + double density = 3.344490e-01; + double temperature = 3.981051e-04; + FAIL_IF_NOT( + rtt_dsxx::soft_equiv(eloss_mod.getEloss(temperature, density, energy), + 1.958064043427486800e-01, 1.e-8)); + } + + // Get eloss value for almost last (2,3,4) grid point + { + double energy = 1.384273e+01; + double density = 3.344495e+03; + double temperature = 2.511868e+01; + FAIL_IF_NOT( + rtt_dsxx::soft_equiv(eloss_mod.getEloss(temperature, density, energy), + 8.502486928162006370e+04, 1.e-8)); + } + + // Get eloss value for a point between grid points (1.5,2.5,3.5, i.e. requiring linear interpolation) + { + double energy = 4.377453e+00; + double density = 3.344494e+02; + double temperature = 3.981044e+00; + FAIL_IF_NOT( + rtt_dsxx::soft_equiv(eloss_mod.getEloss(temperature, density, energy), + 1.391042023333255202e+05, 1.e-8)); + } + + if (ut.numFails == 0) { + PASSMSG("Tabular_CP_Eloss test passes."); + } else { + FAILMSG("Tabular_CP_Eloss test fails."); + } +} + +//---------------------------------------------------------------------------// + +int main(int argc, char *argv[]) { + rtt_dsxx::ScalarUnitTest ut(argc, argv, rtt_dsxx::release); + try { + dedx_table_test(ut); + } + UT_EPILOG(ut); +} + +//---------------------------------------------------------------------------// +// end of tst_Tabular_CP_Eloss.cc +//---------------------------------------------------------------------------// diff --git a/src/ds++/DracoMath.hh b/src/ds++/DracoMath.hh index ba6724f40a..ddb77e137b 100644 --- a/src/ds++/DracoMath.hh +++ b/src/ds++/DracoMath.hh @@ -207,62 +207,6 @@ constexpr inline double linear_interpolate(double const x1, double const x2, return value; } -//---------------------------------------------------------------------------// -/*! - * \brief Do a 3D linear interpolation between vertices of a rectangular prism. - * - * Algorithm from wikipedia's Trilinear Interpolation article, hat tip to E. - * Norris for the reference. - * - * \param[in] x0 lower x coordinate of lattice - * \param[in] x1 upper x coordinate of lattic - * \param[in] y0 lower y coordinate of lattice - * \param[in] y1 upper y coordinate of lattice - * \param[in] z0 lower z coordinate of lattice - * \param[in] z1 upper z coordinate of lattic - * \param[in] f000 function at (x0,y0,z0) - * \param[in] f100 function at (x1,y0,z0) - * \param[in] f001 function at (x0,y0,z1) - * \param[in] f101 function at (x1,y0,z1) - * \param[in] f010 function at (x0,y1,z0) - * \param[in] f110 function at (x1,y1,z0) - * \param[in] f011 function at (x0,y1,z1) - * \param[in] f111 function at (x1,y1,z1) - * \param[in] x x coordinate of interpolation point - * \param[in] y y coordinate of interpolation point - * \param[in] z z coordinate of interpolation point - * \return The function value linearly interpolated to (x,y,z) - */ -inline double -linear_interpolate_3(double const x0, double const x1, double const y0, - double const y1, double const z0, double const z1, - double const f000, double const f100, double const f001, - double const f101, double const f010, double const f110, - double const f011, double const f111, double const x, - double const y, double const z) { - Require(std::abs(x1 - x0) > std::numeric_limits::epsilon()); - Require(std::abs(y1 - y0) > std::numeric_limits::epsilon()); - Require(std::abs(z1 - z0) > std::numeric_limits::epsilon()); - Require((x >= x0) && (x <= x1) && (y >= y0) && (y <= y1) && (z >= z0) && - (z <= z1)); - - double xd = (x - x0) / (x1 - x0); - double yd = (y - y0) / (y1 - y0); - double zd = (z - z0) / (z1 - z0); - - double f00 = f000 * (1. - xd) + f100 * xd; - double f01 = f001 * (1. - xd) + f101 * xd; - double f10 = f010 * (1. - xd) + f110 * xd; - double f11 = f011 * (1. - xd) + f111 * xd; - - double f0 = f00 * (1. - yd) + f10 * yd; - double f1 = f01 * (1. - yd) + f11 * yd; - - double f = f0 * (1. - zd) + f1 * zd; - - return f; -} - //----------------------------------------------------------------------------// /*! * \brief Fast ceiling of an integer division From 9b34ad7e6274651a26e6327647052e0a2b81d23d Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Tue, 14 Jan 2020 12:31:26 -0700 Subject: [PATCH 4/6] Tweaks for 32-bit builds under appveyor. --- config/CMakeAddFortranSubdirectory.cmake | 4 ++-- config/windows-cl.cmake | 15 +++++++++------ src/FortranChecks/test/CMakeLists.txt | 7 +++++-- src/RTT_Format_Reader/CellDataIDs.cc | 9 +++------ src/RTT_Format_Reader/CellFlags.cc | 10 +++++----- src/RTT_Format_Reader/Dims.hh | 12 ++++++------ src/RTT_Format_Reader/Flags.hh | 6 +++--- src/RTT_Format_Reader/Header.cc | 13 +++++-------- src/c4/C4_Serial.cc | 13 ++++++++++++- .../__p0009_bits/mixed_size_storage.hpp | 8 +++++++- src/rng/Counter_RNG.hh | 2 +- 11 files changed, 58 insertions(+), 41 deletions(-) diff --git a/config/CMakeAddFortranSubdirectory.cmake b/config/CMakeAddFortranSubdirectory.cmake index 82efeedc1b..48ff32311b 100644 --- a/config/CMakeAddFortranSubdirectory.cmake +++ b/config/CMakeAddFortranSubdirectory.cmake @@ -405,7 +405,7 @@ function( cafs_fix_mpi_library ) set(verbose FALSE) # MS-MPI and gfortran do not play nice together... - if(WIN32) + if(WIN32 AND "${DRACO_C4}" STREQUAL "MPI") if(verbose) message("CAFS: MPI_Fortran_LIBRARIES= ${MPI_Fortran_LIBRARIES}") endif() @@ -461,7 +461,7 @@ function( cafs_fix_mpi_library ) if(verbose) message("CAFS: MPI_gfortran_LIBRARIES= ${MPI_gfortran_LIBRARIES}") endif() - endif(WIN32) + endif() endfunction(cafs_fix_mpi_library) diff --git a/config/windows-cl.cmake b/config/windows-cl.cmake index 1d64ae2a48..37c391efd6 100644 --- a/config/windows-cl.cmake +++ b/config/windows-cl.cmake @@ -133,22 +133,25 @@ endif() # # Locate a Windows sockets library (required!) -if( CMAKE_CL_64 ) +if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL 8 ) set( winsock_suffix_dir "x64") else() set( winsock_suffix_dir "x86") endif() +set( winkitlibdir "$ENV{ProgramFiles\(x86\)}/Windows Kits/10/Lib") +file( GLOB winkitdirs "${winkitlibdir}/*/um/${winsock_suffix_dir}" ) foreach( lib ws2_32;wsock32;winsock32;mswsock32 ) if( NOT Lib_win_winsock ) - find_library( winsock_lib_${lib} ${lib} ) find_library( winsock_lib_${lib} NAMES ${lib} - HINTS "C:/Windows/System32" - "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/${winsock_suffix_dir}" ) - set( Lib_win_winsock "${winsock_lib_${lib}}" CACHE FILEPATH - "Windows sockets library.") + HINTS C:/Windows/System32;${winkitdirs} ) + if( EXISTS "${winsock_lib_${lib}}" ) + set( Lib_win_winsock "${winsock_lib_${lib}}" CACHE FILEPATH + "Windows sockets library.") + endif() endif() endforeach() +unset(winkitdirs winkitlibdir) # winsock is a required dependency. if( NOT Lib_win_winsock ) diff --git a/src/FortranChecks/test/CMakeLists.txt b/src/FortranChecks/test/CMakeLists.txt index e8e4d56308..f0b19b9e81 100644 --- a/src/FortranChecks/test/CMakeLists.txt +++ b/src/FortranChecks/test/CMakeLists.txt @@ -41,10 +41,13 @@ set( ptest_sources # When building with MVSE and linking Fortran libraries generated with MinGW's # gfortran, the libquadmath-0.dll library must be found in the path. if( MSVC ) - find_file( mingw_libquadmath libquadmath-0.dll ) + get_filename_component( CAFS_Fortran_DIR "${CAFS_Fortran_COMPILER}" DIRECTORY) + find_file( mingw_libquadmath libquadmath-0.dll + HINTS ${CAFS_Fortran_DIR} ) if( NOT mingw_libquadmath ) message( FATAL_ERROR "ERROR in FortranChecks\test: - The library libquadmath-0.dll must be found in your PATH to allow these tests to run!") + The library libquadmath-0.dll must be found in your PATH to allow these " + "tests to run!") endif() endif() diff --git a/src/RTT_Format_Reader/CellDataIDs.cc b/src/RTT_Format_Reader/CellDataIDs.cc index 7178d24c61..7e24499c04 100644 --- a/src/RTT_Format_Reader/CellDataIDs.cc +++ b/src/RTT_Format_Reader/CellDataIDs.cc @@ -5,18 +5,15 @@ * \date Wed Jun 7 10:33:26 2000 * \brief Implementation file for RTT_Format_Reader/CellDataIDs class. * \note Copyright (C) 2016-2019 Triad National Security, LLC. - * All rights reserved. - */ -//---------------------------------------------------------------------------// - + * All rights reserved. */ //---------------------------------------------------------------------------// #include "CellDataIDs.hh" namespace rtt_RTT_Format_Reader { /*! - * \brief Parses the cell_data_ids data block from the mesh file via calls - * to private member functions. + * \brief Parses the cell_data_ids data block from the mesh file via calls to + * private member functions. * \param meshfile Mesh file name. */ void CellDataIDs::readDataIDs(ifstream &meshfile) { diff --git a/src/RTT_Format_Reader/CellFlags.cc b/src/RTT_Format_Reader/CellFlags.cc index a474cdf0e3..7f4f33a4a9 100644 --- a/src/RTT_Format_Reader/CellFlags.cc +++ b/src/RTT_Format_Reader/CellFlags.cc @@ -1,12 +1,12 @@ -//----------------------------------*-C++-*--------------------------------// +//----------------------------------*-C++-*-----------------------------------// /*! * \file RTT_Format_Reader/CellFlags.cc * \author B.T. Adams * \date Mon Jun 7 10:33:26 2000 - * \brief Implementation file for RTT_Format_Reader/CellFlags clas + * \brief Implementation file for RTT_Format_Reader/CellFlags class * \note Copyright (C) 2016-2019 Triad National Security, LLC. * All rights reserved. */ -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// #include "CellFlags.hh" @@ -96,6 +96,6 @@ int CellFlags::get_flag_type_index(string &desired_flag_type) const { } // end namespace rtt_RTT_Format_Reader -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// // end of RTT_Format_Reader/CellFlags.cc -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// diff --git a/src/RTT_Format_Reader/Dims.hh b/src/RTT_Format_Reader/Dims.hh index c3d6421ab8..a0a43d6d19 100644 --- a/src/RTT_Format_Reader/Dims.hh +++ b/src/RTT_Format_Reader/Dims.hh @@ -229,20 +229,20 @@ public: /*! * \brief Validates the specified side type. * \param sidetype Side type number. - * \return The existance of the side type. + * \return The existence of the side type. */ bool allowed_side_type(size_t sidetype) const { - return side_types.end() != - std::find(side_types.begin(), side_types.end(), sidetype); + return side_types.end() != std::find(side_types.begin(), side_types.end(), + static_cast(sidetype)); } /*! * \brief Validates the specified cell type. * \param celltype Cell type number. - * \return The existance of the cell type. + * \return The existence of the cell type. */ bool allowed_cell_type(size_t celltype) const { - return cell_types.end() != - std::find(cell_types.begin(), cell_types.end(), celltype); + return cell_types.end() != std::find(cell_types.begin(), cell_types.end(), + static_cast(celltype)); } }; diff --git a/src/RTT_Format_Reader/Flags.hh b/src/RTT_Format_Reader/Flags.hh index ea8acac558..8fb989b5f2 100644 --- a/src/RTT_Format_Reader/Flags.hh +++ b/src/RTT_Format_Reader/Flags.hh @@ -50,11 +50,11 @@ public: /*! * \brief Validates the specified flag index. * \param flag Flag index. - * \return The existance of the flag. + * \return The existence of the flag. */ bool allowed_flag(size_t flag) const { - return flag_nums.end() != - std::find(flag_nums.begin(), flag_nums.end(), flag); + return flag_nums.end() != std::find(flag_nums.begin(), flag_nums.end(), + static_cast(flag)); } /*! diff --git a/src/RTT_Format_Reader/Header.cc b/src/RTT_Format_Reader/Header.cc index 88a608cb0c..b4a253b612 100644 --- a/src/RTT_Format_Reader/Header.cc +++ b/src/RTT_Format_Reader/Header.cc @@ -1,15 +1,12 @@ -//----------------------------------*-C++-*--------------------------------// +//----------------------------------*-C++-*-----------------------------------// /*! * \file RTT_Format_Reader/Header.cc * \author B.T. Adams * \date WED Jun 7 10:33:26 2000 * \brief Implementation file for RTT_Format_Reader/Header class. * \note Copyright (C) 2016-2019 Triad National Security, LLC. - * All rights reserved. - */ -//---------------------------------------------------------------------------// - -//---------------------------------------------------------------------------// + * All rights reserved. */ +//----------------------------------------------------------------------------// #include "Header.hh" #include "ds++/Assert.hh" @@ -117,6 +114,6 @@ void Header::readEndKeyword(ifstream &meshfile) { } // end namespace rtt_RTT_Format_Reader -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// // end of RTT_Format_Reader/Header.cc -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// diff --git a/src/c4/C4_Serial.cc b/src/c4/C4_Serial.cc index 58e4ddbfa1..9084f6c81a 100644 --- a/src/c4/C4_Serial.cc +++ b/src/c4/C4_Serial.cc @@ -124,6 +124,13 @@ unsigned wait_any(unsigned /*count*/, C4_Req * /*requests*/) { //---------------------------------------------------------------------------// // ABORT //---------------------------------------------------------------------------// + +#ifdef _MSC_FULL_VER +// - 4702 unreachable code +#pragma warning(push) +#pragma warning(disable : 4702) +#endif + int abort(int error) { // This test is not recorded as tested by BullseyeCoverage because abort // terminates the execution and BullseyeCoverage only reports coverage for @@ -131,9 +138,13 @@ int abort(int error) { // call system exit std::abort(); - return error; + return error; // unreachable } +#ifdef _MSC_FULL_VER +#pragma warning(pop) +#endif + //---------------------------------------------------------------------------// // isScalar //---------------------------------------------------------------------------// diff --git a/src/experimental/__p0009_bits/mixed_size_storage.hpp b/src/experimental/__p0009_bits/mixed_size_storage.hpp index e85b99c1ee..c95bb3dc9f 100644 --- a/src/experimental/__p0009_bits/mixed_size_storage.hpp +++ b/src/experimental/__p0009_bits/mixed_size_storage.hpp @@ -185,7 +185,13 @@ class mixed_static_and_dynamic_size_storage< template MDSPAN_INLINE_FUNCTION constexpr mixed_static_and_dynamic_size_storage( construct_mixed_storage_from_sizes_tag_t, Integral... dyn_sizes) - : dynamic_sizes(ptrdiff_t{dyn_sizes}...) {} +#if (defined(_MSC_VER) && !defined(_WIN64)) + : dynamic_sizes(ptrdiff_t{static_cast(dyn_sizes)}...) +#else + : dynamic_sizes(ptrdiff_t{dyn_sizes}...) +#endif + { + } template MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 diff --git a/src/rng/Counter_RNG.hh b/src/rng/Counter_RNG.hh index 960ce2e65e..a74942cfca 100644 --- a/src/rng/Counter_RNG.hh +++ b/src/rng/Counter_RNG.hh @@ -33,7 +33,7 @@ /* #if (DBS_GNUC_VERSION >= 40204) && !defined(__ICC) && !defined(NVCC) -// Suppress GCC's "unused parameter" warning, about lhs and rhs in sse.h, and an +// Suppress GCC's "unused parameter" warning, about LHS and RHS in sse.h, and an // "unused local typedef" warning, from a pre-C++11 implementation of a static // assertion in compilerfeatures.h. */ From 22036eb7dc57161ff4cfc609f77baeb83494088d Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Tue, 14 Jan 2020 12:37:27 -0700 Subject: [PATCH 5/6] Fix issues related to scalar 32-bit MSVC builds. + In `CMakeAddFortranSubdirectory.cmake`, only munge MPI settings if `DRACO_C4=MPI`. + In `windows-cl.cmake`: - Use `CMAKE_SIZEOF_VOID_P` instead of `CMAKE_CL_64` as recommended by CMake. - Make searching for `ws2_32.lib` more robust by searching in more locations and exiting the seearch loop once found. + In `FortranChecks/test/CMakeLists.txt`, make the search for `libquadmath-0.dll` more robust. + Fix some comparisons between signed and unsigned integral values in `RTT_Format_Reader` and in `mdpsan`'s implementation. + Suppress a warning about unreachable code in `C4_Serial.cc`. --- config/CMakeAddFortranSubdirectory.cmake | 4 ++-- config/windows-cl.cmake | 15 +++++++++------ src/FortranChecks/test/CMakeLists.txt | 7 +++++-- src/RTT_Format_Reader/CellDataIDs.cc | 9 +++------ src/RTT_Format_Reader/CellFlags.cc | 10 +++++----- src/RTT_Format_Reader/Dims.hh | 12 ++++++------ src/RTT_Format_Reader/Flags.hh | 6 +++--- src/RTT_Format_Reader/Header.cc | 13 +++++-------- src/c4/C4_Serial.cc | 13 ++++++++++++- .../__p0009_bits/mixed_size_storage.hpp | 8 +++++++- src/rng/Counter_RNG.hh | 2 +- 11 files changed, 58 insertions(+), 41 deletions(-) diff --git a/config/CMakeAddFortranSubdirectory.cmake b/config/CMakeAddFortranSubdirectory.cmake index 82efeedc1b..48ff32311b 100644 --- a/config/CMakeAddFortranSubdirectory.cmake +++ b/config/CMakeAddFortranSubdirectory.cmake @@ -405,7 +405,7 @@ function( cafs_fix_mpi_library ) set(verbose FALSE) # MS-MPI and gfortran do not play nice together... - if(WIN32) + if(WIN32 AND "${DRACO_C4}" STREQUAL "MPI") if(verbose) message("CAFS: MPI_Fortran_LIBRARIES= ${MPI_Fortran_LIBRARIES}") endif() @@ -461,7 +461,7 @@ function( cafs_fix_mpi_library ) if(verbose) message("CAFS: MPI_gfortran_LIBRARIES= ${MPI_gfortran_LIBRARIES}") endif() - endif(WIN32) + endif() endfunction(cafs_fix_mpi_library) diff --git a/config/windows-cl.cmake b/config/windows-cl.cmake index 1d64ae2a48..37c391efd6 100644 --- a/config/windows-cl.cmake +++ b/config/windows-cl.cmake @@ -133,22 +133,25 @@ endif() # # Locate a Windows sockets library (required!) -if( CMAKE_CL_64 ) +if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL 8 ) set( winsock_suffix_dir "x64") else() set( winsock_suffix_dir "x86") endif() +set( winkitlibdir "$ENV{ProgramFiles\(x86\)}/Windows Kits/10/Lib") +file( GLOB winkitdirs "${winkitlibdir}/*/um/${winsock_suffix_dir}" ) foreach( lib ws2_32;wsock32;winsock32;mswsock32 ) if( NOT Lib_win_winsock ) - find_library( winsock_lib_${lib} ${lib} ) find_library( winsock_lib_${lib} NAMES ${lib} - HINTS "C:/Windows/System32" - "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/${winsock_suffix_dir}" ) - set( Lib_win_winsock "${winsock_lib_${lib}}" CACHE FILEPATH - "Windows sockets library.") + HINTS C:/Windows/System32;${winkitdirs} ) + if( EXISTS "${winsock_lib_${lib}}" ) + set( Lib_win_winsock "${winsock_lib_${lib}}" CACHE FILEPATH + "Windows sockets library.") + endif() endif() endforeach() +unset(winkitdirs winkitlibdir) # winsock is a required dependency. if( NOT Lib_win_winsock ) diff --git a/src/FortranChecks/test/CMakeLists.txt b/src/FortranChecks/test/CMakeLists.txt index e8e4d56308..f0b19b9e81 100644 --- a/src/FortranChecks/test/CMakeLists.txt +++ b/src/FortranChecks/test/CMakeLists.txt @@ -41,10 +41,13 @@ set( ptest_sources # When building with MVSE and linking Fortran libraries generated with MinGW's # gfortran, the libquadmath-0.dll library must be found in the path. if( MSVC ) - find_file( mingw_libquadmath libquadmath-0.dll ) + get_filename_component( CAFS_Fortran_DIR "${CAFS_Fortran_COMPILER}" DIRECTORY) + find_file( mingw_libquadmath libquadmath-0.dll + HINTS ${CAFS_Fortran_DIR} ) if( NOT mingw_libquadmath ) message( FATAL_ERROR "ERROR in FortranChecks\test: - The library libquadmath-0.dll must be found in your PATH to allow these tests to run!") + The library libquadmath-0.dll must be found in your PATH to allow these " + "tests to run!") endif() endif() diff --git a/src/RTT_Format_Reader/CellDataIDs.cc b/src/RTT_Format_Reader/CellDataIDs.cc index 7178d24c61..7e24499c04 100644 --- a/src/RTT_Format_Reader/CellDataIDs.cc +++ b/src/RTT_Format_Reader/CellDataIDs.cc @@ -5,18 +5,15 @@ * \date Wed Jun 7 10:33:26 2000 * \brief Implementation file for RTT_Format_Reader/CellDataIDs class. * \note Copyright (C) 2016-2019 Triad National Security, LLC. - * All rights reserved. - */ -//---------------------------------------------------------------------------// - + * All rights reserved. */ //---------------------------------------------------------------------------// #include "CellDataIDs.hh" namespace rtt_RTT_Format_Reader { /*! - * \brief Parses the cell_data_ids data block from the mesh file via calls - * to private member functions. + * \brief Parses the cell_data_ids data block from the mesh file via calls to + * private member functions. * \param meshfile Mesh file name. */ void CellDataIDs::readDataIDs(ifstream &meshfile) { diff --git a/src/RTT_Format_Reader/CellFlags.cc b/src/RTT_Format_Reader/CellFlags.cc index a474cdf0e3..7f4f33a4a9 100644 --- a/src/RTT_Format_Reader/CellFlags.cc +++ b/src/RTT_Format_Reader/CellFlags.cc @@ -1,12 +1,12 @@ -//----------------------------------*-C++-*--------------------------------// +//----------------------------------*-C++-*-----------------------------------// /*! * \file RTT_Format_Reader/CellFlags.cc * \author B.T. Adams * \date Mon Jun 7 10:33:26 2000 - * \brief Implementation file for RTT_Format_Reader/CellFlags clas + * \brief Implementation file for RTT_Format_Reader/CellFlags class * \note Copyright (C) 2016-2019 Triad National Security, LLC. * All rights reserved. */ -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// #include "CellFlags.hh" @@ -96,6 +96,6 @@ int CellFlags::get_flag_type_index(string &desired_flag_type) const { } // end namespace rtt_RTT_Format_Reader -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// // end of RTT_Format_Reader/CellFlags.cc -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// diff --git a/src/RTT_Format_Reader/Dims.hh b/src/RTT_Format_Reader/Dims.hh index c3d6421ab8..a0a43d6d19 100644 --- a/src/RTT_Format_Reader/Dims.hh +++ b/src/RTT_Format_Reader/Dims.hh @@ -229,20 +229,20 @@ public: /*! * \brief Validates the specified side type. * \param sidetype Side type number. - * \return The existance of the side type. + * \return The existence of the side type. */ bool allowed_side_type(size_t sidetype) const { - return side_types.end() != - std::find(side_types.begin(), side_types.end(), sidetype); + return side_types.end() != std::find(side_types.begin(), side_types.end(), + static_cast(sidetype)); } /*! * \brief Validates the specified cell type. * \param celltype Cell type number. - * \return The existance of the cell type. + * \return The existence of the cell type. */ bool allowed_cell_type(size_t celltype) const { - return cell_types.end() != - std::find(cell_types.begin(), cell_types.end(), celltype); + return cell_types.end() != std::find(cell_types.begin(), cell_types.end(), + static_cast(celltype)); } }; diff --git a/src/RTT_Format_Reader/Flags.hh b/src/RTT_Format_Reader/Flags.hh index ea8acac558..8fb989b5f2 100644 --- a/src/RTT_Format_Reader/Flags.hh +++ b/src/RTT_Format_Reader/Flags.hh @@ -50,11 +50,11 @@ public: /*! * \brief Validates the specified flag index. * \param flag Flag index. - * \return The existance of the flag. + * \return The existence of the flag. */ bool allowed_flag(size_t flag) const { - return flag_nums.end() != - std::find(flag_nums.begin(), flag_nums.end(), flag); + return flag_nums.end() != std::find(flag_nums.begin(), flag_nums.end(), + static_cast(flag)); } /*! diff --git a/src/RTT_Format_Reader/Header.cc b/src/RTT_Format_Reader/Header.cc index 88a608cb0c..b4a253b612 100644 --- a/src/RTT_Format_Reader/Header.cc +++ b/src/RTT_Format_Reader/Header.cc @@ -1,15 +1,12 @@ -//----------------------------------*-C++-*--------------------------------// +//----------------------------------*-C++-*-----------------------------------// /*! * \file RTT_Format_Reader/Header.cc * \author B.T. Adams * \date WED Jun 7 10:33:26 2000 * \brief Implementation file for RTT_Format_Reader/Header class. * \note Copyright (C) 2016-2019 Triad National Security, LLC. - * All rights reserved. - */ -//---------------------------------------------------------------------------// - -//---------------------------------------------------------------------------// + * All rights reserved. */ +//----------------------------------------------------------------------------// #include "Header.hh" #include "ds++/Assert.hh" @@ -117,6 +114,6 @@ void Header::readEndKeyword(ifstream &meshfile) { } // end namespace rtt_RTT_Format_Reader -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// // end of RTT_Format_Reader/Header.cc -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------// diff --git a/src/c4/C4_Serial.cc b/src/c4/C4_Serial.cc index 58e4ddbfa1..9084f6c81a 100644 --- a/src/c4/C4_Serial.cc +++ b/src/c4/C4_Serial.cc @@ -124,6 +124,13 @@ unsigned wait_any(unsigned /*count*/, C4_Req * /*requests*/) { //---------------------------------------------------------------------------// // ABORT //---------------------------------------------------------------------------// + +#ifdef _MSC_FULL_VER +// - 4702 unreachable code +#pragma warning(push) +#pragma warning(disable : 4702) +#endif + int abort(int error) { // This test is not recorded as tested by BullseyeCoverage because abort // terminates the execution and BullseyeCoverage only reports coverage for @@ -131,9 +138,13 @@ int abort(int error) { // call system exit std::abort(); - return error; + return error; // unreachable } +#ifdef _MSC_FULL_VER +#pragma warning(pop) +#endif + //---------------------------------------------------------------------------// // isScalar //---------------------------------------------------------------------------// diff --git a/src/experimental/__p0009_bits/mixed_size_storage.hpp b/src/experimental/__p0009_bits/mixed_size_storage.hpp index e85b99c1ee..c95bb3dc9f 100644 --- a/src/experimental/__p0009_bits/mixed_size_storage.hpp +++ b/src/experimental/__p0009_bits/mixed_size_storage.hpp @@ -185,7 +185,13 @@ class mixed_static_and_dynamic_size_storage< template MDSPAN_INLINE_FUNCTION constexpr mixed_static_and_dynamic_size_storage( construct_mixed_storage_from_sizes_tag_t, Integral... dyn_sizes) - : dynamic_sizes(ptrdiff_t{dyn_sizes}...) {} +#if (defined(_MSC_VER) && !defined(_WIN64)) + : dynamic_sizes(ptrdiff_t{static_cast(dyn_sizes)}...) +#else + : dynamic_sizes(ptrdiff_t{dyn_sizes}...) +#endif + { + } template MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 diff --git a/src/rng/Counter_RNG.hh b/src/rng/Counter_RNG.hh index 960ce2e65e..a74942cfca 100644 --- a/src/rng/Counter_RNG.hh +++ b/src/rng/Counter_RNG.hh @@ -33,7 +33,7 @@ /* #if (DBS_GNUC_VERSION >= 40204) && !defined(__ICC) && !defined(NVCC) -// Suppress GCC's "unused parameter" warning, about lhs and rhs in sse.h, and an +// Suppress GCC's "unused parameter" warning, about LHS and RHS in sse.h, and an // "unused local typedef" warning, from a pre-C++11 implementation of a static // assertion in compilerfeatures.h. */ From 191b65d17d744609b7f0a0e516a7180b75479a3d Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Tue, 14 Jan 2020 14:31:16 -0700 Subject: [PATCH 6/6] fix a dumb cmake syntax error. --- config/windows-cl.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/config/windows-cl.cmake b/config/windows-cl.cmake index 37c391efd6..dc191fd271 100644 --- a/config/windows-cl.cmake +++ b/config/windows-cl.cmake @@ -90,7 +90,8 @@ if( NOT CXX_FLAGS_INITIALIZED ) string( APPEND CMAKE_C_FLAGS_DEBUG " /Z7" ) endif() - # /Zc:__cplusplus - enables the __cplusplus preprocessor macro to report an updated value for recent C++ language standards + # /Zc:__cplusplus - enables the __cplusplus preprocessor macro to report an + # updated value for recent C++ language standards set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHa /Zc:__cplusplus " ) set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" ) @@ -151,7 +152,8 @@ foreach( lib ws2_32;wsock32;winsock32;mswsock32 ) endif() endif() endforeach() -unset(winkitdirs winkitlibdir) +unset(winkitdirs) +unset(winkitlibdir) # winsock is a required dependency. if( NOT Lib_win_winsock ) @@ -160,9 +162,13 @@ endif() # Extra logic to ensure correct winsock is found. if( "${Lib_win_winsock}" MATCHES "um/x86" AND CMAKE_CL_64 ) - message( FATAL_ERROR "Found 32-bit winsock (${Lib_win_winsock} but targeting x64 architecture. Ensure that cmake is run from the x64 Visual Studio Command Prompt." ) + message( FATAL_ERROR "Found 32-bit winsock (${Lib_win_winsock} but targeting " + "x64 architecture. Ensure that cmake is run from the x64 Visual Studio " + "Command Prompt." ) elseif( "${Lib_win_winsock}" MATCHES "um/x64" AND NOT CMAKE_CL_64 ) - message( FATAL_ERROR "Found 64-bit winsock (${Lib_win_winsock} but targeting x86 architecture. Ensure that cmake is run from the x86 Visual Studio Command Prompt." ) + message( FATAL_ERROR "Found 64-bit winsock (${Lib_win_winsock} but " + "targeting x86 architecture. Ensure that cmake is run from the x86 Visual " + "Studio Command Prompt." ) endif() #------------------------------------------------------------------------------#