pax_global_header00006660000000000000000000000064142147346550014525gustar00rootroot0000000000000052 comment=4d125ff98675e1be2714574c47f553f432949c01 kim-api-2.3.0-git/000077500000000000000000000000001421473465500136375ustar00rootroot00000000000000kim-api-2.3.0-git/.clang-format000066400000000000000000000106451421473465500162200ustar00rootroot00000000000000--- # # KIM-API: An API for interatomic models # Copyright (c) 2013--2021, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # Language: Cpp # BasedOnStyle: LLVM AccessModifierOffset: -1 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: true #AlwaysBreakAfterDefinitionReturnType: None # deprecated AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: Yes BinPackArguments: false BinPackParameters: false BraceWrapping: AfterClass: true AfterControlStatement: true AfterEnum: false AfterFunction: true AfterNamespace: true AfterObjCDeclaration: false AfterStruct: true AfterUnion: true AfterExternBlock: false BeforeCatch: true BeforeElse: true IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true #BreakAfterJavaFieldAnnotations: false BreakBeforeBinaryOperators: All BreakBeforeBraces: Custom BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true BreakConstructorInitializers: AfterColon BreakConstructorInitializersBeforeComma: false BreakInheritanceList: AfterColon BreakStringLiterals: true ColumnLimit: 80 #CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: false DisableFormat: false #ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true #ForEachMacros: # - foreach # - Q_FOREACH # - BOOST_FOREACH IncludeBlocks: Preserve #IncludeCategories: # - Regex: '^"(llvm|llvm-c|clang|clang-c)/' # Priority: 2 # - Regex: '^(<|"(gtest|gmock|isl|json)/)' # Priority: 3 # - Regex: '.*' # Priority: 1 #IncludeIsMainRegex: '(Test)?$' IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 2 IndentWrappedFunctionNames: false #JavaScriptQuotes: Leave #JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false #MacroBlockBegin: '' #MacroBlockEnd: '' MaxEmptyLinesToKeep: 2 NamespaceIndentation: None #ObjCBinPackProtocolList: Auto #ObjCBlockIndentWidth: 2 #ObjCSpaceAfterProperty: false #ObjCSpaceBeforeProtocolList: true PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Middle ReflowComments: true SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: true SpaceAfterTemplateKeyword: false SpaceBeforeAssignmentOperators: true SpaceBeforeCpp11BracedList: true SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 SpacesInAngles: false SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: true SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp03 TabWidth: 2 UseTab: Never ... kim-api-2.3.0-git/.format-ignore000066400000000000000000000002211421473465500164040ustar00rootroot00000000000000# Must match line exactly # cpp/src/edn-cpp/edn.hpp cpp/src/edn-cpp/example.cpp cpp/src/edn-cpp/repl.cpp cpp/src/ghc-filesystem/filesystem.hpp kim-api-2.3.0-git/.fprettify.rc000066400000000000000000000021771421473465500162660ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2021, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # indent = 2 line-length = 80 whitespace = 3 strict-indent = true enable-replacements = true c-relations = true strip-comments = false kim-api-2.3.0-git/.github/000077500000000000000000000000001421473465500151775ustar00rootroot00000000000000kim-api-2.3.0-git/.github/workflows/000077500000000000000000000000001421473465500172345ustar00rootroot00000000000000kim-api-2.3.0-git/.github/workflows/build-multiplatform.yml000066400000000000000000000261311421473465500237560ustar00rootroot00000000000000# # CDDL HEADER START # # The contents of this file are subject to the terms of the Common Development # and Distribution License Version 1.0 (the "License"). # # You can obtain a copy of the license at # http://www.opensource.org/licenses/CDDL-1.0. See the License for the # specific language governing permissions and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each file and # include the License file in a prominent location with the name LICENSE.CDDL. # If applicable, add the following below this CDDL HEADER, with the fields # enclosed by brackets "[]" replaced with your own identifying information: # # Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved. # # CDDL HEADER END # # # Copyright (c) 2013--2021, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # Daniel S. Karls # # Release: This file is part of the kim-api.git repository. # name: Build # Run when pushing to all branches other than 'coverity_scan' on: push: branches-ignore: - 'coverity_scan' pull_request: jobs: macos-debug: strategy: fail-fast: false matrix: os: [macos-10.15, macos-11] include: - os: macos-10.15 DISTRO: macos_catalina job_name: macOS Catalina 10.15 (debug) - os: macos-11 DISTRO: macos_bigsur job_name: macOS Big Sur 11 (debug) name: ${{ matrix.job_name }} runs-on: ${{ matrix.os }} env: DISTRO: ${{ matrix.DISTRO }} CMAKE_BUILD_TYPE: Debug CCACHE_DIR: /Users/runner/.ccache/ steps: - name: Check out repository uses: actions/checkout@v2 - name: Initialize ccache uses: actions/cache@v2 with: path: ${{ env.CCACHE_DIR }} key: ${{ env.DISTRO }}-ccache-${{ github.sha }} restore-keys: | ${{ env.DISTRO }}-ccache - name: Ensure ccache dir exists run: | if [ ! -d ${{ env.CCACHE_DIR }} ]; then \ echo "Could not find CCACHE_DIR ${{ env.CCACHE_DIR }}" \ && echo "Creating ${{ env.CCACHE_DIR }}" \ && mkdir -p ${{ env.CCACHE_DIR }}; \ else \ echo "Found CCACHE_DIR ${{ env.CCACHE_DIR }}" \ && ls -lha ${{ env.CCACHE_DIR }}; \ fi - name: Install ccache via homebrew run: brew install ccache - name: Build KIM API, run tests run: | export PATH="/usr/local/opt/ccache/libexec:$PATH" export CXX17=true export CXX=g++-9 export CC=gcc-9 export FC=gfortran-9 env ./scripts/ci-build-and-test linux-debug-sanitize: strategy: fail-fast: false matrix: os: [fedora, openSUSE, ubuntu, debian] include: - os: fedora job_name: Fedora (debug & sanitize) env: DISTRO: fedora CMAKE_BUILD_TYPE: Debug SANITIZE: true CXX17: true CCACHE_DIR: /home/runner/kim-ccache/ WORK_DIR: /home/runner/kim-work/ - os: openSUSE job_name: openSUSE (debug, IWYU, sanitize & LTO) env: DISTRO: openSUSE CMAKE_BUILD_TYPE: Debug IWYU: true SANITIZE: true CXX17: true CXXFLAGS: "-flto=auto" CFLAGS: "-flto=auto" FFLAGS: "-flto=auto" CCACHE_DIR: /home/runner/kim-ccache/ WORK_DIR: /home/runner/kim-work/ - os: ubuntu job_name: Ubuntu (debug, sanitize, & coverage) env: DISTRO: ubuntu CMAKE_BUILD_TYPE: Debug SANITIZE: true COVERAGE: true CXX17: true CCACHE_DIR: /home/runner/kim-ccache/ WORK_DIR: /home/runner/kim-work/ - os: debian job_name: Debian (debug & sanitize) env: DISTRO: debian CMAKE_BUILD_TYPE: Debug SANITIZE: true CXX17: true CCACHE_DIR: /home/runner/kim-ccache/ WORK_DIR: /home/runner/kim-work/ name: ${{ matrix.job_name }} runs-on: ubuntu-latest env: ${{ matrix.env }} steps: - name: Check out repository uses: actions/checkout@v2 - name: Initialize ccache uses: actions/cache@v2 with: path: ${{ env.CCACHE_DIR }} key: ${{ env.DISTRO }}-ccache-${{ github.sha }} restore-keys: | ${{ env.DISTRO }}-ccache - name: Ensure ccache dir exists run: | if [ ! -d ${{ env.CCACHE_DIR }} ]; then \ echo "Could not find CCACHE_DIR ${{ env.CCACHE_DIR }}" \ && echo "Creating ${{ env.CCACHE_DIR }}" \ && mkdir -p ${{ env.CCACHE_DIR }}; \ else \ echo "Found CCACHE_DIR ${{ env.CCACHE_DIR }}" \ && ls -lha ${{ env.CCACHE_DIR }}; \ fi - name: Ensure work dir exists run: | if [ ! -d ${{ env.WORK_DIR }} ]; then mkdir -p ${{ env.WORK_DIR }}; fi - name: Build docker, build KIM API, run tests run: | cd ${{ env.WORK_DIR }} env ${GITHUB_WORKSPACE}/scripts/ci-docker-build-and-run \ "${GITHUB_WORKSPACE}" \ "${{ env.DISTRO }}" \ "${GITHUB_REPOSITORY}:${{ env.DISTRO }}" \ "${{ env.CCACHE_DIR }}" # Ubuntu where we want to use cmake 3.10 specifically has to be separate # because we use a separate gha cache directory for the cmake tarball that is # downloaded. ubuntu-cmake310-debug: name: Ubuntu cmake@3.10 (debug) runs-on: ubuntu-latest env: DISTRO: ubuntu_cmake310 CMAKE_BUILD_TYPE: Debug CCACHE_DIR: /home/runner/kim-ccache/ CMAKE_DIR: /home/runner/kim-cmake310/ WORK_DIR: /home/runner/kim-work/ steps: - name: Check out repository uses: actions/checkout@v2 - name: Initialize cmake 3.10 binaries cache id: cmake-cache uses: actions/cache@v2 with: path: ${{ env.CMAKE_DIR }} key: ${{ env.DISTRO }}-cmake-${{ github.sha }} restore-keys: | ${{ env.DISTRO }}-cmake - name: Ensure cmake dir exists run: | if [ ! -d ${{ env.CMAKE_DIR }} ]; then \ echo "Could not find CMAKE_DIR ${{ env.CMAKE_DIR }}" \ && echo "Creating ${{ env.CMAKE_DIR }}" \ && mkdir -p ${{ env.CMAKE_DIR }}; \ else \ echo "Found CMAKE_DIR ${{ env.CMAKE_DIR }}" \ && ls -lha ${{ env.CMAKE_DIR }}; \ fi # NOTE: The archive downloaded *must* end in .tar.gz and be decompressable via # `tar -xzf` - name: Download cmake 3.10.3 binaries, if necessary if: steps.cmake-cache.outputs.cache-hit != 'true' run: | export CMAKE_VER=3.10.3 export CMAKE_PKG_NAME=cmake-${CMAKE_VER}-Linux-x86_64 export CMAKE_ARCHIVE_NAME=${CMAKE_PKG_NAME}.tar.gz cd ${CMAKE_DIR} wget http://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/${CMAKE_ARCHIVE_NAME} -O ${CMAKE_ARCHIVE_NAME} - name: Initialize ccache uses: actions/cache@v2 with: path: ${{ env.CCACHE_DIR }} key: ${{ env.DISTRO }}-ccache-${{ github.sha }} restore-keys: | ${{ env.DISTRO }}-ccache - name: Ensure ccache dir exists run: | if [ ! -d ${{ env.CCACHE_DIR }} ]; then \ echo "Could not find CCACHE_DIR ${{ env.CCACHE_DIR }}" \ && echo "Creating ${{ env.CCACHE_DIR }}" \ && mkdir -p ${{ env.CCACHE_DIR }}; \ else \ echo "Found CCACHE_DIR ${{ env.CCACHE_DIR }}" \ && ls -lha ${{ env.CCACHE_DIR }}; \ fi - name: Ensure work dir exists run: | if [ ! -d ${{ env.WORK_DIR }} ]; then mkdir -p ${{ env.WORK_DIR }}; fi - name: Build docker, build KIM API, run tests run: | cd ${{ env.WORK_DIR }} env ${GITHUB_WORKSPACE}/scripts/ci-docker-build-and-run \ "${GITHUB_WORKSPACE}" \ "${{ env.DISTRO }}" \ "${GITHUB_REPOSITORY}:${{ env.DISTRO }}" \ "${{ env.CCACHE_DIR }}" \ "${{ env.CMAKE_DIR }}" windows-mingw-debug: name: Windows-MinGW (debug) runs-on: windows-latest env: DISTRO: windows_mingw CMAKE_BUILD_TYPE: Debug WINDOWS_CCACHE_DIR: C:/ccache/ CCACHE_DIR: /home/runneradmin/ccache/ defaults: run: shell: msys2 {0} steps: - name: Check out repository uses: actions/checkout@v2 # Because the msys2/setup-msys2 action creates the path for msys2 where # everything in this job happens at the start of every time this job is # run (of the form ${RUNNER_TEMP}/msys/msys64 where RUNNER_TEMP is a # default GHA envvar containing an absolute windows path), we avoid # directly setting up a cache directory inside of it to hold ccache # artifacts. Instead, we make a cache directory directly in windows and # copy its contents into the ccache directory we use inside of msys2; at # the conclusion of the job, we copy the contents of the ccache directory # back to the windows directory. - name: Initialize windows ccache dir uses: actions/cache@v2 with: path: ${{ env.WINDOWS_CCACHE_DIR }} key: ${{ env.DISTRO }}-ccache-${{ github.sha }} restore-keys: | ${{ env.DISTRO }}-ccache - uses: msys2/setup-msys2@v2 with: msystem: MINGW64 path-type: minimal update: true install: >- mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-doxygen mingw-w64-x86_64-toolchain - name: Ensure windows ccache dir exists run: | if [ ! -d ${{ env.WINDOWS_CCACHE_DIR }} ]; then \ echo "Could not find windows ccache dir ${{ env.WINDOWS_CCACHE_DIR }}" \ && echo "Creating ${{ env.WINDOWS_CCACHE_DIR }}" \ && mkdir -p ${{ env.WINDOWS_CCACHE_DIR }}; \ else \ echo "Found windows ccache dir ${{ env.WINDOWS_CCACHE_DIR }}" \ && ls -lha ${{ env.WINDOWS_CCACHE_DIR }}; \ fi - name: Copy ccache contents (if any) from windows ccache dir -> msys2 working path run: | echo "Copying ${{ env.WINDOWS_CCACHE_DIR}} -> ${{ env.CCACHE_DIR }}" cp -r ${{ env.WINDOWS_CCACHE_DIR }} ${{ env.CCACHE_DIR }} - name: Build KIM API, run tests env: CMAKE_GENERATOR: MinGW Makefiles MAKE: mingw32-make CMAKE_MAKE_PROGRAM: mingw32-make run: | bash ./scripts/ci-build-and-test - name: Copy ccache content from msys2 working path -> windows ccache dir run: cp -r ${{ env.CCACHE_DIR }}/* ${{ env.WINDOWS_CCACHE_DIR }} kim-api-2.3.0-git/.github/workflows/codeql-analysis.yml000066400000000000000000000044741421473465500230600ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ master, devel ] pull_request: # The branches below must be a subset of the branches above branches: [ devel ] schedule: - cron: '20 12 * * 5' jobs: analyze: name: Analyze runs-on: ubuntu-latest strategy: fail-fast: false matrix: language: [ 'cpp' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - name: Checkout repository uses: actions/checkout@v2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 kim-api-2.3.0-git/.github/workflows/coverity-scan.yml000066400000000000000000000102231421473465500225430ustar00rootroot00000000000000# # CDDL HEADER START # # The contents of this file are subject to the terms of the Common Development # and Distribution License Version 1.0 (the "License"). # # You can obtain a copy of the license at # http://www.opensource.org/licenses/CDDL-1.0. See the License for the # specific language governing permissions and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each file and # include the License file in a prominent location with the name LICENSE.CDDL. # If applicable, add the following below this CDDL HEADER, with the fields # enclosed by brackets "[]" replaced with your own identifying information: # # Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved. # # CDDL HEADER END # # # Copyright (c) 2021, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Daniel S. Karls # # Release: This file is part of the kim-api.git repository. # name: Coverity scan # Run only when pushing to dedicated 'coverity_scan' branch on: push: branches: - 'coverity_scan' jobs: coverity-scan: name: Coverity scan runs-on: ubuntu-latest env: COVERITY_DIR: /home/runner/coverity-scan/ COVERITY_INTERMEDIATE_DIR: cov-int BUILD_DIR: build steps: - name: Check out repository uses: actions/checkout@v2 # TODO: Reuse some of the docker environments for this - name: Configure environment run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ make \ cmake \ gcc \ g++ \ gfortran \ xxd \ curl - name: Initialize coverity cache id: coverity-cache uses: actions/cache@v2 with: path: ${{ env.COVERITY_DIR }} key: coverity-${{ github.sha }} restore-keys: | coverity - name: Download coverity if: steps.coverity-cache.outputs.cache-hit != 'true' env: TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} COVERITY_TARBALL: coverity_tool.tgz COVERITY_CHECKSUM_FILE: coverity_tool.md5 run: | mkdir -p ${{ env.COVERITY_DIR }} wget https://scan.coverity.com/download/linux64 \ --post-data "token=${TOKEN}&project=${{ github.repository_owner }}%2Fkim-api" \ -O ${{ env.COVERITY_TARBALL }} wget https://scan.coverity.com/download/linux64 \ --post-data "token=${TOKEN}&project=${{ github.repository_owner }}%2Fkim-api&md5=1" \ -O ${{ env.COVERITY_CHECKSUM_FILE }} echo " ${{ env.COVERITY_TARBALL }}" >> ${{ env.COVERITY_CHECKSUM_FILE }} md5sum -c ${{ env.COVERITY_CHECKSUM_FILE }} tar xzf ${{ env.COVERITY_TARBALL }} --strip 1 -C ${{ env.COVERITY_DIR }} rm ${{ env.COVERITY_TARBALL }} - name: Run coverity run: | mkdir ${{ env.BUILD_DIR }} cd ${{ env.BUILD_DIR }} cmake .. export PATH=${{ env.COVERITY_DIR }}/bin/:${PATH} cov-build --dir ${{ env.COVERITY_INTERMEDIATE_DIR }} make - name: Upload scan results env: EMAIL: relliott@umn.edu TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} RESULTS_TARBALL: kim-api.tgz run: | tar czf ${{ env.RESULTS_TARBALL }} -C ${{ env.BUILD_DIR }} ${{ env.COVERITY_INTERMEDIATE_DIR }} curl --form token=${TOKEN} \ --form email=${EMAIL} \ --form file=@${{ env.RESULTS_TARBALL }} \ --form version="${GITHUB_SHA}" \ --form description="OpenKIM is an online framework for making molecular simulations reliable, reproducible, and portable. Computer implementations of interatomic models are archived in OpenKIM, verified for coding integrity, and tested by computing their predictions for a variety of material properties. Models conforming to the KIM application programming interface (API) work seamlessly with major simulation codes that have adopted the KIM API standard." \ https://scan.coverity.com/builds?project=${{ github.repository_owner }}%2Fkim-api kim-api-2.3.0-git/CMakeLists.txt000066400000000000000000000222411421473465500164000ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Christoph Junghans # Ryan S. Elliott # Daniel S. Karls # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) enable_testing() list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}) include(SetCacheWithFallback) include(DefaultCompilerStandards) # Define options # if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(_LOG_MAX "DEBUG") else() set(_LOG_MAX "INFORMATION") endif() set_cache_with_fallback(KIM_API_LOG_MAXIMUM_LEVEL "${_LOG_MAX}" STRING "Maximum log verbosity") unset(_LOG_MAX) set_property(CACHE KIM_API_LOG_MAXIMUM_LEVEL PROPERTY STRINGS "" SILENT FATAL ERROR WARNING INFORMATION DEBUG) # option(KIM_API_BUILD_EXAMPLES "Build example Drivers, Models, Simulator Models, and Simulators" ON) # set(KIM_API_PROJECT_NAME "kim-api" CACHE STRING "KIM API project name string") mark_as_advanced(KIM_API_PROJECT_NAME) # option(KIM_API_ENABLE_SANITIZE "Enable AddressSanitizer" OFF) mark_as_advanced(KIM_API_ENABLE_SANITIZE) # option(KIM_API_ENABLE_COVERAGE "Enable code coverage" OFF) mark_as_advanced(KIM_API_ENABLE_COVERAGE) # string(TIMESTAMP _KIM_API_CONFIGURATION_TIMESTAMP "%Y-%m-%d-%H-%M-%S" UTC) set(KIM_API_CONFIGURATION_TIMESTAMP "${_KIM_API_CONFIGURATION_TIMESTAMP}" CACHE STRING "UTC timestamp for configuration of kim-api") unset(_KIM_API_CONFIGURATION_TIMESTAMP) mark_as_advanced(KIM_API_CONFIGURATION_TIMESTAMP) # # Additional options (that depend on call to project()) defined below # # Define main project # project(${KIM_API_PROJECT_NAME} VERSION 2.3.0 LANGUAGES CXX C Fortran) # must remain a single line for create-pacakge script set(PROJECT_DESCRIPTION "An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).") # include(GNUInstallDirs) # needs to come after languages are enabled include(RelocatableGNUInstallDirs) # provides CMAKE_INSTALL_RELOC_*DIRS variables include(DefineVersionVariables) # Define options dependent on languages being enabled and/or PROJECT_NAME being defined # set(KIM_API_CMAKE_C_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "C compiler filepath to be used after installation for item compilation.") mark_as_advanced(KIM_API_CMAKE_C_COMPILER) set(KIM_API_CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "C++ compiler filepath to be used after installation for item compilation.") mark_as_advanced(KIM_API_CMAKE_CXX_COMPILER) set(KIM_API_CMAKE_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "Fortran compiler filepath to be used after installation for item compilation.") mark_as_advanced(KIM_API_CMAKE_Fortran_COMPILER) include(DefineInternalVariables) # # Define options dependent on internal variables # include(CompletionConfig) # set install dirs for completions; NOTE: depends on Module 'DefineInternalVariables' set_cache_with_fallback(KIM_API_USER_CONFIGURATION_FILE ".${PROJECT_NAME}/${KIM_API_UID}/config" FILEPATH "Default configuration file name. If not absolute, then relative to user home directory") mark_as_advanced(KIM_API_USER_CONFIGURATION_FILE) # "~/" is expanded by cmake when set(... CACHE PATH ...) is used below; so do not use PATH as type set_cache_with_fallback(KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT "~/.${PROJECT_NAME}/${KIM_API_UID}/${KIM_API_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER}" STRING "Default user collection model drivers dir") # do not use PATH type mark_as_advanced(KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT) set_cache_with_fallback(KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT "~/.${PROJECT_NAME}/${KIM_API_UID}/${KIM_API_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER}" STRING "Default user collection portable models dir") # do not use PATH type mark_as_advanced(KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT) set_cache_with_fallback(KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT "~/.${PROJECT_NAME}/${KIM_API_UID}/${KIM_API_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER}" STRING "Default user collection simulator models dir") # do not use PATH type mark_as_advanced(KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT) # # macro(_set_system_dir var identifier type_string) set(_default_dir_1 "${PROJECT_NAME}/${identifier}") # _1 single escape -- to be used directly set(_default_dir_2 "${PROJECT_NAME}/${identifier}") # _2 double escape -- to be passed into macro/function set(_description "System collection (${KIM_API_PATH_SEPARATOR}-separated) ${type_string} directory list (entries may begin with $ORIGIN (w/ or w/o {}'s), if appropriate)") if(WIN32 AND NOT CYGWIN) # Note: On Win32, ${ORIGIN} refers to the bin/ directory containing libkim-api.dll. file(RELATIVE_PATH _relative_libdir_path "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}") set(_default_dir_1 "\${ORIGIN}/${_relative_libdir_path}/${_default_dir_1}") # Here is the important difference between the _1 and _2 set(_default_dir_2 "\\\${ORIGIN}/${_relative_libdir_path}/${_default_dir_2}") # Here is the important difference between the _1 and _2 unset(_relative_libdir_path) else() set(_default_dir_1 "\${ORIGIN}/${_default_dir_1}") # Here is the important difference between the _1 and _2 set(_default_dir_2 "\\\${ORIGIN}/${_default_dir_2}") # Here is the important difference between the _1 and _2 endif() set_cache_with_fallback(${var} "${_default_dir_2}" STRING ${_description}) if("${${var}}" MATCHES "^${KIM_API_PATH_SEPARATOR}") set(${var} "${_default_dir_1}${${var}}") endif() unset(_default_dir_1) unset(_default_dir_2) unset(_description) mark_as_advanced(${var}) endmacro(_set_system_dir) # _set_system_dir(KIM_API_SYSTEM_MODEL_DRIVERS_DIR "${KIM_API_MODEL_DRIVER_PLURAL_IDENTIFIER}" "model drivers") # _set_system_dir(KIM_API_SYSTEM_PORTABLE_MODELS_DIR "${KIM_API_PORTABLE_MODEL_PLURAL_IDENTIFIER}" "portable models") # _set_system_dir(KIM_API_SYSTEM_SIMULATOR_MODELS_DIR "${KIM_API_SIMULATOR_MODEL_PLURAL_IDENTIFIER}" "simulator models") include(DefaultCompilerFlags) # Define kim-api target # add_library(kim-api SHARED "") set_target_properties(kim-api PROPERTIES OUTPUT_NAME "${PROJECT_NAME}" VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/fortran/${KIM_API_Fortran_MODULE_DIR_IDENTIFIER}" ) target_include_directories(kim-api PUBLIC $> $) if(NOT WIN32 OR CYGWIN) target_link_libraries(kim-api ${CMAKE_DL_LIBS}) endif() # Add install rules for kim-api # install(TARGETS kim-api EXPORT KIM_API_Targets # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior INCLUDES DESTINATION "${CMAKE_INSTALL_RELOC_INCLUDEDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_RELOC_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_RELOC_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_RELOC_BINDIR}") # Add install rules for various metadata files # install( FILES "${PROJECT_SOURCE_DIR}/README.md" "${PROJECT_SOURCE_DIR}/NEWS" "${PROJECT_SOURCE_DIR}/LICENSE.LGPL" DESTINATION "${CMAKE_INSTALL_RELOC_DOCDIR}" ) # Add include subdirectories # add_subdirectory(cpp/include) add_subdirectory(c/include) add_subdirectory(fortran/include) # Add src subdirectories # add_subdirectory(cpp/src) add_subdirectory(c/src) add_subdirectory(fortran/src) # Add cmake subdirectory # add_subdirectory(cmake) # string(MAKE_C_IDENTIFIER "${PROJECT_NAME}" KIM_API_C_ID_PROJECT_NAME) # used in ./completions and ./utils # # Add utils subdirectory # add_subdirectory(utils) # Add other subdirectories # add_subdirectory(docs) add_subdirectory(completions) add_subdirectory(editors/emacs) add_subdirectory(pkg-config) # Add Models & Drivers # if(KIM_API_BUILD_EXAMPLES) set(KIM_API_CMAKE_PREFIX_DIR "") # avoid uninitialized variable warning set(KIM-API_DIR "${PROJECT_BINARY_DIR}/cmake/${KIM_API_BUILD_TREE_CONFIG_DIR_IDENTIFIER}") set(KIM-API-ITEMS_DIR "${PROJECT_BINARY_DIR}/cmake/${KIM_API_BUILD_TREE_CONFIG_DIR_IDENTIFIER}-items") add_subdirectory(examples/model-drivers) add_subdirectory(examples/portable-models) add_subdirectory(examples/simulator-models) add_subdirectory(examples/simulators) unset(KIM_API_CMAKE_PREFIX_DIR) unset(KIM-API_DIR) unset(KIM-API-ITEMS_DIR) endif() include(WriteKIMConfigSummary) kim-api-2.3.0-git/INSTALL000066400000000000000000000663151421473465500147030ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Ellad B. Tadmor # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # ============================= The KIM API package ============================= This file contains instructions for installing the KIM API package. TABLE OF CONTENTS A. System requirements B. Quick start C. Package concepts and operation overview C.1 KIM API library C.2 Collections for Model Drivers (MDs), Portable Models (PMs), and Simulator Models (SMs) C.2.1 The system-collection C.2.2 The user-collection C.2.3 The environment-variable-collection C.2.4 The CWD-collection C.3 Helper utilities D. KIM API Installation D.1 Typical build scenario D.2 CMake build options D.2.1 Compiler selection D.2.2 CMAKE_BUILD_TYPE D.2.3 Installation prefix D.2.4 KIM API specific build options D.3 Installing multiple versions D.4 Uninstall the KIM API E. Adding MDs, PMs, and SMs to the collections E.1 Adding MDs, PMs, and SMs to the system-collection E.2 Adding MDs, PMs, and SMs to the user-collection E.3 Adding MDs, PMs, and SMs to the environment-variable-collection E.4 Adding MDs, PMs, and SMs to the CWD-collection E.5 Adding MDs, PMs, and SMs from a local source directory E.6 Manually adding MDs, PMs, and SMs ------------------------------------------------------------------------------- A. SYSTEM REQUIREMENTS To install and run the KIM API package you need the following: 1. A Unix/Linux/macOS system. 2. CMake (3.10 or later). 3. GNU compilers (gcc, g++, gfortran) version 4.8.x or higher or the corresponding Intel compilers, version 11.1 or higher. Other compilers may also work. 4. (optional) The 'xxd' utility (distributed as part of the vim package). If available, provides faster builds than without. 5. wget or curl, sed, grep, tar, uname, etc. (used by the kim-api-collections-management utility). 6. Doxygen and Graphviz (for generating the documentation). 7. The bash-completion package (for facilitating command-line usage of the helper utilities). 8. pkg-config can be used by code needing to link against the kim-api library. ------------------------------------------------------------------------------- B. QUICK START: For those who don't like to read and are a bit audacious. Try the following: $ mkdir build && cd build $ cmake .. -DCMAKE_BUILD_TYPE=Release $ make $ sudo make install $ sudo ldconfig For more information, see section D. ------------------------------------------------------------------------------- C. PACKAGE LAYOUT AND OPERATION OVERVIEW The KIM API package is a system-level library that aims to give computer programmers the ability to write atomistic or molecular simulation programs (Simulators) that can seamlessly interface with implementations of interatomic potentials (Portable Models, PMs), regardless of the programming language in which the codes are written. The KIM API package provides a dedicated Portable Model Interface (PMI) for use by simulators and PMs and referred to as the KIM API/PMI. A PM can include code and parameters all in one. Or, a PM can include just parameters and use a separate Model Driver (MD) library containing the code. There are also Simulator Models (SMs) that only work with a specific simulator. The KIM API package provides a dedicated Simulator Model Interface (SMI) for use by simulators and SMs and referred to as the KIM API/SMI. In addition to the main KIM API library, a small number of associated helper utilities are provided. C.1. KIM API Library The KIM API library provides the necessary routines for a Simulator to interact with a PM or SM. It also contains an interface for discovering what MDs, PMs, and SMs are available in the KIM API Collections. MDs, PMs, and SMs are built and linked against the KIM API library, then installed in one of the collections (see below) so that they are available for use with a simulator. Simulators are built and linked against the KIM API library so that they can access and use any of the available PMs and/or SM in the various collections. C.2 COLLECTIONS FOR MODEL DRIVERS (MDs), PORTABLE MODELS (PMs), AND SIMULATOR MODELS (SMs) The KIM API supports four Collections of Items. These are the "system-collection", the "user-collection", the "environment-variable-collection", and the "CWD-collection" as described below. Each collection consists of separate sets of three Item Types: MDs, PMs, and SMs. When the KIM API needs to use a particular MD, PD, or SM, it looks for the item by type and name, first in the CWD-collection, then in the environment-variable-collection, then in the user-collection, and finally in the system-collection. It uses the first match that it finds. Note, it is possible for a PM and its associated MD to be located in different collections. The search for each is a separate and independent procedure. See also the documentation for the Collections Interface (c++: KIM::Collections; c: KIM_Collections; and Fortran: kim_collections_module). C.2.1 THE SYSTEM-COLLECTION The system-collection is a collection of MDs, PMs, and SMs that are available to all simulators that use the KIM API library. By default, this collection is located in the same subdirectory as the KIM API library. (See also the "KIM_API_SYSTEM_*_DIR" build options in section D.2.4, below.) MDs, PMs, and SMs may be built and installed to the system-collection at anytime after the KIM API has been built and installed. C.2.2 THE USER-COLLECTION The user-collection is a collection of MDs, PMs, and SMs that are available only to the user who owns the process for the simulator that uses the KIM API library. This collection is located in subdirectories that are specified by a configuration file. The user-collection may be populated with MDs, PMs, and SMs after the KIM API has been built and installed. The configuration file is named "${HOME}/.kim-api//config" by default, where is a unique identifier for the particular installation of the kim-api being used (this allows multiple, independent, installations on a single machine). Here "${HOME}" is the user's home directory. (See item D below for build options controlling this default file name.) If the "KIM_API_CONFIGURATION_FILE" environment variable is set, its value (interpreted as an absolute file name) will supersede the default location and name of the configuration file. For example, the following commands will instruct the KIM API library to use a file named "kim-config" in the /my-kim-stuff folder $ export KIM_API_CONFIGURATION_FILE=/my-kim-stuff/kim-config If the configuration file does not exist, the KIM API library will create it with a default configuration specifying that the user-collection files are stored in "${HOME}/.kim-api//model-drivers/", "${HOME}/.kim-api//portable-models/", and "${HOME}/.kim-api//simulator-models/". More generally, the values in the configuration file may contain colon ':' (on Windows: semi-colon ';') separated lists of fully-qualified directory names (starting, strictly, with '/', '~/' or a root drive letter like 'C:/'). (See item D below for build options controlling these defaults.) C.2.3 THE ENVIRONMENT-VARIABLE-COLLECTION The environment-variable-collection is a collection of MDs, PMs, and SMs that are specified by the run-time environment of the process for the simulator that uses the KIM API library. The locations of this collection are specified by the environment variables "KIM_API_MODEL_DRIVERS_DIR", "KIM_API_PORTABLE_MODELS_DIR", and "KIM_API_SIMULATOR_MODELS_DIR". These variables should contain colon ':' (on Windows: semi-colon ';') separated lists of absolute directory names where the collection MDs, PMs, and SMs, respectively, are located. (For example, in bash you could execute the command $ export KIM_API_PORTABLE_MODELS_DIR=/my-kim-stuff/models-i-am-developing:/my-kim-stuff/misc-portable-models to have the KIM API look for PMs in /my-kim-stuff/models-i-am-developing first and then look in /my-kim-stuff/misc-portable-models. (Similarly for MDs and SMs.) The environment-variable-collection may be populated with MDs, PMs, and SMs after the KIM API has been built and installed. C.2.4 THE CWD-COLLECTION The CWD-collection is a collection of MDs, PMs, SMs that are available to a simulator at run-time. The collection is located in the simulator process's current working directory (CWD). The CWD-collection may be populated with MDs, PMs, and SMs after the KIM API has been built and installed. C.3 HELPER UTILITIES The KIM API package also includes a utility for managing the MDs, PMs, and SMs contained in the various collections and for managing the configuration file. This utility is called "kim-api-collections-management". The KIM API package installs bash completion scripts that are designed to work with the "bash-completion" package (https://github.com/scop/bash-completion). When "bash-completion" is installed and activated on the system, tab-completions for the collections management utility should be automatically loaded and available for use. In addition, when the KIM API package is installed to a "Local (non-global)" (see D below) directory, the package also installs the "kim-api-activate" and "kim-api-deactivate" scripts. The activate script adds the utilities to the executable PATH, adds the KIM API library to the PKG_CONFIG_PATH so that the pkg-config utility can find it, and loads bash tab-completion support for the collections management utility. The deactivate script removes what the activate script added. ------------------------------------------------------------------------------- D. KIM API INSTALLATION D.1 Typical Build Scenario Here, the typical KIM API build and install process is detailed and the system-collection is populated with the example MDs, PMs, and SMs, as well as a single PM and its associated MD, both from openkim.org. Additionally, one of the example simulators is copied to the user's home directory and used to test the KIM API. The KIM API package uses the CMake build system. See the CMake documentation (https://cmake.org/cmake/help/v3.10/) for help with CMake settings. For some common CMake settings and KIM API specific settings, see D.2 below. The commands given below are for the bash shell. By default packages are installed to the Global prefix directory "/usr/local". Here we assume that "/usr/local/bin" is included as part of the system's standard PATH setting. First, we will create a working space and obtain the source package $ export WORKSPACE="${HOME}/kim-api-workspace" $ mkdir "${WORKSPACE}" $ cd "${WORKSPACE} $ wget https://s3.openkim.org/kim-api/kim-api-X.Y.Z.txz # replace X, Y, and Z with the current version numbers $ tar Jxvf kim-api-X.Y.Z.txz $ cd kim-api-X.Y.Z We will set an environment variable to point the the KIM API source. $ export KIM_API_SOURCE="${WORKSPACE}/kim-api-X.Y.Z" # replace X, Y, and Z with the current version numbers Next the configuration and build process begins. (Note: lines beginning with "$", without leading whitespace, in this file are extracted and used in the KIM API automated Continuous-Integration (CI) testing framework.) $ cd "${WORKSPACE}" $ mkdir build $ cd build $ cmake ${KIM_API_SOURCE} -DCMAKE_BUILD_TYPE=Release $ make -j2 If you want, build the documentation. $ make docs If you want, before installing the package, you can run the tests. $ make test Now, install the package (and docs, if built). $ sudo make install $ sudo ldconfig # All linux systems should do this; on Redhat-like systems you may need to first add /usr/local/lib to /etc/ld.so.conf $ cp -r "${KIM_API_SOURCE}/examples/simulators/utility_forces_numer_deriv" "${WORKSPACE}/" $ cd "${WORKSPACE}" If you want, you can now delete the source and build tree. However, you may also want to preserve the "install_manifest.txt" file which would be needed for uninstalling the KIM API package (see D.4 below). $ cp "${WORKSPACE}/build/install_manifest.txt" "${WORKSPACE}/install_manifest.txt" $ rm -r "${WORKSPACE}/build Now, we can build the simulator using the KIM API library that we have just installed. $ cd utility_forces_numer_deriv $ mkdir build $ cd build $ cmake .. $ make Try it with one of the example models: $ printf "ex_model_Ar_P_LJ" | ./utility_forces_numer_deriv Next, we can try it with a model installed from https://openkim.org: $ kim-api-collections-management install system --sudo EDIP_JustoBazantKaxiras_1998_Si__MO_958932894036_002 $ printf "EDIP_JustoBazantKaxiras_1998_Si__MO_958932894036_002" | ./utility_forces_numer_deriv Congratulations, you have now successfully installed the KIM API. If you would like to learn more about the KIM API, read the documentation in the docs directory (/usr/local/share/doc/kim-api). If you would like to install the latest release of all models from https://openkim.org, you can do: $ kim-api-collections-management install system --sudo OpenKIM D.2 CMAKE BUILD OPTIONS The KIM API defines a number of specific build options which are detailed in this section. But first, some notes about a few important standard CMake options. D.2.1 COMPILER SELECTION By default CMake will search for appropriate compilers available on your system. Generally, it selects reasonable choices. However, if you wish to force CMake to use specific compilers, you can do so with environment variables set on the command line. For example, suppose you have the latest GNU Compiler Collection (GCC) version X installed with the compilers named 'gcc-X', 'g++-X', and 'gfortran-X', for the C, C++, and Fortran compilers, respectively. Then, to force CMake to use these compilers, replace the command (from above) $ cmake .. -DCMAKE_BUILD_TYPE=Release with $ CC=gcc-X CXX=g++-X FC=gfortran-X cmake .. -DCMAKE_BUILD_TYPE=Release D.2.2 CMAKE_BUILD_TYPE CMake defines the option CMAKE_BUILD_TYPE which can be set to "Debug", "Release", "RelWithDebInfo", "MinSizeRel", or it can be empty. (See the CMake documentation for more details.) By default CMAKE_BUILD_TYPE is empty. In short, while developing code or debugging, the value of "Debug" or "RelWithDebInfo" should be used. When building for production runs one of the other values should be used. D.2.3 INSTALLATION PREFIX Here and below, all paths or filepaths must be specified in a format appropriate for the OS (windows or linux). Windows paths are of the form C:\dir1\dir2 (forward slashes may be used instead to avoid escaping issues: C:/dir1/dir2) and linux paths are of the form /dir1/dir2. By default CMake installs the KIM API package under the Global prefix "/usr/local". This is referred to as a "Global" (or system-wide) installation. It is available to all users of the system. (Other "Global" prefix values are "/" and "/usr".) However, such installations require root user permissions (as implied by the use of the "sudo" command above). If you do not have root user permission and/or do not want to install the KIM API to the global location, you can change where CMake installs the KIM API by replacing the command (from above) $ cmake .. -DCMAKE_BUILD_TYPE=Release with $ cmake .. -DCMAKE_INSTALL_PREFIX="/install/prefix/path" -DCMAKE_BUILD_TYPE=Release where "/install/prefix/path" should be replaced with your desired prefix. For example, to install the KIM API in the "local" subdirectory of your home directory, use "${HOME}/local". When installed in such a directory, the user may employ the "kim-api-activate" utility to setup the PATH and bash completions. For example: $ source ${HOME}/local/bin/kim-api-activate D.2.4 KIM API SPECIFIC BUILD OPTIONS The KIM API defines two additional regular build options and additional advanced options. * KIM_API_LOG_MAXIMUM_LEVEL (="DEBUG" if CMAKE_BUILD_TYPE is "Debug", otherwise ="INFORMATION") This option takes one of the following six values "SILENT", "FATAL", "ERROR", "WARNING", "INFORMATION", "DEBUG". This value controls, at compile-time, which type of log messages can be printed to the "kim.log" file. * KIM_API_BUILD_EXAMPLES (=ON) When ON CMake will build the example MDs, PMs, SMs and Simulators. NOTE: this option may be removed/changed in future releases when the examples are incorporated into the documentation. Additionally, the KIM API defines the following advanced build options. * KIM_API_PROJECT_NAME (="kim-api") This value controls the naming of many aspects of the package build. Generally this should not be changed. It can be used to build and install, on the same machine, two different copies (typically different versions) of the package. * KIM_API_ENABLE_SANITIZE (=OFF) When ON this enables the AddressSanitizer library for detecting memory corruption bugs. * KIM_API_ENABLE_COVERAGE (=OFF) When ON this enables gcov code coverage. * KIM_API_CONFIGURATION_TIMESTAMP (=) This is used as part of the universal ID for the kim-api installation. * KIM_API_CMAKE_C_COMPILER (="${CMAKE_C_COMPILER}") This value is recorded and used after installation for compilation of items (MDs, PMs, SMs, etc.) to ensure binary compatibility with the installed KIM API. * KIM_API_CMAKE_CXX_COMPILER (="${CMAKE_CXX_COMPILER}") This value is recorded and used after installation for compilation of items (MDs, PMs, SMs, etc.) to ensure binary compatibility with the installed KIM API. * KIM_API_CMAKE_Fortran_COMPILER (="${CMAKE_Fortran_COMPILER}") This value is recorded and used after installation for compilation of items (MDs, PMs, SMs, etc.) to ensure binary compatibility with the installed KIM API. * KIM_API_USER_CONFIGURATION_FILE (=".${PROJECT_NAME}/config") This value determines the default name of the KIM API user configuration file. If the value corresponds to a relative path (does not start with "/"), then it is interpreted as relative to the user's home directory "${HOME}". * KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT (="~/.${PROJECT_NAME}//model-drivers") This value specifies the default colon ':' (semicolon ';' on windows) separated list of the MD directory locations for the user collection. * KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT (="~/.${PROJECT_NAME}//portable-drivers") This value specifies the default colon ':' (semicolon ';' on windows) separated list of the PM directory locations for the user collection. * KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT (="~/.${PROJECT_NAME}//simulator-models") This value specifies the default colon ':' (semicolon ';' on windows) separated list of the SM directory locations for the user collection. * KIM_API_SYSTEM_MODEL_DRIVERS_DIR (="${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/model-drivers") This value specifies a colon ':' (semicolon ';' on windows) separated list of the MD directory locations in the system collection. If the value starts with a colon (semicolon on windows), cmake will update it by prepending the default value. * KIM_API_SYSTEM_PORTABLE_MODELS_DIR (="${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/portable-models") This value specifies a colon ':' (semicolon ';' on windows) separated list of the PM directory locations in the system collection. If the value starts with a colon (semicolon on windows), cmake will update it by prepending the default value. * KIM_API_SYSTEM_SIMULATOR_MODELS_DIR (="${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/simulator-models") This value specifies a colon ':' (semicolon ';' on windows) separated list of the SM directory locations in the system collection. If the value starts with a colon (semicolon on windows), cmake will update it by prepending the default value. D.3 Installing multiple versions On linux and macOS systems if you intend to install multiple versions of the KIM API using the same installation prefix ("-DCMAKE_INSTALL_PREFIX=/install/prefix/path" argument to cmake) you must take care that the installations do not overwrite each other. If you intend to install multiple versions using the same prefix you must use the "-DKIM_API_PROJECT_NAME=project-name" argument (See D.2.4 above) to cmake and use a unique value (any string without whitespace or control characters is valid) for each installation. Full support for the "-DKIM_API_PROJECT_NAME" argument, as described here, was first available in v2.0.2. For example, suppose the current version of the KIM API were v3.2.1, and you want to also install KIM API v3.0.0, and v2.1.1. Then, you would configure each version as follows: * v3.2.1 $ cmake .. [additional args] # use default ("kim-api") for current version. * v3.0.0 $ cmake .. -DKIM_API_PROJECT_NAME=kim-api3.0 [additional args] * v2.1.1 $ cmake .. -DKIM_API_PROJECT_NAME=kim-api2.1 [additional args] D.4 Uninstall the KIM API When the KIM API package is installed, CMake creates a file in the build tree named "install_manifest.txt". For the above commands this file would be located at "${HOME}/kim-api-X.Y.Z/build/install_manifest.txt". The manifest file contains the absolute file name of every file installed as part of the KIM API package. The contents of the install_manifest.txt file can be used to remove these files and, thus, uninstall the KIM API package. Thus, the install_manifest.txt file should be saved for later use, if necessary. For example, the following commands could be used to uninstall the KIM API package (assuming the "install_manifest.txt" file is located in your home directory). $ cd "${HOME}" $ while read line || test -n "${line}"; do sudo rm -f "${line}"; done < install_manifest.txt A more sophisticated set of commands could also remove any empty subdirectories left behind by this process. It may also be desirable to remove the user configuration file and user collection directories. $ rm -rf "${HOME}/.kim-api" ------------------------------------------------------------------------------- E. ADDING MDs, PMs, and SMs TO THE COLLECTIONS Here we describe how to add MDs, PMs, and SMs to the system-collection, user-collection, environment-variable-collection, and the CWD-collection. E.1 ADDING MDs, PMs, and SMs TO THE SYSTEM-COLLECTION Once you have the KIM API installed, it is easy to add additional MDs, PMs, and SMs to the system-collection. $ cd "${WORKSPACE}" $ kim-api-collections-management install system --sudo Morse_Shifted_Jelinek_1972_Ar__MO_831902330215_003 $ kim-api-collections-management install system --sudo Sim_LAMMPS_ADP_PunDarlingKecskes_2015_CuTa__SM_399364650444_000 The kim-api-collections-management utility automatically installs the necessary MD too. You can see the items in the various collections by executing the following command. $ kim-api-collections-management list Now we can test the newly installed PM. $ cd "${WORKSPACE}/utility_forces_numer_deriv/build" # we'll assume this is already built $ printf "Morse_Shifted_Jelinek_1972_Ar__MO_831902330215_003" | ./utility_forces_numer_deriv E.2 ADDING MDs, PMs, and SMs TO THE USER-COLLECTION Adding MDs, PSs, and SMs to the user-collection is similar. $ cd "${WORKSPACE}" $ kim-api-collections-management install user LJ_Shifted_Bernardes_1958HighCutoff_Ar__MO_242741380554_003 $ kim-api-collections-management install user Sim_LAMMPS_AGNI_BotuBatraChapman_2017_Al__SM_666183636896_000 $ kim-api-collections-management list $ cd "${WORKSPACE}/utility_forces_numer_deriv/build" # we'll assume this is already built $ printf "LJ_Shifted_Bernardes_1958HighCutoff_Ar__MO_242741380554_003" | ./utility_forces_numer_deriv E.3 ADDING MDs, PMs, and SMs TO THE ENVIRONMENT-VARIABLE-COLLECTION Adding MDs, PMs, and SMs to the environment-variable-collection is similar. $ cd "${WORKSPACE}" $ mkdir -p "${WORKSPACE}/my-env-collection/model-drivers" $ export KIM_API_MODEL_DRIVERS_DIR="${WORKSPACE}/my-env-collection/model-drivers" $ mkdir -p "${WORKSPACE}/my-env-collection/portable-models" $ export KIM_API_PORTABLE_MODELS_DIR="${WORKSPACE}/my-env-collection/portable-models" $ mkdir -p "${WORKSPACE}/my-env-collection/simulator-models" $ export KIM_API_SIMULATOR_MODELS_DIR="${WORKSPACE}/my-env-collection/simulator-models" $ kim-api-collections-management install environment Morse_Shifted_GirifalcoWeizer_1959HighCutoff_Cu__MO_151002396060_003 $ kim-api-collections-management install environment Sim_LAMMPS_BOP_WardZhouWong_2012_CdZnTe__SM_409035133405_000 $ kim-api-collections-management list $ cd "${WORKSPACE}/utility_forces_numer_deriv/build" # we'll assume this is already built $ printf "Morse_Shifted_GirifalcoWeizer_1959HighCutoff_Cu__MO_151002396060_003" | ./utility_forces_numer_deriv E.4 ADDING MDs, PMs, and SMs TO THE CWD-COLLECTION Adding MDs, PMs, and SMs to the CWD-collection is, again, similar. $ cd "${WORKSPACE}" $ kim-api-collections-management install CWD Exp6_KongChakrabarty_1973_ArNe__MO_946046425752_002 $ kim-api-collections-management install CWD Sim_LAMMPS_MEAM_EtesamiAsadi_2018_Ni__SM_333792531460_000 $ kim-api-collections-management list $ printf "Exp6_KongChakrabarty_1973_ArNe__MO_946046425752_002" | "${WORKSPACE}/utility_forces_numer_deriv/build/utility_forces_numer_deriv" # we'll assume this is already built E.5 Adding MDs, PMs, and SMs from a local source directory The kim-api-collections-management utility allows for the installation of items from a directory on the local file system. This is useful if you are developing an item or do not have network access to openkim.org, but already have the source code downloaded. We'll assume that the item's source code (including the CMakeLists.txt file, parameter files, etc) you want to install are in directory "${WORKSPACE}/item-source". Then you simply provide this directory name instead of the item name. $ kim-api-collections-management install user "${WORKSPACE}/item-source" E.6 Manually adding MDs, PMs, and SMs If necessary a MD, PM, or SM may be manually built and installed. We'll assume the item's source code is in the current directory $ mkdir build $ cd build $ cmake .. -DKIM_API_INSTALL_COLLECTION=SYSTEM $ make $ sudo make install The KIM_API_INSTALL_COLLECTION variable can also take values USER and ENVIRONMENT. ******************************************************************************* SUPPORT Support is always available by posting questions with all relevant information to Members of the OpenKIM development team actively monitor this forum and will do their best to respond to questions in a timely fashion. ******************************************************************************* kim-api-2.3.0-git/LICENSE.LGPL000066400000000000000000000636421421473465500154140ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/NEWS000066400000000000000000001220211421473465500143340ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Ellad B. Tadmor # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # === kim-api-2.3.0 =============== 17Mar2022 ==================================== * Re-license from CDDL to LGPL-2.1-or-later * Fixed bug in c bindings for KIM_Collections_GetDirectoryName() * Transition from Travis CI to github actions * Add partial_particle_energy computation to utility_forces_numer_deriv * Fixes/Improvements to CMake build system === kim-api-2.2.1 =============== 13Dec2020 ==================================== * replace usage of localtime() with more secure localtime_r() * Enable Github code scanning * Refactor CI to move codecov support to centos docker CI and speedup macOS CI * Fix build support for coverage * Improvements and fixes in collections management * Use CMake CACHE variables so kim items can override package settings * Added discussion of standalone portable model CMakeLists.txt files to docs * Eliminate a compiler warning * Updates to support new version of fprettyify * Refactor libkim-api.pc file for more standard support for relocatable behavior * Update travis-ci badge to use .com url * Implement more reliable method for bash scripts to find ORIGIN * Fix bugs in handling of -DKIM_API_SYSTEM_*_DIR=":/dir/..." build options; Add CI testing for usage of these cases. * Correct release date for 2.2.0 in this file (Dec -> Nov) === kim-api-2.2.0 =============== 18Nov2020 ==================================== * The kim-api now supports Windows. Significant additions have been made to the code and CMakeLists.txt files to support building kim-api and items on Windows via Cygwin and MinGW; Build on Windows requires C++17. (Thanks to Alex Stukowski) * kim-api is now "relocatable" after install. When installed to a non-standard PREFIX (with the CMAKE_INSTALL_PREFIX CMake option) the entire install tree may be moved, after install, to a new location in the file system and everything should still work. This uses the RPATH, ${ORIGIN}, and similar mechanisms and is functioning on Linux, macOS, and Windows. (This is tested in the CI.) * Added 'portable-model' utility which prints out an edn dictionary containing information about the features and properties of a portable model. This includes the list of supported compute arguments and callbacks, the parameters that the model makes available at runtime, etc. The utility can be found in the LIBEXEC install directory. * Added Push/PopDefaultPrintFunction to KIM::Log interface to support Simulator specific logging behavior such as the need for MPI communication to the head node for I/O operations * Portable Model parameter files are now guaranteed to all be found in a single subdirectory. This provides uniform handling of parameter files for both Portable Models and Simulator Models. New GetParameterFileDirectoryName() and GetParameterFileBasename() routines have been added and GetParameterFileName() has been deprecated in the KIM::ModelDriverCreate interface. A new GetParameterFileBaseName() routine has been added and GetParameterFileName() has been deprecated in the KIM::SimulatorModel interface. * Update documentation to point to new https://matsci.org discourse OpenKIM forum * Switch to minimum version 3.10 for CMake * Complete refactor of CMake build details to improve exported target support. This required an update to how kim-api items define their CMakeLists.txt files. This version remains backward compatible with item CMakeLists.txt files from older versions, but support for these is deprecated and will be removed in v3. * Added human readable CMake configuration summary log (also a detailed version) which is printed at the end of the cmake configuration step * Added new documentation page describing CMakeLists.txt files for the various kim-api item types * Added native CMake implementation of xxd processing which allows the package to be build on systems without the xxd executable * The collections-management utility will now use curl if wget is not available on the system * Added a user-agent string to wget/curl commands so downloads and queries may be identified as coming from the collections-management utility * Improve debugging of collections-management behavior with new CM_VERBOSITY environment variable and added better error messages * Full refactoring of travis-ci, docker, and testing implementation * Added support for openSUSE, ubuntu, centos, and debian to testing via docker * Added ubuntu_cmake310 to explicitly test build with CMake version 3.10 * Added MinGW travis-ci testing (Thanks to Alex Stukowski) * Added unique build identifier to default name for config and user collection files * Refactor and improve handling of deprecated identifiers in configuration file * Check for and ignore empty kim standard metadata files * Adopted the `fprettify` Fortran code formatter and reformat all Fortran code to conform to the kim-api settings (now in .fprettify.rc). Added scripts to support git-commit hook * Refactor #includes to satisfy include-what-you-use linter * Refactor initialization of pointers as best practice * Fix a bug in C language binding for SimulatorModel Interface * Fix a bug associated with the edn-cpp use of exceptions * Fix issues identified by Coverity Scan * Various fixes and improvements * Various documentation updates === kim-api-2.1.3 =============== 16Aug2019 ==================================== * Adjust kim_collections_module to work around gfortran <= 4.8 bug. * Fix minor bug in collections-management. * Improve backward compatibility support for ~/.kim-api/config file format. * Fix to Fortran/C mapping of KIM_LENGTH_UNIT_BOHR. * Fixes to Fortran documentation and cross-references. * Added information/links to the top level README.md === kim-api-2.1.2 =============== 29Jul2019 ==================================== * Fixup Fortran kim_collections_module interfaces to be consistent with c/c++. * Fixup collections-management for portabability to dash. * Improve item-wrapper.cpp.in for more standard compliant MD, MO, SM behavior. * Improve zsh completion install behavior. * Fixup Fortran c_long communication and overflow behavior. * Add missing testing of interface in examples/simulators/collections-example. * Improve example/simulators to remove warnings. * Fix bug in KIM::SimulatorModel::Create(). === kim-api-2.1.1 =============== 24Jul2019 ==================================== * Refactor 'kim-api-collections-management list' code for performance. * Update collections-management to use 'make -j2' for improved performance. * Improve kim-api-collections-management handling of passwords for use with sudo. Specifically, support reading of passwords with whitespace and other special characters. * Add zsh support to activate/deactivate scripts & zsh completions. * Fix c_long overflow (for i386 systems) bug in Fortran kim_collections_module. * Rework 'kim-api-collections-management install xxx OpenKIM' behavior. Now installs the latest official release archive found at https://s3.openkim.org/archives/collection/. This also greatly reduces the total build and install time. * Redefine/refactor KIM::Collections behavior for finding item names. Previously, a shared library file was found, opened, and checked for validity. To significantly improve performance, now simply the existence of the shared library file is used to identify available item names. * Redefine/refactor collections-management and collections-info to remove '--with-version' option. * Fixup and improve Fortran example codes. * Added reopology.org graphic of available binaries to README.md. === kim-api-2.1.0 =============== 16Jul2019 ==================================== * Added new KIM::SimulatorModel interface providing programatic support to simulators for packaging of parameter files, input commands, and metadata necessary to run a simulator's native potentials. * Added new KIM::Collections interface (and the supporting extensible enumerations KIM::Collection and KIM::CollectionItemTypes) providing programatic access to the KIM API Collections and its configuration settings. (This included a refactor and removal of old_KIM_API_DIRS.*.) * Convert from old 'models' to 'portable-models' nomenclature for KIM API collections, including environment variables, configuration file, etc. (For backward compatibility, the old configuration file format is still accepted.) * Added support for Metadata files to (internal) KIM::SharedLibrary and programatic access to these files from the new KIM::Collections interface. * Automatically add standard openkim.org metadata files (kimspec.edn, kimprovenance.edn, and kimcite-*.bib) to an item's shared library if they exist. * Significant documentation updates to describe the new interfaces as well as changing to the the Portable Model (PM) and Simulator Model (SM) terminology. * Added explicit documentation of Fortran interfaces for routines called by the KIM API (ModelCreate, ModelDestroy, GetNeighborList, etc.). * Added mention of "Toy Models" to documentation. * Added data-type error checking for Portable Model parameter get/set routines; Thanks to Daniel Schopf. * Bug fixes and improvements to kim-api-collections-management script * Added support for Include-What-You-Use (IWYU). * Added (internal) copy of edn-cpp parser for use with SMs. * Updated existing examples as necessary and added SM example. * Added new "unit-test" examples of simulators using the Collections and SM interfaces. * Improvement to pkgconfig support; Thanks to Christoph Junghans. * Added new tests to CI, based on INSTALL file. * Updates create-package script and added run-cmds-from-install script. * Added .clang-format-hook-ignore file and mechanism (specifically for edn-cpp). * Updates to better support binary installation on various systems. * Added CDDL headers to files that did not have them. === kim-api-2.0.2 =============== 28Mar2019 ==================================== * Transition from 'kim-api-v2' naming to 'kim-api' for better alignment with open source conventions * Added a simulator model example * Refactored support for simulator models: separated from models in collections. Updated collections-management utility appropriately * Updated calls to scanf() for better security * Refactored old_KIM_API_DIRS.cpp to remove calls to 'exit()' * Added build options to set system collection directories * Added support for colon-separated list of directories for user and system collections * Added '--version' flag to utilities * Update bash completion to work with old and new bash * Improve robustness of creat-package script * Updated badges to point to 'devel' branch & create-package to change to 'master' branch for release commit * Added coverity & codecov badges to README.md * Added vX.Y.Z-git tags to git repo and updated create-package script * Added NEWS file to Doxygen documentation & updated doxygen settings * Improved version build metadata string using "git describe" * Updated link flags for codecov === kim-api-v2-2.0.1 ============ 27Feb2019 ==================================== * Fix bug in KIM::SemVer::ParseSemVer() * Various minor fixes to address issues identified by Coverity Scan * Fix version string in libkim-api-v2.pc to conform to RPM schema * Added advanced CMake options for compilers used to build items after install * Added item install prefix CMake variables to cache; helps with packaging * Remove dead code in top level CMakeLists.txt === kim-api-v2-2.0.0 ============ 06Feb2019 ==================================== * Update main documentation. * Added function level documentation with cross-references and input/output argument descriptions. * Added Known() member function to extensible enumerations. * Extensible enumeration default constructors now create uninitialized objects. * Rename C++ *.String() routines to *.ToString. * Added 'recursive' to all Fortran routines (for better thread safety). * Added support files for readthedocs. * Additions and fixes for collections-management utility. * Travis CI configuration updates. * Avoid some compiler warnings from clang. * Various CMake fixes/adjustments. * Various bug fixes in api code. === kim-api-v2-2.0.0-beta.3 ===== 07Dec2018 ==================================== * Updated and added examples to work with and demonstrate api changes/additions * Implemented new KIM::Model::IsRoutinePresent interface to facilitate backward compatibility * Updated SpeciesName entries for recently renamed periodic table elements * Added WriteParameterizedModel Routine and assoc. code * Added Extension Routine to allow for non-standard extensions * Added Push/Pop Default Verbosity to KIM::Log * Changed Release default LogVerbosity to INFORMATION * Added ctest test for items to check that shared libraries can be opened * Improvements to Collections-Management behavior * Removed unnecessary header files * Updated travis.ci configuration * Refactored some backend implementation to improve maintainability, including significant new KIM_SharedLibrarySchema interface * Improvements to CMake build system * Updated create-package script * Updated documentation === kim-api-v2.0.0-beta.2 ======= 28Oct2018 ==================================== * CMake build and test replaces custom Makefiles; added travis, gitlab CI A big thank you to Richard Berger and Christoph Junghans for their major contribution in getting the KIM API package converted to CMake. * Using standard pkg-config setup instead of custom kim-api-v2-build-config * Major restructuring of the Fortran bindings. * Make ModelRefresh and ModelComputeArgumentsDestroy functions optional * Add Model routine and callback prototypes in KIM_Functions header * Add a required unique name field for parameters. * Refactoring of neighbor list hints. The half-list hint had a fatal flaw which required its removal. * Significant refactoring of the logging macros in C and C++. Complete removal of all preprocessing for Fortran. * Redesign of release and packaging script and process. * Added a couple of new models that illustrate various features of the api. * Removed v1 to v2 porting guide. * "Summary of Differences Between kim-api-v1 and kim-api-v2" docs page now contains tables with a complete listing of all kim-api identifiers in all languages and their mappings between one-another. * Complete update of documentation. Rework and correct definition of partialVirial and partialParticleVirial. * Added emacs cc-mode settings * Added clang-format settings, scripts, and git-hooks for C/C++ * Complete review of C++, C, and Fortran bindings for consistency * Many other small and not-so-small changes. === kim-api-v2.0.0-beta.1 ======= 07Jul2018 ==================================== * Fix memory leak and uninitialized variables id'ed by coverity scan. * Update docs and porting guide for neighbor list hints changes. * Implement neighbor list hints (paddingNeighbor & halfList); update examples. * Add SetArgumentPointer(xxx * const ptr) to C++ bindings for consistency. * Add C++ LennardJones_Ar stand-alone model example. * Fix compatibility checking code in example simulators. * Update LennardJones612 example to use 1/2 list short-circuit mechanism. * Fix collections-info to set log verbosity to debug. * Use NULL consistently to initialize pointers in implemenation code. === kim-api-v1.9.7 ============== 07Jul2018 ==================================== * Check for errors from mkdir() in KIM_API_DIRS.cpp (id'ed by coverity scan). * Fix support for required-compute of forces in utility-forces-numer-deriv. * Fix identifiers in bash-completions. * Added --log option to CM 'list' command. * Use fixed seed for random number generator in utility-forces-numer-deriv. === kim-api-v2.0.0-beta.0 ======= 26Jun2018 ==================================== * Added a 'Guide for porting content from KIM API v1 to v2' to documentation * Documentation updates and improvements * Implemented extensive error checking and logging within the API * Separated Model object into ComputeArguments and Model * Many refinements and corrections to the new API === kim-api-v1.9.6 ============== 26Jun2018 ==================================== * Updated INSTALL file * Added 'install OpenKIM_with_history' and 'install --force' options to the collections-management utility * Collections-management utility now cleanly handles an unaccessible openkim.org * Fixed bugs and made improvements to build system === kim-api-v1.9.5 ============== 12May2018 ==================================== * Update build system to support parallel builds (make -j). * Fixed bug in collections-management for "install OpenKIM" option. * Update INSTALL file === kim-api-v1.9.4 ============== 09Apr2018 ==================================== * Added '--interactive' option to collections-management utility. * Added Travis-CI support through GitHub. * Fixed bugs in collections-management utility. * Fixed bugs in build system. === kim-api-v1.9.3 ============== 10Feb2018 ==================================== * Major additions to options supported by the kim-api-v1-collections-management utility. Added options include: - list --with-version - install CWD - install environment - reinstall - remove-all Additionally, items can now be installed from a source directory on the local file system. Also, multiple items can be listed on a single command line. * Added a kim-api-v1-activate/deactivate utilities (available when installed to non-standard locations). These add/remove to PATH and setup the bash completions. * Added bash completions for user utilities * Added support for the sysconfdir variable to the build system * Updated utilities to more closely follow docopt.org specifications. * Model/Driver 'make install-*' now respect the DESTDIR environment variable. * Added support for Model/Driver install to the environment collection. * Add tracking of Parameterized Model parameter file file-names within the generated model shared library. * Rename vc_* examples to utility_* to avoid confusion with new openkim.org Verification Checks. * Various minor typo and bug fixes. === kim-api-v2.0.0-alpha.0 ====== 18Jan2018 ==================================== * Complete rewrite of the kim-api package. Released as "alpha" to solicit feedback from the user community. Changes (possibly incompatible) will be made based on user experience. * Major changes are summarized below. * NBCs have been eliminated. * KIM descriptor files have been eliminated. * A new memory management scheme has been adopted. * The api is now much more consistent within each language (C++, C, Fortran) binding. * Improved logging facilities and error messages. * Added Doxygen generated documentation. (See the docs for more details on this version of the kim-api and on the differences between v1 and v2.) === kim-api-v1.9.2 ============== 08Oct2017 ==================================== * Update scripts to use xz compressed tarballs (txz) instead of gz (tgz). This is for compatibility with the recent removal of tgz support on openkim.org. === kim-api-v1.9.1 ============== 27Sep2017 ==================================== * Adjustment to build config flags to make cross-language compiling a bit more flexible * Fix subtle Fortran implementation bug associated with non-short-circuit conditional fortran behavior * Remove 'make install-set-default-to-v1' target and update INSTALL instructions No longer have kim-api-build-config, etc. Now they explicitly include the major version number. For example, kim-api-v1-build-config * Make some shell code more portable * Fixed some other installation details * Fixed missing semi-colon in makefile === kim-api-v1.9.0 ============== 09Sep2017 ==================================== * Added collections-management user utility to manage build and install of OpenKIM Models and Model Drivers * Added support for "Simulator Models" * Dramatically simplify build system by removing supported scenarios. + Removed static-link build option + Removed "in-place" build scenario + Added support and use of the libexec directory to distinguish between user executable utilities and program executable utilities * Incorporate fix to configure script contributed by Christoph Junghans * Fix minor bugs in KIM_API_DIRS === kim-api-v1.8.2 ============== 17Apr2017 ==================================== * Fixed issues reaised by Tobias Brink (this==NULL; and `find` portability) === kim-api-v1.8.1 ============== 28Mar2017 ==================================== * Added additional deprecations in prep. for kim-api-v2.0.0 * Fixed other minor bugs in create_package script and build-config.cpp * Fixed bug in Makefile.ParameterizedModel * Fixed formatting error in Makefiles created by build-config utility * Fixed bug in ex_model_Ar_P_MLJ_CLUSTER_C example model === kim-api-v1.8.0 ============== 17Jan2017 ==================================== * Deprecated significatant features and methods in prep. for kim-api-v2.0.0 * Updated `build-config' utility with more flexible options * Removed `KIM_LINK = dynamic-link' option of build system * Modified/Fixed/Improved the configuration and build system * Added `collections-info' utility for querying environment variables, user configuration files, and lists of models and model drivers in the collections. === kim-api-v1.7.3 ============== 02Jun2016 ==================================== * Added a `configure' script for setting up Makefile.KIM_Config * Added support for environment-variable-collection * Added support for user_config_file_dir_name setting * Documentation update/improvements * Minor improvements to error messages * Added `make add-OpenKIM' feature * Added `make help' feature * Added release dates to NEWS file * Bug fixs === kim-api-v1.7.2 ============== 25Jun2015 ==================================== * Updated copyright years in files * Rewrite of INSTALL file to provide a significantly improved description and instructions for build and installation of the KIM API * Fix error checking bug in ex_test_Ar_multiple_models Test * Improve the build and install process to better follow standard conventions for library soname values. * Increased the maximum number of species supported by the example Tests to 200 * Fixed bug in example Tests related to maximum number of supported species * Updated 'make clean' so that it removes all old library files in the source directories * Fixed default make target for Parameterized Models * Fixed a bug in the installation process associated with the use of DESTDIR * Fixed a regular expression error in the build system * Fixed memory leak in internal KIM API code * Added sanity check to make sure that the 'xxd' utility is available * vc_forces_numer_deriv now outputs configuration energy * Documentation updates === kim-api-v1.7.1 ============== 02Dec2014 ==================================== * Bug fix for build of parameterized Models * Minor documentation update === kim-api-v1.7.0 ============== 21Nov2014 ==================================== * Use 'xxd' utility for encapsulation of KIM descriptor files and param. files * Added LINKSOPATH variable to build system for advanced system install options * Added KIM_API_get_kim_str_len() routine * Fix inconsistencies in ex_test_Ar_multiple_models * remove build system dependency on 'ed' program * Update 'make add-*' mechanism to use permanent url's for openkim.org items * Fix bugs and minor improvements to build system * Minor improvements to error messages * Updates to documentation === kim-api-v1.6.3 ============== 18Aug2014 ==================================== * Fixed install to recognize := and = in Makefiles * Removed use of non-standard strtok_r() * Fixes to ex_model_Cu_PF_Johnson & model_El_PF_Template.c * Fixes build system === kim-api-v1.6.2 ============== 11Aug2014 ==================================== * Correct KIM_API_Versions in template ".kim" files * Update make clean target for Model Drivers and Models * All template ".kim" files now generated from "legos" in git repo === kim-api-v1.6.1 ============== 08Aug2014 ==================================== * Updates to Model Driver and Model template files (in docs/templates/) * Changed the internal mechanism for handling parameter files to remove a security hole associated with the use of tmpnam(). * Revise kim.log entries to be more informative and clear * Bug fixes in build system, examples, and build system * Other small documentation and code improvements === kim-api-v1.6.0 ============== 28Jul2014 ==================================== * Documentation updates. * Model Driver Template and training model examples are now generated from a single consistent "lego" file. Training examples are not included in official release tarballs. * Add SemVer version routines to the KIM API. ".kim" files now require a KIM_API_Version line to indicate the Model/Simulator compatibility. * Change terminology from "Particle Types" to "Particle Species" for clarity and uniformity with the rest of the OpenKIM project. (See KIM_API_get_model_species(), and similar routines.) * Changed KIM API routines that output strings. This avoids output of arrays of strings, which are unnatural in C/C++ and allows for more natural handling of string arguments in Fortran. (See: KIM_API_get_NBC_method(), KIM_API_get_params(), and similar routines.) * Simulators and OpenKIM Tests now should use the "kim-api-build-config" utility in order to obtain appropriate compiler and linker flags for building against the KIM API. * Changed CCFLAGS to more standard CFLAGS Make variable. * Build system now provides ability to download Model Drivers and Models directly from openkim.org. * Change package name from "openkim-api" to "kim-api". * Rename this file (CHANGELOG) to NEWS, to better follow convention. * A complete restructuring of the package directory layout has been performed in order to conform to more standard practices and to better reflect the intended behavior and use of the package components. * Model Drivers now specify the name of their ".kim" file template in their Makefile. The conventional name for these files now ends in ".kim.tpl". * Model ".kim" file name is now specified in the Makefile and can be anything the developer desires. * Remove deprecated KIM_API_init() routine. * Remove deprecated Fortran Cray pointer support. === openkim-api-v1.5.0 ========== 16Jul2014 ==================================== * Documentation updates, including an extensive discussion of the installation process in INSTALL. * Update examples to use KIM_API_file_init() and name their ".kim" file "descriptor.kim" in accordance with the new convention of the openkim.org processing pipeline. * Deprecate KIM_API_init() and add KIM_API_file_init() to replace it as the primary openkim.org Tests should initialize the KIM API and specify their KIM descriptor files. * Portability fixes for the make system * Move away from naming various files based on the item (Model Driver, Model, Test) name. Instead establish standard names for each item type. * Added Makefile.Version to provided the make system with version information and set policy (based on SemVer 2.0.0) for how, when, and why to update the version. * Significant updates to the make system. Primarily associated with installation of the KIM API to a system-wide location, and its use once installed there. === openkim-api-v1.4.1 ========== 19May2014 ==================================== * Added additional compiler flags to support differences between GCC and INTEL * Fixed examples that used set_data when they should have used set_method. * Added LDLIBS flag in split functionality of LDFLAGS variable more appropriately. This is more inline with standard Makefile practice. * Now 32Bit and 64Bit settings add -m32 and -m64 compiler flags automatically * Added KIM_MAKE_VERBOSITY setting to Make system * Updates to README, INSTALL, and Templates * Make system improvements and fixes * Added checks for known buggy compilers * Updated and corrected documentation === openkim-api-v1.4.0 ========== 26Feb2014 ==================================== * Improvements to robustness and efficiency of MAKE_SYSTEM * Updated copyright years in files * Updated documentation to reflect new Fortran 2003 bindings * Converted DOCS/TEMPLATES/ to Fortran 2003 bindings * Made significant improvement to neighbor list handling in example Tests * Made some minor improvements to example Models and Model Drivers * Converted example Models, Model Drivers, and Tests to Fortran 2003 bindings * DEPRECATED all Cray pointer bindings and associated code * Added Fortran 2003 bindings === openkim-api-v1.3.1 ========== 20Jan2014 ==================================== * Fixes to make system to avoid undefined `directoryPATH()' symbol with INTEL compilers and CYGWIN systems * Added notes to INSTALL for gun 4.4 and CYGWIN systems * Fixes to make system to work with gnu make 3.81 (avoid segmentation faults) === openkim-api-v1.3.0 ========== 10Dec2013 ==================================== * change KIM_KEY_STRING_LENGTH to 128 (despite git log that says 257) * Split .kim files and parameter files into chunks to stay under C++ supported string literal length. * Fix for dynamic-link compile option * Some minor code fixes/updates and documentation updates * Updates to `make install' * Fix bug in FCC example Tests * Fix/Update Templates * Fix a bug in Makefile.Test * Added KIM_API_get_rank and KIM_API_get_rank_by_index functions === openkim-api-v1.2.3 ========== 15Nov2013 ==================================== * Fixed bugs in the KIM_API_string_init() function (discovered by Daniel Schopf) * Fixed a memory leak in the api (patch provided by Tobias Brink) * Moved `include "KIM_API_DIRS.h"' from KIM_API.h to KIM_API.cpp. This ensures that this header file does not need to be installed by the `make install' command. * Changes to Makefiles to improve portability (of `make uninstall') * Some minor changes to api code to remove compiler warnings from some compilers === openkim-api-v1.2.2 ========== 17Sep2013 ==================================== * Improved speed of make system when many Models/Tests (and Drivers) exist * Improved an aspect of the api's error checking/reporting === openkim-api-v1.2.1 ========== 21Jul2013 ==================================== * Reverted to gnu make v3.81 from v3.82 to better represent actual needs. === openkim-api-v1.2.0 ========== 12Jul2013 ==================================== * Documentation updates. * Various bug fixes. * Added support for searching ${HOME}/.kim/ and ./ for Models and Model Drivers when the package is installed via the `make install' command. * Added install and uninstall targets to the Make system. * Now the build system (in dynamic-load and dynamic-link modes) hides all symbols in the Model Driver and Model libraries except for the model_init() function and the Model's kim descriptor string. This means that there is no need to worry about symbol clashes between Models, Model Drivers, or Tests. * Implemented dynamic-load, dynamic-link, and static-link build options. * Make system now provides only summary information on the build process. This makes the progress easier to understand. To see the actual build commands use `make -n'. * Removed `integer*8' and changed `real' and `real*8' to `float' and `double'. * Now use -g, -Wall, and -pedantic by default for all compilations. * Changed model_init() function conventions to simplify the scheme. This also resulted in the removal of the Model or Test name from the descriptor files. * Added the openkim-api-descriptor-file-match utility. * Completely rewrote and streamlined the openkim-api Make system * Changed directory names from trailing `s' to trailing `S'. * Updated example Tests and Models to use the new get/set method routines. * Added `const' to api string parameters to avoid warnings in Models and Tests * Added get/set method routines to properly transfer pointers to functions or methods via the api. * Added support to examples for NEIGH_RVEC_H. * Added the NEIGH_RVEC_H NBC method. * Added ex_free_cluster_CLUSTER_memory F90 Test which manages its own memory. * Added ex_model_Cu_PF_Johnson C pair-functional model and template. * Updates and bug fixes in example Models. * Bug fixes for vc_forces_numer_deriv and added vc_config_ener_forces and vc_forces_delta to the distribution. === openkim-api-v1.1.1 ========== 19Aug2012 ==================================== * Added run_forces_numer_deriv_for_all_models script that will run and summarize the results of vc_forces_numer_deriv for all available Models. * Added vc_forces_numer_deriv "verification check" that can be used with any Model to check the consistency of its computed forces with a numerical derivative based on the Model's energy. * Fixed a bug in the MI_OPBC_* support for ex_model_Ne_P_fastLJ * Fixed a bug in the make system that occurred when using static linking that would cause some Models to be incorrectly identified as "unknown" * ex_test_*_free_cluster and ex_test_*_free_cluster_stiff now support CLUSTER NBC (which means they work with ALL NBC methods) * Documentation updates * Updated 32/64 bit switching in Fortran code for easier maintenance * Moved library compile flags to end of command line to make sure all libraries are correctly associated with the appropriate .so files * Cleaned up ex_model_driver_P_* and ex_model_Ne_P_fastLJ to simplify memory management and PARAM_* handling === openkim-api-v1.1.0 ========== 12Jul2012 ==================================== * Documentation updates * Introduced the use of THIS_FILE_NAME in Fortran examples instead of __FILE__. This allows for easily setting the value of THIS_FILE_NAME to something appropriate (short) when the default preprocessor value of __FILE__ is longer that 132 characters (the max line length for Fortran) * Changed KIM standard time unit from `fs' to `ps' to be consistent with LAMMPS `metal' unit system * Changed KIM_COMPUTE and KIM_NOT_COMPUTE to KIM_COMPUTE_TRUE and KIM_COMPUTE_FALSE, respectively * Removed KIM_API_MAX_NEIGHBORS; the api no longer puts any restriction on the number of neighbors for an atom * Updated api and examples to always `return' with an error code instead of `exit' or `stop'. This allows the Test to handle errors and is a better convention for error handling * Added KIM_STATUS_MODEL_UNSUPPORTED_CONFIGURATION for cases where a configuration is identified at run time as unsupported * Removed requirement for a trailing `/' in environment variables (such as $KIM_DIR) * Added make warning if `make' is invoked from a Model directory when static linking is being used. * Added `make examples-force' target * `make examples' only copies files; it no longer also compiles everything * Changed all call-back interfaces (model_init, model_reinit, model_compute, model_destroy) to be consistent: integer functions (in Fortran speak). Also updated examples and templates to conform to this new interface. * Added get_model_partcl_typs() and get_test_partcl_type() service routines Removed get_partcl_types() routine. * Added ability of a Model/Model Driver to set its particle type codes at runtime * Added support for .kimignore files in MODELS, MODEL_DRIVERS, and TESTS directories * Added `Temperature' to standard.kim for "temperature dependent" Models * New Model Driver interface supports reading from any number of files (not strings) * Support for 001-999 particle types in Model Drivers * Use $(strip ) function to avoid difficult trailing space problem in make files * Rearranged and simplify compiler settings files (KIM_API/*_compiler_settings.mk) * Changed CPPLIBFLAG to LINKLIBFLAG in Make files to better represent its use * Many improvements to Make-system portability * Carriage returns are now striped from kim and parameter files during Make * Improvements to the vc_forces_numer_deriv verification check * Bug fixes for KIM_API_init() matching * Significant clean-up/rearrangement of core api code === openkim-api-v1.0.1 ========== 25Feb2012 ==================================== * Bug fix to ex_model_Ne_P_fastLJ * Bug fix to ex_model_Al_PF_ErcolessiAdams (and associated template file) * Documentation updates === openkim-api-v1.0.0 ========== 22Feb2012 ==================================== * Moved all examples to EXAMPLES directory and added `make examples' target. * Renamed all example Model Drivers, Models, and Tests. Now have `ex_' prefix. * Renamed nearly all API functions to improve readability and comprehension. * Changed KIM_API_get_half_neigh and KIM_API_get_full_neigh to just KIM_API_get_neigh. * Total re-work of unit handling for the API. * Added KIM_API_model_info() function for Tests to use for discovering what a Model supports. * Added KIM_API_getm_* and KIM_API_setm_* routines to get/set multiple arguments in one function call. * Added KIM_API_sting_init() for use by Tests that generate their KIM descriptor file "on-the-fly". * Added process_dEdr and process_dE2dr2 approach for calculating general properties. Currently automatic support for `virial', `particleVirial', and `hessian' is available. * Added "unsymmetric half neighbor lists" (numberContributingParticles). * Added model/test buffers for use by Model and Test, respectively. * Improvements in dynamic linking setup. * Examples additions, improvements, and bug fixes. * Bug fixes. === openkim-api-v0.2.0 ========== 15Sep2011 ==================================== * Updated documentation * Added KIM_API_report_error() service function and updated all examples and templates to use this function. * Added KIMstatus.h which contains definitions of KIM status codes. * Added KIM_API_status_msg() service routine to return a string describing a given status code. * Updated messages printed to kim.log file to be more informative. * Model KIM descriptor files are now incorporated into the Model's binary library file. This means that the file is no longer required at run time and that the Model must be recompiled after changes to the descriptor file. * Added Model Driver Templates * Added two Model Drivers and four Models based on the Model Drivers * Removed example model_Ar_P_MMorse in favor of the Morse Driver and its Models * Added support for Model Drivers * Bug fixes === openkim-api-v0.1.2 ========== 22Aug2011 ==================================== * Fixed a number of bugs in the examples related to running on 64bit machines * Fixed a bug in kim_api_get_nbc_method_f() related to running on 64bit machines === openkim-api-v0.1.1 ========== 16Aug2011 ==================================== * Fixed memory handling bug associated with the service functions KIM_API_get_listAtomTypes() KIM_API_get_listParams() KIM_API_get_listFreeParams() KIM_API_get_listFixedParams() KIM_API_get_NBC_method() * Fixed bug in test_**_free_cluster.F90 * Renamed `README.git' to `README_GIT' to avoid confusion with the git convention that the extension `.git' refers to a bare repository === openkim-api-v0.1.0 ========== 08Aug2011 ==================================== * Added TEMPLATE files to help users create their own KIM Models. * Added a number of example Models and Tests to help users understand how to implement their own openkim-api compliant codes. * Added support for ATOM/PARTICLE types * Added support for Models to publish their parameters * Added support for Models to define a `reinit' function for use when their parameters are changed by a Test. * Improved the Makefile system in general (although, more needs to be done) * Added support for neighbor list and boundary conditions (NBC) * Added support for dynamic linking * Updated documentation * Added documentation to the standard.kim file which now describes in detail the format and content of KIM descriptor files. * Added README files to every directory. These files provide a short (hopefully helpful) description of the contents of the directory) === openkim-api-v0.0.0 ========================================================= The initial release of the openkim-api package. This was first made available to participants at the Inaugural Openkim Workshop held in San Diego, CA on Feb. 26-27, 2011. kim-api-2.3.0-git/README.md000066400000000000000000000076431421473465500151300ustar00rootroot00000000000000 [![Build](https://github.com/openkim/kim-api/actions/workflows/build-multiplatform.yml/badge.svg)](https://github.com/openkim/kim-api/actions/workflows/build-multiplatform.yml) [![Documentation Status](https://readthedocs.org/projects/kim-api/badge/?version=devel)](https://kim-api.readthedocs.io/en/devel/?badge=devel) [![Coverity Scan](https://scan.coverity.com/projects/16411/badge.svg?flat=1)](https://scan.coverity.com/projects/openkim-kim-api) [![codecov](https://codecov.io/gh/openkim/kim-api/branch/devel/graph/badge.svg)](https://codecov.io/gh/openkim/kim-api/branch/devel)

The KIM API package

Packaging status The KIM API package is a system-level library that aims to give computer programmers the ability to write atomistic or molecular simulation programs that can seamlessly interface with implementations of interatomic models, regardless of the programming language (C, C++, Fortran, Python, etc.) in which the codes are written. It is part of the larger KIM project (https://openkim.org). Documentation ------------- [Full documentation](https://kim-api.readthedocs.io/en/devel) is available online via [readthedocs.org](https://readthedocs.org) Download -------- All official release archives of the KIM API package can be downloaded from: [https://openkim.org/kim-api/previous-versions](https://openkim.org/kim-api/previous-versions) Release notes are available in the [NEWS](NEWS) file. Installation ------------ See the [INSTALL](INSTALL) file for instructions on how to build and install the package and its documentation. Contributing ------------ Just send us a [pull request](https://help.github.com/articles/using-pull-requests/). When you send your request, make `devel` the destination branch on the [kim-api repository](https://github.com/openkim/kim-api). Please see the [README_GIT](README_GIT) file for some additional details. Issues, bugs, requests, ideas ----------------------------- Use the [issues](https://github.com/openkim/kim-api/issues) tracker to report bugs. License ------- The KIM API is distributed under the terms of the LGPL-2.1-or-later license. All new contributions must be made under this license. See [LICENSE.LGPL](LICENSE.LGPL) and [https://spdx.org/licenses/LGPL-2.1-or-later.html](https://spdx.org/licenses/LGPL-2.1-or-later.html) for details. ******************************************************************************* SUPPORT Support is always available by posting questions with all relevant information to Members of the OpenKIM development team actively monitor this forum and will do their best to respond to questions in a timely fashion. ******************************************************************************* kim-api-2.3.0-git/c/000077500000000000000000000000001421473465500140615ustar00rootroot00000000000000kim-api-2.3.0-git/c/include/000077500000000000000000000000001421473465500155045ustar00rootroot00000000000000kim-api-2.3.0-git/c/include/CMakeLists.txt000066400000000000000000000046561421473465500202570ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # target_include_directories(kim-api PUBLIC $ $ ) configure_file(KIM_Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/KIM_Version.h) set(C_HEADERS KIM_ChargeUnit.h KIM_Collection.h KIM_Collections.h KIM_CollectionItemType.h KIM_ComputeArgumentName.h KIM_ComputeArguments.h KIM_ComputeCallbackName.h KIM_DataType.h KIM_EnergyUnit.h KIM_FunctionTypes.h KIM_LanguageName.h KIM_LengthUnit.h KIM_Log.h KIM_LogMacros.h KIM_LogVerbosity.h KIM_Model.h KIM_ModelCompute.h KIM_ModelComputeArgumentsCreate.h KIM_ModelComputeArgumentsDestroy.h KIM_ModelComputeArguments.h KIM_ModelCreate.h KIM_ModelExtension.h KIM_ModelDestroy.h KIM_ModelDriverCreate.h KIM_ModelDriverHeaders.h KIM_ModelHeaders.h KIM_ModelRefresh.h KIM_ModelRoutineName.h KIM_ModelWriteParameterizedModel.h KIM_Numbering.h KIM_SemVer.h KIM_SimulatorHeaders.h KIM_SimulatorModel.h KIM_SpeciesName.h KIM_SupportStatus.h KIM_SupportedExtensions.h KIM_TemperatureUnit.h KIM_TimeUnit.h KIM_UnitSystem.h ${CMAKE_CURRENT_BINARY_DIR}/KIM_Version.h ) install(FILES ${C_HEADERS} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_INCLUDEDIR}/${PROJECT_NAME}) kim-api-2.3.0-git/c/include/KIM_ChargeUnit.h000066400000000000000000000124701421473465500204120ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_CHARGE_UNIT_H_ #define KIM_CHARGE_UNIT_H_ /** ** \brief \copybrief KIM::ChargeUnit ** ** \sa KIM::ChargeUnit, kim_charge_unit_module::kim_charge_unit_type ** ** \since 2.0 **/ struct KIM_ChargeUnit { /** ** \brief \copybrief KIM::ChargeUnit::chargeUnitID ** ** \sa KIM::ChargeUnit::chargeUnitID, ** kim_charge_unit_module::kim_charge_unit_type::charge_unit_id ** ** \since 2.0 **/ int chargeUnitID; }; #ifndef KIM_CHARGE_UNIT_DEFINED_ #define KIM_CHARGE_UNIT_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_ChargeUnit KIM_ChargeUnit; #endif /** ** \brief \copybrief KIM::ChargeUnit::ChargeUnit(std::string const &) ** ** \sa KIM::ChargeUnit::ChargeUnit(std::string const &), ** kim_charge_unit_module::kim_from_string ** ** \since 2.0 **/ KIM_ChargeUnit KIM_ChargeUnit_FromString(char const * const str); /** ** \brief \copybrief KIM::ChargeUnit::Known ** ** \sa KIM::ChargeUnit::Known, kim_charge_unit_module::kim_known ** ** \since 2.0 **/ int KIM_ChargeUnit_Known(KIM_ChargeUnit const chargeUnit); /** ** \brief \copybrief KIM::ChargeUnit::operator==() ** ** \sa KIM::ChargeUnit::operator==(), kim_charge_unit_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_ChargeUnit_Equal(KIM_ChargeUnit const lhs, KIM_ChargeUnit const rhs); /** ** \brief \copybrief KIM::ChargeUnit::operator!=() ** ** \sa KIM::ChargeUnit::operator!=(), kim_charge_unit_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_ChargeUnit_NotEqual(KIM_ChargeUnit const lhs, KIM_ChargeUnit const rhs); /** ** \brief \copybrief KIM::ChargeUnit::ToString ** ** \sa KIM::ChargeUnit::ToString, kim_charge_unit_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ChargeUnit_ToString(KIM_ChargeUnit const chargeUnit); /** ** \brief \copybrief KIM::CHARGE_UNIT::unused ** ** \sa KIM::CHARGE_UNIT::unused, ** kim_charge_unit_module::kim_charge_unit_unused ** ** \since 2.0 **/ extern KIM_ChargeUnit const KIM_CHARGE_UNIT_unused; /** ** \brief \copybrief KIM::CHARGE_UNIT::C ** ** \sa KIM::CHARGE_UNIT::C, kim_charge_unit_module::kim_charge_unit_c ** ** \since 2.0 **/ extern KIM_ChargeUnit const KIM_CHARGE_UNIT_C; /** ** \brief \copybrief KIM::CHARGE_UNIT::e ** ** \sa KIM::CHARGE_UNIT::e, kim_charge_unit_module::kim_charge_unit_e ** ** \since 2.0 **/ extern KIM_ChargeUnit const KIM_CHARGE_UNIT_e; /** ** \brief \copybrief KIM::CHARGE_UNIT::statC ** ** \sa KIM::CHARGE_UNIT::StatC, kim_charge_unit_module::kim_charge_unit_statc ** ** \since 2.0 **/ extern KIM_ChargeUnit const KIM_CHARGE_UNIT_statC; /** ** \brief \copybrief KIM::CHARGE_UNIT::GetNumberOfChargeUnits ** ** \sa KIM::CHARGE_UNIT::GetNumberOfChargeUnits, ** kim_charge_unit_module::kim_get_number_of_charge_units ** ** \since 2.0 **/ void KIM_CHARGE_UNIT_GetNumberOfChargeUnits(int * const numberOfChargeUnits); /** ** \brief \brief \copybrief KIM::CHARGE_UNIT::GetChargeUnit ** ** \sa KIM::CHARGE_UNIT::GetChargeUnit, ** kim_charge_unit_module::kim_get_charge_unit ** ** \since 2.0 **/ int KIM_CHARGE_UNIT_GetChargeUnit(int const index, KIM_ChargeUnit * const chargeUnit); #endif /* KIM_CHARGE_UNIT_H_ */ kim-api-2.3.0-git/c/include/KIM_Collection.h000066400000000000000000000126651421473465500204620ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COLLECTION_H_ #define KIM_COLLECTION_H_ /** ** \brief \copybrief KIM::Collection ** ** \sa KIM::Collection, kim_collection_module::kim_collection_type ** ** \since 2.1 **/ struct KIM_Collection { /** ** \brief \copybrief KIM::Collection::collectionID ** ** \sa KIM::Collection::collectionID, ** kim_collection_module::kim_collection_type::collection_id ** ** \since 2.1 **/ int collectionID; }; #ifndef KIM_COLLECTION_DEFINED_ #define KIM_COLLECTION_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.1 **/ typedef struct KIM_Collection KIM_Collection; #endif /** ** \brief \copybrief KIM::Collection::Collection(std::string const &) ** ** \sa KIM::Collection::Collection(std::string const &), ** kim_collection_module::kim_from_string ** ** \since 2.1 **/ KIM_Collection KIM_Collection_FromString(char const * const str); /** ** \brief \copybrief KIM::Collection::Known ** ** \sa KIM::Collection::Known, kim_collection_module::kim_known ** ** \since 2.1 **/ int KIM_Collection_Known(KIM_Collection const collection); /** ** \brief \copybrief KIM::Collection::operator==() ** ** \sa KIM::Collection::operator==(), kim_collection_module::operator(.eq.) ** ** \since 2.1 **/ int KIM_Collection_Equal(KIM_Collection const lhs, KIM_Collection const rhs); /** ** \brief \copybrief KIM::Collection::operator!=() ** ** \sa KIM::Collection::operator!=(), kim_collection_module::operator(.ne.) ** ** \since 2.1 **/ int KIM_Collection_NotEqual(KIM_Collection const lhs, KIM_Collection const rhs); /** ** \brief \copybrief KIM::Collection::ToString ** ** \sa KIM::Collection::ToString, kim_collection_module::kim_to_string ** ** \since 2.1 **/ char const * KIM_Collection_ToString(KIM_Collection const collection); /** ** \brief \copybrief KIM::COLLECTION::system ** ** \sa KIM::COLLECTION::system, ** kim_collection_module::kim_collection_system ** ** \since 2.1 **/ extern KIM_Collection const KIM_COLLECTION_system; /** ** \brief \copybrief KIM::COLLECTION::user ** ** \sa KIM::COLLECTION::user, ** kim_collection_module::kim_collection_user ** ** \since 2.1 **/ extern KIM_Collection const KIM_COLLECTION_user; /** ** \brief \copybrief KIM::COLLECTION::environmentVariable ** ** \sa KIM::COLLECTION::environmentVariable, ** kim_collection_module::kim_collection_environment_variable ** ** \since 2.1 **/ extern KIM_Collection const KIM_COLLECTION_environmentVariable; /** ** \brief \copybrief KIM::COLLECTION::currentWorkingDirectory ** ** \sa KIM::COLLECTION::currentWorkingDirectory, ** kim_collection_module::kim_collection_current_working_directory ** ** \since 2.1 **/ extern KIM_Collection const KIM_COLLECTION_currentWorkingDirectory; /** ** \brief \copybrief KIM::COLLECTION::GetNumberOfCollections ** ** \sa KIM::COLLECTION::GetNumberOfCollections, ** kim_collection_module::kim_get_number_of_collections ** ** \since 2.1 **/ void KIM_COLLECTION_GetNumberOfCollections(int * const numberOfCollections); /** ** \brief \brief \copybrief KIM::COLLECTION::GetCollection ** ** \sa KIM::COLLECTION::GetCollection, ** kim_collection_module::kim_get_collection ** ** \since 2.1 **/ int KIM_COLLECTION_GetCollection(int const index, KIM_Collection * const collection); #endif /* KIM_COLLECTION_H_ */ kim-api-2.3.0-git/c/include/KIM_CollectionItemType.h000066400000000000000000000140201421473465500221260ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COLLECTION_ITEM_TYPE_H_ #define KIM_COLLECTION_ITEM_TYPE_H_ /** ** \brief \copybrief KIM::CollectionItemType ** ** \sa KIM::CollectionItemType, ** kim_collection_module::kim_collection_item_type_type ** ** \since 2.1 **/ struct KIM_CollectionItemType { /** ** \brief \copybrief KIM::CollectionItemType::collectionItemTypeID ** ** \sa KIM::CollectionItemType::collectionItemTypeID, ** kim_collection_module::kim_collection_type::collectionItemType_id ** ** \since 2.1 **/ int collectionItemTypeID; }; #ifndef KIM_COLLECTION_ITEM_TYPE_DEFINED_ #define KIM_COLLECTION_ITEM_TYPE_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.1 **/ typedef struct KIM_CollectionItemType KIM_CollectionItemType; #endif /** ** \brief \copybrief KIM::CollectionItemType::CollectionItemType(std::string const &) ** ** \sa KIM::CollectionItemType::CollectionItemType(std::string const &), ** kim_collection_item_type_module::kim_from_string ** ** \since 2.1 **/ KIM_CollectionItemType KIM_CollectionItemType_FromString(char const * const str); /** ** \brief \copybrief KIM::CollectionItemType::Known ** ** \sa KIM::CollectionItemType::Known, ** kim_collection_item_type_module::kim_known ** ** \since 2.1 **/ int KIM_CollectionItemType_Known( KIM_CollectionItemType const collectionItemType); /** ** \brief \copybrief KIM::CollectionItemType::operator==() ** ** \sa KIM::CollectionItemType::operator==(), ** kim_collection_item_type_module::operator(.eq.) ** ** \since 2.1 **/ int KIM_CollectionItemType_Equal(KIM_CollectionItemType const lhs, KIM_CollectionItemType const rhs); /** ** \brief \copybrief KIM::CollectionItemType::operator!=() ** ** \sa KIM::CollectionItemType::operator!=(), ** kim_collection_item_type_module::operator(.ne.) ** ** \since 2.1 **/ int KIM_CollectionItemType_NotEqual(KIM_CollectionItemType const lhs, KIM_CollectionItemType const rhs); /** ** \brief \copybrief KIM::CollectionItemType::ToString ** ** \sa KIM::CollectionItemType::ToString, ** kim_collection_item_type_module::kim_to_string ** ** \since 2.1 **/ char const * KIM_CollectionItemType_ToString( KIM_CollectionItemType const collectionItemType); /** ** \brief \copybrief KIM::COLLECTION_ITEM_TYPE::modelDriver ** ** \sa KIM::COLLECTION_ITEM_TYPE::modelDriver, ** kim_collection_item_type_module::kim_collection_item_type_model_driver ** ** \since 2.1 **/ extern KIM_CollectionItemType const KIM_COLLECTION_ITEM_TYPE_modelDriver; /** ** \brief \copybrief KIM::COLLECTION_ITEM_TYPE::portableModel ** ** \sa KIM::COLLECTION_ITEM_TYPE::portableModel, ** kim_collection_item_type_module::kim_collection_item_type_portable_model ** ** \since 2.1 **/ extern KIM_CollectionItemType const KIM_COLLECTION_ITEM_TYPE_portableModel; /** ** \brief \copybrief KIM::COLLECTION_ITEM_TYPE::simulatorModel ** ** \sa KIM::COLLECTION_ITEM_TYPE::simulatorModel, ** kim_collection_item_type_module::kim_collection_item_type_simulator_model ** ** \since 2.1 **/ extern KIM_CollectionItemType const KIM_COLLECTION_ITEM_TYPE_simulatorModel; /** ** \brief \copybrief KIM::COLLECTION_ITEM_TYPE::GetNumberOfCollectionItemTypes ** ** \sa KIM::COLLECTION_ITEM_TYPE::GetNumberOfCollectionItemTypes, ** kim_collection_item_type_module::kim_get_number_of_collection_item_types ** ** \since 2.1 **/ void KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes( int * const numberOfCollectionItemTypes); /** ** \brief \brief \copybrief KIM::COLLECTION_ITEM_TYPE::GetCollectionItemType ** ** \sa KIM::COLLECTION_ITEM_TYPE::GetCollectionItemType, ** kim_collection_item_type_module::kim_get_collection_item_type ** ** \since 2.1 **/ int KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType( int const index, KIM_CollectionItemType * const collectionItemType); #endif /* KIM_COLLECTION_ITEM_TYPE_H_ */ kim-api-2.3.0-git/c/include/KIM_Collections.h000066400000000000000000000273771421473465500206530ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COLLECTIONS_H_ #define KIM_COLLECTIONS_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.1 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif /** ** \brief Forward declaration. ** ** \since 2.1 **/ #ifndef KIM_COLLECTION_DEFINED_ #define KIM_COLLECTION_DEFINED_ typedef struct KIM_Collection KIM_Collection; #endif /** ** \brief Forward declaration. ** ** \since 2.1 **/ #ifndef KIM_COLLECTION_ITEM_TYPE_DEFINED_ #define KIM_COLLECTION_ITEM_TYPE_DEFINED_ typedef struct KIM_CollectionItemType KIM_CollectionItemType; #endif #ifndef KIM_COLLECTIONS_DEFINED_ #define KIM_COLLECTIONS_DEFINED_ /** ** \brief \copybrief KIM::Collections ** ** \copydetails KIM::Collections ** ** **/ typedef struct KIM_Collections KIM_Collections; #endif /** ** \brief \copybrief KIM::Collections::Create ** ** \sa KIM::Collections::Create, ** kim_collections_module::kim_collections_create ** ** \since 2.1 **/ int KIM_Collections_Create(KIM_Collections ** const collections); /** ** \brief \copybrief KIM::Collections::Destroy ** ** \sa KIM::Collections::Destroy, ** kim_collections_module::kim_collections_destroy ** ** \since 2.1 **/ void KIM_Collections_Destroy(KIM_Collections ** const collections); /** ** \brief \copybrief KIM::Collections::GetItemType ** ** \sa KIM::Collections::GetItemType, ** kim_collections_module::kim_get_item_type ** ** \since 2.1 **/ int KIM_Collections_GetItemType(KIM_Collections * const collections, char const * const itemName, KIM_CollectionItemType * const itemType); /** ** \brief \copybrief KIM::Collections::GetItemLibraryFileNameAndCollection ** ** \sa KIM::Collections::GetItemLibraryFileNameAndCollection, ** kim_collections_module::kim_get_item_library_file_name_and_collection ** ** \since 2.1 **/ int KIM_Collections_GetItemLibraryFileNameAndCollection( KIM_Collections * const collections, KIM_CollectionItemType const itemType, char const * const itemName, char const ** const fileName, KIM_Collection * const collection); /** ** \brief \copybrief KIM::Collections::CacheListOfItemMetadataFiles ** ** \sa KIM::Collections::CacheListOfItemMetadataFiles, ** kim_collections_module::kim_cache_list_of_item_metadata_files ** ** \since 2.1 **/ int KIM_Collections_CacheListOfItemMetadataFiles( KIM_Collections * const collections, KIM_CollectionItemType const itemType, char const * const itemName, int * const extent); /** ** \brief \copybrief KIM::Collections::GetItemMetadataFile ** ** \sa KIM::Collections::GetItemMetadataFile, ** kim_collections_module::kim_get_item_metadata_file_length, ** kim_collections_module::kim_get_item_metadata_file_values ** ** \since 2.1 **/ int KIM_Collections_GetItemMetadataFile( KIM_Collections * const collections, int const index, char const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, char const ** const fileString); /** ** \brief \copybrief KIM::Collections::CacheListOfItemNamesByType ** ** \sa KIM::Collections::CacheListOfItemNamesByType, ** kim_collections_module::kim_cache_list_of_item_names_by_type ** ** \since 2.1 **/ int KIM_Collections_CacheListOfItemNamesByType( KIM_Collections * const collections, KIM_CollectionItemType const itemType, int * const extent); /** ** \brief \copybrief KIM::Collections::GetItemNameByType ** ** \sa KIM::Collections::GetItemNameByType, ** kim_collections_module::kim_get_item_name_by_type ** ** \since 2.1 **/ int KIM_Collections_GetItemNameByType(KIM_Collections * const collections, int const index, char const ** const itemName); /** ** \brief \copybrief KIM::Collections::CacheListOfItemNamesByCollectionAndType ** ** \sa KIM::Collections::CacheListOfItemNamesByCollectionAndType, ** kim_collections_module::kim_cache_list_of_item_names_by_collection_and_type ** ** \since 2.1 **/ int KIM_Collections_CacheListOfItemNamesByCollectionAndType( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, int * const extent); /** ** \brief \copybrief KIM::Collections::GetItemNameByCollectionAndType ** ** \sa KIM::Collections::GetItemNameByCollectionAndType, ** kim_collections_module::kim_get_item_name_by_collection_and_type ** ** \since 2.1 **/ int KIM_Collections_GetItemNameByCollectionAndType( KIM_Collections * const collections, int const index, char const ** const itemName); /** ** \brief \copybrief KIM::Collections::GetItemLibraryFileNameByCollectionAndType ** ** \sa KIM::Collections::GetItemLibraryFileNameByCollectionAndType, ** kim_collections_module::kim_get_item_library_file_name_by_collection_and_type ** ** \since 2.1 **/ int KIM_Collections_GetItemLibraryFileNameByCollectionAndType( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, char const * const itemName, char const ** const fileName); /** ** \brief \copybrief KIM::Collections::CacheListOfItemMetadataFilesByCollectionAndType ** ** \sa KIM::Collections::CacheListOfItemMetadataFilesByCollectionAndType, ** kim_collections_module::kim_cache_list_of_item_metadata_files_by_collection_and_type ** ** \since 2.1 **/ int KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, char const * const itemName, int * const extent); /** ** \brief \copybrief KIM::Collections::GetItemMetadataFileByCollectionAndType ** ** \sa KIM::Collections::GetItemMetadataFileByCollectionAndType, ** kim_collections_module::kim_get_item_metadata_file_length_by_collection_and_type, ** kim_collections_module::kim_get_item_metadata_file_values_by_collection_and_type ** ** \since 2.1 **/ int KIM_Collections_GetItemMetadataFileByCollectionAndType( KIM_Collections * const collections, int const index, char const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, char const ** const fileString); /** ** \brief \copybrief KIM::Collections::GetProjectNameAndSemVer ** ** \sa KIM::Collections::GetProjectNameAndSemVer, ** kim_collections_module::kim_get_project_name_and_sem_ver ** ** \since 2.1 **/ void KIM_Collections_GetProjectNameAndSemVer( KIM_Collections * const collections, char const ** const projectName, char const ** const semVer); /** ** \brief \copybrief KIM::Collections::GetEnvironmentVariableName ** ** \sa KIM::Collections::GetEnvironmentVariableName, ** kim_collections_module::kim_get_environment_variable_name ** ** \since 2.1 **/ int KIM_Collections_GetEnvironmentVariableName( KIM_Collections * const collections, KIM_CollectionItemType const itemType, char const ** const name); /** ** \brief \copybrief KIM::Collections::GetConfigurationFileEnvironmentVariable ** ** \sa KIM::Collections::GetConfigurationFileEnvironmentVariable, ** kim_collections_module::kim_get_configuration_file_environment_variable ** ** \since 2.1 **/ void KIM_Collections_GetConfigurationFileEnvironmentVariable( KIM_Collections * const collections, char const ** const name, char const ** const value); /** ** \brief \copybrief KIM::Collections::GetConfigurationFileName ** ** \sa KIM::Collections::GetConfigurationFileName, ** kim_collections_module::kim_get_configuration_file_name ** ** \since 2.1 **/ void KIM_Collections_GetConfigurationFileName( KIM_Collections * const collections, char const ** const fileName); /** ** \brief \copybrief KIM::Collections::CacheListOfDirectoryNames ** ** \sa KIM::Collections::CacheListOfDirectoryNames, ** kim_collections_module::kim_cache_list_of_directory_names ** ** \since 2.1 **/ int KIM_Collections_CacheListOfDirectoryNames( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, int * const extent); /** ** \brief \copybrief KIM::Collections::GetDirectoryName ** ** \sa KIM::Collections::GetDirectoryName, ** kim_collections_module::kim_get_directory_name ** ** \since 2.1 **/ int KIM_Collections_GetDirectoryName(KIM_Collections * const collections, int const index, char const ** const directoryName); /** ** \brief \copybrief KIM::Collections::SetLogID ** ** \sa KIM::Collections::SetLogID, kim_collections_module::kim_set_log_id ** ** \since 2.1 **/ void KIM_Collections_SetLogID(KIM_Collections * const collections, char const * const logID); /** ** \brief \copybrief KIM::Collections::PushLogVerbosity ** ** \sa KIM::Collections::PushLogVerbosity, *kim_collections_module::kim_push_log_verbosity ** ** \since 2.1 **/ void KIM_Collections_PushLogVerbosity(KIM_Collections * const collections, KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::Collections::PopLogVerbosity ** ** \sa KIM::Collections::PopLogVerbosity, *kim_collections_module::kim_pop_log_verbosity ** ** \since 2.1 **/ void KIM_Collections_PopLogVerbosity(KIM_Collections * const collections); #endif /* KIM_COLLECTIONS_H_ */ kim-api-2.3.0-git/c/include/KIM_ComputeArgumentName.h000066400000000000000000000213511421473465500222770ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #define KIM_COMPUTE_ARGUMENT_NAME_H_ /* Forward declarations */ #ifndef KIM_DATA_TYPE_DEFINED_ #define KIM_DATA_TYPE_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_DataType KIM_DataType; #endif /** ** \brief \copybrief KIM::ComputeArgumentName ** ** \sa KIM::ComputeArgumentName, ** kim_compute_argument_name_module::kim_compute_argument_name_type ** ** \since 2.0 **/ struct KIM_ComputeArgumentName { /** ** \brief \copybrief KIM::ComputeArgumentName::computeArgumentNameID ** ** \sa KIM::ComputeArgumentName::computeArgumentNameID, ** kim_compute_argument_name_module::kim_compute_argument_name_type::compute_argument_name_id ** ** \since 2.0 **/ int computeArgumentNameID; }; #ifndef KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ #define KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_ComputeArgumentName KIM_ComputeArgumentName; #endif /** ** \brief \copybrief KIM::ComputeArgumentName::ComputeArgumentName(std::string const &) ** ** \sa KIM::ComputeArgumentName::ComputeArgumentName(std::string const &), ** kim_compute_argument_name_module::kim_from_string ** ** \since 2.0 **/ KIM_ComputeArgumentName KIM_ComputeArgumentName_FromString(char const * const str); /** ** \brief \copybrief KIM::ComputeArgumentName::Known ** ** \sa KIM::ComputeArgumentName::Known, ** kim_compute_argument_name_module::kim_known ** ** \since 2.0 **/ int KIM_ComputeArgumentName_Known( KIM_ComputeArgumentName const computeArgumentName); /** ** \brief \copybrief KIM::ComputeArgumentName::operator==() ** ** \sa KIM::ComputeArgumentName::operator==(), ** kim_compute_argument_name_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_ComputeArgumentName_Equal(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs); /** ** \brief \copybrief KIM::ComputeArgumentName::operator!=() ** ** \sa KIM::ComputeArgumentName::operator!=(), ** kim_compute_argument_name_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs); /** ** \brief \copybrief KIM::ComputeArgumentName::ToString ** ** \sa KIM::ComputeArgumentName::ToString, ** kim_compute_argument_name_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ComputeArgumentName_ToString( KIM_ComputeArgumentName const computeArgumentName); /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles, ** kim_compute_argument_name_module::kim_compute_argument_name_number_of_particles ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes, ** kim_compute_argument_name_module::kim_compute_argument_name_particle_species_codes ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::particleContributing ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::particleContributing, ** kim_compute_argument_name_module::kim_compute_argument_name_particle_contributing ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::coordinates ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::coordinates, ** kim_compute_argument_name_module::kim_compute_argument_name_coordinates ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialEnergy ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, ** kim_compute_argument_name_module::kim_compute_argument_name_partial_energy ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialForces ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::partialForces, ** kim_compute_argument_name_module::kim_compute_argument_name_partial_forces ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy, ** kim_compute_argument_name_module::kim_compute_argument_name_partial_particle_energy ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialVirial ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::partialVirial, ** kim_compute_argument_name_module::kim_compute_argument_name_partial_virial ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialVirial; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial, ** kim_compute_argument_name_module::kim_compute_argument_name_partial_particle_virial ** ** \since 2.0 **/ extern KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial; /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames, ** kim_compute_argument_name_module::kim_get_number_of_compute_argument_names ** ** \since 2.0 **/ void KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames( int * const numberOfComputeArgumentNames); /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName, ** kim_compute_argument_name_module::kim_get_compute_argument_name ** ** \since 2.0 **/ int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName( int const index, KIM_ComputeArgumentName * const computeArgumentName); /** ** \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType ** ** \sa KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType, ** kim_compute_argument_name_module::kim_get_compute_argument_data_type ** ** \since 2.0 **/ int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType( KIM_ComputeArgumentName const computeArgumentName, KIM_DataType * const dataType); #endif /* KIM_COMPUTE_ARGUMENT_NAME_H_ */ kim-api-2.3.0-git/c/include/KIM_ComputeArguments.h000066400000000000000000000177761421473465500217010ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COMPUTE_ARGUMENTS_H_ #define KIM_COMPUTE_ARGUMENTS_H_ #ifndef KIM_FUNCTION_TYPES_H_ #include "KIM_FunctionTypes.h" /* IWYU pragma: export */ #endif /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_LANGUAGE_NAME_DEFINED_ #define KIM_LANGUAGE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LanguageName KIM_LanguageName; #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ #define KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeArgumentName KIM_ComputeArgumentName; #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_DEFINED_ #define KIM_COMPUTE_CALLBACK_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeCallbackName KIM_ComputeCallbackName; #endif #ifndef KIM_SUPPORT_STATUS_DEFINED_ #define KIM_SUPPORT_STATUS_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_SupportStatus KIM_SupportStatus; #endif #ifndef KIM_COMPUTE_ARGUMENTS_DEFINED_ #define KIM_COMPUTE_ARGUMENTS_DEFINED_ /** ** \brief \copybrief KIM::ComputeArguments ** ** \sa KIM::ComputeArguments, ** kim_compute_arguments_module::kim_compute_arguments_handle_type ** ** \since 2.0 **/ typedef struct KIM_ComputeArguments KIM_ComputeArguments; #endif /** ** \brief \copybrief KIM::ComputeArguments::GetArgumentSupportStatus ** ** \sa KIM::ComputeArguments::GetArgumentSupportStatus, ** kim_compute_arguments_module::kim_get_argument_support_status ** ** \since 2.0 **/ int KIM_ComputeArguments_GetArgumentSupportStatus( KIM_ComputeArguments const * const computeArguments, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus * const supportStatus); /** ** \brief \copybrief KIM::ComputeArguments::GetCallbackSupportStatus ** ** \sa KIM::ComputeArguments::GetCallbackSupportStatus, ** kim_compute_arguments_module::kim_get_callback_support_status ** ** \since 2.0 **/ int KIM_ComputeArguments_GetCallbackSupportStatus( KIM_ComputeArguments const * const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus * const supportStatus); /** ** \brief \copybrief KIM::ComputeArguments::SetArgumentPointer ** ** \sa KIM::ComputeArguments::SetArgumentPointer, ** kim_compute_arguments_module::kim_set_argument_pointer ** ** \since 2.0 **/ int KIM_ComputeArguments_SetArgumentPointerInteger( KIM_ComputeArguments * const computeArguments, KIM_ComputeArgumentName const computeArgumentName, int const * const ptr); /** ** \brief \copybrief KIM::ComputeArguments::SetArgumentPointer ** ** \sa KIM::ComputeArguments::SetArgumentPointer, ** kim_compute_arguments_module::kim_set_argument_pointer ** ** \since 2.0 **/ int KIM_ComputeArguments_SetArgumentPointerDouble( KIM_ComputeArguments * const computeArguments, KIM_ComputeArgumentName const computeArgumentName, double const * const ptr); /** ** \brief \copybrief KIM::ComputeArguments::SetCallbackPointer ** ** \sa KIM::ComputeArguments::SetCallbackPointer, ** kim_compute_arguments_module::kim_set_callback_pointer ** ** \since 2.0 **/ int KIM_ComputeArguments_SetCallbackPointer( KIM_ComputeArguments * const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_LanguageName const languageName, KIM_Function * const fptr, void * const dataObject); /** ** \brief \copybrief KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent ** ** \sa KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent, ** kim_compute_arguments_module::kim_are_all_required_present ** ** \since 2.0 **/ void KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent( KIM_ComputeArguments const * const computeArguments, int * const result); /** ** \brief \copybrief KIM::ComputeArguments::SetSimulatorBufferPointer ** ** \sa KIM::ComputeArguments::SetSimulatorBufferPointer, ** kim_compute_arguments_module::kim_set_simulator_buffer_pointer ** ** \since 2.0 **/ void KIM_ComputeArguments_SetSimulatorBufferPointer( KIM_ComputeArguments * const computeArguments, void * const ptr); /** ** \brief \copybrief KIM::ComputeArguments::GetSimulatorBufferPointer ** ** \sa KIM::ComputeArguments::GetSimulatorBufferPointer, ** kim_compute_arguments_module::kim_get_simulator_buffer_pointer ** ** \since 2.0 **/ void KIM_ComputeArguments_GetSimulatorBufferPointer( KIM_ComputeArguments const * const computeArguments, void ** const ptr); /** ** \brief \copybrief KIM::ComputeArguments::ToString ** ** \sa KIM::ComputeArguments::ToString, ** kim_compute_arguments_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ComputeArguments_ToString( KIM_ComputeArguments const * const computeArguments); /** ** \brief \copybrief KIM::ComputeArguments::SetLogID ** ** \sa KIM::ComputeArguments::SetLogID, ** kim_compute_arguments_module::kim_set_log_id ** ** \since 2.0 **/ void KIM_ComputeArguments_SetLogID( KIM_ComputeArguments * const computeArguments, char const * const logID); /** ** \brief \copybrief KIM::ComputeArguments::PushLogVerbosity ** ** \sa KIM::ComputeArguments::PushLogVerbosity, ** kim_compute_arguments_module::kim_push_log_verbosity ** ** \since 2.0 **/ void KIM_ComputeArguments_PushLogVerbosity( KIM_ComputeArguments * const computeArguments, KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::ComputeArguments::PopLogVerbosity ** ** \sa KIM::ComputeArguments::PopLogVerbosity, ** kim_compute_arguments_module::kim_pop_log_verbosity ** ** \since 2.0 **/ void KIM_ComputeArguments_PopLogVerbosity( KIM_ComputeArguments * const computeArguments); #endif /* KIM_COMPUTE_ARGUMENTS_H_ */ kim-api-2.3.0-git/c/include/KIM_ComputeCallbackName.h000066400000000000000000000143461421473465500222170ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #define KIM_COMPUTE_CALLBACK_NAME_H_ /** ** \brief \copybrief KIM::ComputeCallbackName ** ** \sa KIM::ComputeCallbackName, ** kim_compute_callback_name_module::kim_compute_callback_name_type ** ** \since 2.0 **/ struct KIM_ComputeCallbackName { /** ** \brief \copybrief KIM::ComputeCallbackName::computeCallbackNameID ** ** \sa KIM::ComputeCallbackName::computeCallbackNameID, ** kim_compute_callback_name_module::kim_compute_callback_name_type::compute_callback_name_id ** ** \since 2.0 **/ int computeCallbackNameID; }; #ifndef KIM_COMPUTE_CALLBACK_NAME_DEFINED_ #define KIM_COMPUTE_CALLBACK_NAME_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_ComputeCallbackName KIM_ComputeCallbackName; #endif /** ** \brief \copybrief KIM::ComputeCallbackName::ComputeCallbackName(std::string const &) ** ** \sa KIM::ComputeCallbackName::ComputeCallbackName(std::string const &), ** kim_compute_callback_name_module::kim_from_string ** ** \since 2.0 **/ KIM_ComputeCallbackName KIM_ComputeCallbackName_FromString(char const * const str); /** ** \brief \copybrief KIM::ComputeCallbackName::Known ** ** \sa KIM::ComputeCallbackName::Known, ** kim_compute_callback_name_module::kim_known ** ** \since 2.0 **/ int KIM_ComputeCallbackName_Known( KIM_ComputeCallbackName const computeCallbackName); /** ** \brief \copybrief KIM::ComputeCallbackName::operator==() ** ** \sa KIM::ComputeCallbackName::operator==(), ** kim_compute_callback_name_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_ComputeCallbackName_Equal(KIM_ComputeCallbackName const lhs, KIM_ComputeCallbackName const rhs); /** ** \brief \copybrief KIM::ComputeCallbackName::operator!=() ** ** \sa KIM::ComputeCallbackName::operator!=(), ** kim_compute_callback_name_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_ComputeCallbackName_NotEqual(KIM_ComputeCallbackName const lhs, KIM_ComputeCallbackName const rhs); /** ** \brief \copybrief KIM::ComputeCallbackName::ToString ** ** \sa KIM::ComputeCallbackName::ToString, ** kim_compute_callback_name_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ComputeCallbackName_ToString( KIM_ComputeCallbackName const computeCallbackName); /** ** \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::GetNeighborList ** ** \sa KIM::COMPUTE_CALLBACK_NAME::GetNeighborList, ** kim_compute_callback_name_module::kim_compute_callback_name_get_neighbor_list ** ** \since 2.0 **/ extern KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_GetNeighborList; /** ** \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm ** ** \sa KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm, ** kim_compute_callback_name_module::kim_compute_callback_name_process_dedr_term ** ** \since 2.0 **/ extern KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm; /** ** \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term ** ** \sa KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term, ** kim_compute_callback_name_module::kim_compute_callback_name_process_d2edr2_term ** ** \since 2.0 **/ extern KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term; /** ** \brief \copybrief kim_model_compute_arguments_get_neighbor_list ** ** \since 2.0 **/ typedef int KIM_GetNeighborListFunction(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle); /** ** \brief \copybrief KIM::ProcessDEDrTermFunction ** ** \sa KIM::ProcessDEDrTermFunction, kim_model_compute_arguments_module::kim_model_compute_arguments_process_dedr_term ** ** \since 2.0 **/ typedef int KIM_ProcessDEDrTermFunction(void * const dataObject, double const de, double const r, double const * const dx, int const i, int const j); /** ** \brief \copybrief KIM::ProcessD2EDr2TermFunction ** ** \sa KIM::ProcessD2EDr2TermFunction, ** kim_model_compute_arguments_module::kim_model_compute_arguments_process_d2edr2_term ** ** \since 2.0 **/ typedef int KIM_ProcessD2EDr2TermFunction(void * const dataObject, double const de, double const * const r, double const * const dx, int const * const i, int const * const j); /** ** \brief \copybrief KIM::ModelExtensionFunction ** ** \sa KIM::ModelExtensionFunction, kim_model_module::kim_model_extension ** ** \since 2.0 **/ typedef int KIM_ModelExtensionFunction(KIM_ModelExtension * const modelExtension, void * const extensionStructure); /** ** \brief \copybrief KIM::ModelRefreshFunction ** ** \sa KIM::ModelRefreshFunction, ** kim_model_module::kim_model_clear_then_refresh ** ** \since 2.0 **/ typedef int KIM_ModelRefreshFunction(KIM_ModelRefresh * const modelRefresh); /** ** \brief \copybrief KIM::ModelWriteParameterizedModelFunction ** ** \sa KIM::ModelWriteParameterizedModelFunction, kim_model_module::kim_model_compute_arguments_destroy ** ** \since 2.0 **/ typedef int KIM_ModelComputeArgumentsDestroyFunction( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); /** ** \brief \copybrief KIM::ModelDestroyFunction ** ** \sa KIM::ModelDestroyFunction, kim_model_module::kim_model_destroy ** ** \since 2.0 **/ typedef int KIM_ModelDestroyFunction(KIM_ModelDestroy * const modelDestroy); /** ** \brief \copybrief KIM::LogPrintFunction ** ** \sa KIM::LogPrintFunction, ** kim_log_module::kim_log_push_default_print_function ** ** \since 2.2 **/ typedef int KIM_LogPrintFunction(char const * const entryString); #endif /* KIM_FUNCTION_TYPES_H_ */ kim-api-2.3.0-git/c/include/KIM_LanguageName.h000066400000000000000000000125521421473465500207060ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_LANGUAGE_NAME_H_ #define KIM_LANGUAGE_NAME_H_ /** ** \brief \copybrief KIM::LanguageName ** ** \sa KIM::LanguageName, kim_language_name_module::kim_language_name_type ** ** \since 2.0 **/ struct KIM_LanguageName { /** ** \brief \copybrief KIM::LanguageName::languageNameID ** ** \sa KIM::LanguageName::languageNameID, ** kim_language_name_module::kim_language_name_type::language_name_id ** ** \since 2.0 **/ int languageNameID; }; #ifndef KIM_LANGUAGE_NAME_DEFINED_ #define KIM_LANGUAGE_NAME_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_LanguageName KIM_LanguageName; #endif /** ** \brief \copybrief KIM::LanguageName::LanguageName(std::string const &) ** ** \sa KIM::LanguageName::LanguageName(std::string const &), ** kim_language_name_module::kim_from_string ** ** \since 2.0 **/ KIM_LanguageName KIM_LanguageName_FromString(char const * const str); /** ** \brief \copybrief KIM::LanguageName::Known ** ** \sa KIM::LanguageName::Known, kim_language_name_module::kim_known ** ** \since 2.0 **/ int KIM_LanguageName_Known(KIM_LanguageName const languageName); /** ** \brief \copybrief KIM::LanguageName::operator==() ** ** \sa KIM::LanguageName::operator==(), ** kim_language_name_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_LanguageName_Equal(KIM_LanguageName const lhs, KIM_LanguageName const rhs); /** ** \brief \copybrief KIM::LanguageName::operator!=() ** ** \sa KIM::LanguageName::operator!=(), ** kim_language_name_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_LanguageName_NotEqual(KIM_LanguageName const lhs, KIM_LanguageName const rhs); /** ** \brief \copybrief KIM::LanguageName::ToString ** ** \sa KIM::LanguageName::ToString, kim_language_name_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_LanguageName_ToString(KIM_LanguageName const languageName); /** ** \brief \copybrief KIM::LANGUAGE_NAME::cpp ** ** \sa KIM::LANGUAGE_NAME::cpp, ** kim_language_name_module::kim_language_name_cpp ** ** \since 2.0 **/ extern KIM_LanguageName const KIM_LANGUAGE_NAME_cpp; /** ** \brief \copybrief KIM::LANGUAGE_NAME::c ** ** \sa KIM::LANGUAGE_NAME::c, kim_language_name_module::kim_language_name_c ** ** \since 2.0 **/ extern KIM_LanguageName const KIM_LANGUAGE_NAME_c; /** ** \brief \copybrief KIM::LANGUAGE_NAME::fortran ** ** \sa KIM::LANGUAGE_NAME::fortran, ** kim_language_name_module::kim_language_name_fortran ** ** \since 2.0 **/ extern KIM_LanguageName const KIM_LANGUAGE_NAME_fortran; /** ** \brief \copybrief KIM::LANGUAGE_NAME::GetNumberOfLanguageNames ** ** \sa KIM::LANGUAGE_NAME::GetNumberOfLanguageNames, ** kim_language_name_module::kim_get_number_of_language_names ** ** \since 2.0 **/ void KIM_LANGUAGE_NAME_GetNumberOfLanguageNames( int * const numberOfLanguageNames); /** ** \brief \copybrief KIM::LANGUAGE_NAME::GetLanguageName ** ** \sa KIM::LANGUAGE_NAME::GetLanguageName, ** kim_language_name_module::kim_get_language_name ** ** \since 2.0 **/ int KIM_LANGUAGE_NAME_GetLanguageName(int const index, KIM_LanguageName * const languageName); #endif /* KIM_LANGUAGE_NAME_H_ */ kim-api-2.3.0-git/c/include/KIM_LengthUnit.h000066400000000000000000000132671421473465500204470ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_LENGTH_UNIT_H_ #define KIM_LENGTH_UNIT_H_ /** ** \brief \copybrief KIM::LengthUnit ** ** \sa KIM::LengthUnit, kim_length_unit_module::kim_length_unit_type ** ** \since 2.0 **/ struct KIM_LengthUnit { /** ** \brief \copybrief KIM::LengthUnit::lengthUnitID ** ** \sa KIM::LengthUnit::lengthUnitID, ** kim_length_unit_module::kim_length_unit_type::length_unit_id ** ** \since 2.0 **/ int lengthUnitID; }; #ifndef KIM_LENGTH_UNIT_DEFINED_ #define KIM_LENGTH_UNIT_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_LengthUnit KIM_LengthUnit; #endif /** ** \brief \copybrief KIM::LengthUnit::LengthUnit(std::string const &) ** ** \sa KIM::LengthUnit::LengthUnit(std::string const &), ** kim_length_unit_module::kim_from_string ** ** \since 2.0 **/ KIM_LengthUnit KIM_LengthUnit_FromString(char const * const str); /** ** \brief \copybrief KIM::LengthUnit::Known ** ** \sa KIM::LengthUnit::Known, kim_length_unit_module::kim_known ** ** \since 2.0 **/ int KIM_LengthUnit_Known(KIM_LengthUnit const lengthUnit); /** ** \brief \copybrief KIM::LengthUnit::operator==() ** ** \sa KIM::LengthUnit::operator==(), kim_length_unit_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_LengthUnit_Equal(KIM_LengthUnit const lhs, KIM_LengthUnit const rhs); /** ** \brief \copybrief KIM::LengthUnit::operator!=() ** ** \sa KIM::LengthUnit::operator!=(), kim_length_unit_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_LengthUnit_NotEqual(KIM_LengthUnit const lhs, KIM_LengthUnit const rhs); /** ** \brief \copybrief KIM::LengthUnit::ToString ** ** \sa KIM::LengthUnit::ToString, kim_length_unit_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_LengthUnit_ToString(KIM_LengthUnit const lengthUnit); /** ** \brief \copybrief KIM::LENGTH_UNIT::unused ** ** \sa KIM::LENGTH_UNIT::unused, ** kim_length_unit_module::kim_length_unit_unused ** ** \since 2.0 **/ extern KIM_LengthUnit const KIM_LENGTH_UNIT_unused; /** ** \brief \copybrief KIM::LENGTH_UNIT::A ** ** \sa KIM::LENGTH_UNIT::A, kim_length_unit_module::kim_length_unit_a ** ** \since 2.0 **/ extern KIM_LengthUnit const KIM_LENGTH_UNIT_A; /** ** \brief \copybrief KIM::LENGTH_UNIT::Bohr ** ** \sa KIM::LENGTH_UNIT::Bohr, kim_length_unit_module::kim_length_unit_bohr ** ** \since 2.0 **/ extern KIM_LengthUnit const KIM_LENGTH_UNIT_Bohr; /** ** \brief \copybrief KIM::LENGTH_UNIT::cm ** ** \sa KIM::LENGTH_UNIT::cm, kim_length_unit_module::kim_length_unit_cm ** ** \since 2.0 **/ extern KIM_LengthUnit const KIM_LENGTH_UNIT_cm; /** ** \brief \copybrief KIM::LENGTH_UNIT::m ** ** \sa KIM::LENGTH_UNIT::m, kim_length_unit_module::kim_length_unit_m ** ** \since 2.0 **/ extern KIM_LengthUnit const KIM_LENGTH_UNIT_m; /** ** \brief \copybrief KIM::LENGTH_UNIT::nm ** ** \sa KIM::LENGTH_UNIT::nm, kim_length_unit_module::kim_length_unit_nm ** ** \since 2.0 **/ extern KIM_LengthUnit const KIM_LENGTH_UNIT_nm; /** ** \brief \copybrief KIM::LENGTH_UNIT::GetNumberOfLengthUnits ** ** \sa KIM::LENGTH_UNIT::GetNumberOfLengthUnits, ** kim_length_unit_module::kim_get_number_of_length_units ** ** \since 2.0 **/ void KIM_LENGTH_UNIT_GetNumberOfLengthUnits(int * const numberOfLengthUnits); /** ** \brief \copybrief KIM::LENGTH_UNIT::GetLengthUnit ** ** \sa KIM::LENGTH_UNIT::GetLengthUnit, ** kim_length_unit_module::kim_get_length_unit ** ** \since 2.0 **/ int KIM_LENGTH_UNIT_GetLengthUnit(int const index, KIM_LengthUnit * const lengthUnit); #endif /* KIM_LENGTH_UNIT_H_ */ kim-api-2.3.0-git/c/include/KIM_Log.h000066400000000000000000000126061421473465500171030ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_LOG_H_ #define KIM_LOG_H_ #ifndef KIM_FUNCTION_TYPES_H_ #include "KIM_FunctionTypes.h" /* IWYU pragma: export */ #endif /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_LANGUAGE_NAME_DEFINED_ #define KIM_LANGUAGE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.2 **/ typedef struct KIM_LanguageName KIM_LanguageName; #endif #ifndef KIM_LOG_DEFINED_ #define KIM_LOG_DEFINED_ /** ** \brief \copybrief KIM::Log ** ** \sa KIM::Log, kim_log_module::kim_log_handle_type ** ** \since 2.0 **/ typedef struct KIM_Log KIM_Log; #endif /** ** \brief \copybrief KIM::Log::Create ** ** \sa KIM::Log::Create, kim_log_module::kim_log_create ** ** \since 2.0 **/ int KIM_Log_Create(KIM_Log ** const log); /** ** \brief \copybrief KIM::Log::Destroy ** ** \sa KIM::Log::Destroy, kim_log_module::kim_log_destroy ** ** \since 2.0 **/ void KIM_Log_Destroy(KIM_Log ** const log); /** ** \brief \copybrief KIM::Log::PushDefaultVerbosity ** ** \sa KIM::Log::PushDefaultVerbosity, ** kim_log_module::kim_push_default_verbosity ** ** \since 2.0 **/ void KIM_Log_PushDefaultVerbosity(KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::Log::PopDefaultVerbosity ** ** \sa KIM::Log::PopDefaultVerbosity, ** kim_log_module::kim_pop_default_verbosity ** ** \since 2.0 **/ void KIM_Log_PopDefaultVerbosity(); /** ** \brief \copybrief KIM::Log::PushDefaultPrintFunction ** ** \sa KIM::Log::PushDefaultPrintFunction, ** kim_log_module::kim_push_default_print_function ** ** \since 2.2 **/ void KIM_Log_PushDefaultPrintFunction(KIM_LanguageName const languageName, KIM_Function * const fptr); /** ** \brief \copybrief KIM::Log::PopDefaultPrintFunction ** ** \sa KIM::Log::PopDefaultPrintFunction, ** kim_log_module::kim_pop_default_print_function ** ** \since 2.2 **/ void KIM_Log_PopDefaultPrintFunction(); /** ** \brief \copybrief KIM::Log::GetID ** ** \sa KIM::Log::GetID, kim_log_module::kim_get_id ** ** \since 2.0 **/ char const * KIM_Log_GetID(KIM_Log const * const log); /** ** \brief \copybrief KIM::Log::SetID ** ** \sa KIM::Log::SetID, kim_log_module::kim_set_id ** ** \since 2.0 **/ void KIM_Log_SetID(KIM_Log * const log, char const * const id); /** ** \brief \copybrief KIM::Log::PushVerbosity ** ** \sa KIM::Log::PushVerbosity, kim_log_module::kim_push_verbosity ** ** \since 2.0 **/ void KIM_Log_PushVerbosity(KIM_Log * const log, KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::Log::PopVerbosity ** ** \sa KIM::Log::PopVerbosity, kim_log_module::kim_pop_verbosity ** ** \since 2.0 **/ void KIM_Log_PopVerbosity(KIM_Log * const log); /** ** \brief \copybrief KIM::Log::LogEntry ** ** \sa KIM::Log::LogEntry, kim_log_module::kim_log_entry ** ** \since 2.0 **/ void KIM_Log_LogEntry(KIM_Log const * const log, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); #endif /* KIM_LOG_H_ */ kim-api-2.3.0-git/c/include/KIM_LogMacros.h000066400000000000000000000133561421473465500202530ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #undef FATAL_VERBOSITY /** ** \brief Defined if FATAL Log entries are to be compiled. **/ #define FATAL_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_FATAL_) #undef LOG_FATAL #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_FATAL_) /** ** \def LOG_FATAL(message) ** \brief Convenience macro for FATAL Log entries with compile-time ** optimization. **/ #define LOG_FATAL(message) \ KIM_LOGGER_FUNCTION_NAME(KIM_LOGGER_OBJECT_NAME, \ KIM_LOG_VERBOSITY_fatal, \ message, \ __LINE__, \ __FILE__) #else #define LOG_FATAL(message) #endif #undef ERROR_VERBOSITY /** ** \brief Defined if ERROR Log entries are to be compiled. **/ #define ERROR_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_ERROR_) #undef LOG_ERROR #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_ERROR_) /** ** \def LOG_ERROR(message) ** \brief Convenience macro for ERROR Log entries with compile-time ** optimization. **/ #define LOG_ERROR(message) \ KIM_LOGGER_FUNCTION_NAME(KIM_LOGGER_OBJECT_NAME, \ KIM_LOG_VERBOSITY_error, \ message, \ __LINE__, \ __FILE__) #else #define LOG_ERROR(message) #endif #undef WARNING_VERBOSITY /** ** \brief Defined if WARNING Log entries are to be compiled. **/ #define WARNING_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_WARNING_) #undef LOG_WARNING #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_WARNING_) /** ** \def LOG_WARNING(message) ** \brief Convenience macro for WARNING Log entries with compile-time ** optimization. **/ #define LOG_WARNING(message) \ KIM_LOGGER_FUNCTION_NAME(KIM_LOGGER_OBJECT_NAME, \ KIM_LOG_VERBOSITY_warning, \ message, \ __LINE__, \ __FILE__) #else #define LOG_WARNING(message) #endif #undef INFORMATION_VERBOSITY /** ** \brief Defined if INFORMATION Log entries are to be compiled. **/ #define INFORMATION_VERBOSITY \ (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_INFORMATION_) #undef LOG_INFORMATION #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_INFORMATION_) /** ** \def LOG_INFORMATION(message) ** \brief Convenience macro for INFORMATION Log entries with compile-time ** optimization. **/ #define LOG_INFORMATION(message) \ KIM_LOGGER_FUNCTION_NAME(KIM_LOGGER_OBJECT_NAME, \ KIM_LOG_VERBOSITY_information, \ message, \ __LINE__, \ __FILE__) #else #define LOG_INFORMATION(message) #endif #undef DEBUG_VERBOSITY /** ** \brief Defined if DEBUG Log entries are to be compiled. **/ #define DEBUG_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_DEBUG_) #undef LOG_DEBUG #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_DEBUG_) /** ** \def LOG_DEBUG(message) ** \brief Convenience macro for DEBUG Log entries with compile-time ** optimization. **/ #define LOG_DEBUG(message) \ KIM_LOGGER_FUNCTION_NAME(KIM_LOGGER_OBJECT_NAME, \ KIM_LOG_VERBOSITY_debug, \ message, \ __LINE__, \ __FILE__) #else #define LOG_DEBUG(message) #endif kim-api-2.3.0-git/c/include/KIM_LogVerbosity.h000066400000000000000000000163571421473465500210210ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_LOG_VERBOSITY_H_ #define KIM_LOG_VERBOSITY_H_ /** ** \brief \copybrief KIM::LogVerbosity ** ** \sa KIM::LogVerbosity, kim_log_verbosity_module::kim_log_verbosity_type ** ** \since 2.0 **/ struct KIM_LogVerbosity { /** ** \brief \copybrief KIM::LogVerbosity::logVerbosityID ** ** \sa KIM::LogVerbosity::logVerbosityID, ** kim_log_verbosity_module::kim_log_verbosity_type::log_verbosity_id ** ** \since 2.0 **/ int logVerbosityID; }; #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif /** ** \brief \copybrief KIM::LogVerbosity::LogVerbosity(std::string const &) ** ** \sa KIM::LogVerbosity::LogVerbosity(std::string const &), ** kim_log_verbosity_module::kim_from_string ** ** \since 2.0 **/ KIM_LogVerbosity KIM_LogVerbosity_FromString(char const * const str); /** ** \brief \copybrief KIM::LogVerbosity::Known ** ** \sa KIM::LogVerbosity::Known, kim_log_verbosity_module::kim_known ** ** \since 2.0 **/ int KIM_LogVerbosity_Known(KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::LogVerbosity::operator<() ** ** \sa KIM::LogVerbosity::operator<(), ** kim_log_verbosity_module::operator(.lt.) ** ** \since 2.0 **/ int KIM_LogVerbosity_LessThan(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs); /** ** \brief \copybrief KIM::LogVerbosity::operator>() ** ** \sa KIM::LogVerbosity::operator>(), ** kim_log_verbosity_module::operator(.gt.) ** ** \since 2.0 **/ int KIM_LogVerbosity_GreaterThan(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs); /** ** \brief \copybrief KIM::LogVerbosity::operator<=() ** ** \sa KIM::LogVerbosity::operator<=(), ** kim_log_verbosity_module::operator(.le.) ** ** \since 2.0 **/ int KIM_LogVerbosity_LessThanEqual(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs); /** ** \brief \copybrief KIM::LogVerbosity::operator>=() ** ** \sa KIM::LogVerbosity::operator>=(), ** kim_log_verbosity_module::operator(.ge.) ** ** \since 2.0 **/ int KIM_LogVerbosity_GreaterThanEqual(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs); /** ** \brief \copybrief KIM::LogVerbosity::operator==() ** ** \sa KIM::LogVerbosity::operator==(), ** kim_log_verbosity_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_LogVerbosity_Equal(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs); /** ** \brief \copybrief KIM::LogVerbosity::operator!=() ** ** \sa KIM::LogVerbosity::operator!=(), ** kim_log_verbosity_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_LogVerbosity_NotEqual(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs); /** ** \brief \copybrief KIM::LogVerbosity::ToString ** ** \sa KIM::LogVerbosity::ToString, kim_log_verbosity_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_LogVerbosity_ToString(KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::LOG_VERBOSITY::silent ** ** \sa KIM::LOG_VERBOSITY::silent, ** kim_log_verbosity_module::kim_log_verbosity_silent ** ** \since 2.0 **/ extern KIM_LogVerbosity const KIM_LOG_VERBOSITY_silent; /** ** \brief \copybrief KIM::LOG_VERBOSITY::fatal ** ** \sa KIM::LOG_VERBOSITY::fatal, ** kim_log_verbosity_module::kim_log_verbosity_fatal ** ** \since 2.0 **/ extern KIM_LogVerbosity const KIM_LOG_VERBOSITY_fatal; /** ** \brief \copybrief KIM::LOG_VERBOSITY::error ** ** \sa KIM::LOG_VERBOSITY::error, ** kim_log_verbosity_module::kim_log_verbosity_error ** ** \since 2.0 **/ extern KIM_LogVerbosity const KIM_LOG_VERBOSITY_error; /** ** \brief \copybrief KIM::LOG_VERBOSITY::warning ** ** \sa KIM::LOG_VERBOSITY::warning, ** kim_log_verbosity_module::kim_log_verbosity_warning ** ** \since 2.0 **/ extern KIM_LogVerbosity const KIM_LOG_VERBOSITY_warning; /** ** \brief \copybrief KIM::LOG_VERBOSITY::information ** ** \sa KIM::LOG_VERBOSITY::information, ** kim_log_verbosity_module::kim_log_verbosity_information ** ** \since 2.0 **/ extern KIM_LogVerbosity const KIM_LOG_VERBOSITY_information; /** ** \brief \copybrief KIM::LOG_VERBOSITY::debug ** ** \sa KIM::LOG_VERBOSITY::debug, ** kim_log_verbosity_module::kim_log_verbosity_debug ** ** \since 2.0 **/ extern KIM_LogVerbosity const KIM_LOG_VERBOSITY_debug; /** ** \brief \copybrief KIM::LOG_VERBOSITY::GetNumberOfLogVerbosities ** ** \sa KIM::LOG_VERBOSITY::GetNumberOfLogVerbosities, ** kim_log_verbosity_module::kim_get_number_of_log_verbosities ** ** \since 2.0 **/ void KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities( int * const numberOfLogVerbosities); /** ** \brief \copybrief KIM::LOG_VERBOSITY::GetLogVerbosity ** ** \sa KIM::LOG_VERBOSITY::GetLogVerbosity, ** kim_log_verbosity_module::kim_get_log_verbosity ** ** \since 2.0 **/ int KIM_LOG_VERBOSITY_GetLogVerbosity(int const index, KIM_LogVerbosity * const logVerbosity); #endif /* KIM_LOG_VERBOSITY_H_ */ kim-api-2.3.0-git/c/include/KIM_Model.h000066400000000000000000000327271421473465500174300ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_H_ #define KIM_MODEL_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_DATA_TYPE_DEFINED_ #define KIM_DATA_TYPE_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_DataType KIM_DataType; #endif #ifndef KIM_MODEL_ROUTINE_NAME_DEFINED_ #define KIM_MODEL_ROUTINE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelRoutineName KIM_ModelRoutineName; #endif #ifndef KIM_SPECIES_NAME_DEFINED_ #define KIM_SPECIES_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_SpeciesName KIM_SpeciesName; #endif #ifndef KIM_NUMBERING_DEFINED_ #define KIM_NUMBERING_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_Numbering KIM_Numbering; #endif #ifndef KIM_LENGTH_UNIT_DEFINED_ #define KIM_LENGTH_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LengthUnit KIM_LengthUnit; #endif #ifndef KIM_ENERGY_UNIT_DEFINED_ #define KIM_ENERGY_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_EnergyUnit KIM_EnergyUnit; #endif #ifndef KIM_CHARGE_UNIT_DEFINED_ #define KIM_CHARGE_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ChargeUnit KIM_ChargeUnit; #endif #ifndef KIM_TEMPERATURE_UNIT_DEFINED_ #define KIM_TEMPERATURE_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_TemperatureUnit KIM_TemperatureUnit; #endif #ifndef KIM_TIME_UNIT_DEFINED_ #define KIM_TIME_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_TimeUnit KIM_TimeUnit; #endif #ifndef KIM_COMPUTE_ARGUMENTS_DEFINED_ #define KIM_COMPUTE_ARGUMENTS_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeArguments KIM_ComputeArguments; #endif #ifndef KIM_MODEL_DEFINED_ #define KIM_MODEL_DEFINED_ /** ** \brief \copybrief KIM::Model ** ** \sa KIM::Model, kim_model_module::kim_model_handle_type ** ** \since 2.0 **/ typedef struct KIM_Model KIM_Model; #endif /** ** \brief \copybrief KIM::Model::Create ** ** \sa KIM::Model::Create, kim_model_module::kim_model_create ** ** \since 2.0 **/ int KIM_Model_Create(KIM_Numbering const numbering, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit, char const * const modelName, int * const requestedUnitsAccepted, KIM_Model ** const model); /** ** \brief \copybrief KIM::Model::Destroy ** ** \sa KIM::Model::Destroy, kim_model_module::kim_model_destroy ** ** \since 2.0 **/ void KIM_Model_Destroy(KIM_Model ** const model); /** ** \brief \copybrief KIM::Model::IsRoutinePresent ** ** \sa KIM::Model::IsRoutinePresent, kim_model_module::kim_is_routine_present ** ** \since 2.0 **/ int KIM_Model_IsRoutinePresent(KIM_Model const * const model, KIM_ModelRoutineName const modelRoutineName, int * const present, int * const required); /** ** \brief \copybrief KIM::Model::GetInfluenceDistance ** ** \sa KIM::Model::GetInfluenceDistance, ** kim_model_module::kim_get_influence_distance ** ** \since 2.0 **/ void KIM_Model_GetInfluenceDistance(KIM_Model const * const model, double * const influenceDistance); /** ** \brief \copybrief KIM::Model::GetNeighborListPointers ** ** \sa KIM::Model::GetNeighborListPointers, ** kim_model_module::kim_get_number_of_neighbor_lists, ** kim_model_module::kim_get_neighbor_list_values ** ** \since 2.0 **/ void KIM_Model_GetNeighborListPointers( KIM_Model const * const model, int * const numberOfNeighborLists, double const ** const cutoffs, int const ** const modelWillNotRequestNeighborsOfNoncontributingParticles); /** ** \brief \copybrief KIM::Model::GetUnits ** ** \sa KIM::Model::GetUnits, kim_model_module::kim_get_units ** ** \since 2.0 **/ void KIM_Model_GetUnits(KIM_Model const * const model, KIM_LengthUnit * const lengthUnit, KIM_EnergyUnit * const energyUnit, KIM_ChargeUnit * const chargeUnit, KIM_TemperatureUnit * const temperatureUnit, KIM_TimeUnit * const timeUnit); /** ** \brief \copybrief KIM::Model::ComputeArgumentsCreate ** ** \sa KIM::Model::ComputeArgumentsCreate, ** kim_model_module::kim_compute_arguments_create ** ** \since 2.0 **/ int KIM_Model_ComputeArgumentsCreate( KIM_Model const * const model, KIM_ComputeArguments ** const computeArguments); /** ** \brief \copybrief KIM::Model::ComputeArgumentsDestroy ** ** \sa KIM::Model::ComputeArgumentsDestroy, ** kim_model_module::kim_compute_arguments_destroy ** ** \since 2.0 **/ int KIM_Model_ComputeArgumentsDestroy( KIM_Model const * const model, KIM_ComputeArguments ** const computeArguments); /** ** \brief \copybrief KIM::Model::Compute ** ** \sa KIM::Model::Compute, kim_model_module::kim_compute ** ** \since 2.0 **/ int KIM_Model_Compute(KIM_Model const * const model, KIM_ComputeArguments const * const computeArguments); /** ** \brief \copybrief KIM::Model::Extension ** ** \sa KIM::Model::Extension, kim_model_module::kim_extension ** ** \since 2.0 **/ int KIM_Model_Extension(KIM_Model * const model, char const * const extensionID, void * const extensionStructure); /** ** \brief \copybrief KIM::Model::ClearThenRefresh ** ** \sa KIM::Model::ClearThenRefresh, kim_model_module::kim_clear_then_refresh ** ** \since 2.0 **/ int KIM_Model_ClearThenRefresh(KIM_Model * const model); /** ** \brief \copybrief KIM::Model::WriteParameterizedModel ** ** \sa KIM::Model::WriteParameterizedModel, ** kim_model_module::kim_write_parameterized_model ** ** \since 2.0 **/ int KIM_Model_WriteParameterizedModel(KIM_Model const * const model, char const * const path, char const * const modelName); /** ** \brief \copybrief KIM::Model::GetSpeciesSupportAndCode ** ** \sa KIM::Model::GetSpeciesSupportAndCode, ** kim_model_module::kim_get_species_support_and_code ** ** \since 2.0 **/ int KIM_Model_GetSpeciesSupportAndCode(KIM_Model const * const model, KIM_SpeciesName const speciesName, int * const speciesIsSupported, int * const code); /** ** \brief \copybrief KIM::Model::GetNumberOfParameters ** ** \sa KIM::Model::GetNumberOfParameters, ** kim_model_module::kim_get_number_of_parameters ** ** \since 2.0 **/ void KIM_Model_GetNumberOfParameters(KIM_Model const * const model, int * const numberOfParameters); /** ** \brief \copybrief KIM::Model::GetParameterMetadata ** ** \sa KIM::Model::GetParameterMetadata, ** kim_model_module::kim_get_parameter_metadata ** ** \since 2.0 **/ int KIM_Model_GetParameterMetadata(KIM_Model const * const model, int const parameterIndex, KIM_DataType * const dataType, int * const extent, char const ** const name, char const ** const description); /** ** \brief \copybrief KIM::Model::GetParameter(int const, int const, ** int * const) const ** ** \sa KIM::Model::GetParameter(int const,int const, int * const) const, ** kim_model_module::kim_get_parameter ** ** \since 2.0 **/ int KIM_Model_GetParameterInteger(KIM_Model const * const model, int const parameterIndex, int const arrayIndex, int * const parameterValue); /** ** \brief \copybrief KIM::Model::GetParameter(int const, int const, ** int * const) const ** ** \sa KIM::Model::GetParameter(int const,int const, double * const) const, ** kim_model_module::kim_get_parameter ** ** \since 2.0 **/ int KIM_Model_GetParameterDouble(KIM_Model const * const model, int const parameterIndex, int const arrayIndex, double * const parameterValue); /** ** \brief \copybrief KIM::Model::SetParameter(int const, int const, int const) ** ** \sa KIM::Model::SetParameter(int const, int const, int const), ** kim_model_module::kim_set_parameter ** ** \since 2.0 **/ int KIM_Model_SetParameterInteger(KIM_Model * const model, int const parameterIndex, int const arrayIndex, int const parameterValue); /** ** \brief \copybrief KIM::Model::SetParameter(int const, int const, int const) ** ** \sa KIM::Model::SetParameter(int const, int const, double const), ** kim_model_module::kim_set_parameter ** ** \since 2.0 **/ int KIM_Model_SetParameterDouble(KIM_Model * const model, int const parameterIndex, int const arrayIndex, double const parameterValue); /** ** \brief \copybrief KIM::Model::SetSimulatorBufferPointer ** ** \sa KIM::Model::SetSimulatorBufferPointer, ** kim_model_module::kim_set_simulator_buffer_pointer ** ** \since 2.0 **/ void KIM_Model_SetSimulatorBufferPointer(KIM_Model * const model, void * const ptr); /** ** \brief \copybrief KIM::Model::GetSimulatorBufferPointer ** ** \sa KIM::Model::GetSimulatorBufferPointer, ** kim_model_module::kim_get_simulator_buffer_pointer ** ** \since 2.0 **/ void KIM_Model_GetSimulatorBufferPointer(KIM_Model const * const model, void ** const ptr); /** ** \brief \copybrief KIM::Model::ToString ** ** \sa KIM::Model::ToString, kim_model_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_Model_ToString(KIM_Model const * const model); /** ** \brief \copybrief KIM::Model::SetLogID ** ** \sa KIM::Model::SetLogID, kim_model_module::kim_set_log_id ** ** \since 2.0 **/ void KIM_Model_SetLogID(KIM_Model * const model, char const * const logID); /** ** \brief \copybrief KIM::Model::PushLogVerbosity ** ** \sa KIM::Model::PushLogVerbosity, kim_model_module::kim_push_log_verbosity ** ** \since 2.0 **/ void KIM_Model_PushLogVerbosity(KIM_Model * const model, KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::Model::PopLogVerbosity ** ** \sa KIM::Model::PopLogVerbosity, kim_model_module::kim_pop_log_verbosity ** ** \since 2.0 **/ void KIM_Model_PopLogVerbosity(KIM_Model * const model); #endif /* KIM_MODEL_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelCompute.h000066400000000000000000000073611421473465500207610ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_COMPUTE_H_ #define KIM_MODEL_COMPUTE_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_MODEL_COMPUTE_DEFINED_ #define KIM_MODEL_COMPUTE_DEFINED_ /** ** \brief \copybrief KIM::ModelCompute ** ** \sa KIM::ModelCompute, *kim_model_compute_module::kim_model_compute_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelCompute KIM_ModelCompute; #endif /** ** \brief \copybrief KIM::ModelCompute::GetModelBufferPointer ** ** \sa KIM::ModelCompute::GetModelBufferPointer, ** kim_model_compute_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelCompute_GetModelBufferPointer( KIM_ModelCompute const * const modelCompute, void ** const ptr); /** ** \brief \copybrief KIM::ModelCompute::LogEntry ** ** \sa KIM::ModelCompute::LogEntry, kim_model_compute_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelCompute_LogEntry(KIM_ModelCompute const * const modelCompute, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelCompute::ToString ** ** \sa KIM::ModelCompute::ToString, kim_model_compute_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelCompute_ToString(KIM_ModelCompute const * const modelCompute); #endif /* KIM_MODEL_COMPUTE_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelComputeArguments.h000066400000000000000000000164351421473465500226510ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_H_ #define KIM_MODEL_COMPUTE_ARGUMENTS_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ #define KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeArgumentName KIM_ComputeArgumentName; #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_DEFINED_ #define KIM_COMPUTE_CALLBACK_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeCallbackName KIM_ComputeCallbackName; #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DEFINED_ #define KIM_MODEL_COMPUTE_ARGUMENTS_DEFINED_ /** ** \brief \copybrief KIM::ModelComputeArguments ** ** \sa KIM::ModelComputeArguments, ** kim_model_compute_arguments_module::kim_model_compute_arguments_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelComputeArguments KIM_ModelComputeArguments; #endif /** ** \brief \copybrief KIM::ModelComputeArguments::GetNeighborList ** ** \sa KIM::ModelComputeArguments::GetNeighborList, ** kim_model_compute_arguments_module::kim_get_neighbor_list ** ** \since 2.0 **/ int KIM_ModelComputeArguments_GetNeighborList( KIM_ModelComputeArguments const * const modelComputeArguments, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle); /** ** \brief \copybrief KIM::ModelComputeArguments::ProcessDEDrTerm ** ** \sa KIM::ModelComputeArguments::ProcessDEDrTerm, ** kim_model_compute_arguments_module::kim_process_dedr_term ** ** \since 2.0 **/ int KIM_ModelComputeArguments_ProcessDEDrTerm( KIM_ModelComputeArguments const * const modelComputeArguments, double const de, double const r, double const * const dx, int const i, int const j); /** ** \brief \copybrief KIM::ModelComputeArguments::ProcessD2EDr2Term ** ** \sa KIM::ModelComputeArguments::ProcessD2EDr2Term, ** kim_model_compute_arguments_module::kim_process_d2edr2_term ** ** \since 2.0 **/ int KIM_ModelComputeArguments_ProcessD2EDr2Term( KIM_ModelComputeArguments const * const modelComputeArguments, double const de, double const * const r, double const * const dx, int const * const i, int const * const j); /** ** \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer ** ** \sa KIM::ModelComputeArguments::GetArgumentPointer, ** kim_model_compute_arguments_module::kim_get_argument_pointer ** ** \since 2.0 **/ int KIM_ModelComputeArguments_GetArgumentPointerInteger( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, int ** const ptr); /** ** \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer ** ** \sa KIM::ModelComputeArguments::GetArgumentPointer, ** kim_model_compute_arguments_module::kim_get_argument_pointer ** ** \since 2.0 **/ int KIM_ModelComputeArguments_GetArgumentPointerDouble( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, double ** const ptr); /** ** \brief \copybrief KIM::ModelComputeArguments::IsCallbackPresent ** ** \sa KIM::ModelComputeArguments::IsCallbackPresent, ** kim_model_compute_arguments_module::kim_is_callback_present ** ** \since 2.0 **/ int KIM_ModelComputeArguments_IsCallbackPresent( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_ComputeCallbackName const computeCallbackName, int * const present); /** ** \brief \copybrief KIM::ModelComputeArguments::SetModelBufferPointer ** ** \sa KIM::ModelComputeArguments::SetModelBufferPointer, ** kim_model_compute_arguments_module::kim_set_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelComputeArguments_SetModelBufferPointer( KIM_ModelComputeArguments * const modelComputeArguments, void * const ptr); /** ** \brief \copybrief KIM::ModelComputeArguments::GetModelBufferPointer ** ** \sa KIM::ModelComputeArguments::GetModelBufferPointer, ** kim_model_compute_arguments_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelComputeArguments_GetModelBufferPointer( KIM_ModelComputeArguments const * const modelComputeArguments, void ** const ptr); /** ** \brief \copybrief KIM::ModelComputeArguments::LogEntry ** ** \sa KIM::ModelComputeArguments::LogEntry, ** kim_model_compute_arguments_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelComputeArguments_LogEntry( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelComputeArguments::ToString ** ** \sa KIM::ModelComputeArguments::ToString, ** kim_model_compute_arguments_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelComputeArguments_ToString( KIM_ModelComputeArguments const * const modelComputeArguments); #endif /* KIM_MODEL_COMPUTE_ARGUMENTS_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelComputeArgumentsCreate.h000066400000000000000000000132471421473465500237730ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ #define KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_SUPPORT_STATUS_DEFINED_ #define KIM_SUPPORT_STATUS_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_SupportStatus KIM_SupportStatus; #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ #define KIM_COMPUTE_ARGUMENT_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeArgumentName KIM_ComputeArgumentName; #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_DEFINED_ #define KIM_COMPUTE_CALLBACK_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeCallbackName KIM_ComputeCallbackName; #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_DEFINED_ #define KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_DEFINED_ /** ** \brief \copybrief KIM::ModelComputeArgumentsCreate ** ** \sa KIM::ModelComputeArgumentsCreate, ** kim_model_compute_arguments_create_module::kim_model_compute_arguments_create_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelComputeArgumentsCreate KIM_ModelComputeArgumentsCreate; #endif /** ** \brief \copybrief KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus ** ** \sa KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus, ** kim_model_compute_arguments_create_module::kim_set_argument_support_status ** ** \since 2.0 **/ int KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus const supportStatus); /** ** \brief \copybrief KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus ** ** \sa KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus, ** kim_model_compute_arguments_create_module::kim_set_callback_support_status ** ** \since 2.0 **/ int KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus const supportStatus); /** ** \brief \copybrief KIM::ModelComputeArgumentsCreate::SetModelBufferPointer ** ** \sa KIM::ModelComputeArgumentsCreate::SetModelBufferPointer, ** kim_model_compute_arguments_module::kim_set_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelComputeArgumentsCreate_SetModelBufferPointer( KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate, void * const ptr); /** ** \brief \copybrief KIM::ModelComputeArgumentsCreate::LogEntry ** ** \sa KIM::ModelComputeArgumentsCreate::LogEntry, ** kim_model_compute_arguments_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelComputeArgumentsCreate_LogEntry( KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelComputeArgumentsCreate::ToString ** ** \sa KIM::ModelComputeArgumentsCreate::ToString, ** kim_model_compute_arguments_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelComputeArgumentsCreate_ToString( KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate); #endif /* KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelComputeArgumentsDestroy.h000066400000000000000000000102311421473465500242070ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ #define KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_DEFINED_ #define KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_DEFINED_ /** ** \brief \copybrief KIM::ModelComputeArgumentsDestroy ** ** \sa KIM::ModelComputeArgumentsDestroy, ** kim_model_compute_arguments_destroy_module::kim_model_compute_arguments_destroy_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelComputeArgumentsDestroy KIM_ModelComputeArgumentsDestroy; #endif /** ** \brief \copybrief KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer ** ** \sa KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer, ** kim_model_compute_arguments_destroy_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer( KIM_ModelComputeArgumentsDestroy const * const modelComputeArgumentsDestroy, void ** const ptr); /** ** \brief \copybrief KIM::ModelComputeArgumentsDestroy::LogEntry ** ** \sa KIM::ModelComputeArgumentsDestroy::LogEntry, ** kim_model_compute_arguments_destroy_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelComputeArgumentsDestroy_LogEntry( KIM_ModelComputeArgumentsDestroy const * const modelComputeArgumentsDestroy, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelComputeArgumentsDestroy::ToString ** ** \sa KIM::ModelComputeArgumentsDestroy::ToString, ** kim_model_compute_arguments_destroy_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelComputeArgumentsDestroy_ToString( KIM_ModelComputeArgumentsDestroy const * const modelComputeArgumentsDestroy); #endif /* KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelCreate.h000066400000000000000000000235251421473465500205500ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_CREATE_H_ #define KIM_MODEL_CREATE_H_ #ifndef KIM_FUNCTION_TYPES_H_ #include "KIM_FunctionTypes.h" /* IWYU pragma: export */ #endif /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_LANGUAGE_NAME_DEFINED_ #define KIM_LANGUAGE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LanguageName KIM_LanguageName; #endif #ifndef KIM_NUMBERING_DEFINED_ #define KIM_NUMBERING_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_Numbering KIM_Numbering; #endif #ifndef KIM_MODEL_ROUTINE_NAME_DEFINED_ #define KIM_MODEL_ROUTINE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelRoutineName KIM_ModelRoutineName; #endif #ifndef KIM_SPECIES_NAME_DEFINED_ #define KIM_SPECIES_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_SpeciesName KIM_SpeciesName; #endif #ifndef KIM_LENGTH_UNIT_DEFINED_ #define KIM_LENGTH_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LengthUnit KIM_LengthUnit; #endif #ifndef KIM_ENERGY_UNIT_DEFINED_ #define KIM_ENERGY_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_EnergyUnit KIM_EnergyUnit; #endif #ifndef KIM_CHARGE_UNIT_DEFINED_ #define KIM_CHARGE_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ChargeUnit KIM_ChargeUnit; #endif #ifndef KIM_TEMPERATURE_UNIT_DEFINED_ #define KIM_TEMPERATURE_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_TemperatureUnit KIM_TemperatureUnit; #endif #ifndef KIM_TIME_UNIT_DEFINED_ #define KIM_TIME_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_TimeUnit KIM_TimeUnit; #endif #ifndef KIM_MODEL_CREATE_DEFINED_ #define KIM_MODEL_CREATE_DEFINED_ /** ** \brief \copybrief KIM::ModelCreate ** ** \sa KIM::ModelCreate, kim_model_create_module::kim_model_create_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelCreate KIM_ModelCreate; #endif /** ** \brief \copybrief KIM::ModelCreate::SetModelNumbering ** ** \sa KIM::ModelCreate::SetModelNumbering, ** kim_model_create_module::kim_set_model_numbering ** ** \since 2.0 **/ int KIM_ModelCreate_SetModelNumbering(KIM_ModelCreate * const modelCreate, KIM_Numbering const numbering); /** ** \brief \copybrief KIM::ModelCreate::SetInfluenceDistancePointer ** ** \sa KIM::ModelCreate::SetInfluenceDistancePointer, ** kim_model_create_module::kim_set_influence_distance_pointer ** ** \since 2.0 **/ void KIM_ModelCreate_SetInfluenceDistancePointer( KIM_ModelCreate * const modelCreate, double const * const influenceDistance); /** ** \brief \copybrief KIM::ModelCreate::SetNeighborListPointers ** ** \sa KIM::ModelCreate::SetNeighborListPointers, ** kim_model_create_module::kim_set_neighbor_list_pointers ** ** \since 2.0 **/ void KIM_ModelCreate_SetNeighborListPointers( KIM_ModelCreate * const modelCreate, int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); /** ** \brief \copybrief KIM::ModelCreate::SetRoutinePointer ** ** \sa KIM::ModelCreate::SetRoutinePointer, ** kim_model_create_module::kim_set_routine_pointer ** ** \since 2.0 **/ int KIM_ModelCreate_SetRoutinePointer( KIM_ModelCreate * const modelCreate, KIM_ModelRoutineName const modelRoutineName, KIM_LanguageName const languageName, int const required, KIM_Function * const fptr); /** ** \brief \copybrief KIM::ModelCreate::SetSpeciesCode ** ** \sa KIM::ModelCreate::SetSpeciesCode, ** kim_model_create_module::kim_set_species_code ** ** \since 2.0 **/ int KIM_ModelCreate_SetSpeciesCode(KIM_ModelCreate * const modelCreate, KIM_SpeciesName const speciesName, int const code); /** ** \brief \copybrief KIM::ModelCreate::SetParameterPointer ** ** \sa KIM::ModelCreate::SetParameterPointer, ** kim_model_create_module::kim_set_parameter_pointer ** ** \since 2.0 **/ int KIM_ModelCreate_SetParameterPointerInteger( KIM_ModelCreate * const modelCreate, int const extent, int * const ptr, char const * const name, char const * const description); /** ** \brief \copybrief KIM::ModelCreate::SetParameterPointer ** ** \sa KIM::ModelCreate::SetParameterPointer, ** kim_model_create_module::kim_set_parameter_pointer ** ** \since 2.0 **/ int KIM_ModelCreate_SetParameterPointerDouble( KIM_ModelCreate * const modelCreate, int const extent, double * const ptr, char const * const name, char const * const description); /** ** \brief \copybrief KIM::ModelCreate::SetModelBufferPointer ** ** \sa KIM::ModelCreate::SetModelBufferPointer, ** kim_model_create_module::kim_set_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelCreate_SetModelBufferPointer(KIM_ModelCreate * const modelCreate, void * const ptr); /** ** \brief \copybrief KIM::ModelCreate::SetUnits ** ** \sa KIM::ModelCreate::SetUnits, kim_model_create_module::kim_set_units ** ** \since 2.0 **/ int KIM_ModelCreate_SetUnits(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const lengthUnit, KIM_EnergyUnit const energyUnit, KIM_ChargeUnit const chargeUnit, KIM_TemperatureUnit const temperatureUnit, KIM_TimeUnit const timeUnit); /** ** \brief \copybrief KIM::ModelCreate::ConvertUnit ** ** \sa KIM::ModelCreate::ConvertUnit, ** kim_model_create_module::kim_convert_unit ** ** \since 2.0 **/ int KIM_ModelCreate_ConvertUnit(KIM_LengthUnit const fromLengthUnit, KIM_EnergyUnit const fromEnergyUnit, KIM_ChargeUnit const fromChargeUnit, KIM_TemperatureUnit const fromTemperatureUnit, KIM_TimeUnit const fromTimeUnit, KIM_LengthUnit const toLengthUnit, KIM_EnergyUnit const toEnergyUnit, KIM_ChargeUnit const toChargeUnit, KIM_TemperatureUnit const toTemperatureUnit, KIM_TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor); /** ** \brief \copybrief KIM::ModelCreate::LogEntry ** ** \sa KIM::ModelCreate::LogEntry, kim_model_create_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelCreate_LogEntry(KIM_ModelCreate const * const modelCreate, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelCreate::ToString ** ** \sa KIM::ModelCreate::ToString, kim_model_create_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelCreate_ToString(KIM_ModelCreate const * const modelCreate); #endif /* KIM_MODEL_CREATE_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelDestroy.h000066400000000000000000000073631421473465500210000ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_DESTROY_H_ #define KIM_MODEL_DESTROY_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_MODEL_DESTROY_DEFINED_ #define KIM_MODEL_DESTROY_DEFINED_ /** ** \brief \copybrief KIM::ModelDestroy ** ** \sa KIM::ModelDestroy, ** kim_model_destroy_module::kim_model_destroy_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelDestroy KIM_ModelDestroy; #endif /** ** \brief \copybrief KIM::ModelDestroy::GetModelBufferPointer ** ** \sa KIM::ModelDestroy::GetModelBufferPointer, ** kim_model_destroy_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelDestroy_GetModelBufferPointer( KIM_ModelDestroy const * const modelDestroy, void ** const ptr); /** ** \brief \copybrief KIM::ModelDestroy::LogEntry ** ** \sa KIM::ModelDestroy::LogEntry, kim_model_destroy_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelDestroy_LogEntry(KIM_ModelDestroy const * const modelDestroy, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelDestroy::ToString ** ** \sa KIM::ModelDestroy::ToString, kim_model_destroy_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelDestroy_ToString(KIM_ModelDestroy const * const modelDestroy); #endif /* KIM_MODEL_DESTROY_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelDriverCreate.h000066400000000000000000000264151421473465500217250ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_DRIVER_CREATE_H_ #define KIM_MODEL_DRIVER_CREATE_H_ #ifndef KIM_FUNCTION_TYPES_H_ #include "KIM_FunctionTypes.h" /* IWYU pragma: export */ #endif /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_LANGUAGE_NAME_DEFINED_ #define KIM_LANGUAGE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LanguageName KIM_LanguageName; #endif #ifndef KIM_NUMBERING_DEFINED_ #define KIM_NUMBERING_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_Numbering KIM_Numbering; #endif #ifndef KIM_MODEL_ROUTINE_NAME_DEFINED_ #define KIM_MODEL_ROUTINE_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelRoutineName KIM_ModelRoutineName; #endif #ifndef KIM_SPECIES_NAME_DEFINED_ #define KIM_SPECIES_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_SpeciesName KIM_SpeciesName; #endif #ifndef KIM_LENGTH_UNIT_DEFINED_ #define KIM_LENGTH_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LengthUnit KIM_LengthUnit; #endif #ifndef KIM_ENERGY_UNIT_DEFINED_ #define KIM_ENERGY_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_EnergyUnit KIM_EnergyUnit; #endif #ifndef KIM_CHARGE_UNIT_DEFINED_ #define KIM_CHARGE_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ChargeUnit KIM_ChargeUnit; #endif #ifndef KIM_TEMPERATURE_UNIT_DEFINED_ #define KIM_TEMPERATURE_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_TemperatureUnit KIM_TemperatureUnit; #endif #ifndef KIM_TIME_UNIT_DEFINED_ #define KIM_TIME_UNIT_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_TimeUnit KIM_TimeUnit; #endif #ifndef KIM_MODEL_DRIVER_CREATE_DEFINED_ #define KIM_MODEL_DRIVER_CREATE_DEFINED_ /** ** \brief \copybrief KIM::ModelDriverCreate ** ** \sa KIM::ModelDriverCreate, ** kim_model_driver_create_module::kim_model_driver_create_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelDriverCreate KIM_ModelDriverCreate; #endif /** ** \brief \copybrief KIM::ModelDriverCreate::GetParameterFileDirectoryName ** ** \sa KIM::ModelDriverCreate::GetParameterFileDirectoryName, ** kim_model_driver_create_module::kim_get_parameter_file_directory_name ** ** \since 2.2 **/ void KIM_ModelDriverCreate_GetParameterFileDirectoryName( KIM_ModelDriverCreate const * const modelDriverCreate, char const ** const directoryName); /** ** \brief \copybrief KIM::ModelDriverCreate::GetNumberOfParameterFiles ** ** \sa KIM::ModelDriverCreate::GetNumberOfParameterFiles, ** kim_model_driver_create_module::kim_get_number_of_parameter_files ** ** \since 2.0 **/ void KIM_ModelDriverCreate_GetNumberOfParameterFiles( KIM_ModelDriverCreate const * const modelDriverCreate, int * const numberOfParameterFiles); /** ** \brief \copybrief KIM::ModelDriverCreate::GetParameterFileName ** ** \sa KIM::ModelDriverCreate::GetParameterFileName, ** kim_model_driver_create_module::kim_get_parameter_file_name ** ** \since 2.0 ** ** \deprecated As of 2.2. Please use ** KIM_ModelDriverCreate_GetParameterFileBasename() instead. **/ int KIM_ModelDriverCreate_GetParameterFileName( KIM_ModelDriverCreate const * const modelDriverCreate, int const index, char const ** const parameterFileName); /** ** \brief \copybrief KIM::ModelDriverCreate::GetParameterFileBasename ** ** \sa KIM::ModelDriverCreate::GetParameterFileBasename, ** kim_model_driver_create_module::kim_get_parameter_file_basename ** ** \since 2.2 **/ int KIM_ModelDriverCreate_GetParameterFileBasename( KIM_ModelDriverCreate const * const modelDriverCreate, int const index, char const ** const parameterFileBasename); /** ** \brief \copybrief KIM::ModelDriverCreate::SetModelNumbering ** ** \sa KIM::ModelDriverCreate::SetModelNumbering, ** kim_model_driver_create_module::kim_set_model_numbering ** ** \since 2.0 **/ int KIM_ModelDriverCreate_SetModelNumbering( KIM_ModelDriverCreate * const modelDriverCreate, KIM_Numbering const numbering); /** ** \brief \copybrief KIM::ModelDriverCreate::SetInfluenceDistancePointer ** ** \sa KIM::ModelDriverCreate::SetInfluenceDistancePointer, ** kim_model_driver_create_module::kim_set_influence_distance_pointer ** ** \since 2.0 **/ void KIM_ModelDriverCreate_SetInfluenceDistancePointer( KIM_ModelDriverCreate * const modelDriverCreate, double const * const influenceDistance); /** ** \brief \copybrief KIM::ModelDriverCreate::SetNeighborListPointers ** ** \sa KIM::ModelDriverCreate::SetNeighborListPointers, ** kim_model_driver_create_module::kim_set_neighbor_list_pointers ** ** \since 2.0 **/ void KIM_ModelDriverCreate_SetNeighborListPointers( KIM_ModelDriverCreate * const modelDriverCreate, int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); /** ** \brief \copybrief KIM::ModelDriverCreate::SetRoutinePointer ** ** \sa KIM::ModelDriverCreate::SetRoutinePointer, ** kim_model_driver_create_module::kim_set_routine_pointer ** ** \since 2.0 **/ int KIM_ModelDriverCreate_SetRoutinePointer( KIM_ModelDriverCreate * const modelDriverCreate, KIM_ModelRoutineName const modelRoutineName, KIM_LanguageName const languageName, int const required, KIM_Function * const fptr); /** ** \brief \copybrief KIM::ModelDriverCreate::SetSpeciesCode ** ** \sa KIM::ModelDriverCreate::SetSpeciesCode, ** kim_model_driver_create_module::kim_set_species_code ** ** \since 2.0 **/ int KIM_ModelDriverCreate_SetSpeciesCode( KIM_ModelDriverCreate * const modelDriverCreate, KIM_SpeciesName const speciesName, int const code); /** ** \brief \copybrief KIM::ModelDriverCreate::SetParameterPointer ** ** \sa KIM::ModelDriverCreate::SetParameterPointer, ** kim_model_driver_create_module::kim_set_parameter_pointer ** ** \since 2.0 **/ int KIM_ModelDriverCreate_SetParameterPointerInteger( KIM_ModelDriverCreate * const modelDriverCreate, int const extent, int * const ptr, char const * const name, char const * const description); /** ** \brief \copybrief KIM::ModelDriverCreate::SetParameterPointer ** ** \sa KIM::ModelDriverCreate::SetParameterPointer, ** kim_model_driver_create_module::kim_set_parameter_pointer ** ** \since 2.0 **/ int KIM_ModelDriverCreate_SetParameterPointerDouble( KIM_ModelDriverCreate * const modelDriverCreate, int const extent, double * const ptr, char const * const name, char const * const description); /** ** \brief \copybrief KIM::ModelDriverCreate::SetModelBufferPointer ** ** \sa KIM::ModelDriverCreate::SetModelBufferPointer, ** kim_model_driver_create_module::kim_set_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelDriverCreate_SetModelBufferPointer( KIM_ModelDriverCreate * const modelDriverCreate, void * const ptr); /** ** \brief \copybrief KIM::ModelDriverCreate::SetUnits ** ** \sa KIM::ModelDriverCreate::SetUnits, ** kim_model_driver_create_module::kim_set_units ** ** \since 2.0 **/ int KIM_ModelDriverCreate_SetUnits( KIM_ModelDriverCreate * const modelDriverCreate, KIM_LengthUnit const lengthUnit, KIM_EnergyUnit const energyUnit, KIM_ChargeUnit const chargeUnit, KIM_TemperatureUnit const temperatureUnit, KIM_TimeUnit const timeUnit); /** ** \brief \copybrief KIM::ModelDriverCreate::ConvertUnit ** ** \sa KIM::ModelDriverCreate::ConvertUnit, ** kim_model_driver_create_module::kim_convert_unit ** ** \since 2.0 **/ int KIM_ModelDriverCreate_ConvertUnit( KIM_LengthUnit const fromLengthUnit, KIM_EnergyUnit const fromEnergyUnit, KIM_ChargeUnit const fromChargeUnit, KIM_TemperatureUnit const fromTemperatureUnit, KIM_TimeUnit const fromTimeUnit, KIM_LengthUnit const toLengthUnit, KIM_EnergyUnit const toEnergyUnit, KIM_ChargeUnit const toChargeUnit, KIM_TemperatureUnit const toTemperatureUnit, KIM_TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor); /** ** \brief \copybrief KIM::ModelDriverCreate::LogEntry ** ** \sa KIM::ModelDriverCreate::LogEntry, ** kim_model_driver_create_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelDriverCreate_LogEntry( KIM_ModelDriverCreate const * const modelDriverCreate, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelDriverCreate::ToString ** ** \sa KIM::ModelDriverCreate::ToString, ** kim_model_driver_create_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelDriverCreate_ToString( KIM_ModelDriverCreate const * const modelDriverCreate); #endif /* KIM_MODEL_DRIVER_CREATE_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelDriverHeaders.h000066400000000000000000000073331421473465500220730ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_DRIVER_HEADERS_H_ #define KIM_MODEL_DRIVER_HEADERS_H_ /* IWYU pragma: begin_exports */ #ifndef KIM_MODEL_DRIVER_CREATE_H_ #include "KIM_ModelDriverCreate.h" #endif #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif #ifndef KIM_SUPPORT_STATUS_H_ #include "KIM_SupportStatus.h" #endif #ifndef KIM_UNIT_SYSTEM_H_ #include "KIM_UnitSystem.h" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ #include "KIM_ModelComputeArgumentsCreate.h" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif #ifndef KIM_DATA_TYPE_H_ #include "KIM_DataType.h" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_H_ #include "KIM_ModelComputeArguments.h" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ #include "KIM_ModelComputeArgumentsDestroy.h" #endif #ifndef KIM_MODEL_COMPUTE_H_ #include "KIM_ModelCompute.h" #endif #ifndef KIM_MODEL_EXTENSION_H_ #include "KIM_ModelExtension.h" #endif #ifndef KIM_MODEL_REFRESH_H_ #include "KIM_ModelRefresh.h" #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ #include "KIM_ModelWriteParameterizedModel.h" #endif #ifndef KIM_MODEL_DESTROY_H_ #include "KIM_ModelDestroy.h" #endif /* IWYU pragma: end_exports */ #endif /* KIM_MODEL_DRIVER_HEADERS_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelExtension.h000066400000000000000000000231311421473465500213120ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_EXTENSION_H_ #define KIM_MODEL_EXTENSION_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_MODEL_DEFINED_ #define KIM_MODEL_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_Model KIM_Model; #endif #ifndef KIM_MODEL_COMPUTE_DEFINED_ #define KIM_MODEL_COMPUTE_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelCompute KIM_ModelCompute; #endif #ifndef KIM_MODEL_CREATE_DEFINED_ #define KIM_MODEL_CREATE_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelCreate KIM_ModelCreate; #endif #ifndef KIM_MODEL_DESTROY_DEFINED_ #define KIM_MODEL_DESTROY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelDestroy KIM_ModelDestroy; #endif #ifndef KIM_MODEL_DRIVER_CREATE_DEFINED_ #define KIM_MODEL_DRIVER_CREATE_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelDriverCreate KIM_ModelDriverCreate; #endif #ifndef KIM_MODEL_REFRESH_DEFINED_ #define KIM_MODEL_REFRESH_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelRefresh KIM_ModelRefresh; #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_DEFINED_ #define KIM_MODEL_WRITE_PARAMETERIZED_MODEL_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelWriteParameterizedModel KIM_ModelWriteParameterizedModel; #endif #ifndef KIM_COMPUTE_ARGUMENTS_DEFINED_ #define KIM_COMPUTE_ARGUMENTS_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ComputeArguments KIM_ComputeArguments; #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DEFINED_ #define KIM_MODEL_COMPUTE_ARGUMENTS_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelComputeArguments KIM_ModelComputeArguments; #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_DEFINED_ #define KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelComputeArgumentsCreate KIM_ModelComputeArgumentsCreate; #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_DEFINED_ #define KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_ModelComputeArgumentsDestroy KIM_ModelComputeArgumentsDestroy; #endif #ifndef KIM_MODEL_EXTENSION_DEFINED_ #define KIM_MODEL_EXTENSION_DEFINED_ /** ** \brief \copybrief KIM::ModelExtension ** ** \sa KIM::ModelExtension, ** kim_model_extension_module::kim_model_extension_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelExtension KIM_ModelExtension; #endif /** ** \brief \copybrief KIM::ModelExtension::GetExtensionID ** ** \sa KIM::ModelExtension::GetExtensionID, ** kim_model_extension_module::kim_get_extension_id ** ** \since 2.0 **/ void KIM_ModelExtension_GetExtensionID( KIM_ModelExtension const * const modelExtension, char const ** const extensionID); /** ** \brief \copybrief KIM::ModelExtension::Model ** ** \sa KIM::ModelExtension::Model, kim_model_extension_module::kim_to_model ** ** \since 2.0 **/ KIM_Model * KIM_ModelExtension_ToModel(KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelCompute ** ** \sa KIM::ModelExtension::ModelCompute, ** kim_model_extension_module::kim_to_model_compute ** ** \since 2.0 **/ KIM_ModelCompute * KIM_ModelExtension_ToModelCompute(KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelCreate ** ** \sa KIM::ModelExtension::ModelCreate, ** kim_model_extension_module::kim_to_model_create ** ** \since 2.0 **/ KIM_ModelCreate * KIM_ModelExtension_ToModelCreate(KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelDestroy ** ** \sa KIM::ModelExtension::ModelDestroy, ** kim_model_extension_module::kim_to_model_destroy ** ** \since 2.0 **/ KIM_ModelDestroy * KIM_ModelExtension_ToModelDestroy(KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelDriverCreate ** ** \sa KIM::ModelExtension::ModelDriverCreate, ** kim_model_extension_module::kim_to_model_driver_create ** ** \since 2.0 **/ KIM_ModelDriverCreate * KIM_ModelExtension_ToModelDriverCreate( KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelRefresh ** ** \sa KIM::ModelExtension::ModelRefresh, ** kim_model_extension_module::kim_to_model_refresh ** ** \since 2.0 **/ KIM_ModelRefresh * KIM_ModelExtension_ToModelRefresh(KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelWriteParameterizedModel ** ** \sa KIM::ModelExtension::ModelWriteParameterizedModel, ** kim_model_extension_module::kim_to_model_write_parameterized_model ** ** \since 2.0 **/ KIM_ModelWriteParameterizedModel * KIM_ModelExtension_ToModelWriteParameterizedModel( KIM_ModelExtension * const modelExtension); /** ** \brief \copybrief KIM::ModelExtension::ModelComputeArguments ** ** \sa KIM::ModelExtension::ModelComputeArguments, ** kim_model_extension_module::kim_to_model_compute_arguments ** ** \since 2.0 **/ KIM_ModelComputeArguments * KIM_ModelExtension_ToModelComputeArguments( KIM_ModelExtension const * const modelExtension, KIM_ComputeArguments * const computeArguments); KIM_ModelComputeArgumentsCreate * /** ** \brief \copybrief KIM::ModelExtension::ModelComputeArgumentsCreate ** ** \sa KIM::ModelExtension::ModelComputeArgumentsCreate, ** kim_model_extension_module::kim_to_model_compute_arguments_create ** ** \since 2.0 **/ KIM_ModelExtension_ToModelComputeArgumentsCreate( KIM_ModelExtension const * const modelExtension, KIM_ComputeArguments * const computeArguments); /** ** \brief \copybrief KIM::ModelExtension::ModelComputeArgumentsDestroy ** ** \sa KIM::ModelExtension::ModelComputeArgumentsDestroy, ** kim_model_extension_module::kim_to_model_compute_arguments_destroy ** ** \since 2.0 **/ KIM_ModelComputeArgumentsDestroy * KIM_ModelExtension_ToModelComputeArgumentsDestroy( KIM_ModelExtension const * const modelExtension, KIM_ComputeArguments * const computeArguments); /** ** \brief \copybrief KIM::ModelExtension::GetModelBufferPointer ** ** \sa KIM::ModelExtension::GetModelBufferPointer, ** kim_model_extension_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelExtension_GetModelBufferPointer( KIM_ModelExtension const * const modelCompute, void ** const ptr); /** ** \brief \copybrief KIM::ModelExtension::LogEntry ** ** \sa KIM::ModelExtension::LogEntry, ** kim_model_extension_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelExtension_LogEntry(KIM_ModelExtension const * const modelCompute, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelExtension::ToString ** ** \sa KIM::ModelExtension::ToString, ** kim_model_extension_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelExtension_ToString(KIM_ModelExtension const * const modelCompute); #endif /* KIM_MODEL_EXTENSION_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelHeaders.h000066400000000000000000000072711421473465500207200ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_HEADERS_H_ #define KIM_MODEL_HEADERS_H_ /* IWYU pragma: begin_exports */ #ifndef KIM_MODEL_CREATE_H_ #include "KIM_ModelCreate.h" #endif #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif #ifndef KIM_SUPPORT_STATUS_H_ #include "KIM_SupportStatus.h" #endif #ifndef KIM_UNIT_SYSTEM_H_ #include "KIM_UnitSystem.h" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ #include "KIM_ModelComputeArgumentsCreate.h" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif #ifndef KIM_DATA_TYPE_H_ #include "KIM_DataType.h" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_H_ #include "KIM_ModelComputeArguments.h" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ #include "KIM_ModelComputeArgumentsDestroy.h" #endif #ifndef KIM_MODEL_COMPUTE_H_ #include "KIM_ModelCompute.h" #endif #ifndef KIM_MODEL_EXTENSION_H_ #include "KIM_ModelExtension.h" #endif #ifndef KIM_MODEL_REFRESH_H_ #include "KIM_ModelRefresh.h" #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ #include "KIM_ModelWriteParameterizedModel.h" #endif #ifndef KIM_MODEL_DESTROY_H_ #include "KIM_ModelDestroy.h" #endif /* IWYU pragma: end_exports */ #endif /* KIM_MODEL_HEADERS_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelRefresh.h000066400000000000000000000110401421473465500207300ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_REFRESH_H_ #define KIM_MODEL_REFRESH_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_MODEL_REFRESH_DEFINED_ #define KIM_MODEL_REFRESH_DEFINED_ /** ** \brief \copybrief KIM::ModelRefresh ** ** \sa KIM::ModelRefresh, ** kim_model_refresh_module::kim_model_refresh_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelRefresh KIM_ModelRefresh; #endif /** ** \brief \copybrief KIM::ModelRefresh::SetInfluenceDistancePointer ** ** \sa KIM::ModelRefresh::SetInfluenceDistancePointer, ** kim_model_refresh_module::kim_set_influence_distance_pointer ** ** \since 2.0 **/ void KIM_ModelRefresh_SetInfluenceDistancePointer( KIM_ModelRefresh * const modelRefresh, double const * const influenceDistance); /** ** \brief \copybrief KIM::ModelRefresh::SetNeighborListPointers ** ** \sa KIM::ModelRefresh::SetNeighborListPointers, ** kim_model_refresh_module::kim_set_neighbor_list_pointers ** ** \since 2.0 **/ void KIM_ModelRefresh_SetNeighborListPointers( KIM_ModelRefresh * const modelRefresh, int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); /** ** \brief \copybrief KIM::ModelRefresh::GetModelBufferPointer ** ** \sa KIM::ModelRefresh::GetModelBufferPointer, ** kim_model_refresh_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelRefresh_GetModelBufferPointer( KIM_ModelRefresh const * const modelRefresh, void ** const ptr); /** ** \brief \copybrief KIM::ModelRefresh::LogEntry ** ** \sa KIM::ModelRefresh::LogEntry, kim_model_refresh_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelRefresh_LogEntry(KIM_ModelRefresh const * const modelRefresh, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelRefresh::ToString ** ** \sa KIM::ModelRefresh::ToString, kim_model_refresh_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelRefresh_ToString(KIM_ModelRefresh const * const modelRefresh); #endif /* KIM_MODEL_REFRESH_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelRoutineName.h000066400000000000000000000164701421473465500215740ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_ROUTINE_NAME_H_ #define KIM_MODEL_ROUTINE_NAME_H_ /** ** \brief \copybrief KIM::ModelRoutineName ** ** \sa KIM::ModelRoutineName, ** kim_model_routine_name_module::kim_model_routine_name_type ** ** \since 2.0 **/ struct KIM_ModelRoutineName { /** ** \brief \copybrief KIM::ModelRoutineName::modelRoutineNameID ** ** \sa KIM::ModelRoutineName::modelRoutineNameID, ** kim_model_routine_name_module::kim_model_routine_name_type::model_routine_name_id ** ** \since 2.0 **/ int modelRoutineNameID; }; #ifndef KIM_MODEL_ROUTINE_NAME_DEFINED_ #define KIM_MODEL_ROUTINE_NAME_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_ModelRoutineName KIM_ModelRoutineName; #endif /** ** \brief \copybrief KIM::ModelRoutineName::ModelRoutineName(std::string const &) ** ** \sa KIM::ModelRoutineName::ModelRoutineName(std::string const &), ** kim_model_routine_name_module::kim_from_string ** ** \since 2.0 **/ KIM_ModelRoutineName KIM_ModelRoutineName_FromString(char const * const str); /** ** \brief \copybrief KIM::ModelRoutineName::Known ** ** \sa KIM::ModelRoutineName::Known, kim_model_routine_name_module::kim_known ** ** \since 2.0 **/ int KIM_ModelRoutineName_Known(KIM_ModelRoutineName const modelRoutineName); /** ** \brief \copybrief KIM::ModelRoutineName::operator==() ** ** \sa KIM::ModelRoutineName::operator==(), ** kim_model_routine_name_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_ModelRoutineName_Equal(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs); /** ** \brief \copybrief KIM::ModelRoutineName::operator!=() ** ** \sa KIM::ModelRoutineName::operator!=(), ** kim_model_routine_name_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_ModelRoutineName_NotEqual(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs); /** ** \brief \copybrief KIM::ModelRoutineName::ToString ** ** \sa KIM::ModelRoutineName::ToString, ** kim_model_routine_name_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelRoutineName_ToString(KIM_ModelRoutineName const modelRoutineName); /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::Create ** ** \sa KIM::MODEL_ROUTINE_NAME::Create, ** kim_model_routine_name_module::kim_model_routine_name_create ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Create; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate ** ** \sa KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate, ** kim_model_routine_name_module::kim_model_routine_name_compute_arguments_create ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::Compute ** ** \sa KIM::MODEL_ROUTINE_NAME::Compute, ** kim_model_routine_name_module::kim_model_routine_name_compute ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::Extension ** ** \sa KIM::MODEL_ROUTINE_NAME::Extension, ** kim_model_routine_name_module::kim_model_routine_name_extension ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Extension; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::Refresh ** ** \sa KIM::MODEL_ROUTINE_NAME::Refresh, ** kim_model_routine_name_module::kim_model_routine_name_refresh ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Refresh; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel ** ** \sa KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel, ** kim_model_routine_name_module::kim_model_routine_name_write_parameterized_model ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy ** ** \sa KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy, ** kim_model_routine_name_module::kim_model_routine_name_compute_arguments_destroy ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::Destroy ** ** \sa KIM::MODEL_ROUTINE_NAME::Destroy, ** kim_model_routine_name_module::kim_model_routine_name_destroy ** ** \since 2.0 **/ extern KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy; /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames ** ** \sa KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames, ** kim_model_routine_name_module::kim_get_number_of_model_routine_names ** ** \since 2.0 **/ void KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames( int * const numberOfModelRoutineNames); /** ** \brief \copybrief KIM::MODEL_ROUTINE_NAME::GetModelRoutineName ** ** \sa KIM::MODEL_ROUTINE_NAME::GetModelRoutineName, ** kim_model_routine_name_module::kim_get_model_routine_name ** ** \since 2.0 **/ int KIM_MODEL_ROUTINE_NAME_GetModelRoutineName( int const index, KIM_ModelRoutineName * const modelRoutineName); #endif /* KIM_MODEL_ROUTINE_NAME_H_ */ kim-api-2.3.0-git/c/include/KIM_ModelWriteParameterizedModel.h000066400000000000000000000125021421473465500241260ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ #define KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_DEFINED_ #define KIM_MODEL_WRITE_PARAMETERIZED_MODEL_DEFINED_ /** ** \brief \copybrief KIM::ModelWriteParameterizedModel ** ** \sa KIM::ModelWriteParameterizedModel, ** kim_model_write_parameterized_model_module::kim_model_write_parameterized_model_handle_type ** ** \since 2.0 **/ typedef struct KIM_ModelWriteParameterizedModel KIM_ModelWriteParameterizedModel; #endif /** ** \brief \copybrief KIM::ModelWriteParameterizedModel::GetPath ** ** \sa KIM::ModelWriteParameterizedModel::GetPath, ** kim_model_write_parameterized_model_module::kim_get_path ** ** \since 2.0 **/ void KIM_ModelWriteParameterizedModel_GetPath( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, char const ** const path); /** ** \brief \copybrief KIM::ModelWriteParameterizedModel::GetModelName ** ** \sa KIM::ModelWriteParameterizedModel::GetModelName, ** kim_model_write_parameterized_model_module::kim_get_model_name ** ** \since 2.0 **/ void KIM_ModelWriteParameterizedModel_GetModelName( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, char const ** const modelName); /** ** \brief \copybrief KIM::ModelWriteParameterizedModel::SetParameterFileName ** ** \sa KIM::ModelWriteParameterizedModel::SetParameterFileName, ** kim_model_write_parameterized_model_module::kim_set_parameter_file_name ** ** \since 2.0 **/ void KIM_ModelWriteParameterizedModel_SetParameterFileName( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, char const * const fileName); /** ** \brief \copybrief KIM::ModelWriteParameterizedModel::GetModelBufferPointer ** ** \sa KIM::ModelWriteParameterizedModel::GetModelBufferPointer, ** kim_model_write_parameterized_model_module::kim_get_model_buffer_pointer ** ** \since 2.0 **/ void KIM_ModelWriteParameterizedModel_GetModelBufferPointer( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, void ** const ptr); /** ** \brief \copybrief KIM::ModelWriteParameterizedModel::LogEntry ** ** \sa KIM::ModelWriteParameterizedModel::LogEntry, ** kim_model_write_parameterized_model_module::kim_log_entry ** ** \since 2.0 **/ void KIM_ModelWriteParameterizedModel_LogEntry( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName); /** ** \brief \copybrief KIM::ModelWriteParameterizedModel::ToString ** ** \sa KIM::ModelWriteParameterizedModel::ToString, ** kim_model_write_parameterized_model_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_ModelWriteParameterizedModel_ToString( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel); #endif /* KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ */ kim-api-2.3.0-git/c/include/KIM_Numbering.h000066400000000000000000000115151421473465500203060ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_NUMBERING_H_ #define KIM_NUMBERING_H_ /** ** \brief \copybrief KIM::Numbering ** ** \sa KIM::Numbering, kim_numbering_module::kim_numbering_type ** ** \since 2.0 **/ struct KIM_Numbering { /** ** \brief \copybrief KIM::Numbering::numberingID ** ** \sa KIM::Numbering::numberingID, ** kim_numbering_module::kim_numbering_type::numbering_id ** ** \since 2.0 **/ int numberingID; }; #ifndef KIM_NUMBERING_DEFINED_ #define KIM_NUMBERING_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_Numbering KIM_Numbering; #endif /** ** \brief \copybrief KIM::Numbering::Numbering(std::string const &) ** ** \sa KIM::Numbering::Numbering(std::string const &), ** kim_numbering_module::kim_from_string ** ** \since 2.0 **/ KIM_Numbering KIM_Numbering_FromString(char const * const str); /** ** \brief \copybrief KIM::Numbering::Known ** ** \sa KIM::Numbering::Known, kim_numbering_module::kim_known ** ** \since 2.0 **/ int KIM_Numbering_Known(KIM_Numbering const numbering); /** ** \brief \copybrief KIM::Numbering::operator==() ** ** \sa KIM::Numbering::operator==(), kim_numbering_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_Numbering_Equal(KIM_Numbering const lhs, KIM_Numbering const rhs); /** ** \brief \copybrief KIM::Numbering::operator!=() ** ** \sa KIM::Numbering::operator!=(), kim_numbering_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_Numbering_NotEqual(KIM_Numbering const lhs, KIM_Numbering const rhs); /** ** \brief \copybrief KIM::Numbering::ToString ** ** \sa KIM::Numbering::ToString, kim_numbering_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_Numbering_ToString(KIM_Numbering const numbering); /** ** \brief \copybrief KIM::NUMBERING::zeroBased ** ** \sa KIM::NUMBERING::zeroBased, ** kim_numbering_module::kim_numbering_zero_based ** ** \since 2.0 **/ extern KIM_Numbering const KIM_NUMBERING_zeroBased; /** ** \brief \copybrief KIM::NUMBERING::oneBased ** ** \sa KIM::NUMBERING::oneBased, kim_numbering_module::kim_numbering_one_based ** ** \since 2.0 **/ extern KIM_Numbering const KIM_NUMBERING_oneBased; /** ** \brief \copybrief KIM::NUMBERING::GetNumberOfNumberings ** ** \sa KIM::NUMBERING::GetNumberOfNumberings, ** kim_numbering_module::kim_get_number_of_numberings ** ** \since 2.0 **/ void KIM_NUMBERING_GetNumberOfNumberings(int * const numberOfNumberings); /** ** \brief \copybrief KIM::NUMBERING::GetNumbering ** ** \sa KIM::NUMBERING::GetNumbering, kim_numbering_module::kim_get_numbering ** ** \since 2.0 **/ int KIM_NUMBERING_GetNumbering(int const index, KIM_Numbering * const numbering); #endif /* KIM_NUMBERING_H_ */ kim-api-2.3.0-git/c/include/KIM_SemVer.h000066400000000000000000000064041421473465500175620ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SEM_VER_H_ #define KIM_SEM_VER_H_ /** ** \brief \copybrief KIM::SEM_VER::GetSemVer ** ** \sa KIM::SEM_VER::GetSemVer, kim_sem_ver_module::kim_get_sem_ver ** ** \since 2.0 **/ char const * KIM_SEM_VER_GetSemVer(); /** ** \brief \copybrief KIM::SEM_VER::IsLessThan ** ** \sa KIM::SEM_VER::IsLessThan, kim_sem_ver_module::kim_is_less_than ** ** \since 2.0 **/ int KIM_SEM_VER_IsLessThan(char const * const lhs, char const * const rhs, int * const isLessThan); /** ** \brief \copybrief KIM::SEM_VER::ParseSemVer ** ** \sa KIM::SEM_VER::ParseSemVer, kim_sem_ver_module::kim_parse_sem_ver ** ** \since 2.0 **/ int KIM_SEM_VER_ParseSemVer(char const * const version, int const prereleaseLength, int const buildMetadataLength, int * const major, int * const minor, int * const patch, char * const prerelease, char * const buildMetadata); #endif /* KIM_SEM_VER_H_ */ kim-api-2.3.0-git/c/include/KIM_SimulatorHeaders.h000066400000000000000000000065751421473465500216450ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SIMULATOR_HEADERS_H_ #define KIM_SIMULATOR_HEADERS_H_ /* IWYU pragma: begin_exports */ #ifndef KIM_COLLECTIONS_H_ #include "KIM_Collections.h" #endif #ifndef KIM_COLLECTION_H_ #include "KIM_Collection.h" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_H_ #include "KIM_CollectionItemType.h" #endif #ifndef KIM_MODEL_H_ #include "KIM_Model.h" #endif #ifndef KIM_SIMULATOR_MODEL_H_ #include "KIM_SimulatorModel.h" #endif #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif #ifndef KIM_DATA_TYPE_H_ #include "KIM_DataType.h" #endif #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif #ifndef KIM_UNIT_SYSTEM_H_ #include "KIM_UnitSystem.h" #endif #ifndef KIM_COMPUTE_ARGUMENTS_H_ #include "KIM_ComputeArguments.h" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif #ifndef KIM_SUPPORT_STATUS_H_ #include "KIM_SupportStatus.h" #endif /* IWYU pragma: end_exports */ #endif /* KIM_SIMULATOR_HEADERS_H_ */ kim-api-2.3.0-git/c/include/KIM_SimulatorModel.h000066400000000000000000000251311421473465500213170ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SIMULATOR_MODEL_H_ #define KIM_SIMULATOR_MODEL_H_ /* Forward declarations */ #ifndef KIM_LOG_VERBOSITY_DEFINED_ #define KIM_LOG_VERBOSITY_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_LogVerbosity KIM_LogVerbosity; #endif #ifndef KIM_SIMULATOR_MODEL_DEFINED_ #define KIM_SIMULATOR_MODEL_DEFINED_ /** ** \brief \copybrief KIM::SimulatorModel ** ** \copydetails KIM::SimulatorModel ** ** **/ typedef struct KIM_SimulatorModel KIM_SimulatorModel; #endif /** ** \brief \copybrief KIM::SimulatorModel::Create ** ** \sa KIM::SimulatorModel::Create, ** kim_simulator_model_module::kim_simulator_model_create ** ** \since 2.1 **/ int KIM_SimulatorModel_Create(char const * const simulatorModelName, KIM_SimulatorModel ** const simulatorModel); /** ** \brief \copybrief KIM::SimulatorModel::Destroy ** ** \sa KIM::SimulatorModel::Destroy, ** kim_simulator_model_module::kim_simulator_model_destroy ** ** \since 2.1 **/ void KIM_SimulatorModel_Destroy(KIM_SimulatorModel ** const simulatorModel); /** ** \brief \copybrief KIM::SimulatorModel::GetSimulatorNameAndVersion ** ** \sa KIM::SimulatorModel::GetSimulatorNameAndVersion, ** kim_simulator_model_module::kim_get_simulator_name_and_version ** ** \since 2.1 **/ void KIM_SimulatorModel_GetSimulatorNameAndVersion( KIM_SimulatorModel const * const simulatorModel, char const ** const simulatorName, char const ** const simulatorVersion); /** ** \brief \copybrief KIM::SimulatorModel::GetNumberOfSupportedSpecies ** ** \sa KIM::SimulatorModel::GetNumberOfSupportedSpecies, ** kim_simulator_model_module::kim_get_number_of_supported_species ** ** \since 2.1 **/ void KIM_SimulatorModel_GetNumberOfSupportedSpecies( KIM_SimulatorModel const * const simulatorModel, int * const numberOfSupportedSpecies); /** ** \brief \copybrief KIM::SimulatorModel::GetSupportedSpecies ** ** \sa KIM::SimulatorModel::GetSupportedSpecies, ** kim_simulator_model_module::kim_get_supported_species ** ** \since 2.1 **/ int KIM_SimulatorModel_GetSupportedSpecies( KIM_SimulatorModel const * const simulatorModel, int const index, char const ** const speciesName); /** ** \brief \copybrief KIM::SimulatorModel::OpenAndInitializeTemplateMap ** ** \sa KIM::SimulatorModel::OpenAndInitializeTemplateMap, ** kim_simulator_model_module::kim_open_and_initialize_template_map ** ** \since 2.1 **/ void KIM_SimulatorModel_OpenAndInitializeTemplateMap( KIM_SimulatorModel const * const simulatorModel); /** ** \brief \copybrief KIM::SimulatorModel::TemplateMapIsOpen ** ** \sa KIM::SimulatorModel::TemplateMapIsOpen, ** kim_simulator_model_module::kim_template_map_is_open ** ** \since 2.1 **/ int KIM_SimulatorModel_TemplateMapIsOpen( KIM_SimulatorModel const * const simulatorModel); /** ** \brief \copybrief KIM::SimulatorModel::AddTemplateMap ** ** \sa KIM::SimulatorModel::AddTemplateMap, ** kim_simulator_model_module::kim_add_template_map ** ** \since 2.1 **/ int KIM_SimulatorModel_AddTemplateMap( KIM_SimulatorModel const * const simulatorModel, char const * const key, char const * const value); /** ** \brief \copybrief KIM::SimulatorModel::CloseTemplateMap ** ** \sa KIM::SimulatorModel::CloseTemplateMap, ** kim_simulator_model_module::kim_close_template_map ** ** \since 2.1 **/ void KIM_SimulatorModel_CloseTemplateMap( KIM_SimulatorModel const * const simulatorModel); /** ** \brief \copybrief KIM::SimulatorModel::GetNumberOfSimulatorFields ** ** \sa KIM::SimulatorModel::GetNumberOfSimulatorFields, ** kim_simulator_model_module::kim_get_number_of_simulator_fields ** ** \since 2.1 **/ void KIM_SimulatorModel_GetNumberOfSimulatorFields( KIM_SimulatorModel const * const simulatorModel, int * const numberOfSimulatorFields); /** ** \brief \copybrief KIM::SimulatorModel::GetSimulatorFieldMetadata ** ** \sa KIM::SimulatorModel::GetSimulatorFieldMetadata, ** kim_simulator_model_module::kim_get_simulator_field_metadata ** ** \since 2.1 **/ int KIM_SimulatorModel_GetSimulatorFieldMetadata( KIM_SimulatorModel const * const simulatorModel, int const fieldIndex, int * const extent, char const ** const fieldName); /** ** \brief \copybrief KIM::SimulatorModel::GetSimulatorFieldLine ** ** \sa KIM::SimulatorModel::GetSimulatorFieldLine, ** kim_simulator_model_module::kim_get_simulator_field_line ** ** \since 2.1 **/ int KIM_SimulatorModel_GetSimulatorFieldLine( KIM_SimulatorModel const * const simulatorModel, int const fieldIndex, int const lineIndex, char const ** const lineValue); /** ** \brief \copybrief KIM::SimulatorModel::GetParameterFileDirectoryName ** ** \sa KIM::SimulatorModel::GetParameterFileDirectoryName, ** kim_simulator_model_module::kim_get_parameter_file_directory_name ** ** \since 2.1 **/ void KIM_SimulatorModel_GetParameterFileDirectoryName( KIM_SimulatorModel const * const simulatorModel, char const ** const directoryName); /** ** \brief \copybrief KIM::SimulatorModel::GetSpecificationFileName ** ** \sa KIM::SimulatorModel::GetSpecificationFileName, ** kim_simulator_model_module::kim_get_specification_file_name ** ** \since 2.1 **/ void KIM_SimulatorModel_GetSpecificationFileName( KIM_SimulatorModel const * const simulatorModel, char const ** const specificationFileName); /** ** \brief \copybrief KIM::SimulatorModel::GetNumberOfParameterFiles ** ** \sa KIM::SimulatorModel::GetNumberOfParameterFiles, ** kim_simulator_model_module::kim_get_number_of_parameter_files ** ** \since 2.1 **/ void KIM_SimulatorModel_GetNumberOfParameterFiles( KIM_SimulatorModel const * const simulatorModel, int * const numberOfParameterFiles); /** ** \brief \copybrief KIM::SimulatorModel::GetParameterFileName ** ** \sa KIM::SimulatorModel::GetParameterFileName, ** kim_simulator_model_module::kim_get_parameter_file_name ** ** \since 2.1 ** ** \deprecated As of 2.2. Please use ** KIM_SimulatorModel_GetParameterFileBasename() instead. **/ int KIM_SimulatorModel_GetParameterFileName( KIM_SimulatorModel const * const simulatorModel, int const index, char const ** const parameterFileName); /** ** \brief \copybrief KIM::SimulatorModel::GetParameterFileBasename ** ** \sa KIM::SimulatorModel::GetParameterFileBasename, ** kim_simulator_model_module::kim_get_parameter_file_basename ** ** \since 2.2 **/ int KIM_SimulatorModel_GetParameterFileBasename( KIM_SimulatorModel const * const simulatorModel, int const index, char const ** const parameterFileBasename); /** ** \brief \copybrief KIM::SimulatorModel::SetSimulatorBufferPointer ** ** \sa KIM::SimulatorModel::SetSimulatorBufferPointer, ** kim_simulator_model_module::kim_set_simulator_buffer_pointer ** ** \since 2.1 **/ void KIM_SimulatorModel_SetSimulatorBufferPointer( KIM_SimulatorModel * const simulatorModel, void * const ptr); /** ** \brief \copybrief KIM::SimulatorModel::GetSimulatorBufferPointer ** ** \sa KIM::SimulatorModel::GetSimulatorBufferPointer, ** kim_simulator_model_module::kim_get_simulator_buffer_pointer ** ** \since 2.1 **/ void KIM_SimulatorModel_GetSimulatorBufferPointer( KIM_SimulatorModel const * const simulatorModel, void ** const ptr); /** ** \brief \copybrief KIM::SimulatorModel::ToString ** ** \sa KIM::SimulatorModel::ToString, kim_simulator_model_module::kim_to_string ** ** \since 2.1 **/ char const * KIM_SimulatorModel_ToString(KIM_SimulatorModel const * const simulatorModel); /** ** \brief \copybrief KIM::SimulatorModel::SetLogID ** ** \sa KIM::SimulatorModel::SetLogID, ** kim_simulator_model_module::kim_set_log_id ** ** \since 2.1 **/ void KIM_SimulatorModel_SetLogID(KIM_SimulatorModel * const simulatorModel, char const * const logID); /** ** \brief \copybrief KIM::SimulatorModel::PushLogVerbosity ** ** \sa KIM::SimulatorModel::PushLogVerbosity, ** kim_simulator_model_module::kim_push_log_verbosity ** ** \since 2.1 **/ void KIM_SimulatorModel_PushLogVerbosity( KIM_SimulatorModel * const simulatorModel, KIM_LogVerbosity const logVerbosity); /** ** \brief \copybrief KIM::SimulatorModel::PopLogVerbosity ** ** \sa KIM::SimulatorModel::PopLogVerbosity, ** kim_simulator_model_module::kim_pop_log_verbosity ** ** \since 2.1 **/ void KIM_SimulatorModel_PopLogVerbosity( KIM_SimulatorModel * const simulatorModel); #endif /* KIM_SIMULATOR_MODEL_H_ */ kim-api-2.3.0-git/c/include/KIM_SpeciesName.h000066400000000000000000001010301421473465500205440ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SPECIES_NAME_H_ #define KIM_SPECIES_NAME_H_ /** ** \brief \copybrief KIM::SpeciesName ** ** \sa KIM::SpeciesName, kim_species_name_module::kim_species_name_type ** ** \since 2.0 **/ struct KIM_SpeciesName { /** ** \brief \copybrief KIM::SpeciesName::speciesNameID ** ** \sa KIM::SpeciesName::speciesNameID, ** kim_species_name_module::kim_species_name_type::species_name_id ** ** \since 2.0 **/ int speciesNameID; }; #ifndef KIM_SPECIES_NAME_DEFINED_ #define KIM_SPECIES_NAME_DEFINED_ /** ** \brief Forward declaration. ** ** \since 2.0 **/ typedef struct KIM_SpeciesName KIM_SpeciesName; #endif /** ** \brief \copybrief KIM::SpeciesName::SpeciesName(std::string const &) ** ** \sa KIM::SpeciesName::SpeciesName(std::string const &), ** kim_species_name_module::kim_from_string ** ** \since 2.0 **/ KIM_SpeciesName KIM_SpeciesName_FromString(char const * const str); /** ** \brief \copybrief KIM::SpeciesName::Known ** ** \sa KIM::SpeciesName::Known, kim_species_name_module::kim_known ** ** \since 2.0 **/ int KIM_SpeciesName_Known(KIM_SpeciesName const speciesName); /** ** \brief \copybrief KIM::SpeciesName::operator==() ** ** \sa KIM::SpeciesName::operator==(), kim_species_name_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_SpeciesName_Equal(KIM_SpeciesName const lhs, KIM_SpeciesName const rhs); /** ** \brief \copybrief KIM::SpeciesName::operator!=() ** ** \sa KIM::SpeciesName::operator!=(), kim_species_name_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_SpeciesName_NotEqual(KIM_SpeciesName const lhs, KIM_SpeciesName const rhs); /** ** \brief \copybrief KIM::SpeciesName::ToString ** ** \sa KIM::SpeciesName::ToString, kim_species_name_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_SpeciesName_ToString(KIM_SpeciesName const speciesName); /** ** \brief \copybrief KIM::SPECIES_NAME::electron ** ** \sa KIM::SPECIES_NAME::electron, ** kim_species_name_module::kim_species_name_electron ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_electron; /** ** \brief \copybrief KIM::SPECIES_NAME::H ** ** \sa KIM::SPECIES_NAME::H, kim_species_name_module::kim_species_name_h ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_H; /** ** \brief \copybrief KIM::SPECIES_NAME::He ** ** \sa KIM::SPECIES_NAME::He, kim_species_name_module::kim_species_name_he ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_He; /** ** \brief \copybrief KIM::SPECIES_NAME::Li ** ** \sa KIM::SPECIES_NAME::Li, kim_species_name_module::kim_species_name_li ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Li; /** ** \brief \copybrief KIM::SPECIES_NAME::Be ** ** \sa KIM::SPECIES_NAME::Be, kim_species_name_module::kim_species_name_be ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Be; /** ** \brief \copybrief KIM::SPECIES_NAME::B ** ** \sa KIM::SPECIES_NAME::B, kim_species_name_module::kim_species_name_b ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_B; /** ** \brief \copybrief KIM::SPECIES_NAME::C ** ** \sa KIM::SPECIES_NAME::C, kim_species_name_module::kim_species_name_c ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_C; /** ** \brief \copybrief KIM::SPECIES_NAME::N ** ** \sa KIM::SPECIES_NAME::N, kim_species_name_module::kim_species_name_n ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_N; /** ** \brief \copybrief KIM::SPECIES_NAME::O ** ** \sa KIM::SPECIES_NAME::O, kim_species_name_module::kim_species_name_o ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_O; /** ** \brief \copybrief KIM::SPECIES_NAME::F ** ** \sa KIM::SPECIES_NAME::F, kim_species_name_module::kim_species_name_f ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_F; /** ** \brief \copybrief KIM::SPECIES_NAME::Ne ** ** \sa KIM::SPECIES_NAME::Ne, kim_species_name_module::kim_species_name_ne ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ne; /** ** \brief \copybrief KIM::SPECIES_NAME::Na ** ** \sa KIM::SPECIES_NAME::Na, kim_species_name_module::kim_species_name_na ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Na; /** ** \brief \copybrief KIM::SPECIES_NAME::Mg ** ** \sa KIM::SPECIES_NAME::Mg, kim_species_name_module::kim_species_name_mg ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Mg; /** ** \brief \copybrief KIM::SPECIES_NAME::Al ** ** \sa KIM::SPECIES_NAME::Al, kim_species_name_module::kim_species_name_al ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Al; /** ** \brief \copybrief KIM::SPECIES_NAME::Si ** ** \sa KIM::SPECIES_NAME::Si, kim_species_name_module::kim_species_name_si ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Si; /** ** \brief \copybrief KIM::SPECIES_NAME::P ** ** \sa KIM::SPECIES_NAME::P, kim_species_name_module::kim_species_name_p ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_P; /** ** \brief \copybrief KIM::SPECIES_NAME::S ** ** \sa KIM::SPECIES_NAME::S, kim_species_name_module::kim_species_name_s ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_S; /** ** \brief \copybrief KIM::SPECIES_NAME::Cl ** ** \sa KIM::SPECIES_NAME::Cl, kim_species_name_module::kim_species_name_cl ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cl; /** ** \brief \copybrief KIM::SPECIES_NAME::Ar ** ** \sa KIM::SPECIES_NAME::Ar, kim_species_name_module::kim_species_name_ar ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ar; /** ** \brief \copybrief KIM::SPECIES_NAME::K ** ** \sa KIM::SPECIES_NAME::K, kim_species_name_module::kim_species_name_k ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_K; /** ** \brief \copybrief KIM::SPECIES_NAME::Ca ** ** \sa KIM::SPECIES_NAME::Ca, kim_species_name_module::kim_species_name_ca ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ca; /** ** \brief \copybrief KIM::SPECIES_NAME::Sc ** ** \sa KIM::SPECIES_NAME::Sc, kim_species_name_module::kim_species_name_sc ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Sc; /** ** \brief \copybrief KIM::SPECIES_NAME::Ti ** ** \sa KIM::SPECIES_NAME::Ti, kim_species_name_module::kim_species_name_ti ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ti; /** ** \brief \copybrief KIM::SPECIES_NAME::V ** ** \sa KIM::SPECIES_NAME::V, kim_species_name_module::kim_species_name_v ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_V; /** ** \brief \copybrief KIM::SPECIES_NAME::Cr ** ** \sa KIM::SPECIES_NAME::Cr, kim_species_name_module::kim_species_name_cr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cr; /** ** \brief \copybrief KIM::SPECIES_NAME::Mn ** ** \sa KIM::SPECIES_NAME::Mn, kim_species_name_module::kim_species_name_mn ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Mn; /** ** \brief \copybrief KIM::SPECIES_NAME::Fe ** ** \sa KIM::SPECIES_NAME::Fe, kim_species_name_module::kim_species_name_fe ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Fe; /** ** \brief \copybrief KIM::SPECIES_NAME::Co ** ** \sa KIM::SPECIES_NAME::Co, kim_species_name_module::kim_species_name_co ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Co; /** ** \brief \copybrief KIM::SPECIES_NAME::Ni ** ** \sa KIM::SPECIES_NAME::Ni, kim_species_name_module::kim_species_name_ni ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ni; /** ** \brief \copybrief KIM::SPECIES_NAME::Cu ** ** \sa KIM::SPECIES_NAME::Cu, kim_species_name_module::kim_species_name_cu ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cu; /** ** \brief \copybrief KIM::SPECIES_NAME::Zn ** ** \sa KIM::SPECIES_NAME::Zn, kim_species_name_module::kim_species_name_zn ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Zn; /** ** \brief \copybrief KIM::SPECIES_NAME::Ga ** ** \sa KIM::SPECIES_NAME::Ga, kim_species_name_module::kim_species_name_ga ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ga; /** ** \brief \copybrief KIM::SPECIES_NAME::Ge ** ** \sa KIM::SPECIES_NAME::Ge, kim_species_name_module::kim_species_name_ge ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ge; /** ** \brief \copybrief KIM::SPECIES_NAME::As ** ** \sa KIM::SPECIES_NAME::As, kim_species_name_module::kim_species_name_as ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_As; /** ** \brief \copybrief KIM::SPECIES_NAME::Se ** ** \sa KIM::SPECIES_NAME::Se, kim_species_name_module::kim_species_name_se ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Se; /** ** \brief \copybrief KIM::SPECIES_NAME::Br ** ** \sa KIM::SPECIES_NAME::Br, kim_species_name_module::kim_species_name_br ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Br; /** ** \brief \copybrief KIM::SPECIES_NAME::Kr ** ** \sa KIM::SPECIES_NAME::Kr, kim_species_name_module::kim_species_name_kr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Kr; /** ** \brief \copybrief KIM::SPECIES_NAME::Rb ** ** \sa KIM::SPECIES_NAME::Rb, kim_species_name_module::kim_species_name_rb ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Rb; /** ** \brief \copybrief KIM::SPECIES_NAME::Sr ** ** \sa KIM::SPECIES_NAME::Sr, kim_species_name_module::kim_species_name_sr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Sr; /** ** \brief \copybrief KIM::SPECIES_NAME::Y ** ** \sa KIM::SPECIES_NAME::Y, kim_species_name_module::kim_species_name_y ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Y; /** ** \brief \copybrief KIM::SPECIES_NAME::Zr ** ** \sa KIM::SPECIES_NAME::Zr, kim_species_name_module::kim_species_name_zr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Zr; /** ** \brief \copybrief KIM::SPECIES_NAME::Nb ** ** \sa KIM::SPECIES_NAME::Nb, kim_species_name_module::kim_species_name_nb ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Nb; /** ** \brief \copybrief KIM::SPECIES_NAME::Mo ** ** \sa KIM::SPECIES_NAME::Mo, kim_species_name_module::kim_species_name_mo ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Mo; /** ** \brief \copybrief KIM::SPECIES_NAME::Tc ** ** \sa KIM::SPECIES_NAME::Tc, kim_species_name_module::kim_species_name_tc ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Tc; /** ** \brief \copybrief KIM::SPECIES_NAME::Ru ** ** \sa KIM::SPECIES_NAME::Ru, kim_species_name_module::kim_species_name_ru ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ru; /** ** \brief \copybrief KIM::SPECIES_NAME::Rh ** ** \sa KIM::SPECIES_NAME::Rh, kim_species_name_module::kim_species_name_rh ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Rh; /** ** \brief \copybrief KIM::SPECIES_NAME::Pd ** ** \sa KIM::SPECIES_NAME::Pd, kim_species_name_module::kim_species_name_pd ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pd; /** ** \brief \copybrief KIM::SPECIES_NAME::Ag ** ** \sa KIM::SPECIES_NAME::Ag, kim_species_name_module::kim_species_name_ag ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ag; /** ** \brief \copybrief KIM::SPECIES_NAME::Cd ** ** \sa KIM::SPECIES_NAME::Cd, kim_species_name_module::kim_species_name_cd ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cd; /** ** \brief \copybrief KIM::SPECIES_NAME::In ** ** \sa KIM::SPECIES_NAME::In, kim_species_name_module::kim_species_name_in ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_In; /** ** \brief \copybrief KIM::SPECIES_NAME::Sn ** ** \sa KIM::SPECIES_NAME::Sn, kim_species_name_module::kim_species_name_sn ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Sn; /** ** \brief \copybrief KIM::SPECIES_NAME::Sb ** ** \sa KIM::SPECIES_NAME::Sb, kim_species_name_module::kim_species_name_sb ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Sb; /** ** \brief \copybrief KIM::SPECIES_NAME::Te ** ** \sa KIM::SPECIES_NAME::Te, kim_species_name_module::kim_species_name_te ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Te; /** ** \brief \copybrief KIM::SPECIES_NAME::I ** ** \sa KIM::SPECIES_NAME::I, kim_species_name_module::kim_species_name_i ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_I; /** ** \brief \copybrief KIM::SPECIES_NAME::Xe ** ** \sa KIM::SPECIES_NAME::Xe, kim_species_name_module::kim_species_name_xe ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Xe; /** ** \brief \copybrief KIM::SPECIES_NAME::Cs ** ** \sa KIM::SPECIES_NAME::Cs, kim_species_name_module::kim_species_name_cs ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cs; /** ** \brief \copybrief KIM::SPECIES_NAME::Ba ** ** \sa KIM::SPECIES_NAME::Ba, kim_species_name_module::kim_species_name_ba ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ba; /** ** \brief \copybrief KIM::SPECIES_NAME::La ** ** \sa KIM::SPECIES_NAME::La, kim_species_name_module::kim_species_name_la ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_La; /** ** \brief \copybrief KIM::SPECIES_NAME::Ce ** ** \sa KIM::SPECIES_NAME::Ce, kim_species_name_module::kim_species_name_ce ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ce; /** ** \brief \copybrief KIM::SPECIES_NAME::Pr ** ** \sa KIM::SPECIES_NAME::Pr, kim_species_name_module::kim_species_name_pr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pr; /** ** \brief \copybrief KIM::SPECIES_NAME::Nd ** ** \sa KIM::SPECIES_NAME::Nd, kim_species_name_module::kim_species_name_nd ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Nd; /** ** \brief \copybrief KIM::SPECIES_NAME::Pm ** ** \sa KIM::SPECIES_NAME::Pm, kim_species_name_module::kim_species_name_pm ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pm; /** ** \brief \copybrief KIM::SPECIES_NAME::Sm ** ** \sa KIM::SPECIES_NAME::Sm, kim_species_name_module::kim_species_name_sm ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Sm; /** ** \brief \copybrief KIM::SPECIES_NAME::Eu ** ** \sa KIM::SPECIES_NAME::Eu, kim_species_name_module::kim_species_name_eu ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Eu; /** ** \brief \copybrief KIM::SPECIES_NAME::Gd ** ** \sa KIM::SPECIES_NAME::Gd, kim_species_name_module::kim_species_name_gd ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Gd; /** ** \brief \copybrief KIM::SPECIES_NAME::Tb ** ** \sa KIM::SPECIES_NAME::Tb, kim_species_name_module::kim_species_name_tb ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Tb; /** ** \brief \copybrief KIM::SPECIES_NAME::Dy ** ** \sa KIM::SPECIES_NAME::Dy, kim_species_name_module::kim_species_name_dy ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Dy; /** ** \brief \copybrief KIM::SPECIES_NAME::Ho ** ** \sa KIM::SPECIES_NAME::Ho, kim_species_name_module::kim_species_name_ho ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ho; /** ** \brief \copybrief KIM::SPECIES_NAME::Er ** ** \sa KIM::SPECIES_NAME::Er, kim_species_name_module::kim_species_name_er ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Er; /** ** \brief \copybrief KIM::SPECIES_NAME::Tm ** ** \sa KIM::SPECIES_NAME::Tm, kim_species_name_module::kim_species_name_tm ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Tm; /** ** \brief \copybrief KIM::SPECIES_NAME::Yb ** ** \sa KIM::SPECIES_NAME::Yb, kim_species_name_module::kim_species_name_yb ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Yb; /** ** \brief \copybrief KIM::SPECIES_NAME::Lu ** ** \sa KIM::SPECIES_NAME::Lu, kim_species_name_module::kim_species_name_lu ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Lu; /** ** \brief \copybrief KIM::SPECIES_NAME::Hf ** ** \sa KIM::SPECIES_NAME::Hf, kim_species_name_module::kim_species_name_hf ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Hf; /** ** \brief \copybrief KIM::SPECIES_NAME::Ta ** ** \sa KIM::SPECIES_NAME::Ta, kim_species_name_module::kim_species_name_ta ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ta; /** ** \brief \copybrief KIM::SPECIES_NAME::W ** ** \sa KIM::SPECIES_NAME::W, kim_species_name_module::kim_species_name_w ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_W; /** ** \brief \copybrief KIM::SPECIES_NAME::Re ** ** \sa KIM::SPECIES_NAME::Re, kim_species_name_module::kim_species_name_re ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Re; /** ** \brief \copybrief KIM::SPECIES_NAME::Os ** ** \sa KIM::SPECIES_NAME::Os, kim_species_name_module::kim_species_name_os ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Os; /** ** \brief \copybrief KIM::SPECIES_NAME::Ir ** ** \sa KIM::SPECIES_NAME::Ir, kim_species_name_module::kim_species_name_ir ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ir; /** ** \brief \copybrief KIM::SPECIES_NAME::Pt ** ** \sa KIM::SPECIES_NAME::Pt, kim_species_name_module::kim_species_name_pt ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pt; /** ** \brief \copybrief KIM::SPECIES_NAME::Au ** ** \sa KIM::SPECIES_NAME::Au, kim_species_name_module::kim_species_name_au ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Au; /** ** \brief \copybrief KIM::SPECIES_NAME::Hg ** ** \sa KIM::SPECIES_NAME::Hg, kim_species_name_module::kim_species_name_hg ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Hg; /** ** \brief \copybrief KIM::SPECIES_NAME::Tl ** ** \sa KIM::SPECIES_NAME::Tl, kim_species_name_module::kim_species_name_tl ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Tl; /** ** \brief \copybrief KIM::SPECIES_NAME::Pb ** ** \sa KIM::SPECIES_NAME::Pb, kim_species_name_module::kim_species_name_pb ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pb; /** ** \brief \copybrief KIM::SPECIES_NAME::Bi ** ** \sa KIM::SPECIES_NAME::Bi, kim_species_name_module::kim_species_name_bi ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Bi; /** ** \brief \copybrief KIM::SPECIES_NAME::Po ** ** \sa KIM::SPECIES_NAME::Po, kim_species_name_module::kim_species_name_po ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Po; /** ** \brief \copybrief KIM::SPECIES_NAME::At ** ** \sa KIM::SPECIES_NAME::At, kim_species_name_module::kim_species_name_at ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_At; /** ** \brief \copybrief KIM::SPECIES_NAME::Rn ** ** \sa KIM::SPECIES_NAME::Rn, kim_species_name_module::kim_species_name_rn ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Rn; /** ** \brief \copybrief KIM::SPECIES_NAME::Fr ** ** \sa KIM::SPECIES_NAME::Fr, kim_species_name_module::kim_species_name_fr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Fr; /** ** \brief \copybrief KIM::SPECIES_NAME::Ra ** ** \sa KIM::SPECIES_NAME::Ra, kim_species_name_module::kim_species_name_ra ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ra; /** ** \brief \copybrief KIM::SPECIES_NAME::Ac ** ** \sa KIM::SPECIES_NAME::Ac, kim_species_name_module::kim_species_name_ac ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ac; /** ** \brief \copybrief KIM::SPECIES_NAME::Th ** ** \sa KIM::SPECIES_NAME::Th, kim_species_name_module::kim_species_name_th ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Th; /** ** \brief \copybrief KIM::SPECIES_NAME::Pa ** ** \sa KIM::SPECIES_NAME::Pa, kim_species_name_module::kim_species_name_pa ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pa; /** ** \brief \copybrief KIM::SPECIES_NAME::U ** ** \sa KIM::SPECIES_NAME::U, kim_species_name_module::kim_species_name_u ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_U; /** ** \brief \copybrief KIM::SPECIES_NAME::Np ** ** \sa KIM::SPECIES_NAME::Np, kim_species_name_module::kim_species_name_np ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Np; /** ** \brief \copybrief KIM::SPECIES_NAME::Pu ** ** \sa KIM::SPECIES_NAME::Pu, kim_species_name_module::kim_species_name_pu ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Pu; /** ** \brief \copybrief KIM::SPECIES_NAME::Am ** ** \sa KIM::SPECIES_NAME::Am, kim_species_name_module::kim_species_name_am ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Am; /** ** \brief \copybrief KIM::SPECIES_NAME::Cm ** ** \sa KIM::SPECIES_NAME::Cm, kim_species_name_module::kim_species_name_cm ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cm; /** ** \brief \copybrief KIM::SPECIES_NAME::Bk ** ** \sa KIM::SPECIES_NAME::Bk, kim_species_name_module::kim_species_name_bk ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Bk; /** ** \brief \copybrief KIM::SPECIES_NAME::Cf ** ** \sa KIM::SPECIES_NAME::Cf, kim_species_name_module::kim_species_name_cf ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cf; /** ** \brief \copybrief KIM::SPECIES_NAME::Es ** ** \sa KIM::SPECIES_NAME::Es, kim_species_name_module::kim_species_name_es ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Es; /** ** \brief \copybrief KIM::SPECIES_NAME::Fm ** ** \sa KIM::SPECIES_NAME::Fm, kim_species_name_module::kim_species_name_fm ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Fm; /** ** \brief \copybrief KIM::SPECIES_NAME::Md ** ** \sa KIM::SPECIES_NAME::Md, kim_species_name_module::kim_species_name_md ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Md; /** ** \brief \copybrief KIM::SPECIES_NAME::No ** ** \sa KIM::SPECIES_NAME::No, kim_species_name_module::kim_species_name_no ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_No; /** ** \brief \copybrief KIM::SPECIES_NAME::Lr ** ** \sa KIM::SPECIES_NAME::Lr, kim_species_name_module::kim_species_name_lr ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Lr; /** ** \brief \copybrief KIM::SPECIES_NAME::Rf ** ** \sa KIM::SPECIES_NAME::Rf, kim_species_name_module::kim_species_name_rf ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Rf; /** ** \brief \copybrief KIM::SPECIES_NAME::Db ** ** \sa KIM::SPECIES_NAME::Db, kim_species_name_module::kim_species_name_db ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Db; /** ** \brief \copybrief KIM::SPECIES_NAME::Sg ** ** \sa KIM::SPECIES_NAME::Sg, kim_species_name_module::kim_species_name_sg ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Sg; /** ** \brief \copybrief KIM::SPECIES_NAME::Bh ** ** \sa KIM::SPECIES_NAME::Bh, kim_species_name_module::kim_species_name_bh ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Bh; /** ** \brief \copybrief KIM::SPECIES_NAME::Hs ** ** \sa KIM::SPECIES_NAME::Hs, kim_species_name_module::kim_species_name_hs ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Hs; /** ** \brief \copybrief KIM::SPECIES_NAME::Mt ** ** \sa KIM::SPECIES_NAME::Mt, kim_species_name_module::kim_species_name_mt ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Mt; /** ** \brief \copybrief KIM::SPECIES_NAME::Ds ** ** \sa KIM::SPECIES_NAME::Ds, kim_species_name_module::kim_species_name_ds ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ds; /** ** \brief \copybrief KIM::SPECIES_NAME::Rg ** ** \sa KIM::SPECIES_NAME::Rg, kim_species_name_module::kim_species_name_rg ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Rg; /** ** \brief \copybrief KIM::SPECIES_NAME::Cn ** ** \sa KIM::SPECIES_NAME::Cn, kim_species_name_module::kim_species_name_cn ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Cn; /** ** \brief \copybrief KIM::SPECIES_NAME::Nh ** ** \sa KIM::SPECIES_NAME::Nh, kim_species_name_module::kim_species_name_nh ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Nh; /** ** \brief \copybrief KIM::SPECIES_NAME::Fl ** ** \sa KIM::SPECIES_NAME::Fl, kim_species_name_module::kim_species_name_fl ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Fl; /** ** \brief \copybrief KIM::SPECIES_NAME::Mc ** ** \sa KIM::SPECIES_NAME::Mc, kim_species_name_module::kim_species_name_mc ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Mc; /** ** \brief \copybrief KIM::SPECIES_NAME::Lv ** ** \sa KIM::SPECIES_NAME::Lv, kim_species_name_module::kim_species_name_lv ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Lv; /** ** \brief \copybrief KIM::SPECIES_NAME::Ts ** ** \sa KIM::SPECIES_NAME::Ts, kim_species_name_module::kim_species_name_ts ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Ts; /** ** \brief \copybrief KIM::SPECIES_NAME::Og ** ** \sa KIM::SPECIES_NAME::Og, kim_species_name_module::kim_species_name_og ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_Og; /** ** \brief \copybrief KIM::SPECIES_NAME::user01 ** ** \sa KIM::SPECIES_NAME::user01, ** kim_species_name_module::kim_species_name_user01 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user01; /** ** \brief \copybrief KIM::SPECIES_NAME::user02 ** ** \sa KIM::SPECIES_NAME::user02, ** kim_species_name_module::kim_species_name_user02 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user02; /** ** \brief \copybrief KIM::SPECIES_NAME::user03 ** ** \sa KIM::SPECIES_NAME::user03, ** kim_species_name_module::kim_species_name_user03 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user03; /** ** \brief \copybrief KIM::SPECIES_NAME::user04 ** ** \sa KIM::SPECIES_NAME::user04, ** kim_species_name_module::kim_species_name_user04 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user04; /** ** \brief \copybrief KIM::SPECIES_NAME::user05 ** ** \sa KIM::SPECIES_NAME::user05, ** kim_species_name_module::kim_species_name_user05 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user05; /** ** \brief \copybrief KIM::SPECIES_NAME::user06 ** ** \sa KIM::SPECIES_NAME::user06, ** kim_species_name_module::kim_species_name_user06 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user06; /** ** \brief \copybrief KIM::SPECIES_NAME::user07 ** ** \sa KIM::SPECIES_NAME::user07, ** kim_species_name_module::kim_species_name_user07 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user07; /** ** \brief \copybrief KIM::SPECIES_NAME::user08 ** ** \sa KIM::SPECIES_NAME::user08, ** kim_species_name_module::kim_species_name_user08 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user08; /** ** \brief \copybrief KIM::SPECIES_NAME::user09 ** ** \sa KIM::SPECIES_NAME::user09, ** kim_species_name_module::kim_species_name_user09 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user09; /** ** \brief \copybrief KIM::SPECIES_NAME::user10 ** ** \sa KIM::SPECIES_NAME::user10, ** kim_species_name_module::kim_species_name_user10 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user10; /** ** \brief \copybrief KIM::SPECIES_NAME::user11 ** ** \sa KIM::SPECIES_NAME::user11, ** kim_species_name_module::kim_species_name_user11 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user11; /** ** \brief \copybrief KIM::SPECIES_NAME::user12 ** ** \sa KIM::SPECIES_NAME::user12, ** kim_species_name_module::kim_species_name_user12 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user12; /** ** \brief \copybrief KIM::SPECIES_NAME::user13 ** ** \sa KIM::SPECIES_NAME::user13, ** kim_species_name_module::kim_species_name_user13 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user13; /** ** \brief \copybrief KIM::SPECIES_NAME::user14 ** ** \sa KIM::SPECIES_NAME::user14, ** kim_species_name_module::kim_species_name_user14 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user14; /** ** \brief \copybrief KIM::SPECIES_NAME::user15 ** ** \sa KIM::SPECIES_NAME::user15, ** kim_species_name_module::kim_species_name_user15 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user15; /** ** \brief \copybrief KIM::SPECIES_NAME::user16 ** ** \sa KIM::SPECIES_NAME::user16, ** kim_species_name_module::kim_species_name_user16 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user16; /** ** \brief \copybrief KIM::SPECIES_NAME::user17 ** ** \sa KIM::SPECIES_NAME::user17, ** kim_species_name_module::kim_species_name_user17 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user17; /** ** \brief \copybrief KIM::SPECIES_NAME::user18 ** ** \sa KIM::SPECIES_NAME::user18, ** kim_species_name_module::kim_species_name_user18 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user18; /** ** \brief \copybrief KIM::SPECIES_NAME::user19 ** ** \sa KIM::SPECIES_NAME::user19, ** kim_species_name_module::kim_species_name_user19 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user19; /** ** \brief \copybrief KIM::SPECIES_NAME::user20 ** ** \sa KIM::SPECIES_NAME::user20, ** kim_species_name_module::kim_species_name_user20 ** ** \since 2.0 **/ extern KIM_SpeciesName const KIM_SPECIES_NAME_user20; /** ** \brief \copybrief KIM::SPECIES_NAME::GetNumberOfSpeciesNames ** ** \sa KIM::SPECIES_NAME::GetNumberOfSpeciesNames, ** kim_species_name_module::kim_get_number_of_species_names ** ** \since 2.0 **/ void KIM_SPECIES_NAME_GetNumberOfSpeciesNames(int * const numberOfSpeciesNames); /** ** \brief \copybrief KIM::SPECIES_NAME::GetSpeciesName ** ** \sa KIM::SPECIES_NAME::GetSpeciesName, ** kim_species_name_module::kim_get_species_name ** ** \since 2.0 **/ int KIM_SPECIES_NAME_GetSpeciesName(int const index, KIM_SpeciesName * const speciesName); #endif /* KIM_SPECIES_NAME_H_ */ kim-api-2.3.0-git/c/include/KIM_SupportStatus.h000066400000000000000000000133721421473465500212430ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SUPPORT_STATUS_H_ #define KIM_SUPPORT_STATUS_H_ /** ** \brief \copybrief KIM::SupportStatus ** ** \sa KIM::SupportStatus, kim_support_status_module::kim_support_status_type ** ** \since 2.0 **/ struct KIM_SupportStatus { /** ** \brief \copybrief KIM::SupportStatus::supportStatusID ** ** \sa KIM::SupportStatus::supportStatusID, ** kim_support_status_module::kim_support_status_type::support_status_id ** ** \since 2.0 **/ int supportStatusID; }; #ifndef KIM_SUPPORT_STATUS_DEFINED_ #define KIM_SUPPORT_STATUS_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_SupportStatus KIM_SupportStatus; #endif /** ** \brief \copybrief KIM::SupportStatus::SupportStatus(std::string const &) ** ** \sa KIM::SupportStatus::SupportStatus(std::string const &), ** kim_support_status_module::kim_from_string ** ** \since 2.0 **/ KIM_SupportStatus KIM_SupportStatus_FromString(char const * const str); /** ** \brief \copybrief KIM::SupportStatus::Known ** ** \sa KIM::SupportStatus::Known, kim_support_status_module::kim_known ** ** \since 2.0 **/ int KIM_SupportStatus_Known(KIM_SupportStatus const supportStatus); /** ** \brief \copybrief KIM::SupportStatus::operator==() ** ** \sa KIM::SupportStatus::operator==(), ** kim_support_status_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_SupportStatus_Equal(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs); /** ** \brief \copybrief KIM::SupportStatus::operator!=() ** ** \sa KIM::SupportStatus::operator!=(), ** kim_support_status_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_SupportStatus_NotEqual(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs); /** ** \brief \copybrief KIM::SupportStatus::ToString ** ** \sa KIM::SupportStatus::ToString, kim_support_status_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_SupportStatus_ToString(KIM_SupportStatus const supportStatus); /** ** \brief \copybrief KIM::SUPPORT_STATUS::requiredByAPI ** ** \sa KIM::SUPPORT_STATUS::requiredByAPI, ** kim_support_status_module::kim_support_status_required_by_api ** ** \since 2.0 **/ extern KIM_SupportStatus const KIM_SUPPORT_STATUS_requiredByAPI; /** ** \brief \copybrief KIM::SUPPORT_STATUS::notSupported ** ** \sa KIM::SUPPORT_STATUS::notSupported, ** kim_support_status_module::kim_support_status_not_supported ** ** \since 2.0 **/ extern KIM_SupportStatus const KIM_SUPPORT_STATUS_notSupported; /** ** \brief \copybrief KIM::SUPPORT_STATUS::required ** ** \sa KIM::SUPPORT_STATUS::required, ** kim_support_status_module::kim_support_status_required ** ** \since 2.0 **/ extern KIM_SupportStatus const KIM_SUPPORT_STATUS_required; /** ** \brief \copybrief KIM::SUPPORT_STATUS::optional ** ** \sa KIM::SUPPORT_STATUS::optional, ** kim_support_status_module::kim_support_status_optional ** ** \since 2.0 **/ extern KIM_SupportStatus const KIM_SUPPORT_STATUS_optional; /** ** \brief \copybrief KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses ** ** \sa KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses, ** kim_support_status_module::kim_get_number_of_support_statuses ** ** \since 2.0 **/ void KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses( int * const numberOfSupportStatuses); /** ** \brief \copybrief KIM::SUPPORT_STATUS::GetSupportStatus ** ** \sa KIM::SUPPORT_STATUS::GetSupportStatus, ** kim_support_status_module::kim_get_support_status ** ** \since 2.0 **/ int KIM_SUPPORT_STATUS_GetSupportStatus( int const index, KIM_SupportStatus * const supportStatus); #endif /* KIM_SUPPORT_STATUS_H_ */ kim-api-2.3.0-git/c/include/KIM_SupportedExtensions.h000066400000000000000000000075061421473465500224320ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SUPPORTED_EXTENSIONS_H_ #define KIM_SUPPORTED_EXTENSIONS_H_ #define KIM_SUPPORTED_EXTENSIONS_ID "KIM_SupportedExtensions" #define KIM_MAX_EXTENSION_ID_LENGTH 128 #define KIM_MAX_NUMBER_OF_EXTENSIONS 64 /** ** \brief \copybrief KIM::SupportedExtensions ** ** \sa KIM::SupportedExtensions, ** kim_supported_extensions_module::kim_supported_extensions_type ** ** \since 2.0 **/ struct KIM_SupportedExtensions { /** ** \brief \copybrief KIM::SupportedExtensions::numberOfSupportedExtensions ** ** \sa KIM::SupportedExtensions::numberOfSupportedExtensions, ** kim_supported_extensions_module::kim_supported_extensions_type::number_of_supported_extensions ** ** \since 2.0 **/ int numberOfSupportedExtensions; /** ** \brief \copybrief KIM::SupportedExtensions::supportedExtensionID ** ** \sa KIM::SupportedExtensions::supportedExtensionID, ** kim_supported_extensions_module::kim_supported_extensions_type::supported_extension_id ** ** \since 2.0 **/ char supportedExtensionID[KIM_MAX_NUMBER_OF_EXTENSIONS] [KIM_MAX_EXTENSION_ID_LENGTH]; /** ** \brief \copybrief KIM::SupportedExtensions::supportedExtensionRequired ** ** \sa KIM::SupportedExtensions::supportedExtensionRequired, ** kim_supported_extensions_module::kim_supported_extensions_type::supported_extension_required ** ** \since 2.0 **/ int supportedExtensionRequired[KIM_MAX_NUMBER_OF_EXTENSIONS]; }; #ifndef KIM_SUPPORTED_EXTENSIONS_DEFINED_ #define KIM_SUPPORTED_EXTENSIONS_DEFINED_ typedef struct KIM_SupportedExtensions KIM_SupportedExtensions; #endif #endif /* KIM_SUPPORTED_EXTENSIONS_H_ */ kim-api-2.3.0-git/c/include/KIM_TemperatureUnit.h000066400000000000000000000126001421473465500215110ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_TEMPERATURE_UNIT_H_ #define KIM_TEMPERATURE_UNIT_H_ /** ** \brief \copybrief KIM::TemperatureUnit ** ** \sa KIM::TemperatureUnit, *kim_temperature_unit_module::kim_temperature_unit_type ** ** \since 2.0 **/ struct KIM_TemperatureUnit { /** ** \brief \copybrief KIM::TemperatureUnit::temperatureUnitID ** ** \sa KIM::TemperatureUnit::temperatureUnitID, ** kim_temperature_unit_module::kim_temperature_unit_type::temperature_unit_id ** ** \since 2.0 **/ int temperatureUnitID; }; #ifndef KIM_TEMPERATURE_UNIT_DEFINED_ #define KIM_TEMPERATURE_UNIT_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_TemperatureUnit KIM_TemperatureUnit; #endif /** ** \brief \copybrief KIM::TemperatureUnit::TemperatureUnit(std::string const &) ** ** \sa KIM::TemperatureUnit::TemperatureUnit(std::string const &), ** kim_temperature_unit_module::kim_from_string ** ** \since 2.0 **/ KIM_TemperatureUnit KIM_TemperatureUnit_FromString(char const * const str); /** ** \brief \copybrief KIM::TemperatureUnit::Known ** ** \sa KIM::TemperatureUnit::Known, kim_temperature_unit_module::kim_known ** ** \since 2.0 **/ int KIM_TemperatureUnit_Known(KIM_TemperatureUnit const temperatureUnit); /** ** \brief \copybrief KIM::TemperatureUnit::operator==() ** ** \sa KIM::TemperatureUnit::operator==(), ** kim_temperature_unit_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_TemperatureUnit_Equal(KIM_TemperatureUnit const lhs, KIM_TemperatureUnit const rhs); /** ** \brief \copybrief KIM::TemperatureUnit::operator!=() ** ** \sa KIM::TemperatureUnit::operator!=(), ** kim_temperature_unit_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_TemperatureUnit_NotEqual(KIM_TemperatureUnit const lhs, KIM_TemperatureUnit const rhs); /** ** \brief \copybrief KIM::TemperatureUnit::ToString ** ** \sa KIM::TemperatureUnit::ToString, ** kim_temperature_unit_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_TemperatureUnit_ToString(KIM_TemperatureUnit const temperatureUnit); /** ** \brief \copybrief KIM::TEMPERATURE_UNIT::unused ** ** \sa KIM::TEMPERATURE_UNIT::unused, ** kim_temperature_unit_module::kim_temperature_unit_unused ** ** \since 2.0 **/ extern KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_unused; /** ** \brief \copybrief KIM::TEMPERATURE_UNIT::K ** ** \sa KIM::TEMPERATURE_UNIT::K, ** kim_temperature_unit_module::kim_temperature_unit_k ** ** \since 2.0 **/ extern KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K; /** ** \brief \copybrief KIM::TEMPERATURE_UNIT::GetNumberOfTemperatureUnits ** ** \sa KIM::TEMPERATURE_UNIT::GetNumberOfTemperatureUnits, ** kim_temperature_unit_module::kim_get_number_of_temperature_units ** ** \since 2.0 **/ void KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits( int * const numberOfTemperatureUnits); /** ** \brief \copybrief KIM::TEMPERATURE_UNIT::GetTemperatureUnit ** ** \sa KIM::TEMPERATURE_UNIT::GetTemperatureUnit, ** kim_temperature_unit_module::kim_get_temperature_unit ** ** \since 2.0 **/ int KIM_TEMPERATURE_UNIT_GetTemperatureUnit( int const index, KIM_TemperatureUnit * const temperatureUnit); #endif /* KIM_TEMPERATURE_UNIT_H_ */ kim-api-2.3.0-git/c/include/KIM_TimeUnit.h000066400000000000000000000123741421473465500201220ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_TIME_UNIT_H_ #define KIM_TIME_UNIT_H_ /** ** \brief \copybrief KIM::TimeUnit ** ** \sa KIM::TimeUnit, kim_time_unit_module::kim_time_unit_type ** ** \since 2.0 **/ struct KIM_TimeUnit { /** ** \brief \copybrief KIM::TimeUnit::timeUnitID ** ** \sa KIM::TimeUnit::timeUnitID, ** kim_time_unit_module::kim_time_unit_type::time_unit_id ** ** \since 2.0 **/ int timeUnitID; }; #ifndef KIM_TIME_UNIT_DEFINED_ #define KIM_TIME_UNIT_DEFINED_ /** ** \brief Convenience typedef. ** ** \since 2.0 **/ typedef struct KIM_TimeUnit KIM_TimeUnit; #endif /** ** \brief \copybrief KIM::TimeUnit::TimeUnit(std::string const &) ** ** \sa KIM::TimeUnit::TimeUnit(std::string const &), ** kim_time_unit_module::kim_from_string ** ** \since 2.0 **/ KIM_TimeUnit KIM_TimeUnit_FromString(char const * const str); /** ** \brief \copybrief KIM::TimeUnit::Known ** ** \sa KIM::TimeUnit::Known, kim_time_unit_module::kim_known ** ** \since 2.0 **/ int KIM_TimeUnit_Known(KIM_TimeUnit const timeUnit); /** ** \brief \copybrief KIM::TimeUnit::operator==() ** ** \sa KIM::TimeUnit::operator==(), kim_time_unit_module::operator(.eq.) ** ** \since 2.0 **/ int KIM_TimeUnit_Equal(KIM_TimeUnit const lhs, KIM_TimeUnit const rhs); /** ** \brief \copybrief KIM::TimeUnit::operator!=() ** ** \sa KIM::TimeUnit::operator!=(), kim_time_unit_module::operator(.ne.) ** ** \since 2.0 **/ int KIM_TimeUnit_NotEqual(KIM_TimeUnit const lhs, KIM_TimeUnit const rhs); /** ** \brief \copybrief KIM::TimeUnit::ToString ** ** \sa KIM::TimeUnit::ToString, kim_time_unit_module::kim_to_string ** ** \since 2.0 **/ char const * KIM_TimeUnit_ToString(KIM_TimeUnit const timeUnit); /** ** \brief \copybrief KIM::TIME_UNIT::unused ** ** \sa KIM::TIME_UNIT::unused, kim_time_unit_module::kim_time_unit_unused ** ** \since 2.0 **/ extern KIM_TimeUnit const KIM_TIME_UNIT_unused; /** ** \brief \copybrief KIM::TIME_UNIT::fs ** ** \sa KIM::TIME_UNIT::fs, kim_time_unit_module::kim_time_unit_fs ** ** \since 2.0 **/ extern KIM_TimeUnit const KIM_TIME_UNIT_fs; /** ** \brief \copybrief KIM::TIME_UNIT::ps ** ** \sa KIM::TIME_UNIT::ps, kim_time_unit_module::kim_time_unit_ps ** ** \since 2.0 **/ extern KIM_TimeUnit const KIM_TIME_UNIT_ps; /** ** \brief \copybrief KIM::TIME_UNIT::ns ** ** \sa KIM::TIME_UNIT::ns, kim_time_unit_module::kim_time_unit_ns ** ** \since 2.0 **/ extern KIM_TimeUnit const KIM_TIME_UNIT_ns; /** ** \brief \copybrief KIM::TIME_UNIT::s ** ** \sa KIM::TIME_UNIT::s, kim_time_unit_module::kim_time_unit_s ** ** \since 2.0 **/ extern KIM_TimeUnit const KIM_TIME_UNIT_s; /** ** \brief \copybrief KIM::TIME_UNIT::GetNumberOfTimeUnits ** ** \sa KIM::TIME_UNIT::GetNumberOfTimeUnits, ** kim_time_unit_module::kim_get_number_of_time_units ** ** \since 2.0 **/ void KIM_TIME_UNIT_GetNumberOfTimeUnits(int * const numberOfTimeUnits); /** ** \brief \copybrief KIM::TIME_UNIT::GetTimeUnit ** ** \sa KIM::TIME_UNIT::GetTimeUnit, kim_time_unit_module::kim_get_time_unit ** ** \since 2.0 **/ int KIM_TIME_UNIT_GetTimeUnit(int const index, KIM_TimeUnit * const timeUnit); #endif /* KIM_TIME_UNIT_H_ */ kim-api-2.3.0-git/c/include/KIM_UnitSystem.h000066400000000000000000000051461421473465500205070ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_UNIT_SYSTEM_H_ #define KIM_UNIT_SYSTEM_H_ /* IWYU pragma: begin_exports */ #ifndef KIM_LENGTH_UNIT_H_ #include "KIM_LengthUnit.h" #endif #ifndef KIM_ENERGY_UNIT_H_ #include "KIM_EnergyUnit.h" #endif #ifndef KIM_CHARGE_UNIT_H_ #include "KIM_ChargeUnit.h" #endif #ifndef KIM_TEMPERATURE_UNIT_H_ #include "KIM_TemperatureUnit.h" #endif #ifndef KIM_TIME_UNIT_H_ #include "KIM_TimeUnit.h" #endif /* IWYU pragma: end_exports */ #endif /* KIM_UNIT_SYSTEM_H_ */ kim-api-2.3.0-git/c/include/KIM_Version.h.in000066400000000000000000000073551421473465500204210ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_VERSION_H_ #define KIM_VERSION_H_ /** ** \brief The major version number of the %KIM API ** ** The %KIM API conforms to Semantic Versioning ** 2.0.0. ** ** \since 2.0 **/ /* clang-format off */ #define KIM_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ /* clang-format on */ /** ** \brief The minor version number of the %KIM API ** ** The %KIM API conforms to Semantic Versioning ** 2.0.0. ** ** \since 2.0 **/ /* clang-format off */ #define KIM_VERSION_MINOR @PROJECT_VERSION_MINOR@ /* clang-format on */ /** ** \brief The patch version number of the %KIM API ** ** The %KIM API conforms to Semantic Versioning ** 2.0.0. ** ** \since 2.0 **/ /* clang-format off */ #define KIM_VERSION_PATCH @PROJECT_VERSION_PATCH@ /* clang-format on */ /** ** \brief The prerelease version string of the %KIM API ** ** The %KIM API conforms to Semantic Versioning ** 2.0.0. ** ** \since 2.0 **/ #define KIM_VERSION_PRERELEASE "@PROJECT_VERSION_PRERELEASE@" /** ** \brief The build metadata version string of the %KIM API ** ** The %KIM API conforms to Semantic Versioning ** 2.0.0. ** ** \since 2.0 **/ #define KIM_VERSION_BUILD_METADATA "@PROJECT_VERSION_BUILD_METADATA@" /** ** \brief The complete version string of the %KIM API ** ** The %KIM API conforms to Semantic Versioning ** 2.0.0. ** ** \since 2.0 **/ #define KIM_VERSION_STRING "@PROJECT_VERSION_STRING@" #endif /* KIM_VERSION_H_ */ kim-api-2.3.0-git/c/src/000077500000000000000000000000001421473465500146505ustar00rootroot00000000000000kim-api-2.3.0-git/c/src/CMakeLists.txt000066400000000000000000000054741421473465500174220ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # set(C_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ChargeUnit_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Collection_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Collections_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_CollectionItemType_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeArgumentName_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeArguments_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeCallbackName_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_DataType_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_EnergyUnit_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LanguageName_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LengthUnit_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Log_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LogVerbosity_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Model_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelCompute_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelComputeArguments_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelComputeArgumentsCreate_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelComputeArgumentsDestroy_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelCreate_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelExtension_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelDestroy_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelDriverCreate_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelRefresh_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelRoutineName_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelWriteParameterizedModel_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Numbering_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SemVer_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SimulatorModel_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SpeciesName_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SupportStatus_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_TemperatureUnit_c.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_TimeUnit_c.cpp ) target_sources(kim-api PRIVATE ${C_SOURCES}) kim-api-2.3.0-git/c/src/KIM_ChargeUnit_c.cpp000066400000000000000000000057151421473465500204170ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_CHARGE_UNIT_HPP_ #include "KIM_ChargeUnit.hpp" #endif extern "C" { #ifndef KIM_CHARGE_UNIT_H_ #include "KIM_ChargeUnit.h" #endif } namespace { KIM::ChargeUnit makeChargeUnitCpp(KIM_ChargeUnit const chargeUnit) { KIM::ChargeUnit const * const chargeUnitCpp = reinterpret_cast(&chargeUnit); return *chargeUnitCpp; } KIM_ChargeUnit makeChargeUnitC(KIM::ChargeUnit const chargeUnit) { KIM_ChargeUnit const * const chargeUnitC = reinterpret_cast(&chargeUnit); return *chargeUnitC; } } // namespace extern "C" { KIM_ChargeUnit KIM_ChargeUnit_FromString(char const * const str) { return makeChargeUnitC(KIM::ChargeUnit(std::string(str))); } int KIM_ChargeUnit_Known(KIM_ChargeUnit const chargeUnit) { return makeChargeUnitCpp(chargeUnit).Known(); } int KIM_ChargeUnit_Equal(KIM_ChargeUnit const lhs, KIM_ChargeUnit const rhs) { return (lhs.chargeUnitID == rhs.chargeUnitID); } int KIM_ChargeUnit_NotEqual(KIM_ChargeUnit const lhs, KIM_ChargeUnit const rhs) { return (!KIM_ChargeUnit_Equal(lhs, rhs)); } char const * KIM_ChargeUnit_ToString(KIM_ChargeUnit const chargeUnit) { return makeChargeUnitCpp(chargeUnit).ToString().c_str(); } #include "KIM_ChargeUnit.inc" KIM_ChargeUnit const KIM_CHARGE_UNIT_unused = {ID_unused}; KIM_ChargeUnit const KIM_CHARGE_UNIT_C = {ID_C}; KIM_ChargeUnit const KIM_CHARGE_UNIT_e = {ID_e}; KIM_ChargeUnit const KIM_CHARGE_UNIT_statC = {ID_statC}; void KIM_CHARGE_UNIT_GetNumberOfChargeUnits(int * const numberOfChargeUnits) { KIM::CHARGE_UNIT::GetNumberOfChargeUnits(numberOfChargeUnits); } int KIM_CHARGE_UNIT_GetChargeUnit(int const index, KIM_ChargeUnit * const chargeUnit) { KIM::ChargeUnit chargeUnitCpp; int error = KIM::CHARGE_UNIT::GetChargeUnit(index, &chargeUnitCpp); if (error) return error; *chargeUnit = makeChargeUnitC(chargeUnitCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_CollectionItemType_c.cpp000066400000000000000000000071441421473465500221400ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif extern "C" { #ifndef KIM_COLLECTION_ITEM_TYPE_H_ #include "KIM_CollectionItemType.h" #endif } // extern "C" namespace { KIM::CollectionItemType makeCollectionItemTypeCpp(KIM_CollectionItemType const collectionItemType) { KIM::CollectionItemType const * const collectionItemTypeCpp = reinterpret_cast(&collectionItemType); return *collectionItemTypeCpp; } KIM_CollectionItemType makeCollectionItemTypeC(KIM::CollectionItemType const collectionItemType) { KIM_CollectionItemType const * const collectionItemTypeC = reinterpret_cast(&collectionItemType); return *collectionItemTypeC; } } // namespace extern "C" { KIM_CollectionItemType KIM_CollectionItemType_FromString(char const * const str) { return makeCollectionItemTypeC(KIM::CollectionItemType(std::string(str))); } int KIM_CollectionItemType_Known( KIM_CollectionItemType const collectionItemType) { return makeCollectionItemTypeCpp(collectionItemType).Known(); } int KIM_CollectionItemType_Equal(KIM_CollectionItemType const lhs, KIM_CollectionItemType const rhs) { return (lhs.collectionItemTypeID == rhs.collectionItemTypeID); } int KIM_CollectionItemType_NotEqual(KIM_CollectionItemType const lhs, KIM_CollectionItemType const rhs) { return (!KIM_CollectionItemType_Equal(lhs, rhs)); } char const * KIM_CollectionItemType_ToString(KIM_CollectionItemType const collectionItemType) { return makeCollectionItemTypeCpp(collectionItemType).ToString().c_str(); } #include "KIM_CollectionItemType.inc" KIM_CollectionItemType const KIM_COLLECTION_ITEM_TYPE_modelDriver = {ID_modelDriver}; KIM_CollectionItemType const KIM_COLLECTION_ITEM_TYPE_portableModel = {ID_portableModel}; KIM_CollectionItemType const KIM_COLLECTION_ITEM_TYPE_simulatorModel = {ID_simulatorModel}; void KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes( int * const numberOfCollectionItemTypes) { KIM::COLLECTION_ITEM_TYPE::GetNumberOfCollectionItemTypes( numberOfCollectionItemTypes); } int KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType( int const index, KIM_CollectionItemType * const collectionItemType) { KIM::CollectionItemType collectionItemTypeCpp; int error = KIM::COLLECTION_ITEM_TYPE::GetCollectionItemType( index, &collectionItemTypeCpp); if (error) return error; *collectionItemType = makeCollectionItemTypeC(collectionItemTypeCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_Collection_c.cpp000066400000000000000000000060471421473465500204600ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_COLLECTION_HPP_ #include "KIM_Collection.hpp" #endif extern "C" { #ifndef KIM_COLLECTION_H_ #include "KIM_Collection.h" #endif } // extern "C" namespace { KIM::Collection makeCollectionCpp(KIM_Collection const collection) { KIM::Collection const * const collectionCpp = reinterpret_cast(&collection); return *collectionCpp; } KIM_Collection makeCollectionC(KIM::Collection const collection) { KIM_Collection const * const collectionC = reinterpret_cast(&collection); return *collectionC; } } // namespace extern "C" { KIM_Collection KIM_Collection_FromString(char const * const str) { return makeCollectionC(KIM::Collection(std::string(str))); } int KIM_Collection_Known(KIM_Collection const collection) { return makeCollectionCpp(collection).Known(); } int KIM_Collection_Equal(KIM_Collection const lhs, KIM_Collection const rhs) { return (lhs.collectionID == rhs.collectionID); } int KIM_Collection_NotEqual(KIM_Collection const lhs, KIM_Collection const rhs) { return (!KIM_Collection_Equal(lhs, rhs)); } char const * KIM_Collection_ToString(KIM_Collection const collection) { return makeCollectionCpp(collection).ToString().c_str(); } #include "KIM_Collection.inc" KIM_Collection const KIM_COLLECTION_system = {ID_system}; KIM_Collection const KIM_COLLECTION_user = {ID_user}; KIM_Collection const KIM_COLLECTION_environmentVariable = {ID_environmentVariable}; KIM_Collection const KIM_COLLECTION_currentWorkingDirectory = {ID_currentWorkingDirectory}; void KIM_COLLECTION_GetNumberOfCollections(int * const numberOfCollections) { KIM::COLLECTION::GetNumberOfCollections(numberOfCollections); } int KIM_COLLECTION_GetCollection(int const index, KIM_Collection * const collection) { KIM::Collection collectionCpp; int error = KIM::COLLECTION::GetCollection(index, &collectionCpp); if (error) return error; *collection = makeCollectionC(collectionCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_Collections_c.cpp000066400000000000000000000353031421473465500206400ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #include #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_COLLECTION_HPP_ #include "KIM_Collection.hpp" #endif extern "C" { #ifndef KIM_COLLECTION_H_ #include "KIM_Collection.h" #endif } // extern "C" #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif extern "C" { #ifndef KIM_COLLECTION_ITEM_TYPE_H_ #include "KIM_CollectionItemType.h" #endif } // extern "C" #ifndef KIM_COLLECTIONS_HPP_ #include "KIM_Collections.hpp" #endif extern "C" { #ifndef KIM_COLLECTIONS_H_ #include "KIM_Collections.h" #endif } // extern "C" struct KIM_Collections { void * p; }; #define CONVERT_POINTER \ KIM::Collections * pCollections \ = reinterpret_cast(collections->p) namespace { KIM::CollectionItemType makeItemTypeCpp(KIM_CollectionItemType const itemType) { return KIM::CollectionItemType(itemType.collectionItemTypeID); } KIM::Collection makeCollectionCpp(KIM_Collection const collection) { return KIM::Collection(collection.collectionID); } KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace int KIM_Collections_Create(KIM_Collections ** const collections) { KIM::Collections * pCollections; int error = KIM::Collections::Create(&pCollections); if (error) { *collections = NULL; return true; } else { (*collections) = new KIM_Collections; (*collections)->p = (void *) pCollections; return false; } } void KIM_Collections_Destroy(KIM_Collections ** const collections) { if (*collections != NULL) { KIM::Collections * pCollections = reinterpret_cast((*collections)->p); KIM::Collections::Destroy(&pCollections); } delete (*collections); *collections = NULL; } int KIM_Collections_GetItemType(KIM_Collections * const collections, char const * const itemName, KIM_CollectionItemType * const itemType) { CONVERT_POINTER; return pCollections->GetItemType( itemName, reinterpret_cast(itemType)); } int KIM_Collections_GetItemLibraryFileNameAndCollection( KIM_Collections * const collections, KIM_CollectionItemType const itemType, char const * const itemName, char const ** const fileName, KIM_Collection * const collection) { CONVERT_POINTER; std::string const * pStrFileName; int error = pCollections->GetItemLibraryFileNameAndCollection( makeItemTypeCpp(itemType), itemName, &pStrFileName, reinterpret_cast(collection)); if (error) return true; else { *fileName = pStrFileName->c_str(); return false; } } int KIM_Collections_CacheListOfItemMetadataFiles( KIM_Collections * const collections, KIM_CollectionItemType const itemType, char const * const itemName, int * const extent) { CONVERT_POINTER; return pCollections->CacheListOfItemMetadataFiles( makeItemTypeCpp(itemType), itemName, extent); } int KIM_Collections_GetItemMetadataFile( KIM_Collections * const collections, int const index, char const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, char const ** const fileString) { CONVERT_POINTER; std::string const * pStrFileName; std::string const ** ppStrFileName; if (fileName == NULL) ppStrFileName = NULL; else ppStrFileName = &pStrFileName; std::string const * pStrFileString; std::string const ** ppStrFileString; if (fileString == NULL) ppStrFileString = NULL; else ppStrFileString = &pStrFileString; int error = pCollections->GetItemMetadataFile(index, ppStrFileName, fileLength, fileRawData, availableAsString, ppStrFileString); if (error) return true; else { if (fileName != NULL) *fileName = pStrFileName->c_str(); if (fileString != NULL) { if (pStrFileString == NULL) *fileString = NULL; else *fileString = pStrFileString->c_str(); } return false; } } extern "C" { int KIM_Collections_GetItemMetadataFile_fortran( KIM_Collections * const collections, int const index, char const ** const fileName, long * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, char const ** const fileString) { unsigned int uFileLength; int error = KIM_Collections_GetItemMetadataFile(collections, index, fileName, &uFileLength, fileRawData, availableAsString, fileString); if (error) return true; else if ((sizeof(int) == sizeof(long)) && (uFileLength > INT_MAX)) { std::cerr << "* Error : long overflow for fileLength. " << __FILE__ << ":" << __LINE__ << std::endl; return true; } else { *fileLength = static_cast(uFileLength); return false; } } } // extern "C" int KIM_Collections_CacheListOfItemNamesByType( KIM_Collections * const collections, KIM_CollectionItemType const itemType, int * const extent) { CONVERT_POINTER; return pCollections->CacheListOfItemNamesByType(makeItemTypeCpp(itemType), extent); } int KIM_Collections_GetItemNameByType(KIM_Collections * const collections, int const index, char const ** const itemName) { CONVERT_POINTER; std::string const * pStrItemName; int error = pCollections->GetItemNameByType(index, &pStrItemName); if (error) return true; else { *itemName = pStrItemName->c_str(); return false; } } int KIM_Collections_CacheListOfItemNamesByCollectionAndType( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, int * const extent) { CONVERT_POINTER; return pCollections->CacheListOfItemNamesByCollectionAndType( makeCollectionCpp(collection), makeItemTypeCpp(itemType), extent); } int KIM_Collections_GetItemNameByCollectionAndType( KIM_Collections * const collections, int const index, char const ** const itemName) { CONVERT_POINTER; std::string const * pStrItemName; int error = pCollections->GetItemNameByCollectionAndType(index, &pStrItemName); if (error) return true; else { *itemName = pStrItemName->c_str(); return false; } } int KIM_Collections_GetItemLibraryFileNameByCollectionAndType( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, char const * const itemName, char const ** const fileName) { CONVERT_POINTER; std::string const * pStrFileName; int error = pCollections->GetItemLibraryFileNameByCollectionAndType( makeCollectionCpp(collection), makeItemTypeCpp(itemType), itemName, &pStrFileName); if (error) return true; else { *fileName = pStrFileName->c_str(); return false; } } int KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, char const * const itemName, int * const extent) { CONVERT_POINTER; return pCollections->CacheListOfItemMetadataFilesByCollectionAndType( makeCollectionCpp(collection), makeItemTypeCpp(itemType), itemName, extent); } int KIM_Collections_GetItemMetadataFileByCollectionAndType( KIM_Collections * const collections, int const index, char const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, char const ** const fileString) { CONVERT_POINTER; std::string const * pStrFileName; std::string const ** ppStrFileName; if (fileName == NULL) ppStrFileName = NULL; else ppStrFileName = &pStrFileName; std::string const * pStrFileString; std::string const ** ppStrFileString; if (fileString == NULL) ppStrFileString = NULL; else ppStrFileString = &pStrFileString; int error = pCollections->GetItemMetadataFileByCollectionAndType(index, ppStrFileName, fileLength, fileRawData, availableAsString, ppStrFileString); if (error) return true; else { if (fileName != NULL) *fileName = pStrFileName->c_str(); if (fileString != NULL) { if (pStrFileString == NULL) *fileString = NULL; else *fileString = pStrFileString->c_str(); } return false; } } extern "C" { int KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran( KIM_Collections * const collections, int const index, char const ** const fileName, long * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, char const ** const fileString) { unsigned int uFileLength; int error = KIM_Collections_GetItemMetadataFileByCollectionAndType( collections, index, fileName, &uFileLength, fileRawData, availableAsString, fileString); if (error) return true; else if ((sizeof(int) == sizeof(long)) && (uFileLength > INT_MAX)) { std::cerr << "* Error : long overflow for fileLength. " << __FILE__ << ":" << __LINE__ << std::endl; return true; } else { *fileLength = static_cast(uFileLength); return false; } } } // extern "C" void KIM_Collections_GetProjectNameAndSemVer( KIM_Collections * const collections, char const ** const projectName, char const ** const semVer) { CONVERT_POINTER; std::string const * pStrProjectName; std::string const ** ppStrProjectName; if (projectName == NULL) ppStrProjectName = NULL; else ppStrProjectName = &pStrProjectName; std::string const * pStrSemVer; std::string const ** ppStrSemVer; if (semVer == NULL) ppStrSemVer = NULL; else ppStrSemVer = &pStrSemVer; pCollections->GetProjectNameAndSemVer(ppStrProjectName, ppStrSemVer); if (projectName != NULL) *projectName = pStrProjectName->c_str(); if (semVer != NULL) *semVer = pStrSemVer->c_str(); } int KIM_Collections_GetEnvironmentVariableName( KIM_Collections * const collections, KIM_CollectionItemType const itemType, char const ** const name) { CONVERT_POINTER; std::string const * pStrName; int error = pCollections->GetEnvironmentVariableName( makeItemTypeCpp(itemType), &pStrName); if (error) return true; else { *name = pStrName->c_str(); return false; } } void KIM_Collections_GetConfigurationFileEnvironmentVariable( KIM_Collections * const collections, char const ** const name, char const ** const value) { CONVERT_POINTER; std::string const * pStrName; std::string const ** ppStrName; if (name == NULL) ppStrName = NULL; else ppStrName = &pStrName; std::string const * pStrValue; std::string const ** ppStrValue; if (value == NULL) ppStrValue = NULL; else ppStrValue = &pStrValue; pCollections->GetConfigurationFileEnvironmentVariable(ppStrName, ppStrValue); if (name != NULL) *name = pStrName->c_str(); if (value != NULL) *value = pStrValue->c_str(); } void KIM_Collections_GetConfigurationFileName( KIM_Collections * const collections, char const ** const fileName) { CONVERT_POINTER; std::string const * pStrFileName; pCollections->GetConfigurationFileName(&pStrFileName); *fileName = pStrFileName->c_str(); } int KIM_Collections_CacheListOfDirectoryNames( KIM_Collections * const collections, KIM_Collection const collection, KIM_CollectionItemType const itemType, int * const extent) { CONVERT_POINTER; return pCollections->CacheListOfDirectoryNames( makeCollectionCpp(collection), makeItemTypeCpp(itemType), extent); } int KIM_Collections_GetDirectoryName(KIM_Collections * const collections, int const index, char const ** const directoryName) { CONVERT_POINTER; std::string const * pStrDirectoryName; int error = pCollections->GetDirectoryName(index, &pStrDirectoryName); if (error) return true; else { *directoryName = pStrDirectoryName->c_str(); return false; } } void KIM_Collections_SetLogID(KIM_Collections * const collections, char const * const logID) { CONVERT_POINTER; pCollections->SetLogID(logID); } void KIM_Collections_PushLogVerbosity(KIM_Collections * const collections, KIM_LogVerbosity const logVerbosity) { CONVERT_POINTER; pCollections->PushLogVerbosity(makeLogVerbosityCpp(logVerbosity)); } void KIM_Collections_PopLogVerbosity(KIM_Collections * const collections) { CONVERT_POINTER; pCollections->PopLogVerbosity(); } kim-api-2.3.0-git/c/src/KIM_ComputeArgumentName_c.cpp000066400000000000000000000122411421473465500222760ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif extern "C" { #ifndef KIM_DATA_TYPE_H_ #include "KIM_DataType.h" #endif } // extern "C" #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif } // extern "C" namespace { KIM::ComputeArgumentName makeComputeArgumentNameCpp(KIM_ComputeArgumentName const computeArgumentName) { KIM::ComputeArgumentName const * const computeArgumentNameCpp = reinterpret_cast( &computeArgumentName); return *computeArgumentNameCpp; } KIM_ComputeArgumentName makeComputeArgumentNameC(KIM::ComputeArgumentName const computeArgumentName) { KIM_ComputeArgumentName const * const computeArgumentNameC = reinterpret_cast(&computeArgumentName); return *computeArgumentNameC; } KIM_DataType makeDataTypeC(KIM::DataType const dataType) { KIM_DataType const * const dataTypeC = reinterpret_cast(&dataType); return *dataTypeC; } } // namespace extern "C" { KIM_ComputeArgumentName KIM_ComputeArgumentName_FromString(char const * const str) { return makeComputeArgumentNameC(KIM::ComputeArgumentName(std::string(str))); } int KIM_ComputeArgumentName_Known( KIM_ComputeArgumentName const computeArgumentName) { return makeComputeArgumentNameCpp(computeArgumentName).Known(); } int KIM_ComputeArgumentName_Equal(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs) { return (lhs.computeArgumentNameID == rhs.computeArgumentNameID); } int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs) { return (!KIM_ComputeArgumentName_Equal(lhs, rhs)); } char const * KIM_ComputeArgumentName_ToString(KIM_ComputeArgumentName computeArgumentName) { return makeComputeArgumentNameCpp(computeArgumentName).ToString().c_str(); } // Order doesn't matter as long as all values are unique #include "KIM_ComputeArgumentName.inc" KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles = {ID_numberOfParticles}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes = {ID_particleSpeciesCodes}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing = {ID_particleContributing}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates = {ID_coordinates}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy = {ID_partialEnergy}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces = {ID_partialForces}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy = {ID_partialParticleEnergy}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialVirial = {ID_partialVirial}; KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial = {ID_partialParticleVirial}; void KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames( int * const numberOfComputeArgumentNames) { KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames( numberOfComputeArgumentNames); } int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName( int const index, KIM_ComputeArgumentName * const computeArgumentName) { KIM::ComputeArgumentName computeArgumentNameCpp; int error = KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName( index, &computeArgumentNameCpp); if (error) return error; *computeArgumentName = makeComputeArgumentNameC(computeArgumentNameCpp); return false; } int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType( KIM_ComputeArgumentName const computeArgumentName, KIM_DataType * const dataType) { KIM::ComputeArgumentName computeArgumentNameCpp = makeComputeArgumentNameCpp(computeArgumentName); KIM::DataType dataTypeCpp; int error = KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType( computeArgumentNameCpp, &dataTypeCpp); if (error) return error; *dataType = makeDataTypeC(dataTypeCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ComputeArguments_c.cpp000066400000000000000000000154541421473465500216710ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif extern "C" { #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif } // extern "C" #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif extern "C" { #ifndef KIM_SUPPORT_STATUS_H_ #include "KIM_SupportStatus.h" #endif } // extern "C" #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif } // extern "C" #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif } // extern "C" #ifndef KIM_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ComputeArguments.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_ARGUMENTS_H_ #include "KIM_ComputeArguments.h" #endif } // extern "C" struct KIM_ComputeArguments { void * p; }; #define CONVERT_POINTER \ KIM::ComputeArguments * pComputeArguments \ = reinterpret_cast(computeArguments->p) namespace { KIM::LanguageName makeLanguageNameCpp(KIM_LanguageName const languageName) { return KIM::LanguageName(languageName.languageNameID); } KIM_SupportStatus makeSupportStatusC(KIM::SupportStatus supportStatus) { KIM_SupportStatus supportStatusC = {supportStatus.supportStatusID}; return supportStatusC; } KIM::ComputeArgumentName makeComputeArgumentNameCpp(KIM_ComputeArgumentName const computeArgumentName) { return KIM::ComputeArgumentName(computeArgumentName.computeArgumentNameID); } KIM::ComputeCallbackName makeComputeCallbackNameCpp(KIM_ComputeCallbackName const computeCallbackName) { return KIM::ComputeCallbackName(computeCallbackName.computeCallbackNameID); } KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { int KIM_ComputeArguments_GetArgumentSupportStatus( KIM_ComputeArguments const * const computeArguments, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus * const supportStatus) { CONVERT_POINTER; KIM::SupportStatus supportStatusCpp; int error = pComputeArguments->GetArgumentSupportStatus( makeComputeArgumentNameCpp(computeArgumentName), &supportStatusCpp); if (error) return true; else { *supportStatus = makeSupportStatusC(supportStatusCpp); return false; } } int KIM_ComputeArguments_GetCallbackSupportStatus( KIM_ComputeArguments const * const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus * const supportStatus) { CONVERT_POINTER; KIM::SupportStatus supportStatusCpp; int error = pComputeArguments->GetCallbackSupportStatus( makeComputeCallbackNameCpp(computeCallbackName), &supportStatusCpp); if (error) return true; else { *supportStatus = makeSupportStatusC(supportStatusCpp); return false; } } int KIM_ComputeArguments_SetArgumentPointerInteger( KIM_ComputeArguments * const computeArguments, KIM_ComputeArgumentName const computeArgumentName, int const * const ptr) { CONVERT_POINTER; KIM::ComputeArgumentName argN = makeComputeArgumentNameCpp(computeArgumentName); return pComputeArguments->SetArgumentPointer(argN, ptr); } int KIM_ComputeArguments_SetArgumentPointerDouble( KIM_ComputeArguments * const computeArguments, KIM_ComputeArgumentName const computeArgumentName, double const * const ptr) { CONVERT_POINTER; KIM::ComputeArgumentName argN = makeComputeArgumentNameCpp(computeArgumentName); return pComputeArguments->SetArgumentPointer(argN, ptr); } int KIM_ComputeArguments_SetCallbackPointer( KIM_ComputeArguments * const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_LanguageName const languageName, KIM_Function * const fptr, void * const dataObject) { CONVERT_POINTER; KIM::ComputeCallbackName computeCallbackNameCpp = makeComputeCallbackNameCpp(computeCallbackName); KIM::LanguageName langN = makeLanguageNameCpp(languageName); return pComputeArguments->SetCallbackPointer( computeCallbackNameCpp, langN, fptr, dataObject); } void KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent( KIM_ComputeArguments const * const computeArguments, int * const result) { CONVERT_POINTER; return pComputeArguments->AreAllRequiredArgumentsAndCallbacksPresent(result); } void KIM_ComputeArguments_SetSimulatorBufferPointer( KIM_ComputeArguments * const computeArguments, void * const ptr) { CONVERT_POINTER; pComputeArguments->SetSimulatorBufferPointer(ptr); } void KIM_ComputeArguments_GetSimulatorBufferPointer( KIM_ComputeArguments const * const computeArguments, void ** const ptr) { CONVERT_POINTER; pComputeArguments->GetSimulatorBufferPointer(ptr); } char const * KIM_ComputeArguments_ToString( KIM_ComputeArguments const * const computeArguments) { CONVERT_POINTER; return pComputeArguments->ToString().c_str(); } void KIM_ComputeArguments_SetLogID( KIM_ComputeArguments * const computeArguments, char const * const logID) { CONVERT_POINTER; pComputeArguments->SetLogID(logID); } void KIM_ComputeArguments_PushLogVerbosity( KIM_ComputeArguments * const computeArguments, KIM_LogVerbosity const logVerbosity) { CONVERT_POINTER; pComputeArguments->PushLogVerbosity(makeLogVerbosityCpp(logVerbosity)); } void KIM_ComputeArguments_PopLogVerbosity( KIM_ComputeArguments * const computeArguments) { CONVERT_POINTER; pComputeArguments->PopLogVerbosity(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ComputeCallbackName_c.cpp000066400000000000000000000073741421473465500222230ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif } // extern "C" namespace { KIM::ComputeCallbackName makeComputeCallbackNameCpp(KIM_ComputeCallbackName const computeCallbackName) { KIM::ComputeCallbackName const * const computeCallbackNameCpp = reinterpret_cast( &computeCallbackName); return *computeCallbackNameCpp; } KIM_ComputeCallbackName makeComputeCallbackNameC(KIM::ComputeCallbackName const computeCallbackName) { KIM_ComputeCallbackName const * const computeCallbackNameC = reinterpret_cast(&computeCallbackName); return *computeCallbackNameC; } } // namespace extern "C" { KIM_ComputeCallbackName KIM_ComputeCallbackName_FromString(char const * const str) { return makeComputeCallbackNameC(KIM::ComputeCallbackName(std::string(str))); } int KIM_ComputeCallbackName_Known( KIM_ComputeCallbackName const computeCallbackName) { return makeComputeCallbackNameCpp(computeCallbackName).Known(); } int KIM_ComputeCallbackName_Equal(KIM_ComputeCallbackName const lhs, KIM_ComputeCallbackName const rhs) { return (lhs.computeCallbackNameID == rhs.computeCallbackNameID); } int KIM_ComputeCallbackNameNot_Equal(KIM_ComputeCallbackName const lhs, KIM_ComputeCallbackName const rhs) { return (!KIM_ComputeCallbackName_Equal(lhs, rhs)); } char const * KIM_ComputeCallbackName_ToString(KIM_ComputeCallbackName computeCallbackName) { return makeComputeCallbackNameCpp(computeCallbackName).ToString().c_str(); } // Order doesn't matter as long as all values are unique #include "KIM_ComputeCallbackName.inc" KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_GetNeighborList = {ID_GetNeighborList}; KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm = {ID_ProcessDEDrTerm}; KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term = {ID_ProcessD2EDr2Term}; void KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames( int * const numberOfComputeCallbackNames) { KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames( numberOfComputeCallbackNames); } int KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName( int const index, KIM_ComputeCallbackName * const computeCallbackName) { KIM::ComputeCallbackName computeCallbackNameCpp; int error = KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName( index, &computeCallbackNameCpp); if (error) return error; *computeCallbackName = makeComputeCallbackNameC(computeCallbackNameCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_DataType_c.cpp000066400000000000000000000053241421473465500200750ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif extern "C" { #ifndef KIM_DATA_TYPE_H_ #include "KIM_DataType.h" #endif } // extern "C" namespace { KIM::DataType makeDataTypeCpp(KIM_DataType const dataType) { KIM::DataType const * const dataTypeCpp = reinterpret_cast(&dataType); return *dataTypeCpp; } KIM_DataType makeDataTypeC(KIM::DataType const dataType) { KIM_DataType const * const dataTypeC = reinterpret_cast(&dataType); return *dataTypeC; } } // namespace extern "C" { KIM_DataType KIM_DataType_FromString(char const * const str) { return makeDataTypeC(KIM::DataType(std::string(str))); } int KIM_DataType_Known(KIM_DataType const dataType) { return makeDataTypeCpp(dataType).Known(); } int KIM_DataType_Equal(KIM_DataType const lhs, KIM_DataType const rhs) { return (lhs.dataTypeID == rhs.dataTypeID); } int KIM_DataType_NotEqual(KIM_DataType const lhs, KIM_DataType const rhs) { return (!KIM_DataType_Equal(lhs, rhs)); } char const * KIM_DataType_ToString(KIM_DataType const dataType) { return makeDataTypeCpp(dataType).ToString().c_str(); } #include "KIM_DataType.inc" KIM_DataType const KIM_DATA_TYPE_Integer = {ID_Integer}; KIM_DataType const KIM_DATA_TYPE_Double = {ID_Double}; void KIM_DATA_TYPE_GetNumberOfDataTypes(int * const numberOfDataTypes) { KIM::DATA_TYPE::GetNumberOfDataTypes(numberOfDataTypes); } int KIM_DATA_TYPE_GetDataType(int const index, KIM_DataType * const dataType) { KIM::DataType dataTypeCpp; int error = KIM::DATA_TYPE::GetDataType(index, &dataTypeCpp); if (error) return error; *dataType = makeDataTypeC(dataTypeCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_EnergyUnit_c.cpp000066400000000000000000000062221421473465500204510ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_ENERGY_UNIT_HPP_ #include "KIM_EnergyUnit.hpp" #endif extern "C" { #ifndef KIM_ENERGY_UNIT_H_ #include "KIM_EnergyUnit.h" #endif } namespace { KIM::EnergyUnit makeEnergyUnitCpp(KIM_EnergyUnit const energyUnit) { KIM::EnergyUnit const * const energyUnitCpp = reinterpret_cast(&energyUnit); return *energyUnitCpp; } KIM_EnergyUnit makeEnergyUnitC(KIM::EnergyUnit const energyUnit) { KIM_EnergyUnit const * const energyUnitC = reinterpret_cast(&energyUnit); return *energyUnitC; } } // namespace extern "C" { KIM_EnergyUnit KIM_EnergyUnit_FromString(char const * const str) { return makeEnergyUnitC(KIM::EnergyUnit(std::string(str))); } int KIM_EnergyUnit_Known(KIM_EnergyUnit const energyUnit) { return makeEnergyUnitCpp(energyUnit).Known(); } int KIM_EnergyUnit_Equal(KIM_EnergyUnit const lhs, KIM_EnergyUnit const rhs) { return (lhs.energyUnitID == rhs.energyUnitID); } int KIM_EnergyUnit_NotEqual(KIM_EnergyUnit const lhs, KIM_EnergyUnit const rhs) { return (!KIM_EnergyUnit_Equal(lhs, rhs)); } char const * KIM_EnergyUnit_ToString(KIM_EnergyUnit const energyUnit) { return makeEnergyUnitCpp(energyUnit).ToString().c_str(); } #include "KIM_EnergyUnit.inc" KIM_EnergyUnit const KIM_ENERGY_UNIT_unused = {ID_unused}; KIM_EnergyUnit const KIM_ENERGY_UNIT_amu_A2_per_ps2 = {ID_amu_A2_per_ps2}; KIM_EnergyUnit const KIM_ENERGY_UNIT_erg = {ID_erg}; KIM_EnergyUnit const KIM_ENERGY_UNIT_eV = {ID_eV}; KIM_EnergyUnit const KIM_ENERGY_UNIT_Hartree = {ID_Hartree}; KIM_EnergyUnit const KIM_ENERGY_UNIT_J = {ID_J}; KIM_EnergyUnit const KIM_ENERGY_UNIT_kcal_mol = {ID_kcal_mol}; void KIM_ENERGY_UNIT_GetNumberOfEnergyUnits(int * const numberOfEnergyUnits) { KIM::ENERGY_UNIT::GetNumberOfEnergyUnits(numberOfEnergyUnits); } int KIM_ENERGY_UNIT_GetEnergyUnit(int const index, KIM_EnergyUnit * const energyUnit) { KIM::EnergyUnit energyUnitCpp; int error = KIM::ENERGY_UNIT::GetEnergyUnit(index, &energyUnitCpp); if (error) return error; *energyUnit = makeEnergyUnitC(energyUnitCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_LanguageName_c.cpp000066400000000000000000000062361421473465500207110ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif extern "C" { #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif } // extern "C" namespace { KIM::LanguageName makeLanguageNameCpp(KIM_LanguageName languageName) { KIM::LanguageName const * const languageNameCpp = reinterpret_cast(&languageName); return *languageNameCpp; } KIM_LanguageName makeLanguageNameC(KIM::LanguageName languageName) { KIM_LanguageName const * const languageNameC = reinterpret_cast(&languageName); return *languageNameC; } } // namespace extern "C" { KIM_LanguageName KIM_LanguageName_FromString(char const * const str) { return makeLanguageNameC(KIM::LanguageName(std::string(str))); } int KIM_LanguageName_Known(KIM_LanguageName const languageName) { return makeLanguageNameCpp(languageName).Known(); } int KIM_LanguageName_Equal(KIM_LanguageName const lhs, KIM_LanguageName const rhs) { return (lhs.languageNameID == rhs.languageNameID); } int KIM_LanguageName_NotEqual(KIM_LanguageName const lhs, KIM_LanguageName const rhs) { return (!KIM_LanguageName_Equal(lhs, rhs)); } char const * KIM_LanguageName_ToString(KIM_LanguageName languageName) { return makeLanguageNameCpp(languageName).ToString().c_str(); } // Order doesn't matter as long as all values are unique #include "KIM_LanguageName.inc" KIM_LanguageName const KIM_LANGUAGE_NAME_cpp = {ID_cpp}; KIM_LanguageName const KIM_LANGUAGE_NAME_c = {ID_c}; KIM_LanguageName const KIM_LANGUAGE_NAME_fortran = {ID_fortran}; void KIM_LANGUAGE_NAME_GetNumberOfLanguageNames( int * const numberOfLanguageNames) { KIM::LANGUAGE_NAME::GetNumberOfLanguageNames(numberOfLanguageNames); } int KIM_LANGUAGE_NAME_GetLanguageName(int const index, KIM_LanguageName * const languageName) { KIM::LanguageName languageNameCpp; int error = KIM::LANGUAGE_NAME::GetLanguageName(index, &languageNameCpp); if (error) return error; *languageName = makeLanguageNameC(languageNameCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_LengthUnit_c.cpp000066400000000000000000000060611421473465500204420ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LENGTH_UNIT_HPP_ #include "KIM_LengthUnit.hpp" #endif extern "C" { #ifndef KIM_LENGTH_UNIT_H_ #include "KIM_LengthUnit.h" #endif } namespace { KIM::LengthUnit makeLengthUnitCpp(KIM_LengthUnit const lengthUnit) { KIM::LengthUnit const * const lengthUnitCpp = reinterpret_cast(&lengthUnit); return *lengthUnitCpp; } KIM_LengthUnit makeLengthUnitC(KIM::LengthUnit const lengthUnit) { KIM_LengthUnit const * const lengthUnitC = reinterpret_cast(&lengthUnit); return *lengthUnitC; } } // namespace extern "C" { KIM_LengthUnit KIM_LengthUnit_FromString(char const * const str) { return makeLengthUnitC(KIM::LengthUnit(std::string(str))); } int KIM_LengthUnit_Known(KIM_LengthUnit const lengthUnit) { return makeLengthUnitCpp(lengthUnit).Known(); } int KIM_LengthUnit_Equal(KIM_LengthUnit const lhs, KIM_LengthUnit const rhs) { return (lhs.lengthUnitID == rhs.lengthUnitID); } int KIM_LengthUnit_NotEqual(KIM_LengthUnit const lhs, KIM_LengthUnit const rhs) { return (!KIM_LengthUnit_Equal(lhs, rhs)); } char const * KIM_LengthUnit_ToString(KIM_LengthUnit const lengthUnit) { return makeLengthUnitCpp(lengthUnit).ToString().c_str(); } #include "KIM_LengthUnit.inc" KIM_LengthUnit const KIM_LENGTH_UNIT_unused = {ID_unused}; KIM_LengthUnit const KIM_LENGTH_UNIT_A = {ID_A}; KIM_LengthUnit const KIM_LENGTH_UNIT_Bohr = {ID_Bohr}; KIM_LengthUnit const KIM_LENGTH_UNIT_cm = {ID_cm}; KIM_LengthUnit const KIM_LENGTH_UNIT_m = {ID_m}; KIM_LengthUnit const KIM_LENGTH_UNIT_nm = {ID_nm}; void KIM_LENGTH_UNIT_GetNumberOfLengthUnits(int * const numberOfLengthUnits) { KIM::LENGTH_UNIT::GetNumberOfLengthUnits(numberOfLengthUnits); } int KIM_LENGTH_UNIT_GetLengthUnit(int const index, KIM_LengthUnit * const lengthUnit) { KIM::LengthUnit lengthUnitCpp; int error = KIM::LENGTH_UNIT::GetLengthUnit(index, &lengthUnitCpp); if (error) return error; *lengthUnit = makeLengthUnitC(lengthUnitCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_LogVerbosity_c.cpp000066400000000000000000000103301421473465500210030ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { KIM::LogVerbosity const * const logVerbosityCpp = reinterpret_cast(&logVerbosity); return *logVerbosityCpp; } KIM_LogVerbosity makeLogVerbosityC(KIM::LogVerbosity const logVerbosity) { KIM_LogVerbosity const * const logVerbosityC = reinterpret_cast(&logVerbosity); return *logVerbosityC; } } // namespace extern "C" { KIM_LogVerbosity KIM_LogVerbosity_FromString(char const * const str) { return makeLogVerbosityC(KIM::LogVerbosity(std::string(str))); } int KIM_LogVerbosity_Known(KIM_LogVerbosity const logVerbosity) { return makeLogVerbosityCpp(logVerbosity).Known(); } int KIM_LogVerbosity_LessThan(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs) { return (lhs.logVerbosityID < rhs.logVerbosityID); } int KIM_LogVerbosity_GreaterThan(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs) { return (lhs.logVerbosityID > rhs.logVerbosityID); } int KIM_LogVerbosity_LessThanEqual(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs) { return (lhs.logVerbosityID <= rhs.logVerbosityID); } int KIM_LogVerbosity_GreaterThanEqual(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs) { return (lhs.logVerbosityID >= rhs.logVerbosityID); } int KIM_LogVerbosity_Equal(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs) { return (lhs.logVerbosityID == rhs.logVerbosityID); } int KIM_LogVerbosity_NotEqual(KIM_LogVerbosity const lhs, KIM_LogVerbosity const rhs) { return (!KIM_LogVerbosity_Equal(lhs, rhs)); } char const * KIM_LogVerbosity_ToString(KIM_LogVerbosity const logVerbosity) { return makeLogVerbosityCpp(logVerbosity).ToString().c_str(); } KIM_LogVerbosity const KIM_LOG_VERBOSITY_silent = {KIM::LOG_VERBOSITY::silent.logVerbosityID}; KIM_LogVerbosity const KIM_LOG_VERBOSITY_fatal = {KIM::LOG_VERBOSITY::fatal.logVerbosityID}; KIM_LogVerbosity const KIM_LOG_VERBOSITY_error = {KIM::LOG_VERBOSITY::error.logVerbosityID}; KIM_LogVerbosity const KIM_LOG_VERBOSITY_warning = {KIM::LOG_VERBOSITY::warning.logVerbosityID}; KIM_LogVerbosity const KIM_LOG_VERBOSITY_information = {KIM::LOG_VERBOSITY::information.logVerbosityID}; KIM_LogVerbosity const KIM_LOG_VERBOSITY_debug = {KIM::LOG_VERBOSITY::debug.logVerbosityID}; void KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities( int * const numberOfLogVerbosities) { KIM::LOG_VERBOSITY::GetNumberOfLogVerbosities(numberOfLogVerbosities); } int KIM_LOG_VERBOSITY_GetLogVerbosity(int const index, KIM_LogVerbosity * const logVerbosity) { KIM::LogVerbosity logVerbosityCpp; int error = KIM::LOG_VERBOSITY::GetLogVerbosity(index, &logVerbosityCpp); if (error) return error; *logVerbosity = makeLogVerbosityC(logVerbosityCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_Log_c.cpp000066400000000000000000000073261421473465500171070ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif extern "C" { #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif } // extern "C" #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif extern "C" { #ifndef KIM_LOG_H_ #include "KIM_Log.h" #endif } // extern "C" struct KIM_Log { void * p; }; #define CONVERT_POINTER KIM::Log * pLog = reinterpret_cast(log->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } KIM::LanguageName makeLanguageNameCpp(KIM_LanguageName const languageName) { return KIM::LanguageName(languageName.languageNameID); } } // namespace extern "C" { int KIM_Log_Create(KIM_Log ** const log) { KIM::Log * pLog; int error = KIM::Log::Create(&pLog); if (error) return error; (*log) = new KIM_Log; (*log)->p = (void *) pLog; return false; } void KIM_Log_Destroy(KIM_Log ** const log) { if (*log != NULL) { KIM::Log * pLog = reinterpret_cast((*log)->p); KIM::Log::Destroy(&pLog); } delete (*log); *log = NULL; } void KIM_Log_PushDefaultVerbosity(KIM_LogVerbosity const logVerbosity) { KIM::Log::PushDefaultVerbosity(makeLogVerbosityCpp(logVerbosity)); } void KIM_Log_PopDefaultVerbosity() { KIM::Log::PopDefaultVerbosity(); } void KIM_Log_PushDefaultPrintFunction(KIM_LanguageName const languageName, KIM_Function * const fptr) { KIM::Log::PushDefaultPrintFunction(makeLanguageNameCpp(languageName), fptr); } void KIM_Log_PopDefaultPrintFunction() { KIM::Log::PopDefaultPrintFunction(); } char const * KIM_Log_GetID(KIM_Log const * const log) { CONVERT_POINTER; return pLog->GetID().c_str(); } void KIM_Log_SetID(KIM_Log * const log, char const * const id) { CONVERT_POINTER; pLog->SetID(id); } void KIM_Log_PushVerbosity(KIM_Log * const log, KIM_LogVerbosity const logVerbosity) { CONVERT_POINTER; pLog->PushVerbosity(makeLogVerbosityCpp(logVerbosity)); } void KIM_Log_PopVerbosity(KIM_Log * const log) { CONVERT_POINTER; pLog->PopVerbosity(); } void KIM_Log_LogEntry(KIM_Log const * const log, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pLog->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelComputeArgumentsCreate_c.cpp000066400000000000000000000112111421473465500237610ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif extern "C" { #ifndef KIM_SUPPORT_STATUS_H_ #include "KIM_SupportStatus.h" #endif } // extern "C" #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif } // extern "C" #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif } // extern "C" #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ #include "KIM_ModelComputeArgumentsCreate.hpp" #endif extern "C" { #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ #include "KIM_ModelComputeArgumentsCreate.h" #endif } // extern "C" struct KIM_ModelComputeArgumentsCreate { void * p; }; #define CONVERT_POINTER \ KIM::ModelComputeArgumentsCreate * pModelComputeArgumentsCreate \ = reinterpret_cast( \ modelComputeArgumentsCreate->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } KIM::SupportStatus makeSupportStatusCpp(KIM_SupportStatus const supportStatus) { return KIM::SupportStatus(supportStatus.supportStatusID); } KIM::ComputeArgumentName makeComputeArgumentNameCpp(KIM_ComputeArgumentName const computeArgumentName) { return KIM::ComputeArgumentName(computeArgumentName.computeArgumentNameID); } KIM::ComputeCallbackName makeComputeCallbackNameCpp(KIM_ComputeCallbackName const computeCallbackName) { return KIM::ComputeCallbackName(computeCallbackName.computeCallbackNameID); } } // namespace extern "C" { int KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus const supportStatus) { CONVERT_POINTER; return pModelComputeArgumentsCreate->SetArgumentSupportStatus( makeComputeArgumentNameCpp(computeArgumentName), makeSupportStatusCpp(supportStatus)); } int KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus const supportStatus) { CONVERT_POINTER; return pModelComputeArgumentsCreate->SetCallbackSupportStatus( makeComputeCallbackNameCpp(computeCallbackName), makeSupportStatusCpp(supportStatus)); } void KIM_ModelComputeArgumentsCreate_SetModelBufferPointer( KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate, void * const ptr) { CONVERT_POINTER; pModelComputeArgumentsCreate->SetModelBufferPointer(ptr); } void KIM_ModelComputeArgumentsCreate_LogEntry( KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelComputeArgumentsCreate->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelComputeArgumentsCreate_ToString( KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate) { CONVERT_POINTER; return pModelComputeArgumentsCreate->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelComputeArgumentsDestroy_c.cpp000066400000000000000000000054431421473465500242210ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ #include "KIM_ModelComputeArgumentsDestroy.hpp" #endif extern "C" { #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ #include "KIM_ModelComputeArgumentsDestroy.h" #endif } // extern "C" struct KIM_ModelComputeArgumentsDestroy { void * p; }; #define CONVERT_POINTER \ KIM::ModelComputeArgumentsDestroy * pModelComputeArgumentsDestroy \ = reinterpret_cast( \ modelComputeArgumentsDestroy->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { void KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer( KIM_ModelComputeArgumentsDestroy const * const modelComputeArgumentsDestroy, void ** const ptr) { CONVERT_POINTER; pModelComputeArgumentsDestroy->GetModelBufferPointer(ptr); } void KIM_ModelComputeArgumentsDestroy_LogEntry( KIM_ModelComputeArgumentsDestroy const * const modelComputeArgumentsDestroy, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelComputeArgumentsDestroy->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelComputeArgumentsDestroy_ToString( KIM_ModelComputeArgumentsDestroy const * const modelComputeArgumentsDestroy) { CONVERT_POINTER; return pModelComputeArgumentsDestroy->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelComputeArguments_c.cpp000066400000000000000000000135701421473465500226470ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_ #include "KIM_ComputeArgumentName.h" #endif } // extern "C" #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif extern "C" { #ifndef KIM_COMPUTE_CALLBACK_NAME_H_ #include "KIM_ComputeCallbackName.h" #endif } // extern "C" #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ModelComputeArguments.hpp" #endif extern "C" { #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_H_ #include "KIM_ModelComputeArguments.h" #endif } // extern "C" struct KIM_ModelComputeArguments { void * p; }; #define CONVERT_POINTER \ KIM::ModelComputeArguments * pModelComputeArguments \ = reinterpret_cast( \ modelComputeArguments->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } KIM::ComputeArgumentName makeComputeArgumentNameCpp(KIM_ComputeArgumentName const computeArgumentName) { return KIM::ComputeArgumentName(computeArgumentName.computeArgumentNameID); } KIM::ComputeCallbackName makeComputeCallbackNameCpp(KIM_ComputeCallbackName const computeCallbackName) { return KIM::ComputeCallbackName(computeCallbackName.computeCallbackNameID); } } // namespace extern "C" { int KIM_ModelComputeArguments_GetNeighborList( KIM_ModelComputeArguments const * const modelComputeArguments, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) { CONVERT_POINTER; return pModelComputeArguments->GetNeighborList(neighborListIndex, particleNumber, numberOfNeighbors, neighborsOfParticle); } int KIM_ModelComputeArguments_ProcessDEDrTerm( KIM_ModelComputeArguments const * const modelComputeArguments, double const de, double const r, double const * const dx, int const i, int const j) { CONVERT_POINTER; return pModelComputeArguments->ProcessDEDrTerm(de, r, dx, i, j); } int KIM_ModelComputeArguments_ProcessD2EDr2Term( KIM_ModelComputeArguments const * const modelComputeArguments, double const de, double const * const r, double const * const dx, int const * const i, int const * const j) { CONVERT_POINTER; return pModelComputeArguments->ProcessD2EDr2Term(de, r, dx, i, j); } int KIM_ModelComputeArguments_GetArgumentPointerInteger( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, int ** const ptr) { CONVERT_POINTER; return pModelComputeArguments->GetArgumentPointer( makeComputeArgumentNameCpp(computeArgumentName), ptr); } int KIM_ModelComputeArguments_GetArgumentPointerDouble( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, double ** const ptr) { CONVERT_POINTER; return pModelComputeArguments->GetArgumentPointer( makeComputeArgumentNameCpp(computeArgumentName), ptr); } int KIM_ModelComputeArguments_IsCallbackPresent( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_ComputeCallbackName const computeCallbackName, int * const present) { CONVERT_POINTER; KIM::ComputeCallbackName computeCallbackNameC = makeComputeCallbackNameCpp(computeCallbackName); return pModelComputeArguments->IsCallbackPresent(computeCallbackNameC, present); } void KIM_ModelComputeArguments_SetModelBufferPointer( KIM_ModelComputeArguments * const modelComputeArguments, void * const ptr) { CONVERT_POINTER; pModelComputeArguments->SetModelBufferPointer(ptr); } void KIM_ModelComputeArguments_GetModelBufferPointer( KIM_ModelComputeArguments const * const modelComputeArguments, void ** const ptr) { CONVERT_POINTER; pModelComputeArguments->GetModelBufferPointer(ptr); } void KIM_ModelComputeArguments_LogEntry( KIM_ModelComputeArguments const * const modelComputeArguments, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelComputeArguments->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelComputeArguments_ToString( KIM_ModelComputeArguments const * const modelComputeArguments) { CONVERT_POINTER; return pModelComputeArguments->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelCompute_c.cpp000066400000000000000000000047731421473465500207660ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_MODEL_COMPUTE_HPP_ #include "KIM_ModelCompute.hpp" #endif extern "C" { #ifndef KIM_MODEL_COMPUTE_H_ #include "KIM_ModelCompute.h" #endif } // extern "C" struct KIM_ModelCompute { void * p; }; #define CONVERT_POINTER \ KIM::ModelCompute * pModelCompute \ = reinterpret_cast(modelCompute->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { void KIM_ModelCompute_GetModelBufferPointer( KIM_ModelCompute const * const modelCompute, void ** const ptr) { CONVERT_POINTER; pModelCompute->GetModelBufferPointer(ptr); } void KIM_ModelCompute_LogEntry(KIM_ModelCompute const * const modelCompute, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelCompute->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelCompute_ToString(KIM_ModelCompute const * const modelCompute) { CONVERT_POINTER; return pModelCompute->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelCreate_c.cpp000066400000000000000000000220721421473465500205450ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif extern "C" { #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif } // extern "C" #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif extern "C" { #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif } // extern "C" #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif extern "C" { #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif } // extern "C" #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif extern "C" { #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif } // extern "C" #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif extern "C" { #ifndef KIM_UNIT_SYSTEM_H_ #include "KIM_UnitSystem.h" #endif } // extern "C" #ifndef KIM_MODEL_CREATE_HPP_ #include "KIM_ModelCreate.hpp" #endif extern "C" { #ifndef KIM_MODEL_CREATE_H_ #include "KIM_ModelCreate.h" #endif } // extern "C" struct KIM_ModelCreate { void * p; }; #define CONVERT_POINTER \ KIM::ModelCreate * pModelCreate \ = reinterpret_cast(modelCreate->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } KIM::Numbering makeNumberingCpp(KIM_Numbering const numbering) { return KIM::Numbering(numbering.numberingID); } KIM::LengthUnit makeLengthUnitCpp(KIM_LengthUnit const lengthUnit) { return KIM::LengthUnit(lengthUnit.lengthUnitID); } KIM::EnergyUnit makeEnergyUnitCpp(KIM_EnergyUnit const energyUnit) { return KIM::EnergyUnit(energyUnit.energyUnitID); } KIM::ChargeUnit makeChargeUnitCpp(KIM_ChargeUnit const chargeUnit) { return KIM::ChargeUnit(chargeUnit.chargeUnitID); } KIM::TemperatureUnit makeTemperatureUnitCpp(KIM_TemperatureUnit const temperatureUnit) { return KIM::TemperatureUnit(temperatureUnit.temperatureUnitID); } KIM::TimeUnit makeTimeUnitCpp(KIM_TimeUnit const timeUnit) { return KIM::TimeUnit(timeUnit.timeUnitID); } KIM::LanguageName makeLanguageNameCpp(KIM_LanguageName const languageName) { return KIM::LanguageName(languageName.languageNameID); } KIM::ModelRoutineName makeRoutineNameCpp(KIM_ModelRoutineName const modelRoutineName) { return KIM::ModelRoutineName(modelRoutineName.modelRoutineNameID); } KIM::SpeciesName makeSpecNameCpp(KIM_SpeciesName const speciesName) { return KIM::SpeciesName(speciesName.speciesNameID); } } // namespace extern "C" { int KIM_ModelCreate_SetModelNumbering(KIM_ModelCreate * const modelCreate, KIM_Numbering const numbering) { CONVERT_POINTER; return pModelCreate->SetModelNumbering(makeNumberingCpp(numbering)); } void KIM_ModelCreate_SetInfluenceDistancePointer( KIM_ModelCreate * const modelCreate, double const * const influenceDistance) { CONVERT_POINTER; pModelCreate->SetInfluenceDistancePointer(influenceDistance); } void KIM_ModelCreate_SetNeighborListPointers( KIM_ModelCreate * const modelCreate, int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pModelCreate->SetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } int KIM_ModelCreate_SetRoutinePointer( KIM_ModelCreate * const modelCreate, KIM_ModelRoutineName const modelRoutineName, KIM_LanguageName const languageName, int const required, KIM_Function * const fptr) { CONVERT_POINTER; KIM::ModelRoutineName routN = makeRoutineNameCpp(modelRoutineName); KIM::LanguageName langN = makeLanguageNameCpp(languageName); return pModelCreate->SetRoutinePointer( routN, langN, required, reinterpret_cast(fptr)); } int KIM_ModelCreate_SetSpeciesCode(KIM_ModelCreate * const modelCreate, KIM_SpeciesName const speciesName, int const code) { CONVERT_POINTER; return pModelCreate->SetSpeciesCode(makeSpecNameCpp(speciesName), code); } int KIM_ModelCreate_SetParameterPointerInteger( KIM_ModelCreate * const modelCreate, int const extent, int * const ptr, char const * const name, char const * const description) { CONVERT_POINTER; return pModelCreate->SetParameterPointer(extent, ptr, name, description); } int KIM_ModelCreate_SetParameterPointerDouble( KIM_ModelCreate * const modelCreate, int const extent, double * const ptr, char const * const name, char const * const description) { CONVERT_POINTER; return pModelCreate->SetParameterPointer(extent, ptr, name, description); } void KIM_ModelCreate_SetModelBufferPointer(KIM_ModelCreate * const modelCreate, void * const ptr) { CONVERT_POINTER; pModelCreate->SetModelBufferPointer(ptr); } int KIM_ModelCreate_SetUnits(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const lengthUnit, KIM_EnergyUnit const energyUnit, KIM_ChargeUnit const chargeUnit, KIM_TemperatureUnit const temperatureUnit, KIM_TimeUnit const timeUnit) { CONVERT_POINTER; KIM::LengthUnit lengthU = makeLengthUnitCpp(lengthUnit); KIM::EnergyUnit energyU = makeEnergyUnitCpp(energyUnit); KIM::ChargeUnit chargeU = makeChargeUnitCpp(chargeUnit); KIM::TemperatureUnit temperatureU = makeTemperatureUnitCpp(temperatureUnit); KIM::TimeUnit timeU = makeTimeUnitCpp(timeUnit); return pModelCreate->SetUnits(lengthU, energyU, chargeU, temperatureU, timeU); } int KIM_ModelCreate_ConvertUnit(KIM_LengthUnit const fromLengthUnit, KIM_EnergyUnit const fromEnergyUnit, KIM_ChargeUnit const fromChargeUnit, KIM_TemperatureUnit const fromTemperatureUnit, KIM_TimeUnit const fromTimeUnit, KIM_LengthUnit const toLengthUnit, KIM_EnergyUnit const toEnergyUnit, KIM_ChargeUnit const toChargeUnit, KIM_TemperatureUnit const toTemperatureUnit, KIM_TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor) { return KIM::ModelCreate::ConvertUnit( makeLengthUnitCpp(fromLengthUnit), makeEnergyUnitCpp(fromEnergyUnit), makeChargeUnitCpp(fromChargeUnit), makeTemperatureUnitCpp(fromTemperatureUnit), makeTimeUnitCpp(fromTimeUnit), makeLengthUnitCpp(toLengthUnit), makeEnergyUnitCpp(toEnergyUnit), makeChargeUnitCpp(toChargeUnit), makeTemperatureUnitCpp(toTemperatureUnit), makeTimeUnitCpp(toTimeUnit), lengthExponent, energyExponent, chargeExponent, temperatureExponent, timeExponent, conversionFactor); } void KIM_ModelCreate_LogEntry(KIM_ModelCreate const * const modelCreate, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelCreate->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelCreate_ToString(KIM_ModelCreate const * const modelCreate) { CONVERT_POINTER; return pModelCreate->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelDestroy_c.cpp000066400000000000000000000047721421473465500210020ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_MODEL_DESTROY_HPP_ #include "KIM_ModelDestroy.hpp" #endif extern "C" { #ifndef KIM_MODEL_DESTROY_H_ #include "KIM_ModelDestroy.h" #endif } // extern "C" struct KIM_ModelDestroy { void * p; }; #define CONVERT_POINTER \ KIM::ModelDestroy * pModelDestroy \ = reinterpret_cast(modelDestroy->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { void KIM_ModelDestroy_GetModelBufferPointer( KIM_ModelDestroy const * const modelDestroy, void ** const ptr) { CONVERT_POINTER; pModelDestroy->GetModelBufferPointer(ptr); } void KIM_ModelDestroy_LogEntry(KIM_ModelDestroy const * const modelDestroy, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelDestroy->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelDestroy_ToString(KIM_ModelDestroy const * const modelDestroy) { CONVERT_POINTER; return pModelDestroy->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelDriverCreate_c.cpp000066400000000000000000000245721421473465500217300ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif extern "C" { #ifndef KIM_LANGUAGE_NAME_H_ #include "KIM_LanguageName.h" #endif } // extern "C" #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif extern "C" { #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif } // extern "C" #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif extern "C" { #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif } // extern "C" #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif extern "C" { #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif } // extern "C" #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif extern "C" { #ifndef KIM_UNIT_SYSTEM_H_ #include "KIM_UnitSystem.h" #endif } // extern "C" #ifndef KIM_MODEL_DRIVER_CREATE_HPP_ #include "KIM_ModelDriverCreate.hpp" #endif extern "C" { #ifndef KIM_MODEL_DRIVER_CREATE_H_ #include "KIM_ModelDriverCreate.h" #endif } // extern "C" struct KIM_ModelDriverCreate { void * p; }; #define CONVERT_POINTER \ KIM::ModelDriverCreate * pModelDriverCreate \ = reinterpret_cast(modelDriverCreate->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } KIM::Numbering makeNumberingCpp(KIM_Numbering const numbering) { return KIM::Numbering(numbering.numberingID); } KIM::LengthUnit makeLengthUnitCpp(KIM_LengthUnit const lengthUnit) { return KIM::LengthUnit(lengthUnit.lengthUnitID); } KIM::EnergyUnit makeEnergyUnitCpp(KIM_EnergyUnit const energyUnit) { return KIM::EnergyUnit(energyUnit.energyUnitID); } KIM::ChargeUnit makeChargeUnitCpp(KIM_ChargeUnit const chargeUnit) { return KIM::ChargeUnit(chargeUnit.chargeUnitID); } KIM::TemperatureUnit makeTemperatureUnitCpp(KIM_TemperatureUnit const temperatureUnit) { return KIM::TemperatureUnit(temperatureUnit.temperatureUnitID); } KIM::TimeUnit makeTimeUnitCpp(KIM_TimeUnit const timeUnit) { return KIM::TimeUnit(timeUnit.timeUnitID); } KIM::LanguageName makeLanguageNameCpp(KIM_LanguageName const languageName) { return KIM::LanguageName(languageName.languageNameID); } KIM::ModelRoutineName makeRoutineNameCpp(KIM_ModelRoutineName const modelRoutineName) { return KIM::ModelRoutineName(modelRoutineName.modelRoutineNameID); } KIM::SpeciesName makeSpeciesNameCpp(KIM_SpeciesName const speciesName) { return KIM::SpeciesName(speciesName.speciesNameID); } } // namespace extern "C" { void KIM_ModelDriverCreate_GetParameterFileDirectoryName( KIM_ModelDriverCreate const * const modelDriverCreate, char const ** const directoryName) { CONVERT_POINTER; std::string const * pStr = NULL; pModelDriverCreate->GetParameterFileDirectoryName(&pStr); *directoryName = pStr->c_str(); } void KIM_ModelDriverCreate_GetNumberOfParameterFiles( KIM_ModelDriverCreate const * const modelDriverCreate, int * const numberOfParameterFiles) { CONVERT_POINTER; pModelDriverCreate->GetNumberOfParameterFiles(numberOfParameterFiles); } int KIM_ModelDriverCreate_GetParameterFileName( KIM_ModelDriverCreate const * const modelDriverCreate, int const index, char const ** const parameterFileName) { CONVERT_POINTER; std::string const * pStr; std::string const ** ppStr; if (parameterFileName == NULL) ppStr = NULL; else ppStr = &pStr; int error = pModelDriverCreate->GetParameterFileName(index, ppStr); if (error) return true; else { if (parameterFileName != NULL) *parameterFileName = pStr->c_str(); return false; } } int KIM_ModelDriverCreate_GetParameterFileBasename( KIM_ModelDriverCreate const * const modelDriverCreate, int const index, char const ** const parameterFileBasename) { CONVERT_POINTER; std::string const * pStr; std::string const ** ppStr; if (parameterFileBasename == NULL) ppStr = NULL; else ppStr = &pStr; int error = pModelDriverCreate->GetParameterFileBasename(index, ppStr); if (error) return true; else { if (parameterFileBasename != NULL) *parameterFileBasename = pStr->c_str(); return false; } } int KIM_ModelDriverCreate_SetModelNumbering( KIM_ModelDriverCreate * const modelDriverCreate, KIM_Numbering const numbering) { CONVERT_POINTER; return pModelDriverCreate->SetModelNumbering(makeNumberingCpp(numbering)); } void KIM_ModelDriverCreate_SetInfluenceDistancePointer( KIM_ModelDriverCreate * const modelDriverCreate, double const * const influenceDistance) { CONVERT_POINTER; pModelDriverCreate->SetInfluenceDistancePointer(influenceDistance); } void KIM_ModelDriverCreate_SetNeighborListPointers( KIM_ModelDriverCreate * const modelDriverCreate, int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pModelDriverCreate->SetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } int KIM_ModelDriverCreate_SetRoutinePointer( KIM_ModelDriverCreate * const modelDriverCreate, KIM_ModelRoutineName const modelRoutineName, KIM_LanguageName const languageName, int const required, KIM_Function * const fptr) { CONVERT_POINTER; KIM::ModelRoutineName routN = makeRoutineNameCpp(modelRoutineName); KIM::LanguageName langN = makeLanguageNameCpp(languageName); return pModelDriverCreate->SetRoutinePointer( routN, langN, required, reinterpret_cast(fptr)); } int KIM_ModelDriverCreate_SetSpeciesCode( KIM_ModelDriverCreate * const modelDriverCreate, KIM_SpeciesName const speciesName, int const code) { CONVERT_POINTER; return pModelDriverCreate->SetSpeciesCode(makeSpeciesNameCpp(speciesName), code); } int KIM_ModelDriverCreate_SetParameterPointerInteger( KIM_ModelDriverCreate * const modelDriverCreate, int const extent, int * const ptr, char const * const name, char const * const description) { CONVERT_POINTER; return pModelDriverCreate->SetParameterPointer( extent, ptr, name, description); } int KIM_ModelDriverCreate_SetParameterPointerDouble( KIM_ModelDriverCreate * const modelDriverCreate, int const extent, double * const ptr, char const * const name, char const * const description) { CONVERT_POINTER; return pModelDriverCreate->SetParameterPointer( extent, ptr, name, description); } void KIM_ModelDriverCreate_SetModelBufferPointer( KIM_ModelDriverCreate * const modelDriverCreate, void * const ptr) { CONVERT_POINTER; pModelDriverCreate->SetModelBufferPointer(ptr); } int KIM_ModelDriverCreate_SetUnits( KIM_ModelDriverCreate * const modelDriverCreate, KIM_LengthUnit const lengthUnit, KIM_EnergyUnit const energyUnit, KIM_ChargeUnit const chargeUnit, KIM_TemperatureUnit const temperatureUnit, KIM_TimeUnit const timeUnit) { CONVERT_POINTER; KIM::LengthUnit lengthU = makeLengthUnitCpp(lengthUnit); KIM::EnergyUnit energyU = makeEnergyUnitCpp(energyUnit); KIM::ChargeUnit chargeU = makeChargeUnitCpp(chargeUnit); KIM::TemperatureUnit temperatureU = makeTemperatureUnitCpp(temperatureUnit); KIM::TimeUnit timeU = makeTimeUnitCpp(timeUnit); return pModelDriverCreate->SetUnits( lengthU, energyU, chargeU, temperatureU, timeU); } int KIM_ModelDriverCreate_ConvertUnit( KIM_LengthUnit const fromLengthUnit, KIM_EnergyUnit const fromEnergyUnit, KIM_ChargeUnit const fromChargeUnit, KIM_TemperatureUnit const fromTemperatureUnit, KIM_TimeUnit const fromTimeUnit, KIM_LengthUnit const toLengthUnit, KIM_EnergyUnit const toEnergyUnit, KIM_ChargeUnit const toChargeUnit, KIM_TemperatureUnit const toTemperatureUnit, KIM_TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor) { return KIM::ModelDriverCreate::ConvertUnit( makeLengthUnitCpp(fromLengthUnit), makeEnergyUnitCpp(fromEnergyUnit), makeChargeUnitCpp(fromChargeUnit), makeTemperatureUnitCpp(fromTemperatureUnit), makeTimeUnitCpp(fromTimeUnit), makeLengthUnitCpp(toLengthUnit), makeEnergyUnitCpp(toEnergyUnit), makeChargeUnitCpp(toChargeUnit), makeTemperatureUnitCpp(toTemperatureUnit), makeTimeUnitCpp(toTimeUnit), lengthExponent, energyExponent, chargeExponent, temperatureExponent, timeExponent, conversionFactor); } void KIM_ModelDriverCreate_LogEntry( KIM_ModelDriverCreate const * const modelDriverCreate, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelDriverCreate->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelDriverCreate_ToString( KIM_ModelDriverCreate const * const modelDriverCreate) { CONVERT_POINTER; return pModelDriverCreate->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelExtension_c.cpp000066400000000000000000000115511421473465500213160ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_MODEL_EXTENSION_HPP_ #include "KIM_ModelExtension.hpp" #endif extern "C" { #ifndef KIM_MODEL_EXTENSION_H_ #include "KIM_ModelExtension.h" #endif } // extern "C" struct KIM_ModelExtension { void * p; }; #define CONVERT_POINTER \ KIM::ModelExtension * pModelExtension \ = reinterpret_cast(modelExtension->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { void KIM_ModelExtension_GetExtensionID( KIM_ModelExtension const * const modelExtension, char const ** const extensionID) { CONVERT_POINTER; std::string const * pStrExtensionID; pModelExtension->GetExtensionID(&pStrExtensionID); *extensionID = pStrExtensionID->c_str(); } KIM_Model * KIM_ModelExtension_ToModel(KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelCompute * KIM_ModelExtension_ToModelCompute(KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelCreate * KIM_ModelExtension_ToModelCreate(KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelDestroy * KIM_ModelExtension_ToModelDestroy(KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelDriverCreate * KIM_ModelExtension_ToModelDriverCreate( KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelRefresh * KIM_ModelExtension_ToModelRefresh(KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelWriteParameterizedModel * KIM_ModelExtension_ToModelWriteParameterizedModel( KIM_ModelExtension * const modelExtension) { return reinterpret_cast(modelExtension); } KIM_ModelComputeArguments * KIM_ModelExtension_ToModelComputeArguments( KIM_ModelExtension const * const modelExtension, KIM_ComputeArguments * const computeArguments) { (void) modelExtension; // Avoid unused parameter warning return reinterpret_cast(computeArguments); } KIM_ModelComputeArgumentsCreate * KIM_ModelExtension_ToModelComputeArgumentsCreate( KIM_ModelExtension const * const modelExtension, KIM_ComputeArguments * const computeArguments) { (void) modelExtension; // Avoid unused parameter warning return reinterpret_cast(computeArguments); } KIM_ModelComputeArgumentsDestroy * KIM_ModelExtension_ToModelComputeArgumentsDestroy( KIM_ModelExtension const * const modelExtension, KIM_ComputeArguments * const computeArguments) { (void) modelExtension; // Avoid unused parameter warning return reinterpret_cast(computeArguments); } void KIM_ModelExtension_GetModelBufferPointer( KIM_ModelExtension const * const modelExtension, void ** const ptr) { CONVERT_POINTER; pModelExtension->GetModelBufferPointer(ptr); } void KIM_ModelExtension_LogEntry( KIM_ModelExtension const * const modelExtension, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelExtension->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelExtension_ToString(KIM_ModelExtension const * const modelExtension) { CONVERT_POINTER; return pModelExtension->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelRefresh_c.cpp000066400000000000000000000061731421473465500207440ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_MODEL_REFRESH_HPP_ #include "KIM_ModelRefresh.hpp" #endif extern "C" { #ifndef KIM_MODEL_REFRESH_H_ #include "KIM_ModelRefresh.h" #endif } // extern "C" struct KIM_ModelRefresh { void * p; }; #define CONVERT_POINTER \ KIM::ModelRefresh * pModelRefresh \ = reinterpret_cast(modelRefresh->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { void KIM_ModelRefresh_SetInfluenceDistancePointer( KIM_ModelRefresh * const modelRefresh, double const * const influenceDistance) { CONVERT_POINTER; pModelRefresh->SetInfluenceDistancePointer(influenceDistance); } void KIM_ModelRefresh_SetNeighborListPointers( KIM_ModelRefresh * const modelRefresh, int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pModelRefresh->SetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } void KIM_ModelRefresh_GetModelBufferPointer( KIM_ModelRefresh const * const modelRefresh, void ** const ptr) { CONVERT_POINTER; pModelRefresh->GetModelBufferPointer(ptr); } void KIM_ModelRefresh_LogEntry(KIM_ModelRefresh const * const modelRefresh, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelRefresh->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelRefresh_ToString(KIM_ModelRefresh const * const modelRefresh) { CONVERT_POINTER; return pModelRefresh->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelRoutineName_c.cpp000066400000000000000000000076611421473465500215770ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif extern "C" { #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif } // extern "C" namespace { KIM::ModelRoutineName makeModelRoutineNameCpp(KIM_ModelRoutineName const modelRoutineName) { KIM::ModelRoutineName const * const modelRoutineNameCpp = reinterpret_cast(&modelRoutineName); return *modelRoutineNameCpp; } KIM_ModelRoutineName makeModelRoutineNameC(KIM::ModelRoutineName const modelRoutineName) { KIM_ModelRoutineName const * const modelRoutineNameC = reinterpret_cast(&modelRoutineName); return *modelRoutineNameC; } } // namespace extern "C" { KIM_ModelRoutineName KIM_ModelRoutineName_FromString(char const * const str) { return makeModelRoutineNameC(KIM::ModelRoutineName(std::string(str))); } int KIM_ModelRoutineName_Known(KIM_ModelRoutineName const modelRoutineName) { return makeModelRoutineNameCpp(modelRoutineName).Known(); } int KIM_ModelRoutineName_Equal(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs) { return (lhs.modelRoutineNameID == rhs.modelRoutineNameID); } int KIM_ModelRoutineName_NotEqual(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs) { return (!KIM_ModelRoutineName_Equal(lhs, rhs)); } char const * KIM_ModelRoutineName_ToString(KIM_ModelRoutineName modelRoutineName) { return makeModelRoutineNameCpp(modelRoutineName).ToString().c_str(); } // Order doesn't matter as long as all values are unique #include "KIM_ModelRoutineName.inc" KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Create = {ID_Create}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate = {ID_ComputeArgumentsCreate}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute = {ID_Compute}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Extension = {ID_Extension}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Refresh = {ID_Refresh}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel = {ID_WriteParameterizedModel}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy = {ID_ComputeArgumentsDestroy}; KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy = {ID_Destroy}; void KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames( int * const numberOfModelRoutineNames) { KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames( numberOfModelRoutineNames); } int KIM_MODEL_ROUTINE_NAME_GetModelRoutineName( int const index, KIM_ModelRoutineName * const modelRoutineName) { KIM::ModelRoutineName modelRoutineNameCpp; int error = KIM::MODEL_ROUTINE_NAME::GetModelRoutineName( index, &modelRoutineNameCpp); if (error) return error; *modelRoutineName = makeModelRoutineNameC(modelRoutineNameCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_ModelWriteParameterizedModel_c.cpp000066400000000000000000000072401421473465500241320ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ #include "KIM_ModelWriteParameterizedModel.hpp" #endif extern "C" { #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ #include "KIM_ModelWriteParameterizedModel.h" #endif } // extern "C" struct KIM_ModelWriteParameterizedModel { void * p; }; #define CONVERT_POINTER \ KIM::ModelWriteParameterizedModel * pModelWriteParameterizedModel \ = reinterpret_cast( \ modelWriteParameterizedModel->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { void KIM_ModelWriteParameterizedModel_GetPath( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, char const ** const path) { CONVERT_POINTER; std::string const * pStrPath; pModelWriteParameterizedModel->GetPath(&pStrPath); *path = pStrPath->c_str(); } void KIM_ModelWriteParameterizedModel_GetModelName( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, char const ** const modelName) { CONVERT_POINTER; std::string const * pStrModelName; pModelWriteParameterizedModel->GetModelName(&pStrModelName); *modelName = pStrModelName->c_str(); } void KIM_ModelWriteParameterizedModel_SetParameterFileName( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, char const * const fileName) { CONVERT_POINTER; pModelWriteParameterizedModel->SetParameterFileName(fileName); } void KIM_ModelWriteParameterizedModel_GetModelBufferPointer( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, void ** const ptr) { CONVERT_POINTER; pModelWriteParameterizedModel->GetModelBufferPointer(ptr); } void KIM_ModelWriteParameterizedModel_LogEntry( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel, KIM_LogVerbosity const logVerbosity, char const * const message, int const lineNumber, char const * const fileName) { CONVERT_POINTER; pModelWriteParameterizedModel->LogEntry( makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName); } char const * KIM_ModelWriteParameterizedModel_ToString( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel) { CONVERT_POINTER; return pModelWriteParameterizedModel->ToString().c_str(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_Model_c.cpp000066400000000000000000000314101421473465500174150ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif extern "C" { #ifndef KIM_DATA_TYPE_H_ #include "KIM_DataType.h" #endif } // extern "C" #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif extern "C" { #ifndef KIM_MODEL_ROUTINE_NAME_H_ #include "KIM_ModelRoutineName.h" #endif } // extern "C" #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif extern "C" { #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif } // extern "C" #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif extern "C" { #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif } // extern "C" #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif extern "C" { #ifndef KIM_UNIT_SYSTEM_H_ #include "KIM_UnitSystem.h" #endif } // extern "C" #ifndef KIM_MODEL_HPP_ #include "KIM_Model.hpp" #endif extern "C" { #ifndef KIM_MODEL_H_ #include "KIM_Model.h" #endif } // extern "C" namespace KIM { // Forward declarations class ComputeArguments; } // namespace KIM struct KIM_ComputeArguments { void * p; }; struct KIM_Model { void * p; }; #define CONVERT_POINTER \ KIM::Model * pModel = reinterpret_cast(model->p) namespace { KIM_DataType makeDataTypeC(KIM::DataType const dataType) { KIM_DataType typ; KIM_DataType * pTyp = (KIM_DataType *) &dataType; typ.dataTypeID = pTyp->dataTypeID; return typ; } KIM::ModelRoutineName makeRoutineNameCpp(KIM_ModelRoutineName const modelRoutineName) { return KIM::ModelRoutineName(modelRoutineName.modelRoutineNameID); } KIM::SpeciesName makeSpecNameCpp(KIM_SpeciesName const speciesName) { return KIM::SpeciesName(speciesName.speciesNameID); } KIM::LengthUnit makeLengthUnitCpp(KIM_LengthUnit lengthUnit) { return KIM::LengthUnit(lengthUnit.lengthUnitID); } KIM::EnergyUnit makeEnergyUnitCpp(KIM_EnergyUnit energyUnit) { return KIM::EnergyUnit(energyUnit.energyUnitID); } KIM::ChargeUnit makeChargeUnitCpp(KIM_ChargeUnit chargeUnit) { return KIM::ChargeUnit(chargeUnit.chargeUnitID); } KIM::TemperatureUnit makeTemperatureUnitCpp(KIM_TemperatureUnit temperatureUnit) { return KIM::TemperatureUnit(temperatureUnit.temperatureUnitID); } KIM::TimeUnit makeTimeUnitCpp(KIM_TimeUnit timeUnit) { return KIM::TimeUnit(timeUnit.timeUnitID); } KIM::Numbering makeNumberingCpp(KIM_Numbering numbering) { return KIM::Numbering(numbering.numberingID); } KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { int KIM_Model_Create(KIM_Numbering const numbering, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit, char const * const modelName, int * const requestedUnitsAccepted, KIM_Model ** const model) { std::string modelNameC(modelName); KIM::Model * pModel; int error = KIM::Model::Create(makeNumberingCpp(numbering), makeLengthUnitCpp(requestedLengthUnit), makeEnergyUnitCpp(requestedEnergyUnit), makeChargeUnitCpp(requestedChargeUnit), makeTemperatureUnitCpp(requestedTemperatureUnit), makeTimeUnitCpp(requestedTimeUnit), modelNameC, requestedUnitsAccepted, &pModel); if (error) { *model = NULL; return true; } else { (*model) = new KIM_Model; (*model)->p = (void *) pModel; return false; } } void KIM_Model_Destroy(KIM_Model ** const model) { if (*model != NULL) { KIM::Model * pModel = reinterpret_cast((*model)->p); KIM::Model::Destroy(&pModel); } delete (*model); *model = NULL; } int KIM_Model_IsRoutinePresent(KIM_Model const * const model, KIM_ModelRoutineName const modelRoutineName, int * const present, int * const required) { CONVERT_POINTER; return pModel->IsRoutinePresent( makeRoutineNameCpp(modelRoutineName), present, required); } void KIM_Model_GetInfluenceDistance(KIM_Model const * const model, double * const influenceDistance) { CONVERT_POINTER; pModel->GetInfluenceDistance(influenceDistance); } void KIM_Model_GetNeighborListPointers( KIM_Model const * const model, int * const numberOfNeighborLists, double const ** const cutoffs, int const ** const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pModel->GetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } void KIM_Model_GetUnits(KIM_Model const * const model, KIM_LengthUnit * const lengthUnit, KIM_EnergyUnit * const energyUnit, KIM_ChargeUnit * const chargeUnit, KIM_TemperatureUnit * const temperatureUnit, KIM_TimeUnit * const timeUnit) { CONVERT_POINTER; pModel->GetUnits(reinterpret_cast(lengthUnit), reinterpret_cast(energyUnit), reinterpret_cast(chargeUnit), reinterpret_cast(temperatureUnit), reinterpret_cast(timeUnit)); } int KIM_Model_ComputeArgumentsCreate( KIM_Model const * const model, KIM_ComputeArguments ** const computeArguments) { CONVERT_POINTER; KIM::ComputeArguments * pComputeArguments; int error = pModel->ComputeArgumentsCreate(&pComputeArguments); if (error) { *computeArguments = NULL; return true; } else { (*computeArguments) = new KIM_ComputeArguments; (*computeArguments)->p = (void *) pComputeArguments; return false; } } int KIM_Model_ComputeArgumentsDestroy( KIM_Model const * const model, KIM_ComputeArguments ** const computeArguments) { CONVERT_POINTER; int error = false; if (*computeArguments != NULL) { KIM::ComputeArguments * pComputeArguments = reinterpret_cast((*computeArguments)->p); error = pModel->ComputeArgumentsDestroy(&pComputeArguments); } delete (*computeArguments); *computeArguments = NULL; return error; } int KIM_Model_Compute(KIM_Model const * const model, KIM_ComputeArguments const * const computeArguments) { CONVERT_POINTER; KIM::ComputeArguments const * const pComputeArguments = reinterpret_cast(computeArguments->p); return pModel->Compute(pComputeArguments); } int KIM_Model_Extension(KIM_Model * const model, char const * const extensionID, void * const extensionStructure) { CONVERT_POINTER; return pModel->Extension(extensionID, extensionStructure); } int KIM_Model_ClearThenRefresh(KIM_Model * const model) { CONVERT_POINTER; return pModel->ClearThenRefresh(); } int KIM_Model_WriteParameterizedModel(KIM_Model const * const model, char const * const path, char const * const modelName) { CONVERT_POINTER; return pModel->WriteParameterizedModel(path, modelName); } int KIM_Model_GetSpeciesSupportAndCode(KIM_Model const * const model, KIM_SpeciesName const speciesName, int * const speciesIsSupported, int * const code) { CONVERT_POINTER; return pModel->GetSpeciesSupportAndCode( makeSpecNameCpp(speciesName), speciesIsSupported, code); } void KIM_Model_GetNumberOfParameters(KIM_Model const * const model, int * const numberOfParameters) { CONVERT_POINTER; pModel->GetNumberOfParameters(numberOfParameters); } int KIM_Model_GetParameterMetadata(KIM_Model const * const model, int const parameterIndex, KIM_DataType * const dataType, int * const extent, char const ** const name, char const ** const description) { CONVERT_POINTER; KIM::DataType typ; KIM::DataType * pTyp; if (dataType == NULL) pTyp = NULL; else pTyp = &typ; std::string const * pStrName; std::string const ** ppStrName; if (name == NULL) ppStrName = NULL; else ppStrName = &pStrName; std::string const * pStrDesc; std::string const ** ppStrDesc; if (description == NULL) ppStrDesc = NULL; else ppStrDesc = &pStrDesc; int error = pModel->GetParameterMetadata( parameterIndex, pTyp, extent, ppStrName, ppStrDesc); if (error) return true; else { if (dataType != NULL) *dataType = makeDataTypeC(typ); if (name != NULL) *name = pStrName->c_str(); if (description != NULL) *description = pStrDesc->c_str(); return false; } } int KIM_Model_GetParameterInteger(KIM_Model const * const model, int const parameterIndex, int const arrayIndex, int * const parameterValue) { CONVERT_POINTER; return pModel->GetParameter(parameterIndex, arrayIndex, parameterValue); } int KIM_Model_GetParameterDouble(KIM_Model const * const model, int const parameterIndex, int const arrayIndex, double * const parameterValue) { CONVERT_POINTER; return pModel->GetParameter(parameterIndex, arrayIndex, parameterValue); } int KIM_Model_SetParameterInteger(KIM_Model * const model, int const parameterIndex, int const arrayIndex, int const parameterValue) { CONVERT_POINTER; return pModel->SetParameter(parameterIndex, arrayIndex, parameterValue); } int KIM_Model_SetParameterDouble(KIM_Model * const model, int const parameterIndex, int const arrayIndex, double const parameterValue) { CONVERT_POINTER; return pModel->SetParameter(parameterIndex, arrayIndex, parameterValue); } void KIM_Model_SetSimulatorBufferPointer(KIM_Model * const model, void * const ptr) { CONVERT_POINTER; pModel->SetSimulatorBufferPointer(ptr); } void KIM_Model_GetSimulatorBufferPointer(KIM_Model const * const model, void ** const ptr) { CONVERT_POINTER; pModel->GetSimulatorBufferPointer(ptr); } char const * KIM_Model_ToString(KIM_Model const * const model) { CONVERT_POINTER; return pModel->ToString().c_str(); } void KIM_Model_SetLogID(KIM_Model * const model, char const * const logID) { CONVERT_POINTER; pModel->SetLogID(logID); } void KIM_Model_PushLogVerbosity(KIM_Model * const model, KIM_LogVerbosity const logVerbosity) { CONVERT_POINTER; pModel->PushLogVerbosity(makeLogVerbosityCpp(logVerbosity)); } void KIM_Model_PopLogVerbosity(KIM_Model * const model) { CONVERT_POINTER; pModel->PopLogVerbosity(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_Numbering_c.cpp000066400000000000000000000054271421473465500203140ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif extern "C" { #ifndef KIM_NUMBERING_H_ #include "KIM_Numbering.h" #endif } // extern "C" namespace { KIM::Numbering makeNumberingCpp(KIM_Numbering const numbering) { KIM::Numbering const * const numberingCpp = reinterpret_cast(&numbering); return *numberingCpp; } KIM_Numbering makeNumberingC(KIM::Numbering const numbering) { KIM_Numbering const * const numberingC = reinterpret_cast(&numbering); return *numberingC; } } // namespace extern "C" { KIM_Numbering KIM_Numbering_FromString(char const * const str) { return makeNumberingC(KIM::Numbering(std::string(str))); } int KIM_Numbering_Known(KIM_Numbering const numbering) { return makeNumberingCpp(numbering).Known(); } int KIM_Numbering_Equal(KIM_Numbering const lhs, KIM_Numbering const rhs) { return (lhs.numberingID == rhs.numberingID); } int KIM_Numbering_NotEqual(KIM_Numbering const lhs, KIM_Numbering const rhs) { return (!KIM_Numbering_Equal(lhs, rhs)); } char const * KIM_Numbering_ToString(KIM_Numbering const numbering) { return makeNumberingCpp(numbering).ToString().c_str(); } #include "KIM_Numbering.inc" KIM_Numbering const KIM_NUMBERING_zeroBased = {ID_zeroBased}; KIM_Numbering const KIM_NUMBERING_oneBased = {ID_oneBased}; void KIM_NUMBERING_GetNumberOfNumberings(int * const numberOfNumberings) { KIM::NUMBERING::GetNumberOfNumberings(numberOfNumberings); } int KIM_NUMBERING_GetNumbering(int const index, KIM_Numbering * const numbering) { KIM::Numbering numberingCpp; int error = KIM::NUMBERING::GetNumbering(index, &numberingCpp); if (error) return error; *numbering = makeNumberingC(numberingCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_SemVer_c.cpp000066400000000000000000000054231421473465500175630ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_SEM_VER_HPP_ #include "KIM_SemVer.hpp" #endif extern "C" { #ifndef KIM_SEM_VER_H_ #include "KIM_SemVer.h" #endif } // extern "C" extern "C" { char const * KIM_SEM_VER_GetSemVer() { return KIM::SEM_VER::GetSemVer().c_str(); } int KIM_SEM_VER_IsLessThan(char const * const lhs, char const * const rhs, int * const isLessThan) { return KIM::SEM_VER::IsLessThan( std::string(lhs), std::string(rhs), isLessThan); } int KIM_SEM_VER_ParseSemVer(char const * const version, int const prereleaseLength, int const buildMetadataLength, int * const major, int * const minor, int * const patch, char * const prerelease, char * const buildMetadata) { std::string prereleaseLocal; std::string buildMetadataLocal; std::string * prerel; std::string * build; if (prerelease == NULL) prerel = NULL; else prerel = &prereleaseLocal; if (buildMetadata == NULL) build = NULL; else build = &buildMetadataLocal; int error = KIM::SEM_VER::ParseSemVer( std::string(version), major, minor, patch, prerel, build); if (!error) { if (prerelease != NULL) { char * copyReturn = strncpy(prerelease, prereleaseLocal.c_str(), prereleaseLength); if (copyReturn != prerelease) error = 1; } if (buildMetadata != NULL) { char * copyReturn = strncpy( buildMetadata, buildMetadataLocal.c_str(), buildMetadataLength); if (copyReturn != buildMetadata) error = 1; } } return error; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_SimulatorModel_c.cpp000066400000000000000000000220631421473465500213210ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif extern "C" { #ifndef KIM_LOG_VERBOSITY_H_ #include "KIM_LogVerbosity.h" #endif } // extern "C" #ifndef KIM_SIMULATOR_MODEL_HPP_ #include "KIM_SimulatorModel.hpp" #endif extern "C" { #ifndef KIM_SIMULATOR_MODEL_H_ #include "KIM_SimulatorModel.h" #endif } // extern "C" struct KIM_SimulatorModel { void * p; }; #define CONVERT_POINTER \ KIM::SimulatorModel * pSimulatorModel \ = reinterpret_cast(simulatorModel->p) namespace { KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity logVerbosity) { return KIM::LogVerbosity(logVerbosity.logVerbosityID); } } // namespace extern "C" { int KIM_SimulatorModel_Create(char const * const simulatorModelName, KIM_SimulatorModel ** const simulatorModel) { std::string simulatorModelNameC(simulatorModelName); KIM::SimulatorModel * pSimulatorModel; int error = KIM::SimulatorModel::Create(simulatorModelNameC, &pSimulatorModel); if (error) { *simulatorModel = NULL; return true; } else { (*simulatorModel) = new KIM_SimulatorModel; (*simulatorModel)->p = (void *) pSimulatorModel; return false; } } void KIM_SimulatorModel_Destroy(KIM_SimulatorModel ** const simulatorModel) { if (*simulatorModel != NULL) { KIM::SimulatorModel * pSimulatorModel = reinterpret_cast((*simulatorModel)->p); KIM::SimulatorModel::Destroy(&pSimulatorModel); } delete (*simulatorModel); *simulatorModel = NULL; } void KIM_SimulatorModel_GetSimulatorNameAndVersion( KIM_SimulatorModel const * const simulatorModel, char const ** const simulatorName, char const ** const simulatorVersion) { CONVERT_POINTER; std::string const * pStrSimulatorName; std::string const ** ppStrSimulatorName; if (simulatorName == NULL) ppStrSimulatorName = NULL; else ppStrSimulatorName = &pStrSimulatorName; std::string const * pStrSimulatorVersion; std::string const ** ppStrSimulatorVersion; if (simulatorVersion == NULL) ppStrSimulatorVersion = NULL; else ppStrSimulatorVersion = &pStrSimulatorVersion; pSimulatorModel->GetSimulatorNameAndVersion(ppStrSimulatorName, ppStrSimulatorVersion); if (simulatorName != NULL) *simulatorName = pStrSimulatorName->c_str(); if (simulatorVersion != NULL) *simulatorVersion = pStrSimulatorVersion->c_str(); } void KIM_SimulatorModel_GetNumberOfSupportedSpecies( KIM_SimulatorModel const * const simulatorModel, int * const numberOfSupportedSpecies) { CONVERT_POINTER; pSimulatorModel->GetNumberOfSupportedSpecies(numberOfSupportedSpecies); } int KIM_SimulatorModel_GetSupportedSpecies( KIM_SimulatorModel const * const simulatorModel, int const index, char const ** const speciesName) { CONVERT_POINTER; std::string const * pStrSpecies; int error = pSimulatorModel->GetSupportedSpecies(index, &pStrSpecies); if (error) return true; else { *speciesName = pStrSpecies->c_str(); return false; } } void KIM_SimulatorModel_OpenAndInitializeTemplateMap( KIM_SimulatorModel const * const simulatorModel) { CONVERT_POINTER; pSimulatorModel->OpenAndInitializeTemplateMap(); } int KIM_SimulatorModel_TemplateMapIsOpen( KIM_SimulatorModel const * const simulatorModel) { CONVERT_POINTER; return pSimulatorModel->TemplateMapIsOpen(); } int KIM_SimulatorModel_AddTemplateMap( KIM_SimulatorModel const * const simulatorModel, char const * const key, char const * const value) { CONVERT_POINTER; return pSimulatorModel->AddTemplateMap(key, value); } void KIM_SimulatorModel_CloseTemplateMap( KIM_SimulatorModel const * const simulatorModel) { CONVERT_POINTER; pSimulatorModel->CloseTemplateMap(); } void KIM_SimulatorModel_GetNumberOfSimulatorFields( KIM_SimulatorModel const * const simulatorModel, int * const numberOfSimulatorFields) { CONVERT_POINTER; return pSimulatorModel->GetNumberOfSimulatorFields(numberOfSimulatorFields); } int KIM_SimulatorModel_GetSimulatorFieldMetadata( KIM_SimulatorModel const * const simulatorModel, int const fieldIndex, int * const extent, char const ** const fieldName) { CONVERT_POINTER; std::string const * pStrFieldName; std::string const ** ppStrFieldName; if (fieldName == NULL) ppStrFieldName = NULL; else ppStrFieldName = &pStrFieldName; int error = pSimulatorModel->GetSimulatorFieldMetadata( fieldIndex, extent, ppStrFieldName); if (error) return true; else { if (fieldName != NULL) *fieldName = pStrFieldName->c_str(); return false; } } int KIM_SimulatorModel_GetSimulatorFieldLine( KIM_SimulatorModel const * const simulatorModel, int const fieldIndex, int const lineIndex, char const ** const lineValue) { CONVERT_POINTER; std::string const * pStrLineValue; int error = pSimulatorModel->GetSimulatorFieldLine( fieldIndex, lineIndex, &pStrLineValue); if (error) return true; else { *lineValue = pStrLineValue->c_str(); return false; } } void KIM_SimulatorModel_GetParameterFileDirectoryName( KIM_SimulatorModel const * const simulatorModel, char const ** const directoryName) { CONVERT_POINTER; std::string const * pStrDirectoryName; pSimulatorModel->GetParameterFileDirectoryName(&pStrDirectoryName); *directoryName = pStrDirectoryName->c_str(); } void KIM_SimulatorModel_GetSpecificationFileName( KIM_SimulatorModel const * const simulatorModel, char const ** const specificationFileName) { CONVERT_POINTER; std::string const * pStrSpecificationFileName; pSimulatorModel->GetSpecificationFileName(&pStrSpecificationFileName); *specificationFileName = pStrSpecificationFileName->c_str(); } void KIM_SimulatorModel_GetNumberOfParameterFiles( KIM_SimulatorModel const * const simulatorModel, int * const numberOfParameterFiles) { CONVERT_POINTER; pSimulatorModel->GetNumberOfParameterFiles(numberOfParameterFiles); } int KIM_SimulatorModel_GetParameterFileName( KIM_SimulatorModel const * const simulatorModel, int const index, char const ** const parameterFileName) { CONVERT_POINTER; std::string const * pStrParameterFileName; int error = pSimulatorModel->GetParameterFileName(index, &pStrParameterFileName); if (error) return true; else { *parameterFileName = pStrParameterFileName->c_str(); return false; } } int KIM_SimulatorModel_GetParameterFileBasename( KIM_SimulatorModel const * const simulatorModel, int const index, char const ** const parameterFileBasename) { CONVERT_POINTER; std::string const * pStrParameterFileBasename; int error = pSimulatorModel->GetParameterFileBasename( index, &pStrParameterFileBasename); if (error) return true; else { *parameterFileBasename = pStrParameterFileBasename->c_str(); return false; } } void KIM_SimulatorModel_SetSimulatorBufferPointer( KIM_SimulatorModel * const simulatorModel, void * const ptr) { CONVERT_POINTER; pSimulatorModel->SetSimulatorBufferPointer(ptr); } void KIM_SimulatorModel_GetSimulatorBufferPointer( KIM_SimulatorModel const * const simulatorModel, void ** const ptr) { CONVERT_POINTER; pSimulatorModel->GetSimulatorBufferPointer(ptr); } char const * KIM_SimulatorModel_ToString(KIM_SimulatorModel const * const simulatorModel) { CONVERT_POINTER; return pSimulatorModel->ToString().c_str(); } void KIM_SimulatorModel_SetLogID(KIM_SimulatorModel * const simulatorModel, char const * const logID) { CONVERT_POINTER; pSimulatorModel->SetLogID(logID); } void KIM_SimulatorModel_PushLogVerbosity( KIM_SimulatorModel * const simulatorModel, KIM_LogVerbosity const logVerbosity) { CONVERT_POINTER; pSimulatorModel->PushLogVerbosity(makeLogVerbosityCpp(logVerbosity)); } void KIM_SimulatorModel_PopLogVerbosity( KIM_SimulatorModel * const simulatorModel) { CONVERT_POINTER; pSimulatorModel->PopLogVerbosity(); } } // extern "C" kim-api-2.3.0-git/c/src/KIM_SpeciesName_c.cpp000066400000000000000000000277761421473465500205750ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif extern "C" { #ifndef KIM_SPECIES_NAME_H_ #include "KIM_SpeciesName.h" #endif } // extern "C" namespace { KIM::SpeciesName makeSpeciesNameCpp(KIM_SpeciesName const speciesName) { KIM::SpeciesName const * const speciesNameCpp = reinterpret_cast(&speciesName); return *speciesNameCpp; } KIM_SpeciesName makeSpeciesNameC(KIM::SpeciesName speciesName) { KIM_SpeciesName const * const speciesNameC = reinterpret_cast(&speciesName); return *speciesNameC; } } // namespace extern "C" { KIM_SpeciesName KIM_SpeciesName_FromString(char const * const str) { return makeSpeciesNameC(KIM::SpeciesName(std::string(str))); } int KIM_SpeciesName_Known(KIM_SpeciesName const speciesName) { return makeSpeciesNameCpp(speciesName).Known(); } int KIM_SpeciesName_Equal(KIM_SpeciesName const lhs, KIM_SpeciesName const rhs) { return (lhs.speciesNameID == rhs.speciesNameID); } int KIM_SpeciesName_NotEqual(KIM_SpeciesName const lhs, KIM_SpeciesName const rhs) { return (!KIM_SpeciesName_Equal(lhs, rhs)); } char const * KIM_SpeciesName_ToString(KIM_SpeciesName const speciesName) { return makeSpeciesNameCpp(speciesName).ToString().c_str(); } #include "KIM_SpeciesName.inc" KIM_SpeciesName const KIM_SPECIES_NAME_electron = {ID_electron}; // electron KIM_SpeciesName const KIM_SPECIES_NAME_H = {ID_H}; // Hydrogen KIM_SpeciesName const KIM_SPECIES_NAME_He = {ID_He}; // Helium KIM_SpeciesName const KIM_SPECIES_NAME_Li = {ID_Li}; // Lithium KIM_SpeciesName const KIM_SPECIES_NAME_Be = {ID_Be}; // Beryllium KIM_SpeciesName const KIM_SPECIES_NAME_B = {ID_B}; // Boron KIM_SpeciesName const KIM_SPECIES_NAME_C = {ID_C}; // Carbon KIM_SpeciesName const KIM_SPECIES_NAME_N = {ID_N}; // Nitrogen KIM_SpeciesName const KIM_SPECIES_NAME_O = {ID_O}; // Oxygen KIM_SpeciesName const KIM_SPECIES_NAME_F = {ID_F}; // Fluorine KIM_SpeciesName const KIM_SPECIES_NAME_Ne = {ID_Ne}; // Neon KIM_SpeciesName const KIM_SPECIES_NAME_Na = {ID_Na}; // Sodium KIM_SpeciesName const KIM_SPECIES_NAME_Mg = {ID_Mg}; // Magnesium KIM_SpeciesName const KIM_SPECIES_NAME_Al = {ID_Al}; // Aluminum KIM_SpeciesName const KIM_SPECIES_NAME_Si = {ID_Si}; // Silicon KIM_SpeciesName const KIM_SPECIES_NAME_P = {ID_P}; // Phosphorus KIM_SpeciesName const KIM_SPECIES_NAME_S = {ID_S}; // Sulfur KIM_SpeciesName const KIM_SPECIES_NAME_Cl = {ID_Cl}; // Chlorine KIM_SpeciesName const KIM_SPECIES_NAME_Ar = {ID_Ar}; // Argon KIM_SpeciesName const KIM_SPECIES_NAME_K = {ID_K}; // Potassium KIM_SpeciesName const KIM_SPECIES_NAME_Ca = {ID_Ca}; // Calcium KIM_SpeciesName const KIM_SPECIES_NAME_Sc = {ID_Sc}; // Scandium KIM_SpeciesName const KIM_SPECIES_NAME_Ti = {ID_Ti}; // Titanium KIM_SpeciesName const KIM_SPECIES_NAME_V = {ID_V}; // Vanadium KIM_SpeciesName const KIM_SPECIES_NAME_Cr = {ID_Cr}; // Chromium KIM_SpeciesName const KIM_SPECIES_NAME_Mn = {ID_Mn}; // Manganese KIM_SpeciesName const KIM_SPECIES_NAME_Fe = {ID_Fe}; // Iron KIM_SpeciesName const KIM_SPECIES_NAME_Co = {ID_Co}; // Cobalt KIM_SpeciesName const KIM_SPECIES_NAME_Ni = {ID_Ni}; // Nickel KIM_SpeciesName const KIM_SPECIES_NAME_Cu = {ID_Cu}; // Copper KIM_SpeciesName const KIM_SPECIES_NAME_Zn = {ID_Zn}; // Zinc KIM_SpeciesName const KIM_SPECIES_NAME_Ga = {ID_Ga}; // Gallium KIM_SpeciesName const KIM_SPECIES_NAME_Ge = {ID_Ge}; // Germanium KIM_SpeciesName const KIM_SPECIES_NAME_As = {ID_As}; // Arsenic KIM_SpeciesName const KIM_SPECIES_NAME_Se = {ID_Se}; // Selenium KIM_SpeciesName const KIM_SPECIES_NAME_Br = {ID_Br}; // Bromine KIM_SpeciesName const KIM_SPECIES_NAME_Kr = {ID_Kr}; // Krypton KIM_SpeciesName const KIM_SPECIES_NAME_Rb = {ID_Rb}; // Rubidium KIM_SpeciesName const KIM_SPECIES_NAME_Sr = {ID_Sr}; // Strontium KIM_SpeciesName const KIM_SPECIES_NAME_Y = {ID_Y}; // Yttrium KIM_SpeciesName const KIM_SPECIES_NAME_Zr = {ID_Zr}; // Zirconium KIM_SpeciesName const KIM_SPECIES_NAME_Nb = {ID_Nb}; // Niobium KIM_SpeciesName const KIM_SPECIES_NAME_Mo = {ID_Mo}; // Molybdenum KIM_SpeciesName const KIM_SPECIES_NAME_Tc = {ID_Tc}; // Technetium KIM_SpeciesName const KIM_SPECIES_NAME_Ru = {ID_Ru}; // Ruthenium KIM_SpeciesName const KIM_SPECIES_NAME_Rh = {ID_Rh}; // Rhodium KIM_SpeciesName const KIM_SPECIES_NAME_Pd = {ID_Pd}; // Palladium KIM_SpeciesName const KIM_SPECIES_NAME_Ag = {ID_Ag}; // Silver KIM_SpeciesName const KIM_SPECIES_NAME_Cd = {ID_Cd}; // Cadmium KIM_SpeciesName const KIM_SPECIES_NAME_In = {ID_In}; // Indium KIM_SpeciesName const KIM_SPECIES_NAME_Sn = {ID_Sn}; // Tin KIM_SpeciesName const KIM_SPECIES_NAME_Sb = {ID_Sb}; // Antimony KIM_SpeciesName const KIM_SPECIES_NAME_Te = {ID_Te}; // Tellurium KIM_SpeciesName const KIM_SPECIES_NAME_I = {ID_I}; // Iodine KIM_SpeciesName const KIM_SPECIES_NAME_Xe = {ID_Xe}; // Xenon KIM_SpeciesName const KIM_SPECIES_NAME_Cs = {ID_Cs}; // Cesium KIM_SpeciesName const KIM_SPECIES_NAME_Ba = {ID_Ba}; // Barium KIM_SpeciesName const KIM_SPECIES_NAME_La = {ID_La}; // Lanthanum KIM_SpeciesName const KIM_SPECIES_NAME_Ce = {ID_Ce}; // Cerium KIM_SpeciesName const KIM_SPECIES_NAME_Pr = {ID_Pr}; // Praseodymium KIM_SpeciesName const KIM_SPECIES_NAME_Nd = {ID_Nd}; // Neodymium KIM_SpeciesName const KIM_SPECIES_NAME_Pm = {ID_Pm}; // Promethium KIM_SpeciesName const KIM_SPECIES_NAME_Sm = {ID_Sm}; // Samarium KIM_SpeciesName const KIM_SPECIES_NAME_Eu = {ID_Eu}; // Europium KIM_SpeciesName const KIM_SPECIES_NAME_Gd = {ID_Gd}; // Gadolinium KIM_SpeciesName const KIM_SPECIES_NAME_Tb = {ID_Tb}; // Terbium KIM_SpeciesName const KIM_SPECIES_NAME_Dy = {ID_Dy}; // Dysprosium KIM_SpeciesName const KIM_SPECIES_NAME_Ho = {ID_Ho}; // Holmium KIM_SpeciesName const KIM_SPECIES_NAME_Er = {ID_Er}; // Erbium KIM_SpeciesName const KIM_SPECIES_NAME_Tm = {ID_Tm}; // Thulium KIM_SpeciesName const KIM_SPECIES_NAME_Yb = {ID_Yb}; // Ytterbium KIM_SpeciesName const KIM_SPECIES_NAME_Lu = {ID_Lu}; // Lutetium KIM_SpeciesName const KIM_SPECIES_NAME_Hf = {ID_Hf}; // Hafnium KIM_SpeciesName const KIM_SPECIES_NAME_Ta = {ID_Ta}; // Tantalum KIM_SpeciesName const KIM_SPECIES_NAME_W = {ID_W}; // Tungsten KIM_SpeciesName const KIM_SPECIES_NAME_Re = {ID_Re}; // Rhenium KIM_SpeciesName const KIM_SPECIES_NAME_Os = {ID_Os}; // Osmium KIM_SpeciesName const KIM_SPECIES_NAME_Ir = {ID_Ir}; // Iridium KIM_SpeciesName const KIM_SPECIES_NAME_Pt = {ID_Pt}; // Platinum KIM_SpeciesName const KIM_SPECIES_NAME_Au = {ID_Au}; // Gold KIM_SpeciesName const KIM_SPECIES_NAME_Hg = {ID_Hg}; // Mercury KIM_SpeciesName const KIM_SPECIES_NAME_Tl = {ID_Tl}; // Thallium KIM_SpeciesName const KIM_SPECIES_NAME_Pb = {ID_Pb}; // Lead KIM_SpeciesName const KIM_SPECIES_NAME_Bi = {ID_Bi}; // Bismuth KIM_SpeciesName const KIM_SPECIES_NAME_Po = {ID_Po}; // Polonium KIM_SpeciesName const KIM_SPECIES_NAME_At = {ID_At}; // Astatine KIM_SpeciesName const KIM_SPECIES_NAME_Rn = {ID_Rn}; // Radon KIM_SpeciesName const KIM_SPECIES_NAME_Fr = {ID_Fr}; // Francium KIM_SpeciesName const KIM_SPECIES_NAME_Ra = {ID_Ra}; // Radium KIM_SpeciesName const KIM_SPECIES_NAME_Ac = {ID_Ac}; // Actinium KIM_SpeciesName const KIM_SPECIES_NAME_Th = {ID_Th}; // Thorium KIM_SpeciesName const KIM_SPECIES_NAME_Pa = {ID_Pa}; // Protactinium KIM_SpeciesName const KIM_SPECIES_NAME_U = {ID_U}; // Uranium KIM_SpeciesName const KIM_SPECIES_NAME_Np = {ID_Np}; // Neptunium KIM_SpeciesName const KIM_SPECIES_NAME_Pu = {ID_Pu}; // Plutonium KIM_SpeciesName const KIM_SPECIES_NAME_Am = {ID_Am}; // Americium KIM_SpeciesName const KIM_SPECIES_NAME_Cm = {ID_Cm}; // Curium KIM_SpeciesName const KIM_SPECIES_NAME_Bk = {ID_Bk}; // Berkelium KIM_SpeciesName const KIM_SPECIES_NAME_Cf = {ID_Cf}; // Californium KIM_SpeciesName const KIM_SPECIES_NAME_Es = {ID_Es}; // Einsteinium KIM_SpeciesName const KIM_SPECIES_NAME_Fm = {ID_Fm}; // Fermium KIM_SpeciesName const KIM_SPECIES_NAME_Md = {ID_Md}; // Mendelevium KIM_SpeciesName const KIM_SPECIES_NAME_No = {ID_No}; // Nobelium KIM_SpeciesName const KIM_SPECIES_NAME_Lr = {ID_Lr}; // Lawrencium KIM_SpeciesName const KIM_SPECIES_NAME_Rf = {ID_Rf}; // Rutherfordium KIM_SpeciesName const KIM_SPECIES_NAME_Db = {ID_Db}; // Dubnium KIM_SpeciesName const KIM_SPECIES_NAME_Sg = {ID_Sg}; // Seaborgium KIM_SpeciesName const KIM_SPECIES_NAME_Bh = {ID_Bh}; // Bohrium KIM_SpeciesName const KIM_SPECIES_NAME_Hs = {ID_Hs}; // Hassium KIM_SpeciesName const KIM_SPECIES_NAME_Mt = {ID_Mt}; // Meitnerium KIM_SpeciesName const KIM_SPECIES_NAME_Ds = {ID_Ds}; // Darmstadtium KIM_SpeciesName const KIM_SPECIES_NAME_Rg = {ID_Rg}; // Roentgenium KIM_SpeciesName const KIM_SPECIES_NAME_Cn = {ID_Cn}; // Copernicium KIM_SpeciesName const KIM_SPECIES_NAME_Nh = {ID_Nh}; // Nihonium KIM_SpeciesName const KIM_SPECIES_NAME_Fl = {ID_Fl}; // Flerovium KIM_SpeciesName const KIM_SPECIES_NAME_Mc = {ID_Mc}; // Moscovium KIM_SpeciesName const KIM_SPECIES_NAME_Lv = {ID_Lv}; // Livermorium KIM_SpeciesName const KIM_SPECIES_NAME_Ts = {ID_Ts}; // Tennessine KIM_SpeciesName const KIM_SPECIES_NAME_Og = {ID_Og}; // Oganesson KIM_SpeciesName const KIM_SPECIES_NAME_user01 = {ID_user01}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user02 = {ID_user02}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user03 = {ID_user03}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user04 = {ID_user04}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user05 = {ID_user05}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user06 = {ID_user06}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user07 = {ID_user07}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user08 = {ID_user08}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user09 = {ID_user09}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user10 = {ID_user10}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user11 = {ID_user11}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user12 = {ID_user12}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user13 = {ID_user13}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user14 = {ID_user14}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user15 = {ID_user15}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user16 = {ID_user16}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user17 = {ID_user17}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user18 = {ID_user18}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user19 = {ID_user19}; // user defined KIM_SpeciesName const KIM_SPECIES_NAME_user20 = {ID_user20}; // user defined void KIM_SPECIES_NAME_GetNumberOfSpeciesNames(int * const numberOfSpeciesNames) { KIM::SPECIES_NAME::GetNumberOfSpeciesNames(numberOfSpeciesNames); } int KIM_SPECIES_NAME_GetSpeciesName(int const index, KIM_SpeciesName * const speciesName) { KIM::SpeciesName speciesNameCpp; int error = KIM::SPECIES_NAME::GetSpeciesName(index, &speciesNameCpp); if (error) return error; *speciesName = makeSpeciesNameC(speciesNameCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_SupportStatus_c.cpp000066400000000000000000000064651421473465500212510ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif extern "C" { #ifndef KIM_SUPPORT_STATUS_H_ #include "KIM_SupportStatus.h" #endif } // extern "C" namespace { KIM::SupportStatus makeSupportStatusCpp(KIM_SupportStatus const supportStatus) { KIM::SupportStatus const * const supportStatusCpp = reinterpret_cast(&supportStatus); return *supportStatusCpp; } KIM_SupportStatus makeSupportStatusC(KIM::SupportStatus const supportStatus) { KIM_SupportStatus const * const supportStatusC = reinterpret_cast(&supportStatus); return *supportStatusC; } } // namespace extern "C" { KIM_SupportStatus KIM_SupportStatus_FromString(char const * const str) { return makeSupportStatusC(KIM::SupportStatus(std::string(str))); } int KIM_SupportStatus_Known(KIM_SupportStatus const supportStatus) { return makeSupportStatusCpp(supportStatus).Known(); } int KIM_SupportStatus_Equal(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs) { return (lhs.supportStatusID == rhs.supportStatusID); } int KIM_SupportStatus_NotEqual(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs) { return (!KIM_SupportStatus_Equal(lhs, rhs)); } char const * KIM_SupportStatus_ToString(KIM_SupportStatus const supportStatus) { return makeSupportStatusCpp(supportStatus).ToString().c_str(); } #include "KIM_SupportStatus.inc" KIM_SupportStatus const KIM_SUPPORT_STATUS_requiredByAPI = {ID_requiredByAPI}; KIM_SupportStatus const KIM_SUPPORT_STATUS_notSupported = {ID_notSupported}; KIM_SupportStatus const KIM_SUPPORT_STATUS_required = {ID_required}; KIM_SupportStatus const KIM_SUPPORT_STATUS_optional = {ID_optional}; void KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses( int * const numberOfSupportStatuses) { KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses(numberOfSupportStatuses); } int KIM_SUPPORT_STATUS_GetSupportStatus(int const index, KIM_SupportStatus * const supportStatus) { KIM::SupportStatus supportStatusCpp; int error = KIM::SUPPORT_STATUS::GetSupportStatus(index, &supportStatusCpp); if (error) return error; *supportStatus = makeSupportStatusC(supportStatusCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_TemperatureUnit_c.cpp000066400000000000000000000063441421473465500215220ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_TEMPERATURE_UNIT_HPP_ #include "KIM_TemperatureUnit.hpp" #endif extern "C" { #ifndef KIM_TEMPERATURE_UNIT_H_ #include "KIM_TemperatureUnit.h" #endif } namespace { KIM::TemperatureUnit makeTemperatureUnitCpp(KIM_TemperatureUnit const temperatureUnit) { KIM::TemperatureUnit const * const temperatureUnitCpp = reinterpret_cast(&temperatureUnit); return *temperatureUnitCpp; } KIM_TemperatureUnit makeTemperatureUnitC(KIM::TemperatureUnit const temperatureUnit) { KIM_TemperatureUnit const * const temperatureUnitC = reinterpret_cast(&temperatureUnit); return *temperatureUnitC; } } // namespace extern "C" { KIM_TemperatureUnit KIM_TemperatureUnit_FromString(char const * const str) { return makeTemperatureUnitC(KIM::TemperatureUnit(std::string(str))); } int KIM_TemperatureUnit_Known(KIM_TemperatureUnit const temperatureUnit) { return makeTemperatureUnitCpp(temperatureUnit).Known(); } int KIM_TemperatureUnit_Equal(KIM_TemperatureUnit const lhs, KIM_TemperatureUnit const rhs) { return (lhs.temperatureUnitID == rhs.temperatureUnitID); } int KIM_TemperatureUnit_NotEqual(KIM_TemperatureUnit const lhs, KIM_TemperatureUnit const rhs) { return (!KIM_TemperatureUnit_Equal(lhs, rhs)); } char const * KIM_TemperatureUnit_ToString(KIM_TemperatureUnit const temperatureUnit) { return makeTemperatureUnitCpp(temperatureUnit).ToString().c_str(); } #include "KIM_TemperatureUnit.inc" KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_unused = {ID_unused}; KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K = {ID_K}; void KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits( int * const numberOfTemperatureUnits) { KIM::TEMPERATURE_UNIT::GetNumberOfTemperatureUnits(numberOfTemperatureUnits); } int KIM_TEMPERATURE_UNIT_GetTemperatureUnit( int const index, KIM_TemperatureUnit * const temperatureUnit) { KIM::TemperatureUnit temperatureUnitCpp; int error = KIM::TEMPERATURE_UNIT::GetTemperatureUnit(index, &temperatureUnitCpp); if (error) return error; *temperatureUnit = makeTemperatureUnitC(temperatureUnitCpp); return false; } } // extern "C" kim-api-2.3.0-git/c/src/KIM_TimeUnit_c.cpp000066400000000000000000000055061421473465500201220ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_TIME_UNIT_HPP_ #include "KIM_TimeUnit.hpp" #endif extern "C" { #ifndef KIM_TIME_UNIT_H_ #include "KIM_TimeUnit.h" #endif } namespace { KIM::TimeUnit makeTimeUnitCpp(KIM_TimeUnit const timeUnit) { KIM::TimeUnit const * const timeUnitCpp = reinterpret_cast(&timeUnit); return *timeUnitCpp; } KIM_TimeUnit makeTimeUnitC(KIM::TimeUnit const timeUnit) { KIM_TimeUnit const * const timeUnitC = reinterpret_cast(&timeUnit); return *timeUnitC; } } // namespace extern "C" { KIM_TimeUnit KIM_TimeUnit_FromString(char const * const str) { return makeTimeUnitC(KIM::TimeUnit(std::string(str))); } int KIM_TimeUnit_Known(KIM_TimeUnit const timeUnit) { return makeTimeUnitCpp(timeUnit).Known(); } int KIM_TimeUnit_Equal(KIM_TimeUnit const lhs, KIM_TimeUnit const rhs) { return (lhs.timeUnitID == rhs.timeUnitID); } int KIM_TimeUnit_NotEqual(KIM_TimeUnit const lhs, KIM_TimeUnit const rhs) { return (!KIM_TimeUnit_Equal(lhs, rhs)); } char const * KIM_TimeUnit_ToString(KIM_TimeUnit const tiemUnit) { return makeTimeUnitCpp(tiemUnit).ToString().c_str(); } #include "KIM_TimeUnit.inc" KIM_TimeUnit const KIM_TIME_UNIT_unused = {ID_unused}; KIM_TimeUnit const KIM_TIME_UNIT_fs = {ID_fs}; KIM_TimeUnit const KIM_TIME_UNIT_ps = {ID_ps}; KIM_TimeUnit const KIM_TIME_UNIT_ns = {ID_ns}; KIM_TimeUnit const KIM_TIME_UNIT_s = {ID_s}; void KIM_TIME_UNIT_GetNumberOfTimeUnits(int * const numberOfTimeUnits) { KIM::TIME_UNIT::GetNumberOfTimeUnits(numberOfTimeUnits); } int KIM_TIME_UNIT_GetTimeUnit(int const index, KIM_TimeUnit * const timeUnit) { KIM::TimeUnit timeUnitCpp; int error = KIM::TIME_UNIT::GetTimeUnit(index, &timeUnitCpp); if (error) return error; *timeUnit = makeTimeUnitC(timeUnitCpp); return false; } } // extern "C" kim-api-2.3.0-git/cmake/000077500000000000000000000000001421473465500147175ustar00rootroot00000000000000kim-api-2.3.0-git/cmake/CMakeLists.txt000066400000000000000000000153561421473465500174710ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # include(CMakePackageConfigHelpers) function(_configure_common_package_components) set(_options "") set(_oneValueArgs INSTALL_TREE_DIR BUILD_TREE_DIR INSTALL_CONFIG_IN BUILD_CONFIG_IN CONFIG MACROS_IN MACROS VERSION_FILE VERSION_COMPATIBILITY ) set(_multiValueArgs "") cmake_parse_arguments(_cpkg "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_cpkg_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_configure_common_pacakge_components'") endif() # Create package files configure_file("${_cpkg_INSTALL_CONFIG_IN}" "${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_CONFIG}" @ONLY) configure_file("${_cpkg_MACROS_IN}" "${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_MACROS}" @ONLY) write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_VERSION_FILE}" VERSION ${PROJECT_VERSION} COMPATIBILITY ${_cpkg_VERSION_COMPATIBILITY} ) # Package files for *build tree* configure_file("${_cpkg_BUILD_CONFIG_IN}" "${_cpkg_BUILD_TREE_DIR}/${_cpkg_CONFIG}" @ONLY) configure_file("${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_VERSION_FILE}" "${_cpkg_BUILD_TREE_DIR}/${_cpkg_VERSION_FILE}" COPYONLY) configure_file("${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_MACROS}" "${_cpkg_BUILD_TREE_DIR}/${_cpkg_MACROS}" COPYONLY) # Package files for *install tree* install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_CONFIG}" "${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_MACROS}" "${CMAKE_CURRENT_BINARY_DIR}/${_cpkg_VERSION_FILE}" DESTINATION "${_cpkg_INSTALL_TREE_DIR}" ) endfunction(_configure_common_package_components) ############################################################################### set(_BUILD_TREE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/${KIM_API_BUILD_TREE_CONFIG_DIR_IDENTIFIER}") set(_BUILD_TREE_ITEMS_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/${KIM_API_BUILD_TREE_CONFIG_DIR_IDENTIFIER}-items") # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior set(_INSTALL_TREE_CONFIG_DIR "${CMAKE_INSTALL_RELOC_DATADIR}/cmake/${PROJECT_NAME}") set(_INSTALL_TREE_ITEMS_CONFIG_DIR "${CMAKE_INSTALL_RELOC_DATADIR}/cmake/${PROJECT_NAME}-items") # KIM-API package set(CONFIG_FILE_IN config.cmake.in) set(CONFIG_FILE kim-api-config.cmake) # should _not_ use PROJECT_NAME here set(BUILD_TREE_CONFIG_FILE_IN build-tree-config.cmake.in) set(MACROS_FILE_IN macros.cmake.in) set(MACROS_FILE kim-api-macros.cmake) # should _not_ use PROJECT_NAME here set(TARGETS_FILE kim-api-targets.cmake) # should _not_ use PROJECT_NAME here set(CONFIG_VERSION_FILE kim-api-config-version.cmake) # should _not_ use PROJECT_NAME here _configure_common_package_components( INSTALL_TREE_DIR ${_INSTALL_TREE_CONFIG_DIR} BUILD_TREE_DIR ${_BUILD_TREE_CONFIG_DIR} INSTALL_CONFIG_IN ${CONFIG_FILE_IN} BUILD_CONFIG_IN ${BUILD_TREE_CONFIG_FILE_IN} CONFIG ${CONFIG_FILE} MACROS_IN ${MACROS_FILE_IN} MACROS ${MACROS_FILE} VERSION_FILE ${CONFIG_VERSION_FILE} VERSION_COMPATIBILITY SameMajorVersion ) # KIM-API Targets -- install tree only install(EXPORT KIM_API_Targets FILE "${TARGETS_FILE}" NAMESPACE KIM-API:: DESTINATION "${_INSTALL_TREE_CONFIG_DIR}" ) # REMOVE THE BELOW LINES FOR 3.0.0 RELEASE!!! set(PRE_2_2_COMPATIBILITY_FILE_IN pre-2.2-compatibility.cmake.in) # REMOVE THIS LINE FOR 3.0.0 RELEASE!!! set(PRE_2_2_COMPATIBILITY_FILE kim-api-pre-2.2-compatibility.cmake) # REMOVE THIS LINE FOR 3.0.0 RELEASE!!! configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${PRE_2_2_COMPATIBILITY_FILE_IN}" "${CMAKE_CURRENT_BINARY_DIR}/${PRE_2_2_COMPATIBILITY_FILE}" @ONLY) # REMOVE THIS LINE FOR 3.0.0 RELEASE!!! configure_file("${CMAKE_CURRENT_BINARY_DIR}/${PRE_2_2_COMPATIBILITY_FILE}" "${_BUILD_TREE_CONFIG_DIR}/${PRE_2_2_COMPATIBILITY_FILE}" COPYONLY) # REMOVE THIS LINE FOR 3.0.0 RELEASE!!! install( # REMOVE THESE LINES FOR 3.0.0 RELEASE!!! FILES "${CMAKE_CURRENT_BINARY_DIR}/${PRE_2_2_COMPATIBILITY_FILE}" DESTINATION "${_INSTALL_TREE_CONFIG_DIR}" ) # KIM-API-ITEMS package set(ITEMS_CONFIG_FILE_IN items-config.cmake.in) set(ITEMS_CONFIG_FILE kim-api-items-config.cmake) # should _not_ use PROJECT_NAME here set(BUILD_TREE_ITEMS_CONFIG_FILE_IN build-tree-items-config.cmake.in) set(ITEMS_MACROS_FILE_IN items-macros.cmake.in) set(ITEMS_MACROS_FILE kim-api-items-macros.cmake) # should _not_ use PROJECT_NAME here set(ITEMS_CONFIG_VERSION_FILE kim-api-items-config-version.cmake) # should _not_ use PROJECT_NAME here set(ITEM_COMPILED_WITH_VERSION_IN item-compiled-with-version.txt.in) set(ITEM_COMPILED_WITH_VERSION item-compiled-with-version.txt) set(ITEM_BUILD_SOURCES KIM_SharedLibrarySchema.hpp item-wrapper.cpp.in item-info.txt.in ) _configure_common_package_components( INSTALL_TREE_DIR ${_INSTALL_TREE_ITEMS_CONFIG_DIR} BUILD_TREE_DIR ${_BUILD_TREE_ITEMS_CONFIG_DIR} INSTALL_CONFIG_IN ${ITEMS_CONFIG_FILE_IN} BUILD_CONFIG_IN ${BUILD_TREE_ITEMS_CONFIG_FILE_IN} CONFIG ${ITEMS_CONFIG_FILE} MACROS_IN ${ITEMS_MACROS_FILE_IN} MACROS ${ITEMS_MACROS_FILE} VERSION_FILE ${ITEMS_CONFIG_VERSION_FILE} VERSION_COMPATIBILITY AnyNewerVersion # allow newer major versions for KIM Items as convenience ) # KIM-API-ITEMS extra files configure_file("${ITEM_COMPILED_WITH_VERSION_IN}" "${CMAKE_CURRENT_BINARY_DIR}/${ITEM_COMPILED_WITH_VERSION}" @ONLY) foreach(_FL IN LISTS ITEM_BUILD_SOURCES) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${_FL}" "${_BUILD_TREE_ITEMS_CONFIG_DIR}/${_FL}" COPYONLY) endforeach() unset(_FL) # build tree configure_file("${CMAKE_CURRENT_BINARY_DIR}/${ITEM_COMPILED_WITH_VERSION}" "${_BUILD_TREE_ITEMS_CONFIG_DIR}/${ITEM_COMPILED_WITH_VERSION}" COPYONLY) # install tree install( FILES ${ITEM_BUILD_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/${ITEM_COMPILED_WITH_VERSION}" DESTINATION "${_INSTALL_TREE_ITEMS_CONFIG_DIR}" ) add_subdirectory(Modules) kim-api-2.3.0-git/cmake/KIM_SharedLibrarySchema.hpp000066400000000000000000000054001421473465500220030ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SHARED_LIBRARY_SCHEMA_HPP_ #define KIM_SHARED_LIBRARY_SCHEMA_HPP_ #define KIM_SHARED_LIBRARY_SCHEMA_VERSION 2 #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif namespace KIM { // Forward declarations class LanguageName; namespace SHARED_LIBRARY_SCHEMA { struct SharedLibrarySchemaV2 { struct EmbeddedFile { char const * fileName; unsigned int const fileLength; unsigned char const * const filePointer; }; // struct EmbeddedFile CollectionItemType const itemType; char const * const itemName; LanguageName const createLanguageName; Function * createRoutine; char const * const driverName; EmbeddedFile const * const simulatorModelSpecificationFile; int const numberOfParameterFiles; EmbeddedFile const * const parameterFiles; int const numberOfMetadataFiles; EmbeddedFile const * const metadataFiles; }; // struct SharedLibrarySchemaV2 struct SharedLibrarySchemaV1 { enum ITEM_TYPE { STAND_ALONE_MODEL, PARAMETERIZED_MODEL, SIMULATOR_MODEL, MODEL_DRIVER }; struct EmbeddedFile { char const * fileName; unsigned int const fileLength; unsigned char const * const filePointer; }; // struct EmbeddedFile char const * const compiledWithVersion; ITEM_TYPE const itemType; char const * const itemName; LanguageName const createLanguageName; Function * createRoutine; char const * const driverName; int const numberOfParameterFiles; EmbeddedFile const * const parameterFiles; EmbeddedFile const * const metadataFile; }; // struct SharedLibrarySchemaV1 } // namespace SHARED_LIBRARY_SCHEMA } // namespace KIM #endif // KIM_SHARED_LIBRARY_SCHEMA_HPP_ kim-api-2.3.0-git/cmake/Modules/000077500000000000000000000000001421473465500163275ustar00rootroot00000000000000kim-api-2.3.0-git/cmake/Modules/CMakeLists.txt000066400000000000000000000021041421473465500210640ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # nothing to be done here... kim-api-2.3.0-git/cmake/Modules/CompletionConfig.cmake000066400000000000000000000056251421473465500226000ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Jim Madge # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # - CompletionConfig # # Sets the install paths for completions. # # If the user defines a location use it. If installing to "standard" loc, use # system bash-completion settings if available Otherwise, install into # sysconfdir (but do not cache). # bash completions if((NOT BASH_COMPLETION_COMPLETIONSDIR) AND ("${CMAKE_INSTALL_PREFIX}" IN_LIST KIM_API_STANDARD_INSTALL_PREFIXES)) find_package(bash-completion QUIET) # sets BASH_COMPLETION_COMPLETIONSDIR if(bash-completion_FOUND) include(FindPackageMessage) find_package_message(bash-completion "Found bash-completion: (${BASH_COMPLETION_COMPLETIONSDIR})" "found") endif() endif() set_cache_with_fallback(BASH_COMPLETION_COMPLETIONSDIR "${CMAKE_INSTALL_RELOC_SYSCONFDIR}/bash_completion.d" PATH "Directory where bash completions are installed") if(${CMAKE_VERSION} VERSION_LESS 3.20) set(dir SYSCONFDIR) GNUInstallDirs_get_absolute_install_dir(BASH_COMPLETION_FULL_COMPLETIONSDIR BASH_COMPLETION_COMPLETIONSDIR) unset(dir) else() GNUInstallDirs_get_absolute_install_dir(BASH_COMPLETION_FULL_COMPLETIONSDIR BASH_COMPLETION_COMPLETIONSDIR SYSCONFDIR) endif() RelocatableGNUInstallDirs_get_relocatable_dir(BASH_COMPLETION_RELOC_COMPLETIONSDIR BASH_COMPLETION_FULL_COMPLETIONSDIR BASH_COMPLETION_COMPLETIONSDIR) # zsh completions set_cache_with_fallback(ZSH_COMPLETION_COMPLETIONSDIR "${CMAKE_INSTALL_RELOC_SYSCONFDIR}/zsh_completion.d" PATH "Directory where zsh completions are installed") if(${CMAKE_VERSION} VERSION_LESS 3.20) set(dir SYSCONFDIR) GNUInstallDirs_get_absolute_install_dir(ZSH_COMPLETION_FULL_COMPLETIONSDIR ZSH_COMPLETION_COMPLETIONSDIR) unset(dir) else() GNUInstallDirs_get_absolute_install_dir(ZSH_COMPLETION_FULL_COMPLETIONSDIR ZSH_COMPLETION_COMPLETIONSDIR SYSCONFDIR) endif() RelocatableGNUInstallDirs_get_relocatable_dir(ZSH_COMPLETION_RELOC_COMPLETIONSDIR ZSH_COMPLETION_FULL_COMPLETIONSDIR ZSH_COMPLETION_COMPLETIONSDIR) kim-api-2.3.0-git/cmake/Modules/DefaultCompilerFlags.cmake000066400000000000000000000110531421473465500233650ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # Set global compiler options # include(EnableCXXCompilerFlagIfSupported) enable_cxx_compiler_flag_if_supported("-Wall") enable_cxx_compiler_flag_if_supported("-Wextra") enable_cxx_compiler_flag_if_supported("-pedantic") if(KIM_API_ENABLE_COVERAGE) set(KIM_API_CXX_FLAGS "${KIM_API_CXX_FLAGS} --coverage") endif() if(KIM_API_ENABLE_SANITIZE) enable_cxx_compiler_flag_if_supported("-fsanitize=address") endif() string(STRIP "${KIM_API_CXX_FLAGS}" _s) set(KIM_API_CXX_FLAGS "${_s}" CACHE STRING "KIM API C++ compiler flags") unset(_s) # include(EnableCCompilerFlagIfSupported) enable_c_compiler_flag_if_supported("-Wall") enable_c_compiler_flag_if_supported("-Wextra") enable_c_compiler_flag_if_supported("-pedantic") if(KIM_API_ENABLE_COVERAGE) set(KIM_API_C_FLAGS "${KIM_API_C_FLAGS} --coverage") endif() if(KIM_API_ENABLE_SANITIZE) enable_c_compiler_flag_if_supported("-fsanitize=address") endif() string(STRIP "${KIM_API_C_FLAGS}" _s) set(KIM_API_C_FLAGS "${_s}" CACHE STRING "KIM API C compiler flags") unset(_s) # include(EnableFortranCompilerFlagIfSupported) if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL Intel) enable_fortran_compiler_flag_if_supported("-std=f2003") enable_fortran_compiler_flag_if_supported("-Wall") enable_fortran_compiler_flag_if_supported("-Wextra") enable_fortran_compiler_flag_if_supported("-Wimplicit-interface") enable_fortran_compiler_flag_if_supported("-pedantic") else() enable_fortran_compiler_flag_if_supported("-stand f03") enable_fortran_compiler_flag_if_supported("-warn all") enable_fortran_compiler_flag_if_supported("-e03") enable_fortran_compiler_flag_if_supported("-warn interfaces") enable_fortran_compiler_flag_if_supported("-diag-disable 5462") # disable "Global name too long" warning endif() if(KIM_API_ENABLE_COVERAGE) set(KIM_API_Fortran_FLAGS "${KIM_API_Fortran_FLAGS} --coverage") endif() if(KIM_API_ENABLE_SANITIZE) enable_fortran_compiler_flag_if_supported("-fsanitize=address") endif() string(STRIP "${KIM_API_Fortran_FLAGS}" _s) set(KIM_API_Fortran_FLAGS "${_s}" CACHE STRING "KIM API Fortran compiler flags") unset(_s) # # Set global linker flags # if(NOT KIM_API_EXE_LINKER_FLAGS) set(KIM_API_EXE_LINKER_FLAGS "") endif() if(KIM_API_ENABLE_SANITIZE) set(KIM_API_EXE_LINKER_FLAGS "${KIM_API_EXE_LINKER_FLAGS} -fsanitize=address") endif() if(KIM_API_ENABLE_COVERAGE) set(KIM_API_EXE_LINKER_FLAGS "${KIM_API_EXE_LINKER_FLAGS} --coverage") endif() string(STRIP "${KIM_API_EXE_LINKER_FLAGS}" _s) set(KIM_API_EXE_LINKER_FLAGS "${_s}") unset(_s) # # Update CMAKE variables # string(STRIP "${KIM_API_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" _s) set(CMAKE_CXX_FLAGS_CACHED_VALUE "${CMAKE_CXX_FLAGS}") # for cmake's (< 3.13) that don't have $CACHE{} ;; remove once min cmake is > 3.12 set(CMAKE_CXX_FLAGS "${_s}") unset(_s) string(STRIP "${KIM_API_C_FLAGS} ${CMAKE_C_FLAGS}" _s) set(CMAKE_C_FLAGS_CACHED_VALUE "${CMAKE_C_FLAGS}") # for cmake's (< 3.13) that don't have $CACHE{} ;; remove once min cmake is > 3.12 set(CMAKE_C_FLAGS "${_s}") unset(_s) string(STRIP "${KIM_API_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}" _s) set(CMAKE_Fortran_FLAGS_CACHED_VALUE "${CMAKE_Fortran_FLAGS}") # for cmake's (< 3.13) that don't have $CACHE{} ;; remove once min cmake is > 3.12 set(CMAKE_Fortran_FLAGS "${_s}") unset(_s) # string(STRIP "${KIM_API_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" _s) set(CMAKE_EXE_LINKER_FLAGS_CACHED_VALUE "${CMAKE_EXE_LINKER_FLAGS}") # for cmake's (< 3.13) that don't have $CACHE{} ;; remove once min cmake is > 3.12 set(CMAKE_EXE_LINKER_FLAGS "${_s}") unset(_s) # kim-api-2.3.0-git/cmake/Modules/DefaultCompilerStandards.cmake000066400000000000000000000037621421473465500242640ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # Language standards (also enforced with FLAGS below) # set(CMAKE_CXX_STANDARD 98 CACHE STRING "CXX language standard") # cache to allow command line override mark_as_advanced(CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "CXX language standard required") # cache to allow command line override mark_as_advanced(CMAKE_CXX_STANDARD_REQUIRED) set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "CXX extensions") # cache to allow command line override mark_as_advanced(CMAKE_CXX_EXTENSIONS) # set(CMAKE_C_STANDARD 90 CACHE STRING "C language standard") # cache to allow command line override mark_as_advanced(CMAKE_C_STANDARD) set(CMAKE_C_STANDARD_REQUIRED ON CACHE BOOL "C language standard required") # cache to allow command line override mark_as_advanced(CMAKE_C_STANDARD_REQUIRED) set(CMAKE_C_EXTENSIONS OFF "C extensions") # cache to allow command line override mark_as_advanced(CMAKE_C_EXTENSIONS) # # NO similar setting exist yet in CMake for Fortran kim-api-2.3.0-git/cmake/Modules/DefineInternalVariables.cmake000066400000000000000000000130521421473465500240520ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # Define other internal variables # set(KIM_API_UID "${PROJECT_VERSION_STRING}.${KIM_API_CONFIGURATION_TIMESTAMP}" CACHE INTERNAL "Unique ID value for kim-api installation") # if(WIN32 AND NOT CYGWIN) # Use ';' as path list separator on native Windows platform (including MinGW). set(KIM_API_PATH_SEPARATOR ";" CACHE INTERNAL "Canonical separator character used in path lists") set(KIM_API_STANDARD_INSTALL_PREFIXES "c:/Program Files/${PROJECT_NAME}" CACHE INTERNAL "Canonical list of standard install prefixes") else() # Use ':' as path list separator on Linux/Unix platforms (including Cygwin and Windows Subsystem for Linux). set(KIM_API_PATH_SEPARATOR ":" CACHE INTERNAL "Canonical separator character used in path lists") set(KIM_API_STANDARD_INSTALL_PREFIXES "/" "/usr" "/usr/local" CACHE INTERNAL "Canonical list of standard install prefixes") endif() # set(KIM_API_BUILD_TREE_CONFIG_DIR_IDENTIFIER "build-tree-package-config-files" CACHE INTERNAL "Cononical id for build tree config dir") # set(KIM_API_PKG_CONFIG_DIR_IDENTIFIER "pkgconfig" CACHE INTERNAL "Canonical id for pkg-config dir") # set(KIM_API_Fortran_MODULE_DIR_IDENTIFIER "mod" CACHE INTERNAL "Canonical id for the Fortran module dir") # set(KIM_API_MODEL_DRIVER_IDENTIFIER "model-driver" CACHE INTERNAL "Canonical id for a model driver") set(KIM_API_MODEL_DRIVER_PLURAL_IDENTIFIER "${KIM_API_MODEL_DRIVER_IDENTIFIER}s" CACHE INTERNAL "plural") # set(KIM_API_PORTABLE_MODEL_IDENTIFIER "portable-model" CACHE INTERNAL "Canonical id for a portable model") set(KIM_API_PORTABLE_MODEL_PLURAL_IDENTIFIER "${KIM_API_PORTABLE_MODEL_IDENTIFIER}s" CACHE INTERNAL "plural") # set(KIM_API_SIMULATOR_MODEL_IDENTIFIER "simulator-model" CACHE INTERNAL "Canonical id for a simulator model") set(KIM_API_SIMULATOR_MODEL_PLURAL_IDENTIFIER "${KIM_API_SIMULATOR_MODEL_IDENTIFIER}s" CACHE INTERNAL "plural") # string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_CONFIGURATION_FILE" _KIM_API_ENVIRONMENT_CONFIGURATION_FILE) string(TOUPPER ${_KIM_API_ENVIRONMENT_CONFIGURATION_FILE} _KIM_API_ENVIRONMENT_CONFIGURATION_FILE) set(KIM_API_ENVIRONMENT_CONFIGURATION_FILE "${_KIM_API_ENVIRONMENT_CONFIGURATION_FILE}" CACHE INTERNAL "Configuration file environment variable name") unset(_KIM_API_ENVIRONMENT_CONFIGURATION_FILE) # string(MAKE_C_IDENTIFIER "KIM_API_CMAKE_PREFIX_DIR" _KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR) # should _not_ use PROJECT_NAME here string(TOUPPER ${_KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR} _KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR) set(KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR "${_KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR}" CACHE INTERNAL "CMake prefix dir environment variable name") unset(_KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR) # set(KIM_API_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER "${KIM_API_MODEL_DRIVER_PLURAL_IDENTIFIER}-dir" CACHE INTERNAL "Model drivers directory identifier") # string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_${KIM_API_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER}" _KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR) string(TOUPPER ${_KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR} _KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR) set(KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR "${_KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR}" CACHE INTERNAL "Model drivers directory environment variable name") unset(_KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR) # set(KIM_API_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER "${KIM_API_PORTABLE_MODEL_PLURAL_IDENTIFIER}-dir" CACHE INTERNAL "Portable models directory identifier") # string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_${KIM_API_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER}" _KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR) string(TOUPPER ${_KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR} _KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR) set(KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR "${_KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR}" CACHE INTERNAL "Portable Models directory environment variable name") unset(_KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR) # set(KIM_API_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER "${KIM_API_SIMULATOR_MODEL_PLURAL_IDENTIFIER}-dir" CACHE INTERNAL "Simulator Models directory identifier") # string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_${KIM_API_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER}" _KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR) string(TOUPPER ${_KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR} _KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR) set(KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR "${_KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR}" CACHE INTERNAL "Simulator Models directory environment variable name") unset(_KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR) kim-api-2.3.0-git/cmake/Modules/DefineVersionVariables.cmake000066400000000000000000000114631421473465500237270ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # set(PROJECT_VERSION_PRERELEASE "git" CACHE STRING "Project SemVer prerelease string") # cache to allow change from command line set(_build_metadata "") # avoid uninitialized variable warning find_package(Git QUIET) if(${GIT_FOUND}) include(FindPackageMessage) find_package_message(Git "Found Git: (${GIT_EXECUTABLE})" "found") execute_process(COMMAND ${GIT_EXECUTABLE} -C "${PROJECT_SOURCE_DIR}" rev-parse --show-toplevel OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _toplevel RESULT_VARIABLE _isGitRepo ERROR_QUIET ) if((_isGitRepo EQUAL 0) AND ("${_toplevel}" STREQUAL "${PROJECT_SOURCE_DIR}")) # set configuration to depend on _depend_file # # For details and discussion on the below approach, see: # https://discourse.cmake.org/t/support-for-git-describe-output-in-a-semver-prerelease-string/1714?u=relliott # https://github.com/ellio167/cmake-and-git-describe # # Overall this is a use case only of concern to active developers of the # kim-api project. So, a better solution is not really necessary. # set(_git_describe_sentinel "git-describe-sentinel") set(_depend_file "${CMAKE_CURRENT_BINARY_DIR}/.${_git_describe_sentinel}-file") find_program(_touch touch) if(${CMAKE_MINOR_VERSION} GREATER 11) # use file(GLOB CONFIGURE_DEPENDS ...) mechanism if(EXISTS "${_depend_file}") file(REMOVE "${_depend_file}") endif() file(GLOB _t CONFIGURE_DEPENDS "${_depend_file}") unset(_t) file(TOUCH "${_depend_file}") elseif(_touch) # use system 'touch' with future timestamp and CMAKE_CONFIGURE_DEPENDS mechanism string(TIMESTAMP _time "1%m%d%H%M") math(EXPR _time "${_time} + 1") string(REGEX REPLACE "^.(.*)$" "\\1" _time "${_time}") execute_process(COMMAND ${_touch} -t "${_time}" "${_depend_file}") # set modification/access time 1min in the future unset(_time) set_property(DIRECTORY "${CURRENT_SOURCE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_depend_file}") else() # use CMAKE_CONFIGURE_DEPENDS property mechanism [has a number of corner cases] execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${_depend_file}") add_custom_target(${_git_describe_sentinel}-target ALL COMMAND ${CMAKE_COMMAND} -E touch "${_depend_file}") set_property(DIRECTORY "${CURRENT_SOURCE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_depend_file}") endif() unset(_git_describe_sentinel) unset(_depend_file) execute_process(COMMAND ${GIT_EXECUTABLE} -C "${PROJECT_SOURCE_DIR}" update-index -q --refresh TIMEOUT 5 OUTPUT_QUIET ERROR_QUIET ) if(READTHEDOCS) set(_DIRTY "") else() set(_DIRTY ".dirty") endif() execute_process( COMMAND ${GIT_EXECUTABLE} -C "${PROJECT_SOURCE_DIR}" describe --dirty=${_DIRTY} --broken=.broken --always OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _git_describe ) unset(_DIRTY) set(_build_metadata "${_git_describe}") unset(_git_describe) endif() endif() if(NOT "${_build_metadata}" STREQUAL "") string(APPEND _build_metadata ".") endif() string(APPEND _build_metadata "${CMAKE_CXX_COMPILER_ID}.${CMAKE_C_COMPILER_ID}.${CMAKE_Fortran_COMPILER_ID}") set(PROJECT_VERSION_BUILD_METADATA "${_build_metadata}") # do not cache unset(_build_metadata) set(_version_string "${PROJECT_VERSION}") if(PROJECT_VERSION_PRERELEASE) set(_version_string "${_version_string}-${PROJECT_VERSION_PRERELEASE}") endif() set(PROJECT_VERSION_STRING_WITHOUT_BUILD_METADATA "${_version_string}") # used by pkg-config; do not cache if(PROJECT_VERSION_BUILD_METADATA) set(_version_string "${_version_string}+${PROJECT_VERSION_BUILD_METADATA}") endif() set(PROJECT_VERSION_STRING "${_version_string}") # do not cache unset(_version_string) kim-api-2.3.0-git/cmake/Modules/EnableCCompilerFlagIfSupported.cmake000066400000000000000000000031501421473465500252730ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # include(CheckCCompilerFlag) function(enable_c_compiler_flag_if_supported _flag) if(NOT KIM_API_C_FLAGS) set(KIM_API_C_FLAGS "") endif() string(MAKE_C_IDENTIFIER "${_flag}" _cid_flag) string(FIND "${KIM_API_C_FLAGS}" "${_flag}" _flag_already_set) if(_flag_already_set EQUAL -1) check_c_compiler_flag("${_flag}" c_support_for_${_cid_flag}) if(c_support_for_${_cid_flag}) set(KIM_API_C_FLAGS "${KIM_API_C_FLAGS} ${_flag}" PARENT_SCOPE) endif() unset(c_support_for_${_cid_flag} CACHE) endif() endfunction(enable_c_compiler_flag_if_supported) kim-api-2.3.0-git/cmake/Modules/EnableCXXCompilerFlagIfSupported.cmake000066400000000000000000000032001421473465500255470ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # include(CheckCXXCompilerFlag) function(enable_cxx_compiler_flag_if_supported _flag) if(NOT KIM_API_CXX_FLAGS) set(KIM_API_CXX_FLAGS "") endif() string(MAKE_C_IDENTIFIER "${_flag}" _cid_flag) string(FIND "${KIM_API_CXX_FLAGS}" "${_flag}" _flag_already_set) if(_flag_already_set EQUAL -1) check_cxx_compiler_flag("${_flag}" cxx_support_for_${_cid_flag}) if(cxx_support_for_${_cid_flag}) set(KIM_API_CXX_FLAGS "${KIM_API_CXX_FLAGS} ${_flag}" PARENT_SCOPE) endif() unset(cxx_support_for_${_cid_flag} CACHE) endif() endfunction(enable_cxx_compiler_flag_if_supported) kim-api-2.3.0-git/cmake/Modules/EnableFortranCompilerFlagIfSupported.cmake000066400000000000000000000032601421473465500265260ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # include(CheckFortranCompilerFlag) function(enable_fortran_compiler_flag_if_supported _flag) if(NOT KIM_API_Fortran_FLAGS) set(KIM_API_Fortran_FLAGS "") endif() string(MAKE_C_IDENTIFIER "${_flag}" _cid_flag) string(FIND "${KIM_API_Fortran_FLAGS}" "${_flag}" _flag_already_set) if(_flag_already_set EQUAL -1) check_fortran_compiler_flag("${_flag}" fortran_support_for_${_cid_flag}) if(fortran_support_for_${_cid_flag}) set(KIM_API_Fortran_FLAGS "${KIM_API_Fortran_FLAGS} ${_flag}" PARENT_SCOPE) endif() unset(fortran_support_for_${_cid_flag} CACHE) endif() endfunction(enable_fortran_compiler_flag_if_supported) kim-api-2.3.0-git/cmake/Modules/RelocatableGNUInstallDirs.cmake000066400000000000000000000032521421473465500242730ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # macro(RelocatableGNUInstallDirs_get_relocatable_dir relocvar absvar var) if("${${absvar}}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${${var}}") set(${relocvar} "${${var}}") else() set(${relocvar} "${${absvar}}") endif() endmacro(RelocatableGNUInstallDirs_get_relocatable_dir) # Result directories # foreach(dir BINDIR SBINDIR LIBEXECDIR SYSCONFDIR SHAREDSTATEDIR LOCALSTATEDIR RUNSTATEDIR LIBDIR INCLUDEDIR OLDINCLUDEDIR DATAROOTDIR DATADIR INFODIR LOCALEDIR MANDIR DOCDIR ) RelocatableGNUInstallDirs_get_relocatable_dir(CMAKE_INSTALL_RELOC_${dir} CMAKE_INSTALL_FULL_${dir} CMAKE_INSTALL_${dir}) endforeach() kim-api-2.3.0-git/cmake/Modules/RelocatablePath.cmake000066400000000000000000000047421421473465500223720ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # relocatable_path() -- Construct a path "TO" one absolute filepath "FROM" # another absolute path if their respective "TO_REL" and "FROM_REL" paths are # both relative. Supports an optional RPATH_PREFIX to add any necessary # leading rpath variable name. If either of "TO_REL" or "FROM_REL" are # absolute, just return the absolute "FROM" filepath. function(relocatable_path) set(_options "") set(_oneValueArgs RESULT_VARIABLE FROM FROM_REL TO TO_REL PREFIX) set(_multiValueArgs "") cmake_parse_arguments(_rel "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_rel_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'relocatable_path()'") endif() if(NOT IS_ABSOLUTE "${_rel_FROM}") message(FATAL_ERROR "FROM must be an absolute path in 'relocatable_path()'") endif() if(NOT IS_ABSOLUTE "${_rel_TO}") message(FATAL_ERROR "TO must be an absolute filepath in 'relocatable_path()'") endif() if(NOT _rel_RESULT_VARIABLE) message(FATAL_ERROR "RESULT_VARIABLE not provided in 'relocatable_path()'") endif() if(NOT _rel_PREFIX) set(_rel_PREFIX "") else() set(_rel_PREFIX "${_rel_PREFIX}/") endif() if((NOT IS_ABSOLUTE "${_rel_FROM_REL}") AND (NOT IS_ABSOLUTE "${_rel_TO_REL}")) file(RELATIVE_PATH _rel_rel "${_rel_FROM}" "${_rel_TO}") set(${_rel_RESULT_VARIABLE} "${_rel_PREFIX}${_rel_rel}" PARENT_SCOPE) else() set(${_rel_RESULT_VARIABLE} "${_rel_TO}" PARENT_SCOPE) endif() endfunction(relocatable_path) kim-api-2.3.0-git/cmake/Modules/SetCacheWithFallback.cmake000066400000000000000000000024061421473465500232660ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # inspired by GNUInstallDirs '_GNUInstallDirs_cache_path_fallback' macro(set_cache_with_fallback var default type description) if(NOT ${var}) set(${var} "" CACHE ${type} "${description}") set(${var} "${default}") endif() endmacro(set_cache_with_fallback) kim-api-2.3.0-git/cmake/Modules/WriteKIMConfigSummary.cmake000066400000000000000000000051771421473465500235020ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # function(_write_kim_config_summary) set(_log_detailed_in "${CMAKE_CURRENT_LIST_DIR}/kim-api-configuration-detailed.log.in") set(_log_detailed "${PROJECT_BINARY_DIR}/kim-api-configuration-detailed.log") set(_log_summary_in "${CMAKE_CURRENT_LIST_DIR}/kim-api-configuration-summary.log.in") set(_log_summary "${PROJECT_BINARY_DIR}/kim-api-configuration-summary.log") if(EXISTS "${_log_summary}") file(SHA1 "${_log_summary}" _log_summary_sha1_before) else() set(_log_summary_sha1_before "") endif() set(UPDATE_WHEN_CMAKE_GREATER_THAN_3.12 "") # avoid uninitialized variable warning # _log_detailed contains "CMAKE_*_CACHED_VALUE" references for cmake's (< 3.13) that don't have $CACHE{} ;; remove/change once min cmake is > 3.12 configure_file("${_log_detailed_in}" "${_log_detailed}") # _log_summary contains "CMAKE_*_CACHED_VALUE" references for cmake's (< 3.13) that don't have $CACHE{} ;; remove/change once min cmake is > 3.12 string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE_UPPER) # used by _log_summary_in configure_file("${_log_summary_in}" "${_log_summary}") file(SHA1 "${_log_summary}" _log_summary_sha1_after) if(NOT "${_log_summary_sha1_after}" STREQUAL "${_log_summary_sha1_before}") file(READ "${_log_summary}" _log_content) message(STATUS "\n\n${_log_content}") message(STATUS "The above configuration information can also be found in:") message(STATUS " ${_log_summary}") message(STATUS "A more detailed configuration listing can be found in:") message(STATUS " ${_log_detailed}") message(STATUS "") endif() endfunction(_write_kim_config_summary) _write_kim_config_summary() kim-api-2.3.0-git/cmake/Modules/kim-api-configuration-detailed.log.in000066400000000000000000000135551421473465500254150ustar00rootroot00000000000000### # # kim-api configuration: # # === System values ====================== # CMAKE_SYSEM_NAME: ${CMAKE_SYSTEM_NAME} # CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR} # # === C++ compile values ================= # CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID} # CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION} # CMAKE_CXX_COMPILER: # ${CMAKE_CXX_COMPILER} # KIM_API_CMAKE_CXX_COMPILER: # ${KIM_API_CMAKE_CXX_COMPILER} # # CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD} # CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED} # CMAKE_CXX_EXTENSIONS: ${CMAKE_CXX_EXTENSIONS} # CMAKE_CXX_FLAGS: ${UPDATE_WHEN_CMAKE_GREATER_THAN_3.12}${CMAKE_CXX_FLAGS_CACHED_VALUE} # CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG} # CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE} # CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} # CMAKE_CXX_FLAGS_MINSIZEREL: ${CMAKE_CXX_FLAGS_MINSIZEREL} # # KIM_API_CXX_FLAGS: ${KIM_API_CXX_FLAGS} # # === C compile values =================== # CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID} # CMAKE_C_COMPILER_VERSION: ${CMAKE_C_COMPILER_VERSION} # CMAKE_C_COMPILER: # ${CMAKE_C_COMPILER} # KIM_API_CMAKE_C_COMPILER: # ${KIM_API_CMAKE_C_COMPILER} # # CMAKE_C_STANDARD: ${CMAKE_C_STANDARD} # CMAKE_C_STANDARD_REQUIRED: ${CMAKE_C_STANDARD_REQUIRED} # CMAKE_C_EXTENSIONS: ${CMAKE_C_EXTENSIONS} # CMAKE_C_FLAGS: ${UPDATE_WHEN_CMAKE_GREATER_THAN_3.12}${CMAKE_C_FLAGS_CACHED_VALUE} # CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG} # CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE} # CMAKE_C_FLAGS_RELWITHDEBINFO: ${CMAKE_C_FLAGS_RELWITHDEBINFO} # CMAKE_C_FLAGS_MINSIZEREL: ${CMAKE_C_FLAGS_MINSIZEREL} # # KIM_API_C_FLAGS: ${KIM_API_C_FLAGS} # # === Fortran compile values ============= # CMAKE_Fortran_COMPILER_ID: ${CMAKE_Fortran_COMPILER_ID} # CMAKE_Fortran_COMPILER_VERSION: ${CMAKE_Fortran_COMPILER_VERSION} # CMAKE_Fortran_COMPILER: # ${CMAKE_Fortran_COMPILER} # KIM_API_CMAKE_Fortran_COMPILER: # ${KIM_API_CMAKE_Fortran_COMPILER} # # CMAKE_Fortran_FLAGS: ${UPDATE_WHEN_CMAKE_GREATER_THAN_3.12}${CMAKE_Fortran_FLAGS_CACHED_VALUE} # CMAKE_Fortran_FLAGS_DEBUG: ${CMAKE_Fortran_FLAGS_DEBUG} # CMAKE_Fortran_FLAGS_RELEASE: ${CMAKE_Fortran_FLAGS_RELEASE} # CMAKE_Fortran_FLAGS_RELWITHDEBINFO: ${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} # CMAKE_Fortran_FLAGS_MINSIZEREL: ${CMAKE_Fortran_FLAGS_MINSIZEREL} # # KIM_API_Fortran_FLAGS: ${KIM_API_Fortran_FLAGS} # # === Linker values ====================== # CMAKE_EXE_LINKER_FLAGS: ${UPDATE_WHEN_CMAKE_GREATER_THAN_3.12}${CMAKE_EXE_LINKER_FLAGS_CACHED_VALUE} # CMAKE_EXE_LINKER_FLAGS_DEBUG: ${CMAKE_EXE_LINKER_FLAGS_DEBUG} # CMAKE_EXE_LINKER_FLAGS_RELEASE: ${CMAKE_EXE_LINKER_FLAGS_RELEASE} # CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO: ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} # CMAKE_EXE_LINKER_FLAGS_MINSIZEREL: ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} # # KIM_API_EXE_LINKER_FLAGS: ${KIM_API_EXE_LINKER_FLAGS} # # === Build type value =================== # CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} # # === Directory values =================== # PROJECT_SOURCE_DIR: # ${PROJECT_SOURCE_DIR} # PROJECT_BINARY_DIR: # ${PROJECT_BINARY_DIR} # # === Install directory values =========== # CMAKE_INSTALL_PREFIX: # ${CMAKE_INSTALL_PREFIX} # # CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR} # CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR} # CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR} # CMAKE_INSTALL_LIBEXECDIR: ${CMAKE_INSTALL_LIBEXECDIR} # CMAKE_INSTALL_SYSCONFDIR: ${CMAKE_INSTALL_SYSCONFDIR} # CMAKE_INSTALL_DATADIR: ${CMAKE_INSTALL_DATADIR} # CMAKE_INSTALL_DOCDIR: ${CMAKE_INSTALL_DOCDIR} # # BASH_COMPLETION_COMPLETIONSDIR: ${BASH_COMPLETION_COMPLETIONSDIR} # ZSH_COMPLETION_COMPLETIONSDIR: ${ZSH_COMPLETION_COMPLETIONSDIR} # # === kim-api option values ============== # KIM_API_PROJECT_NAME: ${KIM_API_PROJECT_NAME} # KIM_API_CONFIGURATION_TIMESTAMP: ${KIM_API_CONFIGURATION_TIMESTAMP} # # PROJECT_VERSION: ${PROJECT_VERSION} # PROJECT_VERSION_STRING: ${PROJECT_VERSION_STRING} # KIM_API_UID: ${KIM_API_UID} # # KIM_API_LOG_MAXIMUM_LEVEL: ${KIM_API_LOG_MAXIMUM_LEVEL} # # KIM_API_BUILD_EXAMPLES: ${KIM_API_BUILD_EXAMPLES} # KIM_API_ENABLE_SANITIZE: ${KIM_API_ENABLE_SANITIZE} # KIM_API_ENABLE_COVERAGE: ${KIM_API_ENABLE_COVERAGE} # # KIM_API_USER_CONFIGURATION_FILE: # ${KIM_API_USER_CONFIGURATION_FILE} # # KIM_API_SYSTEM_MODEL_DRIVERS_DIR: # ${KIM_API_SYSTEM_MODEL_DRIVERS_DIR} # KIM_API_SYSTEM_PORTABLE_MODELS_DIR: # ${KIM_API_SYSTEM_PORTABLE_MODELS_DIR} # KIM_API_SYSTEM_SIMULATOR_MODELS_DIR: # ${KIM_API_SYSTEM_SIMULATOR_MODELS_DIR} # # KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT: # ${KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT} # KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT: # ${KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT} # KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT: # ${KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT} # ### kim-api-2.3.0-git/cmake/Modules/kim-api-configuration-summary.log.in000066400000000000000000000035011421473465500253250ustar00rootroot00000000000000### # # kim-api configuration: # # === C++ compile values ================= # CMAKE_CXX_COMPILER: (${CMAKE_CXX_COMPILER_ID}, ${CMAKE_CXX_COMPILER_VERSION}, std=${CMAKE_CXX_STANDARD}) # ${CMAKE_CXX_COMPILER} # # === C compile values =================== # CMAKE_C_COMPILER: (${CMAKE_C_COMPILER_ID}, ${CMAKE_C_COMPILER_VERSION}, std=${CMAKE_C_STANDARD}) # ${CMAKE_C_COMPILER} # # === Fortran compile values ============= # CMAKE_Fortran_COMPILER: (${CMAKE_Fortran_COMPILER_ID}, ${CMAKE_Fortran_COMPILER_VERSION}) # ${CMAKE_Fortran_COMPILER} # # === Build type value =================== # CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} # # === Install directory values =========== # CMAKE_INSTALL_PREFIX: # ${CMAKE_INSTALL_PREFIX} # # CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR} # CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR} # CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR} # CMAKE_INSTALL_LIBEXECDIR: ${CMAKE_INSTALL_LIBEXECDIR} # # === kim-api option values ============== # KIM_API_PROJECT_NAME: ${KIM_API_PROJECT_NAME} # KIM_API_CONFIGURATION_TIMESTAMP: ${KIM_API_CONFIGURATION_TIMESTAMP} # # PROJECT_VERSION: ${PROJECT_VERSION} # PROJECT_VERSION_STRING: ${PROJECT_VERSION_STRING} # KIM_API_UID: ${KIM_API_UID} # # KIM_API_LOG_MAXIMUM_LEVEL: ${KIM_API_LOG_MAXIMUM_LEVEL} # # KIM_API_BUILD_EXAMPLES: ${KIM_API_BUILD_EXAMPLES} # KIM_API_ENABLE_SANITIZE: ${KIM_API_ENABLE_SANITIZE} # KIM_API_ENABLE_COVERAGE: ${KIM_API_ENABLE_COVERAGE} # # KIM_API_USER_CONFIGURATION_FILE: # ${KIM_API_USER_CONFIGURATION_FILE} # ### kim-api-2.3.0-git/cmake/build-tree-config.cmake.in000066400000000000000000000034311421473465500216260ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # - KIM-API package for *build tree* # # # REMOVE THIS IF AND KEEP BODY FOR 3.0.0 RELEASE!!! if("${KIM-API_FIND_VERSION}" VERSION_GREATER "2.1.99") add_library(KIM-API::kim-api ALIAS kim-api) add_executable(KIM-API::portable-model-info ALIAS portable-model-info) add_executable(KIM-API::simulator-model ALIAS simulator-model) add_executable(KIM-API::collections-info ALIAS collections-info) add_executable(KIM-API::shared-library-test ALIAS shared-library-test) endif() # REMOVE THE BELOW FOR 3.0.0 RELEASE!!! if("${KIM-API_FIND_VERSION}" VERSION_LESS "2.2.0") set(_KIM_API_BUILD_TREE_ACTIVE TRUE CACHE INTERNAL "build tree temp") include("${CMAKE_CURRENT_LIST_DIR}/kim-api-pre-2.2-compatibility.cmake") endif() kim-api-2.3.0-git/cmake/build-tree-items-config.cmake.in000066400000000000000000000103431421473465500227450ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # - KIM-API-ITEMS package for *build tree* # # kim_api_items_setup_before_project() - standard item configure, part 1 # kim_api_items_setup_after_project() - standard item configure, part 2 # set(KIM_API_INSTALL_COLLECTION "SYSTEM" CACHE STRING "KIM API Collection in which to install items") set_property(CACHE KIM_API_INSTALL_COLLECTION PROPERTY STRINGS SYSTEM) mark_as_advanced(KIM_API_INSTALL_COLLECTION) # # Macro to perform any necessary standard configuration that must be completed # BEFORE the user calls the 'project()' command # macro(kim_api_items_setup_before_project) set(_options "") set(_oneValueArgs ITEM_TYPE) set(_multiValueArgs "") cmake_parse_arguments(_before_setup "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_before_setup_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'kim_api_items_setup_before_project'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) set(_known_item_types portableModel modelDriver simulatorModel) if(NOT ${_before_setup_ITEM_TYPE} IN_LIST _known_item_types) message(FATAL_ERROR "Unknown KIM API Item type") endif() unset(_known_item_types) # nothing else to do from the build tree... endmacro(kim_api_items_setup_before_project) # # Macro to perform any necessary standard configuration that must be completed # AFTER the user calls the 'project()' command # macro(kim_api_items_setup_after_project) set(_options "") set(_oneValueArgs ITEM_TYPE) set(_multiValueArgs "") cmake_parse_arguments(_after_setup "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_after_setup_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'kim_api_items_setup_after_project'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) set(_known_item_types portableModel modelDriver simulatorModel) if(NOT ${_after_setup_ITEM_TYPE} IN_LIST _known_item_types) message(FATAL_ERROR "Unknown KIM API Item type") endif() unset(_known_item_types) # nothing else to do from the build tree... find_package(KIM-API 2.2 REQUIRED CONFIG) endmacro(kim_api_items_setup_after_project) include("${CMAKE_CURRENT_LIST_DIR}/kim-api-items-macros.cmake") function(_determine_default_system_collection_install_prefix _item_type) if("${_item_type}" STREQUAL "") message(FATAL_ERROR "Empty item type provided.") endif() if("${_item_type}" STREQUAL "modelDriver") set(_dir_list "${KIM_API_SYSTEM_MODEL_DRIVERS_DIR}") elseif("${_item_type}" STREQUAL "portableModel") set(_dir_list "${KIM_API_SYSTEM_PORTABLE_MODELS_DIR}") elseif("${_item_type}" STREQUAL "simulatorModel") set(_dir_list "${KIM_API_SYSTEM_SIMULATOR_MODELS_DIR}") else() message(FATAL_ERROR "Unknown item type.") endif() string(REGEX REPLACE "^([^${KIM_API_PATH_SEPARATOR}]+).*" "\\1" _dir "${_dir_list}") string(REGEX REPLACE "^(\\$ORIGIN|\\\${ORIGIN})" "${CMAKE_INSTALL_FULL_LIBDIR}" _dir "${_dir}") if("${_dir}" STREQUAL "") message(FATAL_ERROR "Unable to determine KIM API item install prefix.") endif() set(_ITEM_INSTALL_PREFIX "${_dir}" PARENT_SCOPE) endfunction(_determine_default_system_collection_install_prefix) kim-api-2.3.0-git/cmake/config.cmake.in000066400000000000000000000036441421473465500176020ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # # - KIM-API package # set(KIM-API_VERSION_STRING "@PROJECT_VERSION_STRING@") set(KIM-API_UID "@KIM_API_UID@") # REMOVE THIS IF AND KEEP BODY FOR 3.0.0 RELEASE!!! if("${KIM-API_FIND_VERSION}" VERSION_GREATER "2.1.99") include("${CMAKE_CURRENT_LIST_DIR}/kim-api-macros.cmake") include("${CMAKE_CURRENT_LIST_DIR}/kim-api-targets.cmake") endif() # REMOVE THE BELOW FOR 3.0.0 RELEASE!!! if("${KIM-API_FIND_VERSION}" VERSION_LESS "2.2.0") include("${CMAKE_CURRENT_LIST_DIR}/kim-api-pre-2.2-compatibility.cmake") endif() if(NOT KIM-API_FIND_QUIETLY) include(FindPackageMessage) if(TARGET KIM-API::kim-api) get_target_property(_kim_loc KIM-API::kim-api IMPORT_LOCATION) else() set(_kim_loc "${KIM_API_PROJECT_NAME}-${KIM_API_VERSION_STRING}") endif() find_package_message(KIM-API "Found KIM-API: ${_kim_loc}" "KIM-API") unset(_kim_loc) endif() kim-api-2.3.0-git/cmake/item-compiled-with-version.txt.in000066400000000000000000000000311421473465500232430ustar00rootroot00000000000000@PROJECT_VERSION_STRING@ kim-api-2.3.0-git/cmake/item-info.txt.in000066400000000000000000000022041421473465500177520ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # item-type:@ITEM_TYPE@ item-name:@ITEM_NAME_QUOTED@ item-driver-name:@ITEM_DRIVER_NAME_QUOTED@ kim-api-2.3.0-git/cmake/item-wrapper.cpp.in000066400000000000000000000051461421473465500204520ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" #endif extern "C" { #ifndef KIM_FUNCTION_TYPES_H_ #include "KIM_FunctionTypes.h" // IWYU pragma: keep #endif } #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_SHARED_LIBRARY_SCHEMA_HPP_ #include "KIM_SharedLibrarySchema.hpp" #endif using namespace KIM::SHARED_LIBRARY_SCHEMA; extern "C" { // clang-format off int kim_shared_library_schema_version = 2; @ITEM_CREATE_ROUTINE_DECLARATION@ @ITEM_SM_SPEC_FILE_DECLARATIONS@ @ITEM_PARAMETER_FILE_DECLARATIONS@ @ITEM_METADATA_FILE_DECLARATIONS@ @ITEM_SM_SPEC_FILE_EMBEDDED_FILE_INITIALIZER_LIST@ @ITEM_PARAMETER_FILE_EMBEDDED_FILE_INITIALIZER_LIST@ @ITEM_METADATA_FILE_EMBEDDED_FILE_INITIALIZER_LIST@ SharedLibrarySchemaV2 kim_shared_library_schema = { KIM::COLLECTION_ITEM_TYPE::@ITEM_TYPE@, // Item Type @ITEM_NAME_QUOTED@, // Item Name KIM::LANGUAGE_NAME::@ITEM_CREATE_ROUTINE_LANGUAGE@, // Create Routine Language reinterpret_cast(@ITEM_CREATE_ROUTINE_NAME@), // Create Routine Name @ITEM_DRIVER_NAME_QUOTED@, // Item Driver Name @ITEM_SM_SPEC_FILE_EMBEDDED_FILE_IDENTIFIER@, // smspec File @ITEM_NUMBER_OF_PARAMETER_FILES@, // Number of Parameter Files @ITEM_PARAMETER_FILE_EMBEDDED_FILE_IDENTIFIER@, // Embedded Parameter Files @ITEM_NUMBER_OF_METADATA_FILES@, // Number of Metadata Files @ITEM_METADATA_FILE_EMBEDDED_FILE_IDENTIFIER@ // Embedded Metadata Files }; } // clang-format on kim-api-2.3.0-git/cmake/items-config.cmake.in000066400000000000000000000072271421473465500207220ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # # - KIM-API-ITEMS package # # kim_api_items_setup_before_project() - standard item configure, part 1 # kim_api_items_setup_after_project() - standard item configure, part 2 # if(NOT REMOVE_THIS_FOR_3_0_0_RELEASE) set(REMOVE_THIS_FOR_3_0_0_RELEASE "") endif() set(KIM-API-ITEMS_VERSION_STRING "@PROJECT_VERSION_STRING@") set(KIM-API-ITEMS_UID "@KIM_API_UID@") # # Macro to perform any necessary standard configuration that must be completed # BEFORE the user calls the 'project()' command # macro(kim_api_items_setup_before_project) set(_options "") set(_oneValueArgs ITEM_TYPE) set(_multiValueArgs "") cmake_parse_arguments(_before_setup "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_before_setup_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'kim_api_items_setup_before_project'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) set(_known_item_types portableModel modelDriver simulatorModel) if(NOT ${_before_setup_ITEM_TYPE} IN_LIST _known_item_types) message(FATAL_ERROR "Unknown KIM API Item type") endif() unset(_known_item_types) kim_api_items_set_cmake_compiler_variables() kim_api_items_set_cmake_build_type_variable_in_cache() endmacro(kim_api_items_setup_before_project) # # Macro to perform any necessary standard configuration that must be completed # AFTER the user calls the 'project()' command # macro(kim_api_items_setup_after_project) set(_options "") set(_oneValueArgs ITEM_TYPE) set(_multiValueArgs "") cmake_parse_arguments(_after_setup "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_after_setup_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'kim_api_items_setup_after_project'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) set(_known_item_types portableModel modelDriver simulatorModel) if(NOT ${_after_setup_ITEM_TYPE} IN_LIST _known_item_types) message(FATAL_ERROR "Unknown KIM API Item type") endif() unset(_known_item_types) # Enable CXX and C so that Items can list only the languages they actually use enable_language(CXX) enable_language(C) enable_testing() kim_api_items_set_cmake_compiler_standard_variables() kim_api_items_prepend_compiler_flags_to_cmake_variables() find_package(KIM-API 2.2 REQUIRED CONFIG) endmacro(kim_api_items_setup_after_project) include("${CMAKE_CURRENT_LIST_DIR}/kim-api-items-macros.cmake") if(NOT KIM-API-ITEMS_FIND_QUIETLY) include(FindPackageMessage) find_package_message(KIM-API-ITEMS "Found KIM-API-ITEMS pacakge." "KIM-API-ITEMS") endif() kim-api-2.3.0-git/cmake/items-macros.cmake.in000066400000000000000000001026341421473465500207370ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # - Macros and Functions that are part of the KIM-API-ITEMS package # # add_kim_api_model_library() - create kim-api model target # add_kim_api_model_driver_library() - creaet kim-api model driver target # # # kim_api_items_set_compiler_variables() # kim_api_items_set_cmake_compiler_variables() # # kim_api_items_set_compiler_standard_variables() # kim_api_items_set_cmake_compiler_standard_variables() # # kim_api_items_set_compiler_flag_variables() # kim_api_items_prepend_compiler_flags_to_cmake_variables() # # kim_api_items_set_build_type_variable() # kim_api_items_set_cmake_build_type_variable_in_cache() # set(KIM_API_INSTALL_COLLECTION "SYSTEM" CACHE STRING "KIM API Collection in which to install items") set_property(CACHE KIM_API_INSTALL_COLLECTION PROPERTY STRINGS SYSTEM USER ENVIRONMENT) # # Function to be used by KIM-API-ITEMS package users to add KIM-API items of type: # * Portable models # - Stand alone portable model # - Parameterized portable model # * Simulator model # function(add_kim_api_model_library${REMOVE_THIS_FOR_3_0_0_RELEASE}) set(_options "") set(_oneValueArgs NAME DRIVER_NAME CREATE_ROUTINE_NAME CREATE_ROUTINE_LANGUAGE SM_SPEC_FILE) set(_multiValueArgs PARAMETER_FILES METADATA_FILES) cmake_parse_arguments(_MODEL "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_MODEL_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'add_kim_api_model_library'") endif() # Determine item type if(NOT "${_MODEL_SM_SPEC_FILE}" STREQUAL "") set(_MODEL_TYPE "simulatorModel") if(NOT "${_MODEL_DRIVER_NAME}" STREQUAL "") message(FATAL_ERROR "Cannot specify SM_SPEC_FILE and DRIVER_NAME together") endif() if(NOT "${_MODEL_CREATE_ROUTINE_NAME}" STREQUAL "") message(FATAL_ERROR "Cannot specify SM_SPEC_FILE and CREATE_ROUTINE_NAME together") endif() if(NOT "${_MODEL_CREATE_ROUTINE_LANGUAGE}" STREQUAL "") message(FATAL_ERROR "Cannot specify SM_SPEC_FILE and CREATE_ROUTINE_LANGUAGE together") endif() else() set(_MODEL_TYPE "portableModel") if("${_MODEL_DRIVER_NAME}" STREQUAL "") # stand-alone if("${_MODEL_CREATE_ROUTINE_NAME}" STREQUAL "") message(FATAL_ERROR "Must specify CREATE_ROUTINE_NAME for stand-alone portable model") endif() if("${_MODEL_CREATE_ROUTINE_LANGUAGE}" STREQUAL "") message(FATAL_ERROR "Must specify CREATE_ROUTINE_LANGUAGE for stand-alone portable model") endif() if(NOT "${_MODEL_PARAMETER_FILES}" STREQUAL "") message(FATAL_ERROR "Cannot specify PARAMETER_FILES for stand-alone portable model") endif() else() # parameterized if(NOT "${_MODEL_CREATE_ROUTINE_NAME}" STREQUAL "") message(FATAL_ERROR "Cannot specify CREATE_ROUTINE_NAME for parameterized portable model") endif() if(NOT "${_MODEL_CREATE_ROUTINE_LANGUAGE}" STREQUAL "") message(FATAL_ERROR "Cannot specify CREATE_ROUTINE_LANGUAGE for parameterized portable model") endif() if("${_MODEL_PARAMETER_FILES}" STREQUAL "") message(FATAL_ERROR "Must specify PARAMETER_FILES for parameterized portable model") endif() endif() endif() _add_kim_api_library( TYPE "${_MODEL_TYPE}" NAME "${_MODEL_NAME}" DRIVER_NAME "${_MODEL_DRIVER_NAME}" CREATE_ROUTINE_LANGUAGE "${_MODEL_CREATE_ROUTINE_LANGUAGE}" CREATE_ROUTINE_NAME "${_MODEL_CREATE_ROUTINE_NAME}" SM_SPEC_FILE "${_MODEL_SM_SPEC_FILE}" PARAMETER_FILES "${_MODEL_PARAMETER_FILES}" METADATA_FILES "${_MODEL_METADATA_FILES}" ) endfunction(add_kim_api_model_library${REMOVE_THIS_FOR_3_0_0_RELEASE}) # # Function to be used by KIM-API-ITEMS package users to add KIM-API model driver items # function(add_kim_api_model_driver_library${REMOVE_THIS_FOR_3_0_0_RELEASE}) set(_options "") set(_oneValueArgs NAME CREATE_ROUTINE_NAME CREATE_ROUTINE_LANGUAGE) set(_multiValueArgs METADATA_FILES) cmake_parse_arguments(_MODEL_DRIVER "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_MODEL_DRIVER_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in 'add_kim_api_model_driver_library'") endif() if("${_MODEL_DRIVER_NAME}" STREQUAL "") message(FATAL_ERROR "No Model Driver name provided") endif() if("${_MODEL_DRIVER_CREATE_ROUTINE_NAME}" STREQUAL "") message(FATAL_ERROR "No Model Driver create routine name provided") endif() if("${_MODEL_DRIVER_CREATE_ROUTINE_LANGUAGE}" STREQUAL "") message(FATAL_ERROR "No Model Driver create routine language provided") endif() _add_kim_api_library( TYPE "modelDriver" NAME "${_MODEL_DRIVER_NAME}" DRIVER_NAME "" CREATE_ROUTINE_LANGUAGE "${_MODEL_DRIVER_CREATE_ROUTINE_LANGUAGE}" CREATE_ROUTINE_NAME "${_MODEL_DRIVER_CREATE_ROUTINE_NAME}" SM_SPEC_FILE "" PARAMETER_FILES "" METADATA_FILES "${_MODEL_DRIVER_METADATA_FILES}" ) endfunction(add_kim_api_model_driver_library${REMOVE_THIS_FOR_3_0_0_RELEASE}) macro(kim_api_items_set_compiler_variables) set(KIM_API_CMAKE_CXX_COMPILER "@KIM_API_CMAKE_CXX_COMPILER@" CACHE FILEPATH "CXX Compiler used to build kim-api package") set(KIM_API_CMAKE_C_COMPILER "@KIM_API_CMAKE_C_COMPILER@" CACHE FILEPATH "C Compiler used to build kim-api package") set(KIM_API_CMAKE_Fortran_COMPILER "@KIM_API_CMAKE_Fortran_COMPILER@" CACHE FILEPATH "Fortran Compiler used to build kim-api package") endmacro(kim_api_items_set_compiler_variables) macro(kim_api_items_set_cmake_compiler_variables) kim_api_items_set_compiler_variables() set(CMAKE_CXX_COMPILER "${KIM_API_CMAKE_CXX_COMPILER}") set(CMAKE_C_COMPILER "${KIM_API_CMAKE_C_COMPILER}") set(CMAKE_Fortran_COMPILER "${KIM_API_CMAKE_Fortran_COMPILER}") endmacro(kim_api_items_set_cmake_compiler_variables) macro(kim_api_items_set_compiler_standard_variables) # Language standards # set(KIM_API_CMAKE_CXX_STANDARD @CMAKE_CXX_STANDARD@ CACHE STRING "CXX_STANDARD used to build kim-api package") set(KIM_API_CMAKE_CXX_STANDARD_REQUIRED @CMAKE_CXX_STANDARD_REQUIRED@ CACHE STRING "CXX_STANDARD_REQUIRED used to build kim-api package") set(KIM_API_CMAKE_CXX_EXTENSIONS @CMAKE_CXX_EXTENSIONS@ CACHE STRING "CXX_EXTENSIONS used to build kim-api package") # set(KIM_API_CMAKE_C_STANDARD @CMAKE_C_STANDARD@ CACHE STRING "C_STANDARD used to build kim-api package") set(KIM_API_CMAKE_C_STANDARD_REQUIRED @CMAKE_C_STANDARD_REQUIRED@ CACHE STRING "C_STANDARD_REQUIRED used to build kim-api package") set(KIM_API_CMAKE_C_EXTENSIONS @CMAKE_C_EXTENSIONS@ CACHE STRING "C_EXTENSIONS used to build kim-api package") # # NO similar setting exist yet in CMake for Fortran endmacro(kim_api_items_set_compiler_standard_variables) macro(kim_api_items_set_cmake_compiler_standard_variables) kim_api_items_set_compiler_standard_variables() set(CMAKE_CXX_STANDARD ${KIM_API_CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD_REQUIRED ${KIM_API_CMAKE_CXX_STANDARD_REQUIRED}) set(CMAKE_CXX_EXTENSIONS ${KIM_API_CMAKE_CXX_EXTENSIONS}) # set(CMAKE_C_STANDARD ${KIM_API_CMAKE_C_STANDARD}) set(CMAKE_C_STANDARD_REQUIRED ${KIM_API_CMAKE_C_STANDARD_REQUIRED}) set(CMAKE_C_EXTENSIONS ${KIM_API_CMAKE_C_EXTENSIONS}) # # NO similar setting exist yet in CMake for Fortran endmacro(kim_api_items_set_cmake_compiler_standard_variables) macro(kim_api_items_set_compiler_flag_variables) set(KIM_API_EXE_LINKER_FLAGS "@KIM_API_EXE_LINKER_FLAGS@" CACHE STRING "EXE_LINKER_FLAGS used to build kim-api package") set(KIM_API_CXX_FLAGS "@KIM_API_CXX_FLAGS@" CACHE STRING "CXX_FLAGS used to build kim-api package") set(KIM_API_C_FLAGS "@KIM_API_C_FLAGS@" CACHE STRING "C_FLAGS used to build kim-api package") set(KIM_API_Fortran_FLAGS "@KIM_API_Fortran_FLAGS@" CACHE STRING "Fortran_FLAGS used to build kim-api package") endmacro(kim_api_items_set_compiler_flag_variables) macro(kim_api_items_prepend_compiler_flags_to_cmake_variables) kim_api_items_set_compiler_flag_variables() set(CMAKE_EXE_LINKER_FLAGS "${KIM_API_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_CXX_FLAGS "${KIM_API_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") set(CMAKE_C_FLAGS "${KIM_API_C_FLAGS} ${CMAKE_C_FLAGS}") set(CMAKE_Fortran_FLAGS "${KIM_API_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}") endmacro(kim_api_items_prepend_compiler_flags_to_cmake_variables) macro(kim_api_items_set_build_type_variable) set(KIM_API_CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" CACHE STRING "Built type used to build kim-api package") endmacro(kim_api_items_set_build_type_variable) macro(kim_api_items_set_cmake_build_type_variable_in_cache) kim_api_items_set_build_type_variable() # enable_language() will cache a default value unless CMAKE_BUILD_TYPE has # previously been cached elsewhere. So, typically this macro must be used # before a call to project(). set(CMAKE_BUILD_TYPE "${KIM_API_CMAKE_BUILD_TYPE}" CACHE STRING "Build Type") endmacro(kim_api_items_set_cmake_build_type_variable_in_cache) # # Function to set ITEM_* variables in parent scope for use in configuring # item-wrapper.cpp.in # # This function does error checking only for each variable individaully, # it does not attempt to validate values across variables. # function(_set_item_template_variables) set(_options "") set(_oneValueArgs TYPE NAME DRIVER_NAME CREATE_ROUTINE_LANGUAGE CREATE_ROUTINE_NAME SM_SPEC_FILE) set(_multiValueArgs PARAMETER_FILES METADATA_FILES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_set_item_template_variables'") endif() # ITEM_TYPE set(_KNOWN_TYPES portableModel modelDriver simulatorModel) if(NOT ${_ITEM_TYPE} IN_LIST _KNOWN_TYPES) message(FATAL_ERROR "Unknown KIM item type") endif() unset(_KNOWN_TYPES) set(ITEM_TYPE "${_ITEM_TYPE}" PARENT_SCOPE) # ITEM_NAME and ITEM_NAME_QUOTED if("${_ITEM_NAME}" STREQUAL "") message(FATAL_ERROR "KIM items must be given names") endif() string(MAKE_C_IDENTIFIER "${_ITEM_NAME}" _ITEM_C_NAME) if(NOT "${_ITEM_C_NAME}" STREQUAL "${_ITEM_NAME}") message(FATAL_ERROR "KIM item names must be valid C identifiers") endif() set(ITEM_NAME "${_ITEM_NAME}" PARENT_SCOPE) set(ITEM_NAME_QUOTED "\"${_ITEM_NAME}\"" PARENT_SCOPE) # ITEM_DRIVER_NAME and ITEM_DRIVER_NAME_QUOTED if("${_ITEM_DRIVER_NAME}" STREQUAL "") set(ITEM_DRIVER_NAME "" PARENT_SCOPE) set(ITEM_DRIVER_NAME_QUOTED "NULL" PARENT_SCOPE) else() set(ITEM_DRIVER_NAME "${_ITEM_DRIVER_NAME}" PARENT_SCOPE) set(ITEM_DRIVER_NAME_QUOTED "\"${_ITEM_DRIVER_NAME}\"" PARENT_SCOPE) endif() # ITEM_CREATE_ROUTINE_LANGUAGE set(_KNOWN_LANGUAGES cpp c fortran) if(NOT "${_ITEM_CREATE_ROUTINE_LANGUAGE}" IN_LIST _KNOWN_LANGUAGES) message(FATAL_ERROR "Unknown KIM item create routine language") endif() unset(_KNOWN_LANGUAGES) set(ITEM_CREATE_ROUTINE_LANGUAGE "${_ITEM_CREATE_ROUTINE_LANGUAGE}" PARENT_SCOPE) # ITEM_CREATE_ROUTINE_NAME if("${_ITEM_CREATE_ROUTINE_NAME}" STREQUAL "") set(ITEM_CREATE_ROUTINE_NAME "NULL" PARENT_SCOPE) else() set(ITEM_CREATE_ROUTINE_NAME "${_ITEM_CREATE_ROUTINE_NAME}" PARENT_SCOPE) endif() # ITEM_CREATE_ROUTINE_DECLARATION if("${_ITEM_CREATE_ROUTINE_NAME}" STREQUAL "") set(ITEM_CREATE_ROUTINE_DECLARATION "" PARENT_SCOPE) else() if("${_ITEM_TYPE}" STREQUAL "modelDriver") set(_create_typedef "ModelDriverCreateFunction") else() set(_create_typedef "ModelCreateFunction") endif() if("${_ITEM_CREATE_ROUTINE_LANGUAGE}" STREQUAL "cpp") set(ITEM_CREATE_ROUTINE_DECLARATION "KIM::${_create_typedef} ${_ITEM_CREATE_ROUTINE_NAME};" PARENT_SCOPE) elseif("${_ITEM_CREATE_ROUTINE_LANGUAGE}" STREQUAL "c") set(ITEM_CREATE_ROUTINE_DECLARATION "KIM_${_create_typedef} ${_ITEM_CREATE_ROUTINE_NAME};" PARENT_SCOPE) elseif("${_ITEM_CREATE_ROUTINE_LANGUAGE}" STREQUAL "fortran") set(ITEM_CREATE_ROUTINE_DECLARATION "void ${_ITEM_CREATE_ROUTINE_NAME}(KIM_${_create_typedef} *, KIM_LengthUnit, KIM_EnergyUnit, KIM_ChargeUnit, KIM_TemperatureUnit, KIM_TimeUnit, int *);" PARENT_SCOPE) else() message(FATAL_ERROR "Unknown KIM item create routine language") endif() unset(_create_typedef) endif() # ITEM_SM_SPEC_FILE set(ITEM_SM_SPEC_FILE "${_ITEM_SM_SPEC_FILE}" PARENT_SCOPE) # ITEM_NUMBER_OF_SM_SPEC_FILES list(LENGTH _ITEM_SM_SPEC_FILE _LIST_LEN) set(ITEM_NUMBER_OF_SM_SPEC_FILES ${_LIST_LEN} PARENT_SCOPE) unset(_LIST_LEN) if(ITEM_NUMBER_OF_SM_SPEC_FILES GREATER 1) message(FATAL_ERROR "There can only be one smspec file") endif() # ITEM_PARAMETER_FILES set(ITEM_PARAMETER_FILES "${_ITEM_PARAMETER_FILES}" PARENT_SCOPE) # ITEM_NUMBER_OF_PARAMETER_FILES list(LENGTH _ITEM_PARAMETER_FILES _LIST_LEN) set(ITEM_NUMBER_OF_PARAMETER_FILES ${_LIST_LEN} PARENT_SCOPE) # ITEM_METADATA_FILES set(_METADATA_LOCAL_FILES "item-compiled-with-version.txt") list(INSERT _ITEM_METADATA_FILES 0 "${_METADATA_LOCAL_FILES}") unset(_METADATA_LOCAL_FILES) file(GLOB _OPENKIM_STANDARD_METADATA_FILES LIST_DIRECTORIES false RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "kimspec.edn" "kimprovenance.edn" "kimcite-*.bib") if(_OPENKIM_STANDARD_METADATA_FILES) foreach(_FL IN LISTS _OPENKIM_STANDARD_METADATA_FILES) file(SHA1 "${CMAKE_CURRENT_SOURCE_DIR}/${_FL}" _FL_SHA1) if (NOT "${_FL_SHA1}" STREQUAL "da39a3ee5e6b4b0d3255bfef95601890afd80709") # SHA1 hash of empty file list(APPEND _ITEM_METADATA_FILES "${_FL}") endif() endforeach() unset(_FL) endif() unset(_OPENKIM_STANDARD_METADATA_FILES) set(ITEM_METADATA_FILES "${_ITEM_METADATA_FILES}" PARENT_SCOPE) # ITEM_NUMBER_OF_METADATA_FILES list(LENGTH _ITEM_METADATA_FILES _LIST_LEN) set(ITEM_NUMBER_OF_METADATA_FILES ${_LIST_LEN} PARENT_SCOPE) unset(_LIST_LEN) endfunction(_set_item_template_variables) macro(_set_model_driver_template_variables) set(_options "") set(_oneValueArgs NAME CREATE_ROUTINE_LANGUAGE CREATE_ROUTINE_NAME) set(_multiValueArgs METADATA_FILES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_set_model_driver_template_variables'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) if("${_ITEM_CREATE_ROUTINE_NAME}" STREQUAL "") message(FATAL_ERROR "Create routine name must be provided") endif() _set_item_template_variables( TYPE "modelDriver" NAME "${_ITEM_NAME}" DRIVER_NAME "" CREATE_ROUTINE_LANGUAGE "${_ITEM_CREATE_ROUTINE_LANGUAGE}" CREATE_ROUTINE_NAME "${_ITEM_CREATE_ROUTINE_NAME}" SM_SPEC_FILE "" PARAMETER_FILES "" METADATA_FILES "${_ITEM_METADATA_FILES}" ) endmacro(_set_model_driver_template_variables) # # Macro to set ITEM_* variables for a STAND ALONE PORTABLE MODEL in current # scope for use in configuring item-wrapper.cpp.in # # This function does error checking to validate all necessary values are # provided. # macro(_set_stand_alone_portable_model_template_variables) set(_options "") set(_oneValueArgs NAME CREATE_ROUTINE_LANGUAGE CREATE_ROUTINE_NAME) set(_multiValueArgs METADATA_FILES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_set_stand_alone_portable_model_template_variables'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) if("${_ITEM_CREATE_ROUTINE_NAME}" STREQUAL "") message(FATAL_ERROR "Create routine name must be provided") endif() _set_item_template_variables( TYPE "portableModel" NAME "${_ITEM_NAME}" DRIVER_NAME "" CREATE_ROUTINE_LANGUAGE "${_ITEM_CREATE_ROUTINE_LANGUAGE}" CREATE_ROUTINE_NAME "${_ITEM_CREATE_ROUTINE_NAME}" SM_SPEC_FILE "" PARAMETER_FILES "" METADATA_FILES "${_ITEM_METADATA_FILES}" ) endmacro() # # Macro to set ITEM_* variables for a PARAMETERIZED PORTABLE MODEL in current # scope for use in configuring item-wrapper.cpp.in # # This function does error checking to validate all necessary values are # provided. # macro(_set_parameterized_portable_model_template_variables) set(_options "") set(_oneValueArgs NAME DRIVER_NAME) set(_multiValueArgs PARAMETER_FILES METADATA_FILES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_set_parameterized_portable_model_template_variables'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) if("${_ITEM_DRIVER_NAME}" STREQUAL "") message(FATAL_ERROR "Driver name must be provided") endif() if("${_ITEM_PARAMETER_FILES}" STREQUAL "") message(FATAL_ERROR "Parameter files must be provided") endif() _set_item_template_variables( TYPE "portableModel" NAME "${_ITEM_NAME}" DRIVER_NAME "${_ITEM_DRIVER_NAME}" CREATE_ROUTINE_LANGUAGE "cpp" CREATE_ROUTINE_NAME "" SM_SPEC_FILE "" PARAMETER_FILES "${_ITEM_PARAMETER_FILES}" METADATA_FILES "${_ITEM_METADATA_FILES}" ) endmacro() # # Macro to set ITEM_* variables for a SIMULATOR MODEL in current scope for use # in configuring item-wrapper.cpp.in # # This function does error checking to validate all necessary values are # provided. # macro(_set_simulator_model_template_variables) set(_options "") set(_oneValueArgs NAME SM_SPEC_FILE) set(_multiValueArgs PARAMETER_FILES METADATA_FILES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_set_simulator_model_template_variables'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) if("${_ITEM_SM_SPEC_FILE}" STREQUAL "") message(FATAL_ERROR "smspec file must be provided") endif() # OK for there to be no parameter files _set_item_template_variables( TYPE "simulatorModel" NAME "${_ITEM_NAME}" DRIVER_NAME "" CREATE_ROUTINE_LANGUAGE "cpp" CREATE_ROUTINE_NAME "" SM_SPEC_FILE "${_ITEM_SM_SPEC_FILE}" PARAMETER_FILES "${_ITEM_PARAMETER_FILES}" METADATA_FILES "${_ITEM_METADATA_FILES}" ) endmacro() # # Function to create a custom command to convert a file (blob) to a c source. # # Convert _filein to hex then format as c source file and write to _fileout. # Assumes _filein is a relative file name in the _dirin directory. # # Sets _blob_to_c_command to string for use with add_custom_command() # function(_add_custom_command_blob_to_c _dirin _filein _fileout) include(FindPackageMessage) find_program(XXD_EXECUTABLE "xxd") if(XXD_EXECUTABLE) find_package_message(xxd "Found xxd: (${XXD_EXECUTABLE})" "found") string(MAKE_C_IDENTIFIER ${_filein} _cfilein) set(_edit_xxd_output "${CMAKE_CURRENT_BINARY_DIR}/EditXXDOutput.cmake") if(NOT EXISTS "${_edit_xxd_output}") file(WRITE "${_edit_xxd_output}" # use a bracket argument to avoid ugly escaping [=[ # This file was automatically generated by CMake; do not edit. file(READ "${fileout}" _content) string(REGEX REPLACE "unsigned char.*[[][]]" "unsigned char const ${varname}[]" _content "${_content}") string(REGEX REPLACE "unsigned int.*=" "unsigned int const ${varname}_len =" _content "${_content}") file(WRITE "${fileout}" "${_content}") unset(_content) ]=] ) endif() add_custom_command(OUTPUT ${_fileout} COMMAND ${XXD_EXECUTABLE} -i "${_filein}" "${_fileout}" COMMAND ${CMAKE_COMMAND} "-Dvarname=${_cfilein}" "-Dfilein=${_filein}" "-Dfileout=${_fileout}" -P "${_edit_xxd_output}" DEPENDS "${_dirin}/${_filein}" "${_edit_xxd_output}" WORKING_DIRECTORY "${_dirin}" ) unset(_cfilein) unset(_edit_xxd_output) else() find_package_message(xxd "Missing xxd: Falling back to less efficient cmake implementation." "missing") string(MAKE_C_IDENTIFIER ${_filein} _cfilein) set(_blob_to_source "${CMAKE_CURRENT_BINARY_DIR}/BlobToCSource.cmake") if(NOT EXISTS "${_blob_to_source}") file(WRITE "${_blob_to_source}" # use a bracket argument to avoid ugly escaping [=[ # This file was automatically generated by CMake; do not edit. file(READ "${filein}" _content HEX) string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," _content "${_content}") string(REGEX REPLACE ",$" "" _content "${_content}") file(WRITE "${fileout}" "unsigned char const ${varname}[] = { ${_content} };\n") file(APPEND "${fileout}" "unsigned int const ${varname}_len = sizeof( ${varname} );\n") unset(_content) ]=] ) endif() add_custom_command(OUTPUT ${_fileout} COMMAND ${CMAKE_COMMAND} "-Dvarname=${_cfilein}" "-Dfilein=${_filein}" "-Dfileout=${_fileout}" -P "${_blob_to_source}" DEPENDS "${_dirin}/${_filein}" "${_blob_to_source}" WORKING_DIRECTORY "${_dirin}" ) unset(_cfilein) unset(_blob_to_source) endif() endfunction(_add_custom_command_blob_to_c) # # Function to create and define targets for c source files from provided data # files. Assumes files are in either current source or current binary dir. # # Sets ITEM_*_SOURCES, ITEM_*_DECLARATIONS, ITEM_*_EMBEDDED_FILE_IDENTIFIER, # and ITEM_*_EMBEDDED_FILE_INITIALIZER_LIST variables in parent scope. # function(_xxd_process_files) set(_options "") set(_oneValueArgs FILE_TYPE) set(_multiValueArgs FILE_NAMES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in macro '_xxd_process_files'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) if("${_ITEM_FILE_TYPE}" STREQUAL "") message(FATAL_ERROR "FILE_TYPE must be provided") endif() set(_ITEM_SOURCES "") set(_ITEM_DECLARATIONS "") set(_ITEM_EMBEDDED_FILE_INITIALIZER_LIST "") set(_ITEM_EMBEDDED_FILE_IDENTIFIER "NULL") if (_ITEM_FILE_NAMES) foreach(_FNAME ${_ITEM_FILE_NAMES}) string(MAKE_C_IDENTIFIER ${_FNAME} _CFNAME) if("${_ITEM_DECLARATIONS}" STREQUAL "") set(_ITEM_DECLARATIONS "extern unsigned int const ${_CFNAME}_len;\n") set(_ITEM_DECLARATIONS "${_ITEM_DECLARATIONS}extern unsigned char const ${_CFNAME}[];") set(_ITEM_EMBEDDED_FILE_IDENTIFIER "${_ITEM_FILE_TYPE}_Files") set(_ITEM_EMBEDDED_FILE_INITIALIZER_LIST "static SharedLibrarySchemaV2::EmbeddedFile const ${_ITEM_FILE_TYPE}_Files[] = {\n") set(_ITEM_EMBEDDED_FILE_INITIALIZER_LIST "${_ITEM_EMBEDDED_FILE_INITIALIZER_LIST} {\"${_FNAME}\", ${_CFNAME}_len, ${_CFNAME}}") else() set(_ITEM_DECLARATIONS "${_ITEM_DECLARATIONS}\nextern unsigned int const ${_CFNAME}_len;\n") set(_ITEM_DECLARATIONS "${_ITEM_DECLARATIONS}extern unsigned char const ${_CFNAME}[];") set(_ITEM_EMBEDDED_FILE_INITIALIZER_LIST "${_ITEM_EMBEDDED_FILE_INITIALIZER_LIST},\n {\"${_FNAME}\", ${_CFNAME}_len, ${_CFNAME}}") endif() unset(_CFNAME) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_FNAME}") set(_DIR_IN "${CMAKE_CURRENT_SOURCE_DIR}") elseif(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${_FNAME}") set(_DIR_IN "${CMAKE_CURRENT_BINARY_DIR}") else() message(FATAL_ERROR "Cannot find metadata file '${_FNAME}'") endif() set(_FILE "${CMAKE_CURRENT_BINARY_DIR}/${_FNAME}.c") list(APPEND _ITEM_SOURCES ${_FILE}) _add_custom_command_blob_to_c("${_DIR_IN}" "${_FNAME}" "${_FILE}") unset(_DIR_IN) endforeach() unset(_FNAME) set(_ITEM_EMBEDDED_FILE_INITIALIZER_LIST "${_ITEM_EMBEDDED_FILE_INITIALIZER_LIST}\n};") endif() set(ITEM_${_ITEM_FILE_TYPE}_SOURCES "${_ITEM_SOURCES}" PARENT_SCOPE) set(ITEM_${_ITEM_FILE_TYPE}_DECLARATIONS "${_ITEM_DECLARATIONS}" PARENT_SCOPE) set(ITEM_${_ITEM_FILE_TYPE}_EMBEDDED_FILE_IDENTIFIER "${_ITEM_EMBEDDED_FILE_IDENTIFIER}" PARENT_SCOPE) set(ITEM_${_ITEM_FILE_TYPE}_EMBEDDED_FILE_INITIALIZER_LIST "${_ITEM_EMBEDDED_FILE_INITIALIZER_LIST}" PARENT_SCOPE) endfunction(_xxd_process_files) # # Function to set collection install prefix and item library file name. # # Sets ITEM_INSTALL_PREFIX and ITEM_OUTPUT_NAME variables in parent scope. # function(_determine_collection_install_prefix_and_output_name _item_type) if("${_item_type}" STREQUAL "") message(FATAL_ERROR "Empty item type provided.") endif() if("${_item_type}" STREQUAL "modelDriver") set(_item_type_upper "MODEL_DRIVER") set(_item_arg "model_drivers") set(_ITEM_OUTPUT_NAME "@PROJECT_NAME@-@KIM_API_MODEL_DRIVER_IDENTIFIER@") elseif("${_item_type}" STREQUAL "portableModel") set(_item_type_upper "PORTABLE_MODEL") set(_item_arg "portable_models") set(_ITEM_OUTPUT_NAME "@PROJECT_NAME@-@KIM_API_PORTABLE_MODEL_IDENTIFIER@") elseif("${_item_type}" STREQUAL "simulatorModel") set(_item_type_upper "SIMULATOR_MODEL") set(_item_arg "simulator_models") set(_ITEM_OUTPUT_NAME "@PROJECT_NAME@-@KIM_API_SIMULATOR_MODEL_IDENTIFIER@") else() message(FATAL_ERROR "Unknown item type.") endif() # if("${KIM_API_INSTALL_COLLECTION}" STREQUAL "SYSTEM") set(_col_arg "system") elseif(KIM_API_INSTALL_COLLECTION STREQUAL "USER") set(_col_arg "config_file") elseif(KIM_API_INSTALL_COLLECTION STREQUAL "ENVIRONMENT") set(_col_arg "env") else() message(FATAL_ERROR "Unknown value of KIM_API_INSTALL_COLLECTION : ${KIM_API_INSTALL_COLLECTION}.") endif() get_property(_IMPORTED TARGET KIM-API::collections-info PROPERTY "IMPORTED") if(_IMPORTED) # using install tree config if("${CMAKE_BUILD_TYPE}" STREQUAL "") set(_BUILD_TYPE "NOCONFIG") else() string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE) endif() get_property(_COLLECTIONS_INFO TARGET KIM-API::collections-info PROPERTY "IMPORTED_LOCATION_${_BUILD_TYPE}") unset(_BUILD_TYPE) if("${_COLLECTIONS_INFO}" STREQUAL "") message(FATAL_ERROR "Unable to locate 'collections-info' utility") endif() execute_process(COMMAND ${_COLLECTIONS_INFO} ${_col_arg} ${_item_arg} OUTPUT_VARIABLE _ITEM_INSTALL_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _error) unset(_COLLECTIONS_INFO) unset(_col_arg) unset(_item_arg) string(REGEX REPLACE "^([^\n]+)\n.*" "\\1" _ITEM_INSTALL_PREFIX "${_ITEM_INSTALL_PREFIX}") # check for command line override of install prefix # # UNDOCUMENTED FEATURE (used by homebrew, as of this writing) # # KIM_API_MODEL_DRIVER_INSTALL_PREFIX # KIM_API_PORTABLE_MODEL_INSTALL_PREFIX # KIM_API_SIMULATOR_MODEL_INSTALL_PREFIX # if(DEFINED KIM_API_${_item_type_upper}_INSTALL_PREFIX) set(_ITEM_INSTALL_PREFIX "${KIM_API_${_item_type_upper}_INSTALL_PREFIX}") endif() unset(_item_type_upper) else() # using build tree config if(NOT "${KIM_API_INSTALL_COLLECTION}" STREQUAL "SYSTEM") message(FATAL_ERROR "Cannot install into ${KIM_API_INSTALL_COLLECTION} collection during KIM API build") else() _determine_default_system_collection_install_prefix(${_item_type}) endif() endif() unset(_IMPORTED) if("${_ITEM_INSTALL_PREFIX}" STREQUAL "") message(FATAL_ERROR "Unable to determine KIM API item install prefix.") endif() # set(ITEM_INSTALL_PREFIX "${_ITEM_INSTALL_PREFIX}" PARENT_SCOPE) set(ITEM_OUTPUT_NAME "${_ITEM_OUTPUT_NAME}" PARENT_SCOPE) endfunction(_determine_collection_install_prefix_and_output_name) # # Wrapper function for CMake's standard add_test() function, which takes care of setting up the DLL search path on Windows. # The function signature is the same as for the built-in add_test() function: # # add_kim_api_test(NAME COMMAND [...] # [CONFIGURATIONS ...] # [WORKING_DIRECTORY] # [COMMAND_EXPAND_LISTS]) # # The wrapper function sets up the ENVIRONMENT property of the test case to extend the DLL search path. # Make sure you do not overwrite that property's value when setting up a custom environment # for the test case. Use set_property(TEST ... APPEND PROPERTY ENVIRONMENT ...) to add further # environment variables. # function(add_kim_api_test) # Foward the function call and all arguments to the built-in add_test() function. cmake_parse_arguments(KIMAPI_TEST "" "NAME" "" ${ARGN}) add_test(NAME ${KIMAPI_TEST_NAME} ${KIMAPI_TEST_UNPARSED_ARGUMENTS}) # Determine the value of the PATH environment variable to be used for running the CMake test. # It is required on Windows, because kim-api.dll needs to be in the search # path when running the test executables. We prepend the CMake build directory to the existing PATH variable. if(CYGWIN) # CMake under Cygwin expects ':' separated path list with '/' directory separators (Unix style). set_property(TEST ${KIMAPI_TEST_NAME} APPEND PROPERTY ENVIRONMENT "PATH=$:$ENV{PATH}") elseif(MINGW) # CMake under MinGW expects ';' separated path list with '\' directory separators (Windows style). string(REPLACE ";" "\\;" PATH_VALUE "$ENV{PATH}") set_property(TEST ${KIMAPI_TEST_NAME} APPEND PROPERTY ENVIRONMENT "PATH=$>\;${PATH_VALUE}") else() # No PATH needed on Unix/Linux platforms, where shared libraries are located using the rpath mechanism. endif() endfunction(add_kim_api_test) # # Function to create a library target of any item type. Uniformly processes # various data files and creates shared-library cmake test which ensures that # there are no undefined symbols in the shared library. # function(_add_kim_api_library) set(_options "") set(_oneValueArgs TYPE NAME DRIVER_NAME CREATE_ROUTINE_LANGUAGE CREATE_ROUTINE_NAME SM_SPEC_FILE) set(_multiValueArgs PARAMETER_FILES METADATA_FILES) cmake_parse_arguments(_ITEM "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if(_ITEM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unparsed arguments found in '_add_kim_api_library'") endif() unset(_options) unset(_oneValueArgs) unset(_multiValueArgs) configure_file(${KIM-API-ITEMS_DIR}/item-compiled-with-version.txt ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) if("${_ITEM_TYPE}" STREQUAL "modelDriver") _set_model_driver_template_variables( NAME "${_ITEM_NAME}" CREATE_ROUTINE_NAME "${_ITEM_CREATE_ROUTINE_NAME}" CREATE_ROUTINE_LANGUAGE "${_ITEM_CREATE_ROUTINE_LANGUAGE}" METADATA_FILES "${_ITEM_METADATA_FILES}" ) elseif("${_ITEM_TYPE}" STREQUAL "portableModel") if("${_ITEM_CREATE_ROUTINE_NAME}" STREQUAL "") _set_parameterized_portable_model_template_variables( NAME "${_ITEM_NAME}" DRIVER_NAME "${_ITEM_DRIVER_NAME}" PARAMETER_FILES "${_ITEM_PARAMETER_FILES}" METADATA_FILES "${_ITEM_METADATA_FILES}" ) else() _set_stand_alone_portable_model_template_variables( NAME "${_ITEM_NAME}" CREATE_ROUTINE_LANGUAGE "${_ITEM_CREATE_ROUTINE_LANGUAGE}" CREATE_ROUTINE_NAME "${_ITEM_CREATE_ROUTINE_NAME}" METADATA_FILES "${_ITEM_METADATA_FILES}" ) endif() elseif("${_ITEM_TYPE}" STREQUAL "simulatorModel") _set_simulator_model_template_variables( NAME "${_ITEM_NAME}" SM_SPEC_FILE "${_ITEM_SM_SPEC_FILE}" PARAMETER_FILES "${_ITEM_PARAMETER_FILES}" METADATA_FILES "${_ITEM_METADATA_FILES}" ) else() message(FATAL_ERROR "Unknown item type") endif() set(_ITEM_SOURCES "") _xxd_process_files(FILE_TYPE SM_SPEC_FILE FILE_NAMES "${ITEM_SM_SPEC_FILE}") list(APPEND _ITEM_SOURCES ${ITEM_SM_SPEC_FILE_SOURCES}) _xxd_process_files(FILE_TYPE PARAMETER_FILE FILE_NAMES "${ITEM_PARAMETER_FILES}") list(APPEND _ITEM_SOURCES ${ITEM_PARAMETER_FILE_SOURCES}) _xxd_process_files(FILE_TYPE METADATA_FILE FILE_NAMES "${ITEM_METADATA_FILES}") list(APPEND _ITEM_SOURCES ${ITEM_METADATA_FILE_SOURCES}) configure_file(${KIM-API-ITEMS_DIR}/item-info.txt.in ${CMAKE_CURRENT_BINARY_DIR}/item-info.txt @ONLY) configure_file(${KIM-API-ITEMS_DIR}/item-wrapper.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/item-wrapper.cpp @ONLY) list(APPEND _ITEM_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/item-wrapper.cpp) add_library(${ITEM_NAME} MODULE ${_ITEM_SOURCES}) target_include_directories(${ITEM_NAME} PRIVATE ${KIM-API-ITEMS_DIR}) target_link_libraries(${ITEM_NAME} PRIVATE KIM-API::kim-api) _determine_collection_install_prefix_and_output_name("${_ITEM_TYPE}") set_target_properties(${ITEM_NAME} PROPERTIES OUTPUT_NAME "${ITEM_OUTPUT_NAME}") install(TARGETS ${ITEM_NAME} LIBRARY DESTINATION "${ITEM_INSTALL_PREFIX}/${ITEM_NAME}") add_kim_api_test(NAME shared_library_test_${ITEM_NAME} COMMAND KIM-API::shared-library-test $) endfunction(_add_kim_api_library) kim-api-2.3.0-git/cmake/macros.cmake.in000066400000000000000000000021351421473465500176130ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # nothing to be done here... kim-api-2.3.0-git/cmake/pre-2.2-compatibility.cmake.in000066400000000000000000000112261421473465500222640ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # # - Code for backward compatibility with pre 2.2.0 KIM-API behavior # # Set various cmake variables (compilers, etc.) and set various KIM_API # variables. Also provide the following macros # # add_kim_api_imported_library() - add kim-api library target # add_kim_api_compiler_flags() - set extra compile/link flags # # REMOVE THIS FILE FOR 3.0.0 RELEASE!!! message(WARNING "\n" "Pre 2.2.0 KIM-API package behavior is deprecated and will be " "removed in 3.0.0. Please update your CMakeLists.txt file to " "use a find_package() signature similar to one of the following:\n" " find_package(KIM-API 2.2 REQUIRED CONFIG)\n" " find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG)\n" "See the examples in the KIM API source package for more details." "\n" ) include(CMakeFindDependencyMacro) set(REMOVE_THIS_FOR_3_0_0_RELEASE "_pre22") find_dependency(KIM-API-ITEMS ${KIM-API_FIND_VERSION}) kim_api_items_set_cmake_compiler_standard_variables() kim_api_items_set_cmake_build_type_variable_in_cache() kim_api_items_set_cmake_compiler_variables() kim_api_items_set_compiler_flag_variables() set(KIM_API_PROJECT_NAME @KIM_API_PROJECT_NAME@) set(KIM_API_VERSION @PROJECT_VERSION@) # wrap add_kim_api_model_library() and add_kim_api_model_driver_library() macro(add_kim_api_model_library) if (NOT TARGET kim-api OR NOT TARGET KIM-API::kim-api) kim_api_items_prepend_compiler_flags_to_cmake_variables() add_kim_api_imported_library() endif() add_kim_api_model_library_pre22(${ARGN}) endmacro(add_kim_api_model_library) macro(add_kim_api_model_driver_library) if (NOT TARGET kim-api OR NOT TARGET KIM-API::kim-api) kim_api_items_prepend_compiler_flags_to_cmake_variables() add_kim_api_imported_library() endif() add_kim_api_model_driver_library_pre22(${ARGN}) endmacro(add_kim_api_model_driver_library) macro(add_kim_api_imported_library) if(_KIM_API_BUILD_TREE_ACTIVE) add_library(KIM-API::kim-api ALIAS kim-api) add_executable(KIM-API::portable-model-info ALIAS portable-model-info) add_executable(KIM-API::simulator-model ALIAS simulator-model) add_executable(KIM-API::collections-info ALIAS collections-info) add_executable(KIM-API::shared-library-test ALIAS shared-library-test) else() include("${KIM-API_DIR}/kim-api-macros.cmake") include("${KIM-API_DIR}/kim-api-targets.cmake") # add shadow kim-api target add_library(kim-api SHARED IMPORTED) get_property(_config TARGET KIM-API::kim-api PROPERTY IMPORTED_CONFIGURATIONS) foreach(_cfg IN LISTS _config) get_property(_loc TARGET KIM-API::kim-api PROPERTY IMPORTED_LOCATION_${_cfg}) set_property(TARGET kim-api PROPERTY IMPORTED_LOCATION_${_cfg} ${_loc}) get_property(_so TARGET KIM-API::kim-api PROPERTY IMPORTED_SONAME_${_cfg}) set_property(TARGET kim-api PROPERTY IMPORTED_SONAME_${_cfg} ${_so}) endforeach() get_property(_val TARGET KIM-API::kim-api PROPERTY INTERFACE_INCLUDE_DIRECTORIES) set_property(TARGET kim-api PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_val}) # add shadow collections-info target add_executable(collections-info IMPORTED) get_property(_config TARGET KIM-API::collections-info PROPERTY IMPORTED_CONFIGURATIONS) foreach(_cfg IN LISTS _config) get_property(_loc TARGET KIM-API::collections-info PROPERTY IMPORTED_LOCATION_${_cfg}) set_property(TARGET collections-info PROPERTY IMPORTED_LOCATION_${_cfg} ${_loc}) endforeach() endif() endmacro(add_kim_api_imported_library) macro(add_kim_api_compiler_flags) kim_api_items_prepend_compiler_flags_to_cmake_variables() endmacro(add_kim_api_compiler_flags) kim-api-2.3.0-git/completions/000077500000000000000000000000001421473465500161735ustar00rootroot00000000000000kim-api-2.3.0-git/completions/CMakeLists.txt000066400000000000000000000046561421473465500207460ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Jim Madge # Yaser Afshar # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # include(RelocatablePath) set(BASH_COMPLETIONS ${PROJECT_NAME}-collections-management.bash) set(ZSH_COMPLETIONS ${PROJECT_NAME}-collections-management.zsh) relocatable_path( FROM "${BASH_COMPLETION_FULL_COMPLETIONSDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_SYSCONFDIR}" TO "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${PROJECT_NAME}/${PROJECT_NAME}-collections-info" TO_REL "${CMAKE_INSTALL_RELOC_LIBEXECDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _collections_info_rel ) configure_file(collections-management.bash.in ${BASH_COMPLETIONS} @ONLY) unset(_collections_info_rel) relocatable_path( FROM "${ZSH_COMPLETION_FULL_COMPLETIONSDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_SYSCONFDIR}" TO "${BASH_COMPLETION_FULL_COMPLETIONSDIR}/${BASH_COMPLETIONS}" TO_REL "${CMAKE_INSTALL_RELOC_SYSCONFDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _bashcomp_rel ) configure_file(collections-management.zsh.in ${ZSH_COMPLETIONS} @ONLY) unset(_bashcomp_rel) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${BASH_COMPLETIONS} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${BASH_COMPLETION_RELOC_COMPLETIONSDIR} ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZSH_COMPLETIONS} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${ZSH_COMPLETION_RELOC_COMPLETIONSDIR} RENAME "_${PROJECT_NAME}-collections-management" ) kim-api-2.3.0-git/completions/collections-management.bash.in000066400000000000000000000142551421473465500240760ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # _@KIM_API_C_ID_PROJECT_NAME@_collections_management() { local ORIGIN if test -n "${ZSH_VERSION}"; then ORIGIN=$(cd "$(dirname "${(%):-%x}")" && pwd) else # Get ORIGIN location of this script: SOURCE="${BASH_SOURCE[0]}" # https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself if command -v readlink >/dev/null 2>&1; then while test -h "$SOURCE"; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done fi ORIGIN="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" fi local collections_info collections_info=@_collections_info_rel@ local cd_type if test -n "${ZSH_VERSION}"; then cd_type=`type -w _cd | sed -e 's/^[^:]*: *//'` else cd_type=`type -t _cd` fi local cur subcommands opts subcommands="list set-user-model-drivers-dir set-user-portable-models-dir " subcommands="${subcommands} set-user-simulator-models-dir install reinstall" subcommands="${subcommands} remove remove-all" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" if test ${COMP_CWORD} -eq 1; then COMPREPLY=( $(compgen -W "${subcommands}" -- "${cur}") ) return 0 else case "${COMP_WORDS[1]}" in list) opts="" if test ${COMP_CWORD} -eq 2; then opts="--log" else return 1 fi COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; set-user-*) if test ${COMP_CWORD} -gt 2; then return 1 else if test x"function" = x"${cd_type}"; then # check if bash_completion has been loaded & _cd defined _cd fi return 0 fi ;; install) if test ${COMP_CWORD} -eq 2; then COMPREPLY=( $(compgen -W "--force CWD environment user system" \ -- "${cur}") ) return 0 fi if test ${COMP_CWORD} -eq 3 -a x"${COMP_WORDS[2]}" = x"--force"; then COMPREPLY=( $(compgen -W "CWD environment user system" \ -- "${cur}") ) return 0 fi local collection_position if test x"${COMP_WORDS[2]}" = x"--force"; then collection_position=3 else collection_position=2 fi opts="" if test ${COMP_CWORD} -eq `expr ${collection_position} + 1` \ -a x"system" = x"${COMP_WORDS[${collection_position}]}"; then opts="--sudo OpenKIM" elif test ${COMP_CWORD} -eq 3; then opts="OpenKIM" fi local query='query={"type":{"$regex":"md|mo|sm"},"kim-api-version":{"$regex":"^@PROJECT_VERSION_MAJOR@\\."}}' query="${query}"'&fields={"kimcode":1}' query="${query}"'&database=obj&history=on' local list=`wget -q -O - --post-data="${query}" \ https://query.openkim.org/api | \ sed -e 's/\[//g' -e 's/\]//g' \ -e 's/{"kimcode": "\([^"]*\)"},*/\1/g'` opts="${opts} ${list}" if test x"function" = x"${cd_type}"; then # check if bash_completion has been loaded & _cd defined _cd fi COMPREPLY=( "${COMPREPLY[@]}" $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; reinstall|remove) opts="" if test ${COMP_CWORD} -eq 2; then opts="--force --interactive --sudo" elif test ${COMP_CWORD} -eq 3 -a x"--interactive" = x"${COMP_WORDS[2]}"; then opts="--sudo" elif test ${COMP_CWORD} -eq 3 -a x"--force" = x"${COMP_WORDS[2]}"; then opts="--sudo" fi local models drivers simulator_models drivers=`${collections_info} model_drivers | sed -e 's|[^[:space:]]* \([^[:space:]]*\) .*|\1|'` models=`${collections_info} portable_models | sed -e 's|[^[:space:]]* \([^[:space:]]*\) .*|\1|'` drivers=`${collections_info} simulator_models | sed -e 's|[^[:space:]]* \([^[:space:]]*\) .*|\1|'` opts="${opts} ${drivers} ${models} ${simulator_models}" if test x"reinstall" = x"${COMP_WORDS[1]}"; then if test x"function" = x"cd_type"; then # check if bash_completion has been loaded & _cd defined _cd fi fi COMPREPLY=( "${COMPREPLY[@]}" $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; remove-all) opts="" if test ${COMP_CWORD} -eq 2; then opts="--force --interactive --sudo" elif test ${COMP_CWORD} -eq 3 -a x"--interactive" = x"${COMP_WORDS[2]}"; then opts="--sudo" elif test ${COMP_CWORD} -eq 3 -a x"--force" = x"${COMP_WORDS[2]}"; then opts="--sudo" fi COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; *) return 1 ;; esac fi return 1 } complete -F _@KIM_API_C_ID_PROJECT_NAME@_collections_management @PROJECT_NAME@-collections-management kim-api-2.3.0-git/completions/collections-management.zsh.in000066400000000000000000000027571421473465500237710ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Yaser Afshar # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # if test -n "${ZSH_VERSION}"; then # While complete is a bash builtin function, ZSH comes with # bashcompinit that creates the same functionality. # The option -U suppresses the alias expansion during reading # using functions in ZSH. autoload -U +X bashcompinit bashcompinit autoload -U +X compinit if test x"${ZSH_DISABLE_COMPFIX}" = x"true"; then compinit -u else compinit fi fi ORIGIN=$(cd "$(dirname "${(%):-%x}")" && pwd) source "@_bashcomp_rel@" kim-api-2.3.0-git/cpp/000077500000000000000000000000001421473465500144215ustar00rootroot00000000000000kim-api-2.3.0-git/cpp/include/000077500000000000000000000000001421473465500160445ustar00rootroot00000000000000kim-api-2.3.0-git/cpp/include/CMakeLists.txt000066400000000000000000000050751421473465500206130ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # target_include_directories(kim-api PUBLIC $ $ ) configure_file(KIM_LOG_DEFINES.inc.in ${CMAKE_CURRENT_BINARY_DIR}/KIM_LOG_DEFINES.inc) configure_file(KIM_Version.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/KIM_Version.hpp) set(CPP_HEADERS KIM_ChargeUnit.hpp KIM_Collection.hpp KIM_CollectionItemType.hpp KIM_Collections.hpp KIM_ComputeArgumentName.hpp KIM_ComputeArguments.hpp KIM_ComputeCallbackName.hpp KIM_DataType.hpp KIM_EnergyUnit.hpp KIM_FunctionTypes.hpp KIM_LanguageName.hpp KIM_LengthUnit.hpp KIM_Log.hpp KIM_LogMacros.hpp KIM_LogVerbosity.hpp KIM_ModelComputeArgumentsCreate.hpp KIM_ModelComputeArgumentsDestroy.hpp KIM_ModelComputeArguments.hpp KIM_ModelCompute.hpp KIM_ModelCreate.hpp KIM_ModelExtension.hpp KIM_ModelDestroy.hpp KIM_ModelDriverCreate.hpp KIM_ModelDriverHeaders.hpp KIM_ModelHeaders.hpp KIM_Model.hpp KIM_ModelRefresh.hpp KIM_ModelRoutineName.hpp KIM_ModelWriteParameterizedModel.hpp KIM_Numbering.hpp KIM_SemVer.hpp KIM_SimulatorHeaders.hpp KIM_SimulatorModel.hpp KIM_SpeciesName.hpp KIM_SupportedExtensions.hpp KIM_SupportStatus.hpp KIM_TemperatureUnit.hpp KIM_TimeUnit.hpp KIM_UnitSystem.hpp ${CMAKE_CURRENT_BINARY_DIR}/KIM_LOG_DEFINES.inc ${CMAKE_CURRENT_BINARY_DIR}/KIM_Version.hpp ) install(FILES ${CPP_HEADERS} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_INCLUDEDIR}/${PROJECT_NAME}) kim-api-2.3.0-git/cpp/include/KIM_ChargeUnit.hpp000066400000000000000000000136151421473465500213140ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_CHARGE_UNIT_HPP_ #define KIM_CHARGE_UNIT_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// ChargeUnit's supported by the %KIM API. /// /// The enumeration constants are contained in the CHARGE_UNIT namespace. /// /// \sa KIM_ChargeUnit, kim_charge_unit_module /// /// \since 2.0 class ChargeUnit { public: /// \brief Integer identifying the specific ChargeUnit represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_ChargeUnit::chargeUnitID, /// kim_charge_unit_module::kim_charge_unit_type::charge_unit_id /// /// \since 2.0 int chargeUnitID; /// \brief Create an uninitialized ChargeUnit object. /// /// \since 2.0 ChargeUnit(); /// \brief Create a ChargeUnit object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 ChargeUnit(int const id); /// \brief Create a ChargeUnit object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_ChargeUnit_FromString, kim_charge_unit_module::kim_from_string /// /// \since 2.0 ChargeUnit(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// ChargeUnit's known to the %KIM API are found in the CHARGE_UNIT /// namespace. /// /// \sa KIM_ChargeUnit_Known, kim_charge_unit_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares ChargeUnit objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_ChargeUnit_Equal, kim_charge_unit_module::operator(.eq.) /// /// \since 2.0 bool operator==(ChargeUnit const & rhs) const; /// \brief Compares ChargeUnit objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_ChargeUnit_NotEqual, kim_charge_unit_module::operator(.ne.) /// /// \since 2.0 bool operator!=(ChargeUnit const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the ChargeUnit object. /// /// \note If the ChargeUnit object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_ChargeUnit_ToString, kim_charge_unit_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class ChargeUnit /// \brief Contains the enumeration constants and the discovery routines for /// the ChargeUnit \ref extensible_enumeration "Extensible Enumeration". namespace CHARGE_UNIT { /// \brief Indicates that a ChargeUnit is not used. /// /// \sa KIM_CHARGE_UNIT_unused, kim_charge_unit_module::kim_charge_unit_unused /// /// \since 2.0 extern ChargeUnit const unused; /// \brief The standard Coulomb unit of charge. /// /// \sa KIM_CHARGE_UNIT_C, kim_charge_unit_module::kim_charge_unit_c /// /// \since 2.0 extern ChargeUnit const C; /// \brief The standard electron unit of charge. /// /// \sa KIM_CHARGE_UNIT_e, kim_charge_unit_module::kim_charge_unit_e /// /// \since 2.0 extern ChargeUnit const e; /// \brief The standard statcoulomb unit of charge. /// /// \sa KIM_CHARGE_UNIT_statC, kim_charge_unit_module::kim_charge_unit_statc /// /// \since 2.0 extern ChargeUnit const statC; /// \brief Get the number of standard ChargeUnit's defined by the %KIM API. /// /// \param[out] numberOfChargeUnits The number of standard ChargeUnit's defined /// by the %KIM API. /// /// \sa KIM_CHARGE_UNIT_GetNumberOfChargeUnits, /// kim_charge_unit_module::kim_get_number_of_charge_units /// /// \since 2.0 void GetNumberOfChargeUnits(int * const numberOfChargeUnits); /// \brief Get the identity of each defined standard ChargeUnit. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// ChargeUnit. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] chargeUnit The ChargeUnit object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfChargeUnits`. /// \return \c false otherwise. /// /// \sa KIM_CHARGE_UNIT_GetChargeUnit, /// kim_charge_unit_module::kim_get_charge_unit /// /// \since 2.0 int GetChargeUnit(int const index, ChargeUnit * const chargeUnit); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for ChargeUnit /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(ChargeUnit const & a, ChargeUnit const & b) const { return a.chargeUnitID < b.chargeUnitID; } }; // struct Comparator } // namespace CHARGE_UNIT } // namespace KIM #endif // KIM_CHARGE_UNIT_HPP_ kim-api-2.3.0-git/cpp/include/KIM_Collection.hpp000066400000000000000000000142511421473465500213530ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COLLECTION_HPP_ #define KIM_COLLECTION_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// Collection's supported by the %KIM API. /// /// The enumeration constants are contained in the COLLECTION namespace. /// /// \sa KIM_Collection, kim_collection_module::kim_collection_type /// /// \since 2.1 class Collection { public: /// \brief Integer identifying the specific Collection represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_Collection::collectionID, /// kim_collection_module::kim_collection_type::collection_id /// /// \since 2.1 int collectionID; /// \brief Create an uninitialized Collection object. /// /// \since 2.1 Collection(); /// \brief Create a Collection object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.1 Collection(int const id); /// \brief Create a Collection object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_Collection_FromString, kim_collection_module::kim_from_string /// /// \since 2.1 Collection(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// Collection's known to the %KIM API are found in the COLLECTION namespace. /// /// \sa KIM_Collection_Known, kim_collection_module::kim_known /// /// \since 2.1 bool Known() const; /// \brief Compares Collection objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_Collection_Equal, kim_collection_module::operator(.eq.) /// /// \since 2.1 bool operator==(Collection const & rhs) const; /// \brief Compares Collection objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_Collection_NotEqual, /// kim_collection_module::operator(.ne.) /// /// \since 2.1 bool operator!=(Collection const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the Collection object. /// /// \note If the Collection object does not correspond to a value /// defined by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_Collection_ToString, kim_collection_module::kim_to_string /// /// \since 2.1 std::string const & ToString() const; }; // class Collection /// \brief Contains the enumeration constants and the discovery routines for /// the Collection \ref extensible_enumeration "Extensible Enumeration". namespace COLLECTION { /// \brief The standard \c system Collection. /// /// The system wide collection. /// /// \sa KIM_COLLECTION_system, kim_collection_module::kim_collection_system /// /// \since 2.1 extern Collection const system; /// \brief The standard \c user Collection. /// /// The user collection. /// /// \sa KIM_COLLECTION_user, /// kim_collection_module::kim_collection_user /// /// \since 2.1 extern Collection const user; /// \brief The standard \c environmentVariable Collection. /// /// The environment variable collection. /// /// \sa KIM_COLLECTION_environmentVariable, /// kim_collection_module::kim_collection_environment_variable /// /// \since 2.1 extern Collection const environmentVariable; /// \brief The standard \c currentWorkingDirectory Collection. /// /// The current working directory collection. /// /// \sa KIM_COLLECTION_currentWorkingDirectory, /// kim_collection_module::kim_collection_currentWorkingDirectory /// /// \since 2.1 extern Collection const currentWorkingDirectory; /// \brief Get the number of standard Collection's defined by the %KIM API. /// /// \param[out] numberOfCollections The number of standard Collection's defined /// by the %KIM API. /// /// \sa KIM_COLLECTION_GetNumberOfCollections, /// kim_collection_module::kim_get_number_of_collections /// /// \since 2.1 void GetNumberOfCollections(int * const numberOfCollections); /// \brief Get the identity of each defined standard Collection. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// Collection. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] collection The Collection object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfCollections`. /// \return \c false otherwise. /// /// \sa KIM_COLLECTION_GetCollection, kim_collection_module::kim_get_collection /// /// \since 2.1 int GetCollection(int const index, Collection * const collection); /// \brief Structure provided for use with std::map. /// /// \since 2.1 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for /// Collection objects so that they can be stored in a std::map. /// /// \since 2.1 bool operator()(Collection const & a, Collection const & b) const { return a.collectionID < b.collectionID; } }; // struct Comparator } // namespace COLLECTION } // namespace KIM #endif // KIM_COLLECTION_HPP_ kim-api-2.3.0-git/cpp/include/KIM_CollectionItemType.hpp000066400000000000000000000153751421473465500230440ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #define KIM_COLLECTION_ITEM_TYPE_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// CollectionItemType's supported by the %KIM API. /// /// The enumeration constants are contained in the COLLECTION_ITEM_TYPE /// namespace. /// /// \sa KIM_CollectionItemType, /// kim_collection_item_type_module::kim_collection_item_type_type /// /// \since 2.1 class CollectionItemType { public: /// \brief Integer identifying the specific CollectionItemType represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_CollectionItemType::collectionItemTypeID, /// kim_collection_item_type_module::kim_collection_item_type_type::collection_item_type_id /// /// \since 2.1 int collectionItemTypeID; /// \brief Create an uninitialized CollectionItemType object. /// /// \since 2.1 CollectionItemType(); /// \brief Create a CollectionItemType object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.1 CollectionItemType(int const id); /// \brief Create a CollectionItemType object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_CollectionItemType_FromString, /// kim_collection_item_type_module::kim_from_string /// /// \since 2.1 CollectionItemType(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// CollectionItemType's known to the %KIM API are found in the /// COLLECTION_TIME_TYPE namespace. /// /// \sa KIM_CollectionItemType_Known, /// kim_collection_item_type_module::kim_known /// /// \since 2.1 bool Known() const; /// \brief Compares CollectionItemType objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_CollectionItemType_Equal, /// kim_collection_item_type_module::operator(.eq.) /// /// \since 2.1 bool operator==(CollectionItemType const & rhs) const; /// \brief Compares CollectionItemType objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_CollectionItemType_NotEqual, /// kim_collection_item_type_module::operator(.ne.) /// /// \since 2.1 bool operator!=(CollectionItemType const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the CollectionItemType object. /// /// \note If the CollectionItemType object does not correspond to a value /// defined by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_CollectionItemType_ToString, /// kim_collection_item_type_module::kim_to_string /// /// \since 2.1 std::string const & ToString() const; }; // class CollectionItemType /// \brief Contains the enumeration constants and the discovery routines for /// the CollectionItemType \ref extensible_enumeration "Extensible Enumeration". namespace COLLECTION_ITEM_TYPE { /// \brief The standard \c modelDriver CollectionItemType. /// /// The item is a model driver. /// /// \sa KIM_COLLECTION_ITEM_TYPE_modelDriver, /// kim_collection_item_type_module::kim_collection_item_type_model_driver /// /// \since 2.1 extern CollectionItemType const modelDriver; /// \brief The standard \c portableModel CollectionItemType. /// /// The item is a portable model. /// /// \sa KIM_COLLECTION_ITEM_TYPE_portableModel, /// kim_collection_item_type_module::kim_collection_item_type_portable_model /// /// \since 2.1 extern CollectionItemType const portableModel; /// \brief The standard \c simulatorModel CollectionItemType. /// /// The item is a simulator model. /// /// \sa KIM_COLLECTION_ITEM_TYPE_simulatorModel, /// kim_collection_item_type_module::kim_collection_item_type_simulator_model /// /// \since 2.1 extern CollectionItemType const simulatorModel; /// \brief Get the number of standard CollectionItemType's defined by the %KIM /// API. /// /// \param[out] numberOfCollectionItemTypes The number of standard /// CollectionItemType's defined by the %KIM API. /// /// \sa KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes, /// kim_collection_item_type_module::kim_get_number_of_collection_item_types /// /// \since 2.1 void GetNumberOfCollectionItemTypes(int * const numberOfCollectionItemTypes); /// \brief Get the identity of each defined standard CollectionItemType. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// CollectionItemType. This index ordering is only guaranteed to /// be stable during the lifetime of the current process. /// \param[out] collectionItemType The CollectionItemType object associated with /// \c index. /// /// \return \c true if `index < 0` or `index >= numberOfCollectionItemTypes`. /// \return \c false otherwise. /// /// \sa KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType, /// kim_collection_item_type_module::kim_get_collection_item_type /// /// \since 2.1 int GetCollectionItemType(int const index, CollectionItemType * const collectionItemType); /// \brief Structure provided for use with std::map. /// /// \since 2.1 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for /// CollectionItemType objects so that they can be stored in a std::map. /// /// \since 2.1 bool operator()(CollectionItemType const & a, CollectionItemType const & b) const { return a.collectionItemTypeID < b.collectionItemTypeID; } }; // struct Comparator } // namespace COLLECTION_ITEM_TYPE } // namespace KIM #endif // KIM_COLLECTION_ITEM_TYPE_HPP_ kim-api-2.3.0-git/cpp/include/KIM_Collections.hpp000066400000000000000000000634541421473465500215470ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COLLECTIONS_HPP_ #define KIM_COLLECTIONS_HPP_ #include namespace KIM { // Forward declarations class LogVerbosity; class Collection; class CollectionItemType; class CollectionsImplementation; /// \brief Provides the interface to the %KIM API %Collections and is meant to /// be used by simulators. /// /// The %KIM API defines interfaces to various types of "items" /// (KIM::CollectionItemType) and these items are organized and stored in /// various "collections" (KIM::Collection) on the user's system. Items are /// generally installed to or removed from the collections by using the \c /// kim-api-collections-management utility, and the %KIM API/PMI and %KIM /// API/SMI find items within the collections using the KIM::Collections /// interface. Typically, the collections are associated with different levels /// of user permissions on the system. The KIM::COLLECTION::system collection /// is available to all users on the system and is managed by the system /// administrator and cannot be changed by users without administrator /// privileges. The KIM::COLLECTION::user collection is specific to each user /// and the use has full privileges to manage the collection. The /// KIM::COLLECTION::environmentVariable and the /// KIM::COLLECTION::currentWorkingDirectory collections allow users more /// dynamic flexibility to manage and store items for special purposes. /// /// Each collection consists of a set of items organized by their item type /// (KIM::CollectionItemType). There are currently three item types: /// KIM::COLLECTION_ITEM_TYPE::portableModel represents %KIM Portable Models /// that can be used with any simulator that supports the %KIM API/PMI; /// KIM::COLLECTION_ITEM_TYPE::simulatorModel represents the %KIM Simulator /// Models that can be used with a specific simulator that supports the %KIM /// API/SMI; and KIM::COLLECTION_ITEM_TYPE::modelDriver represents %KIM %Model /// Drivers that are libraries of code that can be used by multiple Portable /// Models to help reduce code duplication. The KIM::Collections interface /// provides programatic access to the contents and system settings for the /// %KIM API collections and items stored within them. The contents and /// settings of the collections can change during the lifetime of a /// KIM::Collections object (due to installation or removal of items by other /// processes on the machine and/or changes to environment variables or the /// configuration file). Therefore, when lists of information about the /// collections are requested (via a "CacheListOf...()" routine), the /// KIM::Collections interface first creates a cache of the list and then /// provides access to the cached list via a getter ("Get...()") routine. The /// cached list is only updated when the simulator makes another request for /// the list (via a "CacheListOf...()" routine). /// /// Items in the %KIM API collections are generally referred to by name. An /// item name is required to be a valid C-identifier (no other restrictions are /// imposed by the %KIM API). Items in different collections can have the same /// name and items of different type can have the same name. However, this /// should generally be avoided. Typically, an item is referred to by /// specifying its type and name. In such cases the %KIM API will search /// through the %KIM API collections in a specific order (\anchor collection_search_order first the /// KIM::COLLECTION::currentWorkingDirectory, then /// KIM::COLLECTION::environmentVariable, then KIM::COLLECTION::user, and /// finally KIM::COLLECTION::system) and return the first occurrence of an item /// with the requested type and name that is found. In some cases only the /// name of the desired item is known, and Collections::GetItemType must be /// used first to determine the item's type. The Collections::GetItemType /// routine will search through each collection (in the order described just /// \ref collection_search_order "above") and through each item type within /// each collection in a specific order (\anchor collection_item_type_search_order first the /// KIM::COLLECTION_ITEM_TYPE::portableModel type, then the /// KIM::COLLECTION_ITEM_TYPE::simulatorModel type, and finally the /// KIM::COLLECTION_ITEM_TYPE::modelDriver type) and return the first /// occurrence of an item with the requested name that is found. /// /// \sa KIM_Collections, kim_collections_module::kim_collections_handle_type /// /// \since 2.1 class Collections { public: /// \brief Create a new %KIM API Collections object. /// /// \param[out] collections Pointer to the newly created Collections object. /// /// \return \c true if the %KIM API is unable to allocate a new log object. /// \return \c false otherwise. /// /// \post \c `collections == NULL` if an error occurs. /// /// \sa KIM_Collections_Create, kim_collections_module::kim_collections_create /// /// \since 2.1 static int Create(Collections ** const collections); /// \brief Destroy a previously Collections::Create'd object. /// /// \param[inout] collections Pointer to the Collections object. /// /// \pre \c *collections points to a previously created %KIM API Collections /// object. /// /// \post `*collections == NULL`. /// /// \sa KIM_Collections_Destroy, /// kim_collections_module::kim_collections_destroy /// /// \since 2.1 static void Destroy(Collections ** const collections); /// \brief Get the KIM::CollectionItemType of the item in the %KIM API /// collections with a specific name. /// /// Searches for an item with the given name in the %KIM API collections and /// item types (using the standard order for \ref collection_search_order "collections" and \ref collection_item_type_search_order "item types"). /// /// \param[in] itemName The item name to be found. /// \param[out] itemType The KIM::CollectionItemType of the item. /// /// \return \c true if an item with the specificed name cannot be found. /// \return \c false otherwise. /// /// \post \c itemType is unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemType, /// kim_collections_module::kim_get_item_type /// /// \since 2.1 int GetItemType(std::string const & itemName, CollectionItemType * const itemType) const; /// \brief Get the item's library file name and its KIM::Collection. /// /// \param[in] itemType The KIM::CollectionItemType of the item. /// \param[in] itemName The name of the item. /// \param[out] fileName The absolute file and path name of the item's /// library. /// \param[out] collection The KIM::Collection in which the item was found. /// /// \return \c true if \c itemType is unknown. /// \return \c true if a item with the specified type and name cannot be /// found. /// \return \c false otherwise. /// /// \pre \c fileName and \c collection may be \c NULL if the corresponding /// value is not needed. /// /// \post \c fileName and \c collection are unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemLibraryFileNameAndCollection, /// kim_collections_module::kim_get_item_library_file_name_and_collection /// /// \since 2.1 int GetItemLibraryFileNameAndCollection(CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName, Collection * const collection) const; /// \brief Cache a list of an item's metadata files. /// /// \param[in] itemType The KIM::CollectionItemType of the item. /// \param[in] itemName The name of the item. /// \param[out] extent The number of metadata files in the list. /// /// \return \c true if \c itemType is unknown. /// \return \c true if the list is not successfully cached for some reason. /// \return \c false otherwise. /// /// \post `extent == 0` and the cached list is empty if an error occurs. /// /// \sa KIM_Collections_CacheListOfItemMetadataFiles, /// kim_collections_module::kim_cache_list_of_item_metadata_files /// /// \since 2.1 int CacheListOfItemMetadataFiles(CollectionItemType const itemType, std::string const & itemName, int * const extent); /// \brief Get the name and content of one of an item's metadata files. /// /// Provide access to the specified metadata file's name and raw data. If /// there are no embedded NULL characters in the raw data, the file contents /// are also provided as a string, for convenience. /// /// \param[in] index Zero-based index for the metadata file of interest. /// \param[out] fileName The basename (file name without path) of the /// metadata file. /// \param[out] fileLength The length of the metadata file. /// \param[out] fileRawData The raw metadata file content, as a contiguous /// block of memory of length \c fileLength. /// \param[out] availableAsString An integer that is set to \c true if the /// metadata file has no embedded \c NULL characters, and set to /// \c false otherwise. /// \param[out] fileString The contents of the metadata file as a string, if /// `availableAsString == true`, \c NULL otherwise. /// /// \note String pointers obtained from this routine are valid until the next /// call to Collections::CacheListOfItemMetadataFiles or the KIM::Collections /// object is Collections::Destroy'd. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \pre Collections::CacheListOfItemMetadataFiles must have been /// successfully executed before Collections::GetItemMetadataFile is /// called. /// /// \pre \c fileName, \c fileLength, \c fileRawData, \c availableAsString, /// and \c fileString may be \c NULL if the corresponding value is not /// needed. /// /// \post \c fileName, \c fileLength, \c fileRawData, \c availableAsString, /// \c fileString are unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemMetadataFile, /// kim_collections_module::kim_get_item_metadata_file_length, /// kim_collections_module::kim_get_item_metadata_file_values /// /// \since 2.1 int GetItemMetadataFile(int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const; /// \brief Cache a list of all item names of a specific type in the %KIM API /// collections. /// /// \param[in] itemType The KIM::CollectionItemType of the items. /// \param[out] extent The number of item names in the list. /// /// \return \c true if \c itemType is unknown. /// \return \c false otherwise. /// /// \post `extent == 0` and the cached list is empty if an error occurs. /// /// \sa KIM_Collections_CacheListOfItemNamesByType, /// kim_collections_module::kim_cache_list_of_item_names_by_type /// /// \since 2.1 int CacheListOfItemNamesByType(CollectionItemType const itemType, int * const extent); /// \brief Get the name of an item from the cached list. /// /// \param[in] index Zero-based index for the item name of interest. /// \param[out] itemName The item's name. /// /// \note String pointers obtained from this routine are valid until the next /// call to Collections::CacheListOfItemNamesByType or the KIM::Collections /// object is Collections::Destroy'd. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \pre Collections::CacheListOfItemNamesByType must have been successfully /// executed before Collections::GetItemNameByType is called. /// /// \post \c itemName is unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemNameByType, /// kim_collections_module::kim_get_item_name_by_type /// /// \since 2.1 int GetItemNameByType(int const index, std::string const ** const itemName) const; /// \brief Cache a list of all item names of a specific type in a specific /// collection. /// /// \param[in] collection The KIM::Collection of the items. /// \param[in] itemType The KIM::CollectionItemType of the items. /// \param[out] extent The number of item names in the list. /// /// \return \c true if \c collection or \c itemType are unknown. /// \return \c false otherwise. /// /// \post `extent == 0` and the cached list is empty if an error occurs. /// /// \sa KIM_Collections_CacheListOfItemNamesByCollectionAndType, /// kim_collections_module::kim_cache_list_of_item_names_by_collection_and_type /// /// \since 2.1 int CacheListOfItemNamesByCollectionAndType(Collection const collection, CollectionItemType const itemType, int * const extent); /// \brief Get the name of an item from the cached list. /// /// \param[in] index Zero-based index for the item name of interest. /// \param[out] itemName The item's name. /// /// \note String pointers obtained from this routine are valid until the next /// call to Collections::CacheListOfItemNamesByCollectionAndType or the /// KIM::Collections object is Collections::Destroy'd. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \pre Collections::CacheListOfItemNamesByCollectionAndType must have been /// successfully executed before /// Collections::GetItemNameByCollectionAndType is called. /// /// \post \c itemName is unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemNameByCollectionAndType, /// kim_collections_module::kim_get_item_name_by_collection_and_type /// /// \since 2.1 int GetItemNameByCollectionAndType(int const index, std::string const ** const itemName) const; /// \brief Get the item's library file name. /// /// \param[in] collection The KIM::Collection of the item. /// \param[in] itemType The KIM::CollectionItemType of the item. /// \param[in] itemName The name of the item. /// \param[out] fileName The absolute file and path name of the item's /// library. /// /// \return \c true if \c collection or \c itemType are unknown. /// \return \c true if a item with the specified type and name cannot be /// found in the specified collection. /// \return \c false otherwise. /// /// \post \c fileName is unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemLibraryFileNameByCollectionAndType, /// kim_collections_module::kim_get_item_library_file_name_by_collection_and_type /// /// \since 2.1 int GetItemLibraryFileNameByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName) const; /// \brief Cache a list of an item's metadata files. /// /// \param[in] collection The KIM::Collection of the item. /// \param[in] itemType The KIM::CollectionItemType of the item. /// \param[in] itemName The name of the item. /// \param[out] extent The number of metadata files in the list. /// /// \return \c true if \c collection or \c itemType are unknown. /// \return \c true if the list is not successfully cached for some reason. /// \return \c false otherwise. /// /// \post `extent == 0` and the cached list is empty if an error occurs. /// /// \sa KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType, /// kim_collections_module::kim_cache_list_of_item_metadata_files_by_collection_and_type /// /// \since 2.1 int CacheListOfItemMetadataFilesByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, int * const extent); /// \brief Get the name and content of one of an item's metadata files. /// /// Provide access to the specified metadata file's name and raw data. If /// there are no embedded NULL characters in the raw data, the file contents /// are also provided as a string, for convenience. /// /// \param[in] index Zero-based index for the metadata file of interest. /// \param[out] fileName The basename (file name without path) of the /// metadata file. /// \param[out] fileLength The length of the metadata file. /// \param[out] fileRawData The raw metadata file content, as a contiguous /// block of memory of length \c fileLength. /// \param[out] availableAsString An integer that is set to \c true if the /// metadata file has no embedded \c NULL characters, and set to /// \c false otherwise. /// \param[out] fileString The contents of the metadata file as a string, if /// `availableAsString == true`, \c NULL otherwise. /// /// \note String pointers obtained from this routine are valid until the next /// call to Collections::CacheListOfItemMetadataFilesByCollectionAndType or /// the KIM::Collections object is Collections::Destroy'd. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \pre Collections::CacheListOfItemMetadataFilesByCollectionAndType must /// have been successfully executed before /// Collections::GetItemMetadataFileByCollectionAndType is called. /// /// \pre \c fileName, \c fileLength, \c fileRawData, \c availableAsString, /// and \c fileString may be \c NULL if the corresponding value is not /// needed. /// /// \post \c fileName, \c fileLength, \c fileRawData, \c availableAsString, /// \c fileString are unchanged if an error occurs. /// /// \sa KIM_Collections_GetItemMetadataFileByCollectionAndType, /// kim_collections_module::kim_get_item_metadata_file_length_by_collection_and_type, /// kim_collections_module::kim_get_item_metadata_file_values_by_collection_and_type /// /// \since 2.1 int GetItemMetadataFileByCollectionAndType( int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const; /// \brief Get the %KIM API project name and full Semantic Version string. /// /// The %KIM API project name and version string are controlled by CMake /// settings during the configuration process. /// /// \note String pointers obtained from this routine are valid until the /// KIM::Collections object is Collections::Destroy'd. /// /// \param[out] projectName The project name. /// \param[out] semVer The complete Semantic Version string. /// /// \pre \c projectName and \c semVer may be \c NULL if the corresponding /// value is not needed. /// /// \sa KIM_Collections_GetProjectNameAndSemVer, /// kim_collections_module::kim_get_project_name_and_sem_ver /// /// \since 2.1 void GetProjectNameAndSemVer(std::string const ** const projectName, std::string const ** const semVer) const; /// \brief Get the names of environment variables that store configuration /// settings for the KIM::COLLECTION::environmentVariable collection. /// /// \param[in] itemType The KIM::CollectionItemType of interest. /// \param[out] name The environment variable name. /// /// \return \c true if \c itemType is unknown. /// \return \c false otherwise. /// /// \post \c name is unchanged if an error occurs. /// /// \sa KIM_Collections_GetEnvironmentVariableName, /// kim_collections_module::kim_get_environment_variable_name /// /// \since 2.1 int GetEnvironmentVariableName(CollectionItemType const itemType, std::string const ** const name) const; /// \brief Get the name and value of the environment variable that stores the /// name of the %KIM API user configuration file. /// /// The %KIM API user configuration file contains configuration settings for /// the KIM::COLLECTION::user collection. /// /// \note String pointers obtained from this routine are valid until the next /// call to Collections::GetConfigurationFileEnvironmentVariable or the /// KIM::Collections object is Collections::Destroy'd. /// /// \param[out] name The name of the environment variable. /// \param[out] value The current value of the environment variable. /// /// \pre \c name and \c value may be \c NULL if the corresponding value is /// not needed. /// /// \sa KIM_Collections_GetConfigurationFileEnvironmentVariable, /// kim_collections_module::kim_get_configuration_file_environment_variable /// /// \since 2.1 void GetConfigurationFileEnvironmentVariable( std::string const ** const name, std::string const ** const value) const; /// \brief Get the absolute file and path name of the %KIM API user /// configuration file. /// /// The %KIM API user configuration file contains configuration settings for /// the KIM::COLLECTION::user collection. /// /// \note String pointer obtained from this routine are valid until the next /// call to Collections::GetConfigurationFileName or the KIM::Collections /// object is Collections::Destroy'd. /// /// \param[out] fileName The absolute file and path name of the configuration /// file. /// /// \sa KIM_Collections_GetConfigurationFileName, /// kim_collections_module::kim_get_configuration_file_name /// /// \since 2.1 void GetConfigurationFileName(std::string const ** const fileName) const; /// \brief Cache a list of directory names where a specific %KIM API /// collection stores library files for a specific item type. /// /// \param[in] collection The KIM::Collection of the items. /// \param[in] itemType The KIM::CollectionItemType of the items. /// \param[out] extent The number of directory names in the list. /// /// \return \c true if \c collection or \c itemType are unknown. /// \return \c true if the list is not successfully cached for some reason. /// \return \c false otherwise. /// /// \post `extent == 0` and the cached list is empty if an error occurs. /// /// \sa KIM_Collections_CacheListOfDirectoryNames, /// kim_collections_module::kim_cache_list_of_directory_names /// /// \since 2.1 int CacheListOfDirectoryNames(Collection const collection, CollectionItemType const itemType, int * const extent); /// \brief Get the name of a directory from the cached list. /// /// \param[in] index Zero-based index for the directory name of interest. /// \param[out] directoryName The directory's name. /// /// \note String pointers obtained from this routine are valid until the next /// call to Collections::CacheListOfDirectoryNames or the KIM::Collections /// object is Collections::Destroy'd. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \pre Collections::CacheListOfDirectoryNames must have been successfully /// executed before Collections::GetDirectoryName is called. /// /// \post \c directoryName is unchanged if an error occurs. /// /// \sa KIM_Collections_GetDirectoryName, /// kim_collections_module::kim_get_directory_name /// /// \since 2.1 int GetDirectoryName(int const index, std::string const ** const directoryName) const; /// \brief Set the identity of the Log object /// associated with the Collections object. /// /// \param[in] logID String identifying the Collections object's Log object. /// /// \sa KIM_Collections_SetLogID, kim_collections_module::kim_set_log_id /// /// \since 2.1 void SetLogID(std::string const & logID); /// \brief Push a new LogVerbosity onto the Collections object's Log object /// verbosity stack. /// /// \param[in] logVerbosity A LogVerbosity value. /// /// \sa KIM_Collections_PushLogVerbosity, /// kim_collections_module::kim_push_log_verbosity /// /// \since 2.1 void PushLogVerbosity(LogVerbosity const logVerbosity); /// \brief Pop a LogVerbosity from the Collections object's Log object /// verbosity stack. /// /// \sa KIM_Collections_PopLogVerbosity, /// kim_collections_module::kim_pop_log_verbosity /// /// \since 2.1 void PopLogVerbosity(); private: // do not allow copy constructor or operator= Collections(Collections const &); void operator=(Collections const &); Collections(); ~Collections(); CollectionsImplementation * pimpl; }; // class Collections } // namespace KIM #endif // KIM_COLLECTIONS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ComputeArgumentName.hpp000066400000000000000000000230241421473465500231760ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #define KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include namespace KIM { // Forward declaration class DataType; /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// ComputeArgumentName's supported by the %KIM API. /// /// The enumeration constants are contained in the COMPUTE_ARGUMENT_NAME /// namespace. /// /// \sa KIM_ComputeArgumentName, /// kim_compute_argument_name_module::kim_compute_argument_name_type /// /// \since 2.0 class ComputeArgumentName { public: /// \brief Integer identifying the specific ComputeArgumentName represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_ComputeArgumentName::computeArgumentNameID, /// kim_compute_argument_name_module::kim_compute_argument_name_type::compute_argument_name_id /// /// \since 2.0 int computeArgumentNameID; /// \brief Create an uninitialized ComputeArgumentName object. /// /// \since 2.0 ComputeArgumentName(); /// \brief Create a ComputeArgumentName object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 ComputeArgumentName(int const id); /// \brief Create a ComputeArgumentName object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_ComputeArgumentName_FromString, /// kim_compute_argument_name_module::kim_from_string /// /// \since 2.0 ComputeArgumentName(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// ComputeArgumentName's known to the %KIM API are found in the /// COMPUTE_ARGUMENT_NAME namespace. /// /// \sa KIM_ComputeArgumentName_Known, /// kim_compute_argument_name_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares ComputeArgumentName objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_ComputeArgumentName_Equal, /// kim_compute_argument_name_module::operator(.eq.) /// /// \since 2.0 bool operator==(ComputeArgumentName const & rhs) const; /// \brief Compares ComputeArgumentName objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_ComputeArgumentName_NotEqual, /// kim_compute_argument_name_module::operator(.ne.) /// /// \since 2.0 bool operator!=(ComputeArgumentName const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the ComputeArgumentName object. /// /// \note If the ComputeArgumentName object does not correspond to a value /// defined by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_ComputeArgumentName_ToString, /// kim_compute_argument_name_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class ComputeArgumentName /// \brief Contains the enumeration constants and the discovery routines for /// the ComputeArgumentName \ref extensible_enumeration /// "Extensible Enumeration". namespace COMPUTE_ARGUMENT_NAME { /// \brief The standard \c numberOfParticles argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles, /// kim_compute_argument_name_module::kim_compute_argument_name_number_of_particles /// /// \since 2.0 extern ComputeArgumentName const numberOfParticles; /// \brief The standard \c particleSpeciesCodes argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, /// kim_compute_argument_name_module::kim_compute_argument_name_particle_species_codes /// /// \since 2.0 extern ComputeArgumentName const particleSpeciesCodes; /// \brief The standard \c particleContributing argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_particleContributing, /// kim_compute_argument_name_module::kim_compute_argument_name_particle_contributing /// /// \since 2.0 extern ComputeArgumentName const particleContributing; /// \brief The standard \c coordinates argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_coordinates, /// kim_compute_argument_name_module::kim_compute_argument_name_coordinates /// /// \since 2.0 extern ComputeArgumentName const coordinates; /// \brief The standard \c partialEnergy argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, /// kim_compute_argument_name_module::kim_compute_argument_name_partial_energy /// /// \since 2.0 extern ComputeArgumentName const partialEnergy; /// \brief The standard \c partialForces argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_partialForces, /// kim_compute_argument_name_module::kim_compute_argument_name_partial_forces /// /// \since 2.0 extern ComputeArgumentName const partialForces; /// \brief The standard \c partialParticleEnergy argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, /// kim_compute_argument_name_module::kim_compute_argument_name_partial_particle_energy /// /// \since 2.0 extern ComputeArgumentName const partialParticleEnergy; /// \brief The standard \c partialVirial argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_partialVirial, /// kim_compute_argument_name_module::kim_compute_argument_name_partial_virial /// /// \since 2.0 extern ComputeArgumentName const partialVirial; /// \brief The standard \c partialParticleVirial argument. /// /// \todo Add more detailed description of argument. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial, /// kim_compute_argument_name_module::kim_compute_argument_name_partial_particle_virial /// /// \since 2.0 extern ComputeArgumentName const partialParticleVirial; /// \brief Get the number of standard ComputeArgumentName's defined by the %KIM /// API. /// /// \param[out] numberOfComputeArgumentNames The number of standard /// ComputeArgumentName's defined by the %KIM API. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames, /// kim_compute_argument_name_module::kim_get_number_of_compute_argument_names /// /// \since 2.0 void GetNumberOfComputeArgumentNames(int * const numberOfComputeArgumentNames); /// \brief Get the identity of each defined standard ComputeArgumentName. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// ComputeArgumentName. This index ordering is only guaranteed to /// be stable during the lifetime of the current process. /// \param[out] computeArgumentName The ComputeArgumentName object associated /// with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfComputeArgumentNames`. /// \return \c false otherwise. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName, /// kim_compute_argument_name_module::kim_get_compute_argument_name /// /// \since 2.0 int GetComputeArgumentName(int const index, ComputeArgumentName * const computeArgumentName); /// \brief Get the DataType of each defined standard ComputeArgumentName. /// /// \param[in] computeArgumentName The ComputeArgumentName object of interest. /// \param[out] dataType The DataType of the associated ComputeArgumentName. /// /// \return \c true if \p computeArgumentName is "unknown". /// \return \c false otherwise. /// /// \sa KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType, /// kim_compute_argument_name_module::kim_get_compute_argument_data_type /// /// \since 2.0 int GetComputeArgumentDataType(ComputeArgumentName const computeArgumentName, DataType * const dataType); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for /// ComputeArgumentsName objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(ComputeArgumentName const & a, ComputeArgumentName const & b) const { return a.computeArgumentNameID < b.computeArgumentNameID; } }; // struct Comparator } // namespace COMPUTE_ARGUMENT_NAME } // namespace KIM #endif // KIM_COMPUTE_ARGUMENT_NAME_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ComputeArguments.hpp000066400000000000000000000213541421473465500225640ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COMPUTE_ARGUMENTS_HPP_ #define KIM_COMPUTE_ARGUMENTS_HPP_ #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" // IWYU pragma: export #endif namespace KIM { // Forward declarations class LogVerbosity; class LanguageName; class ComputeArgumentName; class ComputeCallbackName; class SupportStatus; class ComputeArgumentsImplementation; /// \brief Provides the primary interface to a %KIM API ComputeArguments object /// and is meant to be used by simulators. /// /// \sa KIM_ComputeArguments, /// kim_compute_arguments_module::kim_compute_arguments_handle_type /// /// \since 2.0 class ComputeArguments { public: /// \brief Get the SupportStatus of a ComputeArgumentName. /// /// \param[in] computeArgumentName The ComputeArgumentName of interest. /// \param[out] supportStatus The Model's corresponding SupportStatus. /// /// \return \c true if \c computeArgumentName is unknown. /// \return \c false otherwise. /// /// \sa KIM_ComputeArguments_GetArgumentSupportStatus, /// kim_compute_arguments_module::kim_get_argument_support_status /// /// \since 2.0 int GetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus * const supportStatus) const; /// \brief Get the SupportStatus of a ComputeCallbackName. /// /// \param[in] computeCallbackName The ComputeCallbackName of interest. /// \param[out] supportStatus The Model's corresponding SupportStatus. /// /// \return \c true if \c computeCallbackName is unknown. /// \return \c false otherwise. /// /// \sa KIM_ComputeArguments_GetCallbackSupportStatus, /// kim_compute_arguments_module::kim_get_callback_support_status /// /// \since 2.0 int GetCallbackSupportStatus(ComputeCallbackName const computeCallbackName, SupportStatus * const supportStatus) const; /// \brief Set the data pointer for a ComputeArgumentName. /// /// \todo Add more detailed description what it means to provide a NULL or /// non-NULL value for various SupportStatus'es. /// /// \param[in] computeArgumentName The ComputeArgumentName of interest. /// \param[in] ptr The data pointer. /// /// \return \c true if \c computeArgumentName is unknown. /// \return \c true if `ptr != NULL` and `computeArgumentName == /// SUPPORT_STATUS::notSupported`. /// \return \c false otherwise. /// /// \sa KIM_ComputeArguments_SetArgumentPointerInteger, /// KIM_ComputeArguments_SetArgumentPointerDouble, /// kim_compute_arguments_module::kim_set_argument_pointer /// /// \since 2.0 int SetArgumentPointer(ComputeArgumentName const computeArgumentName, int const * const ptr); /// \overload int SetArgumentPointer(ComputeArgumentName const computeArgumentName, int * const ptr); /// \overload int SetArgumentPointer(ComputeArgumentName const computeArgumentName, double const * const ptr); /// \overload int SetArgumentPointer(ComputeArgumentName const computeArgumentName, double * const ptr); /// \brief Set the function pointer for a ComputeCallbackName. /// /// \todo Add more detailed description what it means to provide a NULL or /// non-NULL value for various SupportStatus'es. Also, describe dataObject. /// /// \param[in] computeCallbackName The ComputeCallbackName of interest. /// \param[in] languageName The LanguageName of the callback. /// \param[in] fptr The function pointer. /// \param[in] dataObject The data pointer associated with the callback. /// /// \return \c true if \c computeCallbackName is unknown. /// \return \c true if `fptr != NULL` and `computeCallbackName == /// SUPPORT_STATUS::notSupported`. /// \return \c false otherwise. /// /// \sa KIM_ComputeArguments_SetCallbackPointer, /// kim_compute_arguments_module::kim_set_callback_pointer /// /// \since 2.0 int SetCallbackPointer(ComputeCallbackName const computeCallbackName, LanguageName const languageName, Function * const fptr, void * const dataObject); /// \brief Determine if non-NULL pointers have been set for all /// ComputeArgumentName's and ComputeCallbackName's with SupportStatus /// values of SUPPORT_STATUS::requiredByAPI or SUPPORT_STATUS::required. /// /// \param[out] result Is \c true if all such arguments and callbacks have /// non-NULL pointers, and is \c false otherwise. /// /// \sa KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent, /// kim_compute_arguments_module::kim_are_all_required_present /// /// \since 2.0 void AreAllRequiredArgumentsAndCallbacksPresent(int * const result) const; /// \brief Set the \ref cache_buffer_pointers "Simulator's buffer pointer" /// within the ComputeArguments object. /// /// The simulator buffer pointer may be used by the simulator to associate /// a memory buffer with the ComputeArguments object. /// /// \param[in] ptr The simulator buffer data pointer. /// /// \sa KIM_ComputeArguments_SetSimulatorBufferPointer, /// kim_compute_arguments_module::kim_set_simulator_buffer_pointer /// /// \since 2.0 void SetSimulatorBufferPointer(void * const ptr); /// \brief Get the \ref cache_buffer_pointers "Simulator's buffer pointer" /// from the ComputeArguments object. /// /// \param[out] ptr The simulator buffer data pointer. /// /// \note `ptr == NULL` if the simulator has not previously called /// ComputeArguments::SetSimulatorBufferPointer. /// /// \sa KIM_ComputeArguments_GetSimulatorBufferPointer, /// kim_compute_arguments_module::kim_get_simulator_buffer_pointer /// /// \since 2.0 void GetSimulatorBufferPointer(void ** const ptr) const; /// \brief Get a string representing the internal state of the /// ComputeArguments object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ComputeArguments_ToString, /// kim_compute_arguments_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; /// \brief Set the identity of the Log object associated with the /// ComputeArguments object. /// /// \param[in] logID String identifying the ComputeArguments object's Log /// object. /// /// \sa KIM_ComputeArguments_SetLogID, /// kim_compute_arguments_module::kim_set_log_id /// /// \since 2.0 void SetLogID(std::string const & logID); /// \brief Push a new LogVerbosity onto the ComputeArguments object's Log /// object verbosity stack. /// /// \param[in] logVerbosity A LogVerbosity value. /// /// \sa KIM_ComputeArguments_PushLogVerbosity, /// kim_compute_arguments_module::kim_push_log_verbosity /// /// \since 2.0 void PushLogVerbosity(LogVerbosity const logVerbosity); /// \brief Pop a LogVerbosity from the ComputeArguments object's Log object /// verbosity stack. /// /// \sa KIM_ComputeArguments_PopLogVerbosity, /// kim_compute_arguments_module::kim_pop_log_verbosity /// /// \since 2.0 void PopLogVerbosity(); /// \brief Allows Model objects to directly access private member data of a /// ComputeArguments object. /// /// \note This has no practical effect on \e users of the %KIM API. /// /// \since 2.0 friend class ModelImplementation; private: // do not allow copy constructor or operator= ComputeArguments(ComputeArguments const &); void operator=(ComputeArguments const &); ComputeArguments(); ~ComputeArguments(); ComputeArgumentsImplementation * pimpl; }; // class ComputeArguments } // namespace KIM #endif // KIM_COMPUTE_ARGUMENTS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ComputeCallbackName.hpp000066400000000000000000000166001421473465500231120ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #define KIM_COMPUTE_CALLBACK_NAME_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// ComputeCallbackName's supported by the %KIM API. /// /// The enumeration constants are contained in the COMPUTE_CALLBACK_NAME /// namespace. /// /// \sa KIM_ComputeCallbackName, /// kim_compute_callback_name_module::kim_compute_callback_name_type /// /// \since 2.0 class ComputeCallbackName { public: /// \brief Integer identifying the specific ComputeCallbackName represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_ComputeCallbackName::computeCallbackNameID, /// kim_compute_callback_name_module::kim_compute_callback_name_type::compute_callback_name_id /// /// \since 2.0 int computeCallbackNameID; /// \brief Create an uninitialized ComputeCallbackName object. /// /// \since 2.0 ComputeCallbackName(); /// \brief Create a ComputeCallbackName object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 ComputeCallbackName(int const id); /// \brief Create a ComputeCallbackName object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_ComputeCallbackName_FromString, /// kim_compute_callback_name_module::kim_from_string /// /// \since 2.0 ComputeCallbackName(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// ComputeCallbackName's known to the %KIM API are found in the /// COMPUTE_CALLBACK_NAME namespace. /// /// \sa KIM_ComputeCallbackName_Known, /// kim_compute_callback_name_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares ComputeCallbackName objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_ComputeCallbackName_Equal, /// kim_compute_callback_name_module::operator(.eq.) /// /// \since 2.0 bool operator==(ComputeCallbackName const & rhs) const; /// \brief Compares ComputeCallbackName objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_ComputeCallbackName_NotEqual, /// kim_compute_callback_name_module::operator(.ne.) /// /// \since 2.0 bool operator!=(ComputeCallbackName const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the ComputeCallbackName object. /// /// \note If the ComputeCallbackName object does not correspond to a value /// defined by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_ComputeCallbackName_ToString, /// kim_compute_callback_name_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class ComputeCallbackName /// \brief Contains the enumeration constants and the discovery routines for /// the ComputeCallbackName \ref extensible_enumeration /// "Extensible Enumeration". namespace COMPUTE_CALLBACK_NAME { /// \brief The standard \c GetNeighborList callback. /// /// The C++ prototype for this routine is GetNeighborListFunction(). The C /// prototype for this routine is KIM_GetNeighborListFunction(). /// /// \todo Add more detailed description of callback. /// /// \sa KIM_COMPUTE_CALLBACK_NAME_GetNeighborList, /// kim_compute_callback_name_module::kim_compute_callback_name_get_neighbor_list /// /// \since 2.0 extern ComputeCallbackName const GetNeighborList; /// \brief The standard \c ProcessDEDrTerm callback. /// /// The C++ prototype for this routine is ProcessDEDrTermFunction(). The C /// prototype for this routine is KIM_ProcessDEDrTermFunction(). /// /// \todo Add more detailed description of callback. /// /// \sa KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, /// kim_compute_callback_name_module::kim_compute_callback_name_process_dedr_term /// /// \since 2.0 extern ComputeCallbackName const ProcessDEDrTerm; /// \brief The standard \c ProcessD2EDr2Term callback. /// /// The C++ prototype for this routine is ProcessD2EDr2TermFunction(). The C /// prototype for this routine is KIM_ProcessD2EDr2TermFunction(). /// /// \todo Add more detailed description of callback. /// /// \sa KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, /// kim_compute_callback_name_module::kim_compute_callback_name_process_d2edr2_term /// /// \since 2.0 extern ComputeCallbackName const ProcessD2EDr2Term; /// \brief Get the number of standard ComputeCallbackName's defined by the %KIM /// API. /// /// \param[out] numberOfComputeCallbackNames The number of standard /// ComputeCallbackName's defined by the %KIM API. /// /// \sa KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames, /// kim_compute_callback_name_module::kim_get_number_of_compute_callback_names /// /// \since 2.0 void GetNumberOfComputeCallbackNames(int * const numberOfComputeCallbackNames); /// \brief Get the identity of each defined standard ComputeCallbackName. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// ComputeCallbackName. This index ordering is only guaranteed to /// be stable during the lifetime of the current process. /// \param[out] computeCallbackName The ComputeCallbackName object associated /// with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfComputeCallbackNames`. /// \return \c false otherwise. /// /// \sa KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName, /// kim_compute_callback_name_module::kim_get_compute_callback_name /// /// \since 2.0 int GetComputeCallbackName(int const index, ComputeCallbackName * const computeCallbackName); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for /// ComputeCallbackName objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(ComputeCallbackName const & a, ComputeCallbackName const & b) const { return a.computeCallbackNameID < b.computeCallbackNameID; } }; // struct Comparator } // namespace COMPUTE_CALLBACK_NAME } // namespace KIM #endif // KIM_COMPUTE_CALLBACK_NAME_HPP_ kim-api-2.3.0-git/cpp/include/KIM_DataType.hpp000066400000000000000000000130401421473465500207660ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_DATA_TYPE_HPP_ #define KIM_DATA_TYPE_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// DataType's supported by the %KIM API. /// /// The enumeration constants are contained in the DATA_TYPE namespace. /// /// \sa KIM_DataType, kim_data_type_module::kim_data_type_type /// /// \since 2.0 class DataType { public: /// \brief Integer identifying the specific DataType represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_DataType::dataTypeID, /// kim_data_type_module::kim_data_type_type::data_type_id /// /// \since 2.0 int dataTypeID; /// \brief Create an uninitialized DataType object. /// /// \since 2.0 DataType(); /// \brief Create a DataType object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 DataType(int const id); /// \brief Create a DataType object corresponding to the provided string. If /// the string does not match one of the values defined by the %KIM API, then /// an "unknown" object is generated. /// /// \sa KIM_DataType_FromString, kim_data_type_module::kim_from_string /// /// \since 2.0 DataType(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// DataType's known to the %KIM API are found in the DATA_TYPE namespace. /// /// \sa KIM_DataType_Known, kim_data_type_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares DataType objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_DataType_Equal, kim_data_type_module::operator(.eq.) /// /// \since 2.0 bool operator==(DataType const & rhs) const; /// \brief Compares DataType objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_DataType_NotEqual, kim_data_type_module::operator(.ne.) /// /// \since 2.0 bool operator!=(DataType const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the DataType object. /// /// \note If the DataType object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_DataType_ToString, kim_data_type_module::kim_to_string() /// /// \since 2.0 std::string const & ToString() const; }; // class DataType /// \brief Contains the enumeration constants and the discovery routines for /// the DataType \ref extensible_enumeration "Extensible Enumeration". namespace DATA_TYPE { /// \brief The standard \c Integer data type. /// /// \todo Add more detailed description of data type. /// /// \sa KIM_DATA_TYPE_Integer, kim_data_type_module::kim_data_type_integer /// /// \since 2.0 extern DataType const Integer; /// \brief The standard \c Double data type. /// /// \todo Add more detailed description of data type. /// /// \sa KIM_DATA_TYPE_Double, kim_data_type_module::kim_data_type_double /// /// \since 2.0 extern DataType const Double; /// \brief Get the number of standard DataType's defined by the %KIM /// API. /// /// \param[out] numberOfDataTypes The number of standard DataType's defined by /// the %KIM API. /// /// \sa KIM_DATA_TYPE_GetNumberOfDataTypes, /// kim_data_type_module::kim_get_number_of_data_types /// /// \since 2.0 void GetNumberOfDataTypes(int * const numberOfDataTypes); /// \brief Get the identity of each defined standard DataType. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// DataType. This index ordering is only guaranteed to be stable /// during the lifetime of the current process. /// \param[out] dataType The DataType object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfDataTypes`. /// \return \c false otherwise. /// /// \sa KIM_DATA_TYPE_GetDataType, kim_data_type_module::kim_get_data_type /// /// \since 2.0 int GetDataType(int const index, DataType * const dataType); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for DataType objects /// so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(DataType const & a, DataType const & b) const { return a.dataTypeID < b.dataTypeID; } }; // struct Comparator } // namespace DATA_TYPE } // namespace KIM #endif // KIM_DATA_TYPE_HPP_ kim-api-2.3.0-git/cpp/include/KIM_EnergyUnit.hpp000066400000000000000000000150731421473465500213540ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_ENERGY_UNIT_HPP_ #define KIM_ENERGY_UNIT_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// EnergyUnit's supported by the %KIM API. /// /// The enumeration constants are contained in the ENERGY_UNIT namespace. /// /// \sa KIM_EnergyUnit, kim_energy_unit_module::kim_energy_unit_type /// /// \since 2.0 class EnergyUnit { public: /// \brief Integer identifying the specific EnergyUnit represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_EnergyUnit::energyUnitID, /// kim_energy_unit_module::kim_energy_unit_type::energy_unit_id /// /// \since 2.0 int energyUnitID; /// \brief Create an uninitialized EnergyUnit object. /// /// \since 2.0 EnergyUnit(); /// \brief Create a EnergyUnit object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 EnergyUnit(int const id); /// \brief Create an EnergyUnit object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_EnergyUnit_FromString, /// kim_energy_unit_module::kim_from_string /// /// \since 2.0 EnergyUnit(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// EnergyUnit's known to the %KIM API are found in the ENERGY_UNIT /// namespace. /// /// \sa KIM_EnergyUnit_Known, /// kim_energy_unit_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares EnergyUnit objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_EnergyUnit_Equal, /// kim_energy_unit_module::operator(.eq.) /// /// \since 2.0 bool operator==(EnergyUnit const & rhs) const; /// \brief Compares EnergyUnit objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_EnergyUnit_NotEqual, /// kim_energy_unit_module::operator(.ne.) /// /// \since 2.0 bool operator!=(EnergyUnit const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the EnergyUnit object. /// /// \note If the EnergyUnit object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_EnergyUnit_ToString, /// kim_energy_unit_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class EnergyUnit /// \brief Contains the enumeration constants and the discovery routines for /// the EnergyUnit \ref extensible_enumeration "Extensible Enumeration". namespace ENERGY_UNIT { /// \brief Indicates that a EnergyUnit is not used. /// /// \sa KIM_ENERGY_UNIT_unused, /// kim_energy_unit_module::kim_energy_unit_unused /// /// \since 2.0 extern EnergyUnit const unused; /// \brief The standard `amu*A`\f$^2\f$`/ps`\f$^2\f$ unit of energy. /// /// \sa KIM_ENERGY_UNIT_amu_A2_per_ps2, /// kim_energy_unit_module::kim_energy_unit_amu_a2_per_ps2 /// /// \since 2.0 extern EnergyUnit const amu_A2_per_ps2; /// \brief The standard erg unit of energy. /// /// \sa KIM_ENERGY_UNIT_erg, /// kim_energy_unit_module::kim_energy_unit_erg /// /// \since 2.0 extern EnergyUnit const erg; /// \brief The standard electronvolt unit of energy. /// /// \sa KIM_ENERGY_UNIT_eV, /// kim_energy_unit_module::kim_energy_unit_ev /// /// \since 2.0 extern EnergyUnit const eV; /// \brief The standard Hartree unit of energy. /// /// \sa KIM_ENERGY_UNIT_Hartre, /// kim_energy_unit_module::kim_energy_unit_hartree /// /// \since 2.0 extern EnergyUnit const Hartree; /// \brief The standard Joule unit of energy. /// /// \sa KIM_ENERGY_UNIT_J, /// kim_energy_unit_module::kim_energy_unit_j /// /// \since 2.0 extern EnergyUnit const J; /// \brief The standard kilocalorie per mole unit of energy. /// /// \sa KIM_ENERGY_UNIT_kcal_mol, /// kim_energy_unit_module::kim_energy_unit_kcal_mol /// /// \since 2.0 extern EnergyUnit const kcal_mol; /// \brief Get the number of standard EnergyUnit's defined by the %KIM API. /// /// \param[out] numberOfEnergyUnits The number of standard EnergyUnit's defined /// by the %KIM API. /// /// \sa KIM_ENERGY_UNIT_GetNumberOfEnergyUnits, /// kim_energy_unit_module::kim_get_number_of_energy_units /// /// \since 2.0 void GetNumberOfEnergyUnits(int * const numberOfEnergyUnits); /// \brief Get the identity of each defined standard EnergyUnit. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// EnergyUnit. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] energyUnit The EnergyUnit object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfEnergyUnits`. /// \return \c false otherwise. /// /// \sa KIM_ENERGY_UNIT_GetEnergyUnit, /// kim_energy_unit_module::kim_get_energy_unit /// /// \since 2.0 int GetEnergyUnit(int const index, EnergyUnit * const energyUnit); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for EnergyUnit /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(EnergyUnit const & a, EnergyUnit const & b) const { return a.energyUnitID < b.energyUnitID; } }; // struct Comparator } // namespace ENERGY_UNIT } // namespace KIM #endif // KIM_ENERGY_UNIT_HPP_ kim-api-2.3.0-git/cpp/include/KIM_FunctionTypes.hpp000066400000000000000000000157121421473465500220750ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_FUNCTION_TYPES_HPP_ #define KIM_FUNCTION_TYPES_HPP_ #include namespace KIM { // Forward declarations class LengthUnit; class EnergyUnit; class ChargeUnit; class TemperatureUnit; class TimeUnit; class ModelCreate; class ModelDriverCreate; class ModelCompute; class ModelExtension; class ModelComputeArgumentsCreate; class ModelComputeArguments; class ModelRefresh; class ModelWriteParameterizedModel; class ModelComputeArgumentsDestroy; class ModelDestroy; /// \brief Generic function type. /// /// \sa KIM_Function /// /// \since 2.0 typedef void(Function)(void); // Generic function pointer /// \brief Prototype for MODEL_ROUTINE_NAME::Create routine. /// /// \sa KIM_ModelCreateFunction, kim_model_module::kim_model_create /// /// \since 2.0 typedef int ModelCreateFunction(ModelCreate * const modelCreate, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit); /// \brief Prototype for MODEL_ROUTINE_NAME::Create routine. /// /// \sa KIM_ModelDriverCreateFunction, kim_model_module::kim_model_create /// /// \since 2.0 typedef int ModelDriverCreateFunction(ModelDriverCreate * const modelDriverCreate, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit); /// \brief Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate /// routine. /// /// \sa KIM_ModelComputeArgumentsCreateFunction, /// kim_model_module::kim_model_compute_arguments_create /// /// \since 2.0 typedef int ModelComputeArgumentsCreateFunction( ModelCompute const * const modelCompute, ModelComputeArgumentsCreate * const modelComputeArgumentsCreate); /// \brief Prototype for MODEL_ROUTINE_NAME::Compute routine. /// /// \sa KIM_ModelComputeFunction, kim_model_module::kim_model_compute /// /// \since 2.0 typedef int ModelComputeFunction( ModelCompute const * const modelCompute, ModelComputeArguments const * const modelComputeArgumentsCreate); /// \brief Prototype for COMPUTE_CALLBACK_NAME::GetNeighborList routine. /// /// \sa KIM_GetNeighborListFunction, kim_model_compute_arguments_module::kim_model_compute_arguments_get_neighbor_list /// /// \since 2.0 typedef int GetNeighborListFunction(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle); /// \brief Prototype for COMPUTE_CALLBACK_NAME::ProcessDEDrTerm /// routine. /// /// \sa KIM_ProcessDEDrTermFunction, kim_model_compute_arguments_module::kim_model_compute_arguments_process_dedr_term /// /// \since 2.0 typedef int ProcessDEDrTermFunction(void * const dataObject, double const de, double const r, double const * const dx, int const i, int const j); /// \brief Prototype for COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term /// routine. /// /// \sa KIM_ProcessD2EDr2TermFunction, kim_model_compute_arguments_module::kim_model_compute_arguments_process_d2edr2_term /// /// /// \since 2.0 typedef int ProcessD2EDr2TermFunction(void * const dataObject, double const de, double const * const r, double const * const dx, int const * const i, int const * const j); /// \brief Prototype for MODEL_ROUTINE_NAME::Extension routine. /// /// \sa KIM_ModelExtensionFunction, kim_model_module::kim_model_extension /// /// \since 2.0 typedef int ModelExtensionFunction(ModelExtension * const modelExtension, void * const extensionStructure); /// \brief Prototype for MODEL_ROUTINE_NAME::Refresh routine. /// /// \sa KIM_ModelRefreshFunction, /// kim_model_module::kim_model_clear_then_refresh /// /// \since 2.0 typedef int ModelRefreshFunction(ModelRefresh * const modelRefresh); /// \brief Prototype for MODEL_ROUTINE_NAME::WriteParameterizedModel routine. /// /// \sa KIM_ModelWriteParameterizedModelFunction, /// kim_model_module::kim_model_write_parameterized_model /// /// \since 2.0 typedef int ModelWriteParameterizedModelFunction( ModelWriteParameterizedModel const * const modelWriteParameterizedModel); /// \brief Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy /// routine. /// /// \sa KIM_ModelComputeArgumentsDestroyFunction, /// kim_model_module::kim_model_compute_arguments_destroy /// /// \since 2.0 typedef int ModelComputeArgumentsDestroyFunction( ModelCompute const * const modelCompute, ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); /// \brief Prototype for MODEL_ROUTINE_NAME::Destroy routine. /// /// \sa KIM_ModelDestroyFunction, kim_model_module::kim_model_destroy /// /// \since 2.0 typedef int ModelDestroyFunction(ModelDestroy * const modelDestroy); /// \brief Prototype for Log PrintFunction routine. /// /// \sa KIM_LogPrintFunction, /// kim_log_module::kim_log_push_default_print_function /// /// \since 2.2 typedef int LogPrintFunction(std::string const & entryString); } // namespace KIM #endif // KIM_FUNCTION_TYPES_HPP_ kim-api-2.3.0-git/cpp/include/KIM_LOG_DEFINES.inc.in000066400000000000000000000006301421473465500214210ustar00rootroot00000000000000#ifndef KIM_LOG_DEFINES_INC_ #define KIM_LOG_DEFINES_INC_ #define KIM_LOG_VERBOSITY_SILENT_ 0 #define KIM_LOG_VERBOSITY_FATAL_ 1 #define KIM_LOG_VERBOSITY_ERROR_ 2 #define KIM_LOG_VERBOSITY_WARNING_ 3 #define KIM_LOG_VERBOSITY_INFORMATION_ 4 #define KIM_LOG_VERBOSITY_DEBUG_ 5 /* clang-format off */ #define KIM_LOG_MAXIMUM_LEVEL KIM_LOG_VERBOSITY_@KIM_API_LOG_MAXIMUM_LEVEL@_ /* clang-format on */ #endif kim-api-2.3.0-git/cpp/include/KIM_LanguageName.hpp000066400000000000000000000141051421473465500216020ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_LANGUAGE_NAME_HPP_ #define KIM_LANGUAGE_NAME_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// LanguageName's supported by the %KIM API. /// /// The enumeration constants are contained in the LANGUAGE_NAME namespace. /// /// \sa KIM_LanguageName, kim_language_name_module::kim_language_name_type /// /// \since 2.0 class LanguageName { public: /// \brief Integer identifying the specific LanguageName represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_LanguageName::languageNameID, /// kim_language_name_module::kim_language_name_type::language_name_id /// /// \since 2.0 int languageNameID; /// \brief Create an uninitialized LanguageName object. /// /// \since 2.0 LanguageName(); /// \brief Create a LanguageName object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 LanguageName(int const id); /// \brief Create a LanguageName object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_LanguageName_FromString, /// kim_language_name_module::kim_from_string /// /// \since 2.0 LanguageName(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// LanguageName's known to the %KIM API are found in the LANGUAGE_NAME /// namespace. /// /// \sa KIM_LanguageName_Known, kim_language_name_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares LanguageName objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_LanguageName_Equal, kim_language_name_module::operator(.eq.) /// /// \since 2.0 bool operator==(LanguageName const & rhs) const; /// \brief Compares LanguageName objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_LanguageName_NotEqual, kim_language_name_module::operator(.ne.) /// /// \since 2.0 bool operator!=(LanguageName const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the LanguageName object. /// /// \note If the LanguageName object does not correspond to a value defined /// by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_LanguageName_ToString, kim_language_name_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class LanguageName /// \brief Contains the enumeration constants and the discovery routines for /// the LanguageName \ref extensible_enumeration "Extensible Enumeration". namespace LANGUAGE_NAME { /// \brief The standard \c cpp language. /// /// \todo Add more detailed description of the language. /// /// \sa KIM_LANGUAGE_NAME_cpp, kim_language_name_module::kim_language_name_cpp /// /// \since 2.0 extern LanguageName const cpp; /// \brief The standard \c c language. /// /// \todo Add more detailed description of the language. /// /// \sa KIM_LANGUAGE_NAME_c, kim_language_name_module::kim_language_name_c /// /// \since 2.0 extern LanguageName const c; /// \brief The standard \c fortran language. /// /// \todo Add more detailed description of the language. /// /// \sa KIM_LANGUAGE_NAME_fortran, /// kim_language_name_module::kim_language_name_fortran /// /// \since 2.0 extern LanguageName const fortran; /// \brief Get the number of standard LanguageName's defined by the %KIM /// API. /// /// \param[out] numberOfLanguageNames The number of standard LanguageName's /// defined by the %KIM API. /// /// \sa KIM_LANGUAGE_NAME_GetNumberOfLanguageNames, /// kim_language_name_module::kim_get_number_of_language_names /// /// \since 2.0 void GetNumberOfLanguageNames(int * const numberOfLanguageNames); /// \brief Get the identity of each defined standard LanguageName. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// LanguageName. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] languageName The LanguageName object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfLanguageNames`. /// \return \c false otherwise. /// /// \sa KIM_LANGUAGE_NAME_GetLanguageName, /// kim_language_name_module::kim_get_language_name /// /// \since 2.0 int GetLanguageName(int const index, LanguageName * const languageName); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for LanguageName /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(LanguageName const & a, LanguageName const & b) const { return a.languageNameID < b.languageNameID; } }; // struct Comparator } // namespace LANGUAGE_NAME } // namespace KIM #endif // KIM_LANGUAGE_NAME_HPP_ kim-api-2.3.0-git/cpp/include/KIM_LengthUnit.hpp000066400000000000000000000143611421473465500213430ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_LENGTH_UNIT_HPP_ #define KIM_LENGTH_UNIT_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// LengthUnit's supported by the %KIM API. /// /// The enumeration constants are contained in the LENGTH_UNIT namespace. /// /// \sa KIM_LengthUnit, kim_length_unit_module::kim_length_unit_type /// /// \since 2.0 class LengthUnit { public: /// \brief Integer identifying the specific LengthUnit represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_LengthUnit::lengthUnitID, /// kim_length_unit_module::kim_length_unit_type::length_unit_id /// /// \since 2.0 int lengthUnitID; /// \brief Create an uninitialized LengthUnit object. /// /// \since 2.0 LengthUnit(); /// \brief Create a LengthUnit object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 LengthUnit(int const id); /// \brief Create a LengthUnit object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_LengthUnit_FromString, kim_length_unit_module::kim_from_string /// /// \since 2.0 LengthUnit(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// LengthUnit's known to the %KIM API are found in the LENGTH_UNIT /// namespace. /// /// \sa KIM_LengthUnit_Known, kim_length_unit_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares LengthUnit objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_LengthUnit_Equal, kim_length_unit_module::operator(.eq.) /// /// \since 2.0 bool operator==(LengthUnit const & rhs) const; /// \brief Compares LengthUnit objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_LengthUnit_NotEqual, kim_length_unit_module::operator(.ne.) /// /// \since 2.0 bool operator!=(LengthUnit const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the LengthUnit object. /// /// \note If the LengthUnit object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_LengthUnit_ToString, kim_length_unit_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class LengthUnit /// \brief Contains the enumeration constants and the discovery routines for /// the LengthUnit \ref extensible_enumeration "Extensible Enumeration". namespace LENGTH_UNIT { /// \brief Indicates that a LengthUnit is not used. /// /// \sa KIM_LENGTH_UNIT_unused, kim_length_unit_module::kim_length_unit_unused /// /// \since 2.0 extern LengthUnit const unused; /// \brief The standard angstrom unit of length. /// /// \sa KIM_LENGTH_UNIT_A, kim_length_unit_module::kim_length_unit_a /// /// \since 2.0 extern LengthUnit const A; /// \brief The standard Bohr unit of length. /// /// \sa KIM_LENGTH_UNIT_Bohr, kim_length_unit_module::kim_length_unit_bohr /// /// \since 2.0 extern LengthUnit const Bohr; /// \brief The standard centimeter unit of length. /// /// \sa KIM_LENGTH_UNIT_cm, kim_length_unit_module::kim_length_unit_cm /// /// \since 2.0 extern LengthUnit const cm; /// \brief The standard meter unit of length. /// /// \sa KIM_LENGTH_UNIT_m, kim_length_unit_module::kim_length_unit_m /// /// \since 2.0 extern LengthUnit const m; /// \brief The standard nanometer unit of length. /// /// \sa KIM_LENGTH_UNIT_nm, kim_length_unit_module::kim_length_unit_nm /// /// \since 2.0 extern LengthUnit const nm; /// \brief Get the number of standard LengthUnit's defined by the %KIM API. /// /// \param[out] numberOfLengthUnits The number of standard LengthUnit's defined /// by the %KIM API. /// /// \sa KIM_LENGTH_UNIT_GetNumberOfLengthUnits, /// kim_length_unit_module::kim_get_number_of_length_units /// /// \since 2.0 void GetNumberOfLengthUnits(int * const numberOfLengthUnits); /// \brief Get the identity of each defined standard LengthUnit. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// LengthUnit. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] lengthUnit The LengthUnit object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfLengthUnits`. /// \return \c false otherwise. /// /// \sa KIM_LENGTH_UNIT_GetLengthUnit, /// kim_length_unit_module::kim_get_length_unit /// /// \since 2.0 int GetLengthUnit(int const index, LengthUnit * const lengthUnit); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for LengthUnit /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(LengthUnit const & a, LengthUnit const & b) const { return a.lengthUnitID < b.lengthUnitID; } }; // struct Comparator } // namespace LENGTH_UNIT } // namespace KIM #endif // KIM_LENGTH_UNIT_HPP_ kim-api-2.3.0-git/cpp/include/KIM_Log.hpp000066400000000000000000000130421421473465500177760ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_LOG_HPP_ #define KIM_LOG_HPP_ #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" // IWYU pragma: export #endif namespace KIM { // Forward declarations class LogVerbosity; class LanguageName; class LogImplementation; /// \brief Provides the logging interface for the %KIM API. /// /// \sa KIM_Log, kim_log_module::kim_log_handle_type /// /// \since 2.0 class Log { public: /// \brief Create a new %KIM API Log object. /// /// \param[out] log Pointer to the newly created Log object. /// /// \return \c false /// /// \sa KIM_Log_Create, kim_log_module::kim_log_create /// /// \since 2.0 static int Create(Log ** const log); /// \brief Destroy a previously Log::Create'd object. /// /// \param[inout] log Pointer to the Log object. /// /// \pre \c log points to a previously created %KIM API Log object. /// /// \post `log == NULL`. /// /// \sa KIM_Log_Destroy, kim_log_module::kim_log_destroy /// /// \since 2.0 static void Destroy(Log ** const log); /// \brief Push a new default LogVerbosity onto the %KIM API global default /// verbosity stack. /// /// The default LogVerbosity is used when creating new Log objects. /// /// \param[in] logVerbosity A LogVerbosity value. /// /// \sa KIM_Log_PushDefaultVerbosity, /// kim_log_module::kim_push_default_verbosity /// /// \since 2.0 static void PushDefaultVerbosity(LogVerbosity const logVerbosity); /// \brief Pop a LogVerbosity from the %KIM API global default verbosity /// stack. /// /// \sa KIM_Log_PopDefaultVerbosity, /// kim_log_module::kim_pop_default_verbosity /// /// \since 2.0 static void PopDefaultVerbosity(); /// \brief Push a new default log PrintFunction onto the %KIM API global /// default log PrintFunction stack. /// /// The default log PrintFunction is used when creating new Log objects. /// /// \param[in] languageName The LanguageName of the function. /// \param[in] fptr The function pointer. /// /// \sa KIM_Log_PushDefaultPrintFunction, /// kim_log_module::kim_push_default_print_function /// /// \since 2.2 static void PushDefaultPrintFunction(LanguageName const languageName, Function * const fptr); /// \brief Pop a log PrintFunction from the %KIM API global default log /// PrintFunction stack. /// /// \sa KIM_Log_PopDefaultPrintFunction, /// kim_log_module::kim_pop_default_print_function /// /// \since 2.2 static void PopDefaultPrintFunction(); /// \brief Get the identity of the Log object. /// /// \sa KIM_Log_GetID, kim_log_module::kim_get_id /// /// \since 2.0 std::string const & GetID() const; /// \brief Set the identity of the Log object. /// /// \param[in] id String identifying the Log object. /// /// \sa KIM_Log_SetID, kim_log_module::kim_set_id /// /// \since 2.0 void SetID(std::string const & id); /// \brief Push a new LogVerbosity onto the Log object's verbosity stack. /// /// \param[in] logVerbosity A LogVerbosity value. /// /// \sa KIM_Log_PushVerbosity, kim_log_module::kim_push_verbosity /// /// \since 2.0 void PushVerbosity(LogVerbosity const logVerbosity); /// \brief Pop a LogVerbosity from the Log object's verbosity stack. /// /// \sa KIM_Log_PopVerbosity, kim_log_module::kim_pop_verbosity /// /// \since 2.0 void PopVerbosity(); /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_Log_LogEntry, kim_log_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; private: // do not allow copy constructor or operator= Log(Log const &); void operator=(Log const &); Log(); ~Log(); LogImplementation * pimpl; }; // class Log } // namespace KIM #endif // KIM_LOG_HPP_ kim-api-2.3.0-git/cpp/include/KIM_LogMacros.hpp000066400000000000000000000072571421473465500211560ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #undef FATAL_VERBOSITY /// \brief Defined if FATAL Log entries are to be compiled. #define FATAL_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_FATAL_) #undef LOG_FATAL #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_FATAL_) /// \def LOG_FATAL(message) /// \brief Convenience macro for FATAL Log entries with compile-time /// optimization. #define LOG_FATAL(message) \ KIM_LOGGER_OBJECT_NAME->LogEntry( \ KIM::LOG_VERBOSITY::fatal, message, __LINE__, __FILE__) #else #define LOG_FATAL(message) #endif #undef ERROR_VERBOSITY /// \brief Defined if ERROR Log entries are to be compiled. #define ERROR_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_ERROR_) #undef LOG_ERROR #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_ERROR_) /// \def LOG_ERROR(message) /// \brief Convenience macro for ERROR Log entries with compile-time /// optimization. #define LOG_ERROR(message) \ KIM_LOGGER_OBJECT_NAME->LogEntry( \ KIM::LOG_VERBOSITY::error, message, __LINE__, __FILE__) #else #define LOG_ERROR(message) #endif #undef WARNING_VERBOSITY /// \brief Defined if WARNING Log entries are to be compiled. #define WARNING_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_WARNING_) #undef LOG_WARNING #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_WARNING_) /// \def LOG_WARNING(message) /// \brief Convenience macro for WARNING Log entries with compile-time /// optimization. #define LOG_WARNING(message) \ KIM_LOGGER_OBJECT_NAME->LogEntry( \ KIM::LOG_VERBOSITY::warning, message, __LINE__, __FILE__) #else #define LOG_WARNING(message) #endif #undef INFORMATION_VERBOSITY /// \brief Defined if INFORMATION Log entries are to be compiled. #define INFORMATION_VERBOSITY \ (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_INFORMATION_) #undef LOG_INFORMATION #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_INFORMATION_) /// \def LOG_INFORMATION(message) /// \brief Convenience macro for INFORMATION Log entries with compile-time /// optimization. #define LOG_INFORMATION(message) \ KIM_LOGGER_OBJECT_NAME->LogEntry( \ KIM::LOG_VERBOSITY::information, message, __LINE__, __FILE__) #else #define LOG_INFORMATION(message) #endif #undef DEBUG_VERBOSITY /// \brief Defined if DEBUG Log entries are to be compiled. #define DEBUG_VERBOSITY (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_DEBUG_) #undef LOG_DEBUG #if (KIM_LOG_MAXIMUM_LEVEL >= KIM_LOG_VERBOSITY_DEBUG_) /// \def LOG_DEBUG(message) /// \brief Convenience macro for DEBUG Log entries with compile-time /// optimization. #define LOG_DEBUG(message) \ KIM_LOGGER_OBJECT_NAME->LogEntry( \ KIM::LOG_VERBOSITY::debug, message, __LINE__, __FILE__) #else #define LOG_DEBUG(message) #endif kim-api-2.3.0-git/cpp/include/KIM_LogVerbosity.hpp000066400000000000000000000223541421473465500217130ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_LOG_VERBOSITY_HPP_ #define KIM_LOG_VERBOSITY_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// LogVerbosity's supported by the %KIM API. /// /// The enumeration constants are contained in the LOG_VERBOSITY namespace. /// /// \sa KIM_LogVerbosity, /// kim_log_verbosity_module::kim_log_verbosity_type /// /// \since 2.0 class LogVerbosity { public: /// \brief Integer identifying the specific LogVerbosity represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_LogVerbosity::logVerbosityID, /// kim_log_verbosity_module::kim_log_verbosity_type::log_verbosity_id /// /// \since 2.0 int logVerbosityID; /// \brief Create an uninitialized LogVerbosity object. /// /// \since 2.0 LogVerbosity(); /// \brief Create a LogVerbosity object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 LogVerbosity(int const id); /// \brief Create a LogVerbosity object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_LogVerbosity_FromString, /// kim_log_verbosity_module::kim_from_string /// /// \since 2.0 LogVerbosity(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// LogVerbosity's known to the %KIM API are found in the LOG_VERBOSITY /// namespace. /// /// \sa KIM_LogVerbosity_Known, kim_log_verbosity_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares LogVerbosity objects for less-than. /// /// \sa KIM_LogVerbosity_LessThan, kim_log_verbosity_module::operator(.lt.) /// /// \since 2.0 bool operator<(LogVerbosity const & rhs) const; /// \brief Compares LogVerbosity objects for greater-than. /// /// \sa KIM_LogVerbosity_GreaterThan, /// kim_log_verbosity_module::operator(.gt.) /// /// \since 2.0 bool operator>(LogVerbosity const & rhs) const; /// \brief Compares LogVerbosity objects for less-than-equal. /// /// \sa KIM_LogVerbosity_LessThanEqual, /// kim_log_verbosity_module::operator(.le.) /// /// \since 2.0 bool operator<=(LogVerbosity const & rhs) const; /// \brief Compares LogVerbosity objects for greater-than-equal. /// /// \sa KIM_LogVerbosity_GreaterThanEqual, /// kim_log_verbosity_module::operator(.ge.) /// /// \since 2.0 bool operator>=(LogVerbosity const & rhs) const; /// \brief Compares LogVerbosity objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_LogVerbosity_Equal, kim_log_verbosity_module::operator(.eq.) /// /// \since 2.0 bool operator==(LogVerbosity const & rhs) const; /// \brief Compares LogVerbosity objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_LogVerbosity_NotEqual, kim_log_verbosity_module::operator(.ne.) /// /// \since 2.0 bool operator!=(LogVerbosity const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the LogVerbosity object. /// /// \note If the LogVerbosity object does not correspond to a value defined /// by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_LogVerbosity_ToString, kim_log_verbosity_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class LogVerbosity /// \brief Contains the enumeration constants and the discovery routines for /// the LogVerbosity \ref extensible_enumeration "Extensible Enumeration". namespace LOG_VERBOSITY { /// \brief The standard \c silent verbosity. /// /// The \c silent verbosity level should be used when absolutely no messages /// should be written into the log file. /// /// \sa KIM_LOG_VERBOSITY_silent, /// kim_log_verbosity_module::kim_log_verbosity_silent /// /// \since 2.0 extern LogVerbosity const silent; /// \brief The standard \c fatal verbosity. /// /// The \c fatal verbosity level should be used when the execution of the /// program cannot continue in any way and \c exit will be called. Generic /// examples of a \c fatal condition include: failure to allocate requested /// memory, etc. /// /// \sa KIM_LOG_VERBOSITY_fatal, /// kim_log_verbosity_module::kim_log_verbosity_fatal /// /// \since 2.0 extern LogVerbosity const fatal; /// \brief The standard \c error verbosity. /// /// The \c error verbosity level should be used when the execution of some task /// could not be completed. Generic examples of an \c error condition include: /// an email could not be sent, a page could not be rendered, some data could /// not be stored to a database, etc. Something has definitively gone wrong. /// /// \sa KIM_LOG_VERBOSITY_error, /// kim_log_verbosity_module::kim_log_verbosity_error /// /// \since 2.0 extern LogVerbosity const error; /// \brief The standard \c warning verbosity. /// /// The \c warning verbosity level should be used when something unexpected /// happened, but that execution can continue, perhaps in a degraded mode. /// Generic examples of a \c warning condition include: a configuration file /// was missing but defaults were used, a price was calculated as negative, so /// it was clamped to zero, etc. Something is not right, but it has not gone /// properly wrong yet - warnings are often a sign that there will be an error /// very soon. /// /// \sa KIM_LOG_VERBOSITY_warning, /// kim_log_verbosity_module::kim_log_verbosity_warning /// /// \since 2.0 extern LogVerbosity const warning; /// \brief The standard \c information verbosity. /// /// The \c information verbosity level should be used when something normal but /// significant happened. Generic examples of an \c information condition /// include: the system started, the system stopped, the daily inventory update /// job ran, etc. There should not be a continual torrent of these, otherwise /// there is just too much to read. /// /// \sa KIM_LOG_VERBOSITY_information, /// kim_log_verbosity_module::kim_log_verbosity_information /// /// \since 2.0 extern LogVerbosity const information; /// \brief The standard \c debug verbosity. /// /// The \c debug verbosity level should be used when something normal and /// insignificant happened. Generic examples of a \c debug condition include: /// a new user came to the site, a page was rendered, an order was taken, a /// price was updated. This is the stuff excluded from \c info because there /// would be too much of it. /// /// \sa KIM_LOG_VERBOSITY_debug, /// kim_log_verbosity_module::kim_log_verbosity_debug /// /// \since 2.0 extern LogVerbosity const debug; /// \brief Get the number of standard LogVerbosity's defined by the %KIM /// API. /// /// \param[out] numberOfLogVerbosities The number of standard LogVerbosity's /// defined by the %KIM API. /// /// \sa KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities, /// kim_log_verbosity_module::kim_get_number_of_log_verbosities /// /// \since 2.0 void GetNumberOfLogVerbosities(int * const numberOfLogVerbosities); /// \brief Get the identity of each defined standard LogVerbosity. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// LogVerbosity. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] logVerbosity The LogVerbosity object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfLogVerbosities`. /// \return \c false otherwise. /// /// \sa KIM_LOG_VERBOSITY_GetLogVerbosity, /// kim_log_verbosity_module::kim_get_log_verbosity /// /// \since 2.0 int GetLogVerbosity(int const index, LogVerbosity * const logVerbosity); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for LogVerbosity /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(LogVerbosity const & a, LogVerbosity const & b) const { return a.logVerbosityID < b.logVerbosityID; } }; // struct Comparator } // namespace LOG_VERBOSITY } // namespace KIM #endif // KIM_LOG_VERBOSITY_HPP_ kim-api-2.3.0-git/cpp/include/KIM_Model.hpp000066400000000000000000000530721421473465500203240ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_HPP_ #define KIM_MODEL_HPP_ #include namespace KIM { // Forward declarations class LogVerbosity; class DataType; class ModelRoutineName; class SpeciesName; class Numbering; class LengthUnit; class EnergyUnit; class ChargeUnit; class TemperatureUnit; class TimeUnit; class ComputeArguments; class ModelImplementation; /// \brief Provides the primary interface to a %KIM API Model object and is /// meant to be used by simulators. /// /// \sa KIM_Model, kim_model_module::kim_model_handle_type /// /// \since 2.0 class Model { public: /// \brief Create a new %KIM API Model object. /// /// Allocates a new %KIM API Model object for use by a Simulator and calls /// the Model's MODEL_ROUTINE_NAME::Create routine. /// /// \param[in] numbering The Numbering value used by the Simulator. /// \param[in] requestedLengthUnit The base LengthUnit requested by the /// Simulator. /// \param[in] requestedEnergyUnit The base EnergyUnit requested by the /// Simulator. /// \param[in] requestedChargeUnit The base ChargeUnit requested by the /// Simulator. /// \param[in] requestedTemperatureUnit The base TemperatureUnit requested /// by the Simulator. /// \param[in] requestedTimeUnit The base TimeUnit requested by the /// Simulator. /// \param[in] modelName The name of the Model to be created. /// \param[out] requestedUnitsAccepted An integer that is set to \c true if /// the Model accepts the Simulator's requested base units, \c /// false if the Model will use base units other than those /// requested by the Simulator. /// \param[out] model Pointer to the newly created Model object. /// /// \note The value of `modelName` is required to be a valid C-identifier. /// /// \note A requested unit of \c unused indicates that the Simulator will not /// employ any derived units connected to the associated base unit. This /// avoids the need for the Simulator to make an arbitrary choice that could /// cause the Model to not accept its requested base units. /// /// \return \c true if the %KIM API is unable to allocate a new log object. /// \return \c true if \c numbering or any of the base units are unknown. /// \return \c true if the requested model's library cannot be found, /// opened, is of the wrong type, or has some other problem. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Create routine /// returns \c true. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Create routine does /// not set the Model's (1) numbering, (2) base units, (3) influence /// distance, (4) numberOfNeighborLists, (5) cutoff values, (6) /// modelWillNotRequesNeighborsOfNoncontributingParticles, (7) /// required ModelRoutineName pointers, or (8) supported species /// codes. /// \return \c true if `max(cutoffs) > influenceDistance`. /// \return \c true if parameters are registered but not a /// MODEL_ROUTINE_NAME::Refresh pointer, or vise-versa. /// \return \c true if a MODEL_ROUTINE_NAME::WriteParameterizedModel /// pointer is provided but no parameters are registered. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Create routine /// does not set the Model's Numbering. /// \return \c false otherwise. /// /// \post \c requestedUnitsAccepted is unchanged and `model == NULL` if an /// error occurs. /// /// \sa KIM_Model_Create, kim_model_module::kim_model_create /// /// \since 2.0 static int Create(Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const & modelName, int * const requestedUnitsAccepted, Model ** const model); /// \brief Destroy a previously Model::Create'd object. /// /// Call the Model's MODEL_ROUTINE_NAME::Destroy routine and deallocate /// the Model object. /// /// \param[inout] model Pointer to the Model object. /// /// \pre \c *model points to a previously created %KIM API Model object. /// /// \post `*model == NULL`. /// /// \sa KIM_Model_Destroy, kim_model_module::kim_model_destroy /// // \since 2.0 static void Destroy(Model ** const model); /// \brief Determine presence and required status of the given /// ModelRoutineName. /// /// \param[in] modelRoutineName The ModelRoutineName of interest. /// \param[out] present \c true if the Model provides the routine, \c false /// otherwise. /// \param[out] required \c true if the Model requires the use of the routine, /// \c false otherwise. /// /// \return \c true if \c modelRoutineName is unknown. /// \return \c false otherwise. /// /// \pre \c present or \c required may be \c NULL if the corresponding value /// is not needed. /// /// \post \c present and \c required are unchanged if an error occurs. /// /// \sa KIM_Model_IsRoutinePresent, kim_model_module::kim_is_routine_present /// /// \since 2.0 int IsRoutinePresent(ModelRoutineName const modelRoutineName, int * const present, int * const required) const; /// \brief Get the Model's influence distance. /// /// \param[out] influenceDistance /// /// \todo Add more detailed description of \c influenceDistance. (or link to /// docs elsewhere?) /// /// \sa KIM_Model_GetInfluenceDistance, /// kim_model_module::kim_get_influence_distance /// /// \since 2.0 void GetInfluenceDistance(double * const influenceDistance) const; /// \brief Get the Model's neighbor list information. /// /// Each neighbor list has a cutoff value and a flag indicating if the Model /// will request the neighbors of non-contributing particles. /// /// \note Output pointers obtained from this routine are valid until the next /// call to Model::ClearThenRefresh of the KIM::Model object is /// Model::Destroy'd. /// /// \param[out] numberOfNeighborLists The number of neighbor lists required /// by the Model. /// \param[out] cutoffs The cutoff distance for each neighbor list. /// \param[out] modelWillNotRequestNeighborsOfNoncontributingParticles /// \c true if such neighbor lists will not be requested, /// \c false otherwise. /// /// \pre \c numberOfNeighborLists, \c cutoffs, or /// \c modelWillNotRequestNeighborsOfNoncontributingParticles may be /// \c NULL if the corresponding value is not needed. /// /// \sa KIM_Model_GetNeighborListPointers, /// kim_model_module::kim_get_number_of_neighbor_lists, /// kim_model_module::kim_get_neighbor_list_values /// /// \since 2.0 void GetNeighborListPointers( int * const numberOfNeighborLists, double const ** const cutoffs, int const ** const modelWillNotRequestNeighborsOfNoncontributingParticles) const; /// \brief Get the Model's base unit values. /// /// \param[out] lengthUnit The Model's base LengthUnit. /// \param[out] energyUnit The Model's base EnergyUnit. /// \param[out] chargeUnit The Model's base ChargeUnit. /// \param[out] temperatureUnit The Model's base TemperatureUnit. /// \param[out] timeUnit The Model's base TimeUnit. /// /// \note A unit of \c unused indicates the the Model does not deal with any /// quantities whose derived unit involves the corresponding base unit. For /// example, many models only deal with quantities that are derived from just /// the energy and length base units (such as force, virial, etc.), and thus /// should set \c chargeUnit, \c temperatureUnit, and \c timeUnit to \c /// unused. /// /// \pre \c lengthUnit, \c energyUnit, \c chargeUnit, \c temperatureUnit, or /// \c timeUnit may be \c NULL if the corresponding value is not needed. /// /// \sa KIM_Model_GetUnits, kim_model_module::kim_get_units /// /// \since 2.0 void GetUnits(LengthUnit * const lengthUnit, EnergyUnit * const energyUnit, ChargeUnit * const chargeUnit, TemperatureUnit * const temperatureUnit, TimeUnit * const timeUnit) const; /// \brief Create a new ComputeArguments object for the Model object. /// /// Allocates a new ComputeArguments object for use by a Simulator and /// calls the Model's MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine. /// /// \param[inout] computeArguments Pointer to the newly created /// ComputeArguments object. /// /// \return \c true if the %KIM API is unable to allocate a new /// ComputeArguments object. /// \return \c true if the Model's MODEL_ROUTINE_NAME::ComputeArgumentsCreate /// routine returns \c true. /// \return \c false otherwise. /// /// \post `computeArguments == NULL` if an error occurs. /// /// \sa KIM_Model_ComputeArgumentsCreate, /// kim_model_module::kim_compute_arguments_create /// /// \since 2.0 int ComputeArgumentsCreate(ComputeArguments ** const computeArguments) const; /// \brief Destroy a previously Model::ComputeArgumentsCreate'd object. /// /// Call the Model's MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine /// and deallocate the ComputeArguments object. /// /// \param[inout] computeArguments Pointer to the ComputeArguments object. /// /// \return \c true if the ComputeArguments object was created by a /// different Model (as identified by its name string). /// \return \c true if the Model's /// MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine returns \c /// true. /// \return \c false otherwise. /// /// \post \c computeArguments is unchanged if an error occurs, otherwise /// `computeArguments == NULL`. /// /// \sa KIM_Model_ComputeArgumentsDestroy, /// kim_model_module::kim_compute_arguments_destroy /// /// \since 2.0 int ComputeArgumentsDestroy(ComputeArguments ** const computeArguments) const; /// \brief Call the Model's MODEL_ROUTINE_NAME::Compute routine. /// /// \param[in] computeArguments A ComputeArguments object. /// /// \return \c true if \c computeArguments was created by a different Model /// (as identified by its name string). /// \return \c true if /// ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent /// returns \c false for \c computeArguments. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Compute routine /// returns \c true. /// \return \c false otherwise. /// /// \sa KIM_Model_Compute, kim_model_module::kim_compute /// /// \since 2.0 int Compute(ComputeArguments const * const computeArguments) const; /// \brief Call the Model's MODEL_ROUTINE_NAME::Extension routine. /// /// \param[in] extensionID A string uniquely identifying the extension to /// be executed. /// \param[inout] extensionStructure Pointer to a data structure of the type /// defined by the extension to be executed. /// /// \return \c true if the Model does not provide a /// MODEL_ROUTINE_NAME::Extension routine. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Extension routine /// returns \c true. /// \return \c false otherwise. /// /// \sa KIM_Model_Extension, kim_model_module::kim_extension /// /// \since 2.0 int Extension(std::string const & extensionID, void * const extensionStructure); /// \brief Clear influence distance and neighbor list pointers and refresh /// Model object after parameter changes. /// /// Nullify the Model's influence distance, neighbor list cutoff, and \c /// modelWillNotRequestNeighborsOfNoncontributingParticles pointers. Then /// call the Model's MODEL_ROUTINE_NAME::Refresh routine. /// /// \return \c true if the Model does not register any parameters. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Refresh routine /// returns \c true. /// \return \c true if the Model's MODEL_ROUTINE_NAME::Refresh routine /// does not set the influence distance, the number of neighbor lists, /// the neighbor list cutoffs, or the \c /// modelWillNotRequestNeighborsOfNoncontributingParticles pointer. /// \return \c false otherwise. /// /// \sa KIM_Model_ClearThenRefresh, kim_model_module::kim_clear_then_refresh /// /// \since 2.0 int ClearThenRefresh(); /// \brief Call the Model's MODEL_ROUTINE_NAME::WriteParameterizedModel /// routine. /// /// \param[in] path Path string to directory within which the new /// parameterized model files should be written. /// \param[in] modelName Name of the parameterized model to be created. Must /// be a valid C identifier. /// /// \return \c true if the Model object is not a parameterized model. /// \return \c true if \c modelName is not a valid C identifier. /// \return \c true if the Model's /// MODEL_ROUTINE_NAME::WriteParameterizedModel routine returns /// \c true. /// \return \c true if the %KIM API is unable to write the \c CMakeLists.txt /// file. /// \return \c false otherwise. /// /// \sa KIM_Model_WriteParameterizedModel, /// kim_model_module::kim_write_parameterized_model /// /// \since 2.0 int WriteParameterizedModel(std::string const & path, std::string const & modelName) const; /// \brief Get the Model's support and code for the requested SpeciesName. /// /// \param[in] speciesName The SpeciesName of interest. /// \param[out] speciesIsSupported \c true if the Model supports the species /// of interest, \c false otherwise. /// \param[out] code Value used by the Model to refer to the species of /// interest. /// /// \return \c true if \c speciesName is unknown. /// \return \c false otherwise. /// /// \pre \c code may be \c NULL if the value is not needed. /// /// \post \c speciesIsSupported and \c code are unchanged if an error occurs. /// \c code is unchanged if `speciesIsSupported == false`. /// /// \sa KIM_Model_GetSpeciesSupportAndCode, /// kim_model_module::kim_get_species_support_and_code /// /// \since 2.0 int GetSpeciesSupportAndCode(SpeciesName const speciesName, int * const speciesIsSupported, int * const code) const; /// \brief Get the number of parameter arrays provided by the Model. /// /// \param[out] numberOfParameters The number of parameter arrays provided /// by the Model. /// /// \sa KIM_Model_GetNumberOfParameters, /// kim_model_module::kim_get_number_of_parameters /// /// \since 2.0 void GetNumberOfParameters(int * const numberOfParameters) const; /// \brief Get the metadata associated with one of the Model's parameter /// arrays. /// /// \note String pointers obtained from this routine are valid until the /// KIM::Model object is Model::Destroy'd. /// /// \param[in] parameterIndex Zero-based index for the parameter array. /// \param[out] dataType The DataType value for the parameter array. /// \param[out] extent The number of parameters in the array. /// \param[out] name A string identifying the parameter array (will be a valid /// C identifier). /// \param[out] description A free-form string description of the parameter /// array's content. /// /// \return \c true if \c parameterIndex is invalid /// \return \c false otherwise. /// /// \pre \c dataType, \c extent, \c name, or \c description may be \c NULL if /// the corresponding value is not needed. /// /// \sa KIM_Model_GetParameterMetadata, /// kim_model_module::kim_get_parameter_metadata /// /// \since 2.0 int GetParameterMetadata(int const parameterIndex, DataType * const dataType, int * const extent, std::string const ** const name, std::string const ** const description) const; /// \brief Get a parameter value from the Model. /// /// \param[in] parameterIndex Zero-based index for the parameter array of /// interest. /// \param[in] arrayIndex Zero-based index within the array for the parameter /// of interest. /// \param[out] parameterValue The value of the parameter of interest. /// /// \return \c true if \c parameterIndex is invalid. /// \return \c true if the specified parameter and \c parameterValue are of /// different data types. /// \return \c true if \c arrayIndex is invalid. /// \return \c false otherwise. /// /// \sa KIM_Model_GetParameterInteger, KIM_Model_GetParameterDouble, /// kim_model_module::kim_get_parameter /// /// \since 2.0 int GetParameter(int const parameterIndex, int const arrayIndex, int * const parameterValue) const; /// \overload int GetParameter(int const parameterIndex, int const arrayIndex, double * const parameterValue) const; /// \brief Set a parameter value for the Model. /// /// \param[in] parameterIndex Zero-based index for the parameter array of /// interest. /// \param[in] arrayIndex Zero-based index within the array for the parameter /// of interest. /// \param[in] parameterValue The new value for the parameter of interest. /// /// \return \c true if \c parameterIndex is invalid. /// \return \c true if the specified parameter and \c parameterValue are of /// different data types. /// \return \c true if \c arrayIndex is invalid. /// \return \c false otherwise. /// /// \sa KIM_Model_SetParameterInteger, KIM_Model_SetParameterDouble, /// kim_model_module::kim_set_parameter /// /// \since 2.0 int SetParameter(int const parameterIndex, int const arrayIndex, int const parameterValue); /// \overload int SetParameter(int const parameterIndex, int const arrayIndex, double const parameterValue); /// \brief Set the \ref cache_buffer_pointers "Simulator's buffer pointer" /// within the Model object. /// /// The simulator buffer pointer may be used by the simulator to associate /// a memory buffer with the Model object. /// /// \param[in] ptr The simulator buffer data pointer. /// /// \sa KIM_Model_SetSimulatorBufferPointer, /// kim_model_module::kim_set_simulator_buffer_pointer /// /// \since 2.0 void SetSimulatorBufferPointer(void * const ptr); /// \brief Get the \ref cache_buffer_pointers "Simulator's buffer pointer" /// from the Model object. /// /// \param[out] ptr The simulator buffer data pointer. /// /// \note `ptr == NULL` if the simulator has not previously called /// Model::SetSimulatorBufferPointer. /// /// \sa KIM_Model_GetSimulatorBufferPointer, /// kim_model_module::kim_get_simulator_buffer_pointer /// /// \since 2.0 void GetSimulatorBufferPointer(void ** const ptr) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_Model_ToString, kim_model_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; /// \brief Set the identity of the Log object associated with the Model /// object. /// /// \param[in] logID String identifying the Model object's Log object. /// /// \sa KIM_Model_SetLogID, kim_model_module::kim_set_log_id /// /// \since 2.0 void SetLogID(std::string const & logID); /// \brief Push a new LogVerbosity onto the Model object's Log object /// verbosity stack. /// /// \param[in] logVerbosity A LogVerbosity value. /// /// \sa KIM_Model_PushLogVerbosity, kim_model_module::kim_push_log_verbosity /// /// \since 2.0 void PushLogVerbosity(LogVerbosity const logVerbosity); /// \brief Pop a LogVerbosity from the Model object's Log object verbosity /// stack. /// /// \sa KIM_Model_PopLogVerbosity, kim_model_module::kim_pop_log_verbosity /// /// \since 2.0 void PopLogVerbosity(); private: // do not allow copy constructor or operator= Model(Model const &); void operator=(Model const &); Model(); ~Model(); ModelImplementation * pimpl; }; // class Model } // namespace KIM #endif // KIM_MODEL_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelCompute.hpp000066400000000000000000000073741421473465500216650ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_COMPUTE_HPP_ #define KIM_MODEL_COMPUTE_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class ModelComputeImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::Compute routine. /// /// \sa KIM_ModelCompute, /// kim_model_compute_module::kim_model_compute_handle_type /// /// \since 2.0 class ModelCompute { public: /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[out] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelCreate::SetModelBufferPointer or /// ModelDriverCreate::SetModelBufferPointer. /// /// \sa KIM_ModelCompute_GetModelBufferPointer, /// kim_model_compute_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelCompute_LogEntry, kim_model_compute_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelCompute_ToString, kim_model_compute_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelCompute(ModelCompute const &); void operator=(ModelCompute const &); ModelCompute(); ~ModelCompute(); ModelComputeImplementation * pimpl; }; // class ModelCompute } // namespace KIM #endif // KIM_MODEL_COMPUTE_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelComputeArguments.hpp000066400000000000000000000247371421473465500235550ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ #define KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class ComputeArgumentName; class ComputeCallbackName; class ModelComputeArgumentsImplementation; /// \brief Provides the interface to a %KIM API ComputeArguments object for use /// by models within their MODEL_ROUTINE_NAME::Compute routine. /// /// \sa KIM_ModelComputeArguments, /// kim_model_compute_arguments_module::kim_model_compute_arguments_handle_type /// /// \since 2.0 class ModelComputeArguments { public: /// \brief Get the neighbor list for a particle of interest corresponding to /// a particular neighbor list cutoff distance. /// /// \param[in] neighborListIndex Zero-based index corresponding to the /// desired neighbor list cutoff distance. /// \param[in] particleNumber Particle number (using the Model's Numbering, /// as specified in the call to ModelCreate::SetModelNumbering or /// ModelDriverCreate::SetModelNumbering) for the particle of /// interest. /// \param[out] numberOfNeighbors Number of neighbor particles in the list. /// \param[out] neighborsOfParticle Pointer to array of particle neighbor /// numbers (using the Model's Numbering). /// /// \return \c true if \c neighborListIndex is invalid. /// \return \c true if \c particleNumber is invalid. /// \return \c true if the Simulator's COMPUTE_CALLBACK_NAME::GetNeighborList /// routine returns \c true. /// \return \c false otherwise. /// /// \sa KIM_ModelComputeArguments_GetNeighborList, /// kim_model_compute_arguments_module::kim_get_neighbor_list /// /// \since 2.0 int GetNeighborList(int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) const; /// \brief Call the Simulator's COMPUTE_CALLBACK_NAME::ProcessDEDrTerm /// routine. /// /// \todo Add more detailed description of Process mechanism. /// /// \param[in] de Value of DEDr for particle pair. /// \param[in] r Value of particle pair distance, \f$ /// \|\mathbf{r}^{(ij)}\|\f$, where \f$\mathbf{r}^{(ij)} \equiv /// \mathbf{r}^{(j)} - \mathbf{r}^{(i)}\f$ (see the \ref theory /// section). /// \param[in] dx Value of particle pair relative position vector, /// \f$\mathbf{r}^{(ij)}\f$. /// \param[in] i Particle number (using the Model's Numbering, as specified /// in the call to ModelCreate::SetModelNumbering or /// ModelDriverCreate::SetModelNumbering) for first particle in /// pair. /// \param[in] j Particle number (using the Model's Numbering) for second /// particle in pair. /// /// \returns \c true if the Simulator's /// COMPUTE_CALLBACK_NAME::ProcessDEDrTerm routine returns \c true. /// \returns \c false otherwise. /// /// \sa KIM_ModelComputeArguments_ProcessDEDrTerm, /// kim_model_compute_arguments_module::kim_process_dedr_term /// /// \since 2.0 int ProcessDEDrTerm(double const de, double const r, double const * const dx, int const i, int const j) const; /// \brief Call the Simulator's COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term /// routine. /// /// \todo Add more detailed description of Process mechanism. /// /// \param[in] de Value of D2EDr2 for particle pairs. /// \param[in] r Array of particle pair distances. /// \param[in] dx Array of particle pair relative position vectors. /// \param[in] i Array of particle numbers (using the Model's Numbering, as /// specified in the call to ModelCreate::SetModelNumbering or /// ModelDriverCreate::SetModelNumbering) for first particle in /// each pair. /// \param[in] j Array of particle numbers (using the Model's Numbering) for /// second particle in each pair. /// /// \returns \c true if the Simulator's /// COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term routine returns \c /// true. /// \returns \c false otherwise. /// /// \sa KIM_ModelComputeArguments_ProcessD2EDr2Term, /// kim_model_compute_arguments_module::kim_process_d2edr2_term /// /// \since 2.0 int ProcessD2EDr2Term(double const de, double const * const r, double const * const dx, int const * const i, int const * const j) const; /// \brief Get the data pointer for a ComputeArgumentName. /// /// \param[in] computeArgumentName The ComputeArgumentName of interest. /// \param[out] ptr The data pointer. /// /// \return \c true if \c computeArgumentName is unknown. /// \return \c true if `computeArgumentName == SUPPORT_STATUS::notSupported`. /// \return \c false otherwise. /// /// \sa KIM_ModelComputeArguments_GetArgumentPointerInteger, /// KIM_ModelComputeArguments_GetArgumentPointerDouble, /// kim_model_compute_arguments_module::kim_get_argument_pointer /// /// \since 2.0 int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int const ** const ptr) const; /// \overload int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int ** const ptr) const; /// \overload int GetArgumentPointer(ComputeArgumentName const computeArgumentName, double const ** const ptr) const; /// \overload int GetArgumentPointer(ComputeArgumentName const computeArgumentName, double ** const ptr) const; /// \brief Determine if the Simulator has provided a non-NULL function /// pointer for a ComputeCallbackName of interest. /// /// \param[in] computeCallbackName The ComputeCallbackName of interest. /// \param[out] present Is \c true if the callback's function pointer is /// non-NULL, and is \c false otherwise. /// /// \return \c true if \c computeArgumentName is unknown. /// \return \c true if \c computeArguemntName is SUPPORT_STATUS::notSupported. /// \return \c false otherwise. /// /// \post \c present is unchanged in an error occurs. /// /// \sa KIM_ModelComputeArguments_IsCallbackPresent, /// kim_model_compute_arguments_module::kim_is_callback_present /// /// \since 2.0 int IsCallbackPresent(ComputeCallbackName const computeCallbackName, int * const present) const; /// \brief Set the \ref cache_buffer_pointers "Model's buffer pointer" /// within the ComputeArguments object. /// /// The model buffer pointer may be used by the model to associate /// a memory buffer with the ComputeArguments object. /// /// \param[in] ptr The model buffer data pointer. /// /// \sa KIM_ModelComputeArguments_SetModelBufferPointer, /// kim_model_compute_arguments_module::kim_set_model_buffer_pointer /// /// \since 2.0 void SetModelBufferPointer(void * const ptr); /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the ComputeArguments object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the ComputeArguments object. /// /// \param[out] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelComputeArguments::SetModelBufferPointer. /// /// \sa KIM_ModelComputeArguments_GetModelBufferPointer, /// kim_model_compute_arguments_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelComputeArguments_LogEntry, /// kim_model_compute_arguments_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the /// ComputeArguments object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelComputeArguments_ToString, /// kim_model_compute_arguments_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelComputeArguments(ModelComputeArguments const &); void operator=(ModelComputeArguments const &); ModelComputeArguments(); ~ModelComputeArguments(); ModelComputeArgumentsImplementation * pimpl; }; // class ModelComputeArguments } // namespace KIM #endif // KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelComputeArgumentsCreate.hpp000066400000000000000000000131141421473465500246640ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ #define KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class SupportStatus; class ComputeArgumentName; class ComputeCallbackName; class ModelComputeArgumentsCreateImplementation; /// \brief Provides the interface to a %KIM API ComputeArguments object for use /// by models within their MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine. /// /// \sa KIM_ModelComputeArgumentsCreate, /// kim_model_compute_arguments_create_module::kim_model_compute_arguments_create_handle_type /// /// \since 2.0 class ModelComputeArgumentsCreate { public: /// \brief Set the SupportStatus of a ComputeArgumentName. /// /// \param[in] computeArgumentName The ComputeArgumentName of interest. /// \param[in] supportStatus The corresponding SupportStatus. /// /// \return \c true if \c computeArgumentName is unknown. /// \return \c true if \c computeArgumentName is SUPPORT_STATUS::requiredByAPI /// and \c supportStatus is not SUPPORT_STATUS::requiredByAPI. /// \return \c false otherwise. /// /// \sa KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus, /// kim_model_compute_arguments_create_module::kim_set_argument_support_status /// /// \since 2.0 int SetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus); /// \brief Set the SupportStatus of a ComputeCallbackName. /// /// \param[in] computeCallbackName The ComputeCallbackName of interest. /// \param[in] supportStatus The corresponding SupportStatus. /// /// \return \c true if \c computeCallbackName is unknown. /// \return \c true if \c computeCallbackName is SUPPORT_STATUS::requiredByAPI /// and \c supportStatus is not SUPPORT_STATUS::requiredByAPI. /// \return \c false otherwise. /// /// \sa KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus, /// kim_model_compute_arguments_create_module::kim_set_callback_support_status /// /// \since 2.0 int SetCallbackSupportStatus(ComputeCallbackName const computeCallbackName, SupportStatus const supportStatus); /// \brief Set the \ref cache_buffer_pointers "Model's buffer pointer" /// within the ComputeArguments object. /// /// The model buffer pointer may be used by the model to associate a memory /// buffer with the ComputeArguments object. /// /// \param[in] ptr The model buffer data pointer. /// /// \sa KIM_ModelComputeArguments_SetModelBufferPointer, /// kim_model_compute_arguments_create_module::kim_set_model_buffer_pointer /// /// \since 2.0 void SetModelBufferPointer(void * const ptr); /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelComputeArgumentsCreate_LogEntry, /// kim_model_compute_arguments_create_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the /// ComputeArguments object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelComputeArgumentsCreate_ToString, /// kim_model_compute_arguments_create_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelComputeArgumentsCreate(ModelComputeArgumentsCreate const &); void operator=(ModelComputeArgumentsCreate const &); ModelComputeArgumentsCreate(); ~ModelComputeArgumentsCreate(); ModelComputeArgumentsCreateImplementation * pimpl; }; // class ModelComputeArgumentsCreate } // namespace KIM #endif // KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelComputeArgumentsDestroy.hpp000066400000000000000000000102071421473465500251120ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ #define KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class ModelComputeArgumentsDestroyImplementation; /// \brief Provides the interface to a %KIM API ComputeArguments object for use /// by models within their MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine. /// /// \sa KIM_ModelComputeArgumentsDestroy, /// kim_model_compute_arguments_destroy_module::kim_model_compute_arguments_destroy_handle_type /// /// \since 2.0 class ModelComputeArgumentsDestroy { public: /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the ComputeArguments object. /// /// The model buffer pointer may be used by the model to associate /// a memory buffer with the ComputeArguments object. /// /// \param[in] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelComputeArguments::SetModelBufferPointer. /// /// \sa KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer, /// kim_model_compute_arguments_destroy_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelComputeArgumentsDestroy_LogEntry, /// kim_model_compute_arguments_destroy_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the /// ComputeArguments object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelComputeArgumentsDestroy_ToString, /// kim_model_compute_arguments_destroy_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelComputeArgumentsDestroy(ModelComputeArgumentsDestroy const &); void operator=(ModelComputeArgumentsDestroy const &); ModelComputeArgumentsDestroy(); ~ModelComputeArgumentsDestroy(); ModelComputeArgumentsDestroyImplementation * pimpl; }; // class ModelComputeArgumentsDestroy } // namespace KIM #endif // KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelCreate.hpp000066400000000000000000000342201421473465500214420ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_CREATE_HPP_ #define KIM_MODEL_CREATE_HPP_ #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" // IWYU pragma: export #endif namespace KIM { // Forward declarations class LogVerbosity; class LanguageName; class Numbering; class ModelRoutineName; class SpeciesName; class LengthUnit; class EnergyUnit; class ChargeUnit; class TemperatureUnit; class TimeUnit; class ModelCreateImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::Create routine. /// /// \sa ModelDriverCreate, KIM_ModelCreate, KIM_ModelDriverCreate, /// kim_model_driver_create_module::kim_model_driver_create_handle_type /// /// \since 2.0 class ModelCreate { public: /// \brief Set the Model's particle Numbering. /// /// \param[in] numbering The Model's particle Numbering. /// /// \return \c true if \c numbering is unknown. /// \return \c false otherwise. /// /// \sa ModelDriverCreate::SetModelNumbering, /// KIM_ModelCreate_SetModelNumbering, /// KIM_ModelDriverCreate_SetModelNumbering, /// kim_model_driver_create_module::kim_set_model_numbering /// /// \since 2.0 int SetModelNumbering(Numbering const numbering); /// \brief Set the Model's influence distance data pointer. /// /// \todo Add more detailed description of \c influenceDistance (or link to /// docs elsewhere?) /// /// \param[in] influenceDistance Pointer to Model's influence distance. /// /// \note The model is responsible for allocating the memory associated with /// the influence distance data. The model must use the \ref /// cache_buffer_pointers "Model's buffer pointer" to retain access to this /// memory location and avoid a memory leak. /// /// \sa ModelDriverCreate::SetInfluenceDistancePointer, /// KIM_ModelCreate_SetInfluenceDistancePointer, /// KIM_ModelDriverCreate_SetInfluenceDistancePointer, /// kim_model_driver_create_module::kim_set_influence_distance_pointer /// /// \since 2.0 void SetInfluenceDistancePointer(double const * const influenceDistance); /// \brief Set the Model's neighbor list data pointers. /// /// \todo Add more detailed description /// /// \param[in] numberOfNeighborLists The number of neighbor lists required by /// the Model. /// \param[in] cutoffs Array of cutoff values for each of the required /// neighbor lists. /// \param[in] modelWillNotRequestNeighborsOfNoncontributingParticles Array /// of integers; \c true or \c false for each neighbor list /// required by the Model. /// /// \note The model is responsible for allocating the memory associated with /// the neighbor list cutoffs and \c /// modelWillNotRequestNeighborsOfNoncontributingParticles data. The model /// must use the \ref cache_buffer_pointers "Model's buffer pointer" to /// retain access to this memory location and avoid a memory leak. /// /// \sa ModelDriverCreate::SetNeighborListPointers, /// KIM_ModelCreate_SetNeighborListPointers, /// KIM_ModelDriverCreate_SetNeighborListPointers, /// kim_model_driver_create_module::kim_set_neighbor_list_pointers /// /// \since 2.0 void SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); /// \brief Set the function pointer for the ModelRoutineName of interest. /// /// \param[in] modelRoutineName The ModelRoutineName of interest. /// \param[in] languageName The LanguageName of the ModelRoutineName. /// \param[in] required Integer, \c true if the model requires the simulator /// to call the associated ModelRoutineName in order to be used /// correctly, \c false otherwise. /// \param[in] fptr Function pointer for the Model's ModelRoutineName /// routine. /// /// \return \c true if \c modelRoutineName or \c langaugeName are unknown. /// \return \c true if `required == false` and \c modelRoutineName has /// SupportStatus SUPPORT_STATUS::requiredByAPI. /// \return \c false otherwise. /// /// \sa ModelDriverCreate::SetRoutinePointer, /// KIM_ModelCreate_SetRoutinePointer, /// KIM_ModelDriverCreate_SetRoutinePointer, /// kim_model_driver_create_module::kim_set_routine_pointer /// /// \since 2.0 int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function * const fptr); /// \brief Set integer code for supported SpeciesName. /// /// A call to this routine adds/updates the list of SpeciesName's supported /// by the Model and associates the specified SpeciesName with the integer /// code to be used within the COMPUTE_ARGUMENT_NAME::particleSpeciesCodes /// argument. /// /// \param[in] speciesName The SpeciesName of interest. /// \param[in] code The associated code. /// /// \return \c true if \c speciesName is unknown. /// \return \c false otherwise. /// /// \sa ModelDriverCreate::SetSpeciesCode, KIM_ModelCreate_SetSpeciesCode, /// KIM_ModelDriverCreate_SetSpeciesCode, /// kim_model_driver_create_module::kim_set_species_code /// /// \since 2.0 int SetSpeciesCode(SpeciesName const speciesName, int const code); /// \brief Set the next parameter data pointer to be provided by the model. /// /// This routine is called once for each parameter array to be provided by /// the model. The order of these calls is important and determines the /// index assigned to each parameter array for use in the Model::GetParameter /// and related routines. /// /// \param[in] extent The number of entries in the parameter array. /// \param[in] ptr The parameter array data pointer. /// \param[in] name A brief unique name for the parameter array. This name /// must be a valid C identifier. /// \param[in] description A free-form text description of the parameter /// array. This should include details about the data layout /// (e.g., the array corresponds to a square upper-triangular /// matrix in row-major storage). /// /// \note The model is responsible for allocating the memory associated with /// the parameter array data. The model must use the \ref /// cache_buffer_pointers "Model's buffer pointer" to retain access to this /// memory location and avoid a memory leak. /// /// \sa ModelDriverCreate::SetParameterPointer, /// KIM_ModelCreate_SetParameterPointerInteger, /// KIM_ModelCreate_SetParameterPointerDouble, /// KIM_ModelDriverCreate_SetParameterPointerInteger, /// KIM_ModelDriverCreate_SetParameterPointerDouble, /// kim_model_driver_create_module::kim_set_parameter_pointer /// /// \since 2.0 int SetParameterPointer(int const extent, int * const ptr, std::string const & name, std::string const & description); /// \overload int SetParameterPointer(int const extent, double * const ptr, std::string const & name, std::string const & description); /// \brief Set the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[in] ptr The model buffer data pointer. /// /// \sa ModelDriverCreate::SetModelBufferPointer, /// KIM_ModelCreate_SetModelBufferPointer, /// KIM_ModelDriverCreate_SetModelBufferPointer, /// kim_model_driver_create_module::kim_set_model_buffer_pointer /// /// \since 2.0 void SetModelBufferPointer(void * const ptr); /// \brief Set the Model's base unit values. /// /// \param[in] lengthUnit The Model's base LengthUnit. /// \param[in] energyUnit The Model's base EnergyUnit. /// \param[in] chargeUnit The Model's base ChargeUnit. /// \param[in] temperatureUnit The Model's base TemperatureUnit. /// \param[in] timeUnit The Model's base TimeUnit. /// /// \note A unit of \c unused indicates the the Model does not deal with any /// quantities whose derived unit involves the corresponding base unit. For /// example, many models only deal with quantities that are derived from just /// the energy and length base units (such as force, virial, etc.), and thus /// should set \c chargeUnit, \c temperatureUnit, and \c timeUnit to \c /// unused. /// /// \return \c true if any of the base units are unknown. /// \return \c true if \c lengthUnit or \c energyUnit are unused. /// \return \c false otherwise. /// /// \sa ModelDriverCreate::SetUnits, KIM_ModelCreate_SetUnits, /// KIM_ModelDriverCreate_SetUnits, /// kim_model_driver_create_module::kim_set_units /// /// \since 2.0 int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit); /// \brief Get the multiplicative factor to convert between a derived unit /// represented in two different sets of base units. /// /// \param[in] fromLengthUnit The "from" base length unit. /// \param[in] fromEnergyUnit The "from" base energy unit. /// \param[in] fromChargeUnit The "from" base charge unit. /// \param[in] fromTemperatureUnit The "from" base temperature unit. /// \param[in] fromTimeUnit The "from" base time unit. /// \param[in] toLengthUnit The "to" base length unit. /// \param[in] toEnergyUnit The "to" base energy unit. /// \param[in] toChargeUnit The "to" base charge unit. /// \param[in] toTemperatureUnit The "to" base temperature unit. /// \param[in] toTimeUnit The "to" base time unit. /// \param[in] lengthExponent The derived unit's length exponent. /// \param[in] energyExponent The derived unit's energy exponent. /// \param[in] chargeExponent The derived unit's charge exponent. /// \param[in] temperatureExponent The derived unit's temperature exponent. /// \param[in] timeExponent The derived unit's time exponent. /// \param[out] conversionFactor The desired conversion factor. /// /// \return \c true if any of the base units are unknown. /// \return \c true if any of the base units are \c unused and the /// corresponding exponent is nonzero. /// \return \c false otherwise. /// /// \sa ModelDriverCreate::ConvertUnit, KIM_ModelCreate_ConvertUnit, /// KIM_ModelDriverCreate_ConvertUnit, /// kim_model_driver_create_module::kim_convert_unit /// /// \since 2.0 static int ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor); /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelCreate_LogEntry, /// kim_model_driver_create_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelCreate_ToString, /// kim_model_driver_create_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelCreate(ModelCreate const &); void operator=(ModelCreate const &); ModelCreate(); ~ModelCreate(); ModelCreateImplementation * pimpl; }; // class ModelCreate } // namespace KIM #endif // KIM_MODEL_CREATE_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelDestroy.hpp000066400000000000000000000073741421473465500217020ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_DESTROY_HPP_ #define KIM_MODEL_DESTROY_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class ModelDestroyImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::Destroy routine. /// /// \sa KIM_ModelDestroy, /// kim_model_destroy_module::kim_model_destroy_handle_type /// /// \since 2.0 class ModelDestroy { public: /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[out] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelCreate::SetModelBufferPointer or /// ModelDriverCreate::SetModelBufferPointer. /// /// \sa KIM_ModelDestroy_GetModelBufferPointer, /// kim_model_destroy_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelDestroy_LogEntry, kim_model_destroy_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelDestroy_ToString, kim_model_destroy_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelDestroy(ModelDestroy const &); void operator=(ModelDestroy const &); ModelDestroy(); ~ModelDestroy(); ModelDestroyImplementation * pimpl; }; // class ModelDestroy } // namespace KIM #endif // KIM_MODEL_DESTROY_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelDriverCreate.hpp000066400000000000000000000413041421473465500226170ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_DRIVER_CREATE_HPP_ #define KIM_MODEL_DRIVER_CREATE_HPP_ #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" // IWYU pragma: export #endif namespace KIM { // Forward declarations class LogVerbosity; class LanguageName; class Numbering; class ModelRoutineName; class SpeciesName; class LengthUnit; class EnergyUnit; class ChargeUnit; class TemperatureUnit; class TimeUnit; class ModelDriverCreateImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::Create routine. /// /// \sa ModelCreate, KIM_ModelDriverCreate, KIM_ModelCreate, /// kim_model_driver_create_module::kim_model_driver_create_handle_type /// /// \since 2.0 class ModelDriverCreate { public: /// \brief Get absolute path name of the temporary directory where parameter /// files provided by the model are written. /// /// \param[out] directoryName The absolute path name of the Model's /// temporary parameter file directory. /// /// \sa KIM_ModelDriverCreate_GetParameterFileDirectoryName, /// kim_model_driver_create_module::kim_get_parameter_file_directory_name /// /// \since 2.2 void GetParameterFileDirectoryName(std::string const ** const directoryName) const; /// \brief Get the number of parameter files provided by the parameterized /// model. /// /// \param[out] numberOfParameterFiles The number of parameter files. /// /// \sa KIM_ModelDriverCreate_GetNumberOfParameterFiles, /// kim_model_driver_create_module::kim_get_number_of_parameter_files /// /// \since 2.0 void GetNumberOfParameterFiles(int * const numberOfParameterFiles) const; /// \brief Get a particular parameter file name. /// /// \param[in] index Zero-based index for the parameter file of interest. /// \param[out] parameterFileName The fully-qualified path name for the /// parameter file of interest. /// /// \return \c true if the Model object is not a parameterized model /// \return \c true if \c index is invalid. /// \return \c true if `parameterFileName == NULL`. /// \return \c false otherwise. /// /// \sa KIM_ModelDriverCreate_GetParameterFileName, /// kim_model_driver_create_module::kim_get_parameter_file_name /// /// \since 2.0 /// /// \deprecated As of 2.2. Please use GetParameterFileDirectoryName() and /// GetParameterFileBasename() instead. int GetParameterFileName(int const index, std::string const ** const parameterFileName) const; /// \brief Get a particular parameter file basename. The file is located in /// the Model's parameter file directory. /// /// \param[in] index Zero-based index for the parameter file of interest. /// \param[out] parameterFileBasename The basename (file name without path) /// for the parameter file of interest. /// /// \return \c true if the Model object is not a parameterized model /// \return \c true if \c index is invalid. /// \return \c true if `parameterFileBasename == NULL`. /// \return \c false otherwise. /// /// \sa KIM_ModelDriverCreate_GetParameterFileBasename, /// kim_model_driver_create_module::kim_get_parameter_file_basename /// /// \since 2.2 int GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const; /// \brief Set the Model's particle Numbering. /// /// \param[in] numbering The Model's particle Numbering. /// /// \return \c true if \c numbering is unknown. /// \return \c false otherwise. /// /// \sa ModelCreate::SetModelNumbering, /// KIM_ModelDriverCreate_SetModelNumbering, /// KIM_ModelCreate_SetModelNumbering, /// kim_model_driver_create_module::kim_set_model_numbering /// /// \since 2.0 int SetModelNumbering(Numbering const numbering); /// \brief Set the Model's influence distance data pointer. /// /// \todo Add more detailed description of \c influenceDistance (or link to /// docs elsewhere?) /// /// \param[in] influenceDistance Pointer to Model's influence distance. /// /// \note The model is responsible for allocating the memory associated with /// the influence distance data. The model must use the \ref /// cache_buffer_pointers "Model's buffer pointer" to retain access to this /// memory location and avoid a memory leak. /// /// \sa ModelCreate::SetInfluenceDistancePointer, /// KIM_ModelDriverCreate_SetInfluenceDistancePointer, /// KIM_ModelCreate_SetInfluenceDistancePointer, /// kim_model_driver_create_module::kim_set_influence_distance_pointer /// /// \since 2.0 void SetInfluenceDistancePointer(double const * const influenceDistance); /// \brief Set the Model's neighbor list data pointers. /// /// \todo Add more detailed description /// /// \param[in] numberOfNeighborLists The number of neighbor lists required by /// the Model. /// \param[in] cutoffs Array of cutoff values for each of the required /// neighbor lists. /// \param[in] modelWillNotRequestNeighborsOfNoncontributingParticles Array /// of integers; \c true or \c false for each neighbor list /// required by the Model. /// /// \note The model is responsible for allocating the memory associated with /// the neighbor list cutoffs and \c /// modelWillNotRequestNeighborsOfNoncontributingParticles data. The model /// must use the \ref cache_buffer_pointers "Model's buffer pointer" to /// retain access to this memory location and avoid a memory leak. /// /// \sa ModelCreate::SetNeighborListPointers, /// KIM_ModelDriverCreate_SetNeighborListPointers, /// KIM_ModelCreate_SetNeighborListPointers, /// kim_model_driver_create_module::kim_set_neighbor_list_pointers /// /// \since 2.0 void SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); /// \brief Set the function pointer for the ModelRoutineName of interest. /// /// \param[in] modelRoutineName The ModelRoutineName of interest. /// \param[in] languageName The LanguageName of the ModelRoutineName. /// \param[in] required Integer, \c true if the model requires the simulator /// to call the associated ModelRoutineName in order to be used /// correctly, \c false otherwise. /// \param[in] fptr Function pointer for the Model's ModelRoutineName /// routine. /// /// \return \c true if \c modelRoutineName or \c langaugeName are unknown. /// \return \c true if `required == false` and \c modelRoutineName has /// SupportStatus SUPPORT_STATUS::requiredByAPI. /// \return \c false otherwise. /// /// \sa ModelCreate::SetRoutinePointer, KIM_ModelCreate_SetRoutinePointer, /// KIM_ModelDriverCreate_SetRoutinePointer, /// kim_model_driver_create_module::kim_set_routine_pointer /// /// \since 2.0 int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function * const fptr); /// \brief Set integer code for supported SpeciesName. /// /// A call to this routine adds/updates the list of SpeciesName's supported /// by the Model and associates the specified SpeciesName with the integer /// code to be used within the COMPUTE_ARGUMENT_NAME::particleSpeciesCodes /// argument. /// /// \param[in] speciesName The SpeciesName of interest. /// \param[in] code The associated code. /// /// \return \c true if \c speciesName is unknown. /// \return \c false otherwise. /// /// \sa ModelCreate::SetSpeciesCode, KIM_ModelDriverCreate_SetSpeciesCode, /// KIM_ModelCreate_SetSpeciesCode, /// kim_model_driver_create_module::kim_set_species_code /// /// \since 2.0 int SetSpeciesCode(SpeciesName const speciesName, int const code); /// \brief Set the next parameter data pointer to be provided by the model. /// /// This routine is called once for each parameter array to be provided by /// the model. The order of these calls is important and determines the /// index assigned to each parameter array for use in the Model::GetParameter /// and related routines. /// /// \param[in] extent The number of entries in the parameter array. /// \param[in] ptr The parameter array data pointer. /// \param[in] name A brief unique name for the parameter array. This name /// must be a valid C identifier. /// \param[in] description A free-form text description of the parameter /// array. This should include details about the data layout /// (e.g., the array corresponds to a square upper-triangular /// matrix in row-major storage). /// /// \note The model is responsible for allocating the memory associated with /// the parameter array data. The model must use the \ref /// cache_buffer_pointers "Model's buffer pointer" to retain access to this /// memory location and avoid a memory leak. /// /// \sa ModelCreate::SetParameterPointer, /// KIM_ModelDriverCreate_SetParameterPointerInteger, /// KIM_ModelDriverCreate_SetParameterPointerDouble, /// KIM_ModelCreate_SetParameterPointerInteger, /// KIM_ModelCreate_SetParameterPointerDouble, /// kim_model_driver_create_module::kim_set_parameter_pointer /// /// \since 2.0 int SetParameterPointer(int const extent, int * const ptr, std::string const & name, std::string const & description); /// \overload int SetParameterPointer(int const extent, double * const ptr, std::string const & name, std::string const & description); /// \brief Set the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[in] ptr The model buffer data pointer. /// /// \sa ModelCreate::SetModelBufferPointer, /// KIM_ModelDriverCreate_SetModelBufferPointer, /// KIM_ModelCreate_SetModelBufferPointer, /// kim_model_driver_create_module::kim_set_model_buffer_pointer /// /// \since 2.0 void SetModelBufferPointer(void * const ptr); /// \brief Set the Model's base unit values. /// /// \param[in] lengthUnit The Model's base LengthUnit. /// \param[in] energyUnit The Model's base EnergyUnit. /// \param[in] chargeUnit The Model's base ChargeUnit. /// \param[in] temperatureUnit The Model's base TemperatureUnit. /// \param[in] timeUnit The Model's base TimeUnit. /// /// \note A unit of \c unused indicates the the Model does not deal with any /// quantities whose derived unit involves the corresponding base unit. For /// example, many models only deal with quantities that are derived from just /// the energy and length base units (such as force, virial, etc.), and thus /// should set \c chargeUnit, \c temperatureUnit, and \c timeUnit to \c /// unused. /// /// \return \c true if any of the base units are unknown. /// \return \c true if \c lengthUnit or \c energyUnit are unused. /// \return \c false otherwise. /// /// \sa ModelCreate::SetUnits, KIM_ModelDriverCreate_SetUnits, /// KIM_ModelCreate_SetUnits, kim_model_driver_create_module::kim_set_units /// /// \since 2.0 int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit); /// \brief Get the multiplicative factor to convert between a derived unit /// represented in two different sets of base units. /// /// \param[in] fromLengthUnit The "from" base length unit. /// \param[in] fromEnergyUnit The "from" base energy unit. /// \param[in] fromChargeUnit The "from" base charge unit. /// \param[in] fromTemperatureUnit The "from" base temperature unit. /// \param[in] fromTimeUnit The "from" base time unit. /// \param[in] toLengthUnit The "to" base length unit. /// \param[in] toEnergyUnit The "to" base energy unit. /// \param[in] toChargeUnit The "to" base charge unit. /// \param[in] toTemperatureUnit The "to" base temperature unit. /// \param[in] toTimeUnit The "to" base time unit. /// \param[in] lengthExponent The derived unit's length exponent. /// \param[in] energyExponent The derived unit's energy exponent. /// \param[in] chargeExponent The derived unit's charge exponent. /// \param[in] temperatureExponent The derived unit's temperature exponent. /// \param[in] timeExponent The derived unit's time exponent. /// \param[out] conversionFactor The desired conversion factor. /// /// \return \c true if any of the base units are unknown. /// \return \c true if any of the base units are \c unused and the /// corresponding exponent is nonzero. /// \return \c false otherwise. /// /// \sa ModelCreate::ConvertUnit, KIM_ModelDriverCreate_ConvertUnit, /// KIM_ModelCreate_ConvertUnit, /// kim_model_driver_create_module::kim_convert_unit /// /// \since 2.0 static int ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor); /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelDriverCreate_LogEntry, /// kim_model_driver_create_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelCreate_ToString, /// kim_model_driver_create_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelDriverCreate(ModelDriverCreate const &); void operator=(ModelDriverCreate const &); ModelDriverCreate(); ~ModelDriverCreate(); ModelDriverCreateImplementation * pimpl; }; // class ModelDriverCreate } // namespace KIM #endif // KIM_MODEL_DRIVER_CREATE_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelDriverHeaders.hpp000066400000000000000000000052551421473465500227740ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_DRIVER_HEADERS_HPP_ #define KIM_MODEL_DRIVER_HEADERS_HPP_ // IWYU pragma: begin_exports #ifndef KIM_MODEL_DRIVER_CREATE_HPP_ #include "KIM_ModelDriverCreate.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ #include "KIM_ModelComputeArgumentsCreate.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ModelComputeArguments.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ #include "KIM_ModelComputeArgumentsDestroy.hpp" #endif #ifndef KIM_MODEL_COMPUTE_HPP_ #include "KIM_ModelCompute.hpp" #endif #ifndef KIM_MODEL_EXTENSION_HPP_ #include "KIM_ModelExtension.hpp" #endif #ifndef KIM_MODEL_REFRESH_HPP_ #include "KIM_ModelRefresh.hpp" #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ #include "KIM_ModelWriteParameterizedModel.hpp" #endif #ifndef KIM_MODEL_DESTROY_HPP_ #include "KIM_ModelDestroy.hpp" #endif // IWYU pragma: end_exports #endif // KIM_MODEL_DRIVER_HEADERS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelExtension.hpp000066400000000000000000000167261421473465500222260ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_EXTENSION_HPP_ #define KIM_MODEL_EXTENSION_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class Model; class ModelCompute; class ModelCreate; class ModelDestroy; class ModelDriverCreate; class ModelRefresh; class ModelWriteParameterizedModel; class ComputeArguments; class ModelComputeArguments; class ModelComputeArgumentsCreate; class ModelComputeArgumentsDestroy; class ModelExtensionImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::Extension routine. /// /// \sa KIM_ModelExtension, /// kim_model_extension_module::kim_model_extension_handle_type /// /// \since 2.0 class ModelExtension { public: /// \brief Get the extension identification string. /// /// \param[out] extensionID The extension identification string. /// /// \sa KIM_ModelExtension_GetExtensionID, /// kim_model_extension_module::kim_get_extension_id /// /// \since 2.0 void GetExtensionID(std::string const ** const extensionID) const; /// \brief Convert the ModelExtension interface to the Model object to a /// Model interface. /// /// \sa KIM_ModelExtension_ToModel, kim_model_extension_module::kim_to_model /// /// \since 2.0 KIM::Model * Model(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelCompute interface. /// /// \sa KIM_ModelExtension_ToModelCompute, /// kim_model_extension_module::kim_to_model_compute /// /// \since 2.0 KIM::ModelCompute * ModelCompute(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelCreate interface. /// /// \sa KIM_ModelExtension_ToModelCreate, /// kim_model_extension_module::kim_to_model_create /// /// \since 2.0 KIM::ModelCreate * ModelCreate(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelDestroy interface. /// /// \sa KIM_ModelExtension_ToModelDestroy, /// kim_model_extension_module::kim_to_model_destroy /// /// \since 2.0 KIM::ModelDestroy * ModelDestroy(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelDriverCreate interface. /// /// \sa KIM_ModelExtension_ToModelDriverCreate, /// kim_model_extension_module::kim_to_model_driver_create /// /// \since 2.0 KIM::ModelDriverCreate * ModelDriverCreate(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelRefresh interface. /// /// \sa KIM_ModelExtension_ToModelRefresh, /// kim_model_extension_module::kim_to_model_refresh /// /// \since 2.0 KIM::ModelRefresh * ModelRefresh(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelWriteParameterizedModel interface. /// /// \sa KIM_ModelExtension_ToModelWriteParameterizedModel, /// kim_model_extension_module::kim_to_model_write_parameterized_model /// /// \since 2.0 KIM::ModelWriteParameterizedModel * ModelWriteParameterizedModel(); /// \brief Convert the ModelExtension interface to the Model object to a /// ModelComputeArguments interface. /// /// \sa KIM_ModelExtension_ToModelComputeArguments, /// kim_model_extension_module::kim_to_model_compute_arguments /// /// \since 2.0 KIM::ModelComputeArguments * ModelComputeArguments(ComputeArguments * const computeArguments) const; /// \brief Convert the ModelExtension interface to the Model object to a /// ModelComputeArgumentsCreate interface. /// /// \sa KIM_ModelExtension_ToModelComputeArgumentsCreate, /// kim_model_extension_module::kim_to_model_compute_arguments_create /// /// \since 2.0 KIM::ModelComputeArgumentsCreate * ModelComputeArgumentsCreate(ComputeArguments * const computeArguments) const; /// \brief Convert the ModelExtension interface to the Model object to a /// ModelComputeArgumentsDestroy interface. /// /// \sa KIM_ModelExtension_ToModelComputeArgumentsDestroy, /// kim_model_extension_module::kim_to_model_compute_arguments_destroy /// /// \since 2.0 KIM::ModelComputeArgumentsDestroy * ModelComputeArgumentsDestroy(ComputeArguments * const computeArguments) const; /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[out] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelCreate::SetModelBufferPointer or /// ModelDriverCreate::SetModelBufferPointer. /// /// \sa KIM_ModelExtension_GetModelBufferPointer, /// kim_model_extension_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelExtension_LogEntry, /// kim_model_extension_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelExtension_ToString, /// kim_model_extension_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelExtension(ModelExtension const &); void operator=(ModelExtension const &); ModelExtension(); ~ModelExtension(); ModelExtensionImplementation * pimpl; }; // class ModelExtension } // namespace KIM #endif // KIM_MODEL_EXTENSION_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelHeaders.hpp000066400000000000000000000052131421473465500216120ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_HEADERS_HPP_ #define KIM_MODEL_HEADERS_HPP_ // IWYU pragma: begin_exports #ifndef KIM_MODEL_CREATE_HPP_ #include "KIM_ModelCreate.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ #include "KIM_ModelComputeArgumentsCreate.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ModelComputeArguments.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ #include "KIM_ModelComputeArgumentsDestroy.hpp" #endif #ifndef KIM_MODEL_COMPUTE_HPP_ #include "KIM_ModelCompute.hpp" #endif #ifndef KIM_MODEL_EXTENSION_HPP_ #include "KIM_ModelExtension.hpp" #endif #ifndef KIM_MODEL_REFRESH_HPP_ #include "KIM_ModelRefresh.hpp" #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ #include "KIM_ModelWriteParameterizedModel.hpp" #endif #ifndef KIM_MODEL_DESTROY_HPP_ #include "KIM_ModelDestroy.hpp" #endif // IWYU pragma: end_exports #endif // KIM_MODEL_HEADERS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelRefresh.hpp000066400000000000000000000132271421473465500216410ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_REFRESH_HPP_ #define KIM_MODEL_REFRESH_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class ModelRefreshImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::Refresh routine. /// /// \sa KIM_ModelRefresh, /// kim_model_refresh_module::kim_model_refresh_handle_type /// /// \since 2.0 class ModelRefresh { public: /// \brief Set the Model's influence distance data pointer. /// /// \todo Add more detailed description of \c influenceDistance (or link to /// docs elsewhere?) /// /// \param[in] influenceDistance Pointer to Model's influence distance. /// /// \note The model is responsible for allocating the memory associated with /// the influence distance data. The model must use the \ref /// cache_buffer_pointers "Model's buffer pointer" to retain access to this /// memory location and avoid a memory leak. /// /// \sa KIM_ModelRefresh_SetInfluenceDistancePointer, /// kim_model_refresh_module::kim_set_influence_distance_pointer /// /// \since 2.0 void SetInfluenceDistancePointer(double const * const influenceDistance); /// \brief Set the Model's neighbor list data pointers. /// /// \todo Add more detailed description /// /// \param[in] numberOfNeighborLists The number of neighbor lists required by /// the Model. /// \param[in] cutoffs Array of cutoff values for each of the required /// neighbor lists. /// \param[in] modelWillNotRequestNeighborsOfNoncontributingParticles Array /// of integers; \c true or \c false for each neighbor list /// required by the Model. /// /// \note The model is responsible for allocating the memory associated with /// the neighbor list cutoffs and \c /// modelWillNotRequestNeighborsOfNoncontributingParticles data. The model /// must use the \ref cache_buffer_pointers "Model's buffer pointer" to /// retain access to this memory location and avoid a memory leak. /// /// \sa KIM_ModelRefresh_SetNeighborListPointers, /// kim_model_refresh_module::kim_set_neighbor_list_pointers /// /// \since 2.0 void SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[out] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelCreate::SetModelBufferPointer or /// ModelDriverCreate::SetModelBufferPointer. /// /// \sa KIM_ModelRefresh_GetModelBufferPointer, /// kim_model_refresh_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelRefresh_LogEntry, kim_model_refresh_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelRefresh_ToString, kim_model_refresh_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelRefresh(ModelRefresh const &); void operator=(ModelRefresh const &); ModelRefresh(); ~ModelRefresh(); ModelRefreshImplementation * pimpl; }; // class ModelRefresh } // namespace KIM #endif // KIM_MODEL_REFRESH_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelRoutineName.hpp000066400000000000000000000224141421473465500224670ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #define KIM_MODEL_ROUTINE_NAME_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// ModelRoutineName's supported by the %KIM API. /// /// The enumeration constants are contained in the MODEL_ROUTINE_NAME /// namespace. /// /// \sa KIM_ModelRoutineName, /// kim_model_routine_name_module::kim_model_routine_name_type /// /// \since 2.0 class ModelRoutineName { public: /// \brief Integer identifying the specific ModelRoutineName represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_ModelRoutineName::modelRoutineNameID, /// kim_model_routine_name_module::kim_model_routine_name_type::model_routine_name_id /// /// \since 2.0 int modelRoutineNameID; /// \brief Create an uninitialized ModelRoutineName object. /// /// \since 2.0 ModelRoutineName(); /// \brief Create a ModelRoutineName object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 ModelRoutineName(int const id); /// \brief Create a ModelRoutineName object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_ModelRoutineName_FromString, /// kim_model_routine_name_module::kim_from_string /// /// \since 2.0 ModelRoutineName(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// ModelRoutineName's known to the %KIM API are found in the /// MODEL_ROUTINE_NAME namespace. /// /// \sa KIM_ModelRoutineName_Known, kim_model_routine_name_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares ModelRoutineName objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_ModelRoutineName_Equal, /// kim_model_routine_name_module::operator(.eq.) /// /// \since 2.0 bool operator==(ModelRoutineName const & rhs) const; /// \brief Compares ModelRoutineName objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_ModelRoutineName_NotEqual, /// kim_model_routine_name_module::operator(.ne.) /// /// \since 2.0 bool operator!=(ModelRoutineName const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the ModelRoutineName object. /// /// \note If the ModelRoutineName object does not correspond to a value /// defined by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_ModelRoutineName_ToString, /// kim_model_routine_name_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class ModelRoutineName /// \brief Contains the enumeration constants and the discovery routines for /// the ModelRoutineName \ref extensible_enumeration "Extensible Enumeration". namespace MODEL_ROUTINE_NAME { /// \brief The standard \c Create routine. /// /// The C++ prototype for this routine is ModelCreateFunction(). The C /// prototype for this routine is KIM_ModelCreateFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_Create, /// kim_model_routine_name_module::kim_model_routine_name_create /// /// \since 2.0 extern ModelRoutineName const Create; /// \brief The standard \c ComputeArgumentsCreate routine. /// /// The C++ prototype for this routine is /// ModelComputeArgumentsCreateFunction(). The C prototype for this routine is /// KIM_ModelComputeArgumentsCreateFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate, /// kim_model_routine_name_module::kim_model_routine_name_compute_arguments_create /// /// \since 2.0 extern ModelRoutineName const ComputeArgumentsCreate; /// \brief The standard \c Compute routine. /// /// The C++ prototype for this routine is ModelComputeFunction(). The C /// prototype for this routine is KIM_ModelComputeFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_Compute, /// kim_model_routine_name_module::kim_model_routine_name_compute /// /// \since 2.0 extern ModelRoutineName const Compute; /// \brief The standard \c Extension routine. /// /// The C++ prototype for this routine is ModelExtensionFunction(). The C /// prototype for this routine is KIM_ModelExtensionFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_Extension, /// kim_model_routine_name_module::kim_model_routine_name_extension /// /// \since 2.0 extern ModelRoutineName const Extension; /// \brief The standard \c Refresh routine. /// /// The C++ prototype for this routine is ModelRefreshFunction(). The C /// prototype for this routine is KIM_ModelRefreshFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_Refresh, /// kim_model_routine_name_module::kim_model_routine_name_refresh /// /// \since 2.0 extern ModelRoutineName const Refresh; /// \brief The standard \c WriteParameterizedModel routine. /// /// The C++ prototype for this routine is /// ModelWriteParameterizedModelFunction(). The C prototype for this routine /// is KIM_ModelWriteParameterizedModelFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel, /// kim_model_routine_name_module::kim_model_routine_name_write_parameterized_model /// /// \since 2.0 extern ModelRoutineName const WriteParameterizedModel; /// \brief The standard \c ComputeArgumentsDestroy routine. /// /// The C++ prototype for this routine is /// ModelComputeArgumentsDestroyFunction(). The C prototype for this routine /// is KIM_ModelComputeArgumentsDestroyFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy, /// kim_model_routine_name_module::kim_model_routine_name_compute_arguments_destroy /// /// \since 2.0 extern ModelRoutineName const ComputeArgumentsDestroy; /// \brief The standard \c Destroy routine. /// /// The C++ prototype for this routine is ModelDestroyFunction(). The C /// prototype for this routine is KIM_ModelDestroyFunction(). /// /// \todo Add more detailed description of routine. /// /// \sa KIM_MODEL_ROUTINE_NAME_Destroy, /// kim_model_routine_name_module::kim_model_routine_name_destroy /// /// \since 2.0 extern ModelRoutineName const Destroy; /// \brief Get the number of standard ModelRoutineName's defined by the %KIM /// API. /// /// \param[out] numberOfModelRoutineNames The number of standard /// ModelRoutineName's defined by the %KIM API. /// /// \sa KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames, /// kim_model_routine_name_module::kim_get_number_of_model_routine_names /// /// \since 2.0 void GetNumberOfModelRoutineNames(int * const numberOfModelRoutineNames); /// \brief Get the identity of each defined standard ModelRoutineName. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// ModelRoutineName. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] modelRoutineName The ModelRoutineName object associated with \c /// index. /// /// \return \c true if `index < 0` or `index >= numberOfModelRoutineNames`. /// \return \c false otherwise. /// /// \sa KIM_MODEL_ROUTINE_NAME_GetModelRoutineName, /// kim_model_routine_name_module::kim_get_model_routine_name /// /// \since 2.0 int GetModelRoutineName(int const index, ModelRoutineName * const modelRoutineName); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for ModelRoutineName /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(ModelRoutineName const & a, ModelRoutineName const & b) const { return a.modelRoutineNameID < b.modelRoutineNameID; } }; // struct Comparator } // namespace MODEL_ROUTINE_NAME } // namespace KIM #endif // KIM_MODEL_ROUTINE_NAME_HPP_ kim-api-2.3.0-git/cpp/include/KIM_ModelWriteParameterizedModel.hpp000066400000000000000000000130661421473465500250340ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ #define KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ #include #include namespace KIM { // Forward declarations class LogVerbosity; class ModelWriteParameterizedModelImplementation; /// \brief Provides the interface to a %KIM API Model object for use by models /// within their MODEL_ROUTINE_NAME::WriteParameterizedModel routine. /// /// \sa KIM_ModelWriteParameterizedModel, /// kim_model_write_parameterized_model_module::kim_model_write_parameterized_model_handle_type /// /// \since 2.0 class ModelWriteParameterizedModel { public: /// \brief Get the directory path where the parameterized model files should /// be written. /// /// \param[out] path Path string. /// /// \sa KIM_ModelWriteParameterizedModel_GetPath, /// kim_model_write_parameterized_model_module::kim_get_path /// /// \since 2.0 void GetPath(std::string const ** const path) const; /// \brief Get the name of the new parameterized model. /// /// The model name is a valid C identifier and is available as a convenience. /// It is not required for the model to use this name in any way. /// /// \param[out] modelName The parameterized model name. /// /// \sa KIM_ModelWriteParameterizedModel_GetModelName, /// kim_model_write_parameterized_model_module::kim_get_model_name /// /// \since 2.0 void GetModelName(std::string const ** const modelName) const; /// \brief Set the file name for the next parameter file. /// /// This routine must be called once for each parameter file. The order of /// these calls is important and determines the order in which the parameter /// files will be listed in the automatically generated CMakeLists.txt file. /// /// \param[in] fileName File name (basename and extension, without path). /// /// \sa KIM_ModelWriteParameterizedModel_SetParameterFileName, /// kim_model_write_parameterized_model_module::kim_set_parameter_file_name /// /// \since 2.0 void SetParameterFileName(std::string const & fileName) const; /// \brief Get the \ref cache_buffer_pointers "Model's buffer pointer" /// within the Model object. /// /// The model buffer pointer may be used by the Model to associate /// a memory buffer with the Model object. /// /// \param[out] ptr The model buffer data pointer. /// /// \note `ptr == NULL` if the model has not previously called /// ModelCreate::SetModelBufferPointer or /// ModelDriverCreate::SetModelBufferPointer. /// /// \sa KIM_ModelWriteParameterizedModel_GetModelBufferPointer, /// kim_model_write_parameterized_model_module::kim_get_model_buffer_pointer /// /// \since 2.0 void GetModelBufferPointer(void ** const ptr) const; /// \brief Write a log entry into the log file. /// /// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if /// \c logVerbosity is greater-than the Log object's top LogVerbosity on its /// stack. /// /// \param[in] logVerbosity The LogVerbosity level for the entry. /// \param[in] message The body text of the log entry. /// \param[in] lineNumber The source code file line number. /// \param[in] fileName The source code file name. /// /// \sa KIM_ModelWriteParameterizedModel_LogEntry, /// kim_model_write_parameterized_model_module::kim_log_entry /// /// \since 2.0 void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; /// \overload void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; /// \brief Get a string representing the internal state of the Model object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_ModelWriteParameterizedModel_ToString, /// kim_model_write_parameterized_model_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelWriteParameterizedModel(ModelWriteParameterizedModel const &); void operator=(ModelWriteParameterizedModel const &); ModelWriteParameterizedModel(); ~ModelWriteParameterizedModel(); ModelWriteParameterizedModelImplementation * pimpl; }; // class ModelWriteParameterizedModel } // namespace KIM #endif // KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ kim-api-2.3.0-git/cpp/include/KIM_Numbering.hpp000066400000000000000000000131231421473465500212030ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_NUMBERING_HPP_ #define KIM_NUMBERING_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// Numbering's supported by the %KIM API. /// /// The enumeration constants are contained in the NUMBERING namespace. /// /// \sa KIM_Numbering, kim_numbering_module::kim_numbering_type /// /// \since 2.0 class Numbering { public: /// \brief Integer identifying the specific Numbering represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_Numbering::numberingID, /// kim_numbering_module::kim_numbering_type::numbering_id /// /// \since 2.0 int numberingID; /// \brief Create an uninitialized Numbering object. /// /// \since 2.0 Numbering(); /// \brief Create a Numbering object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 Numbering(int const id); /// \brief Create a Numbering object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_Numbering_FromString, kim_numbering_module::kim_from_string /// /// \since 2.0 Numbering(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// Numbering's known to the %KIM API are found in the NUMBERING namespace. /// /// \sa KIM_Numbering_Known, kim_numbering_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares Numbering objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_Numbering_Equal, kim_numbering_module::operator(.eq.) /// /// \since 2.0 bool operator==(Numbering const & rhs) const; /// \brief Compares Numbering objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_Numbering_NotEqual, kim_numbering_module::operator(.ne.) /// /// \since 2.0 bool operator!=(Numbering const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the Numbering object. /// /// \note If the Numbering object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_Numbering_ToString, kim_numbering_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class Numbering /// \brief Contains the enumeration constants and the discovery routines for /// the Numbering \ref extensible_enumeration "Extensible Enumeration". namespace NUMBERING { /// \brief The standard \c zeroBased numbering. /// /// Quantities are numbered starting from zero. /// /// \sa KIM_NUMBERING_zeroBased, kim_numbering_module::kim_numbering_zero_based /// /// \since 2.0 extern Numbering const zeroBased; /// \brief The standard \c oneBased numbering. /// /// Quantities are numbered starting from one. /// /// \sa KIM_NUMBERING_oneBased, kim_numbering_module::kim_numbering_one_based /// /// \since 2.0 extern Numbering const oneBased; /// \brief Get the number of standard Numbering's defined by the %KIM /// API. /// /// \param[out] numberOfNumberings The number of standard Numbering's defined /// by the %KIM API. /// /// \sa KIM_NUMBERING_GetNumberOfNumberings, /// kim_numbering_module::kim_get_number_of_numberings /// /// \since 2.0 void GetNumberOfNumberings(int * const numberOfNumberings); /// \brief Get the identity of each defined standard Numbering. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// Numbering. This index ordering is only guaranteed to be stable /// during the lifetime of the current process. /// \param[out] numbering The Numbering object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfNumberings`. /// \return \c false otherwise. /// /// \sa KIM_NUMBERING_GetNumbering, kim_numbering_module::kim_get_numbering /// /// \since 2.0 int GetNumbering(int const index, Numbering * const numbering); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for Numbering /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(Numbering const & a, Numbering const & b) const { return a.numberingID < b.numberingID; } }; // struct Comparator } // namespace NUMBERING } // namespace KIM #endif // KIM_NUMBERING_HPP_ kim-api-2.3.0-git/cpp/include/KIM_SemVer.hpp000066400000000000000000000073271421473465500204670ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SEM_VER_HPP_ #define KIM_SEM_VER_HPP_ #include namespace KIM { /// \brief Contains routines related to the %KIM API Semantic Version. namespace SEM_VER { /// \brief Get the %KIM API complete Semantic Version string. /// /// \sa KIM_SEM_VER_GetSemVer, kim_sem_ver_module::kim_get_sem_ver /// /// \since 2.0 std::string const & GetSemVer(); /// \brief Compare two Semantic Version strings. /// /// See the Semantic Version 2.0.0 standard /// for the definition of the partial ordering for valid Semantic Version /// strings. /// /// \param[in] lhs Left hand side version string in comparison. /// \param[in] rhs Right hand side version string in comparison. /// \param[out] isLessThan Truth value of `lhs < rhs` as defined by the /// Semantic Version 2.0.0 standard. /// /// \return \c true if ParseSemVer returns \c true for \c lhs or \c rhs. /// \return \c false otherwise. /// /// \sa KIM_SEM_VER_IsLessThan, kim_sem_ver_module::kim_is_less_than /// /// \since 2.0 int IsLessThan(std::string const & lhs, std::string const & rhs, int * const isLessThan); /// \brief Parse Semantic Version string into its six components. /// /// See the Semantic Version 2.0.0 standard /// for definitions of valid Semantic Version strings. /// /// \param[in] version The Semantic Version string to be parsed. /// \param[out] major The major version number. /// \param[out] minor The minor version number. /// \param[out] patch The patch version number. /// \param[out] prerelease The prerelease string. /// \param[out] buildMetadata The build metadata string. /// /// \return \c true if minor and/or patch are missing. /// \return \c true if major number has a leading zero or is not a valid /// integer. /// \return \c true if minor number has a leading zero or is not a valid /// integer. /// \return \c true if patch number has a leading zero or is not a valid /// integer. /// \return \c true if the prerelease string is invalid. /// \return \c true if the build metadata string is invalid. /// \return \c false otherwise. /// /// \pre All output arguments may be \c NULL if the corresponding value is /// not needed. /// /// \post All output arguments are unchanged if an error occurs. /// /// \sa KIM_SEM_VER_ParseSemVer, kim_sem_ver_module::kim_parse_sem_ver /// /// \since 2.0 int ParseSemVer(std::string const & version, int * const major, int * const minor, int * const patch, std::string * const prerelease, std::string * const buildMetadata); } // namespace SEM_VER } // namespace KIM #endif // KIM_SEM_VER_HPP_ kim-api-2.3.0-git/cpp/include/KIM_SimulatorHeaders.hpp000066400000000000000000000045031421473465500225320ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SIMULATOR_HEADERS_HPP_ #define KIM_SIMULATOR_HEADERS_HPP_ // IWYU pragma: begin_exports #ifndef KIM_COLLECTIONS_HPP_ #include "KIM_Collections.hpp" #endif #ifndef KIM_COLLECTION_HPP_ #include "KIM_Collection.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_MODEL_HPP_ #include "KIM_Model.hpp" #endif #ifndef KIM_SIMULATOR_MODEL_HPP_ #include "KIM_SimulatorModel.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ComputeArguments.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif // IWYU pragma: end_exports #endif // KIM_SIMULATOR_HEADERS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_SimulatorModel.hpp000066400000000000000000000510671421473465500222260ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SIMULATOR_MODEL_HPP_ #define KIM_SIMULATOR_MODEL_HPP_ #include namespace KIM { // Forward declarations class LogVerbosity; class SimulatorModelImplementation; /// \brief Provides the primary interface to a %KIM API SimulatorModel object /// and is meant to be used by simulators. /// /// Simulator Models (SMs) are a mechanism by which the %KIM API provides /// support for models that are implemented natively in simulation codes /// ("Simulators"). An SM consists of all the information and data required to /// use the model from within its simulator. This includes a specification /// file in EDN format (see https://openkim.org/about-edn/) containing /// instructions and settings that must be specified for the simulator to /// define and use the model, and one or more parameter files. The %KIM API /// SimulatorModel model object provides a generic interface to access the /// parameter files and the contents of the specification file. Each simulator /// may define its own set of "simulator fields" that contain /// simulator-specific content for the model's setup. A simulator field /// consists of zero or more "lines". Each line is a string containing /// information that is meaningful to the simulator. To allow the simulator to /// specialize the field lines based on user input, the SimulatorModel /// interface provides a template substitution mechanism. Each simulator field /// line may contain template tags of the form "@@" and will be replaced /// by an appropriate value provided by the SimulatorModel object or the /// simulator. /// /// The %KIM API defines the following set of standard template key-value /// entries \anchor standard_template_entries: /// /// * \c parameter-file-dir, with a value equal to the absolute path name of /// the SimulatorModel's temporary parameter file directory. This directory /// is created when the SimulatorModel object is SimulatorModel::Create'd and /// is removed when the object is SimulatorModel::Destroy'd. /// * \c parameter-file-basename-# (# ranges from 1 to the SimulatorModel's /// number of parameter files), with a value equal to the basename (file name /// without path) of the corresponding parameter file. (Parameter file /// ordering is defined by the order files are listed in the SMs /// CMakeLists.txt file.) /// * \c parameter-file-# (# ranges from 1 to the SimulatorModel's number of /// parameter files), with a value equal to the full absolute file name (path /// and base name) of the corresponding parameter file. /// /// To facilitate backward-compatibility, the schema of the specification file /// is explicitly versioned. Each version of the schema is documented here. /// /// ------ /// /// \anchor kim_api_sm_schema_version_1

`kim-api-sm-schema-version = 1` /// (Since 2.1):

/// /// The specification file consists of a single EDN Map. Each key-value pair /// in the map has a key element-type of string. The following list gives the /// *required* key values and the element-type of their corresponding value: /// /// * "kim-api-sm-schema-version", integer /// * "model-name", string /// * "simulator-name", string /// * "simulator-version", string /// * "supported-species", string /// /// The "model-name" string value must be identical to the SimulatorModel's /// name. The "supported-species" string value is a space separated list of /// labels that identify the species supported by the model. The %KIM API does /// not impose any additional constraints on these species labels. /// /// All other key-value pairs in the EDN map are "simulator fields" which must /// have a value with element-type string or vector. If a vector of length /// zero or greater is provided, each element of the vector must have /// element-type string. /// /// **Example of `kim-api-sm-schema-version = 1` file format** /// \code{.edn} /// { /// "kim-api-sm-schema-version" 1 /// "model-name" "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu" /// "simulator-name" "LAMMPS" /// "simulator-version" "12 Dec 2018" /// "supported-species" "Pb Au" /// "units" "metal" /// "model-defn" [ "pair_style lj/cut 10.4057000" /// "variable alchemy_mapping index @@" /// "variable alchemy_curr_type loop 10000" /// "include @@" /// "pair_modify mix arithmetic" /// ] /// } /// \endcode /// /// In this example the "units" and "model-defn" key-value pairs are "simulator /// fields" whose format is defined by the LAMMPS kim_init command. There are /// also two examples of template tags: "@@", which is /// defined by the LAMMPS simulator, and "@@", which is /// defined by the SimulatorModel object. /// /// ------ /// /// \sa KIM_SimulatorModel, /// kim_simulator_model_module::kim_simulator_model_handle_type /// /// \since 2.1 class SimulatorModel { public: /// \brief Create a new %KIM API SimulatorModel object. /// /// Allocates a new %KIM API SimulatorModel object for use by a Simulator. /// /// \param[in] simulatorModelName The name of the SimulatorModel to be /// created. /// \param[out] simulatorModel Pointer to the newly created SimulatorModel /// object. /// /// \note The value of `simulatorModelName` is required to be a valid /// C-identifier. /// /// \return \c true if the %KIM API is unable to allocate a new log object. /// \return \c true if the requested simulator model's library cannot be /// found, opened, is of the wrong type, or has some other problem. /// \return \c true if the simulator model's parameter files cannot be /// written to scratch space. /// \return \c true if the simulator model's specification file is invalid /// EDN, is written in an unsupported schema version, or does not /// provide all required data. /// \return \c false otherwise. /// /// \post `simulatorModel == NULL` if an error occurs. /// /// \sa KIM_SimulatorModel_Create, /// kim_simulator_model_module::kim_simulator_model_create /// /// \since 2.1 static int Create(std::string const & simulatorModelName, SimulatorModel ** const simulatorModel); /// \brief Destroy a previously SimulatorModel::Create'd object. /// /// Deallocate the SimulatorModel object. /// /// \param[inout] simulatorModel Pointer to the SimulatorModel object. /// /// \pre \c *simulatorModel points to a previously created %KIM API /// SimulatorModel object. /// /// \post `*simulatorModel == NULL`. /// /// \sa KIM_SimulatorModel_Destroy, /// kim_simulator_model_module::kim_simulator_model_destroy /// // \since 2.1 static void Destroy(SimulatorModel ** const simulatorModel); /// \brief Get the SimulatorModel's simulator name and version. /// /// \param[out] simulatorName Simulator name. /// \param[out] simulatorVersion Simulator version. /// /// \pre \c simulatorName and \c simulatorVersion may be \c NULL if the /// cooresponding value is not needed. /// /// \sa KIM_SimulatorModel_GetSimulatorNameAndVersion, /// kim_simulator_model_module::kim_get_simulator_name_and_version /// /// \since 2.1 void GetSimulatorNameAndVersion(std::string const ** const simulatorName, std::string const ** const simulatorVersion) const; /// \brief Get the number of species supported by the SimulatorModel. /// /// \param[out] numberOfSupportedSpecies The number of species supported by /// the Simulator Model. /// /// \sa KIM_SimulatorModel_GetNumberOfSupportedSpecies, /// kim_simulator_model_module::kim_get_number_of_supported_species /// /// \since 2.1 void GetNumberOfSupportedSpecies(int * const numberOfSupportedSpecies) const; /// \brief Get a species name supported by the SimulatorModel. /// /// \param[in] index Zero-based index for the species name. /// \param[out] speciesName The value of the species name of interest. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \sa KIM_SimulatorModel_GetSupportedSpecies, /// kim_simulator_model_module::kim_get_supported_species /// /// \since 2.1 int GetSupportedSpecies(int const index, std::string const ** const speciesName) const; /// \brief Open and initialize the template map for simulator field line /// substitutions. /// /// This routine clears the template map of all existing entries, adds the /// %KIM API \ref standard_template_entries "standard template entries", and /// opens the template map for addition of new entries. This allows the /// simulator significant flexibilty. For instance, when only a partial set /// of the simulator's template map key-value entries are known (such as when /// the simulator's input file has been only partially processed). In this /// case, the simulator can close the template map to obtain certain field /// lines that it knows to be complete. Then it can open and initialize the /// template map and continue processing its input. /// /// \sa KIM_SimulatorModel_OpenAndInitializeTemplateMap, /// kim_simulator_model_module::kim_open_and_initialize_template_map /// /// \since 2.1 void OpenAndInitializeTemplateMap(); /// \brief Determine if the template map is open. /// /// \return \c true if the template map is open. /// \return \c false if the template map is closed. /// /// \sa KIM_SimulatorModel_TemplateMapIsOpen, /// kim_simulator_model_module::kim_template_map_is_open /// /// \since 2.1 int TemplateMapIsOpen() const; /// \brief Add a new key-value entry to the template map. /// /// As part of the SimulatorModel::Create'ion of a SimulatorModel object its /// template map is opened and initialized by (internally) executing a call /// to OpenAndInitializeTemplateMap(). The AddTemplateMap() routine allows /// new key-value entries to be added to the open template map. /// /// Once the CloseTemplateMap() routine is executed, the map entries are used /// to perform template substitution on the simulator field line strings. In /// each simulator field line and for each map key-value entry, when \c key, /// surrounded by the template tags "@<" and ">@", is found it will be /// replaced by \c value. For example, if \c key is \c my-key, and \c value /// is \c the-result, then wherever the string `@@` is found within a /// simulator field line it will be replaced by the string `the-result`. // /// \param[in] key The \c key value. Must consist only of digits (0-9), /// lower case letters (a-z), and dashes (-). /// \param[in] value The \c value value. All valid strings are allowed. /// /// \return \c true if the template map has been closed by a call to /// CloseTempateMap(). /// \return \c true if \c key contains invalid characters. /// \return \c false otherwise. /// /// \sa KIM_SimulatorModel_AddTemplateMap, /// kim_simulator_model_module::kim_add_template_map /// /// \since 2.1 int AddTemplateMap(std::string const & key, std::string const & value); /// \brief Close the template map and perform template substitutions. /// /// Close the template map and use the map entries to perform /// search-and-replace substitutions on all simulator field lines. The /// template map must be closed to access the simulator field lines via /// GetSimulatorFieldLine(). /// /// \sa KIM_SimulatorModel_CloseTemplateMap, /// kim_simulator_model_module::kim_close_template_map /// /// \since 2.1 void CloseTemplateMap(); /// \brief Get the number of simulator fields provided by the SimulatorModel. /// /// /// \param[out] numberOfSimulatorFields The number of simulator fields /// provided by the SimulatorModel. /// /// \sa KIM_SimulatorModel_GetNumberOfSimulatorFields, /// kim_simulator_model_module::kim_get_number_of_simulator_fields /// /// \since 2.1 void GetNumberOfSimulatorFields(int * const numberOfSimulatorFields) const; /// \brief Get the metadata for the simulator field of interest. /// /// \param[in] fieldIndex Zero-based index of the simulator field of /// interest. /// \param[out] extent Number of lines in the simulator field of interest. /// \param[out] fieldName Name of the simulator field. /// /// \pre \c extent and \c fieldName may be \c NULL if the corresponding value /// is not needed. /// /// \post \c extent and \c fieldName are unchanged if an error occurs. /// /// \return \c true if \c fieldIndex is invalid. /// \return \c false otherwise. /// /// \sa KIM_SimulatorModel_GetSimulatorFieldMetadata, /// kim_simulator_model_module::kim_get_simulator_field_metadata /// /// \since 2.1 int GetSimulatorFieldMetadata(int const fieldIndex, int * const extent, std::string const ** const fieldName) const; /// \brief Get a line for the simulator field of interest with all template /// substitutions performed (Requires the template map is closed). /// /// \param[in] fieldIndex Zero-based index of the simulator field of /// interest. /// \param[in] lineIndex Zero-based index of the line of interest. /// \param[out] lineValue The value of the simulator field line. /// /// \post \c lineValue is unchanged if an error occurs. /// /// \return \c true if the template map is open. /// \return \c true if \c fieldIndex is invalid. /// \return \c true if \c lineIndex is invalid. /// \return \c false otherwise. /// /// \sa KIM_SimulatorModel_GetSimulatorFieldLine, /// kim_simulator_model_module::kim_get_simulator_field_line /// /// \since 2.1 int GetSimulatorFieldLine(int const fieldIndex, int const lineIndex, std::string const ** const lineValue) const; /// \brief Get absolute path name of the temporary directory where parameter /// files provided by the simulator model are written. /// /// \param[out] directoryName The absolute path name of the SimulatorModel's /// temporary parameter file directory. /// /// \sa KIM_SimulatorModel_GetParameterFileDirectoryName, /// kim_simulator_model_module::kim_get_parameter_file_directory_name /// /// \since 2.1 void GetParameterFileDirectoryName(std::string const ** const directoryName) const; /// \brief Get the SimulatorModel's specification file basename (file name /// without path). The file is located in the SimulatorModel's parameter /// file directory. /// /// \param[out] specificationFileName The basename (file name without path) /// of the specification file. /// /// \sa KIM_SimulatorModel_GetSpecificationFileName, /// kim_simulator_model_module::kim_get_specification_file_name /// /// \since 2.1 void GetSpecificationFileName( std::string const ** const specificationFileName) const; /// \brief Get the number of parameter files provided by the SimulatorModel. /// /// \param[out] numberOfParameterFiles The number of parameter files. /// /// \sa KIM_SimulatorModel_GetNumberOfParameterFiles, /// kim_simulator_model_module::kim_get_number_of_parameter_files /// /// \since 2.1 void GetNumberOfParameterFiles(int * const numberOfParameterFiles) const; /// \brief Get the basename (file name without path) of a particular /// parameter file. The file is located in the SimulatorModel's parameter /// file directory. /// /// \param[in] index Zero-based index for the parameter file of interest. /// \param[out] parameterFileName Basename (file name without path) of the /// parameter file. /// /// \post \c parameterFileName is unchanged if an error occurs. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \sa KIM_SimulatorModel_GetParameterFileName, /// kim_simulator_model_module::kim_get_parameter_file_name /// /// \since 2.1 /// /// \deprecated As of 2.2. Please use GetParameterFileBasename() instead. int GetParameterFileName(int const index, std::string const ** const parameterFileName) const; /// \brief Get the basename (file name without path) of a particular /// parameter file. The file is located in the SimulatorModel's parameter /// file directory. /// /// \param[in] index Zero-based index for the parameter file of interest. /// \param[out] parameterFileBasename Basename (file name without path) of /// the parameter file. /// /// \post \c parameterFileBasename is unchanged if an error occurs. /// /// \return \c true if \c index is invalid. /// \return \c false otherwise. /// /// \sa KIM_SimulatorModel_GetParameterFileBasename, /// kim_simulator_model_module::kim_get_parameter_file_basename /// /// \since 2.2 int GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const; /// \brief Set the \ref cache_buffer_pointers "Simulator's buffer pointer" /// within the SimulatorModel object. /// /// The simulator buffer pointer may be used by the simulator to associate /// a memory buffer with the SimulatorModel object. /// /// \param[in] ptr The simulator buffer data pointer. /// /// \sa KIM_SimulatorModel_SetSimulatorBufferPointer, /// kim_simulator_model_module::kim_set_simulator_buffer_pointer /// /// \since 2.1 void SetSimulatorBufferPointer(void * const ptr); /// \brief Get the \ref cache_buffer_pointers "Simulator's buffer pointer" /// from the SimulatorModel object. /// /// \param[out] ptr The simulator buffer data pointer. /// /// \note `ptr == NULL` if the simulator has not previously called /// SimulatorModel::SetSimulatorBufferPointer. /// /// \sa KIM_SimulatorModel_GetSimulatorBufferPointer, /// kim_simulator_model_module::kim_get_simulator_buffer_pointer /// /// \since 2.1 void GetSimulatorBufferPointer(void ** const ptr) const; /// \brief Get a string representing the internal state of the SimulatorModel /// object. /// /// This string is primarily meant for use as a debugging tool. The string /// may be quite long. It begins and ends with lines consisting only of \c /// ='s. /// /// \sa KIM_SimulatorModel_ToString, /// kim_simulator_model_module::kim_to_string /// /// \since 2.1 std::string const & ToString() const; /// \brief Set the identity of the Log object associated with the /// SimulatorModel object. /// /// \param[in] logID String identifying the SimulatorModel object's Log /// object. /// /// \sa KIM_SimulatorModel_SetLogID, /// kim_simulator_model_module::kim_set_log_id /// /// \since 2.1 void SetLogID(std::string const & logID); /// \brief Push a new LogVerbosity onto the SimulatorModel object's Log /// object verbosity stack. /// /// \param[in] logVerbosity A LogVerbosity value. /// /// \sa KIM_SimulatorModel_PushLogVerbosity, /// kim_simulator_model_module::kim_push_log_verbosity /// /// \since 2.1 void PushLogVerbosity(LogVerbosity const logVerbosity); /// \brief Pop a LogVerbosity from the SimulatorModel object's Log object /// verbosity stack. /// /// \sa KIM_SimulatorModel_PopLogVerbosity, /// kim_simulator_model_module::kim_pop_log_verbosity /// /// \since 2.1 void PopLogVerbosity(); private: // do not allow copy constructor or operator= SimulatorModel(SimulatorModel const &); void operator=(SimulatorModel const &); SimulatorModel(); ~SimulatorModel(); SimulatorModelImplementation * pimpl; }; // class SimulatorModel } // namespace KIM #endif // KIM_SIMULATOR_MODEL_HPP_ kim-api-2.3.0-git/cpp/include/KIM_SpeciesName.hpp000066400000000000000000000715661421473465500214700ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SPECIES_NAME_HPP_ #define KIM_SPECIES_NAME_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// SpeciesName's supported by the %KIM API. /// /// The enumeration constants are contained in the SPECIES_NAME namespace. /// /// \sa KIM_SpeciesName, kim_species_name_module::kim_species_name_type /// /// \since 2.0 class SpeciesName { public: /// \brief Integer identifying the specific SpeciesName represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_SpeciesName::speciesNameID, /// kim_species_name_module::kim_species_name_type::species_name_id /// /// \since 2.0 int speciesNameID; /// \brief Create an uninitialized SpeciesName object. /// /// \since 2.0 SpeciesName(); /// \brief Create a SpeciesName object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 SpeciesName(int const id); /// \brief Create a SpeciesName object corresponding to the provided string. /// If the string does not match one of the values defined by the %KIM API, /// then an "unknown" object is generated. /// /// \sa KIM_SpeciesName_FromString, kim_species_name_module::kim_from_string /// /// \since 2.0 SpeciesName(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// SpeciesName's known to the %KIM API are found in the SPECIES_NAME /// namespace. /// /// \sa KIM_SpeciesName_Known, kim_species_name_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares SpeciesName objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_SpeciesName_Equal, kim_species_name_module::operator(.eq.) /// /// \since 2.0 bool operator==(SpeciesName const & rhs) const; /// \brief Compares SpeciesName objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_SpeciesName_NotEqual, kim_species_name_module::operator(.ne.) /// /// \since 2.0 bool operator!=(SpeciesName const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the SpeciesName object. /// /// \note If the SpeciesName object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_SpeciesName_ToString, kim_species_name_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class SpeciesName /// \brief Contains the enumeration constants and the discovery routines for /// the SpeciesName \ref extensible_enumeration "Extensible Enumeration". namespace SPECIES_NAME { /// \brief The standard \c electron species. /// /// \sa KIM_SPECIES_NAME_electron, /// kim_species_name_module::kim_species_name_electron /// /// \since 2.0 extern SpeciesName const electron; /// \brief The standard \c Hydrogen species. /// /// \sa KIM_SPECIES_NAME_H, kim_species_name_module::kim_species_name_h /// /// \since 2.0 extern SpeciesName const H; /// \brief The standard \c Helium species. /// /// \sa KIM_SPECIES_NAME_He, kim_species_name_module::kim_species_name_he /// /// \since 2.0 extern SpeciesName const He; /// \brief The standard \c Lithium species. /// /// \sa KIM_SPECIES_NAME_Li, kim_species_name_module::kim_species_name_li /// /// \since 2.0 extern SpeciesName const Li; /// \brief The standard \c Beryllium species. /// /// \sa KIM_SPECIES_NAME_Be, kim_species_name_module::kim_species_name_be /// /// \since 2.0 extern SpeciesName const Be; /// \brief The standard \c Boron species. /// /// \sa KIM_SPECIES_NAME_B, kim_species_name_module::kim_species_name_b /// /// \since 2.0 extern SpeciesName const B; /// \brief The standard \c Carbon species. /// /// \sa KIM_SPECIES_NAME_C, kim_species_name_module::kim_species_name_c /// /// \since 2.0 extern SpeciesName const C; /// \brief The standard \c Nitrogen species. /// /// \sa KIM_SPECIES_NAME_N, kim_species_name_module::kim_species_name_n /// /// \since 2.0 extern SpeciesName const N; /// \brief The standard \c Oxygen species. /// /// \sa KIM_SPECIES_NAME_O, kim_species_name_module::kim_species_name_o /// /// \since 2.0 extern SpeciesName const O; /// \brief The standard \c Fluorine species. /// /// \sa KIM_SPECIES_NAME_F, kim_species_name_module::kim_species_name_f /// /// \since 2.0 extern SpeciesName const F; /// \brief The standard \c Neon species. /// /// \sa KIM_SPECIES_NAME_Ne, kim_species_name_module::kim_species_name_ne /// /// \since 2.0 extern SpeciesName const Ne; /// \brief The standard \c Sodium species. /// /// \sa KIM_SPECIES_NAME_Na, kim_species_name_module::kim_species_name_na /// /// \since 2.0 extern SpeciesName const Na; /// \brief The standard \c Magnesium species. /// /// \sa KIM_SPECIES_NAME_Mg, kim_species_name_module::kim_species_name_mg /// /// \since 2.0 extern SpeciesName const Mg; /// \brief The standard \c Aluminum species. /// /// \sa KIM_SPECIES_NAME_Al, kim_species_name_module::kim_species_name_al /// /// \since 2.0 extern SpeciesName const Al; /// \brief The standard \c Silicon species. /// /// \sa KIM_SPECIES_NAME_Si, kim_species_name_module::kim_species_name_si /// /// \since 2.0 extern SpeciesName const Si; /// \brief The standard \c Phosphorus species. /// /// \sa KIM_SPECIES_NAME_P, kim_species_name_module::kim_species_name_p /// /// \since 2.0 extern SpeciesName const P; /// \brief The standard \c Sulfur species. /// /// \sa KIM_SPECIES_NAME_S, kim_species_name_module::kim_species_name_s /// /// \since 2.0 extern SpeciesName const S; /// \brief The standard \c Chlorine species. /// /// \sa KIM_SPECIES_NAME_Cl, kim_species_name_module::kim_species_name_cl /// /// \since 2.0 extern SpeciesName const Cl; /// \brief The standard \c Argon species. /// /// \sa KIM_SPECIES_NAME_Ar, kim_species_name_module::kim_species_name_ar /// /// \since 2.0 extern SpeciesName const Ar; /// \brief The standard \c Potassium species. /// /// \sa KIM_SPECIES_NAME_K, kim_species_name_module::kim_species_name_k /// /// \since 2.0 extern SpeciesName const K; /// \brief The standard \c Calcium species. /// /// \sa KIM_SPECIES_NAME_Ca, kim_species_name_module::kim_species_name_ca /// /// \since 2.0 extern SpeciesName const Ca; /// \brief The standard \c Scandium species. /// /// \sa KIM_SPECIES_NAME_Sc, kim_species_name_module::kim_species_name_sc /// /// \since 2.0 extern SpeciesName const Sc; /// \brief The standard \c Titanium species. /// /// \sa KIM_SPECIES_NAME_Ti, kim_species_name_module::kim_species_name_ti /// /// \since 2.0 extern SpeciesName const Ti; /// \brief The standard \c Vanadium species. /// /// \sa KIM_SPECIES_NAME_V, kim_species_name_module::kim_species_name_v /// /// \since 2.0 extern SpeciesName const V; /// \brief The standard \c Chromium species. /// /// \sa KIM_SPECIES_NAME_Cr, kim_species_name_module::kim_species_name_cr /// /// \since 2.0 extern SpeciesName const Cr; /// \brief The standard \c Manganese species. /// /// \sa KIM_SPECIES_NAME_Mn, kim_species_name_module::kim_species_name_mn /// /// \since 2.0 extern SpeciesName const Mn; /// \brief The standard \c Iron species. /// /// \sa KIM_SPECIES_NAME_Fe, kim_species_name_module::kim_species_name_fe /// /// \since 2.0 extern SpeciesName const Fe; /// \brief The standard \c Cobalt species. /// /// \sa KIM_SPECIES_NAME_Co, kim_species_name_module::kim_species_name_co /// /// \since 2.0 extern SpeciesName const Co; /// \brief The standard \c Nickel species. /// /// \sa KIM_SPECIES_NAME_Ni, kim_species_name_module::kim_species_name_ni /// /// \since 2.0 extern SpeciesName const Ni; /// \brief The standard \c Copper species. /// /// \sa KIM_SPECIES_NAME_Cu, kim_species_name_module::kim_species_name_cu /// /// \since 2.0 extern SpeciesName const Cu; /// \brief The standard \c Zinc species. /// /// \sa KIM_SPECIES_NAME_Zn, kim_species_name_module::kim_species_name_zn /// /// \since 2.0 extern SpeciesName const Zn; /// \brief The standard \c Gallium species. /// /// \sa KIM_SPECIES_NAME_Ga, kim_species_name_module::kim_species_name_ga /// /// \since 2.0 extern SpeciesName const Ga; /// \brief The standard \c Germanium species. /// /// \sa KIM_SPECIES_NAME_Ge, kim_species_name_module::kim_species_name_ge /// /// \since 2.0 extern SpeciesName const Ge; /// \brief The standard \c Arsenic species. /// /// \sa KIM_SPECIES_NAME_As, kim_species_name_module::kim_species_name_as /// /// \since 2.0 extern SpeciesName const As; /// \brief The standard \c Selenium species. /// /// \sa KIM_SPECIES_NAME_Se, kim_species_name_module::kim_species_name_se /// /// \since 2.0 extern SpeciesName const Se; /// \brief The standard \c Bromine species. /// /// \sa KIM_SPECIES_NAME_Br, kim_species_name_module::kim_species_name_br /// /// \since 2.0 extern SpeciesName const Br; /// \brief The standard \c Krypton species. /// /// \sa KIM_SPECIES_NAME_Kr, kim_species_name_module::kim_species_name_kr /// /// \since 2.0 extern SpeciesName const Kr; /// \brief The standard \c Rubidium species. /// /// \sa KIM_SPECIES_NAME_Rb, kim_species_name_module::kim_species_name_rb /// /// \since 2.0 extern SpeciesName const Rb; /// \brief The standard \c Strontium species. /// /// \sa KIM_SPECIES_NAME_Sr, kim_species_name_module::kim_species_name_sr /// /// \since 2.0 extern SpeciesName const Sr; /// \brief The standard \c Yttrium species. /// /// \sa KIM_SPECIES_NAME_Y, kim_species_name_module::kim_species_name_y /// /// \since 2.0 extern SpeciesName const Y; /// \brief The standard \c Zirconium species. /// /// \sa KIM_SPECIES_NAME_Zr, kim_species_name_module::kim_species_name_zr /// /// \since 2.0 extern SpeciesName const Zr; /// \brief The standard \c Niobium species. /// /// \sa KIM_SPECIES_NAME_Nb, kim_species_name_module::kim_species_name_nb /// /// \since 2.0 extern SpeciesName const Nb; /// \brief The standard \c Molybdenum species. /// /// \sa KIM_SPECIES_NAME_Mo, kim_species_name_module::kim_species_name_mo /// /// \since 2.0 extern SpeciesName const Mo; /// \brief The standard \c Technetium species. /// /// \sa KIM_SPECIES_NAME_Tc, kim_species_name_module::kim_species_name_tc /// /// \since 2.0 extern SpeciesName const Tc; /// \brief The standard \c Ruthenium species. /// /// \sa KIM_SPECIES_NAME_Ru, kim_species_name_module::kim_species_name_ru /// /// \since 2.0 extern SpeciesName const Ru; /// \brief The standard \c Rhodium species. /// /// \sa KIM_SPECIES_NAME_Rh, kim_species_name_module::kim_species_name_rh /// /// \since 2.0 extern SpeciesName const Rh; /// \brief The standard \c Palladium species. /// /// \sa KIM_SPECIES_NAME_Pd, kim_species_name_module::kim_species_name_pd /// /// \since 2.0 extern SpeciesName const Pd; /// \brief The standard \c Silver species. /// /// \sa KIM_SPECIES_NAME_Ag, kim_species_name_module::kim_species_name_ag /// /// \since 2.0 extern SpeciesName const Ag; /// \brief The standard \c Cadmium species. /// /// \sa KIM_SPECIES_NAME_Cd, kim_species_name_module::kim_species_name_cd /// /// \since 2.0 extern SpeciesName const Cd; /// \brief The standard \c Indium species. /// /// \sa KIM_SPECIES_NAME_In, kim_species_name_module::kim_species_name_in /// /// \since 2.0 extern SpeciesName const In; /// \brief The standard \c Tin species. /// /// \sa KIM_SPECIES_NAME_Sn, kim_species_name_module::kim_species_name_sn /// /// \since 2.0 extern SpeciesName const Sn; /// \brief The standard \c Antimony species. /// /// \sa KIM_SPECIES_NAME_Sb, kim_species_name_module::kim_species_name_sb /// /// \since 2.0 extern SpeciesName const Sb; /// \brief The standard \c Tellurium species. /// /// \sa KIM_SPECIES_NAME_Te, kim_species_name_module::kim_species_name_te /// /// \since 2.0 extern SpeciesName const Te; /// \brief The standard \c Iodine species. /// /// \sa KIM_SPECIES_NAME_I, kim_species_name_module::kim_species_name_i /// /// \since 2.0 extern SpeciesName const I; /// \brief The standard \c Xenon species. /// /// \sa KIM_SPECIES_NAME_Xe, kim_species_name_module::kim_species_name_xe /// /// \since 2.0 extern SpeciesName const Xe; /// \brief The standard \c Cesium species. /// /// \sa KIM_SPECIES_NAME_Cs, kim_species_name_module::kim_species_name_cs /// /// \since 2.0 extern SpeciesName const Cs; /// \brief The standard \c Barium species. /// /// \sa KIM_SPECIES_NAME_Ba, kim_species_name_module::kim_species_name_ba /// /// \since 2.0 extern SpeciesName const Ba; /// \brief The standard \c Lanthanum species. /// /// \sa KIM_SPECIES_NAME_La, kim_species_name_module::kim_species_name_la /// /// \since 2.0 extern SpeciesName const La; /// \brief The standard \c Cerium species. /// /// \sa KIM_SPECIES_NAME_Ce, kim_species_name_module::kim_species_name_ce /// /// \since 2.0 extern SpeciesName const Ce; /// \brief The standard \c Praseodymium species. /// /// \sa KIM_SPECIES_NAME_Pr, kim_species_name_module::kim_species_name_pr /// /// \since 2.0 extern SpeciesName const Pr; /// \brief The standard \c Neodymium species. /// /// \sa KIM_SPECIES_NAME_Nd, kim_species_name_module::kim_species_name_nd /// /// \since 2.0 extern SpeciesName const Nd; /// \brief The standard \c Promethium species. /// /// \sa KIM_SPECIES_NAME_Pm, kim_species_name_module::kim_species_name_pm /// /// \since 2.0 extern SpeciesName const Pm; /// \brief The standard \c Samarium species. /// /// \sa KIM_SPECIES_NAME_Sm, kim_species_name_module::kim_species_name_sm /// /// \since 2.0 extern SpeciesName const Sm; /// \brief The standard \c Europium species. /// /// \sa KIM_SPECIES_NAME_Eu, kim_species_name_module::kim_species_name_eu /// /// \since 2.0 extern SpeciesName const Eu; /// \brief The standard \c Gadolinium species. /// /// \sa KIM_SPECIES_NAME_Gd, kim_species_name_module::kim_species_name_gd /// /// \since 2.0 extern SpeciesName const Gd; /// \brief The standard \c Terbium species. /// /// \sa KIM_SPECIES_NAME_Tb, kim_species_name_module::kim_species_name_tb /// /// \since 2.0 extern SpeciesName const Tb; /// \brief The standard \c Dysprosium species. /// /// \sa KIM_SPECIES_NAME_Dy, kim_species_name_module::kim_species_name_dy /// /// \since 2.0 extern SpeciesName const Dy; /// \brief The standard \c Holmium species. /// /// \sa KIM_SPECIES_NAME_Ho, kim_species_name_module::kim_species_name_ho /// /// \since 2.0 extern SpeciesName const Ho; /// \brief The standard \c Erbium species. /// /// \sa KIM_SPECIES_NAME_Er, kim_species_name_module::kim_species_name_er /// /// \since 2.0 extern SpeciesName const Er; /// \brief The standard \c Thulium species. /// /// \sa KIM_SPECIES_NAME_Tm, kim_species_name_module::kim_species_name_tm /// /// \since 2.0 extern SpeciesName const Tm; /// \brief The standard \c Ytterbium species. /// /// \sa KIM_SPECIES_NAME_Yb, kim_species_name_module::kim_species_name_yb /// /// \since 2.0 extern SpeciesName const Yb; /// \brief The standard \c Lutetium species. /// /// \sa KIM_SPECIES_NAME_Lu, kim_species_name_module::kim_species_name_lu /// /// \since 2.0 extern SpeciesName const Lu; /// \brief The standard \c Hafnium species. /// /// \sa KIM_SPECIES_NAME_Hf, kim_species_name_module::kim_species_name_hf /// /// \since 2.0 extern SpeciesName const Hf; /// \brief The standard \c Tantalum species. /// /// \sa KIM_SPECIES_NAME_Ta, kim_species_name_module::kim_species_name_ta /// /// \since 2.0 extern SpeciesName const Ta; /// \brief The standard \c Tungsten species. /// /// \sa KIM_SPECIES_NAME_W, kim_species_name_module::kim_species_name_w /// /// \since 2.0 extern SpeciesName const W; /// \brief The standard \c Rhenium species. /// /// \sa KIM_SPECIES_NAME_Re, kim_species_name_module::kim_species_name_re /// /// \since 2.0 extern SpeciesName const Re; /// \brief The standard \c Osmium species. /// /// \sa KIM_SPECIES_NAME_Os, kim_species_name_module::kim_species_name_os /// /// \since 2.0 extern SpeciesName const Os; /// \brief The standard \c Iridium species. /// /// \sa KIM_SPECIES_NAME_Ir, kim_species_name_module::kim_species_name_ir /// /// \since 2.0 extern SpeciesName const Ir; /// \brief The standard \c Platinum species. /// /// \sa KIM_SPECIES_NAME_Pt, kim_species_name_module::kim_species_name_pt /// /// \since 2.0 extern SpeciesName const Pt; /// \brief The standard \c Gold species. /// /// \sa KIM_SPECIES_NAME_Au, kim_species_name_module::kim_species_name_au /// /// \since 2.0 extern SpeciesName const Au; /// \brief The standard \c Mercury species. /// /// \sa KIM_SPECIES_NAME_Hg, kim_species_name_module::kim_species_name_hg /// /// \since 2.0 extern SpeciesName const Hg; /// \brief The standard \c Thallium species. /// /// \sa KIM_SPECIES_NAME_Tl, kim_species_name_module::kim_species_name_tl /// /// \since 2.0 extern SpeciesName const Tl; /// \brief The standard \c Lead species. /// /// \sa KIM_SPECIES_NAME_Pb, kim_species_name_module::kim_species_name_pb /// /// \since 2.0 extern SpeciesName const Pb; /// \brief The standard \c Bismuth species. /// /// \sa KIM_SPECIES_NAME_Bi, kim_species_name_module::kim_species_name_bi /// /// \since 2.0 extern SpeciesName const Bi; /// \brief The standard \c Polonium species. /// /// \sa KIM_SPECIES_NAME_Po, kim_species_name_module::kim_species_name_po /// /// \since 2.0 extern SpeciesName const Po; /// \brief The standard \c Astatine species. /// /// \sa KIM_SPECIES_NAME_At, kim_species_name_module::kim_species_name_at /// /// \since 2.0 extern SpeciesName const At; /// \brief The standard \c Radon species. /// /// \sa KIM_SPECIES_NAME_Rn, kim_species_name_module::kim_species_name_rn /// /// \since 2.0 extern SpeciesName const Rn; /// \brief The standard \c Francium species. /// /// \sa KIM_SPECIES_NAME_Fr, kim_species_name_module::kim_species_name_fr /// /// \since 2.0 extern SpeciesName const Fr; /// \brief The standard \c Radium species. /// /// \sa KIM_SPECIES_NAME_Ra, kim_species_name_module::kim_species_name_ra /// /// \since 2.0 extern SpeciesName const Ra; /// \brief The standard \c Actinium species. /// /// \sa KIM_SPECIES_NAME_Ac, kim_species_name_module::kim_species_name_ac /// /// \since 2.0 extern SpeciesName const Ac; /// \brief The standard \c Thorium species. /// /// \sa KIM_SPECIES_NAME_Th, kim_species_name_module::kim_species_name_th /// /// \since 2.0 extern SpeciesName const Th; /// \brief The standard \c Protactinium species. /// /// \sa KIM_SPECIES_NAME_Pa, kim_species_name_module::kim_species_name_pa /// /// \since 2.0 extern SpeciesName const Pa; /// \brief The standard \c Uranium species. /// /// \sa KIM_SPECIES_NAME_U, kim_species_name_module::kim_species_name_u /// /// \since 2.0 extern SpeciesName const U; /// \brief The standard \c Neptunium species. /// /// \sa KIM_SPECIES_NAME_Np, kim_species_name_module::kim_species_name_np /// /// \since 2.0 extern SpeciesName const Np; /// \brief The standard \c Plutonium species. /// /// \sa KIM_SPECIES_NAME_Pu, kim_species_name_module::kim_species_name_pu /// /// \since 2.0 extern SpeciesName const Pu; /// \brief The standard \c Americium species. /// /// \sa KIM_SPECIES_NAME_Am, kim_species_name_module::kim_species_name_am /// /// \since 2.0 extern SpeciesName const Am; /// \brief The standard \c Curium species. /// /// \sa KIM_SPECIES_NAME_Cm, kim_species_name_module::kim_species_name_cm /// /// \since 2.0 extern SpeciesName const Cm; /// \brief The standard \c Berkelium species. /// /// \sa KIM_SPECIES_NAME_Bk, kim_species_name_module::kim_species_name_bk /// /// \since 2.0 extern SpeciesName const Bk; /// \brief The standard \c Californium species. /// /// \sa KIM_SPECIES_NAME_Cf, kim_species_name_module::kim_species_name_cf /// /// \since 2.0 extern SpeciesName const Cf; /// \brief The standard \c Einsteinium species. /// /// \sa KIM_SPECIES_NAME_Es, kim_species_name_module::kim_species_name_es /// /// \since 2.0 extern SpeciesName const Es; /// \brief The standard \c Fermium species. /// /// \sa KIM_SPECIES_NAME_Fm, kim_species_name_module::kim_species_name_fm /// /// \since 2.0 extern SpeciesName const Fm; /// \brief The standard \c Mendelevium species. /// /// \sa KIM_SPECIES_NAME_Md, kim_species_name_module::kim_species_name_md /// /// \since 2.0 extern SpeciesName const Md; /// \brief The standard \c Nobelium species. /// /// \sa KIM_SPECIES_NAME_No, kim_species_name_module::kim_species_name_no /// /// \since 2.0 extern SpeciesName const No; /// \brief The standard \c Lawrencium species. /// /// \sa KIM_SPECIES_NAME_Lr, kim_species_name_module::kim_species_name_lr /// /// \since 2.0 extern SpeciesName const Lr; /// \brief The standard \c Rutherfordium species. /// /// \sa KIM_SPECIES_NAME_Rf, kim_species_name_module::kim_species_name_rf /// /// \since 2.0 extern SpeciesName const Rf; /// \brief The standard \c Dubnium species. /// /// \sa KIM_SPECIES_NAME_Db, kim_species_name_module::kim_species_name_db /// /// \since 2.0 extern SpeciesName const Db; /// \brief The standard \c Seaborgium species. /// /// \sa KIM_SPECIES_NAME_Sg, kim_species_name_module::kim_species_name_sg /// /// \since 2.0 extern SpeciesName const Sg; /// \brief The standard \c Bohrium species. /// /// \sa KIM_SPECIES_NAME_Bh, kim_species_name_module::kim_species_name_bh /// /// \since 2.0 extern SpeciesName const Bh; /// \brief The standard \c Hassium species. /// /// \sa KIM_SPECIES_NAME_Hs, kim_species_name_module::kim_species_name_hs /// /// \since 2.0 extern SpeciesName const Hs; /// \brief The standard \c Meitnerium species. /// /// \sa KIM_SPECIES_NAME_Mt, kim_species_name_module::kim_species_name_mt /// /// \since 2.0 extern SpeciesName const Mt; /// \brief The standard \c Darmstadtium species. /// /// \sa KIM_SPECIES_NAME_Ds, kim_species_name_module::kim_species_name_ds /// /// \since 2.0 extern SpeciesName const Ds; /// \brief The standard \c Roentgenium species. /// /// \sa KIM_SPECIES_NAME_Rg, kim_species_name_module::kim_species_name_rg /// /// \since 2.0 extern SpeciesName const Rg; /// \brief The standard \c Copernicium species. /// /// \sa KIM_SPECIES_NAME_Cn, kim_species_name_module::kim_species_name_cn /// /// \since 2.0 extern SpeciesName const Cn; /// \brief The standard \c Nihonium species. /// /// \sa KIM_SPECIES_NAME_Nh, kim_species_name_module::kim_species_name_nh /// /// \since 2.0 extern SpeciesName const Nh; /// \brief The standard \c Flerovium species. /// /// \sa KIM_SPECIES_NAME_Fl, kim_species_name_module::kim_species_name_fl /// /// \since 2.0 extern SpeciesName const Fl; /// \brief The standard \c Moscovium species. /// /// \sa KIM_SPECIES_NAME_Mc, kim_species_name_module::kim_species_name_mc /// /// \since 2.0 extern SpeciesName const Mc; /// \brief The standard \c Livermorium species. /// /// \sa KIM_SPECIES_NAME_Lv, kim_species_name_module::kim_species_name_lv /// /// \since 2.0 extern SpeciesName const Lv; /// \brief The standard \c Tennessine species. /// /// \sa KIM_SPECIES_NAME_Ts, kim_species_name_module::kim_species_name_ts /// /// \since 2.0 extern SpeciesName const Ts; /// \brief The standard \c Oganesson species. /// /// \sa KIM_SPECIES_NAME_Og, kim_species_name_module::kim_species_name_og /// /// \since 2.0 extern SpeciesName const Og; /// \brief The standard \c user01 species. /// /// \sa KIM_SPECIES_NAME_user01, /// kim_species_name_module::kim_species_name_user01 /// /// \since 2.0 extern SpeciesName const user01; /// \brief The standard \c user02 species. /// /// \sa KIM_SPECIES_NAME_user02, /// kim_species_name_module::kim_species_name_user02 /// /// \since 2.0 extern SpeciesName const user02; /// \brief The standard \c user03 species. /// /// \sa KIM_SPECIES_NAME_user03, /// kim_species_name_module::kim_species_name_user03 /// /// \since 2.0 extern SpeciesName const user03; /// \brief The standard \c user04 species. /// /// \sa KIM_SPECIES_NAME_user04, /// kim_species_name_module::kim_species_name_user04 /// /// \since 2.0 extern SpeciesName const user04; /// \brief The standard \c user05 species. /// /// \sa KIM_SPECIES_NAME_user05, /// kim_species_name_module::kim_species_name_user05 /// /// \since 2.0 extern SpeciesName const user05; /// \brief The standard \c user06 species. /// /// \sa KIM_SPECIES_NAME_user06, /// kim_species_name_module::kim_species_name_user06 /// /// \since 2.0 extern SpeciesName const user06; /// \brief The standard \c user07 species. /// /// \sa KIM_SPECIES_NAME_user07, /// kim_species_name_module::kim_species_name_user07 /// /// \since 2.0 extern SpeciesName const user07; /// \brief The standard \c user08 species. /// /// \sa KIM_SPECIES_NAME_user08, /// kim_species_name_module::kim_species_name_user08 /// /// \since 2.0 extern SpeciesName const user08; /// \brief The standard \c user09 species. /// /// \sa KIM_SPECIES_NAME_user09, /// kim_species_name_module::kim_species_name_user09 /// /// \since 2.0 extern SpeciesName const user09; /// \brief The standard \c user10 species. /// /// \sa KIM_SPECIES_NAME_user10, /// kim_species_name_module::kim_species_name_user10 /// /// \since 2.0 extern SpeciesName const user10; /// \brief The standard \c user11 species. /// /// \sa KIM_SPECIES_NAME_user11, /// kim_species_name_module::kim_species_name_user11 /// /// \since 2.0 extern SpeciesName const user11; /// \brief The standard \c user12 species. /// /// \sa KIM_SPECIES_NAME_user12, /// kim_species_name_module::kim_species_name_user12 /// /// \since 2.0 extern SpeciesName const user12; /// \brief The standard \c user13 species. /// /// \sa KIM_SPECIES_NAME_user13, /// kim_species_name_module::kim_species_name_user13 /// /// \since 2.0 extern SpeciesName const user13; /// \brief The standard \c user14 species. /// /// \sa KIM_SPECIES_NAME_user14, /// kim_species_name_module::kim_species_name_user14 /// /// \since 2.0 extern SpeciesName const user14; /// \brief The standard \c user15 species. /// /// \sa KIM_SPECIES_NAME_user15, /// kim_species_name_module::kim_species_name_user15 /// /// \since 2.0 extern SpeciesName const user15; /// \brief The standard \c user16 species. /// /// \sa KIM_SPECIES_NAME_user16, /// kim_species_name_module::kim_species_name_user16 /// /// \since 2.0 extern SpeciesName const user16; /// \brief The standard \c user17 species. /// /// \sa KIM_SPECIES_NAME_user17, /// kim_species_name_module::kim_species_name_user17 /// /// \since 2.0 extern SpeciesName const user17; /// \brief The standard \c user18 species. /// /// \sa KIM_SPECIES_NAME_user18, /// kim_species_name_module::kim_species_name_user18 /// /// \since 2.0 extern SpeciesName const user18; /// \brief The standard \c user19 species. /// /// \sa KIM_SPECIES_NAME_user19, /// kim_species_name_module::kim_species_name_user19 /// /// \since 2.0 extern SpeciesName const user19; /// \brief The standard \c user20 species. /// /// \sa KIM_SPECIES_NAME_user20, /// kim_species_name_module::kim_species_name_user20 /// /// \since 2.0 extern SpeciesName const user20; /// \brief Get the number of standard SpeciesName's defined by the %KIM API. /// /// \param[out] numberOfSpeciesNames The number of standard SpeciesName's /// defined by the %KIM API. /// /// \sa KIM_SPECIES_NAME_GetNumberOfSpeciesNames, /// kim_species_name_module::kim_get_number_of_species_names /// /// \since 2.0 void GetNumberOfSpeciesNames(int * const numberOfSpeciesNames); /// \brief Get the identity of each defined standard SpeciesName. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// SpeciesName. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] speciesName The SpeciesName object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfSpeciesNames`. /// \return \c false otherwise. /// /// \sa KIM_SPECIES_NAME_GetSpeciesName, /// kim_species_name_module::kim_get_species_name /// /// \since 2.0 int GetSpeciesName(int const index, SpeciesName * const speciesName); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for SpeciesName /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(SpeciesName const & a, SpeciesName const & b) const { return a.speciesNameID < b.speciesNameID; } }; // struct Comparator } // namespace SPECIES_NAME } // namespace KIM #endif // KIM_SPECIES_NAME_HPP_ kim-api-2.3.0-git/cpp/include/KIM_SupportStatus.hpp000066400000000000000000000147511421473465500221450ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SUPPORT_STATUS_HPP_ #define KIM_SUPPORT_STATUS_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// SupportStatus's supported by the %KIM API. /// /// The enumeration constants are contained in the SUPPORT_STATUS namespace. /// /// \sa KIM_SupportStatus, kim_support_status_module::kim_support_status_type /// /// \since 2.0 class SupportStatus { public: /// \brief Integer identifying the specific SupportStatus represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_SupportStatus::supportStatusID, /// kim_support_status_module::kim_support_status_type::support_status_id /// /// \since 2.0 int supportStatusID; /// \brief Create an uninitialized SupportStatus object. /// /// \since 2.0 SupportStatus(); /// \brief Create a SupportStatus object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 SupportStatus(int const id); /// \brief Create a SupportStatus object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_SupportStatus_FromString, /// kim_support_status_module::kim_from_string /// /// \since 2.0 SupportStatus(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// SupportStatus's known to the %KIM API are found in the SUPPORT_STATUS /// namespace. /// /// \sa KIM_SupportStatus_Known, kim_support_status_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares SupportStatus objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_SupportStatus_Equal, kim_support_status_module::operator(.eq.) /// /// \since 2.0 bool operator==(SupportStatus const & rhs) const; /// \brief Compares SupportStatus objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_SupportStatus_NotEqual, kim_support_status_module::operator(.ne.) /// /// \since 2.0 bool operator!=(SupportStatus const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the SupportStatus object. /// /// \note If the SupportStatus object does not correspond to a value defined /// by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_SupportStatus_ToString, kim_support_status_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class SupportStatus /// \brief Contains the enumeration constants and the discovery routines for /// the SupportStatus \ref extensible_enumeration "Extensible Enumeration". namespace SUPPORT_STATUS { /// \brief The standard \c requiredByAPI status. /// /// \todo Add more detailed description of status. /// /// \sa KIM_SUPPORT_STATUS_requiredByAPI, /// kim_support_status_module::kim_support_status_required_by_api /// /// \since 2.0 extern SupportStatus const requiredByAPI; /// \brief The standard \c notSupported status. /// /// \todo Add more detailed description of status. /// /// \sa KIM_SUPPORT_STATUS_notSupported, /// kim_support_status_module::kim_support_status_not_supported /// /// \since 2.0 extern SupportStatus const notSupported; /// \brief The standard \c required status. /// /// \todo Add more detailed description of status. /// /// \sa KIM_SUPPORT_STATUS_required, /// kim_support_status_module::kim_support_status_required /// /// \since 2.0 extern SupportStatus const required; /// \brief The standard \c optional status. /// /// \todo Add more detailed description of status. /// /// \sa KIM_SUPPORT_STATUS_optional, /// kim_support_status_module::kim_support_status_optional /// /// \since 2.0 extern SupportStatus const optional; /// \brief Get the number of standard SupportStatus's defined by the %KIM /// API. /// /// \param[out] numberOfSupportStatuses The number of standard SupportStatus's /// defined by the %KIM API. /// /// \sa KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses, /// kim_support_status_module::kim_get_number_of_support_statuses /// /// \since 2.0 void GetNumberOfSupportStatuses(int * const numberOfSupportStatuses); /// \brief Get the identity of each defined standard SupportStatus. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// SupportStatus. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] supportStatus The SupportStatus object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfSupportStatuses`. /// \return \c false otherwise. /// /// \sa KIM_SUPPORT_STATUS_GetSupportStatus, /// kim_support_status_module::kim_get_support_status /// /// \since 2.0 int GetSupportStatus(int const index, SupportStatus * const supportStatus); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for SupportStatus /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(SupportStatus const & a, SupportStatus const & b) const { return a.supportStatusID < b.supportStatusID; } }; // struct Comparator } // namespace SUPPORT_STATUS } // namespace KIM #endif // KIM_SUPPORT_STATUS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_SupportedExtensions.hpp000066400000000000000000000041771421473465500233330ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SUPPORTED_EXTENSIONS_HPP_ #define KIM_SUPPORTED_EXTENSIONS_HPP_ #define KIM_SUPPORTED_EXTENSIONS_ID "KIM_SupportedExtensions" #define KIM_MAX_EXTENSION_ID_LENGTH 128 #define KIM_MAX_NUMBER_OF_EXTENSIONS 64 namespace KIM { /// \brief The only standard extension defined by the %KIM API. /// /// This structure provides a standard mechanism for extensions to be /// discovered at run time. /// /// \sa KIM_SupportedExtensions, /// kim_supported_extensions_module::kim_supported_extensions_type /// /// \since 2.0 struct SupportedExtensions { /// The number of extensions supported by the Model. int numberOfSupportedExtensions; /// The unique extension ID's of each supported extension. char supportedExtensionID[KIM_MAX_NUMBER_OF_EXTENSIONS] [KIM_MAX_EXTENSION_ID_LENGTH]; /// \c true if the model requires the simulator to execute the corresponding /// extension in order to be used correctly, \c false otherwise. int supportedExtensionRequired[KIM_MAX_NUMBER_OF_EXTENSIONS]; }; // struct SupportedExtensions } // namespace KIM #endif // KIM_SUPPORTED_EXTENSIONS_HPP_ kim-api-2.3.0-git/cpp/include/KIM_TemperatureUnit.hpp000066400000000000000000000140571421473465500224210ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_TEMPERATURE_UNIT_HPP_ #define KIM_TEMPERATURE_UNIT_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// TemperatureUnit's supported by the %KIM API. /// /// The enumeration constants are contained in the TEMPERATURE_UNIT namespace. /// /// \sa KIM_TemperatureUnit, /// kim_temperature_unit_module::kim_temperature_unit_type /// /// \since 2.0 class TemperatureUnit { public: /// \brief Integer identifying the specific TemperatureUnit represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_TemperatureUnit::temperatureUnitID, /// kim_temperature_unit_module::kim_temperature_unit_type::temperature_unit_id /// /// \since 2.0 int temperatureUnitID; /// \brief Create an uninitialized TemperatureUnit object. /// /// \since 2.0 TemperatureUnit(); /// \brief Create a TemperatureUnit object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 TemperatureUnit(int const id); /// \brief Create a TemperatureUnit object corresponding to the provided /// string. If the string does not match one of the values defined by the /// %KIM API, then an "unknown" object is generated. /// /// \sa KIM_TemperatureUnit_FromString, /// kim_temperature_unit_module::kim_from_string /// /// \since 2.0 TemperatureUnit(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// TemperatureUnit's known to the %KIM API are found in the TEMPERATURE_UNIT /// namespace. /// /// \sa KIM_TemperatureUnit_Known, kim_temperature_unit_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares TemperatureUnit objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_TemperatureUnit_Equal, /// kim_temperature_unit_module::operator(.eq.) /// /// \since 2.0 bool operator==(TemperatureUnit const & rhs) const; /// \brief Compares TemperatureUnit objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_TemperatureUnit_NotEqual, /// kim_temperature_unit_module::operator(.ne.) /// /// \since 2.0 bool operator!=(TemperatureUnit const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the TemperatureUnit object. /// /// \note If the TemperatureUnit object does not correspond to a value /// defined by the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_TemperatureUnit_ToString, /// kim_temperature_unit_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class TemperatureUnit /// \brief Contains the enumeration constants and the discovery routines for /// the TemperatureUnit \ref extensible_enumeration "Extensible Enumeration". namespace TEMPERATURE_UNIT { /// \brief Indicates that a TemperatureUnit is not used. /// /// \sa KIM_TEMPERATURE_UNIT_unused, /// kim_temperature_unit_module::kim_temperature_unit_unused /// /// \since 2.0 extern TemperatureUnit const unused; /// \brief The standard Kelvin unit of temperature. /// /// \sa KIM_TEMPERATURE_UNIT_K, /// kim_temperature_unit_module::kim_temperature_unit_k /// /// \since 2.0 extern TemperatureUnit const K; /// \brief Get the number of standard TemperatureUnit's defined by the %KIM /// API. /// /// \param[out] numberOfTemperatureUnits The number of standard /// TemperatureUnit's defined by the %KIM API. /// /// \sa KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits, /// kim_temperature_unit_module::kim_get_number_of_temperature_units /// /// \since 2.0 void GetNumberOfTemperatureUnits(int * const numberOfTemperatureUnits); /// \brief Get the identity of each defined standard TemperatureUnit. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// TemperatureUnit. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] temperatureUnit The TemperatureUnit object associated with \c /// index. /// /// \return \c true if `index < 0` or `index >= numberOfTemperatureUnits`. /// \return \c false otherwise. /// /// \sa KIM_TEMPERATURE_UNIT_GetTemperatureUnit, /// kim_temperature_unit_module::kim_get_temperature_unit /// /// \since 2.0 int GetTemperatureUnit(int const index, TemperatureUnit * const temperatureUnit); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for TemperatureUnit /// objects so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(TemperatureUnit const & a, TemperatureUnit const & b) const { return a.temperatureUnitID < b.temperatureUnitID; } }; // struct Comparator } // namespace TEMPERATURE_UNIT } // namespace KIM #endif // KIM_TEMPERATURE_UNIT_HPP_ kim-api-2.3.0-git/cpp/include/KIM_TimeUnit.hpp000066400000000000000000000136071421473465500210220ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_TIME_UNIT_HPP_ #define KIM_TIME_UNIT_HPP_ #include namespace KIM { /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the /// TimeUnit's supported by the %KIM API. /// /// The enumeration constants are contained in the TIME_UNIT namespace. /// /// \sa KIM_TimeUnit, kim_time_unit_module::kim_time_unit_type /// /// \since 2.0 class TimeUnit { public: /// \brief Integer identifying the specific TimeUnit represented. /// /// \note This should not be directly accessed and is only public for /// cross-language reasons. /// /// \sa KIM_TimeUnit::timeUnitID, /// kim_time_unit_module::kim_time_unit_type::time_unit_id /// /// \since 2.0 int timeUnitID; /// \brief Create an uninitialized TimeUnit object. /// /// \since 2.0 TimeUnit(); /// \brief Create a TimeUnit object with the specified id. /// /// \note This should not be used directly. /// /// \since 2.0 TimeUnit(int const id); /// \brief Create a TimeUnit object corresponding to the provided string. If /// the string does not match one of the values defined by the %KIM API, then /// an "unknown" object is generated. /// /// \sa KIM_TimeUnit_FromString, kim_time_unit_module::kim_from_string /// /// \since 2.0 TimeUnit(std::string const & str); /// \brief Determines if the object is a quantity known to the %KIM API. /// /// TimeUnit's known to the %KIM API are found in the TIME_UNIT namespace. /// /// \sa KIM_TimeUnit_Known, kim_time_unit_module::kim_known /// /// \since 2.0 bool Known() const; /// \brief Compares TimeUnit objects for equality. /// /// \note Not all "unknown" objects are equal. /// /// \sa KIM_TimeUnit_Equal, kim_time_unit_module::operator(.eq.) /// /// \since 2.0 bool operator==(TimeUnit const & rhs) const; /// \brief Compares TimeUnit objects for inequality. /// /// \note It is possible for two "unknown" objects to be not equal. /// /// \sa KIM_TimeUnit_NotEqual, kim_time_unit_module::operator(.ne.) /// /// \since 2.0 bool operator!=(TimeUnit const & rhs) const; /// \brief Converts the object to a string. /// /// \return A string object representing the TimeUnit object. /// /// \note If the TimeUnit object does not correspond to a value defined by /// the %KIM API, then the string "unknown" is returned. /// /// \sa KIM_TimeUnit_ToString, kim_time_unit_module::kim_to_string /// /// \since 2.0 std::string const & ToString() const; }; // class TimeUnit /// \brief Contains the enumeration constants and the discovery routines for /// the TimeUnit \ref extensible_enumeration "Extensible Enumeration". namespace TIME_UNIT { /// \brief Indicates that a TimeUnit is not used. /// /// \sa KIM_TIME_UNIT_unused, kim_time_unit_module::kim_time_unit_unused /// /// \since 2.0 extern TimeUnit const unused; /// \brief The standard femtosecond unit of time. /// /// \sa KIM_TIME_UNIT_fs, kim_time_unit_module::kim_time_unit_fs /// /// \since 2.0 extern TimeUnit const fs; /// \brief The standard picosecond unit of time. /// /// \sa KIM_TIME_UNIT_ps, kim_time_unit_module::kim_time_unit_ps /// /// \since 2.0 extern TimeUnit const ps; /// \brief The standard nanosecond unit of time. /// /// \sa KIM_TIME_UNIT_ns, kim_time_unit_module::kim_time_unit_ns /// /// \since 2.0 extern TimeUnit const ns; /// \brief The standard second unit of time. /// /// \sa KIM_TIME_UNIT_s, kim_time_unit_module::kim_time_unit_s /// /// \since 2.0 extern TimeUnit const s; /// \brief Get the number of standard TimeUnit's defined by the %KIM API. /// /// \param[out] numberOfTimeUnits The number of standard TimeUnit's defined by /// the %KIM API. /// /// \sa KIM_TIME_UNIT_GetNumberOfTimeUnits, /// kim_time_unit_module::kim_get_number_of_time_units /// /// \since 2.0 void GetNumberOfTimeUnits(int * const numberOfTimeUnits); /// \brief Get the identity of each defined standard TimeUnit. /// /// \param[in] index Zero-based index uniquely labeling each defined standard /// TimeUnitnit. This index ordering is only guaranteed to be /// stable during the lifetime of the current process. /// \param[out] timeUnit The TimeUnit object associated with \c index. /// /// \return \c true if `index < 0` or `index >= numberOfTimeUnits`. /// \return \c false otherwise. /// /// \sa KIM_TIME_UNIT_GetTimeUnit, kim_time_unit_module::kim_get_time_unit /// /// \since 2.0 int GetTimeUnit(int const index, TimeUnit * const timeUnit); /// \brief Structure provided for use with std::map. /// /// \since 2.0 struct Comparator { /// \brief Provides an (logically unmeaningful) ordering for TimeUnit objects /// so that they can be stored in a std::map. /// /// \since 2.0 bool operator()(TimeUnit const & a, TimeUnit const & b) const { return a.timeUnitID < b.timeUnitID; } }; // struct Comparator } // namespace TIME_UNIT } // namespace KIM #endif // KIM_TIME_UNIT_HPP_ kim-api-2.3.0-git/cpp/include/KIM_UnitSystem.hpp000066400000000000000000000030001421473465500213720ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_UNIT_SYSTEM_HPP_ #define KIM_UNIT_SYSTEM_HPP_ // IWYU pragma: begin_exports #ifndef KIM_LENGTH_UNIT_HPP_ #include "KIM_LengthUnit.hpp" #endif #ifndef KIM_ENERGY_UNIT_HPP_ #include "KIM_EnergyUnit.hpp" #endif #ifndef KIM_CHARGE_UNIT_HPP_ #include "KIM_ChargeUnit.hpp" #endif #ifndef KIM_TEMPERATURE_UNIT_HPP_ #include "KIM_TemperatureUnit.hpp" #endif #ifndef KIM_TIME_UNIT_HPP_ #include "KIM_TimeUnit.hpp" #endif // IWYU pragma: end_exports #endif // KIM_UNIT_SYSTEM_HPP_ kim-api-2.3.0-git/cpp/include/KIM_Version.hpp.in000066400000000000000000000050611421473465500213110ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_VERSION_HPP_ #define KIM_VERSION_HPP_ /// \brief The major version number of the %KIM API /// /// The %KIM API conforms to Semantic Versioning /// 2.0.0. /// /// \since 2.0 // clang-format off #define KIM_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ // clang-format on /// \brief The minor version number of the %KIM API /// /// The %KIM API conforms to Semantic Versioning /// 2.0.0. /// /// \since 2.0 // clang-format off #define KIM_VERSION_MINOR @PROJECT_VERSION_MINOR@ // clang-format on /// \brief The patch version number of the %KIM API /// /// The %KIM API conforms to Semantic Versioning /// 2.0.0. /// /// \since 2.0 // clang-format off #define KIM_VERSION_PATCH @PROJECT_VERSION_PATCH@ // clang-format on /// \brief The prerelease version string of the %KIM API /// /// The %KIM API conforms to Semantic Versioning /// 2.0.0. /// /// \since 2.0 #define KIM_VERSION_PRERELEASE "@PROJECT_VERSION_PRERELEASE@" /// \brief The build metadata version string of the %KIM API /// /// The %KIM API conforms to Semantic Versioning /// 2.0.0. /// /// \since 2.0 #define KIM_VERSION_BUILD_METADATA "@PROJECT_VERSION_BUILD_METADATA@" /// \brief The complete version string of the %KIM API /// /// The %KIM API conforms to Semantic Versioning /// 2.0.0. /// /// \since 2.0 #define KIM_VERSION_STRING "@PROJECT_VERSION_STRING@" #endif // KIM_VERSION_HPP_ kim-api-2.3.0-git/cpp/src/000077500000000000000000000000001421473465500152105ustar00rootroot00000000000000kim-api-2.3.0-git/cpp/src/CMakeLists.txt000066400000000000000000000111221421473465500177450ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # target_include_directories(kim-api PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake # for KIM_SharedLibrarySchema.hpp ) configure_file(KIM_Configuration.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/KIM_Configuration.hpp) set(CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ChargeUnit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Collection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_CollectionItemType.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Collections.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_CollectionsImplementation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeArgumentName.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeArguments.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeCallbackName.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_DataType.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_EnergyUnit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_FilesystemPath.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LanguageName.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LengthUnit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Log.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LogVerbosity.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Model.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelCompute.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelComputeArguments.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelComputeArgumentsCreate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelComputeArgumentsDestroy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelCreate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelDestroy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelDriverCreate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelExtension.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelRefresh.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelRoutineName.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelWriteParameterizedModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_Numbering.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SemVer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SpeciesName.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SupportStatus.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SimulatorModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SimulatorModelImplementation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_TemperatureUnit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_TimeUnit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ComputeArgumentsImplementation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_LogImplementation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_ModelImplementation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/KIM_SharedLibrary.cpp ) target_sources(kim-api PRIVATE ${CPP_SOURCES}) if(WIN32 AND NOT CYGWIN) # Activate C++17 language standard on Win32 platform, because kim-api code uses C++ filesystem library internally. # Note: The 'cxx_std_17' target compile feature was added by CMake version 3.8. # For older CMake versions, fall back to setting the CXX_STANDARD target property instead. get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) if("cxx_std_17" IN_LIST cxx_features) target_compile_features(kim-api PUBLIC cxx_std_17) else() set_property(TARGET kim-api PROPERTY CXX_STANDARD 17) set_property(TARGET kim-api PROPERTY CXX_STANDARD_REQUIRED YES) endif() endif() # The KIM API code uses POSIX.1-2008 functions such as strdup() or mkstemp(), which are # not part of the ISO C standard. Thus, when compiling with -std=c++98 instead of -std=gnu98, # these function would be unavailable. # Defining _DEFAULT_SOURCE during compilation tells the GNU C Library headers to make the # POSIX and System V functions available also in strict ANSI C mode. # See also: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html target_compile_definitions(kim-api PRIVATE _DEFAULT_SOURCE) kim-api-2.3.0-git/cpp/src/KIM_ChargeUnit.cpp000066400000000000000000000067451421473465500204610ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_CHARGE_UNIT_SYSTEM_HPP_ #include "KIM_ChargeUnit.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace CHARGE_UNIT { #include "KIM_ChargeUnit.inc" ChargeUnit const unused(ID_unused); ChargeUnit const C(ID_C); ChargeUnit const e(ID_e); ChargeUnit const statC(ID_statC); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[unused] = "unused"; m[C] = "C"; m[e] = "e"; m[statC] = "statC"; return m; } StringMap const chargeUnitToString = GetStringMap(); std::string const chargeUnitUnknown("unknown"); } // namespace void GetNumberOfChargeUnits(int * const numberOfChargeUnits) { *numberOfChargeUnits = chargeUnitToString.size(); } int GetChargeUnit(int const index, ChargeUnit * const chargeUnit) { int numberOfChargeUnits; GetNumberOfChargeUnits(&numberOfChargeUnits); if ((index < 0) || (index >= numberOfChargeUnits)) return true; StringMap::const_iterator iter = chargeUnitToString.begin(); for (int i = 0; i < index; ++i) ++iter; *chargeUnit = iter->first; return false; // no error } } // namespace CHARGE_UNIT // implementation of ChargeUnit ChargeUnit::ChargeUnit() {} ChargeUnit::ChargeUnit(int const id) : chargeUnitID(id) {} ChargeUnit::ChargeUnit(std::string const & str) { chargeUnitID = -1; for (CHARGE_UNIT::StringMap::const_iterator iter = CHARGE_UNIT::chargeUnitToString.begin(); iter != CHARGE_UNIT::chargeUnitToString.end(); ++iter) { if (iter->second == str) { chargeUnitID = (iter->first).chargeUnitID; break; } } } bool ChargeUnit::Known() const { int numberOfChargeUnits; CHARGE_UNIT::GetNumberOfChargeUnits(&numberOfChargeUnits); for (int i = 0; i < numberOfChargeUnits; ++i) { ChargeUnit cgUnit; CHARGE_UNIT::GetChargeUnit(i, &cgUnit); if (*this == cgUnit) { return true; } } return false; } bool ChargeUnit::operator==(ChargeUnit const & rhs) const { return chargeUnitID == rhs.chargeUnitID; } bool ChargeUnit::operator!=(ChargeUnit const & rhs) const { return chargeUnitID != rhs.chargeUnitID; } std::string const & ChargeUnit::ToString() const { CHARGE_UNIT::StringMap::const_iterator iter = CHARGE_UNIT::chargeUnitToString.find(*this); if (iter == CHARGE_UNIT::chargeUnitToString.end()) return CHARGE_UNIT::chargeUnitUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ChargeUnit.inc000066400000000000000000000044611421473465500204410ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_CHARGE_UNIT_INC_ #define KIM_CHARGE_UNIT_INC_ #define ID_unused 0 #define ID_C 1 #define ID_e 2 #define ID_statC 3 #endif /* KIM_CHARGE_UNIT_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_Collection.cpp000066400000000000000000000071441421473465500205150ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_COLLECTION_HPP_ #include "KIM_Collection.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace COLLECTION { #include "KIM_Collection.inc" Collection const system(ID_system); Collection const user(ID_user); Collection const environmentVariable(ID_environmentVariable); Collection const currentWorkingDirectory(ID_currentWorkingDirectory); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[system] = "system"; m[user] = "user"; m[environmentVariable] = "environmentVariable"; m[currentWorkingDirectory] = "currentWorkingDirectory"; return m; } StringMap const collectionToString = GetStringMap(); std::string const collectionUnknown("unknown"); } // namespace void GetNumberOfCollections(int * const numberOfCollections) { *numberOfCollections = collectionToString.size(); } int GetCollection(int const index, Collection * const collection) { int numberOfCollections; GetNumberOfCollections(&numberOfCollections); if ((index < 0) || (index >= numberOfCollections)) return true; StringMap::const_iterator iter = collectionToString.begin(); for (int i = 0; i < index; ++i) ++iter; *collection = iter->first; return false; // no error } } // namespace COLLECTION // implementation of Collection Collection::Collection() {} Collection::Collection(int const id) : collectionID(id) {} Collection::Collection(std::string const & str) { collectionID = -1; for (COLLECTION::StringMap::const_iterator iter = COLLECTION::collectionToString.begin(); iter != COLLECTION::collectionToString.end(); ++iter) { if (iter->second == str) { collectionID = (iter->first).collectionID; break; } } } bool Collection::Known() const { int numberOfCollections; COLLECTION::GetNumberOfCollections(&numberOfCollections); for (int i = 0; i < numberOfCollections; ++i) { Collection col; COLLECTION::GetCollection(i, &col); if (*this == col) { return true; } } return false; } bool Collection::operator==(Collection const & rhs) const { return collectionID == rhs.collectionID; } bool Collection::operator!=(Collection const & rhs) const { return collectionID != rhs.collectionID; } std::string const & Collection::ToString() const { COLLECTION::StringMap::const_iterator iter = COLLECTION::collectionToString.find(*this); if (iter == COLLECTION::collectionToString.end()) return COLLECTION::collectionUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_Collection.inc000066400000000000000000000045251421473465500205040ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COLLECTION_INC_ #define KIM_COLLECTION_INC_ #define ID_system 0 #define ID_user 1 #define ID_environmentVariable 2 #define ID_currentWorkingDirectory 3 #endif /* KIM_COLLECTION_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_CollectionItemType.cpp000066400000000000000000000101651421473465500221730ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace COLLECTION_ITEM_TYPE { #include "KIM_CollectionItemType.inc" CollectionItemType const modelDriver(ID_modelDriver); CollectionItemType const portableModel(ID_portableModel); CollectionItemType const simulatorModel(ID_simulatorModel); namespace { typedef std:: map StringMap; StringMap const GetStringMap() { StringMap m; m[modelDriver] = "modelDriver"; m[portableModel] = "portableModel"; m[simulatorModel] = "simulatorModel"; return m; } StringMap const collectionItemTypeToString = GetStringMap(); std::string const collectionItemTypeUnknown("unknown"); } // namespace void GetNumberOfCollectionItemTypes(int * const numberOfCollectionItemTypes) { *numberOfCollectionItemTypes = collectionItemTypeToString.size(); } int GetCollectionItemType(int const index, CollectionItemType * const collectionItemType) { int numberOfCollectionItemTypes; GetNumberOfCollectionItemTypes(&numberOfCollectionItemTypes); if ((index < 0) || (index >= numberOfCollectionItemTypes)) return true; StringMap::const_iterator iter = collectionItemTypeToString.begin(); for (int i = 0; i < index; ++i) ++iter; *collectionItemType = iter->first; return false; // no error } } // namespace COLLECTION_ITEM_TYPE // implementation of CollectionItemType CollectionItemType::CollectionItemType() {} CollectionItemType::CollectionItemType(int const id) : collectionItemTypeID(id) { } CollectionItemType::CollectionItemType(std::string const & str) { collectionItemTypeID = -1; for (COLLECTION_ITEM_TYPE::StringMap::const_iterator iter = COLLECTION_ITEM_TYPE::collectionItemTypeToString.begin(); iter != COLLECTION_ITEM_TYPE::collectionItemTypeToString.end(); ++iter) { if (iter->second == str) { collectionItemTypeID = (iter->first).collectionItemTypeID; break; } } } bool CollectionItemType::Known() const { int numberOfCollectionItemTypes; COLLECTION_ITEM_TYPE::GetNumberOfCollectionItemTypes( &numberOfCollectionItemTypes); for (int i = 0; i < numberOfCollectionItemTypes; ++i) { CollectionItemType colItemType; COLLECTION_ITEM_TYPE::GetCollectionItemType(i, &colItemType); if (*this == colItemType) { return true; } } return false; } bool CollectionItemType::operator==(CollectionItemType const & rhs) const { return collectionItemTypeID == rhs.collectionItemTypeID; } bool CollectionItemType::operator!=(CollectionItemType const & rhs) const { return collectionItemTypeID != rhs.collectionItemTypeID; } std::string const & CollectionItemType::ToString() const { COLLECTION_ITEM_TYPE::StringMap::const_iterator iter = COLLECTION_ITEM_TYPE::collectionItemTypeToString.find(*this); if (iter == COLLECTION_ITEM_TYPE::collectionItemTypeToString.end()) return COLLECTION_ITEM_TYPE::collectionItemTypeUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_CollectionItemType.inc000066400000000000000000000045271421473465500221670ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COLLECTION_ITEM_TYPE_INC_ #define KIM_COLLECTION_ITEM_TYPE_INC_ #define ID_modelDriver 0 #define ID_portableModel 1 #define ID_simulatorModel 2 #endif /* KIM_COLLECTION_ITEM_TYPE_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_Collections.cpp000066400000000000000000000147261421473465500207040ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_COLLECTIONS_HPP_ #include "KIM_Collections.hpp" #endif #ifndef KIM_COLLECTION_HPP_ #include "KIM_Collection.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_COLLECTIONS_IMPLEMENTATION_HPP_ #include "KIM_CollectionsImplementation.hpp" #endif namespace KIM { int Collections::Create(Collections ** const collections) { *collections = new Collections(); int error = CollectionsImplementation::Create(&((*collections)->pimpl)); if (error) { delete *collections; *collections = NULL; return true; } else { return false; } } void Collections::Destroy(Collections ** const collections) { if (*collections != NULL) { CollectionsImplementation::Destroy(&((*collections)->pimpl)); } delete *collections; *collections = NULL; } int Collections::GetItemType(std::string const & itemName, CollectionItemType * const itemType) const { return pimpl->GetItemType(itemName, itemType); } int Collections::GetItemLibraryFileNameAndCollection( CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName, Collection * const collection) const { return pimpl->GetItemLibraryFileNameAndCollection( itemType, itemName, fileName, collection); } int Collections::CacheListOfItemMetadataFiles(CollectionItemType const itemType, std::string const & itemName, int * const extent) { return pimpl->CacheListOfItemMetadataFiles(itemType, itemName, extent); } int Collections::GetItemMetadataFile( int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const { return pimpl->GetItemMetadataFile( index, fileName, fileLength, fileRawData, availableAsString, fileString); } int Collections::CacheListOfItemNamesByType(CollectionItemType const itemType, int * const extent) { return pimpl->CacheListOfItemNamesByType(itemType, extent); } int Collections::GetItemNameByType(int const index, std::string const ** const itemName) const { return pimpl->GetItemNameByType(index, itemName); } int Collections::CacheListOfItemNamesByCollectionAndType( Collection const collection, CollectionItemType const itemType, int * const extent) { return pimpl->CacheListOfItemNamesByCollectionAndType( collection, itemType, extent); } int Collections::GetItemNameByCollectionAndType( int const index, std::string const ** const itemNames) const { return pimpl->GetItemNameByCollectionAndType(index, itemNames); } int Collections::GetItemLibraryFileNameByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName) const { return pimpl->GetItemLibraryFileNameByCollectionAndType( collection, itemType, itemName, fileName); } int Collections::CacheListOfItemMetadataFilesByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, int * const extent) { return pimpl->CacheListOfItemMetadataFilesByCollectionAndType( collection, itemType, itemName, extent); } int Collections::GetItemMetadataFileByCollectionAndType( int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const { return pimpl->GetItemMetadataFileByCollectionAndType( index, fileName, fileLength, fileRawData, availableAsString, fileString); } void Collections::GetProjectNameAndSemVer( std::string const ** const projectName, std::string const ** const semVer) const { pimpl->GetProjectNameAndSemVer(projectName, semVer); } int Collections::GetEnvironmentVariableName( CollectionItemType const itemType, std::string const ** const name) const { return pimpl->GetEnvironmentVariableName(itemType, name); } void Collections::GetConfigurationFileEnvironmentVariable( std::string const ** const name, std::string const ** const value) const { pimpl->GetConfigurationFileEnvironmentVariable(name, value); } void Collections::GetConfigurationFileName( std::string const ** const fileName) const { pimpl->GetConfigurationFileName(fileName); } int Collections::CacheListOfDirectoryNames(Collection const collection, CollectionItemType const itemType, int * const extent) { return pimpl->CacheListOfDirectoryNames(collection, itemType, extent); } int Collections::GetDirectoryName( int const index, std::string const ** const directoryName) const { return pimpl->GetDirectoryName(index, directoryName); } void Collections::SetLogID(std::string const & logID) { pimpl->SetLogID(logID); } void Collections::PushLogVerbosity(LogVerbosity const logVerbosity) { pimpl->PushLogVerbosity(logVerbosity); } void Collections::PopLogVerbosity() { pimpl->PopLogVerbosity(); } Collections::Collections() : pimpl(NULL) {} Collections::~Collections() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_CollectionsImplementation.cpp000066400000000000000000001224051421473465500236040ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include "KIM_Configuration.hpp" #include "KIM_Version.hpp" #include #include #include #include #include #include #include #define LINELEN 256 #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif #ifndef KIM_COLLECTIONS_IMPLEMENTATION_HPP_ #include "KIM_CollectionsImplementation.hpp" #endif #ifndef KIM_FILESYSTEM_PATH_HPP_ #include "KIM_FilesystemPath.hpp" #endif #ifndef KIM_SHARED_LIBRARY_HPP_ #include "KIM_SharedLibrary.hpp" #endif // log helpers #define SNUM(x) \ static_cast(std::ostringstream() \ << std::dec << x) \ .str() #define SPTR(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #define SFUNC(x) \ static_cast( \ std::ostringstream() << reinterpret_cast(x)) \ .str() namespace { typedef std::map ItemTypeToPathListMap; KIM::FILESYSTEM::Path LibraryName(KIM::CollectionItemType const itemType, KIM::FILESYSTEM::Path const & path) { std::string libName = KIM_SHARED_MODULE_PREFIX; libName += KIM_PROJECT_NAME; libName += "-"; using namespace KIM::COLLECTION_ITEM_TYPE; if (itemType == modelDriver) libName += KIM_MODEL_DRIVER_IDENTIFIER; else if (itemType == portableModel) libName += KIM_PORTABLE_MODEL_IDENTIFIER; else if (itemType == simulatorModel) libName += KIM_SIMULATOR_MODEL_IDENTIFIER; else libName += "UNKNOWN-COLLECTION-ITEM-TYPE"; libName += KIM_SHARED_MODULE_SUFFIX; return path / libName; } int ProcessConfigFileLine( char const * const line, KIM::FILESYSTEM::Path const & configFile, char const * const identifier, std::vector const & deprecatedIdentifiers, KIM::Log * const log, KIM::FILESYSTEM::PathList & userDirs) { char linecpy[LINELEN]; char * word; char const * const sep = " \t="; strncpy(linecpy, line, LINELEN - 1); linecpy[LINELEN - 1] = '\0'; word = strtok(linecpy, sep); bool const foundIdentifier = !strcmp(identifier, word); bool const foundDeprecatedIdentifier = deprecatedIdentifiers.end() != std::find(deprecatedIdentifiers.begin(), deprecatedIdentifiers.end(), std::string(word)); if (!foundIdentifier && !foundDeprecatedIdentifier) { if (log) { std::stringstream ss; ss << "Expected identifier '" << identifier << "' but found '" << word << "' instead in '" << configFile << "' file." << std::endl; log->LogEntry(KIM::LOG_VERBOSITY::error, ss, __LINE__, __FILE__); } userDirs.clear(); return true; } else if (!foundIdentifier) { if (log) { std::stringstream ss; ss << "Deprecated identifier '" << word << "' found in " << configFile << " file. Use '" << identifier << "' instead." << std::endl; log->LogEntry(KIM::LOG_VERBOSITY::warning, ss, __LINE__, __FILE__); } } word = strtok(NULL, sep); userDirs.Parse(word); if (userDirs.empty()) // error { if (log) { std::stringstream ss; ss << "Invalid value in " << configFile << " file: " << word << std::endl; log->LogEntry(KIM::LOG_VERBOSITY::error, ss, __LINE__, __FILE__); } return true; } return false; } void PrivateGetConfigurationFileEnvironmentVariable(std::string & name, std::string & value) { name = KIM_ENVIRONMENT_CONFIGURATION_FILE; char const * const varVal = getenv(name.c_str()); if (NULL != varVal) value = varVal; else value.clear(); } void PrivateGetConfigurationFileName(KIM::FILESYSTEM::Path & fileName) { fileName = KIM_USER_CONFIGURATION_FILE; if (fileName.is_relative()) { fileName = KIM::FILESYSTEM::Path::HomePath() / fileName; } std::string varName; std::string varVal; PrivateGetConfigurationFileEnvironmentVariable(varName, varVal); if (!varVal.empty()) { // ensure we have an absolute path KIM::FILESYSTEM::Path path(varVal); if (path.is_relative()) { fileName = KIM::FILESYSTEM::Path::current_path() / path; } else { fileName = varVal; } } } void PrivateGetEnvironmentVariableName(KIM::CollectionItemType const itemType, std::string & name) { using namespace KIM::COLLECTION_ITEM_TYPE; if (itemType == modelDriver) { name = KIM_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR; } else if (itemType == portableModel) { name = KIM_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR; } else if (itemType == simulatorModel) { name = KIM_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR; } } void PrivateGetProjectNameAndSemVer(std::string & projectName, std::string & semVer) { projectName = KIM_PROJECT_NAME; semVer = KIM_VERSION_STRING; } void PrivateGetCWDDirs(ItemTypeToPathListMap & dirsMap) { using namespace KIM::COLLECTION_ITEM_TYPE; dirsMap[modelDriver].push_back("."); dirsMap[portableModel].push_back("."); dirsMap[simulatorModel].push_back("."); } void PrivateGetEnvironmentDirs(ItemTypeToPathListMap & dirsMap) { using namespace KIM::COLLECTION_ITEM_TYPE; dirsMap[modelDriver].Parse(getenv(KIM_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR)); dirsMap[portableModel].Parse( getenv(KIM_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR)); dirsMap[simulatorModel].Parse( getenv(KIM_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR)); } int PrivateGetUserDirs(KIM::Log * log, ItemTypeToPathListMap & dirsMap) { using namespace KIM::COLLECTION_ITEM_TYPE; KIM::FILESYSTEM::Path configFile; PrivateGetConfigurationFileName(configFile); std::ifstream cfl; cfl.open(configFile.string().c_str()); if (!cfl) { // unable to open file; create with default locations KIM::FILESYSTEM::Path path = configFile; path.remove_filename(); // create collection directories dirsMap[modelDriver].Parse(KIM_USER_MODEL_DRIVERS_DIR_DEFAULT); dirsMap[portableModel].Parse(KIM_USER_PORTABLE_MODELS_DIR_DEFAULT); dirsMap[simulatorModel].Parse(KIM_USER_SIMULATOR_MODELS_DIR_DEFAULT); KIM::CollectionsImplementation::WriteConfigurationFileAndCreateDirectories( configFile, dirsMap); } else { char line[LINELEN]; std::vector deprecatedIdentifiers; cfl.getline(line, LINELEN); if ((cfl.fail()) || (ProcessConfigFileLine(line, configFile, KIM_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER, deprecatedIdentifiers, log, dirsMap[modelDriver]))) { cfl.close(); return true; } deprecatedIdentifiers.clear(); deprecatedIdentifiers.push_back("models-dir"); cfl.getline(line, LINELEN); if (cfl.fail() || ProcessConfigFileLine(line, configFile, KIM_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER, deprecatedIdentifiers, log, dirsMap[portableModel])) { cfl.close(); return true; } deprecatedIdentifiers.clear(); cfl.getline(line, LINELEN); if (!cfl.fail()) { if (ProcessConfigFileLine(line, configFile, KIM_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER, deprecatedIdentifiers, log, dirsMap[simulatorModel])) { cfl.close(); return true; } else { cfl.close(); } } else { cfl.close(); // unable to read SM settings; rewrite file with default SM location KIM::FILESYSTEM::Path path = configFile; path.remove_filename(); dirsMap[simulatorModel].Parse(KIM_USER_SIMULATOR_MODELS_DIR_DEFAULT); if (dirsMap[simulatorModel].MakeDirectories()) return true; std::ofstream fl; fl.open(configFile.string().c_str()); fl << KIM_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER " = " << dirsMap[modelDriver].ToString() << "\n"; fl << KIM_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER " = " << dirsMap[portableModel].ToString() << "\n"; fl << KIM_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER " = " << KIM_USER_SIMULATOR_MODELS_DIR_DEFAULT << "\n"; fl.close(); } } return false; } void PrivateReplaceORIGIN(KIM::FILESYSTEM::PathList & pathList, KIM::FILESYSTEM::Path const & origin) { using namespace KIM::FILESYSTEM; std::vector::iterator path; for (path = pathList.begin(); path != pathList.end(); ++path) { if ((*path).is_relative()) // ORIGIN should not occurr in an absolute path { Path current(*path); Path left(current); Path right; // make left contain first directory name in path // make right contain remainder of path { // ensure current has no trailing slash if (current.filename().empty()) current = current.parent_path(); while (!current.parent_path().empty() && current.parent_path() != current) { right = current.filename() / right; current = current.parent_path(); left = current; } right = right.parent_path(); // remove trailing slash } if (left == "$ORIGIN" || left == "${ORIGIN}") { *path = origin / right; } } } } void PrivateGetSystemDirs(ItemTypeToPathListMap & dirsMap) { using namespace KIM::COLLECTION_ITEM_TYPE; using namespace KIM::FILESYSTEM; Path origin(KIM::SharedLibrary::GetORIGIN()); dirsMap[modelDriver].Parse(KIM_SYSTEM_MODEL_DRIVERS_DIR); PrivateReplaceORIGIN(dirsMap[modelDriver], origin); dirsMap[portableModel].Parse(KIM_SYSTEM_PORTABLE_MODELS_DIR); PrivateReplaceORIGIN(dirsMap[portableModel], origin); dirsMap[simulatorModel].Parse(KIM_SYSTEM_SIMULATOR_MODELS_DIR); PrivateReplaceORIGIN(dirsMap[simulatorModel], origin); } void PrivateGetListOfItemPathsByCollectionAndType( KIM::Collection const collection, KIM::CollectionItemType const itemType, KIM::Log * log, std::vector & paths) { ItemTypeToPathListMap dirsMap; if (collection == KIM::COLLECTION::system) PrivateGetSystemDirs(dirsMap); else if (collection == KIM::COLLECTION::user) PrivateGetUserDirs(log, dirsMap); else if (collection == KIM::COLLECTION::environmentVariable) PrivateGetEnvironmentDirs(dirsMap); else if (collection == KIM::COLLECTION::currentWorkingDirectory) PrivateGetCWDDirs(dirsMap); const KIM::FILESYSTEM::PathList & listOfDirs = dirsMap[itemType]; KIM::FILESYSTEM::PathList::const_iterator dir; for (dir = listOfDirs.begin(); dir != listOfDirs.end(); ++dir) { std::vector subDirs = dir->Subdirectories(); std::vector::const_iterator subDir; for (subDir = subDirs.begin(); subDir != subDirs.end(); ++subDir) { KIM::FILESYSTEM::Path const libName = LibraryName(itemType, *subDir); if (libName.exists()) { paths.push_back(*subDir); } } } } int PrivateGetItemLibraryFileNameByCollectionAndType( KIM::Collection const collection, KIM::CollectionItemType const itemType, std::string const & itemName, KIM::Log * log, KIM::FILESYSTEM::Path * const fileName) { namespace KC = KIM::COLLECTION; ItemTypeToPathListMap dirsMap; if (collection == KC::system) PrivateGetSystemDirs(dirsMap); else if (collection == KC::user) PrivateGetUserDirs(log, dirsMap); else if (collection == KC::environmentVariable) PrivateGetEnvironmentDirs(dirsMap); else if (collection == KC::currentWorkingDirectory) PrivateGetCWDDirs(dirsMap); const KIM::FILESYSTEM::PathList & listOfDirs = dirsMap[itemType]; KIM::FILESYSTEM::PathList::const_iterator dir; for (dir = listOfDirs.begin(); dir != listOfDirs.end(); ++dir) { KIM::FILESYSTEM::Path const libPath = LibraryName(itemType, *dir / itemName); if (libPath.exists()) { if (fileName) *fileName = libPath; return false; } } if (fileName) fileName->clear(); return true; } int PrivateGetListOfItemMetadataFilesByCollectionAndType( KIM::Collection const collection, KIM::CollectionItemType const itemType, std::string const & itemName, KIM::Log * const log, std::vector & fileNames, std::vector & availableAsStrings, std::vector & fileStrings) { fileNames.clear(); availableAsStrings.clear(); fileStrings.clear(); KIM::FILESYSTEM::Path path; if (PrivateGetItemLibraryFileNameByCollectionAndType( collection, itemType, itemName, log, &path)) { return true; } KIM::SharedLibrary lib(log); int error = lib.Open(path); if (error) { return true; } int extent; error = lib.GetNumberOfMetadataFiles(&extent); if (error) { lib.Close(); return true; } for (int i = 0; i < extent; ++i) { std::string flnm; unsigned int length; unsigned char const * data; error = lib.GetMetadataFile(i, &flnm, &length, &data); if (error) { lib.Close(); return true; } fileNames.push_back(flnm); fileStrings.push_back(std::string()); fileStrings.back().assign(reinterpret_cast(data), length); availableAsStrings.push_back( (strlen(fileStrings.back().c_str()) == length) ? true : false); } lib.Close(); return false; } int PrivateGetItemLibraryFileNameAndCollection( KIM::CollectionItemType const itemType, std::string const & itemName, KIM::Log * const log, KIM::FILESYSTEM::Path * const fileName, KIM::Collection * const collection) { namespace KC = KIM::COLLECTION; KIM::FILESYSTEM::Path itemPath; KIM::Collection col; if (!PrivateGetItemLibraryFileNameByCollectionAndType( KC::currentWorkingDirectory, itemType, itemName, log, &itemPath)) { col = KC::currentWorkingDirectory; } else if (!PrivateGetItemLibraryFileNameByCollectionAndType( KC::environmentVariable, itemType, itemName, log, &itemPath)) { col = KC::environmentVariable; } else if (!PrivateGetItemLibraryFileNameByCollectionAndType( KC::user, itemType, itemName, log, &itemPath)) { col = KC::user; } else if (!PrivateGetItemLibraryFileNameByCollectionAndType( KC::system, itemType, itemName, log, &itemPath)) { col = KC::system; } else { return true; } if (fileName) *fileName = itemPath; if (collection) *collection = col; return false; } int PrivateGetListOfItemMetadataFiles(KIM::CollectionItemType const itemType, std::string const & itemName, KIM::Log * const log, std::vector & fileNames, std::vector & availableAsStrings, std::vector & fileStrings) { fileNames.clear(); availableAsStrings.clear(); fileStrings.clear(); KIM::Collection collection; int error = PrivateGetItemLibraryFileNameAndCollection( itemType, itemName, log, NULL, &collection); if (error) { return true; } return PrivateGetListOfItemMetadataFilesByCollectionAndType( collection, itemType, itemName, log, fileNames, availableAsStrings, fileStrings); } int PrivateGetItemType(std::string const & itemName, KIM::Log * const log, KIM::CollectionItemType * const itemType) { using namespace KIM::COLLECTION_ITEM_TYPE; KIM::CollectionItemType it; if (!PrivateGetItemLibraryFileNameAndCollection( portableModel, itemName, log, NULL, NULL)) { it = portableModel; } else if (!PrivateGetItemLibraryFileNameAndCollection( simulatorModel, itemName, log, NULL, NULL)) { it = simulatorModel; } else if (!PrivateGetItemLibraryFileNameAndCollection( modelDriver, itemName, log, NULL, NULL)) { it = modelDriver; } else { return true; } *itemType = it; return false; } } // namespace #include "KIM_LogMacros.hpp" #define KIM_LOGGER_OBJECT_NAME this namespace KIM { int CollectionsImplementation::Create( CollectionsImplementation ** const collectionsImplementation) { // error checking of arguments performed as part of CollectionsCreate() Log * pLog; int error = Log::Create(&pLog); if (error) { return true; } CollectionsImplementation * pCollectionsImplementation; pCollectionsImplementation = new CollectionsImplementation(pLog); #if DEBUG_VERBOSITY std::string const callString = "Create(" + SPTR(collectionsImplementation) + ")."; pCollectionsImplementation->LogEntry( LOG_VERBOSITY::debug, "Created Log and CollectionsImplementation objects after enter " + callString, __LINE__, __FILE__); #endif *collectionsImplementation = pCollectionsImplementation; #if DEBUG_VERBOSITY (*collectionsImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Exit 0=" + callString, __LINE__, __FILE__); #endif return false; } void CollectionsImplementation::Destroy( CollectionsImplementation ** const collectionsImplementation) { #if DEBUG_VERBOSITY std::string callString = "Destroy(" + SPTR(collectionsImplementation) + ")."; (*collectionsImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Enter " + callString, __LINE__, __FILE__); #endif #if DEBUG_VERBOSITY (*collectionsImplementation) ->LogEntry(LOG_VERBOSITY::debug, "Destroying CollectionsImplementation object and exit " + callString, __LINE__, __FILE__); #endif delete *collectionsImplementation; // also deletes Log object *collectionsImplementation = NULL; } bool CollectionsImplementation:: WriteConfigurationFileAndCreateDirectories( // for internal use only FILESYSTEM::Path const & fileName, std::map const & dirsMap) { using namespace KIM::COLLECTION_ITEM_TYPE; // create config file directory KIM::FILESYSTEM::Path path = fileName; path.remove_filename(); if (path.MakeDirectory()) return true; // create/open config file std::ofstream fl; fl.open(fileName.string().c_str(), std::ofstream::out | std::ofstream::trunc); if (!fl) return true; // create collection directories if (dirsMap.find(modelDriver)->second.MakeDirectories()) return true; if (dirsMap.find(portableModel)->second.MakeDirectories()) return true; if (dirsMap.find(simulatorModel)->second.MakeDirectories()) return true; // write config file fl << KIM_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER " = " << dirsMap.find(modelDriver)->second << "\n"; fl << KIM_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER " = " << dirsMap.find(portableModel)->second << "\n"; fl << KIM_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER " = " << dirsMap.find(simulatorModel)->second << "\n"; fl << "\n" << "This file was created by a kim-api installation with " ":\n" << " " << KIM_UID << "\n" << "with path\n" << " " << fileName << "\n\n" << "The associated kim-api dynamic library was installed in\n" << " " << SharedLibrary::GetORIGIN() << "\n" << "at the time this file was created.\n"; fl.close(); return false; } int CollectionsImplementation::GetItemType( std::string const & itemName, CollectionItemType * const itemType) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemType(\"" + itemName + "\", " + SPTR(itemType) + ")."; #endif LOG_DEBUG("Enter " + callString); CollectionItemType it; if (PrivateGetItemType(itemName, log_, &it)) { LOG_ERROR("Unable to find item."); LOG_DEBUG("Exit 1=" + callString); return true; } *itemType = it; LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetItemLibraryFileNameAndCollection( CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName, Collection * const collection) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemLibraryFileNameAndCollection(" + itemType.ToString() + ", \"" + itemName + "\", " + SPTR(fileName) + ", " + SPTR(collection) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (!itemType.Known()) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif Collection col; FILESYSTEM::Path path; if (PrivateGetItemLibraryFileNameAndCollection( itemType, itemName, log_, &path, &col)) { LOG_ERROR("Unable to find item."); LOG_DEBUG("Exit 1=" + callString); return true; } if (fileName) { // Convert from internal KIM::FILESYSTEM::Path represention to conventional // string representation: getItemLibraryFileNameAndCollection_FileName_ = path.string(); *fileName = &getItemLibraryFileNameAndCollection_FileName_; } if (collection) *collection = col; LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::CacheListOfItemMetadataFiles( CollectionItemType const itemType, std::string const & itemName, int * const extent) { #if DEBUG_VERBOSITY std::string const callString = "CacheListOfItemMetadataFiles(" + itemType.ToString() + ", \"" + itemName + "\", " + SPTR(extent) + ")."; #endif LOG_DEBUG("Enter " + callString); *extent = 0; cacheListOfItemMetadataFiles_Names_.clear(); cacheListOfItemMetadataFiles_availableAsString_.clear(); cacheListOfItemMetadataFiles_RawData_.clear(); #if ERROR_VERBOSITY if (!itemType.Known()) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif int error = PrivateGetListOfItemMetadataFiles( itemType, itemName, log_, cacheListOfItemMetadataFiles_Names_, cacheListOfItemMetadataFiles_availableAsString_, cacheListOfItemMetadataFiles_RawData_); if (error) { LOG_ERROR("Unable to cache item metadata files."); LOG_DEBUG("Exit 1=" + callString); return true; } *extent = cacheListOfItemMetadataFiles_Names_.size(); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetItemMetadataFile( int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemMetadataFile(" + SNUM(index) + ", " + SPTR(fileName) + ", " + SPTR(fileLength) + ", " + SPTR(fileRawData) + ", " + SPTR(availableAsString) + ", " + SPTR(fileString) + ")."; #endif LOG_DEBUG("Enter " + callString); if ((index < 0) || (size_t(index) > cacheListOfItemMetadataFiles_Names_.size())) { LOG_ERROR("Invalid metadata file index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (fileName) *fileName = &(cacheListOfItemMetadataFiles_Names_[index]); if (fileLength) *fileLength = (cacheListOfItemMetadataFiles_RawData_[index].length() - 1); if (fileRawData) *fileRawData = reinterpret_cast( cacheListOfItemMetadataFiles_RawData_[index].c_str()); if (availableAsString) *availableAsString = cacheListOfItemMetadataFiles_availableAsString_[index]; if (fileString) { if (cacheListOfItemMetadataFiles_availableAsString_[index]) *fileString = &(cacheListOfItemMetadataFiles_RawData_[index]); else *fileString = NULL; } LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::CacheListOfItemNamesByType( CollectionItemType const itemType, int * const extent) { #if DEBUG_VERBOSITY std::string const callString = "CacheListOfItemNamesByType(" + itemType.ToString() + ", " + SPTR(extent) + ")."; #endif LOG_DEBUG("Enter " + callString); *extent = 0; cacheListOfItemNamesByType_.clear(); #if ERROR_VERBOSITY if (!itemType.Known()) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif namespace KC = KIM::COLLECTION; std::vector listOfPaths; PrivateGetListOfItemPathsByCollectionAndType( KC::system, itemType, log_, listOfPaths); PrivateGetListOfItemPathsByCollectionAndType( KC::user, itemType, log_, listOfPaths); PrivateGetListOfItemPathsByCollectionAndType( KC::environmentVariable, itemType, log_, listOfPaths); PrivateGetListOfItemPathsByCollectionAndType( KC::currentWorkingDirectory, itemType, log_, listOfPaths); // Sort path list and remove duplicates. std::sort(listOfPaths.begin(), listOfPaths.end()); listOfPaths.erase(std::unique(listOfPaths.begin(), listOfPaths.end()), listOfPaths.end()); // Get the item names from the KIM::FILESYSTEM::Path entries. cacheListOfItemNamesByType_.clear(); cacheListOfItemNamesByType_.reserve(listOfPaths.size()); std::vector::const_iterator path; for (path = listOfPaths.begin(); path != listOfPaths.end(); ++path) { cacheListOfItemNamesByType_.push_back(path->filename().string()); } *extent = cacheListOfItemNamesByType_.size(); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetItemNameByType( int const index, std::string const ** const itemName) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemNameByType(" + SNUM(index) + ", " + SPTR(itemName) + ")."; #endif LOG_DEBUG("Enter " + callString); if ((index < 0) || (size_t(index) > cacheListOfItemNamesByType_.size())) { LOG_ERROR("Invalid item name index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } *itemName = &(cacheListOfItemNamesByType_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::CacheListOfItemNamesByCollectionAndType( Collection const collection, CollectionItemType const itemType, int * const extent) { #if DEBUG_VERBOSITY std::string const callString = "CacheListOfItemNamesByCollectionAndType(" + collection.ToString() + ", " + itemType.ToString() + ", " + SPTR(extent) + ")."; #endif LOG_DEBUG("Enter " + callString); *extent = 0; cacheListOfItemNamesByCollectionAndType_.clear(); #if ERROR_VERBOSITY if ((!collection.Known()) || (!itemType.Known())) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::vector listOfPaths; PrivateGetListOfItemPathsByCollectionAndType( collection, itemType, log_, listOfPaths); // Sort path list and remove duplicates. std::sort(listOfPaths.begin(), listOfPaths.end()); listOfPaths.erase(std::unique(listOfPaths.begin(), listOfPaths.end()), listOfPaths.end()); // Extract the item names from the KIM::FILESYSTEM::Path entries. cacheListOfItemNamesByCollectionAndType_.clear(); cacheListOfItemNamesByCollectionAndType_.reserve(listOfPaths.size()); std::vector::const_iterator path; for (path = listOfPaths.begin(); path != listOfPaths.end(); ++path) { cacheListOfItemNamesByCollectionAndType_.push_back( path->filename().string()); } *extent = cacheListOfItemNamesByCollectionAndType_.size(); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetItemNameByCollectionAndType( int const index, std::string const ** const itemName) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemNameByCollectionAndType(" + SNUM(index) + ", " + SPTR(itemName) + ")."; #endif LOG_DEBUG("Enter " + callString); if ((index < 0) || (size_t(index) > cacheListOfItemNamesByCollectionAndType_.size())) { LOG_ERROR("Invalid item name index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } *itemName = &(cacheListOfItemNamesByCollectionAndType_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetItemLibraryFileNameByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemLibraryFileNameByCollectionAndType(" + collection.ToString() + ", " + itemType.ToString() + ", \"" + itemName + "\", " + SPTR(fileName) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((!collection.Known()) || (!itemType.Known())) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif FILESYSTEM::Path path; int error = PrivateGetItemLibraryFileNameByCollectionAndType( collection, itemType, itemName, log_, &path); if (error) { LOG_ERROR("Unable to find item."); LOG_DEBUG("Exit 1=" + callString); return true; } // Convert from internal KIM::FILESYSTEM::Path representation to conventional // std::string representation. getItemLibraryFileNameByCollectionAndType_ = path.string(); *fileName = &getItemLibraryFileNameByCollectionAndType_; LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::CacheListOfItemMetadataFilesByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, int * const extent) { #if DEBUG_VERBOSITY std::string const callString = "CacheListOfItemMetadataFilesByCollectionAndType(" + collection.ToString() + ", " + itemType.ToString() + ", \"" + itemName + "\", " + SPTR(extent) + ")."; #endif LOG_DEBUG("Enter " + callString); *extent = 0; cacheListOfItemMetadataFilesByCollectionAndType_FileNames_.clear(); cacheListOfItemMetadataFilesByCollectionAndType_AvailableAsString_.clear(); cacheListOfItemMetadataFilesByCollectionAndType_FileRawData_.clear(); #if ERROR_VERBOSITY if ((!collection.Known()) || (!itemType.Known())) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif int error = PrivateGetListOfItemMetadataFilesByCollectionAndType( collection, itemType, itemName, log_, cacheListOfItemMetadataFilesByCollectionAndType_FileNames_, cacheListOfItemMetadataFilesByCollectionAndType_AvailableAsString_, cacheListOfItemMetadataFilesByCollectionAndType_FileRawData_); if (error) { LOG_ERROR("Unable to cache item metadata files."); LOG_DEBUG("Exit 1=" + callString); return true; } *extent = cacheListOfItemMetadataFilesByCollectionAndType_FileNames_.size(); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetItemMetadataFileByCollectionAndType( int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const { #if DEBUG_VERBOSITY std::string const callString = "GetItemMetadataFileByCollectionAndType(" + SNUM(index) + ", " + SPTR(fileName) + ", " + SPTR(fileLength) + ", " + SPTR(fileRawData) + ", " + SPTR(availableAsString) + ", " + SPTR(fileString) + ")."; #endif LOG_DEBUG("Enter " + callString); if ((index < 0) || (size_t(index) > cacheListOfItemMetadataFilesByCollectionAndType_FileNames_.size())) { LOG_ERROR("Invalid metadata file index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (fileName != NULL) *fileName = &(cacheListOfItemMetadataFilesByCollectionAndType_FileNames_[index]); if (fileLength != NULL) *fileLength = (cacheListOfItemMetadataFilesByCollectionAndType_FileRawData_[index] .length() - 1); if (fileRawData != NULL) *fileRawData = reinterpret_cast( cacheListOfItemMetadataFilesByCollectionAndType_FileRawData_[index] .c_str()); if (availableAsString != NULL) *availableAsString = cacheListOfItemMetadataFilesByCollectionAndType_AvailableAsString_ [index]; if ((cacheListOfItemMetadataFilesByCollectionAndType_AvailableAsString_ [index]) && (fileString != NULL)) *fileString = &( cacheListOfItemMetadataFilesByCollectionAndType_FileRawData_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } void CollectionsImplementation::GetProjectNameAndSemVer( std::string const ** const projectName, std::string const ** const semVer) const { #if DEBUG_VERBOSITY std::string const callString = "GetProjectNameAndSemVer(" + SPTR(projectName) + ", " + SPTR(semVer) + ")."; #endif LOG_DEBUG("Enter " + callString); PrivateGetProjectNameAndSemVer(getProjectNameAndSemVer_ProjectName_, getProjectNameAndSemVer_SemVer_); if (projectName) *projectName = &getProjectNameAndSemVer_ProjectName_; if (semVer) *semVer = &getProjectNameAndSemVer_SemVer_; LOG_DEBUG("Exit " + callString); } int CollectionsImplementation::GetEnvironmentVariableName( CollectionItemType const itemType, std::string const ** const name) const { #if DEBUG_VERBOSITY std::string const callString = "GetEnvironmentVariableName(" + itemType.ToString() + ", " + SPTR(name) + ")."; #endif LOG_DEBUG("Enter " + callString); if (!itemType.Known()) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } PrivateGetEnvironmentVariableName(itemType, getEnvironmentVariableName_); *name = &getEnvironmentVariableName_; LOG_DEBUG("Exit 0=" + callString); return false; } void CollectionsImplementation::GetConfigurationFileEnvironmentVariable( std::string const ** const name, std::string const ** const value) const { #if DEBUG_VERBOSITY std::string const callString = "GetConfigurationFileEnvironmentVariable(" + SPTR(name) + ", " + SPTR(value) + ")."; #endif LOG_DEBUG("Enter " + callString); PrivateGetConfigurationFileEnvironmentVariable( getConfigurationFileEnvironmentVariable_Name_, getConfigurationFileEnvironmentVariable_Value_); if (name) *name = &getConfigurationFileEnvironmentVariable_Name_; if (value) *value = &getConfigurationFileEnvironmentVariable_Value_; LOG_DEBUG("Exit " + callString); } void CollectionsImplementation::GetConfigurationFileName( std::string const ** const fileName) const { #if DEBUG_VERBOSITY std::string const callString = "GetConfigurationFileName(" + SPTR(fileName) + ")."; #endif LOG_DEBUG("Enter " + callString); FILESYSTEM::Path path; PrivateGetConfigurationFileName(path); // Convert from internal KIM::FILESYSTEM::Path representation to conventional // std::string representation. getConfigurationFileName_ = path.string(); *fileName = &getConfigurationFileName_; LOG_DEBUG("Exit " + callString); } int CollectionsImplementation::CacheListOfDirectoryNames( Collection const collection, CollectionItemType const itemType, int * const extent) { #if DEBUG_VERBOSITY std::string const callString = "CacheListOfDirectoryNames(" + collection.ToString() + ", " + itemType.ToString() + ", " + SPTR(extent) + ")."; #endif LOG_DEBUG("Enter " + callString); *extent = 0; cacheListOfDirectoryNames_.clear(); #if ERROR_VERBOSITY if ((!collection.Known()) || (!itemType.Known())) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif ItemTypeToPathListMap dirsMap; if (collection == COLLECTION::system) { PrivateGetSystemDirs(dirsMap); } else if (collection == COLLECTION::user) { if (PrivateGetUserDirs(log_, dirsMap)) { LOG_ERROR("Unable to update user collection directories."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (collection == COLLECTION::environmentVariable) { PrivateGetEnvironmentDirs(dirsMap); } else if (collection == COLLECTION::currentWorkingDirectory) { PrivateGetCWDDirs(dirsMap); } // Convert from internal KIM::FILESYSTEM::Path representation to conventional // std::string representation. FILESYSTEM::PathList const & pathList = dirsMap[itemType]; cacheListOfDirectoryNames_.clear(); cacheListOfDirectoryNames_.reserve(pathList.size()); FILESYSTEM::PathList::const_iterator path; for (path = pathList.begin(); path != pathList.end(); ++path) { cacheListOfDirectoryNames_.push_back(path->string()); } *extent = cacheListOfDirectoryNames_.size(); LOG_DEBUG("Exit 0=" + callString); return false; } int CollectionsImplementation::GetDirectoryName( int const index, std::string const ** const directoryName) const { #if DEBUG_VERBOSITY std::string const callString = "GetDirectoryName(" + SNUM(index) + ", " + SPTR(directoryName) + ")."; #endif LOG_DEBUG("Enter " + callString); if ((index < 0) || (size_t(index) > cacheListOfDirectoryNames_.size())) { LOG_ERROR("Invalid directory index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } *directoryName = &(cacheListOfDirectoryNames_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } void CollectionsImplementation::SetLogID(std::string const & logID) { #if DEBUG_VERBOSITY std::string const callString = "SetLogID('" + logID + "')."; #endif LOG_DEBUG("Enter " + callString); log_->SetID(logID); LOG_DEBUG("Exit " + callString); } void CollectionsImplementation::PushLogVerbosity( LogVerbosity const logVerbosity) { #if DEBUG_VERBOSITY std::string const callString = "PushLogVerbosity(" + logVerbosity.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); log_->PushVerbosity(logVerbosity); LOG_DEBUG("Exit " + callString); } void CollectionsImplementation::PopLogVerbosity() { #if DEBUG_VERBOSITY std::string const callString = "PopLogVerbosity()."; #endif LOG_DEBUG("Enter " + callString); log_->PopVerbosity(); LOG_DEBUG("Exit " + callString); } void CollectionsImplementation::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } void CollectionsImplementation::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } CollectionsImplementation::CollectionsImplementation(Log * const log) : log_(log) { #if DEBUG_VERBOSITY std::string const callString = "CollectionsImplementation(" + SPTR(log) + ")."; #endif LOG_DEBUG("Enter " + callString); // nothing to do LOG_DEBUG("Exit " + callString); } CollectionsImplementation::~CollectionsImplementation() { #if DEBUG_VERBOSITY std::string const callString = "~CollectionsImplementation()."; #endif LOG_DEBUG("Enter " + callString); // nothing to do LOG_DEBUG("Destroying Log object and exit " + callString); Log::Destroy(&log_); } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_CollectionsImplementation.hpp000066400000000000000000000157521421473465500236170ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COLLECTIONS_IMPLEMENTATION_HPP_ #define KIM_COLLECTIONS_IMPLEMENTATION_HPP_ #include #include #include #include #ifndef KIM_FILESYSTEM_Path_HPP_ #include "KIM_FilesystemPath.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_COLLECTION_HPP_ #include "KIM_Collection.hpp" #endif namespace KIM { // Forward declaration class Log; class CollectionsImplementation { public: static int Create(CollectionsImplementation ** const collectionsImplementation); static void Destroy(CollectionsImplementation ** const collectionsImplementation); static bool WriteConfigurationFileAndCreateDirectories( // for internal use only FILESYSTEM::Path const & fileName, std::map const & dirsMap); int GetItemType(std::string const & itemName, CollectionItemType * const itemType) const; int GetItemLibraryFileNameAndCollection(CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName, Collection * const collection) const; int CacheListOfItemMetadataFiles(CollectionItemType const itemType, std::string const & itemName, int * const extent); int GetItemMetadataFile(int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const; int CacheListOfItemNamesByType(CollectionItemType const itemType, int * const extent); int GetItemNameByType(int const index, std::string const ** const itemName) const; int CacheListOfItemNamesByCollectionAndType(Collection const collection, CollectionItemType const itemType, int * const extent); int GetItemNameByCollectionAndType(int const index, std::string const ** const itemName) const; int GetItemLibraryFileNameByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, std::string const ** const fileName) const; int CacheListOfItemMetadataFilesByCollectionAndType( Collection const collection, CollectionItemType const itemType, std::string const & itemName, int * const extent); int GetItemMetadataFileByCollectionAndType( int const index, std::string const ** const fileName, unsigned int * const fileLength, unsigned char const ** const fileRawData, int * const availableAsString, std::string const ** const fileString) const; void GetProjectNameAndSemVer(std::string const ** const projectName, std::string const ** const semVer) const; int GetEnvironmentVariableName(CollectionItemType const itemType, std::string const ** const name) const; void GetConfigurationFileEnvironmentVariable( std::string const ** const name, std::string const ** const value) const; void GetConfigurationFileName(std::string const ** const fileName) const; int CacheListOfDirectoryNames(Collection const collection, CollectionItemType const itemType, int * const extent); int GetDirectoryName(int const index, std::string const ** const directoryName) const; void SetLogID(std::string const & logID); void PushLogVerbosity(LogVerbosity const logVerbosity); void PopLogVerbosity(); void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; private: // do not allow copy constructor or operator= CollectionsImplementation(CollectionsImplementation const &); void operator=(CollectionsImplementation const &); CollectionsImplementation(Log * const log); ~CollectionsImplementation(); Log * log_; mutable std::string getItemLibraryFileNameAndCollection_FileName_; std::vector cacheListOfItemMetadataFiles_Names_; std::vector cacheListOfItemMetadataFiles_availableAsString_; std::vector cacheListOfItemMetadataFiles_RawData_; std::vector cacheListOfItemNamesByType_; std::vector cacheListOfItemNamesByCollectionAndType_; mutable std::string getItemLibraryFileNameByCollectionAndType_; std::vector cacheListOfItemMetadataFilesByCollectionAndType_FileNames_; std::vector cacheListOfItemMetadataFilesByCollectionAndType_AvailableAsString_; std::vector cacheListOfItemMetadataFilesByCollectionAndType_FileRawData_; mutable std::string getProjectNameAndSemVer_ProjectName_; mutable std::string getProjectNameAndSemVer_SemVer_; mutable std::string getEnvironmentVariableName_; mutable std::string getConfigurationFileEnvironmentVariable_Name_; mutable std::string getConfigurationFileEnvironmentVariable_Value_; mutable std::string getConfigurationFileName_; std::vector cacheListOfDirectoryNames_; }; // class CollectionsImplementation } // namespace KIM #endif // KIM_COLLECTIONS_IMPLEMENTATION_HPP_ kim-api-2.3.0-git/cpp/src/KIM_ComputeArgumentName.cpp000066400000000000000000000150721421473465500223410ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace COMPUTE_ARGUMENT_NAME { #include "KIM_ComputeArgumentName.inc" ComputeArgumentName const numberOfParticles(ID_numberOfParticles); ComputeArgumentName const particleSpeciesCodes(ID_particleSpeciesCodes); ComputeArgumentName const particleContributing(ID_particleContributing); ComputeArgumentName const coordinates(ID_coordinates); ComputeArgumentName const partialEnergy(ID_partialEnergy); ComputeArgumentName const partialForces(ID_partialForces); ComputeArgumentName const partialParticleEnergy(ID_partialParticleEnergy); ComputeArgumentName const partialVirial(ID_partialVirial); ComputeArgumentName const partialParticleVirial(ID_partialParticleVirial); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[numberOfParticles] = "numberOfParticles"; m[particleSpeciesCodes] = "particleSpeciesCodes"; m[particleContributing] = "particleContributing"; m[coordinates] = "coordinates"; m[partialEnergy] = "partialEnergy"; m[partialForces] = "partialForces"; m[partialParticleEnergy] = "partialParticleEnergy"; m[partialVirial] = "partialVirial"; m[partialParticleVirial] = "partialParticleVirial"; return m; } StringMap const computeArgumentNameToString = GetStringMap(); std::string const computeArgumentNameUnknown("unknown"); } // namespace namespace { typedef std:: map DataTypeMap; DataTypeMap const GetDataTypeMap() { // Here we must assume that the DATA_TYPE:: constants are not initialized. int const Integer = 0; int const Double = 1; DataTypeMap m; m[numberOfParticles] = DataType(Integer); m[particleSpeciesCodes] = DataType(Integer); m[particleContributing] = DataType(Integer); m[coordinates] = DataType(Double); m[partialEnergy] = DataType(Double); m[partialForces] = DataType(Double); m[partialParticleEnergy] = DataType(Double); m[partialVirial] = DataType(Double); m[partialParticleVirial] = DataType(Double); return m; } DataTypeMap const computeArgumentNameToDataType = GetDataTypeMap(); } // namespace namespace { typedef std::vector ComputeArgumentVector; ComputeArgumentVector const GetComputeArgumentVector() { ComputeArgumentVector v; v.push_back(numberOfParticles); v.push_back(particleSpeciesCodes); v.push_back(particleContributing); v.push_back(coordinates); return v; } } // namespace // used by KIM::ModelImplementation extern ComputeArgumentVector const requiredByAPI_ComputeArguments = GetComputeArgumentVector(); void GetNumberOfComputeArgumentNames(int * const numberOfComputeArgumentNames) { *numberOfComputeArgumentNames = computeArgumentNameToString.size(); } int GetComputeArgumentName(int const index, ComputeArgumentName * const computeArgumentName) { int numberOfComputeArgumentNames; GetNumberOfComputeArgumentNames(&numberOfComputeArgumentNames); if ((index < 0) || (index >= numberOfComputeArgumentNames)) return true; StringMap::const_iterator iter = computeArgumentNameToString.begin(); for (int i = 0; i < index; ++i) ++iter; *computeArgumentName = iter->first; return false; // no error } int GetComputeArgumentDataType(ComputeArgumentName const computeArgumentName, DataType * const dataType) { DataTypeMap::const_iterator iter = computeArgumentNameToDataType.find(computeArgumentName); if (iter == computeArgumentNameToDataType.end()) return true; else { *dataType = iter->second; return false; } } } // namespace COMPUTE_ARGUMENT_NAME // implementation of ComputeArgumentName ComputeArgumentName::ComputeArgumentName() {} ComputeArgumentName::ComputeArgumentName(int const id) : computeArgumentNameID(id) { } ComputeArgumentName::ComputeArgumentName(std::string const & str) { computeArgumentNameID = -1; for (COMPUTE_ARGUMENT_NAME::StringMap::const_iterator iter = COMPUTE_ARGUMENT_NAME::computeArgumentNameToString.begin(); iter != COMPUTE_ARGUMENT_NAME::computeArgumentNameToString.end(); ++iter) { if (iter->second == str) { computeArgumentNameID = (iter->first).computeArgumentNameID; break; } } } bool ComputeArgumentName::Known() const { int numberOfComputeArgumentNames; COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames( &numberOfComputeArgumentNames); for (int i = 0; i < numberOfComputeArgumentNames; ++i) { ComputeArgumentName cam; COMPUTE_ARGUMENT_NAME::GetComputeArgumentName(i, &cam); if (*this == cam) { return true; } } return false; } bool ComputeArgumentName::operator==(ComputeArgumentName const & rhs) const { return computeArgumentNameID == rhs.computeArgumentNameID; } bool ComputeArgumentName::operator!=(ComputeArgumentName const & rhs) const { return computeArgumentNameID != rhs.computeArgumentNameID; } std::string const & ComputeArgumentName::ToString() const { COMPUTE_ARGUMENT_NAME::StringMap::const_iterator iter = COMPUTE_ARGUMENT_NAME::computeArgumentNameToString.find(*this); if (iter == COMPUTE_ARGUMENT_NAME::computeArgumentNameToString.end()) return COMPUTE_ARGUMENT_NAME::computeArgumentNameUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ComputeArgumentName.inc000066400000000000000000000050351421473465500223260ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COMPUTE_ARGUMENT_NAME_INC_ #define KIM_COMPUTE_ARGUMENT_NAME_INC_ #define ID_numberOfParticles 0 #define ID_particleSpeciesCodes 1 #define ID_particleContributing 2 #define ID_coordinates 3 #define ID_partialEnergy 4 #define ID_partialForces 5 #define ID_partialParticleEnergy 6 #define ID_partialVirial 7 #define ID_partialParticleVirial 8 #endif /* KIM_COMPUTE_ARGUMENT_NAME_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_ComputeArguments.cpp000066400000000000000000000075401421473465500217240ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ComputeArguments.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include "KIM_ComputeArgumentsImplementation.hpp" #endif namespace KIM { int ComputeArguments::GetArgumentSupportStatus( ComputeArgumentName const computeArgumentName, SupportStatus * const supportStatus) const { return pimpl->GetArgumentSupportStatus(computeArgumentName, supportStatus); } int ComputeArguments::GetCallbackSupportStatus( ComputeCallbackName const computeCallbackName, SupportStatus * const supportStatus) const { return pimpl->GetCallbackSupportStatus(computeCallbackName, supportStatus); } int ComputeArguments::SetArgumentPointer( ComputeArgumentName const computeArgumentName, int const * const ptr) { return pimpl->SetArgumentPointer(computeArgumentName, ptr); } int ComputeArguments::SetArgumentPointer( ComputeArgumentName const computeArgumentName, int * const ptr) { return pimpl->SetArgumentPointer(computeArgumentName, ptr); } int ComputeArguments::SetArgumentPointer( ComputeArgumentName const computeArgumentName, double const * const ptr) { return pimpl->SetArgumentPointer(computeArgumentName, ptr); } int ComputeArguments::SetArgumentPointer( ComputeArgumentName const computeArgumentName, double * const ptr) { return pimpl->SetArgumentPointer(computeArgumentName, ptr); } int ComputeArguments::SetCallbackPointer( ComputeCallbackName const computeCallbackName, LanguageName const languageName, Function * const fptr, void * const dataObject) { return pimpl->SetCallbackPointer( computeCallbackName, languageName, fptr, dataObject); } void ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent( int * const result) const { pimpl->AreAllRequiredArgumentsAndCallbacksPresent(result); } void ComputeArguments::SetSimulatorBufferPointer(void * const ptr) { pimpl->SetSimulatorBufferPointer(ptr); } void ComputeArguments::GetSimulatorBufferPointer(void ** const ptr) const { pimpl->GetSimulatorBufferPointer(ptr); } std::string const & ComputeArguments::ToString() const { return pimpl->ToString(); } void ComputeArguments::SetLogID(std::string const & logID) { pimpl->SetLogID(logID); } void ComputeArguments::PushLogVerbosity(LogVerbosity const logVerbosity) { pimpl->PushLogVerbosity(logVerbosity); } void ComputeArguments::PopLogVerbosity() { pimpl->PopLogVerbosity(); } ComputeArguments::ComputeArguments() : pimpl(NULL) {} ComputeArguments::~ComputeArguments() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ComputeArgumentsImplementation.cpp000066400000000000000000001325401421473465500246310ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #include #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include "KIM_ComputeArgumentsImplementation.hpp" #endif #ifndef KIM_FUNCTION_TYPES_H_ extern "C" { #include "KIM_FunctionTypes.h" } #endif namespace KIM { namespace COMPUTE_ARGUMENT_NAME { extern std::vector const requiredByAPI_ComputeArguments; } // namespace COMPUTE_ARGUMENT_NAME namespace COMPUTE_CALLBACK_NAME { extern std::vector const requiredByAPI_ComputeCallbacks; } // namespace COMPUTE_CALLBACK_NAME } // namespace KIM // log helpers #define SNUM(x) \ static_cast(std::ostringstream() \ << std::dec << x) \ .str() #define SPTR(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #define SFUNC(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #include "KIM_LogMacros.hpp" #define KIM_LOGGER_OBJECT_NAME this namespace KIM { int ComputeArgumentsImplementation::Create( std::string const & modelName, std::string const & modelLogID, Numbering const modelNumbering, Numbering const simulatorNumbering, int const numberingOffset, ComputeArgumentsImplementation ** const computeArgumentsImplementation) { Log * pLog; int error = Log::Create(&pLog); if (error) { return true; } pLog->SetID(modelLogID + "_" + pLog->GetID()); *computeArgumentsImplementation = new ComputeArgumentsImplementation( modelName, modelNumbering, simulatorNumbering, numberingOffset, pLog); #if DEBUG_VERBOSITY std::string callString = "Create(" + modelName + ", " + modelLogID + ", " + modelNumbering.ToString() + ", " + simulatorNumbering.ToString() + ", " + SNUM(numberingOffset) + ", " + SPTR(computeArgumentsImplementation) + ")."; (*computeArgumentsImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Created Log and ComputeArgumentsImplementation objects and enter " + callString, __LINE__, __FILE__); #endif #if DEBUG_VERBOSITY (*computeArgumentsImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Exit 0=" + callString, __LINE__, __FILE__); #endif return false; } void ComputeArgumentsImplementation::Destroy( ComputeArgumentsImplementation ** const computeArgumentsImplementation) { #if DEBUG_VERBOSITY std::string const callString = "Destroy(" + SPTR(computeArgumentsImplementation) + ")."; (*computeArgumentsImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Enter " + callString, __LINE__, __FILE__); #endif #if DEBUG_VERBOSITY (*computeArgumentsImplementation) ->LogEntry(LOG_VERBOSITY::debug, "Destroying ComputeArgumentsImplementation object and exit " + callString, __LINE__, __FILE__); #endif delete *computeArgumentsImplementation; // also deletes Log object *computeArgumentsImplementation = NULL; } int ComputeArgumentsImplementation::SetArgumentSupportStatus( ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus) { #if DEBUG_VERBOSITY std::string const callString = "SetArgumentSupportStatus(" + computeArgumentName.ToString() + ", " + supportStatus.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()) || (!supportStatus.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((computeArgumentSupportStatus_[computeArgumentName] == SUPPORT_STATUS::requiredByAPI) && (supportStatus != SUPPORT_STATUS::requiredByAPI)) { LOG_ERROR("Argument '" + computeArgumentName.ToString() + "' SupportStatus is 'requiredByAPI' and cannot be changed."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif computeArgumentSupportStatus_[computeArgumentName] = supportStatus; // initialize pointer if not already done if (supportStatus != SUPPORT_STATUS::notSupported) { std::map::const_iterator result = computeArgumentPointer_.find(computeArgumentName); if (result == computeArgumentPointer_.end()) { LOG_DEBUG("Initialize ComputeArgument pointer."); computeArgumentPointer_[computeArgumentName] = NULL; } } LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::GetArgumentSupportStatus( ComputeArgumentName const computeArgumentName, SupportStatus * const supportStatus) const { #if DEBUG_VERBOSITY std::string const callString = "GetArgumentSupportStatus(" + computeArgumentName.ToString() + ", " + SPTR(supportStatus) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeArgumentSupportStatus_.find(computeArgumentName); *supportStatus = result->second; LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::SetCallbackSupportStatus( ComputeCallbackName const computeCallbackName, SupportStatus const supportStatus) { #if DEBUG_VERBOSITY std::string const callString = "SetCallbackSupportStatus(" + computeCallbackName.ToString() + ", " + supportStatus.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeCallbackName.Known()) || (!supportStatus.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((computeCallbackSupportStatus_[computeCallbackName] == SUPPORT_STATUS::requiredByAPI) && (supportStatus != SUPPORT_STATUS::requiredByAPI)) { LOG_ERROR("ComputeCallback '" + computeCallbackName.ToString() + "' SupportStatus is 'requiredByAPI' and cannot " "be changed."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif computeCallbackSupportStatus_[computeCallbackName] = supportStatus; // initialize pointer if not already done if (supportStatus != SUPPORT_STATUS::notSupported) { std::map::const_iterator result = computeCallbackFunctionPointer_.find(computeCallbackName); if (result == computeCallbackFunctionPointer_.end()) { LOG_DEBUG("Initialize ComputeCallback pointer."); computeCallbackLanguage_[computeCallbackName] = LANGUAGE_NAME::cpp; computeCallbackFunctionPointer_[computeCallbackName] = NULL; computeCallbackDataObjectPointer_[computeCallbackName] = NULL; } } LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::GetCallbackSupportStatus( ComputeCallbackName const computeCallbackName, SupportStatus * const supportStatus) const { #if DEBUG_VERBOSITY std::string const callString = "GetCallbackSupportStatus(" + computeCallbackName.ToString() + ", " + SPTR(supportStatus) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeCallbackName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeCallbackSupportStatus_.find(computeCallbackName); *supportStatus = result->second; LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::SetArgumentPointer( ComputeArgumentName const computeArgumentName, int const * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetArgumentPointer(" + computeArgumentName.ToString() + ", " + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator result = computeArgumentSupportStatus_.find(computeArgumentName); if (result->second == SUPPORT_STATUS::notSupported) { if (ptr == NULL) { LOG_WARNING("Setting 'notSupported' ComputeArgument '" + computeArgumentName.ToString() + "' pointer to NULL. This action, although innocuous, " "is considered an error and should be avoided."); LOG_DEBUG("Exit 0=" + callString); return false; // allow innocuous behavior } else { LOG_ERROR("Pointer value cannot be set for ComputeArgument '" + computeArgumentName.ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } } #endif computeArgumentPointer_[computeArgumentName] = reinterpret_cast(const_cast(ptr)); LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::SetArgumentPointer( ComputeArgumentName const computeArgumentName, int * const ptr) { return SetArgumentPointer(computeArgumentName, const_cast(ptr)); } int ComputeArgumentsImplementation::SetArgumentPointer( ComputeArgumentName const computeArgumentName, double const * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetArgumentPointer(" + computeArgumentName.ToString() + ", " + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator result = computeArgumentSupportStatus_.find(computeArgumentName); if (result->second == SUPPORT_STATUS::notSupported) { if (ptr == NULL) { LOG_WARNING("Setting 'notSupported' ComputeArgument '" + computeArgumentName.ToString() + "' pointer to NULL. This action, although innocuous, " "is considered an error and should be avoided."); LOG_DEBUG("Exit 0=" + callString); return false; // allow innocuous behavior } else { LOG_ERROR("Pointer value cannot be set for ComputeArgument '" + computeArgumentName.ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } } #endif computeArgumentPointer_[computeArgumentName] = reinterpret_cast(const_cast(ptr)); LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::SetArgumentPointer( ComputeArgumentName const computeArgumentName, double * const ptr) { return SetArgumentPointer(computeArgumentName, const_cast(ptr)); } int ComputeArgumentsImplementation::GetArgumentPointer( ComputeArgumentName const computeArgumentName, int const ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetArgumentPointer(" + computeArgumentName.ToString() + ", " + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator statusResult = computeArgumentSupportStatus_.find(computeArgumentName); if (statusResult->second == SUPPORT_STATUS::notSupported) { LOG_ERROR("Pointer value does not exist for ComputeArgument '" + (statusResult->first).ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeArgumentPointer_.find(computeArgumentName); *ptr = reinterpret_cast(result->second); LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::GetArgumentPointer( ComputeArgumentName const computeArgumentName, int ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetArgumentPointer(" + computeArgumentName.ToString() + ", " + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator statusResult = computeArgumentSupportStatus_.find(computeArgumentName); if (statusResult->second == SUPPORT_STATUS::notSupported) { LOG_ERROR("Pointer value does not exist for ComputeArgument '" + (statusResult->first).ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeArgumentPointer_.find(computeArgumentName); *ptr = reinterpret_cast(result->second); LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::GetArgumentPointer( ComputeArgumentName const computeArgumentName, double const ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetArgumentPointer(" + computeArgumentName.ToString() + ", " + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator statusResult = computeArgumentSupportStatus_.find(computeArgumentName); if (statusResult->second == SUPPORT_STATUS::notSupported) { LOG_ERROR("Pointer value does not exist for ComputeArgument '" + (statusResult->first).ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeArgumentPointer_.find(computeArgumentName); *ptr = reinterpret_cast(result->second); LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::GetArgumentPointer( ComputeArgumentName const computeArgumentName, double ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetArgumentPointer(" + computeArgumentName.ToString() + ", " + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeArgumentName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator statusResult = computeArgumentSupportStatus_.find(computeArgumentName); if (statusResult->second == SUPPORT_STATUS::notSupported) { LOG_ERROR("Pointer value does not exist for ComputeArgument '" + (statusResult->first).ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeArgumentPointer_.find(computeArgumentName); *ptr = reinterpret_cast(result->second); LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::SetCallbackPointer( ComputeCallbackName const computeCallbackName, LanguageName const languageName, Function * const fptr, void * const dataObject) { #if DEBUG_VERBOSITY std::string const callString = "SetCallbackPointer(" + computeCallbackName.ToString() + ", " + languageName.ToString() + ", " + SFUNC(fptr) + ", " + SPTR(dataObject) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeCallbackName.Known()) || (!languageName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator result = computeCallbackSupportStatus_.find(computeCallbackName); if (result->second == SUPPORT_STATUS::notSupported) { if (fptr == NULL) { LOG_WARNING("Setting 'notSupported' ComputeCallback '" + computeCallbackName.ToString() + "' pointer to NULL. This action, although innocuous, " "is considered an error and should be avoided."); LOG_DEBUG("Exit 0=" + callString); return false; // allow innocuous behavior } else { LOG_ERROR("Pointer value cannot be set for ComputeCallback '" + computeCallbackName.ToString() + "' that is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } } #endif computeCallbackLanguage_[computeCallbackName] = languageName; computeCallbackFunctionPointer_[computeCallbackName] = fptr; computeCallbackDataObjectPointer_[computeCallbackName] = dataObject; LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::IsCallbackPresent( ComputeCallbackName const computeCallbackName, int * const present) const { #if DEBUG_VERBOSITY std::string const callString = "IsCallbackPresent(" + computeCallbackName.ToString() + ", " + SPTR(present) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!computeCallbackName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map::const_iterator statusResult = computeCallbackSupportStatus_.find(computeCallbackName); if (statusResult->second == SUPPORT_STATUS::notSupported) { LOG_ERROR("Pointer value does not exist for ComputeCallback '" + (statusResult->first).ToString() + "' which is 'notSupported'."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = computeCallbackFunctionPointer_.find(computeCallbackName); if (result->second == NULL) { *present = false; } else { *present = true; } LOG_DEBUG("Exit 0=" + callString); return false; } void ComputeArgumentsImplementation::AreAllRequiredArgumentsAndCallbacksPresent( int * const result) const { #if DEBUG_VERBOSITY std::string const callString = "AreAllRequiredArgumentsAndCallbacksPresent(" + SPTR(result) + ")."; #endif LOG_DEBUG("Enter " + callString); // Check that all required compute arguments are present for (std::map::const_iterator itr = computeArgumentSupportStatus_.begin(); itr != computeArgumentSupportStatus_.end(); ++itr) { if ((itr->second == SUPPORT_STATUS::requiredByAPI) || (itr->second == SUPPORT_STATUS::required)) { if (computeArgumentPointer_.find(itr->first)->second == NULL) { LOG_ERROR("Required ComputeArgument '" + (itr->first).ToString() + "' is not present."); *result = false; LOG_DEBUG("Exit " + callString); return; } } } // Check that all required callbacks are present for (std::map::const_iterator itr = computeCallbackSupportStatus_.begin(); itr != computeCallbackSupportStatus_.end(); ++itr) { if ((itr->second == SUPPORT_STATUS::requiredByAPI) || (itr->second == SUPPORT_STATUS::required)) { if (computeCallbackFunctionPointer_.find(itr->first)->second == NULL) { LOG_ERROR("Required ComputeCallback '" + (itr->first).ToString() + "' is not present."); *result = false; LOG_DEBUG("Exit " + callString); return; } } } *result = true; LOG_DEBUG("Exit " + callString); return; } int ComputeArgumentsImplementation::GetNeighborList( int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) const { // No debug logging for callbacks: too expensive // // #if DEBUG_VERBOSITY // std::string const callString = "GetNeighborList(" // + SNUM(neighborListIndex) + ", " + SNUM(particleNumber) + ", " // + SPTR(numberOfNeighbors) + ", " + SPTR(neighborsOfParticle) + ")."; // #endif // LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((neighborListIndex < 0) || (neighborListIndex >= numberOfNeighborLists_)) { LOG_ERROR("Invalid neighborListIndex, " + SNUM(neighborListIndex) + "."); // LOG_DEBUG("Exit 1=" + callString); return true; } int zeroBasedParticleNumber = particleNumber + ((NUMBERING::zeroBased == modelNumbering_) ? 0 : -1); std::map::const_iterator pointerResult = computeArgumentPointer_.find(COMPUTE_ARGUMENT_NAME::numberOfParticles); int const * numberOfParticles = reinterpret_cast(pointerResult->second); if ((zeroBasedParticleNumber < 0) || (zeroBasedParticleNumber >= *(numberOfParticles))) { LOG_ERROR("Invalid particleNumber, " + SNUM(zeroBasedParticleNumber) + "."); // LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator languageResult = computeCallbackLanguage_.find(COMPUTE_CALLBACK_NAME::GetNeighborList); LanguageName const languageName = languageResult->second; void const * dataObject = (computeCallbackDataObjectPointer_.find( COMPUTE_CALLBACK_NAME::GetNeighborList)) ->second; Function * functionPointer = (computeCallbackFunctionPointer_.find( COMPUTE_CALLBACK_NAME::GetNeighborList)) ->second; GetNeighborListFunction * CppGetNeighborList = reinterpret_cast(functionPointer); KIM_GetNeighborListFunction * CGetNeighborList = reinterpret_cast(functionPointer); typedef void GetNeighborListF(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle, int * const ierr); GetNeighborListF * FGetNeighborList = reinterpret_cast(functionPointer); int simulatorParticleNumber = particleNumber + ((simulatorNumbering_ == modelNumbering_) ? 0 : -numberingOffset_); int const * simulatorNeighborsOfParticle; int error; if (languageName == LANGUAGE_NAME::cpp) { error = CppGetNeighborList(const_cast(dataObject), numberOfNeighborLists_, cutoffs_, neighborListIndex, simulatorParticleNumber, numberOfNeighbors, &simulatorNeighborsOfParticle); } else if (languageName == LANGUAGE_NAME::c) { error = CGetNeighborList(const_cast(dataObject), numberOfNeighborLists_, cutoffs_, neighborListIndex, simulatorParticleNumber, numberOfNeighbors, &simulatorNeighborsOfParticle); } else if (languageName == LANGUAGE_NAME::fortran) { FGetNeighborList(const_cast(dataObject), numberOfNeighborLists_, cutoffs_, neighborListIndex + 1, simulatorParticleNumber, numberOfNeighbors, &simulatorNeighborsOfParticle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); // LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Simulator supplied GetNeighborList() routine returned error."); // LOG_DEBUG("Exit 1=" + callString); return true; } // account for numbering differences if needed if (simulatorNumbering_ != modelNumbering_) { // LOG_DEBUG("Numbering conversion is required."); std::vector & list = getNeighborListStorage_[neighborListIndex]; list.resize(*numberOfNeighbors); for (int i = 0; i < *numberOfNeighbors; ++i) list[i] = simulatorNeighborsOfParticle[i] + numberingOffset_; *neighborsOfParticle = list.data(); } else { // LOG_DEBUG("Numbering conversion is not required."); *neighborsOfParticle = simulatorNeighborsOfParticle; } // LOG_DEBUG("Exit 0=" + callString); return false; } int ComputeArgumentsImplementation::ProcessDEDrTerm(double const de, double const r, double const * const dx, int const i, int const j) const { // No debug logging for callbacks: too expensive // // #if DEBUG_VERBOSITY // std::string const callString = "ProcessDEDrTerm(" // + SNUM(de) + ", " + SNUM(r) + ", " + SPTR(dx) + ", " // + SNUM(i) + ", " + SNUM(j) + ")."; // #endif // LOG_DEBUG("Enter " + callString); std::map::const_iterator languageResult = computeCallbackLanguage_.find(COMPUTE_CALLBACK_NAME::ProcessDEDrTerm); LanguageName languageName = languageResult->second; void const * dataObject = (computeCallbackDataObjectPointer_.find( COMPUTE_CALLBACK_NAME::ProcessDEDrTerm)) ->second; Function * functionPointer = (computeCallbackFunctionPointer_.find( COMPUTE_CALLBACK_NAME::ProcessDEDrTerm)) ->second; ProcessDEDrTermFunction * CppProcess_dEdr = reinterpret_cast(functionPointer); KIM_ProcessDEDrTermFunction * CProcess_dEdr = reinterpret_cast(functionPointer); typedef void ProcessDEDrTermF(void * const dataObject, double const de, double const r, double const(*const dx)[3], int const i, int const j, int * const ierr); ProcessDEDrTermF * FProcess_dEdr = reinterpret_cast(functionPointer); int offset = ((simulatorNumbering_ == modelNumbering_) ? 0 : -numberingOffset_); int simulatorI = i + offset; int simulatorJ = j + offset; int error; if (languageName == LANGUAGE_NAME::cpp) { error = CppProcess_dEdr( const_cast(dataObject), de, r, dx, simulatorI, simulatorJ); } else if (languageName == LANGUAGE_NAME::c) { error = CProcess_dEdr( const_cast(dataObject), de, r, dx, simulatorI, simulatorJ); } else if (languageName == LANGUAGE_NAME::fortran) { FProcess_dEdr(const_cast(dataObject), de, r, reinterpret_cast(dx), simulatorI, simulatorJ, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); // LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Simulator supplied ProcessDEDrTerm() routine returned error."); // LOG_DEBUG("Exit 1=" + callString); return true; } else { // LOG_DEBUG("Exit 0=" + callString); return false; } } int ComputeArgumentsImplementation::ProcessD2EDr2Term(double const de, double const * const r, double const * const dx, int const * const i, int const * const j) const { // No debug logging for callbacks: too expensive // // #if DEBUG_VERBOSITY // std::string const callString = "ProcessD2EDr2Term(" // + SNUM(de) + ", " + SPTR(r) + ", " + SPTR(dx) + ", " // + SPTR(i) + ", " + SPTR(j) + ")."; // #endif // LOG_DEBUG("Enter " + callString); std::map::const_iterator languageResult = computeCallbackLanguage_.find(COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term); LanguageName languageName = languageResult->second; void const * dataObject = (computeCallbackDataObjectPointer_.find( COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term)) ->second; Function * functionPointer = (computeCallbackFunctionPointer_.find( COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term)) ->second; ProcessD2EDr2TermFunction * CppProcess_d2Edr2 = reinterpret_cast(functionPointer); KIM_ProcessD2EDr2TermFunction * CProcess_d2Edr2 = reinterpret_cast(functionPointer); typedef void ProcessD2EDr2TermF(void * const dataObject, double const de, double const(*const r)[2], double const(*const dx)[2][3], int const(*const i)[2], int const(*const j)[2], int * const ierr); ProcessD2EDr2TermF * FProcess_d2Edr2 = reinterpret_cast(functionPointer); int offset = ((simulatorNumbering_ == modelNumbering_) ? 0 : -numberingOffset_); int simulatorI[2]; simulatorI[0] = i[0] + offset; simulatorI[1] = i[1] + offset; int simulatorJ[2]; simulatorJ[0] = j[0] + offset; simulatorJ[1] = j[1] + offset; int error; if (languageName == LANGUAGE_NAME::cpp) { error = CppProcess_d2Edr2( const_cast(dataObject), de, r, dx, simulatorI, simulatorJ); } else if (languageName == LANGUAGE_NAME::c) { error = CProcess_d2Edr2( const_cast(dataObject), de, r, dx, simulatorI, simulatorJ); } else if (languageName == LANGUAGE_NAME::fortran) { FProcess_d2Edr2(const_cast(dataObject), de, reinterpret_cast(r), reinterpret_cast(dx), &simulatorI, &simulatorJ, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); // LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Simulator supplied ProcessD2EDr2Term() routine returned error."); // LOG_DEBUG("Exit 1=" + callString); return true; } else { // LOG_DEBUG("Exit 0=" + callString); return false; } } void ComputeArgumentsImplementation::SetModelBufferPointer(void * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetModelBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); modelBuffer_ = ptr; LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::GetModelBufferPointer( void ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetModelBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); *ptr = modelBuffer_; LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::SetSimulatorBufferPointer(void * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetSimulatorBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); simulatorBuffer_ = ptr; LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::GetSimulatorBufferPointer( void ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); *ptr = simulatorBuffer_; LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::SetLogID(std::string const & logID) { #if DEBUG_VERBOSITY std::string const callString = "SetLogID('" + logID + "')."; #endif LOG_DEBUG("Enter " + callString); log_->SetID(logID); LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::PushLogVerbosity( LogVerbosity const logVerbosity) { #if DEBUG_VERBOSITY std::string const callString = "PushLogVerbosity(" + logVerbosity.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); log_->PushVerbosity(logVerbosity); LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::PopLogVerbosity() { #if DEBUG_VERBOSITY std::string const callString = "PopLogVerbosity()."; #endif LOG_DEBUG("Enter " + callString); log_->PopVerbosity(); LOG_DEBUG("Exit " + callString); } void ComputeArgumentsImplementation::LogEntry( LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } void ComputeArgumentsImplementation::LogEntry( LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ComputeArgumentsImplementation::ToString() const { #if DEBUG_VERBOSITY std::string const callString = "ToString()."; #endif LOG_DEBUG("Enter " + callString); std::stringstream ss; ss << std::setprecision(10) << std::scientific << std::left; ss << "=====================================================================" "===========\n\n"; ss << "ComputeArguments object\n" << "-----------------------\n\n"; ss << "Model Name : " << modelName_ << "\n"; ss << "Log ID : " << log_->GetID() << "\n"; ss << "\n"; ss << "Compute Arguments :\n"; int const argW = 25; ss << "\t" << std::setw(argW) << "Compute Argument Name" << std::setw(argW) << "SupportStatus" << std::setw(argW) << "Pointer" << "\n"; ss << "\t" << std::setw(argW) << "-------------------------" << std::setw(argW) << "-------------------------" << std::setw(argW) << "-------------------------" << "\n\n"; for (std::map::const_iterator argName = computeArgumentSupportStatus_.begin(); argName != computeArgumentSupportStatus_.end(); ++argName) { ss << "\t" << std::setw(argW) << (argName->first).ToString() << std::setw(argW) << (argName->second).ToString(); if ((argName->second) != SUPPORT_STATUS::notSupported) { std::map::const_iterator ptr = computeArgumentPointer_.find(argName->first); if (ptr != computeArgumentPointer_.end()) { ss << std::setw(argW) << SPTR(ptr->second); } else { ss << std::setw(argW) << "Not Set"; } } else { ss << std::setw(argW) << "N/A"; } ss << "\n"; } ss << "\n"; ss << "Compute Callback Functions :\n"; int const cbWn = 25; int const cbWs = 15; int const cbWl = 12; int const cbWd = 25; int const cbWf = 25; ss << "\t" << std::setw(cbWn) << "Compute Callback Name" << std::setw(cbWs) << "SupportStatus" << std::setw(cbWl) << "Language" << std::setw(cbWd) << "Data Pointer" << std::setw(cbWf) << "Pointer (1-set / 0-unset)" << "\n"; ss << "\t" << std::setw(cbWn) << "-------------------------" << std::setw(cbWs) << "---------------" << std::setw(cbWl) << "------------" << std::setw(cbWd) << "-------------------------" << std::setw(cbWf) << "-------------------------" << "\n\n"; for (std::map::const_iterator cbName = computeCallbackSupportStatus_.begin(); cbName != computeCallbackSupportStatus_.end(); ++cbName) { ss << "\t" << std::setw(cbWn) << (cbName->first).ToString() << std::setw(cbWs) << (cbName->second).ToString(); if ((cbName->second) != SUPPORT_STATUS::notSupported) { std::map::const_iterator ptr = computeCallbackLanguage_.find(cbName->first); if (ptr != computeCallbackLanguage_.end()) { ss << std::setw(cbWl) << (ptr->second).ToString(); std::map::const_iterator ptr2 = computeCallbackDataObjectPointer_.find(cbName->first); ss << std::setw(cbWd) << SPTR(ptr2->second); std::map::const_iterator ptr3 = computeCallbackFunctionPointer_.find(cbName->first); ss << std::setw(cbWf) << SFUNC(ptr3->second); } else { ss << std::setw(cbWl) << "Not Set"; } } else { ss << std::setw(cbWs) << "N/A"; } ss << "\n"; } ss << "\n"; ss << "Buffers\n"; ss << "\t" << std::setw(15) << "Buffer" << std::setw(15) << "Pointer" << "\n"; ss << "\t" << std::setw(15) << "---------------" << std::setw(15) << "---------------" << "\n\n"; ss << "\t" << std::setw(15) << "Model" << std::setw(15) << SPTR(modelBuffer_) << "\n" << "\t" << std::setw(15) << "Simulator" << std::setw(15) << SPTR(simulatorBuffer_) << "\n\n"; ss << "=====================================================================" "===========\n"; string_ = ss.str(); LOG_DEBUG("Exit " + callString); return string_; } ComputeArgumentsImplementation::ComputeArgumentsImplementation( std::string const & modelName, Numbering const modelNumbering, Numbering const simulatorNumbering, int const numberingOffset, Log * const log) : modelName_(modelName), log_(log), modelNumbering_(modelNumbering), simulatorNumbering_(simulatorNumbering), numberingOffset_(numberingOffset), inModelComputeRoutine_(false), numberOfNeighborLists_(0), cutoffs_(NULL), modelBuffer_(NULL), simulatorBuffer_(NULL) { #if DEBUG_VERBOSITY std::string const callString = "ComputeArgumentsImplementation(" + modelName + ", " + SPTR(log) + ")."; #endif LOG_DEBUG("Enter " + callString); // populate ComputeArguments int numberOfComputeArgumentNames; COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames( &numberOfComputeArgumentNames); for (int i = 0; i < numberOfComputeArgumentNames; ++i) { ComputeArgumentName computeArgumentName; COMPUTE_ARGUMENT_NAME::GetComputeArgumentName(i, &computeArgumentName); computeArgumentSupportStatus_[computeArgumentName] = SUPPORT_STATUS::notSupported; } // populate requiredByAPI ComputeArguments for (std::vector::const_iterator requiredByAPI_ComputeArgument = COMPUTE_ARGUMENT_NAME::requiredByAPI_ComputeArguments.begin(); requiredByAPI_ComputeArgument != COMPUTE_ARGUMENT_NAME::requiredByAPI_ComputeArguments.end(); ++requiredByAPI_ComputeArgument) { computeArgumentSupportStatus_[*requiredByAPI_ComputeArgument] = SUPPORT_STATUS::requiredByAPI; computeArgumentPointer_[*requiredByAPI_ComputeArgument] = NULL; } // populate ComputeCallbacks int numberOfComputeCallbackNames; COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames( &numberOfComputeCallbackNames); for (int i = 0; i < numberOfComputeCallbackNames; ++i) { ComputeCallbackName computeCallbackName; COMPUTE_CALLBACK_NAME::GetComputeCallbackName(i, &computeCallbackName); computeCallbackSupportStatus_[computeCallbackName] = SUPPORT_STATUS::notSupported; } // populate ComputeCallbacks for (std::vector::const_iterator requiredByAPI_ComputeCallback = COMPUTE_CALLBACK_NAME::requiredByAPI_ComputeCallbacks.begin(); requiredByAPI_ComputeCallback != COMPUTE_CALLBACK_NAME::requiredByAPI_ComputeCallbacks.end(); ++requiredByAPI_ComputeCallback) { computeCallbackSupportStatus_[*requiredByAPI_ComputeCallback] = SUPPORT_STATUS::requiredByAPI; computeCallbackLanguage_[*requiredByAPI_ComputeCallback] = LANGUAGE_NAME::cpp; // place holder computeCallbackFunctionPointer_[*requiredByAPI_ComputeCallback] = NULL; computeCallbackDataObjectPointer_[*requiredByAPI_ComputeCallback] = NULL; } LOG_DEBUG("Exit " + callString); } ComputeArgumentsImplementation::~ComputeArgumentsImplementation() { #if DEBUG_VERBOSITY std::string const callString = "~ComputeArgumentsImplementation()."; #endif LOG_DEBUG("Enter " + callString); LOG_DEBUG("Destroying Log object and exit " + callString); Log::Destroy(&log_); } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ComputeArgumentsImplementation.hpp000066400000000000000000000172501421473465500246360ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #define KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include #include #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif namespace KIM { // Forward declaration class Log; class ComputeArgumentsImplementation { public: friend class ModelImplementation; static int Create( std::string const & modelName, std::string const & modelLogID, Numbering const modelNumbering, Numbering const simulatorNumbering, int const numberingOffset, ComputeArgumentsImplementation ** const computeArgumentsImplementation); static void Destroy( ComputeArgumentsImplementation ** const computeArgumentsImplementation); int SetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus); int GetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus * const supportStatus) const; int SetCallbackSupportStatus(ComputeCallbackName const computeCallbackName, SupportStatus const supportStatus); int GetCallbackSupportStatus(ComputeCallbackName const computeCallbackName, SupportStatus * const supportStatus) const; int SetArgumentPointer(ComputeArgumentName const computeArgumentName, int const * const ptr); int SetArgumentPointer(ComputeArgumentName const computeArgumentName, int * const ptr); int SetArgumentPointer(ComputeArgumentName const computeArgumentName, double const * const ptr); int SetArgumentPointer(ComputeArgumentName const computeArgumentName, double * const ptr); int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int const ** const ptr) const; int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int ** const ptr) const; int GetArgumentPointer(ComputeArgumentName const computeArgumentName, double const ** const ptr) const; int GetArgumentPointer(ComputeArgumentName const computeArgumentName, double ** const ptr) const; int SetCallbackPointer(ComputeCallbackName const computeCallbackName, LanguageName const languageName, Function * const fptr, void * const dataObject); int IsCallbackPresent(ComputeCallbackName const computeCallbackName, int * const present) const; void AreAllRequiredArgumentsAndCallbacksPresent(int * const result) const; int GetNeighborList(int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) const; int ProcessDEDrTerm(double const de, double const r, double const * const dx, int const i, int const j) const; int ProcessD2EDr2Term(double const de, double const * const r, double const * const dx, int const * const i, int const * const j) const; void SetModelBufferPointer(void * const ptr); void GetModelBufferPointer(void ** const ptr) const; void SetSimulatorBufferPointer(void * const ptr); void GetSimulatorBufferPointer(void ** const ptr) const; std::string const & ToString() const; void SetLogID(std::string const & logID); void PushLogVerbosity(LogVerbosity const logVerbosity); void PopLogVerbosity(); void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; private: // do not allow copy constructor or operator= ComputeArgumentsImplementation(ComputeArgumentsImplementation const &); void operator=(ComputeArgumentsImplementation const &); ComputeArgumentsImplementation(std::string const & modelName, Numbering const modelNumbering, Numbering const simulatorNumbering, int const numberingOffset, Log * const log); ~ComputeArgumentsImplementation(); int Validate(ComputeArgumentName const computeArgumentName) const; int Validate(ComputeCallbackName const computeCallbackName) const; int Validate(LanguageName const languageName) const; int Validate(SupportStatus const supportStatus) const; std::string modelName_; Log * log_; Numbering const modelNumbering_; Numbering const simulatorNumbering_; int const numberingOffset_; mutable bool inModelComputeRoutine_; mutable int numberOfNeighborLists_; mutable double const * cutoffs_; std::map computeArgumentSupportStatus_; std::map computeArgumentPointer_; std::map computeCallbackSupportStatus_; std::map computeCallbackLanguage_; std::map computeCallbackFunctionPointer_; std::map computeCallbackDataObjectPointer_; mutable std::vector > getNeighborListStorage_; void * modelBuffer_; void * simulatorBuffer_; mutable std::string string_; }; // class ComputeArgumentsImplementation } // namespace KIM #endif // KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ kim-api-2.3.0-git/cpp/src/KIM_ComputeCallbackName.cpp000066400000000000000000000111341421473465500222460ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace COMPUTE_CALLBACK_NAME { #include "KIM_ComputeCallbackName.inc" ComputeCallbackName const GetNeighborList(ID_GetNeighborList); ComputeCallbackName const ProcessDEDrTerm(ID_ProcessDEDrTerm); ComputeCallbackName const ProcessD2EDr2Term(ID_ProcessD2EDr2Term); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[GetNeighborList] = "GetNeighborList"; m[ProcessDEDrTerm] = "ProcessDEDrTerm"; m[ProcessD2EDr2Term] = "ProcessD2EDr2Term"; return m; } StringMap const computeCallbackNameToString = GetStringMap(); std::string const computeCallbackNameUnknown("unknown"); } // namespace namespace { typedef std::vector ComputeCallbackVector; ComputeCallbackVector const GetComputeCallbackVector() { ComputeCallbackVector v; v.push_back(GetNeighborList); return v; } } // namespace // Used by KIM::ModelImplementation extern ComputeCallbackVector const requiredByAPI_ComputeCallbacks = GetComputeCallbackVector(); void GetNumberOfComputeCallbackNames(int * const numberOfComputeCallbackNames) { *numberOfComputeCallbackNames = computeCallbackNameToString.size(); } int GetComputeCallbackName(int const index, ComputeCallbackName * const computeCallbackName) { int numberOfComputeCallbackNames; GetNumberOfComputeCallbackNames(&numberOfComputeCallbackNames); if ((index < 0) || (index >= numberOfComputeCallbackNames)) return true; StringMap::const_iterator iter = computeCallbackNameToString.begin(); for (int i = 0; i < index; ++i) ++iter; *computeCallbackName = iter->first; return false; // no error } } // namespace COMPUTE_CALLBACK_NAME // implementation of ComputeCallbackName ComputeCallbackName::ComputeCallbackName() {} ComputeCallbackName::ComputeCallbackName(int const id) : computeCallbackNameID(id) { } ComputeCallbackName::ComputeCallbackName(std::string const & str) { computeCallbackNameID = -1; for (COMPUTE_CALLBACK_NAME::StringMap::const_iterator iter = COMPUTE_CALLBACK_NAME::computeCallbackNameToString.begin(); iter != COMPUTE_CALLBACK_NAME::computeCallbackNameToString.end(); ++iter) { if (iter->second == str) { computeCallbackNameID = (iter->first).computeCallbackNameID; break; } } } bool ComputeCallbackName::Known() const { int numberOfComputeCallbackNames; COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames( &numberOfComputeCallbackNames); for (int i = 0; i < numberOfComputeCallbackNames; ++i) { ComputeCallbackName ccn; COMPUTE_CALLBACK_NAME::GetComputeCallbackName(i, &ccn); if (*this == ccn) { return true; } } return false; } bool ComputeCallbackName::operator==(ComputeCallbackName const & rhs) const { return computeCallbackNameID == rhs.computeCallbackNameID; } bool ComputeCallbackName::operator!=(ComputeCallbackName const & rhs) const { return computeCallbackNameID != rhs.computeCallbackNameID; } std::string const & ComputeCallbackName::ToString() const { COMPUTE_CALLBACK_NAME::StringMap::const_iterator iter = COMPUTE_CALLBACK_NAME::computeCallbackNameToString.find(*this); if (iter == COMPUTE_CALLBACK_NAME::computeCallbackNameToString.end()) return COMPUTE_CALLBACK_NAME::computeCallbackNameUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ComputeCallbackName.inc000066400000000000000000000045431421473465500222430ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_COMPUTE_CALLBACK_NAME_INC_ #define KIM_COMPUTE_CALLBACK_NAME_INC_ #define ID_GetNeighborList 0 #define ID_ProcessDEDrTerm 1 #define ID_ProcessD2EDr2Term 2 #endif /* KIM_COMPUTE_CALLBACK_NAME_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_Configuration.hpp.in000066400000000000000000000056721421473465500216470ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_CONFIGURATION_HPP_ #define KIM_CONFIGURATION_HPP_ #define KIM_PROJECT_NAME "@PROJECT_NAME@" #define KIM_UID "@KIM_API_UID@" #define KIM_SHARED_LIBRARY_PREFIX "@CMAKE_SHARED_LIBRARY_PREFIX@" #define KIM_SHARED_LIBRARY_SUFFIX "@CMAKE_SHARED_LIBRARY_SUFFIX@" #define KIM_SHARED_MODULE_PREFIX "@CMAKE_SHARED_MODULE_PREFIX@" #define KIM_SHARED_MODULE_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@" #define KIM_USER_CONFIGURATION_FILE "@KIM_API_USER_CONFIGURATION_FILE@" #define KIM_ENVIRONMENT_CONFIGURATION_FILE \ "@KIM_API_ENVIRONMENT_CONFIGURATION_FILE@" #define KIM_USER_MODEL_DRIVERS_DIR_DEFAULT \ "@KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT@" #define KIM_MODEL_DRIVER_IDENTIFIER "@KIM_API_MODEL_DRIVER_IDENTIFIER@" #define KIM_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER \ "@KIM_API_MODEL_DRIVER_PLURAL_DIR_IDENTIFIER@" #define KIM_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR \ "@KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR@" #define KIM_SYSTEM_MODEL_DRIVERS_DIR "@KIM_API_SYSTEM_MODEL_DRIVERS_DIR@" #define KIM_USER_PORTABLE_MODELS_DIR_DEFAULT \ "@KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT@" #define KIM_PORTABLE_MODEL_IDENTIFIER "@KIM_API_PORTABLE_MODEL_IDENTIFIER@" #define KIM_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER \ "@KIM_API_PORTABLE_MODEL_PLURAL_DIR_IDENTIFIER@" #define KIM_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR \ "@KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR@" #define KIM_SYSTEM_PORTABLE_MODELS_DIR "@KIM_API_SYSTEM_PORTABLE_MODELS_DIR@" #define KIM_USER_SIMULATOR_MODELS_DIR_DEFAULT \ "@KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT@" #define KIM_SIMULATOR_MODEL_IDENTIFIER "@KIM_API_SIMULATOR_MODEL_IDENTIFIER@" #define KIM_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER \ "@KIM_API_SIMULATOR_MODEL_PLURAL_DIR_IDENTIFIER@" #define KIM_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR \ "@KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR@" #define KIM_SYSTEM_SIMULATOR_MODELS_DIR "@KIM_API_SYSTEM_SIMULATOR_MODELS_DIR@" #endif // KIM_CONFIGURATION_HPP_ kim-api-2.3.0-git/cpp/src/KIM_DataType.cpp000066400000000000000000000064151421473465500201350ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace DATA_TYPE { #include "KIM_DataType.inc" DataType const Integer(ID_Integer); DataType const Double(ID_Double); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[Integer] = "Integer"; m[Double] = "Double"; return m; } StringMap const dataTypeToString = GetStringMap(); std::string const dataTypeUnknown("unknown"); } // namespace void GetNumberOfDataTypes(int * const numberOfDataTypes) { *numberOfDataTypes = dataTypeToString.size(); } int GetDataType(int const index, DataType * const dataType) { int numberOfDataTypes; GetNumberOfDataTypes(&numberOfDataTypes); if ((index < 0) || (index >= numberOfDataTypes)) return true; StringMap::const_iterator iter = dataTypeToString.begin(); for (int i = 0; i < index; ++i) ++iter; *dataType = iter->first; return false; // no error } } // namespace DATA_TYPE // implementation of DataType DataType::DataType() {} DataType::DataType(int const id) : dataTypeID(id) {} DataType::DataType(std::string const & str) { dataTypeID = -1; for (DATA_TYPE::StringMap::const_iterator iter = DATA_TYPE::dataTypeToString.begin(); iter != DATA_TYPE::dataTypeToString.end(); ++iter) { if (iter->second == str) { dataTypeID = (iter->first).dataTypeID; break; } } } bool DataType::Known() const { int numberOfDataTypes; DATA_TYPE::GetNumberOfDataTypes(&numberOfDataTypes); for (int i = 0; i < numberOfDataTypes; ++i) { DataType dType; DATA_TYPE::GetDataType(i, &dType); if (*this == dType) { return true; } } return false; } bool DataType::operator==(DataType const & rhs) const { return dataTypeID == rhs.dataTypeID; } bool DataType::operator!=(DataType const & rhs) const { return dataTypeID != rhs.dataTypeID; } std::string const & DataType::ToString() const { DATA_TYPE::StringMap::const_iterator iter = DATA_TYPE::dataTypeToString.find(*this); if (iter == DATA_TYPE::dataTypeToString.end()) return DATA_TYPE::dataTypeUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_DataType.inc000066400000000000000000000044171421473465500201240ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_DATA_TYPE_INC_ #define KIM_DATA_TYPE_INC_ #define ID_Integer 0 #define ID_Double 1 #endif /* KIM_DATA_TYPE_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_EnergyUnit.cpp000066400000000000000000000072731421473465500205160ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_ENERGY_UNIT_HPP_ #include "KIM_EnergyUnit.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace ENERGY_UNIT { #include "KIM_EnergyUnit.inc" EnergyUnit const unused(ID_unused); EnergyUnit const amu_A2_per_ps2(ID_amu_A2_per_ps2); EnergyUnit const erg(ID_erg); EnergyUnit const eV(ID_eV); EnergyUnit const Hartree(ID_Hartree); EnergyUnit const J(ID_J); EnergyUnit const kcal_mol(ID_kcal_mol); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[unused] = "unused"; m[amu_A2_per_ps2] = "amu_A2_per_ps2"; m[erg] = "erg"; m[eV] = "eV"; m[Hartree] = "Hartree"; m[J] = "J"; m[kcal_mol] = "kcal_mol"; return m; } StringMap const energyUnitToString = GetStringMap(); std::string const energyUnitUnknown("unknown"); } // namespace void GetNumberOfEnergyUnits(int * const numberOfEnergyUnits) { *numberOfEnergyUnits = energyUnitToString.size(); } int GetEnergyUnit(int const index, EnergyUnit * const energyUnit) { int numberOfEnergyUnits; GetNumberOfEnergyUnits(&numberOfEnergyUnits); if ((index < 0) || (index >= numberOfEnergyUnits)) return true; StringMap::const_iterator iter = energyUnitToString.begin(); int i = 0; for (; i < index; ++i) ++iter; *energyUnit = iter->first; return false; // no error } } // namespace ENERGY_UNIT // implementation of EnergyUnit EnergyUnit::EnergyUnit() {} EnergyUnit::EnergyUnit(int const id) : energyUnitID(id) {} EnergyUnit::EnergyUnit(std::string const & str) { energyUnitID = -1; for (ENERGY_UNIT::StringMap::const_iterator iter = ENERGY_UNIT::energyUnitToString.begin(); iter != ENERGY_UNIT::energyUnitToString.end(); ++iter) { if (iter->second == str) { energyUnitID = (iter->first).energyUnitID; break; } } } bool EnergyUnit::Known() const { int numberOfEnergyUnits; ENERGY_UNIT::GetNumberOfEnergyUnits(&numberOfEnergyUnits); for (int i = 0; i < numberOfEnergyUnits; ++i) { EnergyUnit eUnit; ENERGY_UNIT::GetEnergyUnit(i, &eUnit); if (*this == eUnit) { return true; } } return false; } bool EnergyUnit::operator==(EnergyUnit const & rhs) const { return energyUnitID == rhs.energyUnitID; } bool EnergyUnit::operator!=(EnergyUnit const & rhs) const { return energyUnitID != rhs.energyUnitID; } std::string const & EnergyUnit::ToString() const { ENERGY_UNIT::StringMap::const_iterator iter = ENERGY_UNIT::energyUnitToString.find(*this); if (iter == ENERGY_UNIT::energyUnitToString.end()) return ENERGY_UNIT::energyUnitUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_EnergyUnit.inc000066400000000000000000000045671421473465500205100ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_ENERGY_UNIT_INC_ #define KIM_ENERGY_UNIT_INC_ #define ID_unused 0 #define ID_amu_A2_per_ps2 1 #define ID_erg 2 #define ID_eV 3 #define ID_Hartree 4 #define ID_J 5 #define ID_kcal_mol 6 #endif /* KIM_ENERGY_UNIT_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_FilesystemPath.cpp000066400000000000000000000251321421473465500213600ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #include // IWYU pragma: keep // For MinGW/Linux #ifndef KIM_FILESYSTEM_PATH_HPP_ #include "KIM_FilesystemPath.hpp" #endif #ifdef KIM_API_USE_FILESYSTEM_LIBRARY #include #else #include #include #include #include #include #include #include #include // IWYU pragma: keep // For macOS #endif namespace KIM { namespace FILESYSTEM { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY const std::string::value_type Path::preferred_separator = ';'; #else const std::string::value_type Path::preferred_separator = ':'; #endif bool Path::MakeDirectory() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY std::error_code ec; std::filesystem::create_directories(path_, ec); if (ec) { std::cerr << "Failed to create directory " << *this << ": " << ec.message() << std::endl; return true; } return false; #else const size_t len = strlen(path_.c_str()); char _path[PATH_MAX]; char * p; errno = 0; /* Copy string so its mutable */ if (len > sizeof(_path) - 1) { errno = ENAMETOOLONG; goto errorLabel; } strcpy(_path, path_.c_str()); /* Iterate the string */ for (p = _path + 1; *p; p++) { if (*p == '/') { /* Temporarily truncate */ *p = '\0'; if (mkdir(_path, S_IRWXU) != 0) { if (errno != EEXIST) { *p = '/'; goto errorLabel; } } *p = '/'; } } if (mkdir(_path, S_IRWXU) != 0) { if (errno != EEXIST) goto errorLabel; } return false; errorLabel: std::cerr << "Failed to create directory '" << path_ << "'." << std::endl; return true; #endif } bool Path::RemoveDirectoryRecursive() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY std::error_code ec; std::filesystem::remove_all(path_, ec); if (ec) { std::cerr << "Failed to remove directory " << *this << ": " << ec.message() << std::endl; return true; } return false; #else int error = false; struct dirent * dp = NULL; DIR * dir = NULL; dir = opendir(path_.c_str()); while ((dp = readdir(dir))) { // assuming no subdirectories, just files if ((0 != strcmp(dp->d_name, ".")) && (0 != strcmp(dp->d_name, ".."))) { Path filePath = *this / dp->d_name; error = error || remove(filePath.path_.c_str()); } } closedir(dir); error = error || remove(path_.c_str()); if (error) { return true; } return false; #endif } std::vector Path::Subdirectories() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY std::vector resultList; std::error_code ec; if (std::filesystem::is_directory(path_, ec)) { for (auto & p : std::filesystem::directory_iterator(path_)) resultList.push_back(Path(p.path())); } return resultList; #else std::vector resultList; DIR * dirp = NULL; struct dirent * dp = NULL; if (NULL != (dirp = opendir(path_.c_str()))) { do { struct stat statBuf; if ((NULL != (dp = readdir(dirp))) && (0 != strcmp(dp->d_name, ".")) && (0 != strcmp(dp->d_name, ".."))) { Path fullPath = *this / dp->d_name; if ((0 == stat(fullPath.path_.c_str(), &statBuf)) && (S_ISDIR(statBuf.st_mode))) { resultList.push_back(fullPath); } } } while (NULL != dp); closedir(dirp); } return resultList; #endif } Path Path::CreateTemporaryDirectory(char const * const namePrefix) { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY // Get the root directory for temporary files. Path temp_dir = std::filesystem::temp_directory_path(); // Keep generating random subdirectory names until we find one that does not // exists yet. std::default_random_engine rnd; Path temp_subdir; do { int random_number = std::uniform_int_distribution(0)(rnd); std::string subdir_name = namePrefix + std::to_string(random_number); temp_subdir = temp_dir / subdir_name; } while (temp_subdir.exists()); // Create the subdirectory. if (temp_subdir.MakeDirectory()) { return Path(); } return temp_subdir; #else std::stringstream templateString; templateString << P_tmpdir << ((*(--(std::string(P_tmpdir).end())) == '/') ? "" : "/") << namePrefix << "XXXXXXXXXXXX"; char * cstr = strdup(templateString.str().c_str()); char * tmpdir = mkdtemp(cstr); if (NULL == tmpdir) { free(cstr); return Path(); } Path result(tmpdir); free(cstr); return result; #endif } bool Path::exists() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return std::filesystem::exists(path_); #else struct stat statBuf; if (0 == stat(path_.c_str(), &statBuf)) return true; return false; #endif } Path Path::current_path() { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return Path(std::filesystem::current_path()); #else return Path(getenv("PWD")); #endif } Path Path::HomePath() { #if defined(KIM_API_USE_FILESYSTEM_LIBRARY) && defined(_WIN32) // Detects the user's home directory on Win32. // Prefer environment variables %HOMEDRIVE% / %HOMEPATH%. if (wchar_t * envHomeDrive = _wgetenv(L"HOMEDRIVE")) { if (wchar_t * envHomePath = _wgetenv(L"HOMEPATH")) { std::filesystem::path homeDrive = envHomeDrive; std::filesystem::path homePath = envHomePath; return Path(homeDrive / homePath); } } // Fall back to environment variable %USERPROFILE%: if (wchar_t * envUserProfile = _wgetenv(L"USERPROFILE")) { std::filesystem::path profilePath = envUserProfile; return Path(profilePath); } // Fall back to environment variable %HOME%: if (wchar_t * envHome = _wgetenv(L"HOME")) { std::filesystem::path homePath = envHome; return Path(homePath); } return Path(); #else return Path(getenv("HOME")); #endif } Path & Path::remove_filename() { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY path_.remove_filename(); #else size_t loc = path_.find_last_of('/'); if (loc != std::string::npos) path_ = path_.substr(0, loc + 1); else path_ = std::string(""); #endif return *this; } bool Path::is_relative() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return path_.is_relative(); #else return path_.empty() || path_[0] != '/'; #endif } Path & Path::operator+=(char const * const s) { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY path_ += std::string(s); #else path_ += s; #endif return *this; } Path & Path::concat(const std::string & p) { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY path_.concat(p); #else path_.append(p); #endif return *this; } std::string Path::string() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return path_.string(); #else return path_; #endif } Path & Path::make_preferred() { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY path_.make_preferred(); #else // No-op, because '/' is the only directory separator on non-Windows // platforms. #endif return *this; } Path Path::parent_path() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return Path(path_.parent_path()); #else Path parent(*this); parent.remove_filename(); if (!parent.empty()) parent.path_ = std::string(parent.path_.begin(), --(parent.path_.end())); return parent; #endif } Path Path::filename() const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return Path(path_.filename()); #else std::string::size_type pos = path_.rfind('/'); if (pos == std::string::npos) return *this; return Path(path_.substr(pos + 1)); #endif } Path & Path::operator/=(const Path & p) { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY path_ /= p.path_; #else if (p.empty()) { if (!filename().empty()) { *this += "/"; } return *this; } if (!p.is_relative()) { path_ = p.path_; } else { if (path_[path_.size() - 1] != '/') path_ += '/'; if (p.path_.size() >= 2 && p.path_[0] == '.' && p.path_[1] == '/') path_.append(p.path_.substr(2)); else path_.append(p.path_); } #endif return *this; } Path Path::operator/(const Path & p) const { #ifdef KIM_API_USE_FILESYSTEM_LIBRARY return path_ / p.path_; #else Path result(*this); result /= p; return result; #endif } const std::string::value_type PathList::PreferredSeparator = Path::preferred_separator; const std::string::value_type PathList::HomeDirectoryShortcut = '~'; // Creates all directories in the path list, including parent directories if // necessary. It's not an error if a directory to be created already exists. // Returns true on error. bool PathList::MakeDirectories() const { for (const_iterator path = begin(); path != end(); ++path) { if (path->MakeDirectory()) return true; } return false; } // Converts the path list into a colon- or semicolon-separated string list. std::string PathList::ToString() const { std::string result; for (const_iterator path = begin(); path != end(); ++path) { if (path != begin()) result += PreferredSeparator; result += path->string(); } return result; } // Parses a list of filesystem paths separated by colons (or semi-colons on // Windows). // '~' at the beginning of a path is replaced with the user's home directory. size_t PathList::Parse(std::string::value_type const * const paths) { clear(); if (!paths) return 0; // Split (semi)colon-separated path list: std::basic_istringstream iss(paths); std::string token; while (std::getline(iss, token, PreferredSeparator)) { // Resolve references to home directory (~). if (token[0] == HomeDirectoryShortcut) { push_back(Path::HomePath().concat(token.substr(1))); } else { push_back(token); } back().make_preferred(); } return size(); } } // namespace FILESYSTEM } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_FilesystemPath.hpp000066400000000000000000000153251421473465500213700ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_FILESYSTEM_PATH_HPP_ #define KIM_FILESYSTEM_PATH_HPP_ #include #include #include // If available, use the std::filesystem::path class // for cross-platform file path handling introduced with C++17. // Older versions of the GCC compiler support C++17 but do not include an // implementation of the std::filesystem library. Then fall back to the GHC // drop-in replacement library. In all other cases, in particular in C++98 mode, // fall back to a minimal implementation based on std::string. #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) // C++17 mode: #if __has_include() // Have std::filesystem implementation: #include #else // Fall back to drop-in library: #define GHC_WIN_WSTRING_STRING_TYPE #include "ghc-filesystem/filesystem.hpp" // We need the alias from ghc::filesystem to std::filesystem namespace std { namespace filesystem = ghc::filesystem; } #endif #define KIM_API_USE_FILESYSTEM_LIBRARY 1 #endif #ifdef KIM_API_USE_FILESYSTEM_LIBRARY namespace { typedef std::filesystem::path KIM_Path; } #else #include namespace { typedef std::string KIM_Path; } #endif namespace KIM { namespace FILESYSTEM { class Path { public: // Platform-dependent character for separating path entries. static const std::string::value_type preferred_separator; Path() {} Path(const char * str) { if (str != NULL) path_ = str; } Path(const std::string & str) : path_(str) {} #ifdef KIM_API_USE_FILESYSTEM_LIBRARY Path(const std::filesystem::path & p) : path_(p) {} Path(std::filesystem::path && p) : path_(std::move(p)) {} #endif Path & operator=(const std::string & other) { path_ = other; return *this; } Path & operator=(const char * other) { path_ = other; return *this; } Path & operator+=(char const * const s); Path & operator/=(const Path & p); Path operator/(const Path & p) const; friend bool operator<(const Path & lhs, const Path & rhs) { return lhs.path_ < rhs.path_; } friend bool operator==(const Path & lhs, const Path & rhs) { return lhs.path_ == rhs.path_; } friend bool operator!=(const Path & lhs, const Path & rhs) { return !(lhs == rhs); } // Concatenates the current path and the argument. Path & concat(const std::string & p); // Turns the path object into a conventional string, which can be passed to // I/O functions. std::string string() const; // Returns the native string representation of the path, using native syntax, // native character type, and native character encoding. This string is // suitable for use with OS APIs. const KIM_Path::value_type * c_str() const { return path_.c_str(); } // Resets the path to an empty string. void clear() { path_.clear(); } // Returns whether this path is the empty string. bool empty() const { return path_.empty(); } // Returns the path of the parent path Path parent_path() const; // Returns the last component of the path. Path filename() const; // Removes a single filename component from the path. Path & remove_filename(); // Converts all directory separators to the preferred directory separator of // the current platform. Path & make_preferred(); // Creates a new directory, including parent directories if necessary. // It's not an error if the directory to be created already exists. // Returns true on error. bool MakeDirectory() const; // Deletes the contents of this path (if it is a directory) and the contents // of all its subdirectories, recursively, then deletes the file path itself. // Returns true on error. bool RemoveDirectoryRecursive() const; // Returns the list of subdirectories of this directory. std::vector Subdirectories() const; // Checks whether the file or directory exists. bool exists() const; // Checks whether the path is relative. bool is_relative() const; // Returns the current working directory. static Path current_path(); // Returns the user's home directory. static Path HomePath(); // Creates a new empty directory that can be used to write temporary files // into. Returns an empty path on failure. static Path CreateTemporaryDirectory(char const * const namePrefix); // Performs stream output on the path (operator <<). template friend std::basic_ostream & operator<<(std::basic_ostream & os, const Path & p) { return os << p.path_; } private: // The internal path storage: KIM_Path path_; }; class PathList : public std::vector { public: // Platform-dependent character for separating paths in the lists. static const std::string::value_type PreferredSeparator; // Platform-dependent character for home directory. static const std::string::value_type HomeDirectoryShortcut; // Creates all directories in the path list, including parent directories if // necessary. It's not an error if a directory to be created already exists. // Returns true on error. bool MakeDirectories() const; // Converts the path list into a colon- or semicolon-separated string list. std::string ToString() const; // Parses a list of filesystem paths separated by colons (or semi-colons on // Windows). // '~' at the beginning of a path is replaced with the user's home directory. size_t Parse(std::string::value_type const * const paths); // Performs stream output on the path (operator <<). template friend std::basic_ostream & operator<<(std::basic_ostream & os, const PathList & p) { return os << p.ToString(); } }; } // namespace FILESYSTEM } // namespace KIM #endif // KIM_FILESYSTEM_PATH_HPP_ kim-api-2.3.0-git/cpp/src/KIM_LanguageName.cpp000066400000000000000000000070741421473465500207500ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace LANGUAGE_NAME { #include "KIM_LanguageName.inc" LanguageName const cpp(ID_cpp); LanguageName const c(ID_c); LanguageName const fortran(ID_fortran); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[cpp] = "cpp"; m[c] = "c"; m[fortran] = "fortran"; return m; } StringMap const languageNameToString = GetStringMap(); std::string const languageNameUnknown("unknown"); } // namespace void GetNumberOfLanguageNames(int * const numberOfLanguageNames) { *numberOfLanguageNames = languageNameToString.size(); } int GetLanguageName(int const index, LanguageName * const languageName) { int numberOfLanguageNames; GetNumberOfLanguageNames(&numberOfLanguageNames); if ((index < 0) || (index >= numberOfLanguageNames)) return true; StringMap::const_iterator iter = languageNameToString.begin(); for (int i = 0; i < index; ++i) ++iter; *languageName = iter->first; return false; // no error } } // namespace LANGUAGE_NAME // implementation of LanguageName LanguageName::LanguageName() {} LanguageName::LanguageName(int const id) : languageNameID(id) {} LanguageName::LanguageName(std::string const & str) { languageNameID = -1; for (LANGUAGE_NAME::StringMap::const_iterator iter = LANGUAGE_NAME::languageNameToString.begin(); iter != LANGUAGE_NAME::languageNameToString.end(); ++iter) { if (iter->second == str) { languageNameID = (iter->first).languageNameID; break; } } } bool LanguageName::Known() const { int numberOfLanguageNames; LANGUAGE_NAME::GetNumberOfLanguageNames(&numberOfLanguageNames); for (int i = 0; i < numberOfLanguageNames; ++i) { LanguageName langName; LANGUAGE_NAME::GetLanguageName(i, &langName); if (*this == langName) { return true; } } return false; } bool LanguageName::operator==(LanguageName const & rhs) const { return languageNameID == rhs.languageNameID; } bool LanguageName::operator!=(LanguageName const & rhs) const { return languageNameID != rhs.languageNameID; } std::string const & LanguageName::ToString() const { LANGUAGE_NAME::StringMap::const_iterator iter = LANGUAGE_NAME::languageNameToString.find(*this); if (iter == LANGUAGE_NAME::languageNameToString.end()) return LANGUAGE_NAME::languageNameUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_LanguageName.inc000066400000000000000000000044471421473465500207400ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_LANGUAGE_NAME_INC_ #define KIM_LANGUAGE_NAME_INC_ #define ID_cpp 0 #define ID_c 1 #define ID_fortran 2 #endif /* KIM_LANGUAGE_NAME_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_LengthUnit.cpp000066400000000000000000000070751421473465500205060ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LENGTH_UNIT_HPP_ #include "KIM_LengthUnit.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace LENGTH_UNIT { #include "KIM_LengthUnit.inc" LengthUnit const unused(ID_unused); LengthUnit const A(ID_A); LengthUnit const Bohr(ID_Bohr); LengthUnit const cm(ID_cm); LengthUnit const m(ID_m); LengthUnit const nm(ID_nm); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap mm; mm[unused] = "unused"; mm[A] = "A"; mm[Bohr] = "Bohr"; mm[cm] = "cm"; mm[m] = "m"; mm[nm] = "nm"; return mm; } StringMap const lengthUnitToString = GetStringMap(); std::string const lengthUnitUnknown("unknown"); } // namespace void GetNumberOfLengthUnits(int * const numberOfLengthUnits) { *numberOfLengthUnits = lengthUnitToString.size(); } int GetLengthUnit(int const index, LengthUnit * const lengthUnit) { int numberOfLengthUnits; GetNumberOfLengthUnits(&numberOfLengthUnits); if ((index < 0) || (index >= numberOfLengthUnits)) return true; StringMap::const_iterator iter = lengthUnitToString.begin(); for (int i = 0; i < index; ++i) ++iter; *lengthUnit = iter->first; return false; // no error } } // namespace LENGTH_UNIT // implementation of LengthUnit LengthUnit::LengthUnit() {} LengthUnit::LengthUnit(int const id) : lengthUnitID(id) {} LengthUnit::LengthUnit(std::string const & str) { lengthUnitID = -1; for (LENGTH_UNIT::StringMap::const_iterator iter = LENGTH_UNIT::lengthUnitToString.begin(); iter != LENGTH_UNIT::lengthUnitToString.end(); ++iter) { if (iter->second == str) { lengthUnitID = (iter->first).lengthUnitID; break; } } } bool LengthUnit::Known() const { int numberOfLengthUnits; LENGTH_UNIT::GetNumberOfLengthUnits(&numberOfLengthUnits); for (int i = 0; i < numberOfLengthUnits; ++i) { LengthUnit lenUnit; LENGTH_UNIT::GetLengthUnit(i, &lenUnit); if (*this == lenUnit) { return true; } } return false; } bool LengthUnit::operator==(LengthUnit const & rhs) const { return lengthUnitID == rhs.lengthUnitID; } bool LengthUnit::operator!=(LengthUnit const & rhs) const { return lengthUnitID != rhs.lengthUnitID; } std::string const & LengthUnit::ToString() const { LENGTH_UNIT::StringMap::const_iterator iter = LENGTH_UNIT::lengthUnitToString.find(*this); if (iter == LENGTH_UNIT::lengthUnitToString.end()) return LENGTH_UNIT::lengthUnitUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_LengthUnit.inc000066400000000000000000000045201421473465500204650ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_LENGTH_UNIT_INC_ #define KIM_LENGTH_UNIT_INC_ #define ID_unused 0 #define ID_A 1 #define ID_Bohr 2 #define ID_cm 3 #define ID_m 4 #define ID_nm 5 #endif /* KIM_LENGTH_UNIT_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_Log.cpp000066400000000000000000000056621421473465500171460ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_LOG_IMPLEMENTATION_HPP_ #include "KIM_LogImplementation.hpp" #endif namespace KIM { int Log::Create(Log ** const log) { *log = new Log(); return LogImplementation::Create(&((*log)->pimpl)); } void Log::Destroy(Log ** const log) { if (*log != NULL) { LogImplementation::Destroy(&((*log)->pimpl)); } delete *log; *log = NULL; } void Log::PushDefaultVerbosity(LogVerbosity const logVerbosity) { LogImplementation::PushDefaultVerbosity(logVerbosity); } void Log::PopDefaultVerbosity() { LogImplementation::PopDefaultVerbosity(); } void Log::PushDefaultPrintFunction(LanguageName const languageName, Function * const fptr) { LogImplementation::PushDefaultPrintFunction(languageName, fptr); } void Log::PopDefaultPrintFunction() { LogImplementation::PopDefaultPrintFunction(); } std::string const & Log::GetID() const { return pimpl->GetID(); } void Log::SetID(std::string const & id) { pimpl->SetID(id); } void Log::PushVerbosity(LogVerbosity const logVerbosity) { pimpl->PushVerbosity(logVerbosity); } void Log::PopVerbosity() { pimpl->PopVerbosity(); } void Log::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { pimpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void Log::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { pimpl->LogEntry(logVerbosity, message.str(), lineNumber, fileName); } Log::Log() : pimpl(NULL) {} Log::~Log() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_LogImplementation.cpp000066400000000000000000000253641421473465500220550ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #include #include #include #include #include #include #ifndef KIM_LOG_IMPLEMENTATION_HPP_ #include "KIM_LogImplementation.hpp" #endif #ifndef KIM_FUNCTION_TYPES_H_ extern "C" { #include "KIM_FunctionTypes.h" } // extern "C" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #include "KIM_LOG_DEFINES.inc" #define LOG_FILE "kim.log" // log helper #define SPTR(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() namespace KIM { namespace { std::stack GetDefaultVerbosityStack() { std::stack s; s.push(KIM_LOG_MAXIMUM_LEVEL); return s; } std::stack defaultLogVerbosity = GetDefaultVerbosityStack(); int Validate(LogVerbosity const logVerbosity) { int numberOfLogVerbosities; LOG_VERBOSITY::GetNumberOfLogVerbosities(&numberOfLogVerbosities); for (int i = 0; i < numberOfLogVerbosities; ++i) { LogVerbosity logVerb; LOG_VERBOSITY::GetLogVerbosity(i, &logVerb); if (logVerbosity == logVerb) { return true; } } return false; } } // namespace int LogImplementation::Create(LogImplementation ** const logImplementation) { *logImplementation = new LogImplementation(); std::stringstream ss; ss << "Log object created. Default verbosity level is '" << defaultLogVerbosity.top().ToString() << "'."; (*logImplementation) ->LogEntry(LOG_VERBOSITY::information, ss.str(), __LINE__, __FILE__); return false; } void LogImplementation::Destroy(LogImplementation ** const logImplementation) { if (*logImplementation != NULL) { (*logImplementation) ->LogEntry(LOG_VERBOSITY::information, "Log object destroyed.", __LINE__, __FILE__); } delete (*logImplementation); *logImplementation = NULL; } void LogImplementation::PushDefaultVerbosity(LogVerbosity const logVerbosity) { LogVerbosity logVerb(logVerbosity); if (!Validate(logVerbosity)) logVerb = defaultLogVerbosity.top(); defaultLogVerbosity.push(logVerb); } void LogImplementation::PopDefaultVerbosity() { defaultLogVerbosity.pop(); if (defaultLogVerbosity.empty()) { defaultLogVerbosity.push(KIM_LOG_MAXIMUM_LEVEL); } } namespace { int GlobalDefaultLogPrintFunction(std::string const & entryString) { // Need to figure out how to do file locking to make this work for // parallel computations. std::ofstream file; file.open(LOG_FILE, std::ios_base::out | std::ios_base::app); if (!file) { std::cerr << "Unable to open " LOG_FILE " file." << std::endl; return true; } else { file << entryString; return false; } } std::stack GetDefaultLogPrintFunctionLanguageNameStack() { std::stack s; s.push(LANGUAGE_NAME::cpp); return s; } std::stack defaultLogPrintFunctionLanguageName = GetDefaultLogPrintFunctionLanguageNameStack(); std::stack GetDefaultLogPrintFunctionPointerStack() { std::stack s; s.push(reinterpret_cast(&GlobalDefaultLogPrintFunction)); return s; } std::stack defaultLogPrintFunctionPointer = GetDefaultLogPrintFunctionPointerStack(); } // namespace void LogImplementation::PushDefaultPrintFunction( LanguageName const languageName, Function * const fptr) { LanguageName language(languageName); if (!language.Known()) { #if ERROR_VERBOSITY std::cerr << "Unknown LanguageName passed to PushDefaultPrintFunction, " "using LANGUAGE_NAME::cpp." << std::endl; #endif language = LANGUAGE_NAME::cpp; } defaultLogPrintFunctionLanguageName.push(language); defaultLogPrintFunctionPointer.push(fptr); } void LogImplementation::PopDefaultPrintFunction() { defaultLogPrintFunctionLanguageName.pop(); defaultLogPrintFunctionPointer.pop(); if (defaultLogPrintFunctionLanguageName.empty()) { defaultLogPrintFunctionLanguageName.push(LANGUAGE_NAME::cpp); defaultLogPrintFunctionPointer.push( reinterpret_cast(&GlobalDefaultLogPrintFunction)); } } std::string const & LogImplementation::GetID() const { return idString_; } namespace { std::string SanitizeID(std::string const & id) { std::string idCopy = id; std::string::iterator itr; for (itr = idCopy.begin(); itr != idCopy.end(); ++itr) { if (isspace(*itr)) { *itr = '_'; } else if ('*' == *itr) { *itr = '_'; } } return idCopy; } } // namespace void LogImplementation::SetID(std::string const & id) { std::string const sanitizedID = SanitizeID(id); std::stringstream ss; ss << "Log object renamed. ID changed to '" << sanitizedID << "'."; std::stringstream tt; tt << "Log object renamed. ID changed from '" << idString_ << "'."; LogEntry(LOG_VERBOSITY::information, ss.str(), __LINE__, __FILE__); idString_ = sanitizedID; LogEntry(LOG_VERBOSITY::information, tt.str(), __LINE__, __FILE__); } void LogImplementation::PushVerbosity(LogVerbosity const logVerbosity) { LogVerbosity logVerb(logVerbosity); if (!Validate(logVerbosity)) logVerb = verbosity_.top(); std::stringstream ss; ss << "Log verbosity '" << logVerb.ToString() << "' pushed (on top of " << verbosity_.top().ToString() << ")."; LogEntry(LOG_VERBOSITY::information, ss.str(), __LINE__, __FILE__); verbosity_.push(logVerb); } void LogImplementation::PopVerbosity() { std::stringstream ss; ss << "Log verbosity '" << verbosity_.top().ToString() << "' popped, revealing '"; verbosity_.pop(); if (verbosity_.empty()) { verbosity_.push(defaultLogVerbosity.top()); } ss << verbosity_.top().ToString() << "'."; LogEntry(LOG_VERBOSITY::information, ss.str(), __LINE__, __FILE__); } void LogImplementation::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { LogVerbosity logVerb(logVerbosity); if (!Validate(logVerbosity)) logVerb = verbosity_.top(); if ((logVerb != LOG_VERBOSITY::silent) && (logVerb <= verbosity_.top())) { std::string tm(GetTimeStamp()); std::string entry(EntryString(logVerb.ToString(), tm, sequence_, idString_, message, lineNumber, fileName)); int error = true; if (printFunctionLanguageName_ == LANGUAGE_NAME::cpp) { LogPrintFunction * CppPrint = reinterpret_cast(printFunctionPointer_); error = CppPrint(entry); } else if (printFunctionLanguageName_ == LANGUAGE_NAME::c) { KIM_LogPrintFunction * CPrint = reinterpret_cast(printFunctionPointer_); error = CPrint(entry.c_str()); } else if (printFunctionLanguageName_ == LANGUAGE_NAME::fortran) { typedef void(kim_log_print_function)(char const * const, int * const); kim_log_print_function * FPrint = reinterpret_cast(printFunctionPointer_); FPrint(entry.c_str(), &error); } else { std::cerr << "Unknown LanguageName for log PrintFunction. Message follows." << std::endl << entry; } if (error) { std::cerr << "Error occurred in log PrintFunction. Message follows." << std::endl << entry; } } } LogImplementation::LogImplementation() : idString_(SPTR(this)), printFunctionLanguageName_(defaultLogPrintFunctionLanguageName.top()), printFunctionPointer_(defaultLogPrintFunctionPointer.top()), latestTimeStamp_(""), sequence_(0) { verbosity_.push(defaultLogVerbosity.top()); } LogImplementation::~LogImplementation() {} std::string LogImplementation::EntryString(std::string const & logVerbosity, std::string const & date, int const sequence, std::string const & idString, std::string const & message, int const lineNumberString, std::string const & fileName) { char const * flName = strrchr(fileName.c_str(), '/'); if (flName != NULL) { flName++; // drop leading '/' } else { flName = fileName.c_str(); } std::stringstream ssPrefix; ssPrefix << date << " * " << sequence << " * " << logVerbosity << " * " << idString << " * " << flName << ":" << lineNumberString << " * "; std::string const prefix(ssPrefix.str()); std::string line; std::stringstream ssMessage(message); std::stringstream ss; while (std::getline(ssMessage, line, '\n')) { ss << prefix << line << "\n"; } return ss.str(); } std::string LogImplementation::GetTimeStamp() const { time_t rawTime; time(&rawTime); char date[1024]; #ifdef _WIN32 struct tm * timeInfo; timeInfo = localtime(&rawTime); strftime(date, 1023, "%Y-%m-%d:%H:%M:%S%Z", timeInfo); #else struct tm timeInfo; localtime_r(&rawTime, &timeInfo); strftime(date, 1023, "%Y-%m-%d:%H:%M:%S%Z", &timeInfo); #endif std::string dateString(date); if (dateString == latestTimeStamp_) { ++sequence_; } else { sequence_ = 0; latestTimeStamp_ = dateString; } return dateString; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_LogImplementation.hpp000066400000000000000000000062051421473465500220530ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_LOG_IMPLEMENTATION_HPP_ #define KIM_LOG_IMPLEMENTATION_HPP_ #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" // IWYU pragma: export #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif namespace KIM { // Forward declarations class LogImplementation { public: static int Create(LogImplementation ** const logImplementation); static void Destroy(LogImplementation ** const logImplementation); static void PushDefaultVerbosity(LogVerbosity const logVerbosity); static void PopDefaultVerbosity(); static void PushDefaultPrintFunction(LanguageName const languageName, Function * const fptr); static void PopDefaultPrintFunction(); std::string const & GetID() const; void SetID(std::string const & id); void PushVerbosity(LogVerbosity const logVerbosity); void PopVerbosity(); void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; private: // do not allow copy constructor or operator= LogImplementation(LogImplementation const &); void operator=(LogImplementation const &); LogImplementation(); ~LogImplementation(); static std::string EntryString(std::string const & logVerbosity, std::string const & date, int const sequence, std::string const & idString, std::string const & message, int const lineNumberString, std::string const & fileName); std::string GetTimeStamp() const; std::string idString_; std::stack verbosity_; LanguageName printFunctionLanguageName_; Function * printFunctionPointer_; mutable std::string latestTimeStamp_; mutable unsigned sequence_; }; // class LogImplementation } // namespace KIM #endif // KIM_LOG_IMPLEMENTATION_HPP_ kim-api-2.3.0-git/cpp/src/KIM_LogVerbosity.cpp000066400000000000000000000104701421473465500210460ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LOG_DEFINES_INC_ #include "KIM_LOG_DEFINES.inc" #endif namespace KIM { // Order is important namespace LOG_VERBOSITY { LogVerbosity const silent(KIM_LOG_VERBOSITY_SILENT_); LogVerbosity const fatal(KIM_LOG_VERBOSITY_FATAL_); LogVerbosity const error(KIM_LOG_VERBOSITY_ERROR_); LogVerbosity const warning(KIM_LOG_VERBOSITY_WARNING_); LogVerbosity const information(KIM_LOG_VERBOSITY_INFORMATION_); LogVerbosity const debug(KIM_LOG_VERBOSITY_DEBUG_); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[silent] = "silent"; m[fatal] = "fatal"; m[error] = "error"; m[warning] = "warning"; m[information] = "information"; m[debug] = "debug"; return m; } StringMap const logVerbosityToString = GetStringMap(); std::string const logVerbosityUnknown("unknown"); } // namespace void GetNumberOfLogVerbosities(int * const numberOfLogVerbosities) { *numberOfLogVerbosities = logVerbosityToString.size(); } int GetLogVerbosity(int const index, LogVerbosity * const logVerbosity) { int numberOfLogVerbosities; GetNumberOfLogVerbosities(&numberOfLogVerbosities); if ((index < 0) || (index >= numberOfLogVerbosities)) return true; StringMap::const_iterator iter = logVerbosityToString.begin(); for (int i = 0; i < index; ++i) ++iter; *logVerbosity = iter->first; return false; // no error } } // namespace LOG_VERBOSITY // implementation of LogVerbosity LogVerbosity::LogVerbosity() {} LogVerbosity::LogVerbosity(int const id) : logVerbosityID(id) {} LogVerbosity::LogVerbosity(std::string const & str) { logVerbosityID = -1; for (LOG_VERBOSITY::StringMap::const_iterator iter = LOG_VERBOSITY::logVerbosityToString.begin(); iter != LOG_VERBOSITY::logVerbosityToString.end(); ++iter) { if (iter->second == str) { logVerbosityID = (iter->first).logVerbosityID; break; } } } bool LogVerbosity::Known() const { int numberOfLogVerbosities; LOG_VERBOSITY::GetNumberOfLogVerbosities(&numberOfLogVerbosities); for (int i = 0; i < numberOfLogVerbosities; ++i) { LogVerbosity lv; LOG_VERBOSITY::GetLogVerbosity(i, &lv); if (*this == lv) { return true; } } return false; } bool LogVerbosity::operator<(LogVerbosity const & rhs) const { return logVerbosityID < rhs.logVerbosityID; } bool LogVerbosity::operator>(LogVerbosity const & rhs) const { return logVerbosityID > rhs.logVerbosityID; } bool LogVerbosity::operator<=(LogVerbosity const & rhs) const { return logVerbosityID <= rhs.logVerbosityID; } bool LogVerbosity::operator>=(LogVerbosity const & rhs) const { return logVerbosityID >= rhs.logVerbosityID; } bool LogVerbosity::operator==(LogVerbosity const & rhs) const { return logVerbosityID == rhs.logVerbosityID; } bool LogVerbosity::operator!=(LogVerbosity const & rhs) const { return logVerbosityID != rhs.logVerbosityID; } std::string const & LogVerbosity::ToString() const { LOG_VERBOSITY::StringMap::const_iterator iter = LOG_VERBOSITY::logVerbosityToString.find(*this); if (iter == LOG_VERBOSITY::logVerbosityToString.end()) return LOG_VERBOSITY::logVerbosityUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_Model.cpp000066400000000000000000000160461421473465500174630ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_MODEL_HPP_ #include "KIM_Model.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif namespace KIM { int Model::Create(Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const & modelName, int * const requestedUnitsAccepted, Model ** const model) { *model = new Model(); int error = ModelImplementation::Create(numbering, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, modelName, requestedUnitsAccepted, &((*model)->pimpl)); if (error) { delete *model; *model = NULL; return true; } else { return false; } } void Model::Destroy(Model ** const model) { if (*model != NULL) { ModelImplementation::Destroy(&((*model)->pimpl)); } delete *model; *model = NULL; } int Model::IsRoutinePresent(ModelRoutineName const modelRoutineName, int * const present, int * const required) const { return pimpl->IsRoutinePresent(modelRoutineName, present, required); } void Model::GetInfluenceDistance(double * const influenceDistance) const { pimpl->GetInfluenceDistance(influenceDistance); } void Model::GetNeighborListPointers( int * const numberOfNeighborLists, double const ** const cutoffs, int const ** const modelWillNotRequestNeighborsOfNoncontributingParticles) const { pimpl->GetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } void Model::GetUnits(LengthUnit * const lengthUnit, EnergyUnit * const energyUnit, ChargeUnit * const chargeUnit, TemperatureUnit * const temperatureUnit, TimeUnit * const timeUnit) const { pimpl->GetUnits( lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit); } int Model::ComputeArgumentsCreate( ComputeArguments ** const computeArguments) const { return pimpl->ComputeArgumentsCreate(computeArguments); } int Model::ComputeArgumentsDestroy( ComputeArguments ** const computeArguments) const { return pimpl->ComputeArgumentsDestroy(computeArguments); } int Model::Compute(ComputeArguments const * const computeArguments) const { return pimpl->Compute(computeArguments); } int Model::Extension(std::string const & extensionID, void * const extensionStructure) { return pimpl->Extension(extensionID, extensionStructure); } int Model::ClearThenRefresh() { return pimpl->ClearThenRefresh(); } int Model::WriteParameterizedModel(std::string const & path, std::string const & modelName) const { return pimpl->WriteParameterizedModel(path, modelName); } int Model::GetSpeciesSupportAndCode(SpeciesName const speciesName, int * const speciesIsSupported, int * const code) const { return pimpl->GetSpeciesSupportAndCode(speciesName, speciesIsSupported, code); } void Model::GetNumberOfParameters(int * const numberOfParameters) const { pimpl->GetNumberOfParameters(numberOfParameters); } int Model::GetParameterMetadata(int const parameterIndex, DataType * const dataType, int * const extent, std::string const ** const name, std::string const ** const description) const { return pimpl->GetParameterMetadata( parameterIndex, dataType, extent, name, description); } int Model::GetParameter(int const parameterIndex, int const arrayIndex, int * const parameterValue) const { return pimpl->GetParameter(parameterIndex, arrayIndex, parameterValue); } int Model::GetParameter(int const parameterIndex, int const arrayIndex, double * const parameterValue) const { return pimpl->GetParameter(parameterIndex, arrayIndex, parameterValue); } int Model::SetParameter(int const parameterIndex, int const arrayIndex, int const parameterValue) { return pimpl->SetParameter(parameterIndex, arrayIndex, parameterValue); } int Model::SetParameter(int const parameterIndex, int const arrayIndex, double const parameterValue) { return pimpl->SetParameter(parameterIndex, arrayIndex, parameterValue); } void Model::SetSimulatorBufferPointer(void * const ptr) { pimpl->SetSimulatorBufferPointer(ptr); } void Model::GetSimulatorBufferPointer(void ** const ptr) const { pimpl->GetSimulatorBufferPointer(ptr); } std::string const & Model::ToString() const { return pimpl->ToString(); } void Model::SetLogID(std::string const & logID) { pimpl->SetLogID(logID); } void Model::PushLogVerbosity(LogVerbosity const logVerbosity) { pimpl->PushLogVerbosity(logVerbosity); } void Model::PopLogVerbosity() { pimpl->PopLogVerbosity(); } Model::Model() : pimpl(NULL) {} Model::~Model() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelCompute.cpp000066400000000000000000000045341421473465500210170ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_COMPUTE_HPP_ #include "KIM_ModelCompute.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { void ModelCompute::GetModelBufferPointer(void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelCompute::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelCompute::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelCompute::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelCompute::ModelCompute() : pimpl(NULL) {} ModelCompute::~ModelCompute() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelComputeArguments.cpp000066400000000000000000000121221421473465500226750ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ModelComputeArguments.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include "KIM_ComputeArgumentsImplementation.hpp" #endif #define CONVERT_POINTER \ ComputeArgumentsImplementation * pImpl \ = reinterpret_cast(pimpl) namespace KIM { int ModelComputeArguments::GetNeighborList( int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) const { CONVERT_POINTER; return pImpl->GetNeighborList(neighborListIndex, particleNumber, numberOfNeighbors, neighborsOfParticle); } int ModelComputeArguments::ProcessDEDrTerm(double const de, double const r, double const * const dx, int const i, int const j) const { CONVERT_POINTER; return pImpl->ProcessDEDrTerm(de, r, dx, i, j); } int ModelComputeArguments::ProcessD2EDr2Term(double const de, double const * const r, double const * const dx, int const * const i, int const * const j) const { CONVERT_POINTER; return pImpl->ProcessD2EDr2Term(de, r, dx, i, j); } int ModelComputeArguments::GetArgumentPointer( ComputeArgumentName const computeArgumentName, int const ** const ptr) const { CONVERT_POINTER; return pImpl->GetArgumentPointer(computeArgumentName, ptr); } int ModelComputeArguments::GetArgumentPointer( ComputeArgumentName const computeArgumentName, int ** const ptr) const { CONVERT_POINTER; return pImpl->GetArgumentPointer(computeArgumentName, ptr); } int ModelComputeArguments::GetArgumentPointer( ComputeArgumentName const computeArgumentName, double ** const ptr) const { CONVERT_POINTER; return pImpl->GetArgumentPointer(computeArgumentName, ptr); } int ModelComputeArguments::GetArgumentPointer( ComputeArgumentName const computeArgumentName, double const ** const ptr) const { CONVERT_POINTER; return pImpl->GetArgumentPointer(computeArgumentName, ptr); } int ModelComputeArguments::IsCallbackPresent( ComputeCallbackName const computeCallbackName, int * const present) const { CONVERT_POINTER; return pImpl->IsCallbackPresent(computeCallbackName, present); } void ModelComputeArguments::SetModelBufferPointer(void * const ptr) { CONVERT_POINTER; pImpl->SetModelBufferPointer(ptr); } void ModelComputeArguments::GetModelBufferPointer(void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelComputeArguments::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelComputeArguments::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelComputeArguments::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelComputeArguments::ModelComputeArguments() : pimpl(NULL) {} ModelComputeArguments::~ModelComputeArguments() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelComputeArgumentsCreate.cpp000066400000000000000000000065731421473465500240360ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_ #include "KIM_ComputeArgumentName.hpp" #endif #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_ #include "KIM_ComputeCallbackName.hpp" #endif #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_ #include "KIM_ModelComputeArgumentsCreate.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include "KIM_ComputeArgumentsImplementation.hpp" #endif #define CONVERT_POINTER \ ComputeArgumentsImplementation * pImpl \ = reinterpret_cast(pimpl) namespace KIM { int ModelComputeArgumentsCreate::SetArgumentSupportStatus( ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus) { CONVERT_POINTER; return pImpl->SetArgumentSupportStatus(computeArgumentName, supportStatus); } int ModelComputeArgumentsCreate::SetCallbackSupportStatus( ComputeCallbackName const computeCallbackName, SupportStatus const supportStatus) { CONVERT_POINTER; return pImpl->SetCallbackSupportStatus(computeCallbackName, supportStatus); } void ModelComputeArgumentsCreate::SetModelBufferPointer(void * const ptr) { CONVERT_POINTER; pImpl->SetModelBufferPointer(ptr); } void ModelComputeArgumentsCreate::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelComputeArgumentsCreate::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelComputeArgumentsCreate::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelComputeArgumentsCreate::ModelComputeArgumentsCreate() : pimpl(NULL) {} ModelComputeArgumentsCreate::~ModelComputeArgumentsCreate() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelComputeArgumentsDestroy.cpp000066400000000000000000000052521421473465500242550ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_HPP_ #include "KIM_ModelComputeArgumentsDestroy.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include "KIM_ComputeArgumentsImplementation.hpp" #endif #define CONVERT_POINTER \ ComputeArgumentsImplementation * pImpl \ = reinterpret_cast(pimpl) namespace KIM { void ModelComputeArgumentsDestroy::GetModelBufferPointer( void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelComputeArgumentsDestroy::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelComputeArgumentsDestroy::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelComputeArgumentsDestroy::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelComputeArgumentsDestroy::ModelComputeArgumentsDestroy() : pimpl(NULL) {} ModelComputeArgumentsDestroy::~ModelComputeArgumentsDestroy() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelCreate.cpp000066400000000000000000000153731421473465500206110ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_MODEL_CREATE_HPP_ #include "KIM_ModelCreate.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { int ModelCreate::SetModelNumbering(Numbering const numbering) { CONVERT_POINTER; return pImpl->SetModelNumbering(numbering); } void ModelCreate::SetInfluenceDistancePointer( double const * const influenceDistance) { CONVERT_POINTER; pImpl->SetInfluenceDistancePointer(influenceDistance); } void ModelCreate::SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pImpl->SetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } int ModelCreate::SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function * const fptr) { CONVERT_POINTER; return pImpl->SetRoutinePointer( modelRoutineName, languageName, required, fptr); } int ModelCreate::SetSpeciesCode(SpeciesName const speciesName, int const code) { CONVERT_POINTER; return pImpl->SetSpeciesCode(speciesName, code); } int ModelCreate::SetParameterPointer(int const extent, int * const ptr, std::string const & name, std::string const & description) { CONVERT_POINTER; return pImpl->SetParameterPointer(extent, ptr, name, description); } int ModelCreate::SetParameterPointer(int const extent, double * const ptr, std::string const & name, std::string const & description) { CONVERT_POINTER; return pImpl->SetParameterPointer(extent, ptr, name, description); } void ModelCreate::SetModelBufferPointer(void * const ptr) { CONVERT_POINTER; pImpl->SetModelBufferPointer(ptr); } int ModelCreate::SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit) { CONVERT_POINTER; return pImpl->SetUnits( lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit); } int ModelCreate::ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor) { return ModelImplementation::ConvertUnit(fromLengthUnit, fromEnergyUnit, fromChargeUnit, fromTemperatureUnit, fromTimeUnit, toLengthUnit, toEnergyUnit, toChargeUnit, toTemperatureUnit, toTimeUnit, lengthExponent, energyExponent, chargeExponent, temperatureExponent, timeExponent, conversionFactor); } void ModelCreate::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelCreate::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelCreate::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelCreate::ModelCreate() : pimpl(NULL) {} ModelCreate::~ModelCreate() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelDestroy.cpp000066400000000000000000000045351421473465500210350ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_DESTROY_HPP_ #include "KIM_ModelDestroy.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { void ModelDestroy::GetModelBufferPointer(void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelDestroy::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelDestroy::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelDestroy::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelDestroy::ModelDestroy() : pimpl(NULL) {} ModelDestroy::~ModelDestroy() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelDriverCreate.cpp000066400000000000000000000174201421473465500217600ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_UNIT_SYSTEM #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_MODEL_DRIVER_CREATE_HPP_ #include "KIM_ModelDriverCreate.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { void ModelDriverCreate::GetParameterFileDirectoryName( std::string const ** const directoryName) const { CONVERT_POINTER; pImpl->GetParameterFileDirectoryName(directoryName); } void ModelDriverCreate::GetNumberOfParameterFiles( int * const numberOfParameterFiles) const { CONVERT_POINTER; pImpl->GetNumberOfParameterFiles(numberOfParameterFiles); } int ModelDriverCreate::GetParameterFileName( int const index, std::string const ** const parameterFileName) const { CONVERT_POINTER; return pImpl->GetParameterFileName(index, parameterFileName); } int ModelDriverCreate::GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const { CONVERT_POINTER; return pImpl->GetParameterFileBasename(index, parameterFileBasename); } int ModelDriverCreate::SetModelNumbering(Numbering const numbering) { CONVERT_POINTER; return pImpl->SetModelNumbering(numbering); } void ModelDriverCreate::SetInfluenceDistancePointer( double const * const influenceDistance) { CONVERT_POINTER; pImpl->SetInfluenceDistancePointer(influenceDistance); } void ModelDriverCreate::SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pImpl->SetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } int ModelDriverCreate::SetRoutinePointer( ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function * const fptr) { CONVERT_POINTER; return pImpl->SetRoutinePointer( modelRoutineName, languageName, required, fptr); } int ModelDriverCreate::SetSpeciesCode(SpeciesName const speciesName, int const code) { CONVERT_POINTER; return pImpl->SetSpeciesCode(speciesName, code); } int ModelDriverCreate::SetParameterPointer(int const extent, int * const ptr, std::string const & name, std::string const & description) { CONVERT_POINTER; return pImpl->SetParameterPointer(extent, ptr, name, description); } int ModelDriverCreate::SetParameterPointer(int const extent, double * const ptr, std::string const & name, std::string const & description) { CONVERT_POINTER; return pImpl->SetParameterPointer(extent, ptr, name, description); } void ModelDriverCreate::SetModelBufferPointer(void * const ptr) { CONVERT_POINTER; pImpl->SetModelBufferPointer(ptr); } int ModelDriverCreate::SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit) { CONVERT_POINTER; return pImpl->SetUnits( lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit); } int ModelDriverCreate::ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor) { return ModelImplementation::ConvertUnit(fromLengthUnit, fromEnergyUnit, fromChargeUnit, fromTemperatureUnit, fromTimeUnit, toLengthUnit, toEnergyUnit, toChargeUnit, toTemperatureUnit, toTimeUnit, lengthExponent, energyExponent, chargeExponent, temperatureExponent, timeExponent, conversionFactor); } void ModelDriverCreate::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelDriverCreate::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelDriverCreate::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelDriverCreate::ModelDriverCreate() : pimpl(NULL) {} ModelDriverCreate::~ModelDriverCreate() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelExtension.cpp000066400000000000000000000076101421473465500213550ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_EXTENSION_HPP_ #include "KIM_ModelExtension.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { void ModelExtension::GetExtensionID( std::string const ** const extensionID) const { CONVERT_POINTER; pImpl->GetExtensionID(extensionID); } Model * ModelExtension::Model() { return reinterpret_cast(this); } ModelCompute * ModelExtension::ModelCompute() { return reinterpret_cast(this); } ModelCreate * ModelExtension::ModelCreate() { return reinterpret_cast(this); } ModelDestroy * ModelExtension::ModelDestroy() { return reinterpret_cast(this); } ModelDriverCreate * ModelExtension::ModelDriverCreate() { return reinterpret_cast(this); } ModelRefresh * ModelExtension::ModelRefresh() { return reinterpret_cast(this); } ModelWriteParameterizedModel * ModelExtension::ModelWriteParameterizedModel() { return reinterpret_cast(this); } ModelComputeArguments * ModelExtension::ModelComputeArguments( ComputeArguments * const computeArguments) const { return reinterpret_cast(computeArguments); } ModelComputeArgumentsCreate * ModelExtension::ModelComputeArgumentsCreate( ComputeArguments * const computeArguments) const { return reinterpret_cast(computeArguments); } ModelComputeArgumentsDestroy * ModelExtension::ModelComputeArgumentsDestroy( ComputeArguments * const computeArguments) const { return reinterpret_cast( computeArguments); } void ModelExtension::GetModelBufferPointer(void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelExtension::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelExtension::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelExtension::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelExtension::ModelExtension() : pimpl(NULL) {} ModelExtension::~ModelExtension() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelImplementation.cpp000066400000000000000000002712531421473465500223740ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #include #include #include #include #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_HPP_ #include "KIM_ComputeArguments.hpp" #endif #ifndef KIM_COLLECTIONS_HPP_ #include "KIM_Collections.hpp" #endif #ifndef KIM_SHARED_LIBRARY_HPP_ #include "KIM_SharedLibrary.hpp" #endif #ifndef KIM_COMPUTE_ARGUMENTS_IMPLEMENTATION_HPP_ #include "KIM_ComputeArgumentsImplementation.hpp" #endif #ifndef KIM_UNIT_SYSTEM_H_ extern "C" { #include "KIM_UnitSystem.h" } // extern "C" #endif #ifndef KIM_MODEL_CREATE_H_ extern "C" { #include "KIM_ModelCreate.h" struct KIM_ModelCreate { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_DRIVER_CREATE_H_ extern "C" { struct KIM_ModelDriverCreate { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_ extern "C" { struct KIM_ModelComputeArgumentsCreate { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_REFRESH_H_ extern "C" { struct KIM_ModelRefresh { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_COMPUTE_H_ extern "C" { struct KIM_ModelCompute { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_EXTENSION_H_ extern "C" { struct KIM_ModelExtension { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_H_ extern "C" { struct KIM_ModelWriteParameterizedModel { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_H_ extern "C" { struct KIM_ModelComputeArguments { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_H_ extern "C" { struct KIM_ModelComputeArgumentsDestroy { void * p; }; } // extern "C" #endif #ifndef KIM_MODEL_DESTROY_H_ extern "C" { struct KIM_ModelDestroy { void * p; }; } // extern "C" #endif #ifndef KIM_FUNCTION_TYPES_H_ extern "C" { #include "KIM_FunctionTypes.h" } #endif namespace KIM { namespace MODEL_ROUTINE_NAME { extern std::vector const requiredByAPI_ModelRoutines; } // namespace MODEL_ROUTINE_NAME } // namespace KIM namespace { KIM_LengthUnit makeLengthUnitC(KIM::LengthUnit const lengthUnit) { KIM_LengthUnit lengthUnitC = {lengthUnit.lengthUnitID}; return lengthUnitC; } KIM_EnergyUnit makeEnergyUnitC(KIM::EnergyUnit const energyUnit) { KIM_EnergyUnit energyUnitC = {energyUnit.energyUnitID}; return energyUnitC; } KIM_ChargeUnit makeChargeUnitC(KIM::ChargeUnit const chargeUnit) { KIM_ChargeUnit chargeUnitC = {chargeUnit.chargeUnitID}; return chargeUnitC; } KIM_TemperatureUnit makeTemperatureUnitC(KIM::TemperatureUnit const temperatureUnit) { KIM_TemperatureUnit temperatureUnitC = {temperatureUnit.temperatureUnitID}; return temperatureUnitC; } KIM_TimeUnit makeTimeUnitC(KIM::TimeUnit const timeUnit) { KIM_TimeUnit timeUnitC = {timeUnit.timeUnitID}; return timeUnitC; } } // namespace // log helpers #define SNUM(x) \ static_cast(std::ostringstream() \ << std::dec << x) \ .str() #define SPTR(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #define SFUNC(x) \ static_cast( \ std::ostringstream() << reinterpret_cast(x)) \ .str() #include "KIM_LogMacros.hpp" #define KIM_LOGGER_OBJECT_NAME this namespace KIM { // Forward declarations class ModelCreate; class ModelDriverCreate; class ModelRefresh; class ModelCompute; class ModelComputeArguments; class ModelDestroy; class ModelExtension; class ModelComputeArgumentsCreate; class ModelComputeArgumentsDestroy; class ModelWriteParameterizedModel; int ModelImplementation::Create( Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const & modelName, int * const requestedUnitsAccepted, ModelImplementation ** const modelImplementation) { // error checking of arguments performed as part of ModelCreate() Log * pLog; int error = Log::Create(&pLog); if (error) { *modelImplementation = NULL; return true; } ModelImplementation * pModelImplementation; pModelImplementation = new ModelImplementation(new SharedLibrary(pLog), pLog); #if DEBUG_VERBOSITY std::string const callString = "Create(" + numbering.ToString() + ", " + requestedLengthUnit.ToString() + ", " + requestedEnergyUnit.ToString() + ", " + requestedChargeUnit.ToString() + ", " + requestedTemperatureUnit.ToString() + ", " + requestedTimeUnit.ToString() + ", '" + modelName + "', " + SPTR(requestedUnitsAccepted) + ", " + SPTR(modelImplementation) + ")."; pModelImplementation->LogEntry( LOG_VERBOSITY::debug, "Created Log and ModelImplementation objects after enter " + callString, __LINE__, __FILE__); #endif error = pModelImplementation->ModelCreate(numbering, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, modelName); if (error) { #if DEBUG_VERBOSITY pModelImplementation->LogEntry( LOG_VERBOSITY::debug, "Destroying ModelImplementation object and exit " + callString, __LINE__, __FILE__); #endif delete pModelImplementation; // also deletes pLog object *modelImplementation = NULL; return true; } LengthUnit finalLengthUnit; EnergyUnit finalEnergyUnit; ChargeUnit finalChargeUnit; TemperatureUnit finalTemperatureUnit; TimeUnit finalTimeUnit; pModelImplementation->GetUnits(&finalLengthUnit, &finalEnergyUnit, &finalChargeUnit, &finalTemperatureUnit, &finalTimeUnit); if (((finalLengthUnit == LENGTH_UNIT::unused) || (finalLengthUnit == requestedLengthUnit)) && ((finalEnergyUnit == ENERGY_UNIT::unused) || (finalEnergyUnit == requestedEnergyUnit)) && ((finalChargeUnit == CHARGE_UNIT::unused) || (finalChargeUnit == requestedChargeUnit)) && ((finalTemperatureUnit == TEMPERATURE_UNIT::unused) || (finalTemperatureUnit == requestedTemperatureUnit)) && ((finalTimeUnit == TIME_UNIT::unused) || (finalTimeUnit == requestedTimeUnit))) { pModelImplementation->LogEntry( LOG_VERBOSITY::debug, "Accepted requested units.", __LINE__, __FILE__); *requestedUnitsAccepted = true; } else { pModelImplementation->LogEntry( LOG_VERBOSITY::debug, "Rejected requested units.", __LINE__, __FILE__); *requestedUnitsAccepted = false; } *modelImplementation = pModelImplementation; #if DEBUG_VERBOSITY (*modelImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Exit 0=" + callString, __LINE__, __FILE__); #endif return false; } void ModelImplementation::Destroy( ModelImplementation ** const modelImplementation) { if (*modelImplementation != NULL) { #if DEBUG_VERBOSITY std::string callString = "Destroy(" + SPTR(modelImplementation) + ")."; (*modelImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Enter " + callString, __LINE__, __FILE__); #endif (*modelImplementation)->ModelDestroy(); #if DEBUG_VERBOSITY (*modelImplementation) ->LogEntry(LOG_VERBOSITY::debug, "Destroying ModelImplementation object and exit " + callString, __LINE__, __FILE__); #endif } delete *modelImplementation; // also deletes Log objects *modelImplementation = NULL; } int ModelImplementation::IsRoutinePresent( ModelRoutineName const modelRoutineName, int * const present, int * const required) const { #if DEBUG_VERBOSITY std::string const callString = "IsRoutinePresent(" + modelRoutineName.ToString() + ", " + SNUM(present) + ", " + SNUM(required) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = !modelRoutineName.Known(); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map:: const_iterator result = routineFunction_.find(modelRoutineName); if (result->second == NULL) { if (present != NULL) *present = false; if (required != NULL) *required = false; } else { if (present != NULL) *present = true; if (required != NULL) { std::map:: const_iterator requiredResult = routineRequired_.find(modelRoutineName); *required = requiredResult->second; } } LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::ComputeArgumentsCreate( ComputeArguments ** const computeArguments) const { #if DEBUG_VERBOSITY std::string const callString = "ComputeArgumentsCreate(" + SPTR(computeArguments) + ")."; #endif LOG_DEBUG("Enter " + callString); *computeArguments = new ComputeArguments(); int error = ComputeArgumentsImplementation::Create(modelName_, log_->GetID(), modelNumbering_, simulatorNumbering_, numberingOffset_, &((*computeArguments)->pimpl)); if (error) { delete *computeArguments; *computeArguments = NULL; LOG_DEBUG("Exit 1=" + callString); return true; } error = ModelComputeArgumentsCreate(*computeArguments); if (error) { delete *computeArguments; *computeArguments = NULL; LOG_DEBUG("Exit 1=" + callString); return true; } // No further error checking needed LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::ComputeArgumentsDestroy( ComputeArguments ** const computeArguments) const { #if DEBUG_VERBOSITY std::string const callString = "ComputeArgumentsDestroy(" + SPTR(computeArguments) + ")."; #endif LOG_DEBUG("Enter " + callString); if (modelName_ != (*computeArguments)->pimpl->modelName_) { LOG_ERROR("ComputeArguments object for Model '" + (*computeArguments)->pimpl->modelName_ + "' cannot be Destroyed with the " "ModelDestroy() routine of Model '" + modelName_ + "'."); LOG_DEBUG("Exit 1=" + callString); return true; } int error = ModelComputeArgumentsDestroy(*computeArguments); if (error) { LOG_DEBUG("Exit 1=" + callString); return true; } ComputeArgumentsImplementation::Destroy(&((*computeArguments)->pimpl)); delete *computeArguments; *computeArguments = NULL; LOG_DEBUG("Exit 0=" + callString); return false; } void ModelImplementation::SetInfluenceDistancePointer( double const * const influenceDistance) { #if DEBUG_VERBOSITY std::string const callString = "SetInfluenceDistancePointer(" + SPTR(influenceDistance) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (influenceDistance == NULL) LOG_ERROR("Null pointer provided for InfluenceDistancePotiner."); #endif influenceDistance_ = influenceDistance; LOG_DEBUG("Exit " + callString); } void ModelImplementation::GetInfluenceDistance( double * const influenceDistance) const { #if DEBUG_VERBOSITY std::string const callString = "GetInfluenceDistance(" + SPTR(influenceDistance) + ")."; #endif LOG_DEBUG("Enter " + callString); *influenceDistance = *influenceDistance_; LOG_DEBUG("Exit " + callString); } void ModelImplementation::SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { #if DEBUG_VERBOSITY std::string const callString = "SetNeighborListPointers(" + SNUM(numberOfNeighborLists) + ", " + SPTR(cutoffs) + ", " + SPTR(modelWillNotRequestNeighborsOfNoncontributingParticles) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (numberOfNeighborLists < 1) LOG_ERROR("Number of neighbor lists, " + SNUM(numberOfNeighborLists) + ", must be >= 1."); if (cutoffs == NULL) LOG_ERROR("Null pointer provided for cutoffs."); if (modelWillNotRequestNeighborsOfNoncontributingParticles == NULL) LOG_ERROR("Null pointer provided for " "modelWillNotRequestNeighborsOfNoncontributingParticles."); #endif numberOfNeighborLists_ = numberOfNeighborLists; cutoffs_ = cutoffs; modelWillNotRequestNeighborsOfNoncontributingParticles_ = modelWillNotRequestNeighborsOfNoncontributingParticles; LOG_DEBUG("Exit " + callString); } void ModelImplementation::GetNeighborListPointers( int * const numberOfNeighborLists, double const ** const cutoffs, int const ** const modelWillNotRequestNeighborsOfNoncontributingParticles) const { #if DEBUG_VERBOSITY std::string const callString = "GetNeighborListPointers(" + SPTR(numberOfNeighborLists) + ", " + SPTR(cutoffs) + ", " + SPTR(modelWillNotRequestNeighborsOfNoncontributingParticles) + ")."; #endif LOG_DEBUG("Enter " + callString); if (numberOfNeighborLists != NULL) *numberOfNeighborLists = numberOfNeighborLists_; if (cutoffs != NULL) *cutoffs = cutoffs_; if (modelWillNotRequestNeighborsOfNoncontributingParticles != NULL) *modelWillNotRequestNeighborsOfNoncontributingParticles = modelWillNotRequestNeighborsOfNoncontributingParticles_; LOG_DEBUG("Exit " + callString); } int ModelImplementation::SetRoutinePointer( ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function * const fptr) { #if DEBUG_VERBOSITY std::string const callString = "SetRoutinePointer(" + modelRoutineName.ToString() + ", " + languageName.ToString() + ", " + SNUM(required) + ", " + SFUNC(fptr) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!modelRoutineName.Known()) || (!languageName.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } if (!required) { using namespace KIM::MODEL_ROUTINE_NAME; for (unsigned int i = 0; i < requiredByAPI_ModelRoutines.size(); ++i) { if (requiredByAPI_ModelRoutines.at(i) == modelRoutineName) { LOG_ERROR(modelRoutineName.ToString() + " routine must be required."); LOG_DEBUG("Exit 1=" + callString); return true; } } } #endif routineLanguage_[modelRoutineName] = languageName; routineRequired_[modelRoutineName] = bool(required); routineFunction_[modelRoutineName] = fptr; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetSpeciesCode(SpeciesName const speciesName, int const code) { #if DEBUG_VERBOSITY std::string const callString = "SetSpeciesCode(" + speciesName.ToString() + ", " + SNUM(code) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = !speciesName.Known(); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif supportedSpecies_[speciesName] = code; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::GetSpeciesSupportAndCode( KIM::SpeciesName const speciesName, int * const speciesIsSupported, int * const code) const { #if DEBUG_VERBOSITY std::string const callString = "GetSpeciesSupportAndCode(" + speciesName.ToString() + ", " + SPTR(speciesIsSupported) + ", " + SPTR(code) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = !speciesName.Known(); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif std::map::const_iterator result = supportedSpecies_.find(speciesName); if (result == supportedSpecies_.end()) { LOG_DEBUG("Species is not supported."); *speciesIsSupported = false; } else { LOG_DEBUG("Species is supported."); *speciesIsSupported = true; if (code != NULL) *code = result->second; } LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetModelNumbering(Numbering const numbering) { #if DEBUG_VERBOSITY std::string const callString = "SetModelNumbering(" + numbering.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = !numbering.Known(); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif modelNumbering_ = numbering; numberingHasBeenSet_ = true; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetSimulatorNumbering(Numbering const numbering) { #if DEBUG_VERBOSITY std::string const callString = "SetSimulatorNumbering(" + numbering.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = !numbering.Known(); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif simulatorNumbering_ = numbering; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit) { #if DEBUG_VERBOSITY std::string const callString = "SetUnits(" + lengthUnit.ToString() + ", " + energyUnit.ToString() + ", " + chargeUnit.ToString() + ", " + temperatureUnit.ToString() + ", " + timeUnit.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!lengthUnit.Known()) || (!energyUnit.Known()) || (!chargeUnit.Known()) || (!temperatureUnit.Known()) || (!timeUnit.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } if (lengthUnit == LENGTH_UNIT::unused) { LOG_ERROR("Models cannot specify 'unused' for LengthUnit"); LOG_DEBUG("Exit 1=" + callString); return true; } if (energyUnit == ENERGY_UNIT::unused) { LOG_ERROR("Models cannot specify 'unused' for EnergyUnit"); LOG_DEBUG("Exit 1=" + callString); return true; } #endif lengthUnit_ = lengthUnit; energyUnit_ = energyUnit; chargeUnit_ = chargeUnit; temperatureUnit_ = temperatureUnit; timeUnit_ = timeUnit; unitsHaveBeenSet_ = true; LOG_DEBUG("Exit 0=" + callString); return false; } void ModelImplementation::GetUnits(LengthUnit * const lengthUnit, EnergyUnit * const energyUnit, ChargeUnit * const chargeUnit, TemperatureUnit * const temperatureUnit, TimeUnit * const timeUnit) const { #if DEBUG_VERBOSITY std::string const callString = "GetUnits(" + SPTR(lengthUnit) + ", " + SPTR(energyUnit) + ", " + SPTR(chargeUnit) + ", " + SPTR(temperatureUnit) + ", " + SPTR(timeUnit) + ")."; #endif LOG_DEBUG("Enter " + callString); if (lengthUnit != NULL) *lengthUnit = lengthUnit_; if (energyUnit != NULL) *energyUnit = energyUnit_; if (chargeUnit != NULL) *chargeUnit = chargeUnit_; if (temperatureUnit != NULL) *temperatureUnit = temperatureUnit_; if (timeUnit != NULL) *timeUnit = timeUnit_; LOG_DEBUG("Exit " + callString); } void ModelImplementation::GetParameterFileDirectoryName( std::string const ** const directoryName) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileDirectoryName(" + SPTR(directoryName) + ")."; #endif LOG_DEBUG("Enter " + callString); *directoryName = ¶meterFileDirectoryNameString_; LOG_DEBUG("Exit " + callString); } int ModelImplementation::GetNumberOfParameterFiles( int * const numberOfParameterFiles) const { #if DEBUG_VERBOSITY std::string const callString = "GetNumberOfParameterFiles(" + SPTR(numberOfParameterFiles) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (modelDriverName_ == "") { LOG_ERROR("Only parameterized models have parameter files."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *numberOfParameterFiles = numberOfParameterFiles_; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::GetParameterFileName( int const index, std::string const ** const parameterFileName) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileName(" + SNUM(index) + ", " + SPTR(parameterFileName) + ")."; #endif LOG_DEBUG("Enter " + callString); LOG_WARNING("Use of the " + callString + " function is deprecated. " "Please use GetParameterFileBasename() instead."); #if ERROR_VERBOSITY if (modelDriverName_ == "") { LOG_ERROR("Only parameterized models have parameter files."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((index < 0) || (index >= numberOfParameterFiles_)) { LOG_ERROR("Invalid parameter file index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterFileName == NULL) { LOG_ERROR("Null pointer provided for parameterFileName."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *parameterFileName = &(parameterFileNames_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileBaseame(" + SNUM(index) + ", " + SPTR(parameterFileBasename) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (modelDriverName_ == "") { LOG_ERROR("Only parameterized models have parameter files."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((index < 0) || (index >= numberOfParameterFiles_)) { LOG_ERROR("Invalid parameter file index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterFileBasename == NULL) { LOG_ERROR("Null pointer provided for parameterFileBasename."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *parameterFileBasename = &(parameterFileBasenames_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } void ModelImplementation::SetParameterFileName( std::string const & filename) const { cmakelists_ << " \"" << filename << "\"\n"; } int ModelImplementation::SetParameterPointer(int const extent, int * const ptr, std::string const & name, std::string const & description) { #if DEBUG_VERBOSITY std::string const callString = "SetParameterPointer(" + SNUM(extent) + ", " + SPTR(ptr) + ", '" + name + "', '" + description + "')."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (extent == 0) { LOG_ERROR("Extent, " + SNUM(extent) + ", must be > 0."); LOG_DEBUG("Exit 1=" + callString); return true; } if (ptr == NULL) { LOG_ERROR("Null pointer provided for parameter."); LOG_DEBUG("Exit 1=" + callString); return true; } if (!IsCIdentifier(name)) { LOG_ERROR("Name '" + name + "' is not a valid C identifier."); LOG_DEBUG("Exit 1=" + callString); return true; } if (std::find(parameterName_.begin(), parameterName_.end(), name) != parameterName_.end()) { LOG_ERROR("Name '" + name + "' is already associated with another " "parameter. Parameter names must be unique."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif parameterName_.push_back(name); parameterDescription_.push_back(description); parameterDataType_.push_back(DATA_TYPE::Integer); parameterExtent_.push_back(extent); parameterPointer_.push_back(ptr); LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetParameterPointer(int const extent, double * const ptr, std::string const & name, std::string const & description) { #if DEBUG_VERBOSITY std::string const callString = "SetParameterPointer(" + SNUM(extent) + ", " + SPTR(ptr) + ", '" + name + "', '" + description + "')."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (extent == 0) { LOG_ERROR("Extent, " + SNUM(extent) + ", must be > 0."); LOG_DEBUG("Exit 1=" + callString); return true; } if (ptr == NULL) { LOG_ERROR("Null pointer provided for parameter."); LOG_DEBUG("Exit 1=" + callString); return true; } if (!IsCIdentifier(name)) { LOG_ERROR("Name '" + name + "' is not a valid C identifier."); LOG_DEBUG("Exit 1=" + callString); return true; } if (std::find(parameterName_.begin(), parameterName_.end(), name) != parameterName_.end()) { LOG_ERROR("Name '" + name + "' is already associated with another " "parameter. Parameter names must be unique."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif parameterName_.push_back(name); parameterDescription_.push_back(description); parameterDataType_.push_back(DATA_TYPE::Double); parameterExtent_.push_back(extent); parameterPointer_.push_back(ptr); LOG_DEBUG("Exit 0=" + callString); return false; } void ModelImplementation::GetNumberOfParameters( int * const numberOfParameters) const { #if DEBUG_VERBOSITY std::string const callString = "GetNumberOfParameters(" + SPTR(numberOfParameters) + ")."; #endif LOG_DEBUG("Enter " + callString); *numberOfParameters = parameterPointer_.size(); LOG_DEBUG("Exit " + callString); } int ModelImplementation::GetParameterMetadata( int const parameterIndex, DataType * const dataType, int * const extent, std::string const ** const name, std::string const ** const description) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterMetadata(" + SNUM(parameterIndex) + ", " + SPTR(dataType) + ", " + SPTR(extent) + ", " + SPTR(name) + ", " + SPTR(description) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((parameterIndex < 0) || (static_cast(parameterIndex) >= parameterPointer_.size())) { LOG_ERROR("Invalid parameter index, " + SNUM(parameterIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif if (dataType != NULL) *dataType = parameterDataType_[parameterIndex]; if (extent != NULL) *extent = parameterExtent_[parameterIndex]; if (name != NULL) *name = &(parameterName_[parameterIndex]); if (description != NULL) *description = &(parameterDescription_[parameterIndex]); LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::GetParameter(int const parameterIndex, int const arrayIndex, int * const parameterValue) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameter(" + SNUM(parameterIndex) + ", " + SNUM(arrayIndex) + ", " + SPTR(parameterValue) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((parameterIndex < 0) || (static_cast(parameterIndex) >= parameterPointer_.size())) { LOG_ERROR("Invalid parameter index, " + SNUM(parameterIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterDataType_[parameterIndex] != DATA_TYPE::Integer) { LOG_ERROR("Data type of parameter is not Integer."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((arrayIndex < 0) || (arrayIndex >= parameterExtent_[parameterIndex])) { LOG_ERROR("Invalid parameter arrayIndex, " + SNUM(arrayIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *parameterValue = reinterpret_cast( parameterPointer_[parameterIndex])[arrayIndex]; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::GetParameter(int const parameterIndex, int const arrayIndex, double * const parameterValue) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameter(" + SNUM(parameterIndex) + ", " + SNUM(arrayIndex) + ", " + SPTR(parameterValue) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((parameterIndex < 0) || (static_cast(parameterIndex) >= parameterPointer_.size())) { LOG_ERROR("Invalid parameter index, " + SNUM(parameterIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterDataType_[parameterIndex] != DATA_TYPE::Double) { LOG_ERROR("Data type of parameter is not Double."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((arrayIndex < 0) || (arrayIndex >= parameterExtent_[parameterIndex])) { LOG_ERROR("Invalid parameter arrayIndex, " + SNUM(arrayIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *parameterValue = reinterpret_cast( parameterPointer_[parameterIndex])[arrayIndex]; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetParameter(int const parameterIndex, int const arrayIndex, int const parameterValue) { #if DEBUG_VERBOSITY std::string const callString = "SetParameter(" + SNUM(parameterIndex) + ", " + SNUM(arrayIndex) + ", " + SNUM(parameterValue) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((parameterIndex < 0) || (static_cast(parameterIndex) >= parameterPointer_.size())) { LOG_ERROR("Invalid parameter index, " + SNUM(parameterIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterDataType_[parameterIndex] != DATA_TYPE::Integer) { LOG_ERROR("Data type of parameter is not Integer."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((arrayIndex < 0) || (arrayIndex >= parameterExtent_[parameterIndex])) { LOG_ERROR("Invalid parameter arrayIndex, " + SNUM(arrayIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif reinterpret_cast(parameterPointer_[parameterIndex])[arrayIndex] = parameterValue; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::SetParameter(int const parameterIndex, int const arrayIndex, double const parameterValue) { #if DEBUG_VERBOSITY std::string const callString = "SetParameter(" + SNUM(parameterIndex) + ", " + SNUM(arrayIndex) + ", " + SNUM(parameterValue) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((parameterIndex < 0) || (static_cast(parameterIndex) >= parameterPointer_.size())) { LOG_ERROR("Invalid parameter index, " + SNUM(parameterIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterDataType_[parameterIndex] != DATA_TYPE::Double) { LOG_ERROR("Data type of parameter is not Double."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((arrayIndex < 0) || (arrayIndex >= parameterExtent_[parameterIndex])) { LOG_ERROR("Invalid parameter arrayIndex, " + SNUM(arrayIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif reinterpret_cast(parameterPointer_[parameterIndex])[arrayIndex] = parameterValue; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::Compute( ComputeArguments const * const computeArguments) const { #if DEBUG_VERBOSITY std::string const callString = "Compute(" + SPTR(computeArguments) + ")."; #endif LOG_DEBUG("Enter " + callString); // Check that computeArguments is for this model if (modelName_ != computeArguments->pimpl->modelName_) { LOG_ERROR("ComputeArguments object for Model '" + computeArguments->pimpl->modelName_ + "' cannot be used with the " "ModelCompute() routine of Model '" + modelName_ + "'."); LOG_DEBUG("Exit 1=" + callString); return true; } // Check that computeArguments is ready... #if ERROR_VERBOSITY int isReady; computeArguments->AreAllRequiredArgumentsAndCallbacksPresent(&isReady); if (!isReady) { LOG_ERROR("Not all required ComputeArguments and ComputeCallbacks " "are present in ComputeArguments object."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif // Set cutoffs data within computeArguments computeArguments->pimpl->inModelComputeRoutine_ = true; computeArguments->pimpl->numberOfNeighborLists_ = numberOfNeighborLists_; computeArguments->pimpl->cutoffs_ = cutoffs_; // Resize computeArguments storage if needed if (simulatorNumbering_ != modelNumbering_) { computeArguments->pimpl->getNeighborListStorage_.resize( numberOfNeighborLists_); } // Call the Model supplied compute routine int error = ModelCompute(computeArguments); // Unset cutoffs data within computeArguments computeArguments->pimpl->inModelComputeRoutine_ = false; computeArguments->pimpl->numberOfNeighborLists_ = 0; computeArguments->pimpl->cutoffs_ = NULL; if (error) { LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } void ModelImplementation::GetExtensionID( std::string const ** const extensionID) const { *extensionID = &extensionID_; } int ModelImplementation::Extension(std::string const & extensionID, void * const extensionStructure) { #if DEBUG_VERBOSITY std::string const callString = "Extension(\"" + extensionID + "\", " + SPTR(extensionStructure) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int present = false; IsRoutinePresent(KIM::MODEL_ROUTINE_NAME::Extension, &present, NULL); if (!present) { LOG_ERROR("The Model does not provide the Extension routine."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif extensionID_ = extensionID; int error = ModelExtension(extensionStructure); extensionID_ = ""; if (error) { LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ClearThenRefresh() { #if DEBUG_VERBOSITY std::string const callString = "ClearThenRefresh()."; #endif LOG_DEBUG("Enter " + callString); if (parameterPointer_.size() == 0) { LOG_ERROR("ClearThenRefresh() called but no parameter pointers have been " "set (and no Refresh routine has been provided)."); LOG_DEBUG("Exit 1=" + callString); return true; } influenceDistance_ = NULL; numberOfNeighborLists_ = 0; cutoffs_ = NULL; modelWillNotRequestNeighborsOfNoncontributingParticles_ = NULL; // Call Model supplied Refresh routine int error = ModelRefresh(); if (error) { LOG_DEBUG("Exit 1=" + callString); return true; } else { #if ERROR_VERBOSITY // error checking if (influenceDistance_ == NULL) { LOG_ERROR("Model supplied Refresh() routine did not set " "influenceDistance."); LOG_DEBUG("Exit 1=" + callString); return true; } if (numberOfNeighborLists_ < 1) { LOG_ERROR("Number of neighbor lists, " + SNUM(numberOfNeighborLists_) + ", must be >= 1."); LOG_DEBUG("Exit 1=" + callString); return true; } if (cutoffs_ == NULL) { LOG_ERROR("Model supplied Refresh() routine did not " "set cutoffs."); LOG_DEBUG("Exit 1=" + callString); return true; } double maxCutoff = 0.0; for (int i = 0; i < numberOfNeighborLists_; ++i) { if (maxCutoff < cutoffs_[i]) maxCutoff = cutoffs_[i]; } if (maxCutoff > *influenceDistance_) { LOG_ERROR("Model max(cutoffs) > influenceDistance."); LOG_DEBUG("Exit 1=" + callString); return true; } if (modelWillNotRequestNeighborsOfNoncontributingParticles_ == NULL) { LOG_ERROR("Model supplied Refresh() routine did not " "set modelWillNotRequestNeighborsOfNoncontributingParticles."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif LOG_DEBUG("Exit 0=" + callString); return false; } } void ModelImplementation::GetPath(std::string const ** const path) const { *path = &writePath_; } void ModelImplementation::GetModelName( std::string const ** const modelName) const { *modelName = &writeModelName_; } int ModelImplementation::WriteParameterizedModel( std::string const & path, std::string const & modelName) const { #if DEBUG_VERBOSITY std::string const callString = "WriteParameterizedModel(\"" + path + "\", \"" + modelName + "\")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (modelDriverName_ == "") { LOG_ERROR("Only parameterized models can implement the " "WritePrameterizedModel() routine."); LOG_DEBUG("Exit 1=" + callString); return true; } int present = false; IsRoutinePresent( KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel, &present, NULL); if (!present) { LOG_ERROR( "The Model does not provide the WriteParameterizedModel routine."); LOG_DEBUG("Exit 1=" + callString); return true; } if (!IsCIdentifier(modelName)) { LOG_ERROR("modelName '" + modelName + "' is not a valid C identifier."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif cmakelists_.str(""); cmakelists_ << "# CMakeLists.txt -- auto-generated by " "KIM::Model::WriteParameterizedModel()\n" "\n" "cmake_minimum_required(VERSION 3.10)\n" "list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR})\n" "find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG)\n" << "\n" << "kim_api_items_setup_before_project(ITEM_TYPE \"portableModel\")\n" << "project(" << modelName << ")\n" << "kim_api_items_setup_after_project(ITEM_TYPE \"portableModel\")\n" << "\n" "add_kim_api_model_library(\n" " NAME ${PROJECT_NAME}\n" << " DRIVER_NAME \"" << modelDriverName_ << "\"\n" << " PARAMETER_FILES\n"; writePath_ = path; writeModelName_ = modelName; int error = ModelWriteParameterizedModel(); if (error) { LOG_ERROR( "Model supplied WriteParameterizedModel() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } cmakelists_ << " )\n"; std::ofstream cmakeFile((path + "/CMakeLists.txt").c_str(), std::ios::out | std::ios::trunc); if (cmakeFile.is_open()) { cmakeFile << cmakelists_.str(); cmakeFile.close(); } else { LOG_ERROR("Unable to open CMakeLists.txt file for write."); LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Exit 0=" + callString); return false; } void ModelImplementation::SetModelBufferPointer(void * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetModelBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); modelBuffer_ = ptr; LOG_DEBUG("Exit " + callString); } void ModelImplementation::GetModelBufferPointer(void ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetModelBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); *ptr = modelBuffer_; LOG_DEBUG("Exit " + callString); } void ModelImplementation::SetSimulatorBufferPointer(void * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetSimulatorBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); simulatorBuffer_ = ptr; LOG_DEBUG("Exit " + callString); } void ModelImplementation::GetSimulatorBufferPointer(void ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); *ptr = simulatorBuffer_; LOG_DEBUG("Exit " + callString); } namespace { typedef std::map LengthMap; LengthMap const GetLengthMap() { LengthMap mm; mm[LENGTH_UNIT::A] = 1.0e-10; mm[LENGTH_UNIT::Bohr] = 5.291772109217171e-11; mm[LENGTH_UNIT::cm] = 1.0e-2; mm[LENGTH_UNIT::m] = 1.0; mm[LENGTH_UNIT::nm] = 1.0e-9; return mm; } typedef std::map EnergyMap; EnergyMap const GetEnergyMap() { EnergyMap m; m[ENERGY_UNIT::amu_A2_per_ps2] = 1.66053886e-23; m[ENERGY_UNIT::erg] = 1.0e7; m[ENERGY_UNIT::eV] = 1.60217646e-19; m[ENERGY_UNIT::Hartree] = 4.3597439422e-18; m[ENERGY_UNIT::J] = 1.0; m[ENERGY_UNIT::kcal_mol] = 6.9477e-21; return m; } typedef std::map ChargeMap; ChargeMap const GetChargeMap() { ChargeMap m; m[CHARGE_UNIT::C] = 1.0; m[CHARGE_UNIT::e] = 1.602e-19; m[CHARGE_UNIT::statC] = 2.99792458e-9; return m; } typedef std::map TemperatureMap; TemperatureMap const GetTemperatureMap() { TemperatureMap m; m[TEMPERATURE_UNIT::K] = 1.0; return m; } typedef std::map TimeMap; TimeMap const GetTimeMap() { TimeMap m; m[TIME_UNIT::fs] = 1.0e-15; m[TIME_UNIT::ps] = 1.0e-12; m[TIME_UNIT::ns] = 1.0e-9; m[TIME_UNIT::s] = 1.0; return m; } } // namespace int ModelImplementation::ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor) { // No debug logging for ConvertUnit: no log object available // // #if DEBUG_VERBOSITY // std::string const callString = "ConvertUnit(" // + fromLengthUnit.ToString() + ", " // + fromEnergyUnit.ToString() + ", " // + fromChargeUnit.ToString() + ", " // + fromTemperatureUnit.ToString() + ", " // + fromTimeUnit.ToString() + ", " // + toLengthUnit.ToString() + ", " // + toEnergyUnit.ToString() + ", " // + toChargeUnit.ToString() + ", " // + toTemperatureUnit.ToString() + ", " // + toTimeUnit.ToString() + ", " // + SNUM(lengthExponent) + ", " // + SNUM(energyExponent) + ", " // + SNUM(chargeExponent) + ", " // + SNUM(temperatureExponent) + ", " // + SNUM(timeExponent) + ", " // + SPTR(conversionFactor) + ")."; // #endif // LOG_DEBUG("Enter " + callString); static LengthMap const lengthConvertToSI = GetLengthMap(); static EnergyMap const energyConvertToSI = GetEnergyMap(); static ChargeMap const chargeConvertToSI = GetChargeMap(); static TemperatureMap const temperatureConvertToSI = GetTemperatureMap(); static TimeMap const timeConvertToSI = GetTimeMap(); #if ERROR_VERBOSITY int error = (!fromLengthUnit.Known()) || (!fromEnergyUnit.Known()) || (!fromChargeUnit.Known()) || (!fromTemperatureUnit.Known()) || (!fromTimeUnit.Known()) || (!toLengthUnit.Known()) || (!toEnergyUnit.Known()) || (!toChargeUnit.Known()) || (!toTemperatureUnit.Known()) || (!toTimeUnit.Known()); if (error) { // LOG_ERROR("Invalid arguments."); // LOG_DEBUG("Exit 1=" + callString); return true; } #endif bool lengthUnused = ((fromLengthUnit == KIM::LENGTH_UNIT::unused) || (toLengthUnit == KIM::LENGTH_UNIT::unused)); if ((lengthExponent != 0.0) && lengthUnused) { // LOG_ERROR("Unable to convert unit."); // LOG_DEBUG("Exit 1=" + callString); return true; } double const lengthConversion = (lengthUnused) ? 1 : (lengthConvertToSI.find(fromLengthUnit)->second / lengthConvertToSI.find(toLengthUnit)->second); bool energyUnused = ((fromEnergyUnit == KIM::ENERGY_UNIT::unused) || (toEnergyUnit == KIM::ENERGY_UNIT::unused)); if ((energyExponent != 0.0) && energyUnused) { // LOG_ERROR("Unable to convert unit."); // LOG_DEBUG("Exit 1=" + callString); return true; } double const energyConversion = (energyUnused) ? 1 : (energyConvertToSI.find(fromEnergyUnit)->second / energyConvertToSI.find(toEnergyUnit)->second); bool chargeUnused = ((fromChargeUnit == KIM::CHARGE_UNIT::unused) || (toChargeUnit == KIM::CHARGE_UNIT::unused)); if ((chargeExponent != 0.0) && chargeUnused) { // LOG_ERROR("Unable to convert unit."); // LOG_DEBUG("Exit 1=" + callString); return true; } double const chargeConversion = (chargeUnused) ? 1 : (chargeConvertToSI.find(fromChargeUnit)->second / chargeConvertToSI.find(toChargeUnit)->second); bool temperatureUnused = ((fromTemperatureUnit == KIM::TEMPERATURE_UNIT::unused) || (toTemperatureUnit == KIM::TEMPERATURE_UNIT::unused)); if ((temperatureExponent != 0.0) && temperatureUnused) { // LOG_ERROR("Unable to convert unit."); // LOG_DEBUG("Exit 1=" + callString); return true; } double const temperatureConversion = (temperatureUnused) ? 1 : (temperatureConvertToSI.find(fromTemperatureUnit)->second / temperatureConvertToSI.find(toTemperatureUnit)->second); bool timeUnused = ((fromTimeUnit == KIM::TIME_UNIT::unused) || (toTimeUnit == KIM::TIME_UNIT::unused)); if ((timeExponent != 0.0) && timeUnused) { // LOG_ERROR("Unable to convert unit."); // LOG_DEBUG("Exit 1=" + callString); return true; } double const timeConversion = (timeUnused) ? 1 : (timeConvertToSI.find(fromTimeUnit)->second / timeConvertToSI.find(toTimeUnit)->second); *conversionFactor = pow(lengthConversion, lengthExponent) * pow(energyConversion, energyExponent) * pow(chargeConversion, chargeExponent) * pow(temperatureConversion, temperatureExponent) * pow(timeConversion, timeExponent); // LOG_DEBUG("Exit 0=" + callString); return false; } void ModelImplementation::SetLogID(std::string const & logID) { #if DEBUG_VERBOSITY std::string const callString = "SetLogID('" + logID + "')."; #endif LOG_DEBUG("Enter " + callString); log_->SetID(logID); LOG_DEBUG("Exit " + callString); } void ModelImplementation::PushLogVerbosity(LogVerbosity const logVerbosity) { #if DEBUG_VERBOSITY std::string const callString = "PushLogVerbosity(" + logVerbosity.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); log_->PushVerbosity(logVerbosity); LOG_DEBUG("Exit " + callString); } void ModelImplementation::PopLogVerbosity() { #if DEBUG_VERBOSITY std::string const callString = "PopLogVerbosity()."; #endif LOG_DEBUG("Enter " + callString); log_->PopVerbosity(); LOG_DEBUG("Exit " + callString); } void ModelImplementation::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelImplementation::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelImplementation::ToString() const { #if DEBUG_VERBOSITY std::string const callString = "ToString()."; #endif LOG_DEBUG("Enter " + callString); std::stringstream ss; ss << std::setprecision(10) << std::scientific << std::left; ss << "=====================================================================" "===========\n\n"; ss << "Model object\n" << "------------\n\n"; ss << "Model Name : " << modelName_ << "\n"; if (modelDriverName_ != "") { ss << "Model Driver Name : " << modelDriverName_ << "\n"; } ss << "Log ID : " << log_->GetID() << "\n"; ss << "\n"; ss << "Model Supplied Routines :\n" << "\t" << std::setw(25) << "Routine Name" << std::setw(10) << "Language" << std::setw(10) << "Required" << std::setw(25) << "Pointer (1-set / 0-unset)" << "\n" << "\t" << std::setw(25) << "-------------------------" << std::setw(10) << "----------" << std::setw(10) << "----------" << std::setw(25) << "-------------------------" << "\n\n"; int numberOfModelRoutineNames; MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames(&numberOfModelRoutineNames); for (int i = 0; i < numberOfModelRoutineNames; ++i) { ModelRoutineName modelRoutineName; MODEL_ROUTINE_NAME::GetModelRoutineName(i, &modelRoutineName); std::map::const_iterator langResult = routineLanguage_.find(modelRoutineName); std::map:: const_iterator requiredResult = routineRequired_.find(modelRoutineName); std::map::const_iterator fptrResult = routineFunction_.find(modelRoutineName); ss << "\t" << std::setw(25) << modelRoutineName.ToString() << std::setw(10) << langResult->second.ToString() << std::setw(10) << requiredResult->second << std::setw(25) << SFUNC(fptrResult->second) << "\n"; } ss << "\n"; ss << "Numbering : " << modelNumbering_.ToString() << "\n\n"; ss << "Units : \n" "\tLength Unit : " << lengthUnit_.ToString() << "\n" "\tEnergy Unit : " << energyUnit_.ToString() << "\n" "\tCharge Unit : " << chargeUnit_.ToString() << "\n" "\tTemperature Unit : " << temperatureUnit_.ToString() << "\n" "\tTime Unit : " << timeUnit_.ToString() << "\n\n"; if (influenceDistance_ == NULL) ss << "Influence Distance : " << "NULL" << "\n\n"; else ss << "Influence Distance : " << *influenceDistance_ << "\n\n"; ss << "Number Of Neighbor Lists : " << numberOfNeighborLists_ << "\n"; ss << "Neighbor List Cutoffs :\n"; ss << "\t" << "index" << " : " << std::setw(20) << "cutoff distance" << std::setw(40) << "modelWillNotRequestNeighborsOfNoncontributingParticles" << "\n"; ss << "\t" << "-----" << "---" << std::setw(20) << "--------------------" << std::setw(40) << "----------------------------------------" << "\n\n"; for (int i = 0; i < numberOfNeighborLists_; ++i) { ss << "\t" << std::setw(5) << i << " : " << std::setw(20) << cutoffs_[i] << std::setw(40) << modelWillNotRequestNeighborsOfNoncontributingParticles_[i] << "\n"; } ss << "\n\n"; ss << "Supported Species :\n"; int const specWidth = 10; ss << "\t" << std::setw(specWidth) << "Species" << std::setw(specWidth) << "Code" << "\n"; ss << "\t" << std::setw(specWidth) << "----------" << std::setw(specWidth) << "----------" << "\n\n"; for (std::map:: const_iterator spec = supportedSpecies_.begin(); spec != supportedSpecies_.end(); ++spec) { ss << "\t" << std::setw(specWidth) << (spec->first).ToString() << std::setw(specWidth) << spec->second << "\n"; } ss << "\n"; int numberOfParameters = parameterPointer_.size(); ss << "Number Of Parameters : " << numberOfParameters << "\n"; ss << "\t" << std::setw(8) << "index" << std::setw(10) << "Data Type" << std::setw(10) << "Extent" << std::setw(15) << "Pointer" << "Name" << "\n"; ss << "\t" << std::setw(8) << "--------" << std::setw(10) << "----------" << std::setw(10) << "----------" << std::setw(15) << "---------------" << "-------------------------" << "\n\n"; for (int i = 0; i < numberOfParameters; ++i) { ss << "\t" << std::setw(8) << i << std::setw(10) << parameterDataType_[i].ToString() << std::setw(10) << parameterExtent_[i] << std::setw(15) << SPTR(parameterPointer_[i]) << parameterName_[i] << "\n"; } ss << "\n"; ss << "Buffers\n"; ss << "\t" << std::setw(15) << "Buffer" << std::setw(15) << "Pointer" << "\n"; ss << "\t" << std::setw(15) << "---------------" << std::setw(15) << "---------------" << "\n\n"; ss << "\t" << std::setw(15) << "Model" << std::setw(15) << SPTR(modelBuffer_) << "\n" << "\t" << std::setw(15) << "Simulator" << std::setw(15) << SPTR(simulatorBuffer_) << "\n\n"; ss << "====================================================================" "============\n"; string_ = ss.str(); LOG_DEBUG("Exit " + callString); return string_; } ModelImplementation::ModelImplementation(SharedLibrary * const sharedLibrary, Log * const log) : modelName_(""), modelDriverName_(""), sharedLibrary_(sharedLibrary), numberOfParameterFiles_(0), log_(log), numberingHasBeenSet_(false), modelNumbering_(NUMBERING::zeroBased), simulatorNumbering_(NUMBERING::zeroBased), numberingOffset_(0), unitsHaveBeenSet_(false), lengthUnit_(LENGTH_UNIT::unused), energyUnit_(ENERGY_UNIT::unused), chargeUnit_(CHARGE_UNIT::unused), temperatureUnit_(TEMPERATURE_UNIT::unused), timeUnit_(TIME_UNIT::unused), influenceDistance_(NULL), numberOfNeighborLists_(0), cutoffs_(NULL), modelWillNotRequestNeighborsOfNoncontributingParticles_(NULL), modelBuffer_(NULL), simulatorBuffer_(NULL), string_("") { #if DEBUG_VERBOSITY std::string const callString = "ModelImplementation(" + SPTR(sharedLibrary) + ", " + SPTR(log) + ")."; #endif LOG_DEBUG("Enter " + callString); // populate default values for // routineLanguage, routineRequired, routineFunction int numberOfModelRoutineNames; MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames(&numberOfModelRoutineNames); for (int i = 0; i < numberOfModelRoutineNames; ++i) { ModelRoutineName modelRoutineName; MODEL_ROUTINE_NAME::GetModelRoutineName(i, &modelRoutineName); routineLanguage_[modelRoutineName] = LANGUAGE_NAME::cpp; routineRequired_[modelRoutineName] = false; routineFunction_[modelRoutineName] = NULL; } LOG_DEBUG("Exit " + callString); } ModelImplementation::~ModelImplementation() { #if DEBUG_VERBOSITY std::string const callString = "~ModelImplementation()."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibrary_->IsOpen()) sharedLibrary_->Close(); delete sharedLibrary_; LOG_DEBUG("Destroying Log object and exit " + callString); Log::Destroy(&log_); } int ModelImplementation::ModelCreate( Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const & modelName) { #if DEBUG_VERBOSITY std::string const callString = "ModelCreate(" + numbering.ToString() + ", " + requestedLengthUnit.ToString() + ", " + requestedEnergyUnit.ToString() + ", " + requestedChargeUnit.ToString() + ", " + requestedTemperatureUnit.ToString() + ", " + requestedTimeUnit.ToString() + ", '" + modelName + "')."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!numbering.Known()) || (!requestedLengthUnit.Known()) || (!requestedEnergyUnit.Known()) || (!requestedChargeUnit.Known()) || (!requestedTemperatureUnit.Known()) || (!requestedTimeUnit.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif modelName_ = modelName; error = SetSimulatorNumbering(numbering); if (error) { LOG_ERROR("Could not set simulator numbering."); LOG_DEBUG("Exit 1=" + callString); return true; } std::string const * itemFilePath; Collections * collections; error = Collections::Create(&collections); if (error) { LOG_ERROR("Could not create Collections object."); LOG_DEBUG("Exit 1=" + callString); return true; } collections->SetLogID(log_->GetID() + "_Collections"); error = collections->GetItemLibraryFileNameAndCollection( COLLECTION_ITEM_TYPE::portableModel, modelName, &itemFilePath, NULL); if (error) { LOG_ERROR("Could not find model shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } error = sharedLibrary_->Open(*itemFilePath); if (error) { LOG_ERROR("Could not open model shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } // get driver name error = sharedLibrary_->GetDriverName(&modelDriverName_); if (error) { LOG_ERROR("Could not get Model Driver name."); LOG_DEBUG("Exit 1=" + callString); return true; } CollectionItemType itemType; error = sharedLibrary_->GetType(&itemType); { using namespace COLLECTION_ITEM_TYPE; if ((itemType == portableModel) && (modelDriverName_ == "")) { LOG_DEBUG("Initializing a stand alone model."); error = InitializeStandAloneModel(requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit); if (error) { LOG_ERROR("Initialization of Stand Alone model returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (itemType == portableModel) { LOG_DEBUG("Initializing a parameterized model."); error = InitializeParameterizedModel(requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, collections); if (error) { LOG_ERROR("Initialization of Parameterized Model returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (itemType == modelDriver) { LOG_ERROR("Creation of a model driver is not allowed."); LOG_DEBUG("Exit 1=" + callString); return true; } else if (itemType == simulatorModel) { LOG_ERROR("Creation of a simulator model is not allowed."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_ERROR("Creation of an unknown model type is not allowed."); LOG_DEBUG("Exit 1=" + callString); return true; } } Collections::Destroy(&collections); #if ERROR_VERBOSITY // Error checking // no need to check parameters if (!numberingHasBeenSet_) { LOG_ERROR("Model supplied Create() routine did not set numbering."); LOG_DEBUG("Exit 1=" + callString); return true; } if (!unitsHaveBeenSet_) { LOG_ERROR("Model supplied Create() routine did not set units."); LOG_DEBUG("Exit 1=" + callString); return true; } if (influenceDistance_ == NULL) { LOG_ERROR("Model supplied Create() routine did not set " "influenceDistance."); LOG_DEBUG("Exit 1=" + callString); return true; } if (numberOfNeighborLists_ < 1) { LOG_ERROR("Model supplied Create() routine did not set " "valid numberOfNeighborLists, must be >= 1."); LOG_DEBUG("Exit 1=" + callString); return true; } if (cutoffs_ == NULL) { LOG_ERROR("Model supplied Create() routine did not set " "cutoffs."); LOG_DEBUG("Exit 1=" + callString); return true; } double maxCutoff = 0.0; for (int i = 0; i < numberOfNeighborLists_; ++i) { if (maxCutoff < cutoffs_[i]) maxCutoff = cutoffs_[i]; } if (maxCutoff > *influenceDistance_) { LOG_ERROR("Model max(cutoffs) > influenceDistance."); LOG_DEBUG("Exit 1=" + callString); return true; } if (modelWillNotRequestNeighborsOfNoncontributingParticles_ == NULL) { LOG_ERROR("Model supplied Create() routine did not set " "modelWillNotRequestNeighborsOfNoncontributingParticles."); LOG_DEBUG("Exit 1=" + callString); return true; } { using namespace KIM::MODEL_ROUTINE_NAME; for (unsigned int i = 0; i < requiredByAPI_ModelRoutines.size(); ++i) { ModelRoutineName const modelRoutineName = requiredByAPI_ModelRoutines.at(i); std::map::const_iterator funcResult = routineFunction_.find(modelRoutineName); if (funcResult->second == NULL) { LOG_ERROR("Model supplied Create() routine did not set pointer for " + modelRoutineName.ToString() + "."); LOG_DEBUG("Exit 1=" + callString); return true; } } } if (parameterPointer_.size() > 0) { if (routineFunction_[MODEL_ROUTINE_NAME::Refresh] == NULL) { // Must be provided if parameter pointers set LOG_ERROR("Model supplied Create() routine did not set pointer for " + MODEL_ROUTINE_NAME::Refresh.ToString() + "."); LOG_DEBUG("Exit 1=" + callString); return true; } } else { if (routineFunction_[MODEL_ROUTINE_NAME::Refresh] != NULL) { // Must not be provided if no parameters set LOG_ERROR("Model supplied Create() routine set pointer for " + MODEL_ROUTINE_NAME::Refresh.ToString() + " but did not " "set parameter pointer(s)."); LOG_DEBUG("Exit 1=" + callString); return true; } if (routineFunction_[MODEL_ROUTINE_NAME::WriteParameterizedModel] != NULL) { // Must not be provided if no parameters set LOG_ERROR("Model supplied Create() routine set pointer for " + MODEL_ROUTINE_NAME::WriteParameterizedModel.ToString() + " but did not " "set parameter pointer(s)."); LOG_DEBUG("Exit 1=" + callString); return true; } } if (supportedSpecies_.empty()) { LOG_ERROR("Model supplied Create() routine did not set SpeciesCode."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif // set numberingOffset_ if (simulatorNumbering_ == modelNumbering_) numberingOffset_ = 0; else if (simulatorNumbering_ == NUMBERING::zeroBased) numberingOffset_ = 1; else numberingOffset_ = -1; LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::ModelDestroy() { #if DEBUG_VERBOSITY std::string const callString = "ModelDestroy()."; #endif LOG_DEBUG("Enter " + callString); std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::Destroy); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::Destroy); ModelDestroyFunction * CppDestroy = reinterpret_cast(funcResult->second); KIM_ModelDestroyFunction * CDestroy = reinterpret_cast(funcResult->second); typedef void ModelDestroyF(KIM_ModelDestroy * const, int * const); ModelDestroyF * FDestroy = reinterpret_cast(funcResult->second); int error; struct Mdl { void * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppDestroy(reinterpret_cast(&M)); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelDestroy cM; cM.p = &M; error = CDestroy(&cM); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelDestroy cM; cM.p = &M; KIM_ModelDestroy cM_Handle; cM_Handle.p = &cM; FDestroy(&cM_Handle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied Destroy() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ModelComputeArgumentsCreate( ComputeArguments * const computeArguments) const { #if DEBUG_VERBOSITY std::string const callString = "ModelComputeArgumentsCreate()."; #endif LOG_DEBUG("Enter " + callString); std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::ComputeArgumentsCreate); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::ComputeArgumentsCreate); ModelComputeArgumentsCreateFunction * CppComputeArgumentsCreate = reinterpret_cast( funcResult->second); KIM_ModelComputeArgumentsCreateFunction * CComputeArgumentsCreate = reinterpret_cast( funcResult->second); typedef void ModelComputeArgumentsCreateF( KIM_ModelCompute const * const, KIM_ModelComputeArgumentsCreate * const, int * const); ModelComputeArgumentsCreateF * FComputeArgumentsCreate = reinterpret_cast(funcResult->second); int error; struct Mdl { void const * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppComputeArgumentsCreate( reinterpret_cast(&M), reinterpret_cast(computeArguments)); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelCompute cM; cM.p = &M; KIM_ModelComputeArgumentsCreate cMcac; cMcac.p = computeArguments; error = CComputeArgumentsCreate(&cM, &cMcac); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelCompute cM; cM.p = &M; KIM_ModelCompute cM_Handle; cM_Handle.p = &cM; KIM_ModelComputeArgumentsCreate cMcac; cMcac.p = computeArguments; KIM_ModelComputeArgumentsCreate cMcac_Handle; cMcac_Handle.p = &cMcac; FComputeArgumentsCreate(&cM_Handle, &cMcac_Handle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied ComputeArgumentsCreate() routine " "returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ModelComputeArgumentsDestroy( ComputeArguments * const computeArguments) const { #if DEBUG_VERBOSITY std::string const callString = "ModelComputeArgumentsDestroy()."; #endif LOG_DEBUG("Enter " + callString); std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::ComputeArgumentsDestroy); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::ComputeArgumentsDestroy); ModelComputeArgumentsDestroyFunction * CppComputeArgumentsDestroy = reinterpret_cast( funcResult->second); KIM_ModelComputeArgumentsDestroyFunction * CComputeArgumentsDestroy = reinterpret_cast( funcResult->second); typedef void ModelComputeArgumentsDestroyF( KIM_ModelCompute const * const, KIM_ModelComputeArgumentsDestroy * const, int * const); ModelComputeArgumentsDestroyF * FComputeArgumentsDestroy = reinterpret_cast(funcResult->second); int error; struct Mdl { void const * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppComputeArgumentsDestroy( reinterpret_cast(&M), reinterpret_cast( computeArguments)); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelCompute cM; cM.p = &M; KIM_ModelComputeArgumentsDestroy cMcad; cMcad.p = computeArguments; error = CComputeArgumentsDestroy(&cM, &cMcad); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelCompute cM; cM.p = &M; KIM_ModelCompute cM_Handle; cM_Handle.p = &cM; KIM_ModelComputeArgumentsDestroy cMcad; cMcad.p = computeArguments; KIM_ModelComputeArgumentsDestroy cMcad_Handle; cMcad_Handle.p = &cMcad; FComputeArgumentsDestroy(&cM_Handle, &cMcad_Handle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied ComputeArgumentsDestroy() routine " "returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ModelCompute( ComputeArguments const * const computeArguments) const { #if DEBUG_VERBOSITY std::string const callString = "ModelCompute(" + SPTR(computeArguments) + ")."; #endif LOG_DEBUG("Enter " + callString); std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::Compute); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::Compute); ModelComputeFunction * CppCompute = reinterpret_cast(funcResult->second); KIM_ModelComputeFunction * CCompute = reinterpret_cast(funcResult->second); typedef void ModelComputeF(KIM_ModelCompute * const, KIM_ModelComputeArguments const * const, int * const); ModelComputeF * FCompute = reinterpret_cast(funcResult->second); int error; struct Mdl { void const * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppCompute( reinterpret_cast(&M), reinterpret_cast(computeArguments)); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelCompute cM; cM.p = &M; KIM_ModelComputeArguments cMca; cMca.p = reinterpret_cast( const_cast(computeArguments)); error = CCompute(&cM, &cMca); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelCompute cM; cM.p = &M; KIM_ModelCompute cM_Handle; cM_Handle.p = &cM; KIM_ModelComputeArguments cMca; cMca.p = reinterpret_cast( const_cast(computeArguments)); KIM_ModelComputeArguments cMca_Handle; cMca_Handle.p = &cMca; FCompute(&cM_Handle, &cMca_Handle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied Compute() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ModelExtension(void * const extensionStructure) { #if DEBUG_VERBOSITY std::string const callString = "ModelExtension(" + SPTR(extensionStructure) + ")."; #endif LOG_DEBUG("Enter " + callString); std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::Extension); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::Extension); ModelExtensionFunction * CppExtension = reinterpret_cast(funcResult->second); KIM_ModelExtensionFunction * CExtension = reinterpret_cast(funcResult->second); typedef void ModelExtensionF( KIM_ModelExtension * const, void * const, int * const); ModelExtensionF * FExtension = reinterpret_cast(funcResult->second); int error; struct Mdl { void * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppExtension(reinterpret_cast(&M), extensionStructure); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelExtension cM; cM.p = &M; error = CExtension(&cM, extensionStructure); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelExtension cM; cM.p = &M; KIM_ModelExtension cM_Handle; cM_Handle.p = &cM; FExtension(&cM_Handle, extensionStructure, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied Extension() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ModelRefresh() { #if DEBUG_VERBOSITY std::string const callString = "ModelRefresh()."; #endif LOG_DEBUG("Enter " + callString); if (parameterPointer_.size() == 0) { LOG_ERROR("Model does not have any adjustable parameters. " "No Refresh() function available."); LOG_DEBUG("Exit 1=" + callString); return true; } std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::Refresh); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::Refresh); ModelRefreshFunction * CppRefresh = reinterpret_cast(funcResult->second); KIM_ModelRefreshFunction * CRefresh = reinterpret_cast(funcResult->second); typedef void ModelRefreshF(KIM_ModelRefresh * const, int * const); ModelRefreshF * FRefresh = reinterpret_cast(funcResult->second); int error; struct Mdl { void * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppRefresh(reinterpret_cast(&M)); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelRefresh cM; cM.p = &M; error = CRefresh(&cM); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelRefresh cM; cM.p = &M; KIM_ModelRefresh cM_Handle; cM_Handle.p = &cM; FRefresh(&cM_Handle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied Refresh() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::ModelWriteParameterizedModel() const { #if DEBUG_VERBOSITY std::string const callString = "ModelWriteParameterizedModel()."; #endif LOG_DEBUG("Enter " + callString); std::map:: const_iterator funcResult = routineFunction_.find(MODEL_ROUTINE_NAME::WriteParameterizedModel); std::map::const_iterator langResult = routineLanguage_.find(MODEL_ROUTINE_NAME::WriteParameterizedModel); ModelWriteParameterizedModelFunction * CppWriteParameterizedModel = reinterpret_cast( funcResult->second); KIM_ModelWriteParameterizedModelFunction * CWriteParameterizedModel = reinterpret_cast( funcResult->second); typedef void ModelWriteParameterizedModelF( KIM_ModelWriteParameterizedModel * const, int * const); ModelWriteParameterizedModelF * FWriteParameterizedModel = reinterpret_cast(funcResult->second); int error; struct Mdl { void const * p; }; Mdl M; M.p = this; if (langResult->second == LANGUAGE_NAME::cpp) { error = CppWriteParameterizedModel( reinterpret_cast(&M)); } else if (langResult->second == LANGUAGE_NAME::c) { KIM_ModelWriteParameterizedModel cM; cM.p = &M; error = CWriteParameterizedModel(&cM); } else if (langResult->second == LANGUAGE_NAME::fortran) { KIM_ModelWriteParameterizedModel cM; cM.p = &M; KIM_ModelWriteParameterizedModel cM_Handle; cM_Handle.p = &cM; FWriteParameterizedModel(&cM_Handle, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR( "Model supplied WriteParameterizedModel() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::InitializeStandAloneModel( LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit) { #if DEBUG_VERBOSITY std::string const callString = "InitializeStandAloneModel(" + requestedLengthUnit.ToString() + ", " + requestedEnergyUnit.ToString() + ", " + requestedChargeUnit.ToString() + ", " + requestedTemperatureUnit.ToString() + ", " + requestedTimeUnit.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY int error = (!requestedLengthUnit.Known()) || (!requestedEnergyUnit.Known()) || (!requestedChargeUnit.Known()) || (!requestedTemperatureUnit.Known()) || (!requestedTimeUnit.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif LanguageName languageName; Function * functionPointer = NULL; error = sharedLibrary_->GetCreateFunctionPointer(&languageName, &functionPointer); if (error) { LOG_ERROR("Could not get ModelCreateFunctionPointer."); LOG_DEBUG("Exit 1=" + callString); return true; } routineLanguage_[MODEL_ROUTINE_NAME::Create] = languageName; routineRequired_[MODEL_ROUTINE_NAME::Create] = true; routineFunction_[MODEL_ROUTINE_NAME::Create] = functionPointer; ModelCreateFunction * CppCreate = reinterpret_cast(functionPointer); KIM_ModelCreateFunction * CCreate = reinterpret_cast(functionPointer); typedef void ModelCreateF(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit, int * const ierr); ModelCreateF * FCreate = reinterpret_cast(functionPointer); struct Mdl { void * p; }; Mdl M; M.p = this; KIM_LengthUnit requestedLengthUnitC = makeLengthUnitC(requestedLengthUnit); KIM_EnergyUnit requestedEnergyUnitC = makeEnergyUnitC(requestedEnergyUnit); KIM_ChargeUnit requestedChargeUnitC = makeChargeUnitC(requestedChargeUnit); KIM_TemperatureUnit requestedTemperatureUnitC = makeTemperatureUnitC(requestedTemperatureUnit); KIM_TimeUnit requestedTimeUnitC = makeTimeUnitC(requestedTimeUnit); if (languageName == LANGUAGE_NAME::cpp) { error = CppCreate(reinterpret_cast(&M), requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit); } else if (languageName == LANGUAGE_NAME::c) { KIM_ModelCreate cM; cM.p = &M; error = CCreate(&cM, requestedLengthUnitC, requestedEnergyUnitC, requestedChargeUnitC, requestedTemperatureUnitC, requestedTimeUnitC); } else if (languageName == LANGUAGE_NAME::fortran) { KIM_ModelCreate cM; cM.p = &M; KIM_ModelCreate cM_Handle; cM_Handle.p = &cM; FCreate(&cM_Handle, requestedLengthUnitC, requestedEnergyUnitC, requestedChargeUnitC, requestedTemperatureUnitC, requestedTimeUnitC, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model supplied Create() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_DEBUG("Exit 0=" + callString); return false; } } int ModelImplementation::InitializeParameterizedModel( LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, Collections * collections) { #if DEBUG_VERBOSITY std::string const callString = "InitializeParameterizedModel(" + requestedLengthUnit.ToString() + ", " + requestedEnergyUnit.ToString() + ", " + requestedChargeUnit.ToString() + ", " + requestedTemperatureUnit.ToString() + ", " + requestedTimeUnit.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); int error; #if ERROR_VERBOSITY error = (!requestedLengthUnit.Known()) || (!requestedEnergyUnit.Known()) || (!requestedChargeUnit.Known()) || (!requestedTemperatureUnit.Known()) || (!requestedTimeUnit.Known()); if (error) { LOG_ERROR("Invalid arguments."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif // write parameter files to scratch space error = sharedLibrary_->WriteParameterFileDirectory() || sharedLibrary_->GetParameterFileDirectoryName( ¶meterFileDirectoryName_) || sharedLibrary_->GetNumberOfParameterFiles(&numberOfParameterFiles_); parameterFileDirectoryNameString_ = parameterFileDirectoryName_.string(); for (int i = 0; i < numberOfParameterFiles_; ++i) { std::string parameterFileName; error = error || sharedLibrary_->GetParameterFile( i, ¶meterFileName, NULL, NULL); parameterFileBasenames_.push_back(parameterFileName.c_str()); FILESYSTEM::Path parameterFilePath = parameterFileDirectoryName_ / parameterFileName; parameterFileNames_.push_back(parameterFilePath.string()); } if (error) { LOG_ERROR("Could not write parameter files to scratch space."); LOG_DEBUG("Exit 1=" + callString); return true; } // create and open driver library SharedLibrary * parameterizedModelLibrary = sharedLibrary_; sharedLibrary_ = new SharedLibrary(log_); std::string const * itemFilePath; error = collections->GetItemLibraryFileNameAndCollection( COLLECTION_ITEM_TYPE::modelDriver, modelDriverName_, &itemFilePath, NULL); if (error) { LOG_ERROR("Could not find model driver shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } error = sharedLibrary_->Open(*itemFilePath); if (error) { LOG_ERROR("Could not open model driver shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } // check that it is a driver CollectionItemType itemType; error = sharedLibrary_->GetType(&itemType); if ((error) || (itemType != COLLECTION_ITEM_TYPE::modelDriver)) { LOG_ERROR("Invalid model driver shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } LanguageName languageName; Function * functionPointer = NULL; error = sharedLibrary_->GetCreateFunctionPointer(&languageName, &functionPointer); if (error) { LOG_ERROR("Could not get ModelCreateFunctionPointer."); LOG_DEBUG("Exit 1=" + callString); return true; } routineLanguage_[MODEL_ROUTINE_NAME::Create] = languageName; routineRequired_[MODEL_ROUTINE_NAME::Create] = true; routineFunction_[MODEL_ROUTINE_NAME::Create] = functionPointer; ModelDriverCreateFunction * CppCreate = reinterpret_cast(functionPointer); KIM_ModelDriverCreateFunction * CCreate = reinterpret_cast(functionPointer); typedef void ModelDriverCreateF( KIM_ModelDriverCreate * const modelDriverCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit, int * const); ModelDriverCreateF * FCreate = reinterpret_cast(functionPointer); struct Mdl { void * p; }; Mdl M; M.p = this; KIM_LengthUnit requestedLengthUnitC = makeLengthUnitC(requestedLengthUnit); KIM_EnergyUnit requestedEnergyUnitC = makeEnergyUnitC(requestedEnergyUnit); KIM_ChargeUnit requestedChargeUnitC = makeChargeUnitC(requestedChargeUnit); KIM_TemperatureUnit requestedTemperatureUnitC = makeTemperatureUnitC(requestedTemperatureUnit); KIM_TimeUnit requestedTimeUnitC = makeTimeUnitC(requestedTimeUnit); if (languageName == LANGUAGE_NAME::cpp) { error = CppCreate(reinterpret_cast(&M), requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit); } else if (languageName == LANGUAGE_NAME::c) { KIM_ModelDriverCreate cM; cM.p = &M; error = CCreate(&cM, requestedLengthUnitC, requestedEnergyUnitC, requestedChargeUnitC, requestedTemperatureUnitC, requestedTimeUnitC); } else if (languageName == LANGUAGE_NAME::fortran) { KIM_ModelDriverCreate cM; cM.p = &M; KIM_ModelDriverCreate cM_Handle; cM_Handle.p = &cM; FCreate(&cM_Handle, requestedLengthUnitC, requestedEnergyUnitC, requestedChargeUnitC, requestedTemperatureUnitC, requestedTimeUnitC, &error); } else { LOG_ERROR("Unknown LanguageName. SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } if (error) { LOG_ERROR("Model Driver supplied Create() routine returned error."); LOG_DEBUG("Exit 1=" + callString); return true; } // remove parameter files parameterizedModelLibrary->RemoveParameterFileDirectory(); parameterizedModelLibrary->Close(); delete parameterizedModelLibrary; parameterizedModelLibrary = NULL; // clear out parameter file stuff numberOfParameterFiles_ = -1; parameterFileNames_.clear(); parameterFileBasenames_.clear(); LOG_DEBUG("Exit 0=" + callString); return false; } int ModelImplementation::IsCIdentifier(std::string const & id) const { std::string const numbers("0123456789"); std::string const cIdentifierChars("_" "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + numbers); if (id.length() == 0) return false; if (std::string::npos != id.find_first_not_of(cIdentifierChars)) return false; if (0 == id.find_first_of(numbers)) return false; return true; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelImplementation.hpp000066400000000000000000000272761421473465500224050ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #define KIM_MODEL_IMPLEMENTATION_HPP_ #include #include #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_DATA_TYPE_HPP_ #include "KIM_DataType.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif #ifndef KIM_UNIT_SYSTEM_HPP_ #include "KIM_UnitSystem.hpp" #endif #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif #ifndef KIM_SPECIESNAME_HPP_ #include "KIM_SpeciesName.hpp" #endif #ifndef KIM_FILESYSTEM_PATH_HPP_ #include "KIM_FilesystemPath.hpp" #endif namespace KIM { // Forward declaration class Log; class Collections; class ComputeArguments; class SharedLibrary; class ModelImplementation { public: static int Create(Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const & modelName, int * const requestedUnitsAccepted, ModelImplementation ** const modelImplementation); static void Destroy(ModelImplementation ** const modelImplementation); int IsRoutinePresent(ModelRoutineName const modelRoutineName, int * const present, int * const required) const; int ComputeArgumentsCreate(ComputeArguments ** const computeArguments) const; int ComputeArgumentsDestroy(ComputeArguments ** const computeArguments) const; void SetInfluenceDistancePointer(double const * const influenceDistance); void GetInfluenceDistance(double * const influenceDistance) const; void SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles); void GetNeighborListPointers( int * const numberOfNeighborLists, double const ** const cutoffs, int const ** const modelWillNotRequestNeighborsOfNoncontributingParticles) const; int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function * const fptr); int SetSpeciesCode(SpeciesName const speciesName, int const code); int GetSpeciesSupportAndCode(SpeciesName const speciesName, int * const speciesIsSupported, int * const code) const; int SetModelNumbering(Numbering const numbering); private: int SetSimulatorNumbering(Numbering const numbering); public: int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit); void GetUnits(LengthUnit * const lengthUnit, EnergyUnit * const energyUnit, ChargeUnit * const chargeUnit, TemperatureUnit * const temperatureUnit, TimeUnit * const timeUnit) const; void GetParameterFileDirectoryName(std::string const ** const directoryName) const; int GetNumberOfParameterFiles(int * const numberOfParameterFiles) const; int GetParameterFileName(int const index, std::string const ** const parameterFileName) const; int GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const; void SetParameterFileName(std::string const & filename) const; int SetParameterPointer(int const extent, int * const ptr, std::string const & name, std::string const & description); int SetParameterPointer(int const extent, double * const ptr, std::string const & name, std::string const & description); void GetNumberOfParameters(int * const numberOfParameters) const; int GetParameterMetadata(int const parameterIndex, DataType * const dataType, int * const extent, std::string const ** const name, std::string const ** const description) const; int GetParameter(int const parameterIndex, int const arrayIndex, int * const parameterValue) const; int GetParameter(int const parameterIndex, int const arrayIndex, double * const parameterValue) const; int SetParameter(int const parameterIndex, int const arrayIndex, int const parameterValue); int SetParameter(int const parameterIndex, int const arrayIndex, double const parameterValue); int Compute(ComputeArguments const * const computeArguments) const; void GetExtensionID(std::string const ** const extensionID) const; int Extension(std::string const & extensionID, void * const extensionStructure); int ClearThenRefresh(); void GetPath(std::string const ** const path) const; void GetModelName(std::string const ** const modelName) const; int WriteParameterizedModel(std::string const & path, std::string const & modelName) const; void SetModelBufferPointer(void * const ptr); void GetModelBufferPointer(void ** const ptr) const; void SetSimulatorBufferPointer(void * const ptr); void GetSimulatorBufferPointer(void ** const ptr) const; static int ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double * const conversionFactor); void SetLogID(std::string const & logID); void PushLogVerbosity(LogVerbosity const logVerbosity); void PopLogVerbosity(); void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; std::string const & ToString() const; private: // do not allow copy constructor or operator= ModelImplementation(ModelImplementation const &); void operator=(ModelImplementation const &); ModelImplementation(SharedLibrary * const sharedLibrary, Log * const log); ~ModelImplementation(); int ModelCreate(Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const & modelName); int ModelDestroy(); int ModelComputeArgumentsCreate( ComputeArguments * const computeArguments) const; int ModelComputeArgumentsDestroy( ComputeArguments * const computeArguments) const; int ModelCompute(ComputeArguments const * const computeArguments) const; int ModelExtension(void * const extensionStructure); int ModelRefresh(); int ModelWriteParameterizedModel() const; int IsCIdentifier(std::string const & id) const; std::string modelName_; std::string modelDriverName_; SharedLibrary * sharedLibrary_; FILESYSTEM::Path parameterFileDirectoryName_; std::string parameterFileDirectoryNameString_; int numberOfParameterFiles_; std::vector parameterFileNames_; std::vector parameterFileBasenames_; Log * log_; int InitializeStandAloneModel(LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit); int InitializeParameterizedModel( LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, Collections * collections); bool numberingHasBeenSet_; Numbering modelNumbering_; Numbering simulatorNumbering_; int numberingOffset_; bool unitsHaveBeenSet_; LengthUnit lengthUnit_; EnergyUnit energyUnit_; ChargeUnit chargeUnit_; TemperatureUnit temperatureUnit_; TimeUnit timeUnit_; double const * influenceDistance_; int numberOfNeighborLists_; double const * cutoffs_; int const * modelWillNotRequestNeighborsOfNoncontributingParticles_; std::map routineLanguage_; std::map routineRequired_; std::map routineFunction_; std::map supportedSpecies_; std::vector parameterName_; std::vector parameterDescription_; std::vector parameterDataType_; std::vector parameterExtent_; std::vector parameterPointer_; std::string extensionID_; mutable std::string writePath_; mutable std::string writeModelName_; mutable std::stringstream cmakelists_; void * modelBuffer_; void * simulatorBuffer_; mutable std::string string_; }; // class ModelImplementation } // namespace KIM #endif // KIM_MODEL_IMPLEMENTATION_HPP_ kim-api-2.3.0-git/cpp/src/KIM_ModelRefresh.cpp000066400000000000000000000055621421473465500210030ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_REFRESH_HPP_ #include "KIM_ModelRefresh.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { void ModelRefresh::SetInfluenceDistancePointer( double const * const influenceDistance) { CONVERT_POINTER; pImpl->SetInfluenceDistancePointer(influenceDistance); } void ModelRefresh::SetNeighborListPointers( int const numberOfNeighborLists, double const * const cutoffs, int const * const modelWillNotRequestNeighborsOfNoncontributingParticles) { CONVERT_POINTER; pImpl->SetNeighborListPointers( numberOfNeighborLists, cutoffs, modelWillNotRequestNeighborsOfNoncontributingParticles); } void ModelRefresh::GetModelBufferPointer(void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelRefresh::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelRefresh::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelRefresh::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelRefresh::ModelRefresh() : pimpl(NULL) {} ModelRefresh::~ModelRefresh() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelRoutineName.cpp000066400000000000000000000117261421473465500216320ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef KIM_MODEL_ROUTINE_NAME_HPP_ #include "KIM_ModelRoutineName.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace MODEL_ROUTINE_NAME { #include "KIM_ModelRoutineName.inc" ModelRoutineName const Create(ID_Create); ModelRoutineName const ComputeArgumentsCreate(ID_ComputeArgumentsCreate); ModelRoutineName const Compute(ID_Compute); ModelRoutineName const Extension(ID_Extension); ModelRoutineName const Refresh(ID_Refresh); ModelRoutineName const WriteParameterizedModel(ID_WriteParameterizedModel); ModelRoutineName const ComputeArgumentsDestroy(ID_ComputeArgumentsDestroy); ModelRoutineName const Destroy(ID_Destroy); namespace { typedef std:: map StringMap; StringMap const GetStringMap() { StringMap m; m[Create] = "Create"; m[ComputeArgumentsCreate] = "ComputeArgumentsCreate"; m[Compute] = "Compute"; m[Extension] = "Extension"; m[Refresh] = "Refresh"; m[WriteParameterizedModel] = "WriteParameterizedModel"; m[ComputeArgumentsDestroy] = "ComputeArgumentsDestroy"; m[Destroy] = "Destroy"; return m; } StringMap const modelRoutineNameToString = GetStringMap(); std::string const modelRoutineNameUnknown("unknown"); } // namespace namespace { typedef std::vector ModelRoutineVector; ModelRoutineVector const GetModelRoutineVector() { ModelRoutineVector v; v.push_back(Create); v.push_back(ComputeArgumentsCreate); v.push_back(Compute); // v.push_back(Refresh); // required only if adjustable prameters exist v.push_back(ComputeArgumentsDestroy); v.push_back(Destroy); return v; } } // namespace // used by KIM::ModelImplementation extern ModelRoutineVector const requiredByAPI_ModelRoutines = GetModelRoutineVector(); void GetNumberOfModelRoutineNames(int * const numberOfModelRoutineNames) { *numberOfModelRoutineNames = modelRoutineNameToString.size(); } int GetModelRoutineName(int const index, ModelRoutineName * const modelRoutineName) { int numberOfModelRoutineNames; GetNumberOfModelRoutineNames(&numberOfModelRoutineNames); if ((index < 0) || (index >= numberOfModelRoutineNames)) return true; StringMap::const_iterator iter = modelRoutineNameToString.begin(); for (int i = 0; i < index; ++i) ++iter; *modelRoutineName = iter->first; return false; // no error } } // namespace MODEL_ROUTINE_NAME // implementation of ModelRoutineName ModelRoutineName::ModelRoutineName() {} ModelRoutineName::ModelRoutineName(int const id) : modelRoutineNameID(id) {} ModelRoutineName::ModelRoutineName(std::string const & str) { modelRoutineNameID = -1; for (MODEL_ROUTINE_NAME::StringMap::const_iterator iter = MODEL_ROUTINE_NAME::modelRoutineNameToString.begin(); iter != MODEL_ROUTINE_NAME::modelRoutineNameToString.end(); ++iter) { if (iter->second == str) { modelRoutineNameID = (iter->first).modelRoutineNameID; break; } } } bool ModelRoutineName::Known() const { int numberOfModelRoutineNames; MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames(&numberOfModelRoutineNames); for (int i = 0; i < numberOfModelRoutineNames; ++i) { ModelRoutineName routine; MODEL_ROUTINE_NAME::GetModelRoutineName(i, &routine); if (*this == routine) { return true; } } return false; } bool ModelRoutineName::operator==(ModelRoutineName const & rhs) const { return modelRoutineNameID == rhs.modelRoutineNameID; } bool ModelRoutineName::operator!=(ModelRoutineName const & rhs) const { return modelRoutineNameID != rhs.modelRoutineNameID; } std::string const & ModelRoutineName::ToString() const { MODEL_ROUTINE_NAME::StringMap::const_iterator iter = MODEL_ROUTINE_NAME::modelRoutineNameToString.find(*this); if (iter == MODEL_ROUTINE_NAME::modelRoutineNameToString.end()) return MODEL_ROUTINE_NAME::modelRoutineNameUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_ModelRoutineName.inc000066400000000000000000000047311421473465500216170ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_MODEL_ROUTINE_NAME_INC_ #define KIM_MODEL_ROUTINE_NAME_INC_ #define ID_Create 0 #define ID_ComputeArgumentsCreate 1 #define ID_Compute 2 #define ID_Extension 3 #define ID_Refresh 4 #define ID_WriteParameterizedModel 5 #define ID_ComputeArgumentsDestroy 6 #define ID_Destroy 7 #endif /* KIM_MODEL_ROUTINE_NAME_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_ModelWriteParameterizedModel.cpp000066400000000000000000000060521421473465500241700ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_MODEL_WRITE_PARAMETERIZED_MODEL_HPP_ #include "KIM_ModelWriteParameterizedModel.hpp" #endif #ifndef KIM_MODEL_IMPLEMENTATION_HPP_ #include "KIM_ModelImplementation.hpp" #endif #define CONVERT_POINTER \ ModelImplementation * pImpl = reinterpret_cast(pimpl) namespace KIM { void ModelWriteParameterizedModel::GetPath( std::string const ** const path) const { CONVERT_POINTER; pImpl->GetPath(path); } void ModelWriteParameterizedModel::GetModelName( std::string const ** const modelName) const { CONVERT_POINTER; pImpl->GetModelName(modelName); } void ModelWriteParameterizedModel::SetParameterFileName( std::string const & fileName) const { CONVERT_POINTER; pImpl->SetParameterFileName(fileName); } void ModelWriteParameterizedModel::GetModelBufferPointer( void ** const ptr) const { CONVERT_POINTER; pImpl->GetModelBufferPointer(ptr); } void ModelWriteParameterizedModel::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } void ModelWriteParameterizedModel::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { CONVERT_POINTER; pImpl->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & ModelWriteParameterizedModel::ToString() const { CONVERT_POINTER; return pImpl->ToString(); } ModelWriteParameterizedModel::ModelWriteParameterizedModel() : pimpl(NULL) {} ModelWriteParameterizedModel::~ModelWriteParameterizedModel() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_Numbering.cpp000066400000000000000000000065051421473465500203500ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_NUMBERING_HPP_ #include "KIM_Numbering.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace NUMBERING { #include "KIM_Numbering.inc" Numbering const zeroBased(ID_zeroBased); Numbering const oneBased(ID_oneBased); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[zeroBased] = "zeroBased"; m[oneBased] = "oneBased"; return m; } StringMap const numberingToString = GetStringMap(); std::string numberingUnknown("unknown"); } // namespace void GetNumberOfNumberings(int * const numberOfNumberings) { *numberOfNumberings = numberingToString.size(); } int GetNumbering(int const index, Numbering * const numbering) { int numberOfNumberings; GetNumberOfNumberings(&numberOfNumberings); if ((index < 0) || (index >= numberOfNumberings)) return true; StringMap::const_iterator iter = numberingToString.begin(); for (int i = 0; i < index; ++i) ++iter; *numbering = iter->first; return false; // no error } } // namespace NUMBERING // implementation of Numbering Numbering::Numbering() {} Numbering::Numbering(int const id) : numberingID(id) {} Numbering::Numbering(std::string const & str) { numberingID = -1; for (NUMBERING::StringMap::const_iterator iter = NUMBERING::numberingToString.begin(); iter != NUMBERING::numberingToString.end(); ++iter) { if (iter->second == str) { numberingID = (iter->first).numberingID; break; } } } bool Numbering::Known() const { int numberOfNumberings; NUMBERING::GetNumberOfNumberings(&numberOfNumberings); for (int i = 0; i < numberOfNumberings; ++i) { Numbering num; NUMBERING::GetNumbering(i, &num); if (*this == num) { return true; } } return false; } bool Numbering::operator==(Numbering const & rhs) const { return numberingID == rhs.numberingID; } bool Numbering::operator!=(Numbering const & rhs) const { return numberingID != rhs.numberingID; } std::string const & Numbering::ToString() const { NUMBERING::StringMap::const_iterator iter = NUMBERING::numberingToString.find(*this); if (iter == NUMBERING::numberingToString.end()) return NUMBERING::numberingUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_Numbering.inc000066400000000000000000000044231421473465500203340ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_NUMBERING_INC_ #define KIM_NUMBERING_INC_ #define ID_zeroBased 0 #define ID_oneBased 1 #endif /* KIM_NUMBERING_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_SemVer.cpp000066400000000000000000000254661421473465500176320ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #include #ifndef KIM_VERSION_HPP_ #include "KIM_Version.hpp" #endif #ifndef KIM_SEM_VER_HPP_ #include "KIM_SemVer.hpp" #endif namespace KIM { namespace SEM_VER { namespace { std::string const version(KIM_VERSION_STRING); enum SERIES_TYPE { PRERELEASE, BUILD_METADATA }; enum IDENTIFIER_TYPE { NUMERIC, ALPHANUMERIC, INVALID }; char const numeric[] = "0123456789"; char const alphaNumeric[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789-"; IDENTIFIER_TYPE IdentifierType(std::string const & identifier) { size_t found; found = identifier.find_first_not_of(numeric); if (found == std::string::npos) { return NUMERIC; } found = identifier.find_first_not_of(alphaNumeric); if (found == std::string::npos) { return ALPHANUMERIC; } return INVALID; } int ParseIdentifiers(SERIES_TYPE type, std::string const & series, std::vector * const identifiers) { if (identifiers != NULL) { identifiers->clear(); } size_t found; std::string subStr; std::string remainderStr = series; while (remainderStr.length() != 0) { found = remainderStr.find_first_of('.'); if (found == std::string::npos) { switch (IdentifierType(remainderStr)) { case INVALID: return true; // Invalid identifier break; case NUMERIC: if (type == PRERELEASE) { if ((remainderStr[0] == '0') && (remainderStr.length() > 1)) { return true; // Has leading zero } } break; case ALPHANUMERIC: if (identifiers != NULL) { identifiers->push_back(remainderStr); } break; } remainderStr = ""; } else { subStr = remainderStr.substr(0, found); remainderStr = remainderStr.substr(found + 1); if (remainderStr.length() == 0) { return true; // Empty final identifier } if (subStr.length() == 0) { return true; // Identifier is empty } switch (IdentifierType(subStr)) { case INVALID: return true; // Invalid identifier break; case NUMERIC: if (type == PRERELEASE) { if ((subStr[0] == '0') && (subStr.length() > 1)) { return true; // Has leading zero } } break; case ALPHANUMERIC: if (identifiers != NULL) { identifiers->push_back(subStr); } break; } } } return false; } bool IsPrereleaseLessThan(std::string const & prereleaseA, std::string const & prereleaseB) { std::vector identifiersA; std::vector identifiersB; // Assume already checked for validity ParseIdentifiers(PRERELEASE, prereleaseA, &identifiersA); ParseIdentifiers(PRERELEASE, prereleaseB, &identifiersB); // use smaller size int size = ((identifiersA.size() > identifiersB.size()) ? identifiersB.size() : identifiersA.size()); for (int i = 0; i < size; ++i) { std::string const & idA = identifiersA[i]; std::string const & idB = identifiersB[i]; IDENTIFIER_TYPE typeA = IdentifierType(idA); IDENTIFIER_TYPE typeB = IdentifierType(idB); if ((typeA == ALPHANUMERIC) && (typeB == NUMERIC)) { return false; } else if ((typeA == NUMERIC) && (typeB == ALPHANUMERIC)) { return true; } else if ((typeA == NUMERIC) && (typeB == NUMERIC)) { char * end; int numberA = strtol(idA.c_str(), &end, 10); int numberB = strtol(idB.c_str(), &end, 10); if (numberA > numberB) { return false; } if (numberA < numberB) { return true; } // numeric identifers are equal } else if ((typeA == ALPHANUMERIC) && (typeB == ALPHANUMERIC)) { if (idA > idB) { return false; } if (idA < idB) { return true; } // alphanumeric identifiers are equal } // move on to the next identifier } if (identifiersA.size() > identifiersB.size()) { return false; } if (identifiersA.size() < identifiersB.size()) { return true; } return false; // Prerelease A and B are identical } enum HAS_ANCILLARY { HAS_NONE, HAS_PRERELEASE_ONLY, HAS_BUILD_METADATA_ONLY, HAS_BOTH }; } // namespace std::string const & GetSemVer() { return SEM_VER::version; } int IsLessThan(std::string const & lhs, std::string const & rhs, int * const isLessThan) { int majorA; int minorA; int patchA; std::string prereleaseA; std::string buildMetadataA; int majorB; int minorB; int patchB; std::string prereleaseB; std::string buildMetadataB; if ((ParseSemVer( lhs, &majorA, &minorA, &patchA, &prereleaseA, &buildMetadataA) || ParseSemVer( rhs, &majorB, &minorB, &patchB, &prereleaseB, &buildMetadataB))) { return true; } if (majorA > majorB) { *isLessThan = false; return false; } else if (majorA < majorB) { *isLessThan = true; return false; } // Major values are equal if (minorA > minorB) { *isLessThan = false; return false; } else if (minorA < minorB) { *isLessThan = true; return false; } // Minor values are equal if (patchA > patchB) { *isLessThan = false; return false; } else if (patchA < patchB) { *isLessThan = true; return false; } // Patch values are equal if ((prereleaseA == "") && (prereleaseB != "")) { *isLessThan = false; return false; } else if ((prereleaseA != "") && (prereleaseB == "")) { *isLessThan = true; return false; } else if ((prereleaseA == "") && (prereleaseB == "")) { *isLessThan = false; // A and B are equal return false; } // Both are prereleases of the same version if (IsPrereleaseLessThan(prereleaseA, prereleaseB)) { *isLessThan = true; return false; } else { *isLessThan = false; return false; } return false; // should not get here } int ParseSemVer(std::string const & version, int * const major, int * const minor, int * const patch, std::string * const prerelease, std::string * const buildMetadata) { HAS_ANCILLARY hasAncillary = HAS_NONE; std::string majorStr; std::string minorStr; std::string patchStr; std::string prereleaseStr; std::string buildMetadataStr; size_t found; found = version.find_first_of('+'); if (found != std::string::npos) { hasAncillary = HAS_BUILD_METADATA_ONLY; } size_t pre = version.find_first_of('-'); if ((pre != std::string::npos) && (pre < found)) { if (hasAncillary == HAS_BUILD_METADATA_ONLY) hasAncillary = HAS_BOTH; else hasAncillary = HAS_PRERELEASE_ONLY; } std::string subStr; std::string remainderStr; // Find Major found = version.find_first_of('.'); if (found == std::string::npos) { return true; // Missing Minor and Patch } majorStr = version.substr(0, found); remainderStr = version.substr(found + 1); // Find Minor found = remainderStr.find_first_of('.'); if (found == std::string::npos) { return true; // Missing Patch } minorStr = remainderStr.substr(0, found); remainderStr = remainderStr.substr(found + 1); // Find Patch switch (hasAncillary) { case HAS_NONE: patchStr = remainderStr; break; case HAS_PRERELEASE_ONLY: found = remainderStr.find_first_of('-'); // Will succeed patchStr = remainderStr.substr(0, found); prereleaseStr = remainderStr.substr(found + 1); break; case HAS_BUILD_METADATA_ONLY: found = remainderStr.find_first_of('+'); // Will succeed patchStr = remainderStr.substr(0, found); buildMetadataStr = remainderStr.substr(found + 1); break; case HAS_BOTH: found = remainderStr.find_first_of('-'); // Will succeed patchStr = remainderStr.substr(0, found); remainderStr = remainderStr.substr(found + 1); found = remainderStr.find_first_of('+'); // Will succeed prereleaseStr = remainderStr.substr(0, found); buildMetadataStr = remainderStr.substr(found + 1); break; } remainderStr = ""; // validate major if ((majorStr[0] == '0') && (majorStr.length() > 1)) { return true; // Has leading zeros } char * end; int majorVerNumber = strtol(majorStr.c_str(), &end, 10); if ('\0' != *end) { return true; // Not a valid integer } // validate minor if ((minorStr[0] == '0') && (minorStr.length() > 1)) { return true; // Has leading zeros } int minorVerNumber = strtol(minorStr.c_str(), &end, 10); if ('\0' != *end) { return true; // Not a valid integer } // validate patch if ((patchStr[0] == '0') && (patchStr.length() > 1)) { return true; // Has leading zeros } int patchVerNumber = strtol(patchStr.c_str(), &end, 10); if ('\0' != *end) { return true; // Not a valid integer } // validate prerelease if ((hasAncillary == HAS_PRERELEASE_ONLY) || (hasAncillary == HAS_BOTH)) { if (ParseIdentifiers(PRERELEASE, prereleaseStr, NULL)) { return true; // Prerelease is invalid } } // validate buildMetadata if ((hasAncillary == HAS_BUILD_METADATA_ONLY) || (hasAncillary == HAS_BOTH)) { if (ParseIdentifiers(BUILD_METADATA, buildMetadataStr, NULL)) { return true; // Build Metadata is invalid } } if (major != NULL) { *major = majorVerNumber; } if (minor != NULL) { *minor = minorVerNumber; } if (patch != NULL) { *patch = patchVerNumber; } if (prerelease != NULL) { *prerelease = prereleaseStr; } if (buildMetadata != NULL) { *buildMetadata = buildMetadataStr; } return false; } } // namespace SEM_VER } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_SharedLibrary.cpp000066400000000000000000000546561421473465500211670ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #include #ifndef _WIN32 #include #else #include #endif #include #include #include // IWYU pragma: keep // For macOS #ifndef KIM_SHARED_LIBRARY_HPP_ #include "KIM_SharedLibrary.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif #ifndef KIM_SHARED_LIBRARY_SCHEMA_HPP_ #include "KIM_SharedLibrarySchema.hpp" #endif namespace { static void * const referencePointForKIM_Library = NULL; KIM::FILESYSTEM::Path PrivateGetORIGIN() { #if !defined(_WIN32) && !defined(__CYGWIN__) Dl_info info; int OK = false; OK = dladdr(&referencePointForKIM_Library, &info); return KIM::FILESYSTEM::Path(OK ? info.dli_fname : "").parent_path(); #else // https://stackoverflow.com/questions/6924195/get-dll-path-at-runtime HMODULE hm = NULL; GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(&referencePointForKIM_Library), &hm); wchar_t pathBuf[MAX_PATH]; if (!GetModuleFileNameW(hm, pathBuf, MAX_PATH)) return KIM::FILESYSTEM::Path(); return KIM::FILESYSTEM::Path(pathBuf).parent_path(); #endif } } // namespace // log helpers #define SNUM(x) \ static_cast(std::ostringstream() \ << std::dec << x) \ .str() #define SPTR(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #define SFUNCP(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #include "KIM_LogMacros.hpp" #define KIM_LOGGER_OBJECT_NAME this namespace KIM { SharedLibrary::SharedLibrary::EmbeddedFile::EmbeddedFile() : fileName(NULL), fileLength(0), filePointer(NULL) { } SharedLibrary::SharedLibrary(Log * const log) : sharedLibraryHandle_(NULL), sharedLibrarySchemaVersion_(NULL), createRoutine_(NULL), numberOfParameterFiles_(0), numberOfMetadataFiles_(0), parameterFileDirectoryName_(""), log_(log) { #if DEBUG_VERBOSITY std::string const callString = "SharedLibrary(" + SPTR(log) + ")."; #endif LOG_DEBUG("Enter " + callString); LOG_DEBUG("Exit " + callString); } SharedLibrary::~SharedLibrary() { #if DEBUG_VERBOSITY std::string const callString = "~SharedLibrary()."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ != NULL) { LOG_WARNING( "SharedLibrary not Close()'d prior to calling ~SharedLibrary()."); int error = Close(); if (error) { LOG_ERROR("SharedLibrary::Close() returned an error."); } } LOG_DEBUG("Exit " + callString); } int SharedLibrary::Open(FILESYSTEM::Path const & sharedLibraryName) { #if DEBUG_VERBOSITY std::string const callString = "Open('" + sharedLibraryName.string() + "')."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ != NULL) { LOG_ERROR(""); LOG_DEBUG("Exit 1=" + callString); return true; // already open } sharedLibraryName_ = sharedLibraryName; #ifndef _WIN32 sharedLibraryHandle_ = dlopen(sharedLibraryName_.string().c_str(), RTLD_NOW); #else FILESYSTEM::Path winPath = sharedLibraryName; sharedLibraryHandle_ = (void *) LoadLibraryExW( winPath.make_preferred().c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); #endif if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Unable to open '" + sharedLibraryName_.string() + "'."); #ifndef _WIN32 LOG_ERROR(dlerror()); #endif LOG_DEBUG("Exit 1=" + callString); return true; } #ifndef _WIN32 sharedLibrarySchemaVersion_ = reinterpret_cast( dlsym(sharedLibraryHandle_, "kim_shared_library_schema_version")); #else sharedLibrarySchemaVersion_ = reinterpret_cast(::GetProcAddress( (HMODULE) sharedLibraryHandle_, "kim_shared_library_schema_version")); #endif if (sharedLibrarySchemaVersion_ == NULL) { LOG_ERROR( "Failed to look up symbol 'kim_shared_library_schema_version' in '" + sharedLibraryName_.string() + "'."); #ifndef _WIN32 LOG_ERROR(dlerror()); #endif LOG_DEBUG("Exit 1=" + callString); return true; } if (*sharedLibrarySchemaVersion_ == 2) { using namespace SHARED_LIBRARY_SCHEMA; #ifndef _WIN32 SharedLibrarySchemaV2 const * const schemaV2 = reinterpret_cast( dlsym(sharedLibraryHandle_, "kim_shared_library_schema")); #else SharedLibrarySchemaV2 const * const schemaV2 = reinterpret_cast(::GetProcAddress( (HMODULE) sharedLibraryHandle_, "kim_shared_library_schema")); #endif if (schemaV2 == NULL) { LOG_ERROR("Failed to look up symbol 'kim_shared_library_schema' in '" + sharedLibraryName_.string() + "'."); #ifndef _WIN32 LOG_ERROR(dlerror()); #endif LOG_DEBUG("Exit 1=" + callString); return true; } itemType_ = schemaV2->itemType; createLanguageName_ = schemaV2->createLanguageName; createRoutine_ = schemaV2->createRoutine; driverName_ = ((schemaV2->driverName) ? schemaV2->driverName : ""); if (schemaV2->simulatorModelSpecificationFile != NULL) { simulatorModelSpecificationFile_.fileName = schemaV2->simulatorModelSpecificationFile->fileName; simulatorModelSpecificationFile_.fileLength = schemaV2->simulatorModelSpecificationFile->fileLength; simulatorModelSpecificationFile_.filePointer = schemaV2->simulatorModelSpecificationFile->filePointer; } numberOfParameterFiles_ = schemaV2->numberOfParameterFiles; for (int i = 0; i < numberOfParameterFiles_; ++i) { EmbeddedFile fl; fl.fileName = schemaV2->parameterFiles[i].fileName; fl.fileLength = schemaV2->parameterFiles[i].fileLength; fl.filePointer = schemaV2->parameterFiles[i].filePointer; parameterFiles_.push_back(fl); } numberOfMetadataFiles_ = schemaV2->numberOfMetadataFiles; for (int i = 0; i < numberOfMetadataFiles_; ++i) { EmbeddedFile fl; fl.fileName = schemaV2->metadataFiles[i].fileName; fl.fileLength = schemaV2->metadataFiles[i].fileLength; fl.filePointer = schemaV2->metadataFiles[i].filePointer; metadataFiles_.push_back(fl); } } else if (*sharedLibrarySchemaVersion_ == 1) { using namespace SHARED_LIBRARY_SCHEMA; #ifndef _WIN32 SharedLibrarySchemaV1 const * const schemaV1 = reinterpret_cast( dlsym(sharedLibraryHandle_, "kim_shared_library_schema")); #else SharedLibrarySchemaV1 const * const schemaV1 = reinterpret_cast(::GetProcAddress( (HMODULE) sharedLibraryHandle_, "kim_shared_library_schema")); #endif if (schemaV1 == NULL) { LOG_ERROR("Failed to look up symbol 'kim_shared_library_schema' in '" + sharedLibraryName_.string() + "'."); #ifndef _WIN32 LOG_ERROR(dlerror()); #endif LOG_DEBUG("Exit 1=" + callString); return true; } if (schemaV1->itemType == SharedLibrarySchemaV1::STAND_ALONE_MODEL) { itemType_ = COLLECTION_ITEM_TYPE::portableModel; } else if (schemaV1->itemType == SharedLibrarySchemaV1::PARAMETERIZED_MODEL) { itemType_ = COLLECTION_ITEM_TYPE::portableModel; // differentiated from above by driverName_ } else if (schemaV1->itemType == SharedLibrarySchemaV1::SIMULATOR_MODEL) { itemType_ = COLLECTION_ITEM_TYPE::simulatorModel; } else if (schemaV1->itemType == SharedLibrarySchemaV1::MODEL_DRIVER) { itemType_ = COLLECTION_ITEM_TYPE::modelDriver; } else { LOG_ERROR("SHOULD NEVER GET HERE."); LOG_DEBUG("Exit 1=" + callString); return true; } createLanguageName_ = schemaV1->createLanguageName; createRoutine_ = schemaV1->createRoutine; driverName_ = ((schemaV1->driverName) ? schemaV1->driverName : ""); if (schemaV1->metadataFile != NULL) { simulatorModelSpecificationFile_.fileName = schemaV1->metadataFile->fileName; simulatorModelSpecificationFile_.fileLength = schemaV1->metadataFile->fileLength; simulatorModelSpecificationFile_.filePointer = schemaV1->metadataFile->filePointer; } numberOfParameterFiles_ = schemaV1->numberOfParameterFiles; for (int i = 0; i < numberOfParameterFiles_; ++i) { EmbeddedFile fl; fl.fileName = schemaV1->parameterFiles[i].fileName; fl.fileLength = schemaV1->parameterFiles[i].fileLength; fl.filePointer = schemaV1->parameterFiles[i].filePointer; parameterFiles_.push_back(fl); } numberOfMetadataFiles_ = 1; EmbeddedFile fl; fl.fileName = "compiled-with-version.txt"; fl.fileLength = strlen(schemaV1->compiledWithVersion); fl.filePointer = reinterpret_cast( schemaV1->compiledWithVersion); metadataFiles_.push_back(fl); } else { LOG_ERROR("Unknown KIM::SharedLibrarySchema version."); LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::IsOpen() const { return (sharedLibraryHandle_ != NULL); } int SharedLibrary::IsOpen(FILESYSTEM::Path const & sharedLibraryName) const { return (IsOpen() && sharedLibraryName == sharedLibraryName_); } int SharedLibrary::Close() { #if DEBUG_VERBOSITY std::string const callString = "Close()."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("SharedLibrary not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } RemoveParameterFileDirectory(); sharedLibraryName_.clear(); sharedLibrarySchemaVersion_ = 0; createRoutine_ = NULL; driverName_ = ""; simulatorModelSpecificationFile_.fileName = NULL; simulatorModelSpecificationFile_.fileLength = 0; simulatorModelSpecificationFile_.filePointer = NULL; numberOfParameterFiles_ = 0; parameterFiles_.clear(); numberOfMetadataFiles_ = 0; metadataFiles_.clear(); #ifndef _WIN32 int error = dlclose(sharedLibraryHandle_); #else int error = !::FreeLibrary((HMODULE) sharedLibraryHandle_); #endif if (error) { LOG_ERROR(""); LOG_DEBUG("Exit 1=" + callString); return true; } else { sharedLibraryHandle_ = NULL; } LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetType(CollectionItemType * const type) const { #if DEBUG_VERBOSITY std::string const callString = "GetType(" + SPTR(type) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } *type = itemType_; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetCreateFunctionPointer( LanguageName * const languageName, Function ** const functionPointer) const { #if DEBUG_VERBOSITY std::string const callString = "GetCreateFunctionPointer(" + SPTR(languageName) + ", " + SFUNCP(functionPointer) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } if (languageName != NULL) *languageName = createLanguageName_; if (functionPointer != NULL) *functionPointer = createRoutine_; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetNumberOfParameterFiles( int * const numberOfParameterFiles) const { #if DEBUG_VERBOSITY std::string const callString = "GetNumberOfParameterFiles(" + SPTR(numberOfParameterFiles) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } *numberOfParameterFiles = numberOfParameterFiles_; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetParameterFile( int const index, std::string * const parameterFileName, unsigned int * const parameterFileLength, unsigned char const ** const parameterFileData) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFile(" + SNUM(index) + ", " + SPTR(parameterFileName) + ", " + SPTR(parameterFileLength) + ", " + SPTR(parameterFileData) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } if (((itemType_ == COLLECTION_ITEM_TYPE::portableModel) && (driverName_ == "")) || (itemType_ == COLLECTION_ITEM_TYPE::modelDriver)) { LOG_ERROR("This item type does not have parameter files."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((index < 0) || index >= numberOfParameterFiles_) { LOG_ERROR("Invalid parameter file index."); LOG_DEBUG("Exit 1=" + callString); return true; } if (parameterFileName != NULL) *parameterFileName = (parameterFiles_[index]).fileName; if (parameterFileLength != NULL) *parameterFileLength = (parameterFiles_[index]).fileLength; if (parameterFileData != NULL) *parameterFileData = (parameterFiles_[index]).filePointer; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetNumberOfMetadataFiles( int * const numberOfMetadataFiles) const { #if DEBUG_VERBOSITY std::string const callString = "GetNumberOfMetadataFiles(" + SPTR(numberOfMetadataFiles) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } *numberOfMetadataFiles = numberOfMetadataFiles_; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetMetadataFile( int const index, std::string * const metadataFileName, unsigned int * const metadataFileLength, unsigned char const ** const metadataFileData) const { #if DEBUG_VERBOSITY std::string const callString = "GetMetadataFile(" + SNUM(index) + ", " + SPTR(metadataFileName) + ", " + SPTR(metadataFileLength) + ", " + SPTR(metadataFileData) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } if ((index < 0) || index >= numberOfMetadataFiles_) { LOG_ERROR("Invalid metadata file index."); LOG_DEBUG("Exit 1=" + callString); return true; } if (metadataFileName != NULL) *metadataFileName = (metadataFiles_[index]).fileName; if (metadataFileLength != NULL) *metadataFileLength = (metadataFiles_[index]).fileLength; if (metadataFileData != NULL) *metadataFileData = (metadataFiles_[index]).filePointer; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetSimulatorModelSpecificationFile( std::string * const specFileName, unsigned int * const specFileLength, unsigned char const ** const specFileData) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorModelSpecificationFile(, " + SPTR(specFileName) + ", " + SPTR(specFileLength) + ", " + SPTR(specFileData) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } if (itemType_ != COLLECTION_ITEM_TYPE::simulatorModel) { LOG_ERROR( "This item type does not have a simulator model specification file."); LOG_DEBUG("Exit 1=" + callString); return true; } if (specFileName != NULL) *specFileName = (simulatorModelSpecificationFile_).fileName; if (specFileLength != NULL) *specFileLength = (simulatorModelSpecificationFile_).fileLength; if (specFileData != NULL) *specFileData = (simulatorModelSpecificationFile_).filePointer; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::WriteParameterFileDirectory() { #if DEBUG_VERBOSITY std::string const callString = "WriteParameterFileDirectory()."; #endif LOG_DEBUG("Enter " + callString); int error; if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } parameterFileDirectoryName_ = FILESYSTEM::Path::CreateTemporaryDirectory( "kim-shared-library-parameter-file-directory-"); if (parameterFileDirectoryName_.empty()) { LOG_ERROR("Could not create a secure temporary directory."); LOG_DEBUG("Exit 1=" + callString); return true; } if (itemType_ == KIM::COLLECTION_ITEM_TYPE::simulatorModel) { unsigned int len; unsigned char const * specificationData; std::string specFileName; error = GetSimulatorModelSpecificationFile( &specFileName, &len, &specificationData); if (error) { LOG_ERROR("Unable to get specification file."); RemoveParameterFileDirectory(); LOG_DEBUG("Exit 1=" + callString); return true; } FILESYSTEM::Path const specificationFilePathName = parameterFileDirectoryName_ / specFileName; std::ofstream fl; fl.open(specificationFilePathName.string().c_str(), std::ifstream::out | std::ifstream::binary); fl.write(reinterpret_cast(specificationData), len); if (!fl) { LOG_ERROR("Unable to get write parameter file."); fl.close(); RemoveParameterFileDirectory(); LOG_DEBUG("Exit 1=" + callString); return true; } } int noParamFiles; GetNumberOfParameterFiles(&noParamFiles); for (int i = 0; i < noParamFiles; ++i) { std::string parameterFileName; unsigned char const * strPtr; unsigned int length; error = GetParameterFile(i, ¶meterFileName, &length, &strPtr); if (error) { LOG_ERROR("Could not get parameter file data."); LOG_DEBUG("Exit 1=" + callString); return true; } FILESYSTEM::Path const parameterFilePathName = parameterFileDirectoryName_ / parameterFileName; std::ofstream fl; fl.open(parameterFilePathName.string().c_str(), std::ifstream::out | std::ifstream::binary); fl.write(reinterpret_cast(strPtr), length); if (!fl) { LOG_ERROR("Unable to get write parameter file."); fl.close(); RemoveParameterFileDirectory(); LOG_DEBUG("Exit 1=" + callString); return true; } } LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetParameterFileDirectoryName( FILESYSTEM::Path * const directoryName) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileDirectoryName(" + SPTR(directoryName) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } *directoryName = parameterFileDirectoryName_; LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::RemoveParameterFileDirectory() { #if DEBUG_VERBOSITY std::string const callString = "RemoveParameterFileDirectory()."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } if (!parameterFileDirectoryName_.empty()) { if (parameterFileDirectoryName_.RemoveDirectoryRecursive()) { LOG_ERROR("Unable to remove simulator model parameter file directory '" + parameterFileDirectoryName_.string() + "'."); } // clear out directory name variable parameterFileDirectoryName_.clear(); } LOG_DEBUG("Exit 0=" + callString); return false; } int SharedLibrary::GetDriverName(std::string * const driverName) const { #if DEBUG_VERBOSITY std::string const callString = "GetDriverName(" + SPTR(driverName) + ")."; #endif LOG_DEBUG("Enter " + callString); if (sharedLibraryHandle_ == NULL) { LOG_ERROR("Library not open."); LOG_DEBUG("Exit 1=" + callString); return true; // not open } if ((itemType_ != COLLECTION_ITEM_TYPE::portableModel) && (driverName_ != "")) { LOG_ERROR("This item type does not have an associated model driver."); LOG_DEBUG("Exit 1=" + callString); return true; } *driverName = driverName_; LOG_DEBUG("Exit 0=" + callString); return false; } // namespace KIM void SharedLibrary::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { if (log_ != NULL) log_->LogEntry(logVerbosity, message, lineNumber, fileName); } FILESYSTEM::Path const SharedLibrary::ORIGIN = PrivateGetORIGIN(); FILESYSTEM::Path SharedLibrary::GetORIGIN() { return ORIGIN; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_SharedLibrary.hpp000066400000000000000000000103071421473465500211550ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SHARED_LIBRARY_HPP_ #define KIM_SHARED_LIBRARY_HPP_ #include #include #ifndef KIM_FUNCTION_TYPES_HPP_ #include "KIM_FunctionTypes.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LANGUAGE_NAME_HPP_ #include "KIM_LanguageName.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_FILESYSTEM_PATH_HPP_ #include "KIM_FilesystemPath.hpp" #endif namespace KIM { // Forward declarations class Log; class SharedLibrary { public: SharedLibrary(Log * const log); ~SharedLibrary(); int Open(FILESYSTEM::Path const & sharedLibraryName); int IsOpen() const; int IsOpen(FILESYSTEM::Path const & sharedLibraryName) const; int Close(); int GetType(CollectionItemType * const type) const; int GetCreateFunctionPointer(LanguageName * const languageName, Function ** const functionPointer) const; int GetNumberOfParameterFiles(int * const numberOfParameterFiles) const; int GetParameterFile(int const index, std::string * const parameterFileName, unsigned int * const parameterFileLength, unsigned char const ** const parameterFileData) const; int GetSimulatorModelSpecificationFile( std::string * const specFileName, unsigned int * const specFileLength, unsigned char const ** const specFileData) const; int WriteParameterFileDirectory(); int GetParameterFileDirectoryName( FILESYSTEM::Path * const directoryName) const; int RemoveParameterFileDirectory(); int GetDriverName(std::string * const driverName) const; int GetNumberOfMetadataFiles(int * const numberOfMetadataFiles) const; int GetMetadataFile(int const index, std::string * const metadataFileName, unsigned int * const metadataFileLength, unsigned char const ** const metadataFileData) const; void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; static FILESYSTEM::Path GetORIGIN(); private: // do not allow copy constructor or operator= SharedLibrary(SharedLibrary const &); void operator=(SharedLibrary const &); // do not allow default constructor SharedLibrary(); struct EmbeddedFile { char const * fileName; unsigned int fileLength; unsigned char const * filePointer; EmbeddedFile(); }; // struct EmbeddedFile static FILESYSTEM::Path const ORIGIN; FILESYSTEM::Path sharedLibraryName_; void * sharedLibraryHandle_; int const * sharedLibrarySchemaVersion_; CollectionItemType itemType_; LanguageName createLanguageName_; Function * createRoutine_; std::string driverName_; EmbeddedFile simulatorModelSpecificationFile_; int numberOfParameterFiles_; std::vector parameterFiles_; int numberOfMetadataFiles_; std::vector metadataFiles_; FILESYSTEM::Path parameterFileDirectoryName_; Log * log_; }; // class SharedLibrary } // namespace KIM #endif // KIM_SHARED_LIBRARY_HPP_ kim-api-2.3.0-git/cpp/src/KIM_SimulatorModel.cpp000066400000000000000000000121241421473465500213540ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_SIMULATOR_MODEL_HPP_ #include "KIM_SimulatorModel.hpp" #endif #ifndef KIM_SIMULATOR_MODEL_IMPLEMENTATION_HPP_ #include "KIM_SimulatorModelImplementation.hpp" #endif namespace KIM { int SimulatorModel::Create(std::string const & simulatorModelName, SimulatorModel ** const simulatorModel) { *simulatorModel = new SimulatorModel(); int error = SimulatorModelImplementation::Create(simulatorModelName, &((*simulatorModel)->pimpl)); if (error) { delete *simulatorModel; *simulatorModel = NULL; return true; } else { return false; } } void SimulatorModel::Destroy(SimulatorModel ** const simulatorModel) { if (*simulatorModel != NULL) { SimulatorModelImplementation::Destroy(&((*simulatorModel)->pimpl)); } delete *simulatorModel; *simulatorModel = NULL; } void SimulatorModel::GetSimulatorNameAndVersion( std::string const ** const simulatorName, std::string const ** const simulatorVersion) const { pimpl->GetSimulatorNameAndVersion(simulatorName, simulatorVersion); } void SimulatorModel::GetNumberOfSupportedSpecies( int * const numberOfSupportedSpecies) const { pimpl->GetNumberOfSupportedSpecies(numberOfSupportedSpecies); } int SimulatorModel::GetSupportedSpecies( int const index, std::string const ** const speciesName) const { return pimpl->GetSupportedSpecies(index, speciesName); } void SimulatorModel::OpenAndInitializeTemplateMap() { pimpl->OpenAndInitializeTemplateMap(); } int SimulatorModel::TemplateMapIsOpen() const { return pimpl->TemplateMapIsOpen(); } int SimulatorModel::AddTemplateMap(std::string const & key, std::string const & value) { return pimpl->AddTemplateMap(key, value); } void SimulatorModel::CloseTemplateMap() { pimpl->CloseTemplateMap(); } void SimulatorModel::GetNumberOfSimulatorFields( int * const numberOfSimulatorFields) const { pimpl->GetNumberOfSimulatorFields(numberOfSimulatorFields); } int SimulatorModel::GetSimulatorFieldMetadata( int const fieldIndex, int * const extent, std::string const ** const fieldName) const { return pimpl->GetSimulatorFieldMetadata(fieldIndex, extent, fieldName); } int SimulatorModel::GetSimulatorFieldLine( int const fieldIndex, int const lineIndex, std::string const ** const lineValue) const { return pimpl->GetSimulatorFieldLine(fieldIndex, lineIndex, lineValue); } void SimulatorModel::GetParameterFileDirectoryName( std::string const ** const directoryName) const { pimpl->GetParameterFileDirectoryName(directoryName); } void SimulatorModel::GetSpecificationFileName( std::string const ** const specificationFileName) const { pimpl->GetSpecificationFileName(specificationFileName); } void SimulatorModel::GetNumberOfParameterFiles( int * const numberOfParameterFiles) const { pimpl->GetNumberOfParameterFiles(numberOfParameterFiles); } int SimulatorModel::GetParameterFileName( int const index, std::string const ** const parameterFileName) const { return pimpl->GetParameterFileName(index, parameterFileName); } int SimulatorModel::GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const { return pimpl->GetParameterFileBasename(index, parameterFileBasename); } void SimulatorModel::SetSimulatorBufferPointer(void * const ptr) { pimpl->SetSimulatorBufferPointer(ptr); } void SimulatorModel::GetSimulatorBufferPointer(void ** const ptr) const { pimpl->GetSimulatorBufferPointer(ptr); } std::string const & SimulatorModel::ToString() const { return pimpl->ToString(); } void SimulatorModel::SetLogID(std::string const & logID) { pimpl->SetLogID(logID); } void SimulatorModel::PushLogVerbosity(LogVerbosity const logVerbosity) { pimpl->PushLogVerbosity(logVerbosity); } void SimulatorModel::PopLogVerbosity() { pimpl->PopLogVerbosity(); } SimulatorModel::SimulatorModel() : pimpl(NULL) {} SimulatorModel::~SimulatorModel() {} } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_SimulatorModelImplementation.cpp000066400000000000000000000762451421473465500243000ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include "edn-cpp/edn.hpp" #include #include #include #include #include #include #include #ifndef KIM_SIMULATOR_MODEL_IMPLEMENTATION_HPP_ #include "KIM_SimulatorModelImplementation.hpp" #endif #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_LOG_HPP_ #include "KIM_Log.hpp" #endif #ifndef KIM_COLLECTION_ITEM_TYPE_HPP_ #include "KIM_CollectionItemType.hpp" #endif #ifndef KIM_COLLECTIONS_HPP_ #include "KIM_Collections.hpp" #endif #ifndef KIM_SHARED_LIBRARY_HPP_ #include "KIM_SharedLibrary.hpp" #endif // log helpers #define SNUM(x) \ static_cast(std::ostringstream() \ << std::dec << x) \ .str() #define SPTR(x) \ static_cast(std::ostringstream() \ << static_cast(x)) \ .str() #define SFUNC(x) \ static_cast( \ std::ostringstream() << reinterpret_cast(x)) \ .str() #include "KIM_LogMacros.hpp" #define KIM_LOGGER_OBJECT_NAME this namespace KIM { int SimulatorModelImplementation::Create( std::string const & simulatorModelName, SimulatorModelImplementation ** const simulatorModelImplementation) { // error checking of arguments performed as part of SimulatorModelCreate() Log * pLog; int error = Log::Create(&pLog); if (error) { *simulatorModelImplementation = NULL; return true; } SimulatorModelImplementation * pSimulatorModelImplementation; pSimulatorModelImplementation = new SimulatorModelImplementation(new SharedLibrary(pLog), pLog); #if DEBUG_VERBOSITY std::string const callString = "Create('" + simulatorModelName + "', " + SPTR(simulatorModelImplementation) + ")."; pSimulatorModelImplementation->LogEntry( LOG_VERBOSITY::debug, "Created Log and SimulatorModelImplementation objects after enter " + callString, __LINE__, __FILE__); #endif error = pSimulatorModelImplementation->Initialize(simulatorModelName); if (error) { #if DEBUG_VERBOSITY pSimulatorModelImplementation->LogEntry( LOG_VERBOSITY::debug, "Destroying SimulatorModelImplementation object and exit " + callString, __LINE__, __FILE__); #endif delete pSimulatorModelImplementation; // also deletes Log object *simulatorModelImplementation = NULL; return true; } *simulatorModelImplementation = pSimulatorModelImplementation; #if DEBUG_VERBOSITY (*simulatorModelImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Exit 0=" + callString, __LINE__, __FILE__); #endif return false; } void SimulatorModelImplementation::Destroy( SimulatorModelImplementation ** const simulatorModelImplementation) { #if DEBUG_VERBOSITY std::string callString = "Destroy(" + SPTR(simulatorModelImplementation) + ")."; (*simulatorModelImplementation) ->LogEntry( LOG_VERBOSITY::debug, "Enter " + callString, __LINE__, __FILE__); #endif #if DEBUG_VERBOSITY (*simulatorModelImplementation) ->LogEntry(LOG_VERBOSITY::debug, "Destroying SimulatorModelImplementation object and exit " + callString, __LINE__, __FILE__); #endif delete *simulatorModelImplementation; // also deletes Log object *simulatorModelImplementation = NULL; } void SimulatorModelImplementation::GetSimulatorNameAndVersion( std::string const ** const simulatorName, std::string const ** const simulatorVersion) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorNameAndVersion(" + SPTR(simulatorName) + ", " + SPTR(simulatorVersion) + ")."; #endif LOG_DEBUG("Enter " + callString); if (simulatorName != NULL) *simulatorName = &simulatorName_; if (simulatorVersion != NULL) *simulatorVersion = &simulatorVersion_; LOG_DEBUG("Exit 0=" + callString); } void SimulatorModelImplementation::GetNumberOfSupportedSpecies( int * const numberOfSupportedSpecies) const { *numberOfSupportedSpecies = simulatorSupportedSpecies_.size(); } int SimulatorModelImplementation::GetSupportedSpecies( int const index, std::string const ** const speciesName) const { #if DEBUG_VERBOSITY std::string const callString = "GetSupportedSpecies(" + SNUM(index) + ", " + SPTR(speciesName) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((index < 0) || (static_cast(index) >= simulatorSupportedSpecies_.size())) { LOG_ERROR("Invalid index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *speciesName = &(simulatorSupportedSpecies_[index]); LOG_DEBUG("Exit 0=" + callString); return false; } void SimulatorModelImplementation::OpenAndInitializeTemplateMap() { #if DEBUG_VERBOSITY std::string const callString = "OpenAndInitializeTemplateMap()."; #endif LOG_DEBUG("Enter " + callString); templateMapOpen_ = true; // clear data templateMap_.clear(); simulatorFields_.clear(); AddStandardTemplatesToMap(); LOG_DEBUG("Exit 0=" + callString); } int SimulatorModelImplementation::TemplateMapIsOpen() const { #if DEBUG_VERBOSITY std::string const callString = "TemplateMapIsOpen()."; #endif LOG_DEBUG("Enter " + callString); int result = templateMapOpen_; LOG_DEBUG("Exit " + SNUM(result) + "=" + callString); return result; } int SimulatorModelImplementation::AddTemplateMap(std::string const & key, std::string const & value) { #if DEBUG_VERBOSITY std::string const callString = "AddTemplateMap('" + key + "', '" + value + "')."; #endif LOG_DEBUG("Enter " + callString); if (!templateMapOpen_) { LOG_ERROR("Template map is closed."); LOG_DEBUG("Exit 1=" + callString); return true; } char allowedCharacters[] = "abcdefghijklmnopqrstuvwxyz" "-0123456789"; if (key.find_first_not_of(allowedCharacters) == std::string::npos) { templateMap_[key] = value; } else { LOG_ERROR("Invalid template key, '" + key + "'."); LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Exit 0=" + callString); return false; } void SimulatorModelImplementation::CloseTemplateMap() { #if DEBUG_VERBOSITY std::string const callString = "CloseTemplateMap()."; #endif LOG_DEBUG("Enter " + callString); templateMapOpen_ = false; ProcessSimulatorFields(); LOG_DEBUG("Exit 0=" + callString); } void SimulatorModelImplementation::AddStandardTemplatesToMap() { #if DEBUG_VERBOSITY std::string const callString = "AddStandardTemplatesToMap()."; #endif LOG_DEBUG("Enter " + callString); AddTemplateMap("parameter-file-dir", parameterFileDirectoryName_.string()); for (size_t i = 0; i < parameterFileBasenames_.size(); ++i) { AddTemplateMap("parameter-file-basename-" + SNUM(i + 1), parameterFileBasenames_[i]); AddTemplateMap( "parameter-file-" + SNUM(i + 1), (parameterFileDirectoryName_ / parameterFileBasenames_[i]).string()); } LOG_DEBUG("Exit 0=" + callString); } int SimulatorModelImplementation::ProcessSimulatorFields() { #if DEBUG_VERBOSITY std::string const callString = "ProcessSimulatorFields()."; #endif LOG_DEBUG("Enter " + callString); if (templateMapOpen_) { LOG_ERROR("Template map is open."); LOG_DEBUG("Exit 1=" + callString); return true; } simulatorFields_.clear(); for (size_t i = 0; i < originalSimulatorFields_.size(); ++i) { std::vector lines; for (size_t j = 0; j < originalSimulatorFields_[i].size(); ++j) { std::string line(originalSimulatorFields_[i][j]); for (std::map::const_iterator itr = templateMap_.begin(); itr != templateMap_.end(); ++itr) { std::string const key = "@<" + itr->first + ">@"; size_t pos = 0; while ((pos = line.find(key, pos)) != std::string::npos) { line.replace(pos, key.length(), itr->second); pos += (itr->second).length(); } } lines.push_back(line); } simulatorFields_.push_back(lines); } LOG_DEBUG("Exit 0=" + callString); return false; } void SimulatorModelImplementation::GetNumberOfSimulatorFields( int * const numberOfSimulatorFields) const { #if DEBUG_VERBOSITY std::string const callString = "GetNumberOfSimulatorFields(" + SPTR(numberOfSimulatorFields) + ")."; #endif LOG_DEBUG("Enter " + callString); *numberOfSimulatorFields = originalSimulatorFields_.size(); LOG_DEBUG("Exit 0=" + callString); } int SimulatorModelImplementation::GetSimulatorFieldMetadata( int const fieldIndex, int * const extent, std::string const ** const fieldName) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorFieldMetadata(" + SNUM(fieldIndex) + ", " + SPTR(extent) + ", " + SPTR(fieldName) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((fieldIndex < 0) || (static_cast(fieldIndex) >= originalSimulatorFields_.size())) { LOG_ERROR("Invalid simulator field index, " + SNUM(fieldIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif if (extent != NULL) *extent = originalSimulatorFields_[fieldIndex].size(); if (fieldName != NULL) *fieldName = &simulatorFieldNames_[fieldIndex]; LOG_DEBUG("Exit 0=" + callString); return false; } int SimulatorModelImplementation::GetSimulatorFieldLine( int const fieldIndex, int const lineIndex, std::string const ** const lineValue) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorFieldLine(" + SNUM(fieldIndex) + ", " + SNUM(lineIndex) + ", " + SPTR(lineValue) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if (templateMapOpen_) { LOG_ERROR("Simulator field lines are not available while the template map " "is open."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((fieldIndex < 0) || (static_cast(fieldIndex) >= simulatorFields_.size())) { LOG_ERROR("Invalid simulator field index, " + SNUM(fieldIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } if ((lineIndex < 0) || (static_cast(lineIndex) >= simulatorFields_[fieldIndex].size())) { LOG_ERROR("Invalid simulator field line index, " + SNUM(lineIndex) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *lineValue = &(simulatorFields_[fieldIndex][lineIndex]); LOG_DEBUG("Exit 0=" + callString); return false; } void SimulatorModelImplementation::GetParameterFileDirectoryName( std::string const ** const directoryName) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileDirectoryName(" + SPTR(directoryName) + ")."; #endif LOG_DEBUG("Enter " + callString); *directoryName = ¶meterFileDirectoryNameString_; LOG_DEBUG("Exit 0=" + callString); } void SimulatorModelImplementation::GetSpecificationFileName( std::string const ** const specificationFileName) const { #if DEBUG_VERBOSITY std::string const callString = "GetSpecificationFileName(" + SPTR(specificationFileName) + ")."; #endif LOG_DEBUG("Enter " + callString); *specificationFileName = &specificationFileName_; LOG_DEBUG("Exit 0=" + callString); } void SimulatorModelImplementation::GetNumberOfParameterFiles( int * const numberOfParameterFiles) const { #if DEBUG_VERBOSITY std::string const callString = "GetNumberOfParameterFiles(" + SPTR(numberOfParameterFiles) + ")."; #endif LOG_DEBUG("Enter " + callString); *numberOfParameterFiles = numberOfParameterFiles_; LOG_DEBUG("Exit 0=" + callString); } int SimulatorModelImplementation::GetParameterFileName( int const index, std::string const ** const parameterFileName) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileName(" + SNUM(index) + ", " + SPTR(parameterFileName) + ")."; #endif LOG_DEBUG("Enter " + callString); LOG_WARNING("Use of the " + callString + " function is deprecated. " "Please use GetParameterFileBasename() instead."); #if ERROR_VERBOSITY if ((index < 0) || (index >= numberOfParameterFiles_)) { LOG_ERROR("Invalid parameter file index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *parameterFileName = ¶meterFileBasenames_[index]; LOG_DEBUG("Exit 0=" + callString); return false; } int SimulatorModelImplementation::GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const { #if DEBUG_VERBOSITY std::string const callString = "GetParameterFileBasename(" + SNUM(index) + ", " + SPTR(parameterFileBasename) + ")."; #endif LOG_DEBUG("Enter " + callString); #if ERROR_VERBOSITY if ((index < 0) || (index >= numberOfParameterFiles_)) { LOG_ERROR("Invalid parameter file index, " + SNUM(index) + "."); LOG_DEBUG("Exit 1=" + callString); return true; } #endif *parameterFileBasename = ¶meterFileBasenames_[index]; LOG_DEBUG("Exit 0=" + callString); return false; } void SimulatorModelImplementation::SetSimulatorBufferPointer(void * const ptr) { #if DEBUG_VERBOSITY std::string const callString = "SetSimulatorBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); simulatorBuffer_ = ptr; LOG_DEBUG("Exit " + callString); } void SimulatorModelImplementation::GetSimulatorBufferPointer( void ** const ptr) const { #if DEBUG_VERBOSITY std::string const callString = "GetSimulatorBufferPointer(" + SPTR(ptr) + ")."; #endif LOG_DEBUG("Enter " + callString); *ptr = simulatorBuffer_; LOG_DEBUG("Exit " + callString); } void SimulatorModelImplementation::SetLogID(std::string const & logID) { #if DEBUG_VERBOSITY std::string const callString = "SetLogID('" + logID + "')."; #endif LOG_DEBUG("Enter " + callString); log_->SetID(logID); LOG_DEBUG("Exit " + callString); } void SimulatorModelImplementation::PushLogVerbosity( LogVerbosity const logVerbosity) { #if DEBUG_VERBOSITY std::string const callString = "PushLogVerbosity(" + logVerbosity.ToString() + ")."; #endif LOG_DEBUG("Enter " + callString); log_->PushVerbosity(logVerbosity); LOG_DEBUG("Exit " + callString); } void SimulatorModelImplementation::PopLogVerbosity() { #if DEBUG_VERBOSITY std::string const callString = "PopLogVerbosity()."; #endif LOG_DEBUG("Enter " + callString); log_->PopVerbosity(); LOG_DEBUG("Exit " + callString); } void SimulatorModelImplementation::LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } void SimulatorModelImplementation::LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const { // No debug logs to avoid infinite loop log_->LogEntry(logVerbosity, message, lineNumber, fileName); } std::string const & SimulatorModelImplementation::ToString() const { #if DEBUG_VERBOSITY std::string const callString = "ToString()."; #endif LOG_DEBUG("Enter " + callString); std::stringstream ss; ss << std::setprecision(10) << std::scientific << std::left; ss << "====================================================================" "============\n\n"; ss << "SimulatorModel object\n" << "------------\n\n"; ss << "SimulatorModel Name : " << simulatorModelName_ << "\n"; ss << "Log ID : " << log_->GetID() << "\n"; ss << "\n"; ss << "Parameter file directory : " << parameterFileDirectoryName_.string() << "\n"; ss << "Specification file name : " << specificationFileName_ << "\n\n"; ss << "Simulator Name : " << simulatorName_ << "\n" << "Simulator Version : " << simulatorVersion_ << "\n" << "Number of supported species : " << simulatorSupportedSpecies_.size() << "\n"; for (size_t i = 0; i < simulatorSupportedSpecies_.size(); ++i) { ss << "\tindex : " << i << "\t'" << simulatorSupportedSpecies_[i] << "'\n"; } ss << "\n"; ss << "Number of parameter files : " << numberOfParameterFiles_ << "\n" << "Parameter files :\n"; for (int i = 0; i < numberOfParameterFiles_; ++i) { ss << "\t" << "index : " << i << "\n" << "\t " << "name : " << parameterFileBasenames_[i] << "\n\n"; } ss << "Original simulator fields :\n"; for (size_t i = 0; i < originalSimulatorFields_.size(); ++i) { ss << "\t" << simulatorFieldNames_[i] << " :\n"; for (size_t j = 0; j < originalSimulatorFields_[i].size(); ++j) { ss << "\t * '" << originalSimulatorFields_[i][j] << "'\n"; } } ss << "\n"; ss << "Template Map is : " << ((templateMapOpen_) ? "open" : "closed") << "\n"; ss << "Template Map contents :\n"; for (std::map::const_iterator itr = templateMap_.begin(); itr != templateMap_.end(); ++itr) { ss << "\t" << std::setw(20) << itr->first << " -> " << std::setw(20) << itr->second << "\n"; } ss << "\n"; ss << "Simulator fields :\n"; for (size_t i = 0; i < simulatorFields_.size(); ++i) { ss << "\t" << simulatorFieldNames_[i] << " :\n"; for (size_t j = 0; j < simulatorFields_[i].size(); ++j) { ss << "\t * '" << simulatorFields_[i][j] << "'\n"; } } ss << "\n"; ss << "Simulator buffer: " << SPTR(simulatorBuffer_) << "\n\n"; ss << "====================================================================" "============\n"; string_ = ss.str(); LOG_DEBUG("Exit " + callString); return string_; } SimulatorModelImplementation::SimulatorModelImplementation( SharedLibrary * const sharedLibrary, Log * const log) : simulatorModelName_(""), sharedLibrary_(sharedLibrary), log_(log), schemaVersion_(0), modelName_(""), simulatorName_(""), simulatorVersion_(""), numberOfParameterFiles_(0), templateMapOpen_(true), simulatorBuffer_(NULL), string_("") { #if DEBUG_VERBOSITY std::string const callString = "SimulatorModelImplementation(" + SPTR(sharedLibrary) + ", " + SPTR(log) + ")."; #endif LOG_DEBUG("Enter " + callString); LOG_DEBUG("Exit " + callString); } SimulatorModelImplementation::~SimulatorModelImplementation() { #if DEBUG_VERBOSITY std::string const callString = "~SimulatorModelImplementation()."; #endif LOG_DEBUG("Enter " + callString); sharedLibrary_->RemoveParameterFileDirectory(); if (sharedLibrary_->IsOpen()) sharedLibrary_->Close(); delete sharedLibrary_; LOG_DEBUG("Destroying Log object and exit " + callString); Log::Destroy(&log_); } int SimulatorModelImplementation::Initialize( std::string const & simulatorModelName) { #if DEBUG_VERBOSITY std::string const callString = "Initialize(" + simulatorModelName + ")."; #endif LOG_DEBUG("Enter " + callString); simulatorModelName_ = simulatorModelName; std::string const * itemFilePath; Collections * collections = NULL; int error = Collections::Create(&collections); if (error) { LOG_ERROR("Could not create Collections object."); LOG_DEBUG("Exit 1=" + callString); return true; } collections->SetLogID(log_->GetID() + "_Collections"); error = collections->GetItemLibraryFileNameAndCollection( COLLECTION_ITEM_TYPE::simulatorModel, simulatorModelName, &itemFilePath, NULL); if (error) { LOG_ERROR("Could not find simulator model shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } error = sharedLibrary_->Open(*itemFilePath); if (error) { LOG_ERROR("Could not open simulator model shared library."); LOG_DEBUG("Exit 1=" + callString); return true; } Collections::Destroy(&collections); CollectionItemType itemType; error = sharedLibrary_->GetType(&itemType); if (error) { LOG_ERROR("Unable to get shared library type."); LOG_DEBUG("Exit 1=" + callString); return true; } { using namespace COLLECTION_ITEM_TYPE; if (itemType == simulatorModel) { LOG_DEBUG("Initializing a simulator model."); } else if (itemType == portableModel) { LOG_ERROR("Creation of a portable model is not allowed."); LOG_DEBUG("Exit 1=" + callString); return true; } else if (itemType == modelDriver) { LOG_ERROR("Creation of a model driver is not allowed."); LOG_DEBUG("Exit 1=" + callString); return true; } else { LOG_ERROR("Creation of an unknown item type is not allowed."); LOG_DEBUG("Exit 1=" + callString); return true; } } // create parameter files on disk and set associated variables error = sharedLibrary_->WriteParameterFileDirectory() || sharedLibrary_->GetSimulatorModelSpecificationFile( &specificationFileName_, NULL, NULL) || sharedLibrary_->GetParameterFileDirectoryName( ¶meterFileDirectoryName_) || sharedLibrary_->GetNumberOfParameterFiles(&numberOfParameterFiles_); for (int i = 0; i < numberOfParameterFiles_; ++i) { std::string parameterFileBasename; error = error || sharedLibrary_->GetParameterFile( i, ¶meterFileBasename, NULL, NULL); if (!error) { parameterFileBasenames_.push_back(parameterFileBasename); } } if (error) { sharedLibrary_->RemoveParameterFileDirectory(); LOG_ERROR("Could not write parameter file directory to scratch space."); LOG_DEBUG("Exit 1=" + callString); return true; } // Convert path to string representation. parameterFileDirectoryNameString_ = parameterFileDirectoryName_.string(); if (GetSchemaVersion()) { // GetSchemaVersion() logs error LOG_DEBUG("Exit 1=" + callString); return true; } if (schemaVersion_ == 1) { if (ReadEdnSchemaV1()) { // ReadEdnSchemaV1() logs error LOG_DEBUG("Exit 1=" + callString); return true; } } else { LOG_ERROR("Shouldn't ever get here."); LOG_DEBUG("Exit 1=" + callString); return true; } // check for all required data if (modelName_ == "") { LOG_ERROR("Required specification field 'model-name' not found."); LOG_DEBUG("Exit 1=" + callString); return true; } else if (modelName_ != simulatorModelName_) { LOG_ERROR( "Specificaiton field 'model-name' not equal to simulator model name."); LOG_DEBUG("Exit 1=" + callString); return true; } if (simulatorName_ == "") { LOG_ERROR("Required specification field 'simulator-name' not found."); LOG_DEBUG("Exit 1=" + callString); return true; } if (simulatorVersion_ == "") { LOG_ERROR("Required specification field 'simulator-version' not found."); LOG_DEBUG("Exit 1=" + callString); return true; } if (simulatorSupportedSpecies_.size() == 0) { LOG_ERROR("Required specification field 'supported-species' not found."); LOG_DEBUG("Exit 1=" + callString); return true; } OpenAndInitializeTemplateMap(); LOG_DEBUG("Exit 0=" + callString); return false; } int SimulatorModelImplementation::ParseEdn(edn::EdnNode & node) const { #if DEBUG_VERBOSITY std::string const callString = "ParseEdn()."; #endif LOG_DEBUG("Enter " + callString); FILESYSTEM::Path const filePath = parameterFileDirectoryName_ / specificationFileName_; std::ifstream ifs; ifs.open(filePath.string().c_str()); if (!ifs.is_open()) { LOG_ERROR("Unable to open simulator model metatdata file."); LOG_DEBUG("Exit 1=" + callString); return true; } std::string ednString((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); ifs.close(); try { node = edn::read(ednString); } catch (std::string e) { LOG_ERROR("Unable to parse EDN file: " + e + "."); LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Exit 0=" + callString); return false; } int SimulatorModelImplementation::GetSchemaVersion() { #if DEBUG_VERBOSITY std::string const callString = "GetSchemaVersion()."; #endif LOG_DEBUG("Enter " + callString); edn::EdnNode node; if (ParseEdn(node)) { // ParseEdn() logs error LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Read " + edn::typeToString(node.type) + ": " + node.value + "."); if (node.type == edn::EdnMap) { std::list::const_iterator itr; for (itr = node.values.begin(); itr != node.values.end(); ++itr) { // find key if (itr->type == edn::EdnString) { std::string key(itr->value); LOG_DEBUG("Read " + edn::typeToString(itr->type) + ": " + itr->value + "."); // get value ++itr; LOG_DEBUG("Read " + edn::typeToString(itr->type) + ": " + itr->value + "."); if (key == "kim-api-sm-schema-version") { if (itr->type == edn::EdnInt) { std::istringstream(itr->value) >> schemaVersion_; } else { LOG_ERROR("Expecting 'EdnInt'."); LOG_DEBUG("Exit 1=" + callString); return true; } } } } } else { LOG_ERROR("Expecting 'EdnMap'."); LOG_DEBUG("Exit 1=" + callString); return true; } if (schemaVersion_ != 1) { LOG_ERROR("Unsupported schema version found."); LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Exit 0=" + callString); return false; } int SimulatorModelImplementation::ReadEdnSchemaV1() { #if DEBUG_VERBOSITY std::string const callString = "ReadEdnSchemaV1()."; #endif LOG_DEBUG("Enter " + callString); edn::EdnNode node; if (ParseEdn(node)) { // ParseEdn() logs error LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Read " + edn::typeToString(node.type) + ": " + node.value + "."); if (node.type == edn::EdnMap) { std::list::const_iterator itr; for (itr = node.values.begin(); itr != node.values.end(); ++itr) { // find key if (itr->type == edn::EdnString) { std::string key(itr->value); LOG_DEBUG("Read " + edn::typeToString(itr->type) + ": " + itr->value + "."); // get value ++itr; LOG_DEBUG("Read " + edn::typeToString(itr->type) + ": " + itr->value + "."); if (key == "kim-api-sm-schema-version") { if (itr->type == edn::EdnInt) { std::istringstream(itr->value) >> schemaVersion_; } else { LOG_ERROR("Expecting 'EdnInt'."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (key == "simulator-version") { if (itr->type == edn::EdnString) { simulatorVersion_ = itr->value; } else { LOG_ERROR("Expecting 'EdnString'."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (key == "simulator-name") { if (itr->type == edn::EdnString) { simulatorName_ = itr->value; } else { LOG_ERROR("Expecting 'EdnString'."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (key == "supported-species") { if (itr->type == edn::EdnString) { std::stringstream ss(itr->value); while (ss) { std::string species; ss >> species; if (species != "") simulatorSupportedSpecies_.push_back(species); } } else { LOG_ERROR("Expecting 'EdnString'."); LOG_DEBUG("Exit 1=" + callString); return true; } } else if (key == "model-name") { if (itr->type == edn::EdnString) { modelName_ = itr->value; } else { LOG_ERROR("Expecting 'EdnString'."); LOG_DEBUG("Exit 1=" + callString); return true; } } else // simulator field { simulatorFieldNames_.push_back(key); std::vector lines; if (itr->type == edn::EdnVector) { std::list::const_iterator vec; for (vec = itr->values.begin(); vec != itr->values.end(); ++vec) { LOG_DEBUG("Read " + edn::typeToString(vec->type) + ": " + vec->value + "."); if (vec->type == edn::EdnString) { lines.push_back(vec->value); } else { LOG_ERROR("Expecting 'EdnString'."); LOG_DEBUG("Exit 1=" + callString); return true; } } } else if (itr->type == edn::EdnString) { lines.push_back(itr->value); } else { LOG_ERROR("Expecting 'EdnVector' or 'EdnString'."); LOG_DEBUG("Exit 1=" + callString); return true; } originalSimulatorFields_.push_back(lines); } } } } else { LOG_ERROR("Expecting 'EdnMap'."); LOG_DEBUG("Exit 1=" + callString); return true; } LOG_DEBUG("Exit 0=" + callString); return false; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_SimulatorModelImplementation.hpp000066400000000000000000000124401421473465500242700ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #ifndef KIM_SIMULATOR_MODEL_IMPLEMENTATION_HPP_ #define KIM_SIMULATOR_MODEL_IMPLEMENTATION_HPP_ #include #include #include #include #ifndef KIM_LOG_VERBOSITY_HPP_ #include "KIM_LogVerbosity.hpp" #endif #ifndef KIM_FILESYSTEM_PATH_HPP_ #include "KIM_FilesystemPath.hpp" #endif namespace edn { // Forward declarations struct EdnNode; } // namespace edn namespace KIM { // Forward declarations class Log; class SharedLibrary; class SimulatorModelImplementation { public: static int Create(std::string const & simulatorModelName, SimulatorModelImplementation ** const simulatorModelImplementation); static void Destroy(SimulatorModelImplementation ** const simulatorModelImplementation); void GetSimulatorNameAndVersion(std::string const ** const simulatorString, std::string const ** const simulatorVersion) const; void GetNumberOfSupportedSpecies(int * const numberOfSupportedSpecies) const; int GetSupportedSpecies(int const index, std::string const ** const speciesName) const; void OpenAndInitializeTemplateMap(); int TemplateMapIsOpen() const; int AddTemplateMap(std::string const & key, std::string const & value); void CloseTemplateMap(); void GetNumberOfSimulatorFields(int * const numberOfSimulatorFields) const; int GetSimulatorFieldMetadata(int const fieldIndex, int * const extent, std::string const ** const fieldName) const; int GetSimulatorFieldLine(int const fieldIndex, int const lineIndex, std::string const ** const lineValue) const; void GetParameterFileDirectoryName(std::string const ** const directoryName) const; void GetSpecificationFileName( std::string const ** const specificationFileName) const; void GetNumberOfParameterFiles(int * const numberOfParameterFiles) const; int GetParameterFileName(int const index, std::string const ** const parameterFileName) const; int GetParameterFileBasename( int const index, std::string const ** const parameterFileBasename) const; void SetSimulatorBufferPointer(void * const ptr); void GetSimulatorBufferPointer(void ** const ptr) const; void LogEntry(LogVerbosity const logVerbosity, std::string const & message, int const lineNumber, std::string const & fileName) const; void LogEntry(LogVerbosity const logVerbosity, std::stringstream const & message, int const lineNumber, std::string const & fileName) const; std::string const & ToString() const; void SetLogID(std::string const & logID); void PushLogVerbosity(LogVerbosity const logVerbosity); void PopLogVerbosity(); private: // do not allow copy constructor or operator= SimulatorModelImplementation(SimulatorModelImplementation const &); void operator=(SimulatorModelImplementation const &); SimulatorModelImplementation(SharedLibrary * const sharedLibrary, Log * const log); ~SimulatorModelImplementation(); std::string simulatorModelName_; SharedLibrary * sharedLibrary_; Log * log_; int ParseEdn(edn::EdnNode & node) const; int GetSchemaVersion(); int ReadEdnSchemaV1(); int Initialize(std::string const & simulatorModelName); FILESYSTEM::Path parameterFileDirectoryName_; std::string parameterFileDirectoryNameString_; std::string specificationFileName_; int schemaVersion_; std::string modelName_; std::string simulatorName_; std::string simulatorVersion_; std::vector simulatorSupportedSpecies_; std::vector simulatorFieldNames_; std::vector > originalSimulatorFields_; std::vector > simulatorFields_; int numberOfParameterFiles_; std::vector parameterFileBasenames_; bool templateMapOpen_; std::map templateMap_; void AddStandardTemplatesToMap(); int ProcessSimulatorFields(); void * simulatorBuffer_; mutable std::string string_; }; // class SimulatorModelImplementation } // namespace KIM #endif // KIM_SIMULATOR_MODEL_IMPLEMENTATION_HPP_ kim-api-2.3.0-git/cpp/src/KIM_SpeciesName.cpp000066400000000000000000000271051421473465500206150ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_SPECIES_NAME_HPP_ #include "KIM_SpeciesName.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace SPECIES_NAME { #include "KIM_SpeciesName.inc" SpeciesName const electron(ID_electron); // electron SpeciesName const H(ID_H); // Hydrogen SpeciesName const He(ID_He); // Helium SpeciesName const Li(ID_Li); // Lithium SpeciesName const Be(ID_Be); // Beryllium SpeciesName const B(ID_B); // Boron SpeciesName const C(ID_C); // Carbon SpeciesName const N(ID_N); // Nitrogen SpeciesName const O(ID_O); // Oxygen SpeciesName const F(ID_F); // Fluorine SpeciesName const Ne(ID_Ne); // Neon SpeciesName const Na(ID_Na); // Sodium SpeciesName const Mg(ID_Mg); // Magnesium SpeciesName const Al(ID_Al); // Aluminum SpeciesName const Si(ID_Si); // Silicon SpeciesName const P(ID_P); // Phosphorus SpeciesName const S(ID_S); // Sulfur SpeciesName const Cl(ID_Cl); // Chlorine SpeciesName const Ar(ID_Ar); // Argon SpeciesName const K(ID_K); // Potassium SpeciesName const Ca(ID_Ca); // Calcium SpeciesName const Sc(ID_Sc); // Scandium SpeciesName const Ti(ID_Ti); // Titanium SpeciesName const V(ID_V); // Vanadium SpeciesName const Cr(ID_Cr); // Chromium SpeciesName const Mn(ID_Mn); // Manganese SpeciesName const Fe(ID_Fe); // Iron SpeciesName const Co(ID_Co); // Cobalt SpeciesName const Ni(ID_Ni); // Nickel SpeciesName const Cu(ID_Cu); // Copper SpeciesName const Zn(ID_Zn); // Zinc SpeciesName const Ga(ID_Ga); // Gallium SpeciesName const Ge(ID_Ge); // Germanium SpeciesName const As(ID_As); // Arsenic SpeciesName const Se(ID_Se); // Selenium SpeciesName const Br(ID_Br); // Bromine SpeciesName const Kr(ID_Kr); // Krypton SpeciesName const Rb(ID_Rb); // Rubidium SpeciesName const Sr(ID_Sr); // Strontium SpeciesName const Y(ID_Y); // Yttrium SpeciesName const Zr(ID_Zr); // Zirconium SpeciesName const Nb(ID_Nb); // Niobium SpeciesName const Mo(ID_Mo); // Molybdenum SpeciesName const Tc(ID_Tc); // Technetium SpeciesName const Ru(ID_Ru); // Ruthenium SpeciesName const Rh(ID_Rh); // Rhodium SpeciesName const Pd(ID_Pd); // Palladium SpeciesName const Ag(ID_Ag); // Silver SpeciesName const Cd(ID_Cd); // Cadmium SpeciesName const In(ID_In); // Indium SpeciesName const Sn(ID_Sn); // Tin SpeciesName const Sb(ID_Sb); // Antimony SpeciesName const Te(ID_Te); // Tellurium SpeciesName const I(ID_I); // Iodine SpeciesName const Xe(ID_Xe); // Xenon SpeciesName const Cs(ID_Cs); // Cesium SpeciesName const Ba(ID_Ba); // Barium SpeciesName const La(ID_La); // Lanthanum SpeciesName const Ce(ID_Ce); // Cerium SpeciesName const Pr(ID_Pr); // Praseodymium SpeciesName const Nd(ID_Nd); // Neodymium SpeciesName const Pm(ID_Pm); // Promethium SpeciesName const Sm(ID_Sm); // Samarium SpeciesName const Eu(ID_Eu); // Europium SpeciesName const Gd(ID_Gd); // Gadolinium SpeciesName const Tb(ID_Tb); // Terbium SpeciesName const Dy(ID_Dy); // Dysprosium SpeciesName const Ho(ID_Ho); // Holmium SpeciesName const Er(ID_Er); // Erbium SpeciesName const Tm(ID_Tm); // Thulium SpeciesName const Yb(ID_Yb); // Ytterbium SpeciesName const Lu(ID_Lu); // Lutetium SpeciesName const Hf(ID_Hf); // Hafnium SpeciesName const Ta(ID_Ta); // Tantalum SpeciesName const W(ID_W); // Tungsten SpeciesName const Re(ID_Re); // Rhenium SpeciesName const Os(ID_Os); // Osmium SpeciesName const Ir(ID_Ir); // Iridium SpeciesName const Pt(ID_Pt); // Platinum SpeciesName const Au(ID_Au); // Gold SpeciesName const Hg(ID_Hg); // Mercury SpeciesName const Tl(ID_Tl); // Thallium SpeciesName const Pb(ID_Pb); // Lead SpeciesName const Bi(ID_Bi); // Bismuth SpeciesName const Po(ID_Po); // Polonium SpeciesName const At(ID_At); // Astatine SpeciesName const Rn(ID_Rn); // Radon SpeciesName const Fr(ID_Fr); // Francium SpeciesName const Ra(ID_Ra); // Radium SpeciesName const Ac(ID_Ac); // Actinium SpeciesName const Th(ID_Th); // Thorium SpeciesName const Pa(ID_Pa); // Protactinium SpeciesName const U(ID_U); // Uranium SpeciesName const Np(ID_Np); // Neptunium SpeciesName const Pu(ID_Pu); // Plutonium SpeciesName const Am(ID_Am); // Americium SpeciesName const Cm(ID_Cm); // Curium SpeciesName const Bk(ID_Bk); // Berkelium SpeciesName const Cf(ID_Cf); // Californium SpeciesName const Es(ID_Es); // Einsteinium SpeciesName const Fm(ID_Fm); // Fermium SpeciesName const Md(ID_Md); // Mendelevium SpeciesName const No(ID_No); // Nobelium SpeciesName const Lr(ID_Lr); // Lawrencium SpeciesName const Rf(ID_Rf); // Rutherfordium SpeciesName const Db(ID_Db); // Dubnium SpeciesName const Sg(ID_Sg); // Seaborgium SpeciesName const Bh(ID_Bh); // Bohrium SpeciesName const Hs(ID_Hs); // Hassium SpeciesName const Mt(ID_Mt); // Meitnerium SpeciesName const Ds(ID_Ds); // Darmstadtium SpeciesName const Rg(ID_Rg); // Roentgenium SpeciesName const Cn(ID_Cn); // Copernicium SpeciesName const Nh(ID_Nh); // Nihonium SpeciesName const Fl(ID_Fl); // Flerovium SpeciesName const Mc(ID_Mc); // Moscovium SpeciesName const Lv(ID_Lv); // Livermorium SpeciesName const Ts(ID_Ts); // Tennessien SpeciesName const Og(ID_Og); // Oganesson SpeciesName const user01(ID_user01); // user defined SpeciesName const user02(ID_user02); // user defined SpeciesName const user03(ID_user03); // user defined SpeciesName const user04(ID_user04); // user defined SpeciesName const user05(ID_user05); // user defined SpeciesName const user06(ID_user06); // user defined SpeciesName const user07(ID_user07); // user defined SpeciesName const user08(ID_user08); // user defined SpeciesName const user09(ID_user09); // user defined SpeciesName const user10(ID_user10); // user defined SpeciesName const user11(ID_user11); // user defined SpeciesName const user12(ID_user12); // user defined SpeciesName const user13(ID_user13); // user defined SpeciesName const user14(ID_user14); // user defined SpeciesName const user15(ID_user15); // user defined SpeciesName const user16(ID_user16); // user defined SpeciesName const user17(ID_user17); // user defined SpeciesName const user18(ID_user18); // user defined SpeciesName const user19(ID_user19); // user defined SpeciesName const user20(ID_user20); // user defined namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[electron] = "electron"; m[H] = "H"; m[He] = "He"; m[Li] = "Li"; m[Be] = "Be"; m[B] = "B"; m[C] = "C"; m[N] = "N"; m[O] = "O"; m[F] = "F"; m[Ne] = "Ne"; m[Na] = "Na"; m[Mg] = "Mg"; m[Al] = "Al"; m[Si] = "Si"; m[P] = "P"; m[S] = "S"; m[Cl] = "Cl"; m[Ar] = "Ar"; m[K] = "K"; m[Ca] = "Ca"; m[Sc] = "Sc"; m[Ti] = "Ti"; m[V] = "V"; m[Cr] = "Cr"; m[Mn] = "Mn"; m[Fe] = "Fe"; m[Co] = "Co"; m[Ni] = "Ni"; m[Cu] = "Cu"; m[Zn] = "Zn"; m[Ga] = "Ga"; m[Ge] = "Ge"; m[As] = "As"; m[Se] = "Se"; m[Br] = "Br"; m[Kr] = "Kr"; m[Rb] = "Rb"; m[Sr] = "Sr"; m[Y] = "Y"; m[Zr] = "Zr"; m[Nb] = "Nb"; m[Mo] = "Mo"; m[Tc] = "Tc"; m[Ru] = "Ru"; m[Rh] = "Rh"; m[Pd] = "Pd"; m[Ag] = "Ag"; m[Cd] = "Cd"; m[In] = "In"; m[Sn] = "Sn"; m[Sb] = "Sb"; m[Te] = "Te"; m[I] = "I"; m[Xe] = "Xe"; m[Cs] = "Cs"; m[Ba] = "Ba"; m[La] = "La"; m[Ce] = "Ce"; m[Pr] = "Pr"; m[Nd] = "Nd"; m[Pm] = "Pm"; m[Sm] = "Sm"; m[Eu] = "Eu"; m[Gd] = "Gd"; m[Tb] = "Tb"; m[Dy] = "Dy"; m[Ho] = "Ho"; m[Er] = "Er"; m[Tm] = "Tm"; m[Yb] = "Yb"; m[Lu] = "Lu"; m[Hf] = "Hf"; m[Ta] = "Ta"; m[W] = "W"; m[Re] = "Re"; m[Os] = "Os"; m[Ir] = "Ir"; m[Pt] = "Pt"; m[Au] = "Au"; m[Hg] = "Hg"; m[Tl] = "Tl"; m[Pb] = "Pb"; m[Bi] = "Bi"; m[Po] = "Po"; m[At] = "At"; m[Rn] = "Rn"; m[Fr] = "Fr"; m[Ra] = "Ra"; m[Ac] = "Ac"; m[Th] = "Th"; m[Pa] = "Pa"; m[U] = "U"; m[Np] = "Np"; m[Pu] = "Pu"; m[Am] = "Am"; m[Cm] = "Cm"; m[Bk] = "Bk"; m[Cf] = "Cf"; m[Es] = "Es"; m[Fm] = "Fm"; m[Md] = "Md"; m[No] = "No"; m[Lr] = "Lr"; m[Rf] = "Rf"; m[Db] = "Db"; m[Sg] = "Sg"; m[Bh] = "Bh"; m[Hs] = "Hs"; m[Mt] = "Mt"; m[Ds] = "Ds"; m[Rg] = "Rg"; m[Cn] = "Cn"; m[Nh] = "Nh"; m[Fl] = "Fl"; m[Mc] = "Mc"; m[Lv] = "Lv"; m[Ts] = "Ts"; m[Og] = "Og"; m[user01] = "user01"; m[user02] = "user02"; m[user03] = "user03"; m[user04] = "user04"; m[user05] = "user05"; m[user06] = "user06"; m[user07] = "user07"; m[user08] = "user08"; m[user09] = "user09"; m[user10] = "user10"; m[user11] = "user11"; m[user12] = "user12"; m[user13] = "user13"; m[user14] = "user14"; m[user15] = "user15"; m[user16] = "user16"; m[user17] = "user17"; m[user18] = "user18"; m[user19] = "user19"; m[user20] = "user20"; return m; } StringMap const speciesNameToString = GetStringMap(); std::string const speciesNameUnknown("unknown"); } // namespace void GetNumberOfSpeciesNames(int * const numberOfSpeciesNames) { *numberOfSpeciesNames = speciesNameToString.size(); } int GetSpeciesName(int const index, SpeciesName * const speciesName) { int numberOfSpeciesNames; GetNumberOfSpeciesNames(&numberOfSpeciesNames); if ((index < 0) || (index >= numberOfSpeciesNames)) return true; SPECIES_NAME::StringMap::const_iterator iter = speciesNameToString.begin(); for (int i = 0; i < index; ++i) ++iter; *speciesName = iter->first; return false; // no error } } // namespace SPECIES_NAME // implementation of SpeciesName SpeciesName::SpeciesName() {} SpeciesName::SpeciesName(int const id) : speciesNameID(id) {} SpeciesName::SpeciesName(std::string const & str) { speciesNameID = -1; for (SPECIES_NAME::StringMap::const_iterator iter = SPECIES_NAME::speciesNameToString.begin(); iter != SPECIES_NAME::speciesNameToString.end(); ++iter) { if (iter->second == str) { speciesNameID = (iter->first).speciesNameID; break; } } } bool SpeciesName::Known() const { int numberOfSpeciesNames; SPECIES_NAME::GetNumberOfSpeciesNames(&numberOfSpeciesNames); for (int i = 0; i < numberOfSpeciesNames; ++i) { SpeciesName specName; SPECIES_NAME::GetSpeciesName(i, &specName); if (*this == specName) { return true; } } return false; } bool SpeciesName::operator==(SpeciesName const & rhs) const { return speciesNameID == rhs.speciesNameID; } bool SpeciesName::operator!=(SpeciesName const & rhs) const { return speciesNameID != rhs.speciesNameID; } std::string const & SpeciesName::ToString() const { SPECIES_NAME::StringMap::const_iterator iter = SPECIES_NAME::speciesNameToString.find(*this); if (iter == SPECIES_NAME::speciesNameToString.end()) return SPECIES_NAME::speciesNameUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_SpeciesName.inc000066400000000000000000000112171421473465500206010ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SPECIES_NAME_INC_ #define KIM_SPECIES_NAME_INC_ #define ID_electron 0 #define ID_H 1 #define ID_He 2 #define ID_Li 3 #define ID_Be 4 #define ID_B 5 #define ID_C 6 #define ID_N 7 #define ID_O 8 #define ID_F 9 #define ID_Ne 10 #define ID_Na 11 #define ID_Mg 12 #define ID_Al 13 #define ID_Si 14 #define ID_P 15 #define ID_S 16 #define ID_Cl 17 #define ID_Ar 18 #define ID_K 19 #define ID_Ca 20 #define ID_Sc 21 #define ID_Ti 22 #define ID_V 23 #define ID_Cr 24 #define ID_Mn 25 #define ID_Fe 26 #define ID_Co 27 #define ID_Ni 28 #define ID_Cu 29 #define ID_Zn 30 #define ID_Ga 31 #define ID_Ge 32 #define ID_As 33 #define ID_Se 34 #define ID_Br 35 #define ID_Kr 36 #define ID_Rb 37 #define ID_Sr 38 #define ID_Y 39 #define ID_Zr 40 #define ID_Nb 41 #define ID_Mo 42 #define ID_Tc 43 #define ID_Ru 44 #define ID_Rh 45 #define ID_Pd 46 #define ID_Ag 47 #define ID_Cd 48 #define ID_In 49 #define ID_Sn 50 #define ID_Sb 51 #define ID_Te 52 #define ID_I 53 #define ID_Xe 54 #define ID_Cs 55 #define ID_Ba 56 #define ID_La 57 #define ID_Ce 58 #define ID_Pr 59 #define ID_Nd 60 #define ID_Pm 61 #define ID_Sm 62 #define ID_Eu 63 #define ID_Gd 64 #define ID_Tb 65 #define ID_Dy 66 #define ID_Ho 67 #define ID_Er 68 #define ID_Tm 69 #define ID_Yb 70 #define ID_Lu 71 #define ID_Hf 72 #define ID_Ta 73 #define ID_W 74 #define ID_Re 75 #define ID_Os 76 #define ID_Ir 77 #define ID_Pt 78 #define ID_Au 79 #define ID_Hg 80 #define ID_Tl 81 #define ID_Pb 82 #define ID_Bi 83 #define ID_Po 84 #define ID_At 85 #define ID_Rn 86 #define ID_Fr 87 #define ID_Ra 88 #define ID_Ac 89 #define ID_Th 90 #define ID_Pa 91 #define ID_U 92 #define ID_Np 93 #define ID_Pu 94 #define ID_Am 95 #define ID_Cm 96 #define ID_Bk 97 #define ID_Cf 98 #define ID_Es 99 #define ID_Fm 100 #define ID_Md 101 #define ID_No 102 #define ID_Lr 103 #define ID_Rf 104 #define ID_Db 105 #define ID_Sg 106 #define ID_Bh 107 #define ID_Hs 108 #define ID_Mt 109 #define ID_Ds 110 #define ID_Rg 111 #define ID_Cn 112 #define ID_Nh 113 #define ID_Fl 114 #define ID_Mc 115 #define ID_Lv 116 #define ID_Ts 117 #define ID_Og 118 #define ID_user01 201 #define ID_user02 202 #define ID_user03 203 #define ID_user04 204 #define ID_user05 205 #define ID_user06 206 #define ID_user07 207 #define ID_user08 208 #define ID_user09 209 #define ID_user10 210 #define ID_user11 211 #define ID_user12 212 #define ID_user13 213 #define ID_user14 214 #define ID_user15 215 #define ID_user16 216 #define ID_user17 217 #define ID_user18 218 #define ID_user19 219 #define ID_user20 220 #endif /* KIM_SPECIES_NAME_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_SupportStatus.cpp000066400000000000000000000074531421473465500213050ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_SUPPORT_STATUS_HPP_ #include "KIM_SupportStatus.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace SUPPORT_STATUS { #include "KIM_SupportStatus.inc" SupportStatus const requiredByAPI(ID_requiredByAPI); SupportStatus const notSupported(ID_notSupported); SupportStatus const required(ID_required); SupportStatus const optional(ID_optional); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[requiredByAPI] = "requiredByAPI"; m[notSupported] = "notSupported"; m[required] = "required"; m[optional] = "optional"; return m; } StringMap const supportStatusToString = GetStringMap(); std::string const supportStatusUnknown("unknown"); } // namespace void GetNumberOfSupportStatuses(int * const numberOfSupportStatuses) { *numberOfSupportStatuses = supportStatusToString.size(); } int GetSupportStatus(int const index, SupportStatus * const supportStatus) { int numberOfSupportStatuses; GetNumberOfSupportStatuses(&numberOfSupportStatuses); if ((index < 0) || (index >= numberOfSupportStatuses)) return true; StringMap::const_iterator iter = supportStatusToString.begin(); for (int i = 0; i < index; ++i) ++iter; *supportStatus = iter->first; return false; // no error } } // namespace SUPPORT_STATUS // implementation of SupportStatus SupportStatus::SupportStatus() {} SupportStatus::SupportStatus(int const id) : supportStatusID(id) {} SupportStatus::SupportStatus(std::string const & str) { supportStatusID = -1; for (SUPPORT_STATUS::StringMap::const_iterator iter = SUPPORT_STATUS::supportStatusToString.begin(); iter != SUPPORT_STATUS::supportStatusToString.end(); ++iter) { if (iter->second == str) { supportStatusID = (iter->first).supportStatusID; break; } } } bool SupportStatus::Known() const { int numberOfSupportStatuses; SUPPORT_STATUS::GetNumberOfSupportStatuses(&numberOfSupportStatuses); for (int i = 0; i < numberOfSupportStatuses; ++i) { SupportStatus supStatus; SUPPORT_STATUS::GetSupportStatus(i, &supStatus); if (*this == supStatus) { return true; } } return false; } bool SupportStatus::operator==(SupportStatus const & rhs) const { return supportStatusID == rhs.supportStatusID; } bool SupportStatus::operator!=(SupportStatus const & rhs) const { return supportStatusID != rhs.supportStatusID; } std::string const & SupportStatus::ToString() const { SUPPORT_STATUS::StringMap::const_iterator iter = SUPPORT_STATUS::supportStatusToString.find(*this); if (iter == SUPPORT_STATUS::supportStatusToString.end()) return SUPPORT_STATUS::supportStatusUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_SupportStatus.inc000066400000000000000000000045261421473465500212720ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_SUPPORT_STATUS_INC_ #define KIM_SUPPORT_STATUS_INC_ #define ID_requiredByAPI 0 #define ID_notSupported 1 #define ID_required 2 #define ID_optional 3 #endif /* KIM_SUPPORT_STATUS_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_TemperatureUnit.cpp000066400000000000000000000073221421473465500215550ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_TEMPERATURE_UNIT_HPP_ #include "KIM_TemperatureUnit.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace TEMPERATURE_UNIT { #include "KIM_TemperatureUnit.inc" TemperatureUnit const unused(ID_unused); TemperatureUnit const K(ID_K); namespace { typedef std:: map StringMap; StringMap const GetStringMap() { StringMap m; m[unused] = "unused"; m[K] = "K"; return m; } StringMap const temperatureUnitToString = GetStringMap(); std::string const temperatureUnitUnknown("unknown"); } // namespace void GetNumberOfTemperatureUnits(int * const numberOfTemperatureUnits) { *numberOfTemperatureUnits = temperatureUnitToString.size(); } int GetTemperatureUnit(int const index, TemperatureUnit * const temperatureUnit) { int numberOfTemperatureUnits; GetNumberOfTemperatureUnits(&numberOfTemperatureUnits); if ((index < 0) || (index >= numberOfTemperatureUnits)) return true; StringMap::const_iterator iter = temperatureUnitToString.begin(); for (int i = 0; i < index; ++i) ++iter; *temperatureUnit = iter->first; return false; // no error } } // namespace TEMPERATURE_UNIT // implementation of TemperatureUnit TemperatureUnit::TemperatureUnit() {} TemperatureUnit::TemperatureUnit(int const id) : temperatureUnitID(id) {} TemperatureUnit::TemperatureUnit(std::string const & str) { temperatureUnitID = -1; for (TEMPERATURE_UNIT::StringMap::const_iterator iter = TEMPERATURE_UNIT::temperatureUnitToString.begin(); iter != TEMPERATURE_UNIT::temperatureUnitToString.end(); ++iter) { if (iter->second == str) { temperatureUnitID = (iter->first).temperatureUnitID; break; } } } bool TemperatureUnit::Known() const { int numberOfTemperatureUnits; TEMPERATURE_UNIT::GetNumberOfTemperatureUnits(&numberOfTemperatureUnits); for (int i = 0; i < numberOfTemperatureUnits; ++i) { TemperatureUnit tempUnit; TEMPERATURE_UNIT::GetTemperatureUnit(i, &tempUnit); if (*this == tempUnit) { return true; } } return false; } bool TemperatureUnit::operator==(TemperatureUnit const & rhs) const { return temperatureUnitID == rhs.temperatureUnitID; } bool TemperatureUnit::operator!=(TemperatureUnit const & rhs) const { return temperatureUnitID != rhs.temperatureUnitID; } std::string const & TemperatureUnit::ToString() const { TEMPERATURE_UNIT::StringMap::const_iterator iter = TEMPERATURE_UNIT::temperatureUnitToString.find(*this); if (iter == TEMPERATURE_UNIT::temperatureUnitToString.end()) return TEMPERATURE_UNIT::temperatureUnitUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_TemperatureUnit.inc000066400000000000000000000044361421473465500215470ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_TEMPERATURE_UNIT_INC_ #define KIM_TEMPERATURE_UNIT_INC_ #define ID_unused 0 #define ID_K 1 #endif /* KIM_TEMPERATURE_UNIT_INC_ */ kim-api-2.3.0-git/cpp/src/KIM_TimeUnit.cpp000066400000000000000000000065651421473465500201660ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include #ifndef KIM_TIME_UNIT_HPP_ #include "KIM_TimeUnit.hpp" #endif namespace KIM { // Order doesn't matter as long as all values are unique namespace TIME_UNIT { #include "KIM_TimeUnit.inc" TimeUnit const unused(ID_unused); TimeUnit const fs(ID_fs); TimeUnit const ps(ID_ps); TimeUnit const ns(ID_ns); TimeUnit const s(ID_s); namespace { typedef std::map StringMap; StringMap const GetStringMap() { StringMap m; m[unused] = "unused"; m[fs] = "fs"; m[ps] = "ps"; m[ns] = "ns"; m[s] = "s"; return m; } StringMap const timeUnitToString = GetStringMap(); std::string const timeUnitUnknown("unknown"); } // namespace void GetNumberOfTimeUnits(int * const numberOfTimeUnits) { *numberOfTimeUnits = timeUnitToString.size(); } int GetTimeUnit(int const index, TimeUnit * const timeUnit) { int numberOfTimeUnits; GetNumberOfTimeUnits(&numberOfTimeUnits); if ((index < 0) || (index >= numberOfTimeUnits)) return true; StringMap::const_iterator iter = timeUnitToString.begin(); for (int i = 0; i < index; ++i) ++iter; *timeUnit = iter->first; return false; // no error } } // namespace TIME_UNIT // implementation of TimeUnit TimeUnit::TimeUnit() {} TimeUnit::TimeUnit(int const id) : timeUnitID(id) {} TimeUnit::TimeUnit(std::string const & str) { timeUnitID = -1; for (TIME_UNIT::StringMap::const_iterator iter = TIME_UNIT::timeUnitToString.begin(); iter != TIME_UNIT::timeUnitToString.end(); ++iter) { if (iter->second == str) { timeUnitID = (iter->first).timeUnitID; break; } } } bool TimeUnit::Known() const { int numberOfTimeUnits; TIME_UNIT::GetNumberOfTimeUnits(&numberOfTimeUnits); for (int i = 0; i < numberOfTimeUnits; ++i) { TimeUnit tmUnit; TIME_UNIT::GetTimeUnit(i, &tmUnit); if (*this == tmUnit) { return true; } } return false; } bool TimeUnit::operator==(TimeUnit const & rhs) const { return timeUnitID == rhs.timeUnitID; } bool TimeUnit::operator!=(TimeUnit const & rhs) const { return timeUnitID != rhs.timeUnitID; } std::string const & TimeUnit::ToString() const { TIME_UNIT::StringMap::const_iterator iter = TIME_UNIT::timeUnitToString.find(*this); if (iter == TIME_UNIT::timeUnitToString.end()) return TIME_UNIT::timeUnitUnknown; else return iter->second; } } // namespace KIM kim-api-2.3.0-git/cpp/src/KIM_TimeUnit.inc000066400000000000000000000044711421473465500201470ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ #ifndef KIM_TIME_UNIT_INC_ #define KIM_TIME_UNIT_INC_ #define ID_unused 0 #define ID_fs 1 #define ID_ps 2 #define ID_ns 3 #define ID_s 4 #endif /* KIM_TIME_UNIT_INC_ */ kim-api-2.3.0-git/cpp/src/edn-cpp/000077500000000000000000000000001421473465500165365ustar00rootroot00000000000000kim-api-2.3.0-git/cpp/src/edn-cpp/LICENSE.txt000066400000000000000000000020721421473465500203620ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2013 shaun gilchrist Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. kim-api-2.3.0-git/cpp/src/edn-cpp/README.md000066400000000000000000000062251421473465500200220ustar00rootroot00000000000000edn-cpp ======= edn lib for c++. ##intro Useful for parsing [edn](http://github.com/edn-format/edn). read returns an `edn::EdnNode`. There are three cases to consider: * If it is an atom (nil, symbol, keyword, bool, int, float, string, char) it will have a `value` property which is a string you can then cast/coerce how you please. * If it is a collection (list, map, vector, set) it will have a `values` property which is itself a list of `edn::EdnNode` items which you can then walk via what ever mechanism and do with them what you will. * If it is a tagged item you will have the raw tagname in the `value` property and then the `values` property will be a list containing the `edn::EdnNode` representing the tagname and another `edn::EdnNode` containing the value for the tag. In general `edn-cpp` makes no assumptions about how you want to reify the data - it just guarantees you have well formed edn node(s) which you can handle how ever you like. ##using #//define DEBUG #include "edn.hpp" #include using edn::EdnNode; using edn::read; using edn::pprint; int main() { try { EdnNode someMap = read("{:some :map :with [a vector of symbols]}"); std::cout << pprint(someMap) << std::endl; } catch (const char* e) { std::cout << "Error parsing: " << e << std::endl; } } will output: {:some :map :with [a vector of symbols]} And with debug uncommented: ]>}> ##debug If you define DEBUG you will see debug output when using pprint. This looks like: >]>}> Which is nice when proving things are parsing as you expect. ##api list lex(string ednString) EdnNode read(string ednString) string pprint(EdnNode node) bool validSymbol(string value) bool validKeyword(string value) bool validNil(string value) bool validBool(string value) bool validInt(string value) bool validFloat(string value) bool validChar(string value) EdnNode handleAtom(EdnToken token) EdnNode handleCollection(EdnToken token, list values) EdnNode handleTagged(EdnToken token, EdnNode value) ##structs EdnToken TokenType type int line string value EdnNode EdnToken type int line string value #used for atoms list values #used for collections ##enums TokenType TokenString TokenAtom TokenParen NodeType EdnNil EdnSymbol EdnKeyword EdnBool EdnInt EdnFloat EdnString EdnChar EdnList EdnVector EdnMap EdnSet EdnDiscard EdnTagged ##todo make pprint actually format as demonstrated above. Right now it is just a single string with out the indentation. kim-api-2.3.0-git/cpp/src/edn-cpp/edn-cpp.origin000066400000000000000000000002121421473465500212700ustar00rootroot00000000000000https://github.com/ellio167/edn-cpp (forked-from) https://github.com/shaunxcode/edn-cpp commit b7a23fb56db59d639d32dd148619bc299fd2c71a kim-api-2.3.0-git/cpp/src/edn-cpp/edn.hpp000066400000000000000000000302161421473465500200170ustar00rootroot00000000000000#include #include #include #include #include namespace edn { using std::cout; using std::endl; using std::string; using std::list; string validSymbolChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.*+!-_?$%&=:#/"; enum TokenType { TokenString, TokenAtom, TokenParen }; struct EdnToken { TokenType type; int line; string value; }; enum NodeType { EdnNil, EdnSymbol, EdnKeyword, EdnBool, EdnInt, EdnFloat, EdnString, EdnChar, EdnList, EdnVector, EdnMap, EdnSet, EdnDiscard, EdnTagged }; struct EdnNode { NodeType type; int line; string value; list values; }; void createToken(TokenType type, int line, string value, list &tokens) { EdnToken token; token.type = type; token.line = line; token.value = value; tokens.push_back(token); } string typeToString(NodeType type) { string output; switch (type) { case EdnSymbol: output = "EdnSymbol"; break; case EdnKeyword: output = "EdnKeyword"; break; case EdnInt: output = "EdnInt"; break; case EdnFloat: output = "EdnFloat"; break; case EdnChar: output = "EdnChar"; break; case EdnBool: output = "EdnBool"; break; case EdnNil: output = "EdnNil"; break; case EdnString: output = "EdnString"; break; case EdnTagged: output = "EdnTagged"; break; case EdnList: output = "EdnList"; break; case EdnVector: output = "EdnVector"; break; case EdnSet: output = "EdnSet"; break; case EdnMap: output = "EdnMap"; break; case EdnDiscard: output = "EdnDiscard"; break; } return output; } //by default checks if first char is in range of chars bool strRangeIn(string str, const char* range, int start = 0, int stop = 1) { string strRange = str.substr(start, stop); return (std::strspn(strRange.c_str(), range) == strRange.length()); } list lex(string edn) { string::iterator it; int line = 1; char escapeChar = '\\'; bool escaping = false; bool inString = false; string stringContent = ""; bool inComment = false; string token = ""; string paren = ""; list tokens; for (it = edn.begin(); it != edn.end(); ++it) { if (*it == '\n' || *it == '\r') line++; if (!inString && *it == ';' && !escaping) inComment = true; if (inComment) { if (*it == '\n') { inComment = false; if (token != "") { createToken(TokenAtom, line, token, tokens); token = ""; } continue; } } if (*it == '"' && !escaping) { if (inString) { createToken(TokenString, line, stringContent, tokens); inString = false; } else { stringContent = ""; inString = true; } continue; } if (inString) { if (*it == escapeChar && !escaping) { escaping = true; continue; } if (escaping) { escaping = false; if (*it == 't' || *it == 'n' || *it == 'f' || *it == 'r') stringContent += escapeChar; } stringContent += *it; } else if (*it == '(' || *it == ')' || *it == '[' || *it == ']' || *it == '{' || *it == '}' || *it == '\t' || *it == '\n' || *it == '\r' || *it == ' ' || *it == ',') { if (token != "") { createToken(TokenAtom, line, token, tokens); token = ""; } if (*it == '(' || *it == ')' || *it == '[' || *it == ']' || *it == '{' || *it == '}') { paren = ""; paren += *it; createToken(TokenParen, line, paren, tokens); } } else { if (escaping) { escaping = false; } else if (*it == escapeChar) { escaping = true; } if (token == "#_" || (token.length() == 2 && token[0] == escapeChar)) { createToken(TokenAtom, line, token, tokens); token = ""; } token += *it; } } if (token != "") { createToken(TokenAtom, line, token, tokens); } return tokens; } void uppercase(string &str) { std::transform(str.begin(), str.end(), str.begin(), ::toupper); } bool validSymbol(string value) { //first we uppercase the value uppercase(value); if (std::strspn(value.c_str(), validSymbolChars.c_str()) != value.length()) return false; //if the value starts with a number that is not ok if (strRangeIn(value, "0123456789")) return false; //first char can not start with : # or / - but / by itself is valid if (strRangeIn(value, ":#/") && !(value.length() == 1 && value[0] == '/')) return false; //if the first car is - + or . then the next char must NOT be numeric, by by themselves they are valid if (strRangeIn(value, "-+.") && value.length() > 1 && strRangeIn(value, "0123456789", 1)) return false; if (std::count(value.begin(), value.end(), '/') > 1) return false; return true; } bool validKeyword(string value) { return (value[0] == ':' && validSymbol(value.substr(1,value.length() - 1))); } bool validNil(string value) { return (value == "nil"); } bool validBool(string value) { return (value == "true" || value == "false"); } bool validInt(string value, bool allowSign = true) { //if we have a positive or negative symbol that is ok but remove it for testing if (strRangeIn(value, "-+") && value.length() > 1 && allowSign) value = value.substr(1, value.length() - 1); //if string ends with N or M that is ok, but remove it for testing if (strRangeIn(value, "NM", value.length() - 1, 1)) value = value.substr(0, value.length() - 2); if (std::strspn(value.c_str(), "0123456789") != value.length()) return false; return true; } bool validFloat(string value) { uppercase(value); string front; string back; int epos; int periodPos = value.find_first_of('.'); if (periodPos) { front = value.substr(0, periodPos); back = value.substr(periodPos + 1); } else { front = ""; back = value; } if(front == "" || validInt(front)) { epos = back.find_first_of('E'); if(epos > -1) { //ends with E which is invalid if ((unsigned)epos == back.length() - 1) return false; //both the decimal and exponent should be valid - do not allow + or - on dec (pass false as arg to validInt) if (!validInt(back.substr(0, epos), false) || !validInt(back.substr(epos + 1))) return false; } else { //if back ends with M remove for validation if (strRangeIn(back, "M", back.length() - 1, 1)) back = back.substr(0, back.length() - 1); if (!validInt(back, false)) return false; } return true; } return false; } bool validChar(string value) { return (value.at(0) == '\\' && value.length() == 2); } EdnNode handleAtom(EdnToken token) { EdnNode node; node.line = token.line; node.value = token.value; if (validNil(token.value)) node.type = EdnNil; else if (token.type == TokenString) node.type = EdnString; else if (validChar(token.value)) node.type = EdnChar; else if (validBool(token.value)) node.type = EdnBool; else if (validInt(token.value)) node.type = EdnInt; else if (validFloat(token.value)) node.type = EdnFloat; else if (validKeyword(token.value)) node.type = EdnKeyword; else if (validSymbol(token.value)) node.type = EdnSymbol; else throw string("Could not parse atom"); return node; } EdnNode handleCollection(EdnToken token, list values) { EdnNode node; node.line = token.line; node.values = values; if (token.value == "(") { node.type = EdnList; } else if (token.value == "[") { node.type = EdnVector; } if (token.value == "{") { node.type = EdnMap; } return node; } EdnNode handleTagged(EdnToken token, EdnNode value) { EdnNode node; node.line = token.line; string tagName = token.value.substr(1, token.value.length() - 1); if (tagName == "_") { node.type = EdnDiscard; } else if (tagName == "") { //special case where we return early as # { is a set - thus tagname is empty node.type = EdnSet; if (value.type != EdnMap) { throw string("Was expection a { } after hash to build set"); } node.values = value.values; return node; } else { node.type = EdnTagged; } if (!validSymbol(tagName)) { throw string("Invalid tag name"); } EdnToken symToken; symToken.type = TokenAtom; symToken.line = token.line; symToken.value = tagName; list values; values.push_back(handleAtom(symToken)); values.push_back(value); node.values = values; return node; } EdnToken shiftToken(list &tokens) { EdnToken nextToken = tokens.front(); tokens.pop_front(); return nextToken; } EdnNode readAhead(EdnToken token, list &tokens) { if (token.type == TokenParen) { EdnToken nextToken; list L; string closeParen; if (token.value == "(") closeParen = ")"; if (token.value == "[") closeParen = "]"; if (token.value == "{") closeParen = "}"; while (true) { if (tokens.empty()) throw string("unexpected end of list"); nextToken = shiftToken(tokens); if (nextToken.value == closeParen) { return handleCollection(token, L); } else { L.push_back(readAhead(nextToken, tokens)); } } } else if (token.value == ")" || token.value == "]" || token.value == "}") { throw string("Unexpected " + token.value); } else { if (token.value.size() && token.value.at(0) == '#') { return handleTagged(token, readAhead(shiftToken(tokens), tokens)); } else { return handleAtom(token); } } } string escapeQuotes(const string &before) { string after; after.reserve(before.length() + 4); for (string::size_type i = 0; i < before.length(); ++i) { if (before[i] == '"' || before[i] == '\\') { after += '\\'; } after += before[i]; } return after; } string pprint(EdnNode &node, int indent = 1) { string prefix(""); if (indent) { prefix.insert(0, indent, ' '); } string output; if (node.type == EdnList || node.type == EdnSet || node.type == EdnVector || node.type == EdnMap) { string vals = ""; for (list::iterator it=node.values.begin(); it != node.values.end(); ++it) { if (vals.length() > 0) vals += prefix; vals += pprint(*it, indent + 1); if (node.type == EdnMap) { ++it; vals += " " + pprint(*it, 1); } if (std::distance(it, node.values.end()) != 1) vals += "\n"; } if (node.type == EdnList) output = "(" + vals + ")"; else if (node.type == EdnVector) output = "[" + vals + "]"; else if (node.type == EdnMap) output = "{" + vals + "}"; else if (node.type == EdnSet) output = "#{" + vals + "}"; #ifdef DEBUG return "<" + typeToString(node.type) + " " + output + ">"; #endif } else if (node.type == EdnTagged) { output = "#" + pprint(node.values.front()) + " " + pprint(node.values.back()); #ifdef DEBUG return ""; #endif } else if (node.type == EdnString) { output = "\"" + escapeQuotes(node.value) + "\""; #ifdef DEBUG return ""; #endif } else { #ifdef DEBUG return "<" + typeToString(node.type) + " " + node.value + ">"; #endif output = node.value; } return output; } EdnNode read(string edn) { list tokens = lex(edn); if (tokens.size() == 0) { throw string("No parsable tokens found in string"); } return readAhead(shiftToken(tokens), tokens); } } kim-api-2.3.0-git/cpp/src/edn-cpp/example.cpp000066400000000000000000000005241421473465500206760ustar00rootroot00000000000000#define DEBUG #include "edn.hpp" #include using edn::EdnNode; using edn::read; using edn::pprint; int main() { try { EdnNode someMap = read("{:some :map :with [a vector of symbols]}"); std::cout << pprint(someMap) << std::endl; } catch (const char* e) { std::cout << "Error parsing: " << e << std::endl; } } kim-api-2.3.0-git/cpp/src/edn-cpp/repl.cpp000066400000000000000000000010561421473465500202060ustar00rootroot00000000000000#define DEBUG (1) #include "edn.hpp" #include #include #include int main() { edn::validSymbolChars += "<>'"; std::string ednString; while (true) { std::cout << "edn> "; getline(std::cin, ednString); if (ednString.length() == 0) { std::cout << std::endl; } else { try { edn::EdnNode node = edn::read(ednString); std::cout << edn::pprint(node) << std::endl; } catch (const char* e) { std::cout << "Error: " << e << std::endl; } } } return 0; } kim-api-2.3.0-git/cpp/src/ghc-filesystem/000077500000000000000000000000001421473465500201335ustar00rootroot00000000000000kim-api-2.3.0-git/cpp/src/ghc-filesystem/LICENSE000066400000000000000000000020761421473465500211450ustar00rootroot00000000000000Copyright (c) 2018, Steffen SchÃŧmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. kim-api-2.3.0-git/cpp/src/ghc-filesystem/README.md000066400000000000000000001062161421473465500214200ustar00rootroot00000000000000![Supported Platforms](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows%20%7C%20FreeBSD-blue.svg) ![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg) [![Build Status](https://travis-ci.org/gulrak/filesystem.svg?branch=master)](https://travis-ci.org/gulrak/filesystem) [![Build Status](https://ci.appveyor.com/api/projects/status/t07wp3k2cddo0hpo/branch/master?svg=true)](https://ci.appveyor.com/project/gulrak/filesystem) [![Build Status](https://api.cirrus-ci.com/github/gulrak/filesystem.svg?branch=master)](https://cirrus-ci.com/github/gulrak/filesystem) [![Build Status](https://cloud.drone.io/api/badges/gulrak/filesystem/status.svg?ref=refs/heads/master)](https://cloud.drone.io/gulrak/filesystem) [![Coverage Status](https://coveralls.io/repos/github/gulrak/filesystem/badge.svg?branch=master)](https://coveralls.io/github/gulrak/filesystem?branch=master) [![Latest Release Tag](https://img.shields.io/github/tag/gulrak/filesystem.svg)](https://github.com/gulrak/filesystem/tree/v1.3.2) # Filesystem This is a header-only single-file std::filesystem compatible helper library, based on the C++17 specs, but implemented for C++11, C++14 or C++17 (tightly following the C++17 with very few documented exceptions). It is currently tested on macOS 10.12/10.14, Windows 10, Ubuntu 18.04, FreeBSD 12 and Alpine ARM/ARM64 Linux but should work on other systems too, as long as you have at least a C++11 compatible compiler. It is of course in its own namespace `ghc::filesystem` to not interfere with a regular `std::filesystem` should you use it in a mixed C++17 environment. *It could still use some polishing, test coverage is above 90%, I didn't benchmark much yet, but I'll try to optimize some parts and refactor others, so I'm striving to improve it as long as it doesn't introduce additional C++17 compatibility issues. Feedback is always welcome. Simply open an issue if you see something missing or wrong or not behaving as expected and I'll comment.* ## Motivation I'm often in need of filesystem functionality, mostly `fs::path`, but directory access too, and when beginning to use C++11, I used that language update to try to reduce my third-party dependencies. I could drop most of what I used, but still missed some stuff that I started implementing for the fun of it. Originally I based these helpers on my own coding- and naming conventions. When C++17 was finalized, I wanted to use that interface, but it took a while, to push myself to convert my classes. The implementation is closely based on chapter 30.10 from the C++17 standard and a draft close to that version is [Working Draft N4687](https://github.com/cplusplus/draft/raw/master/papers/n4687.pdf). It is from after the standardization of C++17 but it contains the latest filesystem interface changes compared to the [Working Draft N4659](https://github.com/cplusplus/draft/raw/master/papers/n4659.pdf). I want to thank the people working on improving C++, I really liked how the language evolved with C++11 and the following standards. Keep on the good work! Oh, and if you ask yourself, what `ghc` is standing for, it is simply `gulraks helper classes`, yeah, I know, not very imaginative, but I wanted a short namespace and I use it in some of my private classes (so it has nothing to do with Haskell). ## Platforms `ghc::filesystem` is developed on macOS but tested on Windows and Linux. It should work on any of these with a C++11-capable compiler. I currently don't have a BSD derivate besides macOS, so the preprocessor checks will cry out if you try to use it there, but if there is demand, I can try to help. Also there are some checks to hopefully better work on Android, but as I currently don't test with the Android NDK, I wouldn't call it a supported platform yet. All in all, I don't see it replacing `std::filesystem` where full C++17 is available, it doesn't try to be a "better" `std::filesystem`, just a drop-in if you can't use it (with the exception of the UTF-8 preference on Windows). Unit tests are currently run with: * macOS 10.12: Xcode 9.2 (clang-900.0.39.2), GCC 9.2, Clang 9.0, macOS 10.13: Xcode 10.1, macOS 10.14: Xcode 11.2 * Windows: Visual Studio 2017, Visual Studio 2015, Visual Studio 2019, MinGW GCC 6.3 (Win32), GCC 7.2 (Win64) * Linux (Ubuntu): GCC (5.5, 6.5, 7.4, 8.3, 9.2), Clang (5.0, 6.0, 7.1, 8.0, 9.0) * Linux (Alpine ARM/ARM64): GCC 9.2.0 * FreeBSD: Clang 8.0 ## Tests The header comes with a set of unit-tests and uses [CMake](https://cmake.org/) as a build tool and [Catch2](https://github.com/catchorg/Catch2) as test framework. All tests agains this implementation should succeed, depending on your environment it might be that there are some warnings, e.g. if you have no rights to create Symlinks on Windows or at least the test thinks so, but these are just informative. To build the tests from inside the project directory under macOS or Linux just: ```cpp mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Debug .. make ``` This generates `filesystem_test`, the binary that runs all tests. If the default compiler is a GCC 8 or newer, or Clang 7 or newer, it additionally tries to build a version of the test binary compiled against GCCs/Clangs `std::filesystem` implementation, named `std_filesystem_test` as an additional test of conformance. Ideally all tests should compile and succeed with all filesystem implementations, but in reality, there are some differences in behavior, sometimes due to room for interpretation in in the standard, and there might be issues in these implementations too. ## Usage ### Downloads The latest release version is [v1.3.2](https://github.com/gulrak/filesystem/tree/v1.3.2) and source archives can be found [here](https://github.com/gulrak/filesystem/releases/tag/v1.3.2). ### Using it as Single-File-Header As `ghc::filesystem` is at first a header-only library, it should be enough to copy the header or the `include/ghc` directory into your project folder oder point your include path to this place and simply include the `filesystem.hpp` header (or `ghc/filesystem.hpp` if you use the subdirectory). Everything is in the namespace `ghc::filesystem`, so one way to use it only as a fallback could be: ```cpp #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) #if __has_include() #define GHC_USE_STD_FS #include namespace fs = std::filesystem; #endif #endif #ifndef GHC_USE_STD_FS #include namespace fs = ghc::filesystem; #endif ``` **Note that this code uses a two-stage preprocessor condition because Visual Studio 2015 doesn't like the `(<...>)` syntax, even if it could cut evaluation early before.** **Note also, that on MSVC this detection only works starting from version 15.7 on and when setting the `/Zc:__cplusplus` compile switch, as the compiler allways reports `199711L` without that switch ([see](https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/)).** If you want to also use the `fstream` wrapper with `path` support as fallback, you might use: ```cpp #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) #if __has_include() #define GHC_USE_STD_FS #include namespace fs { using namespace std::filesystem; using ifstream = std::ifstream; using ofstream = std::ofstream; using fstream = std::fstream; } #endif #endif #ifndef GHC_USE_STD_FS #include namespace fs { using namespace ghc::filesystem; using ifstream = ghc::filesystem::ifstream; using ofstream = ghc::filesystem::ofstream; using fstream = ghc::filesystem::fstream; } #endif ``` Now you have e.g. `fs::ofstream out(somePath);` and it is either the wrapper or the C++17 `std::ofstream`. **Be aware, as a header-only library, it is not hiding the fact, that it uses system includes, so they "pollute" your global namespace.** :information_source: **Hint:** There is an additional header named `ghc/fs_std.hpp` that implements this dynamic selection of a filesystem implementation, that you can include instead of `ghc/filesystem.hpp` when you want std::filesystem where available and ghc::filesystem where not. It also enables the `wchar_t` support on `ghc::filesystem` on Windows, so the resulting implementation in the `fs` namespace will be compatible. ### Using it as Forwarding-/Implementation-Header Alternatively, starting from v1.1.0 `ghc::filesystem` can also be used by including one of two additional wrapper headers. These allow to include a forwarded version in most places (`ghc/fs_fwd.hpp`) while hiding the implementation details in a single cpp that includes `ghc/fs_impl.hpp` to implement the needed code. That way system includes are only visible from inside the cpp, all other places are clean. Be aware, that it is currently not supported to hide the implementation into a Windows-DLL, as a DLL interface with C++ standard templates in interfaces is a different beast. If someone is willing to give it a try, I might integrate a PR but currently working on that myself is not a priority. If you use the forwarding/implementation approach, you can still use the dynamic switching like this: ```cpp #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) #if __has_include() #define GHC_USE_STD_FS #include namespace fs { using namespace std::filesystem; using ifstream = std::ifstream; using ofstream = std::ofstream; using fstream = std::fstream; } #endif #endif #ifndef GHC_USE_STD_FS #include namespace fs { using namespace ghc::filesystem; using ifstream = ghc::filesystem::ifstream; using ofstream = ghc::filesystem::ofstream; using fstream = ghc::filesystem::fstream; } #endif ``` and in the implementation hiding cpp, you might use (before any include that includes `ghc/fs_fwd.hpp` to take precedence: ```cpp #if !(defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) #if __has_include()) #include #endif #endif ``` :information_source: **Hint:** There are additional helper headers, named `ghc/fs_std_fwd.hpp` and `ghc/fs_std_impl.hpp` that use this technique, so you can simply include them if you want to dynamically select the filesystem implementation. they also enable the `wchar_t` support on `ghc::filesystem` on Windows, so the resulting implementation in the `fs` namespace will be compatible. ### Git Submodule and CMake Starting from v1.1.0, it is possible to add `ghc::filesystem` as a git submodule, add the directory to your `CMakeLists.txt` with `add_subdirectory()` and then simply use `target_link_libraries(your-target ghc_filesystem)` to ensure correct include path that allow `#include ` to work. The `CMakeLists.txt` offers a few options to customize its behaviour: * `GHC_FILESYSTEM_BUILD_TESTING` - Compile tests, default is `OFF` when used as a submodule, else `ON`. * `GHC_FILESYSTEM_BUILD_EXAMPLES` - Compile the examples, default is `OFF` when used as a submodule, else `ON`. * `GHC_FILESYSTEM_WITH_INSTALL` - Add install target to build, default is `OFF` when used as a submodule, else `ON`. ### Versioning There is a version macro `GHC_FILESYSTEM_VERSION` defined in case future changes might make it needed to react on the version, but I don't plan to break anything. It's the version as decimal number `(major * 10000 + minor * 100 + patch)`. **Note:** Starting from v1.0.2 only even patch versions will be used for releases and odd patch version will only be used for in between commits while working on the next version. ## Documentation There is almost no documentation in this release, as any `std::filesystem` documentation would work, besides the few differences explained in the next section. So you might head over to https://en.cppreference.com/w/cpp/filesystem for a description of the components of this library. The only additions to the standard are documented here: ### `ghc::filesystem::ifstream`, `ghc::filesystem::ofstream`, `ghc::filesystem::fstream` These are simple wrappers around `std::ifstream`, `std::ofstream` and `std::fstream`. They simply add an `open()` method and a constuctor with an `ghc::filesystem::path` argument as the `fstream` variants in C++17 have them. ### `ghc::filesystem::u8arguments` This is a helper class that currently checks for UTF-8 encoding on non-Windows platforms but on Windows it fetches the command line arguments als Unicode strings from the OS with ```cpp ::CommandLineToArgvW(::GetCommandLineW(), &argc) ``` and then converts them to UTF-8, and replaces `argc` and `argv`. It is a guard-like class that reverts its changes when going out of scope. So basic usage is: ```cpp namespace fs = ghc::filesystem; int main(int argc, char* argv[]) { fs::u8arguments u8guard(argc, argv); if(!u8guard.valid()) { std::cerr << "Bad encoding, needs UTF-8." << std::endl; exit(EXIT_FAILURE); } // now use argc/argv as usual, they have utf-8 enconding on windows // ... return 0; } ``` That way `argv` is UTF-8 encoded as long as the scope from `main` is valid. **Note:** On macOS, while debugging under Xcode the code currently will return `false` as Xcode starts the application with `US-ASCII` as encoding, no matter what encoding is actually used and even setting `LC_ALL` in the product scheme doesn't change anything. I still need to investigate this. ## Differences As this implementation is based on existing code from my private helper classes, it derived some constraints of it, leading to some differences between this and the standard C++17 API. ### LWG Defects This implementation has switchable behavior for the LWG defects [#2682](https://wg21.cmeerw.net/lwg/issue2682), [#2935](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2935) and [#2937](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2937). The currently selected behavior is following [#2682](https://wg21.cmeerw.net/lwg/issue2682), [#2937](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2937) but not following [#2935](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2935), as I feel it is a bug to report no error on a `create_directory()` or `create_directories()` where a regular file of the same name prohibits the creation of a directory and forces the user of those functions to double-check via `fs::is_directory` if it really worked. The more intuitive approach to directory creation of treating a file with that name as an error is also advocated by the newer paper [WG21 P1164R0](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1164r0.pdf), the revison P1161R1 was agreed upon on Kona 2019 meeting [see merge](https://github.com/cplusplus/draft/issues/2703) and GCC by now switched to following its proposal ([GCC #86910](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86910)). ### Not Implemented on C++ before C++17 ```cpp // methods in ghc::filesystem::path: path& operator+=(basic_string_view x); int compare(basic_string_view s) const; ``` These are not implemented under C++11 and C++14, as there is no `std::basic_string_view` available and I did want to keep this implementation self-contained and not write a full C++17-upgrade for C++11/14. Starting with v1.1.0 these are supported when compiling ghc::filesystem under C++17. ### Differences in API ```cpp filesystem::path::string_type filesystem::path::value_type ``` In Windows, an implementation should use `std::wstring` and `wchar_t` as types used for the native representation, but as I'm a big fan of the ["UTF-8 Everywhere" philosophy](https://utf8everywhere.org/), I decided agains it for now. If you need to call some Windows API, use the W-variant with the `path::wstring()` member (e.g. `GetFileAttributesW(p.wstring().c_str())`). This gives you the Unicode variant independant of the `UNICODE` macro and makes sharing code between Windows, Linux and macOS easier. Starting with v1.2.0 `ghc::filesystem` has the option to select the more standard conforming APi with `wchar_t` and `std::wstring` on Windows by defining `GHC_WIN_WSTRING_STRING_TYPE`. This define has no effect on other platforms and will be set by the helping headers `ghc/fs_std.hpp` and the pair `ghc/fs_std_fwd.hpp`/`ghc/fs_std_impl.hpp` to enhance compatibility. ```cpp const path::string_type& path::native() const /*noexcept*/; const path::value_type *path::c_str() const /*noexcept*/; ``` These two can not be `noexcept` with the current implementation. This due to the fact, that internally path is working on the generic path version only, and the getters need to do a conversion to native path format. ```cpp const path::string_type& path::generic_string() const; ``` This returns a const reference, instead of a value, because it can. This implementation uses the generic representation for internal workings, so it's "free" to return that. ### Differences in Behavior #### fs.path ([ref](https://en.cppreference.com/w/cpp/filesystem/path)) As the complete inner mechanics of this implementation `fs::path` are working on the generic format, it is the internal representation. So creating any mixed slash `fs::path` object under Windows (e.g. with `"C:\foo/bar"`) will lead to a unified path with `"C:\foo\bar"` via `native()` and `"C:/foo/bar"` via `generic_string()` API. Additionally this implementation follows the standards suggestion to handle posix paths of the form `"//host/path"` and USC path on windows also as having a root-name (e.g. `"//host"`). The GCC implementation didn't choose to do that while testing on Ubuntu 18.04 and macOS with GCC 8.1.0 or Clang 7.0.0. This difference will show as warnings under std::filesystem. This leads to a change in the algorithm described in the standard for `operator/=(path& p)` where any path `p` with `p.is_absolute()` will degrade to an assignment, while this implementation has the exception where `*this == *this.root_name()` and `p == preferred_seperator` a normal append will be done, to allow: ```cpp fs::path p1 = "//host/foo/bar/file.txt"; fs::path p2; for (auto p : p1) p2 /= p; ASSERT(p1 == p2); ``` For all non-host-leading paths the behaviour will match the one described by the standard. #### fs.op.copy ([ref](https://en.cppreference.com/w/cpp/filesystem/copy)) Then there is `fs::copy`. The tests in the suite fail partially with C++17 `std::filesystem` on GCC/Clang. They complain about a copy call with `fs::copy_options::recursive` combined with `fs::copy_options::create_symlinks` or `fs::copy_options::create_hard_links` if the source is a directory. There is nothing in the standard that forbids this combination and it is the only way to deep-copy a tree while only create links for the files. There is [LWG #2682](https://wg21.cmeerw.net/lwg/issue2682) that supports this interpretation, but the issue ignores the usefulness of the combination with recursive and part of the justification for the proposed solution is "we did it so for almost two years". But this makes `fs::copy` with `fs::copy_options::create_symlinks` or `fs::copy_options::create_hard_links` just a more complicated syntax for the `fs::create_symlink` or `fs::create_hardlink` operation and I don't want to believe, that this was the intention of the original writing. As there is another issue related to copy, with a different take on the description. **Note:** With v1.1.2 I decided to integrate a behavior switch for this and make the LWG #2682 the default. ## Open Issues ### General Known Issues There are still some methods that break the `noexcept` clause, some are related to LWG defects, some are due to my implementation. I work on fixing the later ones, and might in cases where there is no way of implementing the feature without risk of an exception, break conformance and remove the `noexcept`. ### Windows #### Symbolic Links on Windows As symbolic links on Windows, while being supported more or less since Windows Vista (with some strict security constraints) and fully since some earlier build of Windows 10, when "Developer Mode" is activated, are at time of writing (2018) rarely used, still they are supported with this implementation. #### Permissions The Windows ACL permission feature translates badly to the POSIX permission bit mask used in the interface of C++17 filesystem. The permissions returned in the `file_status` are therefore currently synthesized for the `user`-level and copied to the `group`- and `other`-level. There is still some potential for more interaction with the Windows permission system, but currently setting or reading permissions with this implementation will most certainly not lead to the expected behavior. ## Release Notes ### v1.3.3 (wip) * Pull request [#62](https://github.com/gulrak/filesystem/pull/62), various fixes for better Android support, thanks for the PR * Pull request [#61](https://github.com/gulrak/filesystem/pull/61), `ghc::filesystem` now supports use in projects with disabled exceptions. API signatures using exceptions for error handling are not available in this mode, thanks for the PR (this resolves [#60](https://github.com/gulrak/filesystem/issues/60) and [#43](https://github.com/gulrak/filesystem/issues/43)) ### [v1.3.2](https://github.com/gulrak/filesystem/releases/tag/v1.3.2) * Bugfix for [#58](https://github.com/gulrak/filesystem/issues/58), on MinGW the compilation could fail with an error about an undefined `ERROR_FILE_TOO_LARGE` constant. * Bugfix for [#56](https://github.com/gulrak/filesystem/issues/58), `fs::lexically_relative` didn't ignore trailing slash on the base parameter, thanks for PR [#57](https://github.com/gulrak/filesystem/pull/57). * Bugfix for [#55](https://github.com/gulrak/filesystem/issues/55), `fs::create_directories` returned `true` when nothing needed to be created, because the directory already existed. * Bugfix for [#54](https://github.com/gulrak/filesystem/issues/54), `error_code` was not reset, if cached result was returned. * Pull request [#53](https://github.com/gulrak/filesystem/pull/53), fix for wrong handling of leading whitespace when reading `fs::path` from a stream. * Pull request [#52](https://github.com/gulrak/filesystem/pull/52), an ARM Linux target is now part of the CI infrastructure with the service of Drone CI. * Pull request [#51](https://github.com/gulrak/filesystem/pull/51), FreeBSD is now part of the CI infrastucture with the service of Cirrus CI. * Pull request [#50](https://github.com/gulrak/filesystem/pull/50), adaptive cast to `timespec` fields to avoid warnings. ### [v1.3.0](https://github.com/gulrak/filesystem/releases/tag/v1.3.0) * **Important: `ghc::filesystem` is re-licensed from BSD-3-Clause to MIT license.** (see [#47](https://github.com/gulrak/filesystem/issues/47)) * Pull request [#46](https://github.com/gulrak/filesystem/pull/46), suppresses unused parameter warning on Android. * Bugfix for [#44](https://github.com/gulrak/filesystem/issues/44), fixes for warnings from newer Xcode versions. ### [v1.2.10](https://github.com/gulrak/filesystem/releases/tag/v1.2.10) * The Visual Studio 2019 compiler, GCC 9.2 and Clang 9.0 where added to the CI configuration. * Bugfix for [#41](https://github.com/gulrak/filesystem/issues/41), `fs::rename` on Windows didn't replace an axisting regular file as required by the standard, but gave an error. New tests and a fix as provided in the issue was implemented. * Bugfix for [#39](https://github.com/gulrak/filesystem/issues/39), for the forwarding use via `fs_fwd.hpp` or `fs_std_fwd.hpp` der was a use of `DWORD` in the forwarding part leading to an error if `Windows.h` was not included before the header. The tests were changed to give an error in that case too and the useage of `DWORD` was removed. * Bugfix for [#38](https://github.com/gulrak/filesystem/issues/38), casting the return value of `GetProcAddress` gave a warning with `-Wcast-function-type` on MSYS2 and MinGW GCC 9 builds. ### [v1.2.8](https://github.com/gulrak/filesystem/releases/tag/v1.2.8) * Pull request [#30](https://github.com/gulrak/filesystem/pull/30), the `CMakeLists.txt` will automatically exclude building examples and tests when used as submodule, the configuration options now use a prefixed name to reduce risk of conflicts. * Pull request [#24](https://github.com/gulrak/filesystem/pull/24), install target now creates a `ghcFilesystemConfig.cmake` in `${CMAKE_INSTALL_LIBDIR}/cmake/ghcFilesystem` for `find_package` that exports a target as `ghcFilesystem::ghc_filesystem`. * Pull request [#31](https://github.com/gulrak/filesystem/pull/31), fixes `error: redundant redeclaration of 'constexpr' static data member` deprecation warning in C++17 mode. * Pull request [#32](https://github.com/gulrak/filesystem/pull/32), fixes old-style-cast warnings. * Pull request [#34](https://github.com/gulrak/filesystem/pull/34), fixes [TOCTOU](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use) situation on `fs::create_directories`, thanks for the PR! * Feature [#35](https://github.com/gulrak/filesystem/issues/35), new CMake option to add an install target `GHC_FILESYSTEM_WITH_INSTALL` that is defaulted to OFF if `ghc::filesystem` is used via `add_subdirectory`. * Bugfix for [#33](https://github.com/gulrak/filesystem/issues/33), fixes an issue with `fs::path::lexically_normal()` that leaves a trailing separator in case of a resulting path ending with `..` as last element. * Bugfix for [#36](https://github.com/gulrak/filesystem/issues/36), warings on Xcode 11.2 due to unhelpfull references in path element iteration. ### [v1.2.6](https://github.com/gulrak/filesystem/releases/tag/v1.2.6) * Pull request [#23](https://github.com/gulrak/filesystem/pull/23), tests and examples can now be disabled in CMake via seting `BUILD_TESTING` and `BUILD_EXAMPLES` to `NO`, `OFF` or `FALSE`. * Pull request [#25](https://github.com/gulrak/filesystem/pull/25), missing specialization for construction from `std::string_view` when available was added. * Additional test case when `std::string_view` is available. * Bugfix for [#27](https://github.com/gulrak/filesystem/issues/27), the `fs::path::preferred_seperator` declaration was not compiling on pre C++17 compilers and no test accessed it, to show the problem. Fixed it to an construction C++11 compiler should accept and added a test that is successful on all combinations tested. * Bugfix for [#29](https://github.com/gulrak/filesystem/issues/29), stricter warning settings where chosen and resulting warnings where fixed. ### [v1.2.4](https://github.com/gulrak/filesystem/releases/tag/v1.2.4) * Enabled stronger warning switches and resulting fixed issues on GCC and MinGW * Bugfix for #22, the `fs::copy_options` where not forwarded from `fs::copy` to `fs::copy_file` in one of the cases. ### [v1.2.2](https://github.com/gulrak/filesystem/releases/tag/v1.2.2) * Fix for ([#21](https://github.com/gulrak/filesystem/pull/21)), when compiling on Alpine Linux with musl instead of glibc, the wrong `strerror_r` signature was expected. The complex preprocessor define mix was dropped in favor of the usual dispatch by overloading a unifying wrapper. ### [v1.2.0](https://github.com/gulrak/filesystem/releases/tag/v1.2.0) * Added MinGW 32/64 and Visual Studio 2015 builds to the CI configuration. * Fixed additional compilation issues on MinGW. * Pull request ([#13](https://github.com/gulrak/filesystem/pull/13)), set minimum required CMake version to 3.7.2 (as in Debian 8). * Pull request ([#14](https://github.com/gulrak/filesystem/pull/14)), added support for a make install target. * Bugfix for ([#15](https://github.com/gulrak/filesystem/issues/15)), the forward/impl way of using `ghc::filesystem` missed a `` include in the windows case. * Bugfix for ([#16](https://github.com/gulrak/filesystem/issues/16)), VS2019 didn't like the old size dispatching in the utf8 decoder, so it was changed to a sfinae based approach. * New feature ([#17](https://github.com/gulrak/filesystem/issues/17)), optional support for standard conforming `wchar_t/std::wstring` interface when compiling on Windows with defined `GHC_WIN_WSTRING_STRING_TYPE`, this is default when using the `ghc/fs_std*.hpp` header, to enhance compatibility. * New feature ([#18](https://github.com/gulrak/filesystem/issues/18)), optional filesystem exceptions/errors on unicode errors with defined `GHC_RAISE_UNICODE_ERRORS` (instead of replacing invalid code points or UTF-8 encoding errors with the replacement character `U+FFFD`). * Pull request ([#20](https://github.com/gulrak/filesystem/pull/20)), fix for file handle leak in `fs::copy_file`. * Coverage now checked in CI (~95% line coverage). ### [v1.1.4](https://github.com/gulrak/filesystem/releases/tag/v1.1.4) * Additional Bugfix for ([#12](https://github.com/gulrak/filesystem/issues/12)), error in old unified `readdir/readdir_r` code of `fs::directory_iterator`; as `readdir_r` is now depricated, I decided to drop it and the resulting code is much easier, shorter and due to more refactoring faster * Fix for crashing unit tests against MSVC C++17 std::filesystem * Travis-CI now additionally test with Xcode 10.2 on macOS * Some minor refactorings ### [v1.1.2](https://github.com/gulrak/filesystem/releases/tag/v1.1.2) * Bugfix for ([#11](https://github.com/gulrak/filesystem/issues/11)), `fs::path::lexically_normal()` had some issues with `".."`-sequences. * Bugfix for ([#12](https://github.com/gulrak/filesystem/issues/12)), `fs::recursive_directory_iterator` could run into endless loops, the methods depth() and pop() had issues and the copy behaviour and `input_iterator_tag` conformance was broken, added tests * Restructured some CMake code into a macro to ease the support for C++17 std::filesystem builds of tests and examples for interoperability checks. * Some fixes on Windows tests to ease interoperability test runs. * Reduced noise on `fs::weakly_canonical()` tests against `std::fs` * Added simple `du` example showing the `recursive_directory_iterator` used to add the sizes of files in a directory tree. * Added error checking in `fs::file_time_type` test helpers * `fs::copy()` now conforms LWG #2682, disallowing the use of `copy_option::create_symlinks' to be used on directories ### [v1.1.0](https://github.com/gulrak/filesystem/releases/tag/v1.1.0) * Restructuring of the project directory. The header files are now using `hpp` as extension to be marked as c++ and they where moved to `include/ghc/` to be able to include by `` as the former include name might have been to generic and conflict with other files. * Better CMake support: `ghc::filesystem` now can be used as a submodul and added with `add_subdirectory` and will export itself as `ghc_filesystem` target. To use it, only `target_link_libraries(your-target ghc_filesystem)` is needed and the include directories will be set so `#include ` will be a valid directive. Still you can simply only add the header file to you project and include it from there. * Enhancement ([#10](https://github.com/gulrak/filesystem/issues/10)), support for separation of implementation and forwarded api: Two additional simple includes are added, that can be used to forward `ghc::filesystem` declarations (`fs_fwd.hpp`) and to wrap the implementation into a single cpp (`fs_impl.hpp`) * The `std::basic_string_view` variants of the `fs::path` api are now supported when compiling with C++17. * Added CI integration for Travis-CI and Appveyor. * Fixed MinGW compilation issues. * Added long filename support for Windows. ### [v1.0.10](https://github.com/gulrak/filesystem/releases/tag/v1.0.10) * Bugfix for ([#9](https://github.com/gulrak/filesystem/issues/9)), added missing return statement to `ghc::filesystem::path::generic_string()` * Added checks to hopefully better compile against Android NDK. There where no tests run yet, so feedback is needed to actually call this supported. * `filesystem.h` was renamed `filesystem.hpp` to better reflect that it is a c++ language header. ### [v1.0.8](https://github.com/gulrak/filesystem/releases/tag/v1.0.8) * Bugfix for ([#6](https://github.com/gulrak/filesystem/issues/6)), where `ghc::filesystem::remove()` and `ghc::filesystem::remove_all()` both are now able to remove a single file and both will not raise an error if the path doesn't exist. * Merged pull request ([#7](https://github.com/gulrak/filesystem/pull/7)), a typo leading to setting error code instead of comparing it in `ghc::filesystem::remove()` under Windows. * Bugfix for (([#8](https://github.com/gulrak/filesystem/issues/8)), the Windows version of `ghc::filesystem::directory_iterator` now releases resources when reaching `end()` like the POSIX one does. ### [v1.0.6](https://github.com/gulrak/filesystem/releases/tag/v1.0.6) * Bugfix for ([#4](https://github.com/gulrak/filesystem/issues/4)), missing error_code propagation in `ghc::filesystem::copy()` and `ghc::filesystem::remove_all` fixed. * Bugfix for ([#5](https://github.com/gulrak/filesystem/issues/5)), added missing std namespace in `ghc::filesystem::recursive_directory_iterator::difference_type`. ### [v1.0.4](https://github.com/gulrak/filesystem/releases/tag/v1.0.4) * Bugfix for ([#3](https://github.com/gulrak/filesystem/issues/3)), fixed missing inlines and added test to ensure including into multiple implementation files works as expected. * Building tests with `-Wall -Wextra -Werror` and fixed resulting issues. ### [v1.0.2](https://github.com/gulrak/filesystem/releases/tag/v1.0.2) * Updated catch2 to v2.4.0. * Refactored `fs.op.permissions` test to work with all tested `std::filesystem` implementations (gcc, clang, msvc++). * Added helper class `ghc::filesystem::u8arguments` as `argv` converter, to help follow the UTF-8 path on windows. Simply instantiate it with `argc` and `argv` and it will fetch the Unicode version of the command line and convert it to UTF-8. The destructor reverts the change. * Added `examples` folder with hopefully some usefull example usage. Examples are tested (and build) with `ghc::filesystem` and C++17 `std::filesystem` when available. * Starting with this version, only even patch level versions will be tagged and odd patch levels mark in-between non-stable wip states. * Tests can now also be run against MS version of std::filesystem for comparison. * Added missing `fstream` include. * Removed non-conforming C99 `timespec`/`timeval` usage. * Fixed some integer type mismatches that could lead to warnings. * Fixed `chrono` conversion issues in test and example on clang 7.0.0. ### [v1.0.1](https://github.com/gulrak/filesystem/releases/tag/v1.0.1) * Bugfix: `ghc::filesystem::canonical` now sees empty path as non-existant and reports an error. Due to this `ghc::filesystem::weakly_canonical` now returns relative paths for non-existant argument paths. ([#1](https://github.com/gulrak/filesystem/issues/1)) * Bugfix: `ghc::filesystem::remove_all` now also counts directories removed ([#2](https://github.com/gulrak/filesystem/issues/2)) * Bugfix: `recursive_directory_iterator` tests didn't respect equality domain issues and dereferencable constraints, leading to fails on `std::filesystem` tests. * Bugfix: Some `noexcept` tagged methods and functions could indirectly throw exceptions due to UFT-8 decoding issues. * `std_filesystem_test` is now also generated if LLVM/clang 7.0.0 is found. ### [v1.0.0](https://github.com/gulrak/filesystem/releases/tag/v1.0.0) This was the first public release version. It implements the full range of C++17 std::filesystem, as far as possible without other C++17 dependencies. kim-api-2.3.0-git/cpp/src/ghc-filesystem/filesystem.hpp000066400000000000000000005063001421473465500230340ustar00rootroot00000000000000//--------------------------------------------------------------------------------------- // // ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14/C++17 // //--------------------------------------------------------------------------------------- // // Copyright (c) 2018, Steffen SchÃŧmann // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // //--------------------------------------------------------------------------------------- // // To dynamically select std::filesystem where available, you could use: // // #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() // #include // namespace fs = std::filesystem; // #else // #include // namespace fs = ghc::filesystem; // #endif // //--------------------------------------------------------------------------------------- #ifndef GHC_FILESYSTEM_H #define GHC_FILESYSTEM_H // #define BSD manifest constant only in // sys/param.h #ifndef _WIN32 #include #endif #ifndef GHC_OS_DETECTED #if defined(__APPLE__) && defined(__MACH__) #define GHC_OS_MACOS #elif defined(__linux__) #define GHC_OS_LINUX #if defined(__ANDROID__) #define GHC_OS_ANDROID #endif #elif defined(_WIN64) #define GHC_OS_WINDOWS #define GHC_OS_WIN64 #elif defined(_WIN32) #define GHC_OS_WINDOWS #define GHC_OS_WIN32 #elif defined(__svr4__) #define GHC_OS_SYS5R4 #elif defined(BSD) #define GHC_OS_BSD #else #error "Operating system currently not supported!" #endif #define GHC_OS_DETECTED #endif #if defined(GHC_FILESYSTEM_IMPLEMENTATION) #define GHC_EXPAND_IMPL #define GHC_INLINE #ifdef GHC_OS_WINDOWS #define GHC_FS_API #define GHC_FS_API_CLASS #else #define GHC_FS_API __attribute__((visibility("default"))) #define GHC_FS_API_CLASS __attribute__((visibility("default"))) #endif #elif defined(GHC_FILESYSTEM_FWD) #define GHC_INLINE #ifdef GHC_OS_WINDOWS #define GHC_FS_API extern #define GHC_FS_API_CLASS #else #define GHC_FS_API extern #define GHC_FS_API_CLASS #endif #else #define GHC_EXPAND_IMPL #define GHC_INLINE inline #define GHC_FS_API #define GHC_FS_API_CLASS #endif #ifdef GHC_EXPAND_IMPL #ifdef GHC_OS_WINDOWS #include // additional includes #include #include #include #include #include #else #include #include #include #include #include #include #include #include #ifdef GHC_OS_ANDROID #include #if __ANDROID_API__ < 12 #include #endif #include #define statvfs statfs #else #include #endif #if !defined(__ANDROID__) || __ANDROID_API__ >= 26 #include #endif #endif #ifdef GHC_OS_MACOS #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #else // GHC_EXPAND_IMPL #include #include #include #include #include #include #include #ifdef GHC_OS_WINDOWS #include #endif #endif // GHC_EXPAND_IMPL //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Behaviour Switches (see README.md, should match the config in test/filesystem_test.cpp): //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2682 disables the since then invalid use of the copy option create_symlinks on directories // configure LWG conformance () #define LWG_2682_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2395 makes crate_directory/create_directories not emit an error if there is a regular // file with that name, it is superceded by P1164R1, so only activate if really needed // #define LWG_2935_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2937 enforces that fs::equivalent emits an error, if !fs::exists(p1)||!exists(p2) #define LWG_2937_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // UTF8-Everywhere is the original behaviour of ghc::filesystem. With this define you can // enable the more standard conforming implementation option that uses wstring on Windows // as ghc::filesystem::string_type. // #define GHC_WIN_WSTRING_STRING_TYPE //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Raise errors/exceptions when invalid unicode codepoints or UTF-8 sequences are found, // instead of replacing them with the unicode replacement character (U+FFFD). // #define GHC_RAISE_UNICODE_ERRORS //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) #define GHC_FILESYSTEM_VERSION 10303L #if !defined(GHC_WITH_EXCEPTIONS) && (defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)) #define GHC_WITH_EXCEPTIONS #endif #if !defined(GHC_WITH_EXCEPTIONS) && defined(GHC_RAISE_UNICODE_ERRORS) #error "Can't raise unicode errors whith exception support disabled" #endif namespace ghc { namespace filesystem { // temporary existing exception type for yet unimplemented parts class GHC_FS_API_CLASS not_implemented_exception : public std::logic_error { public: not_implemented_exception() : std::logic_error("function not implemented yet.") { } }; template class path_helper_base { public: using value_type = char_type; #ifdef GHC_OS_WINDOWS static constexpr value_type preferred_separator = '\\'; #else static constexpr value_type preferred_separator = '/'; #endif }; #if __cplusplus < 201703L template constexpr char_type path_helper_base::preferred_separator; #endif // 30.10.8 class path class GHC_FS_API_CLASS path #if defined(GHC_OS_WINDOWS) && defined(GHC_WIN_WSTRING_STRING_TYPE) #define GHC_USE_WCHAR_T : private path_helper_base { public: using path_helper_base::value_type; #else : private path_helper_base { public: using path_helper_base::value_type; #endif using string_type = std::basic_string; using path_helper_base::preferred_separator; // 30.10.10.1 enumeration format /// The path format in wich the constructor argument is given. enum format { generic_format, ///< The generic format, internally used by ///< ghc::filesystem::path with slashes native_format, ///< The format native to the current platform this code ///< is build for auto_format, ///< Try to auto-detect the format, fallback to native }; template struct _is_basic_string : std::false_type { }; template struct _is_basic_string> : std::true_type { }; #ifdef __cpp_lib_string_view template struct _is_basic_string> : std::true_type { }; #endif template using path_type = typename std::enable_if::value, path>::type; #ifdef GHC_USE_WCHAR_T template using path_from_string = typename std::enable_if<_is_basic_string::value || std::is_same::type>::value || std::is_same::type>::value || std::is_same::type>::value || std::is_same::type>::value, path>::type; template using path_type_EcharT = typename std::enable_if::value || std::is_same::value || std::is_same::value, path>::type; #else template using path_from_string = typename std::enable_if<_is_basic_string::value || std::is_same::type>::value || std::is_same::type>::value, path>::type; template using path_type_EcharT = typename std::enable_if::value || std::is_same::value || std::is_same::value || std::is_same::value, path>::type; #endif // 30.10.8.4.1 constructors and destructor path() noexcept; path(const path& p); path(path&& p) noexcept; path(string_type&& source, format fmt = auto_format); template > path(const Source& source, format fmt = auto_format); template path(InputIterator first, InputIterator last, format fmt = auto_format); #ifdef GHC_WITH_EXCEPTIONS template > path(const Source& source, const std::locale& loc, format fmt = auto_format); template path(InputIterator first, InputIterator last, const std::locale& loc, format fmt = auto_format); #endif ~path(); // 30.10.8.4.2 assignments path& operator=(const path& p); path& operator=(path&& p) noexcept; path& operator=(string_type&& source); path& assign(string_type&& source); template path& operator=(const Source& source); template path& assign(const Source& source); template path& assign(InputIterator first, InputIterator last); // 30.10.8.4.3 appends path& operator/=(const path& p); template path& operator/=(const Source& source); template path& append(const Source& source); template path& append(InputIterator first, InputIterator last); // 30.10.8.4.4 concatenation path& operator+=(const path& x); path& operator+=(const string_type& x); #ifdef __cpp_lib_string_view path& operator+=(std::basic_string_view x); #endif path& operator+=(const value_type* x); path& operator+=(value_type x); template path_from_string& operator+=(const Source& x); template path_type_EcharT& operator+=(EcharT x); template path& concat(const Source& x); template path& concat(InputIterator first, InputIterator last); // 30.10.8.4.5 modifiers void clear() noexcept; path& make_preferred(); path& remove_filename(); path& replace_filename(const path& replacement); path& replace_extension(const path& replacement = path()); void swap(path& rhs) noexcept; // 30.10.8.4.6 native format observers const string_type& native() const; // this implementation doesn't support noexcept for native() const value_type* c_str() const; // this implementation doesn't support noexcept for c_str() operator string_type() const; template , class Allocator = std::allocator> std::basic_string string(const Allocator& a = Allocator()) const; std::string string() const; std::wstring wstring() const; std::string u8string() const; std::u16string u16string() const; std::u32string u32string() const; // 30.10.8.4.7 generic format observers template , class Allocator = std::allocator> std::basic_string generic_string(const Allocator& a = Allocator()) const; const std::string& generic_string() const; // this is different from the standard, that returns by value std::wstring generic_wstring() const; std::string generic_u8string() const; std::u16string generic_u16string() const; std::u32string generic_u32string() const; // 30.10.8.4.8 compare int compare(const path& p) const noexcept; int compare(const string_type& s) const; #ifdef __cpp_lib_string_view int compare(std::basic_string_view s) const; #endif int compare(const value_type* s) const; // 30.10.8.4.9 decomposition path root_name() const; path root_directory() const; path root_path() const; path relative_path() const; path parent_path() const; path filename() const; path stem() const; path extension() const; // 30.10.8.4.10 query bool empty() const noexcept; bool has_root_name() const; bool has_root_directory() const; bool has_root_path() const; bool has_relative_path() const; bool has_parent_path() const; bool has_filename() const; bool has_stem() const; bool has_extension() const; bool is_absolute() const; bool is_relative() const; // 30.10.8.4.11 generation path lexically_normal() const; path lexically_relative(const path& base) const; path lexically_proximate(const path& base) const; // 30.10.8.5 iterators class iterator; using const_iterator = iterator; iterator begin() const; iterator end() const; private: using impl_value_type = std::string::value_type; using impl_string_type = std::basic_string; friend class directory_iterator; void append_name(const char* name); static constexpr impl_value_type generic_separator = '/'; template class input_iterator_range { public: typedef InputIterator iterator; typedef InputIterator const_iterator; typedef typename InputIterator::difference_type difference_type; input_iterator_range(const InputIterator& first, const InputIterator& last) : _first(first) , _last(last) { } InputIterator begin() const { return _first; } InputIterator end() const { return _last; } private: InputIterator _first; InputIterator _last; }; friend void swap(path& lhs, path& rhs) noexcept; friend size_t hash_value(const path& p) noexcept; static void postprocess_path_with_format(impl_string_type& p, format fmt); impl_string_type _path; #ifdef GHC_OS_WINDOWS impl_string_type native_impl() const; mutable string_type _native_cache; #else const impl_string_type& native_impl() const; #endif }; // 30.10.8.6 path non-member functions GHC_FS_API void swap(path& lhs, path& rhs) noexcept; GHC_FS_API size_t hash_value(const path& p) noexcept; GHC_FS_API bool operator==(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator!=(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator<(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator<=(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator>(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator>=(const path& lhs, const path& rhs) noexcept; GHC_FS_API path operator/(const path& lhs, const path& rhs); // 30.10.8.6.1 path inserter and extractor template std::basic_ostream& operator<<(std::basic_ostream& os, const path& p); template std::basic_istream& operator>>(std::basic_istream& is, path& p); // 30.10.8.6.2 path factory functions template > path u8path(const Source& source); template path u8path(InputIterator first, InputIterator last); // 30.10.9 class filesystem_error class GHC_FS_API_CLASS filesystem_error : public std::system_error { public: filesystem_error(const std::string& what_arg, std::error_code ec); filesystem_error(const std::string& what_arg, const path& p1, std::error_code ec); filesystem_error(const std::string& what_arg, const path& p1, const path& p2, std::error_code ec); const path& path1() const noexcept; const path& path2() const noexcept; const char* what() const noexcept override; private: std::string _what_arg; std::error_code _ec; path _p1, _p2; }; class GHC_FS_API_CLASS path::iterator { public: using value_type = const path; using difference_type = std::ptrdiff_t; using pointer = const path*; using reference = const path&; using iterator_category = std::bidirectional_iterator_tag; iterator(); iterator(const impl_string_type::const_iterator& first, const impl_string_type::const_iterator& last, const impl_string_type::const_iterator& pos); iterator& operator++(); iterator operator++(int); iterator& operator--(); iterator operator--(int); bool operator==(const iterator& other) const; bool operator!=(const iterator& other) const; reference operator*() const; pointer operator->() const; private: impl_string_type::const_iterator increment(const std::string::const_iterator& pos) const; impl_string_type::const_iterator decrement(const std::string::const_iterator& pos) const; void updateCurrent(); impl_string_type::const_iterator _first; impl_string_type::const_iterator _last; impl_string_type::const_iterator _root; impl_string_type::const_iterator _iter; path _current; }; struct space_info { uintmax_t capacity; uintmax_t free; uintmax_t available; }; // 30.10.10, enumerations enum class file_type { none, not_found, regular, directory, symlink, block, character, fifo, socket, unknown, }; enum class perms : uint16_t { none = 0, owner_read = 0400, owner_write = 0200, owner_exec = 0100, owner_all = 0700, group_read = 040, group_write = 020, group_exec = 010, group_all = 070, others_read = 04, others_write = 02, others_exec = 01, others_all = 07, all = 0777, set_uid = 04000, set_gid = 02000, sticky_bit = 01000, mask = 07777, unknown = 0xffff }; enum class perm_options : uint16_t { replace = 3, add = 1, remove = 2, nofollow = 4, }; enum class copy_options : uint16_t { none = 0, skip_existing = 1, overwrite_existing = 2, update_existing = 4, recursive = 8, copy_symlinks = 0x10, skip_symlinks = 0x20, directories_only = 0x40, create_symlinks = 0x80, create_hard_links = 0x100 }; enum class directory_options : uint16_t { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2, }; // 30.10.11 class file_status class GHC_FS_API_CLASS file_status { public: // 30.10.11.1 constructors and destructor file_status() noexcept; explicit file_status(file_type ft, perms prms = perms::unknown) noexcept; file_status(const file_status&) noexcept; file_status(file_status&&) noexcept; ~file_status(); // assignments: file_status& operator=(const file_status&) noexcept; file_status& operator=(file_status&&) noexcept; // 30.10.11.3 modifiers void type(file_type ft) noexcept; void permissions(perms prms) noexcept; // 30.10.11.2 observers file_type type() const noexcept; perms permissions() const noexcept; private: file_type _type; perms _perms; }; using file_time_type = std::chrono::time_point; // 30.10.12 Class directory_entry class GHC_FS_API_CLASS directory_entry { public: // 30.10.12.1 constructors and destructor directory_entry() noexcept = default; directory_entry(const directory_entry&) = default; directory_entry(directory_entry&&) noexcept = default; #ifdef GHC_WITH_EXCEPTIONS explicit directory_entry(const path& p); #endif directory_entry(const path& p, std::error_code& ec); ~directory_entry(); // assignments: directory_entry& operator=(const directory_entry&) = default; directory_entry& operator=(directory_entry&&) noexcept = default; // 30.10.12.2 modifiers #ifdef GHC_WITH_EXCEPTIONS void assign(const path& p); #endif void assign(const path& p, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS void replace_filename(const path& p); #endif void replace_filename(const path& p, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS void refresh(); #endif void refresh(std::error_code& ec) noexcept; // 30.10.12.3 observers const filesystem::path& path() const noexcept; operator const filesystem::path&() const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool exists() const; #endif bool exists(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_block_file() const; #endif bool is_block_file(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_character_file() const; #endif bool is_character_file(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_directory() const; #endif bool is_directory(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_fifo() const; #endif bool is_fifo(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_other() const; #endif bool is_other(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_regular_file() const; #endif bool is_regular_file(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_socket() const; #endif bool is_socket(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS bool is_symlink() const; #endif bool is_symlink(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS uintmax_t file_size() const; #endif uintmax_t file_size(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS uintmax_t hard_link_count() const; #endif uintmax_t hard_link_count(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS file_time_type last_write_time() const; #endif file_time_type last_write_time(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS file_status status() const; #endif file_status status(std::error_code& ec) const noexcept; #ifdef GHC_WITH_EXCEPTIONS file_status symlink_status() const; #endif file_status symlink_status(std::error_code& ec) const noexcept; bool operator<(const directory_entry& rhs) const noexcept; bool operator==(const directory_entry& rhs) const noexcept; bool operator!=(const directory_entry& rhs) const noexcept; bool operator<=(const directory_entry& rhs) const noexcept; bool operator>(const directory_entry& rhs) const noexcept; bool operator>=(const directory_entry& rhs) const noexcept; private: friend class directory_iterator; filesystem::path _path; file_status _status; file_status _symlink_status; uintmax_t _file_size = 0; #ifndef GHC_OS_WINDOWS uintmax_t _hard_link_count = 0; #endif time_t _last_write_time = 0; }; // 30.10.13 Class directory_iterator class GHC_FS_API_CLASS directory_iterator { public: class GHC_FS_API_CLASS proxy { public: const directory_entry& operator*() const& noexcept { return _dir_entry; } directory_entry operator*() && noexcept { return std::move(_dir_entry); } private: explicit proxy(const directory_entry& dir_entry) : _dir_entry(dir_entry) { } friend class directory_iterator; friend class recursive_directory_iterator; directory_entry _dir_entry; }; using iterator_category = std::input_iterator_tag; using value_type = directory_entry; using difference_type = std::ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // 30.10.13.1 member functions directory_iterator() noexcept; #ifdef GHC_WITH_EXCEPTIONS explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); #endif directory_iterator(const path& p, std::error_code& ec) noexcept; directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept; directory_iterator(const directory_iterator& rhs); directory_iterator(directory_iterator&& rhs) noexcept; ~directory_iterator(); directory_iterator& operator=(const directory_iterator& rhs); directory_iterator& operator=(directory_iterator&& rhs) noexcept; const directory_entry& operator*() const; const directory_entry* operator->() const; #ifdef GHC_WITH_EXCEPTIONS directory_iterator& operator++(); #endif directory_iterator& increment(std::error_code& ec) noexcept; // other members as required by 27.2.3, input iterators #ifdef GHC_WITH_EXCEPTIONS proxy operator++(int) { proxy p{**this}; ++*this; return p; } #endif bool operator==(const directory_iterator& rhs) const; bool operator!=(const directory_iterator& rhs) const; private: friend class recursive_directory_iterator; class impl; std::shared_ptr _impl; }; // 30.10.13.2 directory_iterator non-member functions GHC_FS_API directory_iterator begin(directory_iterator iter) noexcept; GHC_FS_API directory_iterator end(const directory_iterator&) noexcept; // 30.10.14 class recursive_directory_iterator class GHC_FS_API_CLASS recursive_directory_iterator { public: using iterator_category = std::input_iterator_tag; using value_type = directory_entry; using difference_type = std::ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // 30.10.14.1 constructors and destructor recursive_directory_iterator() noexcept; #ifdef GHC_WITH_EXCEPTIONS explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); #endif recursive_directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept; recursive_directory_iterator(const path& p, std::error_code& ec) noexcept; recursive_directory_iterator(const recursive_directory_iterator& rhs); recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; ~recursive_directory_iterator(); // 30.10.14.1 observers directory_options options() const; int depth() const; bool recursion_pending() const; const directory_entry& operator*() const; const directory_entry* operator->() const; // 30.10.14.1 modifiers recursive_directory_iterator& recursive_directory_iterator& operator=(const recursive_directory_iterator& rhs); recursive_directory_iterator& operator=(recursive_directory_iterator&& rhs) noexcept; #ifdef GHC_WITH_EXCEPTIONS recursive_directory_iterator& operator++(); #endif recursive_directory_iterator& increment(std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS void pop(); #endif void pop(std::error_code& ec); void disable_recursion_pending(); // other members as required by 27.2.3, input iterators #ifdef GHC_WITH_EXCEPTIONS directory_iterator::proxy operator++(int) { directory_iterator::proxy proxy{**this}; ++*this; return proxy; } #endif bool operator==(const recursive_directory_iterator& rhs) const; bool operator!=(const recursive_directory_iterator& rhs) const; private: struct recursive_directory_iterator_impl { directory_options _options; bool _recursion_pending; std::stack _dir_iter_stack; recursive_directory_iterator_impl(directory_options options, bool recursion_pending) : _options(options) , _recursion_pending(recursion_pending) { } }; std::shared_ptr _impl; }; // 30.10.14.2 directory_iterator non-member functions GHC_FS_API recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; GHC_FS_API recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; // 30.10.15 filesystem operations #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path absolute(const path& p); #endif GHC_FS_API path absolute(const path& p, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path canonical(const path& p); #endif GHC_FS_API path canonical(const path& p, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void copy(const path& from, const path& to); #endif GHC_FS_API void copy(const path& from, const path& to, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void copy(const path& from, const path& to, copy_options options); #endif GHC_FS_API void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool copy_file(const path& from, const path& to); #endif GHC_FS_API bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option); #endif GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink); #endif GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool create_directories(const path& p); #endif GHC_FS_API bool create_directories(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool create_directory(const path& p); #endif GHC_FS_API bool create_directory(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool create_directory(const path& p, const path& attributes); #endif GHC_FS_API bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink); #endif GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link); #endif GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void create_symlink(const path& to, const path& new_symlink); #endif GHC_FS_API void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path current_path(); #endif GHC_FS_API path current_path(std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void current_path(const path& p); #endif GHC_FS_API void current_path(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool exists(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool exists(const path& p); #endif GHC_FS_API bool exists(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool equivalent(const path& p1, const path& p2); #endif GHC_FS_API bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API uintmax_t file_size(const path& p); #endif GHC_FS_API uintmax_t file_size(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API uintmax_t hard_link_count(const path& p); #endif GHC_FS_API uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_block_file(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_block_file(const path& p); #endif GHC_FS_API bool is_block_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_character_file(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_character_file(const path& p); #endif GHC_FS_API bool is_character_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_directory(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_directory(const path& p); #endif GHC_FS_API bool is_directory(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_empty(const path& p); #endif GHC_FS_API bool is_empty(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_fifo(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_fifo(const path& p); #endif GHC_FS_API bool is_fifo(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_other(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_other(const path& p); #endif GHC_FS_API bool is_other(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_regular_file(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_regular_file(const path& p); #endif GHC_FS_API bool is_regular_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_socket(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_socket(const path& p); #endif GHC_FS_API bool is_socket(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_symlink(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool is_symlink(const path& p); #endif GHC_FS_API bool is_symlink(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API file_time_type last_write_time(const path& p); #endif GHC_FS_API file_time_type last_write_time(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void last_write_time(const path& p, file_time_type new_time); #endif GHC_FS_API void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void permissions(const path& p, perms prms, perm_options opts = perm_options::replace); #endif GHC_FS_API void permissions(const path& p, perms prms, std::error_code& ec) noexcept; GHC_FS_API void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path proximate(const path& p, std::error_code& ec); GHC_FS_API path proximate(const path& p, const path& base = current_path()); #endif GHC_FS_API path proximate(const path& p, const path& base, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path read_symlink(const path& p); #endif GHC_FS_API path read_symlink(const path& p, std::error_code& ec); GHC_FS_API path relative(const path& p, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path relative(const path& p, const path& base = current_path()); #endif GHC_FS_API path relative(const path& p, const path& base, std::error_code& ec); #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API bool remove(const path& p); #endif GHC_FS_API bool remove(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API uintmax_t remove_all(const path& p); #endif GHC_FS_API uintmax_t remove_all(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void rename(const path& from, const path& to); #endif GHC_FS_API void rename(const path& from, const path& to, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API void resize_file(const path& p, uintmax_t size); #endif GHC_FS_API void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API space_info space(const path& p); #endif GHC_FS_API space_info space(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API file_status status(const path& p); #endif GHC_FS_API file_status status(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool status_known(file_status s) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API file_status symlink_status(const path& p); #endif GHC_FS_API file_status symlink_status(const path& p, std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path temp_directory_path(); #endif GHC_FS_API path temp_directory_path(std::error_code& ec) noexcept; #ifdef GHC_WITH_EXCEPTIONS GHC_FS_API path weakly_canonical(const path& p); #endif GHC_FS_API path weakly_canonical(const path& p, std::error_code& ec) noexcept; // Non-C++17 add-on std::fstream wrappers with path template > class basic_filebuf : public std::basic_filebuf { public: basic_filebuf() {} ~basic_filebuf() override {} basic_filebuf(const basic_filebuf&) = delete; const basic_filebuf& operator=(const basic_filebuf&) = delete; basic_filebuf* open(const path& p, std::ios_base::openmode mode) { #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) return std::basic_filebuf::open(p.wstring().c_str(), mode) ? this : 0; #else return std::basic_filebuf::open(p.string().c_str(), mode) ? this : 0; #endif } }; template > class basic_ifstream : public std::basic_ifstream { public: basic_ifstream() {} #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) explicit basic_ifstream(const path& p, std::ios_base::openmode mode = std::ios_base::in) : std::basic_ifstream(p.wstring().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in) { std::basic_ifstream::open(p.wstring().c_str(), mode); } #else explicit basic_ifstream(const path& p, std::ios_base::openmode mode = std::ios_base::in) : std::basic_ifstream(p.string().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in) { std::basic_ifstream::open(p.string().c_str(), mode); } #endif basic_ifstream(const basic_ifstream&) = delete; const basic_ifstream& operator=(const basic_ifstream&) = delete; ~basic_ifstream() override {} }; template > class basic_ofstream : public std::basic_ofstream { public: basic_ofstream() {} #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) explicit basic_ofstream(const path& p, std::ios_base::openmode mode = std::ios_base::out) : std::basic_ofstream(p.wstring().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::out) { std::basic_ofstream::open(p.wstring().c_str(), mode); } #else explicit basic_ofstream(const path& p, std::ios_base::openmode mode = std::ios_base::out) : std::basic_ofstream(p.string().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::out) { std::basic_ofstream::open(p.string().c_str(), mode); } #endif basic_ofstream(const basic_ofstream&) = delete; const basic_ofstream& operator=(const basic_ofstream&) = delete; ~basic_ofstream() override {} }; template > class basic_fstream : public std::basic_fstream { public: basic_fstream() {} #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) explicit basic_fstream(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : std::basic_fstream(p.wstring().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) { std::basic_fstream::open(p.wstring().c_str(), mode); } #else explicit basic_fstream(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : std::basic_fstream(p.string().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) { std::basic_fstream::open(p.string().c_str(), mode); } #endif basic_fstream(const basic_fstream&) = delete; const basic_fstream& operator=(const basic_fstream&) = delete; ~basic_fstream() override {} }; typedef basic_filebuf filebuf; typedef basic_filebuf wfilebuf; typedef basic_ifstream ifstream; typedef basic_ifstream wifstream; typedef basic_ofstream ofstream; typedef basic_ofstream wofstream; typedef basic_fstream fstream; typedef basic_fstream wfstream; class GHC_FS_API_CLASS u8arguments { public: u8arguments(int& argc, char**& argv); ~u8arguments() { _refargc = _argc; _refargv = _argv; } bool valid() const { return _isvalid; } private: int _argc; char** _argv; int& _refargc; char**& _refargv; bool _isvalid; #ifdef GHC_OS_WINDOWS std::vector _args; std::vector _argp; #endif }; //------------------------------------------------------------------------------------------------- // Implementation //------------------------------------------------------------------------------------------------- namespace detail { // GHC_FS_API void postprocess_path_with_format(path::impl_string_type& p, path::format fmt); enum utf8_states_t { S_STRT = 0, S_RJCT = 8 }; GHC_FS_API void appendUTF8(std::string& str, uint32_t unicode); GHC_FS_API bool is_surrogate(uint32_t c); GHC_FS_API bool is_high_surrogate(uint32_t c); GHC_FS_API bool is_low_surrogate(uint32_t c); GHC_FS_API unsigned consumeUtf8Fragment(const unsigned state, const uint8_t fragment, uint32_t& codepoint); enum class portable_error { none = 0, exists, not_found, not_supported, not_implemented, invalid_argument, is_a_directory, }; GHC_FS_API std::error_code make_error_code(portable_error err); #ifdef GHC_OS_WINDOWS GHC_FS_API std::error_code make_system_error(uint32_t err = 0); #else GHC_FS_API std::error_code make_system_error(int err = 0); #endif } // namespace detail namespace detail { #ifdef GHC_EXPAND_IMPL GHC_INLINE std::error_code make_error_code(portable_error err) { #ifdef GHC_OS_WINDOWS switch (err) { case portable_error::none: return std::error_code(); case portable_error::exists: return std::error_code(ERROR_ALREADY_EXISTS, std::system_category()); case portable_error::not_found: return std::error_code(ERROR_PATH_NOT_FOUND, std::system_category()); case portable_error::not_supported: return std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); case portable_error::not_implemented: return std::error_code(ERROR_CALL_NOT_IMPLEMENTED, std::system_category()); case portable_error::invalid_argument: return std::error_code(ERROR_INVALID_PARAMETER, std::system_category()); case portable_error::is_a_directory: #ifdef ERROR_DIRECTORY_NOT_SUPPORTED return std::error_code(ERROR_DIRECTORY_NOT_SUPPORTED, std::system_category()); #else return std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); #endif } #else switch (err) { case portable_error::none: return std::error_code(); case portable_error::exists: return std::error_code(EEXIST, std::system_category()); case portable_error::not_found: return std::error_code(ENOENT, std::system_category()); case portable_error::not_supported: return std::error_code(ENOTSUP, std::system_category()); case portable_error::not_implemented: return std::error_code(ENOSYS, std::system_category()); case portable_error::invalid_argument: return std::error_code(EINVAL, std::system_category()); case portable_error::is_a_directory: return std::error_code(EISDIR, std::system_category()); } #endif return std::error_code(); } #ifdef GHC_OS_WINDOWS GHC_INLINE std::error_code make_system_error(uint32_t err) { return std::error_code(err ? static_cast(err) : static_cast(::GetLastError()), std::system_category()); } #else GHC_INLINE std::error_code make_system_error(int err) { return std::error_code(err ? err : errno, std::system_category()); } #endif #endif // GHC_EXPAND_IMPL template using EnableBitmask = typename std::enable_if::value || std::is_same::value || std::is_same::value || std::is_same::value, Enum>::type; } // namespace detail template detail::EnableBitmask operator&(Enum X, Enum Y) { using underlying = typename std::underlying_type::type; return static_cast(static_cast(X) & static_cast(Y)); } template detail::EnableBitmask operator|(Enum X, Enum Y) { using underlying = typename std::underlying_type::type; return static_cast(static_cast(X) | static_cast(Y)); } template detail::EnableBitmask operator^(Enum X, Enum Y) { using underlying = typename std::underlying_type::type; return static_cast(static_cast(X) ^ static_cast(Y)); } template detail::EnableBitmask operator~(Enum X) { using underlying = typename std::underlying_type::type; return static_cast(~static_cast(X)); } template detail::EnableBitmask& operator&=(Enum& X, Enum Y) { X = X & Y; return X; } template detail::EnableBitmask& operator|=(Enum& X, Enum Y) { X = X | Y; return X; } template detail::EnableBitmask& operator^=(Enum& X, Enum Y) { X = X ^ Y; return X; } #ifdef GHC_EXPAND_IMPL namespace detail { GHC_INLINE bool in_range(uint32_t c, uint32_t lo, uint32_t hi) { return (static_cast(c - lo) < (hi - lo + 1)); } GHC_INLINE bool is_surrogate(uint32_t c) { return in_range(c, 0xd800, 0xdfff); } GHC_INLINE bool is_high_surrogate(uint32_t c) { return (c & 0xfffffc00) == 0xd800; } GHC_INLINE bool is_low_surrogate(uint32_t c) { return (c & 0xfffffc00) == 0xdc00; } GHC_INLINE void appendUTF8(std::string& str, uint32_t unicode) { if (unicode <= 0x7f) { str.push_back(static_cast(unicode)); } else if (unicode >= 0x80 && unicode <= 0x7ff) { str.push_back(static_cast((unicode >> 6) + 192)); str.push_back(static_cast((unicode & 0x3f) + 128)); } else if ((unicode >= 0x800 && unicode <= 0xd7ff) || (unicode >= 0xe000 && unicode <= 0xffff)) { str.push_back(static_cast((unicode >> 12) + 224)); str.push_back(static_cast(((unicode & 0xfff) >> 6) + 128)); str.push_back(static_cast((unicode & 0x3f) + 128)); } else if (unicode >= 0x10000 && unicode <= 0x10ffff) { str.push_back(static_cast((unicode >> 18) + 240)); str.push_back(static_cast(((unicode & 0x3ffff) >> 12) + 128)); str.push_back(static_cast(((unicode & 0xfff) >> 6) + 128)); str.push_back(static_cast((unicode & 0x3f) + 128)); } else { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal code point for unicode character.", str, std::make_error_code(std::errc::illegal_byte_sequence)); #else appendUTF8(str, 0xfffd); #endif } } // Thanks to Bjoern Hoehrmann (https://bjoern.hoehrmann.de/utf-8/decoder/dfa/) // and Taylor R Campbell for the ideas to this DFA approach of UTF-8 decoding; // Generating debugging and shrinking my own DFA from scratch was a day of fun! GHC_INLINE unsigned consumeUtf8Fragment(const unsigned state, const uint8_t fragment, uint32_t& codepoint) { static const uint32_t utf8_state_info[] = { // encoded states 0x11111111u, 0x11111111u, 0x77777777u, 0x77777777u, 0x88888888u, 0x88888888u, 0x88888888u, 0x88888888u, 0x22222299u, 0x22222222u, 0x22222222u, 0x22222222u, 0x3333333au, 0x33433333u, 0x9995666bu, 0x99999999u, 0x88888880u, 0x22818108u, 0x88888881u, 0x88888882u, 0x88888884u, 0x88888887u, 0x88888886u, 0x82218108u, 0x82281108u, 0x88888888u, 0x88888883u, 0x88888885u, 0u, 0u, 0u, 0u, }; uint8_t category = fragment < 128 ? 0 : (utf8_state_info[(fragment >> 3) & 0xf] >> ((fragment & 7) << 2)) & 0xf; codepoint = (state ? (codepoint << 6) | (fragment & 0x3fu) : (0xffu >> category) & fragment); return state == S_RJCT ? static_cast(S_RJCT) : static_cast((utf8_state_info[category + 16] >> (state << 2)) & 0xf); } GHC_INLINE bool validUtf8(const std::string& utf8String) { std::string::const_iterator iter = utf8String.begin(); unsigned utf8_state = S_STRT; std::uint32_t codepoint = 0; while (iter < utf8String.end()) { if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast(*iter++), codepoint)) == S_RJCT) { return false; } } if (utf8_state) { return false; } return true; } } // namespace detail #endif namespace detail { template ::type* = nullptr> inline StringType fromUtf8(const std::string& utf8String, const typename StringType::allocator_type& alloc = typename StringType::allocator_type()) { return StringType(utf8String.begin(), utf8String.end(), alloc); } template ::type* = nullptr> inline StringType fromUtf8(const std::string& utf8String, const typename StringType::allocator_type& alloc = typename StringType::allocator_type()) { StringType result(alloc); result.reserve(utf8String.length()); std::string::const_iterator iter = utf8String.begin(); unsigned utf8_state = S_STRT; std::uint32_t codepoint = 0; while (iter < utf8String.end()) { if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast(*iter++), codepoint)) == S_STRT) { if (codepoint <= 0xffff) { result += static_cast(codepoint); } else { codepoint -= 0x10000; result += static_cast((codepoint >> 10) + 0xd800); result += static_cast((codepoint & 0x3ff) + 0xdc00); } codepoint = 0; } else if (utf8_state == S_RJCT) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += static_cast(0xfffd); utf8_state = S_STRT; codepoint = 0; #endif } } if (utf8_state) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += static_cast(0xfffd); #endif } return result; } template ::type* = nullptr> inline StringType fromUtf8(const std::string& utf8String, const typename StringType::allocator_type& alloc = typename StringType::allocator_type()) { StringType result(alloc); result.reserve(utf8String.length()); std::string::const_iterator iter = utf8String.begin(); unsigned utf8_state = S_STRT; std::uint32_t codepoint = 0; while (iter < utf8String.end()) { if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast(*iter++), codepoint)) == S_STRT) { result += static_cast(codepoint); codepoint = 0; } else if (utf8_state == S_RJCT) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += static_cast(0xfffd); utf8_state = S_STRT; codepoint = 0; #endif } } if (utf8_state) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += static_cast(0xfffd); #endif } return result; } template ::type size = 1> inline std::string toUtf8(const std::basic_string& unicodeString) { return std::string(unicodeString.begin(), unicodeString.end()); } template ::type size = 2> inline std::string toUtf8(const std::basic_string& unicodeString) { std::string result; for (auto iter = unicodeString.begin(); iter != unicodeString.end(); ++iter) { char32_t c = *iter; if (is_surrogate(c)) { ++iter; if (iter != unicodeString.end() && is_high_surrogate(c) && is_low_surrogate(*iter)) { appendUTF8(result, (char32_t(c) << 10) + *iter - 0x35fdc00); } else { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal code point for unicode character.", result, std::make_error_code(std::errc::illegal_byte_sequence)); #else appendUTF8(result, 0xfffd); if(iter == unicodeString.end()) { break; } #endif } } else { appendUTF8(result, c); } } return result; } template ::type size = 4> inline std::string toUtf8(const std::basic_string& unicodeString) { std::string result; for (auto c : unicodeString) { appendUTF8(result, static_cast(c)); } return result; } template inline std::string toUtf8(const charT* unicodeString) { return toUtf8(std::basic_string>(unicodeString)); } } // namespace detail #ifdef GHC_EXPAND_IMPL namespace detail { GHC_INLINE bool startsWith(const std::string& what, const std::string& with) { return with.length() <= what.length() && equal(with.begin(), with.end(), what.begin()); } } // namespace detail GHC_INLINE void path::postprocess_path_with_format(path::impl_string_type& p, path::format fmt) { #ifdef GHC_RAISE_UNICODE_ERRORS if(!detail::validUtf8(p)) { path t; t._path = p; throw filesystem_error("Illegal byte sequence for unicode character.", t, std::make_error_code(std::errc::illegal_byte_sequence)); } #endif switch (fmt) { #ifndef GHC_OS_WINDOWS case path::auto_format: case path::native_format: #endif case path::generic_format: // nothing to do break; #ifdef GHC_OS_WINDOWS case path::auto_format: case path::native_format: if (detail::startsWith(p, std::string("\\\\?\\"))) { // remove Windows long filename marker p.erase(0, 4); if (detail::startsWith(p, std::string("UNC\\"))) { p.erase(0, 2); p[0] = '\\'; } } for (auto& c : p) { if (c == '\\') { c = '/'; } } break; #endif } if (p.length() > 2 && p[0] == '/' && p[1] == '/' && p[2] != '/') { std::string::iterator new_end = std::unique(p.begin() + 2, p.end(), [](path::value_type lhs, path::value_type rhs) { return lhs == rhs && lhs == '/'; }); p.erase(new_end, p.end()); } else { std::string::iterator new_end = std::unique(p.begin(), p.end(), [](path::value_type lhs, path::value_type rhs) { return lhs == rhs && lhs == '/'; }); p.erase(new_end, p.end()); } } #endif // GHC_EXPAND_IMPL template inline path::path(const Source& source, format fmt) : _path(detail::toUtf8(source)) { postprocess_path_with_format(_path, fmt); } template <> inline path::path(const std::wstring& source, format fmt) { _path = detail::toUtf8(source); postprocess_path_with_format(_path, fmt); } template <> inline path::path(const std::u16string& source, format fmt) { _path = detail::toUtf8(source); postprocess_path_with_format(_path, fmt); } template <> inline path::path(const std::u32string& source, format fmt) { _path = detail::toUtf8(source); postprocess_path_with_format(_path, fmt); } #ifdef __cpp_lib_string_view template <> inline path::path(const std::string_view& source, format fmt) { _path = detail::toUtf8(std::string(source)); postprocess_path_with_format(_path, fmt); } #ifdef GHC_USE_WCHAR_T template <> inline path::path(const std::wstring_view& source, format fmt) { _path = detail::toUtf8(std::wstring(source).c_str()); postprocess_path_with_format(_path, fmt); } #endif #endif template inline path u8path(const Source& source) { return path(source); } template inline path u8path(InputIterator first, InputIterator last) { return path(first, last); } template inline path::path(InputIterator first, InputIterator last, format fmt) : path(std::basic_string::value_type>(first, last), fmt) { // delegated } #ifdef GHC_EXPAND_IMPL namespace detail { GHC_INLINE bool equals_simple_insensitive(const char* str1, const char* str2) { #ifdef GHC_OS_WINDOWS #ifdef __GNUC__ while (::tolower((unsigned char)*str1) == ::tolower((unsigned char)*str2++)) { if (*str1++ == 0) return true; } return false; #else return 0 == ::_stricmp(str1, str2); #endif #else return 0 == ::strcasecmp(str1, str2); #endif } GHC_INLINE const char* strerror_adapter(char* gnu, char*) { return gnu; } GHC_INLINE const char* strerror_adapter(int posix, char* buffer) { if(posix) { return "Error in strerror_r!"; } return buffer; } template GHC_INLINE std::string systemErrorText(ErrorNumber code = 0) { #if defined(GHC_OS_WINDOWS) LPVOID msgBuf; DWORD dw = code ? static_cast(code) : ::GetLastError(); FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&msgBuf, 0, NULL); std::string msg = toUtf8(std::wstring((LPWSTR)msgBuf)); LocalFree(msgBuf); return msg; #else char buffer[512]; return strerror_adapter(strerror_r(code ? code : errno, buffer, sizeof(buffer)), buffer); #endif } #ifdef GHC_OS_WINDOWS using CreateSymbolicLinkW_fp = BOOLEAN(WINAPI*)(LPCWSTR, LPCWSTR, DWORD); using CreateHardLinkW_fp = BOOLEAN(WINAPI*)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES); GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, bool to_directory, std::error_code& ec) { std::error_code tec; auto fs = status(target_name, tec); if ((fs.type() == file_type::directory && !to_directory) || (fs.type() == file_type::regular && to_directory)) { ec = detail::make_error_code(detail::portable_error::not_supported); return; } #if defined(__GNUC__) && __GNUC__ >= 8 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-function-type" #endif static CreateSymbolicLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW")); #if defined(__GNUC__) && __GNUC__ >= 8 #pragma GCC diagnostic pop #endif if (api_call) { if (api_call(detail::fromUtf8(new_symlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), to_directory ? 1 : 0) == 0) { auto result = ::GetLastError(); if (result == ERROR_PRIVILEGE_NOT_HELD && api_call(detail::fromUtf8(new_symlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), to_directory ? 3 : 2) != 0) { return; } ec = detail::make_system_error(result); } } else { ec = detail::make_system_error(ERROR_NOT_SUPPORTED); } } GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec) { #if defined(__GNUC__) && __GNUC__ >= 8 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-function-type" #endif static CreateHardLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW")); #if defined(__GNUC__) && __GNUC__ >= 8 #pragma GCC diagnostic pop #endif if (api_call) { if (api_call(detail::fromUtf8(new_hardlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), NULL) == 0) { ec = detail::make_system_error(); } } else { ec = detail::make_system_error(ERROR_NOT_SUPPORTED); } } #else GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, bool, std::error_code& ec) { if (::symlink(target_name.c_str(), new_symlink.c_str()) != 0) { ec = detail::make_system_error(); } } GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec) { if (::link(target_name.c_str(), new_hardlink.c_str()) != 0) { ec = detail::make_system_error(); } } #endif template GHC_INLINE file_status file_status_from_st_mode(T mode) { #ifdef GHC_OS_WINDOWS file_type ft = file_type::unknown; if ((mode & _S_IFDIR) == _S_IFDIR) { ft = file_type::directory; } else if ((mode & _S_IFREG) == _S_IFREG) { ft = file_type::regular; } else if ((mode & _S_IFCHR) == _S_IFCHR) { ft = file_type::character; } perms prms = static_cast(mode & 0xfff); return file_status(ft, prms); #else file_type ft = file_type::unknown; if (S_ISDIR(mode)) { ft = file_type::directory; } else if (S_ISREG(mode)) { ft = file_type::regular; } else if (S_ISCHR(mode)) { ft = file_type::character; } else if (S_ISBLK(mode)) { ft = file_type::block; } else if (S_ISFIFO(mode)) { ft = file_type::fifo; } else if (S_ISLNK(mode)) { ft = file_type::symlink; } else if (S_ISSOCK(mode)) { ft = file_type::socket; } perms prms = static_cast(mode & 0xfff); return file_status(ft, prms); #endif } GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec) { #ifdef GHC_OS_WINDOWS #ifndef REPARSE_DATA_BUFFER_HEADER_SIZE typedef struct _REPARSE_DATA_BUFFER { ULONG ReparseTag; USHORT ReparseDataLength; USHORT Reserved; union { struct { USHORT SubstituteNameOffset; USHORT SubstituteNameLength; USHORT PrintNameOffset; USHORT PrintNameLength; ULONG Flags; WCHAR PathBuffer[1]; } SymbolicLinkReparseBuffer; struct { USHORT SubstituteNameOffset; USHORT SubstituteNameLength; USHORT PrintNameOffset; USHORT PrintNameLength; WCHAR PathBuffer[1]; } MountPointReparseBuffer; struct { UCHAR DataBuffer[1]; } GenericReparseBuffer; } DUMMYUNIONNAME; } REPARSE_DATA_BUFFER; #ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024) #endif #endif std::shared_ptr file(CreateFileW(p.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); if (file.get() == INVALID_HANDLE_VALUE) { ec = detail::make_system_error(); return path(); } std::shared_ptr reparseData((REPARSE_DATA_BUFFER*)std::calloc(1, MAXIMUM_REPARSE_DATA_BUFFER_SIZE), std::free); ULONG bufferUsed; path result; if (DeviceIoControl(file.get(), FSCTL_GET_REPARSE_POINT, 0, 0, reparseData.get(), MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bufferUsed, 0)) { if (IsReparseTagMicrosoft(reparseData->ReparseTag)) { switch (reparseData->ReparseTag) { case IO_REPARSE_TAG_SYMLINK: result = std::wstring(&reparseData->SymbolicLinkReparseBuffer.PathBuffer[reparseData->SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; case IO_REPARSE_TAG_MOUNT_POINT: result = std::wstring(&reparseData->MountPointReparseBuffer.PathBuffer[reparseData->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; default: break; } } } else { ec = detail::make_system_error(); } return result; #else size_t bufferSize = 256; while (true) { std::vector buffer(bufferSize, static_cast(0)); auto rc = ::readlink(p.c_str(), buffer.data(), buffer.size()); if (rc < 0) { ec = detail::make_system_error(); return path(); } else if (rc < static_cast(bufferSize)) { return path(std::string(buffer.data(), static_cast(rc))); } bufferSize *= 2; } return path(); #endif } #ifdef GHC_OS_WINDOWS GHC_INLINE time_t timeFromFILETIME(const FILETIME& ft) { ULARGE_INTEGER ull; ull.LowPart = ft.dwLowDateTime; ull.HighPart = ft.dwHighDateTime; return static_cast(ull.QuadPart / 10000000ULL - 11644473600ULL); } GHC_INLINE void timeToFILETIME(time_t t, FILETIME& ft) { LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = static_cast(ll); ft.dwHighDateTime = static_cast(ll >> 32); } template GHC_INLINE uintmax_t hard_links_from_INFO(const INFO* info) { return static_cast(-1); } template <> GHC_INLINE uintmax_t hard_links_from_INFO(const BY_HANDLE_FILE_INFORMATION* info) { return info->nNumberOfLinks; } template GHC_INLINE file_status status_from_INFO(const path& p, const INFO* info, std::error_code&, uintmax_t* sz = nullptr, time_t* lwt = nullptr) noexcept { file_type ft = file_type::unknown; if ((info->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { ft = file_type::symlink; } else { if ((info->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { ft = file_type::directory; } else { ft = file_type::regular; } } perms prms = perms::owner_read | perms::group_read | perms::others_read; if (!(info->dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { prms = prms | perms::owner_write | perms::group_write | perms::others_write; } std::string ext = p.extension().generic_string(); if (equals_simple_insensitive(ext.c_str(), ".exe") || equals_simple_insensitive(ext.c_str(), ".cmd") || equals_simple_insensitive(ext.c_str(), ".bat") || equals_simple_insensitive(ext.c_str(), ".com")) { prms = prms | perms::owner_exec | perms::group_exec | perms::others_exec; } if (sz) { *sz = static_cast(info->nFileSizeHigh) << (sizeof(info->nFileSizeHigh) * 8) | info->nFileSizeLow; } if (lwt) { *lwt = detail::timeFromFILETIME(info->ftLastWriteTime); } return file_status(ft, prms); } #endif GHC_INLINE bool is_not_found_error(std::error_code& ec) { #ifdef GHC_OS_WINDOWS return ec.value() == ERROR_FILE_NOT_FOUND || ec.value() == ERROR_PATH_NOT_FOUND || ec.value() == ERROR_INVALID_NAME; #else return ec.value() == ENOENT || ec.value() == ENOTDIR; #endif } GHC_INLINE file_status symlink_status_ex(const path& p, std::error_code& ec, uintmax_t* sz = nullptr, uintmax_t* nhl = nullptr, time_t* lwt = nullptr) noexcept { #ifdef GHC_OS_WINDOWS file_status fs; WIN32_FILE_ATTRIBUTE_DATA attr; if (!GetFileAttributesExW(detail::fromUtf8(p.u8string()).c_str(), GetFileExInfoStandard, &attr)) { ec = detail::make_system_error(); } else { ec.clear(); fs = detail::status_from_INFO(p, &attr, ec, sz, lwt); if (nhl) { *nhl = 0; } if (attr.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { fs.type(file_type::symlink); } } if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found); } return ec ? file_status(file_type::none) : fs; #else (void)sz; (void)nhl; (void)lwt; struct ::stat fs; auto result = ::lstat(p.c_str(), &fs); if (result == 0) { ec.clear(); file_status f_s = detail::file_status_from_st_mode(fs.st_mode); return f_s; } ec = detail::make_system_error(); if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found, perms::unknown); } return file_status(file_type::none); #endif } GHC_INLINE file_status status_ex(const path& p, std::error_code& ec, file_status* sls = nullptr, uintmax_t* sz = nullptr, uintmax_t* nhl = nullptr, time_t* lwt = nullptr, int recurse_count = 0) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS if (recurse_count > 16) { ec = detail::make_system_error(0x2A9 /*ERROR_STOPPED_ON_SYMLINK*/); return file_status(file_type::unknown); } WIN32_FILE_ATTRIBUTE_DATA attr; if (!::GetFileAttributesExW(p.wstring().c_str(), GetFileExInfoStandard, &attr)) { ec = detail::make_system_error(); } else if (attr.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { path target = resolveSymlink(p, ec); file_status result; if (!ec && !target.empty()) { if (sls) { *sls = status_from_INFO(p, &attr, ec); } return detail::status_ex(target, ec, nullptr, sz, nhl, lwt, recurse_count + 1); } return file_status(file_type::unknown); } if (ec) { if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found); } return file_status(file_type::none); } if (nhl) { *nhl = 0; } return detail::status_from_INFO(p, &attr, ec, sz, lwt); #else (void)recurse_count; struct ::stat st; auto result = ::lstat(p.c_str(), &st); if (result == 0) { ec.clear(); file_status fs = detail::file_status_from_st_mode(st.st_mode); if (fs.type() == file_type::symlink) { result = ::stat(p.c_str(), &st); if (result == 0) { if (sls) { *sls = fs; } fs = detail::file_status_from_st_mode(st.st_mode); } } if (sz) { *sz = static_cast(st.st_size); } if (nhl) { *nhl = st.st_nlink; } if (lwt) { *lwt = st.st_mtime; } return fs; } else { ec = detail::make_system_error(); if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found, perms::unknown); } return file_status(file_type::none); } #endif } } // namespace detail GHC_INLINE u8arguments::u8arguments(int& argc, char**& argv) : _argc(argc) , _argv(argv) , _refargc(argc) , _refargv(argv) , _isvalid(false) { #ifdef GHC_OS_WINDOWS LPWSTR* p; p = ::CommandLineToArgvW(::GetCommandLineW(), &argc); _args.reserve(static_cast(argc)); _argp.reserve(static_cast(argc)); for (size_t i = 0; i < static_cast(argc); ++i) { _args.push_back(detail::toUtf8(std::wstring(p[i]))); _argp.push_back((char*)_args[i].data()); } argv = _argp.data(); ::LocalFree(p); _isvalid = true; #else std::setlocale(LC_ALL, ""); #if defined(__ANDROID__) && __ANDROID_API__ < 26 _isvalid = true; #else if (detail::equals_simple_insensitive(::nl_langinfo(CODESET), "UTF-8")) { _isvalid = true; } #endif #endif } //----------------------------------------------------------------------------- // 30.10.8.4.1 constructors and destructor GHC_INLINE path::path() noexcept {} GHC_INLINE path::path(const path& p) : _path(p._path) { } GHC_INLINE path::path(path&& p) noexcept : _path(std::move(p._path)) { } GHC_INLINE path::path(string_type&& source, format fmt) #ifdef GHC_USE_WCHAR_T : _path(detail::toUtf8(source)) #else : _path(std::move(source)) #endif { postprocess_path_with_format(_path, fmt); } #endif // GHC_EXPAND_IMPL #ifdef GHC_WITH_EXCEPTIONS template inline path::path(const Source& source, const std::locale& loc, format fmt) : path(source, fmt) { std::string locName = loc.name(); if (!(locName.length() >= 5 && (locName.substr(locName.length() - 5) == "UTF-8" || locName.substr(locName.length() - 5) == "utf-8"))) { throw filesystem_error("This implementation only supports UTF-8 locales!", path(_path), detail::make_error_code(detail::portable_error::not_supported)); } } template inline path::path(InputIterator first, InputIterator last, const std::locale& loc, format fmt) : path(std::basic_string::value_type>(first, last), fmt) { std::string locName = loc.name(); if (!(locName.length() >= 5 && (locName.substr(locName.length() - 5) == "UTF-8" || locName.substr(locName.length() - 5) == "utf-8"))) { throw filesystem_error("This implementation only supports UTF-8 locales!", path(_path), detail::make_error_code(detail::portable_error::not_supported)); } } #endif #ifdef GHC_EXPAND_IMPL GHC_INLINE path::~path() {} //----------------------------------------------------------------------------- // 30.10.8.4.2 assignments GHC_INLINE path& path::operator=(const path& p) { _path = p._path; return *this; } GHC_INLINE path& path::operator=(path&& p) noexcept { _path = std::move(p._path); return *this; } GHC_INLINE path& path::operator=(path::string_type&& source) { return assign(source); } GHC_INLINE path& path::assign(path::string_type&& source) { #ifdef GHC_USE_WCHAR_T _path = detail::toUtf8(source); #else _path = std::move(source); #endif postprocess_path_with_format(_path, native_format); return *this; } #endif // GHC_EXPAND_IMPL template inline path& path::operator=(const Source& source) { return assign(source); } template inline path& path::assign(const Source& source) { _path.assign(detail::toUtf8(source)); postprocess_path_with_format(_path, native_format); return *this; } template <> inline path& path::assign(const path& source) { _path = source._path; return *this; } template inline path& path::assign(InputIterator first, InputIterator last) { _path.assign(first, last); postprocess_path_with_format(_path, native_format); return *this; } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.3 appends GHC_INLINE path& path::operator/=(const path& p) { if (p.empty()) { // was: if ((!has_root_directory() && is_absolute()) || has_filename()) if (!_path.empty() && _path[_path.length() - 1] != '/' && _path[_path.length() - 1] != ':') { _path += '/'; } return *this; } if ((p.is_absolute() && (_path != root_name() || p._path != "/")) || (p.has_root_name() && p.root_name() != root_name())) { assign(p); return *this; } if (p.has_root_directory()) { assign(root_name()); } else if ((!has_root_directory() && is_absolute()) || has_filename()) { _path += '/'; } auto iter = p.begin(); bool first = true; if (p.has_root_name()) { ++iter; } while (iter != p.end()) { if (!first && !(!_path.empty() && _path[_path.length() - 1] == '/')) { _path += '/'; } first = false; _path += (*iter++).generic_string(); } return *this; } GHC_INLINE void path::append_name(const char* name) { if (_path.empty()) { this->operator/=(path(name)); } else { if (_path.back() != path::generic_separator) { _path.push_back(path::generic_separator); } _path += name; } } #endif // GHC_EXPAND_IMPL template inline path& path::operator/=(const Source& source) { return append(source); } template inline path& path::append(const Source& source) { return this->operator/=(path(detail::toUtf8(source))); } template <> inline path& path::append(const path& p) { return this->operator/=(p); } template inline path& path::append(InputIterator first, InputIterator last) { std::basic_string::value_type> part(first, last); return append(part); } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.4 concatenation GHC_INLINE path& path::operator+=(const path& x) { return concat(x._path); } GHC_INLINE path& path::operator+=(const string_type& x) { return concat(x); } #ifdef __cpp_lib_string_view GHC_INLINE path& path::operator+=(std::basic_string_view x) { return concat(x); } #endif GHC_INLINE path& path::operator+=(const value_type* x) { return concat(string_type(x)); } GHC_INLINE path& path::operator+=(value_type x) { #ifdef GHC_OS_WINDOWS if (x == '\\') { x = generic_separator; } #endif if (_path.empty() || _path.back() != generic_separator) { #ifdef GHC_USE_WCHAR_T _path += detail::toUtf8(string_type(1, x)); #else _path += x; #endif } return *this; } #endif // GHC_EXPAND_IMPL template inline path::path_from_string& path::operator+=(const Source& x) { return concat(x); } template inline path::path_type_EcharT& path::operator+=(EcharT x) { std::basic_string part(1, x); concat(detail::toUtf8(part)); return *this; } template inline path& path::concat(const Source& x) { path p(x); postprocess_path_with_format(p._path, native_format); _path += p._path; return *this; } template inline path& path::concat(InputIterator first, InputIterator last) { _path.append(first, last); postprocess_path_with_format(_path, native_format); return *this; } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.5 modifiers GHC_INLINE void path::clear() noexcept { _path.clear(); } GHC_INLINE path& path::make_preferred() { // as this filesystem implementation only uses generic_format // internally, this must be a no-op return *this; } GHC_INLINE path& path::remove_filename() { if (has_filename()) { _path.erase(_path.size() - filename()._path.size()); } return *this; } GHC_INLINE path& path::replace_filename(const path& replacement) { remove_filename(); return append(replacement); } GHC_INLINE path& path::replace_extension(const path& replacement) { if (has_extension()) { _path.erase(_path.size() - extension()._path.size()); } if (!replacement.empty() && replacement._path[0] != '.') { _path += '.'; } return concat(replacement); } GHC_INLINE void path::swap(path& rhs) noexcept { _path.swap(rhs._path); } //----------------------------------------------------------------------------- // 30.10.8.4.6, native format observers #ifdef GHC_OS_WINDOWS GHC_INLINE path::impl_string_type path::native_impl() const { impl_string_type result; if (is_absolute() && _path.length() > MAX_PATH - 10) { // expand long Windows filenames with marker if (has_root_name() && _path[0] == '/') { result = "\\\\?\\UNC" + _path.substr(1); } else { result = "\\\\?\\" + _path; } } else { result = _path; } /*if (has_root_name() && root_name()._path[0] == '/') { return _path; }*/ for (auto& c : result) { if (c == '/') { c = '\\'; } } return result; } #else GHC_INLINE const path::impl_string_type& path::native_impl() const { return _path; } #endif GHC_INLINE const path::string_type& path::native() const { #ifdef GHC_OS_WINDOWS #ifdef GHC_USE_WCHAR_T _native_cache = detail::fromUtf8(native_impl()); #else _native_cache = native_impl(); #endif return _native_cache; #else return _path; #endif } GHC_INLINE const path::value_type* path::c_str() const { return native().c_str(); } GHC_INLINE path::operator path::string_type() const { return native(); } #endif // GHC_EXPAND_IMPL template inline std::basic_string path::string(const Allocator& a) const { return detail::fromUtf8>(native_impl(), a); } #ifdef GHC_EXPAND_IMPL GHC_INLINE std::string path::string() const { return native_impl(); } GHC_INLINE std::wstring path::wstring() const { #ifdef GHC_USE_WCHAR_T return native(); #else return detail::fromUtf8(native()); #endif } GHC_INLINE std::string path::u8string() const { return native_impl(); } GHC_INLINE std::u16string path::u16string() const { return detail::fromUtf8(native_impl()); } GHC_INLINE std::u32string path::u32string() const { return detail::fromUtf8(native_impl()); } #endif // GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.7, generic format observers template inline std::basic_string path::generic_string(const Allocator& a) const { return detail::fromUtf8>(_path, a); } #ifdef GHC_EXPAND_IMPL GHC_INLINE const std::string& path::generic_string() const { return _path; } GHC_INLINE std::wstring path::generic_wstring() const { return detail::fromUtf8(_path); } GHC_INLINE std::string path::generic_u8string() const { return _path; } GHC_INLINE std::u16string path::generic_u16string() const { return detail::fromUtf8(_path); } GHC_INLINE std::u32string path::generic_u32string() const { return detail::fromUtf8(_path); } //----------------------------------------------------------------------------- // 30.10.8.4.8, compare GHC_INLINE int path::compare(const path& p) const noexcept { return native().compare(p.native()); } GHC_INLINE int path::compare(const string_type& s) const { return native().compare(path(s).native()); } #ifdef __cpp_lib_string_view GHC_INLINE int path::compare(std::basic_string_view s) const { return native().compare(path(s).native()); } #endif GHC_INLINE int path::compare(const value_type* s) const { return native().compare(path(s).native()); } //----------------------------------------------------------------------------- // 30.10.8.4.9, decomposition GHC_INLINE path path::root_name() const { #ifdef GHC_OS_WINDOWS if (_path.length() >= 2 && std::toupper(static_cast(_path[0])) >= 'A' && std::toupper(static_cast(_path[0])) <= 'Z' && _path[1] == ':') { return path(_path.substr(0, 2)); } #endif if (_path.length() > 2 && _path[0] == '/' && _path[1] == '/' && _path[2] != '/' && std::isprint(_path[2])) { impl_string_type::size_type pos = _path.find_first_of("/\\", 3); if (pos == impl_string_type::npos) { return path(_path); } else { return path(_path.substr(0, pos)); } } return path(); } GHC_INLINE path path::root_directory() const { path root = root_name(); if (_path.length() > root._path.length() && _path[root._path.length()] == '/') { return path("/"); } return path(); } GHC_INLINE path path::root_path() const { return root_name().generic_string() + root_directory().generic_string(); } GHC_INLINE path path::relative_path() const { std::string root = root_path()._path; return path(_path.substr((std::min)(root.length(), _path.length())), generic_format); } GHC_INLINE path path::parent_path() const { if (has_relative_path()) { if (empty() || begin() == --end()) { return path(); } else { path pp; for (string_type s : input_iterator_range(begin(), --end())) { if (s == "/") { // don't use append to join a path- pp += s; } else { pp /= s; } } return pp; } } else { return *this; } } GHC_INLINE path path::filename() const { return relative_path().empty() ? path() : path(*--end()); } GHC_INLINE path path::stem() const { impl_string_type fn = filename().string(); if (fn != "." && fn != "..") { impl_string_type::size_type n = fn.rfind('.'); if (n != impl_string_type::npos && n != 0) { return path{fn.substr(0, n)}; } } return path{fn}; } GHC_INLINE path path::extension() const { impl_string_type fn = filename().string(); impl_string_type::size_type pos = fn.find_last_of('.'); if (pos == std::string::npos || pos == 0) { return ""; } return fn.substr(pos); } //----------------------------------------------------------------------------- // 30.10.8.4.10, query GHC_INLINE bool path::empty() const noexcept { return _path.empty(); } GHC_INLINE bool path::has_root_name() const { return !root_name().empty(); } GHC_INLINE bool path::has_root_directory() const { return !root_directory().empty(); } GHC_INLINE bool path::has_root_path() const { return !root_path().empty(); } GHC_INLINE bool path::has_relative_path() const { return !relative_path().empty(); } GHC_INLINE bool path::has_parent_path() const { return !parent_path().empty(); } GHC_INLINE bool path::has_filename() const { return !filename().empty(); } GHC_INLINE bool path::has_stem() const { return !stem().empty(); } GHC_INLINE bool path::has_extension() const { return !extension().empty(); } GHC_INLINE bool path::is_absolute() const { #ifdef GHC_OS_WINDOWS return has_root_name() && has_root_directory(); #else return has_root_directory(); #endif } GHC_INLINE bool path::is_relative() const { return !is_absolute(); } //----------------------------------------------------------------------------- // 30.10.8.4.11, generation GHC_INLINE path path::lexically_normal() const { path dest; bool lastDotDot = false; for (string_type s : *this) { if (s == ".") { dest /= ""; continue; } else if (s == ".." && !dest.empty()) { auto root = root_path(); if (dest == root) { continue; } else if (*(--dest.end()) != "..") { if (dest._path.back() == generic_separator) { dest._path.pop_back(); } dest.remove_filename(); continue; } } if (!(s.empty() && lastDotDot)) { dest /= s; } lastDotDot = s == ".."; } if (dest.empty()) { dest = "."; } return dest; } GHC_INLINE path path::lexically_relative(const path& base) const { if (root_name() != base.root_name() || is_absolute() != base.is_absolute() || (!has_root_directory() && base.has_root_directory())) { return path(); } const_iterator a = begin(), b = base.begin(); while (a != end() && b != base.end() && *a == *b) { ++a; ++b; } if (a == end() && b == base.end()) { return path("."); } int count = 0; for (const auto& element : input_iterator_range(b, base.end())) { if (element != "." && element != "" && element != "..") { ++count; } else if (element == "..") { --count; } } if (count < 0) { return path(); } path result; for (int i = 0; i < count; ++i) { result /= ".."; } for (const auto& element : input_iterator_range(a, end())) { result /= element; } return result; } GHC_INLINE path path::lexically_proximate(const path& base) const { path result = lexically_relative(base); return result.empty() ? *this : result; } //----------------------------------------------------------------------------- // 30.10.8.5, iterators GHC_INLINE path::iterator::iterator() {} GHC_INLINE path::iterator::iterator(const path::impl_string_type::const_iterator& first, const path::impl_string_type::const_iterator& last, const path::impl_string_type::const_iterator& pos) : _first(first) , _last(last) , _iter(pos) { updateCurrent(); // find the position of a potential root directory slash #ifdef GHC_OS_WINDOWS if (_last - _first >= 3 && std::toupper(static_cast(*first)) >= 'A' && std::toupper(static_cast(*first)) <= 'Z' && *(first + 1) == ':' && *(first + 2) == '/') { _root = _first + 2; } else #endif { if (_first != _last && *_first == '/') { if (_last - _first >= 2 && *(_first + 1) == '/' && !(_last - _first >= 3 && *(_first + 2) == '/')) { _root = increment(_first); } else { _root = _first; } } else { _root = _last; } } } GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(const path::impl_string_type::const_iterator& pos) const { path::impl_string_type::const_iterator i = pos; bool fromStart = i == _first; if (i != _last) { // we can only sit on a slash if it is a network name or a root if (*i++ == '/') { if (i != _last && *i == '/') { if (fromStart && !(i + 1 != _last && *(i + 1) == '/')) { // leadind double slashes detected, treat this and the // following until a slash as one unit i = std::find(++i, _last, '/'); } else { // skip redundant slashes while (i != _last && *i == '/') { ++i; } } } } else { if (fromStart && i != _last && *i == ':') { ++i; } else { i = std::find(i, _last, '/'); } } } return i; } GHC_INLINE path::impl_string_type::const_iterator path::iterator::decrement(const path::impl_string_type::const_iterator& pos) const { path::impl_string_type::const_iterator i = pos; if (i != _first) { --i; // if this is now the root slash or the trailing slash, we are done, // else check for network name if (i != _root && (pos != _last || *i != '/')) { #ifdef GHC_OS_WINDOWS static const std::string seps = "/:"; i = std::find_first_of(std::reverse_iterator(i), std::reverse_iterator(_first), seps.begin(), seps.end()).base(); if (i > _first && *i == ':') { i++; } #else i = std::find(std::reverse_iterator(i), std::reverse_iterator(_first), '/').base(); #endif // Now we have to check if this is a network name if (i - _first == 2 && *_first == '/' && *(_first + 1) == '/') { i -= 2; } } } return i; } GHC_INLINE void path::iterator::updateCurrent() { if (_iter != _first && _iter != _last && (*_iter == '/' && _iter != _root) && (_iter + 1 == _last)) { _current = ""; } else { _current.assign(_iter, increment(_iter)); if (_current.generic_string().size() > 1 && _current.generic_string()[0] == '/' && _current.generic_string()[_current.generic_string().size() - 1] == '/') { // shrink successive slashes to one _current = "/"; } } } GHC_INLINE path::iterator& path::iterator::operator++() { _iter = increment(_iter); while (_iter != _last && // we didn't reach the end _iter != _root && // this is not a root position *_iter == '/' && // we are on a slash (_iter + 1) != _last // the slash is not the last char ) { ++_iter; } updateCurrent(); return *this; } GHC_INLINE path::iterator path::iterator::operator++(int) { path::iterator i{*this}; ++(*this); return i; } GHC_INLINE path::iterator& path::iterator::operator--() { _iter = decrement(_iter); updateCurrent(); return *this; } GHC_INLINE path::iterator path::iterator::operator--(int) { auto i = *this; --(*this); return i; } GHC_INLINE bool path::iterator::operator==(const path::iterator& other) const { return _iter == other._iter; } GHC_INLINE bool path::iterator::operator!=(const path::iterator& other) const { return _iter != other._iter; } GHC_INLINE path::iterator::reference path::iterator::operator*() const { return _current; } GHC_INLINE path::iterator::pointer path::iterator::operator->() const { return &_current; } GHC_INLINE path::iterator path::begin() const { return iterator(_path.begin(), _path.end(), _path.begin()); } GHC_INLINE path::iterator path::end() const { return iterator(_path.begin(), _path.end(), _path.end()); } //----------------------------------------------------------------------------- // 30.10.8.6, path non-member functions GHC_INLINE void swap(path& lhs, path& rhs) noexcept { swap(lhs._path, rhs._path); } GHC_INLINE size_t hash_value(const path& p) noexcept { return std::hash()(p.generic_string()); } GHC_INLINE bool operator==(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() == rhs.generic_string(); } GHC_INLINE bool operator!=(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() != rhs.generic_string(); } GHC_INLINE bool operator<(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() < rhs.generic_string(); } GHC_INLINE bool operator<=(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() <= rhs.generic_string(); } GHC_INLINE bool operator>(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() > rhs.generic_string(); } GHC_INLINE bool operator>=(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() >= rhs.generic_string(); } GHC_INLINE path operator/(const path& lhs, const path& rhs) { path result(lhs); result /= rhs; return result; } #endif // GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.6.1 path inserter and extractor template inline std::basic_ostream& operator<<(std::basic_ostream& os, const path& p) { os << "\""; auto ps = p.string(); for (auto c : ps) { if (c == '"' || c == '\\') { os << '\\'; } os << c; } os << "\""; return os; } template inline std::basic_istream& operator>>(std::basic_istream& is, path& p) { std::basic_string tmp; charT c; is >> c; if (c == '"') { auto sf = is.flags(); is >> std::noskipws; while (is) { auto c2 = is.get(); if (is) { if (c2 == '\\') { c2 = is.get(); if (is) { tmp += static_cast(c2); } } else if (c2 == '"') { break; } else { tmp += static_cast(c2); } } } if ((sf & std::ios_base::skipws) == std::ios_base::skipws) { is >> std::skipws; } p = path(tmp); } else { is >> tmp; p = path(static_cast(c) + tmp); } return is; } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.9 Class filesystem_error GHC_INLINE filesystem_error::filesystem_error(const std::string& what_arg, std::error_code ec) : std::system_error(ec, what_arg) , _what_arg(what_arg) , _ec(ec) { } GHC_INLINE filesystem_error::filesystem_error(const std::string& what_arg, const path& p1, std::error_code ec) : std::system_error(ec, what_arg) , _what_arg(what_arg) , _ec(ec) , _p1(p1) { if (!_p1.empty()) { _what_arg += ": '" + _p1.u8string() + "'"; } } GHC_INLINE filesystem_error::filesystem_error(const std::string& what_arg, const path& p1, const path& p2, std::error_code ec) : std::system_error(ec, what_arg) , _what_arg(what_arg) , _ec(ec) , _p1(p1) , _p2(p2) { if (!_p1.empty()) { _what_arg += ": '" + _p1.u8string() + "'"; } if (!_p2.empty()) { _what_arg += ", '" + _p2.u8string() + "'"; } } GHC_INLINE const path& filesystem_error::path1() const noexcept { return _p1; } GHC_INLINE const path& filesystem_error::path2() const noexcept { return _p2; } GHC_INLINE const char* filesystem_error::what() const noexcept { return _what_arg.c_str(); } //----------------------------------------------------------------------------- // 30.10.15, filesystem operations #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path absolute(const path& p) { std::error_code ec; path result = absolute(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE path absolute(const path& p, std::error_code& ec) { ec.clear(); #ifdef GHC_OS_WINDOWS if (p.empty()) { return absolute(current_path(ec), ec) / ""; } ULONG size = ::GetFullPathNameW(p.wstring().c_str(), 0, 0, 0); if (size) { std::vector buf(size, 0); ULONG s2 = GetFullPathNameW(p.wstring().c_str(), size, buf.data(), nullptr); if (s2 && s2 < size) { path result = path(std::wstring(buf.data(), s2)); if (p.filename() == ".") { result /= "."; } return result; } } ec = detail::make_system_error(); return path(); #else path base = current_path(ec); if (!ec) { if (p.empty()) { return base / p; } if (p.has_root_name()) { if (p.has_root_directory()) { return p; } else { return p.root_name() / base.root_directory() / base.relative_path() / p.relative_path(); } } else { if (p.has_root_directory()) { return base.root_name() / p; } else { return base / p; } } } ec = detail::make_system_error(); return path(); #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path canonical(const path& p) { std::error_code ec; auto result = canonical(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE path canonical(const path& p, std::error_code& ec) { if (p.empty()) { ec = detail::make_error_code(detail::portable_error::not_found); return path(); } path work = p.is_absolute() ? p : absolute(p, ec); path root = work.root_path(); path result; auto fs = status(work, ec); if (ec) { return path(); } if (fs.type() == file_type::not_found) { ec = detail::make_error_code(detail::portable_error::not_found); return path(); } bool redo; do { redo = false; result.clear(); for (auto pe : work) { if (pe.empty() || pe == ".") { continue; } else if (pe == "..") { result = result.parent_path(); continue; } else if ((result / pe).string().length() <= root.string().length()) { result /= pe; continue; } auto sls = symlink_status(result / pe, ec); if (ec) { return path(); } if (is_symlink(sls)) { redo = true; auto target = read_symlink(result / pe, ec); if (ec) { return path(); } if (target.is_absolute()) { result = target; continue; } else { result /= target; continue; } } else { result /= pe; } } work = result; } while (redo); ec.clear(); return result; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy(const path& from, const path& to) { copy(from, to, copy_options::none); } #endif GHC_INLINE void copy(const path& from, const path& to, std::error_code& ec) noexcept { copy(from, to, copy_options::none, ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy(const path& from, const path& to, copy_options options) { std::error_code ec; copy(from, to, options, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } } #endif GHC_INLINE void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept { std::error_code tec; file_status fs_from, fs_to; ec.clear(); if ((options & (copy_options::skip_symlinks | copy_options::copy_symlinks | copy_options::create_symlinks)) != copy_options::none) { fs_from = symlink_status(from, ec); } else { fs_from = status(from, ec); } if (!exists(fs_from)) { if (!ec) { ec = detail::make_error_code(detail::portable_error::not_found); } return; } if ((options & (copy_options::skip_symlinks | copy_options::create_symlinks)) != copy_options::none) { fs_to = symlink_status(to, tec); } else { fs_to = status(to, tec); } if (is_other(fs_from) || is_other(fs_to) || (is_directory(fs_from) && is_regular_file(fs_to)) || (exists(fs_to) && equivalent(from, to, ec))) { ec = detail::make_error_code(detail::portable_error::invalid_argument); } else if (is_symlink(fs_from)) { if ((options & copy_options::skip_symlinks) == copy_options::none) { if (!exists(fs_to) && (options & copy_options::copy_symlinks) != copy_options::none) { copy_symlink(from, to, ec); } else { ec = detail::make_error_code(detail::portable_error::invalid_argument); } } } else if (is_regular_file(fs_from)) { if ((options & copy_options::directories_only) == copy_options::none) { if ((options & copy_options::create_symlinks) != copy_options::none) { create_symlink(from.is_absolute() ? from : canonical(from, ec), to, ec); } else if ((options & copy_options::create_hard_links) != copy_options::none) { create_hard_link(from, to, ec); } else if (is_directory(fs_to)) { copy_file(from, to / from.filename(), options, ec); } else { copy_file(from, to, options, ec); } } } #ifdef LWG_2682_BEHAVIOUR else if (is_directory(fs_from) && (options & copy_options::create_symlinks) != copy_options::none) { ec = detail::make_error_code(detail::portable_error::is_a_directory); } #endif else if (is_directory(fs_from) && (options == copy_options::none || (options & copy_options::recursive) != copy_options::none)) { if (!exists(fs_to)) { create_directory(to, from, ec); if (ec) { return; } } for (auto iter = directory_iterator(from, ec); iter != directory_iterator(); iter.increment(ec)) { if (!ec) { copy(iter->path(), to / iter->path().filename(), options | static_cast(0x8000), ec); } if (ec) { return; } } } return; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool copy_file(const path& from, const path& to) { return copy_file(from, to, copy_options::none); } #endif GHC_INLINE bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept { return copy_file(from, to, copy_options::none, ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) { std::error_code ec; auto result = copy_file(from, to, option, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } return result; } #endif GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept { std::error_code tecf, tect; auto sf = status(from, tecf); auto st = status(to, tect); bool overwrite = false; ec.clear(); if (!is_regular_file(sf)) { ec = tecf; return false; } if (exists(st) && (!is_regular_file(st) || equivalent(from, to, ec) || (options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none)) { ec = tect ? tect : detail::make_error_code(detail::portable_error::exists); return false; } if (exists(st)) { if ((options & copy_options::update_existing) == copy_options::update_existing) { auto from_time = last_write_time(from, ec); if (ec) { ec = detail::make_system_error(); return false; } auto to_time = last_write_time(to, ec); if (ec) { ec = detail::make_system_error(); return false; } if (from_time <= to_time) { return false; } } overwrite = true; } #ifdef GHC_OS_WINDOWS if (!::CopyFileW(detail::fromUtf8(from.u8string()).c_str(), detail::fromUtf8(to.u8string()).c_str(), !overwrite)) { ec = detail::make_system_error(); return false; } return true; #else std::vector buffer(16384, '\0'); int in = -1, out = -1; if ((in = ::open(from.c_str(), O_RDONLY)) < 0) { ec = detail::make_system_error(); return false; } std::shared_ptr guard_in(nullptr, [in](void*) { ::close(in); }); int mode = O_CREAT | O_WRONLY | O_TRUNC; if (!overwrite) { mode |= O_EXCL; } if ((out = ::open(to.c_str(), mode, static_cast(sf.permissions() & perms::all))) < 0) { ec = detail::make_system_error(); return false; } std::shared_ptr guard_out(nullptr, [out](void*) { ::close(out); }); ssize_t br, bw; while ((br = ::read(in, buffer.data(), buffer.size())) > 0) { ssize_t offset = 0; do { if ((bw = ::write(out, buffer.data() + offset, static_cast(br))) > 0) { br -= bw; offset += bw; } else if (bw < 0) { ec = detail::make_system_error(); return false; } } while (br); } return true; #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink) { std::error_code ec; copy_symlink(existing_symlink, new_symlink, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), existing_symlink, new_symlink, ec); } } #endif GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept { ec.clear(); auto to = read_symlink(existing_symlink, ec); if (!ec) { if (exists(to, ec) && is_directory(to, ec)) { create_directory_symlink(to, new_symlink, ec); } else { create_symlink(to, new_symlink, ec); } } } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directories(const path& p) { std::error_code ec; auto result = create_directories(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept { path current; ec.clear(); bool didCreate = false; for (path::string_type part : p) { current /= part; if (current != p.root_name() && current != p.root_path()) { std::error_code tec; auto fs = status(current, tec); if (tec && fs.type() != file_type::not_found) { ec = tec; return false; } if (!exists(fs)) { create_directory(current, ec); if (ec) { std::error_code tmp_ec; if (is_directory(current, tmp_ec)) { ec.clear(); } else { return false; } } didCreate = true; } #ifndef LWG_2935_BEHAVIOUR else if (!is_directory(fs)) { ec = detail::make_error_code(detail::portable_error::exists); return false; } #endif } } return didCreate; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directory(const path& p) { std::error_code ec; auto result = create_directory(p, path(), ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE bool create_directory(const path& p, std::error_code& ec) noexcept { return create_directory(p, path(), ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool create_directory(const path& p, const path& attributes) { std::error_code ec; auto result = create_directory(p, attributes, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept { std::error_code tec; ec.clear(); auto fs = status(p, tec); #ifdef LWG_2935_BEHAVIOUR if (status_known(fs) && exists(fs)) { return false; } #else if (status_known(fs) && exists(fs) && is_directory(fs)) { return false; } #endif #ifdef GHC_OS_WINDOWS if (!attributes.empty()) { if (!::CreateDirectoryExW(detail::fromUtf8(attributes.u8string()).c_str(), detail::fromUtf8(p.u8string()).c_str(), NULL)) { ec = detail::make_system_error(); return false; } } else if (!::CreateDirectoryW(detail::fromUtf8(p.u8string()).c_str(), NULL)) { ec = detail::make_system_error(); return false; } #else ::mode_t attribs = static_cast(perms::all); if (!attributes.empty()) { struct ::stat fileStat; if (::stat(attributes.c_str(), &fileStat) != 0) { ec = detail::make_system_error(); return false; } attribs = fileStat.st_mode; } if (::mkdir(p.c_str(), attribs) != 0) { ec = detail::make_system_error(); return false; } #endif return true; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink) { std::error_code ec; create_directory_symlink(to, new_symlink, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), to, new_symlink, ec); } } #endif GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept { detail::create_symlink(to, new_symlink, true, ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) { std::error_code ec; create_hard_link(to, new_hard_link, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), to, new_hard_link, ec); } } #endif GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept { detail::create_hardlink(to, new_hard_link, ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void create_symlink(const path& to, const path& new_symlink) { std::error_code ec; create_symlink(to, new_symlink, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), to, new_symlink, ec); } } #endif GHC_INLINE void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept { detail::create_symlink(to, new_symlink, false, ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path current_path() { std::error_code ec; auto result = current_path(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), ec); } return result; } #endif GHC_INLINE path current_path(std::error_code& ec) { ec.clear(); #ifdef GHC_OS_WINDOWS DWORD pathlen = ::GetCurrentDirectoryW(0, 0); std::unique_ptr buffer(new wchar_t[size_t(pathlen) + 1]); if (::GetCurrentDirectoryW(pathlen, buffer.get()) == 0) { ec = detail::make_system_error(); return path(); } return path(std::wstring(buffer.get()), path::native_format); #else size_t pathlen = static_cast(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX))); std::unique_ptr buffer(new char[pathlen + 1]); if (::getcwd(buffer.get(), pathlen) == nullptr) { ec = detail::make_system_error(); return path(); } return path(buffer.get()); #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void current_path(const path& p) { std::error_code ec; current_path(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } #endif GHC_INLINE void current_path(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS if (!::SetCurrentDirectoryW(detail::fromUtf8(p.u8string()).c_str())) { ec = detail::make_system_error(); } #else if (::chdir(p.string().c_str()) == -1) { ec = detail::make_system_error(); } #endif } GHC_INLINE bool exists(file_status s) noexcept { return status_known(s) && s.type() != file_type::not_found; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool exists(const path& p) { return exists(status(p)); } #endif GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept { file_status s = status(p, ec); if (status_known(s)) { ec.clear(); } return exists(s); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool equivalent(const path& p1, const path& p2) { std::error_code ec; bool result = equivalent(p1, p2, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p1, p2, ec); } return result; } #endif GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS std::shared_ptr file1(::CreateFileW(p1.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); auto e1 = ::GetLastError(); std::shared_ptr file2(::CreateFileW(p2.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); if (file1.get() == INVALID_HANDLE_VALUE || file2.get() == INVALID_HANDLE_VALUE) { #ifdef LWG_2937_BEHAVIOUR ec = detail::make_system_error(e1 ? e1 : ::GetLastError()); #else if (file1 == file2) { ec = detail::make_system_error(e1 ? e1 : ::GetLastError()); } #endif return false; } BY_HANDLE_FILE_INFORMATION inf1, inf2; if (!::GetFileInformationByHandle(file1.get(), &inf1)) { ec = detail::make_system_error(); return false; } if (!::GetFileInformationByHandle(file2.get(), &inf2)) { ec = detail::make_system_error(); return false; } return inf1.ftLastWriteTime.dwLowDateTime == inf2.ftLastWriteTime.dwLowDateTime && inf1.ftLastWriteTime.dwHighDateTime == inf2.ftLastWriteTime.dwHighDateTime && inf1.nFileIndexHigh == inf2.nFileIndexHigh && inf1.nFileIndexLow == inf2.nFileIndexLow && inf1.nFileSizeHigh == inf2.nFileSizeHigh && inf1.nFileSizeLow == inf2.nFileSizeLow && inf1.dwVolumeSerialNumber == inf2.dwVolumeSerialNumber; #else struct ::stat s1, s2; auto rc1 = ::stat(p1.c_str(), &s1); auto e1 = errno; auto rc2 = ::stat(p2.c_str(), &s2); if (rc1 || rc2) { #ifdef LWG_2937_BEHAVIOUR ec = detail::make_system_error(e1 ? e1 : errno); #else if (rc1 && rc2) { ec = detail::make_system_error(e1 ? e1 : errno); } #endif return false; } return s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino && s1.st_size == s2.st_size && s1.st_mtime == s2.st_mtime; #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t file_size(const path& p) { std::error_code ec; auto result = file_size(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS WIN32_FILE_ATTRIBUTE_DATA attr; if (!GetFileAttributesExW(detail::fromUtf8(p.u8string()).c_str(), GetFileExInfoStandard, &attr)) { ec = detail::make_system_error(); return static_cast(-1); } return static_cast(attr.nFileSizeHigh) << (sizeof(attr.nFileSizeHigh) * 8) | attr.nFileSizeLow; #else struct ::stat fileStat; if (::stat(p.c_str(), &fileStat) == -1) { ec = detail::make_system_error(); return static_cast(-1); } return static_cast(fileStat.st_size); #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t hard_link_count(const path& p) { std::error_code ec; auto result = hard_link_count(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS uintmax_t result = static_cast(-1); std::shared_ptr file(::CreateFileW(p.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); BY_HANDLE_FILE_INFORMATION inf; if (file.get() == INVALID_HANDLE_VALUE) { ec = detail::make_system_error(); } else { if (!::GetFileInformationByHandle(file.get(), &inf)) { ec = detail::make_system_error(); } else { result = inf.nNumberOfLinks; } } return result; #else uintmax_t result = 0; file_status fs = detail::status_ex(p, ec, nullptr, nullptr, &result, nullptr); if (fs.type() == file_type::not_found) { ec = detail::make_error_code(detail::portable_error::not_found); } return ec ? static_cast(-1) : result; #endif } GHC_INLINE bool is_block_file(file_status s) noexcept { return s.type() == file_type::block; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_block_file(const path& p) { return is_block_file(status(p)); } #endif GHC_INLINE bool is_block_file(const path& p, std::error_code& ec) noexcept { return is_block_file(status(p, ec)); } GHC_INLINE bool is_character_file(file_status s) noexcept { return s.type() == file_type::character; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_character_file(const path& p) { return is_character_file(status(p)); } #endif GHC_INLINE bool is_character_file(const path& p, std::error_code& ec) noexcept { return is_character_file(status(p, ec)); } GHC_INLINE bool is_directory(file_status s) noexcept { return s.type() == file_type::directory; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_directory(const path& p) { return is_directory(status(p)); } #endif GHC_INLINE bool is_directory(const path& p, std::error_code& ec) noexcept { return is_directory(status(p, ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_empty(const path& p) { if (is_directory(p)) { return directory_iterator(p) == directory_iterator(); } else { return file_size(p) == 0; } } #endif GHC_INLINE bool is_empty(const path& p, std::error_code& ec) noexcept { auto fs = status(p, ec); if (ec) { return false; } if (is_directory(fs)) { directory_iterator iter(p, ec); if (ec) { return false; } return iter == directory_iterator(); } else { auto sz = file_size(p, ec); if (ec) { return false; } return sz == 0; } } GHC_INLINE bool is_fifo(file_status s) noexcept { return s.type() == file_type::fifo; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_fifo(const path& p) { return is_fifo(status(p)); } #endif GHC_INLINE bool is_fifo(const path& p, std::error_code& ec) noexcept { return is_fifo(status(p, ec)); } GHC_INLINE bool is_other(file_status s) noexcept { return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_other(const path& p) { return is_other(status(p)); } #endif GHC_INLINE bool is_other(const path& p, std::error_code& ec) noexcept { return is_other(status(p, ec)); } GHC_INLINE bool is_regular_file(file_status s) noexcept { return s.type() == file_type::regular; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_regular_file(const path& p) { return is_regular_file(status(p)); } #endif GHC_INLINE bool is_regular_file(const path& p, std::error_code& ec) noexcept { return is_regular_file(status(p, ec)); } GHC_INLINE bool is_socket(file_status s) noexcept { return s.type() == file_type::socket; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_socket(const path& p) { return is_socket(status(p)); } #endif GHC_INLINE bool is_socket(const path& p, std::error_code& ec) noexcept { return is_socket(status(p, ec)); } GHC_INLINE bool is_symlink(file_status s) noexcept { return s.type() == file_type::symlink; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool is_symlink(const path& p) { return is_symlink(symlink_status(p)); } #endif GHC_INLINE bool is_symlink(const path& p, std::error_code& ec) noexcept { return is_symlink(symlink_status(p, ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_time_type last_write_time(const path& p) { std::error_code ec; auto result = last_write_time(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE file_time_type last_write_time(const path& p, std::error_code& ec) noexcept { time_t result = 0; ec.clear(); file_status fs = detail::status_ex(p, ec, nullptr, nullptr, nullptr, &result); return ec ? (file_time_type::min)() : std::chrono::system_clock::from_time_t(result); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void last_write_time(const path& p, file_time_type new_time) { std::error_code ec; last_write_time(p, new_time, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } #endif GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept { ec.clear(); auto d = new_time.time_since_epoch(); #ifdef GHC_OS_WINDOWS std::shared_ptr file(::CreateFileW(p.wstring().c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL), ::CloseHandle); FILETIME ft; auto tt = std::chrono::duration_cast(d).count() * 10 + 116444736000000000; ft.dwLowDateTime = static_cast(tt); ft.dwHighDateTime = static_cast(tt >> 32); if (!::SetFileTime(file.get(), 0, 0, &ft)) { ec = detail::make_system_error(); } #elif defined(GHC_OS_MACOS) #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 struct ::stat fs; if (::stat(p.c_str(), &fs) == 0) { struct ::timeval tv[2]; tv[0].tv_sec = fs.st_atimespec.tv_sec; tv[0].tv_usec = static_cast(fs.st_atimespec.tv_nsec / 1000); tv[1].tv_sec = std::chrono::duration_cast(d).count(); tv[1].tv_usec = static_cast(std::chrono::duration_cast(d).count() % 1000000); if (::utimes(p.c_str(), tv) == 0) { return; } } ec = detail::make_system_error(); return; #else struct ::timespec times[2]; times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; times[1].tv_sec = std::chrono::duration_cast(d).count(); times[1].tv_nsec = std::chrono::duration_cast(d).count() % 1000000000; if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { ec = detail::make_system_error(); } return; #endif #endif #else #ifndef UTIME_OMIT #define UTIME_OMIT ((1l << 30) - 2l) #endif struct ::timespec times[2]; times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; times[1].tv_sec = static_cast(std::chrono::duration_cast(d).count()); times[1].tv_nsec = static_cast(std::chrono::duration_cast(d).count() % 1000000000); #if defined(__ANDROID_API__) && __ANDROID_API__ < 12 if (syscall(__NR_utimensat, AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { #else if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { #endif ec = detail::make_system_error(); } return; #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) { std::error_code ec; permissions(p, prms, opts, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } #endif GHC_INLINE void permissions(const path& p, perms prms, std::error_code& ec) noexcept { permissions(p, prms, perm_options::replace, ec); } GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec) { if (static_cast(opts & (perm_options::replace | perm_options::add | perm_options::remove)) == 0) { ec = detail::make_error_code(detail::portable_error::invalid_argument); return; } auto fs = symlink_status(p, ec); if ((opts & perm_options::replace) != perm_options::replace) { if ((opts & perm_options::add) == perm_options::add) { prms = fs.permissions() | prms; } else { prms = fs.permissions() & ~prms; } } #ifdef GHC_OS_WINDOWS #ifdef __GNUC__ auto oldAttr = GetFileAttributesW(p.wstring().c_str()); if (oldAttr != INVALID_FILE_ATTRIBUTES) { DWORD newAttr = ((prms & perms::owner_write) == perms::owner_write) ? oldAttr & ~(static_cast(FILE_ATTRIBUTE_READONLY)) : oldAttr | FILE_ATTRIBUTE_READONLY; if (oldAttr == newAttr || SetFileAttributesW(p.wstring().c_str(), newAttr)) { return; } } ec = detail::make_system_error(); #else int mode = 0; if ((prms & perms::owner_read) == perms::owner_read) { mode |= _S_IREAD; } if ((prms & perms::owner_write) == perms::owner_write) { mode |= _S_IWRITE; } if (::_wchmod(p.wstring().c_str(), mode) != 0) { ec = detail::make_system_error(); } #endif #else if ((opts & perm_options::nofollow) != perm_options::nofollow) { if (::chmod(p.c_str(), static_cast(prms)) != 0) { ec = detail::make_system_error(); } } #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path proximate(const path& p, std::error_code& ec) { return proximate(p, current_path(), ec); } #endif #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path proximate(const path& p, const path& base) { return weakly_canonical(p).lexically_proximate(weakly_canonical(base)); } #endif GHC_INLINE path proximate(const path& p, const path& base, std::error_code& ec) { return weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path read_symlink(const path& p) { std::error_code ec; auto result = read_symlink(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE path read_symlink(const path& p, std::error_code& ec) { file_status fs = symlink_status(p, ec); if (fs.type() != file_type::symlink) { ec = detail::make_error_code(detail::portable_error::invalid_argument); return path(); } auto result = detail::resolveSymlink(p, ec); return ec ? path() : result; } GHC_INLINE path relative(const path& p, std::error_code& ec) { return relative(p, current_path(ec), ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path relative(const path& p, const path& base) { return weakly_canonical(p).lexically_relative(weakly_canonical(base)); } #endif GHC_INLINE path relative(const path& p, const path& base, std::error_code& ec) { return weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool remove(const path& p) { std::error_code ec; auto result = remove(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS std::wstring np = detail::fromUtf8(p.u8string()); DWORD attr = GetFileAttributesW(np.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { auto error = ::GetLastError(); if (error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND) { return false; } ec = detail::make_system_error(error); } if (!ec) { if (attr & FILE_ATTRIBUTE_DIRECTORY) { if (!RemoveDirectoryW(np.c_str())) { ec = detail::make_system_error(); } } else { if (!DeleteFileW(np.c_str())) { ec = detail::make_system_error(); } } } #else if (::remove(p.c_str()) == -1) { auto error = errno; if (error == ENOENT) { return false; } ec = detail::make_system_error(); } #endif return ec ? false : true; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t remove_all(const path& p) { std::error_code ec; auto result = remove_all(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept { ec.clear(); uintmax_t count = 0; if (p == "/") { ec = detail::make_error_code(detail::portable_error::not_supported); return static_cast(-1); } std::error_code tec; auto fs = status(p, tec); if (exists(fs) && is_directory(fs)) { for (auto iter = directory_iterator(p, ec); iter != directory_iterator(); iter.increment(ec)) { if (ec) { break; } bool is_symlink_result = iter->is_symlink(ec); if (ec) return static_cast(-1); bool is_directory_result = iter->is_directory(ec); if (ec) return static_cast(-1); if (!is_symlink_result && is_directory_result) { count += remove_all(iter->path(), ec); if (ec) { return static_cast(-1); } } else { remove(iter->path(), ec); if (ec) { return static_cast(-1); } ++count; } } } if (!ec) { if (remove(p, ec)) { ++count; } } if (ec) { return static_cast(-1); } return count; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void rename(const path& from, const path& to) { std::error_code ec; rename(from, to, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } } #endif GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS if (from != to) { if (!MoveFileExW(detail::fromUtf8(from.u8string()).c_str(), detail::fromUtf8(to.u8string()).c_str(), (DWORD)MOVEFILE_REPLACE_EXISTING)) { ec = detail::make_system_error(); } } #else if (from != to) { if (::rename(from.c_str(), to.c_str()) != 0) { ec = detail::make_system_error(); } } #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void resize_file(const path& p, uintmax_t size) { std::error_code ec; resize_file(p, size, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } #endif GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS LARGE_INTEGER lisize; lisize.QuadPart = static_cast(size); if(lisize.QuadPart < 0) { #ifdef ERROR_FILE_TOO_LARGE ec = detail::make_system_error(ERROR_FILE_TOO_LARGE); #else ec = detail::make_system_error(223); #endif return; } std::shared_ptr file(CreateFileW(detail::fromUtf8(p.u8string()).c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL), CloseHandle); if (file.get() == INVALID_HANDLE_VALUE) { ec = detail::make_system_error(); } else if (SetFilePointerEx(file.get(), lisize, NULL, FILE_BEGIN) == 0 || SetEndOfFile(file.get()) == 0) { ec = detail::make_system_error(); } #else if (::truncate(p.c_str(), static_cast(size)) != 0) { ec = detail::make_system_error(); } #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE space_info space(const path& p) { std::error_code ec; auto result = space(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS ULARGE_INTEGER freeBytesAvailableToCaller = {{0, 0}}; ULARGE_INTEGER totalNumberOfBytes = {{0, 0}}; ULARGE_INTEGER totalNumberOfFreeBytes = {{0, 0}}; if (!GetDiskFreeSpaceExW(detail::fromUtf8(p.u8string()).c_str(), &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { ec = detail::make_system_error(); return {static_cast(-1), static_cast(-1), static_cast(-1)}; } return {static_cast(totalNumberOfBytes.QuadPart), static_cast(totalNumberOfFreeBytes.QuadPart), static_cast(freeBytesAvailableToCaller.QuadPart)}; #else struct ::statvfs sfs; if (::statvfs(p.c_str(), &sfs) != 0) { ec = detail::make_system_error(); return {static_cast(-1), static_cast(-1), static_cast(-1)}; } return {static_cast(sfs.f_blocks * sfs.f_frsize), static_cast(sfs.f_bfree * sfs.f_frsize), static_cast(sfs.f_bavail * sfs.f_frsize)}; #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status status(const path& p) { std::error_code ec; auto result = status(p, ec); if (result.type() == file_type::none) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE file_status status(const path& p, std::error_code& ec) noexcept { return detail::status_ex(p, ec); } GHC_INLINE bool status_known(file_status s) noexcept { return s.type() != file_type::none; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status symlink_status(const path& p) { std::error_code ec; auto result = symlink_status(p, ec); if (result.type() == file_type::none) { throw filesystem_error(detail::systemErrorText(ec.value()), ec); } return result; } #endif GHC_INLINE file_status symlink_status(const path& p, std::error_code& ec) noexcept { return detail::symlink_status_ex(p, ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path temp_directory_path() { std::error_code ec; path result = temp_directory_path(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), ec); } return result; } #endif GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS wchar_t buffer[512]; auto rc = GetTempPathW(511, buffer); if (!rc || rc > 511) { ec = detail::make_system_error(); return path(); } return path(std::wstring(buffer)); #else static const char* temp_vars[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR", nullptr}; const char* temp_path = nullptr; for (auto temp_name = temp_vars; *temp_name != nullptr; ++temp_name) { temp_path = std::getenv(*temp_name); if (temp_path) { return path(temp_path); } } return path("/tmp"); #endif } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE path weakly_canonical(const path& p) { std::error_code ec; auto result = weakly_canonical(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } #endif GHC_INLINE path weakly_canonical(const path& p, std::error_code& ec) noexcept { path result; ec.clear(); bool scan = true; for (auto pe : p) { if (scan) { std::error_code tec; if (exists(result / pe, tec)) { result /= pe; } else { if (ec) { return path(); } scan = false; if (!result.empty()) { result = canonical(result, ec) / pe; if (ec) { break; } } else { result /= pe; } } } else { result /= pe; } } if (scan) { if (!result.empty()) { result = canonical(result, ec); } } return ec ? path() : result.lexically_normal(); } //----------------------------------------------------------------------------- // 30.10.11 class file_status // 30.10.11.1 constructors and destructor GHC_INLINE file_status::file_status() noexcept : file_status(file_type::none) { } GHC_INLINE file_status::file_status(file_type ft, perms prms) noexcept : _type(ft) , _perms(prms) { } GHC_INLINE file_status::file_status(const file_status& other) noexcept : _type(other._type) , _perms(other._perms) { } GHC_INLINE file_status::file_status(file_status&& other) noexcept : _type(other._type) , _perms(other._perms) { } GHC_INLINE file_status::~file_status() {} // assignments: GHC_INLINE file_status& file_status::operator=(const file_status& rhs) noexcept { _type = rhs._type; _perms = rhs._perms; return *this; } GHC_INLINE file_status& file_status::operator=(file_status&& rhs) noexcept { _type = rhs._type; _perms = rhs._perms; return *this; } // 30.10.11.3 modifiers GHC_INLINE void file_status::type(file_type ft) noexcept { _type = ft; } GHC_INLINE void file_status::permissions(perms prms) noexcept { _perms = prms; } // 30.10.11.2 observers GHC_INLINE file_type file_status::type() const noexcept { return _type; } GHC_INLINE perms file_status::permissions() const noexcept { return _perms; } //----------------------------------------------------------------------------- // 30.10.12 class directory_entry // 30.10.12.1 constructors and destructor // directory_entry::directory_entry() noexcept = default; // directory_entry::directory_entry(const directory_entry&) = default; // directory_entry::directory_entry(directory_entry&&) noexcept = default; #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) : _path(p) , _file_size(0) #ifndef GHC_OS_WINDOWS , _hard_link_count(0) #endif , _last_write_time(0) { refresh(); } #endif GHC_INLINE directory_entry::directory_entry(const filesystem::path& p, std::error_code& ec) : _path(p) , _file_size(0) #ifndef GHC_OS_WINDOWS , _hard_link_count(0) #endif , _last_write_time(0) { refresh(ec); } GHC_INLINE directory_entry::~directory_entry() {} // assignments: // directory_entry& directory_entry::operator=(const directory_entry&) = default; // directory_entry& directory_entry::operator=(directory_entry&&) noexcept = default; // 30.10.12.2 directory_entry modifiers #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::assign(const filesystem::path& p) { _path = p; refresh(); } #endif GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_code& ec) { _path = p; refresh(ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p) { _path.replace_filename(p); refresh(); } #endif GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std::error_code& ec) { _path.replace_filename(p); refresh(ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void directory_entry::refresh() { std::error_code ec; refresh(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _path, ec); } } #endif GHC_INLINE void directory_entry::refresh(std::error_code& ec) noexcept { #ifdef GHC_OS_WINDOWS _status = detail::status_ex(_path, ec, &_symlink_status, &_file_size, nullptr, &_last_write_time); #else _status = detail::status_ex(_path, ec, &_symlink_status, &_file_size, &_hard_link_count, &_last_write_time); #endif } // 30.10.12.3 directory_entry observers GHC_INLINE const filesystem::path& directory_entry::path() const noexcept { return _path; } GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept { return _path; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::exists() const { return filesystem::exists(status()); } #endif GHC_INLINE bool directory_entry::exists(std::error_code& ec) const noexcept { return filesystem::exists(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_block_file() const { return filesystem::is_block_file(status()); } #endif GHC_INLINE bool directory_entry::is_block_file(std::error_code& ec) const noexcept { return filesystem::is_block_file(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_character_file() const { return filesystem::is_character_file(status()); } #endif GHC_INLINE bool directory_entry::is_character_file(std::error_code& ec) const noexcept { return filesystem::is_character_file(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_directory() const { return filesystem::is_directory(status()); } #endif GHC_INLINE bool directory_entry::is_directory(std::error_code& ec) const noexcept { return filesystem::is_directory(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_fifo() const { return filesystem::is_fifo(status()); } #endif GHC_INLINE bool directory_entry::is_fifo(std::error_code& ec) const noexcept { return filesystem::is_fifo(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_other() const { return filesystem::is_other(status()); } #endif GHC_INLINE bool directory_entry::is_other(std::error_code& ec) const noexcept { return filesystem::is_other(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_regular_file() const { return filesystem::is_regular_file(status()); } #endif GHC_INLINE bool directory_entry::is_regular_file(std::error_code& ec) const noexcept { return filesystem::is_regular_file(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_socket() const { return filesystem::is_socket(status()); } #endif GHC_INLINE bool directory_entry::is_socket(std::error_code& ec) const noexcept { return filesystem::is_socket(status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE bool directory_entry::is_symlink() const { return filesystem::is_symlink(symlink_status()); } #endif GHC_INLINE bool directory_entry::is_symlink(std::error_code& ec) const noexcept { return filesystem::is_symlink(symlink_status(ec)); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t directory_entry::file_size() const { if (_status.type() != file_type::none) { return _file_size; } return filesystem::file_size(path()); } #endif GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { ec.clear(); return _file_size; } return filesystem::file_size(path(), ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE uintmax_t directory_entry::hard_link_count() const { #ifndef GHC_OS_WINDOWS if (_status.type() != file_type::none) { return _hard_link_count; } #endif return filesystem::hard_link_count(path()); } #endif GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const noexcept { #ifndef GHC_OS_WINDOWS if (_status.type() != file_type::none) { ec.clear(); return _hard_link_count; } #endif return filesystem::hard_link_count(path(), ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_time_type directory_entry::last_write_time() const { if (_status.type() != file_type::none) { return std::chrono::system_clock::from_time_t(_last_write_time); } return filesystem::last_write_time(path()); } #endif GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { ec.clear(); return std::chrono::system_clock::from_time_t(_last_write_time); } return filesystem::last_write_time(path(), ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status directory_entry::status() const { if (_status.type() != file_type::none) { return _status; } return filesystem::status(path()); } #endif GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { ec.clear(); return _status; } return filesystem::status(path(), ec); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE file_status directory_entry::symlink_status() const { if (_symlink_status.type() != file_type::none) { return _symlink_status; } return filesystem::symlink_status(path()); } #endif GHC_INLINE file_status directory_entry::symlink_status(std::error_code& ec) const noexcept { if (_symlink_status.type() != file_type::none) { ec.clear(); return _symlink_status; } return filesystem::symlink_status(path(), ec); } GHC_INLINE bool directory_entry::operator<(const directory_entry& rhs) const noexcept { return _path < rhs._path; } GHC_INLINE bool directory_entry::operator==(const directory_entry& rhs) const noexcept { return _path == rhs._path; } GHC_INLINE bool directory_entry::operator!=(const directory_entry& rhs) const noexcept { return _path != rhs._path; } GHC_INLINE bool directory_entry::operator<=(const directory_entry& rhs) const noexcept { return _path <= rhs._path; } GHC_INLINE bool directory_entry::operator>(const directory_entry& rhs) const noexcept { return _path > rhs._path; } GHC_INLINE bool directory_entry::operator>=(const directory_entry& rhs) const noexcept { return _path >= rhs._path; } //----------------------------------------------------------------------------- // 30.10.13 class directory_iterator #ifdef GHC_OS_WINDOWS class directory_iterator::impl { public: impl(const path& p, directory_options options) : _base(p) , _options(options) , _dirHandle(INVALID_HANDLE_VALUE) { if (!_base.empty()) { ZeroMemory(&_findData, sizeof(WIN32_FIND_DATAW)); if ((_dirHandle = FindFirstFileW(detail::fromUtf8((_base / "*").u8string()).c_str(), &_findData)) != INVALID_HANDLE_VALUE) { if (std::wstring(_findData.cFileName) == L"." || std::wstring(_findData.cFileName) == L"..") { increment(_ec); } else { _current = _base / std::wstring(_findData.cFileName); copyToDirEntry(_ec); } } else { auto error = ::GetLastError(); _base = filesystem::path(); if (error != ERROR_ACCESS_DENIED || (options & directory_options::skip_permission_denied) == directory_options::none) { _ec = detail::make_system_error(); } } } } impl(const impl& other) = delete; ~impl() { if (_dirHandle != INVALID_HANDLE_VALUE) { FindClose(_dirHandle); _dirHandle = INVALID_HANDLE_VALUE; } } void increment(std::error_code& ec) { if (_dirHandle != INVALID_HANDLE_VALUE) { do { if (FindNextFileW(_dirHandle, &_findData)) { _current = _base; #ifdef GHC_RAISE_UNICODE_ERRORS try { _current.append_name(detail::toUtf8(_findData.cFileName).c_str()); } catch(filesystem_error& fe) { ec = fe.code(); return; } #else _current.append_name(detail::toUtf8(_findData.cFileName).c_str()); #endif copyToDirEntry(ec); } else { auto err = ::GetLastError(); if(err != ERROR_NO_MORE_FILES) { _ec = ec = detail::make_system_error(err); } FindClose(_dirHandle); _dirHandle = INVALID_HANDLE_VALUE; _current = filesystem::path(); break; } } while (std::wstring(_findData.cFileName) == L"." || std::wstring(_findData.cFileName) == L".."); } else { ec = _ec; } } void copyToDirEntry(std::error_code& ec) { _dir_entry._path = _current; if (_findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { _dir_entry._status = detail::status_ex(_current, ec, &_dir_entry._symlink_status, &_dir_entry._file_size, nullptr, &_dir_entry._last_write_time); } else { _dir_entry._status = detail::status_from_INFO(_current, &_findData, ec, &_dir_entry._file_size, &_dir_entry._last_write_time); _dir_entry._symlink_status = _dir_entry._status; } if (ec) { if (_dir_entry._status.type() != file_type::none && _dir_entry._symlink_status.type() != file_type::none) { ec.clear(); } else { _dir_entry._file_size = static_cast(-1); _dir_entry._last_write_time = 0; } } } path _base; directory_options _options; WIN32_FIND_DATAW _findData; HANDLE _dirHandle; path _current; directory_entry _dir_entry; std::error_code _ec; }; #else // POSIX implementation class directory_iterator::impl { public: impl(const path& path, directory_options options) : _base(path) , _options(options) , _dir(nullptr) , _entry(nullptr) { if (!path.empty()) { _dir = ::opendir(path.native().c_str()); } if (!path.empty()) { if (!_dir) { auto error = errno; _base = filesystem::path(); if (error != EACCES || (options & directory_options::skip_permission_denied) == directory_options::none) { _ec = detail::make_system_error(); } } else { increment(_ec); } } } impl(const impl& other) = delete; ~impl() { if (_dir) { ::closedir(_dir); } } void increment(std::error_code& ec) { if (_dir) { do { errno = 0; _entry = readdir(_dir); if (_entry) { _current = _base; _current.append_name(_entry->d_name); _dir_entry = directory_entry(_current, ec); } else { ::closedir(_dir); _dir = nullptr; _current = path(); if (errno) { ec = detail::make_system_error(); } break; } } while (std::strcmp(_entry->d_name, ".") == 0 || std::strcmp(_entry->d_name, "..") == 0); } } path _base; directory_options _options; path _current; DIR* _dir; struct ::dirent* _entry; directory_entry _dir_entry; std::error_code _ec; }; #endif // 30.10.13.1 member functions GHC_INLINE directory_iterator::directory_iterator() noexcept : _impl(new impl(path(), directory_options::none)) { } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_iterator::directory_iterator(const path& p) : _impl(new impl(p, directory_options::none)) { if (_impl->_ec) { throw filesystem_error(detail::systemErrorText(_impl->_ec.value()), p, _impl->_ec); } _impl->_ec.clear(); } GHC_INLINE directory_iterator::directory_iterator(const path& p, directory_options options) : _impl(new impl(p, options)) { if (_impl->_ec) { throw filesystem_error(detail::systemErrorText(_impl->_ec.value()), p, _impl->_ec); } } #endif GHC_INLINE directory_iterator::directory_iterator(const path& p, std::error_code& ec) noexcept : _impl(new impl(p, directory_options::none)) { if (_impl->_ec) { ec = _impl->_ec; } } GHC_INLINE directory_iterator::directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept : _impl(new impl(p, options)) { if (_impl->_ec) { ec = _impl->_ec; } } GHC_INLINE directory_iterator::directory_iterator(const directory_iterator& rhs) : _impl(rhs._impl) { } GHC_INLINE directory_iterator::directory_iterator(directory_iterator&& rhs) noexcept : _impl(std::move(rhs._impl)) { } GHC_INLINE directory_iterator::~directory_iterator() {} GHC_INLINE directory_iterator& directory_iterator::operator=(const directory_iterator& rhs) { _impl = rhs._impl; return *this; } GHC_INLINE directory_iterator& directory_iterator::operator=(directory_iterator&& rhs) noexcept { _impl = std::move(rhs._impl); return *this; } GHC_INLINE const directory_entry& directory_iterator::operator*() const { return _impl->_dir_entry; } GHC_INLINE const directory_entry* directory_iterator::operator->() const { return &_impl->_dir_entry; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE directory_iterator& directory_iterator::operator++() { std::error_code ec; _impl->increment(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_current, ec); } return *this; } #endif GHC_INLINE directory_iterator& directory_iterator::increment(std::error_code& ec) noexcept { _impl->increment(ec); return *this; } GHC_INLINE bool directory_iterator::operator==(const directory_iterator& rhs) const { return _impl->_current == rhs._impl->_current; } GHC_INLINE bool directory_iterator::operator!=(const directory_iterator& rhs) const { return _impl->_current != rhs._impl->_current; } // 30.10.13.2 directory_iterator non-member functions GHC_INLINE directory_iterator begin(directory_iterator iter) noexcept { return iter; } GHC_INLINE directory_iterator end(const directory_iterator&) noexcept { return directory_iterator(); } //----------------------------------------------------------------------------- // 30.10.14 class recursive_directory_iterator GHC_INLINE recursive_directory_iterator::recursive_directory_iterator() noexcept : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { _impl->_dir_iter_stack.push(directory_iterator()); } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p) : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { _impl->_dir_iter_stack.push(directory_iterator(p)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, directory_options options) : _impl(new recursive_directory_iterator_impl(options, true)) { _impl->_dir_iter_stack.push(directory_iterator(p, options)); } #endif GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept : _impl(new recursive_directory_iterator_impl(options, true)) { _impl->_dir_iter_stack.push(directory_iterator(p, options, ec)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, std::error_code& ec) noexcept : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { _impl->_dir_iter_stack.push(directory_iterator(p, ec)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const recursive_directory_iterator& rhs) : _impl(rhs._impl) { } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept : _impl(std::move(rhs._impl)) { } GHC_INLINE recursive_directory_iterator::~recursive_directory_iterator() {} // 30.10.14.1 observers GHC_INLINE directory_options recursive_directory_iterator::options() const { return _impl->_options; } GHC_INLINE int recursive_directory_iterator::depth() const { return static_cast(_impl->_dir_iter_stack.size() - 1); } GHC_INLINE bool recursive_directory_iterator::recursion_pending() const { return _impl->_recursion_pending; } GHC_INLINE const directory_entry& recursive_directory_iterator::operator*() const { return *(_impl->_dir_iter_stack.top()); } GHC_INLINE const directory_entry* recursive_directory_iterator::operator->() const { return &(*(_impl->_dir_iter_stack.top())); } // 30.10.14.1 modifiers recursive_directory_iterator& GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator=(const recursive_directory_iterator& rhs) { _impl = rhs._impl; return *this; } GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator=(recursive_directory_iterator&& rhs) noexcept { _impl = std::move(rhs._impl); return *this; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator++() { std::error_code ec; increment(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_dir_iter_stack.empty() ? path() : _impl->_dir_iter_stack.top()->path(), ec); } return *this; } #endif GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept { auto status = (*this)->status(ec); if (ec) return *this; auto symlink_status = (*this)->symlink_status(ec); if (ec) return *this; if (recursion_pending() && is_directory(status) && (!is_symlink(symlink_status) || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { _impl->_dir_iter_stack.push(directory_iterator((*this)->path(), _impl->_options, ec)); } else { _impl->_dir_iter_stack.top().increment(ec); } if (!ec) { while (depth() && _impl->_dir_iter_stack.top() == directory_iterator()) { _impl->_dir_iter_stack.pop(); _impl->_dir_iter_stack.top().increment(ec); } } else if (!_impl->_dir_iter_stack.empty()) { _impl->_dir_iter_stack.pop(); } _impl->_recursion_pending = true; return *this; } #ifdef GHC_WITH_EXCEPTIONS GHC_INLINE void recursive_directory_iterator::pop() { std::error_code ec; pop(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_dir_iter_stack.empty() ? path() : _impl->_dir_iter_stack.top()->path(), ec); } } #endif GHC_INLINE void recursive_directory_iterator::pop(std::error_code& ec) { if (depth() == 0) { *this = recursive_directory_iterator(); } else { do { _impl->_dir_iter_stack.pop(); _impl->_dir_iter_stack.top().increment(ec); } while (depth() && _impl->_dir_iter_stack.top() == directory_iterator()); } } GHC_INLINE void recursive_directory_iterator::disable_recursion_pending() { _impl->_recursion_pending = false; } // other members as required by 27.2.3, input iterators GHC_INLINE bool recursive_directory_iterator::operator==(const recursive_directory_iterator& rhs) const { return _impl->_dir_iter_stack.top() == rhs._impl->_dir_iter_stack.top(); } GHC_INLINE bool recursive_directory_iterator::operator!=(const recursive_directory_iterator& rhs) const { return _impl->_dir_iter_stack.top() != rhs._impl->_dir_iter_stack.top(); } // 30.10.14.2 directory_iterator non-member functions GHC_INLINE recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept { return iter; } GHC_INLINE recursive_directory_iterator end(const recursive_directory_iterator&) noexcept { return recursive_directory_iterator(); } #endif // GHC_EXPAND_IMPL } // namespace filesystem } // namespace ghc // cleanup some macros #undef GHC_INLINE #undef GHC_EXPAND_IMPL #endif // GHC_FILESYSTEM_H kim-api-2.3.0-git/cpp/src/ghc-filesystem/ghc-filesystem.origin000066400000000000000000000001251421473465500242650ustar00rootroot00000000000000https://github.com/gulrak/filesystem commit 3f1c185ab414e764c694b8171d1c4d8c5c437517 kim-api-2.3.0-git/docs/000077500000000000000000000000001421473465500145675ustar00rootroot00000000000000kim-api-2.3.0-git/docs/CMakeLists.txt000066400000000000000000000071311421473465500173310ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) find_package(Doxygen QUIET) if(Doxygen_FOUND) include(FindPackageMessage) find_package_message(Doxygen "Found Doxygen: (${DOXYGEN_EXECUTABLE})" "found") endif() set(DOXYGEN_PROJECT_NAME "${PROJECT_NAME}") set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION_STRING}") set(DOXYGEN_STRIP_FROM_PATH "../../") set(DOXYGEN_CASE_SENSE_NAMES NO) set(DOXYGEN_TAB_SIZE 2) set(DOXYGEN_EXCLUDE_SYMBOLS "*_DEFINED_" "*_HPP_" "*_H_") set(DOXYGEN_ENABLE_PREPROCESSING YES) set(DOXYGEN_SKIP_FUNCTION_MACROS NO) set(DOXYGEN_EXTRACT_ALL YES) set(DOXYGEN_EXTRACT_STATIC YES) set(DOXYGEN_EXTRACT_ANON_NSPACES YES) set(DOXYGEN_FILE_PATTERNS "*.c" "*.cpp" "*.h" "*.h.in" "*.hpp" "*.hpp.in" "*.inc" "*.f90" ) # additional patterns for examples set(DOXYGEN_FILE_PATTERNS ${DOXYGEN_FILE_PATTERNS} "*.LGPL" "*.txt" "*.sh" "README" "*.params" "*.in" "*.bib" "*.edn" ) set(DOXYGEN_EXTENSION_MAPPING "in=C++") set(DOXYGEN_RECURSIVE YES) set(DOXYGEN_EXAMPLE_PATH "../examples") set(DOXYGEN_IMAGE_PATH "src/asymptote-figures") set(DOXYGEN_SOURCE_BROWSER YES) set(DOXYGEN_USE_MATHJAX YES) set(DOXYGEN_MATHJAX_RELPATH "https://cdn.jsdelivr.net/npm/mathjax@2") set(DOXYGEN_EXTRA_PACKAGES "amsmath") set(DOXYGEN_GENERATE_LATEX YES) if(READTHEDOCS) set(DOXYGEN_HTML_FOOTER "readthedocs/footer.html") endif(READTHEDOCS) set(SOURCES "src/cmake-files.txt" "src/table-of-contents.txt" "src/features.txt" "src/theory.txt" "src/implementation.txt" "src/version2-differences.txt" "../cpp/include/" "../c/include/" "../fortran/include/" "../INSTALL" "../NEWS" "../examples/model-drivers/" "../examples/portable-models/" "../examples/simulator-models/" "../examples/simulators/" ) if(DOXYGEN_FOUND) doxygen_add_docs( docs ${SOURCES} COMMENT "Generate documentation" ) add_custom_command(OUTPUT refman.pdf COMMAND make COMMAND ${CMAKE_COMMAND} -E copy refman.pdf ${CMAKE_CURRENT_BINARY_DIR}/refman.pdf WORKING_DIRECTORY latex DEPENDS docs ) # TODO fix dependencies add_custom_target(pdf DEPENDS docs refman.pdf SOURCES ${SOURCES}) endif(DOXYGEN_FOUND) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_DOCDIR} OPTIONAL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/refman.pdf # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_DOCDIR} OPTIONAL) kim-api-2.3.0-git/docs/readthedocs/000077500000000000000000000000001421473465500170545ustar00rootroot00000000000000kim-api-2.3.0-git/docs/readthedocs/conf.py000066400000000000000000000047771421473465500203720ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # import subprocess analyticsScript = '''\ ''' script=open('script.html', 'w') script.write(analyticsScript) script.close() subprocess.call('conda install -y cmake', shell=True) subprocess.call('conda env export -n root', shell=True) subprocess.call('doxygen -w html orig_header.html orig_footer.html orig_stylesheet.css', shell=True) subprocess.call('cat script.html orig_footer.html > footer.html', shell=True) subprocess.call('rm -rf build; mkdir build; cd build; FC=true cmake ../../../ -DREADTHEDOCS=ON; make docs', shell=True) html_extra_path = ['./build/docs/html'] ################################################################################ project = u'kim-api' author = u'Ryan S. Elliott' # The suffix(es) of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # The language for content autogenerated by Sphinx. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = None kim-api-2.3.0-git/docs/readthedocs/index.rst000066400000000000000000000022071421473465500207160ustar00rootroot00000000000000.. .. KIM-API: An API for interatomic models .. Copyright (c) 2013--2022, Regents of the University of Minnesota. .. All rights reserved. .. .. Contributors: .. Richard Berger .. Christoph Junghans .. Ryan S. Elliott .. .. SPDX-License-Identifier: LGPL-2.1-or-later .. .. This library is free software; you can redistribute it and/or .. modify it under the terms of the GNU Lesser General Public .. License as published by the Free Software Foundation; either .. version 2.1 of the License, or (at your option) any later version. .. .. This library is distributed in the hope that it will be useful, .. but WITHOUT ANY WARRANTY; without even the implied warranty of .. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU .. Lesser General Public License for more details. .. .. You should have received a copy of the GNU Lesser General Public License .. along with this library; if not, write to the Free Software Foundation, .. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .. .. .. Release: This file is part of the kim-api.git repository. .. .. kim-api documentation master file .. toctree:: :maxdepth: 2 kim-api-2.3.0-git/docs/src/000077500000000000000000000000001421473465500153565ustar00rootroot00000000000000kim-api-2.3.0-git/docs/src/asymptote-figures/000077500000000000000000000000001421473465500210455ustar00rootroot00000000000000kim-api-2.3.0-git/docs/src/asymptote-figures/square-lattice-configuration-1.jpg000066400000000000000000000431161421473465500275020ustar00rootroot00000000000000˙Ø˙āJFIF˙ÛC       ˙Ā <7˙Ä  ˙Ä@ ! 1A"2QSUa‘“ŅBq#R3b4‚’$%ąÁđ˙Ú?•4DDDDDDDDDDDDDDDDTëũ­÷›cíÍšTвW°Ë54Ļ)|°ā\Öŧ[1‘ßŦ[ą´úƒMĐî5ÃU^ŸÆīsŽĸ§Š¸Ë$NļžYcĨˆĩÎÁ6Į $“ęŗ¯pšDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEåšÛhī[. {éęÂF˛WÆK~ÎL!Ãü`jm¤ĨŠąim¤ŠŠ-v%_˜æŧēcO )ädL‰Îp÷0āo¸ėoÛ=ŽžÉhĄŗR>WÁAM,n•åī-cCAsŠĀîWąŽás§ˇĩ­xtŗË‘ ŒÉ!ü‡Ųö“Ø{•Më­†ûæēĸļAŠšfŋũˇD==ƒ›ÜƒÛ‘'>Ŗj*ú[„>},ŧ€<\!ĖpõkîäWĄuųđgtyû9ÂīĢ3öp\ųą}ãTķbûÆūŠæÅ÷ũS͋īú§›Ū7õO6/ŧoęžl_xßÕ<ØžņŋĒyą}ãTķbûÆūŠæÅ÷ũS͋īú§›Ū7õO6/ŧoęžl_xßÕ<ØžņŋĒyą}ãTķbûÆūŠæÅ÷ũS͋īú§›Ū7õO6/ŧoęē ÎÚXnÁĀāƒ3sŸÕu‹í‚E愀x“ņ õû=WSĩ5€-ēÁ#Ŋ8Äîn?Ø7$˙…ĮĪã—ŠŲqŠ'ЊsųIÄ/É˙QW}SÛ#>¤>oņØ5§˙’õPÚéhųXd–yîO3šČ˙ȟaų É{‚˛ŅL˙ŌŌUã|áė!Ãûƒųat‰ĩ Ņ–’žāÁũpŋʐÍŽú9˙Ü?ęX˙õtW b=yŌ=Ã˙“i˙~™Šl8Š@~ĮJG÷ĪĸíųŨ”šŦz.O8hø†d˙në˛;•ēWˆâ¯§{ĪŖ[+Iũ2ģŧØžņŋĒyą}ãTķbûÆūŠæÅ÷ũS͋īú§›Ū7õO6/ŧoęžl_xßÕ<ØžņŋĒyą}ãTķbûÆūŠæÅ÷ũS͋īú§›Ū7õO6/ŧoęžl_xßÕ<ØžņŋĒyą}ãTķbûÆūŠæÅ÷ũS͋īú§›Ū7õ\á3>ƒA<8lĖ'ė ą†ļíĸ•‘MSTáɰ@ŪNĮÚIĀhüÜBčę*ĪĨ%E5š‡Ņ‘ŗÎÍĮ ˙i\ü†)?õw+A?[5.Œņ?éĢîûlrwHKÜš$“ūW`°XšöČÛ-{>Ģž™į õ’Í" EaĮ'…;Oø ÷ōËoáôß´ßá>Ymü>›ö›ü'Ë-ŋ‡Ķ~Ķ„ųeˇđúoÚođŸ,ļūMûMūå–ßÃéŋiŋÂ|˛Ûø}7í7øO–[ĻũĻ˙ ōËoáôß´ßá>Ymü>›ö›ü'Ë-ŋ‡Ķ~Ķ„ųeˇđúoÚođŸ,ļūMûMūå–ßÃéŋiŋÂ|˛Ûø}7í7øO–[ĻũĻ˙ ōËoáôß´ßá>Ymü>›ö›ü'Ë-ŋ‡Ķ~Ķ„ųeˇđúoÚođŸ,ļūMûMūå–ßÃéŋiŋÂᖛToĮl¤kÁČp… ƒũđģ~v°ũŋP.ĐFØ.Qåėdâö‡ėFBëøJLƒđądz}Ųt‹=¤;˜ĩŌ}žCs˙é~žYmü>›ö›ü'Ë-ŋ‡Ķ~Ķ„ųeˇđúoÚođŸ,ļūMûMūå–ßÃéŋiŋÂ|˛Ûø}7í7øO–[ĻũĻ˙ ōËoáôß´ßá>Ymü>›ö›ü'Ë-ŋ‡Ķ~Ķ„ųeˇđúoÚođŸ,ļūMûMūå–ßÃéŋiŋÂ|˛Ûø}7í7øO–[ĻũĻ˙ ōËoáôß´ßá>Ymü>›ö›ü'Ë-ŋ‡Ķ~Ķ„ųeˇđúoÚođŸ,ļūMûMūå–ßÃéŋiŋÂ|˛Ûø}7í7ø_‡Ų,ŌHŲd´Q9ėúŽ4ė%ŋØã˛ë:vÁß˙ÂPG$ŠvOÛčŋéĢ˙ˇ@؈ū¨žčŨú´‚†ÆcīEx¸ĀīlÍæˇûb@åÁvĸĸúOm=Ę!ę#LŋāZīÕĢĶAtĨ¸ķd%ėš,y°ĘŌÉ#ĪĻZ}žÃč}Šö/ÚĒĻãĨĄâĒŨåÄâ2ØÆ2įŸČosîģ¨-ôöøŒp<ō’GœžGÉĮÜ˙ū Ԉˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆŧ7+ck@ž <ŠČAō'hîĶöų4û´˙ûîŋvĘ×WR6ia1JŌčåŒ˙KÚpā¸Čė}Æ­C.čøÄīÉŨjÚ­ĩĩiúo­|4ļęę,Ր1Øį4ŧƒšįœ3sŽøRÁą›§CŊÛC¤÷^ŨBú(u5ļ*ī†yɁįŗŲŸp÷*úDDX׊ æĨé÷dĩ^īU[q:~ŒK w4ī{c‰Ž>Íæöäũ™Q…Ķ˙‹ĻûŪ7ĒËfŨ[m†ãĨuÎ|”Ô>DÔiøŸČ—ņ.ÎF{‚Ļ xu›ŠēJĐÚ~iŖĒÕļĸxé*+Ŗ2SŅÃa’BĀG7“#A8õ'8ÂÅ~>!ۏÔnž¸íđĐÛĒ.ĸß-ÎŲu Ļø~mŒ´IąƒĮ8p-pĮĄz"hˆˆŖ ¯ß ŲŲ}é­Ų­–¤´Đ7NĮšÜĢŠ>&J‰ä˛ylką­{A8$œ÷[OĐ?U×­6nm[¨ėôöíGc¯6ģĢ)C…<Ī kŲ4`’Z×wnN=ņ…˛Čˆ‹Ī_[OmĄŠ¸Õ¸ļ XŸ<¤ Æ‚IĮö uwŒPOŨ ‹ž’ąéĘmMXæSŲjhË垘;Ë>y ҜˇčqŪ^6¯p-ģ­ļÚgrŦđIĻĩĶÜâ†O­•Å‡í ’3ī…u"",AՖūÃĶFÄę-Û6‘s̎6*z G8ĩ’ÕLđČÃČî äq߁ܨęé[Ň{õnųØ4NđŅXŽZ{V\âļ4ĐĐü4Öųfxdnaķ`qh!Ų8É*]iG‰\:ģĨ F›Ķkkĸ—Tj–ĪP+kâ2ÃGMkIk2äsžĀp{+oÃc¯­Ôõúũļ[ŗoˇÉ~´ÛūkGs ƒČmDFÆöK%ĄĀČ p'#ˇ}ûDDEŊqø o&Õī­ãivfŽŅlĸŌs2šē˛žˆTË[QÁ¯xĮ‹#¸öŽ Čô[§ŅS5=Vl]ã]lŅ[/4•’ÚްAŸ!ÕģĖ‹9!ŽkÚpIÁ$dã+?ĸ"*vŖžQé=sԗķKiŖšē~.ōâa{°>Ü4¨hĒņ•ęۖoô– 6ŨÚ¯Ŗ`u!2:——Ą¨Ī?7õŖŸé˜íĒ­úëGXõ­Ĩ˛6Šũn§šSļA‡69ŖkÚæ†Ui`ÎŗúK[uŨ +Dw;¯Ÿ ē×M1"'ULOIŽüį'ČÎT|ôËâīģ{ŽÛ&ūPZŽēväɜÉí”"šĸ†FąĪ`h‰xņސČ9택ˇ3ÁĪfĩŪčÕë›.ŊŊiģ-Ō­Õ•ļ:ZXäk^įr{`•Į1´’{ģŽ{vĀ[ĪĄô^œÛgКFŪÚ+5†Ž* (ĪŖnOší’}É%Wŗš{uĨ7oAŪöß[Ûū2ɤu%\AÜ]Ä÷kŋĨÍ 8bŌ͔đ…Ú=¨ŨZÆŊkëÆŠĨ˛Uļļ×jФŽÛ+Ę7Nö“æņ ĐHûüĸ""Á}Zôˇũ]hzM+ŦkjíUö™ŨUjģQĩŽ–•î{K]Ųėp-íõAŦ~ü>6į¤[•ËVQę*ŨSĒnT˙ķĒvĀĘjrāįGm'Å­äââNė3ŦDDEĻũ\øhíˇTÚᛗ¯¸i-G,1ĶÜ&§ĻeD5ŦŒqc‹Kd ŧîČ한ziéŋAôšļTûi MD"gVWWÕg­ŠpŌŋ‡f´ŽĀų“•ŅåėdŦtr09ŽiPT{jĪ}•Ô[Ÿ>ގnúŅĻĢ*ŨWQ§ā‚7rw'EA9dg¸kˆ[ķĻôí›Héûn–Ķ´1ŅZí‘PŅĶĮõb†6†ąŖûIY›Ã´Ú;|vâ÷ĩÚō‰õkäLŪ[¸Éd‘ģú^׸´wČėĩ§ ĒØíÔĄŨžģģjŲŦu?gĄŠ¤Žž(fRYKI29§¸Į=–ö"""×ίú0ÛίôÍļŲĒ.UvKՍō>×xŖ¯|!øįØîĪÜZqA×4núÛžãģ],÷ÚŨIŠoq6žĒëW aĶ´ōōb¤ņip’I$Lalâ""-(ę§Âëlē“ÜywNƒZ\t…ęâ#fĶŌ2Ļ ÂĐ% sšY'9 āg9ØîŸ6CtÛļŨ­ĐNh(œų§ŠŠptõ•ī$ŌäpĀč˛J""éŦ¤Ĩ¸ROA['§ŠĐÍÆZö8aÍ#ÜHQíUāŋ˛3îYÔņn ‡J>Ģ❧[ |€åŸ Tį"?oĢËųî¤×l ˛[),ÖĒHéh¨ ŽššÆLhkZØz‘?ßm’Ņ=Cmßjĩũ<ĪĩŨZ× `plÔͰōŽhÉ5Ã=ÁdÅjŋNž›?˛:ņÚķSęēũs53&ŠŨE[HĘzhD,/‘­q2?‹œpsŒãЈˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ­ÍČÕ¯Đ[{ŠĩÄt­~Ÿ´UÜÛLßYŒ0ē@ĪķĮ ¨Ĩ÷Nå˛{ ­÷RÍmm}~´ËUKÁ,2ök ĀīÁĨÁÎüPÍŗ%WZ7ĸҍ5>âWę‹]Ōį  LL4ŌÃ$Ĩ°ą­S€wŅ-Įp3žęxØîlkđG îé\đCU”Õ0˛Xead‘ŊĄÍ{HÁPG˛Ôš >‘-û–ŨȋHܝåÕ|lvGח[7.CũŦr,Ņ…ÅŊąŒv[pÆ5 cCZŅ€Āė_¤DEinĻÕč]éĐ×-šÜ{WkՁŗĀōZæ¸ļF8wcÚpC‡pVéÛÃû§n™õ\úįAŲîuˇįąđĶ×]ęÅCé"Öl 5­i#ąv ąÛ=ĘŲ$DDXWŠ>ļ[ĒĢež“tlÕFļĶĖP\íķųtíwÖ`vs ņp### ­Ķ×LûKĶ’ŸHíMŽJHkfՕSĒĢ$ŌHq@h œåeDDDZˇŊžŊ1īÆáIšš˛Įv ŧÖ=˛\Ļģáâ¸8 r•ŧN@šŧIĮ~ũÖÄčŊĻ6īJZôF‹ŗSÚŦ–jvŌŅQĀ0ČŖo ûIõ$žä’OrĢhˆ‹ĪpˇĐŨ¨*mw:HǍë"|LĀæKk˜ā{A Íj†“đšé'Gn\;•nŌˇJ‰i*…mĻŽāeˇĶĖɤFG'œ×8Ø­ˇDDEdo&ĖmŪũčJŨšÜë n–jŌŲ8s1É ­ú˛ÄņŨnNûH9…‹únčC§ū—ouš§o-ģídN§ų•Ú¨TM91ņĩŦ$ œzã˛ØtDDX'Šn‹ö;ĒĻÛęw6Ī[ÖÔÃ%ÖŲQäU2"rbq!Í{2IĀā“Œd̎aēzÚŪ›tPЛUbuæ553M)–ĸŽbķ%÷qĀĀØ’Qjžėxgôŗŧ;‘>įj==vĸšWĪņ7*{ey§Ļ¯—ÔžFq%ŽqúŅšõõîļgMiģŽĶöí+ĨíTöÛEϚ:J*JvqŽX0Ö´}€SDD^íŽŅŠŦĩÚwP[ ¯ļ\éäĨĢĨœŖš´ĩĖp÷Žmˇ†/J{_šPnuMŨk+h*E]ē†ãp3ŅŅLZö0´œķs°@>ĄmŠ"""""""""""""""""""""""""""""""""""""árˆˆˆ¸\ĸ"".=}(ˆˆˆˆˆˆ¸\ĸ""""""""""árˆˆˆ¸ü—(ˆˆ‹Œå|äoOSDęëŊk]G¸:šÍ~ ēNČ))Ģæ§e¯Ëq´€ĀÜ`öīŽųʞ^–ĩļ°Ü~ö˙\ëø Z‚ķc§Š¯Ė~Y’B0$ãíĖü䞚""hnˇÚΘw]íĐ{oöËg*Y˜ÎnĻ‘Œ|ā}ąąÎx'°ã“čĄ3ĨžŖú€ĶFé+Ŋ‹^jKÍuúûIGqĸĒŽšĨ—(Ļ™­‘’1Î!ßEăęŌ21…ô<ˆˆŠ<übˇ‹uvÛm´f›ĐĢ’ÕĒ+jãŧWĐŊŅHņc§ķ[‚Öģ›Ü@#—°ƒŧwŋxnûĮyÚģŽ ģß4ŒÖYŽ2Į[<“˛ßPĮ°1ės‰áĪ‘inp{d)}DDE >*ÛëŊu;uÛ§ękՓMiĘjGZhhꤧŠq$-{Ē]ĀŽn/sš Î01‚ˇ‹Â‡w7CvzrŦ›s.×WXoR[-—Z×ÍUL"c¸9įģĖnqo"IÆô[¨ˆˆŧ×9ęimĩu4TßQ I9Į˜đŌZßōpÎģꇨĢÖîWîEßsu5Ĩ§¸Čö6éae šķˆ!­cqĮ†0qß=×ĐfÅjOŽ6cDk iAđWÛ͆ŠļáăėĸĄîĄ÷ãOõEĸŠŦēĶPŪÛĒ/”öûŊēĒēZ˜ë ™āJįĩäŽMisÃũGį_@HˆˆŖOÆSy÷kAZ46…ŅwĢOj&VOsŦĄ‘đžĒX‹)Ũ#H! 8¸´ųČ ÎđkŪŨÔúÛWmŽĸÔ7[æ“ĸŗļį Ž™ķŠ ¯9ŒkX÷Z$kžxį zŠ]DDEž&õŊĩũUjYĢo–[&•ž,ļú:Šiĸ˜ņQ†‘Éī.'Ÿ`0‘ī -ÖÜ­Ũén‚ųšÕÕwëuŌĒ×GrĒÉšļ– ÂĮŊĮ떗=œŊOũōļÕR5}ĘåfŌwģŊšâî6暚J|gΙ‘9Ėf?7?ĘųČŦꓨš÷EûĨ6ęęxõHŦ3ķŌĩŒw,ų"đĢåņãŽØ_E[m{Ŋę]ŧĶ‹RÛūítŗŅÖWScMDĩŌ3Øq# äDDZšâKē[´]*ßõ>ØTÔŅ]'ŦĨˇĪqĻ˙ģCM3Ëd•¤}SõXíĪ>¸Q5Ņ—S]FhMꤏDßīÚĄ÷˜ę›YeĢĒ–Ž*Ė@÷ų…Ž'ihw1ßąÁSG­:9é“põØÜŊeŗv žĸ26ijä‰Í7tŅĩÁ’žÃģÚsī•˜ ‚hc§§…‘EC# kveûDD]5”t— I¨+ébŠĻŠŅM ŦdŒpÚæžÄH ŦGˇôĶĩ:ĘMĀÛũŸąZ/ī.,Ŧy€¸aŪK^âØŗ˙€¸ôY‰ą¸ģg woLThÍÉŌ–ũCeŠp|”•ąshxô{OĢ\=œŌûUh:Ų̈́ļTÚv@Û4ä5ŽkęŸN×:j‚=<É^KŨŽøādád$DDXÃx:f؝ü–ЧvöÚÕ¨jmÍ5LÁņĪ3ždnk‹3ũ$‘ÜöWŽŽŅšSo´ŨŅ~†ÉeļĮåRĐŅB#Š&úöܞäžäœ•ZDDE…īũtŋĒ7ū¨ßļ_NÖjGN*dĒ|. šlƒæI>[ߑœš¤Ÿ|ŦÎÖĩ cCZŅ€Āė\ĸ"/-ÖÕlž[jŦכ}=ulN‚Ļšĸ1$SFá‡1Í=œ8 ŦWļ#ôáŗ:ž}gļ›Kd˛^§oÆF×É$-wÖl^cœ"Ü3ģz,ŧˆˆŠŅÜũ¤ÛmįĶ/ŅûŖŖ­ÚŠĐųĸž˛<ųrGąÃc†OvWi67iļ&Į.Úm mĶ”UÔ V%CĀĀt’8—ŧé’qžĘúDDEЎwĨޟ÷ŪåEzŨ}°´_î †ŽPøæōÁΖ᯿šėĪô¸‘ÜŦ…Ļ´ÎžŅļ-Ĩ,´v›EļĶŌQRD#†ĮŖZŅØ*š"",/?F}/Tî/ũVŸe´ëõ/Ä|YĒō]嚌ōķŒ9ō‹ķߗįŋ¯ušSīö ǞÖéÍKi¤ēZî0ēžŽŽŽ&Ë ņģÕŽkģąļĶtĨĶÎÆŪęõ&ÖmežÃuŦkŖ’˛ ųflnõc#œci÷ Ā+,ĸ""""""""""""""""""""""""""""""""""""*;5–’üí+ĒŗēôÁÉÖŅ]Ēɋ—?OÉV~d’8ct˛ČÖ1€šÎqĀh¤Ÿ`Šv [Ĩ5Sg~—Ô֛ÃiŸåĖh+c¨;ėwp"ĒȈˆŧ7›í“NP>ë¨o46ē(ČŠ­¨d4ŸLŊäúŽËeŌŲzĄ†ég¸Ō×ŅÔ7œ5Ķ6X¤oÚ×4Gö+ԈˆŠyÖ:GNUĶPjUhĩÕVœSAY]NsŒ1¯p.īÛ˛Ģ‚Č+”DDTz]c¤kosiš-Ug¨ŧS‚fˇÅ]ęcהA܇ų °ˆˆ‹Žzˆ)`’ĻĒhá†&—É$Ž k=I'°š§Ø5V˜ÕtōVimGkŧAüš% ŦŽĄŒwüIa ÉUS¯ēOézsÔˇÛ}ό80ÔWU2šAÉä ¯M } ŌŽ…˛ļ ēZ†‡Å< #‘§ĐĩÍ$ų…čDDEGēk-!dšSYoZĒĪAp­ĀĻ¤ĒŽŠ)ĻÉĀāĮ89ŨūĀĢˆˆŠoÖ:Bív¨°ZĩUžļéGŸˆĸ§ŽŠIáĮ¯8Úâæ˙ĢˆˆŠØÜ÷ę¸ļÛUIĄZ]¨Ûe­6IŦō]äãķįÅ|ÕÚ+wWgŋ+cÔēę ×smˆyÕl°VēĶåŒÉņ>S¸đ˙Īū?ųa|įmnčGģöÍ =āë—^b4n…ŌˇÖGgQ$į–}ŗžŲ_M4ŦĐĶ›€`Ē13Ī úžf,~YĘīDDZ-ãQšTũ1Rĸ]ZÛ,—¸›Š]Iž_ åŋË÷ōŒŧy{gŽVøEÔnK:Žĸ§Ō.¯:vKmYÔ­—Ã|8‰ŪQ“úyyŪ_\vƜÔDDPËã?QšG}´õ5áÕãE N˛Žâ•Õ<ßņ'ˇc/ÔÎ{ņãėŗ÷‚ŊNäM´šŌ-Bę÷iް ŠĪ–&ā˙Šįúígšī•#ˆˆˆžmēąĢÜŲē“×’î|—¨ãŋU T—2)ō_d~_{cSšŅTû‹SŌÖÜÍēßū¤uŸk.Nō šīĖÃåį=ūŪë6ĸ",KՔû…MĶnâOĩB§ũRË A 4šķÁĮĶ1cŋ˜#æ[ŽųÆĪ÷O›ŖūhéöÂK‘ÖžSŠo ŧĘ÷™G˜$÷,#—>]¸ōĘúYg> ķ1Ë–=2ŋHˆˆŠŨnļúJíg…ĶėÔ%ÎēļŲŦ$Œįqįœ~jâDDE×QOOW”ĩPG434˛Hähs^Ō0Aą{*.—ĐZD Ŗ4eŽÂ*ŨĘŖå–øi|ĶöģËhåūUy/Qim3ĢíŽŗęÍ;lŊP9ÁîĨ¸RGQpô<Īį…ŨeąY4Ũļ6ŗŅZíôãŒ4´Tė‚ĮØÖ0?Ā^äDDVöĄÛÍĢk鮚ĢCØ/5´Xøj›…ļ‰aÁČāį´–÷īØĢ­kրĀvrˆˆŠŨĸÛ­žļęuuģBéú[ėåÆ[œ6ČYVō}s(o3Ÿ~ęâDDEĶYEGq¤–‚áI U5C rÃ4aņČĶę×4ö ũ…Rtž‡ŅZžj]¤,ļjÎhí”RļG}Ž´dūeWR56ŌzŌ€ZĩŽ˜´ßhšņ §šQGSpū ŲüײÕiĩX­đZl–ĘK} 3xAMK bŠ&ũc@  ֈˆŠŪŊmŪßęKŊ6 ÔZOŨ.”xøzÚÛd3ĪG Ōæā÷*áDDDVõĢnļūÃ|ŸSØô.ŸˇŪ*šy÷ [d1TËËër•­v}ō{Ģ…b]Õ_Nz[GˇÃxôÍĢR=ėŒĐTVøŪīĒŲ>Œdũ ŦŠŒ•–'ĩėxkšr>„úDD]uôtōÕÕĪBÃ$˛ČāÖ1€dšÄö䕋ô'Tũ;nvŽ›BhāĶwģü<˙ûZ°_'­å’—īĀģˇu•[úīp4NØiĒc¸ZĸŨ§ė´xķĢkįFŌ} õqöhÉ>ÁQöŗ{ö—{m•¨×öMKI Š ĐÍÉđ¸ú°áÍĪļ@ΞžcŊÖędļ8Ņ3vw*ËĻĨ¸äŌÃY1ķeÕÂ6‚î öåŒ~jīŌú§Mëk ¨ŌÚÅĸá––ļŠvË Ė>ísN˙ÂǍˆˆąEīĒۜ4Ūžn×ßw›LQjƒ3iÍžZĀÉ]éßõ˙ü\ā%•‚=Á ”DE᝝ĄĩQOsšÖAIIKĻžyä Ž(Ú2į9Į° ’V6Û~¨:|ŨíES¤ļ×vôõūņH×=ôTĩ?î9­?IĖĖÜŗ!eDDVÆânnßí.œ—WnV¯ļi˗Uy˙ mέ„˙t_õķۏ,įļ2˛Â""/âņiĶöēĢåöåMoˇĐÄéęjĒelqCF\įšØ {•öŋŠ}„Ū›­]‹kwVÁ¨Ž4-/š’’ŖũĐĀp^Ö¸ö˙ä܏Í@6õė&ūiŊėŋhíeĸĩËS×]ĻsfŽŽYūdé$%ŗDđ˜×į ƒīƒŒ)ņé_Hë]ĶĻŪčíŖGę;MŠžžŧI'7Fđ;Fį{–4ĩ„˙â˛ĸ""Â]ičy¸Ũ.îÛA3õ ÆÖ[M/ã%K#],-?kãkØŋ,{¨BéKd7ÃRu!ŖmZGH_í×K5ö–ŽļĒZI`mē(fkĨ|¯ pĄÃš'ōžŠ‘GoŒĻØn–šÛ-¨´UĒávąiēúŠ/T”LtŽˆĘÆj{–ˇŒ.ĮŅįöƒ<6ŖvčwžûšYn–­–k}\ÕPžĢĒ^ö:(Ø2Î.q#ęú{Š…DDE+ÛGŧũQŨ5ÕĘÃwēiģõ%#l•Ôôī–Ų-cé˛ĐCׇ쉯yįŨo7„ļÚî†ÜtŲTÍĮĸŽļÁ{ŊKqŗ[kXæK+ŖcKËŨ‚GĩÎãˇę[˛ˆˆŧ×8ję-ĩtô ™`‘ĘF|š HkŋÁÁ_6šķ`wæŅģw-žÔ}Š+5l÷9#āĘ)e}l¯âV<דČ?8ÁÉ+čgb4îŦŌ;-ĄôžģŦuVĄĩX(i.Ršüɨd-kÁwõF3īŒĢík¯ˆÜ]Ëé?[i=¯eD÷Šá‚gQĶgÍ­ĻŽVžhŠs~õcęúŲ}ëÔSči´Ž—ž[_§otõ÷Zéhä†:Xž ÂW893“8žî.ÆĐr""(ËņŸÚŨÕÕÖ}­4ĩĻåvŌÖ!W Ę (Ũ/ÂÔJXY;ØĐO֖ōÆ0qžöƒÕîŊ“\k-ÅēŲnv­UhmšŽĢ‰đ˛ēˇÎcÚck€įå°I—ÃĖÆ{•,ˆˆˆ ‹Äßg÷ŠŲՆŠÕwÍ9y¸Ųõ,°Īc¯†žIá}8‰Œ5Ā×0‚ =}ũT‘ø\íÆåíŸJļëNæPÖÛękî•Wuž°ÍIE gš‡ģ98=üOp핷HˆŠ‘Ģčn×M'{ļXjūįWnŠ‚Š|ãʝņ9ąŋ>Øqü/›šîŸwę ГlęvãRŋXķNi…Ž’I‹ŋîã¤ũ/38Į|¯Ŗļ´ßė;yĻ,zŽģã/Vû=-ÆŖ—/6Ĩĩ˛;>ųp'>ęäDDZąâ[ˇ{•šŊ'ę?ļÕuˇjékĢ-ô€™Ģhâ~dÜAâū#׆IôW°ũBk}đĄ~ŲZ¯V ģL5OĢŧK”đŅ5ĐHÎ/ye䆆ú÷Î;/Ą,s‘îšDDD\$“ęšDDD\Ā ”DD\b\ĸ"".03œ ũĢ”DDEĀd€}W(ˆˆ¸õėPĀ\ĸ""ā€}@+”DDEÆsŸĩrˆˆˆ¸@W(ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆŋË>yälqÆŌ÷Ŋį k@É$Ÿ@ĩj‡ÄΤ Žäŗl顊’¯ācē>…íļžlāP{q.íĖŽ?ž;­§kƒ€sH Œ‚=×(ˆŠØÜ­ËŅCĸî[ƒ¸—ú{5ŠÕ}MTŲ=ÉÃZ֌—šÄ€$•ˆēëŋ§.Ĩ55FŒÛSXÛä1:xč.tnĨ–Ļ6ũgE’Cđ;‘ž@wÆÂ"""ÄCõ]˛/Z¨.[ŗŠd¤šę÷6†‚ŽQWPŽOlcŅČˉ'Ŋ•OazŒÚnĨ4œšĮiĩĖŠ)ĻøzČ%‰ĐÔŌJFC%ŨÚHîp}‰ÂɈˆˆĩ¯yüCz_؍zíļÖúÂļKŨ9kkŖļĐ>Š”%ØÃfs{`‚Z2@õ >é-[ĻõۚļëyĻēŲnôíĒĸ­Ļ(æ‰ŪŽ˙áîAUtDEĶYYInŖžá_S=54nšiĨpk#Ŗ.s‰ė’V°i?Ū‘ĩžåCļ}PÚę睂¤¯¨ |Vú™‰âÖ˛gČöipŸ~ám*""+;vwsoļ?DWn&æęlö:-|Īis¤‘Ũ›lh.{Ü}Ā+tņÖīONŨĢ´öØęzŖy ‹ânšRZ‰!$`’ĐHÎFFBĪHˆˆ°¯Q=`l_KąÛ™ēږh+ŽĀž’ŨCLjj¤Œ8 q`=š8ŒžÃ8*čŲ úÚūĸt[5æÔę6]mži§ŽŒÅ=,Āc–7wc°Aû9…‘kęxôŠŗû‹6ØęŨkY%ŪŽVÁ_%ęičd'ģ%‘ŋÔßę #ßŋeąš~˙eÕV: K§.t÷]Ν•TutīŽx^2×´PAUDEäģŨ­– ]]ōõ_ ž‚ÔÕTÎđČቀšĪs`’ĩĢnŧHúOŨ ȃkôθĢeŌļ ŌĐTVÛ䧤Ŧ›8k#•Ūî?Wn}ŊBÚDDEmîV•¨×[wŠôU%ÁÔßŦõ–ØĒ›œÂéĄsûwė]•Ö˙¯jˇ%›y.ŌŨ)‡Æ|<—§ōÆEËŧâŖ75™ Č8ëÜøZá—ŅgPzG¨›víîˆēč똧Ēų¤F ĢϚDؙúEŖŸ"â1ô@îJ˜4DDQOâ¯ŅŪúîVīÛw‹ltĮWZĒí0ZęhíĖķj(e‰Ī ųcšcÃķÉŖąÎq؜×áEĶ&éėŨęģöęÚå˛VjúēY)lķŸ÷éၯd­ s˟WÔŒã8[ڈˆŠ:‹đųęĻמú–—OmëU[¯—ššëuâß– ĸžg=ĻWį8rÃņŒéŨLOI;K¨67§MĩÚĒš•W{%ŋkŖ6G,’:GD×{ĩ…ü÷â˛ō""ÆMí}įz6 \ívž¸ļ†į¨mŌŌL÷ŗÍėæąäz5ÅŧOäâĄgf<;ú¯Ŋo=“O^öÂ÷Ļ(í×Xf¯ŊÕ°GMMR‡:Hå;膓nę|ØŪ k9qdú•úDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDZš^0 7>¯@Pé-C¨mļĘŗE]|Ą|BöģŒ†(ÜyJ֐{åšĮlöÎėčŨ_§ĩū”´ëm'rŽžÍ{¤ŽēŠĻ?Ib{Aiü~ãØä*Ę""ˇw_é]ŦŅ7ÃÖ×6ĐXė4¯ŦŦœ´¸ĩöhÜâp¤€´įf<[ļ3v÷J‡mjô•˙L2ķT(­wJų"|3Lįb6ĘÖÅĖā—HUŊˆˆ°§UXmŋIzŸWëÆVWTÜįu-ŽÕBj+%h˰\@cäãé0IY}"uûĩ]\×ÜôŨ‚Īr͚’×Åē×p{$3Ķr 2E#;;‰ 8ČõÖĪĸ""ÔnŦ—=$Œ…šzsę#oúœÛZ]ËÛÉĒI$ŽĨĢŖĒhmEK.Š@ Á …”sXŌ÷¸5­$œ„jŋΟtÖæThšm%¨îļ::ÃGQ¨iŒ^VZî/’8Iį$`ƒƒHîĸŪ›öŅĒ,vũI`ފļŲuĨОŽĻ#–M cĮäA{ŅŖģĨŖļWoo[›¯ŽŽÉb§ķęÆķ{É!­ū§šÄ4´­Ré÷ÅkewÛthļļm%}Ōĩw™žŅW_,RÃU1ú‘?ĖNwŖsI=ÂŨ´DDXĢ>ąļΤM1oŧëjjÛĨÎõ#ãļZ(8‰Ē8c›Üį1äܸįšŠ!õŅĩŨ_AuĸŌöۅ‡PYXŲĒí1ī08ņFöv{s€{ Á[ ˆˆ‹N:ĸņ:Ųîš7 Ûc&™ŧjËåûŖmōĮT%ā9ą—ŋëIĂZFN{-…ØmķĐ}Eí­ˇtvî˛im•åŅI ė ž–vI ­€æœz ƒ‚˛""ęĒǧĄĨšļ˛vCāŨ3lЉÕNo:A’÷ė œâ°ĀWę""ÆLėÃzƒØÍ[´_5ųl×ú15Yisbž7ļH‹€î[͍Į|ĸÛ§ß žĸmûŲbšîŒV{.—Ķ×HnÔ×TIXØdk!c~æZ^€IÆ{)˜DDEĻū$ũëĢ´.ŦۊúFę]!QQ$5’ųQVÃ;X$`öcÁ„gąî Ģxkø|î¯O›‰qŪå46ÚæÛĨĩÛ-Tĩm¨ûŽi’i^˰ 3 h$÷$ãä}Zø‚ømoFīo…vōl´T¨5$p|ÆßS\ĘiŠ*"‰ąōi†ē75=ŽAĪlamg‡ßJwž”6^}/ĢîtÕz’˙puÖæÚW—ÁLî c!cˆ¸ĩŊŨŽäœvlō""ķÜ(ĄšĐTÛjyy5pž 8œ.iÛąP§Ģŧ:—ƒsęl:RKv“ž´škü÷ĮåS9ŲXOûœÚßPĐA#ąîĻ#iļú‹j6ËKm­ēŽJĒ}3iĻļ2y>´žTaĨä{d‚qí•v"",7ÕŪÁŋŠm„Ô{MKueļžāØĒmõ2gËeT/F$ŋG@sėŖĨ/ ž 4ŪüiŨcģĐZŦzwIÜáē9ô×TË_$Ž8„g-isZKĮ ĪlŠ„DDEŖŪ&kŽŠ­ZgVímUšK2zg[k'˛˛šR×} Ņls}@ úŒwļŧ3ē ÜΚĩ ŨۚŠŠītˇüĸŠĶIRڃ&FHųe‘ŋG$ÆĀÖ´žŲ$û)DDEũuxeožåoŨīv6juöÛĢĻe]]5MttĶPÔpk^?Ü >3Į äd‚;dîĪB3Ũ:VØzMŊÔWh.ĘÚéŽ×GS`ŠyZÆųQ’pkch偓“čļSu-Š—TiËŽšŽ{ŲOvĸž†g0áÍdą–8Ī**ŧzœfäģLŌO`“Jšž,Ôn¯hhĨĪ×4˙÷|Î?Ō3ũXîĻwCiJ- ĸė:&Û4’ŌX-´ÖČd“ëŊÆØÃæCr̈ˆ‹uąĶgT{uÛ+=Úuáĩ\­“OŸ$ÔÂN&;†šŽssƒ‚AĮeũ1xIīWũJeÛ}…ĶvØæíEpŽĻϞGFæ0Gå’Đ\Kˆ8Į~ĶˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆŠē—QZtŽējĢõOÃÛlôsWÕˌđ†&ŊØ÷ÃZT`ĐxÛ ˇ%´ĩû7 :õžWÅ6ŊΚGNNŸōÉéíËŨJ5˛ãGxļŌ]íĶ Š+ ŽĻ ėøŪĐæŸō^¤DE‡:ŽęONt­´ÛŖļMt”OļßøĒš,ayƒ@kœãƒŲ§œ-YčīÅ[˙¨=ÚŖÚMÄÛĘ-9Y}æË5eēŠķDųÚŌ˙&Vŧd5§ g*BQiĮ^ ô]!×ŲtnŅņjMWxĻųƒĸĒĐŌŌRs,kœZ99Îs\F0I>\] uÃhëN^™WĻ›§uN›tFáCÆh%†\đš'2×4´÷į+iQFˇR>/ŽÚâģížÜmĄˇiēĮÛî7 úįÄ抈ŨÆVÂÖÖ¸‡;9#8ÂŪ^Ÿ÷ŗLu´ļ ÛŌqKOE{…ÅôŗdĨŽ,–ؖš¤dzŒu‘^ë[ÛčĢæžÕ NŸ šãXöŒ¸E ˆܜ`rBã]ķ]ÍĨļj­ŸĻļčēĘÁOņ\%u,.v+Ú[ÁøÎ\ŅŽŲÁ>ō‘ņTÃM<’)ZĮ´ösHČ#ü.ÄDE‚ēÄęĢOt‘ĩ?ëû­žKÍĘž­ļëEĩ’ųbĸ ´¸—ŋ‹֒Húęĩûĸæu3šƒi5恤Ķw›„2Īh¨ˇÔžh* L/|OšîÎ;v[눈‹IzęņĻé?UÛļßHčĒ}KŠęip­5ŗēj8HŒ}Éīwp0ĮŽp˛GDeŲzÃĐw+ĐĶÆÁ¨tõDt×k{e2Ä<ĀLrÄō,w Z}{˛HˆˆŖ#{üd ˇrëĸļûj¨¯ē~Ã^û}U}mtÍVøž[+ĄkZCCKŗœgHĖîžšß ¯Ķģ̤|ÖÚõjĸŽ`ģ%¯‰øíɯkšqÛ˛ŊŠēۓ§v{nuįjĮČÛNœ ’ē¤D2÷†ŽĖh÷sœCGæBŽŠņŸ˙UîĩģLëÍĻŖ˛é[Ŋs(Ŗ¯Ĩ¸>Zš1#ÃY$­sC^Ņ‘ËŽ02Fqƒ(‡æAî\ĸ""Ĩj­7jÖZfí¤o°™­×Ē)íõqƒ‚čeacĀ>Į*+č<õ{”Ī˜îũ˛MƝ1Ύ–As’Ÿ–|Ž8ōÚō;säGŋe+V›e’ÕGfˇEåŌPSĮK3ž1ąĄ­ü€ ֈˆ°¯W}4Yē­ŲĘŨ°š^d´UļĻ;˛āØüÁOWpi{290ĩîiČî§ôcáW{Ø]āĄŨŨŌ×v›ÄúxÉ%ž‚Ķŧ îi`šWČ~ˆqÃ=đIíƒ#Hˆˆ´¯¯īyúˇšŲuŪ‹Õ´v-Wg¤ųl¸1îĨŦĨæį´Ā\ĮĩĪ~ė`rtĐÜéëå]ķSA~Õz˜ÂÚęŠXÜĘjx"äY AßIŨÜIq=ģ wÛDDQ‡Ôˇ„˙s7šņ¸{Y¸ļkMŸS×>ã_Ct†S%ō;”Ļ"FāĶČã$w[åĶĻĮiîœļ{Oí›Ē’˛žÍŒÕ’´5õU8žYH™sްĀöY)[ģ‰Ąl[Ą/ûyŠĸt–­EožŨVpáŦ-%§ŲÃ9˜ 0to‚–Ąˇî…5V¯Ũ‹Mf†ŖŦlå´´Ō6áW \‰Ípōã.‹ƒŽø W)Šá¤§Š’š1PąąÆÆú5 `ūb""Ā]htŖięįiÛĄ*/Ÿ%ģÛ+ÆŅp1™áŽilŒĮ5ÄwˆôÁ×^†ü0nũ7î“7suĩ˛ķuĩÃ4z+S$ōbtŦ,|Ō>@ŌO8¤I'°Rˆˆ‹Eú÷đá­ęĢWÛˇ?oõ…RÁFËut&HiĒáa&7‡01íäGÕ ŒzcžLčOŖNtÚŲ]Š}Ԛ’ĸ*‹Ĩ\1˜éØ#iÃ]܆ķy.8$ģĐŲÄDDQiž> ڇZo×WmŽįYíšgP\$¸TRÜ •Õ4.•åō6>ļVåÎã’ĶŒöŠŲ ¤Ķûĩ:oiôÄŌĪA§hÅ3g›ŗį’é%psÜį`zg ųDDV†î펟ŪmŗÔ{[Ē ­ļjJ (g’,y‘rîŲŸękƒ\?0ŖkiüuœŨ›}÷q7BĪrŅöŠæV6ž‚žVÕ×ļ7‡29‡Ā!Îí>Õ*mhkCZ`ėšDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDPĪē1{ņ˙UkĒ6ÖΧ¨´mžĩđŌÛë¨LŗV@Įcœ˛ōkœpĖqÎ;áJöÆîöí“Ũ{m č ÔÖØĢžį&žĪf}đđā¸WŌ""ÆŊGī5'Oģ'ǎzŽÖë—ú~ŒK w<ī{c‰ĨŪÍ/{r~Ė¨ÃØ]öŧoM’ËēļËÃJęœ6ų)č(|‰¨Ō1ņŋ‘/â\2œŒ÷L2""-Aņë3Rt•Ąlč+EV¨ÕĩÅIQ]’žŽ ’9ŧ™ ĮrNq…Šü8ŧCˇ¨í{qÚ á ˇOvų.vËĨž›áųļ2Ņ$RÆáĀĩÄčT‰"""Œ>ŋēeņxŨzŨĮe“(-7M;qŽbŲí”?QE#csŲ€ a-âA=•ąÕOGÛCfëZĪ llģÛlzʲ*ĘÚZz˜ĀĶ8—ļQž Îp,gˇ˛˜=ĸôæÜčû6ƒŌ6öĐŲl4qPP̓žFÜ “ę}É÷$•\DDVžįíŪ•ŨŋžíÎļˇüe’ũFúZ¸ƒ¸ģ‰î×KšāąD¯Bũ&íEëĢģŨŽúۭƏoęäŽĩĶÔTFY,ĐËūҜ61ΉØA#žGe2Hˆˆĩ[Äsc4đtķtŧęÚjĻÜtkr´ÕŌĘ$RöĩÁĖpÆ[éBž{ˇēsF]÷ǚšŽ§TWË% OS+\Ęz`CœØš8—ŪD’Nė2¤Q[øētķˇNŊiũæĨ‚ē“QßĨmļâč&h†Ĩ‘4HæŸ÷p܂2Č8ĘŨnŒöKBl^Âiũ;Ą)jÖ]ëĒ*¤OSU+Éīpv­ķ+9""/Ė‘˛V:)Į‚×4Œ‚¨*7Ŗ-› ëēß´Á{ŖĶ†ļ*ŠéaĢ`0‰I{ĸ‰Æ2ZĖöäīčĻOMiÛ6ĶÖŨ+§hcĸĩÚ)"ĄŖ§ęÅ m cGö*’""ą÷ˇk4vômnĄÛ}yBúĢ5Ū‘Í™ąŋ„‘šŸM’1Ø<^×5¤ãЎĘ-|7:_Û ĮRwëÕé—;„›yRjŦņO;<¯=’–˛YCX9š¸ĀäÁSˆˆ‹N|Ov#@nŽÁÔëIKUķE‡OkŦĨ‘Ŧxl…Ąņ?-ptg 8ėAw͟á5°›}ĸvǎwmtõsęmI#č*jjekÄTҏM Av ŗ’KG| -öDDEž+ũ8mŊåiũŅļC_EyÖS.⠘!™Ņ†°JXH´Npp3’¤'ĨŊ™Đû˛ZwCč9âĄu;kį–ĸA$õ34:I$p{Ā–YDD]5”tˇ Ič+`dôõ1ēĸxË^Į 9¤{‚ ī=ėÄ]{GąĐüō=%QZ'4­Ŧg6°ũ?$?ËȏÛūXūŦ÷SAjĩÛė–ĘK5Ē–:Z*#ĻĻ‚1†Åցö^¤DEzŒÚ ž{9¨ö÷_QM=ŽĻ•Õ-tysA<@ž9cq5ÃÜ‚AŊ,m&ŽŨ=YŠõmē˛ķ.‘2SÛéjåa§>g(ËäcZ œN;€3œg˙Ųkim-api-2.3.0-git/docs/src/asymptote-figures/square-lattice-configuration-1.pdf000066400000000000000000000220061421473465500274660ustar00rootroot00000000000000%PDF-1.4 %Įėĸ 5 0 obj <> stream xœŨËŽ,ˇ †÷ũŗŒ.×ũ˛ đ.Îė‚Ŧ&°ƒ ÄČ"¯UéŋPė7Œ>bSyŠœæ§QËŋŒÃô1Ūđúõũúé—ããˇ˙žÆß^×6ŒĶt|ŦįplĮųņ-ÉąË8žzm4—Kã¯×ŧ ķ4Z2›fŨ§íĸYFÔÖ+5–ú÷¯Wœ+›i Ûüõĩ×uëĮ˙^ĶĮĪåŋ•ČūÜAd˙|ũõĩŽëpĪ_ļs˜ĪŠD!Éš į|ę5krüõZ–y8– 1ÍÃ8ļĀ1f–”`Ļ^“&ĮeF˛ĨĩōÚZã׎cģŸŸįžÃYž¯ķoŋ–a؜IĮ´ãž+W8vūQrį g?‡íšû:ķ­…Yû< ÛæäØyH‰<ƒ…ėûũ´úŠ'ÖÖuÃ˛ė!˙Ļqœ‡Ķų7Å‡ÍO˜cįŸ4#˛€1×pū]Û4×ĸ,ē–iĪYkpėüŖD~ÃBŽ#ÖVąÅښæsÎ=äâtģ°NĘÅiY–aš•3;)š3ŽŗŸŋÃvÍÅiŪ§a™•‹ĶŧŽÃ>Ų.ÆÎEJėkĩ}ĩÕG<ąļĻíڇåŠųwéĩ:˙î"Ũ7įÆ!˙¨ÁüŖŽą†ķoڎq8Wåß´mĨũYŊÆÎ?JėwĩãˆĩÕ_lMm]ã6\sĖÅģH×Ũšxmķ0ÎŒC.Bōdf×ŋWÛČÅķ‡ÅĐtn×>?8š‰<ƒ…ė{S[]Äkkž§mXˇķ]Ŗ—û§ųŽQˇ4:ûø>RKĶ5Ž 8ųæéŧw>ķ´_ÃäĪŽ{”ČÃj ‡ËḚ̄bEÍÛ\På8ߕšÍfŠí˜†y15`ė ¤äá ĖŽ¯ļA"ëu ëbYbҟ"DžÁBö=VTņÜO¨éXV¤D%ēÔÜIšk¯éŲ‹æŪÔ|G‰ú[Xˆp寨#ĢwNŊt$âžâšŸPîRŋ-Q[ģŌÜ1šŸžōt•Ē+M=¨9Nöఐ;_ŗbîåeîĨ÷[Ŧ-sŖ$ČņcŌ472“¤L“ŽÅw’€i!kš!ŗ-­ ŲģXgũÅkÎ I 3Á¯­Ļ’Y% dgrlž“H YĶ ™mi-XČŪŚë/ļXsæII@„ĖŌ"Ÿŧy’Y% äŽ,p,îŗ¤’Ą,€ĩ†ØR^@bŋĢ…GŦšūb‹5gļ”d¨ŧ9*/ŖĘKj0w`AcqŸ%• eä¨5Ėōû]-ä8bÍõ[SsâLK*)*#@‘ĘqϞŠĖ:ZИ<( ˆQ@”ZCĖ)/ ‘—°ãhjŽģØbÍ<-ŠäȌX2ežĖ)ž”ãt‰…’TnÔ|`ĨxĘHäa5CˆåÖUXąŌ˟–T‚_€.EâOą 5Č.´ 19Q¤,€4ĩ†XT^@"/a!Į+­ŋ؞J‹ģ×—Râũíú œw•ÍĨīûÎø|MûÔæGJŧ׍Ŋī°+^š´Ų/į>zÚWœŨW<ĪJ;ÖߖhOģ~ŌæŨcŗčûū2v¨Ķ~´9Qíic;í‚Íûäô2īĢGÎî6ļX[fQIÔãwIŠķ4‹ž÷ĻčnS/kN”$Šū8uĐfҎ›^ŌBŠ#ÖYąÅš , ‰ûaöĮmįi}īMŲģļŊŦ9Q’$ûãÔAÍ=6ũĻ…GŦšūb‹5g•™ā×VĶ,ĘŦ˛FÍ:ÍäXœh fęĩÕ4‹žŲŌZymsvŋąÅš ,J ķQ¯­ĻYTy) ä%gr,N´3õÚjÍļ´V^;pvˇą55'ĩ¤’¤2¤Šœ‹*7¤ÜĄÉ‰’€$e¤Š5Äĸō‚ô’RMÍu[Ŧš¤’H‘N>x)3Cī×ÄŅt‰‹’€'9Ÿ¸É ¤ô€ôRąÜē +VšYԒJ’⠐ĻčC,*6‘؅4&'J’”ĻÖ‹Ę jĐKZHqÄJë/ļįÉœ,•K!ņY—úĶ Ÿ0 \šĪ pO-Y \ ‰ĪŊāL8!.mÎÎāLM:cĶpvWņÜO(aų–@G\jíį%&Ņ|ä„gVŌ Cĸ$:åRŊ¤S1æĐ÷s3ÕÅtĘ&vQÅz üI‰öŊq–,í0ūĖ{ĐÜÅN{ց?)!=r<í”ū|ÛK‡—´âˆĩÕ_lĄÎŒŸüŒÕÖ7ˇÂ۝fĶgۊÖNuģsm0”čČÍđ´[nö|ßO¯>s~B¨ŗŽĸŠu˜“õŊėƒÛ30gîAÕŖĻžÕĖ) û^öÁm§˜ķ­—Ļßš÷<ŨmlĄÎŒœ¨õe+Üvš&Î܊ĒSMĢ`Đvŋh†ÛnŲŧųŪOÃįÔ}›¤{ŒĒŠ3sĻ$xúzm5g2“¨ÁLãLÅ™”pĻ^[ÍĀ™oļ¸VZ;2tˇą…:3kJPŗĀ¯žPéġ‘lšĨ19PĖãKĢgĐ|ˇ„…še=wPŦŽĀ–’€ É $GŌ„Ų’ŦA ˛-h,滑dH $GŽaļ¤Ō€—´âˆÕÕ_lOuÅķęgRâíÕĮ|Ž<|g8Ÿ4įoČĶÉôđŨaH|ē§ŨÃ9øĘ™í yœœO'é#7÷Īķ„î'ÄßáJBD<÷q͔ķšŦCƒ˜įxWP8Îb+⨌I „u‰Ā˜đÁ đQÚ(žgÕidąŽĖ˜’č4 ž9’΍„īį“%<›’Nĸ„īSÂīķtK:˙bÆ|?!/i!ÅkŦŋØbŊԄD¨ˆŒJ֔ ¨‰œ’rN0ŦI Y„’u‰ĀšđÁ đZÚ(bŊõYŦ7ŗĻ$ÚÕæ.wģžOœw˜ĩv¤ũŊbI¸ĢÍ]îvÜŦųžSNŋķÎē9ēߨbŊ䤄ČČŦ$R"+œĖJ*0+i€c3§$`FZ Rb 3'}Ŋρ6ŠXoŊEÖԛ˜ĶvÃėŽÛž3|Į8wĻę\s'ĢīSĸn˜ŨqÛ?›9ß;lvāŠ#<ŨoląŪJđCFõjƘ?‘Q| §Ų @)Ar>ųö  \_ đķÛbŠuTŦ2ŗ§%āŊļšá{ĮdjU8Sc}˙˜ÎÔkĢiö|ˇÅĩŌځĢûí~rK)ēaŽŋŋĨ„šÜ‰°™;—i-­đ8t™ĻsX}[×2^Įpø6/ŽÍ‹”(ia~ˆĻÚ¯ĘÕë;Õ3Īj}ŋŸV_ņiŋr)W¯īTĪ8+û~?­žâyžĐũä¯x•—$ É­´™DšÛ2ÃįģÍį6Lū˙%oķž>;Š´Āą8Q$-4š†Y”^X^ŌBŠãyZŨÆkË,* H’Ų@ŌdŽE&‰E‘ibQŽÍĸ”$a¤É5ĖĸôÂđrąÎú‹-֜Y”’$3‚¤Éœ1‹2̤Ŧ“ŒÍ‰’€$i¤É5ĖĸôÂđ›Rąæú‹-֜YT$3‚¤Éœ ,ŠŦ‹"ëÄĸ›E%IŌHSkˆEå…4čwĩãˆ5×_ląæĖĸ’€$•— MåĨXTyI æ%-p,N´¤’¤,€4ĩ†XT^Hƒ~ÃBŠ#Ö\ą55'ĩ¤’¤2¤Šœ1‹2ĢČĸĖ:˛¨ÆbQJH’´ŌÔbQy! x 9ŽĻæē‹-֜Ô’J”Ė'SF@ƜâûH9Mט¸(IåIÍnjŠ<<„B,ˇŽÂŠ•fĩ¤’¤ø¤)ú0‹’MČĸd˛¨ÆbQJH’´ŌÔbQy! x 9ŽXiũÅö<š{ãĨÁŌ*•Ūû4‡)tÛįą^OC*Ũļkü5æm;–;ecÃ#%ÂËjā!OX“bíúÎã–æ´n?ĪŠ“HÂS öÄ0XÍ W¤Oe€cá…$j@|‚ÁĀkT9ŋ !<ĄŽĸ O+´ŋ°û…MuŋXÕŨ/ܒŧ–ŽÕ˜Z‚ÖØŲr÷žôAđķÛÂĶę*Ēø´Ü8Q€ž‰6Ų7qUõMt‹ ôš4fK# ›`OÄÜ5ŅiT9ŋ !>­žĸ O+|øR€Ī^ūdåg/îęŗ—?”ŠĀŸŲ4 1?%á' đs•+ø“—>HŖēČųmáiuÕķû–ûSėŪËߏk8Öûî×ō0Įûü#މ> /Contents 5 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ 4 0 R ] /Count 1 >> endobj 1 0 obj <> endobj 7 0 obj <>endobj 12 0 obj <> endobj 13 0 obj <> endobj 10 0 obj <> endobj 8 0 obj <> endobj 11 0 obj <> endobj 14 0 obj <>stream xœŠVūCMMI8%øøøsûVøœøM‹ ‹ Šø÷[÷X÷Uns‚Copyright (c) 1997, 2009 American Mathematical Society (), with Reserved Font Name CMMI8.CMMI8Computer ModernpQŊøˆøĒûVŦ÷+§ø§øNŲŋû ƒk‰ƒc‹}‹x‚”†•‹ŽÕ‹Ķ‹ ˆ’‹Ŋ #š‹ž™}‹[‹‘”’ŌŠ÷ ˜tĒgÁ‹÷÷÷"÷%îKĖ;O[bmnvŌH‹‹g‹rt{lt^€X‹ˆ‚’‡“˜ŒĨ’˜žÄ´‹¤’ts‡s‰ƒĶ{œ‹šą¸ļĸ¯‹ŊžZ^fu mPqU[_\‹G{Ų’–ŒŽv øC•––÷p û`•Ģ Ų  7Ÿ § ūš§ī endstream endobj 9 0 obj <> endobj 15 0 obj <>stream xœcd`ab`dddwöõõ441U~H3ūaú!ËÜŨũĶã§k7s7ËĘÂBßcŋGņ``fdĖ/mqÎ/¨,ĘLĪ(QĐHÖT0´´4×Q020°TpĖM-ĘLNĖSđM,ÉHÍM,rr‚ķ“3SK*4l2JJ ŦôõËËËõs‹õō‹Ōí4uĘ3K2‚R‹S‹ĘRSÜōķJüsS n̓PÎųšĨ%ŠE žų)ŠEy Œ! Ļ LŒŒ,tđũ¸ØŊâ'ÃZÆÅ? ˜˜ūø&:qqī”Yũ“{×t/čæxŋĢŨļĻ=ĩ5MžĢžĩŊŋuâÔî ŗûäV|wíŌŨÛŨ'9­ĩģ\îĪvļ’ÖJŋß] Ũ]mũm'÷öĪč—ÛúwÁáī’ŨįØOínččîlĢ”˙-õgmcJgŖbˇdQKwEã´î K–öv/‘˙nĀļ¤{Yį’nŽiSģįMmé.4ėž2̧{R˙lyž˛?œ§N›öŊ`Ûī„Šė šÎpËqą˜Īįá\8‰‡‡xqĸ§ endstream endobj 16 0 obj <>stream 2018-01-06T12:22:25-06:00 2018-01-06T12:22:25-06:00 dvips(k) 5.997 Copyright 2017 Radical Eye Software square-lattice-configuration-1_.dvi endstream endobj 2 0 obj <>endobj xref 0 17 0000000000 65535 f 0000005068 00000 n 0000008499 00000 n 0000005009 00000 n 0000004852 00000 n 0000000015 00000 n 0000004832 00000 n 0000005133 00000 n 0000005401 00000 n 0000006304 00000 n 0000005245 00000 n 0000005554 00000 n 0000005174 00000 n 0000005204 00000 n 0000005784 00000 n 0000006513 00000 n 0000007019 00000 n trailer << /Size 17 /Root 1 0 R /Info 2 0 R /ID [] >> startxref 8729 %%EOF kim-api-2.3.0-git/docs/src/asymptote-figures/square-lattice-configuration-2.jpg000066400000000000000000000522451421473465500275060ustar00rootroot00000000000000˙Ø˙āJFIF˙ÛC       ˙Ā k7˙Ä  ˙ÄF!1AQ "SaŅ2BUq‘“#b3CĄRr‚ą4s’ĸ5TÁÂŌ˙Ú?ښ""""""""""""""""/:ũo­ē[_CAušÚų^Îz˜9{VF š Ä7 ížëhŗōlĸÉKŸ\ŗ›¤Ô5ˇ›¤´t•ŗ–Ø%–V˜ ;1’ķoŋŊâ`DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDT—Kt7k|öډĒ"ŽĄ…u<Ί@“ÚC‡čV5ŋhMĢÁņį g§Ēƒyf}ELLu9‚&DdÜôkŪy‹ŊŌÖŠĘ4đ2šž*hšš"cXŪc𨠆ä÷ŽÄDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDTw œöĩŽ–ĸ]Ä03Ģä?!ā<Éč=Ŋ4ŒķvÜģ|÷Ųvļ˙b{y…æ‹oœíūÕS*ŠdŅÔÄāá¸!āîžļĸ}™Ŗ?“‚ûÚÅņû§kÄoîŦ_ŋēvą|FūéÚÅņû§kÄoîŦ_ŋēvą|FūéÚÅņû§kÄoîŦ_ŋēvą|FūéÚÅņû§kÄoîŦ_ŋēvą|FūéÚÅņû§kÄoîŦ_ŋēvą|FūéÚÅņû§kÄoîžvđīËÛ3.`š‚7iō_QQW]Ѝdm9lŗÔ›ø›ôOf[Ļū&ũŲ–ßÃéŋ‰ŋDöeˇđúoâoŅ=™mü>›ø›ôOf[Ļū&ũŲ–ßÃéŋ‰ŋDöeˇđúoâoŅ=™mü>›ø›ôOf[Ļū&ũŲ–ßÃéŋ‰ŋDöeˇđúoâoŅ=™mü>›ø›ôOf[Ļū&ũŲ–ßÃéŋ‰ŋDöeˇđúoâoŅ=™mü>›ø›ôOf[Ļū&ũŲ–ßÃéŋ‰ŋDöeˇđúoâoŅ=™mü>›ø›ô]nąŲ]'lëE“n^Wg6Ū[ėē†3€Û=+@î ŒūÉūĩˇcj #ģąĒ•€~@;oö_=‘[Ŗ~ŦfŨ͜6fūģŽoūKáĒžPõŦĸŠļ/)7kĀķ1¸õũOÉVŅWŌÜ!íŠ%æō¸Zæ;ÉÍ=Z~ET* ĩdôņGMDĢĢwe #vŗĻåįäĐ ÛÄė[5‚7×WĪjˇĩõŅrWLč ņ´´ŽÛŪhôvā ÕŗdŌėbŨ’M•AŒšw[) ˆEMBČĄ{Ųą§”ŸëLCļv‡e{"""""""""""""""""âö6F–=ĄÍp؂7y/ *YĄĸŠ76GO.Ā{ÉõØĒ|ŗāhmÖ÷IQSęđASY)&JŽÉœ­'ryGWŅĐ2UΈˆˆˆˆˆˆˆˆˆˆˆˆˆˆēįžh=DŦŠ6 Ü÷€2ŧŸęäNh|ŠÖ1WUy^ņ^ŽōÛŋëD¸ëœÖÂųmdķ7:—Ėr÷˜˙.­ōÛģՆxjblôō˛HŪ7kØw|ŠėDDDDDDDDDDDDDDDDTĩ÷*[sgs$‡–(ŖŌH|šßû—ž,ĪģsÕŪŲË)SÄĮīęŖpCšáūĻāīĻûöĶÜåŖ•–ûÖŅĘãÉNÛE?—ü¯ūĶúnŊTDDDDDDDD]rĪ /šfFĐ7%ÎúĒäxünå}ęˆũvũWÁ’Y#bŽ­Ōũ’Č^æŸú€Ûũ×(/öēã ŌĶąŪžA×õjíöŊÄņ?čž× øū'ũÚô˙Ä˙ĸ{^ƒâ?øŸô]sß­”ņö˛Í(nût‚CūÁ̍dևĮÚÆú—ˇ›—Ũ¤˜˙.]˙UÍ×Ú`K[Crqm… ŊRŨŧ<×Áv­“˙/`Ž'ģy`~îßö|ß$Š?f‚…Ÿ2éß˙ōûŽQXЌŦЏK-|ė<Í}A­>m`Ų­üößæŊ$^dļa+ĒmĶKoĮ™Î§ 5įÍĖ;ĩߞÛü×ōZnöĐסä]N˙˙°Ų}öÅt{ ŒvŊ§ģxŨƒũŸžß˜ “oÔĆē†äŌzlheéú†íūëÉ­ ‹ļ‘õ,o7/ŊI0;ū\ģŽØ/ÖʈûXĻ”ˇ}ēÁ ˙bÕŲízˆ˙âŅ=¯AņüOú'ĩč>#˙‰˙DöŊÄņ?čē§ŋÚéƒLĶJŽÃjy_Ņ̃˛[+$tRUē2Ī´d…íh˙¨ŋŨsfCaō˛ķDOūģ~Ēļ)ᝡđĖÉFāĩĀ‚?E؈ˆˆˆŠĒ.6úMŊjēžûģIZŨ˙rŠĸų;6ņJ÷ÂɉũUĮüOfėŨ/o7+]ĘOĒËßųrǁxˇ¸ d؍Įô_ô_}¯AņüOú'ĩč>#˙‰˙EOQ’Yéœ4ķFũ)Ĩwũšž˙ˆmÅܑļ˛BYÎ9(ævãôoËŊ ú3ūM˛į)ōgûŋ”/žĶģK˙–ĮĻnũ؞8Æßô—ö_=W ĢéSq§Ŗaīm,|īÛūwô˙āĒ(m÷ēh".ãgĪ#‹åpųšÛž]ĘĩuÍ51: ˆ™,o9h-pų‚ŧŅe¨Ŗ˙ė×9i˜?ИvŅ~€æūAĀ|—!SAŌ{e5Hzž~RéxÛ˙’{nVĒ,W(ļī"6ČūĮ˙EõŲ d’šâƏPM˙ų\eÉėи2Yį ŊVSßų5T Ŋö¯ūũßkĐ|G˙ū‰ízˆ˙âŅu; ĩ6qNf—´#}Ŋ^Mļüųv\“Øž9plC}™Ž‹˜5ÛūĮ9ÚÅŽûl'n˙÷UÍs^7k`¯¨ˆŧÉîĶÍ;čėÔ­Ē–3´’Ŋü°Ä|‹€$ģû@üČ\}WSī\ī2oß9ė#!ËīŸÕ˲zĮ ƒÛjĻsÚw’0÷īįĖíĪûĒčâŽ&ōEXß&‚戈ˆˆˆˆˆˆˆˆˆˆ‹Œ‘G+y%¯o“†áPKXæ%ÎĩS5äīĪŋüÍØŽŗgĢĨ÷­wŠ˜ööņŸ‘æ÷ĮčåĘ ŦņNĘ;Å3ieōÅ#Í §Č;`Cŋ´Ëuéĸ"ꨨ‚’ÔÔĘØĸŒnį8ėķ…Eęį֎&[éŨ,íæ™ÃĖGÜßú‰>m\ŋÃԒõ¯ĒŦŽ>SÎyö7f˙˛Š‚ŅjĻßÕ­”ąŪY F˙°Uhˆˆˆˆˆˆˆˆˆˆ‹ĒjjjĩEQtË- ŗžëIYqĪ=‘É Ž÷‹$îq;ģĘڂ""-.zGøÍâÛÄŽAĻx~w|ÃŦ„°SŌĶÚęJú§˜™!¨‘íŲĪÜģŨō€Nōg¯ŖO^ĩˆ.âÉu6 ×^l÷j‹9š9Ž¯Š6FöĘũ€ã´å$w–īßē•Čˆ‹ËĘ.ĶX1›ŊöšÕKnĄ¨ĢŽß+ŖÎ éæFßĒüũWúBxˇŠÔĮęS5~õOP*ĖĖ´˛R-Ŧ›~ÃÕžÁfŪīQšīß~Ģ~ēk”VfúwŒfW q ĒžŲčî3R˙ĸųĄkÜÎŊzŽDDEøíËŗâŌíÆ3œ>—U2ÆXnų,œô´b>wEŸrI~Č?§‰X—Zô:ÁĀÅVŦē—äÔU5YMģŊc×ĖÕ°dtõOä~ņČOõ›önĀw€ķw.ņš:1™ÜĩHđĖöņAęUų ŠŠåSO˰ŽYakÜđ“ˇÉ^hˆŠ"q‘rÉsŨfŌiķ[Ž‹ęî5ˇëēsOU]$aÍ Š_ēd$īˇR6īî8w_ąHũų>¨<;äŲ­ųMEUĸí…Ũ.“WÁ]ÉLųW‘ÅÍ{ŅĖAûøˆÔG_ 癍ōj†Q§×j™ũfļjŲ`¤­—}Ë兄IīÛnoԌļÛ¨,öúkMĒŽJ*(YOOO #Š6Æ´tTĸ"/>˙`˛åVJėo#ĩĶ\­w:wŌÖRT0>)âxŲĖsOx Ŧ¤ŪŽ4[PĻa8ŊÁ#ĨĄumtĩ1P<īī@Į’v$w#Ā…#ŅcímĐ],â8FŦbņ^-͔OšŨôŗˇi!Ėvχb:W‡Ãī š%Ã˛ēƒI1OPšæZkkęguE]@oŲk¤wPŅšŲŖaŋ]ˇYu×Ū8tâRũI”ęv,ˇĒV6p Ģ},ķÄßŗĨ‡g´xn7Ā…•tīNp'ÃíøžcÔļ[­…”Ô”āōˇsģœIܹĒK‰$“ÔĢ‘| ą‚Ŗ%oŖ{„*ũK:ĨQĻ öƒę}uô Ģ•ļįĪÍĖ^iåęîĨŋgûTšcLkĀÖ´lĀÉXZŲĸ:¯ø-FŸę-ļJš deM<ôō˜ĒhĒYū\đH:˛Fîv=ŨH ‚ąp-Œcå›Pĩ#VŗŨQ¸bÎæĮ!Ęnjk[‡FČČÚ|€w=Ū@í¸ Mĸ""ÁÚõÂv­ų ĢP(ōŦÎėpšjŸĢõzą;˜eË䝏QšęĒt…Œ'A+¯9L7ûū_™ä­ģå _Ŧ×Tą§vÆĀG?uŖĀnNÃlЈˆŠ-fÜbwœÂû•iļ¯ę™A—Léō;V1rŅÜdwې1ĀöOw]Ë|ĪNĢ8é`z[ôãNmĪŗÛųœžd–i\w|Ōŧõ|Ž=KûŊ‘—bXæyŒ\đĖēĶÎÍyĻ}m$íŨ“Dņąi˙ôGPv!EšFæŲhq܏Yu7"ĶĢUKjhpkįžŲ+ˇdo ÉNÛ4‘ųŠqMMOGO$ †ØâŽ6†ĩŒhØ4ĐÛ.ÔDEŒ5÷‡}?â/¤ĮķQpŖĢ´Õ û=â×Riëí•@l%‚QÜ|Á‡N€‹Iø'İ\î=PÔ=DËõW+ŖĨ}ļģ-ĢmC-đMí9ŋEėÛ.–ËŨ[5ƚžŠŠ‚H*iĨląJĶÜæŊ¤‡˜*ЧpÕ­,´dņáW]HÆ(ō ˆk-sŨ ŽŠÎ=ĀD]ÍšđnU؈ˆ‹„˛ÅOžyq´šīyŲ­hęI'¸+cÕ]1În5VŒ/PņģíuūąMmēAS,[t%Íc‰掤DDEkjĶ%˛ižYyÃ) Uū†Ë[Ql„3œÉTČ^čšãģĀéâŋ8V]bÖē]T§Ô;^m‘É›žâŲ›UëRēĻj’˙ōČßŪž^Mļ íļŨéSŠēVc–ĒËŨ?aqžŠ +"åÛŗŅ‚öíáŗ‰ ŌDDPĶŌģœęf ÂÄÕzq[]@ۍ⚂ķ]D÷2X(^Ų íęÆžFÆÂAˇŠ×ŸĸŋQĩjÛÅuƒÅî—:Ûõ•# Ąt¯}?Ģ6';ˇ{IŲŽcÃ6w~įoŊ˛Ūē""->úfõUŠĩoĀp¸ÛđŸb˛ēŽ(%tpVՙŲžũŽĪsc@?dūōĖ>…üûTr?ÎqÜĒáp¸âö:ĘAf¨Ŧ‘ŌvHŲ ĐFį}Đnåßf—rŲ ""/ÎwĨŦ™Ų­Ë<Č/Tw›=úĒ–ŽX’gäBČZ¸ĐĀŌ {÷æÜīēŪŲf g,éæQŠîŠ“"ŽĩsTMRŌŲĒ#ll3?~÷> Įãžū+8"",OÅ~Maŧ7ę&Qό˜äļÛDô…ŧŌDā=é6;šŒ.xų´-pũĢ:Ķa×ŧ[&Á2{ínQ_zόŗÖ¤•×$ >)'´kÁ ķoßŋ†ëôŽÂâÆ—ˇg7÷ÉBŽ-mØæĄņuŖZA­U·Kî6ۅÎ:§0ŅŪ/q8Šįp ;fZÂz—m÷—“™āg ÜmčŊtXõã.5ôY†;f´“Z;jρ§–75ãŨvÃ}ŋ=įZ""(ŖšoĨ:˙Å.ŧWqjˇäųv3}‹†öÛėB0ašyH“rKĀ;ģŽmÍÅÁ|;_5ãI4šį-~”cĩļú‹TmœĪKmšÍ]%<„Øę;?34“­×œĢŅĖŪũƒSē|†ß×ÔÚØÖķ8Ô˛ē=‡‰æâT.ĐŪ84Îø/ƒR3Čl÷k•âÍ%×&ĖĢęwšŌ] \én]Īã“pÖ7Øn7YĀO™æ%ā7ŧîĻŽĒāúI †ŽŦ5UsÉ4¯ßŠ.‰Ŧ;žū˙!QIô]ëi´Ã ÆîWĒË&”fÖËFisĨyĐZ¤..kž:ąphsŧēxėqo3 §Ø>Ĩđķe´bZ‘nŋÚéņ`6{Ûd™­’ I5ē2â^îo-ũíŽÁ t‚7LĐŲ {GÛ¨]ˆˆˆ‹RpÛ TķĩFH1XrˇHf7V[cv§ž@vØ?ûĀæųŦ’ˆˆŠŠõdŗä–ĒĢAj¤š[kŖ0ÔŌUÂŲa™‡Ŋ¯c"­ 3ЍҎVIĨēk`Æ$¸ęĨˇŅļ9%īĘįũŽ]û›žÃÉ_ˆˆˆ­-GŌ]3Õû^ĘžļŨ’ûŋd8‘īāžË"C Tņ2"dqFĐÆ1­hî.hˆ‹‹ØŲXö‡5ÃbÜäąÎ+ƂāųŒúƒˆi-hČę œû%ļ8æßh´îšß—müVHDDEcęö‰éŽŧb§ ÕLRšųm á2ZyGA$R°‡Æī›HVžˆp›Ą|=ÖÖŪ4Ût7‹ƒ;*›ĩ}\ĩĩ¯§ôÄĶ9Îk:uģ°ß}–`DDE…ĩ¯ƒí×ûÕ6O¨x|ŽžRÅØ6ëm­š†­đü9$…Í/o†Îßo •ķĨZE§:'ˆÁƒi†-IbŗĀã'a%ŌH~Ԓ=ÄēG†îq' W‚""ø@#b7G ƒŅãÂ^K™Oš\tÅŦšŽ§×*íÔ× ˆ-ĩ3īŋ<”ŦxŒ’z‘°Ä)nˇPZ()­Vē(i(čâlôđ028ŖhŲŦkG@B""ņŗ ;Īņ̆šX¨ī6[¤& Ę*¸Ãâ™‡ĀƒķØ‚:‚VŌÎøfŅüŸ;Ä09x ßŲĶ\Ž3×6Ũŋ˙ŽÉžæÅō n< Ī興ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆŠÍŋk.’bųE6’j^3kŋÖmØ[jîÅRũūÎŅšĀõđķđW’""./{XŌ÷¸5­’NĀ5hbēɤŲÍöŗÃu+ŊŨíûúÍŌæcąŨq;ā¯DD^fG“c˜}žŖ!Ë/´{]#y§ŦލdÆ?šī G…įø>ŖZ=ŋ€å֌ŠŨÎc5VĘČę#í%„ė~GĒ÷ŅZ™ÎĢ閙 S¨zã~ŧîJat¸ELf?ÚāOæ:+’†ēŠįG ÂÛY]-KĪ‚Häa‡5ÃĄĖ.ôDDVlÚͤ”Ų›tęŖS1ˆō‡ÖÚt„U—æö\ÜÜßÛļ˙%y"""ņōėÃĀqĘėģ4ŋŅYlÖØŒÕuՓ≃ĸūĀw“Đ,a¤œbđŨŽ9˜–šę…žįyc\öPË´ĶNÁŪø›3[Úw~VgDDE5ˆ-ĐM=ãVŗĒ uŽ,¤†Ni**\;Äp°9īÛā°ņ+ŋHĩĪIõâÁ&I¤ųĩŋ ĸâ*-–ū –'€øĪ—0øn¯ÄDDXOT8Đá—Fōą„jĢÛ-÷ļōúÅ$qËRę@{Œæ&¸EŪ>ҝrËXîG`ËŦtY6/xŖēÚn0ļzJĘI›,3F{œ×7Ą ŌDD]U54ÔTŌÖVTG1ŌK, cåÎ'  É+X8ėá;'ÎY§–]h˛ÍwšU€¸JĘiæßnÎ:‡4D÷oĐlîģˇYéĩ¨z“é>/Sšj>UoĮė´› jëeäo1îkG{œ|ĐIđ ĘŅž+4ˆ Ęģ^•j5âãDÎÖjG%=HâĨk\æuķAFëķ÷ŽØĻ­Û5Į'˛j}ēí6iSx˜Ô‰c{æĒ•ōWĮĶwĩĀ‚ÂŪ›˛ũpąlĪ,Ü9éŨĢSIĘ)qúXî"ĨÜĶ5ážëd?ņ†ōƒŋ]ÁŨeDDE‚xäŗj&A–ĸÚ4ą•’d5ŊĸŠˆ‘<° jŨKl:öëG\ã:ŠtâoĨĶ*“/´Úi§|,s}V’XtĮouŸ8w7BŪ;/ŅÚ""-izk,›rÁ0;ĩŽ ęŒ2ßWTo,ĻkUNk; &§/(”4ž€“âBÅ…{ĻWËr*(+ĄÁ”ĶÜ${\)§ŽíX`k7÷]#Z$$ŽĄ¤īŪáhgŌŖę}ųÛ8§¯}ĸã;ąĘ‡ĩƝÔ"&Gėî×ķķ4uæ$žũÖĮ=öH°p™CĄS×ĶCQwǍ°ÁZ‘–įrė×uk ‚W4¸čB™Hˆ‹ËĘbŧOŒ]áĮ¤Ũd ¨m É– ÆáÜôû[/ĖíĶÕhõJ|Zådŋģ=uÔĮ%1ŠC^úã'xûÅÅũC‡įŋŠũ(i.SE§ĩq7m‘AfĸŽë&û—UˆZ%$øž~nĒæDDPëŌ3 :CgÔ55ēYgÎ)ę3h"cŸ§," '`ûPļBy‡ĖŦ~/s= ÔkĻŽØ8wēcwŊTn]kĒĮgÆå ˇ1ÜÕ™đôd˜ęĮmŨŨĐŠúˆˆŠd÷­:Á}#|‡ˆÉ¨(¨.¸… {sŊ–‹t1Į×#cäūœS÷;‰ëī ųé×Í}!ŲYÃˇĒÔb´xQŖÍî6…˛ŽęgœĪrIƒŨÍßšŨ{ÔāDD]s‰LB{ƒļčĩ˙ÁfuÃŽéŪ‹ņvÆ,š›KŨ_Œ ÄĘĒūiœY#{aŧИËCZŨúī͍ß$ú5Š$f–f×\~‚˛ƒOnŲÍŌŗĨĒkšYisšX×ulEáÅŖķRíGH¯3ŧp¨4X45“Vš8ddžŒžŪZĪǘÍē’anxÜ,ŽúŸĀŨ˙éqœĢ­}eš:LJÅllFī Øĩĸؚ;VJŲH/q}š;õ™úE—Ûtkˇįō=ų%6?AÕŌŪj›œĮÅÜÛî|÷Wē""…|qIŲu˙@ķ jĨíô†Û_pŽäúˆĖ”ˇwÆŅG5[v#v. ķX׌Ûîǚ¯ĻvŽnVĢžŽŅšę‰Ž8´ąš´ÖƒHđæTÍģąqhc\w~íÆû¨˛Yk+áēUÚ(§­Ļ˙&ĻJv:X˙åyĐĒäDDEEGdŗ[Ēg­ˇÚ(Šj*ŽķÍ ;ųO›œîũUj"".ǚjzČKWOđĘ9_Œk‡‘Ą ŽßlļÚ)YCiˇĶQSGö!§‰ąąŋ“Z ĨĘËgŊ28¯š:öDņ$mЁ˛†8w8ąųĒÆĩŦhkZ`čúˆˆŠ‰ÖK+ŽbôëE¸5ŧ‚ŦĶŗļ ōįۛo–ęĩ5ĘŲnŧĐTZŽôõ´Uq˜§Ļ¨‰˛E+B×5‡äU›€h>‹éU}U×M´ˇÆĢkAlõ6ËdPK =H.hßo—ržŅ[Yæšéö¨ŲÆ?¨Ø]›%ˇ5ũŖiŽtl¨c]˙CÁØüÂíÂt˙Ķ[#1­?Ä­8íĒ7ļ’ÛHĘxš{‹XįæźœčˆęeæŸ"Ô'ÅrĨ(*ˍŽĻhÝÍ܁äUķGGIoĨ††‚–jjvâ†26°kZ:€]Ȉ‹áĀĩĀz|V<´pí øūbíAąčū!C’:GKí:{D ¨=î Ü8ųŽĢ""""ķ˛rÁ–ŲęąėĸÉCwĩÖŗŗ¨Ŗ­ŗC+|œĮ ˇtīF4—I#ŠLtãÅÅi¤ÚíņĶē]ģš‹@$"¯4DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD_æąĨīpkZ7$€ Ûøôá6ëŠJ¨uŽĶ%õõ>¤ÃÉ(¤’Ŗ~^Éĩ%Ŋ‘w7AīlO@VDDEáfųÆ#ĻøŊ~kävKŽ>ÖŽļŽNHãnû™$’Hைņ{Ã×:Û“ę-Öį@Ã,´2A-4æ v21’ĩĨíËwÛqžË2"""ÆZßĞ‹pék¤ēęöqKcmÁå”p>jŠļæ,Š0^@Üníļ÷¯kIĩMuĮ‹8Ō˞Ž˙h•æ#4‡E ؘäc€toŽŽõš^hˆˆ°FĻqÅÂæg#NsíWˇĐ_˜ö˛ĻË;iíļž6šąˆ$8î~Ë6Úî–ÛŨļ–ķg¯‚ļ†ēTSTĶČŅ8n×ĩÃĄA ŠtÖVR[é&¯¯ŠŠžšš7K4Ōŧ5‘ąŖw9Î=IX+ãĢ…mLÔĻ8n­ÛĢoŌĘ`ĻŅKUrš ¯hd„øžžŦöˆˆ‹kĪziÃŽ=G|Īë+d¨ēÔzĻĶmĨuU}Ę~ŸĶ‚õqÉØ Į^ĄZú%Æ6˜ëV]S§ ŗeneMNkƒ)ĩē‚ŽĸœwË$‰Ķŧ*ŦSß/ļYЍ‰ ’N‡˛.đŗîZ9Đî ¸ČuÂÁ‹AĨŲN=WmģĶÍYs­ˇËOOodRĩΘĖāyyw¤ķļßuúcKXÖšÅÄ >?5ÉC^,*æŅî(´ŗ‰üĮ¸_4ōÃh¸XnUtŽĒu‚Ēwoq žR!pęķØrģSņN18ŗŌ īöúÛĨ“Kę+n™bheĻĻË#(#|iŊŨK{†äø;Q@Ŧ#W°ž x„Öš"i+ŦPjCū%°eĻ‚jŠk…ŖØQ™#k‹_ܝOË{΃ëõ[õŸ‰{+pÆđLî[u%ŠÚgSIuu,nlˇęĐōvĮs⠘HˆŠĘÖŧJ÷žčūk„ãUŪ§užØk­ôSķrōM,c >ręé/ú¤4Pč6 ā×ģN c6wc•˜ąÍ$÷JĀÃ1ėŌÉ31q?|÷ôŪGđ1ĻŲŽ“đģ„áyå3¨ī0A=TÔ.q&…“Ī$˧?65íiāŗŌ""Šū|;'ŊéæœXņZœŽŨ§šŋ&žcôė2Ip ‡˜IËú…œÁÜž[ų,5ÄŋúaƎŽh7”7\Ŗ1Ŋß-Õ¤ڧ§n/5ōÔĪ#ÚokAnŸ´z÷o°˜蠎7ŧŊĖ`iqûÄõ؈ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ¸IsFčĻ˛1ã•ÍpÜäBęĸˇĐ[ ļÚzHA$GMģųėĘĄ5uļŨtˆAs Ļ̈882x›#AķŲĀõ]ėcchc֍€`’äˆˆŠ–KUŽjÖ\ĨļŌžŽ!ŗ* LAÛnR"""Ĩ¤ĩZíōK5ļ–šIĪ4ކ°Č|Ü@ëúǤDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDE õŌšÂūœjeV›Õģ"ģ{6¨Ņ\.ÖÚ6IGO+]Ęđ x|§ŧą¤t;nĨÖ9‘Y2ëģ)ÆŽP\-Wjhë(ĒĄw3&…íkō …é""/6Í19ÄŽšÎgv†Ųd˛Rž˛ļŽ_ŗmNÊ'¸ԒīQgF=)<6kNĨŌi…­™ ’ļé?ĒÚęîÔąĮOY1;1Ė{‹īģÎ䁞ęa"""ĖãoŧYÚ%Ģ´Ũ"luv3‘ÎkŲžĀwĀÜo EŽ%Ŋ"ú ÃeŸe,Ŋß2'Ŧ¤ŗÁž¤ĮŲÚēG´ąåˆ'mÂ͚1ŦøžéõģS4Öîkė×f‚örK­;>)Xzĩí=ãō#pAWĘ""á,ąÃæšFĮm.{Üv Š$ø +ũ-Ü)PjKđ'Tä2ĐGWęRdQQ4ÛÁå/˙hcī†wuФĢĨ¯¤†ēŠĸ9éęclĐËš›#7kā‚+šbū!xÄ¸uÁâËrJ ûĩeÆ˛;]šÍm`}eŌēMû8"iņ;O€ķč#ÅxĐÎlšÎ9ˆq%ÃŊįKi3J–ŅX/2\â¯Ŗ}[žÅ5CŖ°‘ŪøūâV"""ēéÅe^jģE´§Kޚ—¨× /iÉhĄŠe4ú>nQ5UCÁl`žáˇ_1¸ŪŖ@8Ĩ:ą—_4›P´æé§Z‘ŽĶ˛ļŽÁp™“ļĸĮfÔĶN͛,{ÃĻãŊg¤DDQ*ņÆŪ“ä™ '\5_ĩ7Äk$ ēßâšEEõ1ęÅFׂj ~]ū]Fųŋ@õ× âO)ĩ e]4fyhĢíõąöuVęȎŌĶĖß´íų‚ŠČȈŠÚԝDÅ4—Ŋj6qq6K +ĒęæÛ™ÜŖ kGŪs‰ hņ$ú“b´ŅjŽ đ——cēM_$eš#ĢážĒ–šBuUMņÆw}úŪzo0­w;}îŲIy´ÕÅWC]*i§‰Û˛XžĐæŊ§ÄAšĒDDX{ˆŪ$Ŧ<>Úė”ãēe™nYXmØŪ5jÕ\jŨOFFĐAsČ;n:p~4otCĻ|LhÅÃHî—ĘiĒŦ•õw(ĢmĩÂ&sÉŦ0ÉZŅŋ)ßôéž´ĩOŅUÅEĢV. '‹"ĮĢkžú 蝆8„y-3‡¸=Žh>đ =Ũ7Ũn7‡Ŋ-›DôK Ԛ›˜¸ĪŒÚaĄšŠ †Ë(ŧ´ŧŧÄíŋ†Ë!ĸ",IņŒ\8‚á÷1Ō[EÎ;}Â÷HĪSž]û1ëØā \>DWz""Ä|Pņ#‡đŗĨ5šŸ—ŌTWÎĘ* }9 ’˛Šā–Fz4l×8¸ī°ičNÁG>Ŋ)¯ē—”dÚ&!xš2GÚ%eĀUÁTæ4šŅ8–0ąü ‘ĐƒąÛ΄DDQ¯Hn'ÂÖՆŅâeyUΛןF*Å44”ÅÅ­t’r¸ķ8ĩÛ47š¤’:oyđeÆ^!ÆrŊYėsØo–Ŗ‚ëjša0‹´Į$r9ØîW ZAÄȄDDZę×/L>ĻŗrĶė?KĒ2›]†ąô ĢŽb˜É4nå”Afîf´‚q‘ā:ŠÍ¤šŖŠëV›ØuG ¨’[>CHÚĒ~Õŧ˛GÔĩņŧx9Žių‚ŽôDEmę> czUßu/Ēu=›Ą–žąėo3š7ŲŖÅÄėņ$( Ĩž™Œ'7ÕZ 7*ԚŧsģÖļŠ–ņí6Ī${Ãc|ņvmģ‘ĖZãËžũv[¸;‚žĸ"(ũğųļŸåxĻ‹h–E”jflÉę( ¸Nč¨mÔP˙™WRæõä h ’Č8…×üYqũâŋÅéįÍã›ü/“bŌLhjĒbo<”’Į.îdœŊAčN‡}ÄĒDDE2Ū!xÕ=XĘôŋ„ÜC6ũ?¨mA“å’Íę˛\ y%ŸßĢāˇWWb•šœvYܨ’ŲX@.oīÜ Íkšö‡°‚× Á!}DDEãf˜Ĩŗ:Ä/xUč<ÛīÖú‹mWfvwe4ncļ>g–¤­ž…mY–Ę ŽŖc§ލ=÷(ŒžŊ%0vüĸŪVČGMųųAëךmęŅk¤ąÚhŦ´ si­ôņŌÂw"645ģŸ€*ÄDE€¸×ár,ôb]<†öËEâ†ļ;ĨϞVÄږ5ÍäŧŽkÜ GCąÛcxô\gē#Ŧ´ÁŦy%’Wc†GÚm֙¤›ĩ¨s ˛=ÍhkZâ$ížĀuŲz""(é ôvdüPåvŊSŌ܂ŲE‘ŌвŲ_Es{ã†Ē9ΎFHÖģ•íįp ˆÛ¨#Ž@ô|pO]Â|Ÿ-žŅŨrĖĒH\hƒŊZ–ƒģ8Xį^w{‹°đtÜËdDDZ˜×˙Cæ§åZĪxĘ4Ģ3Į[‹äw)n/mŌYc¨ˇ™¤/‘œ­c„­Îå ‚FĀíŪļGÃæÚ¸Ņŧ_HŦõōWAQö/Ģ‘ŧލ™Ît’ÉËה9īqĀlDDDVV´ée›[4§'Ō›ũD´ôY-žJ'Īđ¸õd€ō׆ģo–¯ô—ĐÕĒ­[ˇWj^qŽ? ´WĮW$–įĘęĢ„qŧ8F#s‹›` .; öŨmŅ­kҰhØ žĸ"(ÍÄΏęûuO âk‡Ú;eß/Ä(jl×zãP)âŧÚæw3Ŗd§¤rĩېONŖËckâ¸FkļĢZī§´:kˆéœ•Ö\~;Ŗ+ëŽ)cėûyŸådlÃĄü÷$LDDPÚģ âk…í^ĪrÍĶ PÁu*æoõ“vŽß]iē=˛¸:AĘøž@=7#aŨˇ[į…}Õ;ežq¯^ͤÎõôą=ļ^֞ÍnĻil4Ũ§tëģœ7^ĨIDEnę&jÔŦ!Ķëá{mų˛ĻŲRæ}ϞhË ‡Ėsn?%ą9= ÚE§0på`Ņŧk&–ÕIėk~oąÁG‘MQLīę#fŪčī-Œ–á›E"áīDą­)SsŠ´Ã$•Õģl**æ‘ŌĖöķŊÛxėĘ(ˆ‹quĄ™^´āÖJÍ7ŧRÛ3œûK“ãsVoęŌUAžđËļû1íqøŧ7XK9ÆøÆâúŠĪŖÚĢŖ6.Âc¸ŌVåˇA|Žž[›)äzŊqõc^öƒģˇÛa×ĻÆoÅ!Æ6kŅä戈ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆĩ Šū™ŊRŖÕZČô×Į…[k_PÜc•Õuņ1Û#^EÛiåÜoĖZjÖ}+ÅõRÉK-5MmŠž8%ęøK‡ŧÂ|y\7ņÛuyĸ",qÄFŗÚø|ҜŖWŽÖų+âĮéąŌFîSQ;ŪØâ›î‚÷´ā7+\=ú`uC+֋>-Ģ8v:1Œ’嚎ĩC,uįLđČßģžá+Cˆæą$›-ŗ"""ˆžŽ7.ÃEuË2—Īę~ŊĖiŠ`„7žWĩ¤’^ĐÖî¤OceĸëI[-ĒëI‹ĄmLmc‹ĸ'¯#›#ę7#ŽÛœôˆˆ¨¯Wj;šžûps›KmĨ–ŽrŅšÆÂįl.=I>$•q""+?W´ŗÖÍ6ŋénk’YōCK9‰Ü˛FwdŒ>kÚט čGĄķ ŌÍ\ˇęaŠĶå6Ëk+­vąnũ¤Ŧw4fĄüîæ p• nGxđGn3¸2ÃøÂíļ‹Ŋî{ öÃ,“ZްÂ&ėĀ "’2G;ĘĶЂ A Úz=ņ>뮙u^W&S–]iŊDÖz¨§‚–›˜9ˉœÎ;¸ĩ쏟ēŽōáâ÷ŅmŠņ'Šręž-Ÿ?ŧ]MŧC%­ATæ44LĐŌÉ9@ŧčwŪIpĮÖÂæ•QivSS[sIY]_R–˛ĒMƒåp6kZ;ƒGSŪ˛Â""č¯Ą¤šĐÔ[kālÔÕq> ĸwsãp!Í?" [Ū… ŖSy¤ÕĢ>%I¨6PiŦd|Ûö ¨įååÛ§9g6Ūõ[ ąYm˜Ũ–ƒ˛Ō2–ßkϊŽ’}˜ĄĄŦhüšUȈ‹ qAÃåNŊbļgc9[ņl×ēG}Åī´•ŒrČĪŊĮGČõÛcˆ›Ã—zį•â§Šüûfr‚đË%M;MęēŧRTž]šX^Vôīņ1FmháßWéõ‘ŧFđĮ™ØėŲ}uļ;>AhČa’Keæ–3ŧNqßŽVw;ĀG]ę4‡}Pļęĩ׈ž#ŗKNAŸ×[’ÛEd…ņ[,ļū~wG?ŧ÷ŊĀâ<û÷ŨIDEņÍkÚXđ \6 ø… -ŧ8qs uˇüS…FÁ]€_ëę.TT]$îŠĮĻÜŌ6ŅŲ#’ū›øw“›øcĐ8zĶęŒzŗ"›#Čīˇ*‹îG{™œ¸\g É oŨhØ5ŖČoâ˛ę""ą5ĮH1ŊyŌŧƒJrš&†‚ũMŲzÄæSJ×Å3?šk]ˇŽÛ(ŊxáĪŽŨBÃ#Đ-GÖÜē|øŲAsČ-´3‹õŌŪŨ‡böģúL{Ú9\āzîw.ëŧĮÅ1›6ŒZpüz”SZė”PÛčá~Hb`cū=Ljˆ°7œ;äēĩY‰jF•fPâZ—§õ2ÔØŽU0™ŠgŠV†ÍKRÁÔÄđP zuXŌ5Û_ŗ‹>OÆ~[‰Wcøģ'6œS†vRÍU,F7TÔK/ŧHi<­íōëŧÄDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDVæŖæéöŸdšÜ´oĢf;iĢēvŒŊŒN“ ųvũVmž•Ž-éĩ5™Å~]KUguPt¸ß¨Ä(}[›ŦM!ŊŖO/@ūnmúû–ôqëŧy‚Û~ŠB˕5ĮŪ`‘á§æ7ŲzˆŠ0zCø—Ëx_Đ3—`T°ģ ŧÜâŗŅUOi{÷LZz9ÁąĐznA;í˛…OHg9ˇ}$Õŧ‘ųuŖ.|ĐÃ4ÔŅ2ĸ‚ĄąēFŊŽ­Ū3ČAiß`wm×nȈˆĩ›éDã›YtOPmZ3Ŗ÷SšÖ¸îˇŗiØú‰Œ¯{YE↴H’vÜm×'ú/8žÔŽ&1 §ÕY#¸^ņ )\Ëŧp6#WO8x ”4ö1ž  Á7™Æˆˆ‹HœGúO8Ÿ~ģ_áĶĖŋü-cwz‹} Ž*8dlĖ‚GF]P^Ōds‹I#pû ļŨm‹…MeŽâ‡ü;VŽļČč+ī´N5Eŋf'ŽGE#™ŋ^W9…ĀāvYecŽ#5Z}ĐėĪUém‚ãQÚä̧Ļ;ōÉ.áŦæÛ¨hswȧ­ôĨņQAŦ–Ģžo—3#Įîˇ(`¸YC q6 E?#CŖsAŨŊNä ÷[ĘcƒØ×€@poŪš""(›ÅMŠZ‡¯˜ ¸{]‚PdļšĖ!ŋ[Ü_%ä´¯?aî —8uoAļh,úÁ×zgƒ[õ*ÎôûUęęŦōZōŠá[[lފ.ŅĩĖ@qŒ÷9ģl7=ũ›ˆˆ õˇÔ5uŖTaŋk>_ƒāēg~v-k˛b—QŠĒĒ€ÉWS(ÄG+HÛníļ;ß#æē•ęާđšŠYĨFlũ;õ ë6GUąĢž‚­…Ė‚¨ĩ+6OR ų)Rˆˆ­-[ÎŋđĮK˛ŨE.­8՚˛čÚqŋõ] NxoO@äĄĻŸpã­š×Ŗ”Fß8´Ī-z‰’ÛFCkŠÕplVk^Ã$4Ļ”WÆĘג|úēÉõ’û¯\;bz“”ĶCę˛)é.&´RÔSĖø_+čķ6àß`ŗB""ޏiĻĨÚ }šāZķŲŧĮ,´îÉbxû/iî?2 °ŋ ŪŽíá.›=Å æ÷˜ä‚–ļņ;$4Q?Ŗ„McĐâßt¸‚vÜ ˇ*Q"""üRđIŖZEnĒÔn6ûÕĸ7CGwĩĘØę ;˜ž×5ėßr‚NÄnwšxnáƒJøYÃ&ÃtÆßRÖÖĖ*nõ˛‰jĢe`éĐ4į§RV[DDEĩŅmÃNŗjmF§ŨūËWs¨5WZ+MS"Ļ­”õsČscsWšÜô'u)đĖ;ĶėRՄá֘m–[-+(či!ėQ0l™>$ž¤’ORŊ¤DEæd¸Ũ1ĮŽ8ĻMl‚ãiģSIG[K3wdĐŊĨŽi0TIĶ/EO cŠÔڗCAvuļŠĩļÛUÎą’ŅŌĖĶģ@`tœ§bĐ÷¸îĻJ"",+Äg ļyv?’Zķ Žœáķ>ŖÉíAĻzBņŗã{ŌH°Ũ„÷ ÚúGÂ5ūÁĒēŨ¯ËtÕ,ŌĶK%’Zšč¨m1Č6‘ĐĶÆKDŽ ūgĻũT’DDEu7„ ĒŗSŽÚÃÃÖš]t¯"Éãc2(aˇÅ_Ass+gt0|oįĶsŊķ× ļ-7Š›’]2ŧ¯+Ŧ%ģ8Ģ@7p:26‚yX ÛsÔŦˆˆŠn–Ë}îŲWfģQÅWC_éĒ`•ģ˛XžŌ×1ÃÄH?š‡ŋũę-’ÕWĨú}ÅĻaŽé5|’v˜ËhašĻšžGújz×xâ<ÎmÜzƒ×yOĻÚwŠi6 e͜"Ü(l– VRRCŋ3šG{œ~ķœIs‰$Ģ•c­zĐŧ3ˆm<ĒĶĖÔÕÁ æŽ˛ŠžŠNÎĒßYŪ*ˆ_÷^Ķŋæ +Ųx"Ī2\“Ģâ;‰Kū§ã˜du֋ÖØh –ĸ?ōĨŦs 5o÷wųõ ËTDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEđäĒZĩŽįÚ mʖ¯ąw$„Í“‘ŪG”ČĒ´DD]5•´vúwÕ×ÕÃMcwË4Œhų“Đ/´ÕTÕ°2ĒŽĸ)ás2Hž×0GBģQRV]­Véa†ás¤Ĩ’ĄÜ°˛išĮH|š ę%VˆˆˆŠ#ģZĻŽ’× Αõ‘i)Û3LŦeģî?eVˆˆ‹‹ŪČØd‘Á­hܸ€jž‚élēÄgĩÜiĢ"k‹KéælxnŌz¯Ī.ąqÄæQŦ÷|ÖģSr|~ãošĖĘKmt´đ[ZÉ6C}Ũļ<Ā—÷ßuŊ^süŸTø|Āu3ĻlģõŽžŽš­:R6/ đØ?oîY=a.4õ72ŅŪŗÍDĶöoZčę“ųũXÉ+#tüŊĮŗkÜūŊ=ŪĢLü)qoĆ?Äf)YĸäŲ'øŽųKCtļW×ËU|SĖđcq 84ōÜ/Đ*""-wz`5ķVôŖÂđŨ9ŧÜlüĒJĮ\î”2ϐB#åĻl­÷˜hįˆ$;ˇXŋŅÄV´åú—i&[’]ō\f;3îąKq¨}Cí͞V4Čō\đō9wÛpņ[aDDE¤OIēôî'˛-;ĄÍ/ØÎ?‰É6Ęmd´—š<Ôŧ°‚÷8ŧėNāņß`~Œ-gԍmá–î§WT\ŽV‹ŊMĸ @ū­mi?Ô,æåæëĶo%*ã§Qķ)áo7˰:§ŅŪ!‚ X̘Ō]BÉįŽ*ŨŌ{œø(åĢ|h^pË]ŽēšŪm9ū1hnGEž‹äī¨šÖ&ī,{&qå īŽūģÍMĘī™ŪaYĻKCęwk円á[//$ŌĀ×ŧmā7$ė¯DDE8Ņ’ŗQuģF8gČ2ŠüsÎæ¸ÕßfŖŠu4—gŌÆ×EníFÅĄäîGŽãĈx–Áėæx& pŦjí5ų<Ֆ›ĻëŗUŌŨ`e+ŪÚŽÆG8‡Dæ‚\?âŨw‘š™Á¯ YÖ˛ÛŗlĢGŦĩ׋‹ÍMdÅĶFĘŠ[ÜųbcÄrKšwņŨI ZZjhh¨éゞŠ(Ŗhk#cFÍk@číDDTˇK]ļ÷mĒŗŪ( ­Ą­…ôõ4Õ‡Į4n9ŽičA‚ ) zaŠ÷|ĶŌ[M˛ķA)u]¤Ķ^qī›+ÜØÎčÚė‘DDEaëV’iž˛āĩ˜Ļ§â9 ­ ÔG Pp1JĐv{ŌĮu#vv$+s†ŊŌ Ãģ-,Á-öuå’ēXL’MP[ŋ/<˛9Ī nvė7;—Ņ`%ø`Đ]hĢ´äš™ĻļëÍ֞XéYZdš Œ<ßåšđŊ…흃ˇÛs˛ĖxNŠiæ-nÃp‹–Él„CIEIdQ7ŋ ņ$’I=I$’J÷F[‡ŧ-Vëģ3z­ąIv”››ßŧĸÕssvϜ?ą'›¯ØØžŊęL€Z Á}DDXģ‰<Âõ3D˛Ŧ:ĮéîÔ0ĐM] r—4ÅQčåcØC˜ö‘Đ´ƒŪ;‰ZāôYÛbÕũnŊäZŠYrËn.Ôˇ›EXļ{á ÄŲZĂGxęļ∈ŠúWą‹5›J-šÕc‚{^u`Ēmē˙oĒ––˛]ņҧØvsÃŽI[”Øâ­ĒÆā7kEH‘ņMCVĪŗ,RF暎ëāv>;¨蔺Qę­ë(ՍM’ˇ+ËŦlmēÛuŊWMY-%;ųšæF%{šŨĮMĀßbFũJ˙Ųkim-api-2.3.0-git/docs/src/asymptote-figures/square-lattice-configuration-2.pdf000066400000000000000000000231621421473465500274730ustar00rootroot00000000000000%PDF-1.4 %Įėĸ 5 0 obj <> stream xœŨÍŽ%I­…įį)öđö “ü˙‚„˜5CŒęŠžēĸ%^gÆú– <ŠVĢĘ>‡vÄĘU{gœŋ}únøôįúķûĪ_ŋøũöųéī_ũ᧝cîö}Ũ>ËÚ Į2}~ļfē­ß>Û܍ņĮЏŨt ŸyīÖĶųû×8uÃ>­ÖŒŨÂØķ¯8ÃĻž[OãT<†gû#ž~˙úķ×ÜĮąÍŸ| ŸßÆ˙˙)ũæŋ9Ĩ˙ûúÃ×ÜĪ]ßīŸi]ēi8Ãˇæčģ}œ?Ķ>uSü9Cˇœúeëö°Dūū5Mx?¤Eüš[z@Ö1Ítt{ŒÄÃ4Ũpę5rŒPhĨ<<ķ¸ öÚÜÎĘQĪ5J>מ[Ŗ;æÆÛÆh€qq› gãĄ9û‹Á×ߛįÖxkŒ?†ŨˇŽ{7NŗŨ"ģQ8,9xÄ}ę5ŠÔuDU—y+]7ôũŅõĢģ.6üŅŁBG g×ŲB=e’™#ģîXöޟwŨ1mŨ´Œž9ģã–‡guGŊ/ˇēŖ†ņģu-}8LÃŊâŗ|šön_ķä•\ÎriÎvcđõwšn8ŒëÖ KæãŧvŽũJÎc]ŠŒ´9xF^7Õ˛ŠûjXûĮŊöŪ:nŨxdī­ķÖyš#—ŪÂŪÃå6GöŪ°lk7nîŊaY–n9rÉŲ{hĨ<<ķ¨ûę}šŨöÕ1ôŨQņ˜ĸ|ŧĮcÉÖõG6ŒäԈŌ\íĻÁíī—gõážNŲ‡û:wĨ ›˜]ØdĮ¤Ņ o;ęŋ:ē—Æ1đ˛Kŋã•Üoã¸Fe÷rö›-ÔMö`šÍ‘ũ6Tãã°Mņ,•SHÎvC㠛ƒgu'Ŋ-ŗēÆ%s¨ĪIã˛ĖŨ:Ķ€ã˛Eí'ˇ r6 šŗĪÜūŪ\ˇ—~ŠĮ)wā8īc ķ’DΚDcw2+3@kÄßâŠ3ˆŨj~wõįC‹āąôąé—´ˆĸīįS§nCášÖˆ)Žg_ôųŨãqÆîüîĸšæÁ䏇8(Ļü¨Ö˛I 5ĸ‰×p8$Ū“e2Z(>†?28ĢķÆŦęŪIЉ‚¨ú›@ļŪ( S}cƒÖV/ŅüR2äPŖM›ûÂ.5(>ܨ;é=9Õ}•Ŧ œ€3Ō#É*¯ōÕ_.9éž5"„×pØ"Ū“O2Z(b†?2¨ûęMYÕ}U˜$x +bđ˜s$8û{ˈå\iüVŽī§§ū”‡<ž6Ô[Ršę˛fKåˆh y{Œķ{ĘãˇĨrÄŊ_ēōžî¸íąq‹䤉hāyō`¨9 STiĄ(íážĮU¨×æVw”ŖŧYĢ^đ[ˇj”ō^ŽēČę2{@öûš(xGW …L‘´‘ ŌBAâážEŨ_/KŦîļÂĨ1õS/˜Ē[ sT?ŲBũf’ yDû“ŗCÍQøŖĸH Åm÷<ęn{_nuˇ%‰´†Wn9zy—s9_ØåĐÆBMgČųâŽ5zy≞ÃLŌQ؂¸åá‘GŨpīË­îšÂ'­!¤/!ŒôeōIú ú–M)ŅĀ ņgdŽd•Da Ei÷<ęž{_nˇ=ÁL…^ĘĨ!xa—–ÉWzi*,h:+<ĶEu‰¤ú¤đLu’-Ôiö`ŲTČ"ā’L‘l“ lĄ qpĪĸeV÷XÎÔčU]õ‚_ãUŗ”}ÕMļPˇŲƒeŋđk^úŃ8Ĩį0ëtļ JyxäQwÚûrk˙rŪxõųĮW ėz>%E#:9 'qČo4‡bą>: ÃܕKŽĻūˆ™ũfĤŽh —é xŋ3õ‡ rČ=ė–Õ4ËųŧœÍîtšˇë%|Ž|šĪîúĨßi§ŽŧH;͑Õv’ķR(4\ %žJs”KĄZi íāž…rSÆ&6Vˆ–°ZĐ–2‰ ël ÕÁaVˆ–āÚÂIl"-¤=ܲ¸—-ūŅøâ ļbžWHKZnŌĸ§E+J:hršy 7ɃoŌåæĄD(j;¸gq/[>[Ŗ‡[wš~Ŋüxėũ…ĘbČ~tMM{¸ĩ=üz?; [7îyÜ+—ŠŅÕ4Ē7×PšŧۆĘŲB•ŗdßmƒ†ģmđĀŨ6Ė‘wÛ((F;¸gņ¨ZŠhJ^2=HyQũ¨åeĮ‚˛āÁ˛…ŦĐŗ’´G)ĪĀŖ–CāįŠĐÃo)Ük–$ŠŅ%(mš|GŠÖŗÜĸĸO‹V‘t€ė[TĐčp‹ Sä-*ŠÁ ‘ņ÷îKČNM\Ö @fA˛Yq[¨"ö`8MM\{ {CļŖ°Qâជ˛Ûûđ[ē)€Ų-Ν5ŋ,5mq. ώiÔĢŦ2ˆ‹?=ž‰ĻĨ1æÚA:ŋ˘øŖˆ<āąî'†éęũŧš vîãˆŲō{EsGĐXŋW4÷ķp~Ē“ņTԏŃd#¨5yīâå!īels$H…-ˆ'Ĩöh¨Ŋem™’ũßĸNׯUÔßūüęÛ×/~§D´ËíúíĪ_í/ž_ÜŽ‹–ņŧCõÛĪ_üŸo?ČąņÆéOß~ãÎ_¤Đ[? įĀ5jŅĶįĮX¯Īˇ˙ ûŋūđc<ÍĮŽ?šũmž‡8SãŲãĮ9ŠånC~ųÃЍëÔ¯˙n†ŗūGúŋĖ0c›aÜ㠋'>ŒáĮƒÕ:-˙ŪųžŸŋ4å?…˙ëo_ŋ‹˙ū 9~endstream endobj 6 0 obj 4997 endobj 4 0 obj <> /Contents 5 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ 4 0 R ] /Count 1 >> endobj 1 0 obj <> endobj 7 0 obj <>endobj 12 0 obj <> endobj 13 0 obj <> endobj 10 0 obj <> endobj 8 0 obj <> endobj 11 0 obj <> endobj 14 0 obj <>stream xœŠVūCMMI8%øøøsûVøœøM‹ ‹ Šø÷[÷X÷Uns‚Copyright (c) 1997, 2009 American Mathematical Society (), with Reserved Font Name CMMI8.CMMI8Computer ModernpQŊøˆøĒûVŦ÷+§ø§øNŲŋû ƒk‰ƒc‹}‹x‚”†•‹ŽÕ‹Ķ‹ ˆ’‹Ŋ #š‹ž™}‹[‹‘”’ŌŠ÷ ˜tĒgÁ‹÷÷÷"÷%îKĖ;O[bmnvŌH‹‹g‹rt{lt^€X‹ˆ‚’‡“˜ŒĨ’˜žÄ´‹¤’ts‡s‰ƒĶ{œ‹šą¸ļĸ¯‹ŊžZ^fu mPqU[_\‹G{Ų’–ŒŽv øC•––÷p û`•Ģ Ų  7Ÿ § ūš§ī endstream endobj 9 0 obj <> endobj 15 0 obj <>stream xœ%oHqÆīöįŧl™)+ÍÚ]j dūCĨ[JŊP¤Œ‚ūИ—47įéļ4ēmÎíöŨ9ˇŨVY:EĢY„øĒ _Dԋ ?o„‚ |ÕīŽķE+_=ĪķâĪķā˜F…á8žcėėí ‹‹!ĒKÖđé ĀAąŧo”TŽm×Ŗ‹h}IY׿É#YĘ÷iô>u NE ŊCå ĪJÆd*…ŗ„r9™3—ûvģ!WĶ”Öm›‹ëtöQ\ endstream endobj 16 0 obj <>stream 2018-01-06T12:22:26-06:00 2018-01-06T12:22:26-06:00 dvips(k) 5.997 Copyright 2017 Radical Eye Software square-lattice-configuration-2_.dvi endstream endobj 2 0 obj <>endobj xref 0 17 0000000000 65535 f 0000005318 00000 n 0000009119 00000 n 0000005259 00000 n 0000005102 00000 n 0000000015 00000 n 0000005082 00000 n 0000005383 00000 n 0000005651 00000 n 0000006596 00000 n 0000005495 00000 n 0000005846 00000 n 0000005424 00000 n 0000005454 00000 n 0000006076 00000 n 0000006809 00000 n 0000007639 00000 n trailer << /Size 17 /Root 1 0 R /Info 2 0 R /ID [] >> startxref 9349 %%EOF kim-api-2.3.0-git/docs/src/asymptote-source/000077500000000000000000000000001421473465500207015ustar00rootroot00000000000000kim-api-2.3.0-git/docs/src/asymptote-source/square-lattice-configuration-1.asy000066400000000000000000000027401421473465500273500ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // //settings.outformat = "pdf"; size(20cm); int maxrow = 5; int maxcol = 10; real circleSize = 0.075pt; pen p = black+2; int particleID = 0; for (int i=0; i < maxcol; ++i) { for (int j=0; jModelCreate (or \em ModelDriverCreate ) routine (required), which performs initialization tasks for the KIM::Model object. -# The ModelComputeArgumentsCreate routine (required), which performs initialization tasks for a KIM::ComputeArguments object. -# The \em ModelCompute routine (required), which uses the configuration information stored in a KIM::ComputeArguments object to perform the PM's core computational tasks. -# The ModelExtension routine (optional), which provides a mechanism for creating and using non-standard extensions to the %KIM API. -# The ModelRefresh routine (required if parameter pointers are set, otherwise should not be provided), which performs updates after a simulator makes changes to the PM's parameters (if this is supported). -# The ModelWriteParameterizedModel (optional) routine, which can be used to write the parameter files and CMake file necessary to create a new parameterized PM from the current set of in-memory parameters. -# The \em ModelComputeArgumentsDestroy routine (required), which performs finalization tasks for a KIM::ComputeArguments object. -# The ModelDestroy routine (required), which performs finalization tasks for the KIM::Model object. The %KIM API/PMI provides a separate interface to be used by the PM or MD. For each of the routines itemized above, the following table lists (i) the associated KIM::ModelRoutineName extensible enumeration constant, (ii) links to the associated %KIM API/PMI interface(s) available within the routine, (iii) links to the routine's prototype (in C++, C, and Fortran), and (iv) whether the %KIM API/PMI requires a PM or MD to provide the routine, or if it is optional.
Model Routine Name constant %KIM API/PMI Interface Routine prototype (C++; C; Fortran) %KIM API/PMI Required / Optional
KIM::MODEL_ROUTINE_NAME::Create KIM::ModelCreate or
KIM::ModelDriverCreate
KIM::ModelCreateFunction,
KIM::ModelDriverCreateFunction;
\ref KIM_ModelCreateFunction,
\ref KIM_ModelDriverCreateFunction;
kim_model_module::kim_model_create
required
KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate KIM::ModelComputeArgumentsCreate KIM::ModelComputeArgumentsCreateFunction;
\ref KIM_ModelComputeArgumentsCreateFunction;
kim_model_module::kim_model_compute_arguments_create
required
KIM::MODEL_ROUTINE_NAME::Compute KIM::ModelCompute and
KIM::ModelComputeArguments
KIM::ModelComputeFunction;
\ref KIM_ModelComputeFunction;
kim_model_module::kim_model_compute
required
KIM::MODEL_ROUTINE_NAME::Extension KIM::ModelExtension KIM::ModelExtensionFunction;
\ref KIM_ModelExtensionFunction;
kim_model_module::kim_model_extension
optional
KIM::MODEL_ROUTINE_NAME::Refresh KIM::ModelRefresh KIM::ModelRefreshFunction;
\ref KIM_ModelRefreshFunction;
kim_model_module::kim_model_clear_then_refresh
required if one or more parameter pointers set, otherwise should not be provided
KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel KIM::ModelWriteParameterizedModel KIM::ModelWriteParameterizedModelFunction;
\ref KIM_ModelWriteParameterizedModelFunction;
kim_model_module::kim_model_write_parameterized_model
optional
KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy KIM::ModelComputeArgumentsDestroy KIM::ModelComputeArgumentsDestroyFunction;
\ref KIM_ModelComputeArgumentsDestroyFunction;
kim_model_module::kim_model_compute_arguments_destroy
required
KIM::MODEL_ROUTINE_NAME::Destroy KIM::ModelDestroy KIM::ModelDestroyFunction;
\ref KIM_ModelDestroyFunction;
kim_model_module::kim_model_destroy
required
The above table also indicates which routines must be provided by a PM. For optional routines, each PM must indicate that the routine is required or optional for use by the simulator, as described below. \note **Language restrictions implied by the %KIM API/PMI:**
The %KIM API/PMI implements a cross-language object-oriented-like framework. All persistent data (analogous to member variables) needed by a PM or MD object must be stored using the \ref cache_buffer_pointers "Caching Capabilities" of the %KIM API. For the framework to operate correctly, without surprising behavior, PM and MD implementations must obey certain restrictions as described below. \note - C++ The use of static and/or global variables within PM and MD code must be avoided. - C The use of static and/or global variables within PM and MD code must be avoided. - Fortran The use of COMMON blocks must be avoided. The use of the SAVE attribute must be avoided. Thus, variables should not be initialized when they are declared (as this implies the SAVE attribute). Further, the use of module variables, except for those defined with the PARAMETER attribute, must be avoided. (The Fortran 2008 standard requires that all module variables, implicitly, have the SAVE attribute; that is, they are stored in static memory.) Similarly, all Fortran subroutines and functions should have the RECURSIVE attribute (this is the default starting only with the Fortran 2015 standard). This is because without the RECURSIVE attribute compilers are allowed to use static memory for a subroutine's/function's local variables (effectively giving them the SAVE attribute). These restrictions are even more important if thread-safety is required. The use of RECURSIVE subroutines/functions and avoidance of using the SAVE attribute help to assure that memory access conflicts are averted. The %KIM API/PMI provides two interfaces to be used by the Simulator, KIM::Model and KIM::ComputeArguments, for interacting with a PM. The interaction between the simulator and a PM involves the following steps: - A simulator creates a Portable Model object, by calling KIM::Model::Create, that will be used to exchange pointers to data and functions related to the PM between the simulator and PM. Creating this object includes the specification of how the simulator will number particles (zero-based or one-based), determination of the physical base units that the PM will use, and execution of the PM's ModelCreate routine. When calling KIM::Model::Create to create a PM object, the simulator provides a set of "requested" base units that it would prefer to use. The %KIM API/PMI gives the PM final authority to decide on the base units it will use. Best practice for PMs is to respect the request of the simulator and to use the requested base units by converting its parameters appropriately. The \c requestedUnitsAccepted output argument of the KIM::Model::Create routine is a convenience that allows the simulator a short-cut to determine if its request for base units was accepted. (The alternative is for the simulator to call to KIM::Model::GetUnits and compare the results to the requested units.) If a base unit is not relevant to the simulator (e.g., a unit of time is not necessary for static equilibrium computations), then the simulator should specify that the corresponding requested base unit(s) is/are "unused". Similarly, if a base unit is irrelevant to the PM (e.g., many models only require units of length and energy; Thus, units of charge, temperature, and time are irrelevant), then the PM should specify that the corresponding base unit(s) is/are "unused" (regardless of the simulator's requested values) when calling KIM::ModelCreate::SetUnits within its ModelCreate routine. Additionally, the PM should select its preferred (non-"unused") base unit value when the simulator provides a request of "unused" for a relevant base unit. The %KIM API/PMI supports "Toy Models", which are a deliberately simplistic model with many details removed so that it can be used to explain a mechanism concisely. Toy models do not model a real material, but are rather associated with a class of materials (e.g., glasses). Toy PMs should use the "user" species values (KIM::SPECIES_NAME::user01 through KIM::SPECIES_NAME::user20). Some toy models are formulated to be nondimensional. Rather than introducing a new type of nondimensional units to the %KIM API/PMI with accompanying requirements for simulators to support this, toy PMs should define their length base unit as KIM::LENGTH_UNIT::A and their energy base unit as KIM::ENERGY_UNIT::eV. From the perspective of the toy PM these can be considered proxy units (similar to Lennard-Jones units). (See also [Toy Model support within openkim.org](https://openkim.org/about-toy-models).) - Once a PM object is obtained, the simulator should use KIM::Model::IsRoutinePresent to determine which routines the PM has provided and if they are required or optional. From this information the simulator should determine if it can proceed to work with the PM, or if the PM requires the use of routines that are not supported by the simulator it should exit. - Next, the simulator creates a KIM::ComputeArguments object, by calling KIM::Model::ComputeArgumentsCreate, that will be used to exchange pointers to data and functions related to the atomic configuration and values being computed for it. Creating this object includes execution of the PM's ModelComputeArgumentsCreate routine. - Then, to perform a computation, the simulator provides a compute-arguments object to the KIM::Model::Compute routine (which, in part, executes the PM's ModelCompute function). - There are input compute-arguments that include the various components that make up a configuration (number of particles, particle position vectors, etc.). - There are output compute-arguments that include the quantities (like partial energy and partial forces), defined in Section \ref theory, associated with the configuration. - There are also compute-callback functions (such as a function to get a particle's neighbor list) that the simulator provides for use by the PM. - When a simulator is finished working with a PM, it needs to clean up by calling KIM::Model::ComputeArgumentsDestroy (which, in part, executes the PM's ModelComputeArgumentsDestroy routine) to delete each of the compute-arguments objects that were created, and finally calling KIM::Model::Destroy (which, in part, executes the PM's ModelDestroy routine) to delete the KIM::Model object. The %KIM API/PMI provides a list of all compute-arguments and compute-callbacks defined as part of the official API. Each argument and callback has a "Support Status" that can be one of four values: requiredByAPI, notSupported, required, or optional. A PM specifies a support status value, as part of its ModelComputeArgumentsCreate routine, for every compute-argument and compute-callback defined by the %KIM API/PMI. Some arguments and callbacks are required by the %KIM API and can only have a support status of requiredByAPI. All other arguments and callbacks are not required by the %KIM API/PMI, and therefore the PM may set their support status to any one of the three remaining options: required, optional, or notSupported. Just before the PM's ModelComputeArgumentsCreate routine is executed, the %KIM API/PMI initializes the support status of all arguments and callbacks to either requiredByAPI or notSupported, as indicated in the below tables. It is the responsibility of the simulator to use the KIM::ComputeArguments object interface to determine the support status of each compute-argument and compute-callback and to use this information to determine if the PM is capable of performing the desired computation. Below, lists of each input compute-argument, output compute-argument, and compute-callback are provided. To be explicit, zero-based particle numbering is used where necessary. Input compute-argument table: | Compute Argument Name | Unit | Data Type | Extent | Memory Layout | Valid Support Statuses (bold -- default) | | --------------------- | ------ | --------- | --------------------- | ------------------------------------------------------------------ | ---------------------------------------- | | numberOfParticles | N/A | integer | 1 | | requiredByAPI | | particleSpeciesCodes | N/A | integer | numberOfParticles | \f$sc^{(0)}, sc^{(1)}, \dots\f$ | requiredByAPI | | particleContributing | N/A | integer | numberOfParticles | \f$c^{(0)}, c^{(1)}, \dots\f$ | requiredByAPI | | coordinates | length | double | numberOfParticles * 3 | \f$r^{(0)}_1, r^{(0)}_2, r^{(0)}_3, r^{(1)}_1, r^{(1)}_2, \dots\f$ | requiredByAPI | - numberOfParticles is the number of particles (contributing and non-contributing) in the configuration. - particleSpeciesCodes contains integer codes (as defined by the PM) specifying the species of each particle. For example, if the PM defines the mapping Cu \f$\leftrightarrow 1\f$, Al \f$\leftrightarrow 2\f$, and Ni \f$\leftrightarrow 3\f$, then \f$sc^{(0)} = 3, sc^{(1)} = 1, sc^{(2)} = 2, \dots\f$ means that particle 0 is a nickel atom, particle 1 is a copper atom, particle 2 is an aluminum atom. - particleContributing contains the contributing/non-contributing status of each particle. Particle \f$i\f$ is contributing if \f$c^{(i)} = 1\f$ and non-contributing if \f$c^{(i)} = 0\f$. - coordinates contains the Cartesian components of the particles' position vectors, \f$\mathbf{r}^{(i)} = r^{(i)}_1 \mathbf{e}_1 + r^{(i)}_2 \mathbf{e}_2 + r^{(i)}_3 \mathbf{e}_3\f$. Output compute-argument table: | Compute Argument Name | Unit | Data Type | Extent | Memory Layout | Valid Support Statuses (bold -- default) | | ---------------------------------------------------- | -------------------------- | --------- | --------------------- | ----------------------------------------------------------------------- | ---------------------------------------- | | \ref partial_energy "partialEnergy" | energy | double | 1 | | required, optional, notSupported | | \ref partial_forces "partialForces" | force | double | numberOfParticles * 3 | \f$f^{\mathcal{C}(0)}_1, f^{\mathcal{C}(0)}_2, f^{\mathcal{C}(0)}_3, f^{\mathcal{C}(1)}_1, f^{\mathcal{C}(1)}_2\dots\f$ | required, optional, notSupported | | \ref partial_particle_energy "partialParticleEnergy" | energy | double | numberOfParticles | \f$E^{\mathcal{C}}_0, E^{\mathcal{C}}_1, E^{\mathcal{C}}_2, \dots\f$ | required, optional, notSupported | | \ref partial_virial "partialVirial" | energy | double | 6 | \f$V^{\mathcal{C}}_{11}, V^{\mathcal{C}}_{22}, V^{\mathcal{C}}_{33}, V^{\mathcal{C}}_{23}, V^{\mathcal{C}}_{31}, V^{\mathcal{C}}_{12}\f$ | required, optional, notSupported | | \ref partial_particle_virial "partialParticleVirial" | energy | double | numberOfParticles * 6 | \f$\mathbf{V}^{\mathcal{C}(0)}, \mathbf{V}^{\mathcal{C}(1)}, \mathbf{V}^{\mathcal{C}(2)}, \dots\f$ | required, optional, notSupported | - partialEnergy is the configuration's partial energy \f$E^{\mathcal{C}}\f$. - partialForces contains the partial force vector for each particle, \f$\mathbf{f}^{\mathcal{C}(i)} = f^{\mathcal{C}(i)}_1 \mathbf{e}_1 + f^{\mathcal{C}(i)}_2 \mathbf{e}_2 + f^{\mathcal{C}(i)}_3 \mathbf{e}_3\f$. - partialParticleEnergy contains the partial particle energy for each particle, \f$E^{\mathcal{C}}_i\f$. - partialVirial is the configuration's partial virial tensor, \f$\mathbf{V}^{\mathcal{C}}\f$. - partialParticleVirial contains the partial particle virial tensor for each particle, \f$\mathbf{V}^{\mathcal{C}(i)}\f$. Compute-callback table: | Compute Callback Name | Valid Support Statuses (bold -- default) | | --------------------- | ---------------------------------------- | | GetNeighborList | requiredByAPI | | ProcessDEDrTerm | required, optional, notSupported | | ProcessD2EDr2Term | required, optional, notSupported | - GetNeighborList is a callback function that allows a PM to obtain the list of neighbors of a particle. The PM may request any number (\f$\ge1\f$) of neighbor lists with different (or equal) cutoff distances. The GetNeighborList callback function must support the return of the appropriate list of neighbors. The returned list of neighbors consists of a contiguous-in-memory list of integers corresponding to an unordered full list of a particle's neighbors (not including itself). Each such neighbor list must contain at least all particles within the corresponding cutoff distance of the specified particle. (However, the returned list may contain particles beyond the cutoff distance.) Neighbor lists provided by the simulator must be consistent with the configuration coordinates and the PM's cutoff values. In particular, the PM must, in principle, be able to independently construct its own equivalent neighbor list using just the particle coordinates. Further, the GetNeighborList callback routine must check to ensure that the neighbor list data (provided, via the simulator, by the compute-arguments object) is consistent with the PM's cutoff values. CAUTION - SIMULATOR DEVELOPERS: In general, it is important that neighbor lists provided by a simulator are "efficient" in the sense that the list contains only a small number of particles that are located outside the cutoff distance. If the lists are not efficient, then the PM computational time may be severely impacted. This is especially true for PMs that request multiple neighbor lists with a wide range of cutoff distances. Neighbor List Hint \anchor neighbor_list_hint : The above describes the default behavior and all PMs must work correctly when provided with neighbor lists of this type. However, based on the neighbor list hint provided by the PM a simulator may provide the PM with a modified neighbor list that is more efficient. If the PM sets its "modelWillNotRequestNeighborsOfNoncontributingParticles" value to 1 (true), it is guaranteeing that it will not request the neighbors of non-contributing particles. In this case, the simulator does not need to generate a neighbor list for such particles. The PM has no way of knowing if the simulator is taking advantage of its hint, so it must work correctly for all types of neighbor lists consistent with its provided hint. - ProcessDEDrTerm is a callback function that allows for access to the derivatives of the configuration's partial energy, \f$E^{\mathcal{C}}\f$, with respect to all pair-distances, \f$r^{(i,j)}, i,j \in C_{p}\f$. That is, it allows the PM to communicate the values of \f$\frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}}\f$ to the simulator. Recall that \f$r^{(i,j)}\f$ and \f$r^{(j,i)}\f$ are just two different notations for the same quantity. Thus, there are only \f$\frac{\text{numberOfParticles} \cdot (\text{numberOfParticles} + 1)}{2}\f$ quantities (as opposed to \f$(\text{numberOfParticles})^2\f$) referred to by the notation \f$\frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}}\f$. These quantities can be used to compute many quantities of interest associated with the configuration. For example, it is possible to independently compute the partial virial from this information using the formula \f[ \mathbf{V}^{\mathcal{C}} = \sum_{i \in C_p} \sum_{j \in \mathcal{N}^{(i)}_{r_{\text{infl}}}} \;\; \sum_{k \not= j; \; k \in \bar{\mathcal{N}}^{(i)}_{r_{\text{infl}}}} \left(\frac{1}{2 r^{(j,k)}} \frac{\partial \tilde{E}_i}{\partial r^{(j,k)}} \right) \mathbf{r}^{(j,k)} \otimes \mathbf{r}^{(j,k)}. \f] - ProcessD2EDr2Term is a callback function that allows for access to the second derivatives of the configuration's partial energy, \f$E^{\mathcal{C}}\f$, with respect to all pair-distances, \f$r^{(i,j)}, i,j \in C_{p}\f$. That is, it allows the PM to communicate the values of \f$\frac{\partial^2 E^{\mathcal{C}}}{\partial r^{(i,j)} \partial r^{(m,n)}}\f$ to the simulator. See the documentation of the KIM::Model and KIM::ComputeArguments interfaces for more details of the %KIM API/PMI from the simulator's perspective. See the documentation of the KIM::ModelCompute, KIM::ModelComputeArguments, KIM::ModelComputeArgumentsCreate, KIM::ModelComputeArgumentsDestroy, KIM::ModelCreate, KIM::ModelDestroy, KIM::ModelDriverCreate, KIM::ModelExtension, KIM::ModelRefresh, and KIM::ModelWriteParameterizedModel interfaces for more details of the %KIM API/PMI from the PM's perspective. \anchor kim_api_smi ## The KIM API Simulator Model Interface (KIM API/SMI) In code, Simulator Models (SMs) are simply a set of parameter files and a specification file which contains simulator input commands and metadata (supported species, units, etc.) needed to run the model in its native simulator. The %KIM API/SMI consists of the KIM::SimulatorModel interface which provides programatic access to the SM's parameter files and the contents of its specification file. Conceptually, an SM specification file contains a series of key-value pairs. Some key-value pairs are defined and required by the %KIM API/SMI. All other key-value pairs are called "Simulator Fields". For flexibility and generality, the content and meaning of the simulator fields is not defined by the %KIM API/SMI. Instead, each simulator is free to create and define its own set of specifications. The value part of a simulator field key-value pair is one or more strings called "Simulator Field Lines". These strings may contain template tags (of the form "@@") which the KIM::SimulatorModel object will replace by performing template substitution using the "Template Map". The %KIM API/SMI defines a small set of template mappings which facilitate providing copies of the SM's parameter files to the simulator. Additionally, simulators may define their own template mappings and add these to the %KIM API/SMI's set to be used for template substitution. Although the %KIM API/SMI is designed for maximum flexibility, an example of one way it can be used by a simulator to support SMs is helpful. In particular, for the [LAMMPS](https://lammps.sandia.gov) simulator, performing a simulation with a specific model typically involves three separate parts: (1) specifying the physical units in which the model's parameters are given and therefore the units in which the simulation will be performed; (2) specifying other default properties needed by the model which must be set before the LAMMPS simulation box is defined, such as the LAMMPS atom style; and (3) specifying the `pair_style` or other style commands that define the model's interactions and read in the model's parameter files. Here is an example LAMMPS input file for the ReaxFF potential, similar to the CHO example included in the LAMMPS distribution. \code{.unparsed} # REAX potential for CHO system units real atom_style charge neigh_modify every 10 delay 0 check no neighbor 2 bin read_data data.CHO pair_style reax/c lmp_control pair_coeff * * ffield.reax.cho H C O fix reaxqeq all qeq/reax 1 0.0 10.0 1e-6 param.qeq fix 1 all nve fix 2 all temp/berendsen 500.0 500.0 100.0 timestep 0.25 run 100 \endcode In this case, the `units` line corresponds to (1) above. The `atom_style` and `neigh_modify` lines correspond to (2) above. And, the `pair_style`, `pair_coeff`, and `fix reaxqeq` lines correspond to (3) above. The strings "lmp_control", "ffield.reax.cho", and "param.qeq" are parameter file names (which are expected to be in the current working directory, since the names do not start with a '/'). Also of note is the string of parameters "H C O" on the `pair_coeff` line, which specifies a mapping between the species names "H", "C", and "O" used by the ReaxFF model and the LAMMPS atom type numbers 1, 2, and 3, respectively. The number of atom types and their species mapping are part of the simulation, not part of the model. In this case these values are specified within the "data.CHO" input file listed on the `read_data` line. Since the number of atom types and the species map can change from simulation to simulation, any LAMMPS %KIM SM implementation will need a way of specifying the atom type mapping on the `pair_coeff` line. The LAMMPS SM implementation accommodates all of these needs by defining three Simulator Fields, corresponding to the three parts of a LAMMPS model specification discussed above. (1) A "units" field, with a single line containing the LAMMPS unit system string required by the model. (2) A "model-init" field, with zero or more lines containing, in this case, the `atom_style` and `neigh_modify` commands. And (3) a "model-defn" field, with zero or more lines containing, in this case, the `pair_style`, `pair_coeff`, and `fix reaxqeq` commands. In the latter field lines, the correct parameter file names are obtained through the %KIM API/SMI's template substitution mechanism, using the standard template keys for the SM's parameter files. The correct atom type mapping is obtained through a special, LAMMPS defined, template map with key "atom-type-sym-list". The result of all of these considerations and definitions is the following SM specification file (see the \ref kim_api_sm_schema_version_1 "KIM API/SMI Specification File Schema" for details of the file format) for the LAMMPS ReaxFF model. \code{.edn} { "kim-api-sm-schema-version" 1 "model-name" "Sim_LAMMPS_ReaxFF_ChenowethVanDuinGoddard_2008_CHO__SM_584143153761_000" "simulator-name" "LAMMPS" "simulator-version" "28 Feb 2019" "supported-species" "C H O" "units" "real" "model-init" [ "atom_style charge" "neigh_modify one 4000" ] "model-defn" [ "pair_style reax/c @@ safezone 2.0 mincap 100" "pair_coeff * * @@ @@" "fix reaxqeq all qeq/reax 1 0.0 10.0 1.0e-6 @@" ] } \endcode The ordering of the SM's parameter files is specified in the SM's \c CMakeLists.txt configuration file. With this SM defined and installed in one of the %KIM API collections, the following is equivalent to the above LAMMPS input script. \code{.unparsed} # REAX potential for CHO system kim_init Sim_LAMMPS_ReaxFF_ChenowethVanDuinGoddard_2008_CHO__SM_584143153761_000 real neighbor 2 bin read_data data.CHO kim_interactions C H O fix 1 all nve fix 2 all temp/berendsen 500.0 500.0 100.0 timestep 0.25 run 100 \endcode See the documentation of the KIM::SimulatorModel interface for more details of the %KIM API/SMI. Next Section: \ref version2_differences. */ LocalWords: yyyy Ellad Tadmor Karls kim api ref ModelCreate ModelCompute LocalWords: ModelDriverCreate ModelRefresh ModelDestroy requiredByAPI sc Cu LocalWords: notSupported numberOfParticles particleSpeciesCodes Ni mathbf EDr LocalWords: particleContributing leftrightarrow partialEnergy partialForces LocalWords: mathcal partialParticleEnergy partialVirial partialParticleVirial LocalWords: virial GetNeighborList ProcessDEDrTerm ProcessD ac infl otimes em LocalWords: ModelComputeArgumentsCreate ModelComputeArgumentsDestroy ge cdot LocalWords: Modelcompureargumentsdestroy ModelExtension CMake PMI PMs MDs tr LocalWords: modelWillNotRequestNeighborsOfNoncontributingParticles td br PM's LocalWords: ModelWriteParameterizedModel requestedUnitsAccepted SMI SMs SM's LocalWords: metadata programatic SM SMI's nondimensional Lennard openkim org LocalWords: pmi smi PMI ModelCreateFunction ModelDriverCreateFunction LAMMPS LocalWords: ModelComputeArgumentsCreateFunction ModelComputeFunction ReaxFF LocalWords: ModelExtensionFunction ModelRefreshFunction ModelDestroyFunction LocalWords: ModelWriteParameterizedModelFunction CHO REAX reax lmp coeff qeq LocalWords: ModelComputeArgumentsDestroyFunction reaxqeq param nve berendsen LocalWords: timestep endcode init defn sym sm edn Sim ChenowethVanDuinGoddard LocalWords: safezone mincap CMakeLists txt kim-api-2.3.0-git/docs/src/table-of-contents.txt000066400000000000000000000170761421473465500214560ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ /** \mainpage Table of Contents The Knowledgebase of Interatomic Models (%KIM) Application Programming Interface (API) defines a standard (the Portable Model Interface (PMI)) for how molecular simulators interface with interatomic models (also called potentials or force-fields). This allows a single computer implementation of a Portable Model (PM) to be used (without modification) within multiple simulator codes. A PM can include code and parameters all in one. Or, a PM can include just parameters and use a separate Model Driver (MD) library containing the code. See [openkim.org](https://openkim.org) to find many PM implementations, [openkim.org/projects-using-kim](https://openkim.org/projects-using-kim) to learn which simulators support the %KIM API/PMI, and [openkim.org/doc/usage/using-models](https://openkim.org/doc/usage/using-models) to learn how to use %KIM PMs with those simulators. The %KIM API also defines a standard (the Simulator Model Interface (SMI)) that allows for the creation and curation of Simulator Models (SMs), which are packages containing the metadata necessary to set up and run a model that is implemented as an integrated part of a simulation code (simulator). A %KIM SM includes all of the necessary parameter files, simulator input commands, and metadata (supported species, units, etc.) needed to run the model in its native simulator. See [openkim.org](https://openkim.org) to find many SM packages, [openkim.org/projects-using-kim](https://openkim.org/projects-using-kim) to learn which simulators support the %KIM API/SMI, and [openkim.org/doc/usage/using-models](https://openkim.org/doc/usage/using-models) to learn how to use %KIM SMs with those simulators. This documentation describes the specifications and official implementation of the %KIM API as a system-level software library that gives computer programmers the ability to write PM, SM, and/or Simulators in supported programming language (C, C++, Fortran). Table of Contents: -# \ref features -# \ref theory -# [**INSTALL the %KIM API package**](_i_n_s_t_a_l_l_source.html) -# \ref implementation -# Example Portable Models (PMs) written in C++ (\link ../examples/portable-models/LennardJones_Ar LennardJones_Ar\endlink), C (\link ../examples/portable-models/ex_model_Ar_P_Morse_07C ex_model_Ar_P_Morse_07C\endlink, \link ../examples/portable-models/ex_model_Ar_P_Morse_MultiCutoff ex_model_Ar_P_Morse_MultiCutoff\endlink, \link ../examples/portable-models/ex_model_Ar_P_Morse_07C_w_Extensions ex_model_Ar_P_Morse_07C_w_Extensions\endlink) and Fortran (\link ../examples/portable-models/ex_model_Ar_P_MLJ_Fortran ex_model_Ar_P_MLJ_Fortran\endlink, \link ../examples/portable-models/ex_model_Ar_SLJ_MultiCutoff ex_model_Ar_SLJ_MultiCutoff\endlink) -# Example Model Drivers (MDs) written in C++ (\link ../examples/model-drivers/LennardJones612__MD_414112407348_003 LennardJones612__MD_414112407348_003\endlink), C (\link ../examples/model-drivers/ex_model_driver_P_Morse ex_model_driver_P_Morse\endlink), and Fortran (\link ../examples/model-drivers/ex_model_driver_P_LJ ex_model_driver_P_LJ\endlink). -# Example PMs using MDs (\link ../examples/portable-models/ex_model_Ar_P_LJ ex_model_Ar_P_LJ\endlink, \link ../examples/portable-models/ex_model_Ar_P_Morse ex_model_Ar_P_Morse\endlink, \link ../examples/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003 LennardJones612_UniversalShifted__MO_959249795837_003\endlink). -# An Example SM (\link ../examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu\endlink). -# Example Simulators written in C++ ( \link ../examples/simulators/ex_test_Ar_fcc_cluster_cpp ex_test_Ar_fcc_cluster_cpp\endlink, \link ../examples/simulators/collections-example collections-example\endlink, \link ../examples/simulators/simulator-model-example simulator-model-example\endlink), C (\link ../examples/simulators/ex_test_Ar_fcc_cluster ex_test_Ar_fcc_cluster\endlink, \link ../examples/simulators/collections-example collections-example\endlink, \link ../examples/simulators/simulator-model-example simulator-model-example\endlink), and Fortran ( \link ../examples/simulators/ex_test_Ar_fcc_cluster_fortran ex_test_Ar_fcc_cluster_fortran\endlink, \link ../examples/simulators/collections-example collections-example\endlink, \link ../examples/simulators/simulator-model-example simulator-model-example\endlink). -# A utility for checking the consistency between a PM's energy function and its forces function (\link ../examples/simulators/utility_forces_numer_deriv utility_forces_numer_deriv\endlink). This performs a numerical differentiation of the PM's energy, using Ridder's method, and compares the result with the PM's forces. -# \ref cmake_files -# \ref version2_differences -# The [NEWS](_n_e_w_s_source.html) file. In addition, all public header files and included example codes are available for [browsing](files.html). */ LocalWords: yyyy Ellad Tadmor kim api mainpage atomistic interatomic ref LocalWords: Ar fcc cpp fortran MLJ LennardJones hpp LJ params html SLJ org SM LocalWords: MultiCutoff UniversalShifted Knowledgebase openkim PMI PMs SMI em LocalWords: curation SMs metadata MDs Sim LAMMPS LJcut AkersonElliott PbAu pb LocalWords: smspec edn au PM's numer deriv Ridder's kim-api-2.3.0-git/docs/src/theory.txt000066400000000000000000000413151421473465500174350ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* Daniel Karls */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ /** \page theory Theory for the Portable Model Interface Previous Section: \ref features. \anchor energy_per_particle The %KIM API Portable Model Interface (PMI) is concerned with "simulators" and "portable models" (PMs). Conceptually, a %KIM PM is a subprogram that defines an energy-per-particle function, \f$E_i\f$, and an "influence distance", \f$r_{\text{infl}}\f$, that identifies the particle separation range over which \f$E_i\f$ depends on the position of its neighboring particles. (Note, this is not necessarily equal to the neighbor list cutoff radius used by a model.) A %KIM PM is defined for a specific material system (a specific set of particle species: e.g., Al, Ni, and Cu) and contains all parameter values necessary for evaluating \f$E_i\f$ for any configuration containing particles of the supported species. A %KIM PM will, typically, also have the ability to compute other quantities related to the energy-per-particle, such as the force on a particle or the particle's virial. Conceptually, a KIM-PMI-compliant simulator is a computer program that is compatible with the %KIM API/PMI and performs a numerical simulation based on the energy, forces, etc. of a set of particles. This could be a molecular dynamics simulation, a Monte Carlo simulation, or other similar simulation technique. Such a simulator treats a %KIM PM as a black box. It constructs an atomistic "Configuration" of interest and passes this configuration to a %KIM PM along with a list of quantities (energy, force, virial, etc.) to be computed. The model then performs the requested computation and passes the results back to the simulator. Once the simulator has received the model's results it may use these values to advance its simulation and update the atomistic configuration. Typically, this sequence of events is repeated in an iterative process until the simulator determines it has reached convergence or some other stopping condition is achieved. The purpose of the %KIM API/PMI is to coordinate the information exchange between KIM-compliant simulators and %KIM PMs. It does this through the definition of various concepts and quantities, and by providing a set of subroutines that facilitate the necessary communication between simulators and PMs. A simulator supporting the %KIM API/PMI can work with all %KIM PMs (as long as they can agree on units and the necessary species are supported by the model) and vice versa. Of central importance to the information exchange process is the definition of an atomistic "Configuration", \f$\mathcal{C}\f$. Abstractly, a configuration consists of a set of particles \f$C_p\f$ and their associated data. For each particle \f$i \in C_p\f$, the following additional data must be defined. -# The particle's species (H, He, Li, etc.). -# The particle's position vector \f$\mathbf{r}^{(i)} = r^{(i)}_j \mathbf{e}_j = r^{(i)}_1 \mathbf{e}_1 + r^{(i)}_2 \mathbf{e}_2 + r^{(i)}_3 \mathbf{e}_3,\f$ where \f$\mathbf{e}_j, \; j=1,2,3\f$ are unit vectors along the global fixed Cartesian coordinate system \f$x\f$, \f$y\f$, and \f$z\f$ directions, respectively. -# The particle's "Contributing Status", which is either "contributing" or "non-contributing". Non-contributing particles exist as part of the configuration only to provide the proper environment for the contributing particles. Thus, non-contributing particles (sometimes called "ghost" or "padding" particles) can be thought of as providing the appropriate boundary conditions for the configuration. Before proceeding further, we introduce the notation \f$\mathbf{r}^{(i,j)} \equiv \mathbf{r}^{(j)} - \mathbf{r}^{(i)}\f$ for the relative position vector from particle \f$i\f$ to particle \f$j\f$, and the notation \f$r^{(i,j)}\f$ for the magnitude of the vector \f$\mathbf{r}^{(i,j)}\f$. Note that \f$r^{(j,i)} = r^{(i,j)}\f$ and these are simply two different notations for the same quantity. Returning to the definition and description of a configuration, a configuration's set of particles may be partitioned into two disjoint sets: The set of contributing particles \f$C_{cp}\f$, and the set of non-contributing particles \f$C_{ncp}\f$. So that \f[ C_{p} = C_{cp} \cup C_{ncp} \quad \text{and} \quad C_{cp} \cap C_{ncp} = \emptyset. \f] For a particle \f$i \in C_p\f$, define the particle's ("punctured") influence neighborhood, \f$\mathcal{N}^{(i)}_{r_\text{infl}}\f$, as the subset of particles (not including the particle, itself) in the configuration that are located no more than \f$r_{\text{infl}}\f$ away from particle \f$i\f$. That is, \f[ \mathcal{N}^{(i)}_{r_\text{infl}} \equiv \{ j \in C_p \;|\; 0 < r^{(i,j)} \le r_{\text{infl}} \}. \f] Finally, define the closure of the particle's influence neighborhood, \f$\bar{\mathcal{N}}^{(i)}_{r_{\text{infl}}}\f$: \f[ \bar{\mathcal{N}}^{(i)}_{r_{\text{infl}}} \equiv \mathcal{N}^{(i)}_{r_{\text{infl}}} \cup \{i\}. \f] With the above definitions, it is possible to more specifically identify the functional dependence for a %KIM PM's energy-per-particle function, \f$E_i\f$: \f[ E_i = \bar{E}_i(\mathbf{r}^{(j)} \;|\; j \in \bar{\mathcal{N}}^{(i)}_{r_{\text{infl}}}). \f] In fact, due to the principle of material frame indifference, this function must only be a function of the distances between these particles: \f[ E_i = \tilde{E}_i( r^{(j,k)} \;|\; j,k \in \bar{\mathcal{N}}^{(i)}_{r_{\text{infl}}}) . \f] Further, it is required that the energy-per-particle function is independent of the particle numbering. That is, the value of the energy function cannot depend on the order in which the particles are labeled with a unique identification number. It is usually most convenient to work with the function of position vectors, \f$\bar{E}_i(\mathbf{r}^{(j)})\f$. However, in some cases it is advantageous to work with the function of distances, \f$\tilde{E}_i(r^{(j,k)})\f$. When the distinction is unimportant the unaccented notation, \f$E_i\f$, will be used. \anchor partial_energy Now a configuration's "Partial Energy" may be defined as the sum of its contributing particles' energies: \f[ E^\mathcal{C} = \sum_{i \in C_{cp}} E_i. \f] From this definition of the configuration's partial energy, a set of additional quantities may be derived that are often of interest in simulations. \anchor partial_particle_energy First, define formally, the configuration's "Partial Particle Energy" for particle \f$i\f$, \f$E^{\mathcal{C}}_i\f$, as simply the model's energy-per-particle value for contributing particles and zero for non-contributing particles, \f[ E^{\mathcal{C}}_i \equiv \begin{cases} E_i, & i \in C_{cp},\\ 0, & i \in C_{ncp}. \end{cases} \f] \anchor partial_forces Second, the configuration's "Partial Force" on particle \f$j\f$, \f$\mathbf{f}^{\mathcal{C}(j)}\f$, is defined as the negative of the derivative of the configuration's partial energy with respect to the particle's position vector: \f[ \mathbf{f}^{\mathcal{C}(j)} \equiv - \frac{\partial E^{\mathcal{C}}}{\partial \mathbf{r}^{(j)}}, \quad j \in C_{p}. \f] Note that, in general, every particle (both contributing and non-contributing) has a partial force. \anchor partial_virial Third, the configuration's "Partial Virial" tensor, \f$\mathbf{V}^{\mathcal{C}}\f$, is defined in terms of the partial forces: \f[ \mathbf{V}^{\mathcal{C}} \equiv - \sum_{i \in C_{p}} \mathbf{f}^{\mathcal{C}(i)} \otimes \mathbf{r}^{(i)} = \sum_{i \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial \mathbf{r}^{(i)}} \otimes \mathbf{r}^{(i)}, \f] where \f$\otimes\f$ is the tensor product operation. Although the partial virial tensor is given in terms of the absolute particle positions, \f$\mathbf{r}^{(i)}\f$, it can be shown to be independent of the coordinate origin. Indeed, \f{align*}{ \mathbf{V}^{\mathcal{C}} = \sum_{i \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial \mathbf{r}^{(i)}} \otimes \mathbf{r}^{(i)} &= \frac{1}{2} \left[ \sum_{i \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial \mathbf{r}^{(i)}} \otimes \mathbf{r}^{(i)} + \sum_{j \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial \mathbf{r}^{(j)}} \otimes \mathbf{r}^{(j)} \right] \\ &= \frac{1}{2} \left[ \sum_{i \in C_{p}} \sum_{j \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \frac{\partial r^{(i,j)}}{\partial \mathbf{r}^{(i)}} \otimes \mathbf{r}^{(i)} + \sum_{j \in C_{p}} \sum_{i \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial {r}^{(i,j)}} \frac{\partial r^{(i,j)}}{\partial \mathbf{r}^{(j)}} \otimes \mathbf{r}^{(j)} \right] \\ &= \frac{1}{2} \left[ \sum_{i \in C_{p}} \sum_{j \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \frac{\mathbf{r}^{(i,j)}}{r^{(i,j)}} \otimes \mathbf{r}^{(i)} + \sum_{j \in C_{p}} \sum_{i \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial {r}^{(i,j)}} \frac{\mathbf{r}^{(j,i)}}{r^{(i,j)}} \otimes \mathbf{r}^{(j)} \right] \\ &= \frac{1}{2} \left[ \sum_{i \in C_{p}} \sum_{j \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \frac{\mathbf{r}^{(i,j)}}{r^{(i,j)}} \otimes \mathbf{r}^{(i)} + \sum_{j \in C_{p}} \sum_{i \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial {r}^{(i,j)}} \left(-\frac{\mathbf{r}^{(i,j)}}{r^{(i,j)}}\right) \otimes \mathbf{r}^{(j)} \right] \\ &= \frac{1}{2} \left[ \sum_{i \in C_{p}} \sum_{j \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \frac{\mathbf{r}^{(i,j)}}{r^{(i,j)}} \otimes \left(\mathbf{r}^{(i)} - \mathbf{r}^{(j)}\right) \right] \\ &= \frac{1}{2} \left[ \sum_{i \in C_{p}} \sum_{j \in C_{p}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \frac{\mathbf{r}^{(i,j)}}{r^{(i,j)}} \otimes \mathbf{r}^{(i,j)} \right]. \f} So, an equivalent definition for the virial tensor is \f[ \mathbf{V}^{\mathcal{C}} \equiv \sum_{i, j \in C_{p}} \left( \frac{1}{2 r^{(i,j)}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \right) \mathbf{r}^{(i,j)} \otimes \mathbf{r}^{(i,j)}. \f] \anchor partial_particle_virial It is common to partition the partial virial into particle contributions, the "Partial Particle Virial" tensors \f$\mathbf{V}^{\mathcal{C}(i)}\f$ such that \f[ \mathbf{V}^{\mathcal{C}} = \sum_{i \in C_{p}} \mathbf{V}^{\mathcal{C}(i)}. \f] However, this decomposition is not unique, and different definitions of the particle virial tensor are found in the literature. For example, here are two common definitions: \f{gather*}{ \mathbf{V}^{\mathcal{C}(i)} \equiv \sum_{j \in C_{p}} \left( \frac{1}{2 r^{(i,j)}} \frac{\partial E^{\mathcal{C}}}{\partial r^{(i,j)}} \right) \mathbf{r}^{(i,j)} \otimes \mathbf{r}^{(i,j)}; && \mathbf{V}^{\mathcal{C}(i)} \equiv \sum_{j, k \in C_{p}} \left( \frac{1}{2 r^{(j,k)}} \frac{\partial E^{\mathcal{C}}_i}{\partial r^{(j,k)}} \right) \mathbf{r}^{(j,k)} \otimes \mathbf{r}^{(j,k)}. \f} Notice, in the first definition the configuration's partial energy \f$E^{\mathcal{C}}\f$ is used, whereas in the second definition the partial particle energy \f$E^{\mathcal{C}}_i\f$ of particle \f$i\f$ is used. Further, it is obvious by inspection that with these definitions the sum of partial particle virial tensors equals the partial virial tensor. Thus, the %KIM API/PMI does not impose a specific definition for a PM's partial particle virial tensor. It simply requires that the PM's definition satisfies the summation formula \f$\mathbf{V}^{\mathcal{C}} = \sum_{i \in C_{p}} \mathbf{V}^{\mathcal{C}(i)}\f$. ## Domain Decomposition The definitions of a configuration's partial energy, forces, and virial are designed to allow for easy (and low communication) parallel computation via domain decomposition. This section presents a simple example that illustrates how this works. Start with a configuration of particles corresponding to a finite strip of a centered square lattice. \image html square-lattice-configuration-1.jpg \image latex square-lattice-configuration-1.pdf The total energy of the system, particle energy, the total force on each particle, the total virial tensor, and the particle virial tensors can be computed using a single configuration. In this case, the configuration is \f$\mathcal{T}\f$, the set of particles is \f$T_p\f$, the set of contributing particles is \f$T_{cp} = T_p\f$, and the set of non-contributing particles is \f$T_{ncp}=\emptyset\f$. Then, the total energy is \f$E=E^\mathcal{T}\f$, the particle energy is \f$E_i=E^{\mathcal{T}}_i\f$, the total force is \f$\mathbf{f}^{(i)}=\mathbf{f}^{\mathcal{T}(i)}\f$, the total virial tensor is \f$\mathbf{V} = \mathbf{V}^{\mathcal{T}}\f$, and the particle virial tensor \f$\mathbf{V}^{(i)} = \mathbf{V}^{\mathcal{T}(i)}\f$. Next, it is shown how to compute \f$E\f$, \f$E_i\f$, \f$\mathbf{f}^{(i)}\f$, \f$\mathbf{V}\f$, and \f$\mathbf{V}^{(i)}\f$ using a decomposition into two domains. Partition \f$T_p\f$ into two disjoint subsets, \f$A_p\f$ and \f$B_p\f$. That is, \f$A_p \cap B_p = \emptyset\f$ and \f$A_p \cup B_p = T_p\f$. \image html square-lattice-configuration-2.jpg \image latex square-lattice-configuration-2.pdf Next, define configuration \f$\mathcal{C}\f$ to have particles \f$C_p=T_p\f$ with \f$C_{cp}=A_p\f$ and \f$C_{ncp}=B_p\f$, and configuration \f$\mathcal{D}\f$ to have particles \f$D_p=T_p\f$ with \f$D_{cp}=B_p\f$ and \f$D_{ncp}=A_p\f$. (In practice, one can get away with including only those non-contributing particles that fall within the "influence distance" of at least one contributing particle.) Then, we can add up (or "assemble") the values using the contributions from each domain \f{align*}{ E &= E^\mathcal{C} + E^\mathcal{D},\\ \mathbf{f}^{(i)} &= \mathbf{f}^{\mathcal{C}(i)} + \mathbf{f}^{\mathcal{D}(i)},\\ \mathbf{V} &= \mathbf{V}^{\mathcal{C}} + \mathbf{V}^{\mathcal{D}}, \\ \mathbf{V}^{(i)} &= \mathbf{V}^{\mathcal{C}(i)} + \mathbf{V}^{\mathcal{D}(i)}. \f} Here it becomes clear why the %KIM API/PMI prepends the term "Partial" to all of its standard quantity names. In general, the quantities computed by a PM are only one "partial" contribution to a total. For example, here we can say that the force on particle \f$i\f$, \f$\mathbf{f}^{(i)}\f$, is the sum of \f$\mathcal{C}\f$'s partial force \f$\mathbf{f}^{\mathcal{C}(i)}\f$ and \f$\mathcal{D}\f$'s partial force \f$\mathbf{f}^{\mathcal{D}(i)}\f$. For the particle energies, we can just take the value from the (only) domain where the particle is contributing \f[ E_i = \begin{cases} E^{\mathcal{C}}_i & \text{if $i \in C_{cp}$},\\ E^{\mathcal{D}}_i & \text{if $i \in D_{cp}$}. \end{cases} \f] Next Section: \ref implementation. */ LocalWords: yyyy Ellad Tadmor Karls kim api infl Ni Cu virial monte Li LocalWords: carlo atomistic mathcal mathbf equiv ac cp ncp emptyset le otimes LocalWords: unaccented html jpg pdf np ref em PMI PMs PM's kim-api-2.3.0-git/docs/src/version2-differences.txt000066400000000000000000002470421421473465500221520ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /* */ /* Release: This file is part of the kim-api.git repository. */ /* */ /** \page version2_differences Summary of Differences Between kim-api-v1 and kim-api-v2 Previous Section: \ref implementation. \note This section describes version 2.0 of the %KIM API. Additions made in version 2.1 and above to the %KIM API package are not included. Experience with using and supporting the kim-api-v1 package has shown that the package's complexity (in terms of the number of different "modes of operation"; e.g., neighbor lists: half, full, iterator, locator; Neighbor-list Boundary Conditions (NBCs): cluster, miopbc, neigh_pure, neigh_rvec; etc.) makes it difficult for new users to become competent kim-api-v1 code developers. This also means that %KIM Models will only work with KIM-compliant codes that support the same modes of operation, thereby limiting the utility of the kim-api as a standard. Further, the kim-api's complexity results in model implementations that are convoluted due to developers' desire to support all modes of operation. This experience has led us to an approach that gives kim-api-v2 a dramatically simplified form, while still retaining a high degree of flexibility. Thus, in regard to feature design and selection for the kim-api-v2 package, we have taken "simplicity" as a guiding principle. ## High-level changes between kim-api-v1 and kim-api-v2 - NBCs Have Been Eliminated: kim-api-v2 supports only one type of configuration (as described in Section \ref theory). This corresponds, roughly, to the kim-api-v1 NEIGH_PURE_F NBC. Additionally: - All neighbor lists in kim-api-v2 are full, unordered, and random-access. (However, see \ref neighbor_list_hint "Neighbor List Hint".) - Particle Contributing (a.k.a., padding or ghost-atom) status (contributing or non-contributing) is explicitly specified in the particleContributing argument. A particle with zero neighbors in (one of) its neighbor lists has no special meaning in kim-api-v2, as opposed to in kim-api-v1 where this indicates the particle is non-contributing. - Compute Routine Arguments and Callbacks Have Been Separated From the Model Object: kim-api-v2 separates the arguments and callbacks of the compute routine from the model object. These items are now stored in a separate compute-arguments object that must be provided to the model's compute routine. This new approach provides a cleaner conceptual distinction between things the model is responsible for (influence distance, cutoffs, parameters, and create / compute / destroy routines), and things that the simulator is responsible for (the configuration, compute-arguments, and compute-callback routines). One practical advantage of this separation occurs for multi-threaded simulators. Such a simulator can use a single model object with multiple compute-arguments objects to compute (energy, forces, etc.) for many different configurations simultaneously. Without the model/compute-arguments separation multiple model objects would be necessary. This would require multiple in-memory copies of the model's parameter set, which can be very wasteful since (in particular, for "machine learning" models) a model's parameter set can be very large. - %KIM Descriptor Files Have Been Eliminated: kim-api-v2 does not use %KIM descriptor files. Instead, kim-api-v2 models register their units, conventions, and parameters in their ModelCreate initialization routine, and they register their arguments and callbacks in their ModelComputeArgumentsCreate initialization routine. Simulator--model matching is now the responsibility of the simulator. This is facilitated by kim-api-v2 through the availability of routines for obtaining the model's registered values of all necessary quantities at run-time. Best practice for kim-api-v2 simulators is to, first create a model object and an associated compute-arguments object (which also execute the model's initialization routines), second interrogate the model's capabilities to determine if the desired computation can be successfully performed with the model, and third, if possible, perform the desired computation. This scheme for simulator--model matching places a larger burden (as compared to kim-api-v1) on the simulator. However, it has been determined that a full-featured "KIM descriptor file"--based matching specification (covering all possibilities) is too complex. Thus, it is best to perform this matching process in the simulator's code at run-time. In the worst-case, a simulator can simply assume that it matches with the model and attempt to perform the desired computation. As long as the simulator carefully checks for any and all errors reported by the %KIM API, it should detect an error at some point during its processing if the simulator, in fact, does not match with the model. - A New Memory Management Scheme: kim-api-v2 requires the simulator to be responsible for storage memory associated with all input and output compute-arguments communicated between the simulator and the model via a compute-arguments object. Similarly, kim-api-v2 requires the model to be responsible for storage memory associated with its influence distance, its neighbor list cutoff values, and its published parameters. kim-api-v2 does not provide a routine analogous to the KIM_API_Allocate() of kim-api-v1. This routine is now seen as a source of much confusion regarding the memory management model employed in kim-api-v1. Thus, it is best not to provide such a capability as part of kim-api-v2. - Language Consistency: kim-api-v2 aims to conform to standard practice and idioms of the native code language, as opposed to kim-api-v1 which aimed to maintain consistency of the api across languages. This means that using the kim-api-v2 in your preferred language feels more natural. For example, the C++ api bindings extensively use namespaces, objects, std::string, and error codes as function return values. The Fortran api binding provides error codes as arguments to SUBROUTINES, uses handles to objects, and hides (as much as possible) the effort of making Fortran interoperable with C and other languages. In particular, the need for explicit use of the intrinsic C_F_POINTER() subroutine has been minimized. Consistent identifier naming schemes have been established within each language binding. Abbreviations have been avoided to make names easier to remember. - Explicit Definitions: Clear definitions for all concepts used by the kim-api-v2 package are provided in Section \ref theory. In most cases, these are the same concepts and definitions employed by kim-api-v1. However, they were not explicitly stated in the kim-api-v1 documentation. - Improved Logging Facilities and Error Messages: kim-api-v2 has been redesigned and rewritten from the ground up. Significantly improved facilities for logging events and execution progress have been included. Along with these general enhancements, all error messages have been rewritten with an eye toward improved clarity. ## Lower-level changes between kim-api-v2 and kim-api-v1 - FIXED Parameters Have Been Eliminated: kim-api-v2 defines only one type of "published" parameters for a model. These are all changeable, and thus, would correspond to the "FREE" parameters of kim-api-v1. The FIXED parameters of kim-api-v1 must now be stored in the model buffer and are inaccessible to the simulator. - Argument Shape and Extent: For simplicity, explicit api tracking of argument shape and extent has been eliminated from kim-api-v2. These values are defined as part of the api documentation. All arguments must have fixed shape and extent values that are either given numbers or defined in terms of numberOfParticles. Published model parameters are always taken to be one-dimensional arrays with a specified extent that must be defined by the model and communicated to the API through the get/set routines for parameters. Thus, scalar parameters have extent 1. Multidimensional array parameters are treated by the API as one-dimensional arrays with extent equal to the total number of values in the multidimensional array. - Extensible Strongly-Typed Enumerations: kim-api-v2 uses \ref extensible_enumeration "extensible strongly-typed enumerations" as identifiers for quantities as opposed to kim-api-v1 which uses character arrays (strings) or "index" values. Thus, all "index" values and the associated routines (such as KIM_API_get_index()) have been eliminated. Each of the extensible enumerations in kim-api-v2 has an interface for discovering and comparing all of the members of the enumeration. Discovery is implemented using two functions. One provides the number of members in the enumeration, and the other provides a copy of the \f$i\f$-th enumeration member. (The ordering is undefined, but guaranteed to be stable during any single run-time program execution using the %KIM API.) The various discovery and comparison routines are listed in the table below. - Consistent and Descriptive Identifier Names: The entire set of kim-api-v2 identifier names (namespace, module, object, subroutine, function, enumerations) have been reviewed and selected for clarity and consistency. As a result many of the identifier names from kim-api-v1 have changed in kim-api-v2. Here we provide complete tables of \ref routine_id_table "routine names", \ref external_enum_id_table "external enumeration constants", and \ref external_enum_discovery_table "external enumeration discovery routines". Routine identifier name table \anchor routine_id_table :
kim-api-v1 kim-api-v2 C++ Binding kim-api-v2 C Binding kim-api-v2 Fortran Binding
KIM_API_file_init() N/A N/A N/A
KIM_API_string_init() KIM::Model::Create() KIM_Model_Create() kim_model_module::kim_model_create()
N/A KIM::ModelCreate::SetModelNumbering()
KIM::ModelDriverCreate::SetModelNumbering()
KIM_ModelCreate_SetModelNumbering()
KIM_ModelDriverCreate_SetModelNumbering()
kim_model_create_module::kim_set_model_numbering()
kim_model_driver_create_module::kim_set_model_numbering()
N/A KIM::Model::IsRoutinePresent() KIM_Model_IsRoutinePresent() kim_model_module::kim_is_routine_present()
N/A KIM::Model::ComputeArgumentsCreate() KIM_Model_ComputeArgumentsCreate() kim_model_module::kim_compute_arguments_create()
N/A KIM::Model::ComputeArgumentsDestroy() KIM_Model_ComputeArgumentsDestroy() kim_model_module::kim_compute_arguments_destroy()
KIM_API_get_version() KIM::SEM_VER::GetSemVer() KIM_SEM_VER_GetSemVer() kim_sem_ver_module::kim_get_sem_ver()
KIM_API_get_version_major() KIM::SEM_VER::ParseSemVer() KIM_SEM_VER_ParseSemVer() kim_sem_ver_module::kim_parse_sem_ver()
KIM_API_get_version_minor() KIM::SEM_VER::ParseSemVer() KIM_SEM_VER_ParseSemVer() kim_sem_ver_module::kim_parse_sem_ver()
KIM_API_get_version_prerelease() KIM::SEM_VER::ParseSemVer() KIM_SEM_VER_ParseSemVer() kim_sem_ver_module::kim_parse_sem_ver()
KIM_API_get_version_metadata() KIM::SEM_VER::ParseSemVer() KIM_SEM_VER_ParseSemVer() kim_sem_ver_module::kim_parse_sem_ver()
KIM_API_get_version_newer() KIM::SEM_VER::IsLessThan() KIM_SEM_VER_IsLessThan() kim_sem_ver_module::kim_is_less_than()
KIM_API_model_info() N/A N/A N/A
KIM_API_allocate() N/A N/A N/A
KIM_API_c_free() N/A N/A N/A
KIM_API_free() N/A N/A N/A
KIM_API_print() KIM::ComputeArguments::ToString()
KIM::Model::ToString()
KIM::ModelCompute::ToString()
KIM::ModelComputeArguments::ToString()
KIM::ModelComputeArgumentsCreate::ToString()
KIM::ModelComputeArgumentsDestroy::ToString()
KIM::ModelCreate::ToString()
KIM::ModelExtension::ToString()
KIM::ModelDestroy::ToString()
KIM::ModelDriverCreate::ToString()
KIM::ModelRefresh::ToString()
KIM::ModelWriteParameterizedModel::ToString()
KIM_ComputeArguments_ToString()
KIM_Model_ToString()
KIM_ModelCompute_ToString()
KIM_ModelComputeArguments_ToString()
KIM_ModelComputeArgumentsCreate_ToString()
KIM_ModelComputeArgumentsDestroy_ToString()
KIM_ModelCreate_ToString()
KIM_ModelExtension_ToString()
KIM_ModelDestroy_ToString()
KIM_ModelDriverCreate_ToString()
KIM_ModelRefresh_ToString()
KIM_ModelWriteParameterizedModel_ToString()
kim_compute_arguments_module::kim_to_string()
kim_model_module::kim_to_string()
kim_model_compute_module::kim_to_string()
kim_model_compute_arguments_module::kim_to_string()
kim_model_compute_arguments_create_module::kim_to_string()
kim_model_compute_arguments_destroy_module::kim_to_string()
kim_model_create_module::kim_to_string()
kim_model_extension_module::kim_to_string()
kim_model_destroy_module::kim_to_string()
kim_model_driver_create_module::kim_to_string()
kim_model_refresh_module::kim_to_string()
kim_model_write_parameterized_model_module::kim_to_string()
KIM_API_model_compute() KIM::Model::Compute() KIM_Model_Compute() kim_model_module::kim_compute()
N/A KIM::Model::Extension() KIM_Model_Extension() kim_model_module::kim_extension()
N/A KIM::Model::WriteParameterizedModel() KIM_Model_WriteParameterizedModel() kim_model_module::kim_write_parameterized_model()
KIM_API_model_destroy() KIM::Model::Destroy() KIM_Model_Destroy() kim_model_module::kim_model_destroy()
KIM_API_set_model_buffer() KIM::ModelComputeArguments::SetModelBufferPointer()
KIM::ModelCreate::SetModelBufferPointer()
KIM::ModelDriverCreate::SetModelBufferPointer()
KIM::ModelComputeArgumentsCreate::SetModelBufferPointer()
KIM_ModelComputeArguments_SetModelBufferPointer()
KIM_ModelCreate_SetModelBufferPointer()
KIM_ModelDriverCreate_SetModelBufferPointer()
KIM_ModelComputeArgumentsCreate_SetModelBufferPointer()
kim_model_compute_arguments_module::kim_set_model_buffer_pointer()
kim_model_create_module::kim_set_model_buffer_pointer()
kim_model_driver_create_module::kim_set_model_buffer_pointer()
kim_model_compute_arguments_create_module::kim_set_model_buffer_pointer()
KIM_API_set_sim_buffer() KIM::Model::SetSimulatorBufferPointer()
KIM::ComputeArguments::SetSimulatorBufferPointer()
KIM_Model_SetSimulatorBufferPointer()
KIM_ComputeArguments_SetSimulatorBufferPointer()
kim_model_module::kim_set_simulator_buffer_pointer()
kim_compute_arguments_module::kim_set_simulator_buffer_pointer()
KIM_API_get_model_buffer() KIM::ModelCompute::GetModelBufferPointer()
KIM::ModelExtension::GetModelBufferPointer()
KIM::ModelComputeArguments::GetModelBufferPointer()
KIM::ModelDestroy::GetModelBufferPointer()
KIM::ModelRefresh::GetModelBufferPointer()
KIM::ModelComputeArguments::GetModelBufferPointer()
KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer()
KIM::ModelWriteParameterizedModel::GetModelBufferPointer()
KIM_ModelCompute_GetModelBufferPointer()
KIM_ModelExtension_GetModelBufferPointer()
KIM_ModelComputeArguments_GetModelBufferPointer()
KIM_ModelDestroy_GetModelBufferPointer()
KIM_ModelRefresh_GetModelBufferPointer()
KIM_ModelComputeArguments_GetModelBufferPointer()
KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer()
KIM_ModelWriteParameterizedModel_GetModelBufferPointer()
kim_model_compute_module::kim_get_model_buffer_pointer()
kim_model_extension_module::kim_get_model_buffer_pointer()
kim_model_compute_arguments_module::kim_get_model_buffer_pointer()
kim_model_destroy_module::kim_get_model_buffer_pointer()
kim_model_refresh_module::kim_get_model_buffer_pointer()
kim_model_compute_arguments_module::kim_get_model_buffer_pointer()
kim_model_compute_arguments_destroy_module::kim_get_model_buffer_pointer()
kim_model_write_parameterized_model_module::kim_get_model_buffer_pointer()
KIM_API_get_sim_buffer() KIM::Model::GetSimulatorBufferPointer()
KIM::ComputeArguments::GetSimulatorBufferPointer()
KIM_Model_GetSimulatorBufferPointer()
KIM_ComputeArguments_GetSimulatorBufferPointer()
kim_model_module::kim_get_simulator_buffer_pointer()
kim_compute_arguments_module::kim_get_simulator_buffer_pointer()
KIM_API_is_half_neighbors() N/A N/A N/A
KIM_API_set_data() KIM::ComputeArguments::SetArgumentPointer() KIM_ComputeArguments_SetArgumentPointerInteger()
KIM_ComputeArguments_SetArgumentPointerDouble()
kim_compute_arguments_module::kim_set_argument_pointer()
N/A KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus() KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus() kim_model_compute_arguments_create_module::kim_set_argument_support_status()
N/A KIM::ComputeArguments::GetArgumentSupportStatus() KIM_ComputeArguments_GetArgumentSupportStatus() kim_compute_arguments_module::kim_get_argument_support_status()
N/A KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus() KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus() kim_model_compute_arguments_create_module::kim_set_callback_support_status()
N/A KIM::ComputeArguments::GetCallbackSupportStatus() KIM_ComputeArguments_GetCallbackSupportStatus() kim_compute_arguments_module::kim_get_callback_support_status()
KIM_API_set_method() KIM::ComputeArguments::SetCallbackPointer() KIM_ComputeArguments_SetCallbackPointer() kim_compute_arguments_module::kim_set_callback_pointer()
KIM_API_get_data() KIM::ModelComputeArguments::GetArgumentPointer() KIM_ModelComputeArguments_GetArgumentPointerInteger()
KIM_ModelComputeArguments_GetArgumentPointerDouble()
kim_model_compute_arguments_module::kim_get_argument_pointer()
KIM_API_get_method() N/A N/A N/A
N/A KIM::ModelComputeArguments::IsCallbackPresent() KIM_ModelComputeArguments_IsCallbackPresent() kim_model_compute_arguments_module::kim_is_callback_present()
N/A KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent() KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent() kim_compute_arguments_module::kim_are_all_required_present()
KIM_API_get_size() N/A N/A N/A
KIM_API_get_rank() N/A N/A N/A
KIM_API_get_shape() N/A N/A N/A
KIM_API_set_shape() N/A N/A N/A
KIM_API_set_compute() N/A N/A N/A
KIM_API_get_compute() N/A N/A N/A
N/A KIM::ModelCreate::SetInfluenceDistancePointer()
KIM::ModelDriverCreate::SetInfluenceDistancePointer()
KIM::ModelRefresh::SetInfluenceDistancePointer()
KIM_ModelCreate_SetInfluenceDistancePointer()
KIM_ModelDriverCreate_SetInfluenceDistancePointer()
KIM_ModelRefresh_SetInfluenceDistancePointer()
kim_model_create_module::kim_set_influence_distance_pointer()
kim_model_driver_create_module::kim_set_influence_distance_pointer()
kim_model_refresh_module::kim_set_influence_distance_pointer()
N/A KIM::Model::GetInfluenceDistance() KIM_Model_GetInfluenceDistance() kim_model_module::kim_get_influence_distance()
N/A KIM::Model::GetNeighborListPointers() KIM_Model_GetNeighborListPointers() kim_model_module::kim_get_number_of_neighbor_lists()

kim_model_module::kim_get_neighbor_list_values()
N/A KIM::ModelCreate::SetNeighborListPointers()
KIM::ModelDriverCreate::SetNeighborListPointers()
KIM::ModelRefresh::SetNeighborListPointers()
KIM_ModelCreate_SetNeighborListPointers()
KIM_ModelDriverCreate_SetNeighborListPointers()
KIM_ModelRefresh_SetNeighborListPointers()
kim_model_create_module::kim_set_neighbor_list_pointers()
kim_model_driver_create_module::kim_set_neighbor_list_pointers()
kim_model_refresh_module::kim_set_neighbor_list_pointers()
N/A KIM::ModelCreate::SetRoutinePointer()
KIM::ModelDriverCreate::SetRoutinePointer()
KIM_ModelCreate_SetRoutinePointer()
KIM_ModelDriverCreate_SetRoutinePointer()
kim_model_create_module::kim_set_routine_pointer()
kim_model_driver_create_module::kim_set_routine_pointer()
KIM_API_get_index() N/A N/A N/A
KIM_API_model_init() N/A N/A N/A
KIM_API_model_reinit() KIM::Model::ClearThenRefresh() KIM_Model_ClearThenRefresh() kim_model_module::kim_clear_then_refresh()
KIM_API_get_num_model_species() N/A N/A N/A
KIM_API_get_model_species() KIM::Model::GetSpeciesSupportAndCode() KIM_Model_GetSpeciesSupportAndCode() kim_model_module::kim_get_species_support_and_code()
KIM_API_get_num_sim_species() N/A N/A N/A
KIM_API_get_sim_species() N/A N/A N/A
N/A KIM::ModelDriverCreate::GetNumberOfParameterFiles() KIM_ModelDriverCreate_GetNumberOfParameterFiles() kim_model_driver_create_module::kim_get_number_of_parameter_files()
N/A KIM::ModelDriverCreate::GetParameterFileName() KIM_ModelDriverCreate_GetParameterFileName() kim_model_driver_create_module::kim_get_parameter_file_name()
KIM_API_get_num_params() KIM::Model::GetNumberOfParameters() KIM_Model_GetNumberOfParameters() kim_model_module::kim_get_number_of_parameters()
KIM_API_get_parameter() KIM::Model::GetParameter() KIM_Model_GetParameterInteger()
KIM_Model_GetParameterDouble()
kim_model_module::kim_get_parameter()
N/A KIM::Model::SetParameter() KIM_Model_SetParameterInteger()
KIM_Model_SetParameterDouble()
kim_model_module::kim_set_parameter()
N/A KIM::Model::GetParameterMetadata() KIM_Model_GetParameterMetadata() kim_model_module::kim_get_parameter_metadata()
N/A KIM::ModelCreate::SetParameterPointer()
KIM::ModelDriverCreate::SetParameterPointer()
KIM_ModelCreate_SetParameterPointerInteger()
KIM_ModelCreate_SetParameterPointerDouble()
KIM_ModelDriverCreate_SetParameterPointerInteger()
KIM_ModelDriverCreate_SetParameterPointerDouble()
kim_model_create_module::kim_set_parameter_pointer()
kim_model_driver_create_module::kim_set_parameter_pointer()
KIM_API_get_num_free_params() N/A N/A N/A
KIM_API_get_free_parameter() N/A N/A N/A
KIM_API_get_num_fixed_params() N/A N/A N/A
KIM_API_get_fixed_parameter() N/A N/A N/A
KIM_API_get_NBC_method() N/A N/A N/A
KIM_API_get_species_code() KIM::Model::GetSpeciesSupportAndCode() KIM_Model_GetSpeciesSupportAndCode() kim_model_module::kim_get_species_support_and_code()
KIM_API_set_species_code() KIM::ModelCreate::SetSpeciesCode()
KIM::ModelDriverCreate::SetSpeciesCode()
KIM_ModelCreate_SetSpeciesCode()
KIM_ModelDriverCreate_SetSpeciesCode()
kim_model_create_module::kim_set_species_code()
kim_model_driver_create_module::kim_set_species_code()
KIM_API_get_model_kim_str_len() N/A N/A N/A
KIM_API_get_model_kim_str() N/A N/A N/A
KIM_API_get_neigh_mode() N/A N/A N/A
KIM_API_get_neigh() KIM::ModelComputeArguments::GetNeighborList() KIM_ModelComputeArguments_GetNeighborList() kim_model_compute_arguments_module::kim_get_neighbor_list()
KIM_API_process_dEdr() KIM::ModelComputeArguments::ProcessDEDrTerm() KIM_ModelComputeArguments_ProcessDEDrTerm() kim_model_compute_arguments_module::kim_process_dedr_term()
KIM_API_process_d2Edr2() KIM::ModelComputeArguments::ProcessD2EDr2Term() KIM_ModelComputeArguments_ProcessD2EDr2Term() kim_model_compute_arguments_module::kim_process_d2edr2_term()
KIM_API_get_status_msg() N/A N/A N/A
KIM_API_report_error() KIM::Log::LogEntry()
KIM::ModelCreate::LogEntry()
KIM::ModelCompute::LogEntry()
KIM::ModelExtension::LogEntry()
KIM::ModelRefresh::LogEntry()
KIM::ModelDestroy::LogEntry()
KIM::ModelComputeArguments::LogEntry()
KIM::ModelComputeArgumentsCreate::LogEntry()
KIM::ModelComputeArgumentsDestroy::LogEntry()
KIM::ModelDriverCreate::LogEntry()
KIM::ModelWriteParameterizedModel::LogEntry()
KIM_Log_LogEntry()
KIM_ModelCreate_LogEntry()
KIM_ModelCompute_LogEntry()
KIM_ModelExtension_LogEntry()
KIM_ModelRefresh_LogEntry()
KIM_ModelDestroy_LogEntry()
KIM_ModelComputeArguments_LogEntry()
KIM_ModelComputeArgumentsCreate_LogEntry()
KIM_ModelComputeArgumentsDestroy_LogEntry()
KIM_ModelDriverCreate_LogEntry()
KIM_ModelWriteParameterizedModel_LogEntry()
kim_log_module::kim_log_entry()
kim_model_create_module::kim_log_entry()
kim_model_compute_module::kim_log_entry()
kim_model_extension_module::kim_log_entry()
kim_model_refresh_module::kim_log_entry()
kim_model_destroy_module::kim_log_entry()
kim_model_compute_arguments_module::kim_log_entry()
kim_model_compute_arguments_create_module::kim_log_entry()
kim_model_compute_arguments_destroy_module::kim_log_entry()
kim_model_driver_create_module::kim_log_entry()
kim_model_write_parameterized_model_module::kim_log_entry()
N/A KIM::Log::Create() KIM_Log_Create() kim_log_module::kim_log_create()
N/A KIM::Log::Destroy() KIM_Log_Destroy() kim_log_module::kim_log_destroy()
N/A KIM::Log::PushDefaultVerbosity() KIM_Log_PushDefaultVerbosity() kim_log_module::kim_push_default_verbosity()
N/A KIM::Log::PopDefaultVerbosity() KIM_Log_PopDefaultVerbosity() kim_log_module::kim_pop_default_verbosity()
N/A KIM::Log::GetID() KIM_Log_GetID() kim_log_module::kim_get_id()
N/A KIM::Log::SetID() KIM_Log_SetID() kim_log_module::kim_set_id()
N/A KIM::Log::PushVerbosity() KIM_Log_PushVerbosity() kim_log_module::kim_push_verbosity()
N/A KIM::Log::PopVerbosity() KIM_Log_PopVerbosity() kim_log_module::kim_pop_verbosity()
N/A KIM::Model::SetLogID()
KIM::ComputeArguments::SetLogID()
KIM_Model_SetLogID()
KIM_ComputeArguments_SetLogID()
kim_model_module::kim_set_log_id()
kim_compute_arguments_module::kim_set_log_id()
N/A KIM::Model::PushLogVerbosity()
KIM::ComputeArguments::PushLogVerbosity()
KIM_Model_PushLogVerbosity()
KIM_ComputeArguments_PushLogVerbosity()
kim_model_module::kim_push_log_verbosity()
kim_compute_arguments_module::kim_push_log_verbosity()
N/A KIM::Model::PopLogVerbosity()
KIM::ComputeArguments::PopLogVerbosity()
KIM_Model_PopLogVerbosity()
KIM_ComputeArguments_PopLogVerbosity()
kim_model_module::kim_pop_log_verbosity()
kim_compute_arguments_module::kim_pop_log_verbosity()
KIM_API_get_scale_conversion() KIM::ModelCreate::ConvertUnit()
KIM::ModelDriverCreate::ConvertUnit()
KIM_ModelCreate_ConvertUnit()
KIM_ModelDriverCreate_ConvertUnit()
kim_model_create_module::kim_convert_unit()
kim_model_driver_create_module::kim_convert_unit()
KIM_API_get_unit_handling() N/A N/A N/A
KIM_API_get_unit_length() KIM::Model::GetUnits() KIM_Model_GetUnits() kim_model_module::kim_get_units()
KIM_API_get_unit_energy() KIM::Model::GetUnits() KIM_Model_GetUnits() kim_model_module::kim_get_units()
KIM_API_get_unit_charge() KIM::Model::GetUnits() KIM_Model_GetUnits() kim_model_module::kim_get_units()
KIM_API_get_unit_temperature() KIM::Model::GetUnits() KIM_Model_GetUnits() kim_model_module::kim_get_units()
KIM_API_get_unit_time() KIM::Model::GetUnits() KIM_Model_GetUnits() kim_model_module::kim_get_units()
N/A KIM::ModelCreate::SetUnits()
KIM::ModelDriverCreate::SetUnits()
KIM_ModelCreate_SetUnits()
KIM_ModelDriverCreate_SetUnits()
kim_model_create_module::kim_set_units()
kim_model_driver_create_module::kim_set_units()
KIM_API_convert_to_act_unit() N/A N/A N/A
KIM_API_set_data_by_index() N/A N/A N/A
KIM_API_set_method_by_index() N/A N/A N/A
KIM_API_get_data_by_index() N/A N/A N/A
KIM_API_get_method_by_index() N/A N/A N/A
KIM_API_get_size_by_index() N/A N/A N/A
KIM_API_get_rank_by_index() N/A N/A N/A
KIM_API_get_shape_by_index() N/A N/A N/A
KIM_API_set_compute_by_index() N/A N/A N/A
KIM_API_get_compute_by_index() N/A N/A N/A
KIM_API_getm_compute() N/A N/A N/A
KIM_API_setm_compute() N/A N/A N/A
KIM_API_getm_compute_by_index() N/A N/A N/A
KIM_API_setm_compute_by_index() N/A N/A N/A
KIM_API_getm_data() N/A N/A N/A
KIM_API_getm_method() N/A N/A N/A
KIM_API_setm_data() N/A N/A N/A
KIM_API_setm_method() N/A N/A N/A
KIM_API_getm_data_by_index() N/A N/A N/A
KIM_API_getm_method_by_index() N/A N/A N/A
KIM_API_setm_data_by_index() N/A N/A N/A
KIM_API_setm_method_by_index() N/A N/A N/A
KIM_API_getm_index() N/A N/A N/A
N/A KIM::ModelExtension::GetExtensionID() \ref KIM_ModelExtension_GetExtensionID() kim_model_extension_module::kim_get_extension_id()
N/A KIM::ModelExtension::Model() \ref KIM_ModelExtension_ToModel() kim_model_extension_module::kim_to_model()
N/A KIM::ModelExtension::ModelCompute() \ref KIM_ModelExtension_ToModelCompute() kim_model_extension_module::kim_to_model_compute()
N/A KIM::ModelExtension::ModelCreate() \ref KIM_ModelExtension_ToModelCreate() kim_model_extension_module::kim_to_model_create()
N/A KIM::ModelExtension::ModelDestroy() \ref KIM_ModelExtension_ToModelDestroy() kim_model_extension_module::kim_to_model_destroy()
N/A KIM::ModelExtension::ModelDriverCreate() \ref KIM_ModelExtension_ToModelDriverCreate() kim_model_extension_module::kim_to_model_driver_create()
N/A KIM::ModelExtension::ModelRefresh() \ref KIM_ModelExtension_ToModelRefresh() kim_model_extension_module::kim_to_model_refresh()
N/A KIM::ModelExtension::ModelWriteParameterizedModel() \ref KIM_ModelExtension_ToModelWriteParameterizedModel() kim_model_extension_module::kim_to_model_write_parameterized_model()
N/A KIM::ModelExtension::ModelComputeArguments() \ref KIM_ModelExtension_ToModelComputeArguments() kim_model_extension_module::kim_to_model_compute_arguments()
N/A KIM::ModelExtension::ModelComputeArgumentsCreate() \ref KIM_ModelExtension_ToModelComputeArgumentsCreate() kim_model_extension_module::kim_to_model_compute_arguments_create()
N/A KIM::ModelExtension::ModelComputeArgumentsDestroy() \ref KIM_ModelExtension_ToModelComputeArgumentsDestroy() kim_model_extension_module::kim_to_model_compute_arguments_destroy()
N/A KIM::ModelWriteParameterizedModel::GetPath() \ref KIM_ModelWriteParameterizedModel_GetPath() kim_model_write_parameterized_model_module::kim_get_path()
N/A KIM::ModelWriteParameterizedModel::GetModelName() \ref KIM_ModelWriteParameterizedModel_GetModelName() kim_model_write_parameterized_model_module::kim_get_model_name()
N/A KIM::ModelWriteParameterizedModel::SetParameterFileName() \ref KIM_ModelWriteParameterizedModel_SetParameterFileName() kim_model_write_parameterized_model_module::kim_set_parameter_file_name()
N/A KIM::ModelWriteParameterizedModel::GetPath() \ref KIM_ModelWriteParameterizedModel_GetPath() kim_model_write_parameterized_model_module::kim_get_path()


Extensible enumeration identifier name table \anchor external_enum_id_table :
kim-api-v1 kim-api-v2 C++ Binding kim-api-v2 C Binding kim-api-v2 Fortran Binding
"numberOfParticles" KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles \ref KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles kim_compute_argument_name_module::kim_compute_argument_name_number_of_particles
"particleSpecies" KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes \ref KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes kim_compute_argument_name_module::kim_compute_argument_name_particle_species_codes
N/A KIM::COMPUTE_ARGUMENT_NAME::particleContributing \ref KIM_COMPUTE_ARGUMENT_NAME_particleContributing kim_compute_argument_name_module::kim_compute_argument_name_particle_contributing
"coordinates" KIM::COMPUTE_ARGUMENT_NAME::coordinates \ref KIM_COMPUTE_ARGUMENT_NAME_coordinates kim_compute_argument_name_module::kim_compute_argument_name_coordinates
"energy" KIM::COMPUTE_ARGUMENT_NAME::partialEnergy \ref KIM_COMPUTE_ARGUMENT_NAME_partialEnergy kim_compute_argument_name_module::kim_compute_argument_name_partial_energy
"forces" KIM::COMPUTE_ARGUMENT_NAME::partialForces \ref KIM_COMPUTE_ARGUMENT_NAME_partialForces kim_compute_argument_name_module::kim_compute_argument_name_partial_forces
"particleEnergy" KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy \ref KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy kim_compute_argument_name_module::kim_compute_argument_name_partial_particle_energy
"virial" KIM::COMPUTE_ARGUMENT_NAME::partialVirial \ref KIM_COMPUTE_ARGUMENT_NAME_partialVirial kim_compute_argument_name_module::kim_compute_argument_name_partial_virial
"particleVirial" KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial \ref KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial kim_compute_argument_name_module::kim_compute_argument_name_partial_particle_virial
"cutoff" N/A N/A N/A
"numberContributingParticles" N/A N/A N/A
"numberOfSpecies" N/A N/A N/A
"particleCharge" N/A N/A N/A
"particleSize" N/A N/A N/A
"neighObject" N/A N/A N/A
"boxSideLengths" N/A N/A N/A
"temperature" N/A N/A N/A
"hessian" N/A N/A N/A
"PARAM_FREE_cutoff" N/A N/A N/A
"get_neigh" KIM::COMPUTE_CALLBACK_NAME::GetNeighborList \ref KIM_COMPUTE_CALLBACK_NAME_GetNeighborList kim_compute_callback_name_module::kim_compute_callback_name_get_neighbor_list
"process_dEdr" KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm \ref KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm kim_compute_callback_name_module::kim_compute_callback_name_process_dedr_term
"process_d2Edr2" KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term \ref KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term kim_compute_callback_name_module::kim_compute_callback_name_process_d2edr2_term
"ZeroBasedLists" KIM::NUMBERING::zeroBased \ref KIM_NUMBERING_zeroBased kim_numbering_module::kim_numbering_zero_based
"OneBasedLists" KIM::NUMBERING::oneBased \ref KIM_NUMBERING_oneBased kim_numbering_module::kim_numbering_one_based
"Neigh_IterAccess" N/A N/A N/A
"Neigh_LocaAccess" N/A N/A N/A
"Neigh_BothAccess" N/A N/A N/A
"CLUSTER" N/A N/A N/A
"NEIGH_PURE_H" N/A N/A N/A
"NEIGH_PURE_F" N/A N/A N/A
"NEIGH_RVEC_H" N/A N/A N/A
"NEIGH_RVEC_F" N/A N/A N/A
"MI_OPBC_H" N/A N/A N/A
"MI_OPBC_F" N/A N/A N/A
"electron" KIM::SPECIES_NAME::electron \ref KIM_SPECIES_NAME_electron kim_species_name_module::kim_species_name_electron
"H" KIM::SPECIES_NAME::H \ref KIM_SPECIES_NAME_H kim_species_name_module::kim_species_name_h
"He" KIM::SPECIES_NAME::He \ref KIM_SPECIES_NAME_He kim_species_name_module::kim_species_name_he
etc. etc. etc. etc.
"user20" KIM::SPECIES_NAME::user20 \ref KIM_SPECIES_NAME_user20 kim_species_name_module::kim_species_name_user20
"C" KIM::CHARGE_UNIT::C \ref KIM_CHARGE_UNIT_C kim_charge_unit_module::kim_charge_unit_c
"e" KIM::CHARGE_UNIT::e \ref KIM_CHARGE_UNIT_e kim_charge_unit_module::kim_charge_unit_e
"statC" KIM::CHARGE_UNIT::statC \ref KIM_CHARGE_UNIT_statC kim_charge_unit_module::kim_charge_unit_statc
N/A KIM::CHARGE_UNIT::unused \ref KIM_CHARGE_UNIT_unused kim_charge_unit_module::kim_charge_unit_unused
"amu_A2_per_ps2" KIM::ENERGY_UNIT::amu_A2_per_ps2 \ref KIM_ENERGY_UNIT_amu_A2_per_ps2 kim_energy_unit_module::kim_energy_unit_amu_a2_per_ps2
"erg" KIM::ENERGY_UNIT::erg \ref KIM_ENERGY_UNIT_erg kim_energy_unit_module::kim_energy_unit_erg
"eV" KIM::ENERGY_UNIT::eV \ref KIM_ENERGY_UNIT_eV kim_energy_unit_module::kim_energy_unit_ev
"Hartree" KIM::ENERGY_UNIT::Hartree \ref KIM_ENERGY_UNIT_Hartree kim_energy_unit_module::kim_energy_unit_hartree
"J" KIM::ENERGY_UNIT::J \ref KIM_ENERGY_UNIT_J kim_energy_unit_module::kim_energy_unit_j
"kcal_mol" KIM::ENERGY_UNIT::kcal_mol \ref KIM_ENERGY_UNIT_kcal_mol kim_energy_unit_module::kim_energy_unit_kcal_mol
N/A KIM::ENERGY_UNIT::unused \ref KIM_ENERGY_UNIT_unused kim_energy_unit_module::kim_energy_unit_unused
"A" KIM::LENGTH_UNIT::A \ref KIM_LENGTH_UNIT_A kim_length_unit_module::kim_length_unit_a
"Bohr" KIM::LENGTH_UNIT::Bohr \ref KIM_LENGTH_UNIT_Bohr kim_length_unit_module::kim_length_unit_bohr
"cm" KIM::LENGTH_UNIT::cm \ref KIM_LENGTH_UNIT_cm kim_length_unit_module::kim_length_unit_cm
"m" KIM::LENGTH_UNIT::m \ref KIM_LENGTH_UNIT_m kim_length_unit_module::kim_length_unit_m
"nm" KIM::LENGTH_UNIT::nm \ref KIM_LENGTH_UNIT_nm kim_length_unit_module::kim_length_unit_nm
N/A KIM::LENGTH_UNIT::unused \ref KIM_LENGTH_UNIT_unused kim_length_unit_module::kim_length_unit_unused
"K" KIM::TEMPERATURE_UNIT::K \ref KIM_TEMPERATURE_UNIT_K kim_temperature_unit_module::kim_temperature_unit_k
N/A KIM::TEMPERATURE_UNIT::unused \ref KIM_TEMPERATURE_UNIT_unused kim_temperature_unit_module::kim_temperature_unit_unused
"fs" KIM::TIME_UNIT::fs \ref KIM_TIME_UNIT_fs kim_time_unit_module::kim_time_unit_fs
"ps" KIM::TIME_UNIT::ps \ref KIM_TIME_UNIT_ps kim_time_unit_module::kim_time_unit_ps
"ns" KIM::TIME_UNIT::ns \ref KIM_TIME_UNIT_ns kim_time_unit_module::kim_time_unit_ns
"s" KIM::TIME_UNIT::s \ref KIM_TIME_UNIT_s kim_time_unit_module::kim_time_unit_s
N/A KIM::TIME_UNIT::unused \ref KIM_TIME_UNIT_unused kim_time_unit_module::kim_time_unit_unused
N/A KIM::DATA_TYPE::Integer \ref KIM_DATA_TYPE_Integer kim_data_type_module::kim_data_type_integer
N/A KIM::DATA_TYPE::Double \ref KIM_DATA_TYPE_Double kim_data_type_module::kim_data_type_double
N/A KIM::LANGUAGE_NAME::cpp \ref KIM_LANGUAGE_NAME_cpp kim_language_name_module::kim_language_name_cpp
N/A KIM::LANGUAGE_NAME::c \ref KIM_LANGUAGE_NAME_c kim_language_name_module::kim_language_name_c
N/A KIM::LANGUAGE_NAME::fortran \ref KIM_LANGUAGE_NAME_fortran kim_language_name_module::kim_language_name_fortran
N/A KIM::LOG_VERBOSITY::silent \ref KIM_LOG_VERBOSITY_silent kim_log_verbosity_module::kim_log_verbosity_silent
N/A KIM::LOG_VERBOSITY::fatal \ref KIM_LOG_VERBOSITY_fatal kim_log_verbosity_module::kim_log_verbosity_fatal
N/A KIM::LOG_VERBOSITY::error \ref KIM_LOG_VERBOSITY_error kim_log_verbosity_module::kim_log_verbosity_error
N/A KIM::LOG_VERBOSITY::warning \ref KIM_LOG_VERBOSITY_warning kim_log_verbosity_module::kim_log_verbosity_warning
N/A KIM::LOG_VERBOSITY::information \ref KIM_LOG_VERBOSITY_information kim_log_verbosity_module::kim_log_verbosity_information
N/A KIM::LOG_VERBOSITY::debug \ref KIM_LOG_VERBOSITY_debug kim_log_verbosity_module::kim_log_verbosity_debug
N/A KIM::SUPPORT_STATUS::requiredByAPI \ref KIM_SUPPORT_STATUS_requiredByAPI kim_support_status_module::kim_support_status_required_by_api
N/A KIM::SUPPORT_STATUS::notSupported \ref KIM_SUPPORT_STATUS_notSupported kim_support_status_module::kim_support_status_not_supported
N/A KIM::SUPPORT_STATUS::required \ref KIM_SUPPORT_STATUS_required kim_support_status_module::kim_support_status_required
N/A KIM::SUPPORT_STATUS::optional \ref KIM_SUPPORT_STATUS_optional kim_support_status_module::kim_support_status_optional
N/A KIM::MODEL_ROUTINE_NAME::Create \ref KIM_MODEL_ROUTINE_NAME_Create kim_model_routine_name_module::kim_model_routine_name_create
N/A KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate \ref KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate kim_model_routine_name_module::kim_model_routine_name_compute_arguments_create
N/A KIM::MODEL_ROUTINE_NAME::Compute \ref KIM_MODEL_ROUTINE_NAME_Compute kim_model_routine_name_module::kim_model_routine_name_compute
N/A KIM::MODEL_ROUTINE_NAME::Extension \ref KIM_MODEL_ROUTINE_NAME_Extension kim_model_routine_name_module::kim_model_routine_name_extension
N/A KIM::MODEL_ROUTINE_NAME::Refresh \ref KIM_MODEL_ROUTINE_NAME_Refresh kim_model_routine_name_module::kim_model_routine_name_refresh
N/A KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel \ref KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel kim_model_routine_name_module::kim_model_routine_name_write_parameterized_model
N/A KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy \ref KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy kim_model_routine_name_module::kim_model_routine_name_compute_arguments_destroy
N/A KIM::MODEL_ROUTINE_NAME::Destroy \ref KIM_MODEL_ROUTINE_NAME_Destroy kim_model_routine_name_module::kim_model_routine_name_destroy
N/A KIM::Function() KIM_Function() N/A
N/A KIM::ModelCreateFunction() KIM_ModelCreateFunction() N/A
N/A KIM::ModelDriverCreateFunction() KIM_ModelDriverCreateFunction() N/A
N/A KIM::ModelComputeArgumentsCreateFunction() KIM_ModelComputeArgumentsCreateFunction() N/A
N/A KIM::ModelComputeFunction() KIM_ModelComputeFunction() N/A
N/A KIM::ModelExtensionFunction() KIM_ModelExtensionFunction() N/A
N/A KIM::ModelWriteParameterizedModelFunction() KIM_ModelWriteParameterizedModelFunction() N/A
N/A KIM::GetNeighborListFunction() KIM_GetNeighborListFunction() N/A
N/A KIM::ProcessDEDrTermFunction() KIM_ProcessDEDrTermFunction() N/A
N/A KIM::ProcessD2EDr2TermFunction() KIM_ProcessD2EDr2TermFunction() N/A
N/A KIM::ModelRefreshFunction() KIM_ModelRefreshFunction() N/A
N/A KIM::ModelComputeArgumentsDestroyFunction() KIM_ModelComputeArgumentsDestroyFunction() N/A
N/A KIM::ModelDestroyFunction() KIM_ModelDestroyFunction() N/A


Extensible enumeration discovery and comparison routine identifier name table \anchor external_enum_discovery_table :
kim-api-v2 C++ Binding kim-api-v2 C Binding kim-api-v2 Fortran Binding
KIM::ChargeUnit::ChargeUnit()
KIM::ChargeUnit::ChargeUnit(int const)
KIM::ChargeUnit::ChargeUnit(std::string const &)


KIM_ChargeUnit_FromString()


kim_charge_unit_module::kim_from_string()
KIM::ChargeUnit::operator==() \ref KIM_ChargeUnit_Equal() kim_charge_unit_module::operator(.ne.)
KIM::ChargeUnit::operator!=() \ref KIM_ChargeUnit_NotEqual() kim_charge_unit_module::operator(.ne.)
KIM::ChargeUnit::ToString() KIM_ChargeUnit_ToString() kim_charge_unit_module::kim_to_string()
KIM::CHARGE_UNIT::GetNumberOfChargeUnits() KIM_CHARGE_UNIT_GetNumberOfChargeUnits() kim_charge_unit_module::kim_get_number_of_charge_units()
KIM::CHARGE_UNIT::GetChargeUnit() KIM_CHARGE_UNIT_GetChargeUnit() kim_charge_unit_module::kim_get_charge_unit()
KIM::ModelRoutineName::ModelRoutineName()
KIM::ModelRoutineName::ModelRoutineName(int const)
KIM::ModelRoutineName::ModelRoutineName(std::string const &)


KIM_ModelRoutineName_FromString()


kim_model_routine_name_module::kim_from_string()
KIM::ModelRoutineName::operator==() \ref KIM_ModelRoutineName_Equal() kim_model_routine_name_module::operator(.eq.)
KIM::ModelRoutineName::operator!=() \ref KIM_ModelRoutineName_NotEqual() kim_model_routine_name_module::operator(.ne.)
KIM::ModelRoutineName::ToString() KIM_ModelRoutineName_ToString() kim_model_routine_name_module::kim_to_string()
KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames() KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames() kim_model_routein_name_module::kim_get_number_of_model_routine_names()
KIM::MODEL_ROUTINE_NAME::GetModelRoutineName() KIM_MODEL_ROUTINE_NAME_GetModelRoutineName() kim_model_routine_name_module::kim_get_compute_argument_name()
KIM::ComputeArgumentName::ComputeArgumentName()
KIM::ComputeArgumentName::ComputeArgumentName(int const)
KIM::ComputeArgumentName::ComputeArgumentName(std::string const &)


KIM_ComputeArgumentName_FromString()


kim_compute_argument_name_module::kim_from_string()
KIM::ComputeArgumentName::operator==() \ref KIM_ComputeArgumentName_Equal() kim_compute_argument_name_module::operator(.eq.)
KIM::ComputeArgumentName::operator!=() \ref KIM_ComputeArgumentName_NotEqual() kim_compute_argument_name_module::operator(.ne.)
KIM::ComputeArgumentName::ToString() KIM_ComputeArgumentName_ToString() kim_compute_argument_name_module::kim_to_string()
KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames() KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames() kim_compute_argument_name_module::kim_get_number_of_compute_argument_names()
KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName() KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName() kim_compute_argument_name_module::kim_get_compute_argument_name()
KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType() KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType() kim_compute_argument_name_module::kim_get_compute_argument_data_type()
KIM::ComputeCallbackName::ComputeCallbackName()
KIM::ComputeCallbackName::ComputeCallbackName(int const)
KIM::ComputeCallbackName::ComputeCallbackName(std::string const &)


KIM_ComputeCallbackName_FromString()


kim_compute_callback_name_module::kim_from_string()
KIM::ComputeCallbackName::operator==() \ref KIM_ComputeCallbackName_Equal() kim_compute_callback_name_module::operator(.eq.)
KIM::ComputeCallbackName::operator!=() \ref KIM_ComputeCallbackName_NotEqual() kim_compute_callback_name_module::operator(.ne.)
KIM::ComputeCallbackName::ToString() KIM_ComputeCallbackName_ToString() kim_compute_callback_name_module::kim_to_string()
KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames() KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames() kim_compute_callback_name_module::kim_get_number_of_compute_callback_names()
KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName() KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName() kim_compute_callback_name_module::kim_get_compute_callback_name()
KIM::DataType::DataType()
KIM::DataType::DataType(int const)
KIM::DataType::DataType(std::string const &)


KIM_DataType_FromString()


kim_data_type_module::kim_from_string()
KIM::DataType::operator==() \ref KIM_DataType_Equal() kim_data_type_module::operator(.eq.)
KIM::DataType::operator!=() \ref KIM_DataType_NotEqual() kim_data_type_module::operator(.ne.)
KIM::DataType::ToString() KIM_DataType_ToString() kim_data_type_module::kim_to_string()
KIM::DATA_TYPE::GetNumberOfDataTypes() KIM_DATA_TYPE_GetNumberOfDataTypes() kim_data_type_module::kim_get_number_of_data_types()
KIM::DATA_TYPE::GetDataType() KIM_DATA_TYPE_GetDataType() kim_data_type_module::kim_get_data_type()
KIM::EnergyUnit::EnergyUnit()
KIM::EnergyUnit::EnergyUnit(int const)
KIM::EnergyUnit::EnergyUnit(std::string const &)


KIM_EnergyUnit_FromString()


kim_energy_unit_module::kim_from_string()
KIM::EnergyUnit::operator==() \ref KIM_EnergyUnit_Equal() kim_energy_unit_module::operator(.eq.)
KIM::EnergyUnit::operator!=() \ref KIM_EnergyUnit_NotEqual() kim_energy_unit_module::operator(.ne.)
KIM::EnergyUnit::ToString() KIM_EnergyUnit_ToString() kim_energy_unit_module::kim_to_string()
KIM::ENERGY_UNIT::GetNumberOfEnergyUnits() KIM_ENERGY_UNIT_GetNumberOfEnergyUnits() kim_energy_unit_module::kim_get_number_of_energy_units()
KIM::ENERGY_UNIT::GetEnergyUnit() KIM_ENERGY_UNIT_GetEnergyUnit() kim_energy_unit_module::kim_get_energy_unit()
KIM::LanguageName::LanguageName()
KIM::LanguageName::LanguageName(int const)
KIM::LanguageName::LanguageName(std::string const &)


KIM_LanguageName_FromString()


kim_language_name_module::kim_from_string()
KIM::LanguageName::operator==() \ref KIM_LanguageName_Equal() kim_language_name_module::operator(.eq.)
KIM::LanguageName::operator!=() \ref KIM_LanguageName_NotEqual() kim_language_name_module::operator(.ne.)
KIM::LanguageName::ToString() KIM_LanguageName_ToString() kim_language_name_module::kim_to_string()
KIM::LANGUAGE_NAME::GetNumberOfLanguageNames() KIM_LANGUAGE_NAME_GetNumberOfLanguageNames() kim_language_name_module::kim_get_number_of_language_names()
KIM::LANGUAGE_NAME::GetLanguageName() KIM_LANGUAGE_NAME_GetLanguageName() kim_language_name_module::kim_get_language_name()
KIM::LengthUnit::LengthUnit()
KIM::LengthUnit::LengthUnit(int const)
KIM::LengthUnit::LengthUnit(std::string const &)


KIM_LengthUnit_FromString()


kim_length_unit_module::kim_from_string()
KIM::LengthUnit::operator==() \ref KIM_LengthUnit_Equal() kim_length_unit_module::operator(.eq.)
KIM::LengthUnit::operator!=() \ref KIM_LengthUnit_NotEqual() kim_length_unit_module::operator(.ne.)
KIM::LengthUnit::ToString() KIM_LengthUnit_ToString() kim_length_unit_module::kim_to_string()
KIM::LENGTH_UNIT::GetNumberOfLengthUnits() KIM_LENGTH_UNIT_GetNumberOfLengthUnits() kim_length_unit_module::kim_get_number_of_length_units()
KIM::LENGTH_UNIT::GetLengthUnit() KIM_LENGTH_UNIT_GetLengthUnit() kim_length_unit_module::kim_get_length_unit()
KIM::LogVerbosity::LogVerbosity()
KIM::LogVerbosity::LogVerbosity(int const)
KIM::LogVerbosity::LogVerbosity(std::string const &)


KIM_LogVerbosity_FromString()


kim_log_verbosity_module::kim_from_string()
KIM::LogVerbosity::operator<() \ref KIM_LogVerbosity_LessThan() kim_log_verbosity_module::operator(.lt.)
KIM::LogVerbosity::operator>() \ref KIM_LogVerbosity_GreaterThan() kim_log_verbosity_module::operator(.gt.)
KIM::LogVerbosity::operator<=() \ref KIM_LogVerbosity_LessThanEqual() kim_log_verbosity_module::operator(.le.)
KIM::LogVerbosity::operator>=() \ref KIM_LogVerbosity_GreaterThanEqual() kim_log_verbosity_module::operaotr(.ge.)
KIM::LogVerbosity::operator==() \ref KIM_LogVerbosity_Equal() kim_log_verbosity_module::operator(.eq.)
KIM::LogVerbosity::operator!=() \ref KIM_LogVerbosity_NotEqual() kim_log_verbosity_module::operator(.ne.)
KIM::LogVerbosity::ToString() KIM_LogVerbosity_ToString() kim_log_verbosity_module::kim_to_string()
KIM::LOG_VERBOSITY::GetNumberOfLogVerbosities() KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities() kim_log_verbosity_module::kim_get_number_of_log_verbosities()
KIM::LOG_VERBOSITY::GetLogVerbosity() KIM_LOG_VERBOSITY_GetLogVerbosity() kim_log_verbosity_module::kim_get_log_verbosity()
KIM::Numbering::Numbering()
KIM::Numbering::Numbering(int const)
KIM::Numbering::Numbering(std::string const &)


KIM_Numbering_FromString()


kim_numbering_module::kim_from_string()
KIM::Numbering::operator==() \ref KIM_Numbering_Equal() kim_numbering_module::operator(.eq.)
KIM::Numbering::operator!=() \ref KIM_Numbering_NotEqual() kim_numbering_module::operator(.ne.)
KIM::Numbering::ToString() KIM_Numbering_ToString() kim_numbering_module::kim_to_string()
KIM::NUMBERING::GetNumberOfNumberings() KIM_NUMBERING_GetNumberOfNumberings() kim_numbering_module::kim_get_number_of_numberings()
KIM::NUMBERING::GetNumbering() KIM_NUMBERING_GetNumbering() kim_numbering_module::kim_get_numbering()
KIM::SpeciesName::SpeciesName()
KIM::SpeciesName::SpeciesName(int const)
KIM::SpeciesName::SpeciesName(std::string const &)


KIM_SpeciesName_FromString()


kim_species_name_module::kim_from_string()
KIM::SpeciesName::operator==() \ref KIM_SpeciesName_Equal() kim_species_name_module::operator(.eq.)
KIM::SpeciesName::operator!=() \ref KIM_SpeciesName_NotEqual() kim_species_name_module::operator(.ne.)
KIM::SpeciesName::ToString() KIM_SpeciesName_ToString() kim_species_name_module::kim_to_string()
KIM::SPECIES_NAME::GetNumberOfSpeciesNames() KIM_SPECIES_NAME_GetNumberOfSpeciesNames() kim_species_name_module::kim_get_number_of_species_names()
KIM::SPECIES_NAME::GetSpeciesName() KIM_SPECIES_NAME_GetSpeciesName() kim_species_name_module::kim_get_species_name()
KIM::SupportStatus::SupportStatus()
KIM::SupportStatus::SupportStatus(int const)
KIM::SupportStatus::SupportStatus(std::string const &)


KIM_SupportStatus_FromString()


kim_support_status_module::kim_from_string()
KIM::SupportStatus::operator==() \ref KIM_SupportStatus_Equal() kim_support_status_module::operator(.eq.)
KIM::SupportStatus::operator!=() \ref KIM_SupportStatus_NotEqual() kim_support_status_module::operator(.ne.)
KIM::SupportStatus::ToString() KIM_SupportStatus_ToString() kim_support_status_module::kim_to_string()
KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses() KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses() kim_support_status_module::kim_get_number_of_support_statuses()
KIM::SUPPORT_STATUS::GetSupportStatus() KIM_SUPPORT_STATUS_GetSupportStatus() kim_support_status_module::kim_get_support_status()
KIM::TemperatureUnit::TemperatureUnit()
KIM::TemperatureUnit::TemperatureUnit(int const)
KIM::TemperatureUnit::TemperatureUnit(std::string const &)


KIM_TemperatureUnit_FromString()


kim_temperature_unit_module::kim_from_string()
KIM::TemperatureUnit::operator==() \ref KIM_TemperatureUnit_Equal() kim_temperature_unit_module::operator(.eq.)
KIM::TemperatureUnit::operator!=() \ref KIM_TemperatureUnit_NotEqual() kim_temperature_unit_module::operator(.ne.)
KIM::TemperatureUnit::ToString() KIM_TemperatureUnit_ToString() kim_temperature_unit_module::kim_to_string()
KIM::TEMPERATURE_UNIT::GetNumberOfTemperatureUnits() KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits() kim_temperature_unit_module::kim_get_number_of_temperature_units()
KIM::TEMPERATURE_UNIT::GetTemperatureUnit() KIM_TEMPERATURE_UNIT_GetTemperatureUnit() kim_temperature_unit_module::kim_get_temperature_unit()
KIM::TimeUnit::TimeUnit()
KIM::TimeUnit::TimeUnit(int const)
KIM::TimeUnit::TimeUnit(std::string const &)


KIM_TimeUnit_FromString()


kim_time_unit_module::kim_from_string()
KIM::TimeUnit::operator==() \ref KIM_TimeUnit_Equal() kim_time_unit_module::operator(.eq.)
KIM::TimeUnit::operator!=() \ref KIM_TimeUnit_NotEqual() kim_time_unit_module::operator(.ne.)
KIM::TimeUnit::ToString() KIM_TimeUnit_ToString() kim_time_unit_module::kim_to_string()
KIM::TIME_UNIT::GetNumberOfTimeUnits() KIM_TIME_UNIT_GetNumberOfTimeUnits() kim_time_unit_module::kim_get_number_of_time_units()
KIM::TIME_UNIT::GetTimeUnit() KIM_TIME_UNIT_GetTimeUnit() kim_time_unit_module::kim_get_time_unit()
Next Seciton: [Browse files](files.html). */ LocalWords: yyyy Ellad Tadmor kim api NBCs miopbc rvec api's ref init tr LocalWords: particleContributing ModelCreate rightarrow SetCallbackPointer td LocalWords: prerelease metadata sim reinit num params str len dEdr Edr msg br LocalWords: getm setm numberOfParticles ModelComputeArgumentsCreate SEM VER LocalWords: GetNumberOfParameters SetModelNumbering ModelDriverCreate dedr MI LocalWords: ComputeArgumentsCreate ComputeArgumentsDestroy GetSemVer ToString LocalWords: ParseSemVer IsLessThan ComputeArguments ModelCompute ModelDestroy LocalWords: ModelComputeArguments ModelComputeArgumentsDestroy ModelRefresh LocalWords: SetModelBufferPointer SetSimulatorBufferPointer IsCallbackPresent LocalWords: GetModelBufferPointer GetSimulatorBufferPointer SetRefreshPointer LocalWords: SetArgumentPointerInteger SetArgumentPointerDouble SetSpeciesCode LocalWords: SetArgumentSupportStatus GetArgumentSupportStatus GetNeighborList LocalWords: SetCallbackSupportStatus GetCallbackSupportStatus ProcessDEDrTerm LocalWords: GetArgumentPointerInteger GetArgumentPointerDouble ProcessD EDr LocalWords: AreAllRequiredArgumentsAndCallbacksPresent GetInfluenceDistance LocalWords: SetInfluenceDistancePointer GetNeighborListPointers edr LogEntry LocalWords: SetNeighborListPointers SetDestroyPointer SetComputePointer GetID LocalWords: SetComputeArgumentsCreatePointer ClearThenRefresh SetID SetLogID LocalWords: SetComputeArgumentsDestroyPointer GetSpeciesSupportAndCode virial LocalWords: GetNumberOfParameterFiles GetParameterFileName GetParameterDouble LocalWords: GetParameterInteger SetParameterInteger SetParameterDouble PARAM LocalWords: GetParameterMetadata SetParameterPointerInteger PushVerbosity amu LocalWords: SetParameterPointerDouble PopVerbosity PushLogVerbosity GetUnits LocalWords: PopLogVerbosity ConvertUnit SetUnits particleSpecies particleSize LocalWords: particleSpeciesCodes partialEnergy partialForces particleEnergy LocalWords: partialParticleEnergy partialVirial particleVirial particleCharge LocalWords: partialParticleVirial numberContributingParticles numberOfSpecies LocalWords: neighObject boxSideLengths hessian ZeroBasedLists zeroBased OPBC LocalWords: OneBasedLists oneBased IterAccess LocaAccess BothAccess statC ps LocalWords: erg eV Hartree mol fs ns cpp fortran requiredByAPI notSupported LocalWords: ModelCreateFunction ModelDriverCreateFunction TermFunction int eq LocalWords: ModelComputeArgumentsCreateFunction ModelComputeFunction NotEqual LocalWords: GetNeighborListFunction ProcessDEDrTermFunction ChargeUnit ne lt LocalWords: ModelRefreshFunction ModelComputeArgumentsDestroyFunction gt le LocalWords: ModelDestroyFunction FromString GetNumberOfChargeUnits DataType LocalWords: GetChargeUnit ComputeArgumentName GetNumberOfComputeArgumentNames LocalWords: GetComputeArgumentName GetComputeArgumentDataType GetDataType ge LocalWords: ComputeCallbackName GetNumberOfComputeCallbackNames EnergyUnit em LocalWords: GetComputeCallbackName GetNumberOfDataTypes GetEnergyUnit Seciton LocalWords: GetNumberOfEnergyUnits LanguageName GetNumberOfLanguageNames html LocalWords: GetLanguageName LengthUnit GetNumberOfLengthUnits GetLengthUnit LocalWords: LogVerbosity LessThan GreaterThan LessThanEqual GreaterThanEqual LocalWords: GetNumberOfLogVerbosities GetLogVerbosity GetNumberOfNumberings LocalWords: GetNumbering SpeciesName GetNumberOfSpeciesNames GetSpeciesName LocalWords: SupportStatus GetNumberOfSupportStatuses GetSupportStatus ToModel LocalWords: TemperatureUnit GetNumberOfTemperatureUnits GetTemperatureUnit LocalWords: TimeUnit GetNumberOfTimeUnits GetTimeUnit IsRoutinePresent const LocalWords: ModelExtension WriteParameterizedModel SetRoutinePointer GetPath LocalWords: PushDefaultVerbosity PopDefaultVerbosity GetExtensionID enum LocalWords: ToModelCompute ToModelCreate ToModelDestroy ToModelDriverCreate LocalWords: ToModelRefresh ToModelWriteParameterizedModel GetModelName LocalWords: ToModelComputeArguments ToModelComputeArgumentsCreate LocalWords: ToModelComputeArgumentsDestroy ModelWriteParameterizedModel LocalWords: SetParameterFileName ModelExtensionFunction ModelRoutineName LocalWords: ModelWriteParameterizedModelFunction GetNumberOfModelRoutineNames LocalWords: GetModelRoutineName kim-api-2.3.0-git/editors/000077500000000000000000000000001421473465500153105ustar00rootroot00000000000000kim-api-2.3.0-git/editors/emacs/000077500000000000000000000000001421473465500164005ustar00rootroot00000000000000kim-api-2.3.0-git/editors/emacs/CMakeLists.txt000066400000000000000000000023631421473465500211440ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Jim Madge # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # install( FILES kim-api-c-style.el # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_DATADIR}/emacs/site-lisp/${PROJECT_NAME} ) kim-api-2.3.0-git/editors/emacs/kim-api-c-style.el000066400000000000000000000173661421473465500216440ustar00rootroot00000000000000;; ;; KIM-API: An API for interatomic models ;; Copyright (c) 2013--2022, Regents of the University of Minnesota. ;; All rights reserved. ;; ;; Contributors: ;; Ryan S. Elliott ;; ;; SPDX-License-Identifier: LGPL-2.1-or-later ;; ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public ;; License as published by the Free Software Foundation; either ;; version 2.1 of the License, or (at your option) any later version. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; ;; You should have received a copy of the GNU Lesser General Public License ;; along with this library; if not, write to the Free Software Foundation, ;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;; ;; ;; Release: This file is part of the kim-api.git repository. ;; ;;; kim-api-c-style.el --- kim-api's C/C++ style for c-mode ;; Keywords: c, tools ;; This file derives from the google-c-style.el file. ;;; Commentary: ;; Provides the kim-api C/C++ coding style. You may wish to add ;; 'kim-api-set-c-style' to your 'c-mode-common-hook' after requiring this ;; file. For example: ;; ;; (add-hook 'c-mode-common-hook 'kim-api-set-c-style) ;; ;; If you want the RETURN key to go to the next line and space over ;; to the right place, add this to your .emacs right after the load-file: ;; ;; (add-hook 'c-mode-common-hook 'kim-api-make-newline-indent) ;;; Code: ;; For some reason 1) c-backward-syntactic-ws is a macro and 2) under Emacs 22 ;; bytecode cannot call (unexpanded) macros at run time: (eval-when-compile (require 'cc-defs)) (defconst kim-api-c-style `((c-recognize-knr-p . nil) (c-enable-xemacs-performance-kludge-p . t) ; speed up indentation in XEmacs (c-basic-offset . 2) (indent-tabs-mode . nil) (c-comment-only-line-offset . 0) (c-hanging-braces-alist . ((defun-open before after) (defun-close before after) (class-open before after) (class-close before after) (inexpr-class-open before after) (inexpr-class-close before after) (namespace-open before after) (inline-open before after) (inline-close before after) (block-open before after) (block-close . c-snug-do-while) (extern-lang-open before after) (extern-lang-close before after) (statement-case-open before after) (substatement-open before after))) (c-hanging-colons-alist . ((case-label) (label after) (access-label after) (member-init-intro before) (inher-intro))) (c-hanging-semi&comma-criteria . (c-semi&comma-no-newlines-for-oneline-inliners c-semi&comma-inside-parenlist c-semi&comma-no-newlines-before-nonblanks)) (c-indent-comments-syntactically-p . t) (comment-column . 40) (c-indent-comment-alist . ((other . (space . 2)))) (c-cleanup-list . (empty-defun-braces defun-close-semi list-close-comma scope-operator)) (c-offsets-alist . ( (access-label . *) (arglist-cont . 0) (arglist-intro . ++) (class-close . 0) (class-open . 0) (cpp-define-intro . +) (defun-block-intro . +) (func-decl-cont . 0) (inclass . +) (inline-close . 0) (innamespace . 0) (namespace-close . 0) (namespace-open . 0) (topmost-intro . 0) (topmost-intro-cont . 0) (annotation-top-cont . 0) (annotation-var-cont . +) (arglist-close . c-lineup-close-paren) (arglist-cont-nonempty . (c-lineup-string-cont c-lineup-arglist)) (block-close . 0) (block-open . 0) (brace-entry-open . 0) (brace-list-close . 0) (brace-list-entry . c-lineup-under-anchor) (brace-list-intro . +) (brace-list-open . 0) (c . c-lineup-C-comments) (case-label . +) (catch-clause . 0) (comment-intro . c-lineup-comment) (composition-close . 0) (composition-open . 0) (cpp-macro . -1000) (cpp-macro-cont . +) (defun-close . 0) (defun-open . 0) (do-while-closure . 0) (else-clause . 0) (extern-lang-close . 0) (extern-lang-open . 0) (friend . 0) (incomposition . +) (inexpr-class . +) (inexpr-statement . +) (inextern-lang . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . ++) (inlambda . c-lineup-inexpr-block) (inline-open . 0) (inmodule . +) (knr-argdecl . 0) (knr-argdecl-intro . +) (label . /) (lambda-intro-cont . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . ++) (module-close . 0) (module-open . 0) (statement . 0) (statement-block-intro . +) (statement-case-intro . +) (statement-case-open . 0) (statement-cont . (c-lineup-string-cont c-lineup-cascaded-calls c-lineup-assignments ++)) (stream-op . c-lineup-streamop) (string . -1000) (substatement . +) (substatement-label . 2) (substatement-open . 0) (template-args-cont c-lineup-template-args +) ) ) ) "kim-api C/C++ Programming Style.") (defun kim-api-set-c-style () "Set the current buffer's c-style to kim-api C/C++ Programming Style. Meant to be added to `c-mode-common-hook'." (interactive) (make-local-variable 'c-tab-always-indent) (setq c-tab-always-indent t) (c-add-style "kim-api" kim-api-c-style t)) (defun kim-api-make-newline-indent () "Sets up preferred newline behavior. Not set by default. Meant to be added to `c-mode-common-hook'." (interactive) (define-key c-mode-base-map "\C-m" 'newline-and-indent) (define-key c-mode-base-map [ret] 'newline-and-indent)) (provide 'kim-api-c-style) ;;; kim-api-c-style.el ends here kim-api-2.3.0-git/examples/000077500000000000000000000000001421473465500154555ustar00rootroot00000000000000kim-api-2.3.0-git/examples/README000066400000000000000000000031631421473465500163400ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (examples) contains directories with example Model Drivers, Portable Models, Simulator Models, and Simulators. Please see the README files within each directory for information about the examples. Items in these directories may be built as part of the main KIM API build. Or, they may be build separately, after the KIM API has been built and installed. In the latter case, for Portable Models and Model Drivers, use the kim-api-collections-management utility to build and install the items. For the simulators, the following example sequence of commands is typical. $ cd simulators/ex_test_Ar_fcc_cluster $ mkdir build $ cd build $ cmake ../ -DCMAKE_BUILD_TYPE=Release $ make kim-api-2.3.0-git/examples/model-drivers/000077500000000000000000000000001421473465500202315ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/CMakeLists.txt000066400000000000000000000023251421473465500227730ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) add_subdirectory(ex_model_driver_P_LJ) add_subdirectory(ex_model_driver_P_Morse) add_subdirectory(LennardJones612__MD_414112407348_003) kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/000077500000000000000000000000001421473465500254535ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/CMakeLists.txt000066400000000000000000000031661421473465500302210ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "modelDriver") project(LennardJones612__MD_414112407348_003 LANGUAGES CXX) kim_api_items_setup_after_project(ITEM_TYPE "modelDriver") add_kim_api_model_driver_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_driver_create" CREATE_ROUTINE_LANGUAGE "cpp" ) target_sources(${PROJECT_NAME} PRIVATE LennardJones612.cpp LennardJones612Implementation.cpp ) kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/CreateDispatch.sh000077500000000000000000000077001421473465500307010ustar00rootroot00000000000000#!/bin/sh # # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Stephen M. Whalen # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # flName=LennardJones612ImplementationComputeDispatch.cpp printf "switch (GetComputeIndex(isComputeProcess_dEdr,\n" > $flName printf " isComputeProcess_d2Edr2,\n" >> $flName printf " isComputeEnergy,\n" >> $flName printf " isComputeForces,\n" >> $flName printf " isComputeParticleEnergy,\n" >> $flName printf " isComputeVirial,\n" >> $flName printf " isComputeParticleVirial,\n" >> $flName printf " isShift))\n" >> $flName printf "{\n" >> $flName i=0 for processdE in false true; do for processd2E in false true; do for energy in false true; do for force in false true; do for particleEnergy in false true; do for virial in false true; do for particleVirial in false true; do for sshift in false true; do printf " case $i:\n" >> $flName printf " ier = Compute<$processdE, $processd2E, " >> $flName printf "$energy, $force, " >> $flName printf "$particleEnergy, $virial, " >> $flName printf "$particleVirial, $sshift>(\n" >> $flName printf " modelCompute,\n" >> $flName printf " modelComputeArguments,\n" >> $flName printf " particleSpeciesCodes,\n" >> $flName printf " particleContributing,\n" >> $flName printf " coordinates,\n" >> $flName printf " energy,\n" >> $flName printf " forces,\n" >> $flName printf " particleEnergy,\n" >> $flName printf " *virial,\n" >> $flName printf " particleVirial);\n" >> $flName printf " break;\n" >> $flName i=`expr $i + 1` done # sshift done # particleVirial done # virial done # particleEnergy done # force done # energy done # processd2E done # processdE printf " default:\n" >> $flName printf " std::cout << \"Unknown compute function index\" << std::endl;\n" >> $flName printf " ier = true;\n" >> $flName printf " break;\n" >> $flName printf "}\n" >> $flName kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/LICENSE.LGPL000066400000000000000000000636421421473465500272300ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/LennardJones612.cpp000066400000000000000000000141611421473465500307750ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Andrew Akerson // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #include "LennardJones612.hpp" #include "LennardJones612Implementation.hpp" #include //============================================================================== // // This is the standard interface to KIM Model Drivers // //============================================================================== //****************************************************************************** extern "C" { int model_driver_create(KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit) { int ier; // read input files, convert units if needed, compute // interpolation coefficients, set cutoff, and publish parameters LennardJones612 * const modelObject = new LennardJones612(modelDriverCreate, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, &ier); if (ier) { // constructor already reported the error delete modelObject; return ier; } // register pointer to LennardJones612 object in KIM object modelDriverCreate->SetModelBufferPointer(static_cast(modelObject)); // everything is good ier = false; return ier; } } // extern "C" //============================================================================== // // Implementation of LennardJones612 public wrapper functions // //============================================================================== //****************************************************************************** LennardJones612::LennardJones612( KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int * const ier) { implementation_ = new LennardJones612Implementation(modelDriverCreate, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, ier); } //****************************************************************************** LennardJones612::~LennardJones612() { delete implementation_; } //****************************************************************************** // static member function int LennardJones612::Destroy(KIM::ModelDestroy * const modelDestroy) { LennardJones612 * modelObject; modelDestroy->GetModelBufferPointer(reinterpret_cast(&modelObject)); if (modelObject != NULL) { // delete object itself delete modelObject; } // everything is good return false; } //****************************************************************************** // static member function int LennardJones612::Refresh(KIM::ModelRefresh * const modelRefresh) { LennardJones612 * modelObject; modelRefresh->GetModelBufferPointer(reinterpret_cast(&modelObject)); return modelObject->implementation_->Refresh(modelRefresh); } //****************************************************************************** // static member function int LennardJones612::Compute( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments) { LennardJones612 * modelObject; modelCompute->GetModelBufferPointer(reinterpret_cast(&modelObject)); return modelObject->implementation_->Compute(modelCompute, modelComputeArguments); } //****************************************************************************** // static member function int LennardJones612::ComputeArgumentsCreate( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) { LennardJones612 * modelObject; modelCompute->GetModelBufferPointer(reinterpret_cast(&modelObject)); return modelObject->implementation_->ComputeArgumentsCreate( modelComputeArgumentsCreate); } //****************************************************************************** // static member function int LennardJones612::ComputeArgumentsDestroy( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy) { LennardJones612 * modelObject; modelCompute->GetModelBufferPointer(reinterpret_cast(&modelObject)); return modelObject->implementation_->ComputeArgumentsDestroy( modelComputeArgumentsDestroy); } kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/LennardJones612.hpp000066400000000000000000000056151421473465500310060ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Andrew Akerson // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #ifndef LENNARD_JONES_612_HPP_ #define LENNARD_JONES_612_HPP_ #include "KIM_ModelDriverHeaders.hpp" extern "C" { int model_driver_create(KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit); } class LennardJones612Implementation; class LennardJones612 { public: LennardJones612(KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int * const ier); ~LennardJones612(); // no need to make these "extern" since KIM will only access them // via function pointers. "static" is required so that there is not // an implicit this pointer added to the prototype by the C++ compiler static int Destroy(KIM::ModelDestroy * const modelDestroy); static int Refresh(KIM::ModelRefresh * const modelRefresh); static int Compute(KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments); static int ComputeArgumentsCreate( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate); static int ComputeArgumentsDestroy( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); private: LennardJones612Implementation * implementation_; }; #endif // LENNARD_JONES_612_HPP_ LennardJones612Implementation.cpp000066400000000000000000001115271421473465500336300ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Stephen M. Whalen // Andrew Akerson // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #include #include #include // IWYU pragma: keep // BUG WORK-AROUND #include #include #include #include "KIM_ModelDriverHeaders.hpp" #include "LennardJones612.hpp" #include "LennardJones612Implementation.hpp" #define MAXLINE 1024 #define IGNORE_RESULT(fn) \ if (fn) {} //============================================================================== // // Implementation of LennardJones612Implementation public member functions // //============================================================================== //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDriverCreate // LennardJones612Implementation::LennardJones612Implementation( KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int * const ier) : numberModelSpecies_(0), numberUniqueSpeciesPairs_(0), shift_(0), cutoffs_(NULL), epsilons_(NULL), sigmas_(NULL), influenceDistance_(0.0), cutoffsSq2D_(NULL), modelWillNotRequestNeighborsOfNoncontributingParticles_(1), fourEpsilonSigma6_2D_(NULL), fourEpsilonSigma12_2D_(NULL), twentyFourEpsilonSigma6_2D_(NULL), fortyEightEpsilonSigma12_2D_(NULL), oneSixtyEightEpsilonSigma6_2D_(NULL), sixTwentyFourEpsilonSigma12_2D_(NULL), shifts2D_(NULL), cachedNumberOfParticles_(0) { FILE * parameterFilePointers[MAX_PARAMETER_FILES]; int numberParameterFiles; modelDriverCreate->GetNumberOfParameterFiles(&numberParameterFiles); *ier = OpenParameterFiles( modelDriverCreate, numberParameterFiles, parameterFilePointers); if (*ier) return; *ier = ProcessParameterFiles( modelDriverCreate, numberParameterFiles, parameterFilePointers); CloseParameterFiles(numberParameterFiles, parameterFilePointers); if (*ier) return; *ier = ConvertUnits(modelDriverCreate, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit); if (*ier) return; *ier = SetRefreshMutableValues(modelDriverCreate); if (*ier) return; *ier = RegisterKIMModelSettings(modelDriverCreate); if (*ier) return; *ier = RegisterKIMParameters(modelDriverCreate); if (*ier) return; *ier = RegisterKIMFunctions(modelDriverCreate); if (*ier) return; // everything is good *ier = false; return; } //****************************************************************************** LennardJones612Implementation::~LennardJones612Implementation() { // note: it is ok to delete a null pointer and we have ensured that // everything is initialized to null delete[] cutoffs_; Deallocate2DArray(cutoffsSq2D_); delete[] epsilons_; delete[] sigmas_; Deallocate2DArray(fourEpsilonSigma6_2D_); Deallocate2DArray(fourEpsilonSigma12_2D_); Deallocate2DArray(twentyFourEpsilonSigma6_2D_); Deallocate2DArray(fortyEightEpsilonSigma12_2D_); Deallocate2DArray(oneSixtyEightEpsilonSigma6_2D_); Deallocate2DArray(sixTwentyFourEpsilonSigma12_2D_); Deallocate2DArray(shifts2D_); } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelRefresh // int LennardJones612Implementation::Refresh( KIM::ModelRefresh * const modelRefresh) { int ier; ier = SetRefreshMutableValues(modelRefresh); if (ier) return ier; // nothing else to do for this case // everything is good ier = false; return ier; } //****************************************************************************** int LennardJones612Implementation::Compute( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments) { int ier; // KIM API Model Input compute flags bool isComputeProcess_dEdr = false; bool isComputeProcess_d2Edr2 = false; // // KIM API Model Output compute flags bool isComputeEnergy = false; bool isComputeForces = false; bool isComputeParticleEnergy = false; bool isComputeVirial = false; bool isComputeParticleVirial = false; // // KIM API Model Input int const * particleSpeciesCodes = NULL; int const * particleContributing = NULL; VectorOfSizeDIM const * coordinates = NULL; // // KIM API Model Output double * energy = NULL; double * particleEnergy = NULL; VectorOfSizeDIM * forces = NULL; VectorOfSizeSix * virial = NULL; VectorOfSizeSix * particleVirial = NULL; ier = SetComputeMutableValues(modelComputeArguments, isComputeProcess_dEdr, isComputeProcess_d2Edr2, isComputeEnergy, isComputeForces, isComputeParticleEnergy, isComputeVirial, isComputeParticleVirial, particleSpeciesCodes, particleContributing, coordinates, energy, particleEnergy, forces, virial, particleVirial); if (ier) return ier; // Skip this check for efficiency // // ier = CheckParticleSpecies(modelComputeArguments, particleSpeciesCodes); // if (ier) return ier; bool const isShift = (1 == shift_); #include "LennardJones612ImplementationComputeDispatch.cpp" return ier; } //****************************************************************************** int LennardJones612Implementation::ComputeArgumentsCreate( KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) const { int ier; ier = RegisterKIMComputeArgumentsSettings(modelComputeArgumentsCreate); if (ier) return ier; // nothing else to do for this case // everything is good ier = false; return ier; } //****************************************************************************** int LennardJones612Implementation::ComputeArgumentsDestroy( KIM::ModelComputeArgumentsDestroy * const /* modelComputeArgumentsDestroy */) const { int ier; // nothing else to do for this case // everything is good ier = false; return ier; } //============================================================================== // // Implementation of LennardJones612Implementation private member functions // //============================================================================== //****************************************************************************** void LennardJones612Implementation::AllocatePrivateParameterMemory() { // nothing to do for this case } //****************************************************************************** void LennardJones612Implementation::AllocateParameterMemory() { // allocate memory for data cutoffs_ = new double[numberUniqueSpeciesPairs_]; AllocateAndInitialize2DArray( cutoffsSq2D_, numberModelSpecies_, numberModelSpecies_); epsilons_ = new double[numberUniqueSpeciesPairs_]; sigmas_ = new double[numberUniqueSpeciesPairs_]; AllocateAndInitialize2DArray( fourEpsilonSigma6_2D_, numberModelSpecies_, numberModelSpecies_); AllocateAndInitialize2DArray( fourEpsilonSigma12_2D_, numberModelSpecies_, numberModelSpecies_); AllocateAndInitialize2DArray( twentyFourEpsilonSigma6_2D_, numberModelSpecies_, numberModelSpecies_); AllocateAndInitialize2DArray( fortyEightEpsilonSigma12_2D_, numberModelSpecies_, numberModelSpecies_); AllocateAndInitialize2DArray( oneSixtyEightEpsilonSigma6_2D_, numberModelSpecies_, numberModelSpecies_); AllocateAndInitialize2DArray(sixTwentyFourEpsilonSigma12_2D_, numberModelSpecies_, numberModelSpecies_); AllocateAndInitialize2DArray( shifts2D_, numberModelSpecies_, numberModelSpecies_); } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDriverCreate // int LennardJones612Implementation::OpenParameterFiles( KIM::ModelDriverCreate * const modelDriverCreate, int const numberParameterFiles, FILE * parameterFilePointers[MAX_PARAMETER_FILES]) { int ier; if (numberParameterFiles > MAX_PARAMETER_FILES) { ier = true; LOG_ERROR("LennardJones612 given too many parameter files"); return ier; } std::string const * paramFileDirName; modelDriverCreate->GetParameterFileDirectoryName(¶mFileDirName); for (int i = 0; i < numberParameterFiles; ++i) { std::string const * paramFileName; ier = modelDriverCreate->GetParameterFileBasename(i, ¶mFileName); if (ier) { LOG_ERROR("Unable to get parameter file name"); return ier; } std::string filename = *paramFileDirName + "/" + *paramFileName; parameterFilePointers[i] = fopen(filename.c_str(), "r"); if (parameterFilePointers[i] == 0) { char message[MAXLINE]; sprintf(message, "LennardJones612 parameter file number %d cannot be opened", i); ier = true; LOG_ERROR(message); for (int j = i - 1; j >= 0; --j) { fclose(parameterFilePointers[j]); } return ier; } } // everything is good ier = false; return ier; } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDriverCreate // int LennardJones612Implementation::ProcessParameterFiles( KIM::ModelDriverCreate * const modelDriverCreate, int const /* numberParameterFiles */, FILE * const parameterFilePointers[MAX_PARAMETER_FILES]) { int N, ier; int endOfFileFlag = 0; char spec1[MAXLINE], spec2[MAXLINE], nextLine[MAXLINE]; char * nextLinePtr; int iIndex, jIndex, indx, iiIndex, jjIndex; double nextCutoff, nextEpsilon, nextSigma; nextLinePtr = nextLine; getNextDataLine( parameterFilePointers[0], nextLinePtr, MAXLINE, &endOfFileFlag); ier = sscanf(nextLine, "%d %d", &N, &shift_); if (ier != 2) { sprintf(nextLine, "unable to read first line of the parameter file"); ier = true; LOG_ERROR(nextLine); fclose(parameterFilePointers[0]); return ier; } numberModelSpecies_ = N; numberUniqueSpeciesPairs_ = ((numberModelSpecies_ + 1) * numberModelSpecies_) / 2; AllocateParameterMemory(); // set all values in the arrays to -1 for mixing later for (int i = 0; i < ((N + 1) * N / 2); i++) { cutoffs_[i] = -1; epsilons_[i] = -1; sigmas_[i] = -1; } // keep track of known species std::map modelSpeciesMap; std::vector speciesNameVector; int index = 0; // Read and process data lines getNextDataLine( parameterFilePointers[0], nextLinePtr, MAXLINE, &endOfFileFlag); while (endOfFileFlag == 0) { ier = sscanf(nextLine, "%s %s %lg %lg %lg", spec1, spec2, &nextCutoff, &nextEpsilon, &nextSigma); if (ier != 5) { sprintf(nextLine, "error reading lines of the parameter file"); LOG_ERROR(nextLine); return true; } // convert species strings to proper type instances KIM::SpeciesName const specName1(spec1); KIM::SpeciesName const specName2(spec2); // check for new species std::map:: const_iterator iIter = modelSpeciesMap.find(specName1); if (iIter == modelSpeciesMap.end()) { modelSpeciesMap[specName1] = index; modelSpeciesCodeList_.push_back(index); speciesNameVector.push_back(specName1); ier = modelDriverCreate->SetSpeciesCode(specName1, index); if (ier) return ier; iIndex = index; index++; } else { iIndex = modelSpeciesMap[specName1]; } std::map:: const_iterator jIter = modelSpeciesMap.find(specName2); if (jIter == modelSpeciesMap.end()) { modelSpeciesMap[specName2] = index; modelSpeciesCodeList_.push_back(index); speciesNameVector.push_back(specName2); ier = modelDriverCreate->SetSpeciesCode(specName2, index); if (ier) return ier; jIndex = index; index++; } else { jIndex = modelSpeciesMap[specName2]; } if (iIndex >= jIndex) { indx = jIndex * N + iIndex - (jIndex * jIndex + jIndex) / 2; } else { indx = iIndex * N + jIndex - (iIndex * iIndex + iIndex) / 2; } cutoffs_[indx] = nextCutoff; epsilons_[indx] = nextEpsilon; sigmas_[indx] = nextSigma; getNextDataLine( parameterFilePointers[0], nextLinePtr, MAXLINE, &endOfFileFlag); } // check that we got all like - like pairs std::stringstream ss; ss << "There are not values for like-like pairs of:"; for (int i = 0; i < N; i++) { if (cutoffs_[(i * N + i - (i * i + i) / 2)] == -1) { ss << " "; ss << (speciesNameVector[i].ToString()).c_str(); ier = -1; } } if (ier == -1) { LOG_ERROR(ss); return true; } // Perform Mixing if nessisary for (int jIndex = 0; jIndex < N; jIndex++) { jjIndex = (jIndex * N + jIndex - (jIndex * jIndex + jIndex) / 2); for (int iIndex = (jIndex + 1); iIndex < N; iIndex++) { indx = jIndex * N + iIndex - (jIndex * jIndex + jIndex) / 2; if (cutoffs_[indx] == -1) { iiIndex = (iIndex * N + iIndex - (iIndex * iIndex + iIndex) / 2); epsilons_[indx] = sqrt(epsilons_[iiIndex] * epsilons_[jjIndex]); sigmas_[indx] = (sigmas_[iiIndex] + sigmas_[jjIndex]) / 2.0; cutoffs_[indx] = (cutoffs_[iiIndex] + cutoffs_[jjIndex]) / 2.0; } } } // everything is good ier = false; return ier; } //****************************************************************************** void LennardJones612Implementation::getNextDataLine(FILE * const filePtr, char * nextLinePtr, int const maxSize, int * endOfFileFlag) { do { if (fgets(nextLinePtr, maxSize, filePtr) == NULL) { *endOfFileFlag = 1; break; } while ((nextLinePtr[0] == ' ' || nextLinePtr[0] == '\t') || (nextLinePtr[0] == '\n' || nextLinePtr[0] == '\r')) { nextLinePtr = (nextLinePtr + 1); } } while ((strncmp("#", nextLinePtr, 1) == 0) || (strlen(nextLinePtr) == 0)); } //****************************************************************************** void LennardJones612Implementation::CloseParameterFiles( int const numberParameterFiles, FILE * const parameterFilePointers[MAX_PARAMETER_FILES]) { for (int i = 0; i < numberParameterFiles; ++i) fclose(parameterFilePointers[i]); } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDriverCreate // int LennardJones612Implementation::ConvertUnits( KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit) { int ier; // define default base units KIM::LengthUnit fromLength = KIM::LENGTH_UNIT::A; KIM::EnergyUnit fromEnergy = KIM::ENERGY_UNIT::eV; KIM::ChargeUnit fromCharge = KIM::CHARGE_UNIT::e; KIM::TemperatureUnit fromTemperature = KIM::TEMPERATURE_UNIT::K; KIM::TimeUnit fromTime = KIM::TIME_UNIT::ps; // changing units of cutoffs and sigmas double convertLength = 1.0; ier = KIM::ModelDriverCreate::ConvertUnit(fromLength, fromEnergy, fromCharge, fromTemperature, fromTime, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, 1.0, 0.0, 0.0, 0.0, 0.0, &convertLength); if (ier) { LOG_ERROR("Unable to convert length unit"); return ier; } if (convertLength != ONE) { for (int i = 0; i < numberUniqueSpeciesPairs_; ++i) { cutoffs_[i] *= convertLength; // convert to active units sigmas_[i] *= convertLength; // convert to active units } } // changing units of epsilons double convertEnergy = 1.0; ier = KIM::ModelDriverCreate::ConvertUnit(fromLength, fromEnergy, fromCharge, fromTemperature, fromTime, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, 0.0, 1.0, 0.0, 0.0, 0.0, &convertEnergy); if (ier) { LOG_ERROR("Unable to convert energy unit"); return ier; } if (convertEnergy != ONE) { for (int i = 0; i < numberUniqueSpeciesPairs_; ++i) { epsilons_[i] *= convertEnergy; // convert to active units } } // register units ier = modelDriverCreate->SetUnits(requestedLengthUnit, requestedEnergyUnit, KIM::CHARGE_UNIT::unused, KIM::TEMPERATURE_UNIT::unused, KIM::TIME_UNIT::unused); if (ier) { LOG_ERROR("Unable to set units to requested values"); return ier; } // everything is good ier = false; return ier; } //****************************************************************************** int LennardJones612Implementation::RegisterKIMModelSettings( KIM::ModelDriverCreate * const modelDriverCreate) const { // register numbering int error = modelDriverCreate->SetModelNumbering(KIM::NUMBERING::zeroBased); return error; } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelComputeArgumentsCreate // int LennardJones612Implementation::RegisterKIMComputeArgumentsSettings( KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) const { // register arguments LOG_INFORMATION("Register argument supportStatus"); int error = modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, KIM::SUPPORT_STATUS::optional) || modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialForces, KIM::SUPPORT_STATUS::optional) || modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy, KIM::SUPPORT_STATUS::optional) || modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialVirial, KIM::SUPPORT_STATUS::optional) || modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial, KIM::SUPPORT_STATUS::optional); // register callbacks LOG_INFORMATION("Register callback supportStatus"); error = error || modelComputeArgumentsCreate->SetCallbackSupportStatus( KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm, KIM::SUPPORT_STATUS::optional) || modelComputeArgumentsCreate->SetCallbackSupportStatus( KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term, KIM::SUPPORT_STATUS::optional); return error; } //****************************************************************************** // helper macro #define SNUM(x) \ static_cast(std::ostringstream() \ << std::dec << x) \ .str() //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDriverCreate // int LennardJones612Implementation::RegisterKIMParameters( KIM::ModelDriverCreate * const modelDriverCreate) { int ier = false; // publish parameters (order is important) ier = modelDriverCreate->SetParameterPointer( 1, &shift_, "shift", "If (shift == 1), all LJ potentials are shifted to zero energy " "at their respective cutoff distance. Otherwise, no shifting is " "performed."); if (ier) { LOG_ERROR("set_parameter shift"); return ier; } ier = modelDriverCreate->SetParameterPointer( numberUniqueSpeciesPairs_, cutoffs_, "cutoffs", "Lower-triangular matrix (of size N=" + SNUM(numberModelSpecies_) + ") " "in row-major storage. Ordering is according to SpeciesCode " "values. " "For example, to find the parameter related to SpeciesCode 'i' and " "SpeciesCode 'j' (i >= j), use (zero-based) " "index = (j*N + i - (j*j + j)/2)."); if (ier) { LOG_ERROR("set_parameter cutoffs"); return ier; } ier = modelDriverCreate->SetParameterPointer( numberUniqueSpeciesPairs_, epsilons_, "epsilons", "Lower-triangular matrix (of size N=" + SNUM(numberModelSpecies_) + ") " "in row-major storage. Ordering is according to SpeciesCode " "values. " "For example, to find the parameter related to SpeciesCode 'i' and " "SpeciesCode 'j' (i >= j), use (zero-based) " "index = (j*N + i - (j*j + j)/2)."); if (ier) { LOG_ERROR("set_parameter epsilons"); return ier; } ier = modelDriverCreate->SetParameterPointer( numberUniqueSpeciesPairs_, sigmas_, "sigmas", "Lower-triangular matrix (of size N=" + SNUM(numberModelSpecies_) + ") " "in row-major storage. Ordering is according to SpeciesCode " "values. " "For example, to find the parameter related to SpeciesCode 'i' and " "SpeciesCode 'j' (i >= j), use (zero-based) " "index = (j*N + i - (j*j + j)/2)."); if (ier) { LOG_ERROR("set_parameter sigmas"); return ier; } // everything is good ier = false; return ier; } //****************************************************************************** int LennardJones612Implementation::RegisterKIMFunctions( KIM::ModelDriverCreate * const modelDriverCreate) const { int error; // Use function pointer definitions to verify correct prototypes KIM::ModelDestroyFunction * destroy = LennardJones612::Destroy; KIM::ModelRefreshFunction * refresh = LennardJones612::Refresh; KIM::ModelComputeFunction * compute = LennardJones612::Compute; KIM::ModelComputeArgumentsCreateFunction * CACreate = LennardJones612::ComputeArgumentsCreate; KIM::ModelComputeArgumentsDestroyFunction * CADestroy = LennardJones612::ComputeArgumentsDestroy; // register the destroy() and reinit() functions error = modelDriverCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::Destroy, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(destroy)) || modelDriverCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::Refresh, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(refresh)) || modelDriverCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::Compute, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(compute)) || modelDriverCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(CACreate)) || modelDriverCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(CADestroy)); return error; } //****************************************************************************** template int LennardJones612Implementation::SetRefreshMutableValues( ModelObj * const modelObj) { // use (possibly) new values of parameters to compute other quantities // NOTE: This function is templated because it's called with both a // modelDriverCreate object during initialization and with a // modelRefresh object when the Model's parameters have been altered int ier; // update cutoffsSq, epsilons, and sigmas for (int i = 0; i < numberModelSpecies_; ++i) { for (int j = 0; j <= i; ++j) { int const index = j * numberModelSpecies_ + i - (j * j + j) / 2; cutoffsSq2D_[i][j] = cutoffsSq2D_[j][i] = (cutoffs_[index] * cutoffs_[index]); fourEpsilonSigma6_2D_[i][j] = fourEpsilonSigma6_2D_[j][i] = 4.0 * epsilons_[index] * pow(sigmas_[index], 6.0); fourEpsilonSigma12_2D_[i][j] = fourEpsilonSigma12_2D_[j][i] = 4.0 * epsilons_[index] * pow(sigmas_[index], 12.0); twentyFourEpsilonSigma6_2D_[i][j] = twentyFourEpsilonSigma6_2D_[j][i] = 6.0 * fourEpsilonSigma6_2D_[i][j]; fortyEightEpsilonSigma12_2D_[i][j] = fortyEightEpsilonSigma12_2D_[j][i] = 12.0 * fourEpsilonSigma12_2D_[i][j]; oneSixtyEightEpsilonSigma6_2D_[i][j] = oneSixtyEightEpsilonSigma6_2D_[j][i] = 7.0 * twentyFourEpsilonSigma6_2D_[i][j]; sixTwentyFourEpsilonSigma12_2D_[i][j] = sixTwentyFourEpsilonSigma12_2D_[j][i] = 13.0 * fortyEightEpsilonSigma12_2D_[i][j]; } } // update cutoff value in KIM API object influenceDistance_ = 0.0; for (int i = 0; i < numberModelSpecies_; i++) { int indexI = modelSpeciesCodeList_[i]; for (int j = 0; j < numberModelSpecies_; j++) { int indexJ = modelSpeciesCodeList_[j]; if (influenceDistance_ < cutoffsSq2D_[indexI][indexJ]) { influenceDistance_ = cutoffsSq2D_[indexI][indexJ]; } } } influenceDistance_ = sqrt(influenceDistance_); modelObj->SetInfluenceDistancePointer(&influenceDistance_); modelObj->SetNeighborListPointers( 1, &influenceDistance_, &modelWillNotRequestNeighborsOfNoncontributingParticles_); // update shifts // compute and set shifts2D_ check if minus sign double const * const * const constFourEpsSig6_2D = fourEpsilonSigma6_2D_; double const * const * const constFourEpsSig12_2D = fourEpsilonSigma12_2D_; if (1 == shift_) { double phi; for (int iSpecies = 0; iSpecies < numberModelSpecies_; iSpecies++) { for (int jSpecies = 0; jSpecies <= iSpecies; jSpecies++) { int const index = jSpecies * numberModelSpecies_ + iSpecies - (jSpecies * jSpecies + jSpecies) / 2; double const rij2 = cutoffs_[index] * cutoffs_[index]; double const r2iv = 1.0 / rij2; double const r6iv = r2iv * r2iv * r2iv; LENNARD_JONES_PHI(;); shifts2D_[iSpecies][jSpecies] = shifts2D_[jSpecies][iSpecies] = phi; } } } // everything is good ier = false; return ier; } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelComputeArguments // int LennardJones612Implementation::SetComputeMutableValues( KIM::ModelComputeArguments const * const modelComputeArguments, bool & isComputeProcess_dEdr, bool & isComputeProcess_d2Edr2, bool & isComputeEnergy, bool & isComputeForces, bool & isComputeParticleEnergy, bool & isComputeVirial, bool & isComputeParticleVirial, int const *& particleSpeciesCodes, int const *& particleContributing, VectorOfSizeDIM const *& coordinates, double *& energy, double *& particleEnergy, VectorOfSizeDIM *& forces, VectorOfSizeSix *& virial, VectorOfSizeSix *& particleVirial) { int ier = true; // get compute flags int compProcess_dEdr; int compProcess_d2Edr2; modelComputeArguments->IsCallbackPresent( KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm, &compProcess_dEdr); modelComputeArguments->IsCallbackPresent( KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term, &compProcess_d2Edr2); isComputeProcess_dEdr = compProcess_dEdr; isComputeProcess_d2Edr2 = compProcess_d2Edr2; int const * numberOfParticles; ier = modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles, &numberOfParticles) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes, &particleSpeciesCodes) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::particleContributing, &particleContributing) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::coordinates, (double const **) &coordinates) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, &energy) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy, &particleEnergy) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialForces, (double const **) &forces) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialVirial, (double const **) &virial) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial, (double const **) &particleVirial); if (ier) { LOG_ERROR("GetArgumentPointer"); return ier; } isComputeEnergy = (energy != NULL); isComputeParticleEnergy = (particleEnergy != NULL); isComputeForces = (forces != NULL); isComputeVirial = (virial != NULL); isComputeParticleVirial = (particleVirial != NULL); // update values cachedNumberOfParticles_ = *numberOfParticles; // everything is good ier = false; return ier; } //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute int LennardJones612Implementation::CheckParticleSpeciesCodes( KIM::ModelCompute const * const modelCompute, int const * const particleSpeciesCodes) const { int ier; for (int i = 0; i < cachedNumberOfParticles_; ++i) { if ((particleSpeciesCodes[i] < 0) || (particleSpeciesCodes[i] >= numberModelSpecies_)) { ier = true; LOG_ERROR("unsupported particle species codes detected"); return ier; } } // everything is good ier = false; return ier; } //****************************************************************************** int LennardJones612Implementation::GetComputeIndex( const bool & isComputeProcess_dEdr, const bool & isComputeProcess_d2Edr2, const bool & isComputeEnergy, const bool & isComputeForces, const bool & isComputeParticleEnergy, const bool & isComputeVirial, const bool & isComputeParticleVirial, const bool & isShift) const { // const int processdE = 2; const int processd2E = 2; const int energy = 2; const int force = 2; const int particleEnergy = 2; const int virial = 2; const int particleVirial = 2; const int shift = 2; int index = 0; // processdE index += (int(isComputeProcess_dEdr)) * processd2E * energy * force * particleEnergy * virial * particleVirial * shift; // processd2E index += (int(isComputeProcess_d2Edr2)) * energy * force * particleEnergy * virial * particleVirial * shift; // energy index += (int(isComputeEnergy)) * force * particleEnergy * virial * particleVirial * shift; // force index += (int(isComputeForces)) * particleEnergy * virial * particleVirial * shift; // particleEnergy index += (int(isComputeParticleEnergy)) * virial * particleVirial * shift; // virial index += (int(isComputeVirial)) * particleVirial * shift; // particleVirial index += (int(isComputeParticleVirial)) * shift; // shift index += (int(isShift)); return index; } //****************************************************************************** void LennardJones612Implementation::ProcessVirialTerm( const double & dEidr, const double & rij, const double * const r_ij, const int & /* i */, const int & /* j */, VectorOfSizeSix virial) const { double const v = dEidr / rij; virial[0] += v * r_ij[0] * r_ij[0]; virial[1] += v * r_ij[1] * r_ij[1]; virial[2] += v * r_ij[2] * r_ij[2]; virial[3] += v * r_ij[1] * r_ij[2]; virial[4] += v * r_ij[0] * r_ij[2]; virial[5] += v * r_ij[0] * r_ij[1]; } //****************************************************************************** void LennardJones612Implementation::ProcessParticleVirialTerm( const double & dEidr, const double & rij, const double * const r_ij, const int & i, const int & j, VectorOfSizeSix * const particleVirial) const { double const v = dEidr / rij; VectorOfSizeSix vir; vir[0] = 0.5 * v * r_ij[0] * r_ij[0]; vir[1] = 0.5 * v * r_ij[1] * r_ij[1]; vir[2] = 0.5 * v * r_ij[2] * r_ij[2]; vir[3] = 0.5 * v * r_ij[1] * r_ij[2]; vir[4] = 0.5 * v * r_ij[0] * r_ij[2]; vir[5] = 0.5 * v * r_ij[0] * r_ij[1]; for (int k = 0; k < 6; ++k) { particleVirial[i][k] += vir[k]; particleVirial[j][k] += vir[k]; } } //============================================================================== // // Implementation of helper functions // //============================================================================== //****************************************************************************** void AllocateAndInitialize2DArray(double **& arrayPtr, int const extentZero, int const extentOne) { // allocate memory and set pointers arrayPtr = new double *[extentZero]; arrayPtr[0] = new double[extentZero * extentOne]; for (int i = 1; i < extentZero; ++i) { arrayPtr[i] = arrayPtr[i - 1] + extentOne; } // initialize for (int i = 0; i < extentZero; ++i) { for (int j = 0; j < extentOne; ++j) { arrayPtr[i][j] = 0.0; } } } //****************************************************************************** void Deallocate2DArray(double **& arrayPtr) { // deallocate memory if (arrayPtr != NULL) delete[] arrayPtr[0]; delete[] arrayPtr; // nullify pointer arrayPtr = NULL; } LennardJones612Implementation.hpp000066400000000000000000000465761421473465500336500ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Andrew Akerson // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #ifndef LENNARD_JONES_612_IMPLEMENTATION_HPP_ #define LENNARD_JONES_612_IMPLEMENTATION_HPP_ #include "KIM_LogMacros.hpp" #include "KIM_ModelDriverHeaders.hpp" #include #include #include #define DIMENSION 3 #define ONE 1.0 #define HALF 0.5 #define MAX_PARAMETER_FILES 1 #define PARAM_SHIFT_INDEX 0 #define PARAM_CUTOFFS_INDEX 1 #define PARAM_EPSILONS_INDEX 2 #define PARAM_SIGMAS_INDEX 3 //============================================================================== // // Type definitions, enumerations, and helper function prototypes // //============================================================================== // type declaration for get neighbor functions typedef int(GetNeighborFunction)(void const * const, int const, int * const, int const ** const); // type declaration for vector of constant dimension typedef double VectorOfSizeDIM[DIMENSION]; typedef double VectorOfSizeSix[6]; // helper routine declarations void AllocateAndInitialize2DArray(double **& arrayPtr, int const extentZero, int const extentOne); void Deallocate2DArray(double **& arrayPtr); //============================================================================== // // Declaration of LennardJones612Implementation class // //============================================================================== //****************************************************************************** class LennardJones612Implementation { public: LennardJones612Implementation( KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int * const ier); ~LennardJones612Implementation(); // no explicit Destroy() needed here int Refresh(KIM::ModelRefresh * const modelRefresh); int Compute(KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments); int ComputeArgumentsCreate(KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) const; int ComputeArgumentsDestroy(KIM::ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy) const; private: // Constant values that never change // Set in constructor (via SetConstantValues) // // // LennardJones612Implementation: constants int numberModelSpecies_; std::vector modelSpeciesCodeList_; int numberUniqueSpeciesPairs_; // Constant values that are read from the input files and never change // Set in constructor (via functions listed below) // // // Private Model Parameters // Memory allocated in AllocatePrivateParameterMemory() (from constructor) // Memory deallocated in destructor // Data set in ReadParameterFile routines // none // // KIM API: Model Parameters whose (pointer) values never change // Memory allocated in AllocateParameterMemory() (from constructor) // Memory deallocated in destructor // Data set in ReadParameterFile routines OR by KIM Simulator int shift_; double * cutoffs_; double * epsilons_; double * sigmas_; // Mutable values that only change when Refresh() executes // Set in Refresh (via SetRefreshMutableValues) // // // KIM API: Model Parameters (can be changed directly by KIM Simulator) // none // // LennardJones612Implementation: values (changed only by Refresh()) double influenceDistance_; double ** cutoffsSq2D_; int modelWillNotRequestNeighborsOfNoncontributingParticles_; double ** fourEpsilonSigma6_2D_; double ** fourEpsilonSigma12_2D_; double ** twentyFourEpsilonSigma6_2D_; double ** fortyEightEpsilonSigma12_2D_; double ** oneSixtyEightEpsilonSigma6_2D_; double ** sixTwentyFourEpsilonSigma12_2D_; double ** shifts2D_; // Mutable values that can change with each call to Refresh() and Compute() // Memory may be reallocated on each call // // // LennardJones612Implementation: values that change int cachedNumberOfParticles_; // Helper methods // // // Related to constructor void AllocatePrivateParameterMemory(); void AllocateParameterMemory(); static int OpenParameterFiles(KIM::ModelDriverCreate * const modelDriverCreate, int const numberParameterFiles, FILE * parameterFilePointers[MAX_PARAMETER_FILES]); int ProcessParameterFiles( KIM::ModelDriverCreate * const modelDriverCreate, int const numberParameterFiles, FILE * const parameterFilePointers[MAX_PARAMETER_FILES]); void getNextDataLine(FILE * const filePtr, char * const nextLine, int const maxSize, int * endOfFileFlag); static void CloseParameterFiles(int const numberParameterFiles, FILE * const parameterFilePointers[MAX_PARAMETER_FILES]); int ConvertUnits(KIM::ModelDriverCreate * const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit); int RegisterKIMModelSettings( KIM::ModelDriverCreate * const modelDriverCreate) const; int RegisterKIMComputeArgumentsSettings( KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) const; int RegisterKIMParameters(KIM::ModelDriverCreate * const modelDriverCreate); int RegisterKIMFunctions( KIM::ModelDriverCreate * const modelDriverCreate) const; // // Related to Refresh() template int SetRefreshMutableValues(ModelObj * const modelObj); // // Related to Compute() int SetComputeMutableValues( KIM::ModelComputeArguments const * const modelComputeArguments, bool & isComputeProcess_dEdr, bool & isComputeProcess_d2Edr2, bool & isComputeEnergy, bool & isComputeForces, bool & isComputeParticleEnergy, bool & isComputeVirial, bool & isComputeParticleVirial, int const *& particleSpeciesCodes, int const *& particleContributing, VectorOfSizeDIM const *& coordinates, double *& energy, double *& particleEnergy, VectorOfSizeDIM *& forces, VectorOfSizeSix *& virial, VectorOfSizeSix *& particleViral); int CheckParticleSpeciesCodes(KIM::ModelCompute const * const modelCompute, int const * const particleSpeciesCodes) const; int GetComputeIndex(const bool & isComputeProcess_dEdr, const bool & isComputeProcess_d2Edr2, const bool & isComputeEnergy, const bool & isComputeForces, const bool & isComputeParticleEnergy, const bool & isComputeVirial, const bool & isComputeParticleVirial, const bool & isShift) const; void ProcessVirialTerm(const double & dEidr, const double & rij, const double * const r_ij, const int & i, const int & j, VectorOfSizeSix virial) const; void ProcessParticleVirialTerm(const double & dEidr, const double & rij, const double * const r_ij, const int & i, const int & j, VectorOfSizeSix * const particleVirial) const; // compute functions template int Compute(KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments, const int * const particleSpeciesCodes, const int * const particleContributing, const VectorOfSizeDIM * const coordinates, double * const energy, VectorOfSizeDIM * const forces, double * const particleEnergy, VectorOfSizeSix virial, VectorOfSizeSix * const particleVirial) const; }; //============================================================================== // // Definition of LennardJones612Implementation::Compute functions // // NOTE: Here we rely on the compiler optimizations to prune dead code // after the template expansions. This provides high efficiency // and easy maintenance. // //============================================================================== //****************************************************************************** // MACRO to compute Lennard-Jones phi // (used for efficiency) // // exshift - expression to be added to the end of the phi value #define LENNARD_JONES_PHI(exshift) \ phi = r6iv \ * (constFourEpsSig12_2D[iSpecies][jSpecies] * r6iv \ - constFourEpsSig6_2D[iSpecies][jSpecies]) exshift; //****************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute // template int LennardJones612Implementation::Compute( KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments, const int * const particleSpeciesCodes, const int * const particleContributing, const VectorOfSizeDIM * const coordinates, double * const energy, VectorOfSizeDIM * const forces, double * const particleEnergy, VectorOfSizeSix virial, VectorOfSizeSix * const particleVirial) const { int ier = false; if ((isComputeEnergy == false) && (isComputeParticleEnergy == false) && (isComputeForces == false) && (isComputeProcess_dEdr == false) && (isComputeProcess_d2Edr2 == false) && (isComputeVirial == false) && (isComputeParticleVirial == false)) return ier; // initialize energy and forces if (isComputeEnergy == true) { *energy = 0.0; } if (isComputeVirial == true) { for (int i = 0; i < 6; ++i) virial[i] = 0.0; } if (isComputeParticleEnergy == true) { int const cachedNumParticles = cachedNumberOfParticles_; for (int i = 0; i < cachedNumParticles; ++i) { particleEnergy[i] = 0.0; } } if (isComputeForces == true) { int const cachedNumParticles = cachedNumberOfParticles_; for (int i = 0; i < cachedNumParticles; ++i) { for (int j = 0; j < DIMENSION; ++j) forces[i][j] = 0.0; } } if (isComputeParticleVirial == true) { int const cachedNumParticles = cachedNumberOfParticles_; for (int i = 0; i < cachedNumParticles; ++i) { for (int j = 0; j < 6; ++j) particleVirial[i][j] = 0.0; } } // calculate contribution from pair function // // Setup loop over contributing particles int ii = 0; int numnei = 0; int const * n1atom = NULL; double const * const * const constCutoffsSq2D = cutoffsSq2D_; double const * const * const constFourEpsSig6_2D = fourEpsilonSigma6_2D_; double const * const * const constFourEpsSig12_2D = fourEpsilonSigma12_2D_; double const * const * const constTwentyFourEpsSig6_2D = twentyFourEpsilonSigma6_2D_; double const * const * const constFortyEightEpsSig12_2D = fortyEightEpsilonSigma12_2D_; double const * const * const constOneSixtyEightEpsSig6_2D = oneSixtyEightEpsilonSigma6_2D_; double const * const * const constSixTwentyFourEpsSig12_2D = sixTwentyFourEpsilonSigma12_2D_; double const * const * const constShifts2D = shifts2D_; for (ii = 0; ii < cachedNumberOfParticles_; ++ii) { if (particleContributing[ii]) { modelComputeArguments->GetNeighborList(0, ii, &numnei, &n1atom); int const numNei = numnei; int const * const n1Atom = n1atom; int const i = ii; int const iSpecies = particleSpeciesCodes[i]; // Setup loop over neighbors of current particle for (int jj = 0; jj < numNei; ++jj) { int const j = n1Atom[jj]; int const jContrib = particleContributing[j]; if (!(jContrib && (j < i))) // effective half-list { int const jSpecies = particleSpeciesCodes[j]; double * r_ij; double r_ijValue[DIMENSION]; // Compute r_ij r_ij = r_ijValue; for (int k = 0; k < DIMENSION; ++k) r_ij[k] = coordinates[j][k] - coordinates[i][k]; double const * const r_ij_const = const_cast(r_ij); // compute distance squared double const rij2 = r_ij_const[0] * r_ij_const[0] + r_ij_const[1] * r_ij_const[1] + r_ij_const[2] * r_ij_const[2]; if (rij2 <= constCutoffsSq2D[iSpecies][jSpecies]) { // compute contribution to energy, force, etc. double phi = 0.0; double dphiByR = 0.0; double d2phi = 0.0; double dEidrByR = 0.0; double d2Eidr2 = 0.0; double const r2iv = 1.0 / rij2; double const r6iv = r2iv * r2iv * r2iv; // Compute pair potential and its derivatives if (isComputeProcess_d2Edr2 == true) { // Compute d2phi d2phi = r6iv * (constSixTwentyFourEpsSig12_2D[iSpecies][jSpecies] * r6iv - constOneSixtyEightEpsSig6_2D[iSpecies][jSpecies]) * r2iv; if (jContrib == 1) { d2Eidr2 = d2phi; } else { d2Eidr2 = 0.5 * d2phi; } } if ((isComputeProcess_dEdr == true) || (isComputeForces == true) || (isComputeVirial == true) || (isComputeParticleVirial == true)) { // Compute dphi dphiByR = r6iv * (constTwentyFourEpsSig6_2D[iSpecies][jSpecies] - constFortyEightEpsSig12_2D[iSpecies][jSpecies] * r6iv) * r2iv; if (jContrib == 1) { dEidrByR = dphiByR; } else { dEidrByR = 0.5 * dphiByR; } } if ((isComputeEnergy == true) || (isComputeParticleEnergy == true)) { // Compute phi if (isShift == true) { LENNARD_JONES_PHI(-constShifts2D[iSpecies][jSpecies]); } else { LENNARD_JONES_PHI(;); } } // Contribution to energy if (isComputeEnergy == true) { if (jContrib == 1) { *energy += phi; } else { *energy += 0.5 * phi; } } // Contribution to particleEnergy if (isComputeParticleEnergy == true) { double const halfPhi = 0.5 * phi; particleEnergy[i] += halfPhi; if (jContrib == 1) { particleEnergy[j] += halfPhi; } } // Contribution to forces if (isComputeForces == true) { for (int k = 0; k < DIMENSION; ++k) { double const contrib = dEidrByR * r_ij_const[k]; forces[i][k] += contrib; forces[j][k] -= contrib; } } // Call process_dEdr if ((isComputeProcess_dEdr == true) || (isComputeVirial == true) || (isComputeParticleVirial == true)) { double const rij = sqrt(rij2); double const dEidr = dEidrByR * rij; if (isComputeProcess_dEdr == true) { ier = modelComputeArguments->ProcessDEDrTerm( dEidr, rij, r_ij_const, i, j); if (ier) { LOG_ERROR("process_dEdr"); return ier; } } if (isComputeVirial == true) { ProcessVirialTerm(dEidr, rij, r_ij_const, i, j, virial); } if (isComputeParticleVirial == true) { ProcessParticleVirialTerm( dEidr, rij, r_ij_const, i, j, particleVirial); } } // Call process_d2Edr2 if (isComputeProcess_d2Edr2 == true) { double const rij = sqrt(rij2); double const R_pairs[2] = {rij, rij}; double const * const pRs = &R_pairs[0]; double const Rij_pairs[6] = {r_ij_const[0], r_ij_const[1], r_ij_const[2], r_ij_const[0], r_ij_const[1], r_ij_const[2]}; double const * const pRijConsts = &Rij_pairs[0]; int const i_pairs[2] = {i, i}; int const j_pairs[2] = {j, j}; int const * const pis = &i_pairs[0]; int const * const pjs = &j_pairs[0]; ier = modelComputeArguments->ProcessD2EDr2Term( d2Eidr2, pRs, pRijConsts, pis, pjs); if (ier) { LOG_ERROR("process_d2Edr2"); return ier; } } } // if particleContributing } // if i < j or j non contributing } // if particles i and j interact } // end of first neighbor loop } // end of loop over contributing particles // everything is good ier = false; return ier; } #endif // LENNARD_JONES_612_IMPLEMENTATION_HPP_ LennardJones612ImplementationComputeDispatch.cpp000066400000000000000000002435331421473465500366500ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003switch (GetComputeIndex(isComputeProcess_dEdr, isComputeProcess_d2Edr2, isComputeEnergy, isComputeForces, isComputeParticleEnergy, isComputeVirial, isComputeParticleVirial, isShift)) { case 0: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 1: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 2: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 3: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 4: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 5: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 6: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 7: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 8: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 9: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 10: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 11: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 12: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 13: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 14: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 15: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 16: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 17: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 18: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 19: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 20: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 21: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 22: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 23: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 24: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 25: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 26: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 27: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 28: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 29: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 30: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 31: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 32: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 33: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 34: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 35: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 36: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 37: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 38: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 39: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 40: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 41: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 42: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 43: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 44: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 45: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 46: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 47: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 48: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 49: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 50: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 51: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 52: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 53: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 54: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 55: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 56: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 57: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 58: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 59: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 60: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 61: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 62: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 63: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 64: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 65: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 66: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 67: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 68: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 69: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 70: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 71: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 72: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 73: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 74: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 75: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 76: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 77: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 78: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 79: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 80: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 81: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 82: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 83: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 84: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 85: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 86: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 87: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 88: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 89: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 90: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 91: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 92: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 93: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 94: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 95: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 96: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 97: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 98: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 99: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 100: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 101: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 102: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 103: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 104: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 105: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 106: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 107: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 108: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 109: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 110: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 111: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 112: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 113: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 114: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 115: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 116: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 117: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 118: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 119: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 120: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 121: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 122: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 123: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 124: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 125: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 126: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 127: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 128: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 129: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 130: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 131: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 132: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 133: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 134: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 135: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 136: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 137: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 138: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 139: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 140: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 141: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 142: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 143: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 144: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 145: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 146: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 147: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 148: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 149: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 150: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 151: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 152: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 153: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 154: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 155: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 156: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 157: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 158: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 159: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 160: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 161: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 162: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 163: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 164: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 165: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 166: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 167: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 168: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 169: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 170: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 171: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 172: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 173: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 174: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 175: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 176: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 177: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 178: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 179: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 180: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 181: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 182: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 183: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 184: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 185: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 186: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 187: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 188: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 189: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 190: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 191: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 192: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 193: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 194: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 195: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 196: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 197: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 198: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 199: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 200: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 201: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 202: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 203: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 204: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 205: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 206: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 207: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 208: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 209: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 210: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 211: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 212: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 213: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 214: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 215: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 216: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 217: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 218: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 219: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 220: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 221: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 222: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 223: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 224: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 225: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 226: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 227: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 228: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 229: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 230: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 231: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 232: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 233: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 234: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 235: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 236: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 237: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 238: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 239: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 240: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 241: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 242: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 243: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 244: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 245: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 246: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 247: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 248: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 249: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 250: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 251: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 252: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 253: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 254: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; case 255: ier = Compute( modelCompute, modelComputeArguments, particleSpeciesCodes, particleContributing, coordinates, energy, forces, particleEnergy, *virial, particleVirial); break; default: std::cout << "Unknown compute function index" << std::endl; ier = true; break; } kim-api-2.3.0-git/examples/model-drivers/LennardJones612__MD_414112407348_003/README000066400000000000000000000052201421473465500263320ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Andrew Akerson # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (LennardJones612__MD_414112407348_003) contains a Lennard-Jones Driver which reads a parameter file containing the parameters for up to 139 species. It supports shifted and non-shifted energy behavior. The driver is written in C++. This Model Driver expects one parameter file as decribed below. The model driver implements the functional form: phi_{ij}(r) = 4 * epsilon_{ij} * [ (sigma_{ij}/r)^12 - (sigma_{ij}/r)^6 ] + shift_{ij}, where i, j = 0, 1, 2, ..., N-1, and N is the number of supported species. The format of the parameter file is as follows: * Blank lines and lines beginning with the `#' character are ignored. * Line 0 : N, shift - N : integer number of distinct particle species - shift : integer value: 0-for no shift; 1-for shifts. All shift values are computed at run time * Lines 1,2,...: species_i, species_j, cutoff, epsilon, sigma - species_i : A valid KIM API particle species string - species_j : A valid KIM API particle species string - cutoff : double cutoff distance value (in Angstroms) for phi_{ij}(r) - epsilon : double energy value (in eV) for epsilon_{ij} - sigma : double sigma distance value (in Angstroms) for sigma_{ij} The parameter file must contain all "like-like" parameter sets (i.e., lines where species_i and species_j are identical) for each species which occurs in the file. The model driver uses the Lorentz-Berthelot rules to generate any "cross-interaction" parameter sets which are not provided. The model driver sets the `influcenceDistance' argument to max_{ij}(cutoff_{ij}). The model driver uses this same influenceDistance as its NeighborListCutoff value. kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_LJ/000077500000000000000000000000001421473465500242445ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_LJ/CMakeLists.txt000066400000000000000000000031151421473465500270040ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "modelDriver") project(ex_model_driver_P_LJ LANGUAGES Fortran) kim_api_items_setup_after_project(ITEM_TYPE "modelDriver") add_kim_api_model_driver_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_driver_create_routine" CREATE_ROUTINE_LANGUAGE "fortran" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.f90) kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_LJ/LICENSE.LGPL000066400000000000000000000636421421473465500260210ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_LJ/README000066400000000000000000000027351421473465500251330ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_driver_P_LJ) contains a shifted Lennard-Jones pair potential Model driver written in Fortran 90. phi(r) = 4 * epsilon * ( (sigma/r)^12 - (sigma/r)^6 ) + shift where shift is computed so that phi(rcut) = 0.0 To create a KIM Model from this Model Driver, one parameter file is required. This file must have the following format: Line 1: `SpeciesName' string with element symbol Line 1: `cutoff' value in angstroms Line 2: Lennard-Jones `epsilon' value in eV Line 3: Lennard-Jones `sigma' value in Angstroms kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_LJ/ex_model_driver_P_LJ.f90000066400000000000000000000774651421473465500306220ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! Ellad B. Tadmor ! Valeriu Smirichinski ! Stephen M. Whalen ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! !**************************************************************************** !** !** MODULE ex_model_driver_P_LJ !** !** Lennard-Jones pair potential KIM Model Driver !** shifted to have zero energy at the cutoff radius !** !** Language: Fortran 2003 !** !**************************************************************************** module ex_model_driver_p_lj use, intrinsic :: iso_c_binding use kim_model_driver_headers_module implicit none save private public & BUFFER_TYPE, & Compute_Energy_Forces, & compute_arguments_create, & compute_arguments_destroy, & refresh, & write_model, & destroy, & calc_phi, & calc_phi_dphi, & calc_phi_dphi_d2phi, & speccode ! Below are the definitions and values of all Model parameters integer(c_int), parameter :: cd = c_double ! for literal constants integer(c_int), parameter :: DIM = 3 ! dimensionality of space integer(c_int), parameter :: speccode = 1 ! internal species code !----------------------------------------------------------------------------- ! ! Definition of Buffer type ! !----------------------------------------------------------------------------- type, bind(c) :: BUFFER_TYPE character(c_char) :: species_name(100) real(c_double) :: influence_distance(1) real(c_double) :: Pcutoff(1) real(c_double) :: cutsq(1) integer(c_int) :: & model_will_not_request_neighbors_of_noncontributing_particles(1) real(c_double) :: epsilon(1) real(c_double) :: sigma(1) real(c_double) :: shift(1) end type BUFFER_TYPE contains !----------------------------------------------------------------------------- ! ! Calculate pair potential phi(r) ! !----------------------------------------------------------------------------- recursive subroutine calc_phi(model_epsilon, & model_sigma, & model_shift, & model_cutoff, r, phi) implicit none !-- Transferred variables real(c_double), intent(in) :: model_epsilon real(c_double), intent(in) :: model_sigma real(c_double), intent(in) :: model_shift real(c_double), intent(in) :: model_cutoff real(c_double), intent(in) :: r real(c_double), intent(out) :: phi !-- Local variables real(c_double) rsq, sor, sor6, sor12 rsq = r * r ! r^2 sor = model_sigma / r ! (sig/r) sor6 = sor * sor * sor ! sor6 = sor6 * sor6 ! (sig/r)^6 sor12 = sor6 * sor6 ! (sig/r)^12 if (r > model_cutoff) then ! Argument exceeds cutoff radius phi = 0.0_cd else phi = 4.0_cd * model_epsilon * (sor12 - sor6) + model_shift end if end subroutine calc_phi !----------------------------------------------------------------------------- ! ! Calculate pair potential phi(r) and its derivative dphi(r) ! !----------------------------------------------------------------------------- recursive subroutine calc_phi_dphi(model_epsilon, & model_sigma, & model_shift, & model_cutoff, r, phi, dphi) implicit none !-- Transferred variables real(c_double), intent(in) :: model_epsilon real(c_double), intent(in) :: model_sigma real(c_double), intent(in) :: model_shift real(c_double), intent(in) :: model_cutoff real(c_double), intent(in) :: r real(c_double), intent(out) :: phi, dphi !-- Local variables real(c_double) rsq, sor, sor6, sor12 rsq = r * r ! r^2 sor = model_sigma / r ! (sig/r) sor6 = sor * sor * sor ! sor6 = sor6 * sor6 ! (sig/r)^6 sor12 = sor6 * sor6 ! (sig/r)^12 if (r > model_cutoff) then ! Argument exceeds cutoff radius phi = 0.0_cd dphi = 0.0_cd else phi = 4.0_cd * model_epsilon * (sor12 - sor6) + model_shift dphi = 24.0_cd * model_epsilon * (-2.0_cd * sor12 + sor6) / r end if end subroutine calc_phi_dphi !----------------------------------------------------------------------------- ! ! Calculate pair potential phi(r) and its derivatives dphi(r) and d2phi(r) ! !----------------------------------------------------------------------------- recursive subroutine calc_phi_dphi_d2phi(model_epsilon, & model_sigma, & model_shift, & model_cutoff, r, phi, dphi, d2phi) implicit none !-- Transferred variables real(c_double), intent(in) :: model_epsilon real(c_double), intent(in) :: model_sigma real(c_double), intent(in) :: model_shift real(c_double), intent(in) :: model_cutoff real(c_double), intent(in) :: r real(c_double), intent(out) :: phi, dphi, d2phi !-- Local variables real(c_double) rsq, sor, sor6, sor12 rsq = r * r ! r^2 sor = model_sigma / r ! (sig/r) sor6 = sor * sor * sor ! sor6 = sor6 * sor6 ! (sig/r)^6 sor12 = sor6 * sor6 ! (sig/r)^12 if (r > model_cutoff) then ! Argument exceeds cutoff radius phi = 0.0_cd dphi = 0.0_cd d2phi = 0.0_cd else phi = 4.0_cd * model_epsilon * (sor12 - sor6) + model_shift dphi = 24.0_cd * model_epsilon * (-2.0_cd * sor12 + sor6) / r d2phi = 24.0_cd * model_epsilon * (26.0_cd * sor12 - 7.0_cd * sor6) / rsq end if end subroutine calc_phi_dphi_d2phi !----------------------------------------------------------------------------- ! ! Compute energy and forces on particles from the positions. ! !----------------------------------------------------------------------------- recursive subroutine Compute_Energy_Forces( & model_compute_handle, model_compute_arguments_handle, ierr) bind(c) implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle integer(c_int), intent(out) :: ierr !-- Local variables real(c_double) :: r, Rsqij, phi, dphi, d2phi, dEidr, d2Eidr integer(c_int) :: i, j, jj, numnei integer(c_int) :: ierr2 integer(c_int) :: comp_force, comp_energy, comp_enepot, comp_process_dEdr, & comp_process_d2Edr2 type(BUFFER_TYPE), pointer :: buf; type(c_ptr) :: pbuf real(c_double), target :: Rij(DIM) real(c_double), target :: Rij_pairs(DIM, 2) real(c_double), target :: r_pairs(2) integer(c_int), target :: i_pairs(2), j_pairs(2) !-- KIM variables real(c_double) :: model_cutoff integer(c_int), pointer :: N real(c_double), pointer :: energy real(c_double), pointer :: coor(:, :) real(c_double), pointer :: force(:, :) real(c_double), pointer :: enepot(:) integer(c_int), pointer :: nei1part(:) integer(c_int), pointer :: particleSpeciesCodes(:) integer(c_int), pointer :: particleContributing(:) ! get model buffer from KIM object call kim_get_model_buffer_pointer(model_compute_handle, pbuf) call c_f_pointer(pbuf, buf) model_cutoff = buf%influence_distance(1) ! Check to see if we have been asked to compute the forces, energyperpart, ! energy and d1Edr ! ierr = 0 call kim_is_callback_present( & model_compute_arguments_handle, & KIM_COMPUTE_CALLBACK_NAME_PROCESS_DEDR_TERM, comp_process_dedr, ierr2) ierr = ierr + ierr2 call kim_is_callback_present( & model_compute_arguments_handle, & KIM_COMPUTE_CALLBACK_NAME_PROCESS_D2EDR2_TERM, comp_process_d2edr2, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry(model_compute_arguments_handle, & KIM_LOG_VERBOSITY_ERROR, "get_compute") ierr = 1 return end if ! Unpack data from KIM object ! ierr = 0 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, n, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, & n, particlespeciesCodes, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, & n, particlecontributing, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, dim, n, coor, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, energy, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, dim, n, force, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, n, enepot, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry(model_compute_arguments_handle, & KIM_LOG_VERBOSITY_ERROR, "get_argument_pointer") ierr = 1 return end if if (associated(energy)) then comp_energy = 1 else comp_energy = 0 end if if (associated(force)) then comp_force = 1 else comp_force = 0 end if if (associated(enepot)) then comp_enepot = 1 else comp_enepot = 0 end if ! Check to be sure that the species are correct ! ierr = 1 ! assume an error do i = 1, N if (particleSpeciesCodes(i) /= speccode) then call kim_log_entry( & model_compute_arguments_handle, KIM_LOG_VERBOSITY_ERROR, & "Unexpected species code detected") ierr = 1 return end if end do ierr = 0 ! everything is ok ! Initialize potential energies, forces ! if (comp_enepot == 1) enepot = 0.0_cd if (comp_energy == 1) energy = 0.0_cd if (comp_force == 1) force = 0.0_cd ! ! Compute energy and forces ! ! Loop over particles and compute energy and forces ! do i = 1, N if (particleContributing(i) == 1) then ! Set up neighbor list for next particle ! call kim_get_neighbor_list( & model_compute_arguments_handle, 1, i, numnei, nei1part, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_arguments_handle, KIM_LOG_VERBOSITY_ERROR, & "kim_api_get_neigh") ierr = 1 return end if ! Loop over the neighbors of particle i ! do jj = 1, numnei j = nei1part(jj) ! get neighbor ID ! compute relative position vector ! Rij(:) = coor(:, j) - coor(:, i) ! distance vector between i j ! compute energy and forces ! Rsqij = dot_product(Rij, Rij) ! compute square distance if (Rsqij < buf%cutsq(1)) then ! particles are interacting? r = sqrt(Rsqij) ! compute distance if (comp_process_d2Edr2 == 1) then call calc_phi_dphi_d2phi(buf%epsilon(1), & buf%sigma(1), & buf%shift(1), & buf%Pcutoff(1), & r, phi, dphi, d2phi) ! compute pair potential ! and it derivatives dEidr = 0.5_cd * dphi ! regular contribution d2Eidr = 0.5_cd * d2phi elseif (comp_force == 1 .or. comp_process_dEdr == 1) then call calc_phi_dphi(buf%epsilon(1), & buf%sigma(1), & buf%shift(1), & buf%Pcutoff(1), & r, phi, dphi) ! compute pair potential ! and it derivative dEidr = 0.5_cd * dphi ! regular contribution else call calc_phi(buf%epsilon(1), & buf%sigma(1), & buf%shift(1), & buf%Pcutoff(1), & r, phi) ! compute just pair potential end if ! contribution to energy ! if (comp_enepot == 1) then enepot(i) = enepot(i) + 0.5_cd * phi ! accumulate energy end if if (comp_energy == 1) then energy = energy + 0.5_cd * phi ! add half v to total energy end if ! contribution to process_dEdr ! if (comp_process_dEdr == 1) then call kim_process_dedr_term( & model_compute_arguments_handle, deidr, r, rij, i, j, ierr) end if ! contribution to process_d2Edr2 if (comp_process_d2Edr2 == 1) then r_pairs(1) = r r_pairs(2) = r Rij_pairs(:, 1) = Rij Rij_pairs(:, 2) = Rij i_pairs(1) = i i_pairs(2) = i j_pairs(1) = j j_pairs(2) = j call kim_process_d2edr2_term( & model_compute_arguments_handle, d2eidr, & r_pairs, Rij_pairs, i_pairs, j_pairs, ierr) end if ! contribution to forces ! if (comp_force == 1) then force(:, i) = force(:, i) + dEidr * Rij / r ! accumulate force on particle i force(:, j) = force(:, j) - dEidr * Rij / r ! accumulate force on particle j end if end if end do ! loop on jj end if ! if particleContributing end do ! do i ! Everything is great ! ierr = 0 return end subroutine Compute_Energy_Forces !----------------------------------------------------------------------------- ! ! Model driver refresh routine ! !----------------------------------------------------------------------------- recursive subroutine refresh(model_refresh_handle, ierr) bind(c) implicit none !-- transferred variables type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle integer(c_int), intent(out) :: ierr !-- Local variables real(c_double) energy_at_cutoff type(BUFFER_TYPE), pointer :: buf; type(c_ptr) :: pbuf ! get model buffer from KIM object call kim_get_model_buffer_pointer(model_refresh_handle, pbuf) call c_f_pointer(pbuf, buf) call kim_set_influence_distance_pointer(model_refresh_handle, & buf%influence_distance(1)) call kim_set_neighbor_list_pointers( & model_refresh_handle, 1, buf%influence_distance, & buf%model_will_not_request_neighbors_of_noncontributing_particles) ! Set new values in KIM object and buffer ! buf%influence_distance(1) = buf%Pcutoff(1) buf%cutsq(1) = (buf%Pcutoff(1))**2 ! calculate pair potential at r=cutoff with shift=0.0 call calc_phi(buf%epsilon(1), & buf%sigma(1), & 0.0_cd, & buf%Pcutoff(1), & buf%Pcutoff(1), energy_at_cutoff) buf%shift(1) = -energy_at_cutoff ierr = 0 return end subroutine refresh !----------------------------------------------------------------------------- ! ! Model driver write_model routine ! !----------------------------------------------------------------------------- recursive subroutine write_model( & model_write_parameterized_model_handle, ierr) bind(c) implicit none !-- transferred variables type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle integer(c_int), intent(out) :: ierr !-- Local variables integer i type(BUFFER_TYPE), pointer :: buf; type(c_ptr) :: pbuf character(len=512, kind=c_char) :: path character(len=512, kind=c_char) :: model_name character(len=512, kind=c_char) :: string_buffer character(len=100, kind=c_char) :: species_name ! get model buffer from KIM object call kim_get_model_buffer_pointer( & model_write_parameterized_model_handle, pbuf) call c_f_pointer(pbuf, buf) call kim_get_path(model_write_parameterized_model_handle, path) call kim_get_model_name(model_write_parameterized_model_handle, model_name) write (string_buffer, '(A)') trim(model_name)//".params" call kim_set_parameter_file_name(model_write_parameterized_model_handle, & string_buffer) write (string_buffer, '(A)') trim(path)//"/"//trim(string_buffer) open (42, FILE=trim(string_buffer), & STATUS="REPLACE", ACTION="WRITE", iostat=ierr) if (ierr /= 0) then call kim_log_entry( & model_write_parameterized_model_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to open parameter file for writing.") return end if do i = 1, 100 species_name(i:i) = buf%species_name(i) end do write (42, '(A)') trim(species_name) write (42, '(ES20.10)') buf%Pcutoff(1) write (42, '(ES20.10)') buf%epsilon(1) write (42, '(ES20.10)') buf%sigma(1) ierr = 0 return end subroutine write_model !----------------------------------------------------------------------------- ! ! Model driver destroy routine ! !----------------------------------------------------------------------------- recursive subroutine destroy(model_destroy_handle, ierr) bind(c) implicit none !-- Transferred variables type(kim_model_destroy_handle_type), intent(in) :: model_destroy_handle integer(c_int), intent(out) :: ierr !-- Local variables type(BUFFER_TYPE), pointer :: buf; type(c_ptr) :: pbuf ! get model buffer from KIM object call kim_get_model_buffer_pointer(model_destroy_handle, pbuf) call c_f_pointer(pbuf, buf) deallocate (buf) ierr = 0 return end subroutine destroy !----------------------------------------------------------------------------- ! ! Model driver compute arguments create routine ! !----------------------------------------------------------------------------- recursive subroutine compute_arguments_create( & model_compute_handle, model_compute_arguments_create_handle, ierr) bind(c) implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_create_handle_type), intent(in) :: & model_compute_arguments_create_handle integer(c_int), intent(out) :: ierr integer(c_int) ierr2 ! avoid unsed dummy argument warnings if (model_compute_handle == KIM_MODEL_COMPUTE_NULL_HANDLE) continue ierr = 0 ierr2 = 0 ! register arguments call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, & KIM_SUPPORT_STATUS_OPTIONAL, ierr) call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry( & model_compute_arguments_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to register arguments support_statuss") ierr = 1 goto 42 end if ! register callbacks call kim_set_callback_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_CALLBACK_NAME_PROCESS_DEDR_TERM, & KIM_SUPPORT_STATUS_OPTIONAL, ierr) call kim_set_callback_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_CALLBACK_NAME_PROCESS_D2EDR2_TERM, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry( & model_compute_arguments_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to register callbacks support_statuss") ierr = 1 goto 42 end if ierr = 0 42 continue return end subroutine compute_arguments_create !----------------------------------------------------------------------------- ! ! Model driver compute arguments destroy routine ! !----------------------------------------------------------------------------- recursive subroutine compute_arguments_destroy( & model_compute_handle, model_compute_arguments_destroy_handle, ierr) bind(c) implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: & model_compute_arguments_destroy_handle integer(c_int), intent(out) :: ierr ! avoid unsed dummy argument warnings if (model_compute_handle == KIM_MODEL_COMPUTE_NULL_HANDLE) continue if (model_compute_arguments_destroy_handle == & KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_NULL_HANDLE) continue ierr = 0 return end subroutine compute_arguments_destroy end module ex_model_driver_p_lj !----------------------------------------------------------------------------- ! ! Model driver create routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_driver_create_routine( & model_driver_create_handle, requested_length_unit, requested_energy_unit, & requested_charge_unit, requested_temperature_unit, requested_time_unit, & ierr) bind(c) use, intrinsic :: iso_c_binding use ex_model_driver_p_lj use kim_model_driver_headers_module implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants !-- Transferred variables type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(kim_length_unit_type), intent(in), value :: requested_length_unit type(kim_energy_unit_type), intent(in), value :: requested_energy_unit type(kim_charge_unit_type), intent(in), value :: requested_charge_unit type(kim_temperature_unit_type), intent(in), value :: & requested_temperature_unit type(kim_time_unit_type), intent(in), value :: requested_time_unit integer(c_int), intent(out) :: ierr !-- Local variables integer i integer(c_int) :: number_of_parameter_files character(len=1024, kind=c_char) :: parameter_file_directory_name character(len=1024, kind=c_char) :: parameter_file_basename character(len=1024, kind=c_char) :: parameter_file_name integer(c_int) :: ierr2 type(BUFFER_TYPE), pointer :: buf type(kim_species_name_type) species_name ! define variables for all model parameters to be read in real(c_double) factor character(len=100, kind=c_char) in_species real(c_double) in_cutoff real(c_double) in_epsilon real(c_double) in_sigma real(c_double) energy_at_cutoff ! register units call kim_set_units( & model_driver_create_handle, & REQUESTED_LENGTH_UNIT, & REQUESTED_ENERGY_UNIT, & KIM_CHARGE_UNIT_UNUSED, & KIM_TEMPERATURE_UNIT_UNUSED, & KIM_TIME_UNIT_UNUSED, ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "Unable to set units") ierr = 1 goto 42 end if ! register numbering call kim_set_model_numbering( & model_driver_create_handle, KIM_NUMBERING_ONE_BASED, ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "Unable to set numbering") ierr = 1 goto 42 end if ! store callback pointers in KIM object call kim_set_routine_pointer( & model_driver_create_handle, KIM_MODEL_ROUTINE_NAME_COMPUTE, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(Compute_Energy_Forces), ierr) call kim_set_routine_pointer( & model_driver_create_handle, & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(compute_arguments_create), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_driver_create_handle, KIM_MODEL_ROUTINE_NAME_REFRESH, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(refresh), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_driver_create_handle, & KIM_MODEL_ROUTINE_NAME_WRITE_PARAMETERIZED_MODEL, & KIM_LANGUAGE_NAME_FORTRAN, 0, c_funloc(write_model), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_driver_create_handle, & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(compute_arguments_destroy), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_driver_create_handle, KIM_MODEL_ROUTINE_NAME_DESTROY, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(destroy), ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry( & model_driver_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to store callback pointers") ierr = 1 goto 42 end if ! process parameter files call kim_get_number_of_parameter_files( & model_driver_create_handle, number_of_parameter_files) if (number_of_parameter_files /= 1) then call kim_log_entry( & model_driver_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Wrong number of parameter files") ierr = 1 goto 42 end if ! Read in model parameters from parameter file ! call kim_get_parameter_file_directory_name( & model_driver_create_handle, parameter_file_directory_name) call kim_get_parameter_file_basename( & model_driver_create_handle, 1, parameter_file_basename, ierr) if (ierr /= 0) then call kim_log_entry( & model_driver_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to get parameter file basename") ierr = 1 goto 42 end if parameter_file_name = trim(parameter_file_directory_name)//"/"// & trim(parameter_file_basename) open (10, file=parameter_file_name, status="old") read (10, *, iostat=ierr, err=100) in_species read (10, *, iostat=ierr, err=100) in_cutoff read (10, *, iostat=ierr, err=100) in_epsilon read (10, *, iostat=ierr, err=100) in_sigma close (10) goto 200 100 continue ! reading parameters failed call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "Unable to read LJ parameters") ierr = 1 goto 42 200 continue ! register species call kim_from_string(in_species, species_name) call kim_set_species_code( & model_driver_create_handle, species_name, speccode, ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "Unable to set species code") ierr = 1 goto 42 end if ! convert to appropriate units call kim_convert_unit( & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_E, & KIM_TEMPERATURE_UNIT_K, & KIM_TIME_UNIT_PS, & requested_length_unit, & requested_energy_unit, & requested_charge_unit, & requested_temperature_unit, & requested_time_unit, & 1.0_cd, 0.0_cd, 0.0_cd, 0.0_cd, 0.0_cd, factor, ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "kim_api_convert_to_act_unit") ierr = 1 goto 42 end if in_cutoff = in_cutoff * factor call kim_convert_unit( & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_E, & KIM_TEMPERATURE_UNIT_K, & KIM_TIME_UNIT_PS, & requested_length_unit, & requested_energy_unit, & requested_charge_unit, & requested_temperature_unit, & requested_time_unit, & 0.0_cd, 1.0_cd, 0.0_cd, 0.0_cd, 0.0_cd, factor, ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "kim_api_convert_to_act_unit") ierr = 1 goto 42 end if in_epsilon = in_epsilon * factor call kim_convert_unit( & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_E, & KIM_TEMPERATURE_UNIT_K, & KIM_TIME_UNIT_PS, & requested_length_unit, & requested_energy_unit, & requested_charge_unit, & requested_temperature_unit, & requested_time_unit, & 1.0_cd, 0.0_cd, 0.0_cd, 0.0_cd, 0.0_cd, factor, ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "kim_api_convert_to_act_unit") ierr = 1 goto 42 end if in_sigma = in_sigma * factor allocate (buf) ! setup buffer ! set value of parameters do i = 1, 100 buf%species_name(i) = in_species(i:i) end do buf%influence_distance(1) = in_cutoff buf%Pcutoff(1) = in_cutoff buf%cutsq(1) = in_cutoff**2 buf%model_will_not_request_neighbors_of_noncontributing_particles = 1 buf%epsilon(1) = in_epsilon buf%sigma(1) = in_sigma call calc_phi(in_epsilon, & in_sigma, & 0.0_cd, & in_cutoff, & in_cutoff, energy_at_cutoff) buf%shift(1) = -energy_at_cutoff ! store model cutoff in KIM object call kim_set_influence_distance_pointer( & model_driver_create_handle, buf%influence_distance(1)) call kim_set_neighbor_list_pointers( & model_driver_create_handle, 1, buf%influence_distance, & buf%model_will_not_request_neighbors_of_noncontributing_particles) ! end setup buffer ! store in model buffer call kim_set_model_buffer_pointer( & model_driver_create_handle, c_loc(buf)) ! set pointers to parameters in KIM object call kim_set_parameter_pointer( & model_driver_create_handle, buf%pcutoff, "cutoff", & "Distance beyond which particles do not interact with one another.", ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "set_parameter") ierr = 1 goto 42 end if call kim_set_parameter_pointer( & model_driver_create_handle, buf%epsilon, "epsilon", & "Maximum depth of the potential well.", ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "set_parameter") ierr = 1 goto 42 end if call kim_set_parameter_pointer( & model_driver_create_handle, buf%sigma, "sigma", & "Distance at which energy is zero and force is repulsive.", ierr) if (ierr /= 0) then call kim_log_entry(model_driver_create_handle, & KIM_LOG_VERBOSITY_ERROR, "set_parameter") ierr = 1 goto 42 end if ierr = 0 42 continue return end subroutine model_driver_create_routine kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_Morse/000077500000000000000000000000001421473465500250245ustar00rootroot00000000000000kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_Morse/CMakeLists.txt000066400000000000000000000030721421473465500275660ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "modelDriver") project(ex_model_driver_P_Morse LANGUAGES C) kim_api_items_setup_after_project(ITEM_TYPE "modelDriver") add_kim_api_model_driver_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_driver_create" CREATE_ROUTINE_LANGUAGE "c" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.c) kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_Morse/LICENSE.LGPL000066400000000000000000000636421421473465500266010ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_Morse/README000066400000000000000000000030721421473465500257060ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_driver_P_Morse) contains a shifted Morse pair potential Model driver written in C. phi(r) = epsilon * ( - exp[ -2*C*(r - Rzero) ] + 2*exp[ -C*(r - Rzero) ] ) + shift where shift is computed so that phi(rcut) = 0.0 To create a KIM Model from this Model Driver, one parameter file is required. This file must have the following format: Line 1: `SpeciesName' string with element symbol Line 2: `cutoff' value in angstroms Line 3: Morse `epsilon' value in eV Line 4: Morse `C' value in 1/Angstroms Line 5: Morse `Rzero' value in Angstroms Any additional lines will be silently ignored. kim-api-2.3.0-git/examples/model-drivers/ex_model_driver_P_Morse/ex_model_driver_P_Morse.c000066400000000000000000000620241421473465500317670ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* Stephen M. Whalen */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /******************************************************************************/ /* */ /* ex_model_driver_P_Morse pair potential KIM Model Driver */ /* shifted to have zero energy at the cutoff radius */ /* */ /* Language: C */ /* */ /******************************************************************************/ #include "KIM_LogMacros.h" #include "KIM_ModelDriverHeaders.h" #include #include #include #define TRUE 1 #define FALSE 0 /******************************************************************************/ /* Below are the definitions for some constants */ /******************************************************************************/ #define DIM 3 /* dimensionality of space */ #define SPECCODE 1 /* internal species code */ #define SPEC_NAME_LEN 64 /* max length of species name string */ #define SPEC_NAME_FMT "%63s" /* Define prototype for Model Driver init */ int model_driver_create(KIM_ModelDriverCreate * const modelDriverCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit); /* Define prototypes for destroy */ /* defined as static to avoid namespace clashes with other codes */ static int destroy_routine(KIM_ModelDestroy * const modelDestroy); /* Define prototype for routines */ static int compute_routine(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments); static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate); static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); static int refresh_routine(KIM_ModelRefresh * const modelRefresh); static int write_parameterized_model(KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel); /* Define prototypes for pair potential calculations */ static void calc_phi(double const * epsilon, double const * C, double const * Rzero, double const * shift, double const cutoff, double const r, double * phi); static void calc_phi_dphi(double const * epsilon, double const * C, double const * Rzero, double const * shift, double const cutoff, double const r, double * phi, double * dphi); /* Define model_buffer structure */ struct model_buffer { double influenceDistance; double cutoff; double cutsq; int modelWillNotRequestNeighborsOfNoncontributingParticles; char speciesName[SPEC_NAME_LEN]; double epsilon; double C; double Rzero; double shift; }; /* Calculate pair potential phi(r) */ static void calc_phi(double const * epsilon, double const * C, double const * Rzero, double const * shift, double const cutoff, double const r, double * phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; } return; } /* Calculate pair potential phi(r) and its derivative dphi(r) */ static void calc_phi_dphi(double const * epsilon, double const * C, double const * Rzero, double const * shift, double const cutoff, double const r, double * phi, double * dphi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); } return; } /* compute function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute static int compute_routine(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments) { /* local variables */ double R; double Rsqij; double phi; double dphi; double dEidr; double Rij[DIM]; int ier; int i; int j; int jj; int k; int const * neighListOfCurrentPart; struct model_buffer * buffer; int comp_energy; int comp_force; int comp_particleEnergy; int * nParts; int * particleSpeciesCodes; int * particleContributing; double cutoff; double * cutsq; double * epsilon; double * C; double * Rzero; double * shift; double * coords; double * energy; double * force; double * particleEnergy; int numOfPartNeigh; /* get buffer from KIM object */ KIM_ModelCompute_GetModelBufferPointer(modelCompute, (void **) &buffer); /* unpack info from the buffer */ cutoff = buffer->influenceDistance; cutsq = &(buffer->cutsq); epsilon = &(buffer->epsilon); C = &(buffer->C); Rzero = &(buffer->Rzero); shift = &(buffer->shift); ier = KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles, &nParts) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, &particleSpeciesCodes) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleContributing, &particleContributing) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &coords) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, &energy) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialForces, &force) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, &particleEnergy); if (ier) { LOG_ERROR("GetArgumentPointer"); return ier; } comp_energy = (energy != NULL); comp_force = (force != NULL); comp_particleEnergy = (particleEnergy != NULL); /* Check to be sure that the species are correct */ /**/ ier = TRUE; /* assume an error */ for (i = 0; i < *nParts; ++i) { if (SPECCODE != particleSpeciesCodes[i]) { LOG_ERROR("Unexpected species code detected"); return ier; } } ier = FALSE; /* everything is ok */ /* initialize potential energies, forces, and virial term */ if (comp_particleEnergy) { for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; } } if (comp_energy) { *energy = 0.0; } if (comp_force) { for (i = 0; i < *nParts; ++i) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] = 0.0; } } } /* Compute energy and forces */ /* loop over particles and compute enregy and forces */ for (i = 0; i < *nParts; ++i) { if (particleContributing[i]) { ier = KIM_ModelComputeArguments_GetNeighborList(modelComputeArguments, 0, i, &numOfPartNeigh, &neighListOfCurrentPart); if (ier) { /* some sort of problem, exit */ LOG_ERROR("KIM_get_neigh"); ier = TRUE; return ier; } /* loop over the neighbors of particle i */ for (jj = 0; jj < numOfPartNeigh; ++jj) { j = neighListOfCurrentPart[jj]; /* get neighbor ID */ /* compute relative position vector and squared distance */ Rsqij = 0.0; for (k = 0; k < DIM; ++k) { Rij[k] = coords[j * DIM + k] - coords[i * DIM + k]; /* compute squared distance */ Rsqij += Rij[k] * Rij[k]; } /* compute energy and force */ if (Rsqij < *cutsq) { /* particles are interacting ? */ R = sqrt(Rsqij); if (comp_force) { /* compute pair potential and its derivative */ calc_phi_dphi(epsilon, C, Rzero, shift, cutoff, R, &phi, &dphi); /* compute dEidr */ dEidr = 0.5 * dphi; } else { /* compute just pair potential */ calc_phi(epsilon, C, Rzero, shift, cutoff, R, &phi); } /* contribution to energy */ if (comp_particleEnergy) { particleEnergy[i] += 0.5 * phi; } if (comp_energy) { *energy += 0.5 * phi; } /* contribution to forces */ if (comp_force) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] += dEidr * Rij[k] / R; /* accumulate force on i */ force[j * DIM + k] -= dEidr * Rij[k] / R; /* accumulate force on j */ } } } /* if Rsqij */ } /* loop on jj */ } /* if particleContributing */ } /* infinite while loop (terminated by break statements above) */ /* everything is great */ ier = FALSE; return ier; } /* Create function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDriverCreate_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDriverCreate int model_driver_create(KIM_ModelDriverCreate * const modelDriverCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit) { /* KIM variables */ int numberOfParameterFiles; char const * paramfiledirname; char const * paramfilebasename; char paramfile1name[2048]; /* Local variables */ FILE * fid; char speciesNameString[SPEC_NAME_LEN]; KIM_SpeciesName speciesName; double cutoff; double epsilon; double C; double Rzero; int ier; double dummy; struct model_buffer * buffer; /* Use function pointer definitions to verify prototypes */ KIM_ModelDriverCreateFunction * create = model_driver_create; KIM_ModelComputeArgumentsCreateFunction * CACreate = compute_arguments_create; KIM_ModelComputeFunction * compute = compute_routine; KIM_ModelRefreshFunction * refresh = refresh_routine; KIM_ModelWriteParameterizedModelFunction * writeModel = write_parameterized_model; KIM_ModelComputeArgumentsDestroyFunction * CADestroy = compute_arguments_destroy; KIM_ModelDestroyFunction * destroy = destroy_routine; (void) create; /* avoid unused parameter warnings */ (void) requestedLengthUnit; (void) requestedEnergyUnit; (void) requestedChargeUnit; (void) requestedTemperatureUnit; (void) requestedTimeUnit; /* using fixed units */ ier = KIM_ModelDriverCreate_SetUnits(modelDriverCreate, KIM_LENGTH_UNIT_A, KIM_ENERGY_UNIT_eV, KIM_CHARGE_UNIT_unused, KIM_TEMPERATURE_UNIT_unused, KIM_TIME_UNIT_unused); if (ier == TRUE) { LOG_ERROR("Problem setting units"); return ier; } ier = KIM_ModelDriverCreate_SetModelNumbering(modelDriverCreate, KIM_NUMBERING_zeroBased); if (ier == TRUE) { LOG_ERROR("Unable to set numbering"); return ier; } /* store pointer to functions in KIM object */ ier = KIM_ModelDriverCreate_SetRoutinePointer( modelDriverCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CACreate) || KIM_ModelDriverCreate_SetRoutinePointer( modelDriverCreate, KIM_MODEL_ROUTINE_NAME_Compute, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) compute) || KIM_ModelDriverCreate_SetRoutinePointer( modelDriverCreate, KIM_MODEL_ROUTINE_NAME_Refresh, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) refresh) || KIM_ModelDriverCreate_SetRoutinePointer( modelDriverCreate, KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel, KIM_LANGUAGE_NAME_c, FALSE, (KIM_Function *) writeModel) || KIM_ModelDriverCreate_SetRoutinePointer( modelDriverCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CADestroy) || KIM_ModelDriverCreate_SetRoutinePointer( modelDriverCreate, KIM_MODEL_ROUTINE_NAME_Destroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) destroy); /* get number of parameter files */ KIM_ModelDriverCreate_GetNumberOfParameterFiles(modelDriverCreate, &numberOfParameterFiles); /* set paramfile1name */ if (numberOfParameterFiles != 1) { ier = TRUE; LOG_ERROR("Incorrect number of parameter files."); return ier; } KIM_ModelDriverCreate_GetParameterFileDirectoryName(modelDriverCreate, ¶mfiledirname); ier = KIM_ModelDriverCreate_GetParameterFileBasename( modelDriverCreate, 0, ¶mfilebasename); if (ier == TRUE) { LOG_ERROR("Unable to get parameter file basename."); return ier; } sprintf(paramfile1name, "%s/%s", paramfiledirname, paramfilebasename); /* Read in model parameters from parameter file */ fid = fopen(paramfile1name, "r"); if (fid == NULL) { ier = TRUE; LOG_ERROR("Unable to open parameter file for Morse parameters"); return ier; } ier = fscanf(fid, SPEC_NAME_FMT " \n%lf \n%lf \n%lf \n%lf", speciesNameString, /* element symbol */ &cutoff, /* cutoff distance in angstroms */ &epsilon, /* Morse epsilon in eV */ &C, /* Morse C in 1/Angstroms */ &Rzero /* Morse Rzero in Angstroms */ ); fclose(fid); /* check that we read the right number of parameters */ if (5 != ier) { ier = TRUE; LOG_ERROR("Unable to read all parameters"); return ier; } /* register species */ speciesName = KIM_SpeciesName_FromString(speciesNameString); ier = KIM_ModelDriverCreate_SetSpeciesCode( modelDriverCreate, speciesName, SPECCODE); if (ier == TRUE) { LOG_ERROR("Unable to set species code for Ar."); return ier; } /* allocate buffer */ buffer = (struct model_buffer *) malloc(sizeof(struct model_buffer)); if (NULL == buffer) { ier = TRUE; LOG_ERROR("malloc"); return ier; } /* setup buffer */ /* set value of parameters */ buffer->influenceDistance = cutoff; buffer->cutoff = cutoff; buffer->cutsq = (cutoff) * (cutoff); buffer->modelWillNotRequestNeighborsOfNoncontributingParticles = 1; sprintf(buffer->speciesName, "%s", speciesNameString); buffer->epsilon = epsilon; buffer->C = C; buffer->Rzero = Rzero; /* set value of parameter shift */ dummy = 0.0; /* call calc_phi with r=cutoff and shift=0.0 */ calc_phi(&(buffer->epsilon), &(buffer->C), &(buffer->Rzero), &dummy, cutoff, cutoff, &(buffer->shift)); /* set shift to -shift */ buffer->shift = -buffer->shift; /* end setup buffer */ /* store in model buffer */ KIM_ModelDriverCreate_SetModelBufferPointer(modelDriverCreate, (void *) buffer); /* publish model parameters */ ier = KIM_ModelDriverCreate_SetParameterPointerDouble(modelDriverCreate, 1, &(buffer->cutoff), "cutoff", "pair cutoff distance") || KIM_ModelDriverCreate_SetParameterPointerDouble(modelDriverCreate, 1, &(buffer->epsilon), "epsilon", "Morse epsilon") || KIM_ModelDriverCreate_SetParameterPointerDouble( modelDriverCreate, 1, &(buffer->C), "C", "Morse C") || KIM_ModelDriverCreate_SetParameterPointerDouble( modelDriverCreate, 1, &(buffer->Rzero), "Rzero", "Morse Rzero"); if (ier == TRUE) { LOG_ERROR("Unable to set parameter pointer(s)."); return TRUE; } /* store model cutoff in KIM object */ KIM_ModelDriverCreate_SetInfluenceDistancePointer( modelDriverCreate, &(buffer->influenceDistance)); KIM_ModelDriverCreate_SetNeighborListPointers( modelDriverCreate, 1, &(buffer->cutoff), &(buffer->modelWillNotRequestNeighborsOfNoncontributingParticles)); return FALSE; } /* Refresh function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelRefresh_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelRefresh int refresh_routine(KIM_ModelRefresh * const modelRefresh) { double dummy; struct model_buffer * buffer; /* get model buffer from KIM object */ KIM_ModelRefresh_GetModelBufferPointer(modelRefresh, (void **) &buffer); /* set value of parameter shift */ dummy = 0.0; /* call calc_phi with r=cutoff and shift=0.0 */ calc_phi(&(buffer->epsilon), &(buffer->C), &(buffer->Rzero), &dummy, buffer->cutoff, buffer->cutoff, &(buffer->shift)); /* set shift to -shift */ buffer->shift = -buffer->shift; /* set influence distance to current value of cutoff parameter */ buffer->influenceDistance = buffer->cutoff; /* store model cutoff in KIM object */ KIM_ModelRefresh_SetInfluenceDistancePointer(modelRefresh, &(buffer->influenceDistance)); KIM_ModelRefresh_SetNeighborListPointers( modelRefresh, 1, &(buffer->cutoff), &(buffer->modelWillNotRequestNeighborsOfNoncontributingParticles)); return FALSE; } /* destroy function */ static int destroy_routine(KIM_ModelDestroy * const modelDestroy) { /* Local variables */ struct model_buffer * buffer; int ier; /* get model buffer from KIM object */ KIM_ModelDestroy_GetModelBufferPointer(modelDestroy, (void **) &buffer); /* free the buffer */ free(buffer); ier = FALSE; return ier; } /* compute arguments create routine */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelComputeArgumentsCreate_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelComputeArgumentsCreate static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) { int ier; (void) modelCompute; /* avoid unused parameter warning */ /* register arguments */ ier = KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, KIM_SUPPORT_STATUS_optional) || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, KIM_SUPPORT_STATUS_optional) || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialForces, KIM_SUPPORT_STATUS_optional); if (ier == TRUE) { LOG_ERROR("Unable to set argument supportStatus."); return TRUE; } else { return FALSE; } } /* compute arguments destroy routine */ static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy) { (void) modelCompute; /* avoid unused parameter warning */ (void) modelComputeArgumentsDestroy; /* Nothing further to do */ return FALSE; } /* write parameterized model routine */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelWriteParameterizedModel_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelWriteParameterizedModel static int write_parameterized_model( KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel) { FILE * fp; char stringBuffer[2048]; struct model_buffer const * buffer; char const * path; char const * modelName; /* get buffer from KIM object */ KIM_ModelWriteParameterizedModel_GetModelBufferPointer( modelWriteParameterizedModel, (void **) &buffer); KIM_ModelWriteParameterizedModel_GetPath(modelWriteParameterizedModel, &path); KIM_ModelWriteParameterizedModel_GetModelName(modelWriteParameterizedModel, &modelName); sprintf(stringBuffer, "%s.params", modelName); KIM_ModelWriteParameterizedModel_SetParameterFileName( modelWriteParameterizedModel, stringBuffer); sprintf(stringBuffer, "%s/%s.params", path, modelName); fp = fopen(stringBuffer, "w"); if (NULL == fp) { LOG_ERROR("Unable to open parameter file for writing."); return TRUE; } fprintf(fp, "%s\n", buffer->speciesName); fprintf(fp, "%20.10f\n", buffer->cutoff); fprintf(fp, "%20.10f\n", buffer->epsilon); fprintf(fp, "%20.10f\n", buffer->C); fprintf(fp, "%20.10f\n", buffer->Rzero); fclose(fp); return FALSE; } kim-api-2.3.0-git/examples/portable-models/000077500000000000000000000000001421473465500205465ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/CMakeLists.txt000066400000000000000000000027551421473465500233170ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) add_subdirectory(ex_model_Ar_P_LJ) add_subdirectory(ex_model_Ar_P_MLJ_Fortran) add_subdirectory(ex_model_Ar_P_Morse) add_subdirectory(ex_model_Ar_P_Morse_07C) add_subdirectory(ex_model_Ar_P_Morse_07C_w_Extensions) add_subdirectory(ex_model_Ar_P_Morse_MultiCutoff) add_subdirectory(ex_model_Ar_SLJ_MultiCutoff) add_subdirectory(LennardJones612_UniversalShifted__MO_959249795837_003) add_subdirectory(LennardJones_Ar) kim-api-2.3.0-git/examples/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003/000077500000000000000000000000001421473465500314105ustar00rootroot00000000000000CMakeLists.txt000066400000000000000000000030551421473465500340740ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(LennardJones612_UniversalShifted__MO_959249795837_003) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} DRIVER_NAME "LennardJones612__MD_414112407348_003" PARAMETER_FILES "LennardJones612_UniversalShifted.params" ) LICENSE.LGPL000066400000000000000000000636421421473465500331060ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! LennardJones612_UniversalShifted.params000066400000000000000000000277751421473465500407320ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003139 1 # cutoff and sigmas are in units of Angstroms # epsilon are in units of Electron Volts #Species_i # Species_j # cutoff # epsilon # sigma H H 2.2094300 4.4778900 0.5523570 He He 1.9956100 0.0009421 0.4989030 Li Li 9.1228000 1.0496900 2.2807000 Be Be 6.8421000 0.5729420 1.7105300 B B 6.0581100 2.9670300 1.5145300 C C 5.4166600 6.3695300 1.3541700 N N 5.0603000 9.7537900 1.2650800 O O 4.7039500 5.1264700 1.1759900 F F 4.0625000 1.6059200 1.0156200 Ne Ne 4.1337700 0.0036471 1.0334400 Na Na 11.8311000 0.7367450 2.9577800 Mg Mg 10.0493000 0.0785788 2.5123300 Al Al 8.6239000 2.7006700 2.1559700 Si Si 7.9111800 3.1743100 1.9778000 P P 7.6260900 5.0305000 1.9065200 S S 7.4835500 4.3692700 1.8708900 Cl Cl 7.2697300 4.4832800 1.8174300 Ar Ar 7.5548200 0.0123529 1.8887100 K K 14.4682000 0.5517990 3.6170500 Ca Ca 12.5439000 0.1326790 3.1359600 Sc Sc 12.1162000 1.6508000 3.0290600 Ti Ti 11.4035000 1.1802700 2.8508800 V V 10.9046000 2.7524900 2.7261500 Cr Cr 9.9067900 1.5367900 2.4767000 Mn Mn 9.9067900 0.5998880 2.4767000 Fe Fe 9.4078900 1.1844200 2.3519700 Co Co 8.9802600 1.2776900 2.2450600 Ni Ni 8.8377200 2.0757200 2.2094300 Cu Cu 9.4078900 2.0446300 2.3519700 Zn Zn 8.6951700 0.1915460 2.1737900 Ga Ga 8.6951700 1.0642000 2.1737900 Ge Ge 8.5526300 2.7017100 2.1381600 As As 8.4813600 3.9599000 2.1203400 Se Se 8.5526300 3.3867700 2.1381600 Br Br 8.5526300 1.9706300 2.1381600 Kr Kr 8.2675400 0.0173276 2.0668900 Rb Rb 15.6798000 0.4682650 3.9199500 Sr Sr 13.8980000 0.1339230 3.4745100 Y Y 13.5417000 2.7597500 3.3854200 Zr Zr 12.4726000 3.0520100 3.1181500 Nb Nb 11.6886000 5.2782000 2.9221500 Mo Mo 10.9759000 4.4749900 2.7439700 Tc Tc 10.4770000 3.3815900 2.6192400 Ru Ru 10.4057000 1.9617200 2.6014200 Rh Rh 10.1206000 2.4058200 2.5301500 Pd Pd 9.9067900 1.3709700 2.4767000 Ag Ag 10.3344000 1.6497600 2.5836100 Cd Cd 10.2632000 0.0377447 2.5657900 In In 10.1206000 0.8113140 2.5301500 Sn Sn 9.9067900 1.9005700 2.4767000 Sb Sb 9.9067900 3.0882800 2.4767000 Te Te 9.8355200 2.6312300 2.4588800 I I 9.9067900 1.5393800 2.4767000 Xe Xe 9.9780700 0.0238880 2.4945200 Cs Cs 17.3903000 0.4166420 4.3475900 Ba Ba 15.3235000 1.9000000 3.8308600 La La 14.7533000 2.4996100 3.6883200 Ce Ce 14.5395000 2.5700800 3.6348700 Pr Pr 14.4682000 1.2994600 3.6170500 Nd Nd 14.3257000 0.8196050 3.5814100 Pm Pm 14.1831000 3.2413400 3.5457800 Sm Sm 14.1118000 0.5211220 3.5279600 Eu Eu 14.1118000 0.4299180 3.5279600 Gd Gd 13.9693000 2.0995600 3.4923200 Tb Tb 13.8267000 1.3999900 3.4566900 Dy Dy 13.6842000 0.6900550 3.4210500 Ho Ho 13.6842000 0.6900550 3.4210500 Er Er 13.4704000 0.7387660 3.3676000 Tm Tm 13.5417000 0.5211220 3.3854200 Yb Yb 13.3278000 0.1303990 3.3319600 Lu Lu 13.3278000 1.4331500 3.3319600 Hf Hf 12.4726000 3.3608600 3.1181500 Ta Ta 12.1162000 4.0034300 3.0290600 W W 11.5460000 6.8638900 2.8865100 Re Re 10.7621000 4.4387100 2.6905100 Os Os 10.2632000 4.2625300 2.5657900 Ir Ir 10.0493000 3.7028700 2.5123300 Pt Pt 9.6929800 3.1401000 2.4232400 Au Au 9.6929800 2.3058000 2.4232400 Hg Hg 9.4078900 0.0454140 2.3519700 Tl Tl 10.3344000 0.5770870 2.5836100 Pb Pb 10.4057000 0.8589880 2.6014200 Bi Bi 10.5482000 2.0798700 2.6370600 Po Po 9.9780700 1.8995300 2.4945200 At At 10.6908000 1.3854420 2.6727000 Rn Rn 10.6908000 0.0214992 2.6727000 Fr Fr 18.5307000 0.3749778 4.6326700 Ra Ra 15.7511000 1.7100000 3.9377700 Ac Ac 15.3235000 2.2496490 3.8308600 Th Th 14.6820000 2.3130720 3.6705000 Pa Pa 14.2544000 1.1695140 3.5635900 U U 13.9693000 0.7376445 3.4923200 Np Np 13.5417000 2.9172060 3.3854200 Pu Pu 13.3278000 0.4690098 3.3319600 Am Am 12.8289000 0.3869262 3.2072400 Cm Cm 12.0450000 1.8896040 3.0112400 Bk Bk 11.9737000 1.2599910 2.9934200 Cf Cf 11.9737000 0.6210495 2.9934200 Es Es 11.7599000 0.6210495 2.9399700 Fm Fm 11.9024000 0.6648894 2.9756000 Md Md 12.3300000 0.4690098 3.0825100 No No 12.5439000 0.1173591 3.1359600 Lr Lr 11.4748000 1.2898350 2.8686900 Rf Rf 11.1897000 3.0247740 2.7974200 Db Db 10.6195000 3.6030870 2.6548800 Sg Sg 10.1919000 6.1775010 2.5479700 Bh Bh 10.0493000 3.9948390 2.5123300 Hs Hs 9.5504300 3.8362770 2.3876100 Mt Mt 9.1940700 3.3325830 2.2985200 Ds Ds 9.1228000 2.8260900 2.2807000 Rg Rg 8.6239000 2.0752200 2.1559700 Cn Cn 8.6951700 0.0408726 2.1737900 Nh Nh 9.6929800 0.5193783 2.4232400 Fl Fl 10.1919000 0.7730892 2.5479700 Mc Mc 11.5460000 1.8718830 2.8865100 Lv Lv 12.4726000 1.7095770 3.1181500 Ts Ts 11.7599000 1.2468978 2.9399700 Og Og 11.1897000 0.0193493 2.7974200 electron electron 4.0 1.0 1.0 user01 user01 4.0 1.0 1.0 user02 user02 4.0 1.0 1.0 user03 user03 4.0 1.0 1.0 user04 user04 4.0 1.0 1.0 user05 user05 4.0 1.0 1.0 user06 user06 4.0 1.0 1.0 user07 user07 4.0 1.0 1.0 user08 user08 4.0 1.0 1.0 user09 user09 4.0 1.0 1.0 user10 user10 4.0 1.0 1.0 user11 user11 4.0 1.0 1.0 user12 user12 4.0 1.0 1.0 user13 user13 4.0 1.0 1.0 user14 user14 4.0 1.0 1.0 user15 user15 4.0 1.0 1.0 user16 user16 4.0 1.0 1.0 user17 user17 4.0 1.0 1.0 user18 user18 4.0 1.0 1.0 user19 user19 4.0 1.0 1.0 user20 user20 4.0 1.0 1.0 # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Andrew Akerson # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # * Sigma parameters are set to (2^{-1/6})*r_0, where r_0 is the atomic # covalent radius. Covalent radii for elements 1--96 were taken from Wolfram # Mathematica's `ElementData["CovalentRadius"]' command. Covalent radii for # elements 97--118 were taken from Fig. 3 of the article Pyykko, M. Atsumi, # J. Chem. Eur. J. 15 (2009) 12770. # # * Epsilon parameters are set to the bond dissociation energy. Bond # dissociation energies for elements 1--55, 57--60, and 61--84 were taken # from the CRC Handbook of Chemistry and Physics, 91st Edition, # Ed. W.H. Haynes, 2010. (as posted here: # http://staff.ustc.edu.cn/~luo971/2010-91-CRC-BDEs-Tables.pdf) # # The value (cohesive energy, in this case) for element 56 was obtained from # p. 50 in Charles Kittel. Introduction to Solid State Physics, 8th # edition. Hoboken, NJ: John Wiley & Sons, Inc, 2005. # # The bond dissociation energy value for element 61 was obtained from # "Interpolation scheme for the cohesive energies for the lanthanides and # actinides" Borje Johansson and Anders Rosengren, Phys. Rev. B 11, 1367 # (1975). # # The bond dissociation energies for elements 85--118 were not found in the # literature. Thus, the values used here are approximated by subtracting 10% # from the value for the element in the same Group (column) and previous # Period (row) of the periodic table. # # * Cutoff parameters are set to 4.0*sigma. This corresponds to a cutoff # energy of approximately epsilon/1024. # # * Lorentz-Berthelot mixing rules are used for interactions between unlike # particles. Each interaction potential is shifted to zero energy at its # cutoff distance. README000066400000000000000000000053011421473465500322100ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Andrew Akerson # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (LennardJones612_UniversalShifted__MO_959249795837_003) contains a Lennard-Jones model defined for the entire set of KIM API particle types. * Sigma parameters are set to (2^{-1/6})*r_0, where r_0 is the atomic covalent radius. Covalent radii for elements 1--96 were taken from Wolfram Mathematica's `ElementData["CovalentRadius"]' command. Covalent radii for elements 97--118 were taken from Fig. 3 of the article Pyykko, M. Atsumi, J. Chem. Eur. J. 15 (2009) 12770. * Epsilon parameters are set to the bond dissociation energy. Bond dissociation energies for elements 1--55, 57--60, and 61--84 were taken from the CRC Handbook of Chemistry and Physics, 91st Edition, Ed. W.H. Haynes, 2010. (as posted here: http://staff.ustc.edu.cn/~luo971/2010-91-CRC-BDEs-Tables.pdf) The value (cohesive energy, in this case) for element 56 was obtained from p. 50 in Charles Kittel. Introduction to Solid State Physics, 8th edition. Hoboken, NJ: John Wiley & Sons, Inc, 2005. The bond dissociation energy value for element 61 was obtained from "Interpolation scheme for the cohesive energies for the lanthanides and actinides" Borje Johansson and Anders Rosengren, Phys. Rev. B 11, 1367 (1975). The bond dissociation energies for elements 85--118 were not found in the literature. Thus, the values used here are approximated by subtracting 10% from the value for the element in the same Group (column) and previous Period (row) of the periodic table. * Cutoff parameters are set to 4.0*sigma. This corresponds to a cutoff energy of approximately epsilon/1024. * Lorentz-Berthelot mixing rules are used for interactions between unlike particles. Each interaction potential is shifted to zero energy at its cutoff distance. kim-api-2.3.0-git/examples/portable-models/LennardJones_Ar/000077500000000000000000000000001421473465500235525ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/LennardJones_Ar/CMakeLists.txt000066400000000000000000000030561421473465500263160ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(LennardJones_Ar LANGUAGES CXX) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_create" CREATE_ROUTINE_LANGUAGE "cpp" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.cpp) kim-api-2.3.0-git/examples/portable-models/LennardJones_Ar/LICENSE.LGPL000066400000000000000000000636421421473465500253270ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/LennardJones_Ar/LennardJones_Ar.cpp000066400000000000000000000361671421473465500272770ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #include "KIM_LogMacros.hpp" #include "KIM_ModelHeaders.hpp" #include #include #define DIMENSION 3 namespace { class LennardJones_Ar { public: //**************************************************************************** LennardJones_Ar(KIM::ModelCreate * const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int * const error) : epsilon_(0.0104), sigma_(3.4000), influenceDistance_(8.1500), cutoff_(influenceDistance_), cutoffSq_(cutoff_ * cutoff_), modelWillNotRequestNeighborsOfNoncontributingParticles_(1) { *error = ConvertUnits(modelCreate, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit); if (*error) return; modelCreate->SetModelNumbering(KIM::NUMBERING::zeroBased); modelCreate->SetInfluenceDistancePointer(&influenceDistance_); modelCreate->SetNeighborListPointers( 1, &cutoff_, &modelWillNotRequestNeighborsOfNoncontributingParticles_); modelCreate->SetSpeciesCode(KIM::SPECIES_NAME::Ar, 0); // use function pointer declarations to verify prototypes KIM::ModelComputeArgumentsCreateFunction * CACreate = LennardJones_Ar::ComputeArgumentsCreate; KIM::ModelComputeFunction * compute = LennardJones_Ar::Compute; KIM::ModelComputeArgumentsDestroyFunction * CADestroy = LennardJones_Ar::ComputeArgumentsDestroy; KIM::ModelDestroyFunction * destroy = LennardJones_Ar::Destroy; *error = modelCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(CACreate)) || modelCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::Compute, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(compute)) || modelCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(CADestroy)) || modelCreate->SetRoutinePointer( KIM::MODEL_ROUTINE_NAME::Destroy, KIM::LANGUAGE_NAME::cpp, true, reinterpret_cast(destroy)); if (*error) return; // everything is good *error = false; return; }; //**************************************************************************** ~LennardJones_Ar() {}; //**************************************************************************** // no need to make these "extern" since KIM will only access them // via function pointers. "static" is required so that there is not // an implicit this pointer added to the prototype by the C++ compiler static int Destroy(KIM::ModelDestroy * const modelDestroy) { LennardJones_Ar * model; modelDestroy->GetModelBufferPointer(reinterpret_cast(&model)); if (model != NULL) { // delete object itself delete model; } // everything is good return false; } //**************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute // static int Compute(KIM::ModelCompute const * const modelCompute, KIM::ModelComputeArguments const * const modelComputeArguments) { int const * numberOfParticlesPointer; int const * particleSpeciesCodes; int const * particleContributing; double const * coordinates; double * partialEnergy; double * partialForces; LennardJones_Ar * lj; modelCompute->GetModelBufferPointer(reinterpret_cast(&lj)); double const epsilon = lj->epsilon_; double const sigma = lj->sigma_; double const cutoffSq = lj->cutoffSq_; int error = modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles, &numberOfParticlesPointer) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes, &particleSpeciesCodes) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::particleContributing, &particleContributing) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::coordinates, (double const **) &coordinates) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, &partialEnergy) || modelComputeArguments->GetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialForces, (double const **) &partialForces); if (error) { LOG_ERROR("Unable to get argument pointers"); return error; } int const numberOfParticles = *numberOfParticlesPointer; // initialize energy and forces *partialEnergy = 0.0; int const extent = numberOfParticles * DIMENSION; for (int i = 0; i < extent; ++i) { partialForces[i] = 0.0; } int jContributing; int i, j, jj, numberOfNeighbors; int const * neighbors; double phi; double xcoord, ycoord, zcoord; double xrij, yrij, zrij; double rij2; double r2inv, r6inv, dphiByR, dEidrByR; double xdf, ydf, zdf; double const fortyEight = 48.0 * epsilon * pow(sigma, 12.0); double const twentyFour = 24.0 * epsilon * pow(sigma, 6.0); double const four12 = 4.0 * epsilon * pow(sigma, 12.0); double const four6 = 4.0 * epsilon * pow(sigma, 6.0); for (i = 0; i < numberOfParticles; ++i) { if (particleContributing[i]) { xcoord = coordinates[i * DIMENSION + 0]; ycoord = coordinates[i * DIMENSION + 1]; zcoord = coordinates[i * DIMENSION + 2]; modelComputeArguments->GetNeighborList( 0, i, &numberOfNeighbors, &neighbors); for (jj = 0; jj < numberOfNeighbors; ++jj) { j = neighbors[jj]; jContributing = particleContributing[j]; if (!(jContributing && (j < i))) { xrij = coordinates[j * DIMENSION + 0] - xcoord; yrij = coordinates[j * DIMENSION + 1] - ycoord; zrij = coordinates[j * DIMENSION + 2] - zcoord; rij2 = xrij * xrij + yrij * yrij + zrij * zrij; if (rij2 < cutoffSq) { r2inv = 1.0 / rij2; r6inv = r2inv * r2inv * r2inv; phi = 0.5 * r6inv * (four12 * r6inv - four6); dphiByR = r6inv * (twentyFour - fortyEight * r6inv) * r2inv; *partialEnergy += phi; if (jContributing) { *partialEnergy += phi; dEidrByR = dphiByR; } else { dEidrByR = 0.5 * dphiByR; } xdf = dEidrByR * xrij; ydf = dEidrByR * yrij; zdf = dEidrByR * zrij; partialForces[i * DIMENSION + 0] += xdf; partialForces[i * DIMENSION + 1] += ydf; partialForces[i * DIMENSION + 2] += zdf; partialForces[j * DIMENSION + 0] -= xdf; partialForces[j * DIMENSION + 1] -= ydf; partialForces[j * DIMENSION + 2] -= zdf; } // if (rij2 < cutoffSq_) } // if (i < j) } // for jj } // if (particleContributing[i]) } // for i // everything is good return false; }; //**************************************************************************** static int ComputeArgumentsCreate( KIM::ModelCompute const * const /* modelCompute */, KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) { // register arguments int error = modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, KIM::SUPPORT_STATUS::required) || modelComputeArgumentsCreate->SetArgumentSupportStatus( KIM::COMPUTE_ARGUMENT_NAME::partialForces, KIM::SUPPORT_STATUS::required); // register callbacks // // none return error; } //**************************************************************************** static int ComputeArgumentsDestroy(KIM::ModelCompute const * const /* modelCompute */, KIM::ModelComputeArgumentsDestroy * const /* modelComputeArgumentsDestroy */) { // nothing further to do return false; } private: //**************************************************************************** // Member variables double epsilon_; double sigma_; double influenceDistance_; double cutoff_; double cutoffSq_; int const modelWillNotRequestNeighborsOfNoncontributingParticles_; //**************************************************************************** #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCreate // int ConvertUnits(KIM::ModelCreate * const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit) { int ier; // define default base units KIM::LengthUnit fromLength = KIM::LENGTH_UNIT::A; KIM::EnergyUnit fromEnergy = KIM::ENERGY_UNIT::eV; KIM::ChargeUnit fromCharge = KIM::CHARGE_UNIT::unused; KIM::TemperatureUnit fromTemperature = KIM::TEMPERATURE_UNIT::unused; KIM::TimeUnit fromTime = KIM::TIME_UNIT::unused; // changing units of cutoffs and sigmas double convertLength = 1.0; ier = KIM::ModelCreate::ConvertUnit(fromLength, fromEnergy, fromCharge, fromTemperature, fromTime, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, 1.0, 0.0, 0.0, 0.0, 0.0, &convertLength); if (ier) { LOG_ERROR("Unable to convert length unit"); return ier; } influenceDistance_ *= convertLength; // convert to active units cutoff_ = influenceDistance_; cutoffSq_ = cutoff_ * cutoff_; sigma_ *= convertLength; // convert to active units // changing units of epsilons double convertEnergy = 1.0; ier = KIM::ModelCreate::ConvertUnit(fromLength, fromEnergy, fromCharge, fromTemperature, fromTime, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, 0.0, 1.0, 0.0, 0.0, 0.0, &convertEnergy); if (ier) { LOG_ERROR("Unable to convert energy unit"); return ier; } epsilon_ *= convertEnergy; // convert to active units // register units ier = modelCreate->SetUnits(requestedLengthUnit, requestedEnergyUnit, KIM::CHARGE_UNIT::unused, KIM::TEMPERATURE_UNIT::unused, KIM::TIME_UNIT::unused); if (ier) { LOG_ERROR("Unable to set units to requested values"); return ier; } // everything is good ier = false; return ier; } }; } // namespace extern "C" { //****************************************************************************** int model_create(KIM::ModelCreate * const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit) { int error; LennardJones_Ar * const model = new LennardJones_Ar(modelCreate, requestedLengthUnit, requestedEnergyUnit, requestedChargeUnit, requestedTemperatureUnit, requestedTimeUnit, &error); if (error) { // constructor already reported the error delete model; return error; } // register pointer to LennardJones_Ar object in moedelCreate object modelCreate->SetModelBufferPointer(reinterpret_cast(model)); // everything is good return false; } } // extern "C" kim-api-2.3.0-git/examples/portable-models/LennardJones_Ar/README000066400000000000000000000021421421473465500244310ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (LennardJones_Ar) contains a Morse pair potential Model written in C++. phi(r) = epsilon * ( - exp[ -2*C*(r - Rzero) ] + 2*exp[ -C*(r - Rzero) ] ). kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_LJ/000077500000000000000000000000001421473465500236305ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_LJ/CMakeLists.txt000066400000000000000000000027501421473465500263740ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_P_LJ) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} DRIVER_NAME "ex_model_driver_P_LJ" PARAMETER_FILES "ex_model_Ar_P_LJ.params" ) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_LJ/LICENSE.LGPL000066400000000000000000000636421421473465500254050ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_LJ/README000066400000000000000000000022001421473465500245020ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_Ar_P_LJ) contains a shifted Lennard-Jones pair potential Model based on the KIM Model Driver ex_model_driver_P_LJ. This Model implements the Lennard-Jones potential for Ar. kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_LJ/ex_model_Ar_P_LJ.params000066400000000000000000000023111421473465500301140ustar00rootroot00000000000000Ar +8.150000000000000E+000 +1.040000000000000E-002 +3.400000000000000E+000 # Parameters taken from: E. B. Tadmor and R. E. Miller, 'Modeling Materials', Cambridge University Press, 2011 # # Release: This file is part of the kim-api-v1.8.0 package. # # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Ellad B. Tadmor # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_MLJ_Fortran/000077500000000000000000000000001421473465500254405ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_MLJ_Fortran/CMakeLists.txt000066400000000000000000000031101421473465500301730ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_P_MLJ_Fortran LANGUAGES Fortran) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_create_routine" CREATE_ROUTINE_LANGUAGE "fortran" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.f90) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_MLJ_Fortran/LICENSE.LGPL000066400000000000000000000636421421473465500272150ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_MLJ_Fortran/README000066400000000000000000000021021421473465500263130ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_Ar_P_MLJ_Fortran) contains a modified Lennard Jones (LJ) Model with smoothed cutoff radius written in Fortran. kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_MLJ_Fortran/ex_model_Ar_P_MLJ_Fortran.f90000066400000000000000000000501651421473465500326610ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! Ellad B. Tadmor ! Valeriu Smirichinski ! Stephen M. Whalen ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! !**************************************************************************** !** !** MODULE ex_model_Ar_P_MLJ_F03 !** !** Modified Lennard-Jones pair potential (with smooth cutoff) model for Ar !** !** Reference: Ashcroft and Mermin !** !** Language: Fortran 2003 !** !**************************************************************************** module ex_model_Ar_P_MLJ_F03 use, intrinsic :: iso_c_binding use kim_model_headers_module implicit none save private public Compute_Energy_Forces, & model_destroy_func, & model_compute_arguments_create, & model_compute_arguments_destroy, & model_cutoff, & speccode, & buffer_type ! Below are the definitions and values of all Model parameters integer(c_int), parameter :: cd = c_double ! used for literal constants integer(c_int), parameter :: DIM = 3 ! dimensionality of space integer(c_int), parameter :: speccode = 1 ! internal species code real(c_double), parameter :: model_cutoff = 8.15_cd ! cutoff radius ! in angstroms real(c_double), parameter :: model_cutsq = model_cutoff**2 !----------------------------------------------------------------------------- ! Below are the definitions and values of all additional model parameters ! ! Recall that the Fortran 2003 format for declaring parameters is as follows: ! ! integer(c_int), parameter :: parname = value ! This defines an integer ! ! parameter called `parname' ! ! with a value equal to ! ! `value' (a number) ! ! real(c_double), parameter :: parname = value ! This defines a real(c_double) ! ! parameter called `parname' ! ! with a value equal to ! ! `value' (a number) !----------------------------------------------------------------------------- real(c_double), parameter :: lj_epsilon = 0.0104_cd real(c_double), parameter :: lj_sigma = 3.40_cd real(c_double), parameter :: lj_cutnorm = model_cutoff / lj_sigma real(c_double), parameter :: & lj_A = 12.0_cd * lj_epsilon * (-26.0_cd + 7.0_cd * lj_cutnorm**6) & / (lj_cutnorm**14 * lj_sigma**2) real(c_double), parameter :: & lj_B = 96.0_cd * lj_epsilon * (7.0_cd - 2.0_cd * lj_cutnorm**6) & / (lj_cutnorm**13 * lj_sigma) real(c_double), parameter :: & lj_C = 28.0_cd * lj_epsilon * (-13.0_cd + 4.0_cd * lj_cutnorm**6) & / (lj_cutnorm**12) type, bind(c) :: buffer_type real(c_double) :: influence_distance real(c_double) :: cutoff(1) integer(c_int) :: & model_will_not_request_neighbors_of_noncontributing_particles(1) end type buffer_type contains !----------------------------------------------------------------------------- ! ! Calculate pair potential phi(r) ! !----------------------------------------------------------------------------- recursive subroutine calc_phi(r, phi) implicit none !-- Transferred variables real(c_double), intent(in) :: r real(c_double), intent(out) :: phi !-- Local variables real(c_double) rsq, sor, sor6, sor12 rsq = r * r ! r^2 sor = lj_sigma / r ! (sig/r) sor6 = sor * sor * sor ! sor6 = sor6 * sor6 ! (sig/r)^6 sor12 = sor6 * sor6 ! (sig/r)^12 if (r > model_cutoff) then ! Argument exceeds cutoff radius phi = 0.0_cd else phi = 4.0_cd * lj_epsilon * (sor12 - sor6) + lj_A * rsq + lj_B * r + lj_C end if end subroutine calc_phi !----------------------------------------------------------------------------- ! ! Calculate pair potential phi(r) and its derivative dphi(r) ! !----------------------------------------------------------------------------- recursive subroutine calc_phi_dphi(r, phi, dphi) implicit none !-- Transferred variables real(c_double), intent(in) :: r real(c_double), intent(out) :: phi, dphi !-- Local variables real(c_double) rsq, sor, sor6, sor12 rsq = r * r ! r^2 sor = lj_sigma / r ! (sig/r) sor6 = sor * sor * sor ! sor6 = sor6 * sor6 ! (sig/r)^6 sor12 = sor6 * sor6 ! (sig/r)^12 if (r > model_cutoff) then ! Argument exceeds cutoff radius phi = 0.0_cd dphi = 0.0_cd else phi = 4.0_cd * lj_epsilon * (sor12 - sor6) + lj_A * rsq + lj_B * r + lj_C dphi = 24.0_cd * lj_epsilon * (-2.0_cd * sor12 + sor6) / r & + 2.0_cd * lj_A * r + lj_B end if end subroutine calc_phi_dphi !----------------------------------------------------------------------------- ! ! Compute energy and forces on particles from the positions. ! !----------------------------------------------------------------------------- recursive subroutine Compute_Energy_Forces( & model_compute_handle, model_compute_arguments_handle, ierr) bind(c) implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle integer(c_int), intent(out) :: ierr !-- Local variables real(c_double) :: Rij(DIM) real(c_double) :: r, Rsqij, phi, dphi, dEidr = 0.0_cd integer(c_int) :: i, j, jj, numnei, comp_force, comp_enepot, & comp_virial, comp_energy integer(c_int) :: ierr2 !-- KIM variables integer(c_int), pointer :: N real(c_double), pointer :: energy real(c_double), pointer :: coor(:, :) real(c_double), pointer :: force(:, :) real(c_double), pointer :: enepot(:) integer(c_int), pointer :: nei1part(:) integer(c_int), pointer :: particleSpeciesCodes(:) integer(c_int), pointer :: particleContributing(:) real(c_double), pointer :: virial(:) ! Unpack data from KIM object ! ierr = 0 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, N, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, n, & particleSpeciesCodes, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, n, & particleContributing, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, dim, n, coor, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, energy, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, dim, n, force, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, n, enepot, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, 6, virial, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry(model_compute_arguments_handle, & KIM_LOG_VERBOSITY_ERROR, "get data") ierr = 1 return end if ! Check to see if we have been asked to compute the forces, energyperpart, ! energy and virial ! if (associated(energy)) then comp_energy = 1 else comp_energy = 0 end if if (associated(force)) then comp_force = 1 else comp_force = 0 end if if (associated(enepot)) then comp_enepot = 1 else comp_enepot = 0 end if if (associated(virial)) then comp_virial = 1 else comp_virial = 0 end if ! Check to be sure that the species are correct ! ierr = 1 ! assume an error do i = 1, N if (particleSpeciesCodes(i) /= speccode) then call kim_log_entry( & model_compute_handle, KIM_LOG_VERBOSITY_ERROR, & "Unexpected species code detected") ierr = 1 return end if end do ierr = 0 ! everything is ok ! Initialize potential energies, forces, virial term ! if (comp_enepot == 1) enepot = 0.0_cd if (comp_energy == 1) energy = 0.0_cd if (comp_force == 1) force = 0.0_cd if (comp_virial == 1) virial = 0.0_cd ! ! Compute energy and forces ! ! Loop over particles and compute energy and forces ! do i = 1, N if (particleContributing(i) == 1) then ! Set up neighbor list for next particle call kim_get_neighbor_list( & model_compute_arguments_handle, 1, i, numnei, nei1part, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_arguments_handle, KIM_LOG_VERBOSITY_ERROR, & "GetNeighborList failed") ierr = 1 return end if ! Loop over the neighbors of particle i ! do jj = 1, numnei j = nei1part(jj) ! get neighbor ID ! compute relative position vector ! Rij(:) = coor(:, j) - coor(:, i) ! distance vector between i j ! compute energy and forces ! Rsqij = dot_product(Rij, Rij) ! compute square distance if (Rsqij < model_cutsq) then ! particles are interacting? r = sqrt(Rsqij) ! compute distance if (comp_force == 1 .or. comp_virial == 1) then call calc_phi_dphi(r, phi, dphi) ! compute pair potential ! and it derivative dEidr = 0.5_cd * dphi else call calc_phi(r, phi) ! compute just pair potential end if ! contribution to energy ! if (comp_enepot == 1) then enepot(i) = enepot(i) + 0.5_cd * phi ! accumulate energy end if if (comp_energy == 1) then energy = energy + 0.5_cd * phi end if ! contribution to virial tensor, virial(i,j)=r(i)*r(j)*(dV/dr)/r ! if (comp_virial == 1) then virial(1) = virial(1) + Rij(1) * Rij(1) * dEidr / r virial(2) = virial(2) + Rij(2) * Rij(2) * dEidr / r virial(3) = virial(3) + Rij(3) * Rij(3) * dEidr / r virial(4) = virial(4) + Rij(2) * Rij(3) * dEidr / r virial(5) = virial(5) + Rij(1) * Rij(3) * dEidr / r virial(6) = virial(6) + Rij(1) * Rij(2) * dEidr / r end if ! contribution to forces ! if (comp_force == 1) then force(:, i) = force(:, i) + dEidr * Rij / r ! accumulate force on i force(:, j) = force(:, j) - dEidr * Rij / r ! accumulate force on j end if end if end do ! loop on jj end if ! if particleContributing end do ! do i ! Everything is great ! ierr = 0 return end subroutine Compute_Energy_Forces !----------------------------------------------------------------------------- ! ! Model destroy routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_destroy_func(model_destroy_handle, ierr) bind(c) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_destroy_handle_type), intent(inout) :: model_destroy_handle integer(c_int), intent(out) :: ierr type(buffer_type), pointer :: buf; type(c_ptr) :: pbuf call kim_get_model_buffer_pointer(model_destroy_handle, pbuf) call c_f_pointer(pbuf, buf) call kim_log_entry(model_destroy_handle, & KIM_LOG_VERBOSITY_INFORMATION, & "deallocating model buffer") deallocate (buf) ierr = 0 ! everything is good end subroutine model_destroy_func !----------------------------------------------------------------------------- ! ! Model compute arguments create routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_compute_arguments_create( & model_compute_handle, model_compute_arguments_create_handle, ierr) bind(c) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_create_handle_type), intent(inout) :: & model_compute_arguments_create_handle integer(c_int), intent(out) :: ierr integer(c_int) :: ierr2 ! avoid unused dummy argument warnings if (model_compute_handle == KIM_MODEL_COMPUTE_NULL_HANDLE) continue ierr = 0 ierr2 = 0 ! register arguments call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 ! register call backs ! NONE if (ierr /= 0) then ierr = 1 call kim_log_entry( & model_compute_arguments_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to successfully create compute_arguments object") end if ierr = 0 return end subroutine model_compute_arguments_create !----------------------------------------------------------------------------- ! ! Model compute arguments destroy routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_compute_arguments_destroy( & model_compute_handle, model_compute_arguments_destroy_handle, ierr) bind(c) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_destroy_handle_type), intent(inout) :: & model_compute_arguments_destroy_handle integer(c_int), intent(out) :: ierr ! avoid unused dummy argument warnings if (model_compute_handle == KIM_MODEL_COMPUTE_NULL_HANDLE) continue if (model_compute_arguments_destroy_handle == & KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_NULL_HANDLE) continue ierr = 0 return end subroutine model_compute_arguments_destroy end module ex_model_Ar_P_MLJ_F03 !------------------------------------------------------------------------------- ! ! Model create routine (REQUIRED) ! !------------------------------------------------------------------------------- recursive subroutine model_create_routine( & model_create_handle, requested_length_unit, requested_energy_unit, & requested_charge_unit, requested_temperature_unit, requested_time_unit, & ierr) bind(c) use, intrinsic :: iso_c_binding use ex_model_Ar_P_MLJ_F03 use kim_model_headers_module implicit none !-- Transferred variables type(kim_model_create_handle_type), intent(inout) :: model_create_handle type(kim_length_unit_type), intent(in), value :: requested_length_unit type(kim_energy_unit_type), intent(in), value :: requested_energy_unit type(kim_charge_unit_type), intent(in), value :: requested_charge_unit type(kim_temperature_unit_type), intent(in), value :: & requested_temperature_unit type(kim_time_unit_type), intent(in), value :: requested_time_unit integer(c_int), intent(out) :: ierr !-- KIM variables integer(c_int) :: ierr2 type(buffer_type), pointer :: buf ierr = 0 ierr2 = 0 ! avoid unsed dummy argument warnings if (requested_length_unit == KIM_LENGTH_UNIT_UNUSED) continue if (requested_energy_unit == KIM_ENERGY_UNIT_UNUSED) continue if (requested_charge_unit == KIM_CHARGE_UNIT_UNUSED) continue if (requested_temperature_unit == KIM_TEMPERATURE_UNIT_UNUSED) continue if (requested_time_unit == KIM_TIME_UNIT_UNUSED) continue ! set units call kim_set_units(model_create_handle, & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_UNUSED, & KIM_TEMPERATURE_UNIT_UNUSED, & KIM_TIME_UNIT_UNUSED, & ierr2) ierr = ierr + ierr2 ! register species call kim_set_species_code(model_create_handle, & KIM_SPECIES_NAME_AR, speccode, ierr2) ierr = ierr + ierr2 ! register numbering call kim_set_model_numbering(model_create_handle, & KIM_NUMBERING_ONE_BASED, ierr2) ierr = ierr + ierr2 ! register function pointers call kim_set_routine_pointer( & model_create_handle, & KIM_MODEL_ROUTINE_NAME_COMPUTE, KIM_LANGUAGE_NAME_FORTRAN, & 1, c_funloc(Compute_Energy_Forces), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_create_handle, KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(model_compute_arguments_create), & ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_create_handle, KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY, & KIM_LANGUAGE_NAME_FORTRAN, 1, c_funloc(model_compute_arguments_destroy), & ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_create_handle, & KIM_MODEL_ROUTINE_NAME_DESTROY, KIM_LANGUAGE_NAME_FORTRAN, & 1, c_funloc(model_destroy_func), ierr2) ierr = ierr + ierr2 ! allocate buffer allocate (buf) ! store model buffer in KIM object call kim_set_model_buffer_pointer(model_create_handle, & c_loc(buf)) ! set buffer values buf%influence_distance = model_cutoff buf%cutoff = model_cutoff buf%model_will_not_request_neighbors_of_noncontributing_particles = 1 ! register influence distance call kim_set_influence_distance_pointer( & model_create_handle, buf%influence_distance) ! register cutoff call kim_set_neighbor_list_pointers( & model_create_handle, 1, buf%cutoff, & buf%model_will_not_request_neighbors_of_noncontributing_particles) if (ierr /= 0) then ierr = 1 deallocate (buf) call kim_log_entry(model_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to successfully initialize model") end if ierr = 0 return end subroutine model_create_routine kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse/000077500000000000000000000000001421473465500244105ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse/CMakeLists.txt000066400000000000000000000027611421473465500271560ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_P_Morse) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} DRIVER_NAME "ex_model_driver_P_Morse" PARAMETER_FILES "ex_model_Ar_P_Morse.params" ) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse/LICENSE.LGPL000066400000000000000000000636421421473465500261650ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse/README000066400000000000000000000021671421473465500252760ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_Ar_P_Morse) contains a shifted Morse pair potential Model based on the KIM Model Driver ex_model_driver_P_Morse. This Model implements the Morse potential for Ar. kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse/ex_model_Ar_P_Morse.params000066400000000000000000000021151421473465500314560ustar00rootroot00000000000000Ar 8.15 -0.0134783698072604 1.545 3.786 # Parameters taken from: G. E. Jelinek, Phys. Rev. B, Vol 5, no 8, 1972, pp3210--3217 # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Ellad B. Tadmor # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C/000077500000000000000000000000001421473465500250215ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C/CMakeLists.txt000066400000000000000000000030601421473465500275600ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_P_Morse_07C LANGUAGES C) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_create" CREATE_ROUTINE_LANGUAGE "c" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.c) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C/LICENSE.LGPL000066400000000000000000000636421421473465500265760ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C/README000066400000000000000000000022631421473465500257040ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_Ar_P_Morse_07C) contains a shifted Morse pair potential Model written in C. phi(r) = epsilon * ( - exp[ -2*C*(r - Rzero) ] + 2*exp[ -C*(r - Rzero) ] ) + shift where shift is computed so that phi(rcut) = 0.0 kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C/ex_model_Ar_P_Morse_07C.c000066400000000000000000000567341421473465500314570ustar00rootroot00000000000000/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* Stephen M. Whalen */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /******************************************************************************/ /* */ /* ex_model_Ar_P_Morse_07C pair potential KIM Model */ /* shifted to have zero energy at the cutoff radius */ /* */ /* Language: C */ /* */ /******************************************************************************/ #include "KIM_LogMacros.h" #include "KIM_ModelHeaders.h" #include #include #include #define TRUE 1 #define FALSE 0 /******************************************************************************/ /* Below are the definitions and values of all Model parameters */ /******************************************************************************/ #define DIM 3 /* dimensionality of space */ #define SPECCODE 1 /* internal species code */ #define CUTOFF 8.15 /* Angstroms */ #define EPSILON -0.0134783698072604 /* eV */ #define PARAM_C 1.545 /* 1/Angstroms */ #define RZERO 3.786 /* Angstroms */ /* Model buffer definition */ struct buffer { double influenceDistance; double cutoff; int modelWillNotRequestNeighborsOfNoncontributingParticles; }; typedef struct buffer buffer; /* Define prototype for Model create */ int model_create(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit); /* Define prototype for other routines */ static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate); static int model_compute(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments); static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); static int model_destroy(KIM_ModelDestroy * const modelDestroy); /* Define prototypes for pair potential calculations */ static void calc_phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi); static void calc_phi_dphi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi); static void calc_phi_d2phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi, double * d2phi); /* Calculate pair potential phi(r) */ static void calc_phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; } return; } /* Calculate pair potential phi(r) and its derivative dphi(r) */ static void calc_phi_dphi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); } return; } /* Calculate pair potential phi(r) and its 1st & 2nd derivatives dphi(r), */ /* d2phi(r) */ static void calc_phi_d2phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi, double * d2phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; *d2phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); *d2phi = 2.0 * (*epsilon) * (*C) * (*C) * (ep - 2.0 * ep2); } return; } /* compute function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ static int model_compute(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments) { /* local variables */ double R; double R_pairs[2]; double * pR_pairs = &(R_pairs[0]); double Rsqij; double phi; double dphi; double d2phi; double dEidr = 0.0; double d2Eidr = 0.0; double Rij[DIM]; double * pRij = &(Rij[0]); double Rij_pairs[2][3]; double const * pRij_pairs = &(Rij_pairs[0][0]); int ier; int i; int i_pairs[2]; int * pi_pairs = &(i_pairs[0]); int j; int j_pairs[2]; int * pj_pairs = &(j_pairs[0]); int jj; int k; int const * neighListOfCurrentPart; int comp_energy; int comp_force; int comp_particleEnergy; int comp_process_dEdr; int comp_process_d2Edr2; int * nParts; int * particleSpeciesCodes; int * particleContributing; buffer * bufferPointer; double * cutoff; double cutsq; double epsilon; double C; double Rzero; double shift; double * coords; double * energy; double * force; double * particleEnergy; int numOfPartNeigh; double dummy; /* check to see if we have been asked to compute the forces, */ /* particleEnergy, and d1Edr */ LOG_INFORMATION("Checking if call backs are present."); KIM_ModelComputeArguments_IsCallbackPresent( modelComputeArguments, KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, &comp_process_dEdr); KIM_ModelComputeArguments_IsCallbackPresent( modelComputeArguments, KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, &comp_process_d2Edr2); LOG_INFORMATION("Getting data pointers"); ier = KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles, &nParts) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, &particleSpeciesCodes) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleContributing, &particleContributing) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &coords) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, &energy) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialForces, &force) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, &particleEnergy); if (ier) { LOG_ERROR("get data pointers failed"); return ier; } comp_energy = (energy != NULL); comp_force = (force != NULL); comp_particleEnergy = (particleEnergy != NULL); /* set value of parameters */ KIM_ModelCompute_GetModelBufferPointer(modelCompute, (void **) &bufferPointer); cutoff = &(bufferPointer->cutoff); cutsq = (*cutoff) * (*cutoff); epsilon = EPSILON; C = PARAM_C; Rzero = RZERO; /* set value of parameter shift */ dummy = 0.0; /* call calc_phi with r=cutoff and shift=0.0 */ calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift); /* set shift to -shift */ shift = -(shift); /* Check to be sure that the species are correct */ /**/ ier = TRUE; /* assume an error */ for (i = 0; i < *nParts; ++i) { if (SPECCODE != particleSpeciesCodes[i]) { LOG_ERROR("Unexpected species code detected"); return ier; } } ier = FALSE; /* everything is ok */ /* initialize potential energies, forces, and virial term */ LOG_INFORMATION("Initializing data"); if (comp_particleEnergy) { for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; } } if (comp_energy) { *energy = 0.0; } if (comp_force) { for (i = 0; i < *nParts; ++i) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] = 0.0; } } } /* Compute energy and forces */ /* loop over particles and compute enregy and forces */ LOG_INFORMATION("Starting main compute loop"); for (i = 0; i < *nParts; ++i) { if (particleContributing[i]) { ier = KIM_ModelComputeArguments_GetNeighborList(modelComputeArguments, 0, i, &numOfPartNeigh, &neighListOfCurrentPart); if (ier) { /* some sort of problem, exit */ LOG_ERROR("GetNeighborList failed"); ier = TRUE; return ier; } /* loop over the neighbors of particle i */ for (jj = 0; jj < numOfPartNeigh; ++jj) { j = neighListOfCurrentPart[jj]; /* get neighbor ID */ if (!(particleContributing[j] && (j < i))) { /* short-circuit half-list */ /* compute relative position vector and squared distance */ Rsqij = 0.0; for (k = 0; k < DIM; ++k) { Rij[k] = coords[j * DIM + k] - coords[i * DIM + k]; /* compute squared distance */ Rsqij += Rij[k] * Rij[k]; } /* compute energy and force */ if (Rsqij < cutsq) { /* particles are interacting ? */ R = sqrt(Rsqij); if (comp_process_d2Edr2) { /* compute pair potential and its derivatives */ calc_phi_d2phi( &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi, &d2phi); /* compute dEidr */ if (particleContributing[j]) { dEidr = dphi; d2Eidr = d2phi; } else { dEidr = 0.5 * dphi; d2Eidr = 0.5 * d2phi; } } else if (comp_force || comp_process_dEdr) { /* compute pair potential and its derivative */ calc_phi_dphi( &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi); /* compute dEidr */ if (particleContributing[j]) { dEidr = dphi; } else { dEidr = 0.5 * dphi; } } else { /* compute just pair potential */ calc_phi(&epsilon, &C, &Rzero, &shift, cutoff, R, &phi); } /* contribution to energy */ if (comp_particleEnergy) { particleEnergy[i] += 0.5 * phi; if (particleContributing[j]) { particleEnergy[j] += 0.5 * phi; } } if (comp_energy) { if (particleContributing[j]) { *energy += phi; } else { *energy += 0.5 * phi; } } /* contribution to process_dEdr */ if (comp_process_dEdr) { ier = KIM_ModelComputeArguments_ProcessDEDrTerm( modelComputeArguments, dEidr, R, pRij, i, j); if (ier) { LOG_ERROR("ProcessDEDrTerm callback error"); ier = TRUE; return ier; } } /* contribution to process_d2Edr2 */ if (comp_process_d2Edr2) { R_pairs[0] = R_pairs[1] = R; Rij_pairs[0][0] = Rij_pairs[1][0] = Rij[0]; Rij_pairs[0][1] = Rij_pairs[1][1] = Rij[1]; Rij_pairs[0][2] = Rij_pairs[1][2] = Rij[2]; i_pairs[0] = i_pairs[1] = i; j_pairs[0] = j_pairs[1] = j; ier = KIM_ModelComputeArguments_ProcessD2EDr2Term( modelComputeArguments, d2Eidr, pR_pairs, pRij_pairs, pi_pairs, pj_pairs); if (ier) { LOG_ERROR("ProcessDEDrTerm callback error"); ier = TRUE; return ier; } } /* contribution to forces */ if (comp_force) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] += dEidr * Rij[k] / R; /* accumulate force on i */ force[j * DIM + k] -= dEidr * Rij[k] / R; /* accumulate force on j */ } } } } /* if (i < j) */ } /* loop on jj */ } /* if contributing */ } /* loop on i */ LOG_INFORMATION("Finished compute loop"); /* everything is great */ ier = FALSE; return ier; } /* Create function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCreate_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCreate /**/ int model_create(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit) { buffer * bufferPointer; int error; /* use function pointer definitions to verify prototypes */ KIM_ModelCreateFunction * create = model_create; KIM_ModelComputeArgumentsCreateFunction * CACreate = compute_arguments_create; KIM_ModelComputeFunction * compute = model_compute; KIM_ModelComputeArgumentsDestroyFunction * CADestroy = compute_arguments_destroy; KIM_ModelDestroyFunction * destroy = model_destroy; (void) create; /* avoid unused parameter warnings */ (void) requestedLengthUnit; (void) requestedEnergyUnit; (void) requestedChargeUnit; (void) requestedTemperatureUnit; (void) requestedTimeUnit; /* set units */ LOG_INFORMATION("Set model units"); error = KIM_ModelCreate_SetUnits(modelCreate, /* ignoring requested units */ KIM_LENGTH_UNIT_A, KIM_ENERGY_UNIT_eV, KIM_CHARGE_UNIT_unused, KIM_TEMPERATURE_UNIT_unused, KIM_TIME_UNIT_unused); /* register species */ LOG_INFORMATION("Setting species code"); error = error || KIM_ModelCreate_SetSpeciesCode( modelCreate, KIM_SPECIES_NAME_Ar, SPECCODE); /* register numbering */ LOG_INFORMATION("Setting model numbering"); error = error || KIM_ModelCreate_SetModelNumbering(modelCreate, KIM_NUMBERING_zeroBased); /* register function pointers */ LOG_INFORMATION("Register model function pointers"); error = error || KIM_ModelCreate_SetRoutinePointer( modelCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CACreate) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Compute, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) compute) || KIM_ModelCreate_SetRoutinePointer( modelCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CADestroy) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Destroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) destroy); /* allocate buffer */ bufferPointer = (buffer *) malloc(sizeof(buffer)); /* store model buffer in KIM object */ LOG_INFORMATION("Set influence distance and cutoffs"); KIM_ModelCreate_SetModelBufferPointer(modelCreate, bufferPointer); /* set buffer values */ bufferPointer->influenceDistance = CUTOFF; bufferPointer->cutoff = CUTOFF; bufferPointer->modelWillNotRequestNeighborsOfNoncontributingParticles = 1; /* register influence distance */ KIM_ModelCreate_SetInfluenceDistancePointer( modelCreate, &(bufferPointer->influenceDistance)); /* register cutoff */ KIM_ModelCreate_SetNeighborListPointers( modelCreate, 1, &(bufferPointer->cutoff), &(bufferPointer->modelWillNotRequestNeighborsOfNoncontributingParticles)); if (error) { free(bufferPointer); LOG_ERROR("Unable to successfully initialize model"); return TRUE; } else return FALSE; } /* Destroy function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDestroy_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDestroy /**/ int model_destroy(KIM_ModelDestroy * const modelDestroy) { buffer * bufferPointer; LOG_INFORMATION("Getting buffer"); KIM_ModelDestroy_GetModelBufferPointer(modelDestroy, (void **) &bufferPointer); LOG_INFORMATION("Freeing model memory"); free(bufferPointer); return FALSE; } /* compute arguments create routine */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) { int error; (void) modelCompute; /* avoid unused parameter warning */ /* register arguments */ LOG_INFORMATION("Register argument supportStatus"); error = KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialForces, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, KIM_SUPPORT_STATUS_optional); /* register call backs */ LOG_INFORMATION("Register call back supportStatus"); error = error || KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, KIM_SUPPORT_STATUS_optional); if (error) { LOG_ERROR("Unable to successfully initialize compute arguments"); return TRUE; } else return FALSE; } /* compute arguments destroy routine */ static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy) { (void) modelCompute; /* avoid unused parameter warning */ (void) modelComputeArgumentsDestroy; /* avoid unused parameter warning */ /* Nothing further to do */ return FALSE; } kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C_w_Extensions/000077500000000000000000000000001421473465500275665ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C_w_Extensions/CMakeLists.txt000066400000000000000000000030751421473465500323330ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_P_Morse_07C_w_Extensions LANGUAGES C) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_create" CREATE_ROUTINE_LANGUAGE "c" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.c) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C_w_Extensions/LICENSE.LGPL000066400000000000000000000636421421473465500313430ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C_w_Extensions/README000066400000000000000000000023001421473465500304410ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (ex_model_Ar_P_Morse_07C_w_Extensions) contains a shifted Morse pair potential Model written in C. phi(r) = epsilon * ( - exp[ -2*C*(r - Rzero) ] + 2*exp[ -C*(r - Rzero) ] ) + shift where shift is computed so that phi(rcut) = 0.0 ex_model_Ar_P_Morse_07C_w_Extensions.c000066400000000000000000000621141421473465500366770ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_07C_w_Extensions/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* Stephen M. Whalen */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /******************************************************************************/ /* */ /* ex_model_Ar_P_Morse_07C pair potential KIM Model */ /* shifted to have zero energy at the cutoff radius */ /* */ /* Language: C */ /* */ /******************************************************************************/ #include "KIM_LogMacros.h" #include "KIM_ModelHeaders.h" #include "KIM_SupportedExtensions.h" #include #include #include #include #define TRUE 1 #define FALSE 0 /******************************************************************************/ /* Below are the definitions and values of all Model parameters */ /******************************************************************************/ #define DIM 3 /* dimensionality of space */ #define SPECCODE 1 /* internal species code */ #define CUTOFF 8.15 /* Angstroms */ #define EPSILON -0.0134783698072604 /* eV */ #define PARAM_C 1.545 /* 1/Angstroms */ #define RZERO 3.786 /* Angstroms */ /* Model buffer definition */ struct buffer { double influenceDistance; double cutoff; int modelWillNotRequestNeighborsOfNoncontributingParticles; }; typedef struct buffer buffer; /* Define prototype for Model create */ int model_create(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit); /* Define prototype for other routines */ static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate); static int model_compute(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments); static int model_extension(KIM_ModelExtension * const modelExtension, void * const extensionStructure); static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); static int model_destroy(KIM_ModelDestroy * const modelDestroy); /* Define prototypes for pair potential calculations */ static void calc_phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi); static void calc_phi_dphi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi); static void calc_phi_d2phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi, double * d2phi); /* Calculate pair potential phi(r) */ static void calc_phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; } return; } /* Calculate pair potential phi(r) and its derivative dphi(r) */ static void calc_phi_dphi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); } return; } /* Calculate pair potential phi(r) and its 1st & 2nd derivatives dphi(r), */ /* d2phi(r) */ static void calc_phi_d2phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi, double * d2phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; *d2phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); *d2phi = 2.0 * (*epsilon) * (*C) * (*C) * (ep - 2.0 * ep2); } return; } /* compute function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ static int model_compute(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments) { /* local variables */ double R; double R_pairs[2]; double * pR_pairs = &(R_pairs[0]); double Rsqij; double phi; double dphi; double d2phi; double dEidr = 0.0; double d2Eidr = 0.0; double Rij[DIM]; double * pRij = &(Rij[0]); double Rij_pairs[2][3]; double const * pRij_pairs = &(Rij_pairs[0][0]); int ier; int i; int i_pairs[2]; int * pi_pairs = &(i_pairs[0]); int j; int j_pairs[2]; int * pj_pairs = &(j_pairs[0]); int jj; int k; int const * neighListOfCurrentPart; int comp_energy; int comp_force; int comp_particleEnergy; int comp_process_dEdr; int comp_process_d2Edr2; int * nParts; int * particleSpeciesCodes; int * particleContributing; buffer * bufferPointer; double * cutoff; double cutsq; double epsilon; double C; double Rzero; double shift; double * coords; double * energy; double * force; double * particleEnergy; int numOfPartNeigh; double dummy; /* check to see if we have been asked to compute the forces, */ /* particleEnergy, and d1Edr */ LOG_INFORMATION("Checking if call backs are present."); KIM_ModelComputeArguments_IsCallbackPresent( modelComputeArguments, KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, &comp_process_dEdr); KIM_ModelComputeArguments_IsCallbackPresent( modelComputeArguments, KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, &comp_process_d2Edr2); LOG_INFORMATION("Getting data pointers"); ier = KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles, &nParts) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, &particleSpeciesCodes) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleContributing, &particleContributing) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &coords) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, &energy) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialForces, &force) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, &particleEnergy); if (ier) { LOG_ERROR("get data pointers failed"); return ier; } comp_energy = (energy != NULL); comp_force = (force != NULL); comp_particleEnergy = (particleEnergy != NULL); /* set value of parameters */ KIM_ModelCompute_GetModelBufferPointer(modelCompute, (void **) &bufferPointer); cutoff = &(bufferPointer->cutoff); cutsq = (*cutoff) * (*cutoff); epsilon = EPSILON; C = PARAM_C; Rzero = RZERO; /* set value of parameter shift */ dummy = 0.0; /* call calc_phi with r=cutoff and shift=0.0 */ calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift); /* set shift to -shift */ shift = -(shift); /* Check to be sure that the species are correct */ /**/ ier = TRUE; /* assume an error */ for (i = 0; i < *nParts; ++i) { if (SPECCODE != particleSpeciesCodes[i]) { LOG_ERROR("Unexpected species code detected"); return ier; } } ier = FALSE; /* everything is ok */ /* initialize potential energies, forces, and virial term */ LOG_INFORMATION("Initializing data"); if (comp_particleEnergy) { for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; } } if (comp_energy) { *energy = 0.0; } if (comp_force) { for (i = 0; i < *nParts; ++i) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] = 0.0; } } } /* Compute energy and forces */ /* loop over particles and compute enregy and forces */ LOG_INFORMATION("Starting main compute loop"); for (i = 0; i < *nParts; ++i) { if (particleContributing[i]) { ier = KIM_ModelComputeArguments_GetNeighborList(modelComputeArguments, 0, i, &numOfPartNeigh, &neighListOfCurrentPart); if (ier) { /* some sort of problem, exit */ LOG_ERROR("GetNeighborList failed"); ier = TRUE; return ier; } /* loop over the neighbors of particle i */ for (jj = 0; jj < numOfPartNeigh; ++jj) { j = neighListOfCurrentPart[jj]; /* get neighbor ID */ if (!(particleContributing[j] && (j < i))) { /* short-circuit half-list */ /* compute relative position vector and squared distance */ Rsqij = 0.0; for (k = 0; k < DIM; ++k) { Rij[k] = coords[j * DIM + k] - coords[i * DIM + k]; /* compute squared distance */ Rsqij += Rij[k] * Rij[k]; } /* compute energy and force */ if (Rsqij < cutsq) { /* particles are interacting ? */ R = sqrt(Rsqij); if (comp_process_d2Edr2) { /* compute pair potential and its derivatives */ calc_phi_d2phi( &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi, &d2phi); /* compute dEidr */ if (particleContributing[j]) { dEidr = dphi; d2Eidr = d2phi; } else { dEidr = 0.5 * dphi; d2Eidr = 0.5 * d2phi; } } else if (comp_force || comp_process_dEdr) { /* compute pair potential and its derivative */ calc_phi_dphi( &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi); /* compute dEidr */ if (particleContributing[j]) { dEidr = dphi; } else { dEidr = 0.5 * dphi; } } else { /* compute just pair potential */ calc_phi(&epsilon, &C, &Rzero, &shift, cutoff, R, &phi); } /* contribution to energy */ if (comp_particleEnergy) { particleEnergy[i] += 0.5 * phi; if (particleContributing[j]) { particleEnergy[j] += 0.5 * phi; } } if (comp_energy) { if (particleContributing[j]) { *energy += phi; } else { *energy += 0.5 * phi; } } /* contribution to process_dEdr */ if (comp_process_dEdr) { ier = KIM_ModelComputeArguments_ProcessDEDrTerm( modelComputeArguments, dEidr, R, pRij, i, j); if (ier) { LOG_ERROR("ProcessDEDrTerm callback error"); ier = TRUE; return ier; } } /* contribution to process_d2Edr2 */ if (comp_process_d2Edr2) { R_pairs[0] = R_pairs[1] = R; Rij_pairs[0][0] = Rij_pairs[1][0] = Rij[0]; Rij_pairs[0][1] = Rij_pairs[1][1] = Rij[1]; Rij_pairs[0][2] = Rij_pairs[1][2] = Rij[2]; i_pairs[0] = i_pairs[1] = i; j_pairs[0] = j_pairs[1] = j; ier = KIM_ModelComputeArguments_ProcessD2EDr2Term( modelComputeArguments, d2Eidr, pR_pairs, pRij_pairs, pi_pairs, pj_pairs); if (ier) { LOG_ERROR("ProcessDEDrTerm callback error"); ier = TRUE; return ier; } } /* contribution to forces */ if (comp_force) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] += dEidr * Rij[k] / R; /* accumulate force on i */ force[j * DIM + k] -= dEidr * Rij[k] / R; /* accumulate force on j */ } } } } /* if (i < j) */ } /* loop on jj */ } /* if contributing */ } /* loop on i */ LOG_INFORMATION("Finished compute loop"); /* everything is great */ ier = FALSE; return ier; } /* Extension function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelExtension_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelExtension static int model_extension(KIM_ModelExtension * const modelExtension, void * const extensionStructure) { char const * extensionID; KIM_SupportedExtensions * supportedExtensions; KIM_ModelExtension_GetExtensionID(modelExtension, &extensionID); if (strcmp(extensionID, KIM_SUPPORTED_EXTENSIONS_ID) == 0) { supportedExtensions = (KIM_SupportedExtensions *) extensionStructure; supportedExtensions->numberOfSupportedExtensions = 2; strcpy(supportedExtensions->supportedExtensionID[0], KIM_SUPPORTED_EXTENSIONS_ID); supportedExtensions->supportedExtensionRequired[0] = 0; strcpy(supportedExtensions->supportedExtensionID[1], "Fake_Extension"); supportedExtensions->supportedExtensionRequired[1] = 0; return FALSE; } else { LOG_ERROR("Unknown ExtensionID."); return TRUE; } } /* Create function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCreate_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCreate /**/ int model_create(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit) { buffer * bufferPointer; int error; /* use function pointer definitions to verify prototypes */ KIM_ModelCreateFunction * create = model_create; KIM_ModelComputeArgumentsCreateFunction * CACreate = compute_arguments_create; KIM_ModelComputeFunction * compute = model_compute; KIM_ModelExtensionFunction * extension = model_extension; KIM_ModelComputeArgumentsDestroyFunction * CADestroy = compute_arguments_destroy; KIM_ModelDestroyFunction * destroy = model_destroy; (void) create; /* avoid unused parameter warnings */ (void) requestedLengthUnit; (void) requestedEnergyUnit; (void) requestedChargeUnit; (void) requestedTemperatureUnit; (void) requestedTimeUnit; /* set units */ LOG_INFORMATION("Set model units"); error = KIM_ModelCreate_SetUnits(modelCreate, /* ignoring requested units */ KIM_LENGTH_UNIT_A, KIM_ENERGY_UNIT_eV, KIM_CHARGE_UNIT_unused, KIM_TEMPERATURE_UNIT_unused, KIM_TIME_UNIT_unused); /* register species */ LOG_INFORMATION("Setting species code"); error = error || KIM_ModelCreate_SetSpeciesCode( modelCreate, KIM_SPECIES_NAME_Ar, SPECCODE); /* register numbering */ LOG_INFORMATION("Setting model numbering"); error = error || KIM_ModelCreate_SetModelNumbering(modelCreate, KIM_NUMBERING_zeroBased); /* register function pointers */ LOG_INFORMATION("Register model function pointers"); error = error || KIM_ModelCreate_SetRoutinePointer( modelCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CACreate) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Compute, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) compute) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Extension, KIM_LANGUAGE_NAME_c, FALSE, (KIM_Function *) extension) || KIM_ModelCreate_SetRoutinePointer( modelCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CADestroy) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Destroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) destroy); /* allocate buffer */ bufferPointer = (buffer *) malloc(sizeof(buffer)); /* store model buffer in KIM object */ LOG_INFORMATION("Set influence distance and cutoffs"); KIM_ModelCreate_SetModelBufferPointer(modelCreate, bufferPointer); /* set buffer values */ bufferPointer->influenceDistance = CUTOFF; bufferPointer->cutoff = CUTOFF; bufferPointer->modelWillNotRequestNeighborsOfNoncontributingParticles = 1; /* register influence distance */ KIM_ModelCreate_SetInfluenceDistancePointer( modelCreate, &(bufferPointer->influenceDistance)); /* register cutoff */ KIM_ModelCreate_SetNeighborListPointers( modelCreate, 1, &(bufferPointer->cutoff), &(bufferPointer->modelWillNotRequestNeighborsOfNoncontributingParticles)); if (error) { free(bufferPointer); LOG_ERROR("Unable to successfully initialize model"); return TRUE; } else return FALSE; } /* Destroy function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDestroy_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDestroy /**/ int model_destroy(KIM_ModelDestroy * const modelDestroy) { buffer * bufferPointer; LOG_INFORMATION("Getting buffer"); KIM_ModelDestroy_GetModelBufferPointer(modelDestroy, (void **) &bufferPointer); LOG_INFORMATION("Freeing model memory"); free(bufferPointer); return FALSE; } /* compute arguments create routine */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) { int error; (void) modelCompute; /* avoid unused parameter warning */ /* register arguments */ LOG_INFORMATION("Register argument supportStatus"); error = KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialForces, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, KIM_SUPPORT_STATUS_optional); /* register call backs */ LOG_INFORMATION("Register call back supportStatus"); error = error || KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, KIM_SUPPORT_STATUS_optional); if (error) { LOG_ERROR("Unable to successfully initialize compute arguments"); return TRUE; } else return FALSE; } /* compute arguments destroy routine */ static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy) { (void) modelCompute; /* avoid unused parameter warning */ (void) modelComputeArgumentsDestroy; /* avoid unused parameter warning */ /* Nothing further to do */ return FALSE; } kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_MultiCutoff/000077500000000000000000000000001421473465500267315ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_MultiCutoff/CMakeLists.txt000066400000000000000000000030701421473465500314710ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_P_Morse_MultiCutoff LANGUAGES C) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_create" CREATE_ROUTINE_LANGUAGE "c" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.c) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_MultiCutoff/LICENSE.LGPL000066400000000000000000000636421421473465500305060ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_MultiCutoff/README000066400000000000000000000026031421473465500276120ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory contains a model consisting of the superposition of two shifted Morse pair potentials with different cutoffs. phi_i(r) = epsilon_i * ( - exp[ -2*C_i*(r - Rzero_i) ] + 2*exp[ -C_i*(r - Rzero_i) ] ) + shift_i, for i=1,2 and where shift_i is computed so that phi_i(rcut_i) = 0.0. The model uses two neighbor lists with different cutoffs and does not request neighbors of non-contributing particles. ex_model_Ar_P_Morse_MultiCutoff.c000066400000000000000000000641661421473465500352160ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_P_Morse_MultiCutoff/* */ /* KIM-API: An API for interatomic models */ /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */ /* All rights reserved. */ /* */ /* Contributors: */ /* Ryan S. Elliott */ /* Ellad B. Tadmor */ /* Stephen M. Whalen */ /* */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this library; if not, write to the Free Software Foundation, */ /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /******************************************************************************/ /* */ /* ex_model_Ar_P_Morse_07C pair potential KIM Model */ /* shifted to have zero energy at the cutoff radius */ /* */ /* Language: C */ /* */ /******************************************************************************/ #include "KIM_LogMacros.h" #include "KIM_ModelHeaders.h" #include #include #include #define TRUE 1 #define FALSE 0 /******************************************************************************/ /* Below are the definitions and values of all Model parameters */ /******************************************************************************/ #define DIM 3 /* dimensionality of space */ #define SPECCODE 1 /* internal species code */ #define CUTOFF 8.15 /* Angstroms */ #define EPSILON -0.0134783698072604 /* eV */ #define PARAM_C 1.545 /* 1/Angstroms */ #define RZERO 3.786 /* Angstroms */ /* Model buffer definition */ #define NUMBER_OF_CUTOFFS 2 struct buffer { double influenceDistance; double cutoff[NUMBER_OF_CUTOFFS]; int modelWillNotRequestNeighborsOfNoncontributingParticles[NUMBER_OF_CUTOFFS]; }; typedef struct buffer buffer; /* Define prototype for Model create */ int model_create(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit); /* Define prototype for other routines */ static int model_compute(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments); static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate); static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy); static int model_destroy(KIM_ModelDestroy * const modelDestroy); /* Define prototypes for pair potential calculations */ static void calc_phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi); static void calc_phi_dphi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi); static void calc_phi_d2phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi, double * d2phi); /* Calculate pair potential phi(r) */ static void calc_phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; } return; } /* Calculate pair potential phi(r) and its derivative dphi(r) */ static void calc_phi_dphi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); } return; } /* Calculate pair potential phi(r) and its 1st & 2nd derivatives dphi(r), */ /* d2phi(r) */ static void calc_phi_d2phi(double * epsilon, double * C, double * Rzero, double * shift, double * cutoff, double r, double * phi, double * dphi, double * d2phi) { /* local variables */ double ep; double ep2; ep = exp(-(*C) * (r - *Rzero)); ep2 = ep * ep; if (r > *cutoff) { /* Argument exceeds cutoff radius */ *phi = 0.0; *dphi = 0.0; *d2phi = 0.0; } else { *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift; *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2); *d2phi = 2.0 * (*epsilon) * (*C) * (*C) * (ep - 2.0 * ep2); } return; } /* function to loop over particles */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ int loops(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments, int neighborListIndex, int * nParts, int * particleContributing, double * energy, double * particleEnergy, double * force, double * coords, double cutsq, double epsilon, double C, double Rzero, double shift, double * cutoff, int comp_energy, int comp_force, int comp_particleEnergy, int comp_process_dEdr, int comp_process_d2Edr2) { int ier; int i; int numOfPartNeigh; int const * neighListOfCurrentPart; int jj; int j; double Rsqij; int k; double Rij[DIM]; double phi; double dphi; double d2phi; double dEidr; double d2Eidr; double * pRij = &(Rij[0]); double Rij_pairs[2][3]; double const * pRij_pairs = &(Rij_pairs[0][0]); int i_pairs[2]; int * pi_pairs = &(i_pairs[0]); int j_pairs[2]; int * pj_pairs = &(j_pairs[0]); double R; double R_pairs[2]; double * pR_pairs = &(R_pairs[0]); /* loop over particles and compute enregy and forces */ LOG_INFORMATION("Starting main compute loop"); for (i = 0; i < *nParts; ++i) { if (particleContributing[i]) { ier = KIM_ModelComputeArguments_GetNeighborList(modelComputeArguments, neighborListIndex, i, &numOfPartNeigh, &neighListOfCurrentPart); if (ier) { /* some sort of problem, exit */ LOG_ERROR("GetNeighborList failed"); ier = TRUE; return ier; } /* loop over the neighbors of particle i */ for (jj = 0; jj < numOfPartNeigh; ++jj) { j = neighListOfCurrentPart[jj]; /* get neighbor ID */ if (!(particleContributing[j] && (j < i))) { /* short-circuit half-list */ /* compute relative position vector and squared distance */ Rsqij = 0.0; for (k = 0; k < DIM; ++k) { Rij[k] = coords[j * DIM + k] - coords[i * DIM + k]; /* compute squared distance */ Rsqij += Rij[k] * Rij[k]; } /* compute energy and force */ if (Rsqij < cutsq) { /* particles are interacting ? */ R = sqrt(Rsqij); if (comp_process_d2Edr2) { /* compute pair potential and its derivatives */ calc_phi_d2phi( &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi, &d2phi); /* compute dEidr */ if (particleContributing[j]) { dEidr = dphi; d2Eidr = d2phi; } else { dEidr = 0.5 * dphi; d2Eidr = 0.5 * d2phi; } } else if (comp_force || comp_process_dEdr) { /* compute pair potential and its derivative */ calc_phi_dphi( &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi); /* compute dEidr */ if (particleContributing[j]) { dEidr = dphi; } else { dEidr = 0.5 * dphi; } } else { /* compute just pair potential */ calc_phi(&epsilon, &C, &Rzero, &shift, cutoff, R, &phi); } /* contribution to energy */ if (comp_particleEnergy) { particleEnergy[i] += 0.5 * phi; if (particleContributing[j]) { particleEnergy[j] += 0.5 * phi; } } if (comp_energy) { if (particleContributing[j]) { *energy += phi; } else { *energy += 0.5 * phi; } } /* contribution to process_dEdr */ if (comp_process_dEdr) { ier = KIM_ModelComputeArguments_ProcessDEDrTerm( modelComputeArguments, dEidr, R, pRij, i, j); if (ier) { LOG_ERROR("ProcessDEDrTerm callback error"); ier = TRUE; return ier; } } /* contribution to process_d2Edr2 */ if (comp_process_d2Edr2) { R_pairs[0] = R_pairs[1] = R; Rij_pairs[0][0] = Rij_pairs[1][0] = Rij[0]; Rij_pairs[0][1] = Rij_pairs[1][1] = Rij[1]; Rij_pairs[0][2] = Rij_pairs[1][2] = Rij[2]; i_pairs[0] = i_pairs[1] = i; j_pairs[0] = j_pairs[1] = j; ier = KIM_ModelComputeArguments_ProcessD2EDr2Term( modelComputeArguments, d2Eidr, pR_pairs, pRij_pairs, pi_pairs, pj_pairs); if (ier) { LOG_ERROR("ProcessD2EDr2Term callback error"); ier = TRUE; return ier; } } /* contribution to forces */ if (comp_force) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] += dEidr * Rij[k] / R; /* accumulate force on i */ force[j * DIM + k] -= dEidr * Rij[k] / R; /* accumulate force on j */ } } } } /* if (i < j) */ } /* loop on jj */ } /* if contributing */ } /* loop on i */ LOG_INFORMATION("Finished compute loop"); return FALSE; } /* compute function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ static int model_compute(KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArguments const * const modelComputeArguments) { /* local variables */ int ier; int i; int k; int comp_energy; int comp_force; int comp_particleEnergy; int comp_process_dEdr; int comp_process_d2Edr2; int * particleSpeciesCodes; int * particleContributing; buffer * bufferPointer; double * cutoff; double cutsq; double epsilon; double C; double Rzero; double shift; double * coords; double * energy; double * force; double * particleEnergy; int * nParts; double dummy; /* check to see if we have been asked to compute the forces, */ /* particleEnergy, and d1Edr */ LOG_INFORMATION("Checking if call backs are present."); KIM_ModelComputeArguments_IsCallbackPresent( modelComputeArguments, KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, &comp_process_dEdr); KIM_ModelComputeArguments_IsCallbackPresent( modelComputeArguments, KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, &comp_process_d2Edr2); LOG_INFORMATION("Getting data pointers"); ier = KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles, &nParts) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, &particleSpeciesCodes) || KIM_ModelComputeArguments_GetArgumentPointerInteger( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleContributing, &particleContributing) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_coordinates, &coords) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, &energy) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialForces, &force) || KIM_ModelComputeArguments_GetArgumentPointerDouble( modelComputeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, &particleEnergy); if (ier) { LOG_ERROR("get data pointers failed"); return ier; } comp_energy = (energy != NULL); comp_force = (force != NULL); comp_particleEnergy = (particleEnergy != NULL); /* Check to be sure that the species are correct */ /**/ ier = TRUE; /* assume an error */ for (i = 0; i < *nParts; ++i) { if (SPECCODE != particleSpeciesCodes[i]) { LOG_ERROR("Unexpected species code detected"); return ier; } } ier = FALSE; /* everything is ok */ /* initialize potential energies, forces, and virial term */ LOG_INFORMATION("Initializing data"); if (comp_particleEnergy) { for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; } } if (comp_energy) { *energy = 0.0; } if (comp_force) { for (i = 0; i < *nParts; ++i) { for (k = 0; k < DIM; ++k) { force[i * DIM + k] = 0.0; } } } /* Compute energy and forces */ /* set value of parameters */ KIM_ModelCompute_GetModelBufferPointer(modelCompute, (void **) &bufferPointer); cutoff = &(bufferPointer->cutoff[0]); cutsq = (*cutoff) * (*cutoff); epsilon = EPSILON; C = PARAM_C; Rzero = RZERO; /* set value of parameter shift */ dummy = 0.0; /* call calc_phi with r=cutoff and shift=0.0 */ calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift); /* set shift to -shift */ shift = -(shift); /* do computation for short list */ ier = loops(modelCompute, modelComputeArguments, 0 /* neighborListIndex */, nParts, particleContributing, energy, particleEnergy, force, coords, cutsq, epsilon, C, Rzero, shift, cutoff, comp_energy, comp_force, comp_particleEnergy, comp_process_dEdr, comp_process_d2Edr2); if (ier) return TRUE; cutoff = &(bufferPointer->cutoff[1]); cutsq = (*cutoff) * (*cutoff); epsilon = EPSILON / 4.0; C = PARAM_C / 2.0; Rzero = RZERO * 1.5; /* set value of parameter shift */ dummy = 0.0; /* call calc_phi with r=cutoff and shift=0.0 */ calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift); /* set shift to -shift */ shift = -(shift); /* do computation for short list */ ier = loops(modelCompute, modelComputeArguments, 1 /* neighborListIndex */, nParts, particleContributing, energy, particleEnergy, force, coords, cutsq, epsilon, C, Rzero, shift, cutoff, comp_energy, comp_force, comp_particleEnergy, comp_process_dEdr, comp_process_d2Edr2); if (ier) return TRUE; /* everything is great */ ier = FALSE; return ier; } /* Create function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCreate_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCreate /**/ int model_create(KIM_ModelCreate * const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit) { buffer * bufferPointer; int error; /* use function pointer definitions to verify prototypes */ KIM_ModelCreateFunction * create = model_create; KIM_ModelComputeArgumentsCreateFunction * CACreate = compute_arguments_create; KIM_ModelComputeFunction * compute = model_compute; KIM_ModelComputeArgumentsDestroyFunction * CADestroy = compute_arguments_destroy; KIM_ModelDestroyFunction * destroy = model_destroy; (void) create; /* avoid unused parameter warnings */ (void) requestedLengthUnit; (void) requestedEnergyUnit; (void) requestedChargeUnit; (void) requestedTemperatureUnit; (void) requestedTimeUnit; /* set units */ LOG_INFORMATION("Set model units"); error = KIM_ModelCreate_SetUnits(modelCreate, /* ignoring requested units */ KIM_LENGTH_UNIT_A, KIM_ENERGY_UNIT_eV, KIM_CHARGE_UNIT_unused, KIM_TEMPERATURE_UNIT_unused, KIM_TIME_UNIT_unused); /* register species */ LOG_INFORMATION("Setting species code"); error = error || KIM_ModelCreate_SetSpeciesCode( modelCreate, KIM_SPECIES_NAME_Ar, SPECCODE); /* register numbering */ LOG_INFORMATION("Setting model numbering"); error = error || KIM_ModelCreate_SetModelNumbering(modelCreate, KIM_NUMBERING_zeroBased); /* register function pointers */ LOG_INFORMATION("Register model function pointers"); error = error || KIM_ModelCreate_SetRoutinePointer( modelCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CACreate) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Compute, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) compute) || KIM_ModelCreate_SetRoutinePointer( modelCreate, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) CADestroy) || KIM_ModelCreate_SetRoutinePointer(modelCreate, KIM_MODEL_ROUTINE_NAME_Destroy, KIM_LANGUAGE_NAME_c, TRUE, (KIM_Function *) destroy); /* allocate buffer */ bufferPointer = (buffer *) malloc(sizeof(buffer)); /* store model buffer in KIM object */ LOG_INFORMATION("Set influence distance and cutoffs"); KIM_ModelCreate_SetModelBufferPointer(modelCreate, bufferPointer); /* set buffer values */ bufferPointer->influenceDistance = CUTOFF; bufferPointer->cutoff[0] = CUTOFF / 2.0; bufferPointer->cutoff[1] = CUTOFF; bufferPointer->modelWillNotRequestNeighborsOfNoncontributingParticles[0] = 1; bufferPointer->modelWillNotRequestNeighborsOfNoncontributingParticles[1] = 1; /* register influence distance */ KIM_ModelCreate_SetInfluenceDistancePointer( modelCreate, &(bufferPointer->influenceDistance)); /* register cutoff */ KIM_ModelCreate_SetNeighborListPointers( modelCreate, NUMBER_OF_CUTOFFS, &(bufferPointer->cutoff[0]), &(bufferPointer ->modelWillNotRequestNeighborsOfNoncontributingParticles[0])); if (error) { free(bufferPointer); LOG_ERROR("Unable to successfully initialize model"); return TRUE; } else return FALSE; } /* Initialization function */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDestroy_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelDestroy /**/ int model_destroy(KIM_ModelDestroy * const modelDestroy) { buffer * bufferPointer; LOG_INFORMATION("Getting buffer"); KIM_ModelDestroy_GetModelBufferPointer(modelDestroy, (void **) &bufferPointer); LOG_INFORMATION("Freeing model memory"); free(bufferPointer); return FALSE; } /* compute arguments create routine */ #undef KIM_LOGGER_FUNCTION_NAME #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry #undef KIM_LOGGER_OBJECT_NAME #define KIM_LOGGER_OBJECT_NAME modelCompute /**/ static int compute_arguments_create( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate) { int error; (void) modelCompute; /* avoid unused parameter warning */ /* register arguments */ LOG_INFORMATION("Register argument supportStatus"); error = KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialForces, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, KIM_SUPPORT_STATUS_optional); /* register call backs */ LOG_INFORMATION("Register call back supportStatus"); error = error || KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm, KIM_SUPPORT_STATUS_optional); error = error || KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus( modelComputeArgumentsCreate, KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term, KIM_SUPPORT_STATUS_optional); if (error) { LOG_ERROR("Unable to successfully initialize compute arguments"); return TRUE; } else return FALSE; } /* compute arguments destroy routine */ static int compute_arguments_destroy( KIM_ModelCompute const * const modelCompute, KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy) { (void) modelCompute; /* avoid unused parameter warning */ (void) modelComputeArgumentsDestroy; /* avoid unused parameter warning */ /* Nothing further to do */ return FALSE; } kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_SLJ_MultiCutoff/000077500000000000000000000000001421473465500260155ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_SLJ_MultiCutoff/CMakeLists.txt000066400000000000000000000031121421473465500305520ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "portableModel") project(ex_model_Ar_SLJ_MultiCutoff LANGUAGES Fortran) kim_api_items_setup_after_project(ITEM_TYPE "portableModel") add_kim_api_model_library( NAME ${PROJECT_NAME} CREATE_ROUTINE_NAME "model_create_routine" CREATE_ROUTINE_LANGUAGE "fortran" ) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}.f90) kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_SLJ_MultiCutoff/LICENSE.LGPL000066400000000000000000000636421421473465500275720ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_SLJ_MultiCutoff/README000066400000000000000000000041721421473465500267010ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ellad B. Tadmor # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Spring-modified Lennard-Jones (SLJ) pair potential model for Ar. V = 0.5 \sum_i \sum_j eps_i eps_j 4 [ (sig/r_ij)^12 - (sig/r_ij)^6 ] (1) where eps_i = 0.5 \sum_k spring (r_ik)^2 (2) The potential parameters are `sig` and the spring constant `sig`. This potential uses two cutoffs and requires neighbors of padding atoms for the summ in (2). The loops in (2) are over all atoms for which r_ik < cutoff1 The loops in (1) are over all atoms for which r_ij < cutoff2 For the Ar parameterization, cutoff1 is set so that only nearest neighbors contribute in the equilibrium 0K fcc structure, and cutoff2 is set to include the third neighbor distance. The potential is discontinuous at both cutoffs. It is designed for testing purposes only. The equilibrium spacing for the fcc structure predicted by the SLJ potential is a0 = 2^(1/3)/sqrt(3) * (94297/491)^(1/6) sig = 1.74724 sig The first, second and third neighbor distances in fcc are then: r_NN1 = a0/sqrt(2) = 1.235 sig r_NN2 = a0 = 1.747 sig r_NN3 = a0*sqrt(3/2) = 2.140 sig The parameters `sig` and `spring` are selected to reproduce the experimental properties of fcc argon: a0 = 5.26 A E_c = 0.0104 eV ex_model_Ar_SLJ_MultiCutoff.f90000066400000000000000000000610701421473465500335310ustar00rootroot00000000000000kim-api-2.3.0-git/examples/portable-models/ex_model_Ar_SLJ_MultiCutoff! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ellad B. Tadmor ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! !**************************************************************************** !** !** MODULE ex_model_Ar_SLJ_MultiCutoff !** !** Spring-modified Lennard-Jones (SLJ) pair potential model for Ar !** !** V = 0.5 \sum_i \sum_j eps_i eps_j 4 [ (sig/r_ij)^12 - (sig/r_ij)^6 ] (1) !** !** where !** eps_i = 0.5 \sum_k spring (r_ik)^2 (2) !** !** See README for details. !** !** Language: Fortran 2003 !** !** Author: Ellad B. Tadmor !** !** Date: August 23, 2018 !** !**************************************************************************** module ex_model_Ar_SLJ_MultiCutoff use, intrinsic :: iso_c_binding use kim_model_headers_module implicit none save private public Compute_Energy_Forces, & model_destroy_func, & model_compute_arguments_create, & model_compute_arguments_destroy, & model_cutoff1, & model_cutoff2, & speccode, & buffer_type ! Below are the definitions and values of all Model parameters integer(c_int), parameter :: cd = c_double ! used for literal constants integer(c_int), parameter :: DIM = 3 ! dimensionality of space integer(c_int), parameter :: speccode = 1 ! internal species code !----------------------------------------------------------------------------- ! Below are the definitions and values of all additional model parameters ! ! Recall that the Fortran 2003 format for declaring parameters is as follows: ! ! integer(c_int), parameter :: parname = value ! This defines an integer ! ! parameter called `parname' ! ! with a value equal to ! ! `value' (a number) ! ! real(c_double), parameter :: parname = value ! This defines a real(c_double) ! ! parameter called `parname' ! ! with a value equal to ! ! `value' (a number) !----------------------------------------------------------------------------- real(c_double), parameter :: lj_spring = 0.00051226_cd real(c_double), parameter :: lj_sigma = 5.26_cd / 1.74724_cd ! experimental fcc lattice constant is a0=5.26 real(c_double), parameter :: model_cutoff1 = 1.25 * lj_sigma ! short-range nearest neighbor for fcc real(c_double), parameter :: model_cutoff2 = 2.25 * lj_sigma ! long-range third neighbor for fcc real(c_double), parameter :: model_cutsq1 = model_cutoff1**2 real(c_double), parameter :: model_cutsq2 = model_cutoff2**2 type, bind(c) :: buffer_type real(c_double) :: influence_distance real(c_double) :: cutoff(2) integer(c_int) :: & model_will_not_request_neighbors_of_noncontributing_particles(2) end type buffer_type contains !----------------------------------------------------------------------------- ! ! Calculate Lennard-Jones potential phi(r) and, if requested, ! its derivative dphi(r) ! !----------------------------------------------------------------------------- recursive subroutine calc_phi(r, phi, dphi, calc_deriv) implicit none !-- Transferred variables real(c_double), intent(in) :: r real(c_double), intent(out) :: phi real(c_double), intent(out) :: dphi logical, intent(in) :: calc_deriv !-- Local variables real(c_double) rsq, sor, sor6, sor12 rsq = r * r ! r^2 sor = lj_sigma / r ! (sig/r) sor6 = sor * sor * sor ! sor6 = sor6 * sor6 ! (sig/r)^6 sor12 = sor6 * sor6 ! (sig/r)^12 if (r > model_cutoff2) then ! Argument exceeds cutoff radius phi = 0.0_cd if (calc_deriv) dphi = 0.0_cd else phi = 4.0_cd * (sor12 - sor6) if (calc_deriv) dphi = 24.0_cd * (-2.0_cd * sor12 + sor6) / r end if end subroutine calc_phi !----------------------------------------------------------------------------- ! ! Calculate short-range linear spring-based energy amplitude for `atom` ! !----------------------------------------------------------------------------- recursive subroutine calc_spring_energyamp(model_compute_arguments_handle, & atom, coor, eps, ierr) implicit none !-- Transferred variables type(kim_model_compute_arguments_handle_type), & intent(in) :: model_compute_arguments_handle integer(c_int), intent(in) :: atom real(c_double), intent(in) :: coor(:, :) real(c_double), intent(out) :: eps integer(c_int), intent(out) :: ierr !-- Local variables integer(c_int) k, kk real(c_double) Rrel(DIM) real(c_double) Rsqrel integer(c_int) numneishort integer(c_int), pointer :: neishort(:) ! Get short-range neighbors of `atom` call kim_get_neighbor_list( & model_compute_arguments_handle, 1, atom, numneishort, neishort, ierr) if (ierr /= 0) return eps = 0.0_cd do kk = 1, numneishort k = neishort(kk) Rrel(:) = coor(:, k) - coor(:, atom) Rsqrel = dot_product(Rrel, Rrel) if (Rsqrel < model_cutsq1) eps = eps + Rsqrel end do eps = 0.5_cd * lj_spring * eps end subroutine calc_spring_energyamp !----------------------------------------------------------------------------- ! ! Calculate short-range linear spring-based contribution to force ! !----------------------------------------------------------------------------- recursive subroutine calc_spring_force(model_compute_arguments_handle, atom, & coor, eps, phi, force, ierr) implicit none !-- Transferred variables type(kim_model_compute_arguments_handle_type), & intent(in) :: model_compute_arguments_handle integer(c_int), intent(in) :: atom real(c_double), intent(in) :: coor(:, :) real(c_double), intent(in) :: eps real(c_double), intent(in) :: phi real(c_double), intent(inout) :: force(:, :) integer(c_int), intent(out) :: ierr !-- Local variables integer(c_int) k, kk real(c_double) Rrel(DIM), dforce(DIM) real(c_double) Rsqrel integer(c_int) numneishort integer(c_int), pointer :: neishort(:) ! Get short-range neighbors of `atom` call kim_get_neighbor_list( & model_compute_arguments_handle, 1, atom, numneishort, neishort, ierr) if (ierr /= 0) return ! Add contribution to force on `atom` and its near neighbors that contribute ! to the spring term do kk = 1, numneishort k = neishort(kk) Rrel(:) = coor(:, k) - coor(:, atom) Rsqrel = dot_product(Rrel, Rrel) if (Rsqrel < model_cutsq1) then dforce(:) = 0.5_cd * eps * lj_spring * Rrel(:) * phi force(:, atom) = force(:, atom) + dforce(:) ! accumulate force on atom force(:, k) = force(:, k) - dforce(:) ! accumulate force on k end if end do end subroutine calc_spring_force !----------------------------------------------------------------------------- ! ! Compute energy and forces on particles from the positions. ! !----------------------------------------------------------------------------- recursive subroutine Compute_Energy_Forces( & model_compute_handle, model_compute_arguments_handle, ierr) bind(c) implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle integer(c_int), intent(out) :: ierr !-- Local variables real(c_double) :: Rij(DIM), dforce(DIM) real(c_double) :: r, Rsqij, phi, dphi, dEidr, epsi, epsj integer(c_int) :: i, j, jj, comp_force, comp_enepot, comp_energy !integer(c_int) :: comp_virial integer(c_int) :: numnei integer(c_int) :: ierr2 logical :: calc_deriv !-- KIM variables integer(c_int), pointer :: N real(c_double), pointer :: energy real(c_double), pointer :: coor(:, :) real(c_double), pointer :: force(:, :) real(c_double), pointer :: enepot(:) integer(c_int), pointer :: nei1part(:) integer(c_int), pointer :: particleSpeciesCodes(:) integer(c_int), pointer :: particleContributing(:) !real(c_double), pointer :: virial(:) ! Unpack data from KIM object ! ierr = 0 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, N, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, n, & particleSpeciesCodes, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, n, & particleContributing, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, dim, n, coor, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, energy, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, dim, n, force, ierr2) ierr = ierr + ierr2 call kim_get_argument_pointer( & model_compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, n, enepot, ierr2) ierr = ierr + ierr2 !call kim_model_compute_arguments_get_argument_pointer( & ! model_compute_arguments_handle, & ! KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, 6, virial, ierr2) !ierr = ierr + ierr2 if (ierr /= 0) then call kim_log_entry(model_compute_arguments_handle, & KIM_LOG_VERBOSITY_ERROR, "get data") return end if ! Check to see if we have been asked to compute the forces, energyperpart, ! energy and virial ! if (associated(energy)) then comp_energy = 1 else comp_energy = 0 end if if (associated(force)) then comp_force = 1 else comp_force = 0 end if if (associated(enepot)) then comp_enepot = 1 else comp_enepot = 0 end if !if (associated(virial)) then ! comp_virial = 1 !else ! comp_virial = 0 !end if calc_deriv = comp_force == 1 !.or.comp_virial.eq.1 ! Check to be sure that the species are correct ! ierr = 1 ! assume an error do i = 1, N if (particleSpeciesCodes(i) /= speccode) then call kim_log_entry( & model_compute_handle, KIM_LOG_VERBOSITY_ERROR, & "Unexpected species code detected") return end if end do ierr = 0 ! everything is ok ! Initialize potential energies, forces, virial term ! if (comp_enepot == 1) enepot = 0.0_cd if (comp_energy == 1) energy = 0.0_cd if (comp_force == 1) force = 0.0_cd !if (comp_virial.eq.1) virial = 0.0_cd if (calc_deriv) dEidr = 0.0_cd ! ! Compute energy and forces ! ! Loop over particles and compute energy and forces ! do i = 1, N if (particleContributing(i) == 1) then ! Set up neighbor list for next particle call kim_get_neighbor_list( & model_compute_arguments_handle, 2, i, numnei, nei1part, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_arguments_handle, KIM_LOG_VERBOSITY_ERROR, & "GetNeighborList failed") ierr = 1 return end if ! Get short range contribution for atom i to energy amplitude call calc_spring_energyamp(model_compute_arguments_handle, & i, coor, epsi, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_handle, KIM_LOG_VERBOSITY_ERROR, & "GetNeighborList failed") ierr = 1 return end if ! Loop over the neighbors of particle i ! do jj = 1, numnei j = nei1part(jj) ! get neighbor ID ! Get short range contribution for atom j to energy amplitude call calc_spring_energyamp(model_compute_arguments_handle, j, coor, & epsj, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_handle, KIM_LOG_VERBOSITY_ERROR, & "GetNeighborList failed") ierr = 1 return end if ! compute relative position vector ! Rij(:) = coor(:, j) - coor(:, i) ! distance vector between i j ! compute energy and forces ! Rsqij = dot_product(Rij, Rij) ! compute square distance if (Rsqij < model_cutsq2) then ! particles are interacting? r = sqrt(Rsqij) ! compute distance call calc_phi(r, phi, dphi, calc_deriv) ! compute pair potential and deriv if (calc_deriv) dEidr = 0.5_cd * dphi ! contribution to energy ! if (comp_enepot == 1) then enepot(i) = enepot(i) + 0.5_cd * epsi * epsj * phi ! accumulate energy end if if (comp_energy == 1) then energy = energy + 0.5_cd * epsi * epsj * phi end if !!@@@@@@@@@@@@@@@@@@@@ NOT FIXED YET ! ! contribution to virial tensor, ! ! virial(i,j)=r(i)*r(j)*(dV/dr)/r ! ! ! if (comp_virial.eq.1) then ! virial(1) = virial(1) + Rij(1)*Rij(1)*dEidr/r ! virial(2) = virial(2) + Rij(2)*Rij(2)*dEidr/r ! virial(3) = virial(3) + Rij(3)*Rij(3)*dEidr/r ! virial(4) = virial(4) + Rij(2)*Rij(3)*dEidr/r ! virial(5) = virial(5) + Rij(1)*Rij(3)*dEidr/r ! virial(6) = virial(6) + Rij(1)*Rij(2)*dEidr/r ! endif !!@@@@@@@@@@@@@@@@@@@@ ! contribution to forces ! if (comp_force == 1) then ! Contribution due to short range neighbors of i call calc_spring_force(model_compute_arguments_handle, i, coor, & epsj, phi, force, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_handle, KIM_LOG_VERBOSITY_ERROR, & "GetNeighborList failed") ierr = 1 return end if ! Contribution due to short range neighbors of j call calc_spring_force(model_compute_arguments_handle, j, coor, & epsi, phi, force, ierr) if (ierr /= 0) then ! some sort of problem, exit call kim_log_entry( & model_compute_handle, KIM_LOG_VERBOSITY_ERROR, & "GetNeighborList failed") ierr = 1 return end if ! Contribution due to deriv of LJ term dforce(:) = epsi * epsj * dEidr * Rij(:) / r force(:, i) = force(:, i) + dforce(:) ! accumulate force on i force(:, j) = force(:, j) - dforce(:) ! accumulate force on j end if end if end do ! loop on jj end if ! if particleContributing end do ! do i ! Everything is great ! ierr = 0 return end subroutine Compute_Energy_Forces !----------------------------------------------------------------------------- ! ! Model destroy routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_destroy_func(model_destroy_handle, ierr) bind(c) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_destroy_handle_type), intent(inout) :: model_destroy_handle integer(c_int), intent(out) :: ierr type(buffer_type), pointer :: buf; type(c_ptr) :: pbuf call kim_get_model_buffer_pointer(model_destroy_handle, pbuf) call c_f_pointer(pbuf, buf) call kim_log_entry(model_destroy_handle, KIM_LOG_VERBOSITY_INFORMATION, & "deallocating model buffer") deallocate (buf) ierr = 0 ! everything is good end subroutine model_destroy_func !----------------------------------------------------------------------------- ! ! Model compute arguments create routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_compute_arguments_create( & model_compute_handle, model_compute_arguments_create_handle, ierr) bind(c) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_create_handle_type), intent(inout) :: & model_compute_arguments_create_handle integer(c_int), intent(out) :: ierr integer(c_int) :: ierr2 ! avoid unsed dummy argument warnings if (model_compute_handle == KIM_MODEL_COMPUTE_NULL_HANDLE) continue ierr = 0 ierr2 = 0 ! register arguments call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 call kim_set_argument_support_status( & model_compute_arguments_create_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ierr = ierr + ierr2 ! call kim_set_argument_support_status( & ! model_compute_arguments_create_handle, & ! KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, & ! KIM_SUPPORT_STATUS_OPTIONAL, ierr2) ! ierr = ierr + ierr2 ! register call backs ! NONE if (ierr /= 0) then ierr = 1 call kim_log_entry( & model_compute_arguments_create_handle, & KIM_LOG_VERBOSITY_ERROR, & "Unable to successfully create compute_arguments object") end if return end subroutine model_compute_arguments_create !----------------------------------------------------------------------------- ! ! Model compute arguments destroy routine (REQUIRED) ! !----------------------------------------------------------------------------- recursive subroutine model_compute_arguments_destroy( & model_compute_handle, model_compute_arguments_destroy_handle, ierr) bind(c) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_model_compute_arguments_destroy_handle_type), intent(inout) :: & model_compute_arguments_destroy_handle integer(c_int), intent(out) :: ierr ! avoid unsed dummy argument warnings if (model_compute_handle == KIM_MODEL_COMPUTE_NULL_HANDLE) continue if (model_compute_arguments_destroy_handle == & KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_NULL_HANDLE) continue ierr = 0 return end subroutine model_compute_arguments_destroy end module ex_model_Ar_SLJ_MultiCutoff !------------------------------------------------------------------------------- ! ! Model create routine (REQUIRED) ! !------------------------------------------------------------------------------- recursive subroutine model_create_routine( & model_create_handle, requested_length_unit, requested_energy_unit, & requested_charge_unit, requested_temperature_unit, requested_time_unit, & ierr) bind(c) use, intrinsic :: iso_c_binding use ex_model_Ar_SLJ_MultiCutoff use kim_model_headers_module implicit none !-- Transferred variables type(kim_model_create_handle_type), intent(inout) :: model_create_handle type(kim_length_unit_type), intent(in), value :: requested_length_unit type(kim_energy_unit_type), intent(in), value :: requested_energy_unit type(kim_charge_unit_type), intent(in), value :: requested_charge_unit type(kim_temperature_unit_type), intent(in), value :: & requested_temperature_unit type(kim_time_unit_type), intent(in), value :: requested_time_unit integer(c_int), intent(out) :: ierr !-- KIM variables integer(c_int) :: ierr2 type(buffer_type), pointer :: buf ierr = 0 ierr2 = 0 ! avoid unsed dummy argument warnings if (requested_length_unit == KIM_LENGTH_UNIT_UNUSED) continue if (requested_energy_unit == KIM_ENERGY_UNIT_UNUSED) continue if (requested_charge_unit == KIM_CHARGE_UNIT_UNUSED) continue if (requested_temperature_unit == KIM_TEMPERATURE_UNIT_UNUSED) continue if (requested_time_unit == KIM_TIME_UNIT_UNUSED) continue ! set units call kim_set_units(model_create_handle, & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_UNUSED, & KIM_TEMPERATURE_UNIT_UNUSED, & KIM_TIME_UNIT_UNUSED, & ierr2) ierr = ierr + ierr2 ! register species call kim_set_species_code(model_create_handle, & KIM_SPECIES_NAME_AR, speccode, ierr2) ierr = ierr + ierr2 ! register numbering call kim_set_model_numbering(model_create_handle, & KIM_NUMBERING_ONE_BASED, ierr2) ierr = ierr + ierr2 ! register function pointers call kim_set_routine_pointer( & model_create_handle, & KIM_MODEL_ROUTINE_NAME_COMPUTE, KIM_LANGUAGE_NAME_FORTRAN, & 1, c_funloc(Compute_Energy_Forces), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_create_handle, & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE, & KIM_LANGUAGE_NAME_FORTRAN, & 1, c_funloc(model_compute_arguments_create), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_create_handle, & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY, & KIM_LANGUAGE_NAME_FORTRAN, & 1, c_funloc(model_compute_arguments_destroy), ierr2) ierr = ierr + ierr2 call kim_set_routine_pointer( & model_create_handle, & KIM_MODEL_ROUTINE_NAME_DESTROY, KIM_LANGUAGE_NAME_FORTRAN, 1, & c_funloc(model_destroy_func), ierr2) ierr = ierr + ierr2 ! allocate buffer allocate (buf) ! store model buffer in KIM object call kim_set_model_buffer_pointer(model_create_handle, & c_loc(buf)) ! set buffer values buf%influence_distance = model_cutoff1 + model_cutoff2 buf%cutoff(1) = model_cutoff1 buf%cutoff(2) = model_cutoff2 buf%model_will_not_request_neighbors_of_noncontributing_particles(1) = 0 buf%model_will_not_request_neighbors_of_noncontributing_particles(2) = 1 ! register influence distance call kim_set_influence_distance_pointer( & model_create_handle, buf%influence_distance) ! register cutoff call kim_set_neighbor_list_pointers( & model_create_handle, 2, buf%cutoff, & buf%model_will_not_request_neighbors_of_noncontributing_particles) if (ierr /= 0) then ierr = 1 deallocate (buf) call kim_log_entry( & model_create_handle, KIM_LOG_VERBOSITY_ERROR, & "Unable to successfully initialize model") end if return end subroutine model_create_routine kim-api-2.3.0-git/examples/simulator-models/000077500000000000000000000000001421473465500207555ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulator-models/CMakeLists.txt000066400000000000000000000022141421473465500235140ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) add_subdirectory(Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu) kim-api-2.3.0-git/examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu/000077500000000000000000000000001421473465500312475ustar00rootroot00000000000000Alchemy_PbAu.in000066400000000000000000000004661421473465500340170ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAuif "${alchemy_mapping} == Pb" then & "pair_coeff ${alchemy_curr_type} ${alchemy_curr_type} 0.8589880 2.6014200 10.4057000" & elif "${alchemy_mapping} == Au" & "pair_coeff ${alchemy_curr_type} ${alchemy_curr_type} 2.3058000 2.4232400 9.6929800" next alchemy_curr_type next alchemy_mapping jump SELF CMakeLists.txt000066400000000000000000000027661421473465500337430ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) list(APPEND CMAKE_PREFIX_PATH $ENV{KIM_API_CMAKE_PREFIX_DIR}) find_package(KIM-API-ITEMS 2.2 REQUIRED CONFIG) kim_api_items_setup_before_project(ITEM_TYPE "simulatorModel") project(Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu) kim_api_items_setup_after_project(ITEM_TYPE "simulatorModel") add_kim_api_model_library( NAME "${PROJECT_NAME}" SM_SPEC_FILE "smspec.edn" PARAMETER_FILES "Alchemy_PbAu.in" ) LICENSE.LGPL000066400000000000000000000636421421473465500327450ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kimcite-Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu.bib000066400000000000000000000021551421473465500435660ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu@Misc{akerson:elliott:2019, author = {Andrew Akerson and Ryan S. Elliott}, title = {Lennard-Jones LAMMMPS Simulator Model for alchemy simulations}, howpublished = {OpenKIM kim-api package}, keywords = {OpenKIM, Simulator Model}, publisher = {OpenKIM}, year = 2019, note = {{O}nline; accessed: 2019-07-03} } @Article{tadmor:elliott:2011, author = {E. B. Tadmor and R. S. Elliott and J. P. Sethna and R. E. Miller and C. A. Becker}, title = {The potential of atomistic simulations and the {K}nowledgebase of {I}nteratomic {M}odels}, journal = {{JOM}}, year = {2011}, volume = {63}, number = {7}, pages = {17}, doi = {10.1007/s11837-011-0102-6}, } @Misc{elliott:tadmor:2011, author = {Ryan S. Elliott and Ellad B. Tadmor}, title = {{K}nowledgebase of {I}nteratomic {M}odels ({KIM}) Application Programming Interface ({API})}, howpublished = {\url{https://openkim.org/kim-api}}, publisher = {OpenKIM}, year = 2011, doi = {10.25950/ff8f563a}, note = {{O}nline; accessed: 2019-07-03} } kim-api-2.3.0-git/examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu/smspec.edn000066400000000000000000000007631421473465500332370ustar00rootroot00000000000000{ "kim-api-sm-schema-version" 1 "model-name" "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu" "simulator-name" "LAMMPS" "simulator-version" "12 Dec 2018" "supported-species" "Pb Au" "units" "metal" "model-defn" [ "pair_style lj/cut 10.4057000" "variable alchemy_mapping index @@" "variable alchemy_curr_type loop 10000" "include @@" "pair_modify mix arithmetic" ] } kim-api-2.3.0-git/examples/simulators/000077500000000000000000000000001421473465500176575ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/CMakeLists.txt000066400000000000000000000103561421473465500224240ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) set(_test_models LennardJones612_UniversalShifted__MO_959249795837_003 LennardJones_Ar ex_model_Ar_P_LJ ex_model_Ar_P_MLJ_Fortran ex_model_Ar_P_Morse ex_model_Ar_P_Morse_07C ex_model_Ar_P_Morse_07C_w_Extensions ex_model_Ar_P_Morse_MultiCutoff ex_model_Ar_SLJ_MultiCutoff ) set(_testing_dir "${PROJECT_BINARY_DIR}/Testing") function(_add_simulator_model_tests _simulator_name _test_models _test_models_fail_list) foreach(_model IN LISTS _test_models) set(_test_name "Run_${_simulator_name}_${_model}") set(_test_dir "${_testing_dir}/${_test_name}") file(MAKE_DIRECTORY "${_test_dir}") add_kim_api_test(NAME "${_test_name}" COMMAND sh -c "echo ${_model} | $ > stdout" WORKING_DIRECTORY "${_test_dir}" ) set_property(TEST ${_test_name} APPEND PROPERTY ENVIRONMENT "${KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR}=${PROJECT_BINARY_DIR}/examples/model-drivers" "${KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR}=${PROJECT_BINARY_DIR}/examples/portable-models" "${KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR}=${PROJECT_BINARY_DIR}/examples/simulator-models" ) if("${_model}" IN_LIST _test_models_fail_list) set_tests_properties("${_test_name}" PROPERTIES WILL_FAIL TRUE) endif() endforeach() endfunction(_add_simulator_model_tests) function(_add_simulator_tests _simulator_dir _simulator_name) set(_test_name "Run_${_simulator_name}") set(_test_dir "${_testing_dir}/${_test_name}") file(MAKE_DIRECTORY "${_test_dir}") add_kim_api_test(NAME "${_test_name}" COMMAND sh -c "$ > stdout" WORKING_DIRECTORY "${_test_dir}" ) set_property(TEST ${_test_name} APPEND PROPERTY ENVIRONMENT "${KIM_API_ENVIRONMENT_MODEL_DRIVER_PLURAL_DIR}=${PROJECT_BINARY_DIR}/examples/model-drivers" "${KIM_API_ENVIRONMENT_PORTABLE_MODEL_PLURAL_DIR}=${PROJECT_BINARY_DIR}/examples/portable-models" "${KIM_API_ENVIRONMENT_SIMULATOR_MODEL_PLURAL_DIR}=${PROJECT_BINARY_DIR}/examples/simulator-models" ) endfunction(_add_simulator_tests) add_subdirectory(collections-example) _add_simulator_tests(collections-example collections-example) _add_simulator_tests(collections-example collections-example-c) _add_simulator_tests(collections-example collections-example-fortran) add_subdirectory(ex_test_Ar_fcc_cluster) _add_simulator_model_tests(ex_test_Ar_fcc_cluster "${_test_models}" "ex_model_Ar_P_Morse_MultiCutoff;ex_model_Ar_SLJ_MultiCutoff") add_subdirectory(ex_test_Ar_fcc_cluster_cpp) _add_simulator_model_tests(ex_test_Ar_fcc_cluster_cpp "${_test_models}" "ex_model_Ar_P_Morse_MultiCutoff;ex_model_Ar_SLJ_MultiCutoff") add_subdirectory(ex_test_Ar_fcc_cluster_fortran) _add_simulator_model_tests(ex_test_Ar_fcc_cluster_fortran "${_test_models}" "ex_model_Ar_P_Morse_MultiCutoff;ex_model_Ar_SLJ_MultiCutoff") add_subdirectory(simulator-model-example simulator-model-example) _add_simulator_tests(simulator-model-example simulator-model-example) _add_simulator_tests(simulator-model-example simulator-model-example-c) _add_simulator_tests(simulator-model-example simulator-model-example-fortran) add_subdirectory(utility_forces_numer_deriv) kim-api-2.3.0-git/examples/simulators/collections-example/000077500000000000000000000000001421473465500236265ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/collections-example/CMakeLists.txt000066400000000000000000000030361421473465500263700ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) project(collections-example VERSION 1.0.0 LANGUAGES CXX Fortran) find_package(KIM-API 2.2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp) target_link_libraries(${PROJECT_NAME} KIM-API::kim-api) add_executable(${PROJECT_NAME}-c ${PROJECT_NAME}-c.cpp) target_link_libraries(${PROJECT_NAME}-c KIM-API::kim-api) add_executable(${PROJECT_NAME}-fortran ${PROJECT_NAME}-fortran.f90) target_link_libraries(${PROJECT_NAME}-fortran KIM-API::kim-api) kim-api-2.3.0-git/examples/simulators/collections-example/collections-example-c.cpp000066400000000000000000000231371421473465500305270ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // extern "C" { #include "KIM_Collection.h" #include "KIM_CollectionItemType.h" #include "KIM_Collections.h" } #include void dirsForCollection(KIM_Collection const collection, KIM_Collections * const col) { int extent = 0; { KIM_Collections_CacheListOfDirectoryNames( col, collection, KIM_COLLECTION_ITEM_TYPE_modelDriver, &extent); std::cout << KIM_Collection_ToString(collection) << ":" << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_modelDriver) << " :\n"; for (int i = 0; i < extent; ++i) { char const * dir; KIM_Collections_GetDirectoryName(col, i, &dir); std::cout << "\t" << dir << std::endl; } extent = 0; KIM_Collections_CacheListOfDirectoryNames( col, collection, KIM_COLLECTION_ITEM_TYPE_portableModel, &extent); std::cout << KIM_Collection_ToString(collection) << ":" << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_portableModel) << " :\n"; for (int i = 0; i < extent; ++i) { char const * dir; KIM_Collections_GetDirectoryName(col, i, &dir); std::cout << "\t" << dir << std::endl; } extent = 0; KIM_Collections_CacheListOfDirectoryNames( col, collection, KIM_COLLECTION_ITEM_TYPE_simulatorModel, &extent); std::cout << KIM_Collection_ToString(collection) << ":" << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_simulatorModel) << " :\n"; for (int i = 0; i < extent; ++i) { char const * dir; KIM_Collections_GetDirectoryName(col, i, &dir); std::cout << "\t" << dir << std::endl; } } } void namesForCollection(KIM_Collection kc, KIM_Collections * const col) { int extent; KIM_Collections_CacheListOfItemNamesByCollectionAndType( col, kc, KIM_COLLECTION_ITEM_TYPE_modelDriver, &extent); std::cout << KIM_Collection_ToString(kc) << ":" << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_modelDriver) << " :\n"; for (int i = 0; i < extent; ++i) { char const * name; KIM_Collections_GetItemNameByCollectionAndType(col, i, &name); std::cout << "\t" << name << std::endl; } KIM_Collections_CacheListOfItemNamesByCollectionAndType( col, kc, KIM_COLLECTION_ITEM_TYPE_portableModel, &extent); std::cout << KIM_Collection_ToString(kc) << ":" << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_portableModel) << " :\n"; for (int i = 0; i < extent; ++i) { char const * name; KIM_Collections_GetItemNameByCollectionAndType(col, i, &name); std::cout << "\t" << name << std::endl; } KIM_Collections_CacheListOfItemNamesByCollectionAndType( col, kc, KIM_COLLECTION_ITEM_TYPE_simulatorModel, &extent); std::cout << KIM_Collection_ToString(kc) << ":" << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_simulatorModel) << " :\n"; for (int i = 0; i < extent; ++i) { char const * name; KIM_Collections_GetItemNameByCollectionAndType(col, i, &name); std::cout << "\t" << name << std::endl; } } int main() { KIM_Collections * col; int error = KIM_Collections_Create(&col); if (error) { std::cerr << "Unable to create collections object." << std::endl; return 1; } { char const * project; char const * semVer; KIM_Collections_GetProjectNameAndSemVer(col, &project, &semVer); std::cout << "Project : " << project << std::endl; std::cout << "semVer : " << semVer << std::endl; std::cout << std::endl; } { char const * name; KIM_Collections_GetEnvironmentVariableName( col, KIM_COLLECTION_ITEM_TYPE_modelDriver, &name); std::cout << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_modelDriver) << " env name : " << name << std::endl; std::cout << std::endl; } { char const * name; KIM_Collections_GetEnvironmentVariableName( col, KIM_COLLECTION_ITEM_TYPE_portableModel, &name); std::cout << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_portableModel) << " env name : " << name << std::endl; std::cout << std::endl; } { char const * name; KIM_Collections_GetEnvironmentVariableName( col, KIM_COLLECTION_ITEM_TYPE_simulatorModel, &name); std::cout << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_simulatorModel) << " env name : " << name << std::endl; std::cout << std::endl; } { char const * name; char const * value; KIM_Collections_GetConfigurationFileEnvironmentVariable(col, &name, &value); std::cout << "config file env name : " << name << std::endl << "config file env value: " << value << std::endl; std::cout << std::endl; } { char const * fileName; KIM_Collections_GetConfigurationFileName(col, &fileName); std::cout << "config file name : " << fileName << std::endl; std::cout << std::endl; } { dirsForCollection(KIM_COLLECTION_system, col); dirsForCollection(KIM_COLLECTION_user, col); dirsForCollection(KIM_COLLECTION_environmentVariable, col); dirsForCollection(KIM_COLLECTION_currentWorkingDirectory, col); std::cout << std::endl; } { namesForCollection(KIM_COLLECTION_system, col); namesForCollection(KIM_COLLECTION_user, col); namesForCollection(KIM_COLLECTION_environmentVariable, col); namesForCollection(KIM_COLLECTION_currentWorkingDirectory, col); std::cout << std::endl; } { int extent; KIM_Collections_CacheListOfItemNamesByType( col, KIM_COLLECTION_ITEM_TYPE_modelDriver, &extent); std::cout << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_modelDriver) << " :\n"; for (int i = 0; i < extent; ++i) { char const * name; KIM_Collections_GetItemNameByType(col, i, &name); std::cout << "\t" << name << std::endl; } KIM_Collections_CacheListOfItemNamesByType( col, KIM_COLLECTION_ITEM_TYPE_portableModel, &extent); std::cout << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_portableModel) << " :\n"; for (int i = 0; i < extent; ++i) { char const * name; KIM_Collections_GetItemNameByType(col, i, &name); std::cout << "\t" << name << std::endl; } KIM_Collections_CacheListOfItemNamesByType( col, KIM_COLLECTION_ITEM_TYPE_simulatorModel, &extent); std::cout << KIM_CollectionItemType_ToString( KIM_COLLECTION_ITEM_TYPE_simulatorModel) << " :\n"; for (int i = 0; i < extent; ++i) { char const * name; KIM_Collections_GetItemNameByType(col, i, &name); std::cout << "\t" << name << std::endl; } } { char const * fileName; KIM_Collection collection; int error = KIM_Collections_GetItemLibraryFileNameAndCollection( col, KIM_COLLECTION_ITEM_TYPE_simulatorModel, "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", &fileName, &collection); if (!error) std::cout << "Simulator Model Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu" << " has library name '" << fileName << "' and is part of the '" << KIM_Collection_ToString(collection) << "' collection." << std::endl; else std::cout << "Error from GetItemLibraryFileNameAndCollection." << std::endl; } { int extent; int error = KIM_Collections_CacheListOfItemMetadataFiles( col, KIM_COLLECTION_ITEM_TYPE_simulatorModel, "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", &extent); if (error) std::cout << "Error from CacheListOfItemMetadataFiles." << std::endl; else { char const * fileName; unsigned int fileLength; unsigned char const * fileRawData; int availableAsString; char const * fileString; for (int i = 0; i < extent; ++i) { KIM_Collections_GetItemMetadataFile(col, i, &fileName, &fileLength, &fileRawData, &availableAsString, &fileString); std::cout << "Metadata File " << i << ", " << fileName << ", is of length " << fileLength << std::endl << fileString << std::endl; } } } KIM_Collections_Destroy(&col); return 0; } kim-api-2.3.0-git/examples/simulators/collections-example/collections-example-fortran.f90000066400000000000000000000240411421473465500315670ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! module error use, intrinsic :: iso_c_binding implicit none public contains recursive subroutine my_error(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Error : ", trim(message) stop 1 end subroutine my_error end module error module utilities implicit none public contains subroutine dirs_for_collection(collection, col) use, intrinsic :: iso_c_binding use kim_collections_module use kim_collection_module use kim_collection_item_type_module implicit none type(kim_collection_type), intent(in) :: collection type(kim_collections_handle_type), intent(inout) :: col integer(c_int) ierr integer(c_int) i integer(c_int) extent character(len=2048, kind=c_char) coll_str character(len=2048, kind=c_char) item_type_str character(len=2048, kind=c_char) dir_str call kim_cache_list_of_directory_names( & col, collection, KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER, extent, ierr) call kim_to_string(collection, coll_str) call kim_to_string(KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER, item_type_str) print '(A,":",A," :")', trim(coll_str), trim(item_type_str) do i = 1, extent call kim_get_directory_name(col, i, dir_str, ierr) print '(A,A)', achar(9), trim(dir_str) end do call kim_cache_list_of_directory_names( & col, collection, KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL, extent, ierr) call kim_to_string(collection, coll_str) call kim_to_string(KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL, item_type_str) print '(A,":",A," :")', trim(coll_str), trim(item_type_str) do i = 1, extent call kim_get_directory_name(col, i, dir_str, ierr) print '(A,A)', achar(9), trim(dir_str) end do call kim_cache_list_of_directory_names( & col, collection, KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL, extent, ierr) call kim_to_string(collection, coll_str) call kim_to_string(KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL, item_type_str) print '(A,":",A," :")', trim(coll_str), trim(item_type_str) do i = 1, extent call kim_get_directory_name(col, i, dir_str, ierr) print '(A,A)', achar(9), trim(dir_str) end do end subroutine dirs_for_collection subroutine names_for_collection(kc, col) use, intrinsic :: iso_c_binding use kim_collections_module use kim_collection_module use kim_collection_item_type_module implicit none type(kim_collection_type), intent(in) :: kc type(kim_collections_handle_type), intent(inout) :: col integer(c_int) ierr integer(c_int) i integer(c_int) extent character(len=2048, kind=c_char) coll_str character(len=2048, kind=c_char) item_type_str character(len=2048, kind=c_char) name_str call kim_cache_list_of_item_names_by_collection_and_type( & col, kc, KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER, extent, ierr) call kim_to_string(kc, coll_str) call kim_to_string(KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER, item_type_str) print '(A,":",A," :")', trim(coll_str), trim(item_type_str) do i = 1, extent call kim_get_item_name_by_collection_and_type(col, i, name_str, ierr) print '(A,A)', achar(9), trim(name_str) end do call kim_cache_list_of_item_names_by_collection_and_type( & col, kc, KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL, extent, ierr) call kim_to_string(kc, coll_str) call kim_to_string(KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL, item_type_str) print '(A,":",A," :")', trim(coll_str), trim(item_type_str) do i = 1, extent call kim_get_item_name_by_collection_and_type(col, i, name_str, ierr) print '(A,A)', achar(9), trim(name_str) end do call kim_cache_list_of_item_names_by_collection_and_type( & col, kc, KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL, extent, ierr) call kim_to_string(kc, coll_str) call kim_to_string(KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL, item_type_str) print '(A,":",A," :")', trim(coll_str), trim(item_type_str) do i = 1, extent call kim_get_item_name_by_collection_and_type(col, i, name_str, ierr) print '(A,A)', achar(9), trim(name_str) end do end subroutine names_for_collection end module utilities !------------------------------------------------------------------------------- ! ! Main program ! !------------------------------------------------------------------------------- program collections_example_fortran use, intrinsic :: iso_c_binding use error use utilities use kim_collection_module use kim_collection_item_type_module use kim_collections_module implicit none integer(c_int) :: ierr integer(c_int) :: extent integer(c_int) :: i type(kim_collections_handle_type) :: col type(kim_collection_type) col_t type(kim_collection_item_type_type) it character(len=2048, kind=c_char) project_name character(len=2048, kind=c_char) sem_ver character(len=2048, kind=c_char) name character(len=2048, kind=c_char) value character(len=2048, kind=c_char) file_name integer(c_long) file_length integer(c_int) available_as_string integer(c_signed_char) file_raw_data(10000) character(len=10000, kind=c_char) file_string character(len=2048, kind=c_char) item_type_str call kim_collections_create(col, ierr) if (ierr /= 0) then call my_error("Unable to create collections object.") end if call kim_get_project_name_and_sem_ver(col, project_name, sem_ver) print *, "Project : ", trim(project_name) print *, "semVer : ", trim(sem_ver) print *, "" it = KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER call kim_get_environment_variable_name(col, it, name, ierr) call kim_to_string(it, item_type_str) print '(A," env name : ",A)', trim(item_type_str), trim(name) print *, "" it = KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL call kim_get_environment_variable_name(col, it, name, ierr) call kim_to_string(it, item_type_str) print '(A," env name : ",A)', trim(item_type_str), trim(name) print *, "" it = KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL call kim_get_environment_variable_name(col, it, name, ierr) call kim_to_string(it, item_type_str) print '(A," env name : ",A)', trim(item_type_str), trim(name) print *, "" call kim_get_configuration_file_environment_variable(col, name, value) print '("config file env name : ",A)', trim(name) print '("config file env value : ",A)', trim(value) print *, "" call kim_get_configuration_file_name(col, file_name) print '("config file name : ",A)', trim(file_name) print *, "" call dirs_for_collection(KIM_COLLECTION_SYSTEM, col) call dirs_for_collection(KIM_COLLECTION_USER, col) call dirs_for_collection(KIM_COLLECTION_ENVIRONMENT_VARIABLE, col) call dirs_for_collection(KIM_COLLECTION_CURRENT_WORKING_DIRECTORY, col) print *, "" call names_for_collection(KIM_COLLECTION_SYSTEM, col) call names_for_collection(KIM_COLLECTION_USER, col) call names_for_collection(KIM_COLLECTION_ENVIRONMENT_VARIABLE, col) call names_for_collection(KIM_COLLECTION_CURRENT_WORKING_DIRECTORY, col) print *, "" it = KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER call kim_cache_list_of_item_names_by_type(col, it, extent, ierr) call kim_to_string(it, item_type_str) print '(A," :")', trim(item_type_str) do i = 1, extent call kim_get_item_name_by_type(col, i, name, ierr) print '(A,A)', achar(9), trim(name) end do it = KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL call kim_cache_list_of_item_names_by_type(col, it, extent, ierr) call kim_to_string(it, item_type_str) print '(A," :")', trim(item_type_str) do i = 1, extent call kim_get_item_name_by_type(col, i, name, ierr) print '(A,A)', achar(9), trim(name) end do it = KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL call kim_cache_list_of_item_names_by_type(col, it, extent, ierr) call kim_to_string(it, item_type_str) print '(A," :")', trim(item_type_str) do i = 1, extent call kim_get_item_name_by_type(col, i, name, ierr) print '(A,A)', achar(9), trim(name) end do call kim_get_item_library_file_name_and_collection( & col, it, trim("Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu"), name, & col_t, ierr) if (ierr /= 0) then print '(A)', "Error from GetItemLibraryFileNameAndCollection" else call kim_to_string(col_t, value) print '(A,A,A,A,A,A)', & "Simulator Model Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu ", & "has library name '", trim(name), "' and is part of the '", & trim(value), "' collection." end if call kim_cache_list_of_item_metadata_files( & col, it, trim("Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu"), extent, ierr) if (ierr /= 0) then print '(A)', "Error from CacheListOfItemMetadataFiles" else do i = 1, extent call kim_get_item_metadata_file_length(col, i, file_length, & available_as_string, ierr) call kim_get_item_metadata_file_values(col, i, file_name, & file_raw_data, file_string, ierr) print '(A,I2,A,A,A,I6)', "Metadata File ", i, ", ", trim(file_name), & ", is of length", file_length print '(A)', trim(file_string) end do end if call kim_collections_destroy(col) end program collections_example_fortran kim-api-2.3.0-git/examples/simulators/collections-example/collections-example.cpp000066400000000000000000000203761421473465500303110ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #include "KIM_Collection.hpp" #include "KIM_CollectionItemType.hpp" #include "KIM_Collections.hpp" #include #include void dirsForCollection(KIM::Collection const collection, KIM::Collections * const col) { int extent = 0; { using namespace KIM::COLLECTION_ITEM_TYPE; col->CacheListOfDirectoryNames(collection, modelDriver, &extent); std::cout << collection.ToString() << ":" << modelDriver.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * dir; col->GetDirectoryName(i, &dir); std::cout << "\t" << *dir << std::endl; } extent = 0; col->CacheListOfDirectoryNames(collection, portableModel, &extent); std::cout << collection.ToString() << ":" << portableModel.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * dir; col->GetDirectoryName(i, &dir); std::cout << "\t" << *dir << std::endl; } extent = 0; col->CacheListOfDirectoryNames(collection, simulatorModel, &extent); std::cout << collection.ToString() << ":" << simulatorModel.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * dir; col->GetDirectoryName(i, &dir); std::cout << "\t" << *dir << std::endl; } } } void namesForCollection(KIM::Collection kc, KIM::Collections * const col) { using namespace KIM::COLLECTION_ITEM_TYPE; int extent; col->CacheListOfItemNamesByCollectionAndType(kc, modelDriver, &extent); std::cout << kc.ToString() << ":" << modelDriver.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * name; col->GetItemNameByCollectionAndType(i, &name); std::cout << "\t" << *name << std::endl; } col->CacheListOfItemNamesByCollectionAndType(kc, portableModel, &extent); std::cout << kc.ToString() << ":" << portableModel.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * name; col->GetItemNameByCollectionAndType(i, &name); std::cout << "\t" << *name << std::endl; } col->CacheListOfItemNamesByCollectionAndType(kc, simulatorModel, &extent); std::cout << kc.ToString() << ":" << simulatorModel.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * name; col->GetItemNameByCollectionAndType(i, &name); std::cout << "\t" << *name << std::endl; } } int main() { KIM::Collections * col; int error = KIM::Collections::Create(&col); if (error) { std::cerr << "Unable to create collections object." << std::endl; return 1; } { std::string const * project; std::string const * semVer; col->GetProjectNameAndSemVer(&project, &semVer); std::cout << "Project : " << *project << std::endl; std::cout << "semVer : " << *semVer << std::endl; std::cout << std::endl; } { std::string const * name; col->GetEnvironmentVariableName(KIM::COLLECTION_ITEM_TYPE::modelDriver, &name); std::cout << KIM::COLLECTION_ITEM_TYPE::modelDriver.ToString() << " env name : " << *name << std::endl; std::cout << std::endl; } { std::string const * name; col->GetEnvironmentVariableName(KIM::COLLECTION_ITEM_TYPE::portableModel, &name); std::cout << KIM::COLLECTION_ITEM_TYPE::portableModel.ToString() << " env name : " << *name << std::endl; std::cout << std::endl; } { std::string const * name; col->GetEnvironmentVariableName(KIM::COLLECTION_ITEM_TYPE::simulatorModel, &name); std::cout << KIM::COLLECTION_ITEM_TYPE::simulatorModel.ToString() << " env name : " << *name << std::endl; std::cout << std::endl; } { std::string const * name; std::string const * value; col->GetConfigurationFileEnvironmentVariable(&name, &value); std::cout << "config file env name : " << *name << std::endl << "config file env value: " << *value << std::endl; std::cout << std::endl; } { std::string const * fileName; col->GetConfigurationFileName(&fileName); std::cout << "config file name : " << *fileName << std::endl; std::cout << std::endl; } { using namespace KIM::COLLECTION; dirsForCollection(KIM::COLLECTION::system, col); dirsForCollection(user, col); dirsForCollection(environmentVariable, col); dirsForCollection(currentWorkingDirectory, col); std::cout << std::endl; } { using namespace KIM::COLLECTION; namesForCollection(KIM::COLLECTION::system, col); namesForCollection(user, col); namesForCollection(environmentVariable, col); namesForCollection(currentWorkingDirectory, col); std::cout << std::endl; } { using namespace KIM::COLLECTION_ITEM_TYPE; int extent; col->CacheListOfItemNamesByType(modelDriver, &extent); std::cout << modelDriver.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * name; col->GetItemNameByType(i, &name); std::cout << "\t" << *name << std::endl; } col->CacheListOfItemNamesByType(portableModel, &extent); std::cout << portableModel.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * name; col->GetItemNameByType(i, &name); std::cout << "\t" << *name << std::endl; } col->CacheListOfItemNamesByType(simulatorModel, &extent); std::cout << simulatorModel.ToString() << " :\n"; for (int i = 0; i < extent; ++i) { std::string const * name; col->GetItemNameByType(i, &name); std::cout << "\t" << *name << std::endl; } } { std::string const * fileName; KIM::Collection collection; int error = col->GetItemLibraryFileNameAndCollection( KIM::COLLECTION_ITEM_TYPE::simulatorModel, "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", &fileName, &collection); if (!error) std::cout << "Simulator Model Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu" << " has library name '" << *fileName << "' and is part of the '" << collection.ToString() << "' collection." << std::endl; else std::cout << "Error from GetItemLibraryFileNameAndCollection." << std::endl; } { int extent; int error = col->CacheListOfItemMetadataFiles( KIM::COLLECTION_ITEM_TYPE::simulatorModel, "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", &extent); if (error) std::cout << "Error from CacheListOfItemMetadataFiles." << std::endl; else { std::string const * fileName; unsigned int fileLength; unsigned char const * fileRawData; int availableAsString; std::string const * fileString; for (int i = 0; i < extent; ++i) { col->GetItemMetadataFile(i, &fileName, &fileLength, &fileRawData, &availableAsString, &fileString); std::cout << "Metadata File " << i << ", " << *fileName << ", is of length " << fileLength << std::endl << *fileString << std::endl; } } } KIM::Collections::Destroy(&col); return 0; } kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster/000077500000000000000000000000001421473465500243305ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster/CMakeLists.txt000066400000000000000000000024701421473465500270730ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) project(ex_test_Ar_fcc_cluster VERSION 1.0.0 LANGUAGES C) find_package(KIM-API 2.2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) target_link_libraries(${PROJECT_NAME} KIM-API::kim-api m) kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster/ex_test_Ar_fcc_cluster.c000066400000000000000000000445211421473465500311530ustar00rootroot00000000000000/* * KIM-API: An API for interatomic models * Copyright (c) 2013--2022, Regents of the University of Minnesota. * All rights reserved. * * Contributors: * Ryan S. Elliott * Stephen M. Whalen * * SPDX-License-Identifier: LGPL-2.1-or-later * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "KIM_SimulatorHeaders.h" #include #include #include #define TRUE 1 #define FALSE 0 #define NAMESTRLEN 128 #define NAMESTRFMT "%127s" #define FCCSPACING 5.260 #define DIM 3 #define NCELLSPERSIDE 2 #define NCLUSTERPARTS \ (4 * (NCELLSPERSIDE * NCELLSPERSIDE * NCELLSPERSIDE) \ + 6 * (NCELLSPERSIDE * NCELLSPERSIDE) + 3 * (NCELLSPERSIDE) + 1) #define MY_ERROR(message) \ { \ printf("* Error : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \ exit(1); \ } #define MY_WARNING(message) \ { \ printf("* WARNING : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \ } /* Define neighborlist structure */ typedef struct { double cutoff; int numberOfParticles; int * NNeighbors; int * neighborList; } NeighList; /* Define prototypes */ void fcc_cluster_neighborlist(int half, int numberOfParticles, double * coords, double cutoff, NeighList * nl); int get_cluster_neigh(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle); void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double * coords); /* Main program */ int main() { /* Local variable declarations */ double const MinSpacing = 0.8 * FCCSPACING; double const MaxSpacing = 1.2 * FCCSPACING; double const SpacingIncr = 0.025 * FCCSPACING; double CurrentSpacing; double cutpad = 0.75; /* Angstroms */ double force_norm; int i; int error; /* KIM variable declarations */ KIM_Model * model; /* model inputs */ int numberOfParticles_cluster = NCLUSTERPARTS; int speciesIsSupported; int particleSpecies_cluster_model[NCLUSTERPARTS]; int particleContributing_cluster_model[NCLUSTERPARTS]; double coords_cluster[NCLUSTERPARTS][DIM]; NeighList nl_cluster_model; /* model outputs */ int number_of_neighbor_lists_cluster_model; double influence_distance_cluster_model; double const * cutoff_cluster_model; double energy_cluster_model = 0.0; double forces_cluster[NCLUSTERPARTS * DIM]; char modelname[NAMESTRLEN]; int requestedUnitsAccepted; int numberOfModelRoutineNames; KIM_ModelRoutineName modelRoutineName; int present; int required; int modelArCode; int numberOfComputeArgumentNames; KIM_ComputeArguments * computeArguments; KIM_ComputeArgumentName computeArgumentName; KIM_SupportStatus supportStatus; int numberOfComputeCallbackNames; KIM_ComputeCallbackName computeCallbackName; /* Get KIM Model names */ printf("Please enter valid KIM Model name: \n"); error = scanf(NAMESTRFMT, modelname); if (1 != error) { MY_ERROR("Unable to read model name"); } /* initialize the model */ error = KIM_Model_Create(KIM_NUMBERING_zeroBased, KIM_LENGTH_UNIT_A, KIM_ENERGY_UNIT_eV, KIM_CHARGE_UNIT_e, KIM_TEMPERATURE_UNIT_K, KIM_TIME_UNIT_ps, modelname, &requestedUnitsAccepted, &model); if (error) MY_ERROR("KIM_create_model_interface()"); /* Check for compatibility with the model */ if (!requestedUnitsAccepted) MY_ERROR("Must adapt to model units"); /* Check that we know about all required routines */ KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames( &numberOfModelRoutineNames); for (i = 0; i < numberOfModelRoutineNames; ++i) { KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(i, &modelRoutineName); error = KIM_Model_IsRoutinePresent( model, modelRoutineName, &present, &required); if (error) { MY_ERROR("Unable to get ModelRoutineName."); } if ((present == TRUE) && (required == TRUE)) { if (!(KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Create) || KIM_ModelRoutineName_Equal( modelRoutineName, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate) || KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Compute) || KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Refresh) || KIM_ModelRoutineName_Equal( modelRoutineName, KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy) || KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Destroy))) { MY_ERROR("Unknown required ModelRoutineName found."); } } } /* check species */ error = KIM_Model_GetSpeciesSupportAndCode( model, KIM_SPECIES_NAME_Ar, &speciesIsSupported, &modelArCode); if ((error) || (!speciesIsSupported)) { MY_ERROR("Species Ar not supported"); } error = KIM_Model_ComputeArgumentsCreate(model, &computeArguments); if (error) { MY_ERROR("KIM_Model_ComputeArgumentsCreate"); } /* check arguments */ KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames( &numberOfComputeArgumentNames); for (i = 0; i < numberOfComputeArgumentNames; ++i) { error = KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName( i, &computeArgumentName); if (error) MY_ERROR("can't get argument name"); error = KIM_ComputeArguments_GetArgumentSupportStatus( computeArguments, computeArgumentName, &supportStatus); if (error) MY_ERROR("can't get argument supportStatus"); /* can only handle energy and force as a required arg */ if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required)) { if ((KIM_ComputeArgumentName_NotEqual( computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy)) && (KIM_ComputeArgumentName_NotEqual( computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces))) { MY_ERROR("unsupported required argument"); } } /* must have energy and forces */ if ((KIM_ComputeArgumentName_Equal(computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy)) || (KIM_ComputeArgumentName_Equal( computeArgumentName, KIM_COMPUTE_ARGUMENT_NAME_partialForces))) { if (!((KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required)) || (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_optional)))) { MY_ERROR("energy or forces not available"); } } } /* check call backs */ KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames( &numberOfComputeCallbackNames); for (i = 0; i < numberOfComputeCallbackNames; ++i) { error = KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName( i, &computeCallbackName); if (error) MY_ERROR("can't get call back name"); error = KIM_ComputeArguments_GetCallbackSupportStatus( computeArguments, computeCallbackName, &supportStatus); if (error) MY_ERROR("can't get call back supportStatus"); /* cannot handle any "required" call backs */ if (KIM_SupportStatus_Equal(supportStatus, KIM_SUPPORT_STATUS_required)) { MY_ERROR("unsupported required call back"); } } /* We're compatible with the model. Let's do it. */ error = KIM_ComputeArguments_SetArgumentPointerInteger( computeArguments, KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles, &numberOfParticles_cluster) || KIM_ComputeArguments_SetArgumentPointerInteger( computeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes, particleSpecies_cluster_model) || KIM_ComputeArguments_SetArgumentPointerInteger( computeArguments, KIM_COMPUTE_ARGUMENT_NAME_particleContributing, particleContributing_cluster_model) || KIM_ComputeArguments_SetArgumentPointerDouble( computeArguments, KIM_COMPUTE_ARGUMENT_NAME_coordinates, (double *) &coords_cluster) || KIM_ComputeArguments_SetArgumentPointerDouble( computeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialEnergy, &energy_cluster_model) || KIM_ComputeArguments_SetArgumentPointerDouble( computeArguments, KIM_COMPUTE_ARGUMENT_NAME_partialForces, (double *) &forces_cluster); if (error) MY_ERROR("KIM_setm_data"); KIM_ComputeArguments_SetCallbackPointer( computeArguments, KIM_COMPUTE_CALLBACK_NAME_GetNeighborList, KIM_LANGUAGE_NAME_c, (KIM_Function *) &get_cluster_neigh, &nl_cluster_model); KIM_Model_GetInfluenceDistance(model, &influence_distance_cluster_model); KIM_Model_GetNeighborListPointers(model, &number_of_neighbor_lists_cluster_model, &cutoff_cluster_model, NULL); /* ignoring hint */ if (number_of_neighbor_lists_cluster_model != 1) MY_ERROR("too many neighbor lists"); /* setup particleSpecies */ error = KIM_Model_GetSpeciesSupportAndCode(model, KIM_SPECIES_NAME_Ar, &speciesIsSupported, &(particleSpecies_cluster_model[0])); if (error) MY_ERROR("KIM_get_species_code"); for (i = 1; i < NCLUSTERPARTS; ++i) particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0]; /* setup particleContributing */ for (i = 0; i < NCLUSTERPARTS; ++i) { particleContributing_cluster_model[i] = 1; /* all particles contribute */ } /* setup neighbor lists */ /* allocate memory for list */ nl_cluster_model.numberOfParticles = NCLUSTERPARTS; nl_cluster_model.NNeighbors = (int *) malloc(NCLUSTERPARTS * sizeof(int)); if (NULL == nl_cluster_model.NNeighbors) MY_ERROR("malloc unsuccessful"); nl_cluster_model.neighborList = (int *) malloc(NCLUSTERPARTS * NCLUSTERPARTS * sizeof(int)); if (NULL == nl_cluster_model.neighborList) MY_ERROR("malloc unsuccessful"); /* ready to compute */ printf("This is Test : ex_test_Ar_fcc_cluster\n"); printf("---------------------------------------------------------------------" "-----------\n"); printf("Results for KIM Model : %s\n", modelname); printf("%20s, %20s, %20s\n", "Energy", "Force Norm", "Lattice Spacing"); for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr) { /* update coordinates for cluster */ create_FCC_cluster(CurrentSpacing, NCELLSPERSIDE, &(coords_cluster[0][0])); /* compute neighbor lists */ fcc_cluster_neighborlist(0, NCLUSTERPARTS, &(coords_cluster[0][0]), (*cutoff_cluster_model + cutpad), &nl_cluster_model); /* call compute functions */ error = KIM_Model_Compute(model, computeArguments); if (error) MY_ERROR("KIM_model_compute"); /* compute force norm */ force_norm = 0.0; for (i = 0; i < DIM * numberOfParticles_cluster; ++i) { force_norm += forces_cluster[i] * forces_cluster[i]; } force_norm = sqrt(force_norm); /* print the results */ printf("%20.10e, %20.10e, %20.10e\n", energy_cluster_model, force_norm, CurrentSpacing); } error = KIM_Model_ComputeArgumentsDestroy(model, &computeArguments); if (error) { MY_ERROR("Unable to destroy compute arguments"); } /* free memory of neighbor lists */ free(nl_cluster_model.NNeighbors); free(nl_cluster_model.neighborList); /* free pkim objects */ KIM_Model_Destroy(&model); /* everything is great */ return 0; } void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double * coords) { /* local variables */ double FCCshifts[4][DIM]; double latVec[DIM]; int a; int i; int j; int k; int m; int n; /* create a cubic FCC cluster of parts */ FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0; FCCshifts[1][0] = 0.5 * FCCspacing; FCCshifts[1][1] = 0.5 * FCCspacing; FCCshifts[1][2] = 0.0; FCCshifts[2][0] = 0.5 * FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5 * FCCspacing; FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5 * FCCspacing; FCCshifts[3][2] = 0.5 * FCCspacing; a = 0; for (i = 0; i < nCellsPerSide; ++i) { latVec[0] = ((double) i) * FCCspacing; for (j = 0; j < nCellsPerSide; ++j) { latVec[1] = ((double) j) * FCCspacing; for (k = 0; k < nCellsPerSide; ++k) { latVec[2] = ((double) k) * FCCspacing; for (m = 0; m < 4; ++m) { for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[m][n]; } a++; } } /* add in the remaining three faces */ /* pos-x face */ latVec[0] = NCELLSPERSIDE * FCCspacing; latVec[1] = ((double) i) * FCCspacing; latVec[2] = ((double) j) * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[3][n]; } a++; /* pos-y face */ latVec[0] = ((double) i) * FCCspacing; latVec[1] = NCELLSPERSIDE * FCCspacing; latVec[2] = ((double) j) * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[2][n]; } a++; /* pos-z face */ latVec[0] = ((double) i) * FCCspacing; latVec[1] = ((double) j) * FCCspacing; latVec[2] = NCELLSPERSIDE * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[1][n]; } a++; } /* add in the remaining three edges */ latVec[0] = ((double) i) * FCCspacing; latVec[1] = NCELLSPERSIDE * FCCspacing; latVec[2] = NCELLSPERSIDE * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; latVec[0] = NCELLSPERSIDE * FCCspacing; latVec[1] = ((double) i) * FCCspacing; latVec[2] = NCELLSPERSIDE * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; latVec[0] = NCELLSPERSIDE * FCCspacing; latVec[1] = NCELLSPERSIDE * FCCspacing; latVec[2] = ((double) i) * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; } /* add in the remaining corner */ for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = NCELLSPERSIDE * FCCspacing; } a++; return; } void fcc_cluster_neighborlist(int half, int numberOfParticles, double * coords, double cutoff, NeighList * nl) { /* local variables */ int i; int j; int k; int a; double dx[DIM]; double r2; double cutoff2; nl->cutoff = cutoff; cutoff2 = cutoff * cutoff; for (i = 0; i < numberOfParticles; ++i) { a = 0; for (j = 0; j < numberOfParticles; ++j) { r2 = 0.0; for (k = 0; k < DIM; ++k) { dx[k] = coords[j * DIM + k] - coords[i * DIM + k]; r2 += dx[k] * dx[k]; } if (r2 < cutoff2) { if ((half && i < j) || (!half && i != j)) { /* part j is a neighbor of part i */ (*nl).neighborList[i * NCLUSTERPARTS + a] = j; a++; } } } /* part i has `a' neighbors */ (*nl).NNeighbors[i] = a; } return; } int get_cluster_neigh(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) { /* local variables */ int error = TRUE; NeighList * nl = (NeighList *) dataObject; int numberOfParticles = nl->numberOfParticles; if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->cutoff)) return error; if (neighborListIndex != 0) return error; /* initialize numNeigh */ *numberOfNeighbors = 0; if ((particleNumber >= numberOfParticles) || (particleNumber < 0)) /* invalid id */ { MY_WARNING("Invalid part ID in get_cluster_neigh"); return TRUE; } /* set the returned number of neighbors for the returned part */ *numberOfNeighbors = (*nl).NNeighbors[particleNumber]; /* set the location for the returned neighbor list */ *neighborsOfParticle = &((*nl).neighborList[(particleNumber) *numberOfParticles]); return FALSE; } kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster_cpp/000077500000000000000000000000001421473465500251725ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster_cpp/CMakeLists.txt000066400000000000000000000024761421473465500277430ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) project(ex_test_Ar_fcc_cluster_cpp VERSION 1.0.0 LANGUAGES CXX) find_package(KIM-API 2.2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp) target_link_libraries(${PROJECT_NAME} KIM-API::kim-api) kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster_cpp/ex_test_Ar_fcc_cluster_cpp.cpp000066400000000000000000000614111421473465500332140ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Stephen M. Whalen // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #include "KIM_SimulatorHeaders.hpp" #include "KIM_SupportedExtensions.hpp" #include #include #include #include #include #include #define NAMESTRLEN 128 #define FCCSPACING 5.260 #define DIM 3 #define NCELLSPERSIDE 2 #define NCLUSTERPARTS \ (4 * (NCELLSPERSIDE * NCELLSPERSIDE * NCELLSPERSIDE) \ + 6 * (NCELLSPERSIDE * NCELLSPERSIDE) + 3 * (NCELLSPERSIDE) + 1) #define MY_ERROR(message) \ { \ std::cout << "* Error : \"" << message << "\" : " << __LINE__ << ":" \ << __FILE__ << std::endl; \ exit(1); \ } #define MY_WARNING(message) \ { \ std::cout << "* Warning : \"" << message << "\" : " << __LINE__ << ":" \ << __FILE__ << std::endl; \ } /* Define neighborlist structure */ typedef struct { double cutoff; int numberOfParticles; int * NNeighbors; int * neighborList; } NeighList; /* Define prototypes */ void fcc_cluster_neighborlist(int half, int numberOfParticles, double * coords, double cutoff, NeighList * nl); int get_cluster_neigh(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle); void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double * coords); void compute_loop(double const MinSpacing, double const MaxSpacing, double const SpacingIncr, int const numberOfParticles_cluster, double * const coords_cluster, double const cutoff, NeighList * nl, KIM::Model const * const kim_cluster_model, KIM::ComputeArguments const * const computeArguments, double * const forces_cluster, double * const energy_cluster_model); /* Main program */ int main() { /* Local variable declarations */ double const MinSpacing = 0.8 * FCCSPACING; double const MaxSpacing = 1.2 * FCCSPACING; double const SpacingIncr = 0.025 * FCCSPACING; int i; int error; /* model inputs */ int numberOfParticles_cluster = NCLUSTERPARTS; int particleSpecies_cluster_model[NCLUSTERPARTS]; int particleContributing_cluster_model[NCLUSTERPARTS]; double coords_cluster[NCLUSTERPARTS][DIM]; NeighList nl_cluster_model; /* model outputs */ double influence_distance_cluster_model; int number_of_neighbor_lists; double const * cutoff_cluster_model; double energy_cluster_model; double forces_cluster[NCLUSTERPARTS * DIM]; std::string modelname; /* Get KIM Model names */ printf("Please enter valid KIM Model name: \n"); std::cin >> modelname; /* initialize the model */ KIM::Model * kim_cluster_model; int requestedUnitsAccepted; error = KIM::Model::Create(KIM::NUMBERING::zeroBased, KIM::LENGTH_UNIT::A, KIM::ENERGY_UNIT::eV, KIM::CHARGE_UNIT::e, KIM::TEMPERATURE_UNIT::K, KIM::TIME_UNIT::ps, modelname, &requestedUnitsAccepted, &kim_cluster_model); if (error) { MY_ERROR("KIM::Model::Create()"); } // Check for compatibility with the model if (!requestedUnitsAccepted) { MY_ERROR("Must Adapt to model units"); } // Check that we know about all required routines int numberOfModelRoutineNames; KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames( &numberOfModelRoutineNames); for (int i = 0; i < numberOfModelRoutineNames; ++i) { KIM::ModelRoutineName modelRoutineName; int error = KIM::MODEL_ROUTINE_NAME::GetModelRoutineName(i, &modelRoutineName); if (error) { MY_ERROR("Unable to get ModelRoutineName."); } int present; int required; error = kim_cluster_model->IsRoutinePresent( modelRoutineName, &present, &required); if (error) { MY_ERROR("Unable to get routine present/required."); } std::cout << "Model routine name \"" << modelRoutineName.ToString() << "\" has present = " << present << " and required = " << required << "." << std::endl; if ((present == true) && (required == true)) { using namespace KIM::MODEL_ROUTINE_NAME; if (!((modelRoutineName == Create) || (modelRoutineName == ComputeArgumentsCreate) || (modelRoutineName == Compute) || (modelRoutineName == Refresh) || (modelRoutineName == ComputeArgumentsDestroy) || (modelRoutineName == Destroy))) { MY_ERROR("Unknown Routine \"" + modelRoutineName.ToString() + "\" is required by model."); } } } // print model units KIM::LengthUnit lengthUnit; KIM::EnergyUnit energyUnit; KIM::ChargeUnit chargeUnit; KIM::TemperatureUnit temperatureUnit; KIM::TimeUnit timeUnit; kim_cluster_model->GetUnits( &lengthUnit, &energyUnit, &chargeUnit, &temperatureUnit, &timeUnit); std::cout << "LengthUnit is \"" << lengthUnit.ToString() << "\"" << std::endl << "EnergyUnit is \"" << energyUnit.ToString() << "\"" << std::endl << "ChargeUnit is \"" << chargeUnit.ToString() << "\"" << std::endl << "TemperatureUnit is \"" << temperatureUnit.ToString() << "\"" << std::endl << "TimeUnit is \"" << timeUnit.ToString() << "\"" << std::endl; // check species int speciesIsSupported; int modelArCode; error = kim_cluster_model->GetSpeciesSupportAndCode( KIM::SPECIES_NAME::Ar, &speciesIsSupported, &modelArCode); if ((error) || (!speciesIsSupported)) { MY_ERROR("Species Ar not supported"); } KIM::ComputeArguments * computeArguments; error = kim_cluster_model->ComputeArgumentsCreate(&computeArguments); if (error) { MY_ERROR("Unable to create a ComputeArguments object."); } // check compute arguments int numberOfComputeArgumentNames; KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames( &numberOfComputeArgumentNames); for (int i = 0; i < numberOfComputeArgumentNames; ++i) { KIM::ComputeArgumentName computeArgumentName; KIM::SupportStatus supportStatus; KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName(i, &computeArgumentName); KIM::DataType dataType; KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType(computeArgumentName, &dataType); error = computeArguments->GetArgumentSupportStatus(computeArgumentName, &supportStatus); if (error) MY_ERROR("unable to get ComputeArgument SupportStatus"); std::cout << "ComputeArgument Name \"" << computeArgumentName.ToString() << "\"" << " is of type \"" << dataType.ToString() << "\"" << " and has supportStatus \"" << supportStatus.ToString() << "\"" << std::endl; // can only handle energy and force as a required arg if (supportStatus == KIM::SUPPORT_STATUS::required) { if ((computeArgumentName != KIM::COMPUTE_ARGUMENT_NAME::partialEnergy) && (computeArgumentName != KIM::COMPUTE_ARGUMENT_NAME::partialForces)) { MY_ERROR("unsupported required ComputeArgument"); } } // must have energy and forces if ((computeArgumentName == KIM::COMPUTE_ARGUMENT_NAME::partialEnergy) || (computeArgumentName == KIM::COMPUTE_ARGUMENT_NAME::partialForces)) { if (!((supportStatus == KIM::SUPPORT_STATUS::required) || (supportStatus == KIM::SUPPORT_STATUS::optional))) { MY_ERROR("energy or forces not available"); } } } // check compute callbacks int numberOfComputeCallbackNames; KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames( &numberOfComputeCallbackNames); for (int i = 0; i < numberOfComputeCallbackNames; ++i) { KIM::ComputeCallbackName computeCallbackName; KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName(i, &computeCallbackName); KIM::SupportStatus supportStatus; computeArguments->GetCallbackSupportStatus(computeCallbackName, &supportStatus); std::cout << "ComputeCallback Name \"" << computeCallbackName.ToString() << "\"" << " has supportStatus \"" << supportStatus.ToString() << "\"" << std::endl; // cannot handle any "required" callbacks if (supportStatus == KIM::SUPPORT_STATUS::required) { MY_ERROR("unsupported required ComputeCallback"); } } int numberOfParameters; kim_cluster_model->GetNumberOfParameters(&numberOfParameters); for (int i = 0; i < numberOfParameters; ++i) { KIM::DataType dataType; std::string const * strName; std::string const * strDesc; int extent; kim_cluster_model->GetParameterMetadata( i, &dataType, &extent, &strName, &strDesc); std::cout << "Parameter No. " << i << " has" << std::endl << " data type : \"" << dataType.ToString() << "\"" << std::endl << " extent : " << extent << std::endl << " name : " << *strName << std::endl << " description : " << *strDesc << std::endl; } // Check supported extensions, if any int present; error = kim_cluster_model->IsRoutinePresent( KIM::MODEL_ROUTINE_NAME::Extension, &present, NULL); if (error) { MY_ERROR("Unable to get Extension present/required."); } if (present) { KIM::SupportedExtensions supportedExtensions; error = kim_cluster_model->Extension(KIM_SUPPORTED_EXTENSIONS_ID, &supportedExtensions); if (error) { MY_ERROR("Error returned from KIM::Model::Extension()."); } std::cout << "Model Supports " << supportedExtensions.numberOfSupportedExtensions << " Extensions:" << std::endl; for (int i = 0; i < supportedExtensions.numberOfSupportedExtensions; ++i) { std::cout << " spportedExtensionID[" << std::setw(2) << i << "] = \"" << supportedExtensions.supportedExtensionID[i] << "\" " << "which has required = " << supportedExtensions.supportedExtensionRequired[i] << "." << std::endl; } } // We're compatible with the model. Let's do it. error = computeArguments->SetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles, (int *) &numberOfParticles_cluster) || computeArguments->SetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes, particleSpecies_cluster_model) || computeArguments->SetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::particleContributing, particleContributing_cluster_model) || computeArguments->SetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::coordinates, (double *) coords_cluster) || computeArguments->SetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, &energy_cluster_model) || computeArguments->SetArgumentPointer( KIM::COMPUTE_ARGUMENT_NAME::partialForces, (double *) forces_cluster); if (error) MY_ERROR("KIM_API_set_data"); error = computeArguments->SetCallbackPointer( KIM::COMPUTE_CALLBACK_NAME::GetNeighborList, KIM::LANGUAGE_NAME::cpp, (KIM::Function *) &get_cluster_neigh, &nl_cluster_model); if (error) MY_ERROR("set_call_back"); kim_cluster_model->GetInfluenceDistance(&influence_distance_cluster_model); int const * modelWillNotRequestNeighborsOfNoncontributingParticles; kim_cluster_model->GetNeighborListPointers( &number_of_neighbor_lists, &cutoff_cluster_model, &modelWillNotRequestNeighborsOfNoncontributingParticles); std::cout << "Model has influence distance of : " << influence_distance_cluster_model << std::endl; std::cout << "Model has numberOfNeighborLists : " << number_of_neighbor_lists << std::endl; for (int i = 0; i < number_of_neighbor_lists; ++i) { std::cout << "\t" << "Neighbor list " << i << " has cutoff " << cutoff_cluster_model[i] << " with " "modelWillNotRequestNeighborsOfNoncontributingParticles " << modelWillNotRequestNeighborsOfNoncontributingParticles[i] << std::endl; } // ignoring hints from here on... if (number_of_neighbor_lists != 1) MY_ERROR("too many neighbor lists"); /* setup particleSpecies */ int isSpeciesSupported; error = kim_cluster_model->GetSpeciesSupportAndCode( KIM::SPECIES_NAME::Ar, &isSpeciesSupported, &(particleSpecies_cluster_model[0])); if (error) MY_ERROR("get_species_code"); for (i = 1; i < NCLUSTERPARTS; ++i) particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0]; /* setup particleContributing */ for (i = 0; i < NCLUSTERPARTS; ++i) particleContributing_cluster_model[i] = 1; /* every particle contributes */ /* setup neighbor lists */ /* allocate memory for list */ nl_cluster_model.numberOfParticles = NCLUSTERPARTS; nl_cluster_model.NNeighbors = new int[NCLUSTERPARTS]; if (NULL == nl_cluster_model.NNeighbors) MY_ERROR("new unsuccessful"); nl_cluster_model.neighborList = new int[NCLUSTERPARTS * NCLUSTERPARTS]; if (NULL == nl_cluster_model.neighborList) MY_ERROR("new unsuccessful"); /* ready to compute */ std::ios oldState(NULL); oldState.copyfmt(std::cout); std::cout << std::setiosflags(std::ios::scientific) << std::setprecision(10); std::cout << "This is Test : ex_test_Ar_fcc_cluster_cpp\n"; std::cout << "---------------------------------------------------------------" "-----------------\n"; std::cout << "Results for KIM Model : " << modelname << std::endl; compute_loop(MinSpacing, MaxSpacing, SpacingIncr, numberOfParticles_cluster, &(coords_cluster[0][0]), *cutoff_cluster_model, &nl_cluster_model, kim_cluster_model, computeArguments, forces_cluster, &energy_cluster_model); if (numberOfParameters > 0) { int index = numberOfParameters / 2; KIM::DataType dataType; std::string const * name; double value; error = kim_cluster_model->GetParameterMetadata( index, &dataType, NULL, &name, NULL); if (error) { MY_ERROR("Cannot get parameter metadata."); } if (dataType != KIM::DATA_TYPE::Double) { MY_WARNING("Can't change an integer."); } else { error = kim_cluster_model->GetParameter(index, 0, &value); if (error) { MY_ERROR("Cannot get parameter value."); } value *= 1.5; error = kim_cluster_model->SetParameter(index, 0, value); if (error) { MY_ERROR("Cannot set parameter value."); } error = kim_cluster_model->ClearThenRefresh(); if (error) { MY_ERROR("Model ClearThenRefresh returned error."); } std::cout << std::endl << "Updated parameter \"" << *name << "\" to value " << value << "." << std::endl; kim_cluster_model->GetInfluenceDistance( &influence_distance_cluster_model); kim_cluster_model->GetNeighborListPointers( &number_of_neighbor_lists, &cutoff_cluster_model, &modelWillNotRequestNeighborsOfNoncontributingParticles); compute_loop(MinSpacing, MaxSpacing, SpacingIncr, numberOfParticles_cluster, &(coords_cluster[0][0]), *cutoff_cluster_model, &nl_cluster_model, kim_cluster_model, computeArguments, forces_cluster, &energy_cluster_model); } int present; kim_cluster_model->IsRoutinePresent( KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel, &present, NULL); if (present == true) { error = kim_cluster_model->WriteParameterizedModel( ".", "This_IsTheNewModelName"); if (error) { MY_ERROR("WriteParameterizedModel returned an error."); } } } /* call compute arguments destroy */ error = kim_cluster_model->ComputeArgumentsDestroy(&computeArguments); if (error) { MY_ERROR("Unable to destroy compute arguments"); } /* call model destroy */ KIM::Model::Destroy(&kim_cluster_model); /* free memory of neighbor lists */ delete[] nl_cluster_model.NNeighbors; delete[] nl_cluster_model.neighborList; /* everything is great */ std::cout.copyfmt(oldState); return 0; } void compute_loop(double const MinSpacing, double const MaxSpacing, double const SpacingIncr, int const numberOfParticles_cluster, double * const coords_cluster, double const cutoff, NeighList * nl, KIM::Model const * const kim_cluster_model, KIM::ComputeArguments const * const computeArguments, double * const forces_cluster, double * const energy_cluster_model) { double const cutpad = 0.75; /* Angstroms */ std::cout << std::setw(20) << "Energy" << std::setw(20) << "Force Norm" << std::setw(20) << "Lattice Spacing" << std::endl; for (double CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr) { /* update coordinates for cluster */ create_FCC_cluster(CurrentSpacing, NCELLSPERSIDE, coords_cluster); /* compute neighbor lists */ fcc_cluster_neighborlist( 0, NCLUSTERPARTS, coords_cluster, (cutoff + cutpad), nl); /* call compute functions */ int error = kim_cluster_model->Compute(computeArguments); if (error) MY_ERROR("compute"); /* compute force norm */ double force_norm = 0.0; for (int i = 0; i < DIM * numberOfParticles_cluster; ++i) { force_norm += forces_cluster[i] * forces_cluster[i]; } force_norm = sqrt(force_norm); /* print the results */ std::cout << std::setw(20) << *energy_cluster_model << std::setw(20) << force_norm << std::setw(20) << CurrentSpacing << std::endl; } } void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double * coords) { /* local variables */ double FCCshifts[4][DIM]; double latVec[DIM]; int a; int i; int j; int k; int m; int n; /* create a cubic FCC cluster of parts */ FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0; FCCshifts[1][0] = 0.5 * FCCspacing; FCCshifts[1][1] = 0.5 * FCCspacing; FCCshifts[1][2] = 0.0; FCCshifts[2][0] = 0.5 * FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5 * FCCspacing; FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5 * FCCspacing; FCCshifts[3][2] = 0.5 * FCCspacing; a = 0; for (i = 0; i < nCellsPerSide; ++i) { latVec[0] = ((double) i) * FCCspacing; for (j = 0; j < nCellsPerSide; ++j) { latVec[1] = ((double) j) * FCCspacing; for (k = 0; k < nCellsPerSide; ++k) { latVec[2] = ((double) k) * FCCspacing; for (m = 0; m < 4; ++m) { for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[m][n]; } a++; } } /* add in the remaining three faces */ /* pos-x face */ latVec[0] = NCELLSPERSIDE * FCCspacing; latVec[1] = ((double) i) * FCCspacing; latVec[2] = ((double) j) * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[3][n]; } a++; /* pos-y face */ latVec[0] = ((double) i) * FCCspacing; latVec[1] = NCELLSPERSIDE * FCCspacing; latVec[2] = ((double) j) * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[2][n]; } a++; /* pos-z face */ latVec[0] = ((double) i) * FCCspacing; latVec[1] = ((double) j) * FCCspacing; latVec[2] = NCELLSPERSIDE * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n] + FCCshifts[1][n]; } a++; } /* add in the remaining three edges */ latVec[0] = ((double) i) * FCCspacing; latVec[1] = NCELLSPERSIDE * FCCspacing; latVec[2] = NCELLSPERSIDE * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; latVec[0] = NCELLSPERSIDE * FCCspacing; latVec[1] = ((double) i) * FCCspacing; latVec[2] = NCELLSPERSIDE * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; latVec[0] = NCELLSPERSIDE * FCCspacing; latVec[1] = NCELLSPERSIDE * FCCspacing; latVec[2] = ((double) i) * FCCspacing; for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = latVec[n]; } a++; } /* add in the remaining corner */ for (n = 0; n < DIM; ++n) { coords[a * DIM + n] = NCELLSPERSIDE * FCCspacing; } a++; return; } void fcc_cluster_neighborlist(int half, int numberOfParticles, double * coords, double cutoff, NeighList * nl) { /* local variables */ int i; int j; int k; int a; double dx[DIM]; double r2; double cutoff2; nl->cutoff = cutoff; cutoff2 = cutoff * cutoff; for (i = 0; i < numberOfParticles; ++i) { a = 0; for (j = 0; j < numberOfParticles; ++j) { r2 = 0.0; for (k = 0; k < DIM; ++k) { dx[k] = coords[j * DIM + k] - coords[i * DIM + k]; r2 += dx[k] * dx[k]; } if (r2 < cutoff2) { if ((half && i < j) || (!half && i != j)) { /* part j is a neighbor of part i */ (*nl).neighborList[i * NCLUSTERPARTS + a] = j; a++; } } } /* part i has `a' neighbors */ (*nl).NNeighbors[i] = a; } return; } int get_cluster_neigh(void * const dataObject, int const numberOfNeighborLists, double const * const cutoffs, int const neighborListIndex, int const particleNumber, int * const numberOfNeighbors, int const ** const neighborsOfParticle) { /* local variables */ int error = true; NeighList * nl = (NeighList *) dataObject; int numberOfParticles = nl->numberOfParticles; if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->cutoff)) return error; if (neighborListIndex != 0) return error; /* initialize numNeigh */ *numberOfNeighbors = 0; if ((particleNumber >= numberOfParticles) || (particleNumber < 0)) /* invalid id */ { MY_WARNING("Invalid part ID in get_cluster_neigh"); return true; } /* set the returned number of neighbors for the returned part */ *numberOfNeighbors = (*nl).NNeighbors[particleNumber]; /* set the location for the returned neighbor list */ *neighborsOfParticle = &((*nl).neighborList[(particleNumber) *numberOfParticles]); return false; } kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster_fortran/000077500000000000000000000000001421473465500260635ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster_fortran/CMakeLists.txt000066400000000000000000000025061421473465500306260ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) project(ex_test_Ar_fcc_cluster_fortran VERSION 1.0.0 LANGUAGES Fortran) find_package(KIM-API 2.2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} ${PROJECT_NAME}.f90) target_link_libraries(${PROJECT_NAME} KIM-API::kim-api) ex_test_Ar_fcc_cluster_fortran.f90000066400000000000000000000500671421473465500345400ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/ex_test_Ar_fcc_cluster_fortran! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ellad B. Tadmor ! Ryan S. Elliott ! Stephen M. Whalen ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! module error use, intrinsic :: iso_c_binding implicit none public contains recursive subroutine my_error(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Error : ", trim(message) stop 1 end subroutine my_error recursive subroutine my_warning(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Warning : ", trim(message) end subroutine my_warning end module error !------------------------------------------------------------------------------- ! ! module mod_neighborlist : ! ! Module contains type and routines related to neighbor list calculation ! !------------------------------------------------------------------------------- module mod_neighborlist use, intrinsic :: iso_c_binding public get_neigh type, bind(c) :: neighObject_type real(c_double) :: cutoff integer(c_int) :: number_of_particles type(c_ptr) :: neighbor_list_pointer end type neighObject_type contains !----------------------------------------------------------------------------- ! ! get_neigh neighbor list access function ! ! This function implements Locator and Iterator mode ! !----------------------------------------------------------------------------- recursive subroutine get_neigh(data_object, number_of_neighbor_lists, & cutoffs, neighbor_list_index, request, & numnei, pnei1part, ierr) bind(c) use error implicit none !-- Transferred variables type(c_ptr), value, intent(in) :: data_object integer(c_int), value, intent(in) :: number_of_neighbor_lists real(c_double), intent(in) :: cutoffs(*) integer(c_int), value, intent(in) :: neighbor_list_index integer(c_int), value, intent(in) :: request integer(c_int), intent(out) :: numnei type(c_ptr), intent(out) :: pnei1part integer(c_int), intent(out) :: ierr !-- Local variables integer(c_int) numberOfParticles type(neighObject_type), pointer :: neighObject integer(c_int), pointer :: neighborList(:, :) call c_f_pointer(data_object, neighObject) numberOfParticles = neighObject%number_of_particles call c_f_pointer(neighObject%neighbor_list_pointer, neighborList, & [numberOfParticles + 1, numberOfParticles]) if (number_of_neighbor_lists /= 1) then call my_warning("invalid number of cutoffs") ierr = 1 return end if if (cutoffs(1) > neighObject%cutoff) then call my_warning("neighbor list cutoff too small for model cutoff") ierr = 1 return end if if (neighbor_list_index /= 1) then call my_warning("wrong list index") ierr = 1 return end if if ((request > numberOfParticles) .or. (request < 1)) then print *, request call my_warning("Invalid part ID in get_neigh") ierr = 1 return end if ! set the returned number of neighbors for the returned part numnei = neighborList(1, request) ! set the location for the returned neighbor list pnei1part = c_loc(neighborList(2, request)) ierr = 0 return end subroutine get_neigh end module mod_neighborlist module mod_utility implicit none public contains !----------------------------------------------------------------------------- ! ! NEIGH_PURE_cluster_neighborlist ! !----------------------------------------------------------------------------- recursive subroutine NEIGH_PURE_cluster_neighborlist( & half, numberOfParticles, coords, cutoff, neighObject) use, intrinsic :: iso_c_binding use mod_neighborlist implicit none !-- Transferred variables logical, intent(in) :: half integer(c_int), intent(in) :: numberOfParticles real(c_double), dimension(3, numberOfParticles), & intent(in) :: coords real(c_double), intent(in) :: cutoff type(neighObject_type), intent(inout) :: neighObject !-- Local variables integer(c_int) i, j, a real(c_double) dx(3) real(c_double) r2 real(c_double) cutoff2 integer(c_int), pointer :: neighborList(:, :) call c_f_pointer(neighObject%neighbor_list_pointer, neighborList, & [numberOfParticles + 1, numberOfParticles]) neighObject%cutoff = cutoff cutoff2 = cutoff**2 do i = 1, numberOfParticles a = 1 do j = 1, numberOfParticles dx(:) = coords(:, j) - coords(:, i) r2 = dot_product(dx, dx) if (r2 <= cutoff2) then ! part j is a neighbor of part i if ((j > i) .OR. ((.not. half) .AND. (i /= j))) then a = a + 1 neighborList(a, i) = j end if end if end do ! part i has a-1 neighbors neighborList(1, i) = a - 1 end do return end subroutine NEIGH_PURE_cluster_neighborlist !----------------------------------------------------------------------------- ! ! create_FCC_configuration subroutine ! ! creates a cubic configuration of FCC particles with lattice spacing ! `FCCspacing' and `nCellsPerSide' cells along each direction. ! ! With periodic==.true. this will result in a total number of particles equal ! to 4*(nCellsPerSide)**3 + 6*(nCellsPerSide)**2 + 3*(nCellsPerSide) + 1 ! ! With periodic==.false. this will result in a total number of particles equal ! to 4*(nCellsPerSide)**3 ! ! Returns the Id of the particle situated in the middle of the configuration ! (this particle will have the most neighbors.) ! !----------------------------------------------------------------------------- recursive subroutine create_FCC_configuration(FCCspacing, nCellsPerSide, & periodic, coords, MiddlePartId) use, intrinsic :: iso_c_binding implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants !-- Transferred variables real(c_double), intent(in) :: FCCspacing integer(c_int), intent(in) :: nCellsPerSide logical, intent(in) :: periodic real(c_double), intent(out) :: coords(3, *) integer(c_int), intent(out) :: MiddlePartId ! ! cluster setup variables ! real(c_double) FCCshifts(3, 4) real(c_double) latVec(3) integer(c_int) a, i, j, k, m ! Create a cubic FCC cluster ! FCCshifts(1, 1) = 0.0_cd FCCshifts(2, 1) = 0.0_cd FCCshifts(3, 1) = 0.0_cd FCCshifts(1, 2) = 0.5_cd * FCCspacing FCCshifts(2, 2) = 0.5_cd * FCCspacing FCCshifts(3, 2) = 0.0_cd FCCshifts(1, 3) = 0.5_cd * FCCspacing FCCshifts(2, 3) = 0.0_cd FCCshifts(3, 3) = 0.5_cd * FCCspacing FCCshifts(1, 4) = 0.0_cd FCCshifts(2, 4) = 0.5_cd * FCCspacing FCCshifts(3, 4) = 0.5_cd * FCCspacing MiddlePartID = 1 ! Always put middle particle as #1 a = 1 ! leave space for middle particle as particle #1 do i = 1, nCellsPerSide latVec(1) = (i - 1) * FCCspacing do j = 1, nCellsPerSide latVec(2) = (j - 1) * FCCspacing do k = 1, nCellsPerSide latVec(3) = (k - 1) * FCCspacing do m = 1, 4 a = a + 1 coords(:, a) = latVec + FCCshifts(:, m) if ((i == nCellsPerside / 2 + 1) & .and. (j == nCellsPerSide / 2 + 1) & .and. (k == nCellsPerSide / 2 + 1) & .and. (m == 1)) & then ! put middle particle as #1 coords(:, 1) = latVec + FCCshifts(:, m) a = a - 1 end if end do end do if (.not. periodic) then ! Add in the remaining three faces ! pos-x face latVec(1) = nCellsPerSide * FCCspacing latVec(2) = (i - 1) * FCCspacing latVec(3) = (j - 1) * FCCspacing a = a + 1; coords(:, a) = latVec a = a + 1; coords(:, a) = latVec + FCCshifts(:, 4) ! pos-y face latVec(1) = (i - 1) * FCCspacing latVec(2) = nCellsPerSide * FCCspacing latVec(3) = (j - 1) * FCCspacing a = a + 1; coords(:, a) = latVec a = a + 1; coords(:, a) = latVec + FCCshifts(:, 3) ! pos-z face latVec(1) = (i - 1) * FCCspacing latVec(2) = (j - 1) * FCCspacing latVec(3) = nCellsPerSide * FCCspacing a = a + 1; coords(:, a) = latVec a = a + 1; coords(:, a) = latVec + FCCshifts(:, 2) end if end do if (.not. periodic) then ! Add in the remaining three edges latVec(1) = (i - 1) * FCCspacing latVec(2) = nCellsPerSide * FCCspacing latVec(3) = nCellsPerSide * FCCspacing a = a + 1; coords(:, a) = latVec latVec(1) = nCellsPerSide * FCCspacing latVec(2) = (i - 1) * FCCspacing latVec(3) = nCellsPerSide * FCCspacing a = a + 1; coords(:, a) = latVec latVec(1) = nCellsPerSide * FCCspacing latVec(2) = nCellsPerSide * FCCspacing latVec(3) = (i - 1) * FCCspacing a = a + 1; coords(:, a) = latVec end if end do if (.not. periodic) then ! Add in the remaining corner a = a + 1; coords(:, a) = nCellsPerSide * FCCspacing end if return end subroutine create_FCC_configuration end module mod_utility !******************************************************************************* !** !** PROGRAM vc_forces_numer_deriv !** !** KIM compliant program to perform numerical derivative check on a model !** !******************************************************************************* !------------------------------------------------------------------------------- ! ! Main program ! !------------------------------------------------------------------------------- program ex_test_ar_fcc_cluster_fortran use, intrinsic :: iso_c_binding use error use kim_simulator_headers_module use kim_supported_extensions_module use mod_neighborlist use mod_utility implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants integer(c_int), parameter :: nCellsPerSide = 2 integer(c_int), parameter :: DIM = 3 real(c_double), parameter :: cutpad = 0.75_cd real(c_double), parameter :: FCCspacing = 5.260_cd real(c_double), parameter :: min_spacing = 0.8 * FCCspacing real(c_double), parameter :: max_spacing = 1.2 * FCCspacing real(c_double), parameter :: spacing_incr = 0.025 * FCCspacing real(c_double) :: current_spacing real(c_double) :: force_norm character(len=256, kind=c_char) :: modelname integer(c_int), parameter :: N = 4 * (nCellsPerSide)**3 & + 6 * (nCellsPerSide)**2 & + 3 * (nCellsPerSide) + 1 type(neighObject_type), target :: neighObject integer(c_int), allocatable, target :: neighborList(:, :) type(kim_model_handle_type) :: model_handle type(kim_compute_arguments_handle_type) :: compute_arguments_handle real(c_double) :: influence_distance integer(c_int) :: number_of_neighbor_lists real(c_double) :: cutoff real(c_double) :: cutoffs(1) integer(c_int) :: & model_will_not_request_neighbors_of_noncontributing_particles(1) integer(c_int), target :: particle_species_codes(N) integer(c_int), target :: particle_contributing(N) real(c_double), target :: energy real(c_double), target :: coords(DIM, N) real(c_double), target :: forces(DIM, N) integer(c_int) i, j, ierr, ierr2 integer(c_int) species_is_supported integer(c_int) species_code integer(c_int) requested_units_accepted integer(c_int) number_of_model_routine_names type(kim_model_routine_name_type) model_routine_name integer(c_int) present integer(c_int) required type(kim_supported_extensions_type), target :: supported_extensions character(len=KIM_MAX_EXTENSION_ID_LENGTH, kind=c_char) :: id_string integer :: middledum ! Initialize ierr = 0 supported_extensions%number_of_supported_extensions = 0 ! Get KIM Model name to use print '("Please enter a valid KIM model name: ")' read (*, *) modelname ! Create empty KIM object ! call kim_model_create(KIM_NUMBERING_ONE_BASED, & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_E, & KIM_TEMPERATURE_UNIT_K, & KIM_TIME_UNIT_PS, & trim(modelname), & requested_units_accepted, & model_handle, ierr) if (ierr /= 0) then call my_error("kim_api_create") end if ! check that we are compatible if (requested_units_accepted == 0) then call my_error("Must adapt to model units") end if ! check that we know about all required routines call kim_get_number_of_model_routine_names(number_of_model_routine_names) do i = 1, number_of_model_routine_names call kim_get_model_routine_name(i, model_routine_name, ierr) if (ierr /= 0) then call my_error("kim_get_model_routine_name") end if call kim_is_routine_present(model_handle, model_routine_name, present, & required, ierr) if (ierr /= 0) then call my_error("kim_is_routine_present") end if if ((present == 1) .and. (required == 1)) then if (.not. ((model_routine_name == KIM_MODEL_ROUTINE_NAME_CREATE) & .or. (model_routine_name == & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE) & .or. (model_routine_name == KIM_MODEL_ROUTINE_NAME_COMPUTE) & .or. (model_routine_name == KIM_MODEL_ROUTINE_NAME_REFRESH) & .or. (model_routine_name == & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY) & .or. (model_routine_name == KIM_MODEL_ROUTINE_NAME_DESTROY))) & then call my_error("Unknown required ModelRoutineName found.") end if end if end do ! check that model supports Ar ! call kim_get_species_support_and_code( & model_handle, KIM_SPECIES_NAME_AR, species_is_supported, species_code, ierr) if ((ierr /= 0) .or. (species_is_supported /= 1)) then call my_error("Model does not support Ar") end if ! Check supported extensions, if any call kim_is_routine_present( & model_handle, KIM_MODEL_ROUTINE_NAME_EXTENSION, present, required, ierr) if (ierr /= 0) then call my_error("Unable to get Extension present/required.") end if if (present /= 0) then call kim_extension(model_handle, KIM_SUPPORTED_EXTENSIONS_ID, & c_loc(supported_extensions), ierr) if (ierr /= 0) then call my_error("Error returned from kim_model_extension().") end if write (*, '(A,I2,A)') "Model Supports ", & supported_extensions%number_of_supported_extensions, & " Extensions:" do i = 1, supported_extensions%number_of_supported_extensions call kim_c_char_array_to_string( & supported_extensions%supported_extension_id(:, i), id_string) write (*, '(A,I2,A,A,A,A,I2)') " supportedExtensionID[", i, '] = "', & trim(id_string), '" ', & "which has required = ", & supported_extensions%supported_extension_required(i) end do end if ! Best-practice is to check that the model is compatible ! but we will skip it here ! create compute_arguments object call kim_compute_arguments_create( & model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_model_compute_arguments_create") end if ! register memory with the KIM system ierr = 0 call kim_set_argument_pointer( & compute_arguments_handle, KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, & n, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, & particle_species_codes, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, particle_contributing, & ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, coords, & ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, & energy, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & forces, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call my_error("set_argument_pointer") end if ! Allocate storage for neighbor lists ! allocate (neighborList(N + 1, N)) neighObject%neighbor_list_pointer = c_loc(neighborList) neighObject%number_of_particles = N ! Set pointer in KIM object to neighbor list routine and object ! call kim_set_callback_pointer( & compute_arguments_handle, KIM_COMPUTE_CALLBACK_NAME_GET_NEIGHBOR_LIST, & KIM_LANGUAGE_NAME_FORTRAN, c_funloc(get_neigh), c_loc(neighobject), ierr) if (ierr /= 0) then call my_error("set_callback_pointer") end if call kim_get_influence_distance(model_handle, influence_distance) call kim_get_number_of_neighbor_lists(model_handle, & number_of_neighbor_lists) if (number_of_neighbor_lists /= 1) then call my_error("too many neighbor lists") end if call kim_get_neighbor_list_values( & model_handle, cutoffs, & model_will_not_request_neighbors_of_noncontributing_particles, ierr) if (ierr /= 0) then call my_error("get_neighbor_list_values") end if cutoff = cutoffs(1) ! Setup cluster ! do i = 1, N particle_species_codes(i) = species_code end do ! setup contributing particles do i = 1, N particle_contributing(i) = 1 ! every particle contributes end do ! Print output header ! print * print *, 'This is Test : ex_test_Ar_fcc_cluster_fortran' print * print '(80(''-''))' print '("Results for KIM Model : ",A)', trim(modelname) ! print header print '(3A20)', "Energy", "Force Norm", "Lattice Spacing" ! do the computations current_spacing = min_spacing do while (current_spacing < max_spacing) call create_FCC_configuration(current_spacing, nCellsPerSide, .false., & coords, middleDum) ! Compute neighbor lists call NEIGH_PURE_cluster_neighborlist(.false., N, coords, & (cutoff + cutpad), neighObject) ! Call model compute call kim_compute(model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_api_model_compute") end if ! compue force_norm force_norm = 0.0 do i = 1, N do j = 1, DIM force_norm = force_norm + forces(j, i) * forces(j, i) end do end do force_norm = sqrt(force_norm) ! Print results to screen ! print '(3ES20.10)', energy, force_norm, current_spacing current_spacing = current_spacing + spacing_incr end do ! Deallocate neighbor list object deallocate (neighborList) call kim_compute_arguments_destroy( & model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("compute_arguments_destroy") end if call kim_model_destroy(model_handle) end program ex_test_ar_fcc_cluster_fortran kim-api-2.3.0-git/examples/simulators/simulator-model-example/000077500000000000000000000000001421473465500244255ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/simulator-model-example/CMakeLists.txt000066400000000000000000000031471421473465500271720ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) project(simulator-model-example VERSION 1.0.0 LANGUAGES CXX C Fortran) find_package(KIM-API 2.2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp) target_link_libraries(${PROJECT_NAME} KIM-API::kim-api) add_executable(${PROJECT_NAME}-c ${PROJECT_NAME}-c.cpp) target_link_libraries(${PROJECT_NAME}-c KIM-API::kim-api) add_executable(${PROJECT_NAME}-fortran ${PROJECT_NAME}-fortran.f90) target_link_libraries(${PROJECT_NAME}-fortran KIM-API::kim-api) target_compile_options(${PROJECT_NAME}-fortran PRIVATE "-std=gnu") kim-api-2.3.0-git/examples/simulators/simulator-model-example/simulator-model-example-c.cpp000066400000000000000000000114331421473465500321210ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // extern "C" { #include "KIM_SimulatorHeaders.h" } #include #include #include #include int main() { KIM_SimulatorModel * SM; int error = KIM_SimulatorModel_Create( "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", &SM); if (error) { std::cout << "Can't create SM." << std::endl; goto fail; } { char const * pSimulatorName; char const * pSimulatorVersion; KIM_SimulatorModel_GetSimulatorNameAndVersion( SM, &pSimulatorName, &pSimulatorVersion); std::cout << "Simulator name : " << pSimulatorName << std::endl << "Simulator version : " << pSimulatorVersion << std::endl << std::endl; } { int extent; KIM_SimulatorModel_GetNumberOfSupportedSpecies(SM, &extent); std::cout << "SM supports " << extent << " species:" << std::endl; for (int i = 0; i < extent; ++i) { char const * pSpecies; error = KIM_SimulatorModel_GetSupportedSpecies(SM, i, &pSpecies); if (error) { std::cout << "Unable to get species." << std::endl; goto fail; } else { std::cout << "\t" << std::setw(2) << i << " " << pSpecies << std::endl; } } std::cout << std::endl; } { error = KIM_SimulatorModel_AddTemplateMap( SM, "atom-type-sym-list", "Pb Pb Au Pb"); if (error) { std::cout << "Unable to add template map." << std::endl; goto fail; } KIM_SimulatorModel_CloseTemplateMap(SM); int numberFields; KIM_SimulatorModel_GetNumberOfSimulatorFields(SM, &numberFields); std::cout << "SM has " << std::setw(2) << numberFields << " fields :" << std::endl; for (int i = 0; i < numberFields; ++i) { int extent; char const * pFieldName; error = KIM_SimulatorModel_GetSimulatorFieldMetadata( SM, i, &extent, &pFieldName); std::cout << " Field " << std::setw(2) << i << " is " << pFieldName << " and has " << std::setw(2) << extent << " lines:" << std::endl; for (int j = 0; j < extent; ++j) { char const * pFieldLine; error = KIM_SimulatorModel_GetSimulatorFieldLine(SM, i, j, &pFieldLine); if (error) { std::cout << "Unable to get field line." << std::endl; goto fail; } else { std::cout << "\t" << pFieldLine << std::endl; } } } std::cout << std::endl; } { char const * pDirName; KIM_SimulatorModel_GetParameterFileDirectoryName(SM, &pDirName); std::cout << "SM param dir name is " << pDirName << std::endl; char const * pSpecName; KIM_SimulatorModel_GetSpecificationFileName(SM, &pSpecName); std::cout << "SM spec file name is " << pSpecName << std::endl << std::endl; error = system((std::string("cat ") + pDirName + "/" + pSpecName).c_str()); std::cout << std::endl; int numberParamFiles; KIM_SimulatorModel_GetNumberOfParameterFiles(SM, &numberParamFiles); std::cout << "SM has " << numberParamFiles << " parameter files:" << std::endl; for (int i = 0; i < numberParamFiles; ++i) { char const * pParamFileBasename; error = KIM_SimulatorModel_GetParameterFileBasename( SM, i, &pParamFileBasename); if (error) { std::cout << "Unable to get parameter file basename." << std::endl; goto fail; } else { std::cout << "Parameter file " << std::setw(2) << i << " has basename : " << pParamFileBasename << std::endl; error = system((std::string("cat ") + pDirName + "/" + pParamFileBasename) .c_str()); std::cout << std::endl; } } } KIM_SimulatorModel_Destroy(&SM); return 0; fail: KIM_SimulatorModel_Destroy(&SM); return 1; } kim-api-2.3.0-git/examples/simulators/simulator-model-example/simulator-model-example-fortran.f90000066400000000000000000000113201421473465500331610ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! module error use, intrinsic :: iso_c_binding implicit none public contains recursive subroutine my_error(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Error : ", trim(message) stop 1 end subroutine my_error recursive subroutine my_warning(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Warning : ", trim(message) end subroutine my_warning end module error !------------------------------------------------------------------------------- ! ! Main program ! !------------------------------------------------------------------------------- program collections_example_fortran use, intrinsic :: iso_c_binding use error use kim_simulator_headers_module implicit none interface integer(c_int) function c_system(cmd) bind(c, name="system") use, intrinsic :: iso_c_binding character(c_char), intent(in) :: cmd(*) end function c_system end interface integer(c_int) :: ierr integer(c_int) :: extent integer(c_int) :: no_fields integer(c_int) :: i integer(c_int) :: j type(kim_simulator_model_handle_type) :: sm character(len=2048, kind=c_char) s_name character(len=2048, kind=c_char) s_ver character(len=2048, kind=c_char) species character(len=2048, kind=c_char) field_name character(len=2048, kind=c_char) line character(len=2048, kind=c_char) dir_name character(len=2048, kind=c_char) spec_name character(len=2048, kind=c_char) param_basename call kim_simulator_model_create( & "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", sm, ierr) if (ierr /= 0) then call my_error("Can't create SM.") end if call kim_get_simulator_name_and_version(sm, s_name, s_ver) print *, "Simulator name : ", trim(s_name) print *, "Simulator version : ", trim(s_ver) print *, "" call kim_get_number_of_supported_species(sm, extent) print *, "SM supports", extent, " species:" do i = 1, extent call kim_get_supported_species(sm, i, species, ierr) if (ierr /= 0) then call my_error("Unable to get species.") else print '(A,I2," ",A)', achar(9), i, trim(species) end if end do print *, "" call kim_add_template_map(sm, "atom-type-sym-list", "Pb Pb Au Pb", ierr) if (ierr /= 0) then call my_error("Unable to add template map.") end if call kim_close_template_map(sm) call kim_get_number_of_simulator_fields(sm, no_fields) print '("SM has ",I2," fields :")', no_fields do i = 1, no_fields call kim_get_simulator_field_metadata(sm, i, extent, field_name, ierr) print '(" Field",I2," is ",A," and has ",I2," lines:")', & i, trim(field_name), extent do j = 1, extent call kim_get_simulator_field_line(sm, i, j, line, ierr) if (ierr /= 0) then call my_error("Unable to get field line.") else print '(A,A)', achar(9), trim(line) end if end do end do print *, "" call kim_get_parameter_file_directory_name(sm, dir_name) print '("SM param dir name is ",A)', trim(dir_name) call kim_get_specification_file_name(sm, spec_name) print '("SM spec file name is ",A)', trim(spec_name) ierr = c_system("cat "//trim(dir_name)//"/"//trim(spec_name)//c_null_char) call kim_get_number_of_parameter_files(sm, extent) print '("SM has ",I1," parameter files:")', extent do i = 1, extent call kim_get_parameter_file_basename(sm, i, param_basename, ierr) if (ierr /= 0) then call my_error("Unable to get parameter file basename.") else print '("Parameter file ",I2," has basename ",A)', i, trim(param_basename) ierr = c_system( & "cat "//trim(dir_name)//"/"//trim(param_basename)//c_null_char) print *, "" end if end do call kim_simulator_model_destroy(sm) end program collections_example_fortran kim-api-2.3.0-git/examples/simulators/simulator-model-example/simulator-model-example.cpp000066400000000000000000000111571421473465500317040ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #include "KIM_SimulatorHeaders.hpp" #include #include #include #include int main() { KIM::SimulatorModel * SM; int error = KIM::SimulatorModel::Create( "Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu", &SM); if (error) { std::cout << "Can't create SM." << std::endl; return 1; } { std::string const * pSimulatorName; std::string const * pSimulatorVersion; SM->GetSimulatorNameAndVersion(&pSimulatorName, &pSimulatorVersion); std::cout << "Simulator name : " << *pSimulatorName << std::endl << "Simulator version : " << *pSimulatorVersion << std::endl << std::endl; } { int extent; SM->GetNumberOfSupportedSpecies(&extent); std::cout << "SM supports " << extent << " species:" << std::endl; for (int i = 0; i < extent; ++i) { std::string const * pSpecies; error = SM->GetSupportedSpecies(i, &pSpecies); if (error) { std::cout << "Unable to get species." << std::endl; goto fail; } else { std::cout << "\t" << std::setw(2) << i << " " << *pSpecies << std::endl; } } std::cout << std::endl; } { error = SM->AddTemplateMap("atom-type-sym-list", "Pb Pb Au Pb"); if (error) { std::cout << "Unable to add template map." << std::endl; goto fail; } SM->CloseTemplateMap(); int numberFields; SM->GetNumberOfSimulatorFields(&numberFields); std::cout << "SM has " << std::setw(2) << numberFields << " fields :" << std::endl; for (int i = 0; i < numberFields; ++i) { int extent; std::string const * pFieldName; error = SM->GetSimulatorFieldMetadata(i, &extent, &pFieldName); std::cout << " Field " << std::setw(2) << i << " is " << *pFieldName << " and has " << std::setw(2) << extent << " lines:" << std::endl; for (int j = 0; j < extent; ++j) { std::string const * pFieldLine; error = SM->GetSimulatorFieldLine(i, j, &pFieldLine); if (error) { std::cout << "Unable to get field line." << std::endl; goto fail; } else { std::cout << "\t" << *pFieldLine << std::endl; } } } std::cout << std::endl; } { std::string const * pDirName; SM->GetParameterFileDirectoryName(&pDirName); std::cout << "SM param dir name is " << *pDirName << std::endl; std::string const * pSpecName; SM->GetSpecificationFileName(&pSpecName); std::cout << "SM spec file name is " << *pSpecName << std::endl << std::endl; error = system((std::string("cat ") + *pDirName + "/" + *pSpecName).c_str()); std::cout << std::endl; int numberParamFiles; SM->GetNumberOfParameterFiles(&numberParamFiles); std::cout << "SM has " << numberParamFiles << " parameter files:" << std::endl; for (int i = 0; i < numberParamFiles; ++i) { std::string const * pParamFileBasename; error = SM->GetParameterFileBasename(i, &pParamFileBasename); if (error) { std::cout << "Unable to get parameter file basename." << std::endl; goto fail; } else { std::cout << "Parameter file " << std::setw(2) << i << " has basename : " << *pParamFileBasename << std::endl; error = system( (std::string("cat ") + *pDirName + "/" + *pParamFileBasename) .c_str()); std::cout << std::endl; } } } KIM::SimulatorModel::Destroy(&SM); return 0; // false fail: KIM::SimulatorModel::Destroy(&SM); return 1; // true } kim-api-2.3.0-git/examples/simulators/utility_forces_numer_deriv/000077500000000000000000000000001421473465500253225ustar00rootroot00000000000000kim-api-2.3.0-git/examples/simulators/utility_forces_numer_deriv/CMakeLists.txt000066400000000000000000000026171421473465500300700ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # cmake_minimum_required(VERSION 3.10) project(utility_forces_numer_deriv VERSION 1.0.0 LANGUAGES Fortran) # Enable C++ to workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20438 enable_language(CXX) find_package(KIM-API 2.2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} ${PROJECT_NAME}.f90) target_link_libraries(${PROJECT_NAME} KIM-API::kim-api) kim-api-2.3.0-git/examples/simulators/utility_forces_numer_deriv/LICENSE.LGPL000066400000000000000000000636421421473465500270770ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kim-api-2.3.0-git/examples/simulators/utility_forces_numer_deriv/README000066400000000000000000000074371421473465500262150ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Ellad B. Tadmor # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # This directory (utility_forces_numer_deriv) contains a Verification Check that compares the forces computed by a KIM-compliant Model with those obtained using numerical differentiation of the Model energies. Calling format: printf "model_name" | ./utility_forces_numer_deriv Notes: 1. It checks a single configuration: a perturbed fcc cluster made of a random arrangement of the supported species with spacing scaled by a factor based on the Model's cutoff value. 2. The code computes the DIM*N components of the force vector in two ways: directly using the Model's force calculation (`force_model') and by numerical differentiation using Ridders' method (`force_numer'). The difference between these values in absolute value is also printed (`Force diff') as well as the error predicted by Ridders' method (`pred error'). Ideally, one would expect the force difference to be less than the predicted error. If that is the case the term `ok' is printed at the end of the line. (Most potentials fail this check for most degrees of freedom, so this is not a good criterion.) In addition, the following normalized measure is computed: \alpha = 1/(DIM*N) sqrt( \sum_i w_i (f^{model}_i - f^{numer}_i)^2 / \sum_i w_i ), where w_i is the weight associated with term i: w_i = 1/\hat{\epsilon}_i, and \hat{\epsilon}_i is the normalized error in the numerical calculation: \hat{\epsilon}_i = max(\epsilon^{numer}_i, \epsilon^{prec}) / max(\force^{numer}_i, \epsilon^{prec}) The max functions impose a lower limit on computed values equal to the numerical precision of the computer (\epsilon^{prec}). \alpha has units of force and can be understood as the average error per degree of freedom. The smaller the value of \alpha the more accurate the force calculation of the Model. In the expression for \alpha each term is weighted by the relative accuracy of the numerical estimate for the derivative. Thus if f^{numer}_i is a poor estimate for the derivative (i.e. \epsilon^{numer}_i is large relative to f^{numer}_i) then term i contributes less to \alpha since it is less trustworthy. In addition to \alpha, the maximum term contributing to \alpha is identified. For this degree of freedom, the error and normalized error are printed: forcediff_i = |f^{model}_i - f^{numer}_i}| forcediff_i/|f^{model}_i| This is *not* the largest error (i.e. the largest value of forcediff_i) due to the weighting term w_i. Simply looking at the maximum value of forcediff_i could be misleading since the error in the numerical term, \epsilon^{numer}_i, may be large for the component. Instead the maximum of w_i*forcediff_i is a compromise that in some sense seeks the largest error for components where the numerical derivative are also as accurate possible. kim-api-2.3.0-git/examples/simulators/utility_forces_numer_deriv/utility_forces_numer_deriv.f90000066400000000000000000001276401421473465500333170ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ellad B. Tadmor ! Ryan S. Elliott ! Stephen M. Whalen ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! module error use, intrinsic :: iso_c_binding implicit none public contains recursive subroutine my_error(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Error : ", trim(message) stop end subroutine my_error recursive subroutine my_warning(message) implicit none character(len=*, kind=c_char), intent(in) :: message print *, "* Warning : ", trim(message) end subroutine my_warning end module error !------------------------------------------------------------------------------- ! ! module mod_neighborlist : ! ! Module contains type and routines related to neighbor list calculation ! !------------------------------------------------------------------------------- module mod_neighborlist use, intrinsic :: iso_c_binding public get_neigh type, bind(c) :: neighObject_type real(c_double) :: cutoff integer(c_int) :: number_of_particles type(c_ptr) :: neighbor_list_pointer end type neighObject_type contains !------------------------------------------------------------------------------- ! ! get_neigh neighbor list access function ! ! This function implements Locator and Iterator mode ! !------------------------------------------------------------------------------- !------------------------------------------------------------------------------- ! ! get_neigh neighbor list access function ! ! This function implements Locator and Iterator mode ! !------------------------------------------------------------------------------- recursive subroutine get_neigh(data_object, number_of_neighbor_lists, & cutoffs, neighbor_list_index, request, & numnei, pnei1part, ierr) bind(c) use error implicit none !-- Transferred variables type(c_ptr), value, intent(in) :: data_object integer(c_int), value, intent(in) :: number_of_neighbor_lists real(c_double), intent(in) :: cutoffs(*) integer(c_int), value, intent(in) :: neighbor_list_index integer(c_int), value, intent(in) :: request integer(c_int), intent(out) :: numnei type(c_ptr), intent(out) :: pnei1part integer(c_int), intent(out) :: ierr !-- Local variables integer(c_int) numberOfParticles type(neighObject_type), pointer :: neighObject integer(c_int), pointer :: neighborList(:, :) if (number_of_neighbor_lists > 1) then call my_warning("Model requires too many neighbor lists") ierr = 1 return end if call c_f_pointer(data_object, neighObject) numberOfParticles = neighObject%number_of_particles call c_f_pointer(neighObject%neighbor_list_pointer, neighborList, & [numberOfParticles + 1, numberOfParticles]) if (cutoffs(neighbor_list_index) > neighObject%cutoff) then call my_warning("neighbor list cutoff too small for model cutoff") ierr = 1 return end if if ((request > numberOfParticles) .or. (request < 1)) then print *, request call my_warning("Invalid part ID in get_neigh") ierr = 1 return end if ! set the returned number of neighbors for the returned part numnei = neighborList(1, request) ! set the location for the returned neighbor list pnei1part = c_loc(neighborList(2, request)) ierr = 0 return end subroutine get_neigh end module mod_neighborlist module mod_utilities use kim_simulator_headers_module implicit none public contains !------------------------------------------------------------------------------- ! ! Check if we are compatible with the model ! !------------------------------------------------------------------------------- recursive subroutine check_model_compatibility( & compute_arguments_handle, forces_optional, particle_energy_supported, & particle_energy_optional, model_is_compatible, ierr) use, intrinsic :: iso_c_binding use error implicit none !-- Transferred variables type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle logical, intent(out) :: forces_optional logical, intent(out) :: particle_energy_supported logical, intent(out) :: particle_energy_optional logical, intent(out) :: model_is_compatible integer(c_int), intent(out) :: ierr !-- Local variables integer(c_int) i integer(c_int) number_of_argument_names integer(c_int) number_of_callback_names type(kim_compute_argument_name_type) argument_name type(kim_support_status_type) support_status type(kim_compute_callback_name_type) callback_name ! assume fail model_is_compatible = .false. particle_energy_supported = .false. particle_energy_optional = .false. forces_optional = .false. ierr = 0 ! check arguments call kim_get_number_of_compute_argument_names( & number_of_argument_names) do i = 1, number_of_argument_names call kim_get_compute_argument_name(i, argument_name, & ierr) if (ierr /= 0) then call my_warning("can't get argument name") return end if call kim_get_argument_support_status( & compute_arguments_handle, argument_name, support_status, ierr) if (ierr /= 0) then call my_warning("can't get argument support_status") return end if ! can only handle energy, particle_energy and forces as required args if (support_status == KIM_SUPPORT_STATUS_REQUIRED) then if (.not. ( & (argument_name == KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY) .or. & (argument_name == & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY) .or. & (argument_name == KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES))) then call my_warning("unsupported required argument") ierr = 0 return end if end if ! need both energy and forces not "notSupported" if ((argument_name == KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY) .and. & (support_status == KIM_SUPPORT_STATUS_NOT_SUPPORTED)) then call my_warning("model does not support energy") ierr = 0 return end if if (argument_name == KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES) then if (support_status == KIM_SUPPORT_STATUS_NOT_SUPPORTED) then call my_warning("model does not support forces") ierr = 0 return else if (support_status == KIM_SUPPORT_STATUS_REQUIRED) then forces_optional = .false. else if (support_status == KIM_SUPPORT_STATUS_OPTIONAL) then forces_optional = .true. else call my_warning("unknown support_status for forces") ierr = 0 return end if end if ! check support for particle_energy if (argument_name == & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY) then if (support_status == KIM_SUPPORT_STATUS_NOT_SUPPORTED) then call my_warning("model does not support partial_particle_energy. & &The associated checks will be disabled.") particle_energy_supported = .false. particle_energy_optional = .false. else if (support_status == KIM_SUPPORT_STATUS_REQUIRED) then particle_energy_supported = .true. particle_energy_optional = .false. else if (support_status == KIM_SUPPORT_STATUS_OPTIONAL) then particle_energy_supported = .true. particle_energy_optional = .true. else call my_warning("unknown support_status for particle energy") ierr = 0 return end if end if end do ! check call backs call kim_get_number_of_compute_callback_names( & number_of_callback_names) do i = 1, number_of_callback_names call kim_get_compute_callback_name(i, callback_name, & ierr) if (ierr /= 0) then call my_warning("can't get call back name") return end if call kim_get_callback_support_status( & compute_arguments_handle, callback_name, support_status, ierr) if (ierr /= 0) then call my_warning("can't get call back support_status") return end if ! cannot handle any "required" call backs if (support_status == KIM_SUPPORT_STATUS_REQUIRED) then call my_warning("unsupported required call back") ierr = 0 return end if end do ! got to here, then everything must be OK model_is_compatible = .true. ierr = 0 return end subroutine Check_Model_Compatibility !----------------------------------------------------------------------------- ! ! Get number and identities of particle species supported by ! KIM Model `modelname' ! !----------------------------------------------------------------------------- recursive subroutine Get_Model_Supported_Species( & model_handle, max_species, model_species, num_species, ier) use, intrinsic :: iso_c_binding implicit none !-- Transferred variables type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(in) :: max_species type(kim_species_name_type), intent(out) :: model_species(max_species) integer(c_int), intent(out) :: num_species integer(c_int), intent(out) :: ier !-- Local variables integer(c_int) i integer(c_int) total_num_species type(kim_species_name_type) :: species_name integer(c_int) species_is_supported integer(c_int) code ! Initialize error flag ier = 1 num_species = 0 ! initialize call kim_get_number_of_species_names(total_num_species) if (total_num_species > max_species) return num_species = 0 do i = 1, total_num_species call kim_get_species_name(i, species_name, ier) call kim_get_species_support_and_code(model_handle, species_name, & species_is_supported, code, ier) if ((ier == 0) .and. (species_is_supported /= 0)) then num_species = num_species + 1 model_species(num_species) = species_name end if end do ier = 0 return end subroutine Get_Model_Supported_Species recursive subroutine update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) use, intrinsic :: iso_c_binding use mod_neighborlist implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants !-- Transferred variables integer(c_int), intent(in) :: DIM integer(c_int), intent(in) :: N real(c_double), intent(in) :: coords(DIM, N) real(c_double), intent(in) :: cutoff real(c_double), intent(in) :: cutpad logical, intent(inout) :: do_update_list real(c_double), intent(inout) :: coordsave(DIM, N) type(neighObject_type), intent(inout) :: neighObject integer(c_int), intent(out) :: ierr !-- Local variables real(c_double) disp, disp1, disp2, cutrange, dispvec(DIM) integer(c_int) i ! Initialize error code ! ierr = 0 ! Update neighbor lists if necessary ! if (.not. do_update_list) then ! if update not requested ! check whether a neighbor list update is necessary even if it hasn't been ! requested using the "two max sum" criterion disp1 = 0.0_cd disp2 = 0.0_cd do i = 1, N dispvec(1:DIM) = coords(1:DIM, i) - coordsave(1:DIM, i) disp = sqrt(dot_product(dispvec, dispvec)) if (disp >= disp1) then ! 1st position taken disp2 = disp1 ! push current 1st into 2nd place disp1 = disp ! and put this one into current 1st else if (disp >= disp2) then ! 2nd position taken disp2 = disp end if end do do_update_list = (disp1 + disp2 > cutpad) end if if (do_update_list) then ! save current coordinates coordsave(1:DIM, 1:N) = coords(1:DIM, 1:N) ! compute neighbor lists cutrange = cutoff + cutpad call NEIGH_PURE_cluster_neighborlist(.false., N, coords, cutrange, & neighObject) ! neighbor list uptodate, no need to compute again for now do_update_list = .false. end if return end subroutine update_neighborlist !----------------------------------------------------------------------------- ! ! NEIGH_PURE_cluster_neighborlist ! !----------------------------------------------------------------------------- recursive subroutine NEIGH_PURE_cluster_neighborlist( & half, numberOfParticles, coords, cutoff, neighObject) use, intrinsic :: iso_c_binding use mod_neighborlist implicit none !-- Transferred variables logical, intent(in) :: half integer(c_int), intent(in) :: numberOfParticles real(c_double), dimension(3, numberOfParticles), & intent(in) :: coords real(c_double), intent(in) :: cutoff type(neighObject_type), intent(inout) :: neighObject !-- Local variables integer(c_int), pointer :: neighborList(:, :) integer(c_int) i, j, a real(c_double) dx(3) real(c_double) r2 real(c_double) cutoff2 call c_f_pointer(neighObject%neighbor_list_pointer, neighborList, & [numberOfParticles + 1, numberOfParticles]) neighObject%cutoff = cutoff cutoff2 = cutoff**2 do i = 1, numberOfParticles a = 1 do j = 1, numberOfParticles dx(:) = coords(:, j) - coords(:, i) r2 = dot_product(dx, dx) if (r2 <= cutoff2) then ! part j is a neighbor of part i if ((j > i) .OR. ((.not. half) .AND. (i /= j))) then a = a + 1 neighborList(a, i) = j end if end if end do ! part i has a-1 neighbors neighborList(1, i) = a - 1 end do return end subroutine NEIGH_PURE_cluster_neighborlist !----------------------------------------------------------------------------- ! ! create_FCC_configuration subroutine ! ! creates a cubic configuration of FCC particles with lattice spacing ! `FCCspacing' and `nCellsPerSide' cells along each direction. ! ! With periodic==.true. this will result in a total number of particles equal ! to 4*(nCellsPerSide)**3 + 6*(nCellsPerSide)**2 + 3*(nCellsPerSide) + 1 ! ! With periodic==.false. this will result in a total number of particles equal ! to 4*(nCellsPerSide)**3 ! ! Returns the Id of the particle situated in the middle of the configuration ! (this particle will have the most neighbors.) ! !----------------------------------------------------------------------------- recursive subroutine create_FCC_configuration(FCCspacing, nCellsPerSide, & periodic, coords, MiddlePartId) use, intrinsic :: iso_c_binding implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants !-- Transferred variables real(c_double), intent(in) :: FCCspacing integer(c_int), intent(in) :: nCellsPerSide logical, intent(in) :: periodic real(c_double), intent(out) :: coords(3, *) integer(c_int), intent(out) :: MiddlePartId ! ! cluster setup variables ! real(c_double) FCCshifts(3, 4) real(c_double) latVec(3) integer(c_int) a, i, j, k, m ! Create a cubic FCC cluster ! FCCshifts(1, 1) = 0.0_cd FCCshifts(2, 1) = 0.0_cd FCCshifts(3, 1) = 0.0_cd FCCshifts(1, 2) = 0.5_cd * FCCspacing FCCshifts(2, 2) = 0.5_cd * FCCspacing FCCshifts(3, 2) = 0.0_cd FCCshifts(1, 3) = 0.5_cd * FCCspacing FCCshifts(2, 3) = 0.0_cd FCCshifts(3, 3) = 0.5_cd * FCCspacing FCCshifts(1, 4) = 0.0_cd FCCshifts(2, 4) = 0.5_cd * FCCspacing FCCshifts(3, 4) = 0.5_cd * FCCspacing MiddlePartID = 1 ! Always put middle particle as #1 a = 1 ! leave space for middle particle as particle #1 do i = 1, nCellsPerSide latVec(1) = (i - 1) * FCCspacing do j = 1, nCellsPerSide latVec(2) = (j - 1) * FCCspacing do k = 1, nCellsPerSide latVec(3) = (k - 1) * FCCspacing do m = 1, 4 a = a + 1 coords(:, a) = latVec + FCCshifts(:, m) if ((i == nCellsPerside / 2 + 1) & .and. (j == nCellsPerSide / 2 + 1) & .and. (k == nCellsPerSide / 2 + 1) & .and. (m == 1)) & then ! put middle particle as #1 coords(:, 1) = latVec + FCCshifts(:, m) a = a - 1 end if end do end do if (.not. periodic) then ! Add in the remaining three faces ! pos-x face latVec(1) = nCellsPerSide * FCCspacing latVec(2) = (i - 1) * FCCspacing latVec(3) = (j - 1) * FCCspacing a = a + 1; coords(:, a) = latVec a = a + 1; coords(:, a) = latVec + FCCshifts(:, 4) ! pos-y face latVec(1) = (i - 1) * FCCspacing latVec(2) = nCellsPerSide * FCCspacing latVec(3) = (j - 1) * FCCspacing a = a + 1; coords(:, a) = latVec a = a + 1; coords(:, a) = latVec + FCCshifts(:, 3) ! pos-z face latVec(1) = (i - 1) * FCCspacing latVec(2) = (j - 1) * FCCspacing latVec(3) = nCellsPerSide * FCCspacing a = a + 1; coords(:, a) = latVec a = a + 1; coords(:, a) = latVec + FCCshifts(:, 2) end if end do if (.not. periodic) then ! Add in the remaining three edges latVec(1) = (i - 1) * FCCspacing latVec(2) = nCellsPerSide * FCCspacing latVec(3) = nCellsPerSide * FCCspacing a = a + 1; coords(:, a) = latVec latVec(1) = nCellsPerSide * FCCspacing latVec(2) = (i - 1) * FCCspacing latVec(3) = nCellsPerSide * FCCspacing a = a + 1; coords(:, a) = latVec latVec(1) = nCellsPerSide * FCCspacing latVec(2) = nCellsPerSide * FCCspacing latVec(3) = (i - 1) * FCCspacing a = a + 1; coords(:, a) = latVec end if end do if (.not. periodic) then ! Add in the remaining corner a = a + 1; coords(:, a) = nCellsPerSide * FCCspacing end if return end subroutine create_FCC_configuration recursive subroutine compute_numer_deriv( & partnum, dir, model_handle, compute_arguments_handle, DIM, N, coords, & cutoff, cutpad, energy, do_update_list, coordsave, neighObject, deriv, & deriv_err, ierr) use, intrinsic :: iso_c_binding use error use mod_neighborlist implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants !--Transferred variables integer(c_int), intent(in) :: partnum integer(c_int), intent(in) :: dir type(kim_model_handle_type), intent(in) :: model_handle type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle integer(c_int), intent(in) :: DIM integer(c_int), intent(in) :: N real(c_double), intent(inout) :: coords(DIM, N) real(c_double), intent(in) :: cutoff real(c_double), intent(in) :: cutpad real(c_double), intent(inout) :: energy logical, intent(inout) :: do_update_list real(c_double), intent(inout) :: coordsave(DIM, N) type(neighObject_type), intent(inout) :: neighObject real(c_double), intent(out) :: deriv real(c_double), intent(out) :: deriv_err integer(c_int), intent(out) :: ierr !-- Local variables real(c_double), parameter :: eps_init = 1.e-6_cd integer(c_int), parameter :: number_eps_levels = 15 real(c_double) eps, deriv_last, deriv_err_last integer(c_int) i ! Initialize error flag ierr = 0 deriv_last = 0.0_cd ! initialize ! Outer loop of Ridders' method for computing numerical derivative ! eps = eps_init deriv_err_last = huge(1.0_cd) do i = 1, number_eps_levels deriv = dfridr(eps, deriv_err) if (ierr /= 0) then call my_error("compute_numer_deriv") end if if (deriv_err > deriv_err_last) then deriv = deriv_last deriv_err = deriv_err_last exit end if eps = eps * 10.0_cd deriv_last = deriv deriv_err_last = deriv_err end do return contains !---------------------------------------------------------------------------- ! ! Compute numerical derivative using Ridders' method ! ! Based on code from Numerical Recipes, Press et al., Second Ed., Cambridge, ! 1992 ! ! Ref: Ridders, C. J. F., "Two algorithms for the calculation of F'(x)=D", ! Advances in Engineering Software, Vol. 4, no. 2, pp. 75-76, 1982. ! ! ! Returns the gradient grad() of a KIM-compliant interatomic model at the ! current configuration by Ridders' method of polynomial extrapolation. ! An estimate for the error in each component of the gradient is returned in ! grad_err(). ! !---------------------------------------------------------------------------- real(c_double) recursive function dfridr(h, err) implicit none !-- Transferred variables real(c_double), intent(inout) :: h real(c_double), intent(out) :: err !-- Local variables integer(c_int), parameter :: NTAB = 10 ! Maximum size of tableau real(c_double), parameter :: CON = 1.4_cd ! Stepsize incr. by CON at each iter real(c_double), parameter :: CON2 = CON * CON real(c_double), parameter :: BIG = huge(1.0_cd) real(c_double), parameter :: SAFE = 2.0_cd ! Returns when error is SAFE worse ! than the best so far integer(c_int) i, j real(c_double) errt, fac, hh, a(NTAB, NTAB), fp, fm, coordorig dfridr = 0.0_cd ! initialize err = BIG ! initialize if (abs(h) <= tiny(0.0_cd)) then ! avoid division by zero ierr = 1 return end if hh = h coordorig = coords(dir, partnum) coords(dir, partnum) = coordorig + hh call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) call kim_compute(model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_api_model_compute") end if fp = energy coords(dir, partnum) = coordorig - hh call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) call kim_compute(model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_api_model_compute") end if fm = energy coords(dir, partnum) = coordorig call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) a(1, 1) = (fp - fm) / (2.0_cd * hh) ! successive columns in the Neville tableau will go to smaller step sizes ! and higher orders of extrapolation do i = 2, NTAB ! try new, smaller step size hh = hh / CON coords(dir, partnum) = coordorig + hh call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) call kim_compute(model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_api_model_compute") end if fp = energy coords(dir, partnum) = coordorig - hh call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) call kim_compute(model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_api_model_compute") end if fm = energy coords(dir, partnum) = coordorig call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) a(1, i) = (fp - fm) / (2.0_cd * hh) fac = CON2 ! compute extrapolations of various orders, requiring no new function ! evaluations do j = 2, i a(j, i) = (a(j - 1, i) * fac - a(j - 1, i - 1)) / (fac - 1.0_cd) fac = CON2 * fac ! The error strategy is to compute each new extrapolation to one order ! lower, both at the present step size and the previous one. errt = max(abs(a(j, i) - a(j - 1, i)), abs(a(j, i) - a(j - 1, i - 1))) if (errt <= err) then ! if error is decreased, save the improved answer err = errt dfridr = a(j, i) end if end do if (abs(a(i, i) - a(i - 1, i - 1)) >= SAFE * err) return ! if higher order is worse ! by significant factor ! `SAFE', then quit early. end do return end function dfridr end subroutine compute_numer_deriv end module mod_utilities !******************************************************************************* !** !** PROGRAM vc_forces_numer_deriv !** !** KIM compliant program to perform numerical derivative check on a model !** !******************************************************************************* !------------------------------------------------------------------------------- ! ! Main program ! !------------------------------------------------------------------------------- program vc_forces_numer_deriv use, intrinsic :: iso_c_binding use error use mod_neighborlist use mod_utilities implicit none integer(c_int), parameter :: cd = c_double ! used for literal constants integer(c_int), parameter :: nCellsPerSide = 2 integer(c_int), parameter :: DIM = 3 real(c_double), parameter :: cutpad = 0.75_cd integer(c_int), parameter :: max_species = 200 ! most species supported real(c_double), parameter :: eps_prec = epsilon(1.0_cd) real(c_double) FCCspacing integer(c_int), parameter :: N = 4 * (nCellsPerSide)**3 & + 6 * (nCellsPerSide)**2 & + 3 * (nCellsPerSide) + 1 real(c_double), allocatable :: forces_num(:, :) real(c_double), allocatable :: forces_num_err(:, :) type(kim_species_name_type) :: model_species(max_species) integer(c_int), target :: num_species character(len=5, kind=c_char) :: passfail real(c_double) :: forcediff real(c_double) :: forcediff_sumsq real(c_double) :: weight real(c_double) :: weight_sum real(c_double) :: alpha real(c_double) :: term real(c_double) :: term_max real(c_double), allocatable :: cluster_coords(:, :) real(c_double), allocatable :: cluster_disps(:, :) type(kim_species_name_type), allocatable :: cluster_species(:) integer(c_int) I, J, Imax, Jmax, species_code integer(c_int) seed_size integer(c_int), allocatable :: seed(:) ! ! neighbor list ! type(neighObject_type), target :: neighObject integer(c_int), allocatable, target :: neighborList(:, :) real(c_double), allocatable :: coordsave(:, :) logical do_update_list ! ! KIM variables ! character(len=256, kind=c_char) :: testname = "vc_forces_numer_deriv" character(len=256, kind=c_char) :: modelname type(kim_model_handle_type) :: model_handle type(kim_compute_arguments_handle_type) :: compute_arguments_handle integer(c_int) ierr, ierr2 integer(c_int) species_is_supported integer(c_int), target :: numberOfParticles integer(c_int), target :: particleSpeciesCodes(N) integer(c_int), target :: particleContributing(N) real(c_double) :: influence_distance integer(c_int) :: number_of_neighbor_lists real(c_double), allocatable :: cutoffs(:) integer(c_int), allocatable :: & model_will_not_request_neighbors_of_noncontributing_particles(:) real(c_double) :: cutoff real(c_double), target :: energy real(c_double), target :: particle_energy(N) real(c_double), target :: particle_energy_sum real(c_double), target :: coords(3, N) real(c_double), target :: forces_kim(3, N) real(c_double) :: forces(3, N) integer(c_int) middleDum logical doing_non_contributing logical particle_energy_supported logical particle_energy_optional logical noncontrib_particle_energy_nonzero logical forces_optional logical model_is_compatible integer(c_int) number_of_model_routine_names type(kim_model_routine_name_type) model_routine_name integer(c_int) present integer(c_int) required integer(c_int) requested_units_accepted real(c_double) rnd, deriv, deriv_err real(c_double), pointer :: null_pointer nullify (null_pointer) doing_non_contributing = .false. ! .true. on 2nd pass through main program numberOfParticles = N term_max = 0.0_cd ! initialize ! Initialize error flag ierr = 0 ! Initialize seed for random number generator ! ! NOTE: Here, we set the seed to a fixed value for reproducibility call random_seed(size=seed_size) ! Get seed size for this CPU allocate (seed(seed_size)) seed(:) = 13 call random_seed(put=seed) deallocate (seed) ! Get KIM Model name to use print '("Please enter a valid KIM model name: ")' read (*, *) modelname ! Print output header ! print * print *, 'VERIFICATION CHECK: NUMERICAL DERIVATIVE VERIFICATION OF FORCES' print * print '(120(''-''))' print '("This is Test : ",A)', trim(testname) print '("Results for KIM Model : ",A)', trim(modelname) ! Create empty KIM object ! call kim_model_create(KIM_NUMBERING_ONE_BASED, & KIM_LENGTH_UNIT_A, & KIM_ENERGY_UNIT_EV, & KIM_CHARGE_UNIT_E, & KIM_TEMPERATURE_UNIT_K, & KIM_TIME_UNIT_PS, & trim(modelname), & requested_units_accepted, & model_handle, ierr) if (ierr /= 0) then call my_error("kim_api_create") end if ! check that we are compatible if (requested_units_accepted == 0) then call my_error("Must adapt to model units") end if ! check that we know about all required routines call kim_get_number_of_model_routine_names(number_of_model_routine_names) do i = 1, number_of_model_routine_names call kim_get_model_routine_name(i, model_routine_name, ierr) if (ierr /= 0) then call my_error("kim_get_model_routine_name") end if call kim_is_routine_present(model_handle, model_routine_name, present, & required, ierr) if (ierr /= 0) then call my_error("kim_is_routine_present") end if if ((present == 1) .and. (required == 1)) then if (.not. ((model_routine_name == KIM_MODEL_ROUTINE_NAME_CREATE) & .or. (model_routine_name == & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE) & .or. (model_routine_name == KIM_MODEL_ROUTINE_NAME_COMPUTE) & .or. (model_routine_name == KIM_MODEL_ROUTINE_NAME_REFRESH) & .or. (model_routine_name == & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY) & .or. (model_routine_name == KIM_MODEL_ROUTINE_NAME_DESTROY))) & then call my_error("Unknown required ModelRoutineName found.") end if end if end do ! create compute_arguments object call kim_compute_arguments_create(model_handle, & compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_model_compute_arguments_create") end if call check_model_compatibility(compute_arguments_handle, forces_optional, & particle_energy_supported, & particle_energy_optional, & model_is_compatible, ierr) if (ierr /= 0) then call my_error("error checking compatibility") end if if (.not. model_is_compatible) then call my_error("incompatibility reported by check_model_compatibility") end if ! Get list of particle species supported by the model ! call Get_Model_Supported_Species(model_handle, max_species, model_species, & num_species, ierr) if (ierr /= 0) then call my_error("Get_Model_Supported_Species") end if ! Setup random cluster ! allocate (cluster_coords(3, N), cluster_disps(3, N), cluster_species(N)) do i = 1, N call random_number(rnd) ! return random number between 0 and 1 species_code = 1 + int(rnd * num_species) cluster_species(i) = model_species(species_code) end do FCCspacing = 1.0_cd ! initially generate an FCC cluster with lattice ! spacing equal to one. This is scaled below based ! on the cutoff radius of the model. call create_FCC_configuration(FCCspacing, nCellsPerSide, .false., & cluster_coords, middleDum) ! Generate random displacements for all particles ! do I = 1, N do J = 1, DIM call random_number(rnd) ! return random number between 0 and 1 cluster_disps(J, I) = 0.1_cd * (rnd - 0.5_cd) end do end do ! register memory with the KIM system ierr = 0 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, & numberOfParticles, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, & particleSpeciesCodes, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, & particleContributing, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, coords, ierr2) ierr = ierr + ierr2 call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, energy, ierr2) ierr = ierr + ierr2 if (particle_energy_supported) then call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, particle_energy, ierr2) ierr = ierr + ierr2 end if call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, forces_kim, ierr2) ierr = ierr + ierr2 if (ierr /= 0) then call my_error("set_argument_pointer") end if ! Allocate storage for neighbor lists and ! store pointers to neighbor list object and access function ! allocate (coordsave(DIM, N)) allocate (neighborList(N + 1, N)) neighObject%neighbor_list_pointer = c_loc(neighborList) neighObject%number_of_particles = N allocate (forces_num(DIM, N), forces_num_err(DIM, N)) ! Set pointer in KIM object to neighbor list routine and object ! call kim_set_callback_pointer( & compute_arguments_handle, & KIM_COMPUTE_CALLBACK_NAME_GET_NEIGHBOR_LIST, KIM_LANGUAGE_NAME_FORTRAN, & c_funloc(get_neigh), c_loc(neighobject), ierr) if (ierr /= 0) then call my_error("set_callback_pointer") end if call kim_get_influence_distance(model_handle, influence_distance) call kim_get_number_of_neighbor_lists(model_handle, & number_of_neighbor_lists) allocate (cutoffs(number_of_neighbor_lists), & model_will_not_request_neighbors_of_noncontributing_particles( & number_of_neighbor_lists)) call kim_get_neighbor_list_values( & model_handle, cutoffs, & model_will_not_request_neighbors_of_noncontributing_particles, ierr) if (ierr /= 0) then call my_error("get_neighbor_list_values") end if cutoff = maxval(cutoffs) ! Scale reference FCC configuration based on cutoff radius. FCCspacing = 0.75_cd * cutoff ! set the FCC spacing to a fraction ! of the cutoff radius do i = 1, N cluster_coords(:, i) = FCCspacing * cluster_coords(:, i) end do print '("Using FCC lattice parameter: ",f12.5)', FCCspacing print * 1000 continue ! Start of configuration setup if (doing_non_contributing) then ! Turn particle energy computation back on, if possible if (particle_energy_optional) then call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & particle_energy, ierr) if (ierr /= 0) then call my_error("set_argument_pointer") end if end if ! Turn force computation back on, if possible ! if (forces_optional) then call kim_set_argument_pointer( & compute_arguments_handle, KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & forces_kim, ierr) if (ierr /= 0) then call my_error("set_argument_pointer") end if end if end if do i = 1, N call kim_get_species_support_and_code( & model_handle, cluster_species(i), species_is_supported, & particleSpeciesCodes(i), ierr) end do if (ierr /= 0) then call my_error("kim_api_get_species_code") end if if (.not. doing_non_contributing) then do i = 1, N particleContributing(i) = 1 ! all particle contribute end do else do i = 1, N ! Random collection of contributing atoms call random_number(rnd) ! return random number between 0 and 1 if (rnd > 0.5) then particleContributing(i) = 1 else particleContributing(i) = 0 end if end do end if do i = 1, N coords(:, i) = cluster_coords(:, i) + cluster_disps(:, i) end do ! Compute neighbor lists ! do_update_list = .true. call update_neighborlist(DIM, N, coords, cutoff, cutpad, & do_update_list, coordsave, & neighObject, ierr) if (ierr /= 0) then call my_error("update_neighborlist") end if ! Call model compute to get forces (gradient) ! call kim_compute(model_handle, compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_api_model_compute") end if ! Copy forces in case model will overwrite forces_kim below ! forces = forces_kim ! Add up particle_energy to compare with energy noncontrib_particle_energy_nonzero = .false. if (particle_energy_supported) then particle_energy_sum = 0.0_cd do i = 1, N if (particleContributing(i) == 0) then if (abs(particle_energy(i)) > epsilon(0.0_cd)) then noncontrib_particle_energy_nonzero = .true. end if else particle_energy_sum = particle_energy_sum + particle_energy(i) end if end do end if ! Print results to screen ! print '(41(''=''))' if (.not. doing_non_contributing) then print '("Configuration with all contributing particles")' else print '("Configuration with some non-contributing particles")' end if if (particle_energy_supported) then print '(A25,2X,A25,2X,A15)', "Energy", "Sum Contrib. Energies", "Diff" print '(ES25.15,2X,ES25.15,2X,ES15.5)', energy, particle_energy_sum, & energy - particle_energy_sum if (noncontrib_particle_energy_nonzero) then call my_error( & "Some non-contributing particles have non-zero & &partial_particle_energy") end if else print '("Energy = ",ES25.15)', energy end if print '(41(''=''))' print * ! Turn off particle energy computation, if possible if (particle_energy_optional) then call kim_set_argument_pointer( & compute_arguments_handle, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & null_pointer, ierr) if (ierr /= 0) then call my_error("set_argument_pointer") end if end if ! Turn off force computation, if possible ! if (forces_optional) then call kim_set_argument_pointer( & compute_arguments_handle, KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & null_pointer, ierr) if (ierr /= 0) then call my_error("set_argument_pointer") end if end if ! Compute gradient using numerical differentiation ! do I = 1, N do J = 1, DIM call compute_numer_deriv(I, J, model_handle, compute_arguments_handle, & DIM, N, coords, cutoff, & cutpad, energy, do_update_list, & coordsave, neighObject, deriv, deriv_err, ierr) if (ierr /= 0) then call my_error("compute_numer_deriv") end if forces_num(J, I) = -deriv forces_num_err(J, I) = deriv_err end do end do ! Continue printing results to screen ! print '(A6,2X,A7,2X,A4,2X,A3,2X,2A25,3A15,2X,A4)', "Part", "Contrib", & "Spec", "Dir", "Force_model", "Force_numer", "Force diff", "pred error", & "weight", "stat" forcediff_sumsq = 0.0_cd weight_sum = 0.0_cd do I = 1, N do J = 1, DIM forcediff = abs(forces(J, I) - forces_num(J, I)) if (forcediff < forces_num_err(J, I)) then passfail = "ideal" else passfail = " " end if weight = max(abs(forces_num(J, I)), eps_prec) / & max(abs(forces_num_err(J, I)), eps_prec) term = weight * forcediff**2 if (term > term_max) then term_max = term Imax = I Jmax = J end if forcediff_sumsq = forcediff_sumsq + term weight_sum = weight_sum + weight if (J == 1) then print '(I6,2X,I7,2X,I4,2X,I3,2X,2ES25.15,3ES15.5,2X,A5)', & I, particleContributing(I), & particleSpeciesCodes(I), J, forces(J, I), & forces_num(J, I), forcediff, & forces_num_err(J, I), weight, passfail else print '(23X,I3,2X,2ES25.15,3ES15.5,2X,A5)', & J, forces(J, I), forces_num(J, I), & forcediff, forces_num_err(J, I), weight, passfail end if end do print * end do alpha = sqrt(forcediff_sumsq / weight_sum) / dble(DIM * N) print * print '("alpha = |Force_model - Force_numer|_w/(DIM*N) = ",ES15.5," & &(units of force)")', alpha print * print '(''Maximum term obtained for Part = '',I6,'', Dir = '',I1,'// & ''', forcediff = '',ES15.5, '', forcediff/force_model = '',ES15.5)', & Imax, Jmax, abs(forces(Jmax, Imax) - forces_num(Jmax, Imax)), & abs(forces(Jmax, Imax) - forces_num(Jmax, Imax)) / abs(forces(Jmax, Imax)) if (.not. doing_non_contributing) then doing_non_contributing = .true. print * print * goto 1000 end if ! Free temporary storage ! deallocate (forces_num) deallocate (forces_num_err) deallocate (neighborList) deallocate (coordsave) deallocate (cutoffs) deallocate (model_will_not_request_neighbors_of_noncontributing_particles) call kim_compute_arguments_destroy(model_handle, & compute_arguments_handle, ierr) if (ierr /= 0) then call my_error("kim_model_compute_arguments_destroy") end if call kim_model_destroy(model_handle) ! Print output footer ! print * print '(120(''-''))' ! Free cluster storage ! deallocate (cluster_coords, cluster_disps, cluster_species) stop end program vc_forces_numer_deriv kim-api-2.3.0-git/fortran/000077500000000000000000000000001421473465500153125ustar00rootroot00000000000000kim-api-2.3.0-git/fortran/include/000077500000000000000000000000001421473465500167355ustar00rootroot00000000000000kim-api-2.3.0-git/fortran/include/CMakeLists.txt000066400000000000000000000125511421473465500215010ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # target_include_directories(kim-api PUBLIC $) set(F_MOD_DIR $) set(FORTRAN_MODULES ${F_MOD_DIR}/kim_charge_unit_module.mod ${F_MOD_DIR}/kim_collection_item_type_module.mod ${F_MOD_DIR}/kim_collection_module.mod ${F_MOD_DIR}/kim_collections_module.mod ${F_MOD_DIR}/kim_compute_argument_name_module.mod ${F_MOD_DIR}/kim_compute_arguments_module.mod ${F_MOD_DIR}/kim_compute_callback_name_module.mod ${F_MOD_DIR}/kim_data_type_module.mod ${F_MOD_DIR}/kim_energy_unit_module.mod ${F_MOD_DIR}/kim_language_name_module.mod ${F_MOD_DIR}/kim_length_unit_module.mod ${F_MOD_DIR}/kim_log_module.mod ${F_MOD_DIR}/kim_log_verbosity_module.mod ${F_MOD_DIR}/kim_model_compute_arguments_create_module.mod ${F_MOD_DIR}/kim_model_compute_arguments_destroy_module.mod ${F_MOD_DIR}/kim_model_compute_arguments_module.mod ${F_MOD_DIR}/kim_model_compute_module.mod ${F_MOD_DIR}/kim_model_create_module.mod ${F_MOD_DIR}/kim_model_extension_module.mod ${F_MOD_DIR}/kim_model_destroy_module.mod ${F_MOD_DIR}/kim_model_driver_create_module.mod ${F_MOD_DIR}/kim_model_driver_headers_module.mod ${F_MOD_DIR}/kim_model_headers_module.mod ${F_MOD_DIR}/kim_model_module.mod ${F_MOD_DIR}/kim_model_refresh_module.mod ${F_MOD_DIR}/kim_model_routine_name_module.mod ${F_MOD_DIR}/kim_model_write_parameterized_model_module.mod ${F_MOD_DIR}/kim_numbering_module.mod ${F_MOD_DIR}/kim_sem_ver_module.mod ${F_MOD_DIR}/kim_simulator_headers_module.mod ${F_MOD_DIR}/kim_simulator_model_module.mod ${F_MOD_DIR}/kim_species_name_module.mod ${F_MOD_DIR}/kim_support_status_module.mod ${F_MOD_DIR}/kim_supported_extensions_module.mod ${F_MOD_DIR}/kim_temperature_unit_module.mod ${F_MOD_DIR}/kim_time_unit_module.mod ${F_MOD_DIR}/kim_unit_system_module.mod ) install(FILES ${FORTRAN_MODULES} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_LIBDIR}/${PROJECT_NAME}/${KIM_API_Fortran_MODULE_DIR_IDENTIFIER}) set(F_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/kim_charge_unit_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_collection_item_type_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_collection_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_collections_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_compute_argument_name_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_compute_arguments_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_compute_callback_name_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_data_type_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_energy_unit_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_language_name_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_length_unit_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_log_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_log_verbosity_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_compute_arguments_create_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_compute_arguments_destroy_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_compute_arguments_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_compute_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_create_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_extension_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_destroy_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_driver_create_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_driver_headers_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_headers_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_refresh_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_routine_name_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_model_write_parameterized_model_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_numbering_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_sem_ver_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_simulator_headers_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_simulator_model_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_species_name_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_support_status_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_supported_extensions_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_temperature_unit_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_time_unit_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_unit_system_module.f90 ) target_sources(kim-api PRIVATE ${F_SOURCES}) kim-api-2.3.0-git/fortran/include/kim_charge_unit_module.f90000066400000000000000000000217131421473465500237560ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ChargeUnit !! !! \sa KIM::ChargeUnit, KIM_ChargeUnit !! !! \since 2.0 module kim_charge_unit_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_charge_unit_type, & ! Constants KIM_CHARGE_UNIT_UNUSED, & KIM_CHARGE_UNIT_C, & KIM_CHARGE_UNIT_E, & KIM_CHARGE_UNIT_STATC, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_charge_units, & kim_get_charge_unit !> \brief \copybrief KIM::ChargeUnit !! !! \sa KIM::ChargeUnit, KIM_ChargeUnit !! !! \since 2.0 type, bind(c) :: kim_charge_unit_type !> \brief \copybrief KIM::ChargeUnit::chargeUnitID !! !! \sa KIM::ChargeUnit::chargeUnitID, KIM_ChargeUnit::chargeUnitID !! !! \since 2.0 integer(c_int) charge_unit_id end type kim_charge_unit_type !> \brief \copybrief KIM::CHARGE_UNIT::unused !! !! \sa KIM::CHARGE_UNIT::unused, KIM_CHARGE_UNIT_unused !! !! \since 2.0 type(kim_charge_unit_type), protected, save, & bind(c, name="KIM_CHARGE_UNIT_unused") & :: KIM_CHARGE_UNIT_UNUSED !> \brief \copybrief KIM::CHARGE_UNIT::C !! !! \sa KIM::CHARGE_UNIT::C, KIM_CHARGE_UNIT_C !! !! \since 2.0 type(kim_charge_unit_type), protected, save, & bind(c, name="KIM_CHARGE_UNIT_c") & :: KIM_CHARGE_UNIT_C !> \brief \copybrief KIM::CHARGE_UNIT::e !! !! \sa KIM::CHARGE_UNIT::e, KIM_CHARGE_UNIT_e !! !! \since 2.0 type(kim_charge_unit_type), protected, save, & bind(c, name="KIM_CHARGE_UNIT_e") & :: KIM_CHARGE_UNIT_E !> \brief \copybrief KIM::CHARGE_UNIT::statC !! !! \sa KIM::CHARGE_UNIT::statC, KIM_CHARGE_UNIT_statC !! !! \since 2.0 type(kim_charge_unit_type), protected, save, & bind(c, name="KIM_CHARGE_UNIT_statC") & :: KIM_CHARGE_UNIT_STATC !> \brief \copybrief KIM::ChargeUnit::Known !! !! \sa KIM::ChargeUnit::Known, KIM_ChargeUnit_Known !! !! \since 2.0 interface kim_known module procedure kim_charge_unit_known end interface kim_known !> \brief \copybrief KIM::ChargeUnit::operator==() !! !! \sa KIM::ChargeUnit::operator==(), KIM_ChargeUnit_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_charge_unit_equal end interface operator(.eq.) !> \brief \copybrief KIM::ChargeUnit::operator!=() !! !! \sa KIM::ChargeUnit::operator!=(), KIM_ChargeUnit_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_charge_unit_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ChargeUnit::ChargeUnit(std::string const &) !! !! \sa KIM::ChargeUnit::ChargeUnit(std::string const &), !! KIM_ChargeUnit_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_charge_unit_from_string end interface kim_from_string !> \brief \copybrief KIM::ChargeUnit::ToString !! !! \sa KIM::ChargeUnit::ToString, KIM_ChargeUnit_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_charge_unit_to_string end interface kim_to_string contains !> \brief \copybrief KIM::ChargeUnit::Known !! !! \sa KIM::ChargeUnit::Known, KIM_ChargeUnit_Known !! !! \since 2.0 logical recursive function kim_charge_unit_known(charge_unit) implicit none interface integer(c_int) recursive function known(charge_unit) & bind(c, name="KIM_ChargeUnit_Known") use, intrinsic :: iso_c_binding import kim_charge_unit_type implicit none type(kim_charge_unit_type), intent(in), value :: charge_unit end function known end interface type(kim_charge_unit_type), intent(in) :: charge_unit kim_charge_unit_known = (known(charge_unit) /= 0) end function kim_charge_unit_known !> \brief \copybrief KIM::ChargeUnit::operator==() !! !! \sa KIM::ChargeUnit::operator==(), KIM_ChargeUnit_Equal !! !! \since 2.0 logical recursive function kim_charge_unit_equal(lhs, rhs) implicit none type(kim_charge_unit_type), intent(in) :: lhs type(kim_charge_unit_type), intent(in) :: rhs kim_charge_unit_equal & = (lhs%charge_unit_id == rhs%charge_unit_id) end function kim_charge_unit_equal !> \brief \copybrief KIM::ChargeUnit::operator!=() !! !! \sa KIM::ChargeUnit::operator!=(), KIM_ChargeUnit_NotEqual !! !! \since 2.0 logical recursive function kim_charge_unit_not_equal(lhs, rhs) implicit none type(kim_charge_unit_type), intent(in) :: lhs type(kim_charge_unit_type), intent(in) :: rhs kim_charge_unit_not_equal = .not. (lhs == rhs) end function kim_charge_unit_not_equal !> \brief \copybrief KIM::ChargeUnit::ChargeUnit(std::string const &) !! !! \sa KIM::ChargeUnit::ChargeUnit(std::string const &), !! KIM_ChargeUnit_FromString !! !! \since 2.0 recursive subroutine kim_charge_unit_from_string(string, charge_unit) implicit none interface type(kim_charge_unit_type) recursive function from_string(string) & bind(c, name="KIM_ChargeUnit_FromString") use, intrinsic :: iso_c_binding import kim_charge_unit_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_charge_unit_type), intent(out) :: charge_unit charge_unit = from_string(trim(string)//c_null_char) end subroutine kim_charge_unit_from_string !> \brief \copybrief KIM::ChargeUnit::ToString !! !! \sa KIM::ChargeUnit::ToString, KIM_ChargeUnit_ToString !! !! \since 2.0 recursive subroutine kim_charge_unit_to_string(charge_unit, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(charge_unit) & bind(c, name="KIM_ChargeUnit_ToString") use, intrinsic :: iso_c_binding import kim_charge_unit_type implicit none type(kim_charge_unit_type), intent(in), value :: charge_unit end function get_string end interface type(kim_charge_unit_type), intent(in) :: charge_unit character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(charge_unit) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_charge_unit_to_string !> \brief \copybrief KIM::CHARGE_UNIT::GetNumberOfChargeUnits !! !! \sa KIM::CHARGE_UNIT::GetNumberOfChargeUnits, !! KIM_CHARGE_UNIT_GetNumberOfChargeUnits !! !! \since 2.0 recursive subroutine kim_get_number_of_charge_units(number_of_charge_units) implicit none interface recursive subroutine get_number_of_charge_units(number_of_charge_units) & bind(c, name="KIM_CHARGE_UNIT_GetNumberOfChargeUnits") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_charge_units end subroutine get_number_of_charge_units end interface integer(c_int), intent(out) :: number_of_charge_units call get_number_of_charge_units(number_of_charge_units) end subroutine kim_get_number_of_charge_units !> \brief \copybrief KIM::CHARGE_UNIT::GetChargeUnit !! !! \sa KIM::CHARGE_UNIT::GetChargeUnit, KIM_CHARGE_UNIT_GetChargeUnit !! !! \since 2.0 recursive subroutine kim_get_charge_unit(index, charge_unit, ierr) implicit none interface integer(c_int) recursive function get_charge_unit(index, charge_unit) & bind(c, name="KIM_CHARGE_UNIT_GetChargeUnit") use, intrinsic :: iso_c_binding import kim_charge_unit_type implicit none integer(c_int), intent(in), value :: index type(kim_charge_unit_type), intent(out) :: charge_unit end function get_charge_unit end interface integer(c_int), intent(in) :: index type(kim_charge_unit_type), intent(out) :: charge_unit integer(c_int), intent(out) :: ierr ierr = get_charge_unit(index - 1, charge_unit) end subroutine kim_get_charge_unit end module kim_charge_unit_module kim-api-2.3.0-git/fortran/include/kim_collection_item_type_module.f90000066400000000000000000000246431421473465500257050ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::CollectionItemType !! !! \sa KIM::CollectionItemType, KIM_CollectionItemType !! !! \since 2.1 module kim_collection_item_type_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_collection_item_type_type, & ! Constants KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER, & KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL, & KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_collection_item_types, & kim_get_collection_item_type !> \brief \copybrief KIM::CollectionItemType !! !! \sa KIM::CollectionItemType, KIM_CollectionItemType !! !! \since 2.1 type, bind(c) :: kim_collection_item_type_type !> \brief \copybrief KIM::CollectionItemType::collectionItemTypeID !! !! \sa KIM::CollectionItemType::collectionItemTypeID, !! KIM_CollectionItemType::collectionItemTypeID !! !! \since 2.1 integer(c_int) collection_item_type_id end type kim_collection_item_type_type !> \brief \copybrief KIM::COLLECTION_ITEM_TYPE::modelDriver !! !! \sa KIM::COLLECTION_ITEM_TYPE::modelDriver, !! KIM_COLLECTION_ITEM_TYPE_modelDriver !! !! \since 2.1 type(kim_collection_item_type_type), protected, save, & bind(c, name="KIM_COLLECTION_ITEM_TYPE_modelDriver") & :: KIM_COLLECTION_ITEM_TYPE_MODEL_DRIVER !> \brief \copybrief KIM::COLLECTION_ITEM_TYPE::portableModel !! !! \sa KIM::COLLECTION_ITEM_TYPE::portableModel, !! KIM_COLLECTION_ITEM_TYPE_portableModel !! !! \since 2.1 type(kim_collection_item_type_type), protected, save, & bind(c, name="KIM_COLLECTION_ITEM_TYPE_portableModel") & :: KIM_COLLECTION_ITEM_TYPE_PORTABLE_MODEL !> \brief \copybrief KIM::COLLECTION_ITEM_TYPE::simulatorModel !! !! \sa KIM::COLLECTION_ITEM_TYPE::simulatorModel, !! KIM_COLLECTION_ITEM_TYPE_simulatorModel !! !! \since 2.1 type(kim_collection_item_type_type), protected, save, & bind(c, name="KIM_COLLECTION_ITEM_TYPE_simulatorModel") & :: KIM_COLLECTION_ITEM_TYPE_SIMULATOR_MODEL !> \brief \copybrief KIM::CollectionItemType::Known !! !! \sa KIM::CollectionItemType::Known, KIM_CollectionItemType_Known !! !! \since 2.1 interface kim_known module procedure kim_collection_item_type_known end interface kim_known !> \brief \copybrief KIM::CollectionItemType::operator==() !! !! \sa KIM::CollectionItemType::operator==(), KIM_CollectionItemType_Equal !! !! \since 2.1 interface operator(.eq.) module procedure kim_collection_item_type_equal end interface operator(.eq.) !> \brief \copybrief KIM::CollectionItemType::operator!=() !! !! \sa KIM::CollectionItemType::operator!=(), KIM_CollectionItemType_NotEqual !! !! \since 2.1 interface operator(.ne.) module procedure kim_collection_item_type_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::CollectionItemType::CollectionItemType(std::string const &) !! !! \sa KIM::CollectionItemType::CollectionItemType(std::string const &), !! KIM_CollectionItemType_FromString !! !! \since 2.1 interface kim_from_string module procedure kim_collection_item_type_from_string end interface kim_from_string !> \brief \copybrief KIM::CollectionItemType::ToString !! !! \sa KIM::CollectionItemType::ToString, KIM_CollectionItemType_ToString !! !! \since 2.1 interface kim_to_string module procedure kim_collection_item_type_to_string end interface kim_to_string contains !> \brief \copybrief KIM::CollectionItemType::Known !! !! \sa KIM::CollectionItemType::Known, KIM_CollectionItemType_Known !! !! \since 2.1 logical recursive function kim_collection_item_type_known( & collection_item_type) implicit none interface integer(c_int) recursive function known(collection_item_type) & bind(c, name="KIM_CollectionItemType_Known") use, intrinsic :: iso_c_binding import kim_collection_item_type_type implicit none type(kim_collection_item_type_type), intent(in), value :: & collection_item_type end function known end interface type(kim_collection_item_type_type), intent(in) :: collection_item_type kim_collection_item_type_known = (known(collection_item_type) /= 0) end function kim_collection_item_type_known !> \brief \copybrief KIM::CollectionItemType::operator==() !! !! \sa KIM::CollectionItemType::operator==(), KIM_CollectionItemType_Equal !! !! \since 2.1 logical recursive function kim_collection_item_type_equal(lhs, rhs) implicit none type(kim_collection_item_type_type), intent(in) :: lhs type(kim_collection_item_type_type), intent(in) :: rhs kim_collection_item_type_equal & = (lhs%collection_item_type_id == rhs%collection_item_type_id) end function kim_collection_item_type_equal !> \brief \copybrief KIM::CollectionItemType::operator!=() !! !! \sa KIM::CollectionItemType::operator!=(), KIM_CollectionItemType_NotEqual !! !! \since 2.1 logical recursive function kim_collection_item_type_not_equal(lhs, rhs) implicit none type(kim_collection_item_type_type), intent(in) :: lhs type(kim_collection_item_type_type), intent(in) :: rhs kim_collection_item_type_not_equal = .not. (lhs == rhs) end function kim_collection_item_type_not_equal !> \brief \copybrief KIM::CollectionItemType::CollectionItemType(std::string const &) !! !! \sa KIM::CollectionItemType::CollectionItemType(std::string const &), !! KIM_CollectionItemType_FromString !! !! \since 2.1 recursive subroutine kim_collection_item_type_from_string( & string, collection_item_type) implicit none interface type(kim_collection_item_type_type) recursive function & from_string(string) bind(c, name="KIM_CollectionItemType_FromString") use, intrinsic :: iso_c_binding import kim_collection_item_type_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_collection_item_type_type), intent(out) :: collection_item_type collection_item_type = from_string(trim(string)//c_null_char) end subroutine kim_collection_item_type_from_string !> \brief \copybrief KIM::CollectionItemType::ToString !! !! \sa KIM::CollectionItemType::ToString, KIM_CollectionItemType_ToString !! !! \since 2.1 recursive subroutine kim_collection_item_type_to_string( & collection_item_type, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(collection_item_type) & bind(c, name="KIM_CollectionItemType_ToString") use, intrinsic :: iso_c_binding import kim_collection_item_type_type implicit none type(kim_collection_item_type_type), intent(in), value :: & collection_item_type end function get_string end interface type(kim_collection_item_type_type), intent(in) :: collection_item_type character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(collection_item_type) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_collection_item_type_to_string !> \brief \copybrief KIM::COLLECTION_ITEM_TYPE::GetNumberOfCollectionItemTypes !! !! \sa KIM::COLLECTION_ITEM_TYPE::GetNumberOfCollectionItemTypes, !! KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes !! !! \since 2.1 recursive subroutine kim_get_number_of_collection_item_types( & number_of_collection_item_types) implicit none interface recursive subroutine get_number_of_collection_item_types( & number_of_collection_item_types) & bind(c, name="KIM_COLLECTION_ITEM_TYPE_GetNumberOfCollectionItemTypes") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_collection_item_types end subroutine get_number_of_collection_item_types end interface integer(c_int), intent(out) :: number_of_collection_item_types call get_number_of_collection_item_types(number_of_collection_item_types) end subroutine kim_get_number_of_collection_item_types !> \brief \copybrief KIM::COLLECTION_ITEM_TYPE::GetCollectionItemType !! !! \sa KIM::COLLECTION_ITEM_TYPE::GetCollectionItemType, !! KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType !! !! \since 2.1 recursive subroutine kim_get_collection_item_type(index, & collection_item_type, ierr) implicit none interface integer(c_int) recursive function get_collection_item_type( & index, collection_item_type) & bind(c, name="KIM_COLLECTION_ITEM_TYPE_GetCollectionItemType") use, intrinsic :: iso_c_binding import kim_collection_item_type_type implicit none integer(c_int), intent(in), value :: index type(kim_collection_item_type_type), intent(out) :: collection_item_type end function get_collection_item_type end interface integer(c_int), intent(in) :: index type(kim_collection_item_type_type), intent(out) :: collection_item_type integer(c_int), intent(out) :: ierr ierr = get_collection_item_type(index - 1, collection_item_type) end subroutine kim_get_collection_item_type end module kim_collection_item_type_module kim-api-2.3.0-git/fortran/include/kim_collection_module.f90000066400000000000000000000221241421473465500236160ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::Collection !! !! \sa KIM::Collection, KIM_Collection !! !! \since 2.1 module kim_collection_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_collection_type, & ! Constants KIM_COLLECTION_SYSTEM, & KIM_COLLECTION_USER, & KIM_COLLECTION_ENVIRONMENT_VARIABLE, & KIM_COLLECTION_CURRENT_WORKING_DIRECTORY, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_collections, & kim_get_collection !> \brief \copybrief KIM::Collection !! !! \sa KIM::Collection, KIM_Collection !! !! \since 2.1 type, bind(c) :: kim_collection_type !> \brief \copybrief KIM::Collection::collectionID !! !! \sa KIM::Collection::collectionID, KIM_Collection::collectionID !! !! \since 2.1 integer(c_int) collection_id end type kim_collection_type !> \brief \copybrief KIM::COLLECTION::system !! !! \sa KIM::COLLECTION::system, KIM_COLLECTION_system !! !! \since 2.1 type(kim_collection_type), protected, save, & bind(c, name="KIM_COLLECTION_system") & :: KIM_COLLECTION_SYSTEM !> \brief \copybrief KIM::COLLECTION::user !! !! \sa KIM::COLLECTION::user, KIM_COLLECTION_user !! !! \since 2.1 type(kim_collection_type), protected, save, & bind(c, name="KIM_COLLECTION_user") & :: KIM_COLLECTION_USER !> \brief \copybrief KIM::COLLECTION::environmentVariable !! !! \sa KIM::COLLECTION::environmentVariable, !! KIM_COLLECTION_environmentVariable !! !! \since 2.1 type(kim_collection_type), protected, save, & bind(c, name="KIM_COLLECTION_environmentVariable") & :: KIM_COLLECTION_ENVIRONMENT_VARIABLE !> \brief \copybrief KIM::COLLECTION::currentWorkingDirectory !! !! \sa KIM::COLLECTION::currentWorkingDirectory, !! KIM_COLLECTION_currentWorkingDirectory !! !! \since 2.1 type(kim_collection_type), protected, save, & bind(c, name="KIM_COLLECTION_currentWorkingDirectory") & :: KIM_COLLECTION_CURRENT_WORKING_DIRECTORY !> \brief \copybrief KIM::Collection::Known !! !! \sa KIM::Collection::Known, KIM_Collection_Known !! !! \since 2.1 interface kim_known module procedure kim_collection_known end interface kim_known !> \brief \copybrief KIM::Collection::operator==() !! !! \sa KIM::Collection::operator==(), KIM_Collection_Equal !! !! \since 2.1 interface operator(.eq.) module procedure kim_collection_equal end interface operator(.eq.) !> \brief \copybrief KIM::Collection::operator!=() !! !! \sa KIM::Collection::operator!=(), KIM_Collection_NotEqual !! !! \since 2.1 interface operator(.ne.) module procedure kim_collection_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::Collection::Collection(std::string const &) !! !! \sa KIM::Collection::Collection(std::string const &), !! KIM_Collection_FromString !! !! \since 2.1 interface kim_from_string module procedure kim_collection_from_string end interface kim_from_string !> \brief \copybrief KIM::Collection::ToString !! !! \sa KIM::Collection::ToString, KIM_Collection_ToString !! !! \since 2.1 interface kim_to_string module procedure kim_collection_to_string end interface kim_to_string contains !> \brief \copybrief KIM::Collection::Known !! !! \sa KIM::Collection::Known, KIM_Collection_Known !! !! \since 2.1 logical recursive function kim_collection_known(collection) implicit none interface integer(c_int) recursive function known(collection) & bind(c, name="KIM_Collection_Known") use, intrinsic :: iso_c_binding import kim_collection_type implicit none type(kim_collection_type), intent(in), value :: collection end function known end interface type(kim_collection_type), intent(in) :: collection kim_collection_known = (known(collection) /= 0) end function kim_collection_known !> \brief \copybrief KIM::Collection::operator==() !! !! \sa KIM::Collection::operator==(), KIM_Collection_Equal !! !! \since 2.1 logical recursive function kim_collection_equal(lhs, rhs) implicit none type(kim_collection_type), intent(in) :: lhs type(kim_collection_type), intent(in) :: rhs kim_collection_equal & = (lhs%collection_id == rhs%collection_id) end function kim_collection_equal !> \brief \copybrief KIM::Collection::operator!=() !! !! \sa KIM::Collection::operator!=(), KIM_Collection_NotEqual !! !! \since 2.1 logical recursive function kim_collection_not_equal(lhs, rhs) implicit none type(kim_collection_type), intent(in) :: lhs type(kim_collection_type), intent(in) :: rhs kim_collection_not_equal = .not. (lhs == rhs) end function kim_collection_not_equal !> \brief \copybrief KIM::Collection::Collection(std::string const &) !! !! \sa KIM::Collection::Collection(std::string const &), !! KIM_Collection_FromString !! !! \since 2.1 recursive subroutine kim_collection_from_string(string, collection) implicit none interface type(kim_collection_type) recursive function from_string(string) & bind(c, name="KIM_Collection_FromString") use, intrinsic :: iso_c_binding import kim_collection_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_collection_type), intent(out) :: collection collection = from_string(trim(string)//c_null_char) end subroutine kim_collection_from_string !> \brief \copybrief KIM::Collection::ToString !! !! \sa KIM::Collection::ToString, KIM_Collection_ToString !! !! \since 2.1 recursive subroutine kim_collection_to_string(collection, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(collection) & bind(c, name="KIM_Collection_ToString") use, intrinsic :: iso_c_binding import kim_collection_type implicit none type(kim_collection_type), intent(in), value :: collection end function get_string end interface type(kim_collection_type), intent(in) :: collection character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(collection) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_collection_to_string !> \brief \copybrief KIM::COLLECTION::GetNumberOfCollections !! !! \sa KIM::COLLECTION::GetNumberOfCollections, !! KIM_COLLECTION_GetNumberOfCollections !! !! \since 2.1 recursive subroutine kim_get_number_of_collections(number_of_collections) implicit none interface recursive subroutine get_number_of_collections(number_of_collections) & bind(c, name="KIM_COLLECTION_GetNumberOfCollections") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_collections end subroutine get_number_of_collections end interface integer(c_int), intent(out) :: number_of_collections call get_number_of_collections(number_of_collections) end subroutine kim_get_number_of_collections !> \brief \copybrief KIM::COLLECTION::GetCollection !! !! \sa KIM::COLLECTION::GetCollection, KIM_COLLECTION_GetCollection !! !! \since 2.1 recursive subroutine kim_get_collection(index, collection, ierr) implicit none interface integer(c_int) recursive function get_collection(index, collection) & bind(c, name="KIM_COLLECTION_GetCollection") use, intrinsic :: iso_c_binding import kim_collection_type implicit none integer(c_int), intent(in), value :: index type(kim_collection_type), intent(out) :: collection end function get_collection end interface integer(c_int), intent(in) :: index type(kim_collection_type), intent(out) :: collection integer(c_int), intent(out) :: ierr ierr = get_collection(index - 1, collection) end subroutine kim_get_collection end module kim_collection_module kim-api-2.3.0-git/fortran/include/kim_collections_module.f90000066400000000000000000001565631421473465500240200ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::Collections !! !! \sa KIM::Collections, KIM_Collections !! !! \since 2.1 module kim_collections_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_collections_handle_type, & ! Constants KIM_COLLECTIONS_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_collections_create, & kim_collections_destroy, & kim_get_item_type, & kim_get_item_library_file_name_and_collection, & kim_cache_list_of_item_metadata_files, & kim_get_item_metadata_file_length, & kim_get_item_metadata_file_values, & kim_cache_list_of_item_names_by_type, & kim_get_item_name_by_type, & kim_cache_list_of_item_names_by_collection_and_type, & kim_get_item_name_by_collection_and_type, & kim_get_item_library_file_name_by_collection_and_type, & kim_cache_list_of_item_metadata_files_by_collection_and_type, & kim_get_item_metadata_file_length_by_collection_and_type, & kim_get_item_metadata_file_values_by_collection_and_type, & kim_get_project_name_and_sem_ver, & kim_get_environment_variable_name, & kim_get_configuration_file_environment_variable, & kim_get_configuration_file_name, & kim_cache_list_of_directory_names, & kim_get_directory_name, & kim_set_log_id, & kim_push_log_verbosity, & kim_pop_log_verbosity !> \brief \copybrief KIM::Collections !! !! \sa KIM::Collections, KIM_Collections !! !! \since 2.1 type, bind(c) :: kim_collections_handle_type type(c_ptr) :: p = c_null_ptr end type kim_collections_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.1 type(kim_collections_handle_type), protected, save & :: KIM_COLLECTIONS_NULL_HANDLE !> \brief Compares kim_collections_handle_type's for equality. !! !! \since 2.1 interface operator(.eq.) module procedure kim_collections_handle_equal end interface operator(.eq.) !> \brief Compares kim_collections_handle_type's for inequality. !! !! \since 2.1 interface operator(.ne.) module procedure kim_collections_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::Collections::GetItemType !! !! \sa KIM::Collections::GetItemType, KIM_Collections_GetItemType !! !! \since 2.1 interface kim_get_item_type module procedure kim_collections_get_item_type end interface kim_get_item_type !> \brief \copybrief KIM::Collections::GetItemLibraryFileNameAndCollection !! !! \sa KIM::Collections::GetItemLibraryFileNameAndCollection, !! KIM_Collections_GetItemLibraryFileNameAndCollection !! !! \since 2.1 interface kim_get_item_library_file_name_and_collection module procedure kim_collections_get_item_library_file_name_and_collection end interface kim_get_item_library_file_name_and_collection !> \brief \copybrief KIM::Collections::CacheListOfItemMetadataFiles !! !! \sa KIM::Collections::CacheListOfItemMetadataFiles, !! KIM_Collections_CacheListOfItemMetadataFiles !! !! \since 2.1 interface kim_cache_list_of_item_metadata_files module procedure kim_collections_cache_list_of_item_metadata_files end interface kim_cache_list_of_item_metadata_files !> \brief Get item metadata file length and determine if the file is !! available as a string. !! !! \sa KIM::Collections::GetItemMetadataFile, !! KIM_Collections_GetItemMetadataFile !! !! \since 2.1 interface kim_get_item_metadata_file_length module procedure kim_collections_get_item_metadata_file_length end interface kim_get_item_metadata_file_length !> \brief Get the item's metadata file values. !! !! \sa KIM::Collections::GetItemMetadataFile, !! KIM_Collections_GetItemMetadataFile !! !! \since 2.1 interface kim_get_item_metadata_file_values module procedure kim_collections_get_item_metadata_file_values end interface kim_get_item_metadata_file_values !> \brief \copybrief KIM::Collections::CacheListOfItemNamesByType !! !! \sa KIM::Collections::CacheListOfItemNamesByType, !! KIM_Collections_CacheListOfItemNamesByType !! !! \since 2.1 interface kim_cache_list_of_item_names_by_type module procedure kim_collections_cache_list_of_item_names_by_type end interface kim_cache_list_of_item_names_by_type !> \brief \copybrief KIM::Collections::GetItemNameByType !! !! \sa KIM::Collections::GetItemNameByType, KIM_Collections_GetItemNameByType !! !! \since 2.1 interface kim_get_item_name_by_type module procedure kim_collections_get_item_name_by_type end interface kim_get_item_name_by_type !> \brief \copybrief KIM::Collections::CacheListOfItemNamesByCollectionAndType !! !! \sa KIM::Collections::CacheListOfItemNamesByCollectionAndType, !! KIM_Collections_CacheListOfItemNamesByCollectionAndType !! !! \since 2.1 interface kim_cache_list_of_item_names_by_collection_and_type module procedure & kim_collections_cache_list_of_item_names_by_collection_and_type end interface kim_cache_list_of_item_names_by_collection_and_type !> \brief \copybrief KIM::Collections::GetItemNameByCollectionAndType !! !! \sa KIM::Collections::GetItemNameByCollectionAndType, !! KIM_Collections_GetItemNameByCollectionAndType !! !! \since 2.1 interface kim_get_item_name_by_collection_and_type module procedure kim_collections_get_item_name_by_collection_and_type end interface kim_get_item_name_by_collection_and_type !> \brief \copybrief KIM::Collections::GetItemLibraryFileNameByCollectionAndType !! !! \sa KIM::Collections::GetItemLibraryFileNameByCollectionAndType, !! KIM_Collections_GetItemLibraryFileNameByCollectionAndType !! !! \since 2.1 interface kim_get_item_library_file_name_by_collection_and_type module procedure & kim_collections_get_item_library_file_name_by_coll_and_type end interface kim_get_item_library_file_name_by_collection_and_type !> \brief \copybrief KIM::Collections::CacheListOfItemMetadataFilesByCollectionAndType !! !! \sa KIM::Collections::CacheListOfItemMetadataFilesByCollectionAndType, !! KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType !! !! \since 2.1 interface kim_cache_list_of_item_metadata_files_by_collection_and_type module procedure & kim_colls_cache_list_of_item_metadata_files_by_coll_and_type end interface kim_cache_list_of_item_metadata_files_by_collection_and_type !> \brief Get item metadata file length and determine if the file is !! available as a string. !! !! \sa KIM::Collections::GetItemMetadataFileByCollectionAndType, !! KIM_Collections_GetItemMetadataFileByCollectionAndType !! !! \since 2.1 interface kim_get_item_metadata_file_length_by_collection_and_type module procedure & kim_collections_get_item_metadata_file_length_by_coll_and_type end interface kim_get_item_metadata_file_length_by_collection_and_type !> \brief Get the item's metadata file values. !! !! \sa KIM::Collections::GetItemMetadataFileByCollectionAndType, !! KIM_Collections_GetItemMetadataFileByCollectionAndType !! !! \since 2.1 interface kim_get_item_metadata_file_values_by_collection_and_type module procedure & kim_collections_get_item_metadata_file_values_by_coll_and_type end interface kim_get_item_metadata_file_values_by_collection_and_type !> \brief \copybrief KIM::Collections::GetProjectNameAndSemVer !! !! \sa KIM::Collections::GetProjectNameAndSemVer, !! KIM_Collections_GetProjectNameAndSemVer !! !! \since 2.1 interface kim_get_project_name_and_sem_ver module procedure kim_collections_get_project_name_and_sem_ver end interface kim_get_project_name_and_sem_ver !> \brief \copybrief KIM::Collections::GetEnvironmentVariableName !! !! \sa KIM::Collections::GetEnvironmentVariableName, !! KIM_Collections_GetEnvironmentVariableName !! !! \since 2.1 interface kim_get_environment_variable_name module procedure kim_collections_get_environment_variable_name end interface kim_get_environment_variable_name !> \brief \copybrief KIM::Collections::GetConfigurationFileEnvironmentVariable !! !! \sa KIM::Collections::GetConfigurationFileEnvironmentVariable, !! KIM_Collections_GetConfigurationFileEnvironmentVariable !! !! \since 2.1 interface kim_get_configuration_file_environment_variable module procedure kim_collections_get_configuration_file_environment_variable end interface kim_get_configuration_file_environment_variable !> \brief \copybrief KIM::Collections::GetConfigurationFileName !! !! \sa KIM::Collections::GetConfigurationFileName, !! KIM_Collections_GetConfigurationFileName !! !! \since 2.1 interface kim_get_configuration_file_name module procedure kim_collections_get_configuration_file_name end interface kim_get_configuration_file_name !> \brief \copybrief KIM::Collections::CacheListOfDirectoryNames !! !! \sa KIM::Collections::CacheListOfDirectoryNames, !! KIM_Collections_CacheListOfDirectoryNames !! !! \since 2.1 interface kim_cache_list_of_directory_names module procedure kim_collections_cache_list_of_directory_names end interface kim_cache_list_of_directory_names !> \brief \copybrief KIM::Collections::GetDirectoryName !! !! \sa KIM::Collections::GetDirectoryName, KIM_Collections_GetDirectoryName !! !! \since 2.1 interface kim_get_directory_name module procedure kim_collections_get_directory_name end interface kim_get_directory_name !> \brief \copybrief KIM::Collections::SetLogID !! !! \sa KIM::Collections::SetLogID, KIM_Collections_SetLogID !! !! \since 2.1 interface kim_set_log_id module procedure kim_collections_set_log_id end interface kim_set_log_id !> \brief \copybrief KIM::Collections::PushLogVerbosity !! !! \sa KIM::Collections::PushLogVerbosity, KIM_Collections_PushLogVerbosity !! !! \since 2.1 interface kim_push_log_verbosity module procedure kim_collections_push_log_verbosity end interface kim_push_log_verbosity !> \brief \copybrief KIM::Collections::PopLogVerbosity !! !! \sa KIM::Collections::, KIM_Collections_PopLogVerbosity !! !! \since 2.1 interface kim_pop_log_verbosity module procedure kim_collections_pop_log_verbosity end interface kim_pop_log_verbosity contains !> \brief Compares kim_collections_handle_type's for equality. !! !! \since 2.1 logical recursive function kim_collections_handle_equal(lhs, rhs) implicit none type(kim_collections_handle_type), intent(in) :: lhs type(kim_collections_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_collections_handle_equal = .true. else kim_collections_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_collections_handle_equal !> \brief Compares kim_collections_handle_type's for inequality. !! !! \since 2.1 logical recursive function kim_collections_handle_not_equal(lhs, rhs) implicit none type(kim_collections_handle_type), intent(in) :: lhs type(kim_collections_handle_type), intent(in) :: rhs kim_collections_handle_not_equal = .not. (lhs == rhs) end function kim_collections_handle_not_equal !> \brief \copybrief KIM::Collections::Create !! !! \sa KIM::Collections::Create, KIM_Collections_Create !! !! \since 2.1 recursive subroutine kim_collections_create(collections_handle, ierr) implicit none interface integer(c_int) recursive function create(collections) & bind(c, name="KIM_Collections_Create") use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(out) :: collections end function create end interface type(kim_collections_handle_type), intent(out) :: collections_handle integer(c_int), intent(out) :: ierr type(c_ptr) :: pcollections ierr = create(pcollections) collections_handle%p = pcollections end subroutine kim_collections_create !> \brief \copybrief KIM::Collections::Destroy !! !! \sa KIM::Collections::Destroy, KIM_Collections_Destroy !! !! \since 2.1 recursive subroutine kim_collections_destroy(collections_handle) implicit none interface recursive subroutine destroy(collections) & bind(c, name="KIM_Collections_Destroy") use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(inout) :: collections end subroutine destroy end interface type(kim_collections_handle_type), intent(inout) :: collections_handle type(c_ptr) :: pcollections pcollections = collections_handle%p call destroy(pcollections) collections_handle%p = c_null_ptr end subroutine kim_collections_destroy !> \brief \copybrief KIM::Collections::GetItemType !! !! \sa KIM::Collections::GetItemType, KIM_Collections_GetItemType !! !! \since 2.1 recursive subroutine kim_collections_get_item_type(collections_handle, & item_name, item_type, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function get_item_type( & collections, item_name, item_type) & bind(c, name="KIM_Collections_GetItemType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections character(c_char), intent(in) :: item_name(*) type(kim_collection_item_type_type), intent(out) :: item_type end function get_item_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle character(len=*, kind=c_char), intent(in) :: item_name type(kim_collection_item_type_type), intent(out) :: item_type integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) ierr = get_item_type(collections, trim(item_name)//c_null_char, item_type) end subroutine kim_collections_get_item_type !> \brief \copybrief KIM::Collections::GetItemLibraryFileNameAndCollection !! !! \sa KIM::Collections::GetItemLibraryFileNameAndCollection, !! KIM_Collections_GetItemLibraryFileNameAndCollection !! !! \since 2.1 recursive subroutine & kim_collections_get_item_library_file_name_and_collection( & collections_handle, item_type, item_name, file_name, collection, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function & get_item_library_file_name_and_collection( & collections, item_type, item_name, file_name, collection) & bind(c, name="KIM_Collections_GetItemLibraryFileNameAndCollection") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_item_type_type), intent(in), value :: item_type character(c_char), intent(in) :: item_name(*) type(c_ptr), intent(out) :: file_name type(kim_collection_type), intent(out) :: collection end function get_item_library_file_name_and_collection end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_item_type_type), intent(in) :: item_type character(len=*, kind=c_char), intent(in) :: item_name character(len=*, kind=c_char), intent(out) :: file_name type(kim_collection_type), intent(out) :: collection integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) :: pfile_name call c_f_pointer(collections_handle%p, collections) ierr = get_item_library_file_name_and_collection( & collections, & item_type, & trim(item_name)//c_null_char, & pfile_name, & collection) call kim_convert_c_char_ptr_to_string(pfile_name, file_name) end subroutine kim_collections_get_item_library_file_name_and_collection !> \brief \copybrief KIM::Collections::CacheListOfItemMetadataFiles !! !! \sa KIM::Collections::CacheListOfItemMetadataFiles, !! KIM_Collections_CacheListOfItemMetadataFiles !! !! \since 2.1 recursive subroutine kim_collections_cache_list_of_item_metadata_files( & collections_handle, item_type, item_name, extent, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function cache_list_of_item_metadata_files( & collections, item_type, item_name, extent) & bind(c, name="KIM_Collections_CacheListOfItemMetadataFiles") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_item_type_type), intent(in), value :: item_type character(c_char), intent(in) :: item_name(*) integer(c_int), intent(out) :: extent end function cache_list_of_item_metadata_files end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_item_type_type), intent(in) :: item_type character(len=*, kind=c_char), intent(in) :: item_name integer(c_int), intent(out) :: extent integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) ierr = cache_list_of_item_metadata_files(collections, item_type, & trim(item_name)//c_null_char, & extent) end subroutine kim_collections_cache_list_of_item_metadata_files !> \brief Get item metadata file length and determine if the file is !! available as a string. !! !! \sa KIM::Collections::GetItemMetadataFile, !! KIM_Collections_GetItemMetadataFile !! !! \since 2.1 recursive subroutine kim_collections_get_item_metadata_file_length( & collections_handle, index, file_length, available_as_string, ierr) use kim_interoperable_types_module, only: kim_collections_type implicit none interface integer(c_int) recursive function get_item_metadata_file( & collections, index, file_name, file_length, file_raw_data, & available_as_string, file_string) & bind(c, name="KIM_Collections_GetItemMetadataFile_fortran") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: file_name integer(c_long), intent(out) :: file_length type(c_ptr), intent(out) :: file_raw_data integer(c_int), intent(out) :: available_as_string type(c_ptr), intent(out) :: file_string end function get_item_metadata_file end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in) :: index integer(c_long), intent(out) :: file_length integer(c_int), intent(out) :: available_as_string integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pfile_name, pfile_raw_data, pfile_string call c_f_pointer(collections_handle%p, collections) ierr = get_item_metadata_file(collections, & index - 1, & pfile_name, & file_length, & pfile_raw_data, & available_as_string, & pfile_string) end subroutine kim_collections_get_item_metadata_file_length !> \brief Get the item's metadata file values. !! !! \sa KIM::Collections::GetItemMetadataFile, !! KIM_Collections_GetItemMetadataFile !! !! \since 2.1 recursive subroutine kim_collections_get_item_metadata_file_values( & collections_handle, index, file_name, file_raw_data, file_string, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_item_metadata_file( & collections, index, file_name, file_length, file_raw_data, & available_as_string, file_string) & bind(c, name="KIM_Collections_GetItemMetadataFile_fortran") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: file_name integer(c_long), intent(out) :: file_length type(c_ptr), intent(out) :: file_raw_data integer(c_int), intent(out) :: available_as_string type(c_ptr), intent(out) :: file_string end function get_item_metadata_file end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: file_name integer(c_signed_char), intent(out) :: file_raw_data(:) character(len=*, kind=c_char), intent(out) :: file_string integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections integer(c_long) file_length integer(c_int) available_as_string type(c_ptr) pfile_name, pfile_raw_data, pfile_string integer(c_signed_char), pointer :: file_raw_data_fpointer(:) call c_f_pointer(collections_handle%p, collections) ierr = get_item_metadata_file(collections, & index - 1, & pfile_name, & file_length, & pfile_raw_data, & available_as_string, & pfile_string) if (ierr == 0) then if (size(file_raw_data) < file_length) then ierr = 1 return end if if (available_as_string == 1) then if (len(file_string) < file_length) then ierr = 1 return end if end if call kim_convert_c_char_ptr_to_string(pfile_name, file_name) if (c_associated(pfile_raw_data)) then call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length]) else nullify (file_raw_data_fpointer) end if file_raw_data = file_raw_data_fpointer(1:file_length) if (available_as_string == 1) then call kim_convert_c_char_ptr_to_string(pfile_string, file_string) end if end if end subroutine kim_collections_get_item_metadata_file_values !> \brief \copybrief KIM::Collections::CacheListOfItemNamesByType !! !! \sa KIM::Collections::CacheListOfItemNamesByType, !! KIM_Collections_CacheListOfItemNamesByType !! !! \since 2.1 recursive subroutine kim_collections_cache_list_of_item_names_by_type( & collections_handle, item_type, extent, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function cache_list_of_item_names_by_type( & collections, item_type, extent) & bind(c, name="KIM_Collections_CacheListOfItemNamesByType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_item_type_type), intent(in), value :: item_type integer(c_int), intent(out) :: extent end function cache_list_of_item_names_by_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_item_type_type), intent(in) :: item_type integer(c_int), intent(out) :: extent integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) ierr = cache_list_of_item_names_by_type(collections, item_type, extent) end subroutine kim_collections_cache_list_of_item_names_by_type !> \brief \copybrief KIM::Collections::GetItemNameByType !! !! \sa KIM::Collections::GetItemNameByType, KIM_Collections_GetItemNameByType !! !! \since 2.1 recursive subroutine kim_collections_get_item_name_by_type( & collections_handle, index, item_name, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_item_name_by_type( & collections, index, item_name) & bind(c, name="KIM_Collections_GetItemNameByType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: item_name end function get_item_name_by_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: item_name integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pitem_name call c_f_pointer(collections_handle%p, collections) ierr = get_item_name_by_type(collections, index - 1, pitem_name) call kim_convert_c_char_ptr_to_string(pitem_name, item_name) end subroutine kim_collections_get_item_name_by_type !> \brief \copybrief KIM::Collections::CacheListOfItemNamesByCollectionAndType !! !! \sa KIM::Collections::CacheListOfItemNamesByCollectionAndType, !! KIM_Collections_CacheListOfItemNamesByCollectionAndType !! !! \since 2.1 recursive subroutine & kim_collections_cache_list_of_item_names_by_collection_and_type( & collections_handle, collection, item_type, extent, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function & cache_list_of_item_names_by_collection_and_type( & collections, collection, item_type, extent) & bind(c, name="KIM_Collections_CacheListOfItemNamesByCollectionAndType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_type), intent(in), value :: collection type(kim_collection_item_type_type), intent(in), value :: item_type integer(c_int), intent(out) :: extent end function cache_list_of_item_names_by_collection_and_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_type), intent(in) :: collection type(kim_collection_item_type_type), intent(in) :: item_type integer(c_int), intent(out) :: extent integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) ierr = cache_list_of_item_names_by_collection_and_type(collections, & collection, & item_type, & extent) end subroutine kim_collections_cache_list_of_item_names_by_collection_and_type !> \brief \copybrief KIM::Collections::GetItemNameByCollectionAndType !! !! \sa KIM::Collections::GetItemNameByCollectionAndType, !! KIM_Collections_GetItemNameByCollectionAndType !! !! \since 2.1 recursive subroutine kim_collections_get_item_name_by_collection_and_type( & collections_handle, index, item_name, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_item_name_by_collection_and_type( & collections, index, item_name) & bind(c, name="KIM_Collections_GetItemNameByCollectionAndType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: item_name end function get_item_name_by_collection_and_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: item_name integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pitem_name call c_f_pointer(collections_handle%p, collections) ierr = get_item_name_by_collection_and_type(collections, index - 1, & pitem_name) call kim_convert_c_char_ptr_to_string(pitem_name, item_name) end subroutine kim_collections_get_item_name_by_collection_and_type !> \brief \copybrief KIM::Collections::GetItemLibraryFileNameByCollectionAndType !! !! \sa KIM::Collections::GetItemLibraryFileNameByCollectionAndType, !! KIM_Collections_GetItemLibraryFileNameByCollectionAndType !! !! \since 2.1 recursive subroutine & kim_collections_get_item_library_file_name_by_coll_and_type( & collections_handle, collection, item_type, item_name, file_name, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function & get_item_library_file_name_by_coll_and_type( & collections, collection, item_type, item_name, file_name) & bind(c, & name="KIM_Collections_GetItemLibraryFileNameByCollectionAndType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_type), intent(in), value :: collection type(kim_collection_item_type_type), intent(in), value :: item_type character(c_char), intent(in) :: item_name(*) type(c_ptr), intent(out) :: file_name end function get_item_library_file_name_by_coll_and_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_type), intent(in) :: collection type(kim_collection_item_type_type), intent(in) :: item_type character(len=*, kind=c_char), intent(in) :: item_name character(len=*, kind=c_char), intent(out) :: file_name integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pfile_name call c_f_pointer(collections_handle%p, collections) ierr = get_item_library_file_name_by_coll_and_type( & collections, & collection, & item_type, & trim(item_name)//c_null_char, & pfile_name) call kim_convert_c_char_ptr_to_string(pfile_name, file_name) end subroutine kim_collections_get_item_library_file_name_by_coll_and_type !> \brief \copybrief KIM::Collections::CacheListOfItemMetadataFilesByCollectionAndType !! !! \sa KIM::Collections::CacheListOfItemMetadataFilesByCollectionAndType, !! KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType !! !! \since 2.1 recursive subroutine & kim_colls_cache_list_of_item_metadata_files_by_coll_and_type( & collections_handle, collection, item_type, item_name, extent, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function & cache_list_of_item_metadata_files_by_coll_and_type( & collections, collection, item_type, item_name, extent) & bind(c, & name= & "KIM_Collections_CacheListOfItemMetadataFilesByCollectionAndType") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_type), intent(in), value :: collection type(kim_collection_item_type_type), intent(in), value :: item_type character(c_char), intent(in) :: item_name(*) integer(c_int), intent(out) :: extent end function cache_list_of_item_metadata_files_by_coll_and_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_type), intent(in) :: collection type(kim_collection_item_type_type), intent(in) :: item_type character(len=*, kind=c_char), intent(in) :: item_name integer(c_int), intent(out) :: extent integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) ierr = cache_list_of_item_metadata_files_by_coll_and_type( & collections, & collection, & item_type, & trim(item_name)//c_null_char, & extent) end subroutine kim_colls_cache_list_of_item_metadata_files_by_coll_and_type !> \brief \copybrief KIM::Collections::GetItemMetadataFileByCollectionAndType !! !! \sa KIM::Collections::GetItemMetadataFileByCollectionAndType, !! KIM_Collections_GetItemMetadataFileByCollectionAndType !! !! \since 2.1 recursive subroutine & kim_collections_get_item_metadata_file_length_by_coll_and_type( & collections_handle, index, file_length, available_as_string, ierr) use kim_interoperable_types_module, only: kim_collections_type implicit none interface integer(c_int) recursive function & get_item_metadata_file_by_coll_and_type( & collections, index, & file_name, & file_length, & file_raw_data, & available_as_string, & file_string) & bind(c, & name= & "KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: file_name integer(c_long), intent(out) :: file_length type(c_ptr), intent(out) :: file_raw_data integer(c_int), intent(out) :: available_as_string type(c_ptr), intent(out) :: file_string end function get_item_metadata_file_by_coll_and_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in), value :: index integer(c_long), intent(out) :: file_length integer(c_int), intent(out) :: available_as_string integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pfile_name, pfile_raw_data, pfile_string call c_f_pointer(collections_handle%p, collections) ierr = get_item_metadata_file_by_coll_and_type(collections, & index - 1, & pfile_name, & file_length, & pfile_raw_data, & available_as_string, & pfile_string) end subroutine kim_collections_get_item_metadata_file_length_by_coll_and_type !> \brief Get the item's metadata file values. !! !! \sa KIM::Collections::GetItemMetadataFileByCollectionAndType, !! KIM_Collections_GetItemMetadataFileByCollectionAndType !! !! \since 2.1 recursive subroutine & kim_collections_get_item_metadata_file_values_by_coll_and_type( & collections_handle, index, file_name, file_raw_data, file_string, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function & get_item_metadata_file_by_coll_and_type(collections, & index, & file_name, & file_length, & file_raw_data, & available_as_string, & file_string) & bind(c, & name= & "KIM_Collections_GetItemMetadataFileByCollectionAndType_fortran") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: file_name integer(c_long), intent(out) :: file_length type(c_ptr), intent(out) :: file_raw_data integer(c_int), intent(out) :: available_as_string type(c_ptr), intent(out) :: file_string end function get_item_metadata_file_by_coll_and_type end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: file_name integer(c_signed_char), intent(out) :: file_raw_data(:) character(len=*, kind=c_char), intent(out) :: file_string integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections integer(c_long) file_length integer(c_int) available_as_string type(c_ptr) pfile_name, pfile_raw_data, pfile_string integer(c_signed_char), pointer :: file_raw_data_fpointer(:) call c_f_pointer(collections_handle%p, collections) ierr = get_item_metadata_file_by_coll_and_type(collections, & index - 1, & pfile_name, & file_length, & pfile_raw_data, & available_as_string, & pfile_string) if (ierr == 0) then if (size(file_raw_data) < file_length) then ierr = 1 return end if if (available_as_string == 1) then if (len(file_string) < file_length) then ierr = 1 return end if end if call kim_convert_c_char_ptr_to_string(pfile_name, file_name) if (c_associated(pfile_raw_data)) then call c_f_pointer(pfile_raw_data, file_raw_data_fpointer, [file_length]) else nullify (file_raw_data_fpointer) end if file_raw_data = file_raw_data_fpointer(1:file_length) if (available_as_string == 1) then call kim_convert_c_char_ptr_to_string(pfile_string, file_string) end if end if end subroutine kim_collections_get_item_metadata_file_values_by_coll_and_type !> \brief \copybrief KIM::Collections::GetProjectNameAndSemVer !! !! \sa KIM::Collections::GetProjectNameAndSemVer, !! KIM_Collections_GetProjectNameAndSemVer !! !! \since 2.1 recursive subroutine kim_collections_get_project_name_and_sem_ver( & collections_handle, project_name, sem_ver) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_project_name_and_sem_ver(collections, & project_name, sem_ver) & bind(c, name="KIM_Collections_GetProjectNameAndSemVer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections type(c_ptr), intent(out) :: project_name type(c_ptr), intent(out) :: sem_ver end subroutine get_project_name_and_sem_ver end interface type(kim_collections_handle_type), intent(in) :: collections_handle character(len=*, kind=c_char), intent(out) :: project_name character(len=*, kind=c_char), intent(out) :: sem_ver type(kim_collections_type), pointer :: collections type(c_ptr) pproject_name, psem_ver call c_f_pointer(collections_handle%p, collections) call get_project_name_and_sem_ver(collections, pproject_name, psem_ver) call kim_convert_c_char_ptr_to_string(pproject_name, project_name) call kim_convert_c_char_ptr_to_string(psem_ver, sem_ver) end subroutine kim_collections_get_project_name_and_sem_ver !> \brief \copybrief KIM::Collections::GetEnvironmentVariableName !! !! \sa KIM::Collections::GetEnvironmentVariableName, !! KIM_Collections_GetEnvironmentVariableName !! !! \since 2.1 recursive subroutine kim_collections_get_environment_variable_name( & collections_handle, item_type, name, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function get_environment_variable_name( & collections, item_type, name) & bind(c, name="KIM_Collections_GetEnvironmentVariableName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_item_type_type), intent(in), value :: item_type type(c_ptr), intent(out) :: name end function get_environment_variable_name end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_item_type_type), intent(in) :: item_type character(len=*, kind=c_char), intent(out) :: name integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pname call c_f_pointer(collections_handle%p, collections) ierr = get_environment_variable_name(collections, item_type, pname) call kim_convert_c_char_ptr_to_string(pname, name) end subroutine kim_collections_get_environment_variable_name !> \brief \copybrief KIM::Collections::GetConfigurationFileEnvironmentVariable !! !! \sa KIM::Collections::GetConfigurationFileEnvironmentVariable, !! KIM_Collections_GetConfigurationFileEnvironmentVariable !! !! \since 2.1 recursive subroutine & kim_collections_get_configuration_file_environment_variable( & collections_handle, name, value) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_configuration_file_environment_variable( & collections, name, value) & bind(c, name="KIM_Collections_GetConfigurationFileEnvironmentVariable") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections type(c_ptr), intent(out) :: name type(c_ptr), intent(out) :: value end subroutine get_configuration_file_environment_variable end interface type(kim_collections_handle_type), intent(in) :: collections_handle character(len=*, kind=c_char), intent(out) :: name character(len=*, kind=c_char), intent(out) :: value type(kim_collections_type), pointer :: collections type(c_ptr) pname, pvalue call c_f_pointer(collections_handle%p, collections) call get_configuration_file_environment_variable(collections, pname, pvalue) call kim_convert_c_char_ptr_to_string(pname, name) call kim_convert_c_char_ptr_to_string(pvalue, value) end subroutine kim_collections_get_configuration_file_environment_variable !> \brief \copybrief KIM::Collections::GetConfigurationFileName !! !! \sa KIM::Collections::GetConfigurationFileName, !! KIM_Collections_GetConfigurationFileName !! !! \since 2.1 recursive subroutine kim_collections_get_configuration_file_name( & collections_handle, file_name) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_configuration_file_name(collections, file_name) & bind(c, name="KIM_Collections_GetConfigurationFileName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections type(c_ptr), intent(out) :: file_name end subroutine get_configuration_file_name end interface type(kim_collections_handle_type), intent(in) :: collections_handle character(len=*, kind=c_char), intent(out) :: file_name type(kim_collections_type), pointer :: collections type(c_ptr) pfile_name call c_f_pointer(collections_handle%p, collections) call get_configuration_file_name(collections, pfile_name) call kim_convert_c_char_ptr_to_string(pfile_name, file_name) end subroutine kim_collections_get_configuration_file_name !> \brief \copybrief KIM::Collections::CacheListOfDirectoryNames !! !! \sa KIM::Collections::CacheListOfDirectoryNames, !! KIM_Collections_CacheListOfDirectoryNames !! !! \since 2.1 recursive subroutine kim_collections_cache_list_of_directory_names( & collections_handle, collection, item_type, extent, ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: kim_collection_item_type_type implicit none interface integer(c_int) recursive function cache_list_of_directory_names( & collections, collection, item_type, extent) & bind(c, name="KIM_Collections_CacheListOfDirectoryNames") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type use kim_collection_module, only: kim_collection_type use kim_collection_item_type_module, only: & kim_collection_item_type_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_collection_type), intent(in), value :: collection type(kim_collection_item_type_type), intent(in), value :: item_type integer(c_int), intent(out) :: extent end function cache_list_of_directory_names end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collection_type), intent(in) :: collection type(kim_collection_item_type_type), intent(in) :: item_type integer(c_int), intent(out) :: extent integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) ierr = cache_list_of_directory_names(collections, collection, item_type, & extent) end subroutine kim_collections_cache_list_of_directory_names !> \brief \copybrief KIM::Collections::GetDirectoryName !! !! \sa KIM::Collections::GetDirectoryName, KIM_Collections_GetDirectoryName !! !! \since 2.1 recursive subroutine kim_collections_get_directory_name(collections_handle, & index, & directory_name, & ierr) use kim_interoperable_types_module, only: kim_collections_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_directory_name(collections, index, & directory_name) & bind(c, name="KIM_Collections_GetDirectoryName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: directory_name end function get_directory_name end interface type(kim_collections_handle_type), intent(in) :: collections_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: directory_name integer(c_int), intent(out) :: ierr type(kim_collections_type), pointer :: collections type(c_ptr) pdirectory_name call c_f_pointer(collections_handle%p, collections) ierr = get_directory_name(collections, index - 1, pdirectory_name) call kim_convert_c_char_ptr_to_string(pdirectory_name, directory_name) end subroutine kim_collections_get_directory_name !> \brief \copybrief KIM::Collections::SetLogID !! !! \sa KIM::Collections::SetLogID, KIM_Collections_SetLogID !! !! \since 2.1 recursive subroutine kim_collections_set_log_id(collections_handle, log_id) use kim_interoperable_types_module, only: kim_collections_type implicit none interface recursive subroutine set_log_id(collections, log_id) & bind(c, name="KIM_Collections_SetLogID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections character(c_char), intent(in) :: log_id(*) end subroutine set_log_id end interface type(kim_collections_handle_type), intent(in) :: collections_handle character(len=*, kind=c_char), intent(in) :: log_id type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) call set_log_id(collections, trim(log_id)//c_null_char) end subroutine kim_collections_set_log_id !> \brief \copybrief KIM::Collections::PushLogVerbosity !! !! \sa KIM::Collections::PushLogVerbosity, KIM_Collections_PushLogVerbosity !! !! \since 2.1 recursive subroutine kim_collections_push_log_verbosity(collections_handle, & log_verbosity) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_collections_type implicit none interface recursive subroutine push_log_verbosity(collections, log_verbosity) & bind(c, name="KIM_Collections_PushLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections type(kim_log_verbosity_type), intent(in), value :: log_verbosity end subroutine push_log_verbosity end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) call push_log_verbosity(collections, log_verbosity) end subroutine kim_collections_push_log_verbosity !> \brief \copybrief KIM::Collections::PopLogVerbosity !! !! \sa KIM::Collections::, KIM_Collections_PopLogVerbosity !! !! \since 2.1 recursive subroutine kim_collections_pop_log_verbosity(collections_handle) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_collections_type implicit none interface recursive subroutine pop_log_verbosity(collections) & bind(c, name="KIM_Collections_PopLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_collections_type implicit none type(kim_collections_type), intent(in) :: collections end subroutine pop_log_verbosity end interface type(kim_collections_handle_type), intent(in) :: collections_handle type(kim_collections_type), pointer :: collections call c_f_pointer(collections_handle%p, collections) call pop_log_verbosity(collections) end subroutine kim_collections_pop_log_verbosity end module kim_collections_module kim-api-2.3.0-git/fortran/include/kim_compute_argument_name_module.f90000066400000000000000000000347761421473465500260610ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ComputeArgumentName !! !! \sa KIM::ComputeArgumentName, KIM_ComputeArgumentName !! !! \since 2.0 module kim_compute_argument_name_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_compute_argument_name_type, & ! Constants KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES, & KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING, & KIM_COMPUTE_ARGUMENT_NAME_COORDINATES, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, & KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_VIRIAL, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_compute_argument_names, & kim_get_compute_argument_name, & kim_get_compute_argument_data_type !> \brief \copybrief KIM::ComputeArgumentName !! !! \sa KIM::ComputeArgumentName, KIM_ComputeArgumentName !! !! \since 2.0 type, bind(c) :: kim_compute_argument_name_type !> \brief \copybrief KIM::ComputeArgumentName::computeArgumentNameID !! !! \sa KIM::ComputeArgumentName::computeArgumentNameID, !! KIM_ComputeArgumentName::computeArgumentNameID !! !! \since 2.0 integer(c_int) compute_argument_name_id end type kim_compute_argument_name_type !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles, !! KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles") & :: KIM_COMPUTE_ARGUMENT_NAME_NUMBER_OF_PARTICLES !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::particleSpeciesCodes, !! KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_SPECIES_CODES !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::particleContributing !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::particleContributing, !! KIM_COMPUTE_ARGUMENT_NAME_particleContributing !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_particleContributing") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTICLE_CONTRIBUTING !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::coordinates !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::coordinates, !! KIM_COMPUTE_ARGUMENT_NAME_coordinates !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_coordinates") & :: KIM_COMPUTE_ARGUMENT_NAME_COORDINATES !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialEnergy !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::partialEnergy, !! KIM_COMPUTE_ARGUMENT_NAME_partialEnergy !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialEnergy") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_ENERGY !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialForces !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::partialForces, !! KIM_COMPUTE_ARGUMENT_NAME_partialForces !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialForces") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_FORCES !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::partialParticleEnergy, !! KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_ENERGY !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialVirial !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::partialVirial, !! KIM_COMPUTE_ARGUMENT_NAME_partialVirial !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialVirial") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::partialParticleVirial, !! KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial !! !! \since 2.0 type(kim_compute_argument_name_type), protected, save, & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial") & :: KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_PARTICLE_VIRIAL !> \brief \copybrief KIM::ComputeArgumentName::Known !! !! \sa KIM::ComputeArgumentName::Known, KIM_ComputeArgumentName_Known !! !! \since 2.0 interface kim_known module procedure kim_compute_argument_name_known end interface kim_known !> \brief \copybrief KIM::ComputeArgumentName::operator==() !! !! \sa KIM::ComputeArgumentName::operator==(), KIM_ComputeArgumentName_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_compute_argument_name_equal end interface operator(.eq.) !> \brief \copybrief KIM::ComputeArgumentName::operator!=() !! !! \sa KIM::ComputeArgumentName::operator!=(), !! KIM_ComputeArgumentName_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_compute_argument_name_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ComputeArgumentName::ComputeArgumentName(std::string const &) !! !! \sa KIM::ComputeArgumentName::ComputeArgumentName(std::string const &), !! KIM_ComputeArgumentName_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_compute_argument_name_from_string end interface kim_from_string !> \brief \copybrief KIM::ComputeArgumentName::ToString !! !! \sa KIM::ComputeArgumentName::ToString, KIM_ComputeArgumentName_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_compute_argument_name_to_string end interface kim_to_string contains !> \brief \copybrief KIM::ComputeArgumentName::Known !! !! \sa KIM::ComputeArgumentName::Known, KIM_ComputeArgumentName_Known !! !! \since 2.0 logical recursive function kim_compute_argument_name_known( & compute_argument_name) implicit none interface integer(c_int) recursive function known(compute_argument_name) & bind(c, name="KIM_ComputeArgumentName_Known") use, intrinsic :: iso_c_binding import kim_compute_argument_name_type implicit none type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name end function known end interface type(kim_compute_argument_name_type), intent(in) :: compute_argument_name kim_compute_argument_name_known = (known(compute_argument_name) /= 0) end function kim_compute_argument_name_known !> \brief \copybrief KIM::ComputeArgumentName::operator==() !! !! \sa KIM::ComputeArgumentName::operator==(), KIM_ComputeArgumentName_Equal !! !! \since 2.0 logical recursive function kim_compute_argument_name_equal(lhs, rhs) implicit none type(kim_compute_argument_name_type), intent(in) :: lhs type(kim_compute_argument_name_type), intent(in) :: rhs kim_compute_argument_name_equal & = (lhs%compute_argument_name_id == rhs%compute_argument_name_id) end function kim_compute_argument_name_equal !> \brief \copybrief KIM::ComputeArgumentName::operator!=() !! !! \sa KIM::ComputeArgumentName::operator!=(), !! KIM_ComputeArgumentName_NotEqual !! !! \since 2.0 logical recursive function kim_compute_argument_name_not_equal(lhs, rhs) implicit none type(kim_compute_argument_name_type), intent(in) :: lhs type(kim_compute_argument_name_type), intent(in) :: rhs kim_compute_argument_name_not_equal = .not. (lhs == rhs) end function kim_compute_argument_name_not_equal !> \brief \copybrief KIM::ComputeArgumentName::ComputeArgumentName(std::string const &) !! !! \sa KIM::ComputeArgumentName::ComputeArgumentName(std::string const &), !! KIM_ComputeArgumentName_FromString !! !! \since 2.0 recursive subroutine kim_compute_argument_name_from_string( & string, compute_argument_name) implicit none interface type(kim_compute_argument_name_type) recursive function from_string( & string) bind(c, name="KIM_ComputeArgumentName_FromString") use, intrinsic :: iso_c_binding import kim_compute_argument_name_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_compute_argument_name_type), intent(out) :: compute_argument_name compute_argument_name = from_string(trim(string)//c_null_char) end subroutine kim_compute_argument_name_from_string !> \brief \copybrief KIM::ComputeArgumentName::ToString !! !! \sa KIM::ComputeArgumentName::ToString, KIM_ComputeArgumentName_ToString !! !! \since 2.0 recursive subroutine kim_compute_argument_name_to_string( & compute_argument_name, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(compute_argument_name) & bind(c, name="KIM_ComputeArgumentName_ToString") use, intrinsic :: iso_c_binding import kim_compute_argument_name_type implicit none type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name end function get_string end interface type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(compute_argument_name) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_compute_argument_name_to_string !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames, !! KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames !! !! \since 2.0 recursive subroutine kim_get_number_of_compute_argument_names( & number_of_compute_argument_names) implicit none interface recursive subroutine get_number_of_compute_argument_names( & number_of_compute_argument_names) & bind(c, & name="KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames") use, intrinsic :: iso_c_binding integer(c_int), intent(out) :: number_of_compute_argument_names end subroutine get_number_of_compute_argument_names end interface integer(c_int), intent(out) :: number_of_compute_argument_names call get_number_of_compute_argument_names(number_of_compute_argument_names) end subroutine kim_get_number_of_compute_argument_names !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName, !! KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName !! !! \since 2.0 recursive subroutine kim_get_compute_argument_name( & index, compute_argument_name, ierr) implicit none interface integer(c_int) recursive function get_compute_argument_name( & index, compute_argument_name) & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName") use, intrinsic :: iso_c_binding import kim_compute_argument_name_type implicit none integer(c_int), intent(in), value :: index type(kim_compute_argument_name_type), intent(out) :: & compute_argument_name end function get_compute_argument_name end interface integer(c_int), intent(in) :: index type(kim_compute_argument_name_type), intent(out) :: compute_argument_name integer(c_int), intent(out) :: ierr ierr = get_compute_argument_name(index - 1, compute_argument_name) end subroutine kim_get_compute_argument_name !> \brief \copybrief KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType !! !! \sa KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType, !! KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType !! !! \since 2.0 recursive subroutine kim_get_compute_argument_data_type( & compute_argument_name, & data_type, ierr) use kim_data_type_module, only: kim_data_type_type implicit none interface integer(c_int) recursive function get_compute_argument_data_type( & compute_argument_name, data_type) & bind(c, name="KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentDataType") use, intrinsic :: iso_c_binding use kim_data_type_module, only: kim_data_type_type import kim_compute_argument_name_type implicit none type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(kim_data_type_type), intent(out) :: data_type end function get_compute_argument_data_type end interface type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name type(kim_data_type_type), intent(out) :: data_type integer(c_int), intent(out) :: ierr ierr = get_compute_argument_data_type(compute_argument_name, data_type) end subroutine kim_get_compute_argument_data_type end module kim_compute_argument_name_module kim-api-2.3.0-git/fortran/include/kim_compute_arguments_module.f90000066400000000000000000001122271421473465500252300ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ComputeArguments !! !! \sa KIM::ComputeArguments, KIM_ComputeArguments !! !! \since 2.0 module kim_compute_arguments_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_compute_arguments_handle_type, & ! Constants KIM_COMPUTE_ARGUMENTS_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_argument_support_status, & kim_get_callback_support_status, & kim_set_argument_pointer, & kim_set_callback_pointer, & kim_are_all_required_present, & kim_set_simulator_buffer_pointer, & kim_get_simulator_buffer_pointer, & kim_to_string, & kim_set_log_id, & kim_push_log_verbosity, & kim_pop_log_verbosity !> \brief \copybrief KIM::ComputeArguments !! !! \sa KIM::ComputeArguments, KIM_ComputeArguments !! !! \since 2.0 type, bind(c) :: kim_compute_arguments_handle_type type(c_ptr) :: p = c_null_ptr end type kim_compute_arguments_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_compute_arguments_handle_type), protected, save & :: KIM_COMPUTE_ARGUMENTS_NULL_HANDLE !> \brief Compares kim_compute_arguments_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_compute_arguments_handle_equal end interface operator(.eq.) !> \brief Compares kim_compute_arguments_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_compute_arguments_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ComputeArguments::GetArgumentSupportStatus !! !! \sa KIM::ComputeArguments::GetArgumentSupportStatus, !! KIM_ComputeArguments_GetArgumentSupportStatus !! !! \since 2.0 interface kim_get_argument_support_status module procedure kim_compute_arguments_get_argument_support_status end interface kim_get_argument_support_status !> \brief \copybrief KIM::ComputeArguments::GetCallbackSupportStatus !! !! \sa KIM::ComputeArguments::GetCallbackSupportStatus, !! KIM_ComputeArguments_GetCallbackSupportStatus !! !! \since 2.0 interface kim_get_callback_support_status module procedure kim_compute_arguments_get_callback_support_status end interface kim_get_callback_support_status !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerInteger, !! KIM_ComputeArguments_SetArgumentPointerDouble !! !! \since 2.0 interface kim_set_argument_pointer module procedure kim_compute_arguments_set_argument_pointer_int0 module procedure kim_compute_arguments_set_argument_pointer_int1 module procedure kim_compute_arguments_set_argument_pointer_int2 module procedure kim_compute_arguments_set_argument_pointer_double0 module procedure kim_compute_arguments_set_argument_pointer_double1 module procedure kim_compute_arguments_set_argument_pointer_double2 end interface kim_set_argument_pointer !> \brief \copybrief KIM::ComputeArguments::SetCallbackPointer !! !! \sa KIM::ComputeArguments::SetCallbackPointer, !! KIM_ComputeArguments_SetCallbackPointer !! !! \since 2.0 interface kim_set_callback_pointer module procedure kim_compute_arguments_set_callback_pointer end interface kim_set_callback_pointer !> \brief \copybrief KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent !! !! \sa KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent, !! KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent !! !! \since 2.0 interface kim_are_all_required_present module procedure kim_compute_arguments_are_all_required_present end interface kim_are_all_required_present !> \brief \copybrief KIM::ComputeArguments::SetSimulatorBufferPointer !! !! \sa KIM::ComputeArguments::SetSimulatorBufferPointer, !! KIM_ComputeArguments_SetSimulatorBufferPointer !! !! \since 2.0 interface kim_set_simulator_buffer_pointer module procedure kim_compute_arguments_set_simulator_buffer_pointer end interface kim_set_simulator_buffer_pointer !> \brief \copybrief KIM::ComputeArguments::GetSimulatorBufferPointer !! !! \sa KIM::ComputeArguments::GetSimulatorBufferPointer, !! KIM_ComputeArguments_GetSimulatorBufferPointer !! !! \since 2.0 interface kim_get_simulator_buffer_pointer module procedure kim_compute_arguments_get_simulator_buffer_pointer end interface kim_get_simulator_buffer_pointer !> \brief \copybrief KIM::ComputeArguments::ToString !! !! \sa KIM::ComputeArguments::ToString, KIM_ComputeArguments_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_compute_arguments_to_string end interface kim_to_string !> \brief \copybrief KIM::ComputeArguments::SetLogID !! !! \sa KIM::ComputeArguments::SetLogID, KIM_ComputeArguments_SetLogID !! !! \since 2.0 interface kim_set_log_id module procedure kim_compute_arguments_set_log_id end interface kim_set_log_id !> \brief \copybrief KIM::ComputeArguments::PushLogVerbosity !! !! \sa KIM::ComputeArguments::PushLogVerbosity, !! KIM_ComputeArguments_PushLogVerbosity !! !! \since 2.0 interface kim_push_log_verbosity module procedure kim_compute_arguments_push_log_verbosity end interface kim_push_log_verbosity !> \brief \copybrief KIM::ComputeArguments::PopLogVerbosity !! !! \sa KIM::ComputeArguments::PopLogVerbosity, !! KIM_ComputeArguments_PopLogVerbosity !! !! \since 2.0 interface kim_pop_log_verbosity module procedure kim_compute_arguments_pop_log_verbosity end interface kim_pop_log_verbosity contains !> \brief Compares kim_compute_arguments_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_compute_arguments_handle_equal(lhs, rhs) implicit none type(kim_compute_arguments_handle_type), intent(in) :: lhs type(kim_compute_arguments_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_compute_arguments_handle_equal = .true. else kim_compute_arguments_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_compute_arguments_handle_equal !> \brief Compares kim_compute_arguments_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_compute_arguments_handle_not_equal(lhs, rhs) implicit none type(kim_compute_arguments_handle_type), intent(in) :: lhs type(kim_compute_arguments_handle_type), intent(in) :: rhs kim_compute_arguments_handle_not_equal = .not. (lhs == rhs) end function kim_compute_arguments_handle_not_equal !> \brief \copybrief KIM::ComputeArguments::GetArgumentSupportStatus !! !! \sa KIM::ComputeArguments::GetArgumentSupportStatus, !! KIM_ComputeArguments_GetArgumentSupportStatus !! !! \since 2.0 recursive subroutine kim_compute_arguments_get_argument_support_status( & compute_arguments_handle, compute_argument_name, & support_status, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_support_status( & compute_arguments, compute_argument_name, support_status) & bind(c, name="KIM_ComputeArguments_GetArgumentSupportStatus") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(kim_support_status_type), intent(out) :: support_status end function get_argument_support_status end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name type(kim_support_status_type), intent(out) :: support_status integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = get_argument_support_status(compute_arguments, & compute_argument_name, support_status) end subroutine kim_compute_arguments_get_argument_support_status !> \brief \copybrief KIM::ComputeArguments::GetCallbackSupportStatus !! !! \sa KIM::ComputeArguments::GetCallbackSupportStatus, !! KIM_ComputeArguments_GetCallbackSupportStatus !! !! \since 2.0 recursive subroutine kim_compute_arguments_get_callback_support_status( & compute_arguments_handle, compute_callback_name, support_status, ierr) use kim_compute_callback_name_module, only: kim_compute_callback_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function get_callback_support_status( & compute_arguments, compute_callback_name, support_status) & bind(c, name="KIM_ComputeArguments_GetCallbackSupportStatus") use, intrinsic :: iso_c_binding use kim_compute_callback_name_module, only: & kim_compute_callback_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_callback_name_type), intent(in), value :: & compute_callback_name type(kim_support_status_type), intent(out) :: support_status end function get_callback_support_status end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_callback_name_type), intent(in) :: & compute_callback_name type(kim_support_status_type), intent(out) :: support_status integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = get_callback_support_status(compute_arguments, & compute_callback_name, support_status) end subroutine kim_compute_arguments_get_callback_support_status !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerInteger !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_argument_pointer_int0( & compute_arguments_handle, compute_argument_name, int0, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function set_argument_pointer_integer( & compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ComputeArguments_SetArgumentPointerInteger") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(in), value :: ptr end function set_argument_pointer_integer end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in), target :: int0 integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = set_argument_pointer_integer(compute_arguments, & compute_argument_name, c_loc(int0)) end subroutine kim_compute_arguments_set_argument_pointer_int0 !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerInteger !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_argument_pointer_int1( & compute_arguments_handle, compute_argument_name, int1, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in), target :: int1(:) integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call set(compute_arguments, compute_argument_name, size(int1, 1, c_int), & int1, ierr) return contains recursive subroutine set(compute_arguments, compute_argument_name, & extent1, int1, ierr) use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function set_argument_pointer_integer( & compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ComputeArguments_SetArgumentPointerInteger") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(in), value :: ptr end function set_argument_pointer_integer end interface type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 integer(c_int), intent(in), target :: int1(extent1) integer(c_int), intent(out) :: ierr ierr = set_argument_pointer_integer(compute_arguments, & compute_argument_name, c_loc(int1)) end subroutine set end subroutine kim_compute_arguments_set_argument_pointer_int1 !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerInteger !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_argument_pointer_int2( & compute_arguments_handle, compute_argument_name, int2, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in), target :: int2(:, :) integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call set(compute_arguments, compute_argument_name, size(int2, 1, c_int), & size(int2, 2, c_int), int2, ierr) return contains recursive subroutine set(compute_arguments, compute_argument_name, & extent1, extent2, int2, ierr) use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function set_argument_pointer_integer( & compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ComputeArguments_SetArgumentPointerInteger") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(in), value :: ptr end function set_argument_pointer_integer end interface type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 integer(c_int), intent(in) :: extent2 integer(c_int), intent(in), target :: int2(extent1, extent2) integer(c_int), intent(out) :: ierr ierr = set_argument_pointer_integer(compute_arguments, & compute_argument_name, c_loc(int2)) end subroutine set end subroutine kim_compute_arguments_set_argument_pointer_int2 !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerDouble !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_argument_pointer_double0( & compute_arguments_handle, compute_argument_name, double0, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function set_argument_pointer_double( & compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ComputeArguments_SetArgumentPointerDouble") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(in), value :: ptr end function set_argument_pointer_double end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name real(c_double), intent(in), target :: double0 integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = set_argument_pointer_double(compute_arguments, & compute_argument_name, c_loc(double0)) end subroutine kim_compute_arguments_set_argument_pointer_double0 !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerDouble !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_argument_pointer_double1( & compute_arguments_handle, compute_argument_name, double1, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name real(c_double), intent(in), target :: double1(:) integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call set(compute_arguments, compute_argument_name, & size(double1, 1, c_int), double1, ierr) return contains recursive subroutine set(compute_arguments, compute_argument_name, & extent1, double1, ierr) use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function set_argument_pointer_double( & compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ComputeArguments_SetArgumentPointerDouble") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(in), value :: ptr end function set_argument_pointer_double end interface type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 real(c_double), intent(in), target :: double1(extent1) integer(c_int), intent(out) :: ierr ierr = set_argument_pointer_double(compute_arguments, & compute_argument_name, c_loc(double1)) end subroutine set end subroutine kim_compute_arguments_set_argument_pointer_double1 !> \brief \copybrief KIM::ComputeArguments::SetArgumentPointer !! !! \sa KIM::ComputeArguments::SetArgumentPointer, !! KIM_ComputeArguments_SetArgumentPointerDouble !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_argument_pointer_double2( & compute_arguments_handle, compute_argument_name, double2, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name real(c_double), intent(in), target :: double2(:, :) integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call set(compute_arguments, compute_argument_name, & size(double2, 1, c_int), size(double2, 2, c_int), double2, ierr) return contains recursive subroutine set(compute_arguments, compute_argument_name, & extent1, extent2, double2, ierr) use kim_compute_argument_name_module, only: & kim_compute_argument_name_type implicit none interface integer(c_int) recursive function set_argument_pointer_double( & compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ComputeArguments_SetArgumentPointerDouble") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(in), value :: ptr end function set_argument_pointer_double end interface type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 integer(c_int), intent(in) :: extent2 real(c_double), intent(in), target :: double2(extent1, extent2) integer(c_int), intent(out) :: ierr ierr = set_argument_pointer_double(compute_arguments, & compute_argument_name, c_loc(double2)) end subroutine set end subroutine kim_compute_arguments_set_argument_pointer_double2 !> \brief \copybrief KIM::ComputeArguments::SetCallbackPointer !! !! \sa KIM::ComputeArguments::SetCallbackPointer, !! KIM_ComputeArguments_SetCallbackPointer !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_callback_pointer( & compute_arguments_handle, compute_callback_name, language_name, fptr, & data_object, ierr) use kim_compute_callback_name_module, only: kim_compute_callback_name_type use kim_language_name_module, only: kim_language_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function set_callback_pointer( & compute_arguments, compute_callback_name, language_name, fptr, & data_object) bind(c, name="KIM_ComputeArguments_SetCallbackPointer") use, intrinsic :: iso_c_binding use kim_language_name_module, only: kim_language_name_type use kim_compute_callback_name_module, only: & kim_compute_callback_name_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_language_name_type), intent(in), value :: language_name type(kim_compute_callback_name_type), intent(in), value :: & compute_callback_name type(c_funptr), intent(in), value :: fptr type(c_ptr), intent(in), value :: data_object end function set_callback_pointer end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_callback_name_type), intent(in) :: & compute_callback_name type(kim_language_name_type), intent(in) :: language_name type(c_funptr), intent(in), value :: fptr ! must be left as "value"!?! type(c_ptr), intent(in) :: data_object integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = set_callback_pointer(compute_arguments, compute_callback_name, & language_name, fptr, data_object) end subroutine kim_compute_arguments_set_callback_pointer !> \brief \copybrief KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent !! !! \sa KIM::ComputeArguments::AreAllRequiredArgumentsAndCallbacksPresent, !! KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent !! !! \since 2.0 recursive subroutine kim_compute_arguments_are_all_required_present( & compute_arguments_handle, result_value, ierr) use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface integer(c_int) recursive function & are_all_required_arguments_and_callbacks_present( & compute_arguments, result_value) & bind(c, & name= & "KIM_ComputeArguments_AreAllRequiredArgumentsAndCallbacksPresent") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments integer(c_int), intent(out) :: result_value end function are_all_required_arguments_and_callbacks_present end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle integer(c_int), intent(out) :: result_value integer(c_int), intent(out) :: ierr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = are_all_required_arguments_and_callbacks_present( & compute_arguments, result_value) end subroutine kim_compute_arguments_are_all_required_present !> \brief \copybrief KIM::ComputeArguments::SetSimulatorBufferPointer !! !! \sa KIM::ComputeArguments::SetSimulatorBufferPointer, !! KIM_ComputeArguments_SetSimulatorBufferPointer !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_simulator_buffer_pointer( & compute_arguments_handle, ptr) use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface recursive subroutine set_simulator_buffer_pointer( & compute_arguments, ptr) & bind(c, name="KIM_ComputeArguments_SetSimulatorBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(c_ptr), intent(in), value :: ptr end subroutine set_simulator_buffer_pointer end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(c_ptr), intent(in) :: ptr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call set_simulator_buffer_pointer(compute_arguments, ptr) end subroutine kim_compute_arguments_set_simulator_buffer_pointer !> \brief \copybrief KIM::ComputeArguments::GetSimulatorBufferPointer !! !! \sa KIM::ComputeArguments::GetSimulatorBufferPointer, !! KIM_ComputeArguments_GetSimulatorBufferPointer !! !! \since 2.0 recursive subroutine kim_compute_arguments_get_simulator_buffer_pointer( & compute_arguments_handle, ptr) use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface recursive subroutine get_simulator_buffer_pointer( & compute_arguments, ptr) & bind(c, name="KIM_ComputeArguments_GetSimulatorBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(c_ptr), intent(out) :: ptr end subroutine get_simulator_buffer_pointer end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(c_ptr), intent(out) :: ptr type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call get_simulator_buffer_pointer(compute_arguments, ptr) end subroutine kim_compute_arguments_get_simulator_buffer_pointer !> \brief \copybrief KIM::ComputeArguments::ToString !! !! \sa KIM::ComputeArguments::ToString, KIM_ComputeArguments_ToString !! !! \since 2.0 recursive subroutine kim_compute_arguments_to_string( & compute_arguments_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface type(c_ptr) recursive function compute_arguments_string( & compute_arguments) bind(c, name="KIM_ComputeArguments_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments end function compute_arguments_string end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle character(len=*, kind=c_char), intent(out) :: string type(kim_compute_arguments_type), pointer :: compute_arguments type(c_ptr) :: p call c_f_pointer(compute_arguments_handle%p, compute_arguments) p = compute_arguments_string(compute_arguments) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_compute_arguments_to_string !> \brief \copybrief KIM::ComputeArguments::SetLogID !! !! \sa KIM::ComputeArguments::SetLogID, KIM_ComputeArguments_SetLogID !! !! \since 2.0 recursive subroutine kim_compute_arguments_set_log_id( & compute_arguments_handle, log_id) use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface recursive subroutine set_log_id(compute_arguments, log_id) & bind(c, name="KIM_ComputeArguments_SetLogID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments character(c_char), intent(in) :: log_id(*) end subroutine set_log_id end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle character(len=*, kind=c_char), intent(in) :: log_id type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call set_log_id(compute_arguments, trim(log_id)//c_null_char) end subroutine kim_compute_arguments_set_log_id !> \brief \copybrief KIM::ComputeArguments::PushLogVerbosity !! !! \sa KIM::ComputeArguments::PushLogVerbosity, !! KIM_ComputeArguments_PushLogVerbosity !! !! \since 2.0 recursive subroutine kim_compute_arguments_push_log_verbosity( & compute_arguments_handle, log_verbosity) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface recursive subroutine push_log_verbosity( & compute_arguments, log_verbosity) & bind(c, name="KIM_ComputeArguments_PushLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments type(kim_log_verbosity_type), intent(in), value :: log_verbosity end subroutine push_log_verbosity end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call push_log_verbosity(compute_arguments, log_verbosity) end subroutine kim_compute_arguments_push_log_verbosity !> \brief \copybrief KIM::ComputeArguments::PopLogVerbosity !! !! \sa KIM::ComputeArguments::PopLogVerbosity, !! KIM_ComputeArguments_PopLogVerbosity !! !! \since 2.0 recursive subroutine kim_compute_arguments_pop_log_verbosity( & compute_arguments_handle) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none interface recursive subroutine pop_log_verbosity(compute_arguments) & bind(c, name="KIM_ComputeArguments_PopLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_compute_arguments_type implicit none type(kim_compute_arguments_type), intent(in) :: compute_arguments end subroutine pop_log_verbosity end interface type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(compute_arguments_handle%p, compute_arguments) call pop_log_verbosity(compute_arguments) end subroutine kim_compute_arguments_pop_log_verbosity end module kim_compute_arguments_module kim-api-2.3.0-git/fortran/include/kim_compute_callback_name_module.f90000066400000000000000000000253371421473465500257640ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ComputeCallbackName !! !! \sa KIM::ComputeCallbackName, KIM_ComputeCallbackName !! !! \since 2.0 module kim_compute_callback_name_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_compute_callback_name_type, & ! Constants KIM_COMPUTE_CALLBACK_NAME_GET_NEIGHBOR_LIST, & KIM_COMPUTE_CALLBACK_NAME_PROCESS_DEDR_TERM, & KIM_COMPUTE_CALLBACK_NAME_PROCESS_D2EDR2_TERM, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_compute_callback_names, & kim_get_compute_callback_name !> \brief \copybrief KIM::ComputeCallbackName !! !! \sa KIM::ComputeCallbackName, KIM_ComputeCallbackName !! !! \since 2.0 type, bind(c) :: kim_compute_callback_name_type !> \brief \copybrief KIM::ComputeCallbackName::computeCallbackNameID !! !! \sa KIM::ComputeCallbackName::computeCallbackNameID, !! KIM_ComputeCallbackName::computeCallbackNameID !! !! \since 2.0 integer(c_int) compute_callback_name_id end type kim_compute_callback_name_type !> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::GetNeighborList !! !! \sa KIM::COMPUTE_CALLBACK_NAME::GetNeighborList, !! KIM_COMPUTE_CALLBACK_NAME_GetNeighborList !! !! \since 2.0 type(kim_compute_callback_name_type), protected, save, & bind(c, name="KIM_COMPUTE_CALLBACK_NAME_GetNeighborList") & :: KIM_COMPUTE_CALLBACK_NAME_GET_NEIGHBOR_LIST !> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm !! !! \sa KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm, !! KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm !! !! \since 2.0 type(kim_compute_callback_name_type), protected, save, & bind(c, name="KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm") & :: KIM_COMPUTE_CALLBACK_NAME_PROCESS_DEDR_TERM !> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term !! !! \sa KIM::COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term, !! KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term !! !! \since 2.0 type(kim_compute_callback_name_type), protected, save, & bind(c, name="KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term") & :: KIM_COMPUTE_CALLBACK_NAME_PROCESS_D2EDR2_TERM !> \brief \copybrief KIM::ComputeCallbackName::Known !! !! \sa KIM::ComputeCallbackName::Known, KIM_ComputeCallbackName_Known !! !! \since 2.0 interface kim_known module procedure kim_compute_callback_name_known end interface kim_known !> \brief \copybrief KIM::ComputeCallbackName::operator==() !! !! \sa KIM::ComputeCallbackName::operator==(), KIM_ComputeCallbackName_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_compute_callback_name_equal end interface operator(.eq.) !> \brief \copybrief KIM::ComputeCallbackName::operator!=() !! !! \sa KIM::ComputeCallbackName::operator!=(), !! KIM_ComputeCallbackName_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_compute_callback_name_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ComputeCallbackName::ComputeCallbackName(std::string const &) !! !! \sa KIM::ComputeCallbackName::ComputeCallbackName(std::string const &), !! KIM_ComputeCallbackName_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_compute_callback_name_from_string end interface kim_from_string !> \brief \copybrief KIM::ComputeCallbackName::ToString !! !! \sa KIM::ComputeCallbackName::ToString, KIM_ComputeCallbackName_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_compute_callback_name_to_string end interface kim_to_string contains !> \brief \copybrief KIM::ComputeCallbackName::Known !! !! \sa KIM::ComputeCallbackName::Known, KIM_ComputeCallbackName_Known !! !! \since 2.0 logical recursive function kim_compute_callback_name_known( & compute_callback_name) implicit none interface integer(c_int) recursive function known(compute_callback_name) & bind(c, name="KIM_ComputeCallbackName_Known") use, intrinsic :: iso_c_binding import kim_compute_callback_name_type implicit none type(kim_compute_callback_name_type), intent(in), value :: & compute_callback_name end function known end interface type(kim_compute_callback_name_type), intent(in) :: compute_callback_name kim_compute_callback_name_known = (known(compute_callback_name) /= 0) end function kim_compute_callback_name_known !> \brief \copybrief KIM::ComputeCallbackName::operator==() !! !! \sa KIM::ComputeCallbackName::operator==(), KIM_ComputeCallbackName_Equal !! !! \since 2.0 logical recursive function kim_compute_callback_name_equal(lhs, rhs) implicit none type(kim_compute_callback_name_type), intent(in) :: lhs type(kim_compute_callback_name_type), intent(in) :: rhs kim_compute_callback_name_equal & = (lhs%compute_callback_name_id == rhs%compute_callback_name_id) end function kim_compute_callback_name_equal !> \brief \copybrief KIM::ComputeCallbackName::operator!=() !! !! \sa KIM::ComputeCallbackName::operator!=(), !! KIM_ComputeCallbackName_NotEqual !! !! \since 2.0 logical recursive function kim_compute_callback_name_not_equal(lhs, rhs) implicit none type(kim_compute_callback_name_type), intent(in) :: lhs type(kim_compute_callback_name_type), intent(in) :: rhs kim_compute_callback_name_not_equal = .not. (lhs == rhs) end function kim_compute_callback_name_not_equal !> \brief \copybrief KIM::ComputeCallbackName::ComputeCallbackName(std::string const &) !! !! \sa KIM::ComputeCallbackName::ComputeCallbackName(std::string const &), !! KIM_ComputeCallbackName_FromString !! !! \since 2.0 recursive subroutine kim_compute_callback_name_from_string( & string, compute_callback_name) implicit none interface type(kim_compute_callback_name_type) recursive function from_string( & string) bind(c, name="KIM_ComputeCallbackName_FromString") use, intrinsic :: iso_c_binding import kim_compute_callback_name_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_compute_callback_name_type), intent(out) :: compute_callback_name compute_callback_name = from_string(trim(string)//c_null_char) end subroutine kim_compute_callback_name_from_string !> \brief \copybrief KIM::ComputeCallbackName::ToString !! !! \sa KIM::ComputeCallbackName::ToString, KIM_ComputeCallbackName_ToString !! !! \since 2.0 recursive subroutine kim_compute_callback_name_to_string( & compute_callback_name, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(compute_callback_name) & bind(c, name="KIM_ComputeCallbackName_ToString") use, intrinsic :: iso_c_binding import kim_compute_callback_name_type implicit none type(kim_compute_callback_name_type), intent(in), value :: & compute_callback_name end function get_string end interface type(kim_compute_callback_name_type), intent(in) :: & compute_callback_name character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(compute_callback_name) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_compute_callback_name_to_string !> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames !! !! \sa KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames, !! KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames !! !! \since 2.0 recursive subroutine kim_get_number_of_compute_callback_names( & number_of_compute_callback_names) implicit none interface recursive subroutine get_number_of_compute_callback_names( & number_of_compute_callback_names) & bind(c, & name="KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames") use, intrinsic :: iso_c_binding integer(c_int), intent(out) :: number_of_compute_callback_names end subroutine get_number_of_compute_callback_names end interface integer(c_int), intent(out) :: number_of_compute_callback_names call get_number_of_compute_callback_names(number_of_compute_callback_names) end subroutine kim_get_number_of_compute_callback_names !> \brief \copybrief KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName !! !! \sa KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName, !! KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName !! !! \since 2.0 recursive subroutine kim_get_compute_callback_name(index, & compute_callback_name, & ierr) implicit none interface integer(c_int) recursive function get_compute_callback_name( & index, compute_callback_name) & bind(c, name="KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName") use, intrinsic :: iso_c_binding import kim_compute_callback_name_type implicit none integer(c_int), intent(in), value :: index type(kim_compute_callback_name_type), intent(out) :: & compute_callback_name end function get_compute_callback_name end interface integer(c_int), intent(in) :: index type(kim_compute_callback_name_type), intent(out) :: compute_callback_name integer(c_int), intent(out) :: ierr ierr = get_compute_callback_name(index - 1, compute_callback_name) end subroutine kim_get_compute_callback_name end module kim_compute_callback_name_module kim-api-2.3.0-git/fortran/include/kim_data_type_module.f90000066400000000000000000000202261421473465500234360ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::DataType !! !! \sa KIM::DataType, KIM_DataType !! !! \since 2.0 module kim_data_type_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_data_type_type, & ! Constants KIM_DATA_TYPE_INTEGER, & KIM_DATA_TYPE_DOUBLE, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_data_types, & kim_get_data_type !> \brief \copybrief KIM::DataType !! !! \sa KIM::DataType, KIM_DataType !! !! \since 2.0 type, bind(c) :: kim_data_type_type !> \brief \copybrief KIM::DataType::dataTypeID !! !! \sa KIM::DataType::dataTypeID, KIM_DataType::dataTypeID !! !! \since 2.0 integer(c_int) :: data_type_id end type kim_data_type_type !> \brief \copybrief KIM::DATA_TYPE::Integer !! !! \sa KIM::DATA_TYPE::Integer, KIM_DATA_TYPE_Integer !! !! \since 2.0 type(kim_data_type_type), protected, save, & bind(c, name="KIM_DATA_TYPE_Integer") & :: KIM_DATA_TYPE_INTEGER !> \brief \copybrief KIM::DATA_TYPE::Double !! !! \sa KIM::DATA_TYPE::Double, KIM_DATA_TYPE_Double !! !! \since 2.0 type(kim_data_type_type), protected, save, & bind(c, name="KIM_DATA_TYPE_Double") & :: KIM_DATA_TYPE_DOUBLE !> \brief \copybrief KIM::DataType::Known !! !! \sa KIM::DataType::Known, KIM_DataType_Known !! !! \since 2.0 interface kim_known module procedure kim_data_type_known end interface kim_known !> \brief \copybrief KIM::DataType::operator==() !! !! \sa KIM::DataType::operator==(), KIM_DataType_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_data_type_equal end interface operator(.eq.) !> \brief \copybrief KIM::DataType::operator!=() !! !! \sa KIM::DataType::operator!=(), KIM_DataType_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_data_type_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::DataType::DataType(std::string const &) !! !! \sa KIM::DataType::DataType(std::string const &), KIM_DataType_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_data_type_from_string end interface kim_from_string !> \brief \copybrief KIM::DataType::ToString !! !! \sa KIM::DataType::ToString, KIM_DataType_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_data_type_to_string end interface kim_to_string contains !> \brief \copybrief KIM::DataType::Known !! !! \sa KIM::DataType::Known, KIM_DataType_Known !! !! \since 2.0 logical recursive function kim_data_type_known(data_type) implicit none interface integer(c_int) recursive function known(data_type) & bind(c, name="KIM_DataType_Known") use, intrinsic :: iso_c_binding import kim_data_type_type implicit none type(kim_data_type_type), intent(in), value :: data_type end function known end interface type(kim_data_type_type), intent(in) :: data_type kim_data_type_known = (known(data_type) /= 0) end function kim_data_type_known !> \brief \copybrief KIM::DataType::operator==() !! !! \sa KIM::DataType::operator==(), KIM_DataType_Equal !! !! \since 2.0 logical recursive function kim_data_type_equal(lhs, rhs) implicit none type(kim_data_type_type), intent(in) :: lhs type(kim_data_type_type), intent(in) :: rhs kim_data_type_equal & = (lhs%data_type_id == rhs%data_type_id) end function kim_data_type_equal !> \brief \copybrief KIM::DataType::operator!=() !! !! \sa KIM::DataType::operator!=(), KIM_DataType_NotEqual !! !! \since 2.0 logical recursive function kim_data_type_not_equal(lhs, rhs) implicit none type(kim_data_type_type), intent(in) :: lhs type(kim_data_type_type), intent(in) :: rhs kim_data_type_not_equal = .not. (lhs == rhs) end function kim_data_type_not_equal !> \brief \copybrief KIM::DataType::DataType(std::string const &) !! !! \sa KIM::DataType::DataType(std::string const &), KIM_DataType_FromString !! !! \since 2.0 recursive subroutine kim_data_type_from_string(string, data_type) implicit none interface type(kim_data_type_type) recursive function from_string(string) & bind(c, name="KIM_DataType_FromString") use, intrinsic :: iso_c_binding import kim_data_type_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_data_type_type), intent(out) :: data_type data_type = from_string(trim(string)//c_null_char) end subroutine kim_data_type_from_string !> \brief \copybrief KIM::DataType::ToString !! !! \sa KIM::DataType::ToString, KIM_DataType_ToString !! !! \since 2.0 recursive subroutine kim_data_type_to_string(data_type, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(data_type) & bind(c, name="KIM_DataType_ToString") use, intrinsic :: iso_c_binding import kim_data_type_type implicit none type(kim_data_type_type), intent(in), value :: data_type end function get_string end interface type(kim_data_type_type), intent(in) :: data_type character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(data_type) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_data_type_to_string !> \brief \copybrief KIM::DATA_TYPE::GetNumberOfDataTypes !! !! \sa KIM::DATA_TYPE::GetNumberOfDataTypes, !! KIM_DATA_TYPE_GetNumberOfDataTypes !! !! \since 2.0 recursive subroutine kim_get_number_of_data_types(number_of_data_types) implicit none interface recursive subroutine get_number_of_data_types(number_of_data_types) & bind(c, name="KIM_DATA_TYPE_GetNumberOfDataTypes") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_data_types end subroutine get_number_of_data_types end interface integer(c_int), intent(out) :: number_of_data_types call get_number_of_data_types(number_of_data_types) end subroutine kim_get_number_of_data_types !> \brief \copybrief KIM::DATA_TYPE::GetDataType !! !! \sa KIM::DATA_TYPE::GetDataType, KIM_DATA_TYPE_GetDataType !! !! \since 2.0 recursive subroutine kim_get_data_type(index, data_type, ierr) implicit none interface integer(c_int) recursive function get_data_type(index, data_type) & bind(c, name="KIM_DATA_TYPE_GetDataType") use, intrinsic :: iso_c_binding import kim_data_type_type implicit none integer(c_int), intent(in), value :: index type(kim_data_type_type), intent(out) :: data_type end function get_data_type end interface integer(c_int), intent(in) :: index type(kim_data_type_type), intent(out) :: data_type integer(c_int), intent(out) :: ierr ierr = get_data_type(index - 1, data_type) end subroutine kim_get_data_type end module kim_data_type_module kim-api-2.3.0-git/fortran/include/kim_energy_unit_module.f90000066400000000000000000000235161421473465500240210ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::EnergyUnit !! !! \sa KIM::EnergyUnit, KIM_EnergyUnit !! !! \since 2.0 module kim_energy_unit_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_energy_unit_type, & ! Constants KIM_ENERGY_UNIT_UNUSED, & KIM_ENERGY_UNIT_AMU_A2_PER_PS2, & KIM_ENERGY_UNIT_ERG, & KIM_ENERGY_UNIT_EV, & KIM_ENERGY_UNIT_HARTREE, & KIM_ENERGY_UNIT_J, & KIM_ENERGY_UNIT_KCAL_MOL, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_energy_units, & kim_get_energy_unit !> \brief \copybrief KIM::EnergyUnit !! !! \sa KIM::EnergyUnit, KIM_EnergyUnit !! !! \since 2.0 type, bind(c) :: kim_energy_unit_type !> \brief \copybrief KIM::EnergyUnit::energyUnitID !! !! \sa KIM::EnergyUnit::energyUnitID, KIM_EnergyUnit::energyUnitID !! !! \since 2.0 integer(c_int) energy_unit_id end type kim_energy_unit_type !> \brief \copybrief KIM::ENERGY_UNIT::unused !! !! \sa KIM::ENERGY_UNIT::unused, KIM_ENERGY_UNIT_unused !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_unused") & :: KIM_ENERGY_UNIT_UNUSED !> \brief \copybrief KIM::ENERGY_UNIT::amu_A2_per_ps2 !! !! \sa KIM::ENERGY_UNIT::amu_A2_per_ps2, KIM_ENERGY_UNIT_amu_A2_per_ps2 !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_amu_A2_per_ps2") & :: KIM_ENERGY_UNIT_AMU_A2_PER_PS2 !> \brief \copybrief KIM::ENERGY_UNIT::erg !! !! \sa KIM::ENERGY_UNIT::erg, KIM_ENERGY_UNIT_erg !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_erg") & :: KIM_ENERGY_UNIT_ERG !> \brief \copybrief KIM::ENERGY_UNIT::eV !! !! \sa KIM::ENERGY_UNIT::eV, KIM_ENERGY_UNIT_eV !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_eV") & :: KIM_ENERGY_UNIT_EV !> \brief \copybrief KIM::ENERGY_UNIT::Hartree !! !! \sa KIM::ENERGY_UNIT::Hartree, KIM_ENERGY_UNIT_Hartree !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_Hartree") & :: KIM_ENERGY_UNIT_HARTREE !> \brief \copybrief KIM::ENERGY_UNIT::J !! !! \sa KIM::ENERGY_UNIT::J, KIM_ENERGY_UNIT_J !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_J") & :: KIM_ENERGY_UNIT_J !> \brief \copybrief KIM::ENERGY_UNIT::kcal_mol !! !! \sa KIM::ENERGY_UNIT::kcal_mol, KIM_ENERGY_UNIT_kcal_mol !! !! \since 2.0 type(kim_energy_unit_type), protected, save, & bind(c, name="KIM_ENERGY_UNIT_kcal_mol") & :: KIM_ENERGY_UNIT_KCAL_MOL !> \brief \copybrief KIM::EnergyUnit::Known !! !! \sa KIM::EnergyUnit::Known, KIM_EnergyUnit_Known !! !! \since 2.0 interface kim_known module procedure kim_energy_unit_known end interface kim_known !> \brief \copybrief KIM::EnergyUnit::operator==() !! !! \sa KIM::EnergyUnit::operator==(), KIM_EnergyUnit_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_energy_unit_equal end interface operator(.eq.) !> \brief \copybrief KIM::EnergyUnit::operator!=() !! !! \sa KIM::EnergyUnit::operator!=(), KIM_EnergyUnit_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_energy_unit_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::EnergyUnit::EnergyUnit(std::string const &) !! !! \sa KIM::EnergyUnit::EnergyUnit(std::string const &), !! KIM_EnergyUnit_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_energy_unit_from_string end interface kim_from_string !> \brief \copybrief KIM::EnergyUnit::ToString !! !! \sa KIM::EnergyUnit::ToString, KIM_EnergyUnit_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_energy_unit_to_string end interface kim_to_string contains !> \brief \copybrief KIM::EnergyUnit::Known !! !! \sa KIM::EnergyUnit::Known, KIM_EnergyUnit_Known !! !! \since 2.0 logical recursive function kim_energy_unit_known(energy_unit) implicit none interface integer(c_int) recursive function known(energy_unit) & bind(c, name="KIM_EnergyUnit_Known") use, intrinsic :: iso_c_binding import kim_energy_unit_type implicit none type(kim_energy_unit_type), intent(in), value :: energy_unit end function known end interface type(kim_energy_unit_type), intent(in) :: energy_unit kim_energy_unit_known = (known(energy_unit) /= 0) end function kim_energy_unit_known !> \brief \copybrief KIM::EnergyUnit::operator==() !! !! \sa KIM::EnergyUnit::operator==(), KIM_EnergyUnit_Equal !! !! \since 2.0 logical recursive function kim_energy_unit_equal(lhs, rhs) implicit none type(kim_energy_unit_type), intent(in) :: lhs type(kim_energy_unit_type), intent(in) :: rhs kim_energy_unit_equal & = (lhs%energy_unit_id == rhs%energy_unit_id) end function kim_energy_unit_equal !> \brief \copybrief KIM::EnergyUnit::operator!=() !! !! \sa KIM::EnergyUnit::operator!=(), KIM_EnergyUnit_NotEqual !! !! \since 2.0 logical recursive function kim_energy_unit_not_equal(lhs, rhs) implicit none type(kim_energy_unit_type), intent(in) :: lhs type(kim_energy_unit_type), intent(in) :: rhs kim_energy_unit_not_equal = .not. (lhs == rhs) end function kim_energy_unit_not_equal !> \brief \copybrief KIM::EnergyUnit::EnergyUnit(std::string const &) !! !! \sa KIM::EnergyUnit::EnergyUnit(std::string const &), !! KIM_EnergyUnit_FromString !! !! \since 2.0 recursive subroutine kim_energy_unit_from_string(string, energy_unit) implicit none interface type(kim_energy_unit_type) recursive function from_string(string) & bind(c, name="KIM_EnergyUnit_FromString") use, intrinsic :: iso_c_binding import kim_energy_unit_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_energy_unit_type), intent(out) :: energy_unit energy_unit = from_string(trim(string)//c_null_char) end subroutine kim_energy_unit_from_string !> \brief \copybrief KIM::EnergyUnit::ToString !! !! \sa KIM::EnergyUnit::ToString, KIM_EnergyUnit_ToString !! !! \since 2.0 recursive subroutine kim_energy_unit_to_string(energy_unit, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(energy_unit) & bind(c, name="KIM_EnergyUnit_ToString") use, intrinsic :: iso_c_binding import kim_energy_unit_type implicit none type(kim_energy_unit_type), intent(in), value :: energy_unit end function get_string end interface type(kim_energy_unit_type), intent(in) :: energy_unit character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(energy_unit) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_energy_unit_to_string !> \brief \copybrief KIM::ENERGY_UNIT::GetNumberOfEnergyUnits !! !! \sa KIM::ENERGY_UNIT::GetNumberOfEnergyUnits, !! KIM_ENERGY_UNIT_GetNumberOfEnergyUnits !! !! \since 2.0 recursive subroutine kim_get_number_of_energy_units(number_of_energy_units) implicit none interface recursive subroutine get_number_of_energy_units(number_of_energy_units) & bind(c, name="KIM_ENERGY_UNIT_GetNumberOfEnergyUnits") use, intrinsic :: iso_c_binding integer(c_int), intent(out) :: number_of_energy_units end subroutine get_number_of_energy_units end interface integer(c_int), intent(out) :: number_of_energy_units call get_number_of_energy_units(number_of_energy_units) end subroutine kim_get_number_of_energy_units !> \brief \copybrief KIM::ENERGY_UNIT::GetEnergyUnit !! !! \sa KIM::ENERGY_UNIT::GetEnergyUnit, KIM_ENERGY_UNIT_GetEnergyUnit !! !! \since 2.0 recursive subroutine kim_get_energy_unit(index, energy_unit, ierr) implicit none interface integer(c_int) recursive function get_energy_unit(index, energy_unit) & bind(c, name="KIM_ENERGY_UNIT_GetEnergyUnit") use, intrinsic :: iso_c_binding import kim_energy_unit_type implicit none integer(c_int), intent(in), value :: index type(kim_energy_unit_type), intent(out) :: energy_unit end function get_energy_unit end interface integer(c_int), intent(in) :: index type(kim_energy_unit_type), intent(out) :: energy_unit integer(c_int), intent(out) :: ierr ierr = get_energy_unit(index - 1, energy_unit) end subroutine kim_get_energy_unit end module kim_energy_unit_module kim-api-2.3.0-git/fortran/include/kim_language_name_module.f90000066400000000000000000000220571421473465500242530ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::LanguageName !! !! \sa KIM::LanguageName, KIM_LanguageName !! !! \since 2.0 module kim_language_name_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_language_name_type, & ! Constants KIM_LANGUAGE_NAME_CPP, & KIM_LANGUAGE_NAME_C, & KIM_LANGUAGE_NAME_FORTRAN, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_language_names, & kim_get_language_name !> \brief \copybrief KIM::LanguageName !! !! \sa KIM::LanguageName, KIM_LanguageName !! !! \since 2.0 type, bind(c) :: kim_language_name_type !> \brief \copybrief KIM::LanguageName::languageNameID !! !! \sa KIM::LanguageName::languageNameID, KIM_LanguageName::languageNameID !! !! \since 2.0 integer(c_int) :: language_name_id end type kim_language_name_type !> \brief \copybrief KIM::LANGUAGE_NAME::cpp !! !! \sa KIM::LANGUAGE_NAME::cpp, KIM_LANGUAGE_NAME_cpp !! !! \since 2.0 type(kim_language_name_type), protected, save, & bind(c, name="KIM_LANGUAGE_NAME_cpp") & :: KIM_LANGUAGE_NAME_CPP !> \brief \copybrief KIM::LANGUAGE_NAME::c !! !! \sa KIM::LANGUAGE_NAME::c, KIM_LANGUAGE_NAME_c !! !! \since 2.0 type(kim_language_name_type), protected, save, & bind(c, name="KIM_LANGUAGE_NAME_c") & :: KIM_LANGUAGE_NAME_C !> \brief \copybrief KIM::LANGUAGE_NAME::fortran !! !! \sa KIM::LANGUAGE_NAME::fortran, KIM_LANGUAGE_NAME_fortran !! !! \since 2.0 type(kim_language_name_type), protected, save, & bind(c, name="KIM_LANGUAGE_NAME_fortran") & :: KIM_LANGUAGE_NAME_FORTRAN !> \brief \copybrief KIM::LanguageName::Known !! !! \sa KIM::LanguageName::Known, KIM_LanguageName_Known !! !! \since 2.0 interface kim_known module procedure kim_language_name_known end interface kim_known !> \brief \copybrief KIM::LanguageName::operator==() !! !! \sa KIM::LanguageName::operator==(), KIM_LanguageName_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_language_name_equal end interface operator(.eq.) !> \brief \copybrief KIM::LanguageName::operator!=() !! !! \sa KIM::LanguageName::operator!=(), KIM_LanguageName_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_language_name_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::LanguageName::LanguageName(std::string const &) !! !! \sa KIM::LanguageName::LanguageName(std::string const &), !! KIM_LanguageName_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_language_name_from_string end interface kim_from_string !> \brief \copybrief KIM::LanguageName::ToString !! !! \sa KIM::LanguageName::ToString, KIM_LanguageName_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_language_name_to_string end interface kim_to_string contains !> \brief \copybrief KIM::LanguageName::Known !! !! \sa KIM::LanguageName::Known, KIM_LanguageName_Known !! !! \since 2.0 logical recursive function kim_language_name_known(language_name) implicit none interface integer(c_int) recursive function known(language_name) & bind(c, name="KIM_LanguageName_Known") use, intrinsic :: iso_c_binding import kim_language_name_type implicit none type(kim_language_name_type), intent(in), value :: language_name end function known end interface type(kim_language_name_type), intent(in) :: language_name kim_language_name_known = (known(language_name) /= 0) end function kim_language_name_known !> \brief \copybrief KIM::LanguageName::operator==() !! !! \sa KIM::LanguageName::operator==(), KIM_LanguageName_Equal !! !! \since 2.0 logical recursive function kim_language_name_equal(lhs, rhs) implicit none type(kim_language_name_type), intent(in) :: lhs type(kim_language_name_type), intent(in) :: rhs kim_language_name_equal & = (lhs%language_name_id == rhs%language_name_id) end function kim_language_name_equal !> \brief \copybrief KIM::LanguageName::operator!=() !! !! \sa KIM::LanguageName::operator!=(), KIM_LanguageName_NotEqual !! !! \since 2.0 logical recursive function kim_language_name_not_equal(lhs, rhs) implicit none type(kim_language_name_type), intent(in) :: lhs type(kim_language_name_type), intent(in) :: rhs kim_language_name_not_equal = .not. (lhs == rhs) end function kim_language_name_not_equal !> \brief \copybrief KIM::LanguageName::LanguageName(std::string const &) !! !! \sa KIM::LanguageName::LanguageName(std::string const &), !! KIM_LanguageName_FromString !! !! \since 2.0 recursive subroutine kim_language_name_from_string(string, language_name) implicit none interface type(kim_language_name_type) recursive function from_string(string) & bind(c, name="KIM_LanguageName_FromString") use, intrinsic :: iso_c_binding import kim_language_name_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_language_name_type), intent(out) :: language_name language_name = from_string(trim(string)//c_null_char) end subroutine kim_language_name_from_string !> \brief \copybrief KIM::LanguageName::ToString !! !! \sa KIM::LanguageName::ToString, KIM_LanguageName_ToString !! !! \since 2.0 recursive subroutine kim_language_name_to_string(language_name, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(language_name) & bind(c, name="KIM_LanguageName_ToString") use, intrinsic :: iso_c_binding import kim_language_name_type implicit none type(kim_language_name_type), intent(in), value :: language_name end function get_string end interface type(kim_language_name_type), intent(in) :: language_name character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(language_name) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_language_name_to_string !> \brief \copybrief KIM::LANGUAGE_NAME::GetNumberOfLanguageNames !! !! \sa KIM::LANGUAGE_NAME::GetNumberOfLanguageNames, !! KIM_LANGUAGE_NAME_GetNumberOfLanguageNames !! !! \since 2.0 recursive subroutine kim_get_number_of_language_names( & number_of_language_names) implicit none interface recursive subroutine get_number_of_language_names( & number_of_language_names) & bind(c, name="KIM_LANGUAGE_NAME_GetNumberOfLanguageNames") use, intrinsic :: iso_c_binding integer(c_int), intent(out) :: number_of_language_names end subroutine get_number_of_language_names end interface integer(c_int), intent(out) :: number_of_language_names call get_number_of_language_names(number_of_language_names) end subroutine kim_get_number_of_language_names !> \brief \copybrief KIM::LANGUAGE_NAME::GetLanguageName !! !! \sa KIM::LANGUAGE_NAME::GetLanguageName, KIM_LANGUAGE_NAME_GetLanguageName !! !! \since 2.0 recursive subroutine kim_get_language_name(index, language_name, ierr) implicit none interface integer(c_int) recursive function get_language_name(index, & language_name) & bind(c, name="KIM_LANGUAGE_NAME_GetLanguageName") use, intrinsic :: iso_c_binding import kim_language_name_type integer(c_int), intent(in), value :: index type(kim_language_name_type), intent(out) :: language_name end function get_language_name end interface integer(c_int), intent(in) :: index type(kim_language_name_type), intent(out) :: language_name integer(c_int), intent(out) :: ierr ierr = get_language_name(index - 1, language_name) end subroutine kim_get_language_name end module kim_language_name_module kim-api-2.3.0-git/fortran/include/kim_length_unit_module.f90000066400000000000000000000226741421473465500240150ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::LengthUnit !! !! \sa KIM::LengthUnit, KIM_LengthUnit !! !! \since 2.0 module kim_length_unit_module use, intrinsic :: iso_c_binding implicit none private public & ! Derive types kim_length_unit_type, & ! Constants KIM_LENGTH_UNIT_UNUSED, & KIM_LENGTH_UNIT_A, & KIM_LENGTH_UNIT_BOHR, & KIM_LENGTH_UNIT_CM, & KIM_LENGTH_UNIT_M, & KIM_LENGTH_UNIT_NM, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_length_units, & kim_get_length_unit !> \brief \copybrief KIM::LengthUnit !! !! \sa KIM::LengthUnit, KIM_LengthUnit !! !! \since 2.0 type, bind(c) :: kim_length_unit_type !> \brief \copybrief KIM::LengthUnit::lengthUnitID !! !! \sa KIM::LengthUnit::lengthUnitID, KIM_LengthUnit::lengthUnitID !! !! \since 2.0 integer(c_int) length_unit_id end type kim_length_unit_type !> \brief \copybrief KIM::LENGTH_UNIT::unused !! !! \sa KIM::LENGTH_UNIT::unused, KIM_LENGTH_UNIT_unused !! !! \since 2.0 type(kim_length_unit_type), protected, save, & bind(c, name="KIM_LENGTH_UNIT_unused") & :: KIM_LENGTH_UNIT_UNUSED !> \brief \copybrief KIM::LENGTH_UNIT::A !! !! \sa KIM::LENGTH_UNIT::A, KIM_LENGTH_UNIT_A !! !! \since 2.0 type(kim_length_unit_type), protected, save, & bind(c, name="KIM_LENGTH_UNIT_A") & :: KIM_LENGTH_UNIT_A !> \brief \copybrief KIM::LENGTH_UNIT::Bohr !! !! \sa KIM::LENGTH_UNIT::Bohr, KIM_LENGTH_UNIT_Bohr !! !! \since 2.0 type(kim_length_unit_type), protected, save, & bind(c, name="KIM_LENGTH_UNIT_Bohr") & :: KIM_LENGTH_UNIT_BOHR !> \brief \copybrief KIM::LENGTH_UNIT::cm !! !! \sa KIM::LENGTH_UNIT::cm, KIM_LENGTH_UNIT_cm !! !! \since 2.0 type(kim_length_unit_type), protected, save, & bind(c, name="KIM_LENGTH_UNIT_cm") & :: KIM_LENGTH_UNIT_CM !> \brief \copybrief KIM::LENGTH_UNIT::m !! !! \sa KIM::LENGTH_UNIT::m, KIM_LENGTH_UNIT_m !! !! \since 2.0 type(kim_length_unit_type), protected, save, & bind(c, name="KIM_LENGTH_UNIT_m") & :: KIM_LENGTH_UNIT_M !> \brief \copybrief KIM::LENGTH_UNIT::nm !! !! \sa KIM::LENGTH_UNIT::nm, KIM_LENGTH_UNIT_nm !! !! \since 2.0 type(kim_length_unit_type), protected, save, & bind(c, name="KIM_LENGTH_UNIT_nm") & :: KIM_LENGTH_UNIT_NM !> \brief \copybrief KIM::LengthUnit::Known !! !! \sa KIM::LengthUnit::Known, KIM_LengthUnit_Known !! !! \since 2.0 interface kim_known module procedure kim_length_unit_known end interface kim_known !> \brief \copybrief KIM::LengthUnit::operator==() !! !! \sa KIM::LengthUnit::operator==(), KIM_LengthUnit_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_length_unit_equal end interface operator(.eq.) !> \brief \copybrief KIM::LengthUnit::operator!=() !! !! \sa KIM::LengthUnit::operator!=(), KIM_LengthUnit_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_length_unit_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::LengthUnit::LengthUnit(std::string const &) !! !! \sa KIM::LengthUnit::LengthUnit(std::string const &), !! KIM_LengthUnit_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_length_unit_from_string end interface kim_from_string !> \brief \copybrief KIM::LengthUnit::ToString !! !! \sa KIM::LengthUnit::ToString, KIM_LengthUnit_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_length_unit_to_string end interface kim_to_string contains !> \brief \copybrief KIM::LengthUnit::Known !! !! \sa KIM::LengthUnit::Known, KIM_LengthUnit_Known !! !! \since 2.0 logical recursive function kim_length_unit_known(length_unit) implicit none interface integer(c_int) recursive function known(length_unit) & bind(c, name="KIM_LengthUnit_Known") use, intrinsic :: iso_c_binding import kim_length_unit_type implicit none type(kim_length_unit_type), intent(in), value :: length_unit end function known end interface type(kim_length_unit_type), intent(in) :: length_unit kim_length_unit_known = (known(length_unit) /= 0) end function kim_length_unit_known !> \brief \copybrief KIM::LengthUnit::operator==() !! !! \sa KIM::LengthUnit::operator==(), KIM_LengthUnit_Equal !! !! \since 2.0 logical recursive function kim_length_unit_equal(lhs, rhs) implicit none type(kim_length_unit_type), intent(in) :: lhs type(kim_length_unit_type), intent(in) :: rhs kim_length_unit_equal & = (lhs%length_unit_id == rhs%length_unit_id) end function kim_length_unit_equal !> \brief \copybrief KIM::LengthUnit::operator!=() !! !! \sa KIM::LengthUnit::operator!=(), KIM_LengthUnit_NotEqual !! !! \since 2.0 logical recursive function kim_length_unit_not_equal(lhs, rhs) implicit none type(kim_length_unit_type), intent(in) :: lhs type(kim_length_unit_type), intent(in) :: rhs kim_length_unit_not_equal = .not. (lhs == rhs) end function kim_length_unit_not_equal !> \brief \copybrief KIM::LengthUnit::LengthUnit(std::string const &) !! !! \sa KIM::LengthUnit::LengthUnit(std::string const &), !! KIM_LengthUnit_FromString !! !! \since 2.0 recursive subroutine kim_length_unit_from_string(string, length_unit) implicit none interface type(kim_length_unit_type) recursive function from_string(string) & bind(c, name="KIM_LengthUnit_FromString") use, intrinsic :: iso_c_binding import kim_length_unit_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_length_unit_type), intent(out) :: length_unit length_unit = from_string(trim(string)//c_null_char) end subroutine kim_length_unit_from_string !> \brief \copybrief KIM::LengthUnit::ToString !! !! \sa KIM::LengthUnit::ToString, KIM_LengthUnit_ToString !! !! \since 2.0 recursive subroutine kim_length_unit_to_string(length_unit, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(length_unit) & bind(c, name="KIM_LengthUnit_ToString") use, intrinsic :: iso_c_binding import kim_length_unit_type implicit none type(kim_length_unit_type), intent(in), value :: length_unit end function get_string end interface type(kim_length_unit_type), intent(in) :: length_unit character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(length_unit) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_length_unit_to_string !> \brief \copybrief KIM::LENGTH_UNIT::GetNumberOfLengthUnits !! !! \sa KIM::LENGTH_UNIT::GetNumberOfLengthUnits, !! KIM_LENGTH_UNIT_GetNumberOfLengthUnits !! !! \since 2.0 recursive subroutine kim_get_number_of_length_units(number_of_length_units) implicit none interface recursive subroutine get_number_of_length_units(number_of_length_units) & bind(c, name="KIM_LENGTH_UNIT_GetNumberOfLengthUnits") use, intrinsic :: iso_c_binding integer(c_int), intent(out) :: number_of_length_units end subroutine get_number_of_length_units end interface integer(c_int), intent(out) :: number_of_length_units call get_number_of_length_units(number_of_length_units) end subroutine kim_get_number_of_length_units !> \brief \copybrief KIM::LENGTH_UNIT::GetLengthUnit !! !! \sa KIM::LENGTH_UNIT::GetLengthUnit, KIM_LENGTH_UNIT_GetLengthUnit !! !! \since 2.0 recursive subroutine kim_get_length_unit(index, length_unit, ierr) implicit none interface integer(c_int) recursive function get_length_unit(index, length_unit) & bind(c, name="KIM_LENGTH_UNIT_GetLengthUnit") use, intrinsic :: iso_c_binding import kim_length_unit_type implicit none integer(c_int), intent(in), value :: index type(kim_length_unit_type), intent(out) :: length_unit end function get_length_unit end interface integer(c_int), intent(in) :: index type(kim_length_unit_type), intent(out) :: length_unit integer(c_int), intent(out) :: ierr ierr = get_length_unit(index - 1, length_unit) end subroutine kim_get_length_unit end module kim_length_unit_module kim-api-2.3.0-git/fortran/include/kim_log_module.f90000066400000000000000000000414101421473465500222430ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::Log !! !! \sa KIM::Log, KIM_Log !! !! \since 2.0 module kim_log_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_log_handle_type, & ! Constants KIM_LOG_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_log_create, & kim_log_destroy, & kim_push_default_verbosity, & kim_pop_default_verbosity, & kim_push_default_print_function, & kim_pop_default_print_function, & kim_convert_c_string, & kim_get_id, & kim_set_id, & kim_push_verbosity, & kim_pop_verbosity, & kim_log_entry !> \brief \copybrief KIM::Log !! !! \sa KIM::Log, KIM_Log !! !! \since 2.0 type, bind(c) :: kim_log_handle_type type(c_ptr) :: p = c_null_ptr end type kim_log_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_log_handle_type), protected, save & :: KIM_LOG_NULL_HANDLE !> \brief Compares kim_log_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_log_handle_equal end interface operator(.eq.) !> \brief Compares kim_log_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_log_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::Log::PushDefaultVerbosity !! !! \sa KIM::Log::PushDefaultVerbosity, KIM_Log_PushDefaultVerbosity !! !! \since 2.0 interface kim_push_default_verbosity module procedure kim_log_push_default_verbosity end interface kim_push_default_verbosity !> \brief \copybrief KIM::Log::PopDefaultVerbosity !! !! \sa KIM::Log::PopDefaultVerbosity, KIM_Log_PopDefaultVerbosity !! !! \since 2.0 interface kim_pop_default_verbosity module procedure kim_log_pop_default_verbosity end interface kim_pop_default_verbosity !> \brief \copybrief KIM::Log::PushDefaultPrintFunction !! !! \sa KIM::Log::PushDefaultPrintFunction, KIM_Log_PushDefaultPrintFunction !! !! \since 2.2 interface kim_push_default_print_function module procedure kim_log_push_default_print_function end interface kim_push_default_print_function !> \brief \copybrief KIM::Log::PopDefaultPrintFunction !! !! \sa KIM::Log::PopDefaultPrintFunction, KIM_Log_PopDefaultPrintFunction !! !! \since 2.2 interface kim_pop_default_print_function module procedure kim_log_pop_default_print_function end interface kim_pop_default_print_function !> \brief \copybrief kim_log_module::kim_log_convert_c_string !! !! \since 2.2 interface kim_convert_c_string module procedure kim_log_convert_c_string end interface kim_convert_c_string !> \brief \copybrief KIM::Log::GetID !! !! \sa KIM::Log::GetID, KIM_Log_GetID !! !! \since 2.0 interface kim_get_id module procedure kim_log_get_id end interface kim_get_id !> \brief \copybrief KIM::Log::SetID !! !! \sa KIM::Log::SetID, KIM_Log_SetID !! !! \since 2.0 interface kim_set_id module procedure kim_log_set_id end interface kim_set_id !> \brief \copybrief KIM::Log::PushVerbosity !! !! \sa KIM::Log::PushVerbosity, KIM_Log_PushVerbosity !! !! \since 2.0 interface kim_push_verbosity module procedure kim_log_push_verbosity end interface kim_push_verbosity !> \brief \copybrief KIM::Log::PopVerbosity !! !! \sa KIM::Log::PopVerbosity, KIM_Log_PopVerbosity !! !! \since 2.0 interface kim_pop_verbosity module procedure kim_log_pop_verbosity end interface kim_pop_verbosity !> \brief \copybrief KIM::Log::LogEntry !! !! \sa KIM::Log::LogEntry, KIM_Log_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_log_log_entry end interface kim_log_entry contains !> \brief Compares kim_log_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_log_handle_equal(lhs, rhs) implicit none type(kim_log_handle_type), intent(in) :: lhs type(kim_log_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_log_handle_equal = .true. else kim_log_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_log_handle_equal !> \brief Compares kim_log_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_log_handle_not_equal(lhs, rhs) implicit none type(kim_log_handle_type), intent(in) :: lhs type(kim_log_handle_type), intent(in) :: rhs kim_log_handle_not_equal = .not. (lhs == rhs) end function kim_log_handle_not_equal !> \brief \copybrief KIM::Log::Create !! !! \sa KIM::Log::Create, KIM_Log_Create !! !! \since 2.0 recursive subroutine kim_log_create(log_handle, ierr) implicit none interface integer(c_int) recursive function create(log) & bind(c, name="KIM_Log_Create") use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(out) :: log end function create end interface type(kim_log_handle_type), intent(out) :: log_handle integer(c_int), intent(out) :: ierr type(c_ptr) :: plog ierr = create(plog) log_handle%p = plog end subroutine kim_log_create !> \brief \copybrief KIM::Log::Destroy !! !! \sa KIM::Log::Destroy, KIM_Log_Destroy !! !! \since 2.0 recursive subroutine kim_log_destroy(log_handle) implicit none interface recursive subroutine destroy(log) bind(c, name="KIM_Log_Destroy") use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(inout) :: log end subroutine destroy end interface type(kim_log_handle_type), intent(inout) :: log_handle type(c_ptr) :: plog plog = log_handle%p call destroy(plog) log_handle%p = c_null_ptr end subroutine kim_log_destroy !> \brief \copybrief KIM::Log::PushDefaultVerbosity !! !! \sa KIM::Log::PushDefaultVerbosity, KIM_Log_PushDefaultVerbosity !! !! \since 2.0 recursive subroutine kim_log_push_default_verbosity(log_verbosity) use kim_log_verbosity_module, only: kim_log_verbosity_type implicit none interface recursive subroutine push_default_verbosity(log_verbosity) & bind(c, name="KIM_Log_PushDefaultVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type implicit none type(kim_log_verbosity_type), intent(in), value :: log_verbosity end subroutine push_default_verbosity end interface type(kim_log_verbosity_type), intent(in) :: log_verbosity call push_default_verbosity(log_verbosity) end subroutine kim_log_push_default_verbosity !> \brief \copybrief KIM::Log::PopDefaultVerbosity !! !! \sa KIM::Log::PopDefaultVerbosity, KIM_Log_PopDefaultVerbosity !! !! \since 2.0 recursive subroutine kim_log_pop_default_verbosity() implicit none interface recursive subroutine pop_default_verbosity() & bind(c, name="KIM_Log_PopDefaultVerbosity") use, intrinsic :: iso_c_binding implicit none end subroutine pop_default_verbosity end interface call pop_default_verbosity() end subroutine kim_log_pop_default_verbosity !> \brief \copybrief KIM::Log::PushDefaultPrintFunction !! !! A Fortran routine may provide a KIM::Log::PrintFunction routine. The !! interface for this is given here (see also KIM::LogPrintFunction, \ref !! KIM_LogPrintFunction). !! !! \code{.f90} !! interface !! recursive subroutine log_print_function(entry_string, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! type(c_ptr), intent(in), value :: entry_string !! integer(c_int), intent(out) :: ierr !! end subroutine log_print_function !! end interface !! \endcode !! !! The routine must take a c_ptr pointing to a null terminated c string !! representing the log message. To work with this, the kim_log_module !! provides a conversion routine: kim_log_module::kim_convert_c_string. !! !! An example log print function, which simply writes log messages to stdout, !! is given here: !! !! \code{.f90} !! recursive subroutine log_print_function(entry_string, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! use kim_log_module, only : kim_convert_c_string !! type(c_ptr), intent(in), value :: entry_string !! integer(c_int), intent(out) :: ierr !! !! character(len=2048, kind=c_char) :: message !! !! call kim_convert_c_string(entry_string, message) !! print *, trim(message) !! !! ierr = 0 !! return !! end subroutine log_print_function !! \endcode !! !! \sa KIM::Log::PushDefaultPrintFunction, KIM_Log_PushDefaultPrintFunction !! !! \since 2.2 recursive subroutine kim_log_push_default_print_function(language_name, fptr) use kim_language_name_module, only: kim_language_name_type implicit none interface recursive subroutine push_default_print_function(language_name, fptr) & bind(c, name="KIM_Log_PushDefaultPrintFunction") use, intrinsic :: iso_c_binding use kim_language_name_module, only: kim_language_name_type implicit none type(kim_language_name_type), intent(in), value :: language_name type(c_funptr), intent(in), value :: fptr end subroutine push_default_print_function end interface type(kim_language_name_type), intent(in) :: language_name type(c_funptr), intent(in), value :: fptr ! must be left as "value"!?! call push_default_print_function(language_name, fptr) end subroutine kim_log_push_default_print_function !> \brief \copybrief KIM::Log::PopDefaultPrintFunction !! !! \sa KIM::Log::PopDefaultPrintFunction, KIM_Log_PopDefaultPrintFunction !! !! \since 2.2 recursive subroutine kim_log_pop_default_print_function() implicit none interface recursive subroutine pop_default_print_function() & bind(c, name="KIM_Log_PopDefaultPrintFunction") use, intrinsic :: iso_c_binding implicit none end subroutine pop_default_print_function end interface call pop_default_print_function() end subroutine kim_log_pop_default_print_function !> \brief Convert a c sting to a Fortran string !! !! Convert a c string, given in terms of a char pointer to a Fortran string !! variable. !! !! \param[in] c_char_ptr A pointer to a null terminated c string !! \param[out] string A Fortran string variable !! !! \since 2.2 recursive subroutine kim_log_convert_c_string(c_char_ptr, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none type(c_ptr), intent(in), value :: c_char_ptr character(len=*, kind=c_char), intent(out) :: string call kim_convert_c_char_ptr_to_string(c_char_ptr, string) end subroutine kim_log_convert_c_string !> \brief \copybrief KIM::Log::GetID !! !! \sa KIM::Log::GetID, KIM_Log_GetID !! !! \since 2.0 recursive subroutine kim_log_get_id(log_handle, id_string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_log_type implicit none interface type(c_ptr) recursive function get_id(log) bind(c, name="KIM_Log_GetID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_log_type implicit none type(kim_log_type), intent(in) :: log end function get_id end interface type(kim_log_handle_type), intent(in) :: log_handle character(len=*, kind=c_char), intent(out) :: id_string type(kim_log_type), pointer :: log type(c_ptr) :: p call c_f_pointer(log_handle%p, log) p = get_id(log) call kim_convert_c_char_ptr_to_string(p, id_string) end subroutine kim_log_get_id !> \brief \copybrief KIM::Log::SetID !! !! \sa KIM::Log::SetID, KIM_Log_SetID !! !! \since 2.0 recursive subroutine kim_log_set_id(log_handle, id_string) use kim_interoperable_types_module, only: kim_log_type implicit none interface recursive subroutine set_id(log, id_string) bind(c, name="KIM_Log_SetID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_log_type implicit none type(kim_log_type), intent(in) :: log character(c_char), intent(in) :: id_string(*) end subroutine set_id end interface type(kim_log_handle_type), intent(in) :: log_handle character(len=*, kind=c_char), intent(in) :: id_string type(kim_log_type), pointer :: log call c_f_pointer(log_handle%p, log) call set_id(log, trim(id_string)//c_null_char) end subroutine kim_log_set_id !> \brief \copybrief KIM::Log::PushVerbosity !! !! \sa KIM::Log::PushVerbosity, KIM_Log_PushVerbosity !! !! \since 2.0 recursive subroutine kim_log_push_verbosity(log_handle, log_verbosity) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_log_type implicit none interface recursive subroutine push_verbosity(log, log_verbosity) & bind(c, name="KIM_Log_PushVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_log_type implicit none type(kim_log_type), intent(in) :: log type(kim_log_verbosity_type), intent(in), value :: log_verbosity end subroutine push_verbosity end interface type(kim_log_handle_type), intent(in) :: log_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity type(kim_log_type), pointer :: log call c_f_pointer(log_handle%p, log) call push_verbosity(log, log_verbosity) end subroutine kim_log_push_verbosity !> \brief \copybrief KIM::Log::PopVerbosity !! !! \sa KIM::Log::PopVerbosity, KIM_Log_PopVerbosity !! !! \since 2.0 recursive subroutine kim_log_pop_verbosity(log_handle) use kim_interoperable_types_module, only: kim_log_type implicit none interface recursive subroutine pop_verbosity(log) & bind(c, name="KIM_Log_PopVerbosity") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_log_type implicit none type(kim_log_type), intent(in) :: log end subroutine pop_verbosity end interface type(kim_log_handle_type), intent(in) :: log_handle type(kim_log_type), pointer :: log call c_f_pointer(log_handle%p, log) call pop_verbosity(log) end subroutine kim_log_pop_verbosity !> \brief \copybrief KIM::Log::LogEntry !! !! \sa KIM::Log::LogEntry, KIM_Log_LogEntry !! !! \since 2.0 recursive subroutine kim_log_log_entry(log_handle, log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_log_type implicit none interface recursive subroutine log_entry(log, log_verbosity, message, line_number, & file_name) bind(c, name="KIM_Log_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_log_type implicit none type(kim_log_type), intent(in) :: log type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_log_handle_type), intent(in) :: log_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_log_type), pointer :: log call c_f_pointer(log_handle%p, log) call log_entry(log, log_verbosity, trim(message)//c_null_char, & 0, ""//c_null_char) end subroutine kim_log_log_entry end module kim_log_module kim-api-2.3.0-git/fortran/include/kim_log_verbosity_module.f90000066400000000000000000000320151421473465500243520ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::LogVerbosity !! !! \sa KIM::LogVerbosity, KIM_LogVerbosity !! !! \since 2.0 module kim_log_verbosity_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_log_verbosity_type, & ! Constants KIM_LOG_VERBOSITY_SILENT, & KIM_LOG_VERBOSITY_FATAL, & KIM_LOG_VERBOSITY_ERROR, & KIM_LOG_VERBOSITY_WARNING, & KIM_LOG_VERBOSITY_INFORMATION, & KIM_LOG_VERBOSITY_DEBUG, & ! Routines kim_known, & operator(.lt.), & operator(.gt.), & operator(.le.), & operator(.ge.), & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_log_verbosities, & kim_get_log_verbosity !> \brief \copybrief KIM::LogVerbosity !! !! \sa KIM::LogVerbosity, KIM_LogVerbosity !! !! \since 2.0 type, bind(c) :: kim_log_verbosity_type !> \brief \copybrief KIM::LogVerbosity::logVerbosityID !! !! \sa KIM::LogVerbosity::logVerbosityID, KIM_LogVerbosity::logVerbosityID !! !! \since 2.0 integer(c_int) :: log_verbosity_id end type kim_log_verbosity_type !> \brief \copybrief KIM::LOG_VERBOSITY::silent !! !! \sa KIM::LOG_VERBOSITY::silent, KIM_LOG_VERBOSITY_silent !! !! \since 2.0 type(kim_log_verbosity_type), protected, save, & bind(c, name="KIM_LOG_VERBOSITY_silent") & :: KIM_LOG_VERBOSITY_SILENT !> \brief \copybrief KIM::LOG_VERBOSITY::fatal !! !! \sa KIM::LOG_VERBOSITY::fatal, KIM_LOG_VERBOSITY_fatal !! !! \since 2.0 type(kim_log_verbosity_type), protected, save, & bind(c, name="KIM_LOG_VERBOSITY_fatal") & :: KIM_LOG_VERBOSITY_FATAL !> \brief \copybrief KIM::LOG_VERBOSITY::error !! !! \sa KIM::LOG_VERBOSITY::error, KIM_LOG_VERBOSITY_error !! !! \since 2.0 type(kim_log_verbosity_type), protected, save, & bind(c, name="KIM_LOG_VERBOSITY_error") & :: KIM_LOG_VERBOSITY_ERROR !> \brief \copybrief KIM::LOG_VERBOSITY::warning !! !! \sa KIM::LOG_VERBOSITY::warning, KIM_LOG_VERBOSITY_warning !! !! \since 2.0 type(kim_log_verbosity_type), protected, save, & bind(c, name="KIM_LOG_VERBOSITY_warning") & :: KIM_LOG_VERBOSITY_WARNING !> \brief \copybrief KIM::LOG_VERBOSITY::information !! !! \sa KIM::LOG_VERBOSITY::information, KIM_LOG_VERBOSITY_information !! !! \since 2.0 type(kim_log_verbosity_type), protected, save, & bind(c, name="KIM_LOG_VERBOSITY_information") & :: KIM_LOG_VERBOSITY_INFORMATION !> \brief \copybrief KIM::LOG_VERBOSITY::debug !! !! \sa KIM::LOG_VERBOSITY::debug, KIM_LOG_VERBOSITY_debug !! !! \since 2.0 type(kim_log_verbosity_type), protected, save, & bind(c, name="KIM_LOG_VERBOSITY_debug") & :: KIM_LOG_VERBOSITY_DEBUG !> \brief \copybrief KIM::LogVerbosity::Known !! !! \sa KIM::LogVerbosity::Known, KIM_LogVerbosity_Known !! !! \since 2.0 interface kim_known module procedure kim_log_verbosity_known end interface kim_known !> \brief \copybrief KIM::LogVerbosity::operator<() !! !! \sa KIM::LogVerbosity::operator<(), KIM_LogVerbosity_LessThan !! !! \since 2.0 interface operator(.lt.) module procedure kim_log_verbosity_less_than end interface operator(.lt.) !> \brief \copybrief KIM::LogVerbosity::operator>() !! !! \sa KIM::LogVerbosity::operator>(), KIM_LogVerbosity_GreaterThan !! !! \since 2.0 interface operator(.gt.) module procedure kim_log_verbosity_greater_than end interface operator(.gt.) !> \brief \copybrief KIM::LogVerbosity::operator<=() !! !! \sa KIM::LogVerbosity::operator<=(), KIM_LogVerbosity_LessThanEqual !! !! \since 2.0 interface operator(.le.) module procedure kim_log_verbosity_less_than_equal end interface operator(.le.) !> \brief \copybrief KIM::LogVerbosity::operator>=() !! !! \sa KIM::LogVerbosity::operator>=(), KIM_LogVerbosity_GreaterThanEqual !! !! \since 2.0 interface operator(.ge.) module procedure kim_log_verbosity_greater_than_equal end interface operator(.ge.) !> \brief \copybrief KIM::LogVerbosity::operator==() !! !! \sa KIM::LogVerbosity::operator==(), KIM_LogVerbosity_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_log_verbosity_equal end interface operator(.eq.) !> \brief \copybrief KIM::LogVerbosity::operator!=() !! !! \sa KIM::LogVerbosity::operator!=(), KIM_LogVerbosity_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_log_verbosity_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::LogVerbosity::LogVerbosity(std::string const &) !! !! \sa KIM::LogVerbosity::LogVerbosity(std::string const &), !! KIM_LogVerbosity_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_log_verbosity_from_string end interface kim_from_string !> \brief \copybrief KIM::LogVerbosity::ToString !! !! \sa KIM::LogVerbosity::ToString, KIM_LogVerbosity_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_log_verbosity_to_string end interface kim_to_string contains !> \brief \copybrief KIM::LogVerbosity::Known !! !! \sa KIM::LogVerbosity::Known, KIM_LogVerbosity_Known !! !! \since 2.0 logical recursive function kim_log_verbosity_known(log_verbosity) implicit none interface integer(c_int) recursive function known(log_verbosity) & bind(c, name="KIM_LogVerbosity_Known") use, intrinsic :: iso_c_binding import kim_log_verbosity_type implicit none type(kim_log_verbosity_type), intent(in), value :: log_verbosity end function known end interface type(kim_log_verbosity_type), intent(in) :: log_verbosity kim_log_verbosity_known = (known(log_verbosity) /= 0) end function kim_log_verbosity_known !> \brief \copybrief KIM::LogVerbosity::operator<() !! !! \sa KIM::LogVerbosity::operator<(), KIM_LogVerbosity_LessThan !! !! \since 2.0 logical recursive function kim_log_verbosity_less_than(lhs, rhs) implicit none type(kim_log_verbosity_type), intent(in) :: lhs type(kim_log_verbosity_type), intent(in) :: rhs kim_log_verbosity_less_than & = (lhs%log_verbosity_id < rhs%log_verbosity_id) end function kim_log_verbosity_less_than !> \brief \copybrief KIM::LogVerbosity::operator>() !! !! \sa KIM::LogVerbosity::operator>(), KIM_LogVerbosity_GreaterThan !! !! \since 2.0 logical recursive function kim_log_verbosity_greater_than(lhs, rhs) implicit none type(kim_log_verbosity_type), intent(in) :: lhs type(kim_log_verbosity_type), intent(in) :: rhs kim_log_verbosity_greater_than & = (lhs%log_verbosity_id >= rhs%log_verbosity_id) end function kim_log_verbosity_greater_than !> \brief \copybrief KIM::LogVerbosity::operator<=() !! !! \sa KIM::LogVerbosity::operator<=(), KIM_LogVerbosity_LessThanEqual !! !! \since 2.0 logical recursive function kim_log_verbosity_less_than_equal(lhs, rhs) implicit none type(kim_log_verbosity_type), intent(in) :: lhs type(kim_log_verbosity_type), intent(in) :: rhs kim_log_verbosity_less_than_equal & = (lhs%log_verbosity_id <= rhs%log_verbosity_id) end function kim_log_verbosity_less_than_equal !> \brief \copybrief KIM::LogVerbosity::operator>=() !! !! \sa KIM::LogVerbosity::operator>=(), KIM_LogVerbosity_GreaterThanEqual !! !! \since 2.0 logical recursive function kim_log_verbosity_greater_than_equal(lhs, rhs) implicit none type(kim_log_verbosity_type), intent(in) :: lhs type(kim_log_verbosity_type), intent(in) :: rhs kim_log_verbosity_greater_than_equal & = (lhs%log_verbosity_id >= rhs%log_verbosity_id) end function kim_log_verbosity_greater_than_equal !> \brief \copybrief KIM::LogVerbosity::operator==() !! !! \sa KIM::LogVerbosity::operator==(), KIM_LogVerbosity_Equal !! !! \since 2.0 logical recursive function kim_log_verbosity_equal(lhs, rhs) implicit none type(kim_log_verbosity_type), intent(in) :: lhs type(kim_log_verbosity_type), intent(in) :: rhs kim_log_verbosity_equal & = (lhs%log_verbosity_id == rhs%log_verbosity_id) end function kim_log_verbosity_equal !> \brief \copybrief KIM::LogVerbosity::operator!=() !! !! \sa KIM::LogVerbosity::operator!=(), KIM_LogVerbosity_NotEqual !! !! \since 2.0 logical recursive function kim_log_verbosity_not_equal(lhs, rhs) implicit none type(kim_log_verbosity_type), intent(in) :: lhs type(kim_log_verbosity_type), intent(in) :: rhs kim_log_verbosity_not_equal = .not. (lhs == rhs) end function kim_log_verbosity_not_equal !> \brief \copybrief KIM::LogVerbosity::LogVerbosity(std::string const &) !! !! \sa KIM::LogVerbosity::LogVerbosity(std::string const &), !! KIM_LogVerbosity_FromString !! !! \since 2.0 recursive subroutine kim_log_verbosity_from_string(string, log_verbosity) implicit none interface type(kim_log_verbosity_type) recursive function from_string(string) & bind(c, name="KIM_LogVerbosity_FromString") use, intrinsic :: iso_c_binding import kim_log_verbosity_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_log_verbosity_type), intent(out) :: log_verbosity log_verbosity = from_string(trim(string)//c_null_char) end subroutine kim_log_verbosity_from_string !> \brief \copybrief KIM::LogVerbosity::ToString !! !! \sa KIM::LogVerbosity::ToString, KIM_LogVerbosity_ToString !! !! \since 2.0 recursive subroutine kim_log_verbosity_to_string(log_verbosity, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(log_verbosity) & bind(c, name="KIM_LogVerbosity_ToString") use, intrinsic :: iso_c_binding import kim_log_verbosity_type implicit none type(kim_log_verbosity_type), intent(in), value :: log_verbosity end function get_string end interface type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(log_verbosity) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_log_verbosity_to_string !> \brief \copybrief KIM::LOG_VERBOSITY::GetNumberOfLogVerbosities !! !! \sa KIM::LOG_VERBOSITY::GetNumberOfLogVerbosities, !! KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities !! !! \since 2.0 recursive subroutine kim_get_number_of_log_verbosities( & number_of_log_verbosities) implicit none interface recursive subroutine get_number_of_log_verbosities( & number_of_log_verbosities) & bind(c, name="KIM_LOG_VERBOSITY_GetNumberOfLogVerbosities") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_log_verbosities end subroutine get_number_of_log_verbosities end interface integer(c_int), intent(out) :: number_of_log_verbosities call get_number_of_log_verbosities(number_of_log_verbosities) end subroutine kim_get_number_of_log_verbosities !> \brief \copybrief KIM::LOG_VERBOSITY::GetLogVerbosity !! !! \sa KIM::LOG_VERBOSITY::GetLogVerbosity, KIM_LOG_VERBOSITY_GetLogVerbosity !! !! \since 2.0 recursive subroutine kim_get_log_verbosity(index, log_verbosity, ierr) implicit none interface integer(c_int) recursive function get_log_verbosity( & index, log_verbosity) bind(c, name="KIM_LOG_VERBOSITY_GetLogVerbosity") use, intrinsic :: iso_c_binding import kim_log_verbosity_type implicit none integer(c_int), intent(in), value :: index type(kim_log_verbosity_type), intent(out) :: log_verbosity end function get_log_verbosity end interface integer(c_int), intent(in) :: index type(kim_log_verbosity_type), intent(out) :: log_verbosity integer(c_int), intent(out) :: ierr ierr = get_log_verbosity(index - 1, log_verbosity) end subroutine kim_get_log_verbosity end module kim_log_verbosity_module kim-api-2.3.0-git/fortran/include/kim_model_compute_arguments_create_module.f90000066400000000000000000000371311421473465500277330ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelComputeArgumentsCreate !! !! \sa KIM::ModelComputeArgumentsCreate, !! KIM_ModelComputeArgumentsCreate !! !! \since 2.0 module kim_model_compute_arguments_create_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_compute_arguments_create_handle_type, & ! Constants KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_set_argument_support_status, & kim_set_callback_support_status, & kim_set_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelComputeArgumentsCreate !! !! \sa KIM::ModelComputeArgumentsCreate, !! KIM_ModelComputeArgumentsCreate !! !! \since 2.0 type, bind(c) :: kim_model_compute_arguments_create_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_compute_arguments_create_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_compute_arguments_create_handle_type), protected, save & :: KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_NULL_HANDLE !> \brief Compares kim_model_compute_arguments_create_handle_type's for !! equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_compute_arguments_create_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_compute_arguments_create_handle_type's for !! inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_compute_arguments_create_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus !! !! \sa KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus, !! KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus !! !! \since 2.0 interface kim_set_argument_support_status module procedure & kim_model_compute_arguments_create_set_argument_support_status end interface kim_set_argument_support_status !> \brief \copybrief KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus !! !! \sa KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus, !! KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus !! !! \since 2.0 interface kim_set_callback_support_status module procedure & kim_model_compute_arguments_create_set_callback_support_status end interface kim_set_callback_support_status !> \brief \copybrief KIM::ModelComputeArgumentsCreate::SetModelBufferPointer !! !! \sa KIM::ModelComputeArgumentsCreate::SetModelBufferPointer, !! KIM_ModelComputeArgumentsCreate_SetModelBufferPointer !! !! \since 2.0 interface kim_set_model_buffer_pointer module procedure kim_model_compute_arguments_create_set_model_buffer_pointer end interface kim_set_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArgumentsCreate::LogEntry !! !! \sa KIM::ModelComputeArgumentsCreate::LogEntry, !! KIM_ModelComputeArgumentsCreate_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_compute_arguments_create_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelComputeArgumentsCreate::ToString !! !! \sa KIM::ModelComputeArgumentsCreate::ToString, !! KIM_ModelComputeArgumentsCreate_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_compute_arguments_create_to_string end interface kim_to_string contains !> \brief Compares kim_model_compute_arguments_create_handle_type's for !! equality. !! !! \since 2.0 logical recursive function kim_model_compute_arguments_create_handle_equal( & lhs, rhs) implicit none type(kim_model_compute_arguments_create_handle_type), intent(in) :: lhs type(kim_model_compute_arguments_create_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_compute_arguments_create_handle_equal = .true. else kim_model_compute_arguments_create_handle_equal = c_associated(lhs%p, & rhs%p) end if end function kim_model_compute_arguments_create_handle_equal !> \brief Compares kim_model_compute_arguments_create_handle_type's for !! inequality. !! !! \since 2.0 logical recursive function & kim_model_compute_arguments_create_handle_not_equal(lhs, rhs) implicit none type(kim_model_compute_arguments_create_handle_type), intent(in) :: lhs type(kim_model_compute_arguments_create_handle_type), intent(in) :: rhs kim_model_compute_arguments_create_handle_not_equal = & .not. (lhs == rhs) end function kim_model_compute_arguments_create_handle_not_equal !> \brief \copybrief KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus !! !! \sa KIM::ModelComputeArgumentsCreate::SetArgumentSupportStatus, !! KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_create_set_argument_support_status( & model_commpute_arguments_create_handle, compute_argument_name, & support_status, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none interface integer(c_int) recursive function set_argument_support_status( & model_commpute_arguments_create, compute_argument_name, & support_status) & bind(c, name="KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none type(kim_model_compute_arguments_create_type), intent(in) :: & model_commpute_arguments_create type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(kim_support_status_type), intent(in), value :: support_status end function set_argument_support_status end interface type(kim_model_compute_arguments_create_handle_type), intent(in) :: & model_commpute_arguments_create_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name type(kim_support_status_type), intent(in) :: support_status integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_create_type), pointer :: & model_commpute_arguments_create call c_f_pointer(model_commpute_arguments_create_handle%p, & model_commpute_arguments_create) ierr = set_argument_support_status(model_commpute_arguments_create, & compute_argument_name, support_status) end subroutine kim_model_compute_arguments_create_set_argument_support_status !> \brief \copybrief KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus !! !! \sa KIM::ModelComputeArgumentsCreate::SetCallbackSupportStatus, !! KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_create_set_callback_support_status( & model_commpute_arguments_create_handle, compute_callback_name, & support_status, ierr) use kim_compute_callback_name_module, only: kim_compute_callback_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none interface integer(c_int) recursive function set_callback_support_status( & model_commpute_arguments_create, compute_callback_name, & support_status) & bind(c, name="KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus") use, intrinsic :: iso_c_binding use kim_compute_callback_name_module, only: & kim_compute_callback_name_type use kim_support_status_module, only: kim_support_status_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none type(kim_model_compute_arguments_create_type), intent(in) :: & model_commpute_arguments_create type(kim_compute_callback_name_type), intent(in), value :: & compute_callback_name type(kim_support_status_type), intent(in), value :: support_status end function set_callback_support_status end interface type(kim_model_compute_arguments_create_handle_type), intent(in) :: & model_commpute_arguments_create_handle type(kim_compute_callback_name_type), intent(in) :: & compute_callback_name type(kim_support_status_type), intent(in) :: support_status integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_create_type), pointer :: & model_commpute_arguments_create call c_f_pointer(model_commpute_arguments_create_handle%p, & model_commpute_arguments_create) ierr = set_callback_support_status(model_commpute_arguments_create, & compute_callback_name, support_status) end subroutine kim_model_compute_arguments_create_set_callback_support_status !> \brief \copybrief KIM::ModelComputeArgumentsCreate::SetModelBufferPointer !! !! \sa KIM::ModelComputeArgumentsCreate::SetModelBufferPointer, !! KIM_ModelComputeArgumentsCreate_SetModelBufferPointer !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_create_set_model_buffer_pointer( & model_commpute_arguments_create_handle, ptr) use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none interface recursive subroutine set_model_buffer_pointer( & model_commpute_arguments_create, ptr) & bind(c, name="KIM_ModelComputeArgumentsCreate_SetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none type(kim_model_compute_arguments_create_type), intent(in) :: & model_commpute_arguments_create type(c_ptr), intent(in), value :: ptr end subroutine set_model_buffer_pointer end interface type(kim_model_compute_arguments_create_handle_type), intent(in) :: & model_commpute_arguments_create_handle type(c_ptr), intent(in) :: ptr type(kim_model_compute_arguments_create_type), pointer :: & model_commpute_arguments_create call c_f_pointer(model_commpute_arguments_create_handle%p, & model_commpute_arguments_create) call set_model_buffer_pointer(model_commpute_arguments_create, ptr) end subroutine kim_model_compute_arguments_create_set_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArgumentsCreate::LogEntry !! !! \sa KIM::ModelComputeArgumentsCreate::LogEntry, !! KIM_ModelComputeArgumentsCreate_LogEntry !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_create_log_entry( & model_commpute_arguments_create_handle, log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none interface recursive subroutine log_entry( & model_commpute_arguments_create, log_verbosity, message, line_number, & file_name) bind(c, name="KIM_ModelComputeArgumentsCreate_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none type(kim_model_compute_arguments_create_type), intent(in) :: & model_commpute_arguments_create type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_compute_arguments_create_handle_type), intent(in) :: & model_commpute_arguments_create_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_compute_arguments_create_type), pointer :: & model_commpute_arguments_create call c_f_pointer(model_commpute_arguments_create_handle%p, & model_commpute_arguments_create) call log_entry(model_commpute_arguments_create, log_verbosity, & trim(message)//c_null_char, 0, ""//c_null_char) end subroutine kim_model_compute_arguments_create_log_entry !> \brief \copybrief KIM::ModelComputeArgumentsCreate::ToString !! !! \sa KIM::ModelComputeArgumentsCreate::ToString, !! KIM_ModelComputeArgumentsCreate_ToString !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_create_to_string( & model_commpute_arguments_create_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none interface type(c_ptr) recursive function model_commpute_arguments_create_string( & model_commpute_arguments_create) & bind(c, name="KIM_ModelComputeArgumentsCreate_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_create_type implicit none type(kim_model_compute_arguments_create_type), intent(in) :: & model_commpute_arguments_create end function model_commpute_arguments_create_string end interface type(kim_model_compute_arguments_create_handle_type), intent(in) :: & model_commpute_arguments_create_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_compute_arguments_create_type), pointer :: & model_commpute_arguments_create type(c_ptr) :: p call c_f_pointer(model_commpute_arguments_create_handle%p, & model_commpute_arguments_create) p = model_commpute_arguments_create_string(model_commpute_arguments_create) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_compute_arguments_create_to_string end module kim_model_compute_arguments_create_module kim-api-2.3.0-git/fortran/include/kim_model_compute_arguments_destroy_module.f90000066400000000000000000000240771421473465500301660ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelComputeArgumentsDestroy !! !! \sa KIM::ModelComputeArgumentsDestroy, KIM_ModelComputeArgumentsDestroy !! !! \since 2.0 module kim_model_compute_arguments_destroy_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_compute_arguments_destroy_handle_type, & ! Constants KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelComputeArgumentsDestroy !! !! \sa KIM::ModelComputeArgumentsDestroy, KIM_ModelComputeArgumentsDestroy !! !! \since 2.0 type, bind(c) :: kim_model_compute_arguments_destroy_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_compute_arguments_destroy_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_compute_arguments_destroy_handle_type), protected, save & :: KIM_MODEL_COMPUTE_ARGUMENTS_DESTROY_NULL_HANDLE !> \brief Compares kim_model_compute_arguments_destroy_handle_type's for !! equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_compute_arguments_destroy_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_compute_arguments_destroy_handle_type's for !! inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_compute_arguments_destroy_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer !! !! \sa KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer, !! KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure & kim_model_compute_arguments_destroy_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArgumentsDestroy::LogEntry !! !! \sa KIM::ModelComputeArgumentsDestroy::LogEntry, !! KIM_ModelComputeArgumentsDestroy_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_compute_arguments_destroy_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelComputeArgumentsDestroy::ToString !! !! \sa KIM::ModelComputeArgumentsDestroy::ToString, !! KIM_ModelComputeArgumentsDestroy_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_compute_arguments_destroy_to_string end interface kim_to_string contains !> \brief Compares kim_model_compute_arguments_destroy_handle_type's for !! equality. !! !! \since 2.0 logical recursive function kim_model_compute_arguments_destroy_handle_equal( & lhs, rhs) implicit none type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: lhs type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_compute_arguments_destroy_handle_equal = .true. else kim_model_compute_arguments_destroy_handle_equal = c_associated(lhs%p, & rhs%p) end if end function kim_model_compute_arguments_destroy_handle_equal !> \brief Compares kim_model_compute_arguments_destroy_handle_type's for !! inequality. !! !! \since 2.0 logical recursive function & kim_model_compute_arguments_destroy_handle_not_equal(lhs, rhs) implicit none type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: lhs type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: rhs kim_model_compute_arguments_destroy_handle_not_equal = & .not. (lhs == rhs) end function kim_model_compute_arguments_destroy_handle_not_equal !> \brief \copybrief KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer !! !! \sa KIM::ModelComputeArgumentsDestroy::GetModelBufferPointer, !! KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_destroy_get_model_buffer_pointer( & model_compute_arguments_destroy_handle, ptr) use kim_interoperable_types_module, only: & kim_model_compute_arguments_destroy_type implicit none interface recursive subroutine get_model_buffer_pointer( & model_compute_arguments_destroy, ptr) & bind(c, name="KIM_ModelComputeArgumentsDestroy_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_destroy_type implicit none type(kim_model_compute_arguments_destroy_type), intent(in) :: & model_compute_arguments_destroy type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: & model_compute_arguments_destroy_handle type(c_ptr), intent(out) :: ptr type(kim_model_compute_arguments_destroy_type), pointer :: & model_compute_arguments_destroy call c_f_pointer(model_compute_arguments_destroy_handle%p, & model_compute_arguments_destroy) call get_model_buffer_pointer(model_compute_arguments_destroy, ptr) end subroutine kim_model_compute_arguments_destroy_get_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArgumentsDestroy::LogEntry !! !! \sa KIM::ModelComputeArgumentsDestroy::LogEntry, !! KIM_ModelComputeArgumentsDestroy_LogEntry !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_destroy_log_entry( & model_compute_arguments_destroy_handle, log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_destroy_type implicit none interface recursive subroutine log_entry( & model_compute_arguments_destroy, log_verbosity, message, line_number, & file_name) bind(c, name="KIM_ModelComputeArgumentsDestroy_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_destroy_type implicit none type(kim_model_compute_arguments_destroy_type), intent(in) :: & model_compute_arguments_destroy type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: & model_compute_arguments_destroy_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_compute_arguments_destroy_type), pointer :: & model_compute_arguments_destroy call c_f_pointer(model_compute_arguments_destroy_handle%p, & model_compute_arguments_destroy) call log_entry(model_compute_arguments_destroy, log_verbosity, & trim(message)//c_null_char, 0, ""//c_null_char) end subroutine kim_model_compute_arguments_destroy_log_entry !> \brief \copybrief KIM::ModelComputeArgumentsDestroy::ToString !! !! \sa KIM::ModelComputeArgumentsDestroy::ToString, !! KIM_ModelComputeArgumentsDestroy_ToString !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_destroy_to_string( & model_compute_arguments_destroy_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: & kim_model_compute_arguments_destroy_type implicit none interface type(c_ptr) recursive function model_compute_arguments_destroy_string( & model_compute_arguments_destroy) & bind(c, name="KIM_ModelComputeArgumentsDestroy_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_destroy_type implicit none type(kim_model_compute_arguments_destroy_type), intent(in) :: & model_compute_arguments_destroy end function model_compute_arguments_destroy_string end interface type(kim_model_compute_arguments_destroy_handle_type), intent(in) :: & model_compute_arguments_destroy_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_compute_arguments_destroy_type), pointer :: & model_compute_arguments_destroy type(c_ptr) :: p call c_f_pointer(model_compute_arguments_destroy_handle%p, & model_compute_arguments_destroy) p = model_compute_arguments_destroy_string(model_compute_arguments_destroy) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_compute_arguments_destroy_to_string end module kim_model_compute_arguments_destroy_module kim-api-2.3.0-git/fortran/include/kim_model_compute_arguments_module.f90000066400000000000000000001104531421473465500264070ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelComputeArguments !! !! \sa KIM::ModelComputeArguments, KIM_ModelComputeArguments !! !! \since 2.0 module kim_model_compute_arguments_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_compute_arguments_handle_type, & ! Constants KIM_MODEL_COMPUTE_ARGUMENTS_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_neighbor_list, & kim_process_dedr_term, & kim_process_d2edr2_term, & kim_get_argument_pointer, & kim_is_callback_present, & kim_set_model_buffer_pointer, & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelComputeArguments !! !! \sa KIM::ModelComputeArguments, KIM_ModelComputeArguments !! !! \since 2.0 type, bind(c) :: kim_model_compute_arguments_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_compute_arguments_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_compute_arguments_handle_type), protected, save & :: KIM_MODEL_COMPUTE_ARGUMENTS_NULL_HANDLE !> \brief Compares kim_model_compute_arguments_handle_type's for !! equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_compute_arguments_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_compute_arguments_handle_type's for !! inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_compute_arguments_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelComputeArguments::GetNeighborList !! !! \sa KIM::ModelComputeArguments::GetNeighborList, !! KIM_ModelComputeArguments_GetNeighborList !! !! \since 2.0 interface kim_get_neighbor_list module procedure kim_model_compute_arguments_get_neighbor_list end interface kim_get_neighbor_list !> \brief \copybrief KIM::ModelComputeArguments::ProcessDEDrTerm !! !! \sa KIM::ModelComputeArguments::ProcessDEDrTerm, !! KIM_ModelComputeArguments_ProcessDEDrTerm !! !! \since 2.0 interface kim_process_dedr_term module procedure kim_model_compute_arguments_process_dedr_term end interface kim_process_dedr_term !> \brief \copybrief KIM::ModelComputeArguments::ProcessD2EDr2Term !! !! \sa KIM::ModelComputeArguments::ProcessD2EDr2Term, !! KIM_ModelComputeArguments_ProcessD2EDr2Term !! !! \since 2.0 interface kim_process_d2edr2_term module procedure kim_model_compute_arguments_process_d2edr2_term end interface kim_process_d2edr2_term !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerInteger, !! KIM_ModelComputeArguments_GetArgumentPointerDouble !! !! \since 2.0 interface kim_get_argument_pointer module procedure kim_model_compute_arguments_get_argument_pointer_int0 module procedure kim_model_compute_arguments_get_argument_pointer_int1 module procedure kim_model_compute_arguments_get_argument_pointer_int2 module procedure kim_model_compute_arguments_get_argument_pointer_double0 module procedure kim_model_compute_arguments_get_argument_pointer_double1 module procedure kim_model_compute_arguments_get_argument_pointer_double2 end interface kim_get_argument_pointer !> \brief \copybrief KIM::ModelComputeArguments::IsCallbackPresent !! !! \sa KIM::ModelComputeArguments::IsCallbackPresent, !! KIM_ModelComputeArguments_IsCallbackPresent !! !! \since 2.0 interface kim_is_callback_present module procedure kim_model_compute_arguments_is_callback_present end interface kim_is_callback_present !> \brief \copybrief KIM::ModelComputeArguments::SetModelBufferPointer !! !! \sa KIM::ModelComputeArguments::SetModelBufferPointer, !! KIM_ModelComputeArguments_SetModelBufferPointer !! !! \since 2.0 interface kim_set_model_buffer_pointer module procedure kim_model_compute_arguments_set_model_buffer_pointer end interface kim_set_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArguments::GetModelBufferPointer !! !! \sa KIM::ModelComputeArguments::GetModelBufferPointer, !! KIM_ModelComputeArguments_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure kim_model_compute_arguments_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArguments::LogEntry !! !! \sa KIM::ModelComputeArguments::LogEntry, !! KIM_ModelComputeArguments_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_compute_arguments_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelComputeArguments::ToString !! !! \sa KIM::ModelComputeArguments::ToString, !! KIM_ModelComputeArguments_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_compute_arguments_to_string end interface kim_to_string contains !> \brief Compares kim_model_compute_arguments_handle_type's for !! equality. !! !! \since 2.0 logical recursive function kim_model_compute_arguments_handle_equal(lhs, rhs) implicit none type(kim_model_compute_arguments_handle_type), intent(in) :: lhs type(kim_model_compute_arguments_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_compute_arguments_handle_equal = .true. else kim_model_compute_arguments_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_compute_arguments_handle_equal !> \brief Compares kim_model_compute_arguments_handle_type's for !! inequality. !! !! \since 2.0 logical recursive function kim_model_compute_arguments_handle_not_equal(lhs, & rhs) implicit none type(kim_model_compute_arguments_handle_type), intent(in) :: lhs type(kim_model_compute_arguments_handle_type), intent(in) :: rhs kim_model_compute_arguments_handle_not_equal = .not. (lhs == rhs) end function kim_model_compute_arguments_handle_not_equal !> \brief \copybrief KIM::ModelComputeArguments::GetNeighborList !! !! A Fortran PM must provide a KIM::MODEL_ROUTINE_NAME::GetNeighbotList !! routine. The interface for this is given here (see also !! KIM::GetNeighborListFunction, \ref KIM_GetNeighborListFunction). !! !! \code{.f90} !! interface !! recursive subroutine get_neighbor_list(data_object, & !! number_of_neighbor_lists, cutoffs, neighbor_list_index, & !! particle_number, number_of_neighbors, neighbors_of_particle, ierr) & !! bind(c) !! use, intrinsic :: iso_c_binding !! implicit none !! type(c_ptr), intent(in), value :: data_object !! integer(c_int), intent(in), value :: number_of_neighbor_lists !! real(c_double), intent(in) :: cutoffs(*) !! integer(c_int), intent(in), value :: neighbor_list_index !! integer(c_int), intent(in), value :: particle_number !! integer(c_int), intent(out) :: number_of_neighbors !! type(c_ptr), intent(out) :: neighbors_of_particle !! integer(c_int), intent(out) :: ierr !! end subroutine get_neighbor_ilst !! end interface !! \endcode !! !! \note The use of the "assumed size" type for `cutoffs` above is necessary !! for strict conformance to the Fortran/C interoperability standard. The !! cutoffs array is expected to be of shape \c [number_of_neighbor_lists]. !! !! \sa KIM::ModelComputeArguments::GetNeighborList, !! KIM_ModelComputeArguments_GetNeighborList !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_get_neighbor_list( & model_compute_arguments_handle, neighbor_list_index, particle_number, & number_of_neighbors, neighbors_of_particle, ierr) use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_neighbor_list( & model_compute_arguments, neighbor_list_index, particle_number, & number_of_neighbors, neighbors_of_particle) & bind(c, name="KIM_ModelComputeArguments_GetNeighborList") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments integer(c_int), intent(in), value :: neighbor_list_index integer(c_int), intent(in), value :: particle_number integer(c_int), intent(out) :: number_of_neighbors type(c_ptr), intent(out) :: neighbors_of_particle end function get_neighbor_list end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle integer(c_int), intent(in) :: neighbor_list_index integer(c_int), intent(in) :: particle_number integer(c_int), intent(out) :: number_of_neighbors integer(c_int), intent(out), pointer :: neighbors_of_particle(:) integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_neighbor_list(model_compute_arguments, neighbor_list_index - 1, & particle_number, number_of_neighbors, p) if (c_associated(p)) then call c_f_pointer(p, neighbors_of_particle, [number_of_neighbors]) else nullify (neighbors_of_particle) end if end subroutine kim_model_compute_arguments_get_neighbor_list !> \brief \copybrief KIM::ModelComputeArguments::ProcessDEDrTerm !! !! A Fortran PM may provide a KIM::MODEL_ROUTINE_NAME::ProcessDEDrTerm !! routine. The interface for this is given here (see also !! KIM::ProcessDEDrTermFunction, \ref KIM_ProcessDEDrTermFunction). !! !! \code{.f90} !! interface !! recursive subroutine process_dedr_term(data_object, de, r, dx, i, j, & !! ierr) bind(c) !! use, intrinsic :: iso_c_binding !! implicit none !! type(c_ptr), intent(in), value :: data_object !! real(c_double), intent(in), value :: de !! real(c_double), intent(in), value :: r !! real(c_double), intent(in) :: dx(3) !! integer(c_int), intent(in), value :: i !! integer(c_int), intent(in), value :: j !! integer(c_int), intent(out) :: ierr !! end subroutine process_dedr_term !! end interface !! \endcode !! !! \sa KIM::ModelComputeArguments::ProcessDEDrTerm, !! KIM_ModelComputeArguments_ProcessDEDrTerm !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_process_dedr_term( & model_compute_arguments_handle, de, r, dx, i, j, ierr) use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function process_dedr_term( & model_compute_arguments, de, r, dx, i, j) & bind(c, name="KIM_ModelComputeArguments_ProcessDEDrTerm") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments real(c_double), intent(in), value :: de real(c_double), intent(in), value :: r real(c_double), intent(in) :: dx integer(c_int), intent(in), value :: i integer(c_int), intent(in), value :: j end function process_dedr_term end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle real(c_double), intent(in) :: de real(c_double), intent(in) :: r real(c_double), intent(in) :: dx(:) integer(c_int), intent(in) :: i integer(c_int), intent(in) :: j integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = process_dedr_term(model_compute_arguments, de, r, dx(1), i, j) end subroutine kim_model_compute_arguments_process_dedr_term !> \brief \copybrief KIM::ModelComputeArguments::ProcessD2EDr2Term !! !! A Fortran PM may provide a KIM::MODEL_ROUTINE_NAME::ProcessD2EDr2Term !! routine. The interface for this is given here (see also !! KIM::ProcessD2EDr2TermFunction, \ref KIM_ProcessD2EDr2TermFunction). !! !! \code{.f90} !! interface !! recursive subroutine process_d2edr2_term(data_object, de, r, dx, i, j, & !! ierr) bind(c) !! use, intrinsic :: iso_c_binding !! implicit none !! type(c_ptr), intent(in), value :: data_object !! real(c_double), intent(in), value :: de !! real(c_double), intent(in) :: r(2) !! real(c_double), intent(in) :: dx(3,2) !! integer(c_int), intent(in) :: i(2) !! integer(c_int), intent(in) :: j(2) !! integer(c_int), intent(out) :: ierr !! end subroutine process_d2edr2_term !! end interface !! \endcode !! !! \sa KIM::ModelComputeArguments::ProcessD2EDr2Term, !! KIM_ModelComputeArguments_ProcessD2EDr2Term !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_process_d2edr2_term( & model_compute_arguments_handle, de, r, dx, i, j, ierr) use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function process_d2edr2_term( & model_compute_arguments, de, r, dx, i, j) & bind(c, name="KIM_ModelComputeArguments_ProcessD2EDr2Term") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments real(c_double), intent(in), value :: de real(c_double), intent(in) :: r real(c_double), intent(in) :: dx integer(c_int), intent(in) :: i integer(c_int), intent(in) :: j end function process_d2edr2_term end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle real(c_double), intent(in) :: de real(c_double), intent(in) :: r(:) real(c_double), intent(in) :: dx(:, :) integer(c_int), intent(in) :: i(:) integer(c_int), intent(in) :: j(:) integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = process_d2edr2_term(model_compute_arguments, & de, r(1), dx(1, 1), i(1), j(1)) end subroutine kim_model_compute_arguments_process_d2edr2_term !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerInteger !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_get_argument_pointer_int0( & model_compute_arguments_handle, compute_argument_name, int0, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_pointer_integer( & model_compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ModelComputeArguments_GetArgumentPointerInteger") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(out) :: ptr end function get_argument_pointer_integer end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(out), pointer :: int0 integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_argument_pointer_integer(model_compute_arguments, & compute_argument_name, p) if (c_associated(p)) then call c_f_pointer(p, int0) else nullify (int0) end if end subroutine kim_model_compute_arguments_get_argument_pointer_int0 !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerInteger !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_get_argument_pointer_int1( & model_compute_arguments_handle, compute_argument_name, extent1, int1, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_pointer_integer( & model_compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ModelComputeArguments_GetArgumentPointerInteger") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(out) :: ptr end function get_argument_pointer_integer end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 integer(c_int), intent(out), pointer :: int1(:) integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_argument_pointer_integer(model_compute_arguments, & compute_argument_name, p) if (c_associated(p)) then call c_f_pointer(p, int1, [extent1]) else nullify (int1) end if end subroutine kim_model_compute_arguments_get_argument_pointer_int1 !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerInteger !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_get_argument_pointer_int2( & model_compute_arguments_handle, compute_argument_name, extent1, extent2, & int2, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_pointer_integer( & model_compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ModelComputeArguments_GetArgumentPointerInteger") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(out) :: ptr end function get_argument_pointer_integer end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 integer(c_int), intent(in) :: extent2 integer(c_int), intent(out), pointer :: int2(:, :) integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_argument_pointer_integer(model_compute_arguments, & compute_argument_name, p) if (c_associated(p)) then call c_f_pointer(p, int2, [extent1, extent2]) else nullify (int2) end if end subroutine kim_model_compute_arguments_get_argument_pointer_int2 !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerDouble !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_get_argument_pointer_double0( & model_compute_arguments_handle, compute_argument_name, double0, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_pointer_double( & model_compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ModelComputeArguments_GetArgumentPointerDouble") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(out) :: ptr end function get_argument_pointer_double end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name real(c_double), intent(out), pointer :: double0 integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_argument_pointer_double(model_compute_arguments, & compute_argument_name, p) if (c_associated(p)) then call c_f_pointer(p, double0) else nullify (double0) end if end subroutine kim_model_compute_arguments_get_argument_pointer_double0 !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerDouble !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_get_argument_pointer_double1( & model_compute_arguments_handle, compute_argument_name, extent1, double1, & ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_pointer_double( & model_compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ModelComputeArguments_GetArgumentPointerDouble") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(out) :: ptr end function get_argument_pointer_double end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 real(c_double), intent(out), pointer :: double1(:) integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_argument_pointer_double(model_compute_arguments, & compute_argument_name, p) if (c_associated(p)) then call c_f_pointer(p, double1, [extent1]) else nullify (double1) end if end subroutine kim_model_compute_arguments_get_argument_pointer_double1 !> \brief \copybrief KIM::ModelComputeArguments::GetArgumentPointer !! !! \sa KIM::ModelComputeArguments::GetArgumentPointer, !! KIM_ModelComputeArguments_GetArgumentPointerDouble !! !! \since 2.0 recursive subroutine & kim_model_compute_arguments_get_argument_pointer_double2( & model_compute_arguments_handle, compute_argument_name, extent1, extent2, & double2, ierr) use kim_compute_argument_name_module, only: kim_compute_argument_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function get_argument_pointer_double( & model_compute_arguments, compute_argument_name, ptr) & bind(c, name="KIM_ModelComputeArguments_GetArgumentPointerDouble") use, intrinsic :: iso_c_binding use kim_compute_argument_name_module, only: & kim_compute_argument_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_argument_name_type), intent(in), value :: & compute_argument_name type(c_ptr), intent(out) :: ptr end function get_argument_pointer_double end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_argument_name_type), intent(in) :: & compute_argument_name integer(c_int), intent(in) :: extent1 integer(c_int), intent(in) :: extent2 real(c_double), intent(out), pointer :: double2(:, :) integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = get_argument_pointer_double(model_compute_arguments, & compute_argument_name, p) if (c_associated(p)) then call c_f_pointer(p, double2, [extent1, extent2]) else nullify (double2) end if end subroutine kim_model_compute_arguments_get_argument_pointer_double2 !> \brief \copybrief KIM::ModelComputeArguments::IsCallbackPresent !! !! \sa KIM::ModelComputeArguments::IsCallbackPresent, !! KIM_ModelComputeArguments_IsCallbackPresent !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_is_callback_present( & model_compute_arguments_handle, compute_callback_name, present, ierr) use kim_compute_callback_name_module, only: kim_compute_callback_name_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface integer(c_int) recursive function is_callback_present( & model_compute_arguments, compute_callback_name, present) & bind(c, name="KIM_ModelComputeArguments_IsCallbackPresent") use, intrinsic :: iso_c_binding use kim_compute_callback_name_module, only: & kim_compute_callback_name_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_compute_callback_name_type), intent(in), value :: & compute_callback_name integer(c_int), intent(out) :: present end function is_callback_present end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_compute_callback_name_type), intent(in) :: & compute_callback_name integer(c_int), intent(out) :: present integer(c_int), intent(out) :: ierr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) ierr = is_callback_present(model_compute_arguments, compute_callback_name, & present) end subroutine kim_model_compute_arguments_is_callback_present !> \brief \copybrief KIM::ModelComputeArguments::SetModelBufferPointer !! !! \sa KIM::ModelComputeArguments::SetModelBufferPointer, !! KIM_ModelComputeArguments_SetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_set_model_buffer_pointer( & model_compute_arguments_handle, ptr) use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface recursive subroutine set_model_buffer_pointer( & model_compute_arguments, ptr) & bind(c, name="KIM_ModelComputeArguments_SetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(c_ptr), intent(in), value :: ptr end subroutine set_model_buffer_pointer end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(c_ptr), intent(in) :: ptr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) call set_model_buffer_pointer(model_compute_arguments, ptr) end subroutine kim_model_compute_arguments_set_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArguments::GetModelBufferPointer !! !! \sa KIM::ModelComputeArguments::GetModelBufferPointer, !! KIM_ModelComputeArguments_GetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_get_model_buffer_pointer( & model_compute_arguments_handle, ptr) use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface recursive subroutine get_model_buffer_pointer( & model_compute_arguments, ptr) & bind(c, name="KIM_ModelComputeArguments_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(c_ptr), intent(out) :: ptr type(kim_model_compute_arguments_type), pointer :: model_compute_arguments call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) call get_model_buffer_pointer(model_compute_arguments, ptr) end subroutine kim_model_compute_arguments_get_model_buffer_pointer !> \brief \copybrief KIM::ModelComputeArguments::LogEntry !! !! \sa KIM::ModelComputeArguments::LogEntry, !! KIM_ModelComputeArguments_LogEntry !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_log_entry( & model_compute_arguments_handle, log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface recursive subroutine log_entry(model_compute_arguments, log_verbosity, & message, line_number, file_name) & bind(c, name="KIM_ModelComputeArguments_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_compute_arguments_type), pointer :: model_compute_arguments call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) call log_entry(model_compute_arguments, log_verbosity, & trim(message)//c_null_char, 0, ""//c_null_char) end subroutine kim_model_compute_arguments_log_entry !> \brief \copybrief KIM::ModelComputeArguments::ToString !! !! \sa KIM::ModelComputeArguments::ToString, !! KIM_ModelComputeArguments_ToString !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_to_string( & model_compute_arguments_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_compute_arguments_type implicit none interface type(c_ptr) recursive function model_compute_string( & model_compute_arguments) & bind(c, name="KIM_ModelComputeArguments_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_compute_arguments_type implicit none type(kim_model_compute_arguments_type), intent(in) :: & model_compute_arguments end function model_compute_string end interface type(kim_model_compute_arguments_handle_type), intent(in) :: & model_compute_arguments_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_compute_arguments_type), pointer :: model_compute_arguments type(c_ptr) :: p call c_f_pointer(model_compute_arguments_handle%p, model_compute_arguments) p = model_compute_string(model_compute_arguments) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_compute_arguments_to_string end module kim_model_compute_arguments_module kim-api-2.3.0-git/fortran/include/kim_model_compute_module.f90000066400000000000000000000177061421473465500243310ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelCompute !! !! \sa KIM::ModelCompute, KIM_ModelCompute !! !! \since 2.0 module kim_model_compute_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_compute_handle_type, & ! Constants KIM_MODEL_COMPUTE_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelCompute !! !! \sa KIM::ModelCompute, KIM_ModelCompute !! !! \since 2.0 type, bind(c) :: kim_model_compute_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_compute_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_compute_handle_type), protected, save & :: KIM_MODEL_COMPUTE_NULL_HANDLE !> \brief Compares kim_model_compute_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_compute_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_compute_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_compute_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelCompute::GetModelBufferPointer !! !! \sa KIM::ModelCompute::GetModelBufferPointer, !! KIM_ModelCompute_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure kim_model_compute_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelCompute::LogEntry !! !! \sa KIM::ModelCompute::LogEntry, KIM_ModelCompute_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_compute_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelCompute::ToString !! !! \sa KIM::ModelCompute::ToString, KIM_ModelCompute_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_compute_to_string end interface kim_to_string contains !> \brief Compares kim_model_compute_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_compute_handle_equal(lhs, rhs) implicit none type(kim_model_compute_handle_type), intent(in) :: lhs type(kim_model_compute_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_compute_handle_equal = .true. else kim_model_compute_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_compute_handle_equal !> \brief Compares kim_model_compute_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_compute_handle_not_equal(lhs, rhs) implicit none type(kim_model_compute_handle_type), intent(in) :: lhs type(kim_model_compute_handle_type), intent(in) :: rhs kim_model_compute_handle_not_equal = .not. (lhs == rhs) end function kim_model_compute_handle_not_equal !> \brief \copybrief KIM::ModelCompute::GetModelBufferPointer !! !! \sa KIM::ModelCompute::GetModelBufferPointer, !! KIM_ModelCompute_GetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_compute_get_model_buffer_pointer( & model_compute_handle, ptr) use kim_interoperable_types_module, only: kim_model_compute_type implicit none interface recursive subroutine get_model_buffer_pointer(model_compute, ptr) & bind(c, name="KIM_ModelCompute_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_compute_type implicit none type(kim_model_compute_type), intent(in) :: model_compute type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(c_ptr), intent(out) :: ptr type(kim_model_compute_type), pointer :: model_compute call c_f_pointer(model_compute_handle%p, model_compute) call get_model_buffer_pointer(model_compute, ptr) end subroutine kim_model_compute_get_model_buffer_pointer !> \brief \copybrief KIM::ModelCompute::LogEntry !! !! \sa KIM::ModelCompute::LogEntry, KIM_ModelCompute_LogEntry !! !! \since 2.0 recursive subroutine kim_model_compute_log_entry(model_compute_handle, & log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_compute_type implicit none interface recursive subroutine log_entry( & model_compute, log_verbosity, message, line_number, file_name) & bind(c, name="KIM_ModelCompute_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_compute_type implicit none type(kim_model_compute_type), intent(in) :: model_compute type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_compute_handle_type), intent(in) :: model_compute_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_compute_type), pointer :: model_compute call c_f_pointer(model_compute_handle%p, model_compute) call log_entry(model_compute, log_verbosity, trim(message)//c_null_char, & 0, ""//c_null_char) end subroutine kim_model_compute_log_entry !> \brief \copybrief KIM::ModelCompute::ToString !! !! \sa KIM::ModelCompute::ToString, KIM_ModelCompute_ToString !! !! \since 2.0 recursive subroutine kim_model_compute_to_string(model_compute_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_compute_type implicit none interface type(c_ptr) recursive function model_compute_string(model_compute) & bind(c, name="KIM_ModelCompute_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_compute_type implicit none type(kim_model_compute_type), intent(in) :: model_compute end function model_compute_string end interface type(kim_model_compute_handle_type), intent(in) :: model_compute_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_compute_type), pointer :: model_compute type(c_ptr) :: p call c_f_pointer(model_compute_handle%p, model_compute) p = model_compute_string(model_compute) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_compute_to_string end module kim_model_compute_module kim-api-2.3.0-git/fortran/include/kim_model_create_module.f90000066400000000000000000000744751421473465500241260ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelCreate !! !! \sa KIM::ModelCreate, KIM_ModelCreate !! !! \since 2.0 module kim_model_create_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_create_handle_type, & ! Constants KIM_MODEL_CREATE_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_set_model_numbering, & kim_set_influence_distance_pointer, & kim_set_neighbor_list_pointers, & kim_set_routine_pointer, & kim_set_species_code, & kim_set_parameter_pointer, & kim_set_model_buffer_pointer, & kim_set_units, & kim_convert_unit, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelCreate !! !! \sa KIM::ModelCreate, KIM_ModelCreate !! !! \since 2.0 type, bind(c) :: kim_model_create_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_create_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_create_handle_type), protected, save & :: KIM_MODEL_CREATE_NULL_HANDLE !> \brief Compares kim_model_create_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_create_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_create_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_create_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelCreate::SetModelNumbering !! !! \sa KIM::ModelCreate::SetModelNumbering, KIM_ModelCreate_SetModelNumbering !! !! \since 2.0 interface kim_set_model_numbering module procedure kim_model_create_set_model_numbering end interface kim_set_model_numbering !> \brief \copybrief KIM::ModelCreate::SetInfluenceDistancePointer !! !! \sa KIM::ModelCreate::SetInfluenceDistancePointer, !! KIM_ModelCreate_SetInfluenceDistancePointer !! !! \since 2.0 interface kim_set_influence_distance_pointer module procedure kim_model_create_set_influence_distance_pointer end interface kim_set_influence_distance_pointer !> \brief \copybrief KIM::ModelCreate::SetNeighborListPointers !! !! \sa KIM::ModelCreate::SetNeighborListPointers, !! KIM_ModelCreate_SetNeighborListPointers !! !! \since 2.0 interface kim_set_neighbor_list_pointers module procedure kim_model_create_set_neighbor_list_pointers end interface kim_set_neighbor_list_pointers !> \brief \copybrief KIM::ModelCreate::SetRoutinePointer !! !! \sa KIM::ModelCreate::SetRoutinePointer, KIM_ModelCreate_SetRoutinePointer !! !! \since 2.0 interface kim_set_routine_pointer module procedure kim_model_create_set_routine_pointer end interface kim_set_routine_pointer !> \brief \copybrief KIM::ModelCreate::SetSpeciesCode !! !! \sa KIM::ModelCreate::SetSpeciesCode, KIM_ModelCreate_SetSpeciesCode !! !! \since 2.0 interface kim_set_species_code module procedure kim_model_create_set_species_code end interface kim_set_species_code !> \brief \copybrief KIM::ModelCreate::SetParameterPointer !! !! \sa KIM::ModelCreate::SetParameterPointer, !! KIM_ModelCreate_SetParameterPointerInteger, !! KIM_ModelCreate_SetParameterPointerDouble !! !! \since 2.0 interface kim_set_parameter_pointer module procedure kim_model_create_set_parameter_pointer_integer module procedure kim_model_create_set_parameter_pointer_double end interface kim_set_parameter_pointer !> \brief \copybrief KIM::ModelCreate::SetModelBufferPointer !! !! \sa KIM::ModelCreate::SetModelBufferPointer, !! KIM_ModelCreate_SetModelBufferPointer !! !! \since 2.0 interface kim_set_model_buffer_pointer module procedure kim_model_create_set_model_buffer_pointer end interface kim_set_model_buffer_pointer !> \brief \copybrief KIM::ModelCreate::SetUnits !! !! \sa KIM::ModelCreate::SetUnits, KIM_ModelCreate_SetUnits !! !! \since 2.0 interface kim_set_units module procedure kim_model_create_set_units end interface kim_set_units !> \brief \copybrief KIM::ModelCreate::ConvertUnit !! !! \sa KIM::ModelCreate::ConvertUnit, KIM_ModelCreate_ConvertUnit !! !! \since 2.0 interface kim_convert_unit module procedure kim_model_create_convert_unit end interface kim_convert_unit !> \brief \copybrief KIM::ModelCreate::LogEntry !! !! \sa KIM::ModelCreate::LogEntry, KIM_ModelCreate_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_create_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelCreate::ToString !! !! \sa KIM::ModelCreate::ToString, KIM_ModelCreate_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_create_to_string end interface kim_to_string contains !> \brief Compares kim_model_create_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_create_handle_equal(lhs, rhs) implicit none type(kim_model_create_handle_type), intent(in) :: lhs type(kim_model_create_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_create_handle_equal = .true. else kim_model_create_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_create_handle_equal !> \brief Compares kim_model_create_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_create_handle_not_equal(lhs, rhs) implicit none type(kim_model_create_handle_type), intent(in) :: lhs type(kim_model_create_handle_type), intent(in) :: rhs kim_model_create_handle_not_equal = .not. (lhs == rhs) end function kim_model_create_handle_not_equal !> \brief \copybrief KIM::ModelCreate::SetModelNumbering !! !! \sa KIM::ModelCreate::SetModelNumbering, KIM_ModelCreate_SetModelNumbering !! !! \since 2.0 recursive subroutine kim_model_create_set_model_numbering( & model_create_handle, numbering, ierr) use kim_numbering_module, only: kim_numbering_type use kim_interoperable_types_module, only: kim_model_create_type implicit none interface integer(c_int) recursive function set_model_numbering( & model_create, numbering) & bind(c, name="KIM_ModelCreate_SetModelNumbering") use, intrinsic :: iso_c_binding use kim_numbering_module, only: kim_numbering_type use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(kim_numbering_type), intent(in), value :: numbering end function set_model_numbering end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle type(kim_numbering_type), intent(in) :: numbering integer(c_int), intent(out) :: ierr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) ierr = set_model_numbering(model_create, numbering) end subroutine kim_model_create_set_model_numbering !> \brief \copybrief KIM::ModelCreate::SetInfluenceDistancePointer !! !! \sa KIM::ModelCreate::SetInfluenceDistancePointer, !! KIM_ModelCreate_SetInfluenceDistancePointer !! !! \since 2.0 recursive subroutine kim_model_create_set_influence_distance_pointer( & model_create_handle, influence_distance) use kim_interoperable_types_module, only: kim_model_create_type implicit none interface recursive subroutine set_influence_distance_pointer(model_create, & influence_distance) & bind(c, name="KIM_ModelCreate_SetInfluenceDistancePointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(c_ptr), intent(in), value :: influence_distance end subroutine set_influence_distance_pointer end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle real(c_double), intent(in), target :: influence_distance type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) call set_influence_distance_pointer(model_create, & c_loc(influence_distance)) end subroutine kim_model_create_set_influence_distance_pointer !> \brief \copybrief KIM::ModelCreate::SetNeighborListPointers !! !! \sa KIM::ModelCreate::SetNeighborListPointers, !! KIM_ModelCreate_SetNeighborListPointers !! !! \since 2.0 recursive subroutine kim_model_create_set_neighbor_list_pointers( & model_create_handle, number_of_neighbor_lists, cutoffs, & model_will_not_request_neighbors_of_noncontributing_particles) use kim_interoperable_types_module, only: kim_model_create_type implicit none interface recursive subroutine set_neighbor_list_pointers( & model_create, number_of_neighbor_lists, cutoffs_ptr, & model_will_not_request_neighbors_of_noncontributing_particles) & bind(c, name="KIM_ModelCreate_SetNeighborListPointers") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create integer(c_int), intent(in), value :: number_of_neighbor_lists type(c_ptr), intent(in), value :: cutoffs_ptr type(c_ptr), intent(in), value :: & model_will_not_request_neighbors_of_noncontributing_particles end subroutine set_neighbor_list_pointers end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle integer(c_int), intent(in) :: number_of_neighbor_lists real(c_double), intent(in), target :: cutoffs(number_of_neighbor_lists) integer(c_int), intent(in), target :: & model_will_not_request_neighbors_of_noncontributing_particles( & number_of_neighbor_lists) type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) call set_neighbor_list_pointers( & model_create, number_of_neighbor_lists, c_loc(cutoffs), & c_loc(model_will_not_request_neighbors_of_noncontributing_particles)) end subroutine kim_model_create_set_neighbor_list_pointers !> \brief \copybrief KIM::ModelCreate::SetRoutinePointer !! !! \sa KIM::ModelCreate::SetRoutinePointer, KIM_ModelCreate_SetRoutinePointer !! !! \since 2.0 recursive subroutine kim_model_create_set_routine_pointer( & model_create_handle, model_routine_name, language_name, required, fptr, & ierr) use kim_model_routine_name_module, only: kim_model_routine_name_type use kim_language_name_module, only: kim_language_name_type use kim_interoperable_types_module, only: kim_model_create_type implicit none interface integer(c_int) recursive function set_routine_pointer( & model_create, model_routine_name, language_name, required, fptr) & bind(c, name="KIM_ModelCreate_SetRoutinePointer") use, intrinsic :: iso_c_binding use kim_model_routine_name_module, only: kim_model_routine_name_type use kim_language_name_module, only: kim_language_name_type use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(kim_model_routine_name_type), intent(in), value & :: model_routine_name type(kim_language_name_type), intent(in), value :: language_name integer(c_int), intent(in), value :: required type(c_funptr), intent(in), value :: fptr end function set_routine_pointer end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle type(kim_model_routine_name_type), intent(in) :: model_routine_name type(kim_language_name_type), intent(in) :: language_name integer(c_int), intent(in) :: required type(c_funptr), intent(in), value :: fptr ! must be left as "value"!?! integer(c_int), intent(out) :: ierr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) ierr = set_routine_pointer(model_create, model_routine_name, & language_name, required, fptr) end subroutine kim_model_create_set_routine_pointer !> \brief \copybrief KIM::ModelCreate::SetSpeciesCode !! !! \sa KIM::ModelCreate::SetSpeciesCode, KIM_ModelCreate_SetSpeciesCode !! !! \since 2.0 recursive subroutine kim_model_create_set_species_code( & model_create_handle, species_name, code, ierr) use kim_species_name_module, only: kim_species_name_type use kim_interoperable_types_module, only: kim_model_create_type implicit none interface integer(c_int) recursive function set_species_code(model_create, & species_name, code) & bind(c, name="KIM_ModelCreate_SetSpeciesCode") use, intrinsic :: iso_c_binding use kim_species_name_module, only: kim_species_name_type use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(kim_species_name_type), intent(in), value :: species_name integer(c_int), intent(in), value :: code end function set_species_code end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle type(kim_species_name_type), intent(in) :: species_name integer(c_int), intent(in) :: code integer(c_int), intent(out) :: ierr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) ierr = set_species_code(model_create, species_name, code) end subroutine kim_model_create_set_species_code !> \brief \copybrief KIM::ModelCreate::SetParameterPointer !! !! \sa KIM::ModelCreate::SetParameterPointer, !! KIM_ModelCreate_SetParameterPointerInteger !! !! \since 2.0 recursive subroutine kim_model_create_set_parameter_pointer_integer( & model_create_handle, int1, name, description, ierr) use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_handle_type), intent(in) :: model_create_handle integer(c_int), intent(in), target :: int1(:) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) call set_parameter(model_create, size(int1, 1, c_int), int1, name, & description, ierr) return contains recursive subroutine set_parameter(model_create, extent, int1, name, & description, ierr) use kim_interoperable_types_module, only: kim_model_create_type implicit none interface integer(c_int) recursive function set_parameter_pointer_integer( & model_create, extent, ptr, name, description) & bind(c, name="KIM_ModelCreate_SetParameterPointerInteger") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create integer(c_int), intent(in), value :: extent type(c_ptr), intent(in), value :: ptr character(c_char), intent(in) :: name(*) character(c_char), intent(in) :: description(*) end function set_parameter_pointer_integer end interface type(kim_model_create_type), intent(in) :: model_create integer(c_int), intent(in) :: extent integer(c_int), intent(in), target :: int1(extent) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr ierr = set_parameter_pointer_integer(model_create, & extent, & c_loc(int1), & trim(name)//c_null_char, & trim(description)//c_null_char) end subroutine set_parameter end subroutine kim_model_create_set_parameter_pointer_integer !> \brief \copybrief KIM::ModelCreate::SetParameterPointer !! !! \sa KIM::ModelCreate::SetParameterPointer, !! KIM_ModelCreate_SetParameterPointerDouble !! !! \since 2.0 recursive subroutine kim_model_create_set_parameter_pointer_double( & model_create_handle, double1, name, description, ierr) use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_handle_type), intent(in) :: model_create_handle real(c_double), intent(in), target :: double1(:) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) call set_parameter(model_create, size(double1, 1, c_int), double1, & name, description, ierr) return contains recursive subroutine set_parameter(model_create, extent, double1, name, & description, ierr) implicit none interface integer(c_int) recursive function set_parameter_pointer_double( & model_create, extent, ptr, name, description) & bind(c, name="KIM_ModelCreate_SetParameterPointerDouble") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create integer(c_int), intent(in), value :: extent type(c_ptr), intent(in), value :: ptr character(c_char), intent(in) :: name(*) character(c_char), intent(in) :: description(*) end function set_parameter_pointer_double end interface type(kim_model_create_type), intent(in) :: model_create integer(c_int), intent(in) :: extent real(c_double), intent(in), target :: double1(extent) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr ierr = set_parameter_pointer_double(model_create, & extent, & c_loc(double1), & trim(name)//c_null_char, & trim(description)//c_null_char) end subroutine set_parameter end subroutine kim_model_create_set_parameter_pointer_double !> \brief \copybrief KIM::ModelCreate::SetModelBufferPointer !! !! \sa KIM::ModelCreate::SetModelBufferPointer, !! KIM_ModelCreate_SetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_create_set_model_buffer_pointer( & model_create_handle, ptr) use kim_interoperable_types_module, only: kim_model_create_type implicit none interface recursive subroutine set_model_buffer_pointer(model_create, ptr) & bind(c, name="KIM_ModelCreate_SetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(c_ptr), intent(in), value :: ptr end subroutine set_model_buffer_pointer end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle type(c_ptr), intent(in) :: ptr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) call set_model_buffer_pointer(model_create, ptr) end subroutine kim_model_create_set_model_buffer_pointer !> \brief \copybrief KIM::ModelCreate::SetUnits !! !! \sa KIM::ModelCreate::SetUnits, KIM_ModelCreate_SetUnits !! !! \since 2.0 recursive subroutine kim_model_create_set_units( & model_create_handle, length_unit, energy_unit, charge_unit, & temperature_unit, time_unit, ierr) use kim_unit_system_module, only: & kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type use kim_interoperable_types_module, only: kim_model_create_type implicit none interface integer(c_int) recursive function set_units( & model_create, length_unit, energy_unit, charge_unit, temperature_unit, & time_unit) bind(c, name="KIM_ModelCreate_SetUnits") use, intrinsic :: iso_c_binding use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(kim_length_unit_type), intent(in), value :: length_unit type(kim_energy_unit_type), intent(in), value :: energy_unit type(kim_charge_unit_type), intent(in), value :: charge_unit type(kim_temperature_unit_type), intent(in), value :: temperature_unit type(kim_time_unit_type), intent(in), value :: time_unit end function set_units end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle type(kim_length_unit_type), intent(in) :: length_unit type(kim_energy_unit_type), intent(in) :: energy_unit type(kim_charge_unit_type), intent(in) :: charge_unit type(kim_temperature_unit_type), intent(in) :: temperature_unit type(kim_time_unit_type), intent(in) :: time_unit integer(c_int), intent(out) :: ierr type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) ierr = set_units(model_create, length_unit, energy_unit, & charge_unit, temperature_unit, time_unit) end subroutine kim_model_create_set_units !> \brief \copybrief KIM::ModelCreate::ConvertUnit !! !! \sa KIM::ModelCreate::ConvertUnit, KIM_ModelCreate_ConvertUnit !! !! \since 2.0 recursive subroutine kim_model_create_convert_unit( & from_length_unit, from_energy_unit, & from_charge_unit, from_temperature_unit, from_time_unit, & to_length_unit, to_energy_unit, to_charge_unit, to_temperature_unit, & to_time_unit, length_exponent, energy_exponent, charge_exponent, & temperature_exponent, time_exponent, conversion_factor, ierr) use kim_unit_system_module, only: kim_length_unit_type use kim_unit_system_module, only: kim_energy_unit_type use kim_unit_system_module, only: kim_charge_unit_type use kim_unit_system_module, only: kim_temperature_unit_type use kim_unit_system_module, only: kim_time_unit_type implicit none interface integer(c_int) recursive function convert_unit( & from_length_unit, from_energy_unit, & from_charge_unit, from_temperature_unit, from_time_unit, & to_length_unit, to_energy_unit, to_charge_unit, to_temperature_unit, & to_time_unit, length_exponent, energy_exponent, charge_exponent, & temperature_exponent, time_exponent, conversion_factor) & bind(c, name="KIM_ModelCreate_ConvertUnit") use, intrinsic :: iso_c_binding use kim_unit_system_module, only: kim_length_unit_type use kim_unit_system_module, only: kim_energy_unit_type use kim_unit_system_module, only: kim_charge_unit_type use kim_unit_system_module, only: kim_temperature_unit_type use kim_unit_system_module, only: kim_time_unit_type implicit none type(kim_length_unit_type), intent(in), value :: from_length_unit type(kim_energy_unit_type), intent(in), value :: from_energy_unit type(kim_charge_unit_type), intent(in), value :: from_charge_unit type(kim_temperature_unit_type), intent(in), value :: & from_temperature_unit type(kim_time_unit_type), intent(in), value :: from_time_unit type(kim_length_unit_type), intent(in), value :: to_length_unit type(kim_energy_unit_type), intent(in), value :: to_energy_unit type(kim_charge_unit_type), intent(in), value :: to_charge_unit type(kim_temperature_unit_type), intent(in), value :: & to_temperature_unit type(kim_time_unit_type), intent(in), value :: to_time_unit real(c_double), intent(in), value :: length_exponent real(c_double), intent(in), value :: energy_exponent real(c_double), intent(in), value :: charge_exponent real(c_double), intent(in), value :: temperature_exponent real(c_double), intent(in), value :: time_exponent real(c_double), intent(out) :: conversion_factor end function convert_unit end interface type(kim_length_unit_type), intent(in) :: from_length_unit type(kim_energy_unit_type), intent(in) :: from_energy_unit type(kim_charge_unit_type), intent(in) :: from_charge_unit type(kim_temperature_unit_type), intent(in) :: from_temperature_unit type(kim_time_unit_type), intent(in) :: from_time_unit type(kim_length_unit_type), intent(in) :: to_length_unit type(kim_energy_unit_type), intent(in) :: to_energy_unit type(kim_charge_unit_type), intent(in) :: to_charge_unit type(kim_temperature_unit_type), intent(in) :: to_temperature_unit type(kim_time_unit_type), intent(in) :: to_time_unit real(c_double), intent(in) :: length_exponent real(c_double), intent(in) :: energy_exponent real(c_double), intent(in) :: charge_exponent real(c_double), intent(in) :: temperature_exponent real(c_double), intent(in) :: time_exponent real(c_double), intent(out) :: conversion_factor integer(c_int), intent(out) :: ierr ierr = convert_unit(from_length_unit, from_energy_unit, from_charge_unit, & from_temperature_unit, from_time_unit, to_length_unit, & to_energy_unit, to_charge_unit, to_temperature_unit, & to_time_unit, length_exponent, energy_exponent, & charge_exponent, temperature_exponent, time_exponent, & conversion_factor) end subroutine kim_model_create_convert_unit !> \brief \copybrief KIM::ModelCreate::LogEntry !! !! \sa KIM::ModelCreate::LogEntry, KIM_ModelCreate_LogEntry !! !! \since 2.0 recursive subroutine kim_model_create_log_entry(model_create_handle, & log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_create_type implicit none interface recursive subroutine log_entry(model_create, log_verbosity, message, & line_number, file_name) & bind(c, name="KIM_ModelCreate_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_create_type), pointer :: model_create call c_f_pointer(model_create_handle%p, model_create) call log_entry(model_create, log_verbosity, trim(message)//c_null_char, & 0, ""//c_null_char) end subroutine kim_model_create_log_entry !> \brief \copybrief KIM::ModelCreate::ToString !! !! \sa KIM::ModelCreate::ToString, KIM_ModelCreate_ToString !! !! \since 2.0 recursive subroutine kim_model_create_to_string(model_create_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_create_type implicit none interface type(c_ptr) recursive function model_create_string(model_create) & bind(c, name="KIM_ModelCreate_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_create_type implicit none type(kim_model_create_type), intent(in) :: model_create end function model_create_string end interface type(kim_model_create_handle_type), intent(in) :: model_create_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_create_type), pointer :: model_create type(c_ptr) :: p call c_f_pointer(model_create_handle%p, model_create) p = model_create_string(model_create) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_create_to_string end module kim_model_create_module kim-api-2.3.0-git/fortran/include/kim_model_destroy_module.f90000066400000000000000000000177061421473465500243460ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelDestroy !! !! \sa KIM::ModelDestroy, KIM_ModelDestroy !! !! \since 2.0 module kim_model_destroy_module use, intrinsic :: iso_c_binding implicit none private public & ! Destroy types kim_model_destroy_handle_type, & ! Constants KIM_MODEL_DESTROY_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelDestroy !! !! \sa KIM::ModelDestroy, KIM_ModelDestroy !! !! \since 2.0 type, bind(c) :: kim_model_destroy_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_destroy_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_destroy_handle_type), protected, save & :: KIM_MODEL_DESTROY_NULL_HANDLE !> \brief Compares kim_model_destroy_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_destroy_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_destroy_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_destroy_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelDestroy::GetModelBufferPointer !! !! \sa KIM::ModelDestroy::GetModelBufferPointer, !! KIM_ModelDestroy_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure kim_model_destroy_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelDestroy::LogEntry !! !! \sa KIM::ModelDestroy::LogEntry, KIM_ModelDestroy_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_destroy_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelDestroy::ToString !! !! \sa KIM::ModelDestroy::ToString, KIM_ModelDestroy_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_destroy_to_string end interface kim_to_string contains !> \brief Compares kim_model_destroy_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_destroy_handle_equal(lhs, rhs) implicit none type(kim_model_destroy_handle_type), intent(in) :: lhs type(kim_model_destroy_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_destroy_handle_equal = .true. else kim_model_destroy_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_destroy_handle_equal !> \brief Compares kim_model_destroy_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_destroy_handle_not_equal(lhs, rhs) implicit none type(kim_model_destroy_handle_type), intent(in) :: lhs type(kim_model_destroy_handle_type), intent(in) :: rhs kim_model_destroy_handle_not_equal = .not. (lhs == rhs) end function kim_model_destroy_handle_not_equal !> \brief \copybrief KIM::ModelDestroy::GetModelBufferPointer !! !! \sa KIM::ModelDestroy::GetModelBufferPointer, !! KIM_ModelDestroy_GetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_destroy_get_model_buffer_pointer( & model_destroy_handle, ptr) use kim_interoperable_types_module, only: kim_model_destroy_type implicit none interface recursive subroutine get_model_buffer_pointer(model_destroy, ptr) & bind(c, name="KIM_ModelDestroy_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_destroy_type implicit none type(kim_model_destroy_type), intent(in) :: model_destroy type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_destroy_handle_type), intent(in) :: model_destroy_handle type(c_ptr), intent(out) :: ptr type(kim_model_destroy_type), pointer :: model_destroy call c_f_pointer(model_destroy_handle%p, model_destroy) call get_model_buffer_pointer(model_destroy, ptr) end subroutine kim_model_destroy_get_model_buffer_pointer !> \brief \copybrief KIM::ModelDestroy::LogEntry !! !! \sa KIM::ModelDestroy::LogEntry, KIM_ModelDestroy_LogEntry !! !! \since 2.0 recursive subroutine kim_model_destroy_log_entry(model_destroy_handle, & log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_destroy_type implicit none interface recursive subroutine log_entry( & model_destroy, log_verbosity, message, line_number, file_name) & bind(c, name="KIM_ModelDestroy_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_destroy_type implicit none type(kim_model_destroy_type), intent(in) :: model_destroy type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_destroy_handle_type), intent(in) :: model_destroy_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_destroy_type), pointer :: model_destroy call c_f_pointer(model_destroy_handle%p, model_destroy) call log_entry(model_destroy, log_verbosity, trim(message)//c_null_char, & 0, ""//c_null_char) end subroutine kim_model_destroy_log_entry !> \brief \copybrief KIM::ModelDestroy::ToString !! !! \sa KIM::ModelDestroy::ToString, KIM_ModelDestroy_ToString !! !! \since 2.0 recursive subroutine kim_model_destroy_to_string(model_destroy_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_destroy_type implicit none interface type(c_ptr) recursive function model_destroy_string(model_destroy) & bind(c, name="KIM_ModelDestroy_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_destroy_type implicit none type(kim_model_destroy_type), intent(in) :: model_destroy end function model_destroy_string end interface type(kim_model_destroy_handle_type), intent(in) :: model_destroy_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_destroy_type), pointer :: model_destroy type(c_ptr) :: p call c_f_pointer(model_destroy_handle%p, model_destroy) p = model_destroy_string(model_destroy) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_destroy_to_string end module kim_model_destroy_module kim-api-2.3.0-git/fortran/include/kim_model_driver_create_module.f90000066400000000000000000001223631421473465500254670ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelDriverCreate !! !! \sa KIM::ModelDriverCreate, KIM_ModelDriverCreate !! !! \since 2.0 module kim_model_driver_create_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_driver_create_handle_type, & ! Constants KIM_MODEL_DRIVER_CREATE_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_parameter_file_directory_name, & kim_get_number_of_parameter_files, & kim_get_parameter_file_name, & kim_get_parameter_file_basename, & kim_set_model_numbering, & kim_set_influence_distance_pointer, & kim_set_neighbor_list_pointers, & kim_set_routine_pointer, & kim_set_species_code, & kim_set_parameter_pointer, & kim_set_model_buffer_pointer, & kim_set_units, & kim_convert_unit, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelDriverCreate !! !! \sa KIM::ModelDriverCreate, KIM_ModelDriverCreate !! !! \since 2.0 type, bind(c) :: kim_model_driver_create_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_driver_create_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_driver_create_handle_type), protected, save & :: KIM_MODEL_DRIVER_CREATE_NULL_HANDLE !> \brief Compares kim_model_driver_create_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_driver_create_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_driver_create_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_driver_create_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelDriverCreate::GetParameterFileDirectoryName !! !! \sa KIM::ModelDriverCreate::GetParameterFileDirectoryName, !! KIM_ModelDriverCreate_GetParameterFileDirectoryName !! !! \since 2.2 interface kim_get_parameter_file_directory_name module procedure kim_model_driver_create_get_parameter_file_directory_name end interface kim_get_parameter_file_directory_name !> \brief \copybrief KIM::ModelDriverCreate::GetNumberOfParameterFiles !! !! \sa KIM::ModelDriverCreate::GetNumberOfParameterFiles, !! KIM_ModelDriverCreate_GetNumberOfParameterFiles !! !! \since 2.0 interface kim_get_number_of_parameter_files module procedure kim_model_driver_create_get_number_of_parameter_files end interface kim_get_number_of_parameter_files !> \brief \copybrief KIM::ModelDriverCreate::GetParameterFileName !! !! \sa KIM::ModelDriverCreate::GetParameterFileName, !! KIM_ModelDriverCreate_GetParameterFileName !! !! \since 2.0 !! !! \deprecated As of 2.2. Please use !! kim_model_driver_create_module::kim_get_parameter_file_basename() instead. interface kim_get_parameter_file_name module procedure kim_model_driver_create_get_parameter_file_name end interface kim_get_parameter_file_name !> \brief \copybrief KIM::ModelDriverCreate::GetParameterFileBasename !! !! \sa KIM::ModelDriverCreate::GetParameterFileBasename, !! KIM_ModelDriverCreate_GetParameterFileBasename !! !! \since 2.2 interface kim_get_parameter_file_basename module procedure kim_model_driver_create_get_parameter_file_basename end interface kim_get_parameter_file_basename !> \brief \copybrief KIM::ModelDriverCreate::SetModelNumbering !! !! \sa KIM::ModelDriverCreate::SetModelNumbering, !! KIM_ModelDriverCreate_SetModelNumbering !! !! \since 2.0 interface kim_set_model_numbering module procedure kim_model_driver_create_set_model_numbering end interface kim_set_model_numbering !> \brief \copybrief KIM::ModelDriverCreate::SetInfluenceDistancePointer !! !! \sa KIM::ModelDriverCreate::SetInfluenceDistancePointer, !! KIM_ModelDriverCreate_SetInfluenceDistancePointer !! !! \since 2.0 interface kim_set_influence_distance_pointer module procedure kim_model_driver_create_set_influence_distance_pointer end interface kim_set_influence_distance_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetNeighborListPointers !! !! \sa KIM::ModelDriverCreate::SetNeighborListPointers, !! KIM_ModelDriverCreate_SetNeighborListPointers !! !! \since 2.0 interface kim_set_neighbor_list_pointers module procedure kim_model_driver_create_set_neighbor_list_pointers end interface kim_set_neighbor_list_pointers !> \brief \copybrief KIM::ModelDriverCreate::SetRoutinePointer !! !! \sa KIM::ModelDriverCreate::SetRoutinePointer, !! KIM_ModelDriverCreate_SetRoutinePointer !! !! \since 2.0 interface kim_set_routine_pointer module procedure kim_model_driver_create_set_routine_pointer end interface kim_set_routine_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetSpeciesCode !! !! \sa KIM::ModelDriverCreate::SetSpeciesCode, !! KIM_ModelDriverCreate_SetSpeciesCode !! !! \since 2.0 interface kim_set_species_code module procedure kim_model_driver_create_set_species_code end interface kim_set_species_code !> \brief \copybrief KIM::ModelDriverCreate::SetParameterPointer !! !! \sa KIM::ModelDriverCreate::SetParameterPointer, !! KIM_ModelDriverCreate_SetParameterPointerInteger, !! KIM_ModelDriverCreate_SetParameterPointerDouble !! !! \since 2.0 interface kim_set_parameter_pointer module procedure kim_model_driver_create_set_parameter_pointer_integer module procedure kim_model_driver_create_set_parameter_pointer_double end interface kim_set_parameter_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetModelBufferPointer !! !! \sa KIM::ModelDriverCreate::SetModelBufferPointer, !! KIM_ModelDriverCreate_SetModelBufferPointer !! !! \since 2.0 interface kim_set_model_buffer_pointer module procedure kim_model_driver_create_set_model_buffer_pointer end interface kim_set_model_buffer_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetUnits !! !! \sa KIM::ModelDriverCreate::SetUnits, KIM_ModelDriverCreate_SetUnits !! !! \since 2.0 interface kim_set_units module procedure kim_model_driver_create_set_units end interface kim_set_units !> \brief \copybrief KIM::ModelDriverCreate::ConvertUnit !! !! \sa KIM::ModelDriverCreate::ConvertUnit, KIM_ModelDriverCreate_ConvertUnit !! !! \since 2.0 interface kim_convert_unit module procedure kim_model_driver_create_convert_unit end interface kim_convert_unit !> \brief \copybrief KIM::ModelDriverCreate::LogEntry !! !! \sa KIM::ModelDriverCreate::LogEntry, KIM_ModelDriverCreate_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_driver_create_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelDriverCreate::ToString !! !! \sa KIM::ModelDriverCreate::ToString, KIM_ModelDriverCreate_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_driver_create_to_string end interface kim_to_string contains !> \brief Compares kim_model_driver_create_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_driver_create_handle_equal(lhs, rhs) implicit none type(kim_model_driver_create_handle_type), intent(in) :: lhs type(kim_model_driver_create_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_driver_create_handle_equal = .true. else kim_model_driver_create_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_driver_create_handle_equal !> \brief Compares kim_model_driver_create_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_driver_create_handle_not_equal(lhs, rhs) implicit none type(kim_model_driver_create_handle_type), intent(in) :: lhs type(kim_model_driver_create_handle_type), intent(in) :: rhs kim_model_driver_create_handle_not_equal = .not. (lhs == rhs) end function kim_model_driver_create_handle_not_equal !> \brief \copybrief KIM::ModelDriverCreate::GetParameterFileDirectoryName !! !! \sa KIM::ModelDriverCreate::GetParameterFileDirectoryName, !! KIM_ModelDriverCreate_GetParameterFileDirectoryName !! !! \since 2.2 recursive subroutine & kim_model_driver_create_get_parameter_file_directory_name( & model_driver_create_handle, directory_name) use kim_interoperable_types_module, only: kim_model_driver_create_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_parameter_file_directory_name( & model_driver_create, directory_name) & bind(c, name="KIM_ModelDriverCreate_GetParameterFileDirectoryName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) :: model_driver_create type(c_ptr), intent(out) :: directory_name end subroutine get_parameter_file_directory_name end interface type(kim_model_driver_create_handle_type), intent(in) :: & model_driver_create_handle character(len=*, kind=c_char), intent(out) :: directory_name type(kim_model_driver_create_type), pointer :: model_driver_create type(c_ptr) pdirectory_name call c_f_pointer(model_driver_create_handle%p, model_driver_create) call get_parameter_file_directory_name(model_driver_create, pdirectory_name) call kim_convert_c_char_ptr_to_string(pdirectory_name, directory_name) end subroutine kim_model_driver_create_get_parameter_file_directory_name !> \brief \copybrief KIM::ModelDriverCreate::GetNumberOfParameterFiles !! !! \sa KIM::ModelDriverCreate::GetNumberOfParameterFiles, !! KIM_ModelDriverCreate_GetNumberOfParameterFiles !! !! \since 2.0 recursive subroutine kim_model_driver_create_get_number_of_parameter_files( & model_driver_create_handle, number_of_parameter_files) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface recursive subroutine get_number_of_parameter_files( & model_driver_create, number_of_parameter_files) & bind(c, name="KIM_ModelDriverCreate_GetNumberOfParameterFiles") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(out) :: number_of_parameter_files end subroutine get_number_of_parameter_files end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle integer(c_int), intent(out) :: number_of_parameter_files type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call get_number_of_parameter_files(model_driver_create, & number_of_parameter_files) end subroutine kim_model_driver_create_get_number_of_parameter_files !> \brief \copybrief KIM::ModelDriverCreate::GetParameterFileName !! !! \sa KIM::ModelDriverCreate::GetParameterFileName, !! KIM_ModelDriverCreate_GetParameterFileName !! !! \since 2.0 !! !! \deprecated As of 2.2. Please use !! kim_model_driver_create_module::kim_get_parameter_file_basename() instead. recursive subroutine kim_model_driver_create_get_parameter_file_name( & model_driver_create_handle, index, parameter_file_name, ierr) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function get_parameter_file_name( & model_driver_create, index, parameter_file_name) & bind(c, name="KIM_ModelDriverCreate_GetParameterFileName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: parameter_file_name end function get_parameter_file_name end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: parameter_file_name integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create type(c_ptr) :: p call c_f_pointer(model_driver_create_handle%p, model_driver_create) ierr = get_parameter_file_name(model_driver_create, & index - 1, p) call kim_convert_c_char_ptr_to_string(p, parameter_file_name) end subroutine kim_model_driver_create_get_parameter_file_name !> \brief \copybrief KIM::ModelDriverCreate::GetParameterFileBasename !! !! \sa KIM::ModelDriverCreate::GetParameterFileBasename, !! KIM_ModelDriverCreate_GetParameterFileBasename !! !! \since 2.2 recursive subroutine kim_model_driver_create_get_parameter_file_basename( & model_driver_create_handle, index, parameter_file_basename, ierr) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function get_parameter_file_basename( & model_driver_create, index, parameter_file_basename) & bind(c, name="KIM_ModelDriverCreate_GetParameterFileBasename") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: parameter_file_basename end function get_parameter_file_basename end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: parameter_file_basename integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create type(c_ptr) :: p call c_f_pointer(model_driver_create_handle%p, model_driver_create) ierr = get_parameter_file_basename(model_driver_create, & index - 1, p) call kim_convert_c_char_ptr_to_string(p, parameter_file_basename) end subroutine kim_model_driver_create_get_parameter_file_basename !> \brief \copybrief KIM::ModelDriverCreate::SetModelNumbering !! !! \sa KIM::ModelDriverCreate::SetModelNumbering, !! KIM_ModelDriverCreate_SetModelNumbering !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_model_numbering( & model_driver_create_handle, numbering, ierr) use kim_numbering_module, only: kim_numbering_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function set_model_numbering( & model_driver_create, numbering) & bind(c, name="KIM_ModelDriverCreate_SetModelNumbering") use, intrinsic :: iso_c_binding use kim_numbering_module, only: kim_numbering_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(kim_numbering_type), intent(in), value :: numbering end function set_model_numbering end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(kim_numbering_type), intent(in) :: numbering integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) ierr = set_model_numbering(model_driver_create, numbering) end subroutine kim_model_driver_create_set_model_numbering !> \brief \copybrief KIM::ModelDriverCreate::SetInfluenceDistancePointer !! !! \sa KIM::ModelDriverCreate::SetInfluenceDistancePointer, !! KIM_ModelDriverCreate_SetInfluenceDistancePointer !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_influence_distance_pointer( & model_driver_create_handle, influence_distance) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface recursive subroutine set_influence_distance_pointer(model_driver_create, & influence_distance) & bind(c, name="KIM_ModelDriverCreate_SetInfluenceDistancePointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(c_ptr), intent(in), value :: influence_distance end subroutine set_influence_distance_pointer end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle real(c_double), intent(in), target :: influence_distance type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call set_influence_distance_pointer(model_driver_create, & c_loc(influence_distance)) end subroutine kim_model_driver_create_set_influence_distance_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetNeighborListPointers !! !! \sa KIM::ModelDriverCreate::SetNeighborListPointers, !! KIM_ModelDriverCreate_SetNeighborListPointers !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_neighbor_list_pointers( & model_driver_create_handle, number_of_neighbor_lists, cutoffs, & model_will_not_request_neighbors_of_noncontributing_particles) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface recursive subroutine set_neighbor_list_pointers( & model_driver_create, number_of_neighbor_lists, cutoffs_ptr, & model_will_not_request_neighbors_of_noncontributing_particles) & bind(c, name="KIM_ModelDriverCreate_SetNeighborListPointers") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in), value :: number_of_neighbor_lists type(c_ptr), intent(in), value :: cutoffs_ptr type(c_ptr), intent(in), value :: & model_will_not_request_neighbors_of_noncontributing_particles end subroutine set_neighbor_list_pointers end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle integer(c_int), intent(in) :: number_of_neighbor_lists real(c_double), intent(in), target :: cutoffs(number_of_neighbor_lists) integer(c_int), intent(in), target :: & model_will_not_request_neighbors_of_noncontributing_particles( & number_of_neighbor_lists) type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call set_neighbor_list_pointers( & model_driver_create, number_of_neighbor_lists, c_loc(cutoffs), & c_loc(model_will_not_request_neighbors_of_noncontributing_particles)) end subroutine kim_model_driver_create_set_neighbor_list_pointers !> \brief \copybrief KIM::ModelDriverCreate::SetRoutinePointer !! !! \sa KIM::ModelDriverCreate::SetRoutinePointer, !! KIM_ModelDriverCreate_SetRoutinePointer !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_routine_pointer( & model_driver_create_handle, model_routine_name, language_name, required, & fptr, ierr) use kim_model_routine_name_module, only: kim_model_routine_name_type use kim_language_name_module, only: kim_language_name_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function set_routine_pointer( & model_driver_create, model_routine_name, language_name, required, & fptr) bind(c, name="KIM_ModelDriverCreate_SetRoutinePointer") use, intrinsic :: iso_c_binding use kim_model_routine_name_module, only: kim_model_routine_name_type use kim_language_name_module, only: kim_language_name_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(kim_model_routine_name_type), intent(in), value & :: model_routine_name type(kim_language_name_type), intent(in), value :: language_name integer(c_int), intent(in), value :: required type(c_funptr), intent(in), value :: fptr end function set_routine_pointer end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(kim_model_routine_name_type), intent(in) :: model_routine_name type(kim_language_name_type), intent(in) :: language_name integer(c_int), intent(in) :: required type(c_funptr), intent(in), value :: fptr ! must be left as "value"!?! integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) ierr = set_routine_pointer(model_driver_create, model_routine_name, & language_name, required, fptr) end subroutine kim_model_driver_create_set_routine_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetSpeciesCode !! !! \sa KIM::ModelDriverCreate::SetSpeciesCode, !! KIM_ModelDriverCreate_SetSpeciesCode !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_species_code( & model_driver_create_handle, species_name, code, ierr) use kim_species_name_module, only: kim_species_name_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function set_species_code(model_driver_create, & species_name, code) & bind(c, name="KIM_ModelDriverCreate_SetSpeciesCode") use, intrinsic :: iso_c_binding use kim_species_name_module, only: kim_species_name_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(kim_species_name_type), intent(in), value :: species_name integer(c_int), intent(in), value :: code end function set_species_code end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(kim_species_name_type), intent(in) :: species_name integer(c_int), intent(in) :: code integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) ierr = set_species_code(model_driver_create, species_name, code) end subroutine kim_model_driver_create_set_species_code !> \brief \copybrief KIM::ModelDriverCreate::SetParameterPointer !! !! \sa KIM::ModelDriverCreate::SetParameterPointer, !! KIM_ModelDriverCreate_SetParameterPointerInteger !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_parameter_pointer_integer( & model_driver_create_handle, int1, name, description, ierr) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle integer(c_int), intent(in), target :: int1(:) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call set_parameter(model_driver_create, size(int1, 1, c_int), int1, & name, description, ierr) return contains recursive subroutine set_parameter(model_driver_create, extent, int1, & name, description, ierr) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function set_parameter_pointer_integer( & model_driver_create, extent, ptr, name, description) & bind(c, name="KIM_ModelDriverCreate_SetParameterPointerInteger") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in), value :: extent type(c_ptr), intent(in), value :: ptr character(c_char), intent(in) :: name(*) character(c_char), intent(in) :: description(*) end function set_parameter_pointer_integer end interface type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in) :: extent integer(c_int), intent(in), target :: int1(extent) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr ierr = set_parameter_pointer_integer(model_driver_create, & extent, & c_loc(int1), & trim(name)//c_null_char, & trim(description)//c_null_char) end subroutine set_parameter end subroutine kim_model_driver_create_set_parameter_pointer_integer !> \brief \copybrief KIM::ModelDriverCreate::SetParameterPointer !! !! \sa KIM::ModelDriverCreate::SetParameterPointer, !! KIM_ModelDriverCreate_SetParameterPointerDouble !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_parameter_pointer_double( & model_driver_create_handle, double1, name, description, ierr) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle real(c_double), intent(in), target :: double1(:) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call set_parameter(model_driver_create, size(double1, 1, c_int), & double1, name, description, ierr) return contains recursive subroutine set_parameter(model_driver_create, extent, double1, & name, description, ierr) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function set_parameter_pointer_double( & model_driver_create, extent, ptr, name, description) & bind(c, name="KIM_ModelDriverCreate_SetParameterPointerDouble") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in), value :: extent type(c_ptr), intent(in), value :: ptr character(c_char), intent(in) :: name(*) character(c_char), intent(in) :: description(*) end function set_parameter_pointer_double end interface type(kim_model_driver_create_type), intent(in) & :: model_driver_create integer(c_int), intent(in) :: extent real(c_double), intent(in), target :: double1(extent) character(len=*, kind=c_char), intent(in) :: name character(len=*, kind=c_char), intent(in) :: description integer(c_int), intent(out) :: ierr ierr = set_parameter_pointer_double(model_driver_create, & extent, & c_loc(double1), & trim(name)//c_null_char, & trim(description)//c_null_char) end subroutine set_parameter end subroutine kim_model_driver_create_set_parameter_pointer_double !> \brief \copybrief KIM::ModelDriverCreate::SetModelBufferPointer !! !! \sa KIM::ModelDriverCreate::SetModelBufferPointer, !! KIM_ModelDriverCreate_SetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_model_buffer_pointer( & model_driver_create_handle, ptr) use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface recursive subroutine set_model_buffer_pointer(model_driver_create, ptr) & bind(c, name="KIM_ModelDriverCreate_SetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(c_ptr), intent(in), value :: ptr end subroutine set_model_buffer_pointer end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(c_ptr), intent(in) :: ptr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call set_model_buffer_pointer(model_driver_create, ptr) end subroutine kim_model_driver_create_set_model_buffer_pointer !> \brief \copybrief KIM::ModelDriverCreate::SetUnits !! !! \sa KIM::ModelDriverCreate::SetUnits, KIM_ModelDriverCreate_SetUnits !! !! \since 2.0 recursive subroutine kim_model_driver_create_set_units( & model_driver_create_handle, length_unit, energy_unit, charge_unit, & temperature_unit, time_unit, ierr) use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface integer(c_int) recursive function set_units( & model_driver_create, length_unit, energy_unit, charge_unit, & temperature_unit, time_unit) & bind(c, name="KIM_ModelDriverCreate_SetUnits") use, intrinsic :: iso_c_binding use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(kim_length_unit_type), intent(in), value :: length_unit type(kim_energy_unit_type), intent(in), value :: energy_unit type(kim_charge_unit_type), intent(in), value :: charge_unit type(kim_temperature_unit_type), intent(in), value :: temperature_unit type(kim_time_unit_type), intent(in), value :: time_unit end function set_units end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(kim_length_unit_type), intent(in) :: length_unit type(kim_energy_unit_type), intent(in) :: energy_unit type(kim_charge_unit_type), intent(in) :: charge_unit type(kim_temperature_unit_type), intent(in) :: temperature_unit type(kim_time_unit_type), intent(in) :: time_unit integer(c_int), intent(out) :: ierr type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) ierr = set_units(model_driver_create, length_unit, energy_unit, & charge_unit, temperature_unit, time_unit) end subroutine kim_model_driver_create_set_units !> \brief \copybrief KIM::ModelDriverCreate::ConvertUnit !! !! \sa KIM::ModelDriverCreate::ConvertUnit, KIM_ModelDriverCreate_ConvertUnit !! !! \since 2.0 recursive subroutine kim_model_driver_create_convert_unit( & from_length_unit, from_energy_unit, & from_charge_unit, from_temperature_unit, from_time_unit, & to_length_unit, to_energy_unit, to_charge_unit, to_temperature_unit, & to_time_unit, length_exponent, energy_exponent, charge_exponent, & temperature_exponent, time_exponent, conversion_factor, ierr) use kim_unit_system_module, only: kim_length_unit_type use kim_unit_system_module, only: kim_energy_unit_type use kim_unit_system_module, only: kim_charge_unit_type use kim_unit_system_module, only: kim_temperature_unit_type use kim_unit_system_module, only: kim_time_unit_type implicit none interface integer(c_int) recursive function convert_unit( & from_length_unit, from_energy_unit, & from_charge_unit, from_temperature_unit, from_time_unit, & to_length_unit, to_energy_unit, to_charge_unit, to_temperature_unit, & to_time_unit, length_exponent, energy_exponent, charge_exponent, & temperature_exponent, time_exponent, conversion_factor) & bind(c, name="KIM_ModelDriverCreate_ConvertUnit") use, intrinsic :: iso_c_binding use kim_unit_system_module, only: kim_length_unit_type use kim_unit_system_module, only: kim_energy_unit_type use kim_unit_system_module, only: kim_charge_unit_type use kim_unit_system_module, only: kim_temperature_unit_type use kim_unit_system_module, only: kim_time_unit_type implicit none type(kim_length_unit_type), intent(in), value :: from_length_unit type(kim_energy_unit_type), intent(in), value :: from_energy_unit type(kim_charge_unit_type), intent(in), value :: from_charge_unit type(kim_temperature_unit_type), intent(in), value :: & from_temperature_unit type(kim_time_unit_type), intent(in), value :: from_time_unit type(kim_length_unit_type), intent(in), value :: to_length_unit type(kim_energy_unit_type), intent(in), value :: to_energy_unit type(kim_charge_unit_type), intent(in), value :: to_charge_unit type(kim_temperature_unit_type), intent(in), value :: & to_temperature_unit type(kim_time_unit_type), intent(in), value :: to_time_unit real(c_double), intent(in), value :: length_exponent real(c_double), intent(in), value :: energy_exponent real(c_double), intent(in), value :: charge_exponent real(c_double), intent(in), value :: temperature_exponent real(c_double), intent(in), value :: time_exponent real(c_double), intent(out) :: conversion_factor end function convert_unit end interface type(kim_length_unit_type), intent(in) :: from_length_unit type(kim_energy_unit_type), intent(in) :: from_energy_unit type(kim_charge_unit_type), intent(in) :: from_charge_unit type(kim_temperature_unit_type), intent(in) :: from_temperature_unit type(kim_time_unit_type), intent(in) :: from_time_unit type(kim_length_unit_type), intent(in) :: to_length_unit type(kim_energy_unit_type), intent(in) :: to_energy_unit type(kim_charge_unit_type), intent(in) :: to_charge_unit type(kim_temperature_unit_type), intent(in) :: to_temperature_unit type(kim_time_unit_type), intent(in) :: to_time_unit real(c_double), intent(in) :: length_exponent real(c_double), intent(in) :: energy_exponent real(c_double), intent(in) :: charge_exponent real(c_double), intent(in) :: temperature_exponent real(c_double), intent(in) :: time_exponent real(c_double), intent(out) :: conversion_factor integer(c_int), intent(out) :: ierr ierr = convert_unit(from_length_unit, from_energy_unit, from_charge_unit, & from_temperature_unit, from_time_unit, to_length_unit, & to_energy_unit, to_charge_unit, to_temperature_unit, & to_time_unit, length_exponent, energy_exponent, & charge_exponent, temperature_exponent, time_exponent, & conversion_factor) end subroutine kim_model_driver_create_convert_unit !> \brief \copybrief KIM::ModelDriverCreate::LogEntry !! !! \sa KIM::ModelDriverCreate::LogEntry, KIM_ModelDriverCreate_LogEntry !! !! \since 2.0 recursive subroutine kim_model_driver_create_log_entry( & model_driver_create_handle, log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface recursive subroutine log_entry(model_driver_create, log_verbosity, & message, line_number, file_name) & bind(c, name="KIM_ModelDriverCreate_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_driver_create_type), pointer :: model_driver_create call c_f_pointer(model_driver_create_handle%p, model_driver_create) call log_entry(model_driver_create, log_verbosity, & trim(message)//c_null_char, 0, ""//c_null_char) end subroutine kim_model_driver_create_log_entry !> \brief \copybrief KIM::ModelDriverCreate::ToString !! !! \sa KIM::ModelDriverCreate::ToString, KIM_ModelDriverCreate_ToString !! !! \since 2.0 recursive subroutine kim_model_driver_create_to_string( & model_driver_create_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none interface type(c_ptr) recursive function model_driver_create_string( & model_driver_create) & bind(c, name="KIM_ModelDriverCreate_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_driver_create_type implicit none type(kim_model_driver_create_type), intent(in) & :: model_driver_create end function model_driver_create_string end interface type(kim_model_driver_create_handle_type), intent(in) & :: model_driver_create_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_driver_create_type), pointer :: model_driver_create type(c_ptr) :: p call c_f_pointer(model_driver_create_handle%p, model_driver_create) p = model_driver_create_string(model_driver_create) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_driver_create_to_string end module kim_model_driver_create_module kim-api-2.3.0-git/fortran/include/kim_model_driver_headers_module.f90000066400000000000000000000034301421473465500256300ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! module kim_model_driver_headers_module use, intrinsic :: iso_c_binding use kim_model_driver_create_module use kim_log_verbosity_module use kim_language_name_module use kim_numbering_module use kim_model_routine_name_module use kim_species_name_module use kim_support_status_module use kim_unit_system_module use kim_model_compute_arguments_create_module use kim_compute_argument_name_module use kim_data_type_module use kim_compute_callback_name_module use kim_model_compute_arguments_module use kim_model_compute_arguments_destroy_module use kim_model_compute_module use kim_model_extension_module use kim_model_refresh_module use kim_model_write_parameterized_model_module use kim_model_destroy_module public end module kim_model_driver_headers_module kim-api-2.3.0-git/fortran/include/kim_model_extension_module.f90000066400000000000000000000553151421473465500246670ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelExtension !! !! \sa KIM::ModelExtension, KIM_ModelExtension !! !! \since 2.0 module kim_model_extension_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_extension_handle_type, & ! Constants KIM_MODEL_EXTENSION_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_extension_id, & kim_to_model, & kim_to_model_compute, & kim_to_model_create, & kim_to_model_destroy, & kim_to_model_driver_create, & kim_to_model_refresh, & kim_to_model_write_parameterized_model, & kim_to_model_compute_arguments, & kim_to_model_compute_arguments_create, & kim_to_model_compute_arguments_destroy, & kim_c_char_array_to_string, & kim_c_char_ptr_to_string, & kim_string_to_c_char_array, & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelExtension !! !! \sa KIM::ModelExtension, KIM_ModelExtension !! !! \since 2.0 type, bind(c) :: kim_model_extension_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_extension_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_extension_handle_type), protected, save & :: KIM_MODEL_EXTENSION_NULL_HANDLE !> \brief Compares kim_model_extension_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_extension_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_extension_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_extension_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelExtension::GetExtensionID !! !! \sa KIM::ModelExtension::GetExtensionID, KIM_ModelExtension_GetExtensionID !! !! \since 2.0 interface kim_get_extension_id module procedure kim_model_extension_get_extension_id end interface kim_get_extension_id !> \brief \copybrief KIM::ModelExtension::Model !! !! \sa KIM::ModelExtension::Model, KIM_ModelExtension_ToModel !! !! \since 2.0 interface kim_to_model module procedure kim_model_extension_to_model end interface kim_to_model !> \brief \copybrief KIM::ModelExtension::ModelCompute !! !! \sa KIM::ModelExtension::ModelCompute, KIM_ModelExtension_ToModelCompute !! !! \since 2.0 interface kim_to_model_compute module procedure kim_model_extension_to_model_compute end interface kim_to_model_compute !> \brief \copybrief KIM::ModelExtension::ModelCompute !! !! \sa KIM::ModelExtension::ModelCompute, KIM_ModelExtension_ToModelCompute !! !! \since 2.0 interface kim_to_model_create module procedure kim_model_extension_to_model_create end interface kim_to_model_create !> \brief \copybrief KIM::ModelExtension::ModelDestroy !! !! \sa KIM::ModelExtension::ModelDestroy, KIM_ModelExtension_ToModelDestroy !! !! \since 2.0 interface kim_to_model_destroy module procedure kim_model_extension_to_model_destroy end interface kim_to_model_destroy !> \brief \copybrief KIM::ModelExtension::ModelDriverCreate !! !! \sa KIM::ModelExtension::ModelDriverCreate, !! KIM_ModelExtension_ToModelDriverCreate !! !! \since 2.0 interface kim_to_model_driver_create module procedure kim_model_extension_to_model_driver_create end interface kim_to_model_driver_create !> \brief \copybrief KIM::ModelExtension::ModelRefresh !! !! \sa KIM::ModelExtension::ModelRefresh, KIM_ModelExtension_ToModelRefresh !! !! \since 2.0 interface kim_to_model_refresh module procedure kim_model_extension_to_model_refresh end interface kim_to_model_refresh !> \brief \copybrief KIM::ModelExtension::ModelWriteParameterizedModel !! !! \sa KIM::ModelExtension::ModelWriteParameterizedModel, !! KIM_ModelExtension_ToModelWriteParameterizedModel !! !! \since 2.0 interface kim_to_model_write_parameterized_model module procedure kim_model_extension_to_model_write_parameterized_model end interface kim_to_model_write_parameterized_model !> \brief \copybrief KIM::ModelExtension::ModelComputeArguments !! !! \sa KIM::ModelExtension::ModelComputeArguments, !! KIM_ModelExtension_ToModelComputeArguments !! !! \since 2.0 interface kim_to_model_compute_arguments module procedure kim_model_extension_to_model_compute_arguments end interface kim_to_model_compute_arguments !> \brief \copybrief KIM::ModelExtension::ModelComputeArgumentsCreate !! !! \sa KIM::ModelExtension::ModelComputeArgumentsCreate, !! KIM_ModelExtension_ToModelComputeArgumentsCreate !! !! \since 2.0 interface kim_to_model_compute_arguments_create module procedure kim_model_extension_to_model_compute_arguments_create end interface kim_to_model_compute_arguments_create !> \brief \copybrief KIM::ModelExtension::ModelComputeArgumentsDestroy !! !! \sa KIM::ModelExtension::ModelComputeArgumentsDestroy, !! KIM_ModelExtension_ToModelComputeArgumentsDestroy !! !! \since 2.0 interface kim_to_model_compute_arguments_destroy module procedure kim_model_extension_to_model_compute_arguments_destroy end interface kim_to_model_compute_arguments_destroy !> \brief Copy C character array to Fortran string !! !! \since 2.0 interface kim_c_char_array_to_string module procedure kim_model_extension_convert_c_char_array_to_string end interface kim_c_char_array_to_string !> \brief Copy C character pointer to Fortran string !! !! \since 2.0 interface kim_c_char_ptr_to_string module procedure kim_model_extension_convert_c_char_ptr_to_string end interface kim_c_char_ptr_to_string !> \brief Convert Fortran string to C character array !! !! \since 2.0 interface kim_string_to_c_char_array module procedure kim_model_extension_convert_string_to_c_char_array end interface kim_string_to_c_char_array !> \brief \copybrief KIM::ModelExtension::GetModelBufferPointer !! !! \sa KIM::ModelExtension::GetModelBufferPointer, !! KIM_ModelExtension_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure kim_model_extension_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelExtension::LogEntry !! !! \sa KIM::ModelExtension::LogEntry, KIM_ModelExtension_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_extension_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelExtension::ToString !! !! \sa KIM::ModelExtension::ToString, KIM_ModelExtension_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_extension_to_string end interface kim_to_string contains !> \brief Compares kim_model_extension_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_extension_handle_equal(lhs, rhs) implicit none type(kim_model_extension_handle_type), intent(in) :: lhs type(kim_model_extension_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_extension_handle_equal = .true. else kim_model_extension_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_extension_handle_equal !> \brief Compares kim_model_extension_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_extension_handle_not_equal(lhs, rhs) implicit none type(kim_model_extension_handle_type), intent(in) :: lhs type(kim_model_extension_handle_type), intent(in) :: rhs kim_model_extension_handle_not_equal = .not. (lhs == rhs) end function kim_model_extension_handle_not_equal !> \brief \copybrief KIM::ModelExtension::GetExtensionID !! !! \sa KIM::ModelExtension::GetExtensionID, KIM_ModelExtension_GetExtensionID !! !! \since 2.0 recursive subroutine kim_model_extension_get_extension_id( & model_extension_handle, extension_id) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_extension_type implicit none interface recursive subroutine get_extension_id(model_extension, extension_id) & bind(c, name="KIM_ModelExtension_GetExtensionID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_extension_type implicit none type(kim_model_extension_type), intent(in) :: model_extension type(c_ptr), intent(out) :: extension_id end subroutine get_extension_id end interface type(kim_model_extension_handle_type), intent(in) :: model_extension_handle character(len=*, kind=c_char), intent(out) :: extension_id type(kim_model_extension_type), pointer :: model_extension type(c_ptr) :: p call c_f_pointer(model_extension_handle%p, model_extension) call get_extension_id(model_extension, p) call kim_convert_c_char_ptr_to_string(p, extension_id) end subroutine kim_model_extension_get_extension_id !> \brief \copybrief KIM::ModelExtension::Model !! !! \sa KIM::ModelExtension::Model, KIM_ModelExtension_ToModel !! !! \since 2.0 recursive subroutine kim_model_extension_to_model(model_extension_handle, & model_handle) use kim_model_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_handle_type), intent(out) :: model_handle model_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model !> \brief \copybrief KIM::ModelExtension::ModelCompute !! !! \sa KIM::ModelExtension::ModelCompute, KIM_ModelExtension_ToModelCompute !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_compute( & model_extension_handle, model_compute_handle) use kim_model_compute_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_compute_handle_type), intent(out) :: model_compute_handle model_compute_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model_compute !> \brief \copybrief KIM::ModelExtension::ModelCompute !! !! \sa KIM::ModelExtension::ModelCompute, KIM_ModelExtension_ToModelCompute !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_create( & model_extension_handle, model_create_handle) use kim_model_create_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_create_handle_type), intent(out) :: model_create_handle model_create_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model_create !> \brief \copybrief KIM::ModelExtension::ModelDestroy !! !! \sa KIM::ModelExtension::ModelDestroy, KIM_ModelExtension_ToModelDestroy !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_destroy( & model_extension_handle, model_destroy_handle) use kim_model_destroy_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_destroy_handle_type), intent(out) :: model_destroy_handle model_destroy_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model_destroy !> \brief \copybrief KIM::ModelExtension::ModelDriverCreate !! !! \sa KIM::ModelExtension::ModelDriverCreate, !! KIM_ModelExtension_ToModelDriverCreate !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_driver_create( & model_extension_handle, model_driver_create_handle) use kim_model_driver_create_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_driver_create_handle_type), intent(out) & :: model_driver_create_handle model_driver_create_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model_driver_create !> \brief \copybrief KIM::ModelExtension::ModelRefresh !! !! \sa KIM::ModelExtension::ModelRefresh, KIM_ModelExtension_ToModelRefresh !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_refresh( & model_extension_handle, model_refresh_handle) use kim_model_refresh_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_refresh_handle_type), intent(out) :: model_refresh_handle model_refresh_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model_refresh !> \brief \copybrief KIM::ModelExtension::ModelWriteParameterizedModel !! !! \sa KIM::ModelExtension::ModelWriteParameterizedModel, !! KIM_ModelExtension_ToModelWriteParameterizedModel !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_write_parameterized_model( & model_extension_handle, model_write_parameterized_model_handle) use kim_model_write_parameterized_model_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_model_write_parameterized_model_handle_type), intent(out) & :: model_write_parameterized_model_handle model_write_parameterized_model_handle%p = model_extension_handle%p end subroutine kim_model_extension_to_model_write_parameterized_model !> \brief \copybrief KIM::ModelExtension::ModelComputeArguments !! !! \sa KIM::ModelExtension::ModelComputeArguments, !! KIM_ModelExtension_ToModelComputeArguments !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_compute_arguments( & model_extension_handle, compute_arguments_c_ptr, & model_compute_arguments_handle) use kim_model_compute_arguments_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(c_ptr), intent(in) :: compute_arguments_c_ptr type(kim_model_compute_arguments_handle_type), intent(out) & :: model_compute_arguments_handle ! avoid unused dummy argument warnings if (model_extension_handle == KIM_MODEL_EXTENSION_NULL_HANDLE) continue model_compute_arguments_handle%p = compute_arguments_c_ptr end subroutine kim_model_extension_to_model_compute_arguments !> \brief \copybrief KIM::ModelExtension::ModelComputeArgumentsCreate !! !! \sa KIM::ModelExtension::ModelComputeArgumentsCreate, !! KIM_ModelExtension_ToModelComputeArgumentsCreate !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_compute_arguments_create( & model_extension_handle, compute_arguments_c_ptr, & model_compute_arguments_create_handle) use kim_model_compute_arguments_create_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(c_ptr), intent(in) :: compute_arguments_c_ptr type(kim_model_compute_arguments_create_handle_type), intent(out) & :: model_compute_arguments_create_handle ! avoid unused dummy argument warnings if (model_extension_handle == KIM_MODEL_EXTENSION_NULL_HANDLE) continue model_compute_arguments_create_handle%p = compute_arguments_c_ptr end subroutine kim_model_extension_to_model_compute_arguments_create !> \brief \copybrief KIM::ModelExtension::ModelComputeArgumentsDestroy !! !! \sa KIM::ModelExtension::ModelComputeArgumentsDestroy, !! KIM_ModelExtension_ToModelComputeArgumentsDestroy !! !! \since 2.0 recursive subroutine kim_model_extension_to_model_compute_arguments_destroy( & model_extension_handle, compute_arguments_c_ptr, & model_compute_arguments_destroy_handle) use kim_model_compute_arguments_destroy_module implicit none type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(c_ptr), intent(in) :: compute_arguments_c_ptr type(kim_model_compute_arguments_destroy_handle_type), intent(out) & :: model_compute_arguments_destroy_handle ! avoid unused dummy argument warnings if (model_extension_handle == KIM_MODEL_EXTENSION_NULL_HANDLE) continue model_compute_arguments_destroy_handle%p = compute_arguments_c_ptr end subroutine kim_model_extension_to_model_compute_arguments_destroy !> \brief Copy C character array to Fortran string !! !! \since 2.0 recursive subroutine kim_model_extension_convert_c_char_array_to_string( & c_char_array, string) use kim_convert_string_module, only: kim_convert_c_char_array_to_string implicit none character(len=1, kind=c_char), intent(in) :: c_char_array(:) character(len=*, kind=c_char), intent(out) :: string call kim_convert_c_char_array_to_string(c_char_array, string) end subroutine kim_model_extension_convert_c_char_array_to_string !> \brief Copy C character pointer to Fortran string !! !! \since 2.0 recursive subroutine kim_model_extension_convert_c_char_ptr_to_string( & c_char_ptr, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none type(c_ptr), intent(in) :: c_char_ptr character(len=*, kind=c_char), intent(out) :: string call kim_convert_c_char_ptr_to_string(c_char_ptr, string) end subroutine kim_model_extension_convert_c_char_ptr_to_string !> \brief Convert Fortran string to C character array !! !! \since 2.0 recursive subroutine kim_model_extension_convert_string_to_c_char_array( & string, c_char_array) use kim_convert_string_module, only: kim_convert_string_to_c_char_array implicit none character(len=*, kind=c_char), intent(in) :: string character(len=1, kind=c_char), intent(out) :: c_char_array(:) call kim_convert_string_to_c_char_array(string, c_char_array) end subroutine kim_model_extension_convert_string_to_c_char_array !> \brief \copybrief KIM::ModelExtension::GetModelBufferPointer !! !! \sa KIM::ModelExtension::GetModelBufferPointer, !! KIM_ModelExtension_GetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_extension_get_model_buffer_pointer( & model_extension_handle, ptr) use kim_interoperable_types_module, only: kim_model_extension_type implicit none interface recursive subroutine get_model_buffer_pointer(model_extension, ptr) & bind(c, name="KIM_ModelExtension_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_extension_type implicit none type(kim_model_extension_type), intent(in) :: model_extension type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(c_ptr), intent(out) :: ptr type(kim_model_extension_type), pointer :: model_extension call c_f_pointer(model_extension_handle%p, model_extension) call get_model_buffer_pointer(model_extension, ptr) end subroutine kim_model_extension_get_model_buffer_pointer !> \brief \copybrief KIM::ModelExtension::LogEntry !! !! \sa KIM::ModelExtension::LogEntry, KIM_ModelExtension_LogEntry !! !! \since 2.0 recursive subroutine kim_model_extension_log_entry(model_extension_handle, & log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_extension_type implicit none interface recursive subroutine log_entry( & model_extension, log_verbosity, message, line_number, file_name) & bind(c, name="KIM_ModelExtension_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_extension_type implicit none type(kim_model_extension_type), intent(in) :: model_extension type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_extension_handle_type), intent(in) :: model_extension_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_extension_type), pointer :: model_extension call c_f_pointer(model_extension_handle%p, model_extension) call log_entry(model_extension, log_verbosity, trim(message)//c_null_char, & 0, ""//c_null_char) end subroutine kim_model_extension_log_entry !> \brief \copybrief KIM::ModelExtension::ToString !! !! \sa KIM::ModelExtension::ToString, KIM_ModelExtension_ToString !! !! \since 2.0 recursive subroutine kim_model_extension_to_string(model_extension_handle, & string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_extension_type implicit none interface type(c_ptr) recursive function model_extension_string(model_extension) & bind(c, name="KIM_ModelExtension_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_extension_type implicit none type(kim_model_extension_type), intent(in) :: model_extension end function model_extension_string end interface type(kim_model_extension_handle_type), intent(in) :: model_extension_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_extension_type), pointer :: model_extension type(c_ptr) :: p call c_f_pointer(model_extension_handle%p, model_extension) p = model_extension_string(model_extension) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_extension_to_string end module kim_model_extension_module kim-api-2.3.0-git/fortran/include/kim_model_headers_module.f90000066400000000000000000000034031421473465500242550ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! module kim_model_headers_module use, intrinsic :: iso_c_binding use kim_model_create_module use kim_log_verbosity_module use kim_language_name_module use kim_numbering_module use kim_model_routine_name_module use kim_species_name_module use kim_support_status_module use kim_unit_system_module use kim_model_compute_arguments_create_module use kim_compute_argument_name_module use kim_data_type_module use kim_compute_callback_name_module use kim_model_compute_arguments_module use kim_model_compute_arguments_destroy_module use kim_model_compute_module use kim_model_extension_module use kim_model_refresh_module use kim_model_write_parameterized_model_module use kim_model_destroy_module public end module kim_model_headers_module kim-api-2.3.0-git/fortran/include/kim_model_module.f90000066400000000000000000001547051421473465500225760ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::Model !! !! \sa KIM::Model, KIM_Model !! !! \since 2.0 module kim_model_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_handle_type, & ! Constants KIM_MODEL_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_model_create, & kim_model_destroy, & kim_is_routine_present, & kim_get_influence_distance, & kim_get_number_of_neighbor_lists, & kim_get_neighbor_list_values, & kim_get_units, & kim_compute_arguments_create, & kim_compute_arguments_destroy, & kim_compute, & kim_extension, & kim_clear_then_refresh, & kim_write_parameterized_model, & kim_get_species_support_and_code, & kim_get_number_of_parameters, & kim_get_parameter_metadata, & kim_get_parameter, & kim_set_parameter, & kim_set_simulator_buffer_pointer, & kim_get_simulator_buffer_pointer, & kim_to_string, & kim_set_log_id, & kim_push_log_verbosity, & kim_pop_log_verbosity !> \brief \copybrief KIM::Model !! !! \sa KIM::Model, KIM_Model !! !! \since 2.0 type, bind(c) :: kim_model_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_handle_type), protected, save & :: KIM_MODEL_NULL_HANDLE !> \brief Compares kim_model_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::Model::IsRoutinePresent !! !! \sa KIM::Model::IsRoutinePresent, KIM_Model_IsRoutinePresent !! !! \since 2.0 interface kim_is_routine_present module procedure kim_model_is_routine_present end interface kim_is_routine_present !> \brief \copybrief KIM::Model::GetInfluenceDistance !! !! \sa KIM::Model::GetInfluenceDistance, KIM_Model_GetInfluenceDistance !! !! \since 2.0 interface kim_get_influence_distance module procedure kim_model_get_influence_distance end interface kim_get_influence_distance !> \brief Get Model's number of neighbor lists. !! !! \sa KIM::Model::GetNeighborListPointers, KIM_Model_GetNeighborListPointers !! !! \since 2.0 interface kim_get_number_of_neighbor_lists module procedure kim_model_get_number_of_neighbor_lists end interface kim_get_number_of_neighbor_lists !> \brief Get Model's neighbor list values !! !! \sa KIM::Model::GetNeighborListPointers, KIM_Model_GetNeighborListPointers !! !! \since 2.0 interface kim_get_neighbor_list_values module procedure kim_model_get_neighbor_list_values end interface kim_get_neighbor_list_values !> \brief \copybrief KIM::Model::GetUnits !! !! \sa KIM::Model::GetUnits, KIM_Model_GetUnits !! !! \since 2.0 interface kim_get_units module procedure kim_model_get_units end interface kim_get_units !> \brief \copybrief KIM::Model::ComputeArgumentsCreate !! !! \sa KIM::Model::ComputeArgumentsCreate, KIM_Model_ComputeArgumentsCreate !! !! \since 2.0 interface kim_compute_arguments_create module procedure kim_model_compute_arguments_create end interface kim_compute_arguments_create !> \brief \copybrief KIM::Model::ComputeArgumentsDestroy !! !! \sa KIM::Model::ComputeArgumentsDestroy, KIM_Model_ComputeArgumentsDestroy !! !! \since 2.0 interface kim_compute_arguments_destroy module procedure kim_model_compute_arguments_destroy end interface kim_compute_arguments_destroy !> \brief \copybrief KIM::Model::Compute !! !! \sa KIM::Model::Compute, KIM_Model_Compute !! !! \since 2.0 interface kim_compute module procedure kim_model_compute end interface kim_compute !> \brief \copybrief KIM::Model::Extension !! !! \sa KIM::Model::Extension, KIM_Model_Extension !! !! \since 2.0 interface kim_extension module procedure kim_model_extension end interface kim_extension !> \brief \copybrief KIM::Model::ClearThenRefresh !! !! \sa KIM::Model::ClearThenRefresh, KIM_Model_ClearThenRefresh !! !! \since 2.0 interface kim_clear_then_refresh module procedure kim_model_clear_then_refresh end interface kim_clear_then_refresh !> \brief \copybrief KIM::Model::WriteParameterizedModel !! !! \sa KIM::Model::WriteParameterizedModel, KIM_Model_WriteParameterizedModel !! !! \since 2.0 interface kim_write_parameterized_model module procedure kim_model_write_parameterized_model end interface kim_write_parameterized_model !> \brief \copybrief KIM::Model::GetSpeciesSupportAndCode !! !! \sa KIM::Model::GetSpeciesSupportAndCode, !! KIM_Model_GetSpeciesSupportAndCode !! !! \since 2.0 interface kim_get_species_support_and_code module procedure kim_model_get_species_support_and_code end interface kim_get_species_support_and_code !> \brief \copybrief KIM::Model::GetNumberOfParameters !! !! \sa KIM::Model::GetNumberOfParameters, KIM_Model_GetNumberOfParameters !! !! \since 2.0 interface kim_get_number_of_parameters module procedure kim_model_get_number_of_parameters end interface kim_get_number_of_parameters !> \brief \copybrief KIM::Model::GetParameterMetadata !! !! \sa KIM::Model::GetParameterMetadata, KIM_Model_GetParameterMetadata !! !! \since 2.0 interface kim_get_parameter_metadata module procedure kim_model_get_parameter_metadata end interface kim_get_parameter_metadata !> \brief \copybrief KIM::Model::GetParameter !! !! \sa KIM::Model::GetParameter, KIM_Model_GetParameterInteger, !! KIM_Model_GetParameterDouble !! !! \since 2.0 interface kim_get_parameter module procedure kim_model_get_parameter_integer module procedure kim_model_get_parameter_double end interface kim_get_parameter !> \brief \copybrief KIM::Model::SetParameter !! !! \sa KIM::Model::SetParameter, KIM_Model_SetParameterInteger, !! KIM_Model_SetParameterDouble !! !! \since 2.0 interface kim_set_parameter module procedure kim_model_set_parameter_integer module procedure kim_model_set_parameter_double end interface kim_set_parameter !> \brief \copybrief KIM::Model::SetSimulatorBufferPointer !! !! \sa KIM::Model::SetSimulatorBufferPointer, !! KIM_Model_SetSimulatorBufferPointer !! !! \since 2.0 interface kim_set_simulator_buffer_pointer module procedure kim_model_set_simulator_buffer_pointer end interface kim_set_simulator_buffer_pointer !> \brief \copybrief KIM::Model::GetSimulatorBufferPointer !! !! \sa KIM::Model::GetSimulatorBufferPointer, !! KIM_Model_GetSimulatorBufferPointer !! !! \since 2.0 interface kim_get_simulator_buffer_pointer module procedure kim_model_get_simulator_buffer_pointer end interface kim_get_simulator_buffer_pointer !> \brief \copybrief KIM::Model::ToString !! !! \sa KIM::Model::ToString, KIM_Model_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_to_string end interface kim_to_string !> \brief \copybrief KIM::Model::SetLogID !! !! \sa KIM::Model::SetLogID, KIM_Model_SetLogID !! !! \since 2.0 interface kim_set_log_id module procedure kim_model_set_log_id end interface kim_set_log_id !> \brief \copybrief KIM::Model::PushLogVerbosity !! !! \sa KIM::Model::PushLogVerbosity, KIM_Model_PushLogVerbosity !! !! \since 2.0 interface kim_push_log_verbosity module procedure kim_model_push_log_verbosity end interface kim_push_log_verbosity !> \brief \copybrief KIM::Model::PopLogVerbosity !! !! \sa KIM::Model::, KIM_Model_PopLogVerbosity !! !! \since 2.0 interface kim_pop_log_verbosity module procedure kim_model_pop_log_verbosity end interface kim_pop_log_verbosity contains !> \brief Compares kim_model_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_handle_equal(lhs, rhs) implicit none type(kim_model_handle_type), intent(in) :: lhs type(kim_model_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_handle_equal = .true. else kim_model_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_handle_equal !> \brief Compares kim_model_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_handle_not_equal(lhs, rhs) implicit none type(kim_model_handle_type), intent(in) :: lhs type(kim_model_handle_type), intent(in) :: rhs kim_model_handle_not_equal = .not. (lhs == rhs) end function kim_model_handle_not_equal !> \brief \copybrief KIM::Model::Create !! !! A Fortran PM must provide a KIM::MODEL_ROUTINE_NAME::Create routine. The !! interface for this is given here. !! !! A PM not employing a MD should use the following interface (see also !! KIM::ModelCreateFunction, \ref KIM_ModelCreateFunction) !! !! \code{.f90} !! interface !! recursive subroutine create( & !! model_create_handle, requested_length_unit, requested_energy_unit, & !! requested_charge_unit, requested_temperature_unit, & !! requested_time_unit, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_create_handle_type), intent(in) :: model_create_handle !! type(kim_length_unit_type), intent(in), value :: requested_length_unit !! type(kim_energy_unit_type), intent(in), value :: requested_energy_unit !! type(kim_charge_unit_type), intent(in), value :: requested_charge_unit !! type(kim_temperature_unit_type), intent(in), value :: & !! requested_temperature_unit !! type(kim_time_unit_type), intent(in), value :: requested_time_unit !! integer(c_int), intent(out) :: ierr !! end subroutine create !! end interface !! \endcode !! !! A MD should use the following interface (see also !! KIM::ModelDriverCreateFunction, \ref KIM_ModelDriverCreateFunction) !! !! \code{.f90} !! interface !! recursive subroutine create( & !! model_driver_create_handle, requested_length_unit, & !! requested_energy_unit, requested_charge_unit, & !! requested_temperature_unit, requested_time_unit, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_driver_headers_module !! implicit none !! type(kim_model_driver_create_handle_type), intent(in) :: & !! model_create_handle !! type(kim_length_unit_type), intent(in), value :: requested_length_unit !! type(kim_energy_unit_type), intent(in), value :: requested_energy_unit !! type(kim_charge_unit_type), intent(in), value :: requested_charge_unit !! type(kim_temperature_unit_type), intent(in), value :: & !! requested_temperature_unit !! type(kim_time_unit_type), intent(in), value :: requested_time_unit !! integer(c_int), intent(out) :: ierr !! end subroutine create !! end interface !! \endcode !! !! \sa KIM::Model::Create, KIM_Model_Create !! !! \since 2.0 recursive subroutine kim_model_create( & numbering, requested_length_unit, requested_energy_unit, & requested_charge_unit, requested_temperature_unit, requested_time_unit, & model_name, requested_units_accepted, model_handle, ierr) use kim_numbering_module, only: kim_numbering_type use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type implicit none interface integer(c_int) recursive function create( & numbering, requested_length_unit, requested_energy_unit, & requested_charge_unit, requested_temperature_unit, & requested_time_unit, model_name, requested_units_accepted, model) & bind(c, name="KIM_Model_Create") use, intrinsic :: iso_c_binding use kim_numbering_module, only: kim_numbering_type use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type implicit none type(kim_numbering_type), intent(in), value :: numbering type(kim_length_unit_type), intent(in), value :: requested_length_unit type(kim_energy_unit_type), intent(in), value :: requested_energy_unit type(kim_charge_unit_type), intent(in), value :: requested_charge_unit type(kim_temperature_unit_type), intent(in), value :: & requested_temperature_unit type(kim_time_unit_type), intent(in), value :: requested_time_unit character(c_char), intent(in) :: model_name(*) integer(c_int), intent(out) :: requested_units_accepted type(c_ptr), intent(out) :: model end function create end interface type(kim_numbering_type), intent(in) :: numbering type(kim_length_unit_type), intent(in) :: requested_length_unit type(kim_energy_unit_type), intent(in) :: requested_energy_unit type(kim_charge_unit_type), intent(in) :: requested_charge_unit type(kim_temperature_unit_type), intent(in) :: & requested_temperature_unit type(kim_time_unit_type), intent(in) :: requested_time_unit character(len=*, kind=c_char), intent(in) :: model_name integer(c_int), intent(out) :: requested_units_accepted type(kim_model_handle_type), intent(out) :: model_handle integer(c_int), intent(out) :: ierr type(c_ptr) :: pmodel ierr = create(numbering, requested_length_unit, requested_energy_unit, & requested_charge_unit, requested_temperature_unit, & requested_time_unit, trim(model_name)//c_null_char, & requested_units_accepted, pmodel) model_handle%p = pmodel end subroutine kim_model_create !> \brief \copybrief KIM::Model::Destroy !! !! A Fortran PM must provide a KIM::MODEL_ROUTINE_NAME::Destroy routine. The !! interface for this is given here (see also KIM::ModelDestroyFunction, \ref !! KIM_ModelDestroyFunction). !! !! \code{.f90} !! interface !! recursive subroutine destroy(model_destroy_handle, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_destroy_handle_type), intent(in) :: model_destroy_handle !! integer(c_int), intent(out) :: ierr !! end subroutine destroy !! end interface !! \endcode !! !! \sa KIM::Model::Destroy, KIM_Model_Destroy !! !! \since 2.0 recursive subroutine kim_model_destroy(model_handle) implicit none interface recursive subroutine destroy(model) bind(c, name="KIM_Model_Destroy") use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(inout) :: model end subroutine destroy end interface type(kim_model_handle_type), intent(inout) :: model_handle type(c_ptr) :: pmodel pmodel = model_handle%p call destroy(pmodel) model_handle%p = c_null_ptr end subroutine kim_model_destroy !> \brief \copybrief KIM::Model::IsRoutinePresent !! !! \sa KIM::Model::IsRoutinePresent, KIM_Model_IsRoutinePresent !! !! \since 2.0 recursive subroutine kim_model_is_routine_present( & model_handle, model_routine_name, present, required, ierr) use kim_interoperable_types_module, only: kim_model_type use kim_model_routine_name_module, only: kim_model_routine_name_type implicit none interface integer(c_int) recursive function is_routine_present( & model, model_routine_name, present, required) & bind(c, name="KIM_Model_IsRoutinePresent") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type use kim_model_routine_name_module, only: kim_model_routine_name_type implicit none type(kim_model_type), intent(in) :: model type(kim_model_routine_name_type), intent(in), value & :: model_routine_name integer(c_int), intent(out) :: present integer(c_int), intent(out) :: required end function is_routine_present end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_model_routine_name_type), intent(in) :: model_routine_name integer(c_int), intent(out) :: present integer(c_int), intent(out) :: required integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = is_routine_present(model, model_routine_name, present, required) end subroutine kim_model_is_routine_present !> \brief \copybrief KIM::Model::GetInfluenceDistance !! !! \sa KIM::Model::GetInfluenceDistance, KIM_Model_GetInfluenceDistance !! !! \since 2.0 recursive subroutine kim_model_get_influence_distance( & model_handle, influence_distance) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine get_influence_distance(model, influence_distance) & bind(c, name="KIM_Model_GetInfluenceDistance") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model real(c_double), intent(out) :: influence_distance end subroutine get_influence_distance end interface type(kim_model_handle_type), intent(in) :: model_handle real(c_double), intent(out) :: influence_distance type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call get_influence_distance(model, influence_distance) end subroutine kim_model_get_influence_distance !> \brief Get Model's number of neighbor lists. !! !! \sa KIM::Model::GetNeighborListPointers, KIM_Model_GetNeighborListPointers !! !! \since 2.0 recursive subroutine kim_model_get_number_of_neighbor_lists( & model_handle, number_of_neighbor_lists) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine get_neighbor_list_pointers( & model, number_of_neighbor_lists, cutoffs_ptr, & model_will_not_request_neighbors_of_noncontributing__ptr) & bind(c, name="KIM_Model_GetNeighborListPointers") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(out) :: number_of_neighbor_lists type(c_ptr), intent(out) :: cutoffs_ptr type(c_ptr), intent(out) :: & model_will_not_request_neighbors_of_noncontributing__ptr end subroutine get_neighbor_list_pointers end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(out) :: number_of_neighbor_lists type(kim_model_type), pointer :: model type(c_ptr) cutoffs_ptr, hint_ptr call c_f_pointer(model_handle%p, model) call get_neighbor_list_pointers(model, number_of_neighbor_lists, & cutoffs_ptr, hint_ptr) end subroutine kim_model_get_number_of_neighbor_lists !> \brief Get Model's neighbor list values !! !! \sa KIM::Model::GetNeighborListPointers, KIM_Model_GetNeighborListPointers !! !! \since 2.0 recursive subroutine kim_model_get_neighbor_list_values( & model_handle, cutoffs, & model_will_not_request_neighbors_of_noncontributing_particles, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine get_neighbor_list_pointers( & model, number_of_neighbor_lists, cutoffs_ptr, & model_will_not_request_neighbors_of_noncontributing__ptr) & bind(c, name="KIM_Model_GetNeighborListPointers") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(out) :: number_of_neighbor_lists type(c_ptr), intent(out) :: cutoffs_ptr type(c_ptr), intent(out) :: & model_will_not_request_neighbors_of_noncontributing__ptr end subroutine get_neighbor_list_pointers end interface type(kim_model_handle_type), intent(in) :: model_handle real(c_double), intent(out) :: cutoffs(:) integer(c_int), intent(out) :: & model_will_not_request_neighbors_of_noncontributing_particles(:) integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model integer(c_int) number_of_neighbor_lists real(c_double), pointer :: cutoffs_fpointer(:) integer(c_int), pointer :: & model_will_not_request_neighbors_of_noncontributing__fpointer(:) type(c_ptr) cutoffs_ptr type(c_ptr) model_will_not_request_neighbors_of_noncontributing__ptr call c_f_pointer(model_handle%p, model) call get_neighbor_list_pointers( & model, number_of_neighbor_lists, cutoffs_ptr, & model_will_not_request_neighbors_of_noncontributing__ptr) if (c_associated(cutoffs_ptr)) then call c_f_pointer(cutoffs_ptr, cutoffs_fpointer, & [number_of_neighbor_lists]) else nullify (cutoffs_fpointer) end if if (size(cutoffs) < number_of_neighbor_lists) then ierr = 1 else ierr = 0 cutoffs = cutoffs_fpointer(1:number_of_neighbor_lists) end if if (c_associated( & model_will_not_request_neighbors_of_noncontributing__ptr)) then call c_f_pointer( & model_will_not_request_neighbors_of_noncontributing__ptr, & model_will_not_request_neighbors_of_noncontributing__fpointer, & [number_of_neighbor_lists]) else nullify ( & model_will_not_request_neighbors_of_noncontributing__fpointer) end if if (size( & model_will_not_request_neighbors_of_noncontributing_particles) & < number_of_neighbor_lists) then ierr = 1 else ierr = 0 model_will_not_request_neighbors_of_noncontributing_particles = & model_will_not_request_neighbors_of_noncontributing__fpointer( & 1:number_of_neighbor_lists) end if end subroutine kim_model_get_neighbor_list_values !> \brief \copybrief KIM::Model::GetUnits !! !! \sa KIM::Model::GetUnits, KIM_Model_GetUnits !! !! \since 2.0 recursive subroutine kim_model_get_units( & model_handle, length_unit, energy_unit, charge_unit, temperature_unit, & time_unit) use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine get_units( & model, length_unit, energy_unit, charge_unit, temperature_unit, & time_unit) & bind(c, name="KIM_Model_GetUnits") use, intrinsic :: iso_c_binding use kim_unit_system_module, only: kim_length_unit_type, & kim_energy_unit_type, & kim_charge_unit_type, & kim_temperature_unit_type, & kim_time_unit_type use kim_interoperable_types_module, only: kim_model_type type(kim_model_type), intent(in) :: model type(kim_length_unit_type), intent(out) :: length_unit type(kim_energy_unit_type), intent(out) :: energy_unit type(kim_charge_unit_type), intent(out) :: charge_unit type(kim_temperature_unit_type), intent(out) :: temperature_unit type(kim_time_unit_type), intent(out) :: time_unit end subroutine get_units end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_length_unit_type), intent(out) :: length_unit type(kim_energy_unit_type), intent(out) :: energy_unit type(kim_charge_unit_type), intent(out) :: charge_unit type(kim_temperature_unit_type), intent(out) :: temperature_unit type(kim_time_unit_type), intent(out) :: time_unit type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call get_units(model, length_unit, energy_unit, charge_unit, & temperature_unit, time_unit) end subroutine kim_model_get_units !> \brief \copybrief KIM::Model::ComputeArgumentsCreate !! !! A Fortran PM must provide a !! KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine. The interface !! for this is given here (see also KIM::ModelComputeArgumentsCreateFunction, !! \ref KIM_ModelComputeArgumentsCreateFunction). !! !! \code{.f90} !! interface !! recursive subroutine compute_arguments_create( & !! model_compute_handle, model_compute_arguments_create_handle, ierr) & !! bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_compute_handle_type), intent(in) :: model_compute_handle !! type(kim_model_compute_arguments_create_handle_type), intent(in) & !! :: model_compute_arguments_create_handle !! integer(c_int), intent(out) :: ierr !! end subroutine compute_arguments_create !! end interface !! \endcode !! !! \sa KIM::Model::ComputeArgumentsCreate, KIM_Model_ComputeArgumentsCreate !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_create( & model_handle, compute_arguments_handle, ierr) use kim_compute_arguments_module, only: & kim_compute_arguments_handle_type use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function compute_arguments_create( & model, compute_arguments) & bind(c, name="KIM_Model_ComputeArgumentsCreate") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(c_ptr), intent(out) :: compute_arguments end function compute_arguments_create end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_compute_arguments_handle_type), intent(out) :: & compute_arguments_handle integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model type(c_ptr) :: pcompute_arguments call c_f_pointer(model_handle%p, model) ierr = compute_arguments_create(model, pcompute_arguments) if (ierr == 0) then compute_arguments_handle%p = pcompute_arguments end if end subroutine kim_model_compute_arguments_create !> \brief \copybrief KIM::Model::ComputeArgumentsDestroy !! !! A Fortran PM must provide a !! KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine. The interface !! for this is given here (see also !! KIM::ModelComputeArgumentsDestroyFunction, \ref !! KIM_ModelComputeArgumentsDestroyFunction). !! !! \code{.f90} !! interface !! recursive subroutine compute_arguments_destroy( & !! model_compute_handle, model_compute_arguments_destroy_handle, ierr) & !! bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_compute_handle_type), intent(in) :: model_compute_handle !! type(kim_model_compute_arguments_destroy_handle_type), intent(in) & !! :: model_compute_arguments_destroy_handle !! integer(c_int), intent(out) :: ierr !! end subroutine compute_arguments_destroy !! end interface !! \endcode !! !! \sa KIM::Model::ComputeArgumentsDestroy, KIM_Model_ComputeArgumentsDestroy !! !! \since 2.0 recursive subroutine kim_model_compute_arguments_destroy( & model_handle, compute_arguments_handle, ierr) use kim_compute_arguments_module, only: kim_compute_arguments_handle_type use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function compute_arguments_destroy( & model, compute_arguments) & bind(c, name="KIM_Model_ComputeArgumentsDestroy") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(c_ptr), intent(inout) :: compute_arguments end function compute_arguments_destroy end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_compute_arguments_handle_type), intent(inout) :: & compute_arguments_handle integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model type(c_ptr) pcompute_arguments call c_f_pointer(model_handle%p, model) pcompute_arguments = compute_arguments_handle%p ierr = compute_arguments_destroy(model, pcompute_arguments) if (ierr /= 0) then compute_arguments_handle%p = c_null_ptr end if end subroutine kim_model_compute_arguments_destroy !> \brief \copybrief KIM::Model::Compute !! !! A Fortran PM must provide a KIM::MODEL_ROUTINE_NAME::Compute routine. The !! interface for this is given here (see also KIM::ModelComputeFunction, \ref !! KIM_ModelComputeFunction). !! !! \code{.f90} !! interface !! recursive subroutine compute( & !! model_compute_handle, model_compute_arguments_handle, ierr) & !! bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_compute_handle_type), intent(in) :: model_compute_handle !! type(kim_model_compute_arguments_handle_type), intent(in) :: & !! model_compute_arguments_handle !! integer(c_int), intent(out) :: ierr !! end subroutine compute !! end interface !! \endcode !! !! \sa KIM::Model::Compute, KIM_Model_Compute !! !! \since 2.0 recursive subroutine kim_model_compute( & model_handle, compute_arguments_handle, ierr) use kim_compute_arguments_module, only: kim_compute_arguments_handle_type use kim_interoperable_types_module, only: kim_compute_arguments_type, & kim_model_type implicit none interface integer(c_int) recursive function compute(model, compute_arguments) & bind(c, name="KIM_Model_Compute") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_compute_arguments_type use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(kim_compute_arguments_type), intent(in) :: compute_arguments end function compute end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_compute_arguments_handle_type), intent(in) :: & compute_arguments_handle integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model type(kim_compute_arguments_type), pointer :: compute_arguments call c_f_pointer(model_handle%p, model) call c_f_pointer(compute_arguments_handle%p, compute_arguments) ierr = compute(model, compute_arguments) end subroutine kim_model_compute !> \brief \copybrief KIM::Model::Extension !! !! A Fortran PM may provide a KIM::MODEL_ROUTINE_NAME::Extension routine. !! The interface for this is given here (see also !! KIM::ModelExtensionFunction, \ref KIM_ModelExtensionFunction). !! !! \code{.f90} !! interface !! recursive subroutine extension( & !! model_extension_handle, extension_structure, ierr) & !! bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_extension_handle_type), intent(in) :: & !! model_extension_handle !! type(c_ptr), intent(in), value :: extension_structure !! integer(c_int), intent(out) :: ierr !! end subroutine extension !! end interface !! \endcode !! !! \sa KIM::Model::Extension, KIM_Model_Extension !! !! \since 2.0 recursive subroutine kim_model_extension( & model_handle, extension_id, extension_structure, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function extension( & model, extension_id, extension_structure) & bind(c, name="KIM_Model_Extension") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model character(c_char), intent(in) :: extension_id(*) type(c_ptr), intent(in), value :: extension_structure end function extension end interface type(kim_model_handle_type), intent(in) :: model_handle character(len=*, kind=c_char), intent(in) :: extension_id type(c_ptr), intent(in) :: extension_structure integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = extension(model, trim(extension_id)//c_null_char, & extension_structure) end subroutine kim_model_extension !> \brief \copybrief KIM::Model::ClearThenRefresh !! !! A Fortran PM may need to provide a KIM::MODEL_ROUTINE_NAME::Refresh !! routine. The interface for this is given here (see also !! KIM::ModelRefreshFunction, \ref KIM_ModelRefreshFunction). !! !! \code{.f90} !! interface !! recursive subroutine refresh(model_refresh_handle, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle !! integer(c_int), intent(out) :: ierr !! end subroutine refresh !! end interface !! \endcode !! !! \sa KIM::Model::ClearThenRefresh, KIM_Model_ClearThenRefresh !! !! \since 2.0 recursive subroutine kim_model_clear_then_refresh(model_handle, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function clear_then_refresh(model) & bind(c, name="KIM_Model_ClearThenRefresh") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model end function clear_then_refresh end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = clear_then_refresh(model) end subroutine kim_model_clear_then_refresh !> \brief \copybrief KIM::Model::WriteParameterizedModel !! !! A Fortran PM using a MD may provide a !! KIM::MODEL_ROUTINE_NAME::WriteParameterizedMdoel routine. The interface !! for this is given here (see also !! KIM::ModelWriteParameterizedModelFunction, \ref !! KIM_ModelWriteParameterizedModelFunction). !! !! \code{.f90} !! interface !! recursive subroutine write_parameterized_model( & !! model_write_parameterized_model_handle, ierr) bind(c) !! use, intrinsic :: iso_c_binding !! use kim_model_headers_module !! implicit none !! type(kim_model_write_parameterized_model_handle_type), intent(in) & !! :: model_write_parameterized_model_handle !! integer(c_int), intent(out) :: ierr !! end subroutine write_parameterized_model !! end interface !! \endcode !! !! \sa KIM::Model::WriteParameterizedModel, KIM_Model_WriteParameterizedModel !! !! \since 2.0 recursive subroutine kim_model_write_parameterized_model( & model_handle, path, model_name, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function write_parameterized_model( & model, path, model_name) & bind(c, name="KIM_Model_WriteParameterizedModel") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model character(c_char), intent(in) :: path(*) character(c_char), intent(in) :: model_name(*) end function write_parameterized_model end interface type(kim_model_handle_type), intent(in) :: model_handle character(len=*, kind=c_char), intent(in) :: path character(len=*, kind=c_char), intent(in) :: model_name integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = write_parameterized_model(model, trim(path)//c_null_char, & trim(model_name)//c_null_char) end subroutine kim_model_write_parameterized_model !> \brief \copybrief KIM::Model::GetSpeciesSupportAndCode !! !! \sa KIM::Model::GetSpeciesSupportAndCode, !! KIM_Model_GetSpeciesSupportAndCode !! !! \since 2.0 recursive subroutine kim_model_get_species_support_and_code( & model_handle, species_name, species_is_supported, code, ierr) use kim_species_name_module, only: kim_species_name_type use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function get_species_support_and_code( & model, species_name, species_is_supported, code) & bind(c, name="KIM_Model_GetSpeciesSupportAndCode") use, intrinsic :: iso_c_binding use kim_species_name_module, only: kim_species_name_type use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(kim_species_name_type), intent(in), value :: species_name integer(c_int), intent(out) :: species_is_supported integer(c_int), intent(out) :: code end function get_species_support_and_code end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_species_name_type), intent(in) :: species_name integer(c_int), intent(out) :: species_is_supported integer(c_int), intent(out) :: code integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = get_species_support_and_code(model, species_name, & species_is_supported, code) end subroutine kim_model_get_species_support_and_code !> \brief \copybrief KIM::Model::GetNumberOfParameters !! !! \sa KIM::Model::GetNumberOfParameters, KIM_Model_GetNumberOfParameters !! !! \since 2.0 recursive subroutine kim_model_get_number_of_parameters( & model_handle, number_of_parameters) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine get_number_of_parameters( & model, number_of_parameters) & bind(c, name="KIM_Model_GetNumberOfParameters") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(out) :: number_of_parameters end subroutine get_number_of_parameters end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(out) :: number_of_parameters type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call get_number_of_parameters(model, number_of_parameters) end subroutine kim_model_get_number_of_parameters !> \brief \copybrief KIM::Model::GetParameterMetadata !! !! \sa KIM::Model::GetParameterMetadata, KIM_Model_GetParameterMetadata !! !! \since 2.0 recursive subroutine kim_model_get_parameter_metadata( & model_handle, parameter_index, data_type, extent, name, description, ierr) use kim_data_type_module, only: kim_data_type_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function get_parameter_metadata( & model, parameter_index, data_type, extent, name, description) & bind(c, name="KIM_Model_GetParameterMetadata") use, intrinsic :: iso_c_binding use kim_data_type_module, only: kim_data_type_type use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(in), value :: parameter_index type(kim_data_type_type), intent(out) :: data_type integer(c_int), intent(out) :: extent type(c_ptr), intent(out) :: name type(c_ptr), intent(out) :: description end function get_parameter_metadata end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(in) :: parameter_index type(kim_data_type_type), intent(out) :: data_type integer(c_int), intent(out) :: extent character(len=*, kind=c_char), intent(out) :: name character(len=*, kind=c_char), intent(out) :: description integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model type(c_ptr) :: pname, pdesc call c_f_pointer(model_handle%p, model) ierr = get_parameter_metadata(model, parameter_index - 1, data_type, & extent, pname, pdesc) call kim_convert_c_char_ptr_to_string(pname, name) call kim_convert_c_char_ptr_to_string(pdesc, description) end subroutine kim_model_get_parameter_metadata !> \brief \copybrief KIM::Model::GetParameter !! !! \sa KIM::Model::GetParameter, KIM_Model_GetParameterInteger !! !! \since 2.0 recursive subroutine kim_model_get_parameter_integer( & model_handle, parameter_index, array_index, parameter_value, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function get_parameter_integer( & model, parameter_index, array_index, parameter_value) & bind(c, name="KIM_Model_GetParameterInteger") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(in), value :: parameter_index integer(c_int), intent(in), value :: array_index integer(c_int), intent(out) :: parameter_value end function get_parameter_integer end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(in) :: parameter_index integer(c_int), intent(in) :: array_index integer(c_int), intent(out) :: parameter_value integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = get_parameter_integer(model, parameter_index - 1, array_index - 1, & parameter_value) end subroutine kim_model_get_parameter_integer !> \brief \copybrief KIM::Model::GetParameter !! !! \sa KIM::Model::GetParameter, KIM_Model_GetParameterDouble !! !! \since 2.0 recursive subroutine kim_model_get_parameter_double( & model_handle, parameter_index, array_index, parameter_value, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function get_parameter_double( & model, parameter_index, array_index, parameter_value) & bind(c, name="KIM_Model_GetParameterDouble") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(in), value :: parameter_index integer(c_int), intent(in), value :: array_index real(c_double), intent(out) :: parameter_value end function get_parameter_double end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(in) :: parameter_index integer(c_int), intent(in) :: array_index real(c_double), intent(out) :: parameter_value integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = get_parameter_double(model, parameter_index - 1, array_index - 1, & parameter_value) end subroutine kim_model_get_parameter_double !> \brief \copybrief KIM::Model::SetParameter !! !! \sa KIM::Model::SetParameter, KIM_Model_SetParameterInteger !! !! \since 2.0 recursive subroutine kim_model_set_parameter_integer( & model_handle, parameter_index, array_index, parameter_value, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function set_parameter_integer( & model, parameter_index, array_index, parameter_value) & bind(c, name="KIM_Model_SetParameterInteger") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(in), value :: parameter_index integer(c_int), intent(in), value :: array_index integer(c_int), intent(in), value :: parameter_value end function set_parameter_integer end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(in) :: parameter_index integer(c_int), intent(in) :: array_index integer(c_int), intent(in) :: parameter_value integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = set_parameter_integer(model, parameter_index - 1, array_index - 1, & parameter_value) end subroutine kim_model_set_parameter_integer !> \brief \copybrief KIM::Model::SetParameter !! !! \sa KIM::Model::SetParameter, KIM_Model_SetParameterDouble !! !! \since 2.0 recursive subroutine kim_model_set_parameter_double( & model_handle, parameter_index, array_index, parameter_value, ierr) use kim_interoperable_types_module, only: kim_model_type implicit none interface integer(c_int) recursive function set_parameter_double( & model, parameter_index, array_index, parameter_value) & bind(c, name="KIM_Model_SetParameterDouble") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model integer(c_int), intent(in), value :: parameter_index integer(c_int), intent(in), value :: array_index real(c_double), intent(in), value :: parameter_value end function set_parameter_double end interface type(kim_model_handle_type), intent(in) :: model_handle integer(c_int), intent(in) :: parameter_index integer(c_int), intent(in) :: array_index real(c_double), intent(in) :: parameter_value integer(c_int), intent(out) :: ierr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) ierr = set_parameter_double(model, parameter_index - 1, array_index - 1, & parameter_value) end subroutine kim_model_set_parameter_double !> \brief \copybrief KIM::Model::SetSimulatorBufferPointer !! !! \sa KIM::Model::SetSimulatorBufferPointer, !! KIM_Model_SetSimulatorBufferPointer !! !! \since 2.0 recursive subroutine kim_model_set_simulator_buffer_pointer(model_handle, ptr) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine set_simulator_buffer_pointer(model, ptr) & bind(c, name="KIM_Model_SetSimulatorBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(c_ptr), intent(in), value :: ptr end subroutine set_simulator_buffer_pointer end interface type(kim_model_handle_type), intent(in) :: model_handle type(c_ptr), intent(in) :: ptr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call set_simulator_buffer_pointer(model, ptr) end subroutine kim_model_set_simulator_buffer_pointer !> \brief \copybrief KIM::Model::GetSimulatorBufferPointer !! !! \sa KIM::Model::GetSimulatorBufferPointer, !! KIM_Model_GetSimulatorBufferPointer !! !! \since 2.0 recursive subroutine kim_model_get_simulator_buffer_pointer(model_handle, ptr) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine get_simulator_buffer_pointer(model, ptr) & bind(c, name="KIM_Model_GetSimulatorBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(c_ptr), intent(out) :: ptr end subroutine get_simulator_buffer_pointer end interface type(kim_model_handle_type), intent(in) :: model_handle type(c_ptr), intent(out) :: ptr type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call get_simulator_buffer_pointer(model, ptr) end subroutine kim_model_get_simulator_buffer_pointer !> \brief \copybrief KIM::Model::ToString !! !! \sa KIM::Model::ToString, KIM_Model_ToString !! !! \since 2.0 recursive subroutine kim_model_to_string(model_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_type implicit none interface type(c_ptr) recursive function model_string(model) & bind(c, name="KIM_Model_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model end function model_string end interface type(kim_model_handle_type), intent(in) :: model_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_type), pointer :: model type(c_ptr) :: p call c_f_pointer(model_handle%p, model) p = model_string(model) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_to_string !> \brief \copybrief KIM::Model::SetLogID !! !! \sa KIM::Model::SetLogID, KIM_Model_SetLogID !! !! \since 2.0 recursive subroutine kim_model_set_log_id(model_handle, log_id) use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine set_log_id(model, log_id) & bind(c, name="KIM_Model_SetLogID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model character(c_char), intent(in) :: log_id(*) end subroutine set_log_id end interface type(kim_model_handle_type), intent(in) :: model_handle character(len=*, kind=c_char), intent(in) :: log_id type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call set_log_id(model, trim(log_id)//c_null_char) end subroutine kim_model_set_log_id !> \brief \copybrief KIM::Model::PushLogVerbosity !! !! \sa KIM::Model::PushLogVerbosity, KIM_Model_PushLogVerbosity !! !! \since 2.0 recursive subroutine kim_model_push_log_verbosity(model_handle, log_verbosity) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine push_log_verbosity(model, log_verbosity) & bind(c, name="KIM_Model_PushLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model type(kim_log_verbosity_type), intent(in), value :: log_verbosity end subroutine push_log_verbosity end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call push_log_verbosity(model, log_verbosity) end subroutine kim_model_push_log_verbosity !> \brief \copybrief KIM::Model::PopLogVerbosity !! !! \sa KIM::Model::, KIM_Model_PopLogVerbosity !! !! \since 2.0 recursive subroutine kim_model_pop_log_verbosity(model_handle) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_type implicit none interface recursive subroutine pop_log_verbosity(model) & bind(c, name="KIM_Model_PopLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_type implicit none type(kim_model_type), intent(in) :: model end subroutine pop_log_verbosity end interface type(kim_model_handle_type), intent(in) :: model_handle type(kim_model_type), pointer :: model call c_f_pointer(model_handle%p, model) call pop_log_verbosity(model) end subroutine kim_model_pop_log_verbosity end module kim_model_module kim-api-2.3.0-git/fortran/include/kim_model_refresh_module.f90000066400000000000000000000301101421473465500242730ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelRefresh !! !! \sa KIM::ModelRefresh, KIM_ModelRefresh !! !! \since 2.0 module kim_model_refresh_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_refresh_handle_type, & ! Constants KIM_MODEL_REFRESH_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_set_influence_distance_pointer, & kim_set_neighbor_list_pointers, & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelRefresh !! !! \sa KIM::ModelRefresh, KIM_ModelRefresh !! !! \since 2.0 type, bind(c) :: kim_model_refresh_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_refresh_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_refresh_handle_type), protected, save & :: KIM_MODEL_REFRESH_NULL_HANDLE !> \brief Compares kim_model_refresh_handle_type's for equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_refresh_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_refresh_handle_type's for inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_refresh_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelRefresh::SetInfluenceDistancePointer !! !! \sa KIM::ModelRefresh::SetInfluenceDistancePointer, !! KIM_ModelRefresh_SetInfluenceDistancePointer !! !! \since 2.0 interface kim_set_influence_distance_pointer module procedure kim_model_refresh_set_influence_distance_pointer end interface kim_set_influence_distance_pointer !> \brief \copybrief KIM::ModelRefresh::SetNeighborListPointers !! !! \sa KIM::ModelRefresh::SetNeighborListPointers, !! KIM_ModelRefresh_SetNeighborListPointers !! !! \since 2.0 interface kim_set_neighbor_list_pointers module procedure kim_model_refresh_set_neighbor_list_pointers end interface kim_set_neighbor_list_pointers !> \brief \copybrief KIM::ModelRefresh::GetModelBufferPointer !! !! \sa KIM::ModelRefresh::GetModelBufferPointer, !! KIM_ModelRefresh_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure kim_model_refresh_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelRefresh::LogEntry !! !! \sa KIM::ModelRefresh::LogEntry, KIM_ModelRefresh_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_refresh_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelRefresh::ToString !! !! \sa KIM::ModelRefresh::ToString, KIM_ModelRefresh_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_refresh_to_string end interface kim_to_string contains !> \brief Compares kim_model_refresh_handle_type's for equality. !! !! \since 2.0 logical recursive function kim_model_refresh_handle_equal(lhs, rhs) implicit none type(kim_model_refresh_handle_type), intent(in) :: lhs type(kim_model_refresh_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p) .and. c_associated(rhs%p))) then kim_model_refresh_handle_equal = .true. else kim_model_refresh_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_model_refresh_handle_equal !> \brief Compares kim_model_refresh_handle_type's for inequality. !! !! \since 2.0 logical recursive function kim_model_refresh_handle_not_equal(lhs, rhs) implicit none type(kim_model_refresh_handle_type), intent(in) :: lhs type(kim_model_refresh_handle_type), intent(in) :: rhs kim_model_refresh_handle_not_equal = .not. (lhs == rhs) end function kim_model_refresh_handle_not_equal !> \brief \copybrief KIM::ModelRefresh::SetInfluenceDistancePointer !! !! \sa KIM::ModelRefresh::SetInfluenceDistancePointer, !! KIM_ModelRefresh_SetInfluenceDistancePointer !! !! \since 2.0 recursive subroutine kim_model_refresh_set_influence_distance_pointer( & model_refresh_handle, influence_distance) use kim_interoperable_types_module, only: kim_model_refresh_type implicit none interface recursive subroutine set_influence_distance_pointer(model_refresh, & influence_distance) & bind(c, name="KIM_ModelRefresh_SetInfluenceDistancePointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_refresh_type implicit none type(kim_model_refresh_type), intent(in) :: & model_refresh type(c_ptr), intent(in), value :: influence_distance end subroutine set_influence_distance_pointer end interface type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle real(c_double), intent(in), target :: influence_distance type(kim_model_refresh_type), pointer :: model_refresh call c_f_pointer(model_refresh_handle%p, model_refresh) call set_influence_distance_pointer(model_refresh, & c_loc(influence_distance)) end subroutine kim_model_refresh_set_influence_distance_pointer !> \brief \copybrief KIM::ModelRefresh::SetNeighborListPointers !! !! \sa KIM::ModelRefresh::SetNeighborListPointers, !! KIM_ModelRefresh_SetNeighborListPointers !! !! \since 2.0 recursive subroutine kim_model_refresh_set_neighbor_list_pointers( & model_refresh_handle, number_of_neighbor_lists, cutoffs, & modelWillNotRequestNeighborsOfNoncontributingParticles) use kim_interoperable_types_module, only: kim_model_refresh_type implicit none interface recursive subroutine set_neighbor_list_pointers( & model_refresh, number_of_neighbor_lists, cutoffs_ptr, & modelWillNotRequestNeighborsOfNoncontributingParticles) & bind(c, name="KIM_ModelRefresh_SetNeighborListPointers") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_refresh_type implicit none type(kim_model_refresh_type), intent(in) :: & model_refresh integer(c_int), intent(in), value :: number_of_neighbor_lists type(c_ptr), intent(in), value :: cutoffs_ptr type(c_ptr), intent(in), value :: & modelWillNotRequestNeighborsOfNoncontributingParticles end subroutine set_neighbor_list_pointers end interface type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle integer(c_int), intent(in) :: number_of_neighbor_lists real(c_double), intent(in), target :: cutoffs(number_of_neighbor_lists) integer(c_int), intent(in), target :: & modelWillNotRequestNeighborsOfNoncontributingParticles( & number_of_neighbor_lists) type(kim_model_refresh_type), pointer :: model_refresh call c_f_pointer(model_refresh_handle%p, model_refresh) call set_neighbor_list_pointers( & model_refresh, number_of_neighbor_lists, c_loc(cutoffs), & c_loc(modelWillNotRequestNeighborsOfNoncontributingParticles)) end subroutine kim_model_refresh_set_neighbor_list_pointers !> \brief \copybrief KIM::ModelRefresh::GetModelBufferPointer !! !! \sa KIM::ModelRefresh::GetModelBufferPointer, !! KIM_ModelRefresh_GetModelBufferPointer !! !! \since 2.0 recursive subroutine kim_model_refresh_get_model_buffer_pointer( & model_refresh_handle, ptr) use kim_interoperable_types_module, only: kim_model_refresh_type implicit none interface recursive subroutine get_model_buffer_pointer(model_refresh, ptr) & bind(c, name="KIM_ModelRefresh_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_refresh_type implicit none type(kim_model_refresh_type), intent(in) :: & model_refresh type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle type(c_ptr), intent(out) :: ptr type(kim_model_refresh_type), pointer :: model_refresh call c_f_pointer(model_refresh_handle%p, model_refresh) call get_model_buffer_pointer(model_refresh, ptr) end subroutine kim_model_refresh_get_model_buffer_pointer !> \brief \copybrief KIM::ModelRefresh::LogEntry !! !! \sa KIM::ModelRefresh::LogEntry, KIM_ModelRefresh_LogEntry !! !! \since 2.0 recursive subroutine kim_model_refresh_log_entry(model_refresh_handle, & log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_refresh_type implicit none interface recursive subroutine log_entry( & model_refresh, log_verbosity, message, line_number, file_name) & bind(c, name="KIM_ModelRefresh_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_model_refresh_type implicit none type(kim_model_refresh_type), intent(in) :: & model_refresh type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_refresh_type), pointer :: model_refresh call c_f_pointer(model_refresh_handle%p, model_refresh) call log_entry(model_refresh, log_verbosity, trim(message)//c_null_char, & 0, ""//c_null_char) end subroutine kim_model_refresh_log_entry !> \brief \copybrief KIM::ModelRefresh::ToString !! !! \sa KIM::ModelRefresh::ToString, KIM_ModelRefresh_ToString !! !! \since 2.0 recursive subroutine kim_model_refresh_to_string(model_refresh_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_model_refresh_type implicit none interface type(c_ptr) recursive function model_refresh_string(model_refresh) & bind(c, name="KIM_ModelRefresh_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_model_refresh_type implicit none type(kim_model_refresh_type), intent(in) :: & model_refresh end function model_refresh_string end interface type(kim_model_refresh_handle_type), intent(in) :: model_refresh_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_refresh_type), pointer :: model_refresh type(c_ptr) :: p call c_f_pointer(model_refresh_handle%p, model_refresh) p = model_refresh_string(model_refresh) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_refresh_to_string end module kim_model_refresh_module kim-api-2.3.0-git/fortran/include/kim_model_routine_name_module.f90000066400000000000000000000300501421473465500253250ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelRoutineName !! !! \sa KIM::ModelRoutineName, KIM_ModelRoutineName !! !! \since 2.0 module kim_model_routine_name_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_routine_name_type, & ! Constants KIM_MODEL_ROUTINE_NAME_CREATE, & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE, & KIM_MODEL_ROUTINE_NAME_COMPUTE, & KIM_MODEL_ROUTINE_NAME_EXTENSION, & KIM_MODEL_ROUTINE_NAME_REFRESH, & KIM_MODEL_ROUTINE_NAME_WRITE_PARAMETERIZED_MODEL, & KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY, & KIM_MODEL_ROUTINE_NAME_DESTROY, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_model_routine_names, & kim_get_model_routine_name !> \brief \copybrief KIM::ModelRoutineName !! !! \sa KIM::ModelRoutineName, KIM_ModelRoutineName !! !! \since 2.0 type, bind(c) :: kim_model_routine_name_type !> \brief \copybrief KIM::ModelRoutineName::modelRoutineNameID !! !! \sa KIM::ModelRoutineName::modelRoutineNameID, !! KIM_ModelRoutineName::modelRoutineNameID !! !! \since 2.0 integer(c_int) model_routine_name_id end type kim_model_routine_name_type !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Create !! !! \sa KIM::MODEL_ROUTINE_NAME::Create, KIM_MODEL_ROUTINE_NAME_Create !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_Create") & :: KIM_MODEL_ROUTINE_NAME_CREATE !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate !! !! \sa KIM::MODEL_ROUTINE_NAME::ComputeArgumentsCreate, !! KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate") & :: KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_CREATE !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Compute !! !! \sa KIM::MODEL_ROUTINE_NAME::Compute, KIM_MODEL_ROUTINE_NAME_Compute !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_Compute") & :: KIM_MODEL_ROUTINE_NAME_COMPUTE !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Extension !! !! \sa KIM::MODEL_ROUTINE_NAME::Extension, KIM_MODEL_ROUTINE_NAME_Extension !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_Extension") & :: KIM_MODEL_ROUTINE_NAME_EXTENSION !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Refresh !! !! \sa KIM::MODEL_ROUTINE_NAME::Refresh, KIM_MODEL_ROUTINE_NAME_Refresh !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_Refresh") & :: KIM_MODEL_ROUTINE_NAME_REFRESH !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel !! !! \sa KIM::MODEL_ROUTINE_NAME::WriteParameterizedModel, !! KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel") & :: KIM_MODEL_ROUTINE_NAME_WRITE_PARAMETERIZED_MODEL !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy !! !! \sa KIM::MODEL_ROUTINE_NAME::ComputeArgumentsDestroy, !! KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy") & :: KIM_MODEL_ROUTINE_NAME_COMPUTE_ARGUMENTS_DESTROY !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::Destroy !! !! \sa KIM::MODEL_ROUTINE_NAME::Destroy, KIM_MODEL_ROUTINE_NAME_Destroy !! !! \since 2.0 type(kim_model_routine_name_type), protected, save, & bind(c, name="KIM_MODEL_ROUTINE_NAME_Destroy") & :: KIM_MODEL_ROUTINE_NAME_DESTROY !> \brief \copybrief KIM::ModelRoutineName::Known !! !! \sa KIM::ModelRoutineName::Known, KIM_ModelRoutineName_Known !! !! \since 2.0 interface kim_known module procedure kim_model_routine_name_known end interface kim_known !> \brief \copybrief KIM::ModelRoutineName::operator==() !! !! \sa KIM::ModelRoutineName::operator==(), KIM_ModelRoutineName_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_routine_name_equal end interface operator(.eq.) !> \brief \copybrief KIM::ModelRoutineName::operator!=() !! !! \sa KIM::ModelRoutineName::operator!=(), KIM_ModelRoutineName_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_routine_name_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelRoutineName::ModelRoutineName(std::string const &) !! !! \sa KIM::ModelRoutineName::ModelRoutineName(std::string const &), !! KIM_ModelRoutineName_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_model_routine_name_from_string end interface kim_from_string !> \brief \copybrief KIM::ModelRoutineName::ToString !! !! \sa KIM::ModelRoutineName::ToString, KIM_ModelRoutineName_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_routine_name_to_string end interface kim_to_string contains !> \brief \copybrief KIM::ModelRoutineName::Known !! !! \sa KIM::ModelRoutineName::Known, KIM_ModelRoutineName_Known !! !! \since 2.0 logical recursive function kim_model_routine_name_known(model_routine_name) implicit none interface integer(c_int) recursive function known(model_routine_name) & bind(c, name="KIM_ModelRoutineName_Known") use, intrinsic :: iso_c_binding import kim_model_routine_name_type implicit none type(kim_model_routine_name_type), intent(in), value :: & model_routine_name end function known end interface type(kim_model_routine_name_type), intent(in) :: model_routine_name kim_model_routine_name_known = (known(model_routine_name) /= 0) end function kim_model_routine_name_known !> \brief \copybrief KIM::ModelRoutineName::operator==() !! !! \sa KIM::ModelRoutineName::operator==(), KIM_ModelRoutineName_Equal !! !! \since 2.0 logical recursive function kim_model_routine_name_equal(lhs, rhs) implicit none type(kim_model_routine_name_type), intent(in) :: lhs type(kim_model_routine_name_type), intent(in) :: rhs kim_model_routine_name_equal & = (lhs%model_routine_name_id == rhs%model_routine_name_id) end function kim_model_routine_name_equal !> \brief \copybrief KIM::ModelRoutineName::operator!=() !! !! \sa KIM::ModelRoutineName::operator!=(), KIM_ModelRoutineName_NotEqual !! !! \since 2.0 logical recursive function kim_model_routine_name_not_equal(lhs, rhs) implicit none type(kim_model_routine_name_type), intent(in) :: lhs type(kim_model_routine_name_type), intent(in) :: rhs kim_model_routine_name_not_equal = .not. (lhs == rhs) end function kim_model_routine_name_not_equal !> \brief \copybrief KIM::ModelRoutineName::ModelRoutineName(std::string const &) !! !! \sa KIM::ModelRoutineName::ModelRoutineName(std::string const &), !! KIM_ModelRoutineName_FromString !! !! \since 2.0 recursive subroutine kim_model_routine_name_from_string(string, & model_routine_name) implicit none interface type(kim_model_routine_name_type) recursive function from_string(string) & bind(c, name="KIM_ModelRoutineName_FromString") use, intrinsic :: iso_c_binding import kim_model_routine_name_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_model_routine_name_type), intent(out) :: model_routine_name model_routine_name = from_string(trim(string)//c_null_char) end subroutine kim_model_routine_name_from_string !> \brief \copybrief KIM::ModelRoutineName::ToString !! !! \sa KIM::ModelRoutineName::ToString, KIM_ModelRoutineName_ToString !! !! \since 2.0 recursive subroutine kim_model_routine_name_to_string(model_routine_name, & string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(model_routine_name) & bind(c, name="KIM_ModelRoutineName_ToString") use, intrinsic :: iso_c_binding import kim_model_routine_name_type implicit none type(kim_model_routine_name_type), intent(in), value :: & model_routine_name end function get_string end interface type(kim_model_routine_name_type), intent(in) :: & model_routine_name character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(model_routine_name) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_routine_name_to_string !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames !! !! \sa KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames, !! KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames !! !! \since 2.0 recursive subroutine kim_get_number_of_model_routine_names( & number_of_model_routine_names) implicit none interface recursive subroutine get_number_of_model_routine_names( & number_of_model_routine_names) & bind(c, name="KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames") use, intrinsic :: iso_c_binding integer(c_int), intent(out) :: number_of_model_routine_names end subroutine get_number_of_model_routine_names end interface integer(c_int), intent(out) :: number_of_model_routine_names call get_number_of_model_routine_names(number_of_model_routine_names) end subroutine kim_get_number_of_model_routine_names !> \brief \copybrief KIM::MODEL_ROUTINE_NAME::GetModelRoutineName !! !! \sa KIM::MODEL_ROUTINE_NAME::GetModelRoutineName, !! KIM_MODEL_ROUTINE_NAME_GetModelRoutineName !! !! \since 2.0 recursive subroutine kim_get_model_routine_name(index, & model_routine_name, ierr) implicit none interface integer(c_int) recursive function get_model_routine_name( & index, model_routine_name) & bind(c, name="KIM_MODEL_ROUTINE_NAME_GetModelRoutineName") use, intrinsic :: iso_c_binding import kim_model_routine_name_type implicit none integer(c_int), intent(in), value :: index type(kim_model_routine_name_type), intent(out) :: & model_routine_name end function get_model_routine_name end interface integer(c_int), intent(in) :: index type(kim_model_routine_name_type), intent(out) :: model_routine_name integer(c_int), intent(out) :: ierr ierr = get_model_routine_name(index - 1, model_routine_name) end subroutine kim_get_model_routine_name end module kim_model_routine_name_module kim-api-2.3.0-git/fortran/include/kim_model_write_parameterized_model_module.f90000066400000000000000000000377721421473465500301100ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::ModelWriteParameterizedModel !! !! \sa KIM::ModelWriteParameterizedModel, KIM_ModelWriteParameterizedModel !! !! \since 2.0 module kim_model_write_parameterized_model_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_model_write_parameterized_model_handle_type, & ! Constants KIM_MODEL_WRITE_PARAMETERIZED_MODEL_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_get_path, & kim_get_model_name, & kim_set_parameter_file_name, & kim_get_model_buffer_pointer, & kim_log_entry, & kim_to_string !> \brief \copybrief KIM::ModelWriteParameterizedModel !! !! \sa KIM::ModelWriteParameterizedModel, KIM_ModelWriteParameterizedModel !! !! \since 2.0 type, bind(c) :: kim_model_write_parameterized_model_handle_type type(c_ptr) :: p = c_null_ptr end type kim_model_write_parameterized_model_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.0 type(kim_model_write_parameterized_model_handle_type), protected, save & :: KIM_MODEL_WRITE_PARAMETERIZED_MODEL_NULL_HANDLE !> \brief Compares kim_model_write_parameterized_model_handle_type's for !! equality. !! !! \since 2.0 interface operator(.eq.) module procedure kim_model_write_parameterized_model_handle_equal end interface operator(.eq.) !> \brief Compares kim_model_write_parameterized_model_handle_type's for !! inequality. !! !! \since 2.0 interface operator(.ne.) module procedure kim_model_write_parameterized_model_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::ModelWriteParameterizedModel::GetPath !! !! \sa KIM::ModelWriteParameterizedModel::GetPath, !! KIM_ModelWriteParameterizedModel_GetPath !! !! \since 2.0 interface kim_get_path module procedure kim_model_write_parameterized_model_get_path end interface kim_get_path !> \brief \copybrief KIM::ModelWriteParameterizedModel::GetModelName !! !! \sa KIM::ModelWriteParameterizedModel::GetModelName, !! KIM_ModelWriteParameterizedModel_GetModelName !! !! \since 2.0 interface kim_get_model_name module procedure kim_model_write_parameterized_model_get_model_name end interface kim_get_model_name !> \brief \copybrief KIM::ModelWriteParameterizedModel::SetParameterFileName !! !! \sa KIM::ModelWriteParameterizedModel::SetParameterFileName, !! KIM_ModelWriteParameterizedModel_SetParameterFileName !! !! \since 2.0 interface kim_set_parameter_file_name module procedure kim_model_write_parameterized_model_set_parameter_file_name end interface kim_set_parameter_file_name !> \brief \copybrief KIM::ModelWriteParameterizedModel::GetModelBufferPointer !! !! \sa KIM::ModelWriteParameterizedModel::GetModelBufferPointer, !! KIM_ModelWriteParameterizedModel_GetModelBufferPointer !! !! \since 2.0 interface kim_get_model_buffer_pointer module procedure & kim_model_write_parameterized_model_get_model_buffer_pointer end interface kim_get_model_buffer_pointer !> \brief \copybrief KIM::ModelWriteParameterizedModel::LogEntry !! !! \sa KIM::ModelWriteParameterizedModel::LogEntry, !! KIM_ModelWriteParameterizedModel_LogEntry !! !! \since 2.0 interface kim_log_entry module procedure kim_model_write_parameterized_model_log_entry end interface kim_log_entry !> \brief \copybrief KIM::ModelWriteParameterizedModel::ToString !! !! \sa KIM::ModelWriteParameterizedModel::ToString, !! KIM_ModelWriteParameterizedModel_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_model_write_parameterized_model_to_string end interface kim_to_string contains !> \brief Compares kim_model_write_parameterized_model_handle_type's for !! equality. !! !! \since 2.0 logical recursive function kim_model_write_parameterized_model_handle_equal( & lhs, rhs) implicit none type(kim_model_write_parameterized_model_handle_type), intent(in) :: lhs type(kim_model_write_parameterized_model_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_model_write_parameterized_model_handle_equal = .true. else kim_model_write_parameterized_model_handle_equal = & c_associated(lhs%p, rhs%p) end if end function kim_model_write_parameterized_model_handle_equal !> \brief Compares kim_model_write_parameterized_model_handle_type's for !! inequality. !! !! \since 2.0 logical recursive function & kim_model_write_parameterized_model_handle_not_equal(lhs, rhs) implicit none type(kim_model_write_parameterized_model_handle_type), intent(in) :: lhs type(kim_model_write_parameterized_model_handle_type), intent(in) :: rhs kim_model_write_parameterized_model_handle_not_equal = .not. (lhs == rhs) end function kim_model_write_parameterized_model_handle_not_equal !> \brief \copybrief KIM::ModelWriteParameterizedModel::GetPath !! !! \sa KIM::ModelWriteParameterizedModel::GetPath, !! KIM_ModelWriteParameterizedModel_GetPath !! !! \since 2.0 recursive subroutine kim_model_write_parameterized_model_get_path( & model_write_parameterized_model_handle, path) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none interface recursive subroutine get_path(model_write_parameterized_model, path) & bind(c, name="KIM_ModelWriteParameterizedModel_GetPath") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none type(kim_model_write_parameterized_model_type), intent(in) & :: model_write_parameterized_model type(c_ptr), intent(out) :: path end subroutine get_path end interface type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle character(len=*, kind=c_char), intent(out) :: path type(kim_model_write_parameterized_model_type), pointer & :: model_write_parameterized_model type(c_ptr) :: ppath call c_f_pointer(model_write_parameterized_model_handle%p, & model_write_parameterized_model) call get_path(model_write_parameterized_model, ppath) call kim_convert_c_char_ptr_to_string(ppath, path) end subroutine kim_model_write_parameterized_model_get_path !> \brief \copybrief KIM::ModelWriteParameterizedModel::GetModelName !! !! \sa KIM::ModelWriteParameterizedModel::GetModelName, !! KIM_ModelWriteParameterizedModel_GetModelName !! !! \since 2.0 recursive subroutine kim_model_write_parameterized_model_get_model_name( & model_write_parameterized_model_handle, model_name) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none interface recursive subroutine get_model_name(model_write_parameterized_model, & model_name) & bind(c, name="KIM_ModelWriteParameterizedModel_GetModelName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none type(kim_model_write_parameterized_model_type), intent(in) & :: model_write_parameterized_model type(c_ptr), intent(out) :: model_name end subroutine get_model_name end interface type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle character(len=*, kind=c_char), intent(out) :: model_name type(kim_model_write_parameterized_model_type), pointer & :: model_write_parameterized_model type(c_ptr) :: pmodel_name call c_f_pointer(model_write_parameterized_model_handle%p, & model_write_parameterized_model) call get_model_name(model_write_parameterized_model, pmodel_name) call kim_convert_c_char_ptr_to_string(pmodel_name, model_name) end subroutine kim_model_write_parameterized_model_get_model_name !> \brief \copybrief KIM::ModelWriteParameterizedModel::SetParameterFileName !! !! \sa KIM::ModelWriteParameterizedModel::SetParameterFileName, !! KIM_ModelWriteParameterizedModel_SetParameterFileName !! !! \since 2.0 recursive subroutine & kim_model_write_parameterized_model_set_parameter_file_name( & model_write_parameterized_model_handle, file_name) use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none interface recursive subroutine set_parameter_file_name( & model_write_parameterized_model, file_name) & bind(c, name="KIM_ModelWriteParameterizedModel_SetParameterFileName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none type(kim_model_write_parameterized_model_type), intent(in) & :: model_write_parameterized_model character(c_char), intent(in) :: file_name(*) end subroutine set_parameter_file_name end interface type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle character(len=*, kind=c_char), intent(in) :: file_name type(kim_model_write_parameterized_model_type), pointer & :: model_write_parameterized_model call c_f_pointer(model_write_parameterized_model_handle%p, & model_write_parameterized_model) call set_parameter_file_name(model_write_parameterized_model, & trim(file_name)//c_null_char) end subroutine kim_model_write_parameterized_model_set_parameter_file_name !> \brief \copybrief KIM::ModelWriteParameterizedModel::GetModelBufferPointer !! !! \sa KIM::ModelWriteParameterizedModel::GetModelBufferPointer, !! KIM_ModelWriteParameterizedModel_GetModelBufferPointer !! !! \since 2.0 recursive subroutine & kim_model_write_parameterized_model_get_model_buffer_pointer( & model_write_parameterized_model_handle, ptr) use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none interface recursive subroutine get_model_buffer_pointer( & model_write_parameterized_model, ptr) & bind(c, name="KIM_ModelCompute_GetModelBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none type(kim_model_write_parameterized_model_type), intent(in) & :: model_write_parameterized_model type(c_ptr), intent(out) :: ptr end subroutine get_model_buffer_pointer end interface type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle type(c_ptr), intent(out) :: ptr type(kim_model_write_parameterized_model_type), pointer & :: model_write_parameterized_model call c_f_pointer(model_write_parameterized_model_handle%p, & model_write_parameterized_model) call get_model_buffer_pointer(model_write_parameterized_model, ptr) end subroutine kim_model_write_parameterized_model_get_model_buffer_pointer !> \brief \copybrief KIM::ModelWriteParameterizedModel::LogEntry !! !! \sa KIM::ModelWriteParameterizedModel::LogEntry, !! KIM_ModelWriteParameterizedModel_LogEntry !! !! \since 2.0 recursive subroutine kim_model_write_parameterized_model_log_entry( & model_write_parameterized_model_handle, log_verbosity, message) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none interface recursive subroutine log_entry( & model_write_parameterized_model, log_verbosity, message, line_number, & file_name) bind(c, name="KIM_ModelCompute_LogEntry") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none type(kim_model_write_parameterized_model_type), intent(in) & :: model_write_parameterized_model type(kim_log_verbosity_type), intent(in), value :: log_verbosity character(c_char), intent(in) :: message(*) integer(c_int), intent(in), value :: line_number character(c_char), intent(in) :: file_name(*) end subroutine log_entry end interface type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity character(len=*, kind=c_char), intent(in) :: message type(kim_model_write_parameterized_model_type), pointer & :: model_write_parameterized_model call c_f_pointer(model_write_parameterized_model_handle%p, & model_write_parameterized_model) call log_entry(model_write_parameterized_model, log_verbosity, & trim(message)//c_null_char, 0, ""//c_null_char) end subroutine kim_model_write_parameterized_model_log_entry !> \brief \copybrief KIM::ModelWriteParameterizedModel::ToString !! !! \sa KIM::ModelWriteParameterizedModel::ToString, !! KIM_ModelWriteParameterizedModel_ToString !! !! \since 2.0 recursive subroutine kim_model_write_parameterized_model_to_string( & model_write_parameterized_model_handle, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none interface type(c_ptr) recursive function model_write_parameterized_model_string( & model_write_parameterized_model) & bind(c, name="KIM_ModelCompute_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: & kim_model_write_parameterized_model_type implicit none type(kim_model_write_parameterized_model_type), intent(in) & :: model_write_parameterized_model end function model_write_parameterized_model_string end interface type(kim_model_write_parameterized_model_handle_type), intent(in) & :: model_write_parameterized_model_handle character(len=*, kind=c_char), intent(out) :: string type(kim_model_write_parameterized_model_type), pointer & :: model_write_parameterized_model type(c_ptr) :: p call c_f_pointer(model_write_parameterized_model_handle%p, & model_write_parameterized_model) p = model_write_parameterized_model_string(model_write_parameterized_model) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_model_write_parameterized_model_to_string end module kim_model_write_parameterized_model_module kim-api-2.3.0-git/fortran/include/kim_numbering_module.f90000066400000000000000000000201251421473465500234500ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::Numbering !! !! \sa KIM::Numbering, KIM_Numbering !! !! \since 2.0 module kim_numbering_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_numbering_type, & ! Constants KIM_NUMBERING_ZERO_BASED, & KIM_NUMBERING_ONE_BASED, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_numberings, & kim_get_numbering !> \brief \copybrief KIM::Numbering !! !! \sa KIM::Numbering, KIM_Numbering !! !! \since 2.0 type, bind(c) :: kim_numbering_type integer(c_int) :: numbering_id end type kim_numbering_type !> \brief \copybrief KIM::NUMBERING::zeroBased !! !! \sa KIM::NUMBERING::zeroBased, KIM_NUMBERING_zeroBased !! !! \since 2.0 type(kim_numbering_type), protected, save, & bind(c, name="KIM_NUMBERING_zeroBased") & :: KIM_NUMBERING_ZERO_BASED !> \brief \copybrief KIM::NUMBERING::oneBased !! !! \sa KIM::NUMBERING::oneBased, KIM_NUMBERING_oneBased !! !! \since 2.0 type(kim_numbering_type), protected, save, & bind(c, name="KIM_NUMBERING_oneBased") & :: KIM_NUMBERING_ONE_BASED !> \brief \copybrief KIM::Numbering::Known !! !! \sa KIM::Numbering::Known, KIM_Numbering_Known !! !! \since 2.0 interface kim_known module procedure kim_numbering_known end interface kim_known !> \brief \copybrief KIM::Numbering::operator==() !! !! \sa KIM::Numbering::operator==(), KIM_Numbering_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_numbering_equal end interface operator(.eq.) !> \brief \copybrief KIM::Numbering::operator!=() !! !! \sa KIM::Numbering::operator!=(), KIM_Numbering_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_numbering_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::Numbering::Numbering(std::string const &) !! !! \sa KIM::Numbering::Numbering(std::string const &), !! KIM_Numbering_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_numbering_from_string end interface kim_from_string !> \brief \copybrief KIM::Numbering::ToString !! !! \sa KIM::Numbering::ToString, KIM_Numbering_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_numbering_to_string end interface kim_to_string contains !> \brief \copybrief KIM::Numbering::Known !! !! \sa KIM::Numbering::Known, KIM_Numbering_Known !! !! \since 2.0 logical recursive function kim_numbering_known(numbering) implicit none interface integer(c_int) recursive function known(numbering) & bind(c, name="KIM_Numbering_Known") use, intrinsic :: iso_c_binding import kim_numbering_type implicit none type(kim_numbering_type), intent(in), value :: numbering end function known end interface type(kim_numbering_type), intent(in) :: numbering kim_numbering_known = (known(numbering) /= 0) end function kim_numbering_known !> \brief \copybrief KIM::Numbering::operator==() !! !! \sa KIM::Numbering::operator==(), KIM_Numbering_Equal !! !! \since 2.0 logical recursive function kim_numbering_equal(lhs, rhs) implicit none type(kim_numbering_type), intent(in) :: lhs type(kim_numbering_type), intent(in) :: rhs kim_numbering_equal = (lhs%numbering_id == rhs%numbering_id) end function kim_numbering_equal !> \brief \copybrief KIM::Numbering::operator!=() !! !! \sa KIM::Numbering::operator!=(), KIM_Numbering_NotEqual !! !! \since 2.0 logical recursive function kim_numbering_not_equal(lhs, rhs) implicit none type(kim_numbering_type), intent(in) :: lhs type(kim_numbering_type), intent(in) :: rhs kim_numbering_not_equal = .not. (lhs == rhs) end function kim_numbering_not_equal !> \brief \copybrief KIM::Numbering::Numbering(std::string const &) !! !! \sa KIM::Numbering::Numbering(std::string const &), !! KIM_Numbering_FromString !! !! \since 2.0 recursive subroutine kim_numbering_from_string(string, numbering) implicit none interface type(kim_numbering_type) recursive function from_string(string) & bind(c, name="KIM_Numbering_FromString") use, intrinsic :: iso_c_binding import kim_numbering_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_numbering_type), intent(out) :: numbering numbering = from_string(trim(string)//c_null_char) end subroutine kim_numbering_from_string !> \brief \copybrief KIM::Numbering::ToString !! !! \sa KIM::Numbering::ToString, KIM_Numbering_ToString !! !! \since 2.0 recursive subroutine kim_numbering_to_string(numbering, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(numbering) & bind(c, name="KIM_Numbering_ToString") use, intrinsic :: iso_c_binding import kim_numbering_type implicit none type(kim_numbering_type), intent(in), value :: numbering end function get_string end interface type(kim_numbering_type), intent(in) :: numbering character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(numbering) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_numbering_to_string !> \brief \copybrief KIM::NUMBERING::GetNumberOfNumberings !! !! \sa KIM::NUMBERING::GetNumberOfNumberings, !! KIM_NUMBERING_GetNumberOfNumberings !! !! \since 2.0 recursive subroutine kim_get_number_of_numberings(number_of_numberings) implicit none interface recursive subroutine get_number_of_numberings(number_of_numberings) & bind(c, name="KIM_NUMBERING_GetNumberOfNumberings") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_numberings end subroutine get_number_of_numberings end interface integer(c_int), intent(out) :: number_of_numberings call get_number_of_numberings(number_of_numberings) end subroutine kim_get_number_of_numberings !> \brief \copybrief KIM::NUMBERING::GetNumbering !! !! \sa KIM::NUMBERING::GetNumbering, KIM_NUMBERING_GetNumbering !! !! \since 2.0 recursive subroutine kim_get_numbering(index, numbering, ierr) implicit none interface integer(c_int) recursive function get_numbering(index, numbering) & bind(c, name="KIM_NUMBERING_GetNumbering") use, intrinsic :: iso_c_binding import kim_numbering_type implicit none integer(c_int), intent(in), value :: index type(kim_numbering_type), intent(out) :: numbering end function get_numbering end interface integer(c_int), intent(in) :: index type(kim_numbering_type), intent(out) :: numbering integer(c_int), intent(out) :: ierr ierr = get_numbering(index - 1, numbering) end subroutine kim_get_numbering end module kim_numbering_module kim-api-2.3.0-git/fortran/include/kim_sem_ver_module.f90000066400000000000000000000120671421473465500231300ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::SEM_VER !! !! \sa KIM::SEM_VER !! !! \since 2.0 module kim_sem_ver_module use, intrinsic :: iso_c_binding implicit none private public & ! Routines kim_get_sem_ver, & kim_is_less_than, & kim_parse_sem_ver contains !> \brief \copybrief KIM::SEM_VER::GetSemVer !! !! \sa KIM::SEM_VER::GetSemVer, KIM_SEM_VER_GetSemVer !! !! \since 2.0 recursive subroutine kim_get_sem_ver(version) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_sem_ver() & bind(c, name="KIM_SEM_VER_GetSemVer") use, intrinsic :: iso_c_binding implicit none end function get_sem_ver end interface character(len=*, kind=c_char), intent(out) :: version type(c_ptr) :: p p = get_sem_ver() call kim_convert_c_char_ptr_to_string(p, version) end subroutine kim_get_sem_ver !> \brief \copybrief KIM::SEM_VER::IsLessThan !! !! \sa KIM::SEM_VER::IsLessThan, KIM_SEM_VER_IsLessThan !! !! \since 2.0 recursive subroutine kim_is_less_than(lhs, rhs, is_less_than, ierr) implicit none interface integer(c_int) recursive function is_less_than_func(lhs, rhs, & is_less_than) & bind(c, name="KIM_SEM_VER_IsLessThan") use, intrinsic :: iso_c_binding implicit none character(c_char), intent(in) :: lhs(*) character(c_char), intent(in) :: rhs(*) integer(c_int), intent(out) :: is_less_than end function is_less_than_func end interface character(len=*, kind=c_char), intent(in) :: lhs character(len=*, kind=c_char), intent(in) :: rhs integer(c_int), intent(out) :: is_less_than integer(c_int), intent(out) :: ierr ierr = is_less_than_func(trim(lhs)//c_null_char, trim(rhs)//c_null_char, & is_less_than) end subroutine kim_is_less_than !> \brief \copybrief KIM::SEM_VER::ParseSemVer !! !! \sa KIM::SEM_VER::ParseSemVer, KIM_SEM_VER_ParseSemVer !! !! \since 2.0 recursive subroutine kim_parse_sem_ver(version, major, minor, patch, & prerelease, build_metadata, ierr) use kim_convert_string_module, only: kim_convert_c_char_array_to_string implicit none interface integer(c_int) recursive function parse_sem_ver( & version, prerelease_length, build_metadata_length, major, minor, & patch, prerelease, build_metadata) & bind(c, name="KIM_SEM_VER_ParseSemVer") use, intrinsic :: iso_c_binding implicit none character(c_char), intent(in) :: version(*) integer(c_int), intent(in), value :: prerelease_length integer(c_int), intent(in), value :: build_metadata_length integer(c_int), intent(out) :: major integer(c_int), intent(out) :: minor integer(c_int), intent(out) :: patch type(c_ptr), intent(in), value :: prerelease type(c_ptr), intent(in), value :: build_metadata end function parse_sem_ver end interface character(len=*, kind=c_char), intent(in) :: version integer(c_int), intent(out) :: major integer(c_int), intent(out) :: minor integer(c_int), intent(out) :: patch character(len=*, kind=c_char), intent(out) :: prerelease character(len=*, kind=c_char), intent(out) :: build_metadata integer(c_int), intent(out) :: ierr character(len=1, kind=c_char), target :: prerelease_local(len(prerelease)) character(len=1, kind=c_char), target :: & build_metadata_local(len(build_metadata)) ierr = parse_sem_ver(trim(version)//c_null_char, len(prerelease), & len(build_metadata), major, minor, patch, & c_loc(prerelease_local), c_loc(build_metadata_local)) call kim_convert_c_char_array_to_string(prerelease_local, prerelease) call kim_convert_c_char_array_to_string(build_metadata_local, & build_metadata) end subroutine kim_parse_sem_ver end module kim_sem_ver_module kim-api-2.3.0-git/fortran/include/kim_simulator_headers_module.f90000066400000000000000000000034651421473465500252040ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! module kim_simulator_headers_module use, intrinsic :: iso_c_binding use kim_collections_module use kim_collection_module use kim_collection_item_type_module use kim_model_module use kim_simulator_model_module use kim_log_verbosity_module use kim_data_type_module use kim_language_name_module use kim_model_routine_name_module use kim_species_name_module use kim_numbering_module use kim_unit_system_module use kim_compute_arguments_module use kim_compute_argument_name_module use kim_compute_callback_name_module use kim_support_status_module use kim_model_extension_module, only: kim_c_char_array_to_string use kim_model_extension_module, only: kim_c_char_ptr_to_string use kim_model_extension_module, only: kim_string_to_c_char_array public end module kim_simulator_headers_module kim-api-2.3.0-git/fortran/include/kim_simulator_model_module.f90000066400000000000000000001262431421473465500246710ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::SimulatorModel !! !! \sa KIM::SimulatorModel, KIM_SimulatorModel !! !! \since 2.1 module kim_simulator_model_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_simulator_model_handle_type, & ! Constants KIM_SIMULATOR_MODEL_NULL_HANDLE, & ! Routines operator(.eq.), & operator(.ne.), & kim_simulator_model_create, & kim_simulator_model_destroy, & kim_get_simulator_name_and_version, & kim_get_number_of_supported_species, & kim_get_supported_species, & kim_open_and_initialize_template_map, & kim_template_map_is_open, & kim_add_template_map, & kim_close_template_map, & kim_get_number_of_simulator_fields, & kim_get_simulator_field_metadata, & kim_get_simulator_field_line, & kim_get_parameter_file_directory_name, & kim_get_specification_file_name, & kim_get_number_of_parameter_files, & kim_get_parameter_file_name, & kim_get_parameter_file_basename, & kim_set_simulator_buffer_pointer, & kim_get_simulator_buffer_pointer, & kim_to_string, & kim_set_log_id, & kim_push_log_verbosity, & kim_pop_log_verbosity !> \brief \copybrief KIM::SimulatorModel !! !! \sa KIM::SimulatorModel, KIM_SimulatorModel !! !! \since 2.1 type, bind(c) :: kim_simulator_model_handle_type type(c_ptr) :: p = c_null_ptr end type kim_simulator_model_handle_type !> \brief NULL handle for use in comparisons. !! !! \since 2.1 type(kim_simulator_model_handle_type), protected, save & :: KIM_SIMULATOR_MODEL_NULL_HANDLE !> \brief Compares kim_simulator_model_handle_type's for equality. !! !! \since 2.1 interface operator(.eq.) module procedure kim_simulator_model_handle_equal end interface operator(.eq.) !> \brief Compares kim_simulator_model_handle_type's for inequality. !! !! \since 2.1 interface operator(.ne.) module procedure kim_simulator_model_handle_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::SimulatorModel::GetSimulatorNameAndVersion !! !! \sa KIM::SimulatorModel::GetSimulatorNameAndVersion, !! KIM_SimulatorModel_GetSimulatorNameAndVersion !! !! \since 2.1 interface kim_get_simulator_name_and_version module procedure kim_simulator_model_get_simulator_name_and_version end interface kim_get_simulator_name_and_version !> \brief \copybrief KIM::SimulatorModel::GetNumberOfSupportedSpecies !! !! \sa KIM::SimulatorModel::GetNumberOfSupportedSpecies, !! KIM_SimulatorModel_GetNumberOfSupportedSpecies !! !! \since 2.1 interface kim_get_number_of_supported_species module procedure kim_simulator_model_get_number_of_supported_species end interface kim_get_number_of_supported_species !> \brief \copybrief KIM::SimulatorModel::GetSupportedSpecies !! !! \sa KIM::SimulatorModel::GetSupportedSpecies, !! KIM_SimulatorModel_GetSupportedSpecies !! !! \since 2.1 interface kim_get_supported_species module procedure kim_simulator_model_get_supported_species end interface kim_get_supported_species !> \brief \copybrief KIM::SimulatorModel::OpenAndInitializeTemplateMap !! !! \sa KIM::SimulatorModel::OpenAndInitializeTemplateMap, !! KIM_SimulatorModel_OpenAndInitializeTemplateMap !! !! \since 2.1 interface kim_open_and_initialize_template_map module procedure kim_simulator_model_open_and_initialize_template_map end interface kim_open_and_initialize_template_map !> \brief \copybrief KIM::SimulatorModel::TemplateMapIsOpen !! !! \sa KIM::SimulatorModel::TemplateMapIsOpen, !! KIM_SimulatorModel_TemplateMapIsOpen !! !! \since 2.1 interface kim_template_map_is_open module procedure kim_simulator_model_template_map_is_open end interface kim_template_map_is_open !> \brief \copybrief KIM::SimulatorModel::AddTemplateMap !! !! \sa KIM::SimulatorModel::AddTemplateMap, KIM_SimulatorModel_AddTemplateMap !! !! \since 2.1 interface kim_add_template_map module procedure kim_simulator_model_add_template_map end interface kim_add_template_map !> \brief \copybrief KIM::SimulatorModel::CloseTemplateMap !! !! \sa KIM::SimulatorModel::CloseTemplateMap, !! KIM_SimulatorModel_CloseTemplateMap !! !! \since 2.1 interface kim_close_template_map module procedure kim_simulator_model_close_template_map end interface kim_close_template_map !> \brief \copybrief KIM::SimulatorModel::GetNumberOfSimulatorFields !! !! \sa KIM::SimulatorModel::GetNumberOfSimulatorFields, !! KIM_SimulatorModel_GetNumberOfSimulatorFields !! !! \since 2.1 interface kim_get_number_of_simulator_fields module procedure kim_simulator_model_get_number_of_simulator_fields end interface kim_get_number_of_simulator_fields !> \brief \copybrief KIM::SimulatorModel::GetSimulatorFieldMetadata !! !! \sa KIM::SimulatorModel::GetSimulatorFieldMetadata, !! KIM_SimulatorModel_GetSimulatorFieldMetadata !! !! \since 2.1 interface kim_get_simulator_field_metadata module procedure kim_simulator_model_get_simulator_field_metadata end interface kim_get_simulator_field_metadata !> \brief \copybrief KIM::SimulatorModel::GetSimulatorFieldLine !! !! \sa KIM::SimulatorModel::GetSimulatorFieldLine, !! KIM_SimulatorModel_GetSimulatorFieldLine !! !! \since 2.1 interface kim_get_simulator_field_line module procedure kim_simulator_model_get_simulator_field_line end interface kim_get_simulator_field_line !> \brief \copybrief KIM::SimulatorModel::GetParameterFileDirectoryName !! !! \sa KIM::SimulatorModel::GetParameterFileDirectoryName, !! KIM_SimulatorModel_GetParameterFileDirectoryName !! !! \since 2.1 interface kim_get_parameter_file_directory_name module procedure kim_simulator_model_get_parameter_file_directory_name end interface kim_get_parameter_file_directory_name !> \brief \copybrief KIM::SimulatorModel::GetSpecificationFileName !! !! \sa KIM::SimulatorModel::GetSpecificationFileName, !! KIM_SimulatorModel_GetSpecificationFileName !! !! \since 2.1 interface kim_get_specification_file_name module procedure kim_simulator_model_get_specification_file_name end interface kim_get_specification_file_name !> \brief \copybrief KIM::SimulatorModel::GetNumberOfParameterFiles !! !! \sa KIM::SimulatorModel::GetNumberOfParameterFiles, !! KIM_SimulatorModel_GetNumberOfParameterFiles !! !! \since 2.1 interface kim_get_number_of_parameter_files module procedure kim_simulator_model_get_number_of_parameter_files end interface kim_get_number_of_parameter_files !> \brief \copybrief KIM::SimulatorModel::GetParameterFileName !! !! \sa KIM::SimulatorModel::GetParameterFileName, !! KIM_SimulatorModel_GetParameterFileName !! !! \since 2.1 !! !! \deprecated As of 2.2. Please use !! kim_simulator_model_module::kim_get_parameter_file_basename() instead. interface kim_get_parameter_file_name module procedure kim_simulator_model_get_parameter_file_name end interface kim_get_parameter_file_name !> \brief \copybrief KIM::SimulatorModel::GetParameterFileBasename !! !! \sa KIM::SimulatorModel::GetParameterFileBasename, !! KIM_SimulatorModel_GetParameterFileBasename !! !! \since 2.2 interface kim_get_parameter_file_basename module procedure kim_simulator_model_get_parameter_file_basename end interface kim_get_parameter_file_basename !> \brief \copybrief KIM::SimulatorModel::SetSimulatorBufferPointer !! !! \sa KIM::SimulatorModel::SetSimulatorBufferPointer, !! KIM_SimulatorModel_SetSimulatorBufferPointer !! !! \since 2.1 interface kim_set_simulator_buffer_pointer module procedure kim_simulator_model_set_simulator_buffer_pointer end interface kim_set_simulator_buffer_pointer !> \brief \copybrief KIM::SimulatorModel::GetSimulatorBufferPointer !! !! \sa KIM::SimulatorModel::GetSimulatorBufferPointer, !! KIM_SimulatorModel_GetSimulatorBufferPointer !! !! \since 2.1 interface kim_get_simulator_buffer_pointer module procedure kim_simulator_model_get_simulator_buffer_pointer end interface kim_get_simulator_buffer_pointer !> \brief \copybrief KIM::SimulatorModel::ToString !! !! \sa KIM::SimulatorModel::ToString, KIM_SimulatorModel_ToString !! !! \since 2.1 interface kim_to_string module procedure kim_simulator_model_to_string end interface kim_to_string !> \brief \copybrief KIM::SimulatorModel::SetLogID !! !! \sa KIM::SimulatorModel::SetLogID, KIM_SimulatorModel_SetLogID !! !! \since 2.1 interface kim_set_log_id module procedure kim_simulator_model_set_log_id end interface kim_set_log_id !> \brief \copybrief KIM::SimulatorModel::PushLogVerbosity !! !! \sa KIM::SimulatorModel::PushLogVerbosity, !! KIM_SimulatorModel_PushLogVerbosity !! !! \since 2.1 interface kim_push_log_verbosity module procedure kim_simulator_model_push_log_verbosity end interface kim_push_log_verbosity !> \brief \copybrief KIM::SimulatorModel::PopLogVerbosity !! !! \sa KIM::SimulatorModel::, KIM_SimulatorModel_PopLogVerbosity !! !! \since 2.1 interface kim_pop_log_verbosity module procedure kim_simulator_model_pop_log_verbosity end interface kim_pop_log_verbosity contains !> \brief Compares kim_simulator_model_handle_type's for equality. !! !! \since 2.1 logical recursive function kim_simulator_model_handle_equal(lhs, rhs) implicit none type(kim_simulator_model_handle_type), intent(in) :: lhs type(kim_simulator_model_handle_type), intent(in) :: rhs if ((.not. c_associated(lhs%p)) .and. (.not. c_associated(rhs%p))) then kim_simulator_model_handle_equal = .true. else kim_simulator_model_handle_equal = c_associated(lhs%p, rhs%p) end if end function kim_simulator_model_handle_equal !> \brief Compares kim_simulator_model_handle_type's for inequality. !! !! \since 2.1 logical recursive function kim_simulator_model_handle_not_equal(lhs, rhs) implicit none type(kim_simulator_model_handle_type), intent(in) :: lhs type(kim_simulator_model_handle_type), intent(in) :: rhs kim_simulator_model_handle_not_equal = .not. (lhs == rhs) end function kim_simulator_model_handle_not_equal !> \brief \copybrief KIM::SimulatorModel::Create !! !! \sa KIM::SimulatorModel::Create, KIM_SimulatorModel_Create !! !! \since 2.1 recursive subroutine kim_simulator_model_create(simulator_model_name, & simulator_model_handle, ierr) implicit none interface integer(c_int) recursive function create( & simulator_model_name, simulator_model) & bind(c, name="KIM_SimulatorModel_Create") use, intrinsic :: iso_c_binding implicit none character(c_char), intent(in) :: simulator_model_name(*) type(c_ptr), intent(out) :: simulator_model end function create end interface character(len=*, kind=c_char), intent(in) :: simulator_model_name type(kim_simulator_model_handle_type), intent(out) :: simulator_model_handle integer(c_int), intent(out) :: ierr type(c_ptr) :: psimulator_model ierr = create(trim(simulator_model_name)//c_null_char, psimulator_model) simulator_model_handle%p = psimulator_model end subroutine kim_simulator_model_create !> \brief \copybrief KIM::SimulatorModel::Destroy !! !! \sa KIM::SimulatorModel::Destroy, KIM_SimulatorModel_Destroy !! !! \since 2.1 recursive subroutine kim_simulator_model_destroy(simulator_model_handle) implicit none interface recursive subroutine destroy(simulator_model) & bind(c, name="KIM_SimulatorModel_Destroy") use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(inout) :: simulator_model end subroutine destroy end interface type(kim_simulator_model_handle_type), intent(inout) :: & simulator_model_handle type(c_ptr) :: psimulator_model psimulator_model = simulator_model_handle%p call destroy(psimulator_model) simulator_model_handle%p = c_null_ptr end subroutine kim_simulator_model_destroy !> \brief \copybrief KIM::SimulatorModel::GetSimulatorNameAndVersion !! !! \sa KIM::SimulatorModel::GetSimulatorNameAndVersion, !! KIM_SimulatorModel_GetSimulatorNameAndVersion !! !! \since 2.1 recursive subroutine kim_simulator_model_get_simulator_name_and_version( & simulator_model_handle, simulator_name, simulator_version) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_simulator_name_and_version( & simulator_model, simulator_name, simulator_version) & bind(c, name="KIM_SimulatorModel_GetSimulatorNameAndVersion") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model type(c_ptr), intent(out) :: simulator_name type(c_ptr), intent(out) :: simulator_version end subroutine get_simulator_name_and_version end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle character(len=*, kind=c_char), intent(out) :: simulator_name character(len=*, kind=c_char), intent(out) :: simulator_version type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) psimulator_name, psimulator_version call c_f_pointer(simulator_model_handle%p, simulator_model) call get_simulator_name_and_version(simulator_model, psimulator_name, & psimulator_version) call kim_convert_c_char_ptr_to_string(psimulator_name, simulator_name) call kim_convert_c_char_ptr_to_string(psimulator_version, simulator_version) end subroutine kim_simulator_model_get_simulator_name_and_version !> \brief \copybrief KIM::SimulatorModel::GetNumberOfSupportedSpecies !! !! \sa KIM::SimulatorModel::GetNumberOfSupportedSpecies, !! KIM_SimulatorModel_GetNumberOfSupportedSpecies !! !! \since 2.1 recursive subroutine kim_simulator_model_get_number_of_supported_species( & simulator_model_handle, number_of_supported_species) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine get_number_of_supported_species( & simulator_model, number_of_supported_species) & bind(c, name="KIM_SimulatorModel_GetNumberOfSupportedSpecies") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(out) :: number_of_supported_species end subroutine get_number_of_supported_species end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(out) :: number_of_supported_species type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call get_number_of_supported_species(simulator_model, & number_of_supported_species) end subroutine kim_simulator_model_get_number_of_supported_species !> \brief \copybrief KIM::SimulatorModel::GetSupportedSpecies !! !! \sa KIM::SimulatorModel::GetSupportedSpecies, !! KIM_SimulatorModel_GetSupportedSpecies !! !! \since 2.1 recursive subroutine kim_simulator_model_get_supported_species( & simulator_model_handle, index, species_name, ierr) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_supported_species( & simulator_model, index, species_name) & bind(c, name="KIM_SimulatorModel_GetSupportedSpecies") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: species_name end function get_supported_species end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: species_name integer(c_int), intent(out) :: ierr type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pspecies_name call c_f_pointer(simulator_model_handle%p, simulator_model) ierr = get_supported_species(simulator_model, index - 1, pspecies_name) call kim_convert_c_char_ptr_to_string(pspecies_name, species_name) end subroutine kim_simulator_model_get_supported_species !> \brief \copybrief KIM::SimulatorModel::OpenAndInitializeTemplateMap !! !! \sa KIM::SimulatorModel::OpenAndInitializeTemplateMap, !! KIM_SimulatorModel_OpenAndInitializeTemplateMap !! !! \since 2.1 recursive subroutine kim_simulator_model_open_and_initialize_template_map( & simulator_model_handle) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine open_and_initialize_template_map(simulator_model) & bind(c, name="KIM_SimulatorModel_OpenAndInitializeTemplateMap") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model end subroutine open_and_initialize_template_map end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call open_and_initialize_template_map(simulator_model) end subroutine kim_simulator_model_open_and_initialize_template_map !> \brief \copybrief KIM::SimulatorModel::TemplateMapIsOpen !! !! \sa KIM::SimulatorModel::TemplateMapIsOpen, !! KIM_SimulatorModel_TemplateMapIsOpen !! !! \since 2.1 integer(c_int) recursive function kim_simulator_model_template_map_is_open( & simulator_model_handle) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface integer(c_int) recursive function template_map_is_open(simulator_model) & bind(c, name="KIM_SimulatorModel_TemplateMapIsOpen") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model end function template_map_is_open end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) kim_simulator_model_template_map_is_open = template_map_is_open( & simulator_model) end function kim_simulator_model_template_map_is_open !> \brief \copybrief KIM::SimulatorModel::AddTemplateMap !! !! \sa KIM::SimulatorModel::AddTemplateMap, KIM_SimulatorModel_AddTemplateMap !! !! \since 2.1 recursive subroutine kim_simulator_model_add_template_map( & simulator_model_handle, key, value, ierr) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function add_template_map( & simulator_model, key, value) & bind(c, name="KIM_SimulatorModel_AddTemplateMap") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model character(c_char), intent(in) :: key(*) character(c_char), intent(in) :: value(*) end function add_template_map end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle character(len=*, kind=c_char), intent(in) :: key character(len=*, kind=c_char), intent(in) :: value integer(c_int), intent(out) :: ierr type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) ierr = add_template_map(simulator_model, trim(key)//c_null_char, & trim(value)//c_null_char) end subroutine kim_simulator_model_add_template_map !> \brief \copybrief KIM::SimulatorModel::CloseTemplateMap !! !! \sa KIM::SimulatorModel::CloseTemplateMap, !! KIM_SimulatorModel_CloseTemplateMap !! !! \since 2.1 recursive subroutine kim_simulator_model_close_template_map( & simulator_model_handle) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine close_template_map(simulator_model) & bind(c, name="KIM_SimulatorModel_CloseTemplateMap") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model end subroutine close_template_map end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call close_template_map(simulator_model) end subroutine kim_simulator_model_close_template_map !> \brief \copybrief KIM::SimulatorModel::GetNumberOfSimulatorFields !! !! \sa KIM::SimulatorModel::GetNumberOfSimulatorFields, !! KIM_SimulatorModel_GetNumberOfSimulatorFields !! !! \since 2.1 recursive subroutine kim_simulator_model_get_number_of_simulator_fields( & simulator_model_handle, number_of_simulator_fields) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine get_number_of_simulator_fields( & simulator_model, number_of_simulator_fields) & bind(c, name="KIM_SimulatorModel_GetNumberOfSimulatorFields") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(out) :: number_of_simulator_fields end subroutine get_number_of_simulator_fields end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(out) :: number_of_simulator_fields type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call get_number_of_simulator_fields(simulator_model, & number_of_simulator_fields) end subroutine kim_simulator_model_get_number_of_simulator_fields !> \brief \copybrief KIM::SimulatorModel::GetSimulatorFieldMetadata !! !! \sa KIM::SimulatorModel::GetSimulatorFieldMetadata, !! KIM_SimulatorModel_GetSimulatorFieldMetadata !! !! \since 2.1 recursive subroutine kim_simulator_model_get_simulator_field_metadata( & simulator_model_handle, field_index, extent, field_name, ierr) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_simulator_field_metadata( & simulator_model, field_index, extent, field_name) & bind(c, name="KIM_SimulatorModel_GetSimulatorFieldMetadata") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(in), value :: field_index integer(c_int), intent(out) :: extent type(c_ptr), intent(out) :: field_name end function get_simulator_field_metadata end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(in) :: field_index integer(c_int), intent(out) :: extent character(len=*, kind=c_char), intent(out) :: field_name integer(c_int), intent(out) :: ierr type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pfield_name call c_f_pointer(simulator_model_handle%p, simulator_model) ierr = get_simulator_field_metadata(simulator_model, field_index - 1, & extent, pfield_name) call kim_convert_c_char_ptr_to_string(pfield_name, field_name) end subroutine kim_simulator_model_get_simulator_field_metadata !> \brief \copybrief KIM::SimulatorModel::GetSimulatorFieldLine !! !! \sa KIM::SimulatorModel::GetSimulatorFieldLine, !! KIM_SimulatorModel_GetSimulatorFieldLine !! !! \since 2.1 recursive subroutine kim_simulator_model_get_simulator_field_line( & simulator_model_handle, field_index, line_index, line_value, ierr) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_simulator_field_line( & simulator_model, field_index, line_index, line_value) & bind(c, name="KIM_SimulatorModel_GetSimulatorFieldLine") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(in), value :: field_index integer(c_int), intent(in), value :: line_index type(c_ptr), intent(out) :: line_value end function get_simulator_field_line end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(in), value :: field_index integer(c_int), intent(in), value :: line_index character(len=*, kind=c_char), intent(out) :: line_value integer(c_int), intent(out) :: ierr type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pline_value call c_f_pointer(simulator_model_handle%p, simulator_model) ierr = get_simulator_field_line(simulator_model, field_index - 1, & line_index - 1, pline_value) call kim_convert_c_char_ptr_to_string(pline_value, line_value) end subroutine kim_simulator_model_get_simulator_field_line !> \brief \copybrief KIM::SimulatorModel::GetParameterFileDirectoryName !! !! \sa KIM::SimulatorModel::GetParameterFileDirectoryName, !! KIM_SimulatorModel_GetParameterFileDirectoryName !! !! \since 2.1 recursive subroutine kim_simulator_model_get_parameter_file_directory_name( & simulator_model_handle, directory_name) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_parameter_file_directory_name(simulator_model, & directory_name) & bind(c, name="KIM_SimulatorModel_GetParameterFileDirectoryName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model type(c_ptr), intent(out) :: directory_name end subroutine get_parameter_file_directory_name end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle character(len=*, kind=c_char), intent(out) :: directory_name type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pdirectory_name call c_f_pointer(simulator_model_handle%p, simulator_model) call get_parameter_file_directory_name(simulator_model, pdirectory_name) call kim_convert_c_char_ptr_to_string(pdirectory_name, directory_name) end subroutine kim_simulator_model_get_parameter_file_directory_name !> \brief \copybrief KIM::SimulatorModel::GetSpecificationFileName !! !! \sa KIM::SimulatorModel::GetSpecificationFileName, !! KIM_SimulatorModel_GetSpecificationFileName !! !! \since 2.1 recursive subroutine kim_simulator_model_get_specification_file_name( & simulator_model_handle, specification_file_name) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface recursive subroutine get_specification_file_name( & simulator_model, specification_file_name) & bind(c, name="KIM_SimulatorModel_GetSpecificationFileName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model type(c_ptr), intent(out) :: specification_file_name end subroutine get_specification_file_name end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle character(len=*, kind=c_char), intent(out) :: specification_file_name type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pspecification_file_name call c_f_pointer(simulator_model_handle%p, simulator_model) call get_specification_file_name(simulator_model, pspecification_file_name) call kim_convert_c_char_ptr_to_string(pspecification_file_name, & specification_file_name) end subroutine kim_simulator_model_get_specification_file_name !> \brief \copybrief KIM::SimulatorModel::GetNumberOfParameterFiles !! !! \sa KIM::SimulatorModel::GetNumberOfParameterFiles, !! KIM_SimulatorModel_GetNumberOfParameterFiles !! !! \since 2.1 recursive subroutine kim_simulator_model_get_number_of_parameter_files( & simulator_model_handle, number_of_parameter_files) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine get_number_of_parameter_files( & simulator_model, number_of_parameter_files) & bind(c, name="KIM_SimulatorModel_GetNumberOfParameterFiles") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(out) :: number_of_parameter_files end subroutine get_number_of_parameter_files end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(out) :: number_of_parameter_files type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call get_number_of_parameter_files(simulator_model, & number_of_parameter_files) end subroutine kim_simulator_model_get_number_of_parameter_files !> \brief \copybrief KIM::SimulatorModel::GetParameterFileName !! !! \sa KIM::SimulatorModel::GetParameterFileName, !! KIM_SimulatorModel_GetParameterFileName !! !! \since 2.1 !! !! \deprecated As of 2.2. Please use !! kim_simulator_model_module::kim_get_parameter_file_basename() instead. recursive subroutine kim_simulator_model_get_parameter_file_name( & simulator_model_handle, index, parameter_file_name, ierr) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_parameter_file_name( & simulator_model, index, parameter_file_name) & bind(c, name="KIM_SimulatorModel_GetParameterFileName") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: parameter_file_name end function get_parameter_file_name end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: parameter_file_name integer(c_int), intent(out) :: ierr type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pparameter_file_name call c_f_pointer(simulator_model_handle%p, simulator_model) ierr = get_parameter_file_name(simulator_model, index - 1, & pparameter_file_name) call kim_convert_c_char_ptr_to_string(pparameter_file_name, & parameter_file_name) end subroutine kim_simulator_model_get_parameter_file_name !> \brief \copybrief KIM::SimulatorModel::GetParameterFileBasename !! !! \sa KIM::SimulatorModel::GetParameterFileBasename, !! KIM_SimulatorModel_GetParameterFileBasename !! !! \since 2.2 recursive subroutine kim_simulator_model_get_parameter_file_basename( & simulator_model_handle, index, parameter_file_basename, ierr) use kim_interoperable_types_module, only: kim_simulator_model_type use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface integer(c_int) recursive function get_parameter_file_basename( & simulator_model, index, parameter_file_basename) & bind(c, name="KIM_SimulatorModel_GetParameterFileBasename") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model integer(c_int), intent(in), value :: index type(c_ptr), intent(out) :: parameter_file_basename end function get_parameter_file_basename end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle integer(c_int), intent(in) :: index character(len=*, kind=c_char), intent(out) :: parameter_file_basename integer(c_int), intent(out) :: ierr type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) pparameter_file_basename call c_f_pointer(simulator_model_handle%p, simulator_model) ierr = get_parameter_file_basename(simulator_model, index - 1, & pparameter_file_basename) call kim_convert_c_char_ptr_to_string(pparameter_file_basename, & parameter_file_basename) end subroutine kim_simulator_model_get_parameter_file_basename !> \brief \copybrief KIM::SimulatorModel::SetSimulatorBufferPointer !! !! \sa KIM::SimulatorModel::SetSimulatorBufferPointer, !! KIM_SimulatorModel_SetSimulatorBufferPointer !! !! \since 2.1 recursive subroutine kim_simulator_model_set_simulator_buffer_pointer( & simulator_model_handle, ptr) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine set_simulator_buffer_pointer(simulator_model, ptr) & bind(c, name="KIM_SimulatorModel_SetSimulatorBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model type(c_ptr), intent(in), value :: ptr end subroutine set_simulator_buffer_pointer end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(c_ptr), intent(in) :: ptr type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call set_simulator_buffer_pointer(simulator_model, ptr) end subroutine kim_simulator_model_set_simulator_buffer_pointer !> \brief \copybrief KIM::SimulatorModel::GetSimulatorBufferPointer !! !! \sa KIM::SimulatorModel::GetSimulatorBufferPointer, !! KIM_SimulatorModel_GetSimulatorBufferPointer !! !! \since 2.1 recursive subroutine kim_simulator_model_get_simulator_buffer_pointer( & simulator_model_handle, ptr) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine get_simulator_buffer_pointer(simulator_model, ptr) & bind(c, name="KIM_SimulatorModel_GetSimulatorBufferPointer") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model type(c_ptr), intent(out) :: ptr end subroutine get_simulator_buffer_pointer end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(c_ptr), intent(out) :: ptr type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call get_simulator_buffer_pointer(simulator_model, ptr) end subroutine kim_simulator_model_get_simulator_buffer_pointer !> \brief \copybrief KIM::SimulatorModel::ToString !! !! \sa KIM::SimulatorModel::ToString, KIM_SimulatorModel_ToString !! !! \since 2.1 recursive subroutine kim_simulator_model_to_string(simulator_model_handle, & string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface type(c_ptr) recursive function model_string(simulator_model) & bind(c, name="KIM_SimulatorModel_ToString") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model end function model_string end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle character(len=*, kind=c_char), intent(out) :: string type(kim_simulator_model_type), pointer :: simulator_model type(c_ptr) :: p call c_f_pointer(simulator_model_handle%p, simulator_model) p = model_string(simulator_model) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_simulator_model_to_string !> \brief \copybrief KIM::SimulatorModel::SetLogID !! !! \sa KIM::SimulatorModel::SetLogID, KIM_SimulatorModel_SetLogID !! !! \since 2.1 recursive subroutine kim_simulator_model_set_log_id(simulator_model_handle, & log_id) use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine set_log_id(simulator_model, log_id) & bind(c, name="KIM_SimulatorModel_SetLogID") use, intrinsic :: iso_c_binding use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model character(c_char), intent(in) :: log_id(*) end subroutine set_log_id end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle character(len=*, kind=c_char), intent(in) :: log_id type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call set_log_id(simulator_model, trim(log_id)//c_null_char) end subroutine kim_simulator_model_set_log_id !> \brief \copybrief KIM::SimulatorModel::PushLogVerbosity !! !! \sa KIM::SimulatorModel::PushLogVerbosity, !! KIM_SimulatorModel_PushLogVerbosity !! !! \since 2.1 recursive subroutine kim_simulator_model_push_log_verbosity( & simulator_model_handle, log_verbosity) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine push_log_verbosity(simulator_model, log_verbosity) & bind(c, name="KIM_SimulatorModel_PushLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model type(kim_log_verbosity_type), intent(in), value :: log_verbosity end subroutine push_log_verbosity end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(kim_log_verbosity_type), intent(in) :: log_verbosity type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call push_log_verbosity(simulator_model, log_verbosity) end subroutine kim_simulator_model_push_log_verbosity !> \brief \copybrief KIM::SimulatorModel::PopLogVerbosity !! !! \sa KIM::SimulatorModel::, KIM_SimulatorModel_PopLogVerbosity !! !! \since 2.1 recursive subroutine kim_simulator_model_pop_log_verbosity( & simulator_model_handle) use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_simulator_model_type implicit none interface recursive subroutine pop_log_verbosity(simulator_model) & bind(c, name="KIM_SimulatorModel_PopLogVerbosity") use, intrinsic :: iso_c_binding use kim_log_verbosity_module, only: kim_log_verbosity_type use kim_interoperable_types_module, only: kim_simulator_model_type implicit none type(kim_simulator_model_type), intent(in) :: simulator_model end subroutine pop_log_verbosity end interface type(kim_simulator_model_handle_type), intent(in) :: simulator_model_handle type(kim_simulator_model_type), pointer :: simulator_model call c_f_pointer(simulator_model_handle%p, simulator_model) call pop_log_verbosity(simulator_model) end subroutine kim_simulator_model_pop_log_verbosity end module kim_simulator_model_module kim-api-2.3.0-git/fortran/include/kim_species_name_module.f90000066400000000000000000001317121421473465500241220ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::SpeciesName !! !! \sa KIM::SpeciesName, KIM_SpeciesName !! !! \since 2.0 module kim_species_name_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_species_name_type, & ! Constants KIM_SPECIES_NAME_ELECTRON, & KIM_SPECIES_NAME_H, & KIM_SPECIES_NAME_HE, & KIM_SPECIES_NAME_LI, & KIM_SPECIES_NAME_BE, & KIM_SPECIES_NAME_B, & KIM_SPECIES_NAME_C, & KIM_SPECIES_NAME_N, & KIM_SPECIES_NAME_O, & KIM_SPECIES_NAME_F, & KIM_SPECIES_NAME_NE, & KIM_SPECIES_NAME_NA, & KIM_SPECIES_NAME_MG, & KIM_SPECIES_NAME_AL, & KIM_SPECIES_NAME_SI, & KIM_SPECIES_NAME_P, & KIM_SPECIES_NAME_S, & KIM_SPECIES_NAME_CL, & KIM_SPECIES_NAME_AR, & KIM_SPECIES_NAME_K, & KIM_SPECIES_NAME_CA, & KIM_SPECIES_NAME_SC, & KIM_SPECIES_NAME_TI, & KIM_SPECIES_NAME_V, & KIM_SPECIES_NAME_CR, & KIM_SPECIES_NAME_MN, & KIM_SPECIES_NAME_FE, & KIM_SPECIES_NAME_CO, & KIM_SPECIES_NAME_NI, & KIM_SPECIES_NAME_CU, & KIM_SPECIES_NAME_ZN, & KIM_SPECIES_NAME_GA, & KIM_SPECIES_NAME_GE, & KIM_SPECIES_NAME_AS, & KIM_SPECIES_NAME_SE, & KIM_SPECIES_NAME_BR, & KIM_SPECIES_NAME_KR, & KIM_SPECIES_NAME_RB, & KIM_SPECIES_NAME_SR, & KIM_SPECIES_NAME_Y, & KIM_SPECIES_NAME_ZR, & KIM_SPECIES_NAME_NB, & KIM_SPECIES_NAME_MO, & KIM_SPECIES_NAME_TC, & KIM_SPECIES_NAME_RU, & KIM_SPECIES_NAME_RH, & KIM_SPECIES_NAME_PD, & KIM_SPECIES_NAME_AG, & KIM_SPECIES_NAME_CD, & KIM_SPECIES_NAME_IN, & KIM_SPECIES_NAME_SN, & KIM_SPECIES_NAME_SB, & KIM_SPECIES_NAME_TE, & KIM_SPECIES_NAME_I, & KIM_SPECIES_NAME_XE, & KIM_SPECIES_NAME_CS, & KIM_SPECIES_NAME_BA, & KIM_SPECIES_NAME_LA, & KIM_SPECIES_NAME_CE, & KIM_SPECIES_NAME_PR, & KIM_SPECIES_NAME_ND, & KIM_SPECIES_NAME_PM, & KIM_SPECIES_NAME_SM, & KIM_SPECIES_NAME_EU, & KIM_SPECIES_NAME_GD, & KIM_SPECIES_NAME_TB, & KIM_SPECIES_NAME_DY, & KIM_SPECIES_NAME_HO, & KIM_SPECIES_NAME_ER, & KIM_SPECIES_NAME_TM, & KIM_SPECIES_NAME_YB, & KIM_SPECIES_NAME_LU, & KIM_SPECIES_NAME_HF, & KIM_SPECIES_NAME_TA, & KIM_SPECIES_NAME_W, & KIM_SPECIES_NAME_RE, & KIM_SPECIES_NAME_OS, & KIM_SPECIES_NAME_IR, & KIM_SPECIES_NAME_PT, & KIM_SPECIES_NAME_AU, & KIM_SPECIES_NAME_HG, & KIM_SPECIES_NAME_TL, & KIM_SPECIES_NAME_PB, & KIM_SPECIES_NAME_BI, & KIM_SPECIES_NAME_PO, & KIM_SPECIES_NAME_AT, & KIM_SPECIES_NAME_RN, & KIM_SPECIES_NAME_FR, & KIM_SPECIES_NAME_RA, & KIM_SPECIES_NAME_AC, & KIM_SPECIES_NAME_TH, & KIM_SPECIES_NAME_PA, & KIM_SPECIES_NAME_U, & KIM_SPECIES_NAME_NP, & KIM_SPECIES_NAME_PU, & KIM_SPECIES_NAME_AM, & KIM_SPECIES_NAME_CM, & KIM_SPECIES_NAME_BK, & KIM_SPECIES_NAME_CF, & KIM_SPECIES_NAME_ES, & KIM_SPECIES_NAME_FM, & KIM_SPECIES_NAME_MD, & KIM_SPECIES_NAME_NO, & KIM_SPECIES_NAME_LR, & KIM_SPECIES_NAME_RF, & KIM_SPECIES_NAME_DB, & KIM_SPECIES_NAME_SG, & KIM_SPECIES_NAME_BH, & KIM_SPECIES_NAME_HS, & KIM_SPECIES_NAME_MT, & KIM_SPECIES_NAME_DS, & KIM_SPECIES_NAME_RG, & KIM_SPECIES_NAME_CN, & KIM_SPECIES_NAME_NH, & KIM_SPECIES_NAME_FL, & KIM_SPECIES_NAME_MC, & KIM_SPECIES_NAME_LV, & KIM_SPECIES_NAME_TS, & KIM_SPECIES_NAME_OG, & KIM_SPECIES_NAME_USER01, & KIM_SPECIES_NAME_USER02, & KIM_SPECIES_NAME_USER03, & KIM_SPECIES_NAME_USER04, & KIM_SPECIES_NAME_USER05, & KIM_SPECIES_NAME_USER06, & KIM_SPECIES_NAME_USER07, & KIM_SPECIES_NAME_USER08, & KIM_SPECIES_NAME_USER09, & KIM_SPECIES_NAME_USER10, & KIM_SPECIES_NAME_USER11, & KIM_SPECIES_NAME_USER12, & KIM_SPECIES_NAME_USER13, & KIM_SPECIES_NAME_USER14, & KIM_SPECIES_NAME_USER15, & KIM_SPECIES_NAME_USER16, & KIM_SPECIES_NAME_USER17, & KIM_SPECIES_NAME_USER18, & KIM_SPECIES_NAME_USER19, & KIM_SPECIES_NAME_USER20, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_species_names, & kim_get_species_name !> \brief \copybrief KIM::SpeciesName !! !! \sa KIM::SpeciesName, KIM_SpeciesName !! !! \since 2.0 type, bind(c) :: kim_species_name_type integer(c_int) species_name_id end type kim_species_name_type !> \brief \copybrief KIM::SPECIES_NAME::electron !! !! \sa KIM::SPECIES_NAME::electron, KIM_SPECIES_NAME_electron !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_electron") & :: KIM_SPECIES_NAME_ELECTRON !> \brief \copybrief KIM::SPECIES_NAME::H !! !! \sa KIM::SPECIES_NAME::H, KIM_SPECIES_NAME_H !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_H") & :: KIM_SPECIES_NAME_H !> \brief \copybrief KIM::SPECIES_NAME::He !! !! \sa KIM::SPECIES_NAME::He, KIM_SPECIES_NAME_He !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_He") & :: KIM_SPECIES_NAME_HE !> \brief \copybrief KIM::SPECIES_NAME::Li !! !! \sa KIM::SPECIES_NAME::Li, KIM_SPECIES_NAME_Li !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Li") & :: KIM_SPECIES_NAME_LI !> \brief \copybrief KIM::SPECIES_NAME::Be !! !! \sa KIM::SPECIES_NAME::Be, KIM_SPECIES_NAME_Be !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Be") & :: KIM_SPECIES_NAME_BE !> \brief \copybrief KIM::SPECIES_NAME::B !! !! \sa KIM::SPECIES_NAME::B, KIM_SPECIES_NAME_B !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_B") & :: KIM_SPECIES_NAME_B !> \brief \copybrief KIM::SPECIES_NAME::C !! !! \sa KIM::SPECIES_NAME::C, KIM_SPECIES_NAME_C !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_C") & :: KIM_SPECIES_NAME_C !> \brief \copybrief KIM::SPECIES_NAME::N !! !! \sa KIM::SPECIES_NAME::N, KIM_SPECIES_NAME_N !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_N") & :: KIM_SPECIES_NAME_N !> \brief \copybrief KIM::SPECIES_NAME::O !! !! \sa KIM::SPECIES_NAME::O, KIM_SPECIES_NAME_O !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_O") & :: KIM_SPECIES_NAME_O !> \brief \copybrief KIM::SPECIES_NAME::F !! !! \sa KIM::SPECIES_NAME::F, KIM_SPECIES_NAME_F !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_F") & :: KIM_SPECIES_NAME_F !> \brief \copybrief KIM::SPECIES_NAME::Ne !! !! \sa KIM::SPECIES_NAME::Ne, KIM_SPECIES_NAME_Ne !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ne") & :: KIM_SPECIES_NAME_NE !> \brief \copybrief KIM::SPECIES_NAME::Na !! !! \sa KIM::SPECIES_NAME::Na, KIM_SPECIES_NAME_Na !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Na") & :: KIM_SPECIES_NAME_NA !> \brief \copybrief KIM::SPECIES_NAME::Mg !! !! \sa KIM::SPECIES_NAME::Mg, KIM_SPECIES_NAME_Mg !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Mg") & :: KIM_SPECIES_NAME_MG !> \brief \copybrief KIM::SPECIES_NAME::Al !! !! \sa KIM::SPECIES_NAME::Al, KIM_SPECIES_NAME_Al !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Al") & :: KIM_SPECIES_NAME_AL !> \brief \copybrief KIM::SPECIES_NAME::Si !! !! \sa KIM::SPECIES_NAME::Si, KIM_SPECIES_NAME_Si !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Si") & :: KIM_SPECIES_NAME_SI !> \brief \copybrief KIM::SPECIES_NAME::P !! !! \sa KIM::SPECIES_NAME::P, KIM_SPECIES_NAME_P !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_P") & :: KIM_SPECIES_NAME_P !> \brief \copybrief KIM::SPECIES_NAME::S !! !! \sa KIM::SPECIES_NAME::S, KIM_SPECIES_NAME_S !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_S") & :: KIM_SPECIES_NAME_S !> \brief \copybrief KIM::SPECIES_NAME::Cl !! !! \sa KIM::SPECIES_NAME::Cl, KIM_SPECIES_NAME_Cl !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cl") & :: KIM_SPECIES_NAME_CL !> \brief \copybrief KIM::SPECIES_NAME::Ar !! !! \sa KIM::SPECIES_NAME::Ar, KIM_SPECIES_NAME_Ar !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ar") & :: KIM_SPECIES_NAME_AR !> \brief \copybrief KIM::SPECIES_NAME::K !! !! \sa KIM::SPECIES_NAME::K, KIM_SPECIES_NAME_K !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_K") & :: KIM_SPECIES_NAME_K !> \brief \copybrief KIM::SPECIES_NAME::Ca !! !! \sa KIM::SPECIES_NAME::Ca, KIM_SPECIES_NAME_Ca !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ca") & :: KIM_SPECIES_NAME_CA !> \brief \copybrief KIM::SPECIES_NAME::Sc !! !! \sa KIM::SPECIES_NAME::Sc, KIM_SPECIES_NAME_Sc !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Sc") & :: KIM_SPECIES_NAME_SC !> \brief \copybrief KIM::SPECIES_NAME::Ti !! !! \sa KIM::SPECIES_NAME::Ti, KIM_SPECIES_NAME_Ti !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ti") & :: KIM_SPECIES_NAME_TI !> \brief \copybrief KIM::SPECIES_NAME::V !! !! \sa KIM::SPECIES_NAME::V, KIM_SPECIES_NAME_V !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_V") & :: KIM_SPECIES_NAME_V !> \brief \copybrief KIM::SPECIES_NAME::Cr !! !! \sa KIM::SPECIES_NAME::Cr, KIM_SPECIES_NAME_Cr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cr") & :: KIM_SPECIES_NAME_CR !> \brief \copybrief KIM::SPECIES_NAME::Mn !! !! \sa KIM::SPECIES_NAME::Mn, KIM_SPECIES_NAME_Mn !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Mn") & :: KIM_SPECIES_NAME_MN !> \brief \copybrief KIM::SPECIES_NAME::Fe !! !! \sa KIM::SPECIES_NAME::Fe, KIM_SPECIES_NAME_Fe !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Fe") & :: KIM_SPECIES_NAME_FE !> \brief \copybrief KIM::SPECIES_NAME::Co !! !! \sa KIM::SPECIES_NAME::Co, KIM_SPECIES_NAME_Co !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Co") & :: KIM_SPECIES_NAME_CO !> \brief \copybrief KIM::SPECIES_NAME::Ni !! !! \sa KIM::SPECIES_NAME::Ni, KIM_SPECIES_NAME_Ni !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ni") & :: KIM_SPECIES_NAME_NI !> \brief \copybrief KIM::SPECIES_NAME::Cu !! !! \sa KIM::SPECIES_NAME::Cu, KIM_SPECIES_NAME_Cu !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cu") & :: KIM_SPECIES_NAME_CU !> \brief \copybrief KIM::SPECIES_NAME::Zn !! !! \sa KIM::SPECIES_NAME::Zn, KIM_SPECIES_NAME_Zn !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Zn") & :: KIM_SPECIES_NAME_ZN !> \brief \copybrief KIM::SPECIES_NAME::Ga !! !! \sa KIM::SPECIES_NAME::Ga, KIM_SPECIES_NAME_Ga !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ga") & :: KIM_SPECIES_NAME_GA !> \brief \copybrief KIM::SPECIES_NAME::Ge !! !! \sa KIM::SPECIES_NAME::Ge, KIM_SPECIES_NAME_Ge !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ge") & :: KIM_SPECIES_NAME_GE !> \brief \copybrief KIM::SPECIES_NAME::As !! !! \sa KIM::SPECIES_NAME::As, KIM_SPECIES_NAME_As !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_As") & :: KIM_SPECIES_NAME_AS !> \brief \copybrief KIM::SPECIES_NAME::Se !! !! \sa KIM::SPECIES_NAME::Se, KIM_SPECIES_NAME_Se !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Se") & :: KIM_SPECIES_NAME_SE !> \brief \copybrief KIM::SPECIES_NAME::Br !! !! \sa KIM::SPECIES_NAME::Br, KIM_SPECIES_NAME_Br !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Br") & :: KIM_SPECIES_NAME_BR !> \brief \copybrief KIM::SPECIES_NAME::Kr !! !! \sa KIM::SPECIES_NAME::Kr, KIM_SPECIES_NAME_Kr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Kr") & :: KIM_SPECIES_NAME_KR !> \brief \copybrief KIM::SPECIES_NAME::Rb !! !! \sa KIM::SPECIES_NAME::Rb, KIM_SPECIES_NAME_Rb !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Rb") & :: KIM_SPECIES_NAME_RB !> \brief \copybrief KIM::SPECIES_NAME::Sr !! !! \sa KIM::SPECIES_NAME::Sr, KIM_SPECIES_NAME_Sr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Sr") & :: KIM_SPECIES_NAME_SR !> \brief \copybrief KIM::SPECIES_NAME::Y !! !! \sa KIM::SPECIES_NAME::Y, KIM_SPECIES_NAME_Y !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Y") & :: KIM_SPECIES_NAME_Y !> \brief \copybrief KIM::SPECIES_NAME::Zr !! !! \sa KIM::SPECIES_NAME::Zr, KIM_SPECIES_NAME_Zr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Zr") & :: KIM_SPECIES_NAME_ZR !> \brief \copybrief KIM::SPECIES_NAME::Nb !! !! \sa KIM::SPECIES_NAME::Nb, KIM_SPECIES_NAME_Nb !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Nb") & :: KIM_SPECIES_NAME_NB !> \brief \copybrief KIM::SPECIES_NAME::Mo !! !! \sa KIM::SPECIES_NAME::Mo, KIM_SPECIES_NAME_Mo !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Mo") & :: KIM_SPECIES_NAME_MO !> \brief \copybrief KIM::SPECIES_NAME::Tc !! !! \sa KIM::SPECIES_NAME::Tc, KIM_SPECIES_NAME_Tc !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Tc") & :: KIM_SPECIES_NAME_TC !> \brief \copybrief KIM::SPECIES_NAME::Ru !! !! \sa KIM::SPECIES_NAME::Ru, KIM_SPECIES_NAME_Ru !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ru") & :: KIM_SPECIES_NAME_RU !> \brief \copybrief KIM::SPECIES_NAME::Rh !! !! \sa KIM::SPECIES_NAME::Rh, KIM_SPECIES_NAME_Rh !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Rh") & :: KIM_SPECIES_NAME_RH !> \brief \copybrief KIM::SPECIES_NAME::Pd !! !! \sa KIM::SPECIES_NAME::Pd, KIM_SPECIES_NAME_Pd !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pd") & :: KIM_SPECIES_NAME_PD !> \brief \copybrief KIM::SPECIES_NAME::Ag !! !! \sa KIM::SPECIES_NAME::Ag, KIM_SPECIES_NAME_Ag !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ag") & :: KIM_SPECIES_NAME_AG !> \brief \copybrief KIM::SPECIES_NAME::Cd !! !! \sa KIM::SPECIES_NAME::Cd, KIM_SPECIES_NAME_Cd !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cd") & :: KIM_SPECIES_NAME_CD !> \brief \copybrief KIM::SPECIES_NAME::In !! !! \sa KIM::SPECIES_NAME::In, KIM_SPECIES_NAME_In !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_In") & :: KIM_SPECIES_NAME_IN !> \brief \copybrief KIM::SPECIES_NAME::Sn !! !! \sa KIM::SPECIES_NAME::Sn, KIM_SPECIES_NAME_Sn !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Sn") & :: KIM_SPECIES_NAME_SN !> \brief \copybrief KIM::SPECIES_NAME::Sb !! !! \sa KIM::SPECIES_NAME::Sb, KIM_SPECIES_NAME_Sb !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Sb") & :: KIM_SPECIES_NAME_SB !> \brief \copybrief KIM::SPECIES_NAME::Te !! !! \sa KIM::SPECIES_NAME::Te, KIM_SPECIES_NAME_Te !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Te") & :: KIM_SPECIES_NAME_TE !> \brief \copybrief KIM::SPECIES_NAME::I !! !! \sa KIM::SPECIES_NAME::I, KIM_SPECIES_NAME_I !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_I") & :: KIM_SPECIES_NAME_I !> \brief \copybrief KIM::SPECIES_NAME::Xe !! !! \sa KIM::SPECIES_NAME::Xe, KIM_SPECIES_NAME_Xe !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Xe") & :: KIM_SPECIES_NAME_XE !> \brief \copybrief KIM::SPECIES_NAME::Cs !! !! \sa KIM::SPECIES_NAME::Cs, KIM_SPECIES_NAME_Cs !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cs") & :: KIM_SPECIES_NAME_CS !> \brief \copybrief KIM::SPECIES_NAME::Ba !! !! \sa KIM::SPECIES_NAME::Ba, KIM_SPECIES_NAME_Ba !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ba") & :: KIM_SPECIES_NAME_BA !> \brief \copybrief KIM::SPECIES_NAME::La !! !! \sa KIM::SPECIES_NAME::La, KIM_SPECIES_NAME_La !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_La") & :: KIM_SPECIES_NAME_LA !> \brief \copybrief KIM::SPECIES_NAME::Ce !! !! \sa KIM::SPECIES_NAME::Ce, KIM_SPECIES_NAME_Ce !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ce") & :: KIM_SPECIES_NAME_CE !> \brief \copybrief KIM::SPECIES_NAME::Pr !! !! \sa KIM::SPECIES_NAME::Pr, KIM_SPECIES_NAME_Pr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pr") & :: KIM_SPECIES_NAME_PR !> \brief \copybrief KIM::SPECIES_NAME::Nd !! !! \sa KIM::SPECIES_NAME::Nd, KIM_SPECIES_NAME_Nd !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Nd") & :: KIM_SPECIES_NAME_ND !> \brief \copybrief KIM::SPECIES_NAME::Pm !! !! \sa KIM::SPECIES_NAME::Pm, KIM_SPECIES_NAME_Pm !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pm") & :: KIM_SPECIES_NAME_PM !> \brief \copybrief KIM::SPECIES_NAME::Sm !! !! \sa KIM::SPECIES_NAME::Sm, KIM_SPECIES_NAME_Sm !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Sm") & :: KIM_SPECIES_NAME_SM !> \brief \copybrief KIM::SPECIES_NAME::Eu !! !! \sa KIM::SPECIES_NAME::Eu, KIM_SPECIES_NAME_Eu !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Eu") & :: KIM_SPECIES_NAME_EU !> \brief \copybrief KIM::SPECIES_NAME::Gd !! !! \sa KIM::SPECIES_NAME::Gd, KIM_SPECIES_NAME_Gd !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Gd") & :: KIM_SPECIES_NAME_GD !> \brief \copybrief KIM::SPECIES_NAME::Tb !! !! \sa KIM::SPECIES_NAME::Tb, KIM_SPECIES_NAME_Tb !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Tb") & :: KIM_SPECIES_NAME_TB !> \brief \copybrief KIM::SPECIES_NAME::Dy !! !! \sa KIM::SPECIES_NAME::Dy, KIM_SPECIES_NAME_Dy !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Dy") & :: KIM_SPECIES_NAME_DY !> \brief \copybrief KIM::SPECIES_NAME::Ho !! !! \sa KIM::SPECIES_NAME::Ho, KIM_SPECIES_NAME_Ho !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ho") & :: KIM_SPECIES_NAME_HO !> \brief \copybrief KIM::SPECIES_NAME::Er !! !! \sa KIM::SPECIES_NAME::Er, KIM_SPECIES_NAME_Er !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Er") & :: KIM_SPECIES_NAME_ER !> \brief \copybrief KIM::SPECIES_NAME::Tm !! !! \sa KIM::SPECIES_NAME::Tm, KIM_SPECIES_NAME_Tm !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Tm") & :: KIM_SPECIES_NAME_TM !> \brief \copybrief KIM::SPECIES_NAME::Yb !! !! \sa KIM::SPECIES_NAME::Yb, KIM_SPECIES_NAME_Yb !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Yb") & :: KIM_SPECIES_NAME_YB !> \brief \copybrief KIM::SPECIES_NAME::Lu !! !! \sa KIM::SPECIES_NAME::Lu, KIM_SPECIES_NAME_Lu !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Lu") & :: KIM_SPECIES_NAME_LU !> \brief \copybrief KIM::SPECIES_NAME::Hf !! !! \sa KIM::SPECIES_NAME::Hf, KIM_SPECIES_NAME_Hf !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Hf") & :: KIM_SPECIES_NAME_HF !> \brief \copybrief KIM::SPECIES_NAME::Ta !! !! \sa KIM::SPECIES_NAME::Ta, KIM_SPECIES_NAME_Ta !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ta") & :: KIM_SPECIES_NAME_TA !> \brief \copybrief KIM::SPECIES_NAME::W !! !! \sa KIM::SPECIES_NAME::W, KIM_SPECIES_NAME_W !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_W") & :: KIM_SPECIES_NAME_W !> \brief \copybrief KIM::SPECIES_NAME::Re !! !! \sa KIM::SPECIES_NAME::Re, KIM_SPECIES_NAME_Re !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Re") & :: KIM_SPECIES_NAME_RE !> \brief \copybrief KIM::SPECIES_NAME::Os !! !! \sa KIM::SPECIES_NAME::Os, KIM_SPECIES_NAME_Os !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Os") & :: KIM_SPECIES_NAME_OS !> \brief \copybrief KIM::SPECIES_NAME::Ir !! !! \sa KIM::SPECIES_NAME::Ir, KIM_SPECIES_NAME_Ir !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ir") & :: KIM_SPECIES_NAME_IR !> \brief \copybrief KIM::SPECIES_NAME::Pt !! !! \sa KIM::SPECIES_NAME::Pt, KIM_SPECIES_NAME_Pt !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pt") & :: KIM_SPECIES_NAME_PT !> \brief \copybrief KIM::SPECIES_NAME::Au !! !! \sa KIM::SPECIES_NAME::Au, KIM_SPECIES_NAME_Au !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Au") & :: KIM_SPECIES_NAME_AU !> \brief \copybrief KIM::SPECIES_NAME::Hg !! !! \sa KIM::SPECIES_NAME::Hg, KIM_SPECIES_NAME_Hg !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Hg") & :: KIM_SPECIES_NAME_HG !> \brief \copybrief KIM::SPECIES_NAME::Tl !! !! \sa KIM::SPECIES_NAME::Tl, KIM_SPECIES_NAME_Tl !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Tl") & :: KIM_SPECIES_NAME_TL !> \brief \copybrief KIM::SPECIES_NAME::Pb !! !! \sa KIM::SPECIES_NAME::Pb, KIM_SPECIES_NAME_Pb !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pb") & :: KIM_SPECIES_NAME_PB !> \brief \copybrief KIM::SPECIES_NAME::Bi !! !! \sa KIM::SPECIES_NAME::Bi, KIM_SPECIES_NAME_Bi !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Bi") & :: KIM_SPECIES_NAME_BI !> \brief \copybrief KIM::SPECIES_NAME::Po !! !! \sa KIM::SPECIES_NAME::Po, KIM_SPECIES_NAME_Po !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Po") & :: KIM_SPECIES_NAME_PO !> \brief \copybrief KIM::SPECIES_NAME::At !! !! \sa KIM::SPECIES_NAME::At, KIM_SPECIES_NAME_At !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_At") & :: KIM_SPECIES_NAME_AT !> \brief \copybrief KIM::SPECIES_NAME::Rn !! !! \sa KIM::SPECIES_NAME::Rn, KIM_SPECIES_NAME_Rn !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Rn") & :: KIM_SPECIES_NAME_RN !> \brief \copybrief KIM::SPECIES_NAME::Fr !! !! \sa KIM::SPECIES_NAME::Fr, KIM_SPECIES_NAME_Fr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Fr") & :: KIM_SPECIES_NAME_FR !> \brief \copybrief KIM::SPECIES_NAME::Ra !! !! \sa KIM::SPECIES_NAME::Ra, KIM_SPECIES_NAME_Ra !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ra") & :: KIM_SPECIES_NAME_RA !> \brief \copybrief KIM::SPECIES_NAME::Ac !! !! \sa KIM::SPECIES_NAME::Ac, KIM_SPECIES_NAME_Ac !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ac") & :: KIM_SPECIES_NAME_AC !> \brief \copybrief KIM::SPECIES_NAME::Th !! !! \sa KIM::SPECIES_NAME::Th, KIM_SPECIES_NAME_Th !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Th") & :: KIM_SPECIES_NAME_TH !> \brief \copybrief KIM::SPECIES_NAME::Pa !! !! \sa KIM::SPECIES_NAME::Pa, KIM_SPECIES_NAME_Pa !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pa") & :: KIM_SPECIES_NAME_PA !> \brief \copybrief KIM::SPECIES_NAME::U !! !! \sa KIM::SPECIES_NAME::U, KIM_SPECIES_NAME_U !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_U") & :: KIM_SPECIES_NAME_U !> \brief \copybrief KIM::SPECIES_NAME::Np !! !! \sa KIM::SPECIES_NAME::Np, KIM_SPECIES_NAME_Np !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Np") & :: KIM_SPECIES_NAME_NP !> \brief \copybrief KIM::SPECIES_NAME::Pu !! !! \sa KIM::SPECIES_NAME::Pu, KIM_SPECIES_NAME_Pu !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Pu") & :: KIM_SPECIES_NAME_PU !> \brief \copybrief KIM::SPECIES_NAME::Am !! !! \sa KIM::SPECIES_NAME::Am, KIM_SPECIES_NAME_Am !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Am") & :: KIM_SPECIES_NAME_AM !> \brief \copybrief KIM::SPECIES_NAME::Cm !! !! \sa KIM::SPECIES_NAME::Cm, KIM_SPECIES_NAME_Cm !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cm") & :: KIM_SPECIES_NAME_CM !> \brief \copybrief KIM::SPECIES_NAME::Bk !! !! \sa KIM::SPECIES_NAME::Bk, KIM_SPECIES_NAME_Bk !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Bk") & :: KIM_SPECIES_NAME_BK !> \brief \copybrief KIM::SPECIES_NAME::Cf !! !! \sa KIM::SPECIES_NAME::Cf, KIM_SPECIES_NAME_Cf !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cf") & :: KIM_SPECIES_NAME_CF !> \brief \copybrief KIM::SPECIES_NAME::Es !! !! \sa KIM::SPECIES_NAME::Es, KIM_SPECIES_NAME_Es !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Es") & :: KIM_SPECIES_NAME_ES !> \brief \copybrief KIM::SPECIES_NAME::Fm !! !! \sa KIM::SPECIES_NAME::Fm, KIM_SPECIES_NAME_Fm !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Fm") & :: KIM_SPECIES_NAME_FM !> \brief \copybrief KIM::SPECIES_NAME::Md !! !! \sa KIM::SPECIES_NAME::Md, KIM_SPECIES_NAME_Md !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Md") & :: KIM_SPECIES_NAME_MD !> \brief \copybrief KIM::SPECIES_NAME::No !! !! \sa KIM::SPECIES_NAME::No, KIM_SPECIES_NAME_No !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_No") & :: KIM_SPECIES_NAME_NO !> \brief \copybrief KIM::SPECIES_NAME::Lr !! !! \sa KIM::SPECIES_NAME::Lr, KIM_SPECIES_NAME_Lr !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Lr") & :: KIM_SPECIES_NAME_LR !> \brief \copybrief KIM::SPECIES_NAME::Rf !! !! \sa KIM::SPECIES_NAME::Rf, KIM_SPECIES_NAME_Rf !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Rf") & :: KIM_SPECIES_NAME_RF !> \brief \copybrief KIM::SPECIES_NAME::Db !! !! \sa KIM::SPECIES_NAME::Db, KIM_SPECIES_NAME_Db !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Db") & :: KIM_SPECIES_NAME_DB !> \brief \copybrief KIM::SPECIES_NAME::Sg !! !! \sa KIM::SPECIES_NAME::Sg, KIM_SPECIES_NAME_Sg !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Sg") & :: KIM_SPECIES_NAME_SG !> \brief \copybrief KIM::SPECIES_NAME::Bh !! !! \sa KIM::SPECIES_NAME::Bh, KIM_SPECIES_NAME_Bh !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Bh") & :: KIM_SPECIES_NAME_BH !> \brief \copybrief KIM::SPECIES_NAME::Hs !! !! \sa KIM::SPECIES_NAME::Hs, KIM_SPECIES_NAME_Hs !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Hs") & :: KIM_SPECIES_NAME_HS !> \brief \copybrief KIM::SPECIES_NAME::Mt !! !! \sa KIM::SPECIES_NAME::Mt, KIM_SPECIES_NAME_Mt !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Mt") & :: KIM_SPECIES_NAME_MT !> \brief \copybrief KIM::SPECIES_NAME::Ds !! !! \sa KIM::SPECIES_NAME::Ds, KIM_SPECIES_NAME_Ds !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ds") & :: KIM_SPECIES_NAME_DS !> \brief \copybrief KIM::SPECIES_NAME::Rg !! !! \sa KIM::SPECIES_NAME::Rg, KIM_SPECIES_NAME_Rg !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Rg") & :: KIM_SPECIES_NAME_RG !> \brief \copybrief KIM::SPECIES_NAME::Cn !! !! \sa KIM::SPECIES_NAME::Cn, KIM_SPECIES_NAME_Cn !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Cn") & :: KIM_SPECIES_NAME_CN !> \brief \copybrief KIM::SPECIES_NAME::Nh !! !! \sa KIM::SPECIES_NAME::Nh, KIM_SPECIES_NAME_Nh !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Nh") & :: KIM_SPECIES_NAME_NH !> \brief \copybrief KIM::SPECIES_NAME::Fl !! !! \sa KIM::SPECIES_NAME::Fl, KIM_SPECIES_NAME_Fl !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Fl") & :: KIM_SPECIES_NAME_FL !> \brief \copybrief KIM::SPECIES_NAME::Mc !! !! \sa KIM::SPECIES_NAME::Mc, KIM_SPECIES_NAME_Mc !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Mc") & :: KIM_SPECIES_NAME_MC !> \brief \copybrief KIM::SPECIES_NAME::Lv !! !! \sa KIM::SPECIES_NAME::Lv, KIM_SPECIES_NAME_Lv !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Lv") & :: KIM_SPECIES_NAME_LV !> \brief \copybrief KIM::SPECIES_NAME::Ts !! !! \sa KIM::SPECIES_NAME::Ts, KIM_SPECIES_NAME_Ts !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Ts") & :: KIM_SPECIES_NAME_TS !> \brief \copybrief KIM::SPECIES_NAME::Og !! !! \sa KIM::SPECIES_NAME::Og, KIM_SPECIES_NAME_Og !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_Og") & :: KIM_SPECIES_NAME_OG !> \brief \copybrief KIM::SPECIES_NAME::user01 !! !! \sa KIM::SPECIES_NAME::user01, KIM_SPECIES_NAME_user01 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user01") & :: KIM_SPECIES_NAME_USER01 !> \brief \copybrief KIM::SPECIES_NAME::user02 !! !! \sa KIM::SPECIES_NAME::user02, KIM_SPECIES_NAME_user02 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user02") & :: KIM_SPECIES_NAME_USER02 !> \brief \copybrief KIM::SPECIES_NAME::user03 !! !! \sa KIM::SPECIES_NAME::user03, KIM_SPECIES_NAME_user03 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user03") & :: KIM_SPECIES_NAME_USER03 !> \brief \copybrief KIM::SPECIES_NAME::user04 !! !! \sa KIM::SPECIES_NAME::user04, KIM_SPECIES_NAME_user04 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user04") & :: KIM_SPECIES_NAME_USER04 !> \brief \copybrief KIM::SPECIES_NAME::user05 !! !! \sa KIM::SPECIES_NAME::user05, KIM_SPECIES_NAME_user05 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user05") & :: KIM_SPECIES_NAME_USER05 !> \brief \copybrief KIM::SPECIES_NAME::user06 !! !! \sa KIM::SPECIES_NAME::user06, KIM_SPECIES_NAME_user06 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user06") & :: KIM_SPECIES_NAME_USER06 !> \brief \copybrief KIM::SPECIES_NAME::user07 !! !! \sa KIM::SPECIES_NAME::user07, KIM_SPECIES_NAME_user07 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user07") & :: KIM_SPECIES_NAME_USER07 !> \brief \copybrief KIM::SPECIES_NAME::user08 !! !! \sa KIM::SPECIES_NAME::user08, KIM_SPECIES_NAME_user08 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user08") & :: KIM_SPECIES_NAME_USER08 !> \brief \copybrief KIM::SPECIES_NAME::user09 !! !! \sa KIM::SPECIES_NAME::user09, KIM_SPECIES_NAME_user09 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user09") & :: KIM_SPECIES_NAME_USER09 !> \brief \copybrief KIM::SPECIES_NAME::user10 !! !! \sa KIM::SPECIES_NAME::user10, KIM_SPECIES_NAME_user10 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user10") & :: KIM_SPECIES_NAME_USER10 !> \brief \copybrief KIM::SPECIES_NAME::user11 !! !! \sa KIM::SPECIES_NAME::user11, KIM_SPECIES_NAME_user11 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user11") & :: KIM_SPECIES_NAME_USER11 !> \brief \copybrief KIM::SPECIES_NAME::user12 !! !! \sa KIM::SPECIES_NAME::user12, KIM_SPECIES_NAME_user12 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user12") & :: KIM_SPECIES_NAME_USER12 !> \brief \copybrief KIM::SPECIES_NAME::user13 !! !! \sa KIM::SPECIES_NAME::user13, KIM_SPECIES_NAME_user13 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user13") & :: KIM_SPECIES_NAME_USER13 !> \brief \copybrief KIM::SPECIES_NAME::user14 !! !! \sa KIM::SPECIES_NAME::user14, KIM_SPECIES_NAME_user14 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user14") & :: KIM_SPECIES_NAME_USER14 !> \brief \copybrief KIM::SPECIES_NAME::user15 !! !! \sa KIM::SPECIES_NAME::user15, KIM_SPECIES_NAME_user15 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user15") & :: KIM_SPECIES_NAME_USER15 !> \brief \copybrief KIM::SPECIES_NAME::user16 !! !! \sa KIM::SPECIES_NAME::user16, KIM_SPECIES_NAME_user16 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user16") & :: KIM_SPECIES_NAME_USER16 !> \brief \copybrief KIM::SPECIES_NAME::user17 !! !! \sa KIM::SPECIES_NAME::user17, KIM_SPECIES_NAME_user17 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user17") & :: KIM_SPECIES_NAME_USER17 !> \brief \copybrief KIM::SPECIES_NAME::user18 !! !! \sa KIM::SPECIES_NAME::user18, KIM_SPECIES_NAME_user18 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user18") & :: KIM_SPECIES_NAME_USER18 !> \brief \copybrief KIM::SPECIES_NAME::user19 !! !! \sa KIM::SPECIES_NAME::user19, KIM_SPECIES_NAME_user19 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user19") & :: KIM_SPECIES_NAME_USER19 !> \brief \copybrief KIM::SPECIES_NAME::user20 !! !! \sa KIM::SPECIES_NAME::user20, KIM_SPECIES_NAME_user20 !! !! \since 2.0 type(kim_species_name_type), protected, save, & bind(c, name="KIM_SPECIES_NAME_user20") & :: KIM_SPECIES_NAME_USER20 !> \brief \copybrief KIM::SpeciesName::Known !! !! \sa KIM::SpeciesName::Known, KIM_SpeciesName_Known !! !! \since 2.0 interface kim_known module procedure kim_species_name_known end interface kim_known !> \brief \copybrief KIM::SpeciesName::operator==() !! !! \sa KIM::SpeciesName::operator==(), KIM_SpeciesName_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_species_name_equal end interface operator(.eq.) !> \brief \copybrief KIM::SpeciesName::operator!=() !! !! \sa KIM::SpeciesName::operator!=, KIM_SpeciesName_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_species_name_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::SpeciesName::SpeciesName(std::string const &) !! !! \sa KIM::SpeciesName::SpeciesName(std::string const &), !! KIM_SpeciesName_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_species_name_from_string end interface kim_from_string !> \brief \copybrief KIM::SpeciesName::ToString !! !! \sa KIM::SpeciesName::ToString, KIM_SpeciesName_ToSting !! !! \since 2.0 interface kim_to_string module procedure kim_species_name_to_string end interface kim_to_string contains !> \brief \copybrief KIM::SpeciesName::Known !! !! \sa KIM::SpeciesName::Known, KIM_SpeciesName_Known !! !! \since 2.0 logical recursive function kim_species_name_known(species_name) implicit none interface integer(c_int) recursive function known(species_name) & bind(c, name="KIM_SpeciesName_Known") use, intrinsic :: iso_c_binding import kim_species_name_type implicit none type(kim_species_name_type), intent(in), value :: species_name end function known end interface type(kim_species_name_type), intent(in) :: species_name kim_species_name_known = (known(species_name) /= 0) end function kim_species_name_known !> \brief \copybrief KIM::SpeciesName::operator==() !! !! \sa KIM::SpeciesName::operator==(), KIM_SpeciesName_Equal !! !! \since 2.0 logical recursive function kim_species_name_equal(lhs, rhs) implicit none type(kim_species_name_type), intent(in) :: lhs type(kim_species_name_type), intent(in) :: rhs kim_species_name_equal & = (lhs%species_name_id == rhs%species_name_id) end function kim_species_name_equal !> \brief \copybrief KIM::SpeciesName::operator!=() !! !! \sa KIM::SpeciesName::operator!=, KIM_SpeciesName_NotEqual !! !! \since 2.0 logical recursive function kim_species_name_not_equal(lhs, rhs) implicit none type(kim_species_name_type), intent(in) :: lhs type(kim_species_name_type), intent(in) :: rhs kim_species_name_not_equal = .not. (lhs == rhs) end function kim_species_name_not_equal !> \brief \copybrief KIM::SpeciesName::SpeciesName(std::string const &) !! !! \sa KIM::SpeciesName::SpeciesName(std::string const &), !! KIM_SpeciesName_FromString !! !! \since 2.0 recursive subroutine kim_species_name_from_string(string, species_name) implicit none interface type(kim_species_name_type) recursive function from_string(string) & bind(c, name="KIM_SpeciesName_FromString") use, intrinsic :: iso_c_binding import kim_species_name_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_species_name_type), intent(out) :: species_name species_name = from_string(trim(string)//c_null_char) end subroutine kim_species_name_from_string !> \brief \copybrief KIM::SpeciesName::ToString !! !! \sa KIM::SpeciesName::ToString, KIM_SpeciesName_ToSting !! !! \since 2.0 recursive subroutine kim_species_name_to_string(species_name, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(species_name) & bind(c, name="KIM_SpeciesName_ToString") use, intrinsic :: iso_c_binding import kim_species_name_type implicit none type(kim_species_name_type), intent(in), value :: species_name end function get_string end interface type(kim_species_name_type), intent(in) :: species_name character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(species_name) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_species_name_to_string !> \brief \copybrief KIM::SPECIES_NAME::GetNumberOfSpeciesNames !! !! \sa KIM::SPECIES_NAME::GetNumberOfSpeciesNames, !! KIM_SPECIES_NAME_GetNumberOfSpeciesNames !! !! \since 2.0 recursive subroutine kim_get_number_of_species_names(number_of_species_names) implicit none interface recursive subroutine get_number_of_species_names( & number_of_species_names) & bind(c, name="KIM_SPECIES_NAME_GetNumberOfSpeciesNames") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_species_names end subroutine get_number_of_species_names end interface integer(c_int), intent(out) :: number_of_species_names call get_number_of_species_names(number_of_species_names) end subroutine kim_get_number_of_species_names !> \brief \copybrief KIM::SPECIES_NAME::GetSpeciesName !! !! \sa KIM::SPECIES_NAME::GetSpeciesName, KIM_SPECIES_NAME_GetSpeciesName !! !! \since 2.0 recursive subroutine kim_get_species_name(index, species_name, ierr) implicit none interface integer(c_int) recursive function get_species_name(index, species_name) & bind(c, name="KIM_SPECIES_NAME_GetSpeciesName") use, intrinsic :: iso_c_binding import kim_species_name_type implicit none integer(c_int), intent(in), value :: index type(kim_species_name_type), intent(out) :: species_name end function get_species_name end interface integer(c_int), intent(in) :: index type(kim_species_name_type), intent(out) :: species_name integer(c_int), intent(out) :: ierr ierr = get_species_name(index - 1, species_name) end subroutine kim_get_species_name end module kim_species_name_module kim-api-2.3.0-git/fortran/include/kim_support_status_module.f90000066400000000000000000000233441421473465500246070ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::SupportStatus !! !! \sa KIM::SupportStatus, KIM_SupportStatus !! !! \since 2.0 module kim_support_status_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_support_status_type, & ! Constants KIM_SUPPORT_STATUS_REQUIRED_BY_API, & KIM_SUPPORT_STATUS_NOT_SUPPORTED, & KIM_SUPPORT_STATUS_REQUIRED, & KIM_SUPPORT_STATUS_OPTIONAL, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_support_statuses, & kim_get_support_status !> \brief \copybrief KIM::SupportStatus !! !! \sa KIM::SupportStatus, KIM_SupportStatus !! !! \since 2.0 type, bind(c) :: kim_support_status_type !> \brief \copybrief KIM::SupportStatus::supportStatusID !! !! \sa KIM::SupportStatus::supportStatusID, !! KIM_SupportStatus::supportStatusID !! !! \since 2.0 integer(c_int) :: support_status_id end type kim_support_status_type !> \brief \copybrief KIM::SUPPORT_STATUS::requiredByAPI !! !! \sa KIM::SUPPORT_STATUS::requiredByAPI, KIM_SUPPORT_STATUS_requiredByAPI !! !! \since 2.0 type(kim_support_status_type), protected, save, & bind(c, name="KIM_SUPPORT_STATUS_requiredByAPI") & :: KIM_SUPPORT_STATUS_REQUIRED_BY_API !> \brief \copybrief KIM::SUPPORT_STATUS::notSupported !! !! \sa KIM::SUPPORT_STATUS::notSupported, KIM_SUPPORT_STATUS_notSupported !! !! \since 2.0 type(kim_support_status_type), protected, save, & bind(c, name="KIM_SUPPORT_STATUS_notSupported") & :: KIM_SUPPORT_STATUS_NOT_SUPPORTED !> \brief \copybrief KIM::SUPPORT_STATUS::required !! !! \sa KIM::SUPPORT_STATUS::required, KIM_SUPPORT_STATUS_required !! !! \since 2.0 type(kim_support_status_type), protected, save, & bind(c, name="KIM_SUPPORT_STATUS_required") & :: KIM_SUPPORT_STATUS_REQUIRED !> \brief \copybrief KIM::SUPPORT_STATUS::optional !! !! \sa KIM::SUPPORT_STATUS::optional, KIM_SUPPORT_STATUS_optional !! !! \since 2.0 type(kim_support_status_type), protected, save, & bind(c, name="KIM_SUPPORT_STATUS_optional") & :: KIM_SUPPORT_STATUS_OPTIONAL !> \brief \copybrief KIM::SupportStatus::Known !! !! \sa KIM::SupportStatus::Known, KIM_SupportStatus_Known !! !! \since 2.0 interface kim_known module procedure kim_support_status_known end interface kim_known !> \brief \copybrief KIM::SupportStatus::operator==() !! !! \sa KIM::SupportStatus::operator==(), KIM_SupportStatus_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_support_status_equal end interface operator(.eq.) !> \brief \copybrief KIM::SupportStatus::operator!=() !! !! \sa KIM::SupportStatus::operator!=(), KIM_SupportStatus_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_support_status_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::SupportStatus::SupportStatus(std::string const &) !! !! \sa KIM::SupportStatus::SupportStatus(std::string const &), !! KIM_SupportStatus_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_support_status_from_string end interface kim_from_string !> \brief \copybrief KIM::SupportStatus::ToString !! !! \sa KIM::SupportStatus::ToString, KIM_SupportStatus_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_support_status_to_string end interface kim_to_string contains !> \brief \copybrief KIM::SupportStatus::Known !! !! \sa KIM::SupportStatus::Known, KIM_SupportStatus_Known !! !! \since 2.0 logical recursive function kim_support_status_known(support_status) implicit none interface integer(c_int) recursive function known(support_status) & bind(c, name="KIM_SupportStatus_Known") use, intrinsic :: iso_c_binding import kim_support_status_type implicit none type(kim_support_status_type), intent(in), value :: support_status end function known end interface type(kim_support_status_type), intent(in) :: support_status kim_support_status_known = (known(support_status) /= 0) end function kim_support_status_known !> \brief \copybrief KIM::SupportStatus::operator==() !! !! \sa KIM::SupportStatus::operator==(), KIM_SupportStatus_Equal !! !! \since 2.0 logical recursive function kim_support_status_equal(lhs, rhs) implicit none type(kim_support_status_type), intent(in) :: lhs type(kim_support_status_type), intent(in) :: rhs kim_support_status_equal & = (lhs%support_status_id == rhs%support_status_id) end function kim_support_status_equal !> \brief \copybrief KIM::SupportStatus::operator!=() !! !! \sa KIM::SupportStatus::operator!=(), KIM_SupportStatus_NotEqual !! !! \since 2.0 logical recursive function kim_support_status_not_equal(lhs, rhs) implicit none type(kim_support_status_type), intent(in) :: lhs type(kim_support_status_type), intent(in) :: rhs kim_support_status_not_equal = .not. (lhs == rhs) end function kim_support_status_not_equal !> \brief \copybrief KIM::SupportStatus::SupportStatus(std::string const &) !! !! \sa KIM::SupportStatus::SupportStatus(std::string const &), !! KIM_SupportStatus_FromString !! !! \since 2.0 recursive subroutine kim_support_status_from_string(string, support_status) implicit none interface type(kim_support_status_type) recursive function from_string(string) & bind(c, name="KIM_SupportStatus_FromString") use, intrinsic :: iso_c_binding import kim_support_status_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_support_status_type), intent(out) :: support_status support_status = from_string(trim(string)//c_null_char) end subroutine kim_support_status_from_string !> \brief \copybrief KIM::SupportStatus::ToString !! !! \sa KIM::SupportStatus::ToString, KIM_SupportStatus_ToString !! !! \since 2.0 recursive subroutine kim_support_status_to_string(support_status, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(support_status) & bind(c, name="KIM_SupportStatus_ToString") use, intrinsic :: iso_c_binding import kim_support_status_type implicit none type(kim_support_status_type), intent(in), value :: support_status end function get_string end interface type(kim_support_status_type), intent(in) :: support_status character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(support_status) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_support_status_to_string !> \brief \copybrief KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses !! !! \sa KIM::SUPPORT_STATUS::GetNumberOfSupportStatuses, !! KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses !! !! \since 2.0 recursive subroutine kim_get_number_of_support_statuses( & number_of_support_statuses) implicit none interface recursive subroutine get_number_of_support_statuses( & number_of_support_statuses) & bind(c, name="KIM_SUPPORT_STATUS_GetNumberOfSupportStatuses") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_support_statuses end subroutine get_number_of_support_statuses end interface integer(c_int), intent(out) :: number_of_support_statuses call get_number_of_support_statuses(number_of_support_statuses) end subroutine kim_get_number_of_support_statuses !> \brief \copybrief KIM::SUPPORT_STATUS::GetSupportStatus !! !! \sa KIM::SUPPORT_STATUS::GetSupportStatus, !! KIM_SUPPORT_STATUS_GetSupportStatus !! !! \since 2.0 recursive subroutine kim_get_support_status(index, support_status, ierr) implicit none interface integer(c_int) recursive function get_support_status(index, & support_status) & bind(c, name="KIM_SUPPORT_STATUS_GetSupportStatus") use, intrinsic :: iso_c_binding import kim_support_status_type implicit none integer(c_int), intent(in), value :: index type(kim_support_status_type), intent(out) :: support_status end function get_support_status end interface integer(c_int), intent(in) :: index type(kim_support_status_type), intent(out) :: support_status integer(c_int), intent(out) :: ierr ierr = get_support_status(index - 1, support_status) end subroutine kim_get_support_status end module kim_support_status_module kim-api-2.3.0-git/fortran/include/kim_supported_extensions_module.f90000066400000000000000000000055261421473465500257760ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::SupportedExtensions !! !! \sa KIM::SupportedExtensions, KIM_SupportedExtensions !! !! \since 2.0 module kim_supported_extensions_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_supported_extensions_type, & ! Constants KIM_SUPPORTED_EXTENSIONS_ID, & KIM_MAX_EXTENSION_ID_LENGTH, & KIM_MAX_NUMBER_OF_EXTENSIONS character(len=*, kind=c_char), parameter & :: KIM_SUPPORTED_EXTENSIONS_ID = "KIM_SupportedExtensions" integer(c_int), parameter :: KIM_MAX_EXTENSION_ID_LENGTH = 128 integer(c_int), parameter :: KIM_MAX_NUMBER_OF_EXTENSIONS = 64 !> \brief \copybrief KIM::SupportedExtensions !! !! \sa KIM::SupportedExtensions, KIM_SupportedExtensions !! !! \since 2.0 type, bind(c) :: kim_supported_extensions_type !> \brief \copybrief KIM::SupportedExtensions::numberOfSupportedExtensions !! !! \sa KIM::SupportedExtensions::numberOfSupportedExtensions, !! KIM_SupportedExtensions::numberOfSupportedExtensions !! !! \since 2.0 integer(c_int) number_of_supported_extensions !> \brief \copybrief KIM::SupportedExtensions::supportedExtensionID !! !! \sa KIM::SupportedExtensions::supportedExtensionID, !! KIM_SupportedExtensions::supportedExtensionID !! !! \since 2.0 character(c_char) supported_extension_id(KIM_MAX_EXTENSION_ID_LENGTH, & KIM_MAX_NUMBER_OF_EXTENSIONS) !> \brief \copybrief KIM::SupportedExtensions::supportedExtensionRequired !! !! \sa KIM::SupportedExtensions::supportedExtensionRequired, !! KIM_SupportedExtensions::supportedExtensionRequired !! !! \since 2.0 integer(c_int) supported_extension_required(KIM_MAX_NUMBER_OF_EXTENSIONS) end type kim_supported_extensions_type end module kim_supported_extensions_module kim-api-2.3.0-git/fortran/include/kim_temperature_unit_module.f90000066400000000000000000000226311421473465500250620ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::TemperatureUnit !! !! \sa KIM::TemperatureUnit, KIM_TemperatureUnit !! !! \since 2.0 module kim_temperature_unit_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived type kim_temperature_unit_type, & ! Constants KIM_TEMPERATURE_UNIT_UNUSED, & KIM_TEMPERATURE_UNIT_K, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_temperature_units, & kim_get_temperature_unit !> \brief \copybrief KIM::TemperatureUnit !! !! \sa KIM::TemperatureUnit, KIM_TemperatureUnit !! !! \since 2.0 type, bind(c) :: kim_temperature_unit_type !> \brief \copybrief KIM::TemperatureUnit::temperatureUnitID !! !! \sa KIM::TemperatureUnit::temperatureUnitID, !! KIM_TemperatureUnit::temperatureUnitID !! !! \since 2.0 integer(c_int) temperature_unit_id end type kim_temperature_unit_type !> \brief \copybrief KIM::TEMPERATURE_UNIT::unused !! !! \sa KIM::TEMPERATURE_UNIT::, KIM_TEMPERATURE_UNIT_unused !! !! \since 2.0 type(kim_temperature_unit_type), protected, save, & bind(c, name="KIM_TEMPERATURE_UNIT_unused") & :: KIM_TEMPERATURE_UNIT_UNUSED !> \brief \copybrief KIM::TEMPERATURE_UNIT::K !! !! \sa KIM::TEMPERATURE_UNIT::K, KIM_TEMPERATURE_UNIT_K !! !! \since 2.0 type(kim_temperature_unit_type), protected, save, & bind(c, name="KIM_TEMPERATURE_UNIT_K") & :: KIM_TEMPERATURE_UNIT_K !> \brief \copybrief KIM::TemperatureUnit::Known !! !! \sa KIM::TemperatureUnit::Known, KIM_TemperatureUnit_Known !! !! \since 2.0 interface kim_known module procedure kim_temperature_unit_known end interface kim_known !> \brief \copybrief KIM::TemperatureUnit::operator==() !! !! \sa KIM::TemperatureUnit::operator==(), KIM_TemperatureUnit_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_temperature_unit_equal end interface operator(.eq.) !> \brief \copybrief KIM::TemperatureUnit::operator!=() !! !! \sa KIM::TemperatureUnit::operator!=(), KIM_TemperatureUnit_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_temperature_unit_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::TemperatureUnit::TemperatureUnit(std::string const &) !! !! \sa KIM::TemperatureUnit::TemperatureUnit(std::string const &), !! KIM_TemperatureUnit_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_temperature_unit_from_string end interface kim_from_string !> \brief \copybrief KIM::TemperatureUnit::ToString !! !! \sa KIM::TemperatureUnit::ToString, KIM_TemperatureUnit_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_temperature_unit_to_string end interface kim_to_string contains !> \brief \copybrief KIM::TemperatureUnit::Known !! !! \sa KIM::TemperatureUnit::Known, KIM_TemperatureUnit_Known !! !! \since 2.0 logical recursive function kim_temperature_unit_known(temperature_unit) implicit none interface integer(c_int) recursive function known(temperature_unit) & bind(c, name="KIM_TemperatureUnit_Known") use, intrinsic :: iso_c_binding import kim_temperature_unit_type implicit none type(kim_temperature_unit_type), intent(in), value :: temperature_unit end function known end interface type(kim_temperature_unit_type), intent(in) :: temperature_unit kim_temperature_unit_known = (known(temperature_unit) /= 0) end function kim_temperature_unit_known !> \brief \copybrief KIM::TemperatureUnit::operator==() !! !! \sa KIM::TemperatureUnit::operator==(), KIM_TemperatureUnit_Equal !! !! \since 2.0 logical recursive function kim_temperature_unit_equal(lhs, rhs) implicit none type(kim_temperature_unit_type), intent(in) :: lhs type(kim_temperature_unit_type), intent(in) :: rhs kim_temperature_unit_equal & = (lhs%temperature_unit_id == rhs%temperature_unit_id) end function kim_temperature_unit_equal !> \brief \copybrief KIM::TemperatureUnit::operator!=() !! !! \sa KIM::TemperatureUnit::operator!=(), KIM_TemperatureUnit_NotEqual !! !! \since 2.0 logical recursive function kim_temperature_unit_not_equal(lhs, rhs) implicit none type(kim_temperature_unit_type), intent(in) :: lhs type(kim_temperature_unit_type), intent(in) :: rhs kim_temperature_unit_not_equal = .not. (lhs == rhs) end function kim_temperature_unit_not_equal !> \brief \copybrief KIM::TemperatureUnit::TemperatureUnit(std::string const &) !! !! \sa KIM::TemperatureUnit::TemperatureUnit(std::string const &), !! KIM_TemperatureUnit_FromString !! !! \since 2.0 recursive subroutine kim_temperature_unit_from_string(string, & temperature_unit) implicit none interface type(kim_temperature_unit_type) recursive function from_string(string) & bind(c, name="KIM_TemperatureUnit_FromString") use, intrinsic :: iso_c_binding import kim_temperature_unit_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_temperature_unit_type), intent(out) :: temperature_unit temperature_unit = from_string(trim(string)//c_null_char) end subroutine kim_temperature_unit_from_string !> \brief \copybrief KIM::TemperatureUnit::ToString !! !! \sa KIM::TemperatureUnit::ToString, KIM_TemperatureUnit_ToString !! !! \since 2.0 recursive subroutine kim_temperature_unit_to_string(temperature_unit, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(temperature_unit) & bind(c, name="KIM_TemperatureUnit_ToString") use, intrinsic :: iso_c_binding import kim_temperature_unit_type implicit none type(kim_temperature_unit_type), intent(in), value :: temperature_unit end function get_string end interface type(kim_temperature_unit_type), intent(in) :: temperature_unit character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(temperature_unit) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_temperature_unit_to_string !> \brief \copybrief KIM::TEMPERATURE_UNIT::GetNumberOfTemperatureUnits !! !! \sa KIM::TEMPERATURE_UNIT::GetNumberOfTemperatureUnits, !! KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits !! !! \since 2.0 recursive subroutine kim_get_number_of_temperature_units( & number_of_temperature_units) implicit none interface recursive subroutine get_number_of_temperature_units( & number_of_temperature_units) & bind(c, name="KIM_TEMPERATURE_UNIT_GetNumberOfTemperatureUnits") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_temperature_units end subroutine get_number_of_temperature_units end interface integer(c_int), intent(out) :: number_of_temperature_units call get_number_of_temperature_units(number_of_temperature_units) end subroutine kim_get_number_of_temperature_units !> \brief \copybrief KIM::TEMPERATURE_UNIT::GetTemperatureUnit !! !! \sa KIM::TEMPERATURE_UNIT::GetTemperatureUnit, !! KIM_TEMPERATURE_UNIT_GetTemperatureUnit !! !! \since 2.0 recursive subroutine kim_get_temperature_unit(index, & temperature_unit, ierr) implicit none interface integer(c_int) recursive function get_temperature_unit(index, & temperature_unit) & bind(c, name="KIM_TEMPERATURE_UNIT_GetTemperatureUnit") use, intrinsic :: iso_c_binding import kim_temperature_unit_type implicit none integer(c_int), intent(in), value :: index type(kim_temperature_unit_type), intent(out) :: temperature_unit end function get_temperature_unit end interface integer(c_int), intent(in) :: index type(kim_temperature_unit_type), intent(out) :: temperature_unit integer(c_int), intent(out) :: ierr ierr = get_temperature_unit(index - 1, temperature_unit) end subroutine kim_get_temperature_unit end module kim_temperature_unit_module kim-api-2.3.0-git/fortran/include/kim_time_unit_module.f90000066400000000000000000000215221421473465500234610ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! !> \brief \copybrief KIM::TimeUnit !! !! \sa KIM::TimeUnit, KIM_TimeUnit !! !! \since 2.0 module kim_time_unit_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_time_unit_type, & ! Constants KIM_TIME_UNIT_UNUSED, & KIM_TIME_UNIT_FS, & KIM_TIME_UNIT_PS, & KIM_TIME_UNIT_NS, & KIM_TIME_UNIT_S, & ! Routines kim_known, & operator(.eq.), & operator(.ne.), & kim_from_string, & kim_to_string, & kim_get_number_of_time_units, & kim_get_time_unit !> \brief \copybrief KIM::TimeUnit !! !! \sa KIM::TimeUnit, KIM_TimeUnit !! !! \since 2.0 type, bind(c) :: kim_time_unit_type !> \brief \copybrief KIM::TimeUnit::timeUnitID !! !! \sa KIM::TimeUnit::timeUnitID, KIM_TimeUnit::timeUnitID !! !! \since 2.0 integer(c_int) time_unit_id end type kim_time_unit_type !> \brief \copybrief KIM::TIME_UNIT::unused !! !! \sa KIM::TIME_UNIT::unused, KIM_TIME_UNIT_unused !! !! \since 2.0 type(kim_time_unit_type), protected, save, & bind(c, name="KIM_TIME_UNIT_unused") & :: KIM_TIME_UNIT_UNUSED !> \brief \copybrief KIM::TIME_UNIT::fs !! !! \sa KIM::TIME_UNIT::fs, KIM_TIME_UNIT_fs !! !! \since 2.0 type(kim_time_unit_type), protected, save, & bind(c, name="KIM_TIME_UNIT_fs") & :: KIM_TIME_UNIT_FS !> \brief \copybrief KIM::TIME_UNIT::ps !! !! \sa KIM::TIME_UNIT::ps, KIM_TIME_UNIT_ps !! !! \since 2.0 type(kim_time_unit_type), protected, save, & bind(c, name="KIM_TIME_UNIT_ps") & :: KIM_TIME_UNIT_PS !> \brief \copybrief KIM::TIME_UNIT::ns !! !! \sa KIM::TIME_UNIT::ns, KIM_TIME_UNIT_ns !! !! \since 2.0 type(kim_time_unit_type), protected, save, & bind(c, name="KIM_TIME_UNIT_ns") & :: KIM_TIME_UNIT_NS !> \brief \copybrief KIM::TIME_UNIT::s !! !! \sa KIM::TIME_UNIT::s, KIM_TIME_UNIT_s !! !! \since 2.0 type(kim_time_unit_type), protected, save, & bind(c, name="KIM_TIME_UNIT_s") & :: KIM_TIME_UNIT_S !> \brief \copybrief KIM::TimeUnit::Known !! !! \sa KIM::TimeUnit::Known, KIM_TimeUnit_Known !! !! \since 2.0 interface kim_known module procedure kim_time_unit_known end interface kim_known !> \brief \copybrief KIM::TimeUnit::operator==() !! !! \sa KIM::TimeUnit::operator==(), KIM_TimeUnit_Equal !! !! \since 2.0 interface operator(.eq.) module procedure kim_time_unit_equal end interface operator(.eq.) !> \brief \copybrief KIM::TimeUnit::operator!=() !! !! \sa KIM::TimeUnit::operator!=(), KIM_TimeUnit_NotEqual !! !! \since 2.0 interface operator(.ne.) module procedure kim_time_unit_not_equal end interface operator(.ne.) !> \brief \copybrief KIM::TimeUnit::TimeUnit(std::string const &) !! !! \sa KIM::TimeUnit::TimeUnit(std::string const &), KIM_TimeUnit_FromString !! !! \since 2.0 interface kim_from_string module procedure kim_time_unit_from_string end interface kim_from_string !> \brief \copybrief KIM::TimeUnit::ToString !! !! \sa KIM::TimeUnit::ToString, KIM_TimeUnit_ToString !! !! \since 2.0 interface kim_to_string module procedure kim_time_unit_to_string end interface kim_to_string contains !> \brief \copybrief KIM::TimeUnit::Known !! !! \sa KIM::TimeUnit::Known, KIM_TimeUnit_Known !! !! \since 2.0 logical recursive function kim_time_unit_known(time_unit) implicit none interface integer(c_int) recursive function known(time_unit) & bind(c, name="KIM_TimeUnit_Known") use, intrinsic :: iso_c_binding import kim_time_unit_type implicit none type(kim_time_unit_type), intent(in), value :: time_unit end function known end interface type(kim_time_unit_type), intent(in) :: time_unit kim_time_unit_known = (known(time_unit) /= 0) end function kim_time_unit_known !> \brief \copybrief KIM::TimeUnit::operator==() !! !! \sa KIM::TimeUnit::operator==(), KIM_TimeUnit_Equal !! !! \since 2.0 logical recursive function kim_time_unit_equal(lhs, rhs) implicit none type(kim_time_unit_type), intent(in) :: lhs type(kim_time_unit_type), intent(in) :: rhs kim_time_unit_equal = (lhs%time_unit_id == rhs%time_unit_id) end function kim_time_unit_equal !> \brief \copybrief KIM::TimeUnit::operator!=() !! !! \sa KIM::TimeUnit::operator!=(), KIM_TimeUnit_NotEqual !! !! \since 2.0 logical recursive function kim_time_unit_not_equal(lhs, rhs) implicit none type(kim_time_unit_type), intent(in) :: lhs type(kim_time_unit_type), intent(in) :: rhs kim_time_unit_not_equal = .not. (lhs == rhs) end function kim_time_unit_not_equal !> \brief \copybrief KIM::TimeUnit::TimeUnit(std::string const &) !! !! \sa KIM::TimeUnit::TimeUnit(std::string const &), KIM_TimeUnit_FromString !! !! \since 2.0 recursive subroutine kim_time_unit_from_string(string, time_unit) implicit none interface type(kim_time_unit_type) recursive function from_string(string) & bind(c, name="KIM_TimeUnit_FromString") use, intrinsic :: iso_c_binding import kim_time_unit_type implicit none character(c_char), intent(in) :: string(*) end function from_string end interface character(len=*, kind=c_char), intent(in) :: string type(kim_time_unit_type), intent(out) :: time_unit time_unit = from_string(trim(string)//c_null_char) end subroutine kim_time_unit_from_string !> \brief \copybrief KIM::TimeUnit::ToString !! !! \sa KIM::TimeUnit::ToString, KIM_TimeUnit_ToString !! !! \since 2.0 recursive subroutine kim_time_unit_to_string(time_unit, string) use kim_convert_string_module, only: kim_convert_c_char_ptr_to_string implicit none interface type(c_ptr) recursive function get_string(time_unit) & bind(c, name="KIM_TimeUnit_ToString") use, intrinsic :: iso_c_binding import kim_time_unit_type implicit none type(kim_time_unit_type), intent(in), value :: time_unit end function get_string end interface type(kim_time_unit_type), intent(in) :: time_unit character(len=*, kind=c_char), intent(out) :: string type(c_ptr) :: p p = get_string(time_unit) call kim_convert_c_char_ptr_to_string(p, string) end subroutine kim_time_unit_to_string !> \brief \copybrief KIM::TIME_UNIT::GetNumberOfTimeUnits !! !! \sa KIM::TIME_UNIT::GetNumberOfTimeUnits, !! KIM_TIME_UNIT_GetNumberOfTimeUnits !! !! \since 2.0 recursive subroutine kim_get_number_of_time_units(number_of_time_units) implicit none interface recursive subroutine get_number_of_time_units(number_of_time_units) & bind(c, name="KIM_TIME_UNIT_GetNumberOfTimeUnits") use, intrinsic :: iso_c_binding implicit none integer(c_int), intent(out) :: number_of_time_units end subroutine get_number_of_time_units end interface integer(c_int), intent(out) :: number_of_time_units call get_number_of_time_units(number_of_time_units) end subroutine kim_get_number_of_time_units !> \brief \copybrief KIM::TIME_UNIT::GetTimeUnit !! !! \sa KIM::TIME_UNIT::GetTimeUnit, KIM_TIME_UNIT_GetTimeUnit !! !! \since 2.0 recursive subroutine kim_get_time_unit(index, time_unit, ierr) implicit none interface integer(c_int) recursive function get_time_unit(index, time_unit) & bind(c, name="KIM_TIME_UNIT_GetTimeUnit") use, intrinsic :: iso_c_binding import kim_time_unit_type implicit none integer(c_int), intent(in), value :: index type(kim_time_unit_type), intent(out) :: time_unit end function get_time_unit end interface integer(c_int), intent(in) :: index type(kim_time_unit_type), intent(out) :: time_unit integer(c_int), intent(out) :: ierr ierr = get_time_unit(index - 1, time_unit) end subroutine kim_get_time_unit end module kim_time_unit_module kim-api-2.3.0-git/fortran/include/kim_unit_system_module.f90000066400000000000000000000023731421473465500240520ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! module kim_unit_system_module use, intrinsic :: iso_c_binding use kim_length_unit_module use kim_energy_unit_module use kim_charge_unit_module use kim_temperature_unit_module use kim_time_unit_module public end module kim_unit_system_module kim-api-2.3.0-git/fortran/src/000077500000000000000000000000001421473465500161015ustar00rootroot00000000000000kim-api-2.3.0-git/fortran/src/CMakeLists.txt000066400000000000000000000023441421473465500206440ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # set(F_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/kim_convert_string_module.f90 ${CMAKE_CURRENT_SOURCE_DIR}/kim_interoperable_types_module.f90 ) target_sources(kim-api PRIVATE ${F_SOURCES}) kim-api-2.3.0-git/fortran/src/kim_convert_string_module.f90000066400000000000000000000055531421473465500237040ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! module kim_convert_string_module implicit none private public & kim_convert_c_char_array_to_string, & kim_convert_c_char_ptr_to_string, & kim_convert_string_to_c_char_array contains recursive subroutine kim_convert_c_char_array_to_string(c_char_array, string) use, intrinsic :: iso_c_binding implicit none character(len=1, kind=c_char), intent(in) :: c_char_array(:) character(len=*, kind=c_char), intent(out) :: string integer(c_int) :: i integer(c_int) :: null_index integer(c_int) :: length length = len(string) + 1 do null_index = 1, length if (c_char_array(null_index) == c_null_char) exit end do if (null_index == length) then null_index = len(string) else null_index = null_index - 1 end if string = "" do i = 1, null_index string(i:i) = c_char_array(i) end do end subroutine kim_convert_c_char_array_to_string recursive subroutine kim_convert_c_char_ptr_to_string(c_char_ptr, string) use, intrinsic :: iso_c_binding implicit none type(c_ptr), intent(in) :: c_char_ptr character(len=*, kind=c_char), intent(out) :: string character(len=1, kind=c_char), pointer :: fp(:) integer(c_int) :: length if (c_associated(c_char_ptr)) then length = len(string) + 1 call c_f_pointer(c_char_ptr, fp, [length]) call kim_convert_c_char_array_to_string(fp, string) else string = "" end if end subroutine kim_convert_c_char_ptr_to_string recursive subroutine kim_convert_string_to_c_char_array(string, c_char_array) use, intrinsic :: iso_c_binding implicit none character(len=*, kind=c_char), intent(in) :: string character(len=1, kind=c_char), intent(out) :: c_char_array(:) c_char_array(:) = trim(string)//c_null_char end subroutine kim_convert_string_to_c_char_array end module kim_convert_string_module kim-api-2.3.0-git/fortran/src/kim_interoperable_types_module.f90000066400000000000000000000065771421473465500247240ustar00rootroot00000000000000! ! KIM-API: An API for interatomic models ! Copyright (c) 2013--2022, Regents of the University of Minnesota. ! All rights reserved. ! ! Contributors: ! Ryan S. Elliott ! ! SPDX-License-Identifier: LGPL-2.1-or-later ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with this library; if not, write to the Free Software Foundation, ! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ! ! ! Release: This file is part of the kim-api.git repository. ! module kim_interoperable_types_module use, intrinsic :: iso_c_binding implicit none private public & ! Derived types kim_collections_type, & kim_compute_arguments_type, & kim_log_type, & kim_model_compute_arguments_create_type, & kim_model_compute_arguments_destroy_type, & kim_model_compute_arguments_type, & kim_model_compute_type, & kim_model_create_type, & kim_model_extension_type, & kim_model_destroy_type, & kim_model_driver_create_type, & kim_model_type, & kim_model_refresh_type, & kim_model_write_parameterized_model_type, & kim_simulator_model_type type, bind(c) :: kim_collections_type private type(c_ptr) :: p end type kim_collections_type type, bind(c) :: kim_compute_arguments_type private type(c_ptr) :: p end type kim_compute_arguments_type type, bind(c) :: kim_log_type private type(c_ptr) :: p end type kim_log_type type, bind(c) :: kim_model_compute_arguments_create_type private type(c_ptr) :: p end type kim_model_compute_arguments_create_type type, bind(c) :: kim_model_compute_arguments_destroy_type private type(c_ptr) :: p end type kim_model_compute_arguments_destroy_type type, bind(c) :: kim_model_compute_arguments_type private type(c_ptr) :: p end type kim_model_compute_arguments_type type, bind(c) :: kim_model_compute_type private type(c_ptr) :: p end type kim_model_compute_type type, bind(c) :: kim_model_create_type private type(c_ptr) :: p end type kim_model_create_type type, bind(c) :: kim_model_extension_type private type(c_ptr) :: p end type kim_model_extension_type type, bind(c) :: kim_model_destroy_type private type(c_ptr) :: p end type kim_model_destroy_type type, bind(c) :: kim_model_driver_create_type private type(c_ptr) :: p end type kim_model_driver_create_type type, bind(c) :: kim_model_type private type(c_ptr) :: p end type kim_model_type type, bind(c) :: kim_model_refresh_type private type(c_ptr) :: p end type kim_model_refresh_type type, bind(c) :: kim_model_write_parameterized_model_type private type(c_ptr) :: p end type kim_model_write_parameterized_model_type type, bind(c) :: kim_simulator_model_type private type(c_ptr) :: p end type kim_simulator_model_type end module kim_interoperable_types_module kim-api-2.3.0-git/pkg-config/000077500000000000000000000000001421473465500156635ustar00rootroot00000000000000kim-api-2.3.0-git/pkg-config/CMakeLists.txt000066400000000000000000000071101421473465500204220ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # use 'lib' instead of '${CMAKE_SHARED_LIBRARY_PREFIX}' here to have consistency # of pkg-config usage across systems. set(PKG_CONFIG_FILE "lib${PROJECT_NAME}.pc") relocatable_path( FROM "${CMAKE_INSTALL_FULL_LIBDIR}/${KIM_API_PKG_CONFIG_DIR_IDENTIFIER}" FROM_REL "${CMAKE_INSTALL_RELOC_LIBDIR}" TO "${CMAKE_INSTALL_PREFIX}" TO_REL "./" PREFIX "\${pcfiledir}" RESULT_VARIABLE _installdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_BINDIR}" TO_REL "${CMAKE_INSTALL_RELOC_BINDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _bindir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_LIBEXECDIR}" TO_REL "${CMAKE_INSTALL_RELOC_LIBEXECDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _libexecdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_SYSCONFDIR}" TO_REL "${CMAKE_INSTALL_RELOC_SYSCONFDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _sysconfdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_LIBDIR}" TO_REL "${CMAKE_INSTALL_RELOC_LIBDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _libdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_INCLUDEDIR}" TO_REL "${CMAKE_INSTALL_RELOC_INCLUDEDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _includedir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/${KIM_API_Fortran_MODULE_DIR_IDENTIFIER}" TO_REL "${CMAKE_INSTALL_RELOC_LIBDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _moddir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_PREFIX}" FROM_REL "./" TO "${CMAKE_INSTALL_FULL_DOCDIR}" TO_REL "${CMAKE_INSTALL_RELOC_DOCDIR}" PREFIX "\${prefix}" RESULT_VARIABLE _docdir_rel ) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" _isSystemDir) if("${_isSystemDir}" STREQUAL "-1") set(KIM_API_RPATH_FLAG [=[-Wl,-rpath,${libdir}]=]) else() set(KIM_API_RPATH_FLAG "") endif() unset(_isSystemDir) configure_file(libkim-api.pc.in ${PKG_CONFIG_FILE} @ONLY) unset(_installdir_rel) unset(_bindir_rel) unset(_libexecdir_rel) unset(_sysconfdir_rel) unset(_libdir_rel) unset(_includedir_rel) unset(_moddir_rel) unset(_docdir_rel) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG_CONFIG_FILE} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_LIBDIR}/${KIM_API_PKG_CONFIG_DIR_IDENTIFIER} ) kim-api-2.3.0-git/pkg-config/libkim-api.pc.in000066400000000000000000000044041421473465500206340ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Richard Berger # Christoph Junghans # Ryan S. Elliott # Alexander Stukowski # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # pkg-config file for @PROJECT_NAME@ # https://people.freedesktop.org/~dbn/pkg-config-guide.html # Usage: cc `pkg-config --cflags --libs lib@PROJECT_NAME@` -o myapp myapp.c # after you added ${pcfiledir} to PKG_CONFIG_PATH, # e.g. export PKG_CONFIG_PATH=${pcfiledir} CMAKE_C_COMPILER=@KIM_API_CMAKE_C_COMPILER@ CMAKE_CXX_COMPILER=@KIM_API_CMAKE_CXX_COMPILER@ CMAKE_Fortran_COMPILER=@KIM_API_CMAKE_Fortran_COMPILER@ PROJECT_NAME=@PROJECT_NAME@ prefix=@_installdir_rel@ bindir=@_bindir_rel@ libexecdir=@_libexecdir_rel@ sysconfdir=@_sysconfdir_rel@ libdir=@_libdir_rel@ includedir=@_includedir_rel@/@PROJECT_NAME@ moddir=@_moddir_rel@ docdir=@_docdir_rel@ Name: lib@PROJECT_NAME@ Description: The @PROJECT_NAME@ package is a system-level library that aims to give computer programmers the ability to write atomistic or molecular simulation programs that can seamlessly interface with implementations of interatomic models, regardless of the programming language (C, C++, Fortran, Python, etc.) in which the codes are written. URL: https://openkim.org/kim-api Version: @PROJECT_VERSION_STRING_WITHOUT_BUILD_METADATA@ Requires: Cflags: -I${includedir} -I${moddir} Libs: -L${libdir} @KIM_API_RPATH_FLAG@ -l${PROJECT_NAME} kim-api-2.3.0-git/scripts/000077500000000000000000000000001421473465500153265ustar00rootroot00000000000000kim-api-2.3.0-git/scripts/clang-format-all000077500000000000000000000056741421473465500204100ustar00rootroot00000000000000#!/bin/sh # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # filter file list # NOTE: keep in sync with verion in git-hooks/pre-commit filter_file_list () { local file_list="$1" local ignore_file="`git rev-parse --show-toplevel`/.format-ignore" files_to_check_format="" for file in ${file_list}; do local keep=`printf ${file} | sed -e 's/^.*\.hpp$//' \ -e 's/^.*\.hpp\.in$//' \ -e 's/^.*\.cpp$//' \ -e 's/^.*\.cpp\.in$//' \ -e 's/^.*\.inc$//' \ -e 's/^.*\.inc\.in$//' \ -e 's/^.*\.h$//' \ -e 's/^.*\.h\.in$//' \ -e 's/^.*\.c$//' \ -e 's/^.*\.c\.in$//'` if test -f "${ignore_file}"; then if test `grep -c "^${file}$" "${ignore_file}"` -gt 0; then # ignore printf "File '${file}' is in format-ignore file: ignoring.\n" keep=no fi fi if test x"${keep}" = x""; then files_to_check_format="${files_to_check_format} ${file}" fi done } # goto the top level repo directory if THE_GIT_DIR="`git rev-parse --show-toplevel 2> /dev/null`"; then cd "${THE_GIT_DIR}" else printf "Not in the git repo. Exiting...\n" exit 1 fi files=`find . -name "*.hpp" \ -o -name "*.hpp.in" \ -o -name "*.cpp" \ -o -name "*.cpp.in" \ -o -name "*.inc" \ -o -name "*.inc.in" \ -o -name "*.h" \ -o -name "*.h.in" \ -o -name "*.c" \ -o -name "*.c.in" | \ sed -e 's|^\./||'` printf "Executing clang-format on all c/c++ files in directory ${PWD}.\n" files_to_check_format="" filter_file_list "${files}" clang-format -style=file -i ${files_to_check_format} kim-api-2.3.0-git/scripts/format-all000077500000000000000000000024211421473465500173110ustar00rootroot00000000000000#!/bin/sh # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # goto the top level repo directory if THE_GIT_DIR="`git rev-parse --show-toplevel 2> /dev/null`"; then cd "${THE_GIT_DIR}" else printf "Not in the git repo. Exiting...\n" exit 1 fi ${THE_GIT_DIR}/scripts/clang-format-all ${THE_GIT_DIR}/scripts/fprettify-all kim-api-2.3.0-git/scripts/fprettify-all000077500000000000000000000040471421473465500200430ustar00rootroot00000000000000#!/bin/sh # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # filter file list # NOTE: keep in sync with verion in git-hooks/pre-commit filter_file_list () { local file_list="$1" local ignore_file="`git rev-parse --show-toplevel`/.format-ignore" files_to_check_format="" for file in ${file_list}; do local keep=`printf ${file} | sed -e 's/^.*\.f90$//'` if test -f "${ignore_file}"; then if test `grep -c "^${file}$" "${ignore_file}"` -gt 0; then # ignore printf "File '${file}' is in format-ignore file: ignoring.\n" keep=no fi fi if test x"${keep}" = x""; then files_to_check_format="${files_to_check_format} ${file}" fi done } # goto the top level repo directory if THE_GIT_DIR="`git rev-parse --show-toplevel 2> /dev/null`"; then cd "${THE_GIT_DIR}" else printf "Not in the git repo. Exiting...\n" exit 1 fi files=`find . -name "*.f90" | \ sed -e 's|^\./||'` printf "Executing fprettify on all f90 files in directory ${PWD}.\n" files_to_check_format="" filter_file_list "${files}" fprettify ${files_to_check_format} kim-api-2.3.0-git/utils/000077500000000000000000000000001421473465500147775ustar00rootroot00000000000000kim-api-2.3.0-git/utils/CMakeLists.txt000066400000000000000000000140451421473465500175430ustar00rootroot00000000000000# # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Christoph Junghans # Ryan S. Elliott # Daniel S. Karls # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # include(RelocatablePath) set(PORTABLE_MODEL_INFO ${PROJECT_NAME}-portable-model-info) set(SIMULATOR_MODEL ${PROJECT_NAME}-simulator-model) set(COLLECTIONS_INFO ${PROJECT_NAME}-collections-info) set(COLLECTIONS_MANAGEMENT ${PROJECT_NAME}-collections-management) set(SHARED_LIBRARY_TEST ${PROJECT_NAME}-shared-library-test) set(ACTIVATE_SCRIPT ${PROJECT_NAME}-activate) set(DEACTIVATE_SCRIPT ${PROJECT_NAME}-deactivate) # Set RPATH to support relocatable behavior for utilities if((NOT ("${CMAKE_INSTALL_PREFIX}" IN_LIST KIM_API_STANDARD_INSTALL_PREFIXES)) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") set(_rpath_prefix "@loader_path") else() set(_rpath_prefix "$ORIGIN") endif() relocatable_path( FROM "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${PROJECT_NAME}" FROM_REL "${CMAKE_INSTALL_RELOC_LIBEXECDIR}" TO "${CMAKE_INSTALL_FULL_LIBDIR}" TO_REL "${CMAKE_INSTALL_RELOC_LIBDIR}" PREFIX "${_rpath_prefix}" RESULT_VARIABLE _rel_rpath ) unset(_rpath_prefix) if(NOT IS_ABSOLUTE "${_rel_rpath}") list(APPEND CMAKE_INSTALL_RPATH "${_rel_rpath}") endif() unset(_rel_rpath) endif() if(NOT WIN32 OR CYGWIN) relocatable_path( FROM "${CMAKE_INSTALL_FULL_BINDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_BINDIR}" TO "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${PROJECT_NAME}/${COLLECTIONS_INFO}" TO_REL "${CMAKE_INSTALL_RELOC_LIBEXECDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _collections_info_path ) else() # Note: On WIN32, 'collections-info.exe' and other utilities get installed under ${CMAKE_INSTALL_PREFIX}/bin/. relocatable_path( FROM "${CMAKE_INSTALL_FULL_BINDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_BINDIR}" TO "${CMAKE_INSTALL_FULL_BINDIR}/${COLLECTIONS_INFO}" TO_REL "${CMAKE_INSTALL_RELOC_BINDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _collections_info_path ) endif() configure_file(collections-management.in ${COLLECTIONS_MANAGEMENT} @ONLY) unset(_collections_info_path) relocatable_path( FROM "${CMAKE_INSTALL_FULL_BINDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_BINDIR}" TO "${CMAKE_INSTALL_PREFIX}" TO_REL "./" PREFIX "\${ORIGIN}" RESULT_VARIABLE _installdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_FULL_BINDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_BINDIR}" TO "${CMAKE_INSTALL_FULL_LIBDIR}" TO_REL "${CMAKE_INSTALL_RELOC_LIBDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _libdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_FULL_BINDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_BINDIR}" TO "${BASH_COMPLETION_FULL_COMPLETIONSDIR}" TO_REL "${BASH_COMPLETION_RELOC_COMPLETIONSDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _bashcompdir_rel ) relocatable_path( FROM "${CMAKE_INSTALL_FULL_BINDIR}" FROM_REL "${CMAKE_INSTALL_RELOC_BINDIR}" TO "${ZSH_COMPLETION_FULL_COMPLETIONSDIR}" TO_REL "${ZSH_COMPLETION_RELOC_COMPLETIONSDIR}" PREFIX "\${ORIGIN}" RESULT_VARIABLE _zshcompdir_rel ) configure_file(activate.in ${ACTIVATE_SCRIPT} @ONLY) configure_file(deactivate.in ${DEACTIVATE_SCRIPT} @ONLY) unset(_installdir_rel) unset(_libdir_rel) unset(_bashcompdir_rel) unset(_zshcompdir_rel) add_executable(portable-model-info portable-model-info.cpp) target_link_libraries(portable-model-info kim-api) target_include_directories(portable-model-info PRIVATE "${PROJECT_SOURCE_DIR}/cpp/src") set_target_properties(portable-model-info PROPERTIES OUTPUT_NAME ${PORTABLE_MODEL_INFO}) add_executable(simulator-model simulator-model.cpp) target_link_libraries(simulator-model kim-api) set_target_properties(simulator-model PROPERTIES OUTPUT_NAME ${SIMULATOR_MODEL}) add_executable(collections-info collections-info.cpp) target_include_directories(collections-info PRIVATE "${PROJECT_SOURCE_DIR}/cpp/src/") target_link_libraries(collections-info kim-api) set_target_properties(collections-info PROPERTIES OUTPUT_NAME ${COLLECTIONS_INFO}) add_executable(shared-library-test shared-library-test.cpp) target_include_directories(shared-library-test PRIVATE "${PROJECT_BINARY_DIR}/cpp/include") target_link_libraries(shared-library-test ${CMAKE_DL_LIBS}) set_target_properties(shared-library-test PROPERTIES OUTPUT_NAME ${SHARED_LIBRARY_TEST}) # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior if(NOT WIN32 OR CYGWIN) set(_dir "${CMAKE_INSTALL_RELOC_LIBEXECDIR}/${PROJECT_NAME}") else() set(_dir "${CMAKE_INSTALL_RELOC_BINDIR}") endif() install( TARGETS portable-model-info simulator-model collections-info shared-library-test EXPORT KIM_API_Targets DESTINATION "${_dir}" ) unset(_dir) install( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${COLLECTIONS_MANAGEMENT} # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior DESTINATION ${CMAKE_INSTALL_RELOC_BINDIR} ) if(NOT ("${CMAKE_INSTALL_PREFIX}" IN_LIST KIM_API_STANDARD_INSTALL_PREFIXES)) install( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${ACTIVATE_SCRIPT} ${CMAKE_CURRENT_BINARY_DIR}/${DEACTIVATE_SCRIPT} DESTINATION # use CMAKE_INSTALL_RELOC_* to get relocatable GNUInstallDir behavior ${CMAKE_INSTALL_RELOC_BINDIR} ) endif() kim-api-2.3.0-git/utils/activate.in000077500000000000000000000060411421473465500171330ustar00rootroot00000000000000#!/bin/sh # # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Yaser Afshar # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # Ensure that this script is sourced, not executed BASENAME_SOURCE=`basename -- "$0" 2> /dev/null` if test -n "${ZSH_VERSION}"; then if test $options[posixargzero] != "on"; then setopt posixargzero BASENAME_SOURCE=`basename -- "$0" 2> /dev/null` setopt posixargzero fi fi if test x"${BASENAME_SOURCE}" = x"@PROJECT_NAME@-activate"; then (>&2 printf "\nError:\t@PROJECT_NAME@-activate must be sourced.\n" printf "\tRun 'source @PROJECT_NAME@-activate' not " printf "'@PROJECT_NAME@-activate'.\n\n") exit 1 fi if test -n "${ORIGIN}"; then OLD_KIM_ORIGIN="${ORIGIN}" fi if test -n "${ZSH_VERSION}"; then ORIGIN=$(cd "$(dirname "${(%):-%x}")" && pwd) else # Get ORIGIN location of this script: SOURCE="${BASH_SOURCE[0]}" # https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself if command -v readlink >/dev/null 2>&1; then while test -h "$SOURCE"; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done fi ORIGIN="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" fi export PATH="${ORIGIN}:${PATH}" if test -n "${PKG_CONFIG_PATH+x}"; then export PKG_CONFIG_PATH=":${PKG_CONFIG_PATH}"; fi _libdir_rel=$(cd "@_libdir_rel@" && pwd) export PKG_CONFIG_PATH=${_libdir_rel}/pkgconfig${PKG_CONFIG_PATH} unset _libdir_rel _installdir_rel=$(cd "@_installdir_rel@" && pwd) export @KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR@=${_installdir_rel} unset _installdir_rel if test -n "${ZSH_VERSION}"; then source "@_zshcompdir_rel@/_@PROJECT_NAME@-collections-management" else source "@_bashcompdir_rel@/@PROJECT_NAME@-collections-management.bash" fi if test -n "${OLD_KIM_ORIGIN}"; then ORIGIN="${OLD_KIM_ORIGIN}" unset OLD_KIM_ORIGIN else unset ORIGIN fi kim-api-2.3.0-git/utils/collections-info.cpp000066400000000000000000000432341421473465500207600ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include "KIM_Collection.hpp" #include "KIM_CollectionItemType.hpp" #include "KIM_CollectionsImplementation.hpp" // using non-public internal API #include "KIM_FilesystemPath.hpp" // using non-public internal API #include "KIM_Log.hpp" #include "KIM_LogVerbosity.hpp" #include "KIM_Version.hpp" #include #include #include #include #include void usage(std::string name) { size_t beg = name.find_last_of("/\\"); if (beg != std::string::npos) name = name.substr(beg + 1, std::string::npos); // Follows docopt.org format std::cerr << "Usage:\n" << " " << name << " env (env | model_drivers | portable_models | simulator_models)\n" << " " << name << " config_file (env | name | model_drivers | portable_models | " "simulator_models)\n" << " " << name << " write_config_file " " \n" << " " << name << " type \n" << " " << name << " metadata \n" << " " << name << " system (project | model_drivers | portable_models | " "simulator_models)\n" << " " << name << " model_drivers [--log] [find ]\n" << " " << name << " portable_models [--log] [find ]\n" << " " << name << " simulator_models [--log] [find ]\n" << " " << name << " --version\n"; // note: this interface is likely to change in future kim-api releases } namespace CI { void printDirs(int const extent, KIM::CollectionsImplementation const * const col) { for (int i = 0; i < extent; ++i) { std::string const * dir; col->GetDirectoryName(i, &dir); std::cout << *dir << std::endl; } } enum ENV_OPTIONS { E_ENV, E_MODEL_DRIVERS, E_PORTABLE_MODELS, E_SIMULATOR_MODELS }; void env(ENV_OPTIONS const opt) { KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; KIM::CollectionsImplementation::Create(&col); switch (opt) { case E_ENV: { using namespace KIM::COLLECTION_ITEM_TYPE; std::string const * envName; col->GetEnvironmentVariableName(modelDriver, &envName); std::cout << *envName << " "; col->GetEnvironmentVariableName(portableModel, &envName); std::cout << *envName << " "; col->GetEnvironmentVariableName(simulatorModel, &envName); std::cout << *envName; std::cout << std::endl; break; } case E_MODEL_DRIVERS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::environmentVariable, KIM::COLLECTION_ITEM_TYPE::modelDriver, &extent); printDirs(extent, col); break; } case E_PORTABLE_MODELS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::environmentVariable, KIM::COLLECTION_ITEM_TYPE::portableModel, &extent); printDirs(extent, col); break; } case E_SIMULATOR_MODELS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::environmentVariable, KIM::COLLECTION_ITEM_TYPE::simulatorModel, &extent); printDirs(extent, col); break; } } KIM::CollectionsImplementation::Destroy(&col); KIM::Log::PopDefaultVerbosity(); } enum CONFIG_FILE_OPTIONS { CF_ENV, CF_NAME, CF_MODEL_DRIVERS, CF_PORTABLE_MODELS, CF_SIMULATOR_MODELS }; void configFile(CONFIG_FILE_OPTIONS const opt) { KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; KIM::CollectionsImplementation::Create(&col); switch (opt) { case CF_ENV: { std::string const * fl; std::string const * val; col->GetConfigurationFileEnvironmentVariable(&fl, &val); std::cout << *fl << " " << *val << std::endl; break; } case CF_NAME: { std::string const * dir; col->GetConfigurationFileName(&dir); std::cout << *dir << std::endl; break; } case CF_MODEL_DRIVERS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::user, KIM::COLLECTION_ITEM_TYPE::modelDriver, &extent); printDirs(extent, col); break; } case CF_PORTABLE_MODELS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::user, KIM::COLLECTION_ITEM_TYPE::portableModel, &extent); printDirs(extent, col); break; } case CF_SIMULATOR_MODELS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::user, KIM::COLLECTION_ITEM_TYPE::simulatorModel, &extent); printDirs(extent, col); break; } } KIM::CollectionsImplementation::Destroy(&col); KIM::Log::PopDefaultVerbosity(); } void project() { KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; KIM::CollectionsImplementation::Create(&col); std::string const * project; std::string const * version; col->GetProjectNameAndSemVer(&project, &version); std::cout << *project << " " << *version << std::endl; KIM::CollectionsImplementation::Destroy(&col); KIM::Log::PopDefaultVerbosity(); } enum SYS_OPTIONS { S_MODEL_DRIVERS, S_PORTABLE_MODELS, S_SIMULATOR_MODELS }; void sys(SYS_OPTIONS const opt) { KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; KIM::CollectionsImplementation::Create(&col); switch (opt) { case S_MODEL_DRIVERS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::system, KIM::COLLECTION_ITEM_TYPE::modelDriver, &extent); printDirs(extent, col); break; } case S_PORTABLE_MODELS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::system, KIM::COLLECTION_ITEM_TYPE::portableModel, &extent); printDirs(extent, col); break; } case S_SIMULATOR_MODELS: { int extent; col->CacheListOfDirectoryNames(KIM::COLLECTION::system, KIM::COLLECTION_ITEM_TYPE::simulatorModel, &extent); printDirs(extent, col); break; } } KIM::CollectionsImplementation::Destroy(&col); KIM::Log::PopDefaultVerbosity(); } void listItems(KIM::CollectionItemType const type, bool const list_all, std::string const & name, bool const log) { if (log) KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::debug); else KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; int error = KIM::CollectionsImplementation::Create(&col); if (!error) { if (list_all) { std::vector colList; colList.push_back(KIM::COLLECTION::currentWorkingDirectory); colList.push_back(KIM::COLLECTION::environmentVariable); colList.push_back(KIM::COLLECTION::user); colList.push_back(KIM::COLLECTION::system); for (std::vector::size_type i = 0; i < colList.size(); ++i) { int extent; error = col->CacheListOfItemNamesByCollectionAndType( colList[i], type, &extent); if (error) break; for (int j = 0; j < extent; ++j) { std::string const * itemName; col->GetItemNameByCollectionAndType(j, &itemName); std::string const * itemLibraryFileName; error = col->GetItemLibraryFileNameByCollectionAndType( colList[i], type, *itemName, &itemLibraryFileName); if (!error) { std::size_t found = itemLibraryFileName->find_last_of("/\\"); std::string dir = itemLibraryFileName->substr(0, found); found = dir.find_last_of("/\\"); dir = dir.substr(0, found); std::cout << colList[i].ToString() << " " << *itemName << " " << dir << std::endl; } } } } else { std::string const * itemFileName; KIM::Collection collection; int error = col->GetItemLibraryFileNameAndCollection( type, name, &itemFileName, &collection); if (!error) { std::size_t found = itemFileName->find_last_of("/\\"); std::string dir = itemFileName->substr(0, found); found = dir.find_last_of("/\\"); dir = dir.substr(0, found); std::cout << collection.ToString() << " " << name << " " << dir << std::endl; } } KIM::CollectionsImplementation::Destroy(&col); } KIM::Log::PopDefaultVerbosity(); } } // namespace CI int processEnv(int argc, char * argv[]); int processConfigFile(int argc, char * argv[]); int writeConfigFile(int argc, char * argv[]); int getItemType(int argc, char * argv[]); int getItemMetadata(int argc, char * argv[]); int processSystem(int argc, char * argv[]); int processItems(int argc, char * argv[]); int main(int argc, char * argv[]) { int returnVal = 0; if (argc < 2) { returnVal = 1; } else { if (0 == strcmp("env", argv[1])) { returnVal = processEnv(argc, argv); } else if (0 == strcmp("config_file", argv[1])) { returnVal = processConfigFile(argc, argv); } else if (0 == strcmp("write_config_file", argv[1])) { returnVal = writeConfigFile(argc, argv); } else if (0 == strcmp("type", argv[1])) { returnVal = getItemType(argc, argv); } else if (0 == strcmp("metadata", argv[1])) { returnVal = getItemMetadata(argc, argv); } else if (0 == strcmp("system", argv[1])) { returnVal = processSystem(argc, argv); } else if ((0 == strcmp("model_drivers", argv[1])) || (0 == strcmp("portable_models", argv[1])) || (0 == strcmp("simulator_models", argv[1]))) { returnVal = processItems(argc, argv); } else if (0 == strcmp("--version", argv[1])) { std::cout << KIM_VERSION_STRING << std::endl; returnVal = 0; } else { returnVal = 1; } } if (returnVal != 0) usage(argv[0]); return returnVal; } int processEnv(int argc, char * argv[]) { int returnVal = 0; CI::ENV_OPTIONS opt; if (argc != 3) { returnVal = 1; } else { if (0 == strcmp("env", argv[2])) { opt = CI::E_ENV; } else if (0 == strcmp("model_drivers", argv[2])) { opt = CI::E_MODEL_DRIVERS; } else if (0 == strcmp("portable_models", argv[2])) { opt = CI::E_PORTABLE_MODELS; } else if (0 == strcmp("simulator_models", argv[2])) { opt = CI::E_SIMULATOR_MODELS; } else { returnVal = 1; } } if (0 == returnVal) { CI::env(opt); } return returnVal; } int processConfigFile(int argc, char * argv[]) { int returnVal = 0; CI::CONFIG_FILE_OPTIONS opt; if (argc != 3) { returnVal = 1; } else { if (0 == strcmp("env", argv[2])) { opt = CI::CF_ENV; } else if (0 == strcmp("name", argv[2])) { opt = CI::CF_NAME; } else if (0 == strcmp("model_drivers", argv[2])) { opt = CI::CF_MODEL_DRIVERS; } else if (0 == strcmp("portable_models", argv[2])) { opt = CI::CF_PORTABLE_MODELS; } else if (0 == strcmp("simulator_models", argv[2])) { opt = CI::CF_SIMULATOR_MODELS; } else { returnVal = 1; } } if (0 == returnVal) { CI::configFile(opt); } return returnVal; } int writeConfigFile(int argc, char * argv[]) { int returnVal = 0; if (argc != 6) { returnVal = 1; } else { using namespace KIM::COLLECTION_ITEM_TYPE; KIM::FILESYSTEM::Path fileName(argv[2]); std::map dirsMap; if (!dirsMap[modelDriver].Parse(argv[3])) return 1; if (!dirsMap[portableModel].Parse(argv[4])) return 1; if (!dirsMap[simulatorModel].Parse(argv[5])) return 1; returnVal = KIM::CollectionsImplementation:: WriteConfigurationFileAndCreateDirectories(fileName, dirsMap); } return returnVal; } int getItemType(int argc, char * argv[]) { int returnVal = 0; if (argc != 3) { returnVal = 1; } else { KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; int error = KIM::CollectionsImplementation::Create(&col); if (!error) { KIM::CollectionItemType itemType; error = col->GetItemType(argv[2], &itemType); if (error) returnVal = 1; else { std::cout << itemType.ToString() << std::endl; } KIM::CollectionsImplementation::Destroy(&col); } KIM::Log::PopDefaultVerbosity(); } return returnVal; } int getItemMetadata(int argc, char * argv[]) { int returnVal = 0; if (argc != 3) { returnVal = 1; } else { KIM::Log::PushDefaultVerbosity(KIM::LOG_VERBOSITY::silent); KIM::CollectionsImplementation * col; int error = KIM::CollectionsImplementation::Create(&col); if (!error) { KIM::CollectionItemType itemType; error = col->GetItemType(argv[2], &itemType); if (error) returnVal = 1; else { error = col->GetItemLibraryFileNameAndCollection( itemType, argv[2], NULL, NULL); if (error) returnVal = 1; else { int extent; col->CacheListOfItemMetadataFiles(itemType, argv[2], &extent); for (int i = 0; i < extent; ++i) { std::string const * fileName; std::string const * data; unsigned int fileLength; int asString; error = col->GetItemMetadataFile( i, &fileName, &fileLength, NULL, &asString, &data); if ((error) || (!asString)) { std::cout << "=== MD " << i << " === " << "not available" << std::endl; std::cout << "=======" << "=" << "=====" << "=============" << std::endl; } else { std::string s(*data); s.erase(s.find_last_not_of(" \n\r\t") + 1); // rtrim std::cout << "=== MD " << i << " === " << *fileName << " === " << fileLength << " ===" << std::endl; std::cout << s << std::endl; std::cout << "=======" << "=" << "=====" << "=============" << std::endl; } } } } KIM::CollectionsImplementation::Destroy(&col); } KIM::Log::PopDefaultVerbosity(); } return returnVal; } int processSystem(int argc, char * argv[]) { int returnVal = 0; if (argc != 3) { returnVal = 1; } else { if (0 == strcmp("project", argv[2])) { CI::project(); } else if (0 == strcmp("model_drivers", argv[2])) { CI::sys(CI::S_MODEL_DRIVERS); } else if (0 == strcmp("portable_models", argv[2])) { CI::sys(CI::S_PORTABLE_MODELS); } else if (0 == strcmp("simulator_models", argv[2])) { CI::sys(CI::S_SIMULATOR_MODELS); } else { returnVal = 1; } } return returnVal; } int processItems(int argc, char * argv[]) { int returnVal = 0; bool list_all = true; std::string name; bool log = false; if (argc >= 3) { if (0 == strcmp("--log", argv[2])) { for (int i = 3; i < argc; ++i) argv[i - 1] = argv[i]; argc--; log = true; } } if ((argc == 3) || (argc > 4)) { returnVal = 1; } else { if (argc == 4) { if (0 == strcmp("find", argv[2])) { list_all = false; name = argv[3]; } else { returnVal = 1; } } } if (0 == returnVal) { using namespace KIM::COLLECTION_ITEM_TYPE; if (0 == strcmp("model_drivers", argv[1])) { CI::listItems(modelDriver, list_all, name, log); } else if (0 == strcmp("portable_models", argv[1])) { CI::listItems(portableModel, list_all, name, log); } else if (0 == strcmp("simulator_models", argv[1])) { CI::listItems(simulatorModel, list_all, name, log); } else { returnVal = 1; // unknown argument } } return returnVal; } kim-api-2.3.0-git/utils/collections-management.in000077500000000000000000001207361421473465500217730ustar00rootroot00000000000000#!/bin/bash # # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # John S. Spear # Yaser Afshar # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # Get ORIGIN location of this script: SOURCE="${BASH_SOURCE[0]}" # https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself if command -v readlink >/dev/null 2>&1; then while test -h "$SOURCE"; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done fi ORIGIN="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" collections_info="@_collections_info_path@" major_version=@PROJECT_VERSION_MAJOR@ kim_version_string="@PROJECT_VERSION_STRING@" kim_api_uid_string="@KIM_API_UID@" # It (shell scripting) is easier if no whitespace allowed in kim_user_agent. kim_user_agent="kim-api-collections-management-(${kim_version_string}--`uname -mrs | sed -e 's/ /-/g'`)" make_command="${MAKE:=make} -j2" cmake_command="cmake" # determine web tool to use if command -v wget > /dev/null 2>&1; then web_tool="wget" web_tool_q="${web_tool} --user-agent ${kim_user_agent} -q" web_tool_query="${web_tool_q} -O - --post-data" web_tool_url_stdin="${web_tool_q} -O -" web_tool_download="${web_tool_q} --content-disposition" elif command -v curl > /dev/null 2>&1; then web_tool="curl" web_tool_q="${web_tool} --user-agent ${kim_user_agent} -s" web_tool_query="${web_tool_q} -o - --data" web_tool_url_stdin="${web_tool_q} -O -" web_tool_download="${web_tool_q} --remote-name" else printf "*** ERROR *** Unable to find a web tool: please install 'wget' or 'curl'.\n"; exit 1 fi # define usage function usage () { local command="`printf $0 | sed 's|.*/\([^/][^/]*\)/*|\1|'`" # Follows docopt.org format printf "Usage:\n" printf " ${command} list [--log]\n" printf " ${command} set-user-model-drivers-dir \n" printf " ${command} set-user-portable-models-dir \n" printf " ${command} set-user-simulator-models-dir \n" printf " ${command} install [--force]\n" printf " (CWD | environment | user | system [--sudo])\n" printf " (... | ... | OpenKIM)\n" printf " ${command} reinstall [--force|--interactive] [--sudo]\n" printf " ( | )...\n" printf " ${command} remove [--force|--interactive] [--sudo] ...\n" printf " ${command} remove-all [--force|--interactive] [--sudo]\n" printf " ${command} --version\n" printf "\n\n" printf "list:\n" printf " List installed kim-api model drivers, models, and simulator models\n" printf " * '--log' generate a kim.log file. This will show any errors that\n" printf " occur as the utility searches for installed items.\n" printf "\n" printf "set-user-model-drivers-dir:\n" printf " Rewrite configuration file with provided directory\n" printf "\n" printf "set-user-portable-models-dir:\n" printf " Rewrite configuration file with provided directory\n" printf "\n" printf "set-user-simulator-models-dir:\n" printf " Rewrite configuration file with provided directory\n" printf "\n" printf "install:\n" printf " Install model driver, portable model, or simulator model from openkim.org or\n" printf " from a local path\n" printf " * Installing to a collection places items in the first directory\n" printf " of the corresponding list.)\n" printf " * 'install --force' is essentially equivalent to 'reinstall', but works\n" printf " even when the item is not currently installed.\n" printf " * 'OpenKIM' installs (overwriting items already installed) the latest dated\n" printf " release of all KIM Models found at openkim.org.\n" printf "\n" printf "reinstall:\n" printf " Remove and reinstall items.\n" printf " WARNING: This will remove and reinstall the entire directory of files\n" printf " associated with the item.\n" printf "\n" printf "remove:\n" printf " Remove model driver, portable model, or simulator model.\n" printf " WARNING: This will remove the entire directory of files associated\n" printf " with the item.\n" printf "\n" printf "remove-all:\n" printf " Remove all items from all collections.\n" printf " WARNING: This will remove the entire directory of files associated\n" printf " with all items.\n" printf "\n" printf "\n" printf "NOTE: To obtain output from the CMake configure and make steps\n" printf " set the CM_VERBOSE environment variable.\n" printf "\n" printf " For script debugging, execute with the shell 'x' and/or 'v'\n" printf " options to obtain verbose output. For example:\n" printf " 'sh -xv ${command} ...'.\n" } check_version_compatibility () { local version="$1" local major="`printf -- "%s" "${version}" | sed -e 's/\([^.}]*\).*/\1/'`" local minor="`printf -- "%s" "${version}" | sed -e 's/[^.]*\.\([^.:]*\).*/\1/'`" if test \( ${major} -eq ${major_version} \) ; then return 0 else return 1 fi } check_item_compatibility () { local item_name="$1" local query="query={\"kimcode\":\"${item_name}\"}" query="${query}"'&fields={"kim-api-version":1}' query="${query}"'&database=obj&history=on' local version version="`${web_tool_query} "${query}" https://query.openkim.org/api`" local error_code=$? if test ${error_code} -ne 0; then printf "*** ERROR *** Unable to successfully contact openkim.org to check ${item_name} compatibility.\n" printf " '${web_tool}' returned error code ${error_code}.\n" return 1 fi version="`printf -- "%s" "${version}" | \ sed -e 's/\[//g' -e 's/\]//g' \ -e 's/{"kim-api-version": "\([0-9.]*\)"}/\1/g'`" if test x"" = x"${version}"; then printf "*** ERROR *** ${item_name} not found at openkim.org.\n" return 1 else if check_version_compatibility "${version}"; then return 0 else printf "*** ERROR *** ${item_name} found at openkim.org requires version ${version} of the KIM API\n" printf " which is not compatible with the installed version ${major_version} of the KIM API.\n" return 1 fi fi } check_for_local_build () { local name="$1" if test -d "${name}"; then local_build_path=`cd "${name}" && pwd` return 0 else local_build_path="" return 1 fi # output is: local_build_path } get_local_build_item_name () { local build_path="$1" if test \! -d "${build_path}"; then printf "Item path '${build_path}' does not exist.\n" return 1 fi # create private temporary directory if test x"" = x"${TMPDIR}"; then TMPDIR="/tmp"; fi local build_dir="`mktemp -d "${TMPDIR}/@PROJECT_NAME@-build-XXXXXXXXXX"`" if test $? -ne 0; then printf "Unable to create temporary directory.\n" return 1; fi ( # subshell cd "${build_dir}" || return 1 cp -r "${build_path}" "./item-source" cd item-source && mkdir build && cd build if ! (${cmake_command} ../ > ./cmake-log.txt 2>&1); then cat ./cmake-log.txt return 1 elif test ! -z "${CM_VERBOSE}"; then cat ./cmake-log.txt fi local item_type="`grep -- "item-type:" item-info.txt | sed -e 's/^item-type://'`" case "${item_type}" in modelDriver|portableModel|simulatorModel) printf -- "%s" "`grep -- "item-name:" item-info.txt | sed -e 's/^item-name:"\(.*\)"/\1/'`" \ > "${build_dir}/item_name" ;; *) printf -- "" > "${build_dir}/item_name" printf "Item type '${item_type}' unknown.\n" error="true" ;; esac if test x"true" = x"${error}"; then return 1 else return 0 fi ) || return 1 # exit subshell item_name=`cat ${build_dir}/item_name` rm -rf "${build_dir}" || return 1 return 0 # output is: item_name } check_config_file () { local config_file_name drivers_dir models_dir simulator_models_dir config_file_name="`${collections_info} config_file name`"; if test $? -ne 0; then return 1; fi drivers_dir="`${collections_info} config_file model_drivers`"; if test $? -ne 0; then return 1; fi models_dir="`${collections_info} config_file portable_models`"; if test $? -ne 0; then return 1; fi simulator_models_dir="`${collections_info} config_file simulator_models`"; if test $? -ne 0; then return 1; fi if test \! -f "${config_file_name}" -o x"" = x"${drivers_dir}" -o x"" = x"${models_dir}" -o x"" = x"${simulator_models_dir}"; then printf "Invalid kim-api configuration file.\n" return 1 fi } rewrite_config_file_item_type_dir () { local item_type=$1 local dir=$2 if test -d "${dir}"; then local config_file_name drivers_dir models_dir config_file_name="`${collections_info} config_file name`"; if test $? -ne 0; then return 1; fi drivers_dir="`${collections_info} config_file model_drivers`"; if test $? -ne 0; then return 1; fi models_dir="`${collections_info} config_file portable_models`"; if test $? -ne 0; then return 1; fi simulator_models_dir="`${collections_info} config_file simulator_models`"; if test $? -ne 0; then return 1; fi local full_dir="`cd "${dir}" && pwd`"; if test $? -ne 0; then return 1; fi if test x"${item_type}" = x"drivers"; then drivers_dir=${full_dir} elif test x"${item_type}" = x"models"; then models_dir=${full_dir} elif test x"${item_type}" = x"simulator_models"; then simulator_models_dir=${full_dir} else return 1 fi ${collections_info} write_config_file "${config_file_name}" "${drivers_dir}" "${models_dir}" "${simulator_models_dir}" || return 1 else printf "Directory '%s' does not exist.\n" "${dir}" return 1 fi } get_build_install_item () { local install_collection="$1" local item_name="$2" local force="$3" local use_sudo="$4" local PASSWORD="$5" local found_item="" local item_type="" local local_build_path="" # check for non-empty item_name if test x"" = x"${item_name}"; then printf "Empty item id.\n" return 1 fi # make changes for installing to CWD collection, if necessary if test x"${install_collection}" = x"CWD"; then drivers_env_name="`${collections_info} env env | sed -e 's/^\([^ ]*\) .*/\1/'`"; if test $? -ne 0; then return 1; fi models_env_name="`${collections_info} env env | sed -e 's/^[^ ]* \([^ ]*\) .*/\1/'`"; if test $? -ne 0; then return 1; fi simulator_models_env_name="`${collections_info} env env | sed -e 's/^[^ ]* [^ ]* \([^ ]*\) .*/\1/'`"; if test $? -ne 0; then return 1; fi export ${drivers_env_name}=${PWD} export ${models_env_name}=${PWD} export ${simulator_models_env_name}=${PWD} install_collection="environment" fi # check for local build and get item name if check_for_local_build "${item_name}"; then # sets local_build_path if ! get_local_build_item_name "${local_build_path}"; then # sets item_name # error message already printed return 1 else printf "Found local item named: ${item_name}.\n" printf "In source directory: ${local_build_path}.\n" printf " (If you are trying to install an item from openkim.org\n" printf " rerun this command from a different working directory,\n" printf " or rename the source directory mentioned above.)\n" printf "\n" fi fi # check for existing item if test x"OpenKIM" = x"${item_name}"; then found_item="" item_type="OpenKIM" else found_item="`${collections_info} model_drivers find "${item_name}"`"; if test $? -ne 0; then return 1; fi found_item="${found_item}""`${collections_info} portable_models find "${item_name}"`"; if test $? -ne 0; then return 1; fi found_item="${found_item}""`${collections_info} simulator_models find "${item_name}"`"; if test $? -ne 0; then return 1; fi fi if test x"" != x"${found_item}"; then local item_collection="`printf -- "%s" "${found_item}" | sed -e 's/ .*//'`" printf "Item '${item_name}' already installed in collection '${item_collection}'.\n" if test x"${force}" = x"yes"; then if ! remove_item "${item_name}" "${use_sudo}" "${PASSWORD}" "interactive-no"; then return 1 fi else if test x"${item_collection}" = x"${install_collection}"; then return 0 else return 1 fi fi fi # create private temporary directory if test x"" = x"${TMPDIR}"; then TMPDIR="/tmp"; fi local build_dir="`mktemp -d "${TMPDIR}/@PROJECT_NAME@-build-XXXXXXXXXX"`" if test $? -ne 0; then printf "Unable to create temporary directory.\n" return 1; fi ( # subshell cd "${build_dir}" || return 1 # download item (and possibly its driver) if test x"OpenKIM" = x"${item_type}"; then # find most recent release archive name local archive_basename=`${web_tool_url_stdin} https://s3.openkim.org/archives/collection | \ sed -e '/openkim-models-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].txz/!d' | sed -e '$!d' | \ sed -e 's/^.*\(openkim-models-.*\)\.txz.*$/\1/'` # download archive printf "Downloading..............#%s\n" "${archive_basename}" | sed -e 's/ /./g' -e 's/#/ /g' ${web_tool_download} "https://s3.openkim.org/archives/collection/${archive_basename}.txz" local error_code=$? if test ${error_code} -eq 0; then #tar Jxf "${archive_basename}.txz" && rm -f "${archive_basename}.txz" # Workaround for https://github.com/msys2/MSYS2-packages/issues/1548 xz --decompress --stdout "${archive_basename}.txz" | tar xf - && rm -f "${archive_basename}.txz" else printf " Unable to download ${archive_basename}.txz from https://s3.openkim.org.\n" printf " '${web_tool}' returned error code ${error_code}.\n" return 1 fi # configure archive cd "./${archive_basename}" && mkdir build && cd build if ! ${cmake_command} ../ -DKIM_API_INSTALL_COLLECTION="`printf ${install_collection} | tr "[:lower:]" "[:upper:]"`" > ./cmake-log.txt 2>&1; then cat ./cmake-log.txt return 1 elif test ! -z "${CM_VERBOSE}"; then cat ./cmake-log.txt fi # build and install archive if ! ((${make_command} clean && ${make_command} && ${make_command} CTEST_OUTPUT_ON_FAILURE=1 test) && \ if test x"sudo-yes" = x"${use_sudo}"; then printf -- "%s\n" "${PASSWORD}" | sudo -k -S ${make_command} install 2> /dev/null else ${make_command} install fi); then return 1 fi else if test x"" = x"${local_build_path}"; then if check_item_compatibility "${item_name}"; then printf "Downloading..............#%s\n" "${item_name}" | sed -e 's/ /./g' -e 's/#/ /g' ${web_tool_download} "https://openkim.org/download/${item_name}.txz" local error_code=$? if test ${error_code} -eq 0; then #tar Jxfv "${item_name}.txz" && rm -f "${item_name}.txz" # Workaround for https://github.com/msys2/MSYS2-packages/issues/1548 xz --decompress --stdout "${item_name}.txz" | tar xf - && rm -f "${item_name}.txz" else printf " Unable to download ${item_name} from https://openkim.org. Check the KIM Item ID for errors.\n" printf " '${web_tool}' returned error code ${error_code}.\n" return 1 fi else return 1 fi else cp -r "${local_build_path}" "./${item_name}" fi cd "./${item_name}" && mkdir build && cd build if ! ${cmake_command} ../ -DKIM_API_INSTALL_COLLECTION="`printf ${install_collection} | tr "[:lower:]" "[:upper:]"`" > ./cmake-log.txt 2>&1; then cat ./cmake-log.txt return 1 elif test ! -z "${CM_VERBOSE}"; then cat ./cmake-log.txt fi item_type="`grep "item-type:" item-info.txt | sed -e 's/item-type://'`" item_driver_name="`grep "item-driver-name:" item-info.txt | sed -e 's/item-driver-name:"\(.*\)"/\1/'`" if test x"portableModel" = x"${item_type}" -a x"item-driver-name:NULL" != x"${item_driver_name}"; then dvr="${item_driver_name}" if test x"" != x"`${collections_info} model_drivers find "${dvr}"`"; then printf "Found#installed#driver...#%s\n" "${dvr}" | sed -e 's/ /./g' -e 's/#/ /g' || return 1 else printf "This item needs its driver '${dvr}', but it is not currently installed.\n" printf "Trying to find it at openkim.org.\n" # try openkim.org get_build_install_item "${install_collection}" "${dvr}" "${force}" "${use_sudo}" "${PASSWORD}" || \ printf "*** WARNING *** Model Driver for this item not currently installed in any of the KIM API collections.\n%s\n\n" \ " Continuing with installation of the item anyway." fi if ! (${make_command} clean && ${make_command} && ${make_command} CTEST_OUTPUT_ON_FAILURE=1 test) > ./make-log.txt 2>&1; then cat ./make-log.txt return 1 elif test ! -z "${CM_VERBOSE}"; then cat ./make-log.txt fi if test x"sudo-yes" = x"${use_sudo}"; then printf -- "%s\n" "${PASSWORD}" | sudo -k -S ${make_command} install 2> /dev/null else ${make_command} install fi elif test x"portableModel" = x"${item_type}" -o \ x"modelDriver" = x"${item_type}" -o \ x"simulatorModel" = x"${item_type}"; then if ! (${make_command} clean && ${make_command} && ${make_command} CTEST_OUTPUT_ON_FAILURE=1 test) > ./make-log.txt 2>&1; then cat ./make-log.txt return 1 elif test ! -z "${CM_VERBOSE}"; then cat ./make-log.txt fi if test x"sudo-yes" = x"${use_sudo}"; then printf -- "%s\n" "${PASSWORD}" | sudo -k -S ${make_command} install 2> /dev/null else ${make_command} install fi else printf "Item '${item_name}' of unknown type '${item_type}'.\n" return 1 fi fi ) || return 1 # exit subshell rm -rf "${build_dir}" || return 1 } remove_item () { local item_name="$1" local use_sudo="$2" local PASSWORD="$3" local interactive="$4" local found_item="" local item_type="" local confirmed=1 # check for existing item found_item="`${collections_info} model_drivers find "${item_name}"`" if test x"" = x"${found_item}"; then found_item="`${collections_info} portable_models find "${item_name}"`" if test x"" = x"${found_item}"; then found_item="`${collections_info} simulator_models find "${item_name}"`" if test x"" = x"${found_item}"; then printf "Item '${item_name}' not installed.\n" return 1 else item_type="simulator_models" fi else item_type="portable_models" fi else item_type="model_drivers" fi local item_dir item_dir="`${collections_info} "${item_type}" find "${item_name}" | sed -e 's/^[^ ]* [^ ]* \([^ ]*\).*/\1/'`""/${item_name}"; if test $? -ne 0; then return 1; fi printf "Removing '%s'. " "${item_dir}" if test x"${interactive}" = x"interactive"; then printf "Continue? " if get_confirmation; then confirmed=0 fi else confirmed=0 fi if test 0 -eq ${confirmed}; then if test x"sudo-yes" = x"${use_sudo}"; then printf -- "%s\n" "${PASSWORD}" | sudo -k -S rm -rf "${item_dir}" 2> /dev/null || return 1 else rm -rf "${item_dir}" || return 1 fi printf "[done]\n" else printf "[skipped]\n" fi } split_items_list_into_collections () { local item_type="$1" local items_list="$2" # items_list might have paths with backslashes (in particular \U) # use 'printf "%s" ...' below to avoid escape processing of first argument. local cwd_collection cwd_collection=`printf "%s" "${items_list}" | grep "^currentWorkingDirectory" | \ sed -e 's/^currentWorkingDirectory \([^ ]*\) .*$/ \1/'` local number_cwd number_cwd=`printf "${cwd_collection}" | grep -c ''` if test x"" = x"${number_cwd}"; then number_cwd=0; fi local env_collection env_collection=`printf "%s" "${items_list}" | grep "^environmentVariable" | \ sed -e 's/^environmentVariable \([^ ]*\) .*$/ \1/'` local number_env number_env=`printf "${env_collection}" | grep -c ''` if test x"" = x"${number_env}"; then number_env=0; fi local usr_collection usr_collection=`printf "%s" "${items_list}" | grep "^user" | \ sed -e 's/^user \([^ ]*\) .*$/ \1/'` local number_usr number_usr=`printf "${usr_collection}" | grep -c ''` if test x"" = x"${number_usr}"; then number_usr=0; fi local sys_collection sys_collection=`printf "%s" "${items_list}" | grep "^system" | \ sed -e 's/^system \([^ ]*\) .*$/ \1/'` local number_sys number_sys=`printf "${sys_collection}" | grep -c ''` if test x"" = x"${number_sys}"; then number_sys=0; fi if test x"${item_type}" = x"drivers"; then drivers_cwd_collection=${cwd_collection} drivers_env_collection=${env_collection} drivers_usr_collection=${usr_collection} drivers_sys_collection=${sys_collection} number_drivers_cwd=${number_cwd} number_drivers_env=${number_env} number_drivers_usr=${number_usr} number_drivers_sys=${number_sys} elif test x"${item_type}" = x"models"; then models_cwd_collection=${cwd_collection} models_env_collection=${env_collection} models_usr_collection=${usr_collection} models_sys_collection=${sys_collection} number_models_cwd=${number_cwd} number_models_env=${number_env} number_models_usr=${number_usr} number_models_sys=${number_sys} elif test x"${item_type}" = x"simulator_models"; then simulator_models_cwd_collection=${cwd_collection} simulator_models_env_collection=${env_collection} simulator_models_usr_collection=${usr_collection} simulator_models_sys_collection=${sys_collection} number_simulator_models_cwd=${number_cwd} number_simulator_models_env=${number_env} number_simulator_models_usr=${number_usr} number_simulator_models_sys=${number_sys} fi } print_separator_line () { printf "%79s\n" " " | sed -e "s/ /$1/g" } print_collection_item_list () { local item_label="$1" local dir_list="$2" local number_of_items_in_list=$3 local item_list="$4" printf -- "${item_label}: " if test x"--empty--" = x"${dir_list}"; then printf "%s" "${dir_list}" else printf "'%s' " ${dir_list} fi printf "\n" if test ${number_of_items_in_list} -gt 0; then printf -- "${item_list}\n" # expected to have control characters else printf "\t--empty--\n" fi } print_list_of_items () { local with_log if test x"$1" = x"yes"; then with_log="--log" else with_log="" fi cmake_env_name="@KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR@" cmake_env="${@KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR@}" if test x"" = x"${cmake_env}"; then cmake_env="--empty--"; fi config_env_name="`${collections_info} config_file env | sed -e 's/ .*//'`"; if test $? -ne 0; then return 1; fi config_env="`${collections_info} config_file env | sed -e 's/^[^ ]* //'`"; if test $? -ne 0; then return 1; fi if test x"" = x"${config_env}"; then config_env="--empty--"; fi drivers_env_name="`${collections_info} env env | sed -e 's/^\([^ ]*\) .*/\1/'`"; if test $? -ne 0; then return 1; fi drivers_env="`${collections_info} env model_drivers`"; if test $? -ne 0; then return 1; fi if test x"" = x"${drivers_env}"; then drivers_env="--empty--"; fi models_env_name="`${collections_info} env env | sed -e 's/^[^ ]* \([^ ]*\) .*/\1/'`"; if test $? -ne 0; then return 1; fi models_env="`${collections_info} env portable_models`"; if test $? -ne 0; then return 1; fi if test x"" = x"${models_env}"; then models_env="--empty--"; fi simulator_models_env_name="`${collections_info} env env | sed -e 's/^[^ ]* [^ ]* \([^ ]*\).*/\1/'`"; if test $? -ne 0; then return 1; fi simulator_models_env="`${collections_info} env simulator_models`"; if test $? -ne 0; then return 1; fi if test x"" = x"${simulator_models_env}"; then simulator_models_env="--empty--"; fi printf "\n\n" printf "Knowledgebase of Interatomic Models (KIM)" printf -- " --- Model Collections Listing\n" print_separator_line "=" printf "\n" printf "kim-api : \n\t%s\n" "`${collections_info} system project`" printf "kim-api-uid : \n\t%s\n" "${kim_api_uid_string}" printf "\n" printf "kim-api configuration file:\n\t%s\n" \ "`${collections_info} config_file name`" printf "\n\n" printf "Environment Variables:\n" print_separator_line "-" printf -- "%s:\n" "${cmake_env_name}" printf -- "\t%s\n" "${cmake_env}" printf "\n" printf -- "%s:\n" "${config_env_name}" printf -- "\t%s\n" "${config_env}" printf "\n" printf -- "%s:\n" "${drivers_env_name}" printf -- "\t%s\n" ${drivers_env} # unquoted ${drivers_env} to have multiple separate arguments printf "\n" printf -- "%s:\n" "${models_env_name}" printf -- "\t%s\n" ${models_env} # unquoted ${models_env} to have multiple separate arguments printf "\n" printf -- "%s:\n" "${simulator_models_env_name}" printf -- "\t%s\n" ${simulator_models_env} # unquoted ${simulator_models_env} to have multiple separate arguments printf "\n" print_separator_line "=" model_drivers_list="`${collections_info} model_drivers ${with_log}`"; if test $? -ne 0; then return 1; fi split_items_list_into_collections "drivers" "${model_drivers_list}" models_list="`${collections_info} portable_models ${with_log}`"; if test $? -ne 0; then return 1; fi split_items_list_into_collections "models" "${models_list}" simulator_models_list="`${collections_info} simulator_models ${with_log}`"; if test $? -ne 0; then return 1; fi split_items_list_into_collections "simulator_models" "${simulator_models_list}" printf "\n\n\n" printf "Current Working Directory Collection\n" print_separator_line "-" print_collection_item_list "Model Drivers" "${PWD}" $number_drivers_cwd "${drivers_cwd_collection}" printf "\n" print_collection_item_list "Portable Models" "${PWD}" $number_models_cwd "${models_cwd_collection}" printf "\n" print_collection_item_list "Simulator Models" "${PWD}" $number_simulator_models_cwd "${simulator_models_cwd_collection}" printf "\n\n" printf "Environment Variable Collection\n" print_separator_line "-" print_collection_item_list "Model Drivers" "${drivers_env}" $number_drivers_env "${drivers_env_collection}" printf "\n" print_collection_item_list "Portable Models" "${models_env}" $number_models_env "${models_env_collection}" printf "\n" print_collection_item_list "Simulator Models" "${simulator_models_env}" $number_simulator_models_env "${simulator_models_env_collection}" printf "\n\n" drivers_usr="`${collections_info} config_file model_drivers`"; if test $? -ne 0; then return 1; fi if test x"" = x"${drivers_usr}"; then drivers_usr="--empty--"; fi models_usr="`${collections_info} config_file portable_models`"; if test $? -ne 0; then return 1; fi if test x"" = x"${models_usr}"; then models_usr="--empty--"; fi simulator_models_usr="`${collections_info} config_file simulator_models`"; if test $? -ne 0; then return 1; fi if test x"" = x"${simulator_models_usr}"; then models_usr="--empty--"; fi printf "User Collection\n" print_separator_line "-" print_collection_item_list "Model Drivers" "${drivers_usr}" $number_drivers_usr "${drivers_usr_collection}" printf "\n" print_collection_item_list "Portable Models" "${models_usr}" $number_models_usr "${models_usr_collection}" printf "\n" print_collection_item_list "Simulator Models" "${simulator_models_usr}" $number_simulator_models_usr "${simulator_models_usr_collection}" printf "\n\n" drivers_sys="`${collections_info} system model_drivers`"; if test $? -ne 0; then return 1; fi if test x"" = x"${drivers_sys}"; then drivers_sys="--empty--"; fi models_sys="`${collections_info} system portable_models`"; if test $? -ne 0; then return 1; fi if test x"" = x"${models_sys}"; then models_sys="--empty--"; fi simulator_models_sys="`${collections_info} system simulator_models`"; if test $? -ne 0; then return 1; fi if test x"" = x"${simulator_models_sys}"; then simulator_models_sys="--empty--"; fi printf "System Collection\n" print_separator_line "-" print_collection_item_list "Model Drivers" "${drivers_sys}" $number_drivers_sys "${drivers_sys_collection}" printf "\n" print_collection_item_list "Portable Models" "${models_sys}" $number_models_sys "${models_sys_collection}" printf "\n" print_collection_item_list "Simulator Models" "${simulator_models_sys}" $number_simulator_models_sys "${simulator_models_sys_collection}" printf "\n" } get_password () { # Read the password from stdin PASSWORD=` # To be sure of reading data from the terminal no matter # how output has been redirected. Must redirect stdin # to the controlling terminal exec < /dev/tty || return 1 # TTY current settings in a stty-readable form tty_current_settings=\`stty -g\` || return 1 # Restore the settings on receiving EXIT signal trap 'stty ${tty_current_settings} > /dev/null 2>&1' EXIT # Echo input characters, and disable terminal local echo stty -echo || return 1 # Redirect stdout back to /dev/tty printf "Enter Password : " > /dev/tty # Read the password # The Internal Field Separator (IFS), is commonly used with read command, # parameter expansions and command substitution. # The 'IFS=' prefix keeps read from trimming spaces and tabs, # the -r keeps it from trying to parse backslashes as escapes local error_status error_status=0 IFS= read -r password || error_status=1 if test "${error_status}" -ne 0; then printf "\n*** ERROR *** read command failed to get the entered password. \n" return 1 fi # Display a newline to acknowledge the entered password printf "\n" > /dev/tty # Return the entered password printf '%s\n' "$password" ` || return 1 if !(printf -- '%s\n' "${PASSWORD}" | sudo -k -S printf "" > /dev/null 2>&1); then printf "Bad password.\n" return 1 fi } get_confirmation () { local ANSWER printf "[y/n] : " read ANSWER if test x"${ANSWER}" = x"y"; then return 0; else return 1; fi } ######## main script ######## # check that command is given if test $# -lt 1; then usage exit 1 else command=$1 case $command in list|set-user-model-drivers-dir|set-user-portable-models-dir|set-user-simulator-models-dir|install|reinstall|remove|remove-all|--version) ;; *) printf "unknown command: %s\n\n" $command usage exit 1 esac fi if ! check_config_file; then printf "Aborting!\n" exit 1 fi case $command in list) if test $# -gt 3; then usage exit 1 fi shift list_with_log="no" for arg in "$@"; do case "$arg" in --log) list_with_log="yes" ;; *) printf "unknown option %s\n\n" "$arg" usage exit 1 ;; esac done print_list_of_items "${list_with_log}" ;; set-user-model-drivers-dir) if test $# -lt 2; then usage exit 1 else subcommand=$2 if ! rewrite_config_file_item_type_dir "drivers" "$subcommand"; then printf "\nAborting!\n" exit 1 else printf "\nSuccess!\n" fi fi ;; set-user-portable-models-dir) if test $# -lt 2; then usage exit 1 else subcommand=$2 if ! rewrite_config_file_item_type_dir "models" "$subcommand"; then printf "\nAborting!\n" exit 1 else printf "\nSuccess!\n." fi fi ;; set-user-simulator-models-dir) if test $# -lt 2; then usage exit 1 else subcommand=$2 if ! rewrite_config_file_item_type_dir "simulator_models" "$subcommand"; then printf "\nAborting!\n" exit 1 else printf "\nSuccess!\n." fi fi ;; install) if test $# -lt 3; then usage exit 1 else force="no" if test x"$2" = x"--force"; then force="yes" shift fi subcommand=$2 shift shift case $subcommand in CWD|environment|user) for item_id in $@; do if ! get_build_install_item "${subcommand}" "${item_id}" "${force}" "sudo-no" ""; then printf "\nAborting!\n" exit 1 else printf "\nSuccess!\n" fi done ;; system) PASSWORD="" if test x"--sudo" = x"$1"; then shift use_sudo="sudo-yes" if ! get_password; then printf "\nAborting!\n" exit 1 fi else use_sudo="sudo-no" fi for item_id in $@; do if ! get_build_install_item "system" "${item_id}" "${force}" "${use_sudo}" "${PASSWORD}"; then printf "\nAborting!\n" exit 1 else printf "\nSuccess!\n" fi done ;; *) printf "unknown subcommand: %s\n\n" $subcommand usage exit 1 ;; esac fi ;; reinstall) if test $# -lt 2; then usage exit 1 else shift use_sudo="sudo-no" use_force="force-no" use_interactive="interactive-no" while test x"--" = x"`printf -- "%s" "$1" | sed -e 's/^\(..\).*/\1/'`"; do case $1 in --force) use_force="force-yes" use_interactive="interactive-no" ;; --interactive) use_force="force-no" use_interactive="interactive" ;; --sudo) use_sudo="sudo-yes" if ! get_password; then printf "\nAborting!\n" exit 1 fi ;; *) printf "unknown option: %s\n\n" $1 usage exit 1 ;; esac shift done fi if test x"force-no" = x"${use_force}"; then printf "This will remove and reinstall all files associated with these items.\n" printf " Use the '--interactive' option to request confirmation\n" printf " before attempting to remove each item.\n" printf "\n" printf "Are you sure you want to proceed? " if get_confirmation; then confirmation=0 else confirmation=1 fi else confirmation=0 fi if test 0 -eq ${confirmation}; then for item_id in $@; do if check_for_local_build "${item_id}"; then # sets local_build_path if ! get_local_build_item_name "${local_build_path}"; then # sets item_name printf "\nAborting!\n" exit 1 fi else if ! check_item_compatibility "${item_id}"; then printf "\nAborting!\n" exit 1 else item_name="${item_id}" fi fi found_item="`${collections_info} model_drivers find "${item_name}"` `${collections_info} portable_models find "${item_name}"` `${collections_info} simulator_models find "${item_name}"`" if test \! x"" = x"${found_item}"; then item_collection="`printf "${found_item}" | sed -e 's/^[[:space:]]*\([^[:space:]]*\) .*/\1/'`" if ! (remove_item "${item_name}" "${use_sudo}" "${PASSWORD}" "${use_interactive}" && \ get_build_install_item "${item_collection}" "${item_id}" "${use_sudo}" "${PASSWORD}" "no"); then printf "\nAborting!\n" exit 1 fi else printf "\nAborting!\n" exit 1 fi done printf "\nSuccess!\n" fi ;; remove) if test $# -lt 2; then usage exit 1 else shift use_sudo="sudo-no" use_force="force-no" use_interactive="interactive-no" while test x"--" = x"`printf -- "%s" "$1" | sed -e 's/^\(..\).*/\1/'`"; do case $1 in --force) use_force="force-yes" use_interactive="interactive-no" ;; --interactive) use_force="force-no" use_interactive="interactive" ;; --sudo) use_sudo="sudo-yes" if ! get_password; then printf "\nAborting!\n" exit 1 fi ;; *) printf "unknown option: %s\n\n" $1 usage exit 1 ;; esac shift done fi printf "This will remove all files associated with these items.\n" printf " Use the '--interactive' option to request confirmation\n" printf " before attempting to remove each item.\n" if test x"force-no" = x"${use_force}"; then printf "\n" printf "Are you sure you want to proceed? " if get_confirmation; then confirmation=0 else confirmation=1 fi else confirmation=0 fi if test 0 -eq ${confirmation}; then for item_id in $@; do if ! remove_item "${item_id}" "${use_sudo}" "${PASSWORD}" "${use_interactive}"; then printf "\nAborting!\n" exit 1 fi done printf "\nSuccess!\n" else printf "\nAborting!\n" fi ;; remove-all) shift use_sudo="sudo-no" use_force="force-no" use_interactive="interactive-no" while test x"--" = x"`printf -- "%s" "$1" | sed -e 's/^\(..\).*/\1/'`"; do case $1 in --force) use_force="force-yes" use_interactive="interactive-no" ;; --interactive) use_force="force-no" use_interactive="interactive" ;; --sudo) use_sudo="sudo-yes" if ! get_password; then printf "\nAborting!\n" exit 1 fi ;; *) printf "unknown option: %s\n\n" $1 usage exit 1 ;; esac shift done if test x"force-no" = x"${use_force}"; then printf "This will remove all files associated with all items in the 'environment',\n" printf "'user', and 'system' collections.\n" printf " Use the '--interactive' option to request confirmation\n" printf " before attempting to remove each item.\n" printf "\n" printf "Are you sure you want to proceed? " if get_confirmation; then confirmation=0 else confirmation=1 fi else confirmation=0 fi if test 0 -eq ${confirmation}; then # get full list and loop over it to remove for item_id in `${collections_info} model_drivers | sed -e 's/^[^[:space:]]* \([^[:space:]]*\).*/\1/'`; do if ! remove_item "${item_id}" "${use_sudo}" "${PASSWORD}" "${use_interactive}"; then printf "\n Aborting!\n" exit 1 fi done for item_id in `${collections_info} portable_models | sed -e 's/^[^[:space:]]* \([^[:space:]]*\).*/\1/'`; do if ! remove_item "${item_id}" "${use_sudo}" "${PASSWORD}" "${use_interactive}"; then printf "\n Aborting!\n" exit 1 fi done for item_id in `${collections_info} simulator_models | sed -e 's/^[^[:space:]]* \([^[:space:]]*\).*/\1/'`; do if ! remove_item "${item_id}" "${use_sudo}" "${PASSWORD}" "${use_interactive}"; then printf "\n Aborting!\n" exit 1 fi done printf "\nSuccess!\n" else printf "\nAborting!\n" exit 1 fi ;; --version) if test $# -ne 1; then usage exit 1 else printf "%s\n" "${kim_version_string}" fi ;; esac kim-api-2.3.0-git/utils/deactivate.in000077500000000000000000000067471421473465500174610ustar00rootroot00000000000000#!/bin/sh # # # KIM-API: An API for interatomic models # Copyright (c) 2013--2022, Regents of the University of Minnesota. # All rights reserved. # # Contributors: # Ryan S. Elliott # Yaser Afshar # # SPDX-License-Identifier: LGPL-2.1-or-later # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Release: This file is part of the kim-api.git repository. # # Ensure that this script is sourced, not executed BASENAME_SOURCE=`basename -- "$0" 2> /dev/null` if test -n "${ZSH_VERSION}"; then if test $options[posixargzero] != "on"; then setopt posixargzero BASENAME_SOURCE=`basename -- "$0" 2> /dev/null` setopt posixargzero fi fi if test x"${BASENAME_SOURCE}" = x"@PROJECT_NAME@-deactivate"; then (>&2 printf "\nError:\t@PROJECT_NAME@-deactivate must be sourced.\n" printf "\tRun 'source @PROJECT_NAME@-deactivate' not " printf "'@PROJECT_NAME@-deactivate'.\n\n") exit 1 fi if test -n "${ORIGIN}"; then OLD_KIM_ORIGIN="${ORIGIN}" fi if test -n "${ZSH_VERSION}"; then ORIGIN=$(cd "$(dirname "${(%):-%x}")" && pwd) else # Get ORIGIN location of this script: SOURCE="${BASH_SOURCE[0]}" # https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself if command -v readlink >/dev/null 2>&1; then while test -h "$SOURCE"; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done fi ORIGIN="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" fi export PATH=`printf "${PATH}" | sed -e "s|:${ORIGIN}|:|g" \ -e "s|^${ORIGIN}:*||" \ -e "s|:${ORIGIN}$||"` _libdir_rel=$(cd "@_libdir_rel@" && pwd) export PKG_CONFIG_PATH=`printf "${PKG_CONFIG_PATH}" | \ sed -e "s|:${_libdir_rel}/pkgconfig|:|g" \ -e "s|^${_libdir_rel}/pkgconfig:*||" \ -e "s|:${_libdir_rel}/pkgconfig$||"` unset _libdir_rel if test -z "${PKG_CONFIG_PATH}"; then unset PKG_CONFIG_PATH; fi unset @KIM_API_ENVIRONMENT_CMAKE_PREFIX_DIR@ if test -n "${ZSH_VERSION}"; then _completion_dir="@_zshcompdir_rel@" else _completion_dir="@_bashcompdir_rel@" fi for _func in `grep "_@KIM_API_C_ID_PROJECT_NAME@_.*[[:space:]]*()" \ "${_completion_dir}/@PROJECT_NAME@-collections-management.bash"`; do _func=`printf "${_func}" | sed -e 's|[[:space:]]*().*||'` unset -f "${_func}" done unset _func unset _completion_dir if test -n "${OLD_KIM_ORIGIN}"; then ORIGIN="${OLD_KIM_ORIGIN}" unset OLD_KIM_ORIGIN else unset ORIGIN fi kim-api-2.3.0-git/utils/portable-model-info.cpp000066400000000000000000000226631421473465500213530ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include "KIM_SimulatorHeaders.hpp" #include "KIM_SupportedExtensions.hpp" #include "KIM_Version.hpp" #include "edn-cpp/edn.hpp" #include #include #include #include #include #include void usage(std::string name) { size_t beg = name.find_last_of("/\\"); if (beg != std::string::npos) name = name.substr(beg + 1, std::string::npos); // Follows docopt.org format std::cerr << "Usage:\n" << " " << name << " " << "\n" << " " << name << " " << "--version\n"; // note: this interface is likely to change in future kim-api releases } int main(int argc, char * argv[]) { KIM::Model * mdl; int requestedUnitsAccepted = 0; if ((argc != 2) || (std::string(argv[1]) == "")) { usage(argv[0]); return 1; } if ((argc == 2) && (std::string(argv[1]) == "--version")) { std::cout << KIM_VERSION_STRING << std::endl; return 0; } int error = KIM::Model::Create(KIM::NUMBERING::zeroBased, KIM::LENGTH_UNIT::m, KIM::ENERGY_UNIT::amu_A2_per_ps2, KIM::CHARGE_UNIT::statC, KIM::TEMPERATURE_UNIT::K, KIM::TIME_UNIT::ns, argv[1], &requestedUnitsAccepted, &mdl); if (error) { std::cerr << "Error creating model object" << std::endl; exit(1); } std::stringstream edn; edn << std::setprecision(16) << std::scientific; edn << "{" << "\"model-name\"" << " \"" << argv[1] << "\" "; // Unit information edn << "\"units-request-accepted\"" << " " << ((requestedUnitsAccepted) ? "true" : "false") << " " << "\"units-unused\"" << " " << "["; KIM::LengthUnit length; KIM::EnergyUnit energy; KIM::ChargeUnit charge; KIM::TemperatureUnit temp; KIM::TimeUnit time; mdl->GetUnits(&length, &energy, &charge, &temp, &time); if (length == KIM::LENGTH_UNIT::unused) edn << "\"length\"" << " "; if (energy == KIM::ENERGY_UNIT::unused) edn << "\"energy\"" << " "; if (charge == KIM::CHARGE_UNIT::unused) edn << "\"charge\"" << " "; if (temp == KIM::TEMPERATURE_UNIT::unused) edn << "\"temperature\"" << " "; if (time == KIM::TIME_UNIT::unused) edn << "\"time\"" << " "; edn << "]" << " "; // influence distance double influenceDistance = 0.0; mdl->GetInfluenceDistance(&influenceDistance); edn << "\"influence-distance\"" << " " << "[ " << influenceDistance << " \"" << length.ToString() << "\" ]"; // neighbor lists int numberOfNeighborLists = 0; double const * cutoffs = NULL; int const * nonContrib = NULL; mdl->GetNeighborListPointers(&numberOfNeighborLists, &cutoffs, &nonContrib); edn << "\"neighbor-lists\"" << " " << "{ " << "\"number-of-lists\"" << " " << numberOfNeighborLists << " " << "\"cutoffs\"" << " [ "; for (int i = 0; i < numberOfNeighborLists; ++i) { edn << cutoffs[i] << " "; } edn << "] " << "\"model-will-not-request-neighbors-of-noncontributing-particles\"" << " " << "[ "; for (int i = 0; i < numberOfNeighborLists; ++i) { edn << nonContrib[i] << " "; } edn << "] " << "} "; // Species support and code edn << "\"supported-species\"" << " " << "[ "; int numberSpecies = 0; KIM::SPECIES_NAME::GetNumberOfSpeciesNames(&numberSpecies); for (int i = 0; i < numberSpecies; ++i) { KIM::SpeciesName species; KIM::SPECIES_NAME::GetSpeciesName(i, &species); int supported; int code; error = mdl->GetSpeciesSupportAndCode(species, &supported, &code); if (!error) { if (supported) { edn << "[ \"" << species.ToString() << "\" " << code << " ]" << " "; } } } edn << "] "; // Parameter information int numberOfParameters = 0; mdl->GetNumberOfParameters(&numberOfParameters); edn << "\"parameters\"" << " " << "{ " << "\"number-of-parameters\"" << " " << numberOfParameters << " " << "\"parameter-metadata\"" << "[ "; for (int i = 0; i < numberOfParameters; ++i) { KIM::DataType dtype; int extent; std::string const * name; std::string const * description; error = mdl->GetParameterMetadata(i, &dtype, &extent, &name, &description); if (!error) { edn << "{ " << "\"data-type\"" << " " << "\"" << dtype.ToString() << "\"" << " " << "\"extent\"" << " " << extent << " " << "\"name\"" << " " << "\"" << *name << "\"" << " " << "\"description\"" << " " << "\"" << edn::escapeQuotes(*description) << "\"" << " }" << " "; } } edn << "] " << "} "; // Present routines bool extensionPresent = false; int numberOfModelRoutineNames; KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames( &numberOfModelRoutineNames); edn << "\"routines-present\"" << " " << "{ "; for (int i = 0; i < numberOfModelRoutineNames; ++i) { KIM::ModelRoutineName routineName; int present; int required; KIM::MODEL_ROUTINE_NAME::GetModelRoutineName(i, &routineName); error = mdl->IsRoutinePresent(routineName, &present, &required); if (!error) { if ((routineName == KIM::MODEL_ROUTINE_NAME::Extension) && present) extensionPresent = true; if (present) edn << "\"" << routineName.ToString() << "\"" << " " << ((required) ? "required" : "optional") << " "; } } edn << "} "; // Extensions, if present edn << "\"extensions\"" << " { "; if (extensionPresent) { KIM::SupportedExtensions extensionStruct; error = mdl->Extension(KIM_SUPPORTED_EXTENSIONS_ID, &extensionStruct); if (!error) { for (int i = 0; i < extensionStruct.numberOfSupportedExtensions; ++i) { edn << "\"" << extensionStruct.supportedExtensionID[i] << "\"" << " " << ((extensionStruct.supportedExtensionRequired[i]) ? "\"required\"" : "\"optional\"") << " "; } } } edn << "} "; // Compute Arguments edn << "\"compute-arguments\"" << " { "; KIM::ComputeArguments * computeArguments; error = mdl->ComputeArgumentsCreate(&computeArguments); if (!error) { KIM::ComputeArgumentName argumentName; int numberOfComputeArgumentNames = 0; KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames( &numberOfComputeArgumentNames); for (int i = 0; i < numberOfComputeArgumentNames; ++i) { KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName(i, &argumentName); KIM::SupportStatus supportStatus; error = computeArguments->GetArgumentSupportStatus(argumentName, &supportStatus); if (!error) { edn << "\"" << argumentName.ToString() << "\"" << " " << "\"" << supportStatus.ToString() << "\"" << " "; } } } edn << "} "; // Compute Callbacks edn << "\"compute-callbacks\"" << " { "; if (computeArguments != NULL) { KIM::ComputeCallbackName callbackName; int numberOfComputeCallbackNames = 0; KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames( &numberOfComputeCallbackNames); for (int i = 0; i < numberOfComputeCallbackNames; ++i) { KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName(i, &callbackName); KIM::SupportStatus supportStatus; error = computeArguments->GetCallbackSupportStatus(callbackName, &supportStatus); if (!error) { edn << "\"" << callbackName.ToString() << "\"" << " " << "\"" << supportStatus.ToString() << "\"" << " "; } } } edn << "} "; edn << "}"; // destroy the objects error = mdl->ComputeArgumentsDestroy(&computeArguments); KIM::Model::Destroy(&mdl); edn::EdnNode modelInfo; try { modelInfo = edn::read(edn.str()); } catch (std::string e) { std::cerr << "Error reading edn string" << std::endl; exit(2); } std::cout << edn::pprint(modelInfo); return 0; } kim-api-2.3.0-git/utils/shared-library-test.cpp000066400000000000000000000055131421473465500213740ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include "KIM_Version.hpp" #include #ifndef _WIN32 #include #else #include #endif #include #include void usage(std::string name) { size_t beg = name.find_last_of("/\\"); if (beg != std::string::npos) name = name.substr(beg + 1, std::string::npos); // Follows docopt.org format std::cerr << "Usage:\n" << " " << name << " \n" << " " << name << " --version" << std::endl; // note: this interface is likely to change in future kim-api releases } int IsFilePath(std::string const & filePath) { // not very comperhensive but can be improved as needed if (filePath.length() == 0) return false; return true; } int main(int argc, char * argv[]) { if (argc != 2) { usage(argv[0]); return 1; } else if (std::string(argv[1]) == "--version") { std::cout << KIM_VERSION_STRING << std::endl; return 0; } else { std::string libFilePath(argv[1]); if (!IsFilePath(libFilePath)) // validate lib path { std::cout << "Invalid .\n" << std::endl; return 2; } #ifndef _WIN32 void * sharedLibraryHandle = dlopen(libFilePath.c_str(), RTLD_NOW); #else HMODULE sharedLibraryHandle = LoadLibraryExA( libFilePath.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); #endif if (sharedLibraryHandle == NULL) { #ifndef _WIN32 std::cout << "Unable to open shared library.\n" << dlerror() << std::endl; #else std::cout << "Unable to open shared library." << std::endl; #endif return 3; } else { std::cout << "Successfully opened shared library." << std::endl; #ifndef _WIN32 dlclose(sharedLibraryHandle); #else FreeLibrary(sharedLibraryHandle); #endif return 0; } } } kim-api-2.3.0-git/utils/simulator-model.cpp000066400000000000000000000143741421473465500206310ustar00rootroot00000000000000// // KIM-API: An API for interatomic models // Copyright (c) 2013--2022, Regents of the University of Minnesota. // All rights reserved. // // Contributors: // Ryan S. Elliott // Alexander Stukowski // // SPDX-License-Identifier: LGPL-2.1-or-later // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // // Release: This file is part of the kim-api.git repository. // #include "KIM_SimulatorModel.hpp" #include "KIM_Version.hpp" #include #include #include #include void usage(std::string name) { size_t beg = name.find_last_of("/\\"); if (beg != std::string::npos) name = name.substr(beg + 1, std::string::npos); // Follows docopt.org format std::cerr << "Usage:\n" << " " << name << " " << "\n" << " " << name << " " << " " << "number-of-parameter-files\n" << " " << name << " " << " " << "(smspec-file | ) " << "(data | name)\n" << " " << name << " " << "--version\n"; // note: this interface is likely to change in future kim-api releases } int main(int argc, char * argv[]) { if ((argc < 2) || (argc >= 5)) { usage(argv[0]); return -1; } if ((argc == 2) && (std::string(argv[1]) == "--version")) { std::cout << KIM_VERSION_STRING << std::endl; return 0; } char const * const simulatorModelName = argv[1]; KIM::SimulatorModel * simulatorModel; int error = KIM::SimulatorModel::Create(simulatorModelName, &simulatorModel); if (error) { std::cout << "* Error: Could not create object for name: '" << simulatorModelName << "'" << std::endl; return 1; } int returnValue = 0; if (argc == 2) { std::cout << "SIMULATOR_MODEL"; returnValue = 0; goto cleanup; } if (std::string(argv[2]) == "number-of-parameter-files") { int number; simulatorModel->GetNumberOfParameterFiles(&number); std::cout << number << std::endl; returnValue = 0; goto cleanup; } else if (argc < 4) { usage(argv[0]); returnValue = -2; goto cleanup; } else { std::string const * dirName; simulatorModel->GetParameterFileDirectoryName(&dirName); std::string const * name; if (std::string(argv[2]) == "smspec-file") { simulatorModel->GetSpecificationFileName(&name); std::string const filePath = *dirName + "/" + *name; FILE * file = fopen(filePath.c_str(), "rb"); if (file == NULL) { std::cout << "* Error: unable to open smspec file." << std::endl; returnValue = 8; goto cleanup; } fseek(file, 0, SEEK_END); long int size = ftell(file); fclose(file); file = fopen(filePath.c_str(), "rb"); unsigned char * fileData = new unsigned char[size]; size_t numberReadObjects; numberReadObjects = fread(fileData, sizeof(unsigned char), size, file); fclose(file); if (numberReadObjects != static_cast(size)) { std::cout << "* Error: unable to fully read smspec file." << std::endl; returnValue = 8; goto cleanup; } if (std::string(argv[3]) == "name") { std::cout << *name << std::endl; } else if (std::string(argv[3]) == "data") { fwrite(fileData, sizeof(unsigned char), size, stdout); } delete[] fileData; } else // one-based parameter file index provided { int number; simulatorModel->GetNumberOfParameterFiles(&number); int index = atol(argv[2]); if ((index < 1) || (index > number)) { std::cout << "* Error: invalid index provided." << std::endl; returnValue = 7; goto cleanup; } else { std::string const * dirName; simulatorModel->GetParameterFileDirectoryName(&dirName); // The command line interface uses a one-based index for compatibility // with external scripts. The SharedLibrary API uses a zero-based // index consistent with standard C++ convention. error = simulatorModel->GetParameterFileName(index - 1, &name); if (error) { std::cout << "* Error: unable to get parameter file name." << std::endl; returnValue = 8; goto cleanup; } std::string const filePath = *dirName + "/" + *name; FILE * file = fopen(filePath.c_str(), "r"); if (file == NULL) { std::cout << "* Error: unable to open parameter file." << std::endl; returnValue = 8; goto cleanup; } fseek(file, 0, SEEK_END); long int size = ftell(file); fclose(file); file = fopen(filePath.c_str(), "r"); unsigned char * fileData = new unsigned char[size]; size_t numberReadObjects; numberReadObjects = fread(fileData, sizeof(unsigned char), size, file); fclose(file); if (numberReadObjects != static_cast(size)) { std::cout << "* Error: unable to fully read parameter file." << std::endl; returnValue = 8; goto cleanup; } if (std::string(argv[3]) == "name") { std::cout << *name << std::endl; } else if (std::string(argv[3]) == "data") { fwrite(fileData, sizeof(unsigned char), size, stdout); } delete[] fileData; } } returnValue = 0; goto cleanup; } cleanup: KIM::SimulatorModel::Destroy(&simulatorModel); return returnValue; }