├── .clang-format ├── .codecov.yml ├── .gitignore ├── .lgtm.yml ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── MANIFEST.in ├── README.md ├── appveyor.yml ├── cmake ├── FindPythonLibsNew.cmake ├── FindStandardMathLibraryC.cmake ├── autocmake_safeguards.cmake ├── custom_color_messages.cmake ├── custom_static_library.cmake ├── gau2gridConfig.cmake.in └── psi4OptionsTools.cmake ├── devtools ├── README.md ├── conda-envs │ └── base.yaml ├── scripts │ └── conda_env.py └── travis-ci │ └── before_install.sh ├── docs ├── Makefile ├── requirements.yml └── source │ ├── c_api.rst │ ├── c_example.rst │ ├── c_install.rst │ ├── conf.py │ ├── index.rst │ ├── order.rst │ ├── py_api.rst │ ├── py_example.rst │ └── py_install.rst ├── gau2grid ├── RSH.py ├── __init__.py ├── _version.py ├── c_generator.py ├── c_pragma.py ├── c_util_generator.py ├── c_wrapper.py ├── codegen.py ├── docs_generator.py ├── extras.py ├── order.py ├── python_reference.py ├── tests │ ├── __init__.py │ ├── ref_basis.py │ ├── test_c_code.py │ ├── test_c_generator.py │ ├── test_helper.py │ ├── test_order.py │ └── test_rsh.py └── utility.py ├── make_source.py ├── readthedocs.yml ├── scripts ├── make_release_sources.py ├── rsh_coef_gen.py └── time_compare.py ├── setup.cfg ├── setup.py └── versioneer.py /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: Google 3 | IndentWidth: 4 4 | ColumnLimit: 120 5 | SortIncludes: false 6 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | patch: false 4 | project: 5 | default: 6 | threshold: 50% 7 | comment: 8 | layout: "header" 9 | require_changes: false 10 | branches: null 11 | behavior: default 12 | flags: null 13 | paths: null 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | 103 | # Files resulting from compilation 104 | *.o 105 | *.a 106 | *.so 107 | *.d 108 | .idea 109 | *.swp 110 | 111 | # Compilation directories that people use 112 | obj* 113 | *objdir 114 | config 115 | build* 116 | debug 117 | debug_latest 118 | *.sh 119 | TEST 120 | */test.py 121 | */test.dat 122 | *.dylib 123 | *.so 124 | 125 | # Files resulting from running PSI4 126 | ijk.dat 127 | output.dat 128 | input.py.dat 129 | *.out 130 | *.32 131 | *.clean 132 | *timer.dat 133 | *.molden 134 | *.cube 135 | dfh.* 136 | *.npz 137 | *.zip 138 | -------------------------------------------------------------------------------- /.lgtm.yml: -------------------------------------------------------------------------------- 1 | # Configure LGTM for this package 2 | 3 | extraction: 4 | python: # Configure Python 5 | python_setup: # Configure the setup 6 | version: 3 # Specify Version 3 7 | cpp: 8 | prepare: 9 | packages: 10 | - python3-numpy 11 | 12 | path_classifiers: 13 | test: 14 | - scripts/* 15 | library: 16 | - versioneer.py # Set Versioneer.py to an external "library" (3rd party code) 17 | generated: 18 | - gau2grid/_version.py 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # After changing this file, check it on: 2 | # http://lint.travis-ci.org/ 3 | 4 | language: generic 5 | sudo: false 6 | dist: xenial 7 | 8 | matrix: 9 | 10 | include: 11 | 12 | # MacOS Builds 13 | 14 | - os: osx 15 | env: 16 | - MATRIX_EVAL='brew update &> /dev/null && brew install gcc@8' 17 | - C_COMPILER='gcc-8' 18 | - PYTHON_VER='3.6' 19 | - BUILD_TYPE='release' 20 | 21 | - os: osx 22 | osx_image: xcode8 23 | env: 24 | - C_COMPILER='gcc' 25 | - PYTHON_VER='3.6' 26 | - BUILD_TYPE='release' 27 | 28 | - os: osx 29 | osx_image: xcode10.1 30 | env: 31 | - C_COMPILER='clang' 32 | - PYTHON_VER='3.6' 33 | - BUILD_TYPE='release' 34 | 35 | # Linux Builds 36 | 37 | - os: linux 38 | compiler: clang 39 | addons: 40 | apt: 41 | packages: 42 | - clang-3.6 43 | env: 44 | - C_COMPILER='clang-3.6' 45 | - PYTHON_VER='3.7' 46 | - BUILD_TYPE='release' 47 | 48 | - os: linux 49 | compiler: clang 50 | addons: 51 | apt: 52 | packages: 53 | - clang-6.0 54 | env: 55 | - C_COMPILER='clang-6.0' 56 | - PYTHON_VER='3.6' 57 | - BUILD_TYPE='release' 58 | 59 | - os: linux 60 | compiler: gcc 61 | addons: 62 | apt: 63 | packages: 64 | - gcc-4.9 65 | env: 66 | - C_COMPILER='gcc-4.9' 67 | - PYTHON_VER='3.7' 68 | - BUILD_TYPE='release' 69 | 70 | - os: linux 71 | compiler: gcc 72 | addons: 73 | apt: 74 | sources: 75 | - ubuntu-toolchain-r-test 76 | packages: 77 | - gcc-6 78 | env: 79 | - C_COMPILER='gcc-6' 80 | - PYTHON_VER='3.8' 81 | - BUILD_TYPE='release' 82 | 83 | - os: linux 84 | compiler: gcc 85 | addons: 86 | apt: 87 | sources: 88 | - ubuntu-toolchain-r-test 89 | packages: 90 | - gcc-7 91 | env: 92 | - C_COMPILER='gcc-7' 93 | - PYTHON_VER='3.6' 94 | - BUILD_TYPE='release' 95 | 96 | before_install: 97 | - uname -a 98 | - df -h 99 | - ulimit -a 100 | 101 | 102 | # Setup python environment 103 | - source devtools/travis-ci/before_install.sh 104 | - python -V 105 | 106 | # Eval matrix evaluations if needed 107 | - sh -c '[ -z "$MATRIX_EVAL" ] || eval "${MATRIX_EVAL}"' 108 | 109 | install: 110 | - python devtools/scripts/conda_env.py -n=test -p=$PYTHON_VER devtools/conda-envs/base.yaml 111 | - source activate test 112 | 113 | - > 114 | python setup.py install 115 | -DCMAKE_C_COMPILER=${C_COMPILER} 116 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} 117 | 118 | before_script: 119 | - python -V 120 | - conda list 121 | - python -c 'import numpy; print(numpy.version.version)' 122 | 123 | script: 124 | - export GAU2GRID_FORCE_C_TEST=1 125 | - export SPDIR=`python -c 'from distutils import sysconfig as s; print(s.get_python_lib(plat_specific=True))'` 126 | - pytest -rws -v --durations=5 --cov=${SPDIR}/gau2grid/ --pyargs gau2grid 127 | 128 | notifications: 129 | email: false 130 | 131 | after_success: 132 | - codecov 133 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1 FATAL_ERROR) 2 | 3 | project(gau2grid 4 | VERSION 2.0.7 5 | LANGUAGES C) 6 | set(gau2grid_AUTHORS "Daniel G. A. Smith") 7 | set(gau2grid_DESCRIPTION "Fast computation of a gaussian and its derivative on a grid") 8 | set(gau2grid_URL "https://github.com/dgasmith/gau2grid") 9 | set(gau2grid_LICENSE "BSD 3-clause") 10 | 11 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 12 | 13 | 14 | ############################# Options: Build How? ############################# 15 | include(psi4OptionsTools) 16 | option_with_default(MAX_AM "The maximum gaussian angular momentum to compile" 8) 17 | option_with_default(CMAKE_BUILD_TYPE "Build type (Release or Debug)" Release) 18 | if(CMAKE_CXX_COMPILER_ID MATCHES Intel) 19 | option_with_flags(ENABLE_XHOST "Enables processor-specific optimization (with MSVC, it enables AVX2 instructions)" ON 20 | "-xHost" "-march=native" "/arch:AVX2") 21 | else() 22 | option_with_flags(ENABLE_XHOST "Enables processor-specific optimization (with MSVC, it enables AVX2 instructions)" ON 23 | "-march=native" "-xHost" "/arch:AVX2") 24 | endif() 25 | option_with_default(BUILD_FPIC "Libraries will be compiled with position independent code" ON) 26 | option_with_print(BUILD_SHARED_LIBS "Build final library as shared, not static" ON) 27 | option_with_default(ENABLE_GENERIC "Enables mostly static linking of system libraries for shared library" OFF) 28 | option_with_default(DISABLE_PRAGMA "Disable certain pragma optimizations, appends _GG_NO_PRAGMA to compile flags" OFF ) 29 | 30 | # Warnings 31 | if((${BUILD_SHARED_LIBS}) AND NOT ${BUILD_FPIC}) 32 | message(FATAL_ERROR "BUILD_SHARED_LIBS ON and BUILD_FPIC OFF are incompatible, as shared library requires position independent code") 33 | endif() 34 | 35 | # Install 36 | option_with_default(CMAKE_INSTALL_LIBDIR "Directory to which libraries installed" lib) 37 | option_with_default(PYMOD_INSTALL_LIBDIR "Location within CMAKE_INSTALL_LIBDIR to which python modules are installed 38 | Must start with: / . Used to imitate python install: /python3.6/site-packages ." /) 39 | option_with_print(INSTALL_PYMOD "Additionally installs as independent python module in PYMOD_INSTALL_LIBDIR" OFF) 40 | option_with_default(NATIVE_PYTHON_INSTALL "For INSTALL_PYMOD=ON, install in Python manner to PYTHON_EXECUTABLE's site-packages rather than Linux manner to prefix. Overrides CMAKE_INSTALL_PREFIX, CMAKE_INSTALL_LIBDIR, PYMOD_INSTALL_LIBDIR. Only Py module installed." OFF) 41 | option_with_print(NATIVE_PYTHON_INSTALL_WITH_LIB "Same as NATIVE_PYTHON_INSTALL except installs library, too, _without_ overriding CMAKE_INSTALL_* options." OFF) 42 | 43 | ######################## Process & Validate Options ########################## 44 | include(autocmake_safeguards) 45 | include(custom_color_messages) 46 | include(custom_static_library) 47 | 48 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 49 | set(CMAKE_INSTALL_PREFIX "/usr/local/gau2grid" CACHE PATH "Install path" FORCE) 50 | endif() 51 | message(STATUS "gau2grid install: ${CMAKE_INSTALL_PREFIX}") 52 | 53 | # << Python >> 54 | set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5) # adjust with CMake minimum FindPythonInterp 55 | find_package(PythonLibsNew 3.6 REQUIRED) 56 | message(STATUS "${Cyan}Found Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}${ColourReset}: ${PYTHON_EXECUTABLE} (found version ${PYTHON_VERSION_STRING})") 57 | 58 | 59 | ################################ Main Project ################################ 60 | add_custom_command( 61 | OUTPUT gau2grid/gau2grid.h gau2grid_orbital.c gau2grid_phi.c gau2grid_deriv1.c gau2grid_deriv2.c gau2grid_deriv3.c gau2grid_transform.c gau2grid_helper.c 62 | COMMAND ${PYTHON_EXECUTABLE} -c "import sys; \ 63 | sys.path.append('${PROJECT_SOURCE_DIR}'); \ 64 | import gau2grid as gg; \ 65 | gg.c_gen.generate_c_gau2grid(${MAX_AM}, path='${CMAKE_CURRENT_BINARY_DIR}')" 66 | DEPENDS gau2grid/c_generator.py 67 | gau2grid/c_generator.py 68 | gau2grid/codegen.py 69 | gau2grid/c_pragma.py 70 | gau2grid/c_util_generator.py 71 | gau2grid/c_wrapper.py 72 | gau2grid/docs_generator.py 73 | gau2grid/order.py 74 | gau2grid/python_reference.py 75 | gau2grid/RSH.py 76 | gau2grid/utility.py 77 | VERBATIM) 78 | 79 | set(sources_list ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_phi.c 80 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_orbital.c 81 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_deriv1.c 82 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_deriv2.c 83 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_deriv3.c 84 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_transform.c 85 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_helper.c) 86 | 87 | add_library(gg ${sources_list}) 88 | if ("${CMAKE_C_COMPILER_ID}" STREQUAL "PGI") 89 | set_target_properties(gg PROPERTIES COMPILE_FLAGS "-c11") 90 | else() 91 | set_target_properties(gg PROPERTIES COMPILE_FLAGS "-std=c11") 92 | endif() 93 | set_target_properties(gg PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_FPIC} 94 | SOVERSION 2) # bump whenever interface has changes or removals 95 | 96 | if( DISABLE_PRAGMA ) 97 | target_compile_definitions( gg PRIVATE $ ) 98 | endif() 99 | 100 | find_package(StandardMathLibraryC) 101 | target_link_libraries(gg PRIVATE ${STANDARD_MATH_LIBRARY}) 102 | 103 | if(${BUILD_SHARED_LIBS}) 104 | target_link_libraries(gg PRIVATE ${LIBC_INTERJECT}) 105 | endif() 106 | 107 | 108 | ################################### Install ################################## 109 | include(GNUInstallDirs) 110 | include(CMakePackageConfigHelpers) 111 | 112 | set(PN ${PROJECT_NAME}) 113 | 114 | # Alias to allow for consistent manipulation as a subproject 115 | add_library( ${PN}::gg ALIAS gg ) 116 | 117 | target_include_directories(gg PUBLIC 118 | $ 119 | $) 120 | 121 | # GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share". 122 | set(CMAKECONFIG_INSTALL_DIR "share/cmake/${PN}") 123 | configure_package_config_file(cmake/${PN}Config.cmake.in 124 | "${CMAKE_CURRENT_BINARY_DIR}/${PN}Config.cmake" 125 | INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) 126 | write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PN}ConfigVersion.cmake 127 | VERSION ${${PN}_VERSION} 128 | COMPATIBILITY SameMajorVersion) 129 | 130 | # Install our files 131 | if(${NATIVE_PYTHON_INSTALL_WITH_LIB} OR (NOT(${INSTALL_PYMOD} AND ${NATIVE_PYTHON_INSTALL}))) 132 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gau2grid/gau2grid.h 133 | ${CMAKE_CURRENT_BINARY_DIR}/gau2grid/gau2grid_pragma.h 134 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PN}) 135 | 136 | install(TARGETS gg 137 | EXPORT "${PN}Targets" 138 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 139 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 140 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 141 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 142 | 143 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PN}Config.cmake 144 | ${CMAKE_CURRENT_BINARY_DIR}/${PN}ConfigVersion.cmake 145 | DESTINATION ${CMAKECONFIG_INSTALL_DIR}) 146 | install(EXPORT "${PN}Targets" 147 | NAMESPACE "${PN}::" 148 | DESTINATION ${CMAKECONFIG_INSTALL_DIR}) 149 | export(EXPORT "${PN}Targets" 150 | NAMESPACE "${PN}::" 151 | FILE "${PROJECT_BINARY_DIR}/${PN}Targets.cmake") 152 | endif() 153 | 154 | if(${INSTALL_PYMOD}) 155 | if(${NATIVE_PYTHON_INSTALL}) 156 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c 157 | "import sys; print(sys.prefix);" 158 | OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX 159 | OUTPUT_STRIP_TRAILING_WHITESPACE) 160 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c 161 | "from distutils import sysconfig as s; import os; import sys; cmake_install_prefix = sys.prefix; prefix_lib = s.get_config_var('LIBDIR'); print(prefix_lib.replace(os.path.commonpath([prefix_lib, cmake_install_prefix]), '').strip('/'));" 162 | OUTPUT_VARIABLE CMAKE_INSTALL_LIBDIR 163 | OUTPUT_STRIP_TRAILING_WHITESPACE) 164 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c 165 | "from distutils import sysconfig as s; import os; prefix_lib = s.get_config_var('LIBDIR'); spdir = s.get_python_lib(plat_specific=True); print(spdir.replace(os.path.commonpath([prefix_lib, spdir]), ''));" 166 | OUTPUT_VARIABLE PYMOD_INSTALL_LIBDIR 167 | OUTPUT_STRIP_TRAILING_WHITESPACE) 168 | endif() 169 | 170 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c 171 | "from numpy import distutils; print(distutils.misc_util.get_shared_lib_extension(is_python_ext=False))" 172 | OUTPUT_VARIABLE PYLIB_EXTENSION 173 | OUTPUT_STRIP_TRAILING_WHITESPACE) 174 | 175 | install(DIRECTORY gau2grid 176 | DESTINATION ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR} 177 | USE_SOURCE_PERMISSIONS 178 | FILES_MATCHING PATTERN "*.py") 179 | 180 | install(FILES $ 181 | DESTINATION ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR}/gau2grid 182 | RENAME "gg${PYLIB_EXTENSION}") 183 | 184 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE 185 | DESTINATION ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR}/gau2grid) 186 | endif() 187 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, Daniel Smith 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include gau2grid *.py 2 | 3 | include setup.py 4 | include README.md 5 | include LICENSE 6 | include MANIFEST.in 7 | 8 | include versioneer.py 9 | include gau2grid/_version.py 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Travis CI 4 | 5 | 6 | 7 | Appveyor 8 | 9 | 10 | 11 | Codecov 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Documentation Status 20 | 21 |

22 | 23 | # gau2grid 24 | A collocation code for computing gaussians on a grid of the form: 25 | ``` 26 | out_Lp = x^l y^m z^n \sum_i coeff_i e^(exponent_i * (|center - p|)^2) 27 | ``` 28 | Where the returned matrix dimension are the angular momentum (L) by number of requested points (p). 29 | 30 | ```python 31 | import gau2grid 32 | import numpy as np 33 | 34 | # Build coordinates along the Z axis 35 | >>> xyz = np.zeros((3, 5)) 36 | >>> xyz[2] = np.arange(5) 37 | 38 | # Compute a 's' gaussian with a scaling and exponent of one at the origin 39 | >>> ret = gau2grid.collocation(xyz, 0, [1], [1], [0, 0, 0]) 40 | >>> print(ret["PHI"]) 41 | [[ 1.00000e+00 3.67879e-01 1.83156e-02 1.23409e-04 1.12535e-07]] 42 | 43 | # Compute a 'p' gaussian with a scaling and exponent of one at the origin 44 | >>> ret = gau2grid.collocation(xyz, 1, [1], [1], [0, 0, 0], spherical=False) 45 | >>> print(ret["PHI"]) 46 | [[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] 47 | [ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] 48 | [ 0.00000e+00 3.67879e-01 3.66312e-02 3.70229e-04 4.50140e-07]] 49 | 50 | # Note that the X and Y components are zero as they are orthogonal to our Z vector. 51 | ``` 52 | 53 | The returned matrix can be in either cartesian or regular solid harmonics. There are currently 54 | three algorithms in which to compute these collocation matrices: 55 | - Optimize C: A autogenerated C library that optimizes for cache, 56 | vectorization, and sparsity. Fastest, requires compilation, found at 57 | `gau2grid.collocation`. 58 | - Optimized/Generated NumPy: A exploratory tool to 59 | examine the sparsity in the gaussians. No compilation required, found at 60 | `gau2grid.np_gen.collocation`. 61 | - NumPy Reference: A simple NumPy-based loop 62 | code. No compilation required, found at `gau2grid.ref.collocation`. 63 | 64 | See the [documentation](https://gau2grid.readthedocs.io/en/latest/?badge=latest) for more information! 65 | 66 | ## Building Gau2Grid 67 | The C library is built with CMake and has C no required dependancies other than 68 | the standard library. A CMake and build example can found below: 69 | 70 | ```bash 71 | cmake -H. -Bobjdir 72 | cd objdir; make -j2 73 | ``` 74 | 75 | Several common CMake options are as follow: 76 | - `-DPYTHON_EXECUTABLE` - Path to the desired Python executable 77 | - `-DMAX_AM` - Maximum angular momentum to compile to, default 6 78 | - `-DCMAKE_INSTALL_PREFIX` - Installation directory 79 | 80 | ## Python installation 81 | The gau2grid program (without the optimized C library) can be installed using 82 | the canonical `setup.py` script, 83 | ``` 84 | python setup.py install 85 | ``` 86 | 87 | # Authors 88 | This code was inspired by a number of folks and quite a few provided excellent advice. 89 | 90 | - Daniel G. A. Smith - Code author 91 | - Rob M. Parrish - Author of the Psi4 section which contains the original equations 92 | - Lori A. Burns - CMake, building, and library linking 93 | - Andy C. Simmonett - RSH coefficients 94 | - Ben Pritchard - Generator and vectorization recommendations 95 | 96 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | clone_depth: 5 3 | 4 | install: 5 | - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" 6 | - C:\Miniconda36-x64\Scripts\activate base 7 | - conda install --yes numpy pytest 8 | - conda list 9 | 10 | before_build: 11 | - set SOURCE_FOLDER=%APPVEYOR_BUILD_FOLDER% 12 | - set BUILD_FOLDER=%SOURCE_FOLDER%\build 13 | - set INSTALL_FOLDER=%SOURCE_FOLDER%\install 14 | - mkdir %BUILD_FOLDER% & cd %BUILD_FOLDER% 15 | - cmake -A x64 16 | -DCMAKE_C_FLAGS="/wd4018 /wd4101 /wd4996" 17 | -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=true 18 | -DCMAKE_INSTALL_PREFIX=%INSTALL_FOLDER% 19 | -DINSTALL_PYMOD=ON 20 | .. 21 | 22 | build_script: 23 | - cmake --build . 24 | 25 | after_build: 26 | - cmake --build . --target install 27 | 28 | before_test: 29 | - cd .. 30 | - set PYTHONPATH=%INSTALL_FOLDER%\lib 31 | 32 | test_script: 33 | - set GAU2GRID_FORCE_C_TEST=1 34 | - pytest -rws -v %INSTALL_FOLDER% 35 | -------------------------------------------------------------------------------- /cmake/FindPythonLibsNew.cmake: -------------------------------------------------------------------------------- 1 | # - Find python libraries 2 | # This module finds the libraries corresponding to the Python interpeter 3 | # FindPythonInterp provides. 4 | # This code sets the following variables: 5 | # 6 | # PYTHONLIBS_FOUND - have the Python libs been found 7 | # PYTHON_PREFIX - path to the Python installation 8 | # PYTHON_LIBRARIES - path to the python library 9 | # PYTHON_INCLUDE_DIRS - path to where Python.h is found 10 | # PYTHON_MODULE_EXTENSION - lib extension, e.g. '.so' or '.pyd' 11 | # PYTHON_MODULE_PREFIX - lib name prefix: usually an empty string 12 | # PYTHON_SITE_PACKAGES - path to installation site-packages 13 | # PYTHON_IS_DEBUG - whether the Python interpreter is a debug build 14 | # 15 | # Thanks to talljimbo for the patch adding the 'LDVERSION' config 16 | # variable usage. 17 | 18 | #============================================================================= 19 | # Copyright 2001-2009 Kitware, Inc. 20 | # Copyright 2012 Continuum Analytics, Inc. 21 | # 22 | # All rights reserved. 23 | # 24 | # Redistribution and use in source and binary forms, with or without 25 | # modification, are permitted provided that the following conditions 26 | # are met: 27 | # 28 | # * Redistributions of source code must retain the above copyright 29 | # notice, this list of conditions and the following disclaimer. 30 | # 31 | # * Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # 35 | # * Neither the names of Kitware, Inc., the Insight Software Consortium, 36 | # nor the names of their contributors may be used to endorse or promote 37 | # products derived from this software without specific prior written 38 | # permission. 39 | # 40 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43 | # # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51 | #============================================================================= 52 | 53 | if(PYTHONLIBS_FOUND) 54 | return() 55 | endif() 56 | 57 | # Use the Python interpreter to find the libs. 58 | if(PythonLibsNew_FIND_REQUIRED) 59 | find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) 60 | else() 61 | find_package(PythonInterp ${PythonLibsNew_FIND_VERSION}) 62 | endif() 63 | 64 | if(NOT PYTHONINTERP_FOUND) 65 | set(PYTHONLIBS_FOUND FALSE) 66 | return() 67 | endif() 68 | 69 | # According to http://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter 70 | # testing whether sys has the gettotalrefcount function is a reliable, cross-platform 71 | # way to detect a CPython debug interpreter. 72 | # 73 | # The library suffix is from the config var LDVERSION sometimes, otherwise 74 | # VERSION. VERSION will typically be like "2.7" on unix, and "27" on windows. 75 | execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" 76 | "from distutils import sysconfig as s;import sys;import struct; 77 | print('.'.join(str(v) for v in sys.version_info)); 78 | print(sys.prefix); 79 | print(s.get_python_inc(plat_specific=True)); 80 | print(s.get_python_lib(plat_specific=True)); 81 | print(s.get_config_var('SO')); 82 | print(hasattr(sys, 'gettotalrefcount')+0); 83 | print(struct.calcsize('@P')); 84 | print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); 85 | print(s.get_config_var('LIBDIR') or ''); 86 | print(s.get_config_var('MULTIARCH') or ''); 87 | " 88 | RESULT_VARIABLE _PYTHON_SUCCESS 89 | OUTPUT_VARIABLE _PYTHON_VALUES 90 | ERROR_VARIABLE _PYTHON_ERROR_VALUE) 91 | 92 | if(NOT _PYTHON_SUCCESS MATCHES 0) 93 | if(PythonLibsNew_FIND_REQUIRED) 94 | message(FATAL_ERROR 95 | "Python config failure:\n${_PYTHON_ERROR_VALUE}") 96 | endif() 97 | set(PYTHONLIBS_FOUND FALSE) 98 | return() 99 | endif() 100 | 101 | # Convert the process output into a list 102 | string(REGEX REPLACE ";" "\\\\;" _PYTHON_VALUES ${_PYTHON_VALUES}) 103 | string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES}) 104 | list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST) 105 | list(GET _PYTHON_VALUES 1 PYTHON_PREFIX) 106 | list(GET _PYTHON_VALUES 2 PYTHON_INCLUDE_DIR) 107 | list(GET _PYTHON_VALUES 3 PYTHON_SITE_PACKAGES) 108 | list(GET _PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION) 109 | list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG) 110 | list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) 111 | list(GET _PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX) 112 | list(GET _PYTHON_VALUES 8 PYTHON_LIBDIR) 113 | list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH) 114 | 115 | # Make sure the Python has the same pointer-size as the chosen compiler 116 | # Skip if CMAKE_SIZEOF_VOID_P is not defined 117 | if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZEOF_VOID_P}")) 118 | if(PythonLibsNew_FIND_REQUIRED) 119 | math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8") 120 | math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8") 121 | message(FATAL_ERROR 122 | "Python config failure: Python is ${_PYTHON_BITS}-bit, " 123 | "chosen compiler is ${_CMAKE_BITS}-bit") 124 | endif() 125 | set(PYTHONLIBS_FOUND FALSE) 126 | return() 127 | endif() 128 | 129 | # The built-in FindPython didn't always give the version numbers 130 | string(REGEX REPLACE "\\." ";" _PYTHON_VERSION_LIST ${_PYTHON_VERSION_LIST}) 131 | list(GET _PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR) 132 | list(GET _PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR) 133 | list(GET _PYTHON_VERSION_LIST 2 PYTHON_VERSION_PATCH) 134 | 135 | # Make sure all directory separators are '/' 136 | string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX ${PYTHON_PREFIX}) 137 | string(REGEX REPLACE "\\\\" "/" PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) 138 | string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES ${PYTHON_SITE_PACKAGES}) 139 | 140 | if(CMAKE_HOST_WIN32) 141 | set(PYTHON_LIBRARY 142 | "${PYTHON_PREFIX}/libs/Python${PYTHON_LIBRARY_SUFFIX}.lib") 143 | 144 | # when run in a venv, PYTHON_PREFIX points to it. But the libraries remain in the 145 | # original python installation. They may be found relative to PYTHON_INCLUDE_DIR. 146 | if(NOT EXISTS "${PYTHON_LIBRARY}") 147 | get_filename_component(_PYTHON_ROOT ${PYTHON_INCLUDE_DIR} DIRECTORY) 148 | set(PYTHON_LIBRARY 149 | "${_PYTHON_ROOT}/libs/Python${PYTHON_LIBRARY_SUFFIX}.lib") 150 | endif() 151 | 152 | # raise an error if the python libs are still not found. 153 | if(NOT EXISTS "${PYTHON_LIBRARY}") 154 | message(FATAL_ERROR "Python libraries not found") 155 | endif() 156 | 157 | else() 158 | if(PYTHON_MULTIARCH) 159 | set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}/${PYTHON_MULTIARCH}" "${PYTHON_LIBDIR}") 160 | else() 161 | set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}") 162 | endif() 163 | #message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}") 164 | # Probably this needs to be more involved. It would be nice if the config 165 | # information the python interpreter itself gave us were more complete. 166 | find_library(PYTHON_LIBRARY 167 | NAMES "python${PYTHON_LIBRARY_SUFFIX}" 168 | PATHS ${_PYTHON_LIBS_SEARCH} 169 | NO_DEFAULT_PATH) 170 | 171 | # If all else fails, just set the name/version and let the linker figure out the path. 172 | if(NOT PYTHON_LIBRARY) 173 | set(PYTHON_LIBRARY python${PYTHON_LIBRARY_SUFFIX}) 174 | endif() 175 | endif() 176 | 177 | MARK_AS_ADVANCED( 178 | PYTHON_LIBRARY 179 | PYTHON_INCLUDE_DIR 180 | ) 181 | 182 | # We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the 183 | # cache entries because they are meant to specify the location of a single 184 | # library. We now set the variables listed by the documentation for this 185 | # module. 186 | SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") 187 | SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") 188 | SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") 189 | 190 | find_package_message(PYTHON 191 | "Found PythonLibs: ${PYTHON_LIBRARY}" 192 | "${PYTHON_EXECUTABLE}${PYTHON_VERSION}") 193 | 194 | set(PYTHONLIBS_FOUND TRUE) 195 | -------------------------------------------------------------------------------- /cmake/FindStandardMathLibraryC.cmake: -------------------------------------------------------------------------------- 1 | # * downloaded Nov 2016 from https://android.googlesource.com/platform/external/eigen/+/master/cmake/FindStandardMathLibrary.cmake 2 | # * changed CXX to C 3 | # * note that full path to libm *not* detected 4 | 5 | # - Try to find how to link to the standard math library, if anything at all is needed to do. 6 | # On most platforms this is automatic, but for example it's not automatic on QNX. 7 | # 8 | # Once done this will define 9 | # 10 | # STANDARD_MATH_LIBRARY_FOUND - we found how to successfully link to the standard math library 11 | # STANDARD_MATH_LIBRARY - the name of the standard library that one has to link to. 12 | # -- this will be left empty if it's automatic (most platforms). 13 | # -- this will be set to "m" on platforms where one must explicitly 14 | # pass the "-lm" linker flag. 15 | # 16 | # Copyright (c) 2010 Benoit Jacob 17 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license. 18 | include(CheckCSourceCompiles) 19 | # a little test program for c++ math functions. 20 | # notice the std:: is required on some platforms such as QNX 21 | set(find_standard_math_library_test_program 22 | "#include 23 | int main() { sin(0.0); log(0.0f); }") 24 | # C++ test program 25 | # "#include 26 | # int main() { std::sin(0.0); std::log(0.0f); }") 27 | # first try compiling/linking the test program without any linker flags 28 | set(CMAKE_REQUIRED_FLAGS "") 29 | set(CMAKE_REQUIRED_LIBRARIES "") 30 | CHECK_C_SOURCE_COMPILES( 31 | "${find_standard_math_library_test_program}" 32 | standard_math_library_linked_to_automatically 33 | ) 34 | if(standard_math_library_linked_to_automatically) 35 | # the test program linked successfully without any linker flag. 36 | set(STANDARD_MATH_LIBRARY "") 37 | set(STANDARD_MATH_LIBRARY_FOUND TRUE) 38 | else() 39 | # the test program did not link successfully without any linker flag. 40 | # This is a very uncommon case that so far we only saw on QNX. The next try is the 41 | # standard name 'm' for the standard math library. 42 | set(CMAKE_REQUIRED_LIBRARIES "m") 43 | CHECK_C_SOURCE_COMPILES( 44 | "${find_standard_math_library_test_program}" 45 | standard_math_library_linked_to_as_m) 46 | if(standard_math_library_linked_to_as_m) 47 | # the test program linked successfully when linking to the 'm' library 48 | set(STANDARD_MATH_LIBRARY "m") 49 | set(STANDARD_MATH_LIBRARY_FOUND TRUE) 50 | else() 51 | # the test program still doesn't link successfully 52 | set(STANDARD_MATH_LIBRARY_FOUND FALSE) 53 | endif() 54 | endif() 55 | -------------------------------------------------------------------------------- /cmake/autocmake_safeguards.cmake: -------------------------------------------------------------------------------- 1 | # Downloaded from 2 | # https://github.com/coderefinery/autocmake/blob/master/modules/safeguards.cmake 3 | # * changed text of in-source message 4 | 5 | #.rst: 6 | # 7 | # Provides safeguards against in-source builds and bad build types. 8 | # 9 | # Variables used:: 10 | # 11 | # PROJECT_SOURCE_DIR 12 | # PROJECT_BINARY_DIR 13 | # CMAKE_BUILD_TYPE 14 | 15 | if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) 16 | message(FATAL_ERROR "In-source builds not allowed. Please run CMake from top directory and specify a build directory (e.g., cmake -H. -Bbuild).") 17 | endif() 18 | 19 | string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower) 20 | string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper) 21 | 22 | if(NOT cmake_build_type_tolower STREQUAL "debug" AND 23 | NOT cmake_build_type_tolower STREQUAL "release" AND 24 | NOT cmake_build_type_tolower STREQUAL "relwithdebinfo") 25 | message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo (case-insensitive).") 26 | endif() 27 | -------------------------------------------------------------------------------- /cmake/custom_color_messages.cmake: -------------------------------------------------------------------------------- 1 | # http://stackoverflow.com/a/19578320 2 | 3 | if(NOT WIN32) 4 | string(ASCII 27 Esc) 5 | set(ColourReset "${Esc}[m") 6 | set(ColourBold "${Esc}[1m") 7 | set(Red "${Esc}[31m") 8 | set(Green "${Esc}[32m") 9 | set(Yellow "${Esc}[33m") 10 | set(Blue "${Esc}[34m") 11 | set(Magenta "${Esc}[35m") 12 | set(Cyan "${Esc}[36m") 13 | set(White "${Esc}[37m") 14 | set(BoldRed "${Esc}[1;31m") 15 | set(BoldGreen "${Esc}[1;32m") 16 | set(BoldYellow "${Esc}[1;33m") 17 | set(BoldBlue "${Esc}[1;34m") 18 | set(BoldMagenta "${Esc}[1;35m") 19 | set(BoldCyan "${Esc}[1;36m") 20 | set(BoldWhite "${Esc}[1;37m") 21 | endif() 22 | 23 | #message("This is normal") 24 | #message("${Red}This is Red${ColourReset}") 25 | #message("${Green}This is Green${ColourReset}") 26 | #message("${Yellow}This is Yellow${ColourReset}") 27 | #message("${Blue}This is Blue${ColourReset}") 28 | #message("${Magenta}This is Magenta${ColourReset}") 29 | #message("${Cyan}This is Cyan${ColourReset}") 30 | #message("${White}This is White${ColourReset}") 31 | #message("${BoldRed}This is BoldRed${ColourReset}") 32 | #message("${BoldGreen}This is BoldGreen${ColourReset}") 33 | #message("${BoldYellow}This is BoldYellow${ColourReset}") 34 | #message("${BoldBlue}This is BoldBlue${ColourReset}") 35 | #message("${BoldMagenta}This is BoldMagenta${ColourReset}") 36 | #message("${BoldCyan}This is BoldCyan${ColourReset}") 37 | #message("${BoldWhite}This is BoldWhite\n\n${ColourReset}") 38 | 39 | -------------------------------------------------------------------------------- /cmake/custom_static_library.cmake: -------------------------------------------------------------------------------- 1 | # Downloaded from 2 | # https://github.com/PCMSolver/pcmsolver/blob/release/1.Y/cmake/custom/static_library.cmake 3 | # * suppressed STATIC_LIBRARY_ONLY 4 | # * moved option up 5 | # * corrected CXX block matches statements from C --> CXX compiler 6 | 7 | #.rst: 8 | # 9 | # Enables creation of static library. 10 | # If the shared library is created, make it as static as possible. 11 | # 12 | # Variables modified (provided the corresponding language is enabled):: 13 | # 14 | # CMAKE_Fortran_FLAGS 15 | # CMAKE_C_FLAGS 16 | # CMAKE_CXX_FLAGS 17 | # 18 | # autocmake.cfg configuration:: 19 | # 20 | # docopt: --static Create only the static library [default: False]. 21 | # define: '-DSTATIC_LIBRARY_ONLY=%s' % arguments['--static'] 22 | 23 | if(ENABLE_GENERIC) 24 | if(DEFINED CMAKE_Fortran_COMPILER_ID) 25 | if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) 26 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-libgfortran") 27 | endif() 28 | if(CMAKE_Fortran_COMPILER_ID MATCHES Intel) 29 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-libgcc -static-intel") 30 | endif() 31 | endif() 32 | 33 | if(DEFINED CMAKE_C_COMPILER_ID) 34 | if(CMAKE_C_COMPILER_ID MATCHES GNU) 35 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -fpic") 36 | endif() 37 | if(CMAKE_C_COMPILER_ID MATCHES Intel) 38 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-intel -wd10237") 39 | endif() 40 | if(CMAKE_C_COMPILER_ID MATCHES Clang) 41 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic") 42 | endif() 43 | endif() 44 | 45 | if(DEFINED CMAKE_CXX_COMPILER_ID) 46 | if(CMAKE_CXX_COMPILER_ID MATCHES GNU) 47 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc") 48 | endif() 49 | if(CMAKE_CXX_COMPILER_ID MATCHES Intel) 50 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--as-needed -static-libstdc++ -static-libgcc -static-intel -wd10237") 51 | endif() 52 | if(CMAKE_CXX_COMPILER_ID MATCHES Clang) 53 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") 54 | endif() 55 | endif() 56 | endif() 57 | -------------------------------------------------------------------------------- /cmake/gau2gridConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # gau2gridConfig.cmake 2 | # -------------------- 3 | # 4 | # GAU2GRID cmake module. 5 | # This module sets the following variables in your project:: 6 | # 7 | # gau2grid_FOUND - true if gau2grid and all required components found on the system 8 | # gau2grid_VERSION - gau2grid version in format Major.Minor.Release 9 | # gau2grid_INCLUDE_DIRS - Directory where gau2grid header is located. 10 | # gau2grid_INCLUDE_DIR - same as DIRS 11 | # gau2grid_LIBRARIES - gau2grid library to link against. 12 | # gau2grid_LIBRARY - same as LIBRARIES 13 | # 14 | # 15 | # Available components: 16 | # 17 | # shared - search for only shared library 18 | # static - search for only static library 19 | # 20 | # 21 | # Exported targets:: 22 | # 23 | # If gau2grid is found, this module defines the following :prop_tgt:`IMPORTED` 24 | # target. Target is shared _or_ static, so, for both, use separate, not 25 | # overlapping, installations. :: 26 | # 27 | # gau2grid::gg - the main gau2grid library with header attached. 28 | # 29 | # 30 | # Suggested usage:: 31 | # 32 | # find_package(gau2grid) 33 | # find_package(gau2grid 1.0.1 EXACT CONFIG REQUIRED) 34 | # 35 | # 36 | # The following variables can be set to guide the search for this package:: 37 | # 38 | # gau2grid_DIR - CMake variable, set to directory containing this Config file 39 | # CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package 40 | ## PATH - environment variable, set to bin directory of this package 41 | # CMAKE_DISABLE_FIND_PACKAGE_gau2grid - CMake variable, disables 42 | # find_package(gau2grid) when not REQUIRED, perhaps to force internal build 43 | 44 | @PACKAGE_INIT@ 45 | 46 | set(PN gau2grid) 47 | 48 | if(@BUILD_SHARED_LIBS@) 49 | set(${PN}_shared_FOUND 1) 50 | else() 51 | set(${PN}_static_FOUND 1) 52 | endif() 53 | 54 | check_required_components(${PN}) 55 | 56 | #----------------------------------------------------------------------------- 57 | # Don't include targets if this file is being picked up by another 58 | # project which has already built this as a subproject 59 | #----------------------------------------------------------------------------- 60 | if(NOT TARGET ${PN}::gg) 61 | include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake") 62 | 63 | get_property(_loc TARGET ${PN}::gg PROPERTY LOCATION) 64 | set(${PN}_LIBRARY ${_loc}) 65 | get_property(_ill TARGET ${PN}::gg PROPERTY INTERFACE_LINK_LIBRARIES) 66 | set(${PN}_LIBRARIES ${_ill}) 67 | 68 | get_property(_id TARGET ${PN}::gg PROPERTY INCLUDE_DIRECTORIES) 69 | set(${PN}_INCLUDE_DIR ${_id}) 70 | get_property(_iid TARGET ${PN}::gg PROPERTY INTERFACE_INCLUDE_DIRECTORIES) 71 | set(${PN}_INCLUDE_DIRS ${_iid}) 72 | endif() 73 | 74 | -------------------------------------------------------------------------------- /cmake/psi4OptionsTools.cmake: -------------------------------------------------------------------------------- 1 | ###This file contains functions used throughout the Psi4 build. Like source 2 | ###code, the build system should be factored and common code extracted out into 3 | ###functions/macros. If you find repetitive code throughout the build scripts 4 | ###this is the place to add it (make sure you document it too). 5 | 6 | #Macro for printing an option in a consistent manner 7 | # 8 | #Syntax: print_option(