update to current master

This commit is contained in:
Steve Plimpton
2020-04-30 11:57:17 -06:00
6448 changed files with 2492395 additions and 318578 deletions

5
.github/CODEOWNERS vendored
View File

@ -22,7 +22,6 @@ src/SPIN/* @julient31
src/USER-CGDNA/* @ohenrich src/USER-CGDNA/* @ohenrich
src/USER-CGSDK/* @akohlmey src/USER-CGSDK/* @akohlmey
src/USER-COLVARS/* @giacomofiorin src/USER-COLVARS/* @giacomofiorin
src/USER-DPD/* @timattox
src/USER-INTEL/* @wmbrownintel src/USER-INTEL/* @wmbrownintel
src/USER-MANIFOLD/* @Pakketeretet2 src/USER-MANIFOLD/* @Pakketeretet2
src/USER-MEAMC/* @martok src/USER-MEAMC/* @martok
@ -46,7 +45,7 @@ src/GPU/pair_vashishta_gpu.* @andeplane
src/KOKKOS/pair_vashishta_kokkos.* @andeplane src/KOKKOS/pair_vashishta_kokkos.* @andeplane
src/MANYBODY/pair_vashishta_table.* @andeplane src/MANYBODY/pair_vashishta_table.* @andeplane
src/MANYBODY/pair_atm.* @sergeylishchuk src/MANYBODY/pair_atm.* @sergeylishchuk
src/USER-MISC/fix_bond_react.* @jrgissing src/USER-REACTION/fix_bond_react.* @jrgissing
src/USER-MISC/*_grem.* @dstelter92 src/USER-MISC/*_grem.* @dstelter92
src/USER-MISC/compute_stress_mop*.* @RomainVermorel src/USER-MISC/compute_stress_mop*.* @RomainVermorel
@ -111,6 +110,7 @@ src/exceptions.h @rbberger
src/fix_nh.* @athomps src/fix_nh.* @athomps
src/info.* @akohlmey @rbberger src/info.* @akohlmey @rbberger
src/timer.* @akohlmey src/timer.* @akohlmey
src/min* @sjplimp @stanmoore1
# tools # tools
tools/msi2lmp/* @akohlmey tools/msi2lmp/* @akohlmey
@ -118,6 +118,7 @@ tools/emacs/* @HaoZeke
# cmake # cmake
cmake/* @junghans @rbberger cmake/* @junghans @rbberger
cmake/Modules/Packages/USER-COLVARS.cmake @junghans @rbberger @giacomofiorin
# python # python
python/* @rbberger python/* @rbberger

View File

@ -68,12 +68,12 @@ How quickly your contribution will be integrated depends largely on how much eff
Here is a checklist of steps you need to follow to submit a single file or user package for our consideration. Following these steps will save both you and us time. See existing files in packages in the source directory for examples. If you are uncertain, please ask on the lammps-users mailing list. Here is a checklist of steps you need to follow to submit a single file or user package for our consideration. Following these steps will save both you and us time. See existing files in packages in the source directory for examples. If you are uncertain, please ask on the lammps-users mailing list.
* All source files you provide must compile with the most current version of LAMMPS with multiple configurations. In particular you need to test compiling LAMMPS from scratch with `-DLAMMPS_BIGBIG` set in addition to the default `-DLAMMPS_SMALLBIG` setting. Your code will need to work correctly in serial and in parallel using MPI. * All source files you provide must compile with the most current version of LAMMPS with multiple configurations. In particular you need to test compiling LAMMPS from scratch with `-DLAMMPS_BIGBIG` set in addition to the default `-DLAMMPS_SMALLBIG` setting. Your code will need to work correctly in serial and in parallel using MPI.
* For consistency with the rest of LAMMPS and especially, if you want your contribution(s) to be added to main LAMMPS code or one of its standard packages, it needs to be written in a style compatible with other LAMMPS source files. This means: 2-character indentation per level, no tabs, no lines over 80 characters. I/O is done via the C-style stdio library, style class header files should not import any system headers, STL containers should be avoided in headers, and forward declarations used where possible or needed. All added code should be placed into the LAMMPS_NS namespace or a sub-namespace; global or static variables should be avoided, as they conflict with the modular nature of LAMMPS and the C++ class structure. There MUST NOT be any "using namespace XXX;" statements in headers. In the implementation file (<name>.cpp) system includes should be placed in angular brackets (<>) and for c-library functions the C++ style header files should be included (<cstdio> instead of <stdio.h>, or <cstring> instead of <string.h>). This all is so the developers can more easily understand, integrate, and maintain your contribution and reduce conflicts with other parts of LAMMPS. This basically means that the code accesses data structures, performs its operations, and is formatted similar to other LAMMPS source files, including the use of the error class for error and warning messages. * For consistency with the rest of LAMMPS and especially, if you want your contribution(s) to be added to main LAMMPS code or one of its standard packages, it needs to be written in a style compatible with other LAMMPS source files. This means: 2-character indentation per level, no tabs, no trailing whitespace, no lines over 80 characters. I/O is done via the C-style stdio library, style class header files should not import any system headers, STL containers should be avoided in headers, and forward declarations used where possible or needed. All added code should be placed into the LAMMPS_NS namespace or a sub-namespace; global or static variables should be avoided, as they conflict with the modular nature of LAMMPS and the C++ class structure. There MUST NOT be any "using namespace XXX;" statements in headers. In the implementation file (<name>.cpp) system includes should be placed in angular brackets (<>) and for c-library functions the C++ style header files should be included (<cstdio> instead of <stdio.h>, or <cstring> instead of <string.h>). This all is so the developers can more easily understand, integrate, and maintain your contribution and reduce conflicts with other parts of LAMMPS. This basically means that the code accesses data structures, performs its operations, and is formatted similar to other LAMMPS source files, including the use of the error class for error and warning messages.
* Source, style name, and documentation file should follow the following naming convention: style names should be lowercase and words separated by a forward slash; for a new fix style 'foo/bar', the class should be named FixFooBar, the name of the source files should be 'fix_foo_bar.h' and 'fix_foo_bar.cpp' and the corresponding documentation should be in a file 'fix_foo_bar.txt'. * Source, style name, and documentation file should follow the following naming convention: style names should be lowercase and words separated by a forward slash; for a new fix style 'foo/bar', the class should be named FixFooBar, the name of the source files should be 'fix_foo_bar.h' and 'fix_foo_bar.cpp' and the corresponding documentation should be in a file 'fix_foo_bar.rst'.
* If you want your contribution to be added as a user-contributed feature, and it is a single file (actually a `<name>.cpp` and `<name>.h` file) it can be rapidly added to the USER-MISC directory. Include the one-line entry to add to the USER-MISC/README file in that directory, along with the 2 source files. You can do this multiple times if you wish to contribute several individual features. * If you want your contribution to be added as a user-contributed feature, and it is a single file (actually a `<name>.cpp` and `<name>.h` file) it can be rapidly added to the USER-MISC directory. Include the one-line entry to add to the USER-MISC/README file in that directory, along with the 2 source files. You can do this multiple times if you wish to contribute several individual features.
* If you want your contribution to be added as a user-contribution and it is several related features, it is probably best to make it a user package directory with a name like USER-FOO. In addition to your new files, the directory should contain a README text file. The README should contain your name and contact information and a brief description of what your new package does. If your files depend on other LAMMPS style files also being installed (e.g. because your file is a derived class from the other LAMMPS class), then an Install.sh file is also needed to check for those dependencies. See other README and Install.sh files in other USER directories as examples. Send us a tarball of this USER-FOO directory. * If you want your contribution to be added as a user-contribution and it is several related features, it is probably best to make it a user package directory with a name like USER-FOO. In addition to your new files, the directory should contain a README text file. The README should contain your name and contact information and a brief description of what your new package does. If your files depend on other LAMMPS style files also being installed (e.g. because your file is a derived class from the other LAMMPS class), then an Install.sh file is also needed to check for those dependencies. See other README and Install.sh files in other USER directories as examples. Send us a tarball of this USER-FOO directory.
* Your new source files need to have the LAMMPS copyright, GPL notice, and your name and email address at the top, like other user-contributed LAMMPS source files. They need to create a class that is inside the LAMMPS namespace. If the file is for one of the USER packages, including USER-MISC, then we are not as picky about the coding style (see above). I.e. the files do not need to be in the same stylistic format and syntax as other LAMMPS files, though that would be nice for developers as well as users who try to read your code. * Your new source files need to have the LAMMPS copyright, GPL notice, and your name and email address at the top, like other user-contributed LAMMPS source files. They need to create a class that is inside the LAMMPS namespace. If the file is for one of the USER packages, including USER-MISC, then we are not as picky about the coding style (see above). I.e. the files do not need to be in the same stylistic format and syntax as other LAMMPS files, though that would be nice for developers as well as users who try to read your code.
* You **must** also create or extend a documentation file for each new command or style you are adding to LAMMPS. For simplicity and convenience, the documentation of groups of closely related commands or styles may be combined into a single file. This will be one file for a single-file feature. For a package, it might be several files. These are simple text files with a specific markup language, that are then auto-converted to HTML and PDF. The tools for this conversion are included in the source distribution, and the translation can be as simple as doing "make html pdf" in the doc folder. Thus the documentation source files must be in the same format and style as other `<name>.txt` files in the lammps/doc/src directory for similar commands and styles; use one or more of them as a starting point. A description of the markup can also be found in `lammps/doc/utils/txt2html/README.html` As appropriate, the text files can include links to equations (see doc/Eqs/*.tex for examples, we auto-create the associated JPG files), or figures (see doc/JPG for examples), or even additional PDF files with further details (see doc/PDF for examples). The doc page should also include literature citations as appropriate; see the bottom of doc/fix_nh.txt for examples and the earlier part of the same file for how to format the cite itself. The "Restrictions" section of the doc page should indicate that your command is only available if LAMMPS is built with the appropriate USER-MISC or USER-FOO package. See other user package doc files for examples of how to do this. The prerequisite for building the HTML format files are Python 3.x and virtualenv, the requirement for generating the PDF format manual is the htmldoc software. Please run at least "make html" and carefully inspect and proofread the resulting HTML format doc page before submitting your code. * You **must** also create or extend a documentation file for each new command or style you are adding to LAMMPS. For simplicity and convenience, the documentation of groups of closely related commands or styles may be combined into a single file. This will be one file for a single-file feature. For a package, it might be several files. These are files in the [reStructuredText](https://docutils.sourceforge.io/rst.html) markup language, that are then converted to HTML and PDF. The tools for this conversion are included in the source distribution, and the translation can be as simple as doing "make html pdf" in the doc folder. Thus the documentation source files must be in the same format and style as other `<name>.rst` files in the lammps/doc/src directory for similar commands and styles; use one or more of them as a starting point. An introduction to reStructuredText can be found at [https://docutils.sourceforge.io/docs/user/rst/quickstart.html](https://docutils.sourceforge.io/docs/user/rst/quickstart.html). The text files can include mathematical expressions and symbol in ".. math::" sections or ":math:" expressions or figures (see doc/JPG for examples), or even additional PDF files with further details (see doc/PDF for examples). The doc page should also include literature citations as appropriate; see the bottom of doc/fix_nh.rst for examples and the earlier part of the same file for how to format the cite itself. The "Restrictions" section of the doc page should indicate that your command is only available if LAMMPS is built with the appropriate USER-MISC or USER-FOO package. See other user package doc files for examples of how to do this. The prerequisite for building the HTML format files are Python 3.x and virtualenv. Please run at least `make html`, `make pdf` and `make spelling` and carefully inspect and proofread the resulting HTML format doc page as well as the output produced to the screen. Make sure that all spelling errors are fixed or the necessary false positives are added to the `doc/utils/sphinx-config/false_positives.txt` file. For new styles, those usually also need to be added to lists on the respective overview pages. This can be checked for also with `make style_check`.
* For a new package (or even a single command) you should include one or more example scripts demonstrating its use. These should run in no more than a couple minutes, even on a single processor, and not require large data files as input. See directories under examples/USER for examples of input scripts other users provided for their packages. These example inputs are also required for validating memory accesses and testing for memory leaks with valgrind * For a new package (or even a single command) you should include one or more example scripts demonstrating its use. These should run in no more than a couple minutes, even on a single processor, and not require large data files as input. See directories under examples/USER for examples of input scripts other users provided for their packages. These example inputs are also required for validating memory accesses and testing for memory leaks with valgrind
* If there is a paper of yours describing your feature (either the algorithm/science behind the feature itself, or its initial usage, or its implementation in LAMMPS), you can add the citation to the *.cpp source file. See src/USER-EFF/atom_vec_electron.cpp for an example. A LaTeX citation is stored in a variable at the top of the file and a single line of code that references the variable is added to the constructor of the class. Whenever a user invokes your feature from their input script, this will cause LAMMPS to output the citation to a log.cite file and prompt the user to examine the file. Note that you should only use this for a paper you or your group authored. E.g. adding a cite in the code for a paper by Nose and Hoover if you write a fix that implements their integrator is not the intended usage. That kind of citation should just be in the doc page you provide. * If there is a paper of yours describing your feature (either the algorithm/science behind the feature itself, or its initial usage, or its implementation in LAMMPS), you can add the citation to the *.cpp source file. See src/USER-EFF/atom_vec_electron.cpp for an example. A LaTeX citation is stored in a variable at the top of the file and a single line of code that references the variable is added to the constructor of the class. Whenever a user invokes your feature from their input script, this will cause LAMMPS to output the citation to a log.cite file and prompt the user to examine the file. Note that you should only use this for a paper you or your group authored. E.g. adding a cite in the code for a paper by Nose and Hoover if you write a fix that implements their integrator is not the intended usage. That kind of citation should just be in the doc page you provide.

View File

@ -9,24 +9,24 @@ assignees: ''
**Summary** **Summary**
_Please provide a clear and concise description of what the bug is._ <!--Please provide a clear and concise description of what the bug is.-->
**LAMMPS Version and Platform** **LAMMPS Version and Platform**
_Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version_ <!--Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version-->
**Expected Behavior** **Expected Behavior**
_Describe the expected behavior. Quote from the LAMMPS manual where needed, or explain why the expected behavior is meaningful, especially when it differs from the manual_ <!--Describe the expected behavior. Quote from the LAMMPS manual where needed, or explain why the expected behavior is meaningful, especially when it differs from the manual-->
**Actual Behavior** **Actual Behavior**
_Describe the actual behavior, how it differs from the expected behavior, and how this can be observed. Try to be specific and do **not** use vague terms like "doesn't work" or "wrong result". Do not assume that the person reading this has any experience with or knowledge of your specific area of research._ <!--Describe the actual behavior, how it differs from the expected behavior, and how this can be observed. Try to be specific and do **not** use vague terms like "doesn't work" or "wrong result". Do not assume that the person reading this has any experience with or knowledge of your specific area of research.-->
**Steps to Reproduce** **Steps to Reproduce**
_Describe the steps required to (quickly) reproduce the issue. You can attach (small) files to the section below or add URLs where to download an archive with all necessary files. Please try to create an input set that is as minimal and small as possible and reproduces the bug as quickly as possible. **NOTE:** the less effort and time it takes to reproduce your reported bug, the more likely it becomes, that somebody will look into it and fix the problem._ <!--Describe the steps required to (quickly) reproduce the issue. You can attach (small) files to the section below or add URLs where to download an archive with all necessary files. Please try to create an input set that is as minimal and small as possible and reproduces the bug as quickly as possible. **NOTE:** the less effort and time it takes to reproduce your reported bug, the more likely it becomes, that somebody will look into it and fix the problem.-->
**Further Information, Files, and Links** **Further Information, Files, and Links**
_Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications_ <!--Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications-->

View File

@ -9,12 +9,12 @@ assignees: ''
**Summary** **Summary**
_Please provide a brief and concise description of the suggested feature or change_ <!--Please provide a brief and concise description of the suggested feature or change-->
**Detailed Description** **Detailed Description**
_Please explain how you would like to see LAMMPS enhanced, what feature(s) you are looking for, what specific problems this will solve. If possible, provide references to relevant background information like publications or web pages, and whether you are planning to implement the enhancement yourself or would like to participate in the implementation. If applicable add a reference to an existing bug report or issue that this will address._ <!--Please explain how you would like to see LAMMPS enhanced, what feature(s) you are looking for, what specific problems this will solve. If possible, provide references to relevant background information like publications or web pages, and whether you are planning to implement the enhancement yourself or would like to participate in the implementation. If applicable add a reference to an existing bug report or issue that this will address.-->
**Further Information, Files, and Links** **Further Information, Files, and Links**
_Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications_ <!--Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications-->

View File

@ -9,13 +9,13 @@ assignees: ''
**Summary** **Summary**
_Please provide a clear and concise description of what this issue report is about._ <!--Please provide a clear and concise description of what this issue report is about.-->
**LAMMPS Version and Platform** **LAMMPS Version and Platform**
_Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version_ <!--Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version-->
**Details** **Details**
_Please explain the issue in detail here_ <!--Please explain the issue in detail here-->

View File

@ -1,14 +1,14 @@
**Summary** **Summary**
_Briefly describe the new feature(s), enhancement(s), or bugfix(es) included in this pull request._ <!--Briefly describe the new feature(s), enhancement(s), or bugfix(es) included in this pull request.-->
**Related Issues** **Related Issues**
_If this addresses an open GitHub issue for this project, please mention the issue number here, and describe the relation. Use the phrases `fixes #221` or `closes #135`, when you want an issue to be automatically closed when the pull request is merged_ <!--If this addresses an open GitHub issue for this project, please mention the issue number here, and describe the relation. Use the phrases `fixes #221` or `closes #135`, when you want an issue to be automatically closed when the pull request is merged-->
**Author(s)** **Author(s)**
_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request. If this pull request adds new files to the distribution, please also provide a suitable "long-lived" e-mail address (ideally something that can outlive your institution's e-mail, in case you change jobs) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this contributed code._ <!--Please state name and affiliation of the author or authors that should be credited with the changes in this pull request. If this pull request adds new files to the distribution, please also provide a suitable "long-lived" e-mail address (ideally something that can outlive your institution's e-mail, in case you change jobs) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this contributed code.-->
**Licensing** **Licensing**
@ -16,15 +16,15 @@ By submitting this pull request, I agree, that my contribution will be included
**Backward Compatibility** **Backward Compatibility**
_Please state whether any changes in the pull request will break backward compatibility for inputs, and - if yes - explain what has been changed and why_ <!--Please state whether any changes in the pull request will break backward compatibility for inputs, and - if yes - explain what has been changed and why-->
**Implementation Notes** **Implementation Notes**
_Provide any relevant details about how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected_ <!--Provide any relevant details about how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected-->
**Post Submission Checklist** **Post Submission Checklist**
_Please check the fields below as they are completed **after** the pull request has been submitted. Delete lines that don't apply_ <!--Please check the fields below as they are completed **after** the pull request has been submitted. Delete lines that don't apply-->
- [ ] The feature or features in this pull request is complete - [ ] The feature or features in this pull request is complete
- [ ] Licensing information is complete - [ ] Licensing information is complete
@ -39,6 +39,6 @@ _Please check the fields below as they are completed **after** the pull request
**Further Information, Files, and Links** **Further Information, Files, and Links**
_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)_ <!--Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)-->

View File

@ -9,15 +9,15 @@ assignees: ''
**Summary** **Summary**
_Briefly describe the bug or bugs, that are eliminated by this pull request._ <!--Briefly describe the bug or bugs, that are eliminated by this pull request.-->
**Related Issue(s)** **Related Issue(s)**
_If this request addresses or is related to an existing (open) GitHub issue, e.g. a bug report, mention the issue number number here following a pound sign (aka hashmark), e.g.`#222`._ <!--If this request addresses or is related to an existing (open) GitHub issue, e.g. a bug report, mention the issue number number here following a pound sign (aka hashmark), e.g.`#222`.-->
**Author(s)** **Author(s)**
_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request_ <!--Please state name and affiliation of the author or authors that should be credited with the changes in this pull request-->
**Licensing** **Licensing**
@ -25,18 +25,18 @@ By submitting this pull request I implicitly accept, that my submission is subje
**Backward Compatibility** **Backward Compatibility**
_Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why_ <!--Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why-->
**Detailed Description** **Detailed Description**
_Provide any relevant details about how the fixed bug can be reproduced, how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected_ <!--Provide any relevant details about how the fixed bug can be reproduced, how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected-->
## Post Submission Checklist ## Post Submission Checklist
_Please check the fields below as they are completed *after* the pull request is submitted_ <!--Please check the fields below as they are completed *after* the pull request is submitted-->
- [ ] The code in this pull request is complete - [ ] The code in this pull request is complete
- [ ] The source code follows the LAMMPS formatting guidelines - [ ] The source code follows the LAMMPS formatting guidelines
## Further Information, Files, and Links ## Further Information, Files, and Links
_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. to download input decks for testing)_ <!--Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. to download input decks for testing)-->

View File

@ -9,15 +9,15 @@ assignees: ''
**Summary** **Summary**
_Briefly describe the included changes._ <!--Briefly describe the included changes.-->
**Related Issue(s)** **Related Issue(s)**
_If this request addresses or is related to an existing (open) GitHub issue, e.g. a bug report, mention the issue number number here following a pound sign (aka hashmark), e.g.`#222`. <!--If this request addresses or is related to an existing (open) GitHub issue, e.g. a bug report, mention the issue number number here following a pound sign (aka hashmark), e.g.`#222`.
**Author(s)** **Author(s)**
_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request_ <!--Please state name and affiliation of the author or authors that should be credited with the changes in this pull request-->
**Licensing** **Licensing**
@ -25,11 +25,11 @@ By submitting this pull request I implicitly accept, that my submission is subje
**Detailed Description** **Detailed Description**
_Provide any relevant details about the included changes._ <!--Provide any relevant details about the included changes.-->
## Post Submission Checklist ## Post Submission Checklist
_Please check the fields below as they are completed *after* the pull request is submitted_ <!--Please check the fields below as they are completed *after* the pull request is submitted-->
- [ ] The pull request is complete - [ ] The pull request is complete
- [ ] The source code follows the LAMMPS formatting guidelines - [ ] The source code follows the LAMMPS formatting guidelines

View File

@ -9,34 +9,34 @@ assignees: ''
**Summary** **Summary**
_Briefly describe the new feature(s) included in this pull request._ <!--Briefly describe the new feature(s) included in this pull request.-->
**Related Issues** **Related Issues**
_If this addresses an existing (open) GitHub issue, e.g. a feature request, mention the issue number here following a pound sign (aka hashmark), e.g. `#331`._ <!--If this addresses an existing (open) GitHub issue, e.g. a feature request, mention the issue number here following a pound sign (aka hashmark), e.g. `#331`.-->
**Author(s)** **Author(s)**
_Please state name and affiliation of the author or authors that should be credited with the features added in this pull request. Please provide a suitable "long-lived" e-mail address (e.g. from gmail, yahoo, outlook, etc.) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this code. now and in the future_ <!--Please state name and affiliation of the author or authors that should be credited with the features added in this pull request. Please provide a suitable "long-lived" e-mail address (e.g. from gmail, yahoo, outlook, etc.) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this code. now and in the future-->
**Licensing** **Licensing**
_Please add *yes* or *no* to the following two statements (please contact @lammps/core if you have questions about this)_ <!--Please add *yes* or *no* to the following two statements (please contact @lammps/core if you have questions about this)-->
My contribution may be licensed as GPL v2 (default LAMMPS license): My contribution may be licensed as GPL v2 (default LAMMPS license):
My contribution may be licensed as LGPL (for use as a library with proprietary software): My contribution may be licensed as LGPL (for use as a library with proprietary software):
**Backward Compatibility** **Backward Compatibility**
_Please state if any of the changes in this pull request will affect backward compatibility for inputs, and - if yes - explain what has been changed and why_ <!--Please state if any of the changes in this pull request will affect backward compatibility for inputs, and - if yes - explain what has been changed and why-->
**Implementation Notes** **Implementation Notes**
_Provide any relevant details about how the new features are implemented, how correctness was verified, what platforms (OS, compiler, MPI, hardware, number of processors, accelerator(s)) it was tested on_ <!--Provide any relevant details about how the new features are implemented, how correctness was verified, what platforms (OS, compiler, MPI, hardware, number of processors, accelerator(s)) it was tested on-->
## Post Submission Checklist ## Post Submission Checklist
_Please check the fields below as they are completed *after* the pull request has been submitted_ <!--Please check the fields below as they are completed *after* the pull request has been submitted-->
- [ ] The feature or features in this pull request is complete - [ ] The feature or features in this pull request is complete
- [ ] Licensing information is complete - [ ] Licensing information is complete
@ -51,6 +51,6 @@ _Please check the fields below as they are completed *after* the pull request ha
## Further Information, Files, and Links ## Further Information, Files, and Links
_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)_ <!--Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)-->

View File

@ -9,11 +9,11 @@ assignees: ''
**Summary** **Summary**
_Briefly describe what kind of updates or enhancements for a package or feature are included. If you are not the original author of the package or feature, please mention, whether your contribution was created independently or in collaboration/cooperation with the original author._ <!--Briefly describe what kind of updates or enhancements for a package or feature are included. If you are not the original author of the package or feature, please mention, whether your contribution was created independently or in collaboration/cooperation with the original author.-->
**Author(s)** **Author(s)**
_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request_ <!--Please state name and affiliation of the author or authors that should be credited with the changes in this pull request-->
**Licensing** **Licensing**
@ -21,15 +21,15 @@ By submitting this pull request I implicitly accept, that my submission is subje
**Backward Compatibility** **Backward Compatibility**
_Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why_ <!--Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why-->
**Implementation Notes** **Implementation Notes**
_Provide any relevant details about how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected_ <!--Provide any relevant details about how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected-->
**Post Submission Checklist** **Post Submission Checklist**
_Please check the fields below as they are completed_ <!--Please check the fields below as they are completed-->
- [ ] The feature or features in this pull request is complete - [ ] The feature or features in this pull request is complete
- [ ] Suitable updates to the existing docs are included - [ ] Suitable updates to the existing docs are included
- [ ] One or more example input decks are included - [ ] One or more example input decks are included
@ -37,6 +37,6 @@ _Please check the fields below as they are completed_
**Further Information, Files, and Links** **Further Information, Files, and Links**
_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)_ <!--Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)-->

2
.gitignore vendored
View File

@ -9,6 +9,7 @@
*.d *.d
*.x *.x
*.exe *.exe
*.sif
*.dll *.dll
*.pyc *.pyc
__pycache__ __pycache__
@ -26,6 +27,7 @@ vgcore.*
.vagrant .vagrant
\#*# \#*#
.#* .#*
.vscode
.DS_Store .DS_Store
.DS_Store? .DS_Store?

View File

@ -2,7 +2,7 @@
# CMake build system # CMake build system
# This file is part of LAMMPS # This file is part of LAMMPS
# Created by Christoph Junghans and Richard Berger # Created by Christoph Junghans and Richard Berger
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.10)
project(lammps CXX) project(lammps CXX)
set(SOVERSION 0) set(SOVERSION 0)
@ -21,22 +21,16 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE ) set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE )
endif() endif()
# To avoid conflicts with the conventional Makefile build system, we build everything here
file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
file(GLOB LMP_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)
list(REMOVE_ITEM LIB_SOURCES ${LMP_SOURCES})
# Cmake modules/macros are in a subdirectory to keep this file cleaner # Cmake modules/macros are in a subdirectory to keep this file cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
include(LAMMPSUtils) include(LAMMPSUtils)
get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION) get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h PROJECT_VERSION)
include(PreventInSourceBuilds) include(PreventInSourceBuilds)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
#release comes with -O3 by default
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE)
@ -52,116 +46,85 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR})
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CheckIncludeFileCXX) include(CheckIncludeFileCXX)
# set required compiler flags and compiler/CPU arch specific optimizations
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict")
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4)
set(CMAKE_TUNE_DEFAULT "-xCOMMON-AVX512")
else()
set(CMAKE_TUNE_DEFAULT "-xHost")
endif()
endif() endif()
option(DISABLE_CXX11_REQUIREMENT "Disable check that requires C++11 for compiling LAMMPS" OFF) if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if(DISABLE_CXX11_REQUIREMENT) set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native")
add_definitions(-DLAMMPS_CXX98)
# else()
# set(CMAKE_CXX_STANDARD 11)
endif() endif()
# GNU compiler features if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native")
endif()
# we require C++11 without extensions
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# GNU compiler specific features for testing
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
option(ENABLE_COVERAGE "Enable code coverage" OFF) option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF)
mark_as_advanced(ENABLE_COVERAGE) mark_as_advanced(ENABLE_COVERAGE)
if(ENABLE_COVERAGE) if(ENABLE_COVERAGE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif() endif()
option(ENABLE_SANITIZE_ADDRESS "Enable address sanitizer" OFF)
mark_as_advanced(ENABLE_SANITIZE_ADDRESS)
if(ENABLE_SANITIZE_ADDRESS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
option(ENABLE_SANITIZE_UNDEFINED "Enable undefined behavior sanitizer" OFF)
mark_as_advanced(ENABLE_SANITIZE_UNDEFINED)
if(ENABLE_SANITIZE_UNDEFINED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
option(ENABLE_SANITIZE_THREAD "Enable thread sanitizer" OFF)
mark_as_advanced(ENABLE_SANITIZE_THREAD)
if(ENABLE_SANITIZE_THREAD)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif()
endif() endif()
######################################################################## ########################################################################
# User input options # # User input options #
######################################################################## ########################################################################
option(BUILD_EXE "Build lmp binary" ON) set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically")
if(BUILD_EXE) mark_as_advanced(LAMMPS_MACHINE)
set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically") if(LAMMPS_MACHINE)
mark_as_advanced(LAMMPS_MACHINE) set(LAMMPS_MACHINE "_${LAMMPS_MACHINE}")
if(LAMMPS_MACHINE)
set(LAMMPS_MACHINE "_${LAMMPS_MACHINE}")
endif()
set(LAMMPS_BINARY lmp${LAMMPS_MACHINE})
endif() endif()
set(LAMMPS_BINARY lmp${LAMMPS_MACHINE})
option(BUILD_LIB "Build LAMMPS library" OFF) option(BUILD_SHARED_LIBS "Build shared library" OFF)
if(BUILD_LIB) if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg
option(BUILD_SHARED_LIBS "Build shared library" OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
set(LAMMPS_LIB_SUFFIX "" CACHE STRING "Suffix to append to liblammps and pkg-config file")
mark_as_advanced(LAMMPS_LIB_SUFFIX)
if(LAMMPS_LIB_SUFFIX)
set(LAMMPS_LIB_SUFFIX "_${LAMMPS_LIB_SUFFIX}")
endif()
endif() endif()
option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF)
if(NOT BUILD_EXE AND NOT BUILD_LIB) include(GNUInstallDirs)
message(FATAL_ERROR "You need to at least enable one of two following options: BUILD_LIB or BUILD_EXE") file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
endif() file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)
list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES})
add_library(lammps ${ALL_SOURCES})
add_executable(lmp ${MAIN_SOURCES})
target_link_libraries(lmp PRIVATE lammps)
set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY})
install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR})
option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF)
include(GNUInstallDirs)
set(LAMMPS_LINK_LIBS) set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE
set(LAMMPS_DEPS)
set(LAMMPS_API_DEFINES)
set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE
GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MOLECULE PERI POEMS QEQ GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MOLECULE PERI POEMS QEQ
REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI
USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK USER-COLVARS
USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB
USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REACTION
USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS)
set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU) set(SUFFIX_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU)
foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
option(PKG_${PKG} "Build ${PKG} Package" OFF) option(PKG_${PKG} "Build ${PKG} Package" OFF)
endforeach() endforeach()
######################################################
# download and unpack support binaries for compilation
# of windows binaries.
######################################################
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(LAMMPS_THIRDPARTY_URL "http://download.lammps.org/thirdparty")
file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz"
EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
set(OpenCL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(OpenCL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll")
endif()
set(OpenCL_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include")
endif()
######################################################
###################################################### ######################################################
# packages with special compiler needs or external libs # packages with special compiler needs or external libs
###################################################### ######################################################
include_directories(${LAMMPS_SOURCE_DIR}) target_include_directories(lammps PUBLIC $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}>)
if(PKG_USER-ADIOS) if(PKG_USER-ADIOS)
# The search for ADIOS2 must come before MPI because # The search for ADIOS2 must come before MPI because
@ -169,27 +132,47 @@ if(PKG_USER-ADIOS)
# script that defines the MPI::MPI_C target # script that defines the MPI::MPI_C target
enable_language(C) enable_language(C)
find_package(ADIOS2 REQUIRED) find_package(ADIOS2 REQUIRED)
list(APPEND LAMMPS_LINK_LIBS adios2::adios2) target_link_libraries(lammps PRIVATE adios2::adios2)
endif()
if(NOT CMAKE_CROSSCOMPILING)
set(MPI_CXX_SKIP_MPICXX TRUE)
find_package(MPI QUIET)
option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
else()
option(BUILD_MPI "Build MPI version" OFF)
endif() endif()
# do MPI detection after language activation, if MPI for these language is required
set(MPI_CXX_SKIP_MPICXX TRUE)
find_package(MPI QUIET)
option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
if(BUILD_MPI) if(BUILD_MPI)
find_package(MPI REQUIRED) # We use a non-standard procedure to cross-compile with MPI on Windows
include_directories(${MPI_CXX_INCLUDE_PATH}) if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)
list(APPEND LAMMPS_LINK_LIBS ${MPI_CXX_LIBRARIES}) include(MPI4WIN)
option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF) target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
if(LAMMPS_LONGLONG_TO_LONG) else()
add_definitions(-DLAMMPS_LONGLONG_TO_LONG) find_package(MPI REQUIRED)
target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF)
if(LAMMPS_LONGLONG_TO_LONG)
target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG)
endif()
endif() endif()
else() else()
enable_language(C) enable_language(C)
file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c)
add_library(mpi_stubs STATIC ${MPI_SOURCES}) add_library(mpi_stubs STATIC ${MPI_SOURCES})
include_directories(${LAMMPS_SOURCE_DIR}/STUBS) if(NOT BUILD_SHARED_LIBS)
list(APPEND LAMMPS_LINK_LIBS mpi_stubs) install(TARGETS mpi_stubs EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE})
target_include_directories(mpi_stubs PUBLIC $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}/STUBS> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi>)
install(FILES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi)
if(BUILD_SHARED_LIBS)
target_link_libraries(lammps PRIVATE mpi_stubs)
target_include_directories(lammps INTERFACE $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}/STUBS> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi>)
else()
target_link_libraries(lammps PUBLIC mpi_stubs)
endif()
add_library(MPI::MPI_CXX ALIAS mpi_stubs)
endif() endif()
set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)") set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)")
@ -197,8 +180,7 @@ set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall)
set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES}) set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES})
validate_option(LAMMPS_SIZES LAMMPS_SIZES_VALUES) validate_option(LAMMPS_SIZES LAMMPS_SIZES_VALUES)
string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES) string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES)
add_definitions(-DLAMMPS_${LAMMPS_SIZES}) target_compile_definitions(lammps PUBLIC -DLAMMPS_${LAMMPS_SIZES})
set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_${LAMMPS_SIZES}")
# posix_memalign is not available on Windows # posix_memalign is not available on Windows
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
@ -207,13 +189,12 @@ else()
set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable") set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable")
endif() endif()
if(NOT ${LAMMPS_MEMALIGN} STREQUAL "0") if(NOT ${LAMMPS_MEMALIGN} STREQUAL "0")
add_definitions(-DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN}) target_compile_definitions(lammps PRIVATE -DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN})
endif() endif()
option(LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" OFF) option(LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" OFF)
if(LAMMPS_EXCEPTIONS) if(LAMMPS_EXCEPTIONS)
add_definitions(-DLAMMPS_EXCEPTIONS) target_compile_definitions(lammps PUBLIC -DLAMMPS_EXCEPTIONS)
set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_EXCEPTIONS")
endif() endif()
# "hard" dependencies between packages resulting # "hard" dependencies between packages resulting
@ -224,27 +205,36 @@ pkg_depends(USER-LB MPI)
pkg_depends(USER-PHONON KSPACE) pkg_depends(USER-PHONON KSPACE)
pkg_depends(USER-SCAFACOS MPI) pkg_depends(USER-SCAFACOS MPI)
# detect if we may enable OpenMP support by default
set(BUILD_OMP_DEFAULT OFF)
find_package(OpenMP QUIET) find_package(OpenMP QUIET)
if(OpenMP_FOUND)
# TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30 check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE)
# GNU GCC 9.x uses settings incompatible with our use of 'default(none)' in OpenMP pragmas if(HAVE_OMP_H_INCLUDE)
# where we assume older GCC semantics. For the time being, we disable OpenMP by default set(BUILD_OMP_DEFAULT ON)
# for GCC 9.x and beyond. People may manually turn it on, but need to run the script endif()
# src/USER-OMP/hack_openmp_for_pgi_gcc9.sh on all sources to make it compatible with gcc 9.
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9))
option(BUILD_OMP "Build with OpenMP support" OFF)
else()
option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND})
endif() endif()
option(BUILD_OMP "Build with OpenMP support" ${BUILD_OMP_DEFAULT})
if(BUILD_OMP) if(BUILD_OMP)
find_package(OpenMP REQUIRED) find_package(OpenMP REQUIRED)
check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE) check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE)
if(NOT HAVE_OMP_H_INCLUDE) if(NOT HAVE_OMP_H_INCLUDE)
message(FATAL_ERROR "Cannot find required 'omp.h' header file") message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support")
endif() endif()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9)) OR
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.99.9)) OR
((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18.99.9))
)
# GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts.
# Intel 18.0 was tested to support both, so we switch to OpenMP 4+ from 19.x onward to be safe.
target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=4)
else()
target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=3)
endif()
target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX)
endif() endif()
if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
@ -252,14 +242,19 @@ if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
find_package(LAPACK) find_package(LAPACK)
find_package(BLAS) find_package(BLAS)
if(NOT LAPACK_FOUND OR NOT BLAS_FOUND) if(NOT LAPACK_FOUND OR NOT BLAS_FOUND)
if(CMAKE_GENERATOR STREQUAL "Ninja") include(CheckGeneratorSupport)
status(FATAL_ERROR "Cannot build internal linear algebra library with Ninja build tool due to lack for Fortran support") if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN)
status(FATAL_ERROR "Cannot build internal linear algebra library as CMake build tool lacks Fortran support")
endif() endif()
enable_language(Fortran) enable_language(Fortran)
file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF]) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF])
add_library(linalg STATIC ${LAPACK_SOURCES}) add_library(linalg STATIC ${LAPACK_SOURCES})
set(BLAS_LIBRARIES linalg) if(NOT BUILD_SHARED_LIBS)
set(LAPACK_LIBRARIES linalg) install(TARGETS linalg EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE})
set(BLAS_LIBRARIES "$<TARGET_FILE:linalg>")
set(LAPACK_LIBRARIES "$<TARGET_FILE:linalg>")
else() else()
list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES}) list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif() endif()
@ -270,9 +265,13 @@ find_package(JPEG QUIET)
option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND})
if(WITH_JPEG) if(WITH_JPEG)
find_package(JPEG REQUIRED) find_package(JPEG REQUIRED)
add_definitions(-DLAMMPS_JPEG) target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG)
include_directories(${JPEG_INCLUDE_DIR}) if(CMAKE_VERSION VERSION_LESS 3.12)
list(APPEND LAMMPS_LINK_LIBS ${JPEG_LIBRARIES}) target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIR})
target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES})
else()
target_link_libraries(lammps PRIVATE JPEG::JPEG)
endif()
endif() endif()
find_package(PNG QUIET) find_package(PNG QUIET)
@ -285,9 +284,8 @@ endif()
if(WITH_PNG) if(WITH_PNG)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
include_directories(${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE PNG::PNG ZLIB::ZLIB)
list(APPEND LAMMPS_LINK_LIBS ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) target_compile_definitions(lammps PRIVATE -DLAMMPS_PNG)
add_definitions(-DLAMMPS_PNG)
endif() endif()
find_program(GZIP_EXECUTABLE gzip) find_program(GZIP_EXECUTABLE gzip)
@ -297,7 +295,7 @@ if(WITH_GZIP)
if(NOT GZIP_FOUND) if(NOT GZIP_FOUND)
message(FATAL_ERROR "gzip executable not found") message(FATAL_ERROR "gzip executable not found")
endif() endif()
add_definitions(-DLAMMPS_GZIP) target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP)
endif() endif()
find_program(FFMPEG_EXECUTABLE ffmpeg) find_program(FFMPEG_EXECUTABLE ffmpeg)
@ -307,7 +305,7 @@ if(WITH_FFMPEG)
if(NOT FFMPEG_FOUND) if(NOT FFMPEG_FOUND)
message(FATAL_ERROR "ffmpeg executable not found") message(FATAL_ERROR "ffmpeg executable not found")
endif() endif()
add_definitions(-DLAMMPS_FFMPEG) target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG)
endif() endif()
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
@ -320,29 +318,25 @@ else()
set(CUDA_REQUEST_PIC) set(CUDA_REQUEST_PIC)
endif() endif()
include(Packages/KSPACE) foreach(PKG_WITH_INCL KSPACE PYTHON VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM
include(Packages/PYTHON) USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS)
include(Packages/VORONOI) if(PKG_${PKG_WITH_INCL})
include(Packages/USER-COLVARS) include(Packages/${PKG_WITH_INCL})
include(Packages/USER-MOLFILE) endif()
include(Packages/USER-NETCDF) endforeach()
include(Packages/USER-PLUMED)
include(Packages/USER-QMMM)
include(Packages/USER-QUIP)
include(Packages/USER-SCAFACOS)
include(Packages/USER-SMD)
include(Packages/USER-VTK)
include(Packages/KIM)
include(Packages/LATTE)
include(Packages/MESSAGE)
include(Packages/MSCG)
include(Packages/COMPRESS)
# the windows version of LAMMPS requires a couple extra libraries
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
list(APPEND LAMMPS_LINK_LIBS -lwsock32 -lpsapi)
endif()
set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation")
separate_arguments(CMAKE_TUNE_FLAGS)
include(CheckCXXCompilerFlag)
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
string(REGEX REPLACE "[=\"]" "" _FLAGX ${_FLAG})
check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAGX})
if(COMPILER_SUPPORTS${_FLAGX})
target_compile_options(lammps PRIVATE ${_FLAG})
else()
message(WARNING "${_FLAG} found in CMAKE_TUNE_FLAGS, but not supported by the compiler, skipping")
endif()
endforeach()
######################################################################## ########################################################################
# Basic system tests (standard libraries, headers, functions, types) # # Basic system tests (standard libraries, headers, functions, types) #
######################################################################## ########################################################################
@ -355,18 +349,7 @@ endforeach(HEADER)
set(MATH_LIBRARIES "m" CACHE STRING "math library") set(MATH_LIBRARIES "m" CACHE STRING "math library")
mark_as_advanced( MATH_LIBRARIES ) mark_as_advanced( MATH_LIBRARIES )
include(CheckLibraryExists) target_link_libraries(lammps PRIVATE ${MATH_LIBRARIES})
if (CMAKE_VERSION VERSION_LESS "3.4")
enable_language(C) # check_library_exists isn't supported without a C compiler before v3.4
endif()
# RB: disabled this check because it breaks with KOKKOS CUDA enabled
#foreach(FUNC sin cos)
# check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES})
# if(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
# message(FATAL_ERROR "Could not find needed math function - ${FUNC}")
# endif(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
#endforeach(FUNC)
list(APPEND LAMMPS_LINK_LIBS ${MATH_LIBRARIES})
###################################### ######################################
# Generate Basic Style files # Generate Basic Style files
@ -377,7 +360,7 @@ RegisterStyles(${LAMMPS_SOURCE_DIR})
############################################## ##############################################
# add sources of enabled packages # add sources of enabled packages
############################################ ############################################
foreach(PKG ${DEFAULT_PACKAGES}) foreach(PKG ${STANDARD_PACKAGES})
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp) file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp)
@ -390,8 +373,8 @@ foreach(PKG ${DEFAULT_PACKAGES})
# detects styles in package and adds them to global list # detects styles in package and adds them to global list
RegisterStyles(${${PKG}_SOURCES_DIR}) RegisterStyles(${${PKG}_SOURCES_DIR})
list(APPEND LIB_SOURCES ${${PKG}_SOURCES}) target_sources(lammps PRIVATE ${${PKG}_SOURCES})
include_directories(${${PKG}_SOURCES_DIR}) target_include_directories(lammps PRIVATE ${${PKG}_SOURCES_DIR})
endif() endif()
RegisterPackages(${${PKG}_SOURCES_DIR}) RegisterPackages(${${PKG}_SOURCES_DIR})
@ -400,12 +383,12 @@ endforeach()
# packages that need defines set # packages that need defines set
foreach(PKG MPIIO) foreach(PKG MPIIO)
if(PKG_${PKG}) if(PKG_${PKG})
add_definitions(-DLMP_${PKG}) target_compile_definitions(lammps PRIVATE -DLMP_${PKG})
endif() endif()
endforeach() endforeach()
# dedicated check for entire contents of accelerator packages # dedicated check for entire contents of accelerator packages
foreach(PKG ${ACCEL_PACKAGES}) foreach(PKG ${SUFFIX_PACKAGES})
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp) file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp)
@ -420,16 +403,19 @@ endforeach()
############################################## ##############################################
# add lib sources of (simple) enabled packages # add lib sources of (simple) enabled packages
############################################ ############################################
foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-QMMM) foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD)
if(PKG_${SIMPLE_LIB}) if(PKG_${SIMPLE_LIB})
string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}") string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}")
string(TOLOWER "${PKG_LIB}" PKG_LIB) string(TOLOWER "${PKG_LIB}" PKG_LIB)
file(GLOB_RECURSE ${PKG_LIB}_SOURCES file(GLOB_RECURSE ${PKG_LIB}_SOURCES
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.F
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp) ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp)
add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES})
list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${PKG_LIB} EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE})
target_link_libraries(lammps PRIVATE ${PKG_LIB})
if(PKG_LIB STREQUAL awpmd) if(PKG_LIB STREQUAL awpmd)
target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include)
elseif(PKG_LIB STREQUAL h5md) elseif(PKG_LIB STREQUAL h5md)
@ -441,30 +427,40 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-QMMM)
endforeach() endforeach()
if(PKG_USER-AWPMD) if(PKG_USER-AWPMD)
target_link_libraries(awpmd ${LAPACK_LIBRARIES}) target_link_libraries(awpmd PRIVATE ${LAPACK_LIBRARIES})
endif() endif()
if(PKG_USER-ATC) if(PKG_USER-ATC)
if(LAMMPS_SIZES STREQUAL BIGBIG) if(LAMMPS_SIZES STREQUAL BIGBIG)
message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG") message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG")
endif() endif()
target_link_libraries(atc ${LAPACK_LIBRARIES}) target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES} MPI::MPI_CXX)
target_include_directories(atc PRIVATE ${LAMMPS_SOURCE_DIR})
target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES})
endif() endif()
include(Packages/USER-H5MD) if(PKG_USER-H5MD)
include(Packages/USER-H5MD)
endif()
###################################################################### ######################################################################
# packages which selectively include variants based on enabled styles # packages which selectively include variants based on enabled styles
# e.g. accelerator packages # e.g. accelerator packages
###################################################################### ######################################################################
include(Packages/CORESHELL) foreach(PKG_WITH_INCL CORESHELL QEQ USER-OMP USER-SDPD KOKKOS OPT USER-INTEL GPU)
include(Packages/QEQ) if(PKG_${PKG_WITH_INCL})
include(Packages/USER-OMP) include(Packages/${PKG_WITH_INCL})
include(Packages/USER-SDPD) endif()
include(Packages/KOKKOS) endforeach()
include(Packages/OPT)
include(Packages/USER-INTEL) ######################################################################
include(Packages/GPU) # the windows version of LAMMPS requires a couple extra libraries
# and the MPI library - if use - has to be linked right before those
# and after everything else that is compiled locally
######################################################################
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(lammps PRIVATE -lwsock32 -lpsapi)
endif()
###################################################### ######################################################
# Generate style headers based on global list of # Generate style headers based on global list of
@ -476,14 +472,14 @@ set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles)
GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR}) GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR})
GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR}) GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR})
include_directories(${LAMMPS_STYLE_HEADERS_DIR}) target_include_directories(lammps PRIVATE ${LAMMPS_STYLE_HEADERS_DIR})
###################################### ######################################
# Generate lmpinstalledpkgs.h # Generate lmpinstalledpkgs.h
###################################### ######################################
set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n") set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n")
set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n") set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n")
set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) set(temp_PKG_LIST ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
list(SORT temp_PKG_LIST) list(SORT temp_PKG_LIST)
foreach(PKG ${temp_PKG_LIST}) foreach(PKG ${temp_PKG_LIST})
if(PKG_${PKG}) if(PKG_${PKG})
@ -505,7 +501,7 @@ add_custom_target(gitversion COMMAND ${CMAKE_COMMAND}
-DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}" -DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake) -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h)
list(APPEND LAMMPS_DEPS gitversion) add_dependencies(lammps gitversion)
########################################### ###########################################
# Actually add executable and lib to build # Actually add executable and lib to build
@ -513,94 +509,64 @@ list(APPEND LAMMPS_DEPS gitversion)
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
list (FIND LANGUAGES "Fortran" _index) list (FIND LANGUAGES "Fortran" _index)
if (${_index} GREATER -1) if (${_index} GREATER -1)
list(APPEND LAMMPS_LINK_LIBS ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
endif() endif()
list(REMOVE_DUPLICATES LAMMPS_LINK_LIBS) set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h
if(BUILD_LIB) input.h info.h kspace.h lammps.h lattice.h library.h lmppython.h lmptype.h memory.h modify.h neighbor.h neigh_list.h output.h
add_library(lammps ${LIB_SOURCES}) pair.h pointers.h region.h timer.h universe.h update.h variable.h)
target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) if(LAMMPS_EXCEPTIONS)
if(LAMMPS_DEPS) list(APPEND LAMMPS_CXX_HEADERS exceptions.h)
add_dependencies(lammps ${LAMMPS_DEPS})
endif()
set(LAMMPS_CXX_HEADERS
${LAMMPS_SOURCE_DIR}/angle.h
${LAMMPS_SOURCE_DIR}/atom.h
${LAMMPS_SOURCE_DIR}/bond.h
${LAMMPS_SOURCE_DIR}/citeme.h
${LAMMPS_SOURCE_DIR}/comm.h
${LAMMPS_SOURCE_DIR}/compute.h
${LAMMPS_SOURCE_DIR}/dihedral.h
${LAMMPS_SOURCE_DIR}/domain.h
${LAMMPS_SOURCE_DIR}/error.h
${LAMMPS_SOURCE_DIR}/fix.h
${LAMMPS_SOURCE_DIR}/force.h
${LAMMPS_SOURCE_DIR}/group.h
${LAMMPS_SOURCE_DIR}/improper.h
${LAMMPS_SOURCE_DIR}/input.h
${LAMMPS_SOURCE_DIR}/kspace.h
${LAMMPS_SOURCE_DIR}/lammps.h
${LAMMPS_SOURCE_DIR}/lattice.h
${LAMMPS_SOURCE_DIR}/lmppython.h
${LAMMPS_SOURCE_DIR}/memory.h
${LAMMPS_SOURCE_DIR}/modify.h
${LAMMPS_SOURCE_DIR}/neighbor.h
${LAMMPS_SOURCE_DIR}/neigh_list.h
${LAMMPS_SOURCE_DIR}/output.h
${LAMMPS_SOURCE_DIR}/pair.h
${LAMMPS_SOURCE_DIR}/pointers.h
${LAMMPS_SOURCE_DIR}/region.h
${LAMMPS_SOURCE_DIR}/timer.h
${LAMMPS_SOURCE_DIR}/universe.h
${LAMMPS_SOURCE_DIR}/update.h
${LAMMPS_SOURCE_DIR}/variable.h)
set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_LIB_SUFFIX})
set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
install(FILES ${LAMMPS_CXX_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
configure_file(FindLAMMPS.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Modules)
else()
list(APPEND LMP_SOURCES ${LIB_SOURCES})
endif() endif()
if(BUILD_EXE) set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_MACHINE})
add_executable(lmp ${LMP_SOURCES}) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
if(BUILD_LIB) install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(lmp lammps) target_include_directories(lammps PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
else() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps)
target_link_libraries(lmp ${LAMMPS_LINK_LIBS}) foreach(_HEADER ${LAMMPS_CXX_HEADERS})
if(LAMMPS_DEPS) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/${_HEADER})
add_dependencies(lmp ${LAMMPS_DEPS}) add_custom_target(${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER})
endif() add_dependencies(lammps ${_HEADER})
endif() install(FILES ${LAMMPS_SOURCE_DIR}/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
endforeach()
set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY}) target_include_directories(lammps INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>)
install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) add_library(LAMMPS::lammps ALIAS lammps)
install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1) get_target_property(LAMMPS_DEFINES lammps INTERFACE_COMPILE_DEFINITIONS)
endif() set(LAMMPS_API_DEFINES)
foreach(_DEF ${LAMMPS_DEFINES})
set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -D${_DEF}")
endforeach()
configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
file(GLOB MODULE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Find*.cmake)
install(FILES ${MODULE_FILES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
include(CMakePackageConfigHelpers)
configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY)
write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1)
if(BUILD_TOOLS) if(BUILD_TOOLS)
add_executable(binary2txt ${LAMMPS_TOOLS_DIR}/binary2txt.cpp) add_executable(binary2txt ${LAMMPS_TOOLS_DIR}/binary2txt.cpp)
target_compile_definitions(binary2txt PRIVATE -DLAMMPS_${LAMMPS_SIZES})
install(TARGETS binary2txt DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS binary2txt DESTINATION ${CMAKE_INSTALL_BINDIR})
# ninja-build currently does not support fortran. thus we skip building this tool include(CheckGeneratorSupport)
if(NOT CMAKE_GENERATOR STREQUAL "Ninja") if(CMAKE_GENERATOR_SUPPORT_FORTRAN)
message(STATUS "Skipping building 'chain.x' with Ninja build tool due to lack of Fortran support")
enable_language(Fortran) enable_language(Fortran)
add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f) add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f)
target_link_libraries(chain.x ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) target_link_libraries(chain.x PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
install(TARGETS chain.x DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS chain.x DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
message(WARNING "CMake build doesn't support fortran, skipping building 'chain.x'")
endif() endif()
enable_language(C) enable_language(C)
get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE) get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE)
file(GLOB MSI2LMP_SOURCES ${MSI2LMP_SOURCE_DIR}/[^.]*.c) file(GLOB MSI2LMP_SOURCES ${MSI2LMP_SOURCE_DIR}/[^.]*.c)
add_executable(msi2lmp ${MSI2LMP_SOURCES}) add_executable(msi2lmp ${MSI2LMP_SOURCES})
target_link_libraries(msi2lmp m) target_link_libraries(msi2lmp PRIVATE ${MATH_LIBRARIES})
install(TARGETS msi2lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS msi2lmp DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif() endif()
@ -630,12 +596,19 @@ install(
# conventional build. Only available, if a shared library is built. # conventional build. Only available, if a shared library is built.
# This is primarily for people that only want to use the Python wrapper. # This is primarily for people that only want to use the Python wrapper.
############################################################################### ###############################################################################
if(BUILD_LIB AND BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
find_package(PythonInterp) if(CMAKE_VERSION VERSION_LESS 3.12)
if (PYTHONINTERP_FOUND) find_package(PythonInterp) # Deprecated since version 3.12
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
else()
find_package(Python COMPONENTS Interpreter)
endif()
if (Python_EXECUTABLE)
add_custom_target( add_custom_target(
install-python install-python
${PYTHON_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h
-m ${LAMMPS_PYTHON_DIR}/lammps.py -m ${LAMMPS_PYTHON_DIR}/lammps.py
-l ${CMAKE_BINARY_DIR}/liblammps${CMAKE_SHARED_LIBRARY_SUFFIX} -l ${CMAKE_BINARY_DIR}/liblammps${CMAKE_SHARED_LIBRARY_SUFFIX}
WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR} WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR}
@ -656,10 +629,17 @@ endif()
# LAMMPS for package managers and with different prefix settings. # LAMMPS for package managers and with different prefix settings.
# This requires either a shared library or that the PYTHON package is included. # This requires either a shared library or that the PYTHON package is included.
############################################################################### ###############################################################################
if((BUILD_LIB AND BUILD_SHARED_LIBS) OR (PKG_PYTHON)) if(BUILD_SHARED_LIBS OR PKG_PYTHON)
find_package(PythonInterp) if(CMAKE_VERSION VERSION_LESS 3.12)
if (PYTHONINTERP_FOUND) find_package(PythonInterp) # Deprecated since version 3.12
execute_process(COMMAND ${PYTHON_EXECUTABLE} if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
else()
find_package(Python COMPONENTS Interpreter)
endif()
if (Python_EXECUTABLE)
execute_process(COMMAND ${Python_EXECUTABLE}
-c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" -c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PYTHON_INSTDIR ${PYTHON_DEFAULT_INSTDIR} CACHE PATH "Installation folder for LAMMPS Python module") set(PYTHON_INSTDIR ${PYTHON_DEFAULT_INSTDIR} CACHE PATH "Installation folder for LAMMPS Python module")
@ -673,69 +653,103 @@ include(CodeCoverage)
############################################################################### ###############################################################################
# Print package summary # Print package summary
############################################################################### ###############################################################################
foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
if(PKG_${PKG}) if(PKG_${PKG})
message(STATUS "Building package: ${PKG}") message(STATUS "Building package: ${PKG}")
endif() endif()
endforeach() endforeach()
get_directory_property(CPPFLAGS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) get_target_property(DEFINES lammps COMPILE_DEFINITIONS)
include(FeatureSummary) include(FeatureSummary)
feature_summary(DESCRIPTION "The following packages have been found:" WHAT PACKAGES_FOUND) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND)
message(STATUS "<<< Build configuration >>> message(STATUS "<<< Build configuration >>>
Build type ${CMAKE_BUILD_TYPE} Build type: ${CMAKE_BUILD_TYPE}
Install path ${CMAKE_INSTALL_PREFIX} Install path: ${CMAKE_INSTALL_PREFIX}
Compilers and Flags: Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}
C++ Compiler ${CMAKE_CXX_COMPILER} -- <<< Compilers and Flags: >>>
Type ${CMAKE_CXX_COMPILER_ID} -- C++ Compiler: ${CMAKE_CXX_COMPILER}
Version ${CMAKE_CXX_COMPILER_VERSION} Type: ${CMAKE_CXX_COMPILER_ID}
C++ Flags ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}} Version: ${CMAKE_CXX_COMPILER_VERSION}
Defines ${CPPFLAGS}") C++ Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}
Defines: ${DEFINES}")
get_target_property(OPTIONS lammps COMPILE_OPTIONS)
if(OPTIONS)
message(" Options: ${OPTIONS}")
endif()
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
list (FIND LANGUAGES "Fortran" _index) list (FIND LANGUAGES "Fortran" _index)
if (${_index} GREATER -1) if (${_index} GREATER -1)
message(STATUS "Fortran Compiler ${CMAKE_Fortran_COMPILER} message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}
Type ${CMAKE_Fortran_COMPILER_ID} Type: ${CMAKE_Fortran_COMPILER_ID}
Version ${CMAKE_Fortran_COMPILER_VERSION} Version: ${CMAKE_Fortran_COMPILER_VERSION}
Fortran Flags ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}")
endif() endif()
list (FIND LANGUAGES "C" _index) list (FIND LANGUAGES "C" _index)
if (${_index} GREATER -1) if (${_index} GREATER -1)
message(STATUS "C Compiler ${CMAKE_C_COMPILER} message(STATUS "C compiler: ${CMAKE_C_COMPILER}
Type ${CMAKE_C_COMPILER_ID} Type: ${CMAKE_C_COMPILER_ID}
Version ${CMAKE_C_COMPILER_VERSION} Version: ${CMAKE_C_COMPILER_VERSION}
C Flags ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}") C Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}")
endif() endif()
message(STATUS "<<< Linker flags: >>>")
message(STATUS "Executable name: ${LAMMPS_BINARY}")
if(CMAKE_EXE_LINKER_FLAGS) if(CMAKE_EXE_LINKER_FLAGS)
message(STATUS "Linker flags: message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
Executable ${CMAKE_EXE_LINKER_FLAGS}")
endif() endif()
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
message(STATUS "Shared libraries ${CMAKE_SHARED_LINKER_FLAGS}") message(STATUS "Shared library flags: ${CMAKE_SHARED_LINKER_FLAGS}")
else() else()
message(STATUS "Static libraries ${CMAKE_STATIC_LINKER_FLAGS}") message(STATUS "Static library flags: ${CMAKE_STATIC_LINKER_FLAGS}")
endif() endif()
message(STATUS "Link libraries: ${LAMMPS_LINK_LIBS}")
if(BUILD_MPI) if(BUILD_MPI)
message(STATUS "Using mpi with headers in ${MPI_CXX_INCLUDE_PATH} and ${MPI_CXX_LIBRARIES}") message(STATUS "<<< MPI flags >>>
-- MPI_defines: ${MPI_CXX_COMPILE_DEFINITIONS}
-- MPI includes: ${MPI_CXX_INCLUDE_PATH}
-- MPI libraries: ${MPI_CXX_LIBRARIES};${MPI_Fortran_LIBRARIES}")
endif() endif()
if(PKG_GPU) if(PKG_GPU)
message(STATUS "GPU Api: ${GPU_API}") message(STATUS "<<< GPU package settings >>>
-- GPU API: ${GPU_API}")
if(GPU_API STREQUAL "CUDA") if(GPU_API STREQUAL "CUDA")
message(STATUS "GPU Arch: ${GPU_ARCH}") message(STATUS "GPU architecture: ${GPU_ARCH}")
elseif(GPU_API STREQUAL "OPENCL") elseif(GPU_API STREQUAL "OPENCL")
message(STATUS "OCL Tune: ${OCL_TUNE}") message(STATUS "OpenCL tuning: ${OCL_TUNE}")
elseif(GPU_API STREQUAL "HIP")
message(STATUS "HIP platform: ${HIP_PLATFORM}")
message(STATUS "HIP architecture: ${HIP_ARCH}")
if(HIP_USE_DEVICE_SORT)
message(STATUS "HIP GPU sorting: on")
else()
message(STATUS "HIP GPU sorting: off")
endif()
endif() endif()
message(STATUS "GPU Precision: ${GPU_PREC}") message(STATUS "GPU precision: ${GPU_PREC}")
endif() endif()
if(PKG_KOKKOS) if(PKG_KOKKOS)
message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}") message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}")
endif() endif()
if(PKG_KSPACE) if(PKG_KSPACE)
message(STATUS "Using ${FFT} as primary FFT library") message(STATUS "<<< FFT settings >>>
-- Primary FFT lib: ${FFT}")
if(FFT_SINGLE) if(FFT_SINGLE)
message(STATUS "Using single precision FFTs") message(STATUS "Using single precision FFTs")
else() else()
message(STATUS "Using double precision FFTs") message(STATUS "Using double precision FFTs")
endif() endif()
if(FFT_FFTW_THREADS OR FFT_MKL_THREADS)
message(STATUS "Using threaded FFTs")
else()
message(STATUS "Using non-threaded FFTs")
endif()
if(PKG_KOKKOS)
if(Kokkos_ENABLE_CUDA)
if (${FFT} STREQUAL "KISS")
message(STATUS "Kokkos FFT: KISS")
else()
message(STATUS "Kokkos FFT: cuFFT")
endif()
else()
message(STATUS "Kokkos FFT: ${FFT}")
endif()
endif()
endif() endif()

View File

@ -1,48 +0,0 @@
# - Find liblammps
# Find the native liblammps headers and libraries.
#
# The following variables will set:
# LAMMPS_INCLUDE_DIRS - where to find lammps/library.h, etc.
# LAMMPS_LIBRARIES - List of libraries when using lammps.
# LAMMPS_API_DEFINES - lammps library api defines
# LAMMPS_VERSION - lammps library version
# LAMMPS_FOUND - True if liblammps found.
#
# In addition a LAMMPS::LAMMPS imported target is getting created.
#
# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
# http://lammps.sandia.gov, Sandia National Laboratories
# Steve Plimpton, sjplimp@sandia.gov
#
# Copyright (2003) Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software. This software is distributed under
# the GNU General Public License.
#
# See the README file in the top-level LAMMPS directory.
#
find_package(PkgConfig)
pkg_check_modules(PC_LAMMPS liblammps@LAMMPS_LIB_SUFFIX@)
find_path(LAMMPS_INCLUDE_DIR lammps/library.h HINTS ${PC_LAMMPS_INCLUDE_DIRS} @CMAKE_INSTALL_FULL_INCLUDEDIR@)
set(LAMMPS_VERSION @LAMMPS_VERSION@)
set(LAMMPS_API_DEFINES @LAMMPS_API_DEFINES@)
find_library(LAMMPS_LIBRARY NAMES lammps@LAMMPS_LIB_SUFFIX@ HINTS ${PC_LAMMPS_LIBRARY_DIRS} @CMAKE_INSTALL_FULL_LIBDIR@)
set(LAMMPS_INCLUDE_DIRS "${LAMMPS_INCLUDE_DIR}")
set(LAMMPS_LIBRARIES "${LAMMPS_LIBRARY}")
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LAMMPS_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LAMMPS REQUIRED_VARS LAMMPS_LIBRARY LAMMPS_INCLUDE_DIR VERSION_VAR LAMMPS_VERSION)
mark_as_advanced(LAMMPS_INCLUDE_DIR LAMMPS_LIBRARY)
if(LAMMPS_FOUND AND NOT TARGET LAMMPS::LAMMPS)
add_library(LAMMPS::LAMMPS UNKNOWN IMPORTED)
set_target_properties(LAMMPS::LAMMPS PROPERTIES IMPORTED_LOCATION "${LAMMPS_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${LAMMPS_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS "${LAMMPS_API_DEFINES}")
endif()

View File

@ -0,0 +1,87 @@
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
include(CMakeFindDependencyMacro)
if(@BUILD_MPI@)
find_dependency(MPI REQUIRED CXX)
endif()
if(@PKG_KSPACE@)
if(@FFT@ STREQUAL "FFTW3")
find_dependency(@FFTW@ REQUIRED MODULE)
endif()
endif()
if(NOT @BUILD_SHARED_LIBS@)
if(@BUILD_OMP@)
find_dependency(OpenMP REQUIRED)
endif()
if(@WITH_JPEG@)
find_dependency(JPEG REQUIRED)
endif()
if(@WITH_PNG@)
find_dependency(PNG REQUIRED)
find_dependency(ZLIB REQUIRED)
endif()
if(@PKG_KIM@)
find_dependency(PkgConfig REQUIRED)
pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=@KIM-API_MIN_VERSION@)
if(@CURL_FOUND@)
find_dependency(CURL REQUIRED)
endif()
endif()
if(@PKG_USER-SMD@)
find_dependency(Eigen3 NO_MODULE REQUIRED)
endif()
if(@PKG_USER-SCAFACOS@)
find_dependency(PkgConfig REQUIRED)
find_ependency(GSL REQUIRED)
find_dependency(MPI REQUIRED C Fortran)
pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos)
endif()
if(@PKG_PYTHON@ AND NOT CMAKE_VERSION VERSION_LESS 3.12)
find_package(Python REQUIRED COMPONENTS Development)
endif()
if(@PKG_COMPRESS@)
find_dependency(ZLIB REQUIRED)
endif()
if(@PKG_KOKKOS@)
if(@EXTERNAL_KOKKOS@)
find_dependency(Kokkos 3 REQUIRED)
endif()
endif()
if(@PKG_VORONOI@)
find_dependency(VORO REQUIRED)
endif()
if(@PKG_USER-INTEL@)
if(@INTEL_LRT_MODE@ STREQUAL "THREADS")
find_dependency(Threads REQUIRED)
endif()
if(@TBB_MALLOC_FOUND@)
find_ependency(TBB_MALLOC REQUIRED)
endif()
endif()
if(@PKG_USER-ADIOS@)
find_ependency(ADIOS2 REQUIRED)
endif()
if(@PKG_LATTE@)
find_ependency(LATTE REQUIRED)
endif()
if(@PKG_MESSAGE@)
if(@MESSAGE_ZMQ@)
find_ependency(ZMQ REQUIRED)
endif()
endif()
if(@PKG_MSCG@)
find_ependency(GSL REQUIRED)
find_ependency(MSCG REQUIRED)
endif()
if(@USER-NETCDF@)
if(@NETCDF_FOUND@)
find_ependency(NetCDF REQUIRED)
endif()
if(@PNETCDF_FOUND@)
find_ependency(PNetCDF REQUIRED)
endif()
endif()
if(@PKG_QUIP@)
find_ependency(QUIP REQUIRED)
endif()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/LAMMPS_Targets.cmake")

View File

@ -0,0 +1,21 @@
# ninja-build<1.10 does not support fortran.
if(CMAKE_GENERATOR STREQUAL "Ninja")
set(CMAKE_GENERATOR_SUPPORT_FORTRAN FALSE)
execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" --version
OUTPUT_VARIABLE NINJA_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _Ninja_version_result
)
if(_Ninja_version_result)
message(WARNING "Unable to determine ninja version: ${_Ninja_version_result}, assuming fortran isn't supported")
elseif(NINJA_VERSION VERSION_LESS "1.10")
message(WARNING "Ninja build tool too old, to compile Fortran code, please install ninja-1.10 or newer")
else()
set(CMAKE_GENERATOR_SUPPORT_FORTRAN TRUE)
endif()
else()
set(CMAKE_GENERATOR_SUPPORT_FORTRAN TRUE)
if(NOT CMAKE_GENERATOR STREQUAL "Unix Makefiles")
message(WARNING "Assuming fortran is supported for ${CMAKE_GENERATOR}")
endif()
endif()

View File

@ -1,10 +1,8 @@
############################################################################### ###############################################################################
# Build documentation # Build documentation
############################################################################### ###############################################################################
option(BUILD_DOC "Build LAMMPS documentation" OFF) option(BUILD_DOC "Build LAMMPS HTML documentation" OFF)
if(BUILD_DOC) if(BUILD_DOC)
include(ProcessorCount)
ProcessorCount(NPROCS)
find_package(PythonInterp 3 REQUIRED) find_package(PythonInterp 3 REQUIRED)
set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv) set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv)
@ -26,15 +24,49 @@ if(BUILD_DOC)
COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters
) )
# download mathjax distribution and unpack to folder "mathjax"
file(DOWNLOAD "https://github.com/mathjax/MathJax/archive/3.0.5.tar.gz"
"${CMAKE_CURRENT_BINARY_DIR}/mathjax.tar.gz"
EXPECTED_MD5 5d9d3799cce77a1a95eee6be04eb68e7)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mathjax)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf mathjax.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(GLOB MATHJAX_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*)
execute_process(COMMAND ${CMAKE_COMMAND} -E rename ${MATHJAX_VERSION_DIR} ${CMAKE_CURRENT_BINARY_DIR}/mathjax)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/_static/mathjax)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/mathjax/es5 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/html/_static/mathjax/)
# note, this may run in parallel with other tasks, so we must not use multiple processes here
add_custom_command( add_custom_command(
OUTPUT html OUTPUT html
DEPENDS ${DOC_SOURCES} docenv requirements.txt DEPENDS ${DOC_SOURCES} docenv requirements.txt
COMMAND ${DOCENV_BINARY_DIR}/sphinx-build -j ${NPROCS} -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${LAMMPS_DOC_DIR}/src html COMMAND ${DOCENV_BINARY_DIR}/sphinx-build -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${LAMMPS_DOC_DIR}/src html
) )
# copy selected image files to html output tree
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/html/JPG)
set(HTML_EXTRA_IMAGES balance_nonuniform.jpg balance_rcb.jpg
balance_uniform.jpg bow_tutorial_01.png bow_tutorial_02.png
bow_tutorial_03.png bow_tutorial_04.png bow_tutorial_05.png
dump1.jpg dump2.jpg examples_mdpd.gif gran_funnel.png gran_mixer.png
hop1.jpg hop2.jpg saed_ewald_intersect.jpg saed_mesh.jpg
screenshot_atomeye.jpg screenshot_gl.jpg screenshot_pymol.jpg
screenshot_vmd.jpg sinusoid.jpg xrd_mesh.jpg)
set(HTML_IMAGE_TARGETS "")
foreach(_IMG ${HTML_EXTRA_IMAGES})
string(PREPEND _IMG JPG/)
list(APPEND HTML_IMAGE_TARGETS "html/${_IMG}")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/${_IMG}
DEPENDS ${LAMMPS_DOC_DIR}/src/${_IMG} html/JPG
COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_DOC_DIR}/src/${_IMG} ${CMAKE_BINARY_DIR}/html/${_IMG}
)
endforeach()
add_custom_target( add_custom_target(
doc ALL doc ALL
DEPENDS html DEPENDS html html/_static/mathjax/es5 ${HTML_IMAGE_TARGETS}
SOURCES ${LAMMPS_DOC_DIR}/utils/requirements.txt ${DOC_SOURCES} SOURCES ${LAMMPS_DOC_DIR}/utils/requirements.txt ${DOC_SOURCES}
) )

View File

@ -0,0 +1,16 @@
# - Find CUB
# Find the CUB header library
#
# CUB_INCLUDE_DIRS - where to find cub/cub.cuh
# CUB_FOUND - True if CUB found.
#
find_path(CUB_INCLUDE_DIR cub.cuh PATH_SUFFIXES cub)
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CUB_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CUB DEFAULT_MSG CUB_INCLUDE_DIR)
mark_as_advanced(CUB_INCLUDE_DIR)

View File

@ -1,20 +1,18 @@
# - Find fftw3 # - Find fftw3
# Find the native FFTW3 headers and libraries. # Find the native double precision FFTW3 headers and libraries.
# #
# FFTW3_INCLUDE_DIRS - where to find fftw3.h, etc. # FFTW3_INCLUDE_DIRS - where to find fftw3.h, etc.
# FFTW3_LIBRARIES - List of libraries when using fftw3. # FFTW3_LIBRARIES - List of libraries when using fftw3.
# FFTW3_FOUND - True if fftw3 found. # FFTW3_OMP_LIBRARIES - List of libraries when using fftw3.
# FFTW3_FOUND - True if fftw3 found.
# #
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(PC_FFTW3 fftw3) pkg_check_modules(PC_FFTW3 fftw3)
find_path(FFTW3_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3_INCLUDE_DIRS}) find_path(FFTW3_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3_INCLUDE_DIRS})
find_library(FFTW3_LIBRARY NAMES fftw3 HINTS ${PC_FFTW3_LIBRARY_DIRS}) find_library(FFTW3_LIBRARY NAMES fftw3 HINTS ${PC_FFTW3_LIBRARY_DIRS})
find_library(FFTW3_OMP_LIBRARY NAMES fftw3_omp HINTS ${PC_FFTW3_LIBRARY_DIRS})
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE
@ -22,4 +20,28 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARY FFTW3_INCLUDE_DIR) find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARY FFTW3_INCLUDE_DIR)
mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY ) # Copy the results to the output variables and target.
if(FFTW3_FOUND)
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY} )
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR} )
if(NOT TARGET FFTW3::FFTW3)
add_library(FFTW3::FFTW3 UNKNOWN IMPORTED)
set_target_properties(FFTW3::FFTW3 PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FFTW3_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}")
endif()
if(FFTW3_OMP_LIBRARY)
set(FFTW3_OMP_LIBRARIES ${FFTW3_OMP_LIBRARY})
if(NOT TARGET FFTW3::FFTW3_OMP)
add_library(FFTW3::FFTW3_OMP UNKNOWN IMPORTED)
set_target_properties(FFTW3::FFTW3_OMP PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FFTW3_OMP_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}")
endif()
endif()
endif()
mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY FFTW3_OMP_LIBRARY)

View File

@ -1,8 +1,8 @@
# - Find fftw3f # Find the native single precision FFTW3 headers and libraries.
# Find the native FFTW3F headers and libraries.
# #
# FFTW3F_INCLUDE_DIRS - where to find fftw3f.h, etc. # FFTW3F_INCLUDE_DIRS - where to find fftw3f.h, etc.
# FFTW3F_LIBRARIES - List of libraries when using fftw3f. # FFTW3F_LIBRARIES - List of libraries when using fftw3f.
# FFTW3F_OMP_LIBRARIES - List of libraries when using fftw3.
# FFTW3F_FOUND - True if fftw3f found. # FFTW3F_FOUND - True if fftw3f found.
# #
@ -10,11 +10,8 @@ find_package(PkgConfig)
pkg_check_modules(PC_FFTW3F fftw3f) pkg_check_modules(PC_FFTW3F fftw3f)
find_path(FFTW3F_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3F_INCLUDE_DIRS}) find_path(FFTW3F_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3F_INCLUDE_DIRS})
find_library(FFTW3F_LIBRARY NAMES fftw3f HINTS ${PC_FFTW3F_LIBRARY_DIRS}) find_library(FFTW3F_LIBRARY NAMES fftw3f HINTS ${PC_FFTW3F_LIBRARY_DIRS})
find_library(FFTW3F_OMP_LIBRARY NAMES fftw3f_omp HINTS ${PC_FFTW3F_LIBRARY_DIRS})
set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY})
set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE
@ -22,4 +19,28 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW3F DEFAULT_MSG FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR) find_package_handle_standard_args(FFTW3F DEFAULT_MSG FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR)
mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY ) # Copy the results to the output variables and target.
if(FFTW3F_FOUND)
set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY} )
set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR} )
if(NOT TARGET FFTW3F::FFTW3F)
add_library(FFTW3F::FFTW3F UNKNOWN IMPORTED)
set_target_properties(FFTW3F::FFTW3F PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FFTW3F_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}")
endif()
if(FFTW3F_OMP_LIBRARY)
set(FFTW3F_OMP_LIBRARIES ${FFTW3F_OMP_LIBRARY})
if(NOT TARGET FFTW3F::FFTW3F_OMP)
add_library(FFTW3F::FFTW3F_OMP UNKNOWN IMPORTED)
set_target_properties(FFTW3F::FFTW3F_OMP PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FFTW3F_OMP_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}")
endif()
endif()
endif()
mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY FFTW3F_OMP_LIBRARY)

View File

@ -1,85 +0,0 @@
#
# 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--2019, Regents of the University of Minnesota.
# All rights reserved.
#
# Contributors:
# Richard Berger
# Christoph Junghans
# Ryan S. Elliott
#
# - Find KIM-API
#
# sets standard pkg_check_modules variables plus:
#
# KIM-API-CMAKE_C_COMPILER
# KIM-API-CMAKE_CXX_COMPILER
# KIM-API-CMAKE_Fortran_COMPILER
#
function(_KIMAPI_GET_VERSION _OUT_ver _version_hdr)
if(NOT EXISTS ${_version_hdr})
message(FATAL_ERROR "Header file ${_version_hdr} not found (check value of KIM-API_INCLUDE_DIR)")
endif()
foreach(_var KIM_VERSION_MAJOR KIM_VERSION_MINOR KIM_VERSION_PATCH)
file(STRINGS ${_version_hdr} _contents REGEX "#define ${_var}[ \t]+")
if(_contents)
string(REGEX REPLACE ".*#define ${_var}[ \t]+([0-9]+).*" "\\1" _${_var} "${_contents}")
if(${_${_var}} STREQUAL "")
message(FATAL_ERROR "Version parsing failed for ${_var} in ${_version_hdr}, got empty return!")
elseif(NOT ${_${_var}} MATCHES "^[0-9]+$")
message(FATAL_ERROR "Version parsing failed for ${_var} in ${_version_hdr}, excepted a number but got ${_${_var}}!")
endif()
else()
message(FATAL_ERROR "No ${_var} line found in include file ${_version_hdr}")
endif()
endforeach()
set(${_OUT_ver} ${_KIM_VERSION_MAJOR}.${_KIM_VERSION_MINOR}.${_KIM_VERSION_PATCH} PARENT_SCOPE)
endfunction()
if(KIM-API_FIND_QUIETLY)
set(REQ_OR_QUI "QUIET")
else()
set(REQ_OR_QUI "REQUIRED")
endif()
find_package(PkgConfig ${REQ_OR_QUI})
include(FindPackageHandleStandardArgs)
pkg_check_modules(KIM-API ${REQ_OR_QUI} libkim-api>=2.0)
if(KIM-API_FOUND)
pkg_get_variable(KIM-API-CMAKE_C_COMPILER libkim-api CMAKE_C_COMPILER)
pkg_get_variable(KIM-API-CMAKE_CXX_COMPILER libkim-api CMAKE_CXX_COMPILER)
pkg_get_variable(KIM-API_CMAKE_Fortran_COMPILER libkim-api CMAKE_Fortran_COMPILER)
endif()
if(KIM-API_INCLUDEDIR)
_KIMAPI_GET_VERSION(KIM-API_VERSION ${KIM-API_INCLUDEDIR}/KIM_Version.h)
else()
set(KIM-API_VERSION 0)
endif()
# handle the QUIETLY and REQUIRED arguments and set KIM-API_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(KIM-API REQUIRED_VARS KIM-API_LIBRARIES VERSION_VAR KIM-API_VERSION)

View File

@ -7,12 +7,21 @@
find_library(LATTE_LIBRARY NAMES latte) find_library(LATTE_LIBRARY NAMES latte)
set(LATTE_LIBRARIES ${LATTE_LIBRARY})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LATTE_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set LATTE_FOUND to TRUE
# if all listed variables are TRUE # if all listed variables are TRUE
find_package_handle_standard_args(LATTE DEFAULT_MSG LATTE_LIBRARY) find_package_handle_standard_args(LATTE DEFAULT_MSG LATTE_LIBRARY)
# Copy the results to the output variables and target.
if(LATTE_FOUND)
set(LATTE_LIBRARIES ${LATTE_LIBRARY})
if(NOT TARGET LATTE::latte)
add_library(LATTE::latte UNKNOWN IMPORTED)
set_target_properties(LATTE::latte PROPERTIES
IMPORTED_LOCATION "${LATTE_LIBRARY}")
endif()
endif()
mark_as_advanced(LATTE_LIBRARY) mark_as_advanced(LATTE_LIBRARY)

View File

@ -10,13 +10,22 @@ find_path(MKL_INCLUDE_DIR mkl_dfti.h HINTS $ENV{MKLROOT}/include)
find_library(MKL_LIBRARY NAMES mkl_rt HINTS $ENV{MKLROOT}/lib $ENV{MKLROOT}/lib/intel64) find_library(MKL_LIBRARY NAMES mkl_rt HINTS $ENV{MKLROOT}/lib $ENV{MKLROOT}/lib/intel64)
set(MKL_LIBRARIES ${MKL_LIBRARY})
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set MKL_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set MKL_FOUND to TRUE
# if all listed variables are TRUE # if all listed variables are TRUE
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_LIBRARY MKL_INCLUDE_DIR) find_package_handle_standard_args(MKL DEFAULT_MSG MKL_LIBRARY MKL_INCLUDE_DIR)
if(MKL_FOUND)
set(MKL_LIBRARIES ${MKL_LIBRARY})
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
if(NOT TARGET MKL::MKL)
add_library(MKL::MKL UNKNOWN IMPORTED)
set_target_properties(MKL::MKL PROPERTIES
IMPORTED_LOCATION "${MKL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MKL_INCLUDE_DIR}")
endif()
endif()
mark_as_advanced(MKL_INCLUDE_DIR MKL_LIBRARY ) mark_as_advanced(MKL_INCLUDE_DIR MKL_LIBRARY )

View File

@ -10,13 +10,23 @@ find_path(MSCG_INCLUDE_DIR mscg.h PATH_SUFFIXES mscg)
find_library(MSCG_LIBRARY NAMES mscg) find_library(MSCG_LIBRARY NAMES mscg)
set(MSCG_LIBRARIES ${MSCG_LIBRARY})
set(MSCG_INCLUDE_DIRS ${MSCG_INCLUDE_DIR})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set MSCG_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set MSCG_FOUND to TRUE
# if all listed variables are TRUE # if all listed variables are TRUE
find_package_handle_standard_args(MSCG DEFAULT_MSG MSCG_LIBRARY MSCG_INCLUDE_DIR) find_package_handle_standard_args(MSCG DEFAULT_MSG MSCG_LIBRARY MSCG_INCLUDE_DIR)
# Copy the results to the output variables and target.
if(MSCG_FOUND)
set(MSCG_LIBRARIES ${MSCG_LIBRARY})
set(MSCG_INCLUDE_DIRS ${MSCG_INCLUDE_DIR})
if(NOT TARGET MSCG::MSCG)
add_library(MSCG::MSCG UNKNOWN IMPORTED)
set_target_properties(MSCG::MSCG PROPERTIES
IMPORTED_LOCATION "${MSCG_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MSCG_INCLUDE_DIR}")
endif()
endif()
mark_as_advanced(MSCG_INCLUDE_DIR MSCG_LIBRARY ) mark_as_advanced(MSCG_INCLUDE_DIR MSCG_LIBRARY )

View File

@ -46,10 +46,14 @@ endif()
find_path (NETCDF_INCLUDE_DIR netcdf.h find_path (NETCDF_INCLUDE_DIR netcdf.h
HINTS "${NETCDF_DIR}/include") HINTS "${NETCDF_DIR}/include")
mark_as_advanced (NETCDF_INCLUDE_DIR) mark_as_advanced (NETCDF_INCLUDE_DIR)
set (NETCDF_C_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR}) set (NETCDF_C_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR})
string(REGEX REPLACE "/include/?$" ""
NETCDF_LIB_HINT ${NETCDF_INCLUDE_DIR})
find_library (NETCDF_LIBRARY NAMES netcdf find_library (NETCDF_LIBRARY NAMES netcdf
HINTS "${NETCDF_DIR}/lib") HINTS "${NETCDF_DIR}" "${NETCDF_LIB_HINT}" PATH_SUFFIXES lib lib64)
mark_as_advanced (NETCDF_LIBRARY) mark_as_advanced (NETCDF_LIBRARY)
set (NETCDF_C_LIBRARIES ${NETCDF_LIBRARY}) set (NETCDF_C_LIBRARIES ${NETCDF_LIBRARY})
@ -116,3 +120,14 @@ set (NETCDF_INCLUDE_DIRS ${NetCDF_includes})
include (FindPackageHandleStandardArgs) include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (NetCDF find_package_handle_standard_args (NetCDF
DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDE_DIRS NETCDF_HAS_INTERFACES) DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDE_DIRS NETCDF_HAS_INTERFACES)
# Copy the results to the output variables and target.
if(NetCDF_FOUND)
if(NOT TARGET NetCDF::NetCDF)
add_library(NetCDF::NetCDF UNKNOWN IMPORTED)
set_target_properties(NetCDF::NetCDF PROPERTIES
IMPORTED_LOCATION "${NETCDF_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${NETCDF_LIBRARIES}")
endif()
endif()

View File

@ -0,0 +1,64 @@
# source: https://ftp.space.dtu.dk/pub/Ioana/pism0.6.1-10/CMake/FindPNetCDF.cmake
# license: GPL v3 (https://ftp.space.dtu.dk/pub/Ioana/pism0.6.1-10/COPYING)
#
# - Find PNetCDF
# Find the native PNetCDF includes and library
#
# PNETCDF_INCLUDES - where to find netcdf.h, etc
# PNETCDF_LIBRARIES - Link these libraries when using NetCDF
# PNETCDF_FOUND - True if PNetCDF was found
#
# Normal usage would be:
# find_package (PNetCDF REQUIRED)
# target_link_libraries (uses_pnetcdf ${PNETCDF_LIBRARIES})
if (PNETCDF_INCLUDES AND PNETCDF_LIBRARIES)
# Already in cache, be silent
set (PNETCDF_FIND_QUIETLY TRUE)
endif (PNETCDF_INCLUDES AND PNETCDF_LIBRARIES)
find_path (PNETCDF_INCLUDES pnetcdf.h
HINTS "${PNETCDF_ROOT}/include" "$ENV{PNETCDF_ROOT}/include")
string(REGEX REPLACE "/include/?$" ""
PNETCDF_LIB_HINT ${PNETCDF_INCLUDES})
find_library (PNETCDF_LIBRARIES
NAMES pnetcdf
HINTS ${PNETCDF_LIB_HINT} PATH_SUFFIXES lib lib64)
if ((NOT PNETCDF_LIBRARIES) OR (NOT PNETCDF_INCLUDES))
message(STATUS "Trying to find PNetCDF using LD_LIBRARY_PATH (we're desperate)...")
file(TO_CMAKE_PATH "$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH)
find_library(PNETCDF_LIBRARIES
NAMES pnetcdf
HINTS ${LD_LIBRARY_PATH})
if (PNETCDF_LIBRARIES)
get_filename_component(PNETCDF_LIB_DIR ${PNETCDF_LIBRARIES} PATH)
string(REGEX REPLACE "/(lib|lib64)/?$" "/include"
PNETCDF_H_HINT ${PNETCDF_LIB_DIR})
find_path (PNETCDF_INCLUDES pnetcdf.h
HINTS ${PNETCDF_H_HINT}
DOC "Path to pnetcdf.h")
endif()
endif()
# handle the QUIETLY and REQUIRED arguments and set PNETCDF_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PNetCDF DEFAULT_MSG PNETCDF_LIBRARIES PNETCDF_INCLUDES)
mark_as_advanced (PNETCDF_LIBRARIES PNETCDF_INCLUDES)
if(PNetCDF_FOUND)
if(NOT TARGET PNetCDF::PNetCDF)
add_library(PNetCDF::PNetCDF UNKNOWN IMPORTED)
set_target_properties(PNetCDF::PNetCDF PROPERTIES
IMPORTED_LOCATION "${PNETCDF_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${PNETCDF_INCLUDES}")
endif()
endif()

View File

@ -1,29 +0,0 @@
# - Find quantum-espresso
# Find the native QE headers and libraries.
#
# QE_INCLUDE_DIRS - where to find quantum-espresso.h, etc.
# QE_LIBRARIES - List of libraries when using quantum-espresso.
# QE_FOUND - True if quantum-espresso found.
#
find_path(QE_INCLUDE_DIR libqecouple.h PATH_SUFFIXES COUPLE/include)
find_library(QECOUPLE_LIBRARY NAMES qecouple)
find_library(PW_LIBRARY NAMES pw)
find_library(QEMOD_LIBRARY NAMES qemod)
find_library(QEFFT_LIBRARY NAMES qefft)
find_library(QELA_LIBRARY NAMES qela)
find_library(CLIB_LIBRARY NAMES clib)
find_library(IOTK_LIBRARY NAMES iotk)
set(QE_LIBRARIES ${QECOUPLE_LIBRARY} ${PW_LIBRARY} ${QEMOD_LIBRARY} ${QEFFT_LIBRARY} ${QELA_LIBRARY} ${CLIB_LIBRARY} ${IOTK_LIBRARY})
set(QE_INCLUDE_DIRS ${QE_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set QE_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(QE DEFAULT_MSG QECOUPLE_LIBRARY PW_LIBRARY QEMOD_LIBRARY QEFFT_LIBRARY QELA_LIBRARY CLIB_LIBRARY IOTK_LIBRARY QE_INCLUDE_DIR)
mark_as_advanced(QE_INCLUDE_DIR QECOUPLE_LIBRARY PW_LIBRARY QEMOD_LIBRARY QEFFT_LIBRARY QELA_LIBRARY CLIB_LIBRARY IOTK_LIBRARY)

View File

@ -7,12 +7,21 @@
find_library(QUIP_LIBRARY NAMES quip) find_library(QUIP_LIBRARY NAMES quip)
set(QUIP_LIBRARIES ${QUIP_LIBRARY})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set QUIP_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set QUIP_FOUND to TRUE
# if all listed variables are TRUE # if all listed variables are TRUE
find_package_handle_standard_args(QUIP DEFAULT_MSG QUIP_LIBRARY) find_package_handle_standard_args(QUIP DEFAULT_MSG QUIP_LIBRARY)
# Copy the results to the output variables and target.
if(QUIP_FOUND)
set(QUIP_LIBRARIES ${QUIP_LIBRARY})
if(NOT TARGET QUIP::QUIP)
add_library(QUIP::QUIP UNKNOWN IMPORTED)
set_target_properties(QUIP::QUIP PROPERTIES
IMPORTED_LOCATION "${QUIP_LIBRARY}")
endif()
endif()
mark_as_advanced(QUIP_LIBRARY) mark_as_advanced(QUIP_LIBRARY)

View File

@ -1,46 +0,0 @@
# - Find parts of TBB
# Find the native TBB headers and libraries.
#
# TBB_INCLUDE_DIRS - where to find tbb.h, etc.
# TBB_LIBRARIES - List of libraries when using tbb.
# TBB_FOUND - True if tbb found.
#
########################################################
# TBB
# TODO use more generic FindTBB
find_path(TBB_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
find_library(TBB_LIBRARY NAMES tbb PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
$ENV{TBBROOT}/lib/intel64/gcc4.4
$ENV{TBBROOT}/lib/intel64/gcc4.1)
set(TBB_LIBRARIES ${TBB_LIBRARY})
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set TBB_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(TBB DEFAULT_MSG TBB_LIBRARY TBB_INCLUDE_DIR)
mark_as_advanced(TBB_INCLUDE_DIR TBB_LIBRARY )
########################################################
# TBB Malloc
find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
find_library(TBB_MALLOC_LIBRARY NAMES tbbmalloc PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
$ENV{TBBROOT}/lib/intel64/gcc4.4
$ENV{TBBROOT}/lib/intel64/gcc4.1)
set(TBB_MALLOC_LIBRARIES ${TBB_MALLOC_LIBRARY})
set(TBB_MALLOC_INCLUDE_DIRS ${TBB_MALLOC_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set TBB_MALLOC_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(TBB_MALLOC DEFAULT_MSG TBB_MALLOC_LIBRARY TBB_MALLOC_INCLUDE_DIR)
mark_as_advanced(TBB_MALLOC_INCLUDE_DIR TBB_MALLOC_LIBRARY )

View File

@ -0,0 +1,36 @@
# - Find parts of TBB_MALLOC
# Find the native TBB_MALLOC headers and libraries.
#
# TBB_MALLOC_INCLUDE_DIRS - where to find tbb.h, etc.
# TBB_MALLOC_LIBRARIES - List of libraries when using tbb.
# TBB_MALLOC_FOUND - True if tbb found.
#
########################################################
# TBB Malloc
find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
find_library(TBB_MALLOC_LIBRARY NAMES tbbmalloc PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
$ENV{TBBROOT}/lib/intel64/gcc4.4
$ENV{TBBROOT}/lib/intel64/gcc4.1)
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set TBB_MALLOC_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(TBB_MALLOC DEFAULT_MSG TBB_MALLOC_LIBRARY TBB_MALLOC_INCLUDE_DIR)
if(TBB_MALLOC_FOUND)
set(TBB_MALLOC_LIBRARIES ${TBB_MALLOC_LIBRARY})
set(TBB_MALLOC_INCLUDE_DIRS ${TBB_MALLOC_INCLUDE_DIR})
if(NOT TARGET TBB::TBB_MALLOC)
add_library(TBB::TBB_MALLOC UNKNOWN IMPORTED)
set_target_properties(TBB::TBB_MALLOC PROPERTIES
IMPORTED_LOCATION "${TBB_MALLOC_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${TBB_MALLOC_INCLUDE_DIR}")
endif()
endif()
mark_as_advanced(TBB_MALLOC_INCLUDE_DIR TBB_MALLOC_LIBRARY )

View File

@ -10,13 +10,23 @@ find_path(VORO_INCLUDE_DIR voro++.hh PATH_SUFFIXES voro++)
find_library(VORO_LIBRARY NAMES voro++) find_library(VORO_LIBRARY NAMES voro++)
set(VORO_LIBRARIES ${VORO_LIBRARY})
set(VORO_INCLUDE_DIRS ${VORO_INCLUDE_DIR})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set VORO_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set VORO_FOUND to TRUE
# if all listed variables are TRUE # if all listed variables are TRUE
find_package_handle_standard_args(VORO DEFAULT_MSG VORO_LIBRARY VORO_INCLUDE_DIR) find_package_handle_standard_args(VORO DEFAULT_MSG VORO_LIBRARY VORO_INCLUDE_DIR)
# Copy the results to the output variables and target.
if(VORO_FOUND)
set(VORO_LIBRARIES ${VORO_LIBRARY})
set(VORO_INCLUDE_DIRS ${VORO_INCLUDE_DIR})
if(NOT TARGET VORO::VORO)
add_library(VORO::VORO UNKNOWN IMPORTED)
set_target_properties(VORO::VORO PROPERTIES
IMPORTED_LOCATION "${VORO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${VORO_INCLUDE_DIR}")
endif()
endif()
mark_as_advanced(VORO_INCLUDE_DIR VORO_LIBRARY ) mark_as_advanced(VORO_INCLUDE_DIR VORO_LIBRARY )

View File

@ -1,8 +1,19 @@
find_path(ZMQ_INCLUDE_DIR zmq.h) find_path(ZMQ_INCLUDE_DIR zmq.h)
find_library(ZMQ_LIBRARY NAMES zmq) find_library(ZMQ_LIBRARY NAMES zmq)
set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZMQ DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR) find_package_handle_standard_args(ZMQ DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR)
# Copy the results to the output variables and target.
if(ZMQ_FOUND)
set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})
if(NOT TARGET ZMQ::ZMQ)
add_library(ZMQ::ZMQ UNKNOWN IMPORTED)
set_target_properties(ZMQ::ZMQ PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${ZMQ_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ZMQ_INCLUDE_DIR}")
endif()
endif()

View File

@ -0,0 +1,3 @@
# utility script to call GenerateBinaryHeader function
include(${SOURCE_DIR}/Modules/LAMMPSUtils.cmake)
GenerateBinaryHeader(${VARNAME} ${HEADER_FILE} ${SOURCE_FILES})

View File

@ -69,3 +69,19 @@ macro(pkg_depends PKG1 PKG2)
message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}") message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}")
endif() endif()
endmacro() endmacro()
# CMake-only replacement for bin2c and xxd
function(GenerateBinaryHeader varname outfile files)
message("Creating ${outfile}...")
file(WRITE ${outfile} "// CMake generated file\n")
math(EXPR ARG_END "${ARGC}-1")
foreach(IDX RANGE 2 ${ARG_END})
list(GET ARGV ${IDX} filename)
file(READ ${filename} content HEX)
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," content "${content}")
string(REGEX REPLACE ",$" "" content "${content}")
file(APPEND ${outfile} "const unsigned char ${varname}[] = { ${content} };\n")
file(APPEND ${outfile} "const unsigned int ${varname}_size = sizeof(${varname});\n")
endforeach()
endfunction(GenerateBinaryHeader)

View File

@ -0,0 +1,30 @@
# Download and configure custom MPICH files for Windows
message(STATUS "Downloading and configuring MPICH-1.4.1 for Windows")
include(ExternalProject)
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
ExternalProject_Add(mpi4win_build
URL https://download.lammps.org/thirdparty/mpich2-win64-devel.tar.gz
URL_MD5 4939fdb59d13182fd5dd65211e469f14
CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
BUILD_BYPRODUCTS <SOURCE_DIR>/lib/libmpi.a)
else()
ExternalProject_Add(mpi4win_build
URL https://download.lammps.org/thirdparty/mpich2-win32-devel.tar.gz
URL_MD5 a61d153500dce44e21b755ee7257e031
CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
BUILD_BYPRODUCTS <SOURCE_DIR>/lib/libmpi.a)
endif()
ExternalProject_get_property(mpi4win_build SOURCE_DIR)
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
add_library(MPI::MPI_CXX UNKNOWN IMPORTED)
set_target_properties(MPI::MPI_CXX PROPERTIES
IMPORTED_LOCATION "${SOURCE_DIR}/lib/libmpi.a"
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include"
INTERFACE_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
add_dependencies(MPI::MPI_CXX mpi4win_build)
# set variables for status reporting at the end of CMake run
set(MPI_CXX_INCLUDE_PATH "${SOURCE_DIR}/include")
set(MPI_CXX_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
set(MPI_CXX_LIBRARIES "${SOURCE_DIR}/lib/libmpi.a")

View File

@ -1,5 +1,2 @@
if(PKG_COMPRESS) find_package(ZLIB REQUIRED)
find_package(ZLIB REQUIRED) target_link_libraries(lammps PRIVATE ZLIB::ZLIB)
include_directories(${ZLIB_INCLUDE_DIRS})
list(APPEND LAMMPS_LINK_LIBS ${ZLIB_LIBRARIES})
endif()

View File

@ -1,13 +1,11 @@
if(PKG_CORESHELL) set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL)
set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL) set(CORESHELL_SOURCES)
set(CORESHELL_SOURCES) set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}")
set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}")
# detects styles which have a CORESHELL version # detects styles which have a CORESHELL version
RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES) RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES)
get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES) get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES)
list(APPEND LIB_SOURCES ${CORESHELL_SOURCES}) target_sources(lammps PRIVATE ${CORESHELL_SOURCES})
include_directories(${CORESHELL_SOURCES_DIR}) target_include_directories(lammps PRIVATE ${CORESHELL_SOURCES_DIR})
endif()

View File

@ -1,194 +1,374 @@
if(PKG_GPU) set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU)
if (CMAKE_VERSION VERSION_LESS "3.1") set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
message(FATAL_ERROR "For the GPU package you need at least cmake-3.1") ${GPU_SOURCES_DIR}/fix_gpu.h
endif() ${GPU_SOURCES_DIR}/fix_gpu.cpp)
set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU)
set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
${GPU_SOURCES_DIR}/fix_gpu.h
${GPU_SOURCES_DIR}/fix_gpu.cpp)
set(GPU_API "opencl" CACHE STRING "API used by GPU package") set(GPU_API "opencl" CACHE STRING "API used by GPU package")
set(GPU_API_VALUES opencl cuda) set(GPU_API_VALUES opencl cuda hip)
set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES}) set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES})
validate_option(GPU_API GPU_API_VALUES) validate_option(GPU_API GPU_API_VALUES)
string(TOUPPER ${GPU_API} GPU_API) string(TOUPPER ${GPU_API} GPU_API)
set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision") set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision")
set(GPU_PREC_VALUES double mixed single) set(GPU_PREC_VALUES double mixed single)
set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES}) set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES})
validate_option(GPU_PREC GPU_PREC_VALUES) validate_option(GPU_PREC GPU_PREC_VALUES)
string(TOUPPER ${GPU_PREC} GPU_PREC) string(TOUPPER ${GPU_PREC} GPU_PREC)
if(GPU_PREC STREQUAL "DOUBLE") if(GPU_PREC STREQUAL "DOUBLE")
set(GPU_PREC_SETTING "DOUBLE_DOUBLE") set(GPU_PREC_SETTING "DOUBLE_DOUBLE")
elseif(GPU_PREC STREQUAL "MIXED") elseif(GPU_PREC STREQUAL "MIXED")
set(GPU_PREC_SETTING "SINGLE_DOUBLE") set(GPU_PREC_SETTING "SINGLE_DOUBLE")
elseif(GPU_PREC STREQUAL "SINGLE") elseif(GPU_PREC STREQUAL "SINGLE")
set(GPU_PREC_SETTING "SINGLE_SINGLE") set(GPU_PREC_SETTING "SINGLE_SINGLE")
endif()
file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp)
file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu)
if(GPU_API STREQUAL "CUDA")
find_package(CUDA REQUIRED)
find_program(BIN2C bin2c)
if(NOT BIN2C)
message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.")
endif()
option(CUDPP_OPT "Enable CUDPP_OPT" ON)
option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF)
if(CUDA_MPS_SUPPORT)
set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY")
endif()
set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)")
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu)
if(CUDPP_OPT)
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp)
file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu)
endif()
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ")
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
endif()
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
if(CUDA_VERSION VERSION_GREATER "4.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
endif()
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
if(CUDA_VERSION VERSION_GREATER "5.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
endif()
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
if(CUDA_VERSION VERSION_GREATER "7.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
endif()
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
if(CUDA_VERSION VERSION_GREATER "8.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
endif()
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
if(CUDA_VERSION VERSION_GREATER "9.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
endif()
cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC}
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
foreach(CU_OBJ ${GPU_GEN_OBJS})
get_filename_component(CU_NAME ${CU_OBJ} NAME_WE)
string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}")
add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
DEPENDS ${CU_OBJ}
COMMENT "Generating ${CU_NAME}_cubin.h")
list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h)
endforeach()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h")
add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS})
target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS})
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS})
if(CUDPP_OPT)
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
target_compile_definitions(gpu PRIVATE -DUSE_CUDPP)
endif()
list(APPEND LAMMPS_LINK_LIBS gpu)
add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR)
target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
elseif(GPU_API STREQUAL "OPENCL")
find_package(OpenCL REQUIRED)
set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning")
set(OCL_TUNE_VALUES intel fermi kepler cypress generic)
set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES})
validate_option(OCL_TUNE OCL_TUNE_VALUES)
string(TOUPPER ${OCL_TUNE} OCL_TUNE)
include(OpenCLUtils)
set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h)
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu)
list(REMOVE_ITEM GPU_LIB_CU
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu
)
foreach(GPU_KERNEL ${GPU_LIB_CU})
get_filename_component(basename ${GPU_KERNEL} NAME_WE)
string(SUBSTRING ${basename} 4 -1 KERNEL_NAME)
GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL})
list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h)
endforeach()
GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu)
GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu)
GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu)
GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu)
GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu)
GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu)
GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu)
list(APPEND GPU_LIB_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h
)
add_library(gpu STATIC ${GPU_LIB_SOURCES})
target_link_libraries(gpu ${OpenCL_LIBRARIES})
target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS})
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT)
target_compile_definitions(gpu PRIVATE -DUSE_OPENCL)
list(APPEND LAMMPS_LINK_LIBS gpu)
add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL)
target_link_libraries(ocl_get_devices PRIVATE ${OpenCL_LIBRARIES})
target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS})
endif()
# GPU package
FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX)
set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}")
# detects styles which have GPU version
RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)
get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
list(APPEND LIB_SOURCES ${GPU_SOURCES})
include_directories(${GPU_SOURCES_DIR})
endif() endif()
file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp)
file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu)
if(GPU_API STREQUAL "CUDA")
find_package(CUDA REQUIRED)
find_program(BIN2C bin2c)
if(NOT BIN2C)
message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.")
endif()
option(CUDPP_OPT "Enable CUDPP_OPT" ON)
option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF)
if(CUDA_MPS_SUPPORT)
set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY")
endif()
set(GPU_ARCH "sm_50" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)")
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu)
if(CUDPP_OPT)
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp)
file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu)
endif()
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ")
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
endif()
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
if(CUDA_VERSION VERSION_GREATER "4.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
endif()
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
if(CUDA_VERSION VERSION_GREATER "5.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
endif()
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
if(CUDA_VERSION VERSION_GREATER "7.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
endif()
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
if(CUDA_VERSION VERSION_GREATER "8.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
endif()
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
if(CUDA_VERSION VERSION_GREATER "9.9")
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
endif()
cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC}
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
foreach(CU_OBJ ${GPU_GEN_OBJS})
get_filename_component(CU_NAME ${CU_OBJ} NAME_WE)
string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}")
add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
DEPENDS ${CU_OBJ}
COMMENT "Generating ${CU_NAME}_cubin.h")
list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h)
endforeach()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h")
add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS})
target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS})
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS})
if(CUDPP_OPT)
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
target_compile_definitions(gpu PRIVATE -DUSE_CUDPP)
endif()
target_link_libraries(lammps PRIVATE gpu)
add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR)
target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
elseif(GPU_API STREQUAL "OPENCL")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# download and unpack support binaries for compilation of windows binaries.
set(LAMMPS_THIRDPARTY_URL "http://download.lammps.org/thirdparty")
file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz"
EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_library(OpenCL::OpenCL UNKNOWN IMPORTED)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll")
endif()
set_target_properties(OpenCL::OpenCL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include")
else()
find_package(OpenCL REQUIRED)
endif()
set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning")
set(OCL_TUNE_VALUES intel fermi kepler cypress generic)
set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES})
validate_option(OCL_TUNE OCL_TUNE_VALUES)
string(TOUPPER ${OCL_TUNE} OCL_TUNE)
include(OpenCLUtils)
set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h)
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu)
list(REMOVE_ITEM GPU_LIB_CU
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu
)
foreach(GPU_KERNEL ${GPU_LIB_CU})
get_filename_component(basename ${GPU_KERNEL} NAME_WE)
string(SUBSTRING ${basename} 4 -1 KERNEL_NAME)
GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL})
list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h)
endforeach()
GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu)
GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu)
GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu)
GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu)
GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu)
GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu)
GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu)
list(APPEND GPU_LIB_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h
)
add_library(gpu STATIC ${GPU_LIB_SOURCES})
target_link_libraries(gpu PRIVATE OpenCL::OpenCL)
target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu)
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT)
target_compile_definitions(gpu PRIVATE -DUSE_OPENCL)
target_link_libraries(lammps PRIVATE gpu)
add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL)
target_link_libraries(ocl_get_devices PRIVATE OpenCL::OpenCL)
elseif(GPU_API STREQUAL "HIP")
if(NOT DEFINED HIP_PATH)
if(NOT DEFINED ENV{HIP_PATH})
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
else()
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
endif()
endif()
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
find_package(HIP REQUIRED)
option(HIP_USE_DEVICE_SORT "Use GPU sorting" ON)
if(NOT DEFINED HIP_PLATFORM)
if(NOT DEFINED ENV{HIP_PLATFORM})
set(HIP_PLATFORM "hcc" CACHE PATH "HIP Platform to be used during compilation")
else()
set(HIP_PLATFORM $ENV{HIP_PLATFORM} CACHE PATH "HIP Platform used during compilation")
endif()
endif()
set(ENV{HIP_PLATFORM} ${HIP_PLATFORM})
if(HIP_PLATFORM STREQUAL "hcc")
set(HIP_ARCH "gfx906" CACHE STRING "HIP target architecture")
elseif(HIP_PLATFORM STREQUAL "nvcc")
find_package(CUDA REQUIRED)
set(HIP_ARCH "sm_50" CACHE STRING "HIP primary CUDA architecture (e.g. sm_60)")
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
set(HIP_CUDA_GENCODE "-arch=${HIP_ARCH} ")
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
endif()
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
if(CUDA_VERSION VERSION_GREATER "4.9")
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
endif()
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
if(CUDA_VERSION VERSION_GREATER "5.9")
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
endif()
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
if(CUDA_VERSION VERSION_GREATER "7.9")
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
endif()
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
if(CUDA_VERSION VERSION_GREATER "8.9")
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
endif()
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
if(CUDA_VERSION VERSION_GREATER "9.9")
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
endif()
endif()
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
set(GPU_LIB_CU_HIP "")
foreach(CU_FILE ${GPU_LIB_CU})
get_filename_component(CU_NAME ${CU_FILE} NAME_WE)
string(REGEX REPLACE "^.*lal_" "" CU_NAME "${CU_NAME}")
set(CU_CPP_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cu.cpp")
set(CUBIN_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cubin")
set(CUBIN_H_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h")
if(HIP_PLATFORM STREQUAL "hcc")
configure_file(${CU_FILE} ${CU_CPP_FILE} COPYONLY)
add_custom_command(OUTPUT ${CUBIN_FILE}
VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco -t="${HIP_ARCH}" -f=\"-O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -I${LAMMPS_LIB_SOURCE_DIR}/gpu\" -o ${CUBIN_FILE} ${CU_CPP_FILE}
DEPENDS ${CU_CPP_FILE}
COMMENT "Generating ${CU_NAME}.cubin")
elseif(HIP_PLATFORM STREQUAL "nvcc")
add_custom_command(OUTPUT ${CUBIN_FILE}
VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --fatbin --use_fast_math -DUSE_HIP -D_${GPU_PREC_SETTING} ${HIP_CUDA_GENCODE} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_FILE}
DEPENDS ${CU_FILE}
COMMENT "Generating ${CU_NAME}.cubin")
endif()
add_custom_command(OUTPUT ${CUBIN_H_FILE}
COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -D VARNAME=${CU_NAME} -D HEADER_FILE=${CUBIN_H_FILE} -D SOURCE_FILES=${CUBIN_FILE} -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/GenerateBinaryHeader.cmake
DEPENDS ${CUBIN_FILE}
COMMENT "Generating ${CU_NAME}_cubin.h")
list(APPEND GPU_LIB_SOURCES ${CUBIN_H_FILE})
endforeach()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h ${LAMMPS_LIB_BINARY_DIR}/gpu/*.cu.cpp")
hip_add_library(gpu STATIC ${GPU_LIB_SOURCES})
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu)
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT)
target_compile_definitions(gpu PRIVATE -DUSE_HIP)
if(HIP_USE_DEVICE_SORT)
# add hipCUB
target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
target_compile_definitions(gpu PRIVATE -DUSE_HIP_DEVICE_SORT)
if(HIP_PLATFORM STREQUAL "nvcc")
find_package(CUB)
if(CUB_FOUND)
set(DOWNLOAD_CUB_DEFAULT OFF)
else()
set(DOWNLOAD_CUB_DEFAULT ON)
endif()
option(DOWNLOAD_CUB "Download and compile the CUB library instead of using an already installed one" ${DOWNLOAD_CUB_DEFAULT})
if(DOWNLOAD_CUB)
message(STATUS "CUB download requested")
include(ExternalProject)
ExternalProject_Add(CUB
GIT_REPOSITORY https://github.com/NVlabs/cub
TIMEOUT 5
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
ExternalProject_get_property(CUB SOURCE_DIR)
set(CUB_INCLUDE_DIR ${SOURCE_DIR})
else()
find_package(CUB)
if(NOT CUB_FOUND)
message(FATAL_ERROR "CUB library not found. Help CMake to find it by setting CUB_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
endif()
endif()
target_include_directories(gpu PRIVATE ${CUB_INCLUDE_DIR})
endif()
endif()
hip_add_executable(hip_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
target_compile_definitions(hip_get_devices PRIVATE -DUCL_HIP)
if(HIP_PLATFORM STREQUAL "nvcc")
target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_NVCC__)
target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
target_include_directories(gpu PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_NVCC__)
target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/include)
target_include_directories(hip_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(hip_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
elseif(HIP_PLATFORM STREQUAL "hcc")
target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_HCC__)
target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_HCC__)
target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/../include)
endif()
target_link_libraries(lammps PRIVATE gpu)
endif()
# GPU package
FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX)
set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}")
# detects styles which have GPU version
RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)
get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
if(NOT BUILD_MPI)
# mpistubs is aliased to MPI::MPI_CXX, but older versions of cmake won't work forward the include path
target_link_libraries(gpu PRIVATE mpi_stubs)
else()
target_link_libraries(gpu PRIVATE MPI::MPI_CXX)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
target_compile_definitions(gpu PRIVATE -DLAMMPS_${LAMMPS_SIZES})
set_target_properties(gpu PROPERTIES OUTPUT_NAME lammps_gpu${LAMMPS_MACHINE})
target_sources(lammps PRIVATE ${GPU_SOURCES})
target_include_directories(lammps PRIVATE ${GPU_SOURCES_DIR})

View File

@ -1,57 +1,66 @@
if(PKG_KIM) set(KIM-API_MIN_VERSION 2.1.3)
set(KIM-API_MIN_VERSION 2.1) find_package(CURL)
find_package(CURL) if(CURL_FOUND)
if(CURL_FOUND) if(CMAKE_VERSION VERSION_LESS 3.12)
include_directories(${CURL_INCLUDE_DIRS}) target_include_directories(lammps PRIVATE ${CURL_INCLUDE_DIRS})
list(APPEND LAMMPS_LINK_LIBS ${CURL_LIBRARIES}) target_link_libraries(lammps PRIVATE ${CURL_LIBRARIES})
add_definitions(-DLMP_KIM_CURL)
endif()
find_package(KIM-API QUIET)
if(KIM-API_FOUND)
if (KIM-API_VERSION VERSION_LESS ${KIM-API_MIN_VERSION})
if ("${DOWNLOAD_KIM}" STREQUAL "")
message(WARNING "Unsuitable KIM-API version \"${KIM-API_VERSION}\" found, but required is at least \"${KIM-API_MIN_VERSION}\". Default behavior set to download and build our own.")
endif()
set(DOWNLOAD_KIM_DEFAULT ON)
else()
set(DOWNLOAD_KIM_DEFAULT OFF)
endif()
else() else()
if ("${DOWNLOAD_KIM}" STREQUAL "") target_link_libraries(lammps PRIVATE CURL::libcurl)
message(WARNING "KIM-API package not found. Default behavior set to download and build our own")
endif()
set(DOWNLOAD_KIM_DEFAULT ON)
endif() endif()
option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT}) target_compile_definitions(lammps PRIVATE -DLMP_KIM_CURL)
if(DOWNLOAD_KIM) set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.")
if(CMAKE_GENERATOR STREQUAL "Ninja") mark_as_advanced(LMP_DEBUG_CURL)
message(FATAL_ERROR "Cannot build downloaded KIM-API library with Ninja build tool") if(LMP_DEBUG_CURL)
endif() target_compile_definitions(lammps PRIVATE -DLMP_DEBUG_CURL)
message(STATUS "KIM-API download requested - we will build our own") endif()
include(CheckLanguage) set(LMP_NO_SSL_CHECK OFF CACHE STRING "Tell libcurl to not verify the peer. If on, the connection succeeds regardless of the names in the certificate. Insecure - Use with caution!")
include(ExternalProject) mark_as_advanced(LMP_NO_SSL_CHECK)
enable_language(C) if(LMP_NO_SSL_CHECK)
check_language(Fortran) target_compile_definitions(lammps PRIVATE -DLMP_NO_SSL_CHECK)
if(NOT CMAKE_Fortran_COMPILER)
message(FATAL_ERROR "Compiling the KIM-API library requires a Fortran compiler")
endif()
ExternalProject_Add(kim_build
URL https://s3.openkim.org/kim-api/kim-api-2.1.3.txz
URL_MD5 6ee829a1bbba5f8b9874c88c4c4ebff8
BINARY_DIR build
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
ExternalProject_get_property(kim_build INSTALL_DIR)
set(KIM-API_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api)
set(KIM-API_LDFLAGS ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX})
list(APPEND LAMMPS_DEPS kim_build)
else()
find_package(KIM-API ${KIM-API_MIN_VERSION} REQUIRED)
endif() endif()
list(APPEND LAMMPS_LINK_LIBS "${KIM-API_LDFLAGS}") endif()
include_directories(${KIM-API_INCLUDE_DIRS}) find_package(PkgConfig QUIET)
set(DOWNLOAD_KIM_DEFAULT ON)
if(PKG_CONFIG_FOUND)
pkg_check_modules(KIM-API QUIET libkim-api>=${KIM-API_MIN_VERSION})
if(KIM-API_FOUND)
set(DOWNLOAD_KIM_DEFAULT OFF)
endif()
endif()
option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
if(DOWNLOAD_KIM)
message(STATUS "KIM-API download requested - we will build our own")
include(ExternalProject)
enable_language(C)
enable_language(Fortran)
ExternalProject_Add(kim_build
URL https://s3.openkim.org/kim-api/kim-api-2.1.3.txz
URL_MD5 6ee829a1bbba5f8b9874c88c4c4ebff8
BINARY_DIR build
CMAKE_ARGS ${CMAKE_REQUEST_PIC}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}
)
ExternalProject_get_property(kim_build INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include/kim-api)
add_library(LAMMPS::KIM UNKNOWN IMPORTED)
set_target_properties(LAMMPS::KIM PROPERTIES
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include/kim-api")
target_link_libraries(lammps PRIVATE LAMMPS::KIM)
add_dependencies(LAMMPS::KIM kim_build)
if(NOT BUILD_SHARED_LIBS)
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=${KIM-API_MIN_VERSION})
target_link_libraries(lammps PRIVATE PkgConfig::KIM-API)
endif() endif()

View File

@ -1,66 +1,125 @@
if(PKG_KOKKOS) ########################################################################
# TODO: this option needs to be documented when this works with a # consistency checks and Kokkos options/settings required by LAMMPS
# regular release version of KOKKOS, and a version compatibility check if(Kokkos_ENABLE_CUDA)
# of external KOKKOS lib versus what the KOKKOS package needs is required. message(STATUS "KOKKOS: Enabling CUDA LAMBDA function support")
option(EXTERNAL_KOKKOS "Build against external kokkos library") set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "" FORCE)
if(EXTERNAL_KOKKOS)
find_package(Kokkos REQUIRED)
list(APPEND LAMMPS_LINK_LIBS Kokkos::kokkos)
else()
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
${LAMMPS_LIB_KOKKOS_BIN_DIR})
include_directories(${Kokkos_INCLUDE_DIRS})
list(APPEND LAMMPS_LINK_LIBS kokkos)
endif()
add_definitions(-DLMP_KOKKOS)
set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS)
set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/min_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/min_linesearch_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)
if(PKG_KSPACE)
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp)
endif()
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
# detects styles which have KOKKOS version
RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES)
# register kokkos-only styles
RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h)
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h)
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.h)
if(PKG_USER-DPD)
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp)
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h)
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
endif()
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
list(APPEND LIB_SOURCES ${KOKKOS_PKG_SOURCES})
include_directories(${KOKKOS_PKG_SOURCES_DIR})
endif() endif()
# Adding OpenMP compiler flags without the checks done for
# BUILD_OMP can result in compile failures. Enforce consistency.
if(Kokkos_ENABLE_OPENMP AND NOT BUILD_OMP)
message(FATAL_ERROR "Must enable BUILD_OMP with Kokkos_ENABLE_OPENMP")
endif()
########################################################################
option(EXTERNAL_KOKKOS "Build against external kokkos library" OFF)
option(DOWNLOAD_KOKKOS "Download the KOKKOS library instead of using the bundled one" OFF)
if(DOWNLOAD_KOKKOS)
# extract Kokkos-related variables and values so we can forward them to the Kokkos library build
get_cmake_property(_VARS VARIABLES)
list(FILTER _VARS INCLUDE REGEX ^Kokkos_)
foreach(_VAR IN LISTS _VARS)
list(APPEND KOKKOS_LIB_BUILD_ARGS "-D${_VAR}=${${_VAR}}")
endforeach()
message(STATUS "KOKKOS download requested - we will build our own")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>")
if(CMAKE_REQUEST_PIC)
list(APPEND KOKKOS_LIB_BUILD_ARGS ${CMAKE_REQUEST_PIC})
endif()
# append other CMake variables that need to be forwarded to CMAKE_ARGS
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_INSTALL_LIBDIR=lib")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
include(ExternalProject)
ExternalProject_Add(kokkos_build
URL https://github.com/kokkos/kokkos/archive/3.1.00.tar.gz
URL_MD5 f638a6c786f748a602b26faa0e96ebab
CMAKE_ARGS ${KOKKOS_LIB_BUILD_ARGS}
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkokkoscore.a
)
ExternalProject_get_property(kokkos_build INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
add_library(LAMMPS::KOKKOS UNKNOWN IMPORTED)
set_target_properties(LAMMPS::KOKKOS PROPERTIES
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkokkoscore.a"
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
target_link_libraries(lammps PRIVATE LAMMPS::KOKKOS)
add_dependencies(LAMMPS::KOKKOS kokkos_build)
if(NOT BUILD_SHARED_LIBS)
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
elseif(EXTERNAL_KOKKOS)
find_package(Kokkos 3.1)
if(NOT Kokkos_FOUND)
message(FATAL_ERROR "KOKKOS library version 3.1 or later not found, help CMake to find it by setting KOKKOS_LIBRARY, or set DOWNLOAD_KOKKOS=ON to download it")
endif()
target_link_libraries(lammps PRIVATE Kokkos::kokkos)
else()
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
${LAMMPS_LIB_KOKKOS_BIN_DIR})
target_include_directories(lammps PRIVATE ${Kokkos_INCLUDE_DIRS})
target_link_libraries(lammps PRIVATE kokkos)
endif()
target_compile_definitions(lammps PRIVATE -DLMP_KOKKOS)
set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS)
set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/min_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/min_linesearch_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)
if(PKG_KSPACE)
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/fft3d_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp
${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp)
if(Kokkos_ENABLE_CUDA)
if(NOT ${FFT} STREQUAL "KISS")
target_compile_definitions(lammps PRIVATE -DFFT_CUFFT)
target_link_libraries(lammps PRIVATE cufft)
endif()
endif()
endif()
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
# detects styles which have KOKKOS version
RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES)
# register kokkos-only styles
RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h)
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h)
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.h)
if(PKG_USER-DPD)
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp)
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h)
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
endif()
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
target_sources(lammps PRIVATE ${KOKKOS_PKG_SOURCES})
target_include_directories(lammps PRIVATE ${KOKKOS_PKG_SOURCES_DIR})

View File

@ -1,42 +1,56 @@
if(PKG_KSPACE) option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF)
option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF) set(FFTW "FFTW3")
set(FFTW "FFTW3") if(FFT_SINGLE)
if(FFT_SINGLE) set(FFTW "FFTW3F")
set(FFTW "FFTW3F") target_compile_definitions(lammps PUBLIC -DFFT_SINGLE)
add_definitions(-DFFT_SINGLE) endif()
endif() find_package(${FFTW} QUIET)
find_package(${FFTW} QUIET) if(${FFTW}_FOUND)
if(${FFTW}_FOUND) set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package")
set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package") else()
else() set(FFT "KISS" CACHE STRING "FFT library for KSPACE package")
set(FFT "KISS" CACHE STRING "FFT library for KSPACE package") endif()
endif() set(FFT_VALUES KISS FFTW3 MKL)
set(FFT_VALUES KISS FFTW3 MKL) set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES})
set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES}) validate_option(FFT FFT_VALUES)
validate_option(FFT FFT_VALUES) string(TOUPPER ${FFT} FFT)
string(TOUPPER ${FFT} FFT)
if(FFT STREQUAL "FFTW3")
if(FFT STREQUAL "FFTW3") find_package(${FFTW} REQUIRED)
find_package(${FFTW} REQUIRED) target_compile_definitions(lammps PUBLIC -DFFT_FFTW3)
add_definitions(-DFFT_FFTW3) target_link_libraries(lammps PUBLIC ${FFTW}::${FFTW})
include_directories(${${FFTW}_INCLUDE_DIRS}) if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_LIBRARIES}) option(FFT_FFTW_THREADS "Use threaded FFTW library" ON)
elseif(FFT STREQUAL "MKL") else()
find_package(MKL REQUIRED) option(FFT_FFTW_THREADS "Use threaded FFT library" OFF)
add_definitions(-DFFT_MKL) endif()
include_directories(${MKL_INCLUDE_DIRS})
list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES}) if(FFT_FFTW_THREADS)
else() if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
# last option is KISSFFT target_compile_definitions(lammps PRIVATE -DFFT_FFTW_THREADS)
add_definitions(-DFFT_KISS) target_link_libraries(lammps PRIVATE ${FFTW}::${FFTW}_OMP)
endif() else()
message(FATAL_ERROR "Need OpenMP enabled FFTW3 library for FFT_THREADS")
set(FFT_PACK "array" CACHE STRING "Optimization for FFT") endif()
set(FFT_PACK_VALUES array pointer memcpy) endif()
set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES}) elseif(FFT STREQUAL "MKL")
validate_option(FFT_PACK FFT_PACK_VALUES) find_package(MKL REQUIRED)
if(NOT FFT_PACK STREQUAL "array") target_compile_definitions(lammps PRIVATE -DFFT_MKL)
string(TOUPPER ${FFT_PACK} FFT_PACK) option(FFT_MKL_THREADS "Use threaded MKL FFT" ON)
add_definitions(-DFFT_PACK_${FFT_PACK}) if(FFT_MKL_THREADS)
endif() target_compile_definitions(lammps PRIVATE -DFFT_MKL_THREADS)
endif()
target_link_libraries(lammps PRIVATE MKL::MKL)
else()
# last option is KISSFFT
target_compile_definitions(lammps PRIVATE -DFFT_KISS)
endif()
set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
set(FFT_PACK_VALUES array pointer memcpy)
set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES})
validate_option(FFT_PACK FFT_PACK_VALUES)
if(NOT FFT_PACK STREQUAL "array")
string(TOUPPER ${FFT_PACK} FFT_PACK)
target_compile_definitions(lammps PRIVATE -DFFT_PACK_${FFT_PACK})
endif() endif()

View File

@ -1,38 +1,47 @@
if(PKG_LATTE) enable_language(Fortran)
enable_language(Fortran)
find_package(LATTE) # using lammps in a super-build setting
if(LATTE_FOUND) if(TARGET LATTE::latte)
set(DOWNLOAD_LATTE_DEFAULT OFF) target_link_libraries(lammps PRIVATE LATTE::latte)
else() return()
set(DOWNLOAD_LATTE_DEFAULT ON) endif()
endif()
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT}) find_package(LATTE)
if(DOWNLOAD_LATTE) if(LATTE_FOUND)
if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR set(DOWNLOAD_LATTE_DEFAULT OFF)
message(FATAL_ERROR "For downlading LATTE you need at least cmake-3.7") else()
endif() set(DOWNLOAD_LATTE_DEFAULT ON)
if(CMAKE_GENERATOR STREQUAL "Ninja") endif()
message(FATAL_ERROR "Cannot build downloaded LATTE library with Ninja build tool") option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
endif() if(DOWNLOAD_LATTE)
message(STATUS "LATTE download requested - we will build our own") message(STATUS "LATTE download requested - we will build our own")
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(latte_build ExternalProject_Add(latte_build
URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
URL_MD5 85ac414fdada2d04619c8f936344df14 URL_MD5 85ac414fdada2d04619c8f936344df14
SOURCE_SUBDIR cmake SOURCE_SUBDIR cmake
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC} -DCMAKE_INSTALL_LIBDIR=lib
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES} -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS} -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
-DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
) -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
ExternalProject_get_property(latte_build INSTALL_DIR) BUILD_BYPRODUCTS <INSTALL_DIR>/lib/liblatte.a
set(LATTE_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/liblatte.a) )
list(APPEND LAMMPS_DEPS latte_build) ExternalProject_get_property(latte_build INSTALL_DIR)
else() add_library(LAMMPS::LATTE UNKNOWN IMPORTED)
find_package(LATTE) set_target_properties(LAMMPS::LATTE PROPERTIES
if(NOT LATTE_FOUND) IMPORTED_LOCATION "${INSTALL_DIR}/lib/liblatte.a"
message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it") INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}")
endif() target_link_libraries(lammps PRIVATE LAMMPS::LATTE)
endif() add_dependencies(LAMMPS::LATTE latte_build)
list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES}) if(NOT BUILD_SHARED_LIBS)
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
else()
find_package(LATTE)
if(NOT LATTE_FOUND)
message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
endif()
# latte needs lapack
target_link_libraries(lammps PRIVATE LATTE::latte ${LAPACK_LIBRARIES})
endif() endif()

View File

@ -1,32 +1,35 @@
if(PKG_MESSAGE) if(LAMMPS_SIZES STREQUAL BIGBIG)
if(LAMMPS_SIZES STREQUAL BIGBIG) message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
endif()
option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
add_library(cslib STATIC ${cslib_SOURCES})
if(BUILD_MPI)
target_compile_definitions(cslib PRIVATE -DMPI_YES)
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
else()
target_compile_definitions(cslib PRIVATE -DMPI_NO)
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
endif()
if(MESSAGE_ZMQ)
target_compile_definitions(cslib PRIVATE -DZMQ_YES)
find_package(ZMQ REQUIRED)
target_include_directories(cslib PRIVATE ${ZMQ_INCLUDE_DIRS})
target_link_libraries(cslib PUBLIC ${ZMQ_LIBRARIES})
else()
target_compile_definitions(cslib PRIVATE -DZMQ_NO)
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
endif()
list(APPEND LAMMPS_LINK_LIBS cslib)
include_directories(${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)
endif() endif()
option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
add_library(cslib STATIC ${cslib_SOURCES})
if(NOT BUILD_SHARED_LIBS)
install(TARGETS cslib EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
target_compile_definitions(cslib PRIVATE -DLAMMPS_${LAMMPS_SIZES})
set_target_properties(cslib PROPERTIES OUTPUT_NAME lammps_cslib${LAMMPS_MACHINE})
if(BUILD_MPI)
target_compile_definitions(cslib PRIVATE -DMPI_YES)
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
target_link_libraries(cslib PRIVATE MPI::MPI_CXX)
else()
target_compile_definitions(cslib PRIVATE -DMPI_NO)
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
endif()
if(MESSAGE_ZMQ)
target_compile_definitions(cslib PRIVATE -DZMQ_YES)
find_package(ZMQ REQUIRED)
target_link_libraries(cslib PUBLIC ZMQ::ZMQ)
else()
target_compile_definitions(cslib PRIVATE -DZMQ_NO)
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
endif()
target_link_libraries(lammps PRIVATE cslib)
target_include_directories(lammps PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)

View File

@ -1,45 +1,48 @@
if(PKG_MSCG) find_package(GSL REQUIRED)
find_package(GSL REQUIRED) find_package(MSCG QUIET)
find_package(MSCG QUIET) if(MSGC_FOUND)
if(MSGC_FOUND) set(DOWNLOAD_MSCG_DEFAULT OFF)
set(DOWNLOAD_MSCG_DEFAULT OFF) else()
else() set(DOWNLOAD_MSCG_DEFAULT ON)
set(DOWNLOAD_MSCG_DEFAULT ON)
endif()
option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
if(DOWNLOAD_MSCG)
if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR
message(FATAL_ERROR "For downlading MSCG you need at least cmake-3.7")
endif()
if(CMAKE_GENERATOR STREQUAL "Ninja")
message(FATAL_ERROR "Cannot build downloaded MSCG library with Ninja build tool")
endif()
include(ExternalProject)
if(NOT LAPACK_FOUND)
set(EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a")
endif()
ExternalProject_Add(mscg_build
URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
URL_MD5 8c45e269ee13f60b303edd7823866a91
SOURCE_SUBDIR src/CMake
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS}
BUILD_COMMAND make mscg INSTALL_COMMAND ""
)
ExternalProject_get_property(mscg_build BINARY_DIR)
set(MSCG_LIBRARIES ${BINARY_DIR}/libmscg.a)
ExternalProject_get_property(mscg_build SOURCE_DIR)
set(MSCG_INCLUDE_DIRS ${SOURCE_DIR}/src)
list(APPEND LAMMPS_DEPS mscg_build)
if(NOT LAPACK_FOUND)
file(MAKE_DIRECTORY ${MSCG_INCLUDE_DIRS})
add_dependencies(mscg_build linalg)
endif()
else()
find_package(MSCG)
if(NOT MSCG_FOUND)
message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
endif()
endif()
list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES} ${GSL_LIBRARIES} ${LAPACK_LIBRARIES})
include_directories(${MSCG_INCLUDE_DIRS})
endif() endif()
option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
if(DOWNLOAD_MSCG)
include(ExternalProject)
ExternalProject_Add(mscg_build
URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
URL_MD5 8c45e269ee13f60b303edd7823866a91
SOURCE_SUBDIR src/CMake
CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target mscg
INSTALL_COMMAND ""
BUILD_BYPRODUCTS <BINARY_DIR>/libmscg.a
)
ExternalProject_get_property(mscg_build BINARY_DIR)
ExternalProject_get_property(mscg_build SOURCE_DIR)
file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
add_library(LAMMPS::MSCG UNKNOWN IMPORTED)
set_target_properties(LAMMPS::MSCG PROPERTIES
IMPORTED_LOCATION "${BINARY_DIR}/libmscg.a"
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src"
INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}")
target_link_libraries(lammps PRIVATE LAMMPS::MSCG)
add_dependencies(LAMMPS::MSCG mscg_build)
if(NOT BUILD_SHARED_LIBS)
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
else()
find_package(MSCG)
if(NOT MSCG_FOUND)
message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
endif()
target_link_libraries(lammps PRIVATE MSCG::MSCG)
endif()
target_link_libraries(lammps PRIVATE GSL::gsl ${LAPACK_LIBRARIES})

View File

@ -1,13 +1,11 @@
if(PKG_OPT) set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT)
set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT) set(OPT_SOURCES)
set(OPT_SOURCES) set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}")
set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}")
# detects styles which have OPT version # detects styles which have OPT version
RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES) RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES)
get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES) get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES)
list(APPEND LIB_SOURCES ${OPT_SOURCES}) target_sources(lammps PRIVATE ${OPT_SOURCES})
include_directories(${OPT_SOURCES_DIR}) target_include_directories(lammps PRIVATE ${OPT_SOURCES_DIR})
endif()

View File

@ -1,6 +1,9 @@
if(PKG_PYTHON) if(CMAKE_VERSION VERSION_LESS 3.12)
find_package(PythonLibs REQUIRED) find_package(PythonLibs REQUIRED) # Deprecated since version 3.12
add_definitions(-DLMP_PYTHON) target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIR}) target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARY})
list(APPEND LAMMPS_LINK_LIBS ${PYTHON_LIBRARY}) else()
find_package(Python REQUIRED COMPONENTS Development)
target_link_libraries(lammps PRIVATE Python::Python)
endif() endif()
target_compile_definitions(lammps PRIVATE -DLMP_PYTHON)

View File

@ -1,20 +1,18 @@
# Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed # Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed
if(PKG_QEQ) set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ)
set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ) file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h)
file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h) file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp)
file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp)
if(NOT PKG_MANYBODY) if(NOT PKG_MANYBODY)
list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h) list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h)
list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp) list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp)
endif()
set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}")
foreach(MY_HEADER ${QEQ_HEADERS})
AddStyleHeader(${MY_HEADER} FIX)
endforeach()
get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES)
list(APPEND LIB_SOURCES ${QEQ_SOURCES})
include_directories(${QEQ_SOURCES_DIR})
endif() endif()
set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}")
foreach(MY_HEADER ${QEQ_HEADERS})
AddStyleHeader(${MY_HEADER} FIX)
endforeach()
get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES)
target_sources(lammps PRIVATE ${QEQ_SOURCES})
target_include_directories(lammps PRIVATE ${QEQ_SOURCES_DIR})

View File

@ -1,42 +1,36 @@
if(PKG_USER-COLVARS) set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars)
set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars) file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/[^.]*.cpp)
file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/[^.]*.cpp) # Build Lepton by default
option(COLVARS_LEPTON "Build and link the Lepton library" ON)
# Build Lepton by default if(COLVARS_LEPTON)
set(COLVARS_LEPTON_DEFAULT ON) set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton)
# but not if C++11 is disabled per user request file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp)
if(DEFINED DISABLE_CXX11_REQUIREMENT) add_library(lepton STATIC ${LEPTON_SOURCES})
if(DISABLE_CXX11_REQUIREMENT) if(NOT BUILD_SHARED_LIBS)
set(COLVARS_LEPTON_DEFAULT OFF) install(TARGETS lepton EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif() endif()
# Change the define below to LEPTON_BUILDING_SHARED_LIBRARY when linking Lepton as a DLL with MSVC
option(COLVARS_LEPTON "Build and link the Lepton library" ${COLVARS_LEPTON_DEFAULT}) target_compile_definitions(lepton PRIVATE -DLEPTON_BUILDING_STATIC_LIBRARY)
set_target_properties(lepton PROPERTIES OUTPUT_NAME lammps_lepton${LAMMPS_MACHINE})
# Verify that the user's choice is consistent target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include)
if(DEFINED DISABLE_CXX11_REQUIREMENT) endif()
if((DISABLE_CXX11_REQUIREMENT) AND (COLVARS_LEPTON))
message(FATAL_ERROR "Building the Lepton library requires C++11 or later.") add_library(colvars STATIC ${COLVARS_SOURCES})
endif() if(NOT BUILD_SHARED_LIBS)
endif() install(TARGETS colvars EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(COLVARS_LEPTON) target_compile_definitions(colvars PRIVATE -DLAMMPS_${LAMMPS_SIZES})
set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton) set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE})
file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp) target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
add_library(lepton STATIC ${LEPTON_SOURCES}) target_link_libraries(lammps PRIVATE colvars)
target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include)
endif() if(COLVARS_LEPTON)
target_link_libraries(lammps PRIVATE lepton)
add_library(colvars STATIC ${COLVARS_SOURCES}) target_compile_definitions(colvars PRIVATE -DLEPTON)
target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars) # Disable the line below when linking Lepton as a DLL with MSVC
list(APPEND LAMMPS_LINK_LIBS colvars) target_compile_definitions(colvars PRIVATE -DLEPTON_USE_STATIC_LIBRARIES)
target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include)
if(COLVARS_LEPTON)
list(APPEND LAMMPS_LINK_LIBS lepton)
target_compile_options(colvars PRIVATE -DLEPTON)
target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include)
endif()
endif() endif()

View File

@ -1,8 +1,5 @@
if(PKG_USER-H5MD) enable_language(C)
enable_language(C)
find_package(HDF5 REQUIRED) find_package(HDF5 REQUIRED)
target_link_libraries(h5md ${HDF5_LIBRARIES}) target_link_libraries(h5md PRIVATE ${HDF5_LIBRARIES})
target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS}) target_include_directories(h5md PUBLIC ${HDF5_INCLUDE_DIRS})
include_directories(${HDF5_INCLUDE_DIRS})
endif()

View File

@ -1,118 +1,109 @@
if(PKG_USER-INTEL) check_include_file_cxx(immintrin.h FOUND_IMMINTRIN)
check_include_file_cxx(immintrin.h FOUND_IMMINTRIN) if(NOT FOUND_IMMINTRIN)
if(NOT FOUND_IMMINTRIN) message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")
message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")
endif()
add_definitions(-DLMP_USER_INTEL)
set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)")
set(INTEL_ARCH_VALUES cpu knl)
set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES})
validate_option(INTEL_ARCH INTEL_ARCH_VALUES)
string(TOUPPER ${INTEL_ARCH} INTEL_ARCH)
find_package(Threads QUIET)
if(Threads_FOUND)
set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
else()
set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
endif()
set(INTEL_LRT_VALUES none threads c++11)
set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES})
validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES)
string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE)
if(INTEL_LRT_MODE STREQUAL "THREADS")
if(Threads_FOUND)
add_definitions(-DLMP_INTEL_USELRT)
list(APPEND LAMMPS_LINK_LIBS ${CMAKE_THREAD_LIBS_INIT})
else()
message(FATAL_ERROR "Must have working threads library for Long-range thread support")
endif()
endif()
if(INTEL_LRT_MODE STREQUAL "C++11")
add_definitions(-DLMP_INTEL_USERLRT -DLMP_INTEL_LRT11)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
else()
message(WARNING "USER-INTEL gives best performance with Intel compilers")
endif()
find_package(TBB QUIET)
if(TBB_FOUND)
list(APPEND LAMMPS_LINK_LIBS ${TBB_MALLOC_LIBRARIES})
else()
add_definitions(-DLMP_INTEL_NO_TBB)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries")
endif()
endif()
find_package(MKL QUIET)
if(MKL_FOUND)
add_definitions(-DLMP_USE_MKL_RNG)
list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
else()
message(STATUS "Pair style dpd/intel will be faster with MKL libraries")
endif()
if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256"))
message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform")
endif()
if(INTEL_ARCH STREQUAL "KNL")
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload")
set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"")
add_compile_options(-xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS})
add_definitions(-DLMP_INTEL_OFFLOAD)
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xCOMMON-AVX512")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost")
endif()
include(CheckCXXCompilerFlag)
foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict)
check_cxx_compiler_flag("${__FLAG}" COMPILER_SUPPORTS${_FLAG})
if(COMPILER_SUPPORTS${_FLAG})
add_compile_options(${_FLAG})
endif()
endforeach()
else()
add_compile_options(-O3 -ffast-math)
endif()
endif()
# collect sources
set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL)
set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp
${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp
${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp
${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp
${USER-INTEL_SOURCES_DIR}/npair_intel.cpp)
set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}")
# detect styles which have a USER-INTEL version
RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES)
RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h)
RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h)
RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h)
get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES)
if(PKG_KSPACE)
list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp)
RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h)
endif()
list(APPEND LIB_SOURCES ${USER-INTEL_SOURCES})
include_directories(${USER-INTEL_SOURCES_DIR})
endif() endif()
target_compile_definitions(lammps PRIVATE -DLMP_USER_INTEL)
set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)")
set(INTEL_ARCH_VALUES cpu knl)
set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES})
validate_option(INTEL_ARCH INTEL_ARCH_VALUES)
string(TOUPPER ${INTEL_ARCH} INTEL_ARCH)
find_package(Threads QUIET)
if(Threads_FOUND)
set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
else()
set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
endif()
set(INTEL_LRT_VALUES none threads c++11)
set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES})
validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES)
string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE)
if(INTEL_LRT_MODE STREQUAL "THREADS")
if(Threads_FOUND)
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT)
target_link_libraries(lammps PRIVATE Threads::Threads)
else()
message(FATAL_ERROR "Must have working threads library for Long-range thread support")
endif()
endif()
if(INTEL_LRT_MODE STREQUAL "C++11")
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
else()
message(WARNING "USER-INTEL gives best performance with Intel compilers")
endif()
find_package(TBB_MALLOC QUIET)
if(TBB_MALLOC_FOUND)
target_link_libraries(lammps PRIVATE TBB::TBB_MALLOC)
else()
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_NO_TBB)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries")
endif()
endif()
find_package(MKL QUIET)
if(MKL_FOUND)
target_compile_definitions(lammps PRIVATE -DLMP_USE_MKL_RNG)
target_link_libraries(lammps PRIVATE MKL::MKL)
else()
message(STATUS "Pair style dpd/intel will be faster with MKL libraries")
endif()
if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256"))
message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform")
endif()
if(INTEL_ARCH STREQUAL "KNL")
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload")
set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"")
target_compile_options(lammps PRIVATE -xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS})
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_OFFLOAD)
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
include(CheckCXXCompilerFlag)
foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict)
check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAG})
if(COMPILER_SUPPORTS${_FLAG})
target_compile_options(lammps PRIVATE ${_FLAG})
endif()
endforeach()
endif()
endif()
# collect sources
set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL)
set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp
${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp
${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp
${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp
${USER-INTEL_SOURCES_DIR}/npair_intel.cpp)
set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}")
# detect styles which have a USER-INTEL version
RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES)
RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h)
RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h)
RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h)
get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES)
if(PKG_KSPACE)
list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp)
RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h)
endif()
target_sources(lammps PRIVATE ${USER-INTEL_SOURCES})
target_include_directories(lammps PRIVATE ${USER-INTEL_SOURCES_DIR})

View File

@ -1,14 +1,11 @@
if(PKG_USER-MOLFILE) set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
if (CMAKE_VERSION VERSION_LESS "3.10") # due to INTERFACE without a library add_library(molfile INTERFACE)
message(FATAL_ERROR "For configuring USER-MOLFILE you need CMake 3.10 or later") if(NOT BUILD_SHARED_LIBS)
endif() install(TARGETS molfile EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
add_library(molfile INTERFACE)
target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
# no need to link with -ldl on windows
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS})
endif()
list(APPEND LAMMPS_LINK_LIBS molfile)
endif() endif()
target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
# no need to link with -ldl on windows
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS})
endif()
target_link_libraries(lammps PRIVATE molfile)

View File

@ -1,6 +1,20 @@
if(PKG_USER-NETCDF) # USER-NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary.
find_package(NetCDF REQUIRED) # NetCDF library enables dump style "netcdf", while PNetCDF enables dump style "netcdf/mpiio"
include_directories(${NETCDF_INCLUDE_DIRS}) find_package(NetCDF)
list(APPEND LAMMPS_LINK_LIBS ${NETCDF_LIBRARIES}) if(NETCDF_FOUND)
add_definitions(-DLMP_HAS_NETCDF -DNC_64BIT_DATA=0x0020) find_package(PNetCDF)
endif() else(NETCDF_FOUND)
find_package(PNetCDF REQUIRED)
endif(NETCDF_FOUND)
if(NETCDF_FOUND)
target_link_libraries(lammps PRIVATE NetCDF::NetCDF)
target_compile_definitions(lammps PRIVATE -DLMP_HAS_NETCDF)
endif(NETCDF_FOUND)
if(PNETCDF_FOUND)
target_link_libraries(lammps PRIVATE PNetCDF::PNetCDF)
target_compile_definitions(lammps PRIVATE -DLMP_HAS_PNETCDF)
endif(PNETCDF_FOUND)
target_compile_definitions(lammps PRIVATE -DNC_64BIT_DATA=0x0020)

View File

@ -1,42 +1,40 @@
if(PKG_USER-OMP) set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP)
set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP) set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp
set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp ${USER-OMP_SOURCES_DIR}/thr_omp.cpp
${USER-OMP_SOURCES_DIR}/thr_omp.cpp ${USER-OMP_SOURCES_DIR}/fix_omp.cpp
${USER-OMP_SOURCES_DIR}/fix_omp.cpp ${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp
${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp ${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp
${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp ${USER-OMP_SOURCES_DIR}/domain_omp.cpp)
${USER-OMP_SOURCES_DIR}/domain_omp.cpp) target_compile_definitions(lammps PRIVATE -DLMP_USER_OMP)
add_definitions(-DLMP_USER_OMP) set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}")
set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}")
# detects styles which have USER-OMP version # detects styles which have USER-OMP version
RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES) RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES)
RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h) RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h)
get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES) get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES)
# manually add package dependent source files from USER-OMP that do not provide styles # manually add package dependent source files from USER-OMP that do not provide styles
if(PKG_ASPHERE) if(PKG_ASPHERE)
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp) list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp)
endif() endif()
if(PKG_RIGID) if(PKG_RIGID)
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp) list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp)
endif() endif()
if(PKG_USER-REAXC) if(PKG_USER-REAXC)
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp ${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp
${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp) ${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp)
endif() endif()
list(APPEND LIB_SOURCES ${USER-OMP_SOURCES}) target_sources(lammps PRIVATE ${USER-OMP_SOURCES})
include_directories(${USER-OMP_SOURCES_DIR}) target_include_directories(lammps PRIVATE ${USER-OMP_SOURCES_DIR})
endif()

View File

@ -1,91 +1,101 @@
if(PKG_USER-PLUMED) set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library") set(PLUMED_MODE_VALUES static shared runtime)
set(PLUMED_MODE_VALUES static shared runtime) set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES}) validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
validate_option(PLUMED_MODE PLUMED_MODE_VALUES) string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
set(PLUMED_LINK_LIBS "") set(PLUMED_LINK_LIBS)
if(PLUMED_MODE STREQUAL "STATIC") if(PLUMED_MODE STREQUAL "STATIC")
find_package(LAPACK REQUIRED) find_package(LAPACK REQUIRED)
find_package(BLAS REQUIRED) find_package(BLAS REQUIRED)
find_package(GSL REQUIRED) find_package(GSL REQUIRED)
list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES}) list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} GSL::gsl)
list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${GSL_LIBRARIES}) find_package(ZLIB QUIET)
find_package(ZLIB QUIET) if(ZLIB_FOUND)
if(ZLIB_FOUND) list(APPEND PLUMED_LINK_LIBS ZLIB::ZLIB)
list(APPEND PLUMED_LINK_LIBS ${ZLIB_LIBRARIES})
endif()
endif() endif()
find_package(FFTW3 QUIET)
find_package(PkgConfig QUIET) if(FFTW3_FOUND)
set(DOWNLOAD_PLUMED_DEFAULT ON) list(APPEND PLUMED_LINK_LIBS FFTW3::FFTW3)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PLUMED QUIET plumed)
if(PLUMED_FOUND)
set(DOWNLOAD_PLUMED_DEFAULT OFF)
endif()
endif() endif()
option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
if(DOWNLOAD_PLUMED)
if(CMAKE_GENERATOR STREQUAL "Ninja")
message(FATAL_ERROR "Cannot build downloaded Plumed library with Ninja build tool")
endif()
if(BUILD_MPI)
set(PLUMED_CONFIG_MPI "--enable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
else()
set(PLUMED_CONFIG_MPI "--disable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
endif()
if(BUILD_OMP)
set(PLUMED_CONFIG_OMP "--enable-openmp")
else()
set(PLUMED_CONFIG_OMP "--disable-openmp")
endif()
message(STATUS "PLUMED download requested - we will build our own")
include(ExternalProject)
ExternalProject_Add(plumed_build
URL https://github.com/plumed/plumed2/releases/download/v2.5.3/plumed-src-2.5.3.tgz
URL_MD5 de30d6e7c2dcc0973298e24a6da24286
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
${CONFIGURE_REQUEST_PIC}
--enable-modules=all
${PLUMED_CONFIG_MPI}
${PLUMED_CONFIG_OMP}
CXX=${PLUMED_CONFIG_CXX}
CC=${PLUMED_CONFIG_CC}
)
ExternalProject_get_property(plumed_build INSTALL_DIR)
set(PLUMED_INSTALL_DIR ${INSTALL_DIR})
list(APPEND LAMMPS_DEPS plumed_build)
if(PLUMED_MODE STREQUAL "STATIC")
add_definitions(-D__PLUMED_WRAPPER_CXX=1)
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.a ${PLUMED_LINK_LIBS} ${CMAKE_DL_LIBS})
elseif(PLUMED_MODE STREQUAL "SHARED")
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} ${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_DL_LIBS})
elseif(PLUMED_MODE STREQUAL "RUNTIME")
add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS})
endif()
set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PLUMED REQUIRED plumed)
if(PLUMED_MODE STREQUAL "STATIC")
add_definitions(-D__PLUMED_WRAPPER_CXX=1)
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
elseif(PLUMED_MODE STREQUAL "SHARED")
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
elseif(PLUMED_MODE STREQUAL "RUNTIME")
add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
endif()
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD})
endif()
include_directories(${PLUMED_INCLUDE_DIRS})
endif() endif()
find_package(PkgConfig QUIET)
set(DOWNLOAD_PLUMED_DEFAULT ON)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PLUMED QUIET plumed)
if(PLUMED_FOUND)
set(DOWNLOAD_PLUMED_DEFAULT OFF)
endif()
endif()
option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
if(DOWNLOAD_PLUMED)
if(BUILD_MPI)
set(PLUMED_CONFIG_MPI "--enable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
else()
set(PLUMED_CONFIG_MPI "--disable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
endif()
if(BUILD_OMP)
set(PLUMED_CONFIG_OMP "--enable-openmp")
else()
set(PLUMED_CONFIG_OMP "--disable-openmp")
endif()
message(STATUS "PLUMED download requested - we will build our own")
if(PLUMED_MODE STREQUAL "STATIC")
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumed.a")
elseif(PLUMED_MODE STREQUAL "SHARED")
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX};<INSTALL_DIR>/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
elseif(PLUMED_MODE STREQUAL "RUNTIME")
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumedWrapper.a")
endif()
include(ExternalProject)
ExternalProject_Add(plumed_build
URL https://github.com/plumed/plumed2/releases/download/v2.6.0/plumed-src-2.6.0.tgz
URL_MD5 204d2edae58d9b10ba3ad460cad64191
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
${CONFIGURE_REQUEST_PIC}
--enable-modules=all
${PLUMED_CONFIG_MPI}
${PLUMED_CONFIG_OMP}
CXX=${PLUMED_CONFIG_CXX}
CC=${PLUMED_CONFIG_CC}
BUILD_BYPRODUCTS ${PLUMED_BUILD_BYPRODUCTS}
)
ExternalProject_get_property(plumed_build INSTALL_DIR)
add_library(LAMMPS::PLUMED UNKNOWN IMPORTED)
add_dependencies(LAMMPS::PLUMED plumed_build)
if(NOT BUILD_SHARED_LIBS)
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
if(PLUMED_MODE STREQUAL "STATIC")
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed.a INTERFACE_LINK_LIBRARIES "${PLUMED_LINK_LIBS};${CMAKE_DL_LIBS}")
elseif(PLUMED_MODE STREQUAL "SHARED")
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX};${CMAKE_DL_LIBS}")
elseif(PLUMED_MODE STREQUAL "RUNTIME")
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_DEFAULT_KERNEL=${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumedWrapper.a INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
endif()
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PLUMED REQUIRED plumed)
add_library(LAMMPS::PLUMED INTERFACE IMPORTED)
if(PLUMED_MODE STREQUAL "STATIC")
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
elseif(PLUMED_MODE STREQUAL "SHARED")
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
elseif(PLUMED_MODE STREQUAL "RUNTIME")
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
endif()
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}")
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}")
endif()
target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)

View File

@ -1,9 +1,12 @@
if(PKG_USER-QMMM) enable_language(C)
enable_language(Fortran)
enable_language(C)
message(WARNING "Building QMMM with CMake is still experimental") if(NOT BUILD_SHARED_LIBS)
find_package(QE REQUIRED) message(WARNING "It is recommended to use BUILD_SHARED_LIBS=yes with USER-QMMM")
include_directories(${QE_INCLUDE_DIRS})
list(APPEND LAMMPS_LINK_LIBS ${QE_LIBRARIES})
endif() endif()
add_library(qmmm STATIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm/libqmmm.c)
if(NOT BUILD_SHARED_LIBS)
install(TARGETS qmmm EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_target_properties(qmmm PROPERTIES OUTPUT_NAME lammps_qmmm${LAMMPS_MACHINE})
target_link_libraries(lammps PRIVATE qmmm)
target_include_directories(qmmm PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm)

View File

@ -1,5 +1,3 @@
if(PKG_USER-QUIP) enable_language(Fortran)
enable_language(Fortran) find_package(QUIP REQUIRED)
find_package(QUIP REQUIRED) target_link_libraries(lammps PRIVATE QUIP::QUIP ${LAPACK_LIBRARIES})
list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${LAPACK_LIBRARIES})
endif()

View File

@ -1,62 +1,62 @@
if(PKG_USER-SCAFACOS) enable_language(Fortran)
enable_language(Fortran) enable_language(C)
enable_language(C)
find_package(GSL REQUIRED) find_package(GSL REQUIRED)
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
set(DOWNLOAD_SCAFACOS_DEFAULT ON) find_package(MPI REQUIRED)
if(PKG_CONFIG_FOUND) set(DOWNLOAD_SCAFACOS_DEFAULT ON)
pkg_check_modules(SCAFACOS QUIET scafacos) if(PKG_CONFIG_FOUND)
if(SCAFACOS_FOUND) pkg_check_modules(SCAFACOS QUIET scafacos)
set(DOWNLOAD_SCAFACOS_DEFAULT OFF) if(SCAFACOS_FOUND)
endif() set(DOWNLOAD_SCAFACOS_DEFAULT OFF)
endif() endif()
option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT}) endif()
if(DOWNLOAD_SCAFACOS) option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT})
if(CMAKE_GENERATOR STREQUAL "Ninja") if(DOWNLOAD_SCAFACOS)
message(FATAL_ERROR "Cannot build downloaded ScaFaCoS library with Ninja build tool") message(STATUS "ScaFaCoS download requested - we will build our own")
endif() include(ExternalProject)
message(STATUS "ScaFaCoS download requested - we will build our own") ExternalProject_Add(scafacos_build
include(ExternalProject) URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz
ExternalProject_Add(scafacos_build URL_MD5 bd46d74e3296bd8a444d731bb10c1738
URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-doc
URL_MD5 bd46d74e3296bd8a444d731bb10c1738 --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-doc --with-internal-fftw --with-internal-pfft
--enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m --with-internal-pnfft ${CONFIGURE_REQUEST_PIC}
--with-internal-fftw --with-internal-pfft FC=${CMAKE_MPI_Fortran_COMPILER}
--with-internal-pnfft ${CONFIGURE_REQUEST_PIC} CXX=${CMAKE_MPI_CXX_COMPILER}
FC=${CMAKE_MPI_Fortran_COMPILER} CC=${CMAKE_MPI_C_COMPILER}
CXX=${CMAKE_MPI_CXX_COMPILER} F77=
CC=${CMAKE_MPI_C_COMPILER} BUILD_BYPRODUCTS
F77= <INSTALL_DIR>/lib/libfcs.a
) <INSTALL_DIR>/lib/libfcs_direct.a
ExternalProject_get_property(scafacos_build INSTALL_DIR) <INSTALL_DIR>/lib/libfcs_ewald.a
set(SCAFACOS_BUILD_DIR ${INSTALL_DIR}) <INSTALL_DIR>/lib/libfcs_fmm.a
set(SCAFACOS_INCLUDE_DIRS ${SCAFACOS_BUILD_DIR}/include) <INSTALL_DIR>/lib/libfcs_p2nfft.a
list(APPEND LAMMPS_DEPS scafacos_build) <INSTALL_DIR>/lib/libfcs_p3m.a
# list and order from pkg_config file of ScaFaCoS build <INSTALL_DIR>/lib/libfcs_near.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs.a) <INSTALL_DIR>/lib/libfcs_gridsort.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_direct.a) <INSTALL_DIR>/lib/libfcs_resort.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_ewald.a) <INSTALL_DIR>/lib/libfcs_redist.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fmm.a) <INSTALL_DIR>/lib/libfcs_common.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p2nfft.a) <INSTALL_DIR>/lib/libfcs_pnfft.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p3m.a) <INSTALL_DIR>/lib/libfcs_pfft.a
list(APPEND LAMMPS_LINK_LIBS ${GSL_LIBRARIES}) <INSTALL_DIR>/lib/libfcs_fftw3_mpi.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_near.a) <INSTALL_DIR>/lib/libfcs_fftw3.a
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_gridsort.a) )
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_resort.a) ExternalProject_get_property(scafacos_build INSTALL_DIR)
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_redist.a) file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_common.a) add_library(LAMMPS::SCAFACOS UNKNOWN IMPORTED)
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pnfft.a) set_target_properties(LAMMPS::SCAFACOS PROPERTIES
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pfft.a) IMPORTED_LOCATION "${INSTALL_DIR}/lib/libfcs.a"
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3_mpi.a) INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3.a) INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libfcs.a;${INSTALL_DIR}/lib/libfcs_direct.a;${INSTALL_DIR}/lib/libfcs_ewald.a;${INSTALL_DIR}/lib/libfcs_fmm.a;${INSTALL_DIR}/lib/libfcs_p2nfft.a;${INSTALL_DIR}/lib/libfcs_p3m.a;GSL::gsl;${INSTALL_DIR}/lib/libfcs_near.a;${INSTALL_DIR}/lib/libfcs_gridsort.a;${INSTALL_DIR}/lib/libfcs_resort.a;${INSTALL_DIR}/lib/libfcs_redist.a;${INSTALL_DIR}/lib/libfcs_common.a;${INSTALL_DIR}/lib/libfcs_pnfft.a;${INSTALL_DIR}/lib/libfcs_pfft.a;${INSTALL_DIR}/lib/libfcs_fftw3_mpi.a;${INSTALL_DIR}/lib/libfcs_fftw3.a;MPI::MPI_Fortran;MPI::MPI_C")
list(APPEND LAMMPS_LINK_LIBS ${MPI_Fortran_LIBRARIES}) target_link_libraries(lammps PRIVATE LAMMPS::SCAFACOS)
list(APPEND LAMMPS_LINK_LIBS ${MPI_C_LIBRARIES}) add_dependencies(LAMMPS::SCAFACOS scafacos_build)
else() if(NOT BUILD_SHARED_LIBS)
find_package(PkgConfig REQUIRED) install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
pkg_check_modules(SCAFACOS REQUIRED scafacos) endif()
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_LDFLAGS}) else()
endif() find_package(PkgConfig REQUIRED)
include_directories(${SCAFACOS_INCLUDE_DIRS}) pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos)
target_link_libraries(lammps PRIVATE PkgConfig::SCAFACOS)
endif() endif()

View File

@ -1,13 +1,13 @@
# Fix rigid/meso requires RIGID to be installed # Fix rigid/meso requires RIGID to be installed
if(PKG_USER-SDPD) set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
get_property(hlist GLOBAL PROPERTY FIX) get_property(hlist GLOBAL PROPERTY FIX)
if(NOT PKG_RIGID) if(NOT PKG_RIGID)
list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h) list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h)
list(REMOVE_ITEM LIB_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp) get_target_property(LAMMPS_SOURCES lammps SOURCES)
endif() list(REMOVE_ITEM LAMMPS_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp)
set_property(GLOBAL PROPERTY FIX "${hlist}") set_property(TARGET lammps PROPERTY SOURCES ${LAMMPS_SOURCES})
include_directories(${USER-SDPD_SOURCES_DIR})
endif() endif()
set_property(GLOBAL PROPERTY FIX "${hlist}")
target_include_directories(lammps PRIVATE ${USER-SDPD_SOURCES_DIR})

View File

@ -1,28 +1,31 @@
if(PKG_USER-SMD) find_package(Eigen3 NO_MODULE)
find_package(Eigen3 NO_MODULE) if(EIGEN3_FOUND)
if(EIGEN3_FOUND) set(DOWNLOAD_EIGEN3_DEFAULT OFF)
set(DOWNLOAD_EIGEN3_DEFAULT OFF) else()
else() set(DOWNLOAD_EIGEN3_DEFAULT ON)
set(DOWNLOAD_EIGEN3_DEFAULT ON) endif()
endif() option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT})
option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT}) if(DOWNLOAD_EIGEN3)
if(DOWNLOAD_EIGEN3) message(STATUS "Eigen3 download requested - we will build our own")
message(STATUS "Eigen3 download requested - we will build our own") include(ExternalProject)
include(ExternalProject) ExternalProject_Add(Eigen3_build
ExternalProject_Add(Eigen3_build URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz
URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07
URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07 CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" )
) ExternalProject_get_property(Eigen3_build SOURCE_DIR)
ExternalProject_get_property(Eigen3_build SOURCE_DIR) add_library(LAMMPS::EIGEN3 INTERFACE IMPORTED)
set(EIGEN3_INCLUDE_DIR ${SOURCE_DIR}) set_target_properties(LAMMPS::EIGEN3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}")
list(APPEND LAMMPS_DEPS Eigen3_build) target_link_libraries(lammps PRIVATE LAMMPS::EIGEN3)
else() add_dependencies(LAMMPS::EIGEN3 Eigen3_build)
find_package(Eigen3 NO_MODULE) if(NOT BUILD_SHARED_LIBS)
mark_as_advanced(Eigen3_DIR) install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
if(NOT EIGEN3_FOUND) endif()
message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it") else()
endif() find_package(Eigen3 NO_MODULE)
endif() mark_as_advanced(Eigen3_DIR)
include_directories(${EIGEN3_INCLUDE_DIR}) if(NOT EIGEN3_FOUND)
message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it")
endif()
target_link_libraries(lammps PRIVATE Eigen3::Eigen)
endif() endif()

View File

@ -1,6 +1,4 @@
if(PKG_USER-VTK) find_package(VTK REQUIRED NO_MODULE)
find_package(VTK REQUIRED NO_MODULE) include(${VTK_USE_FILE})
include(${VTK_USE_FILE}) target_compile_definitions(lammps PRIVATE -DLAMMPS_VTK)
add_definitions(-DLAMMPS_VTK) target_link_libraries(lammps PRIVATE ${VTK_LIBRARIES})
list(APPEND LAMMPS_LINK_LIBS ${VTK_LIBRARIES})
endif()

View File

@ -1,45 +1,47 @@
if(PKG_VORONOI) find_package(VORO)
find_package(VORO) if(VORO_FOUND)
if(VORO_FOUND) set(DOWNLOAD_VORO_DEFAULT OFF)
set(DOWNLOAD_VORO_DEFAULT OFF) else()
else() set(DOWNLOAD_VORO_DEFAULT ON)
set(DOWNLOAD_VORO_DEFAULT ON) endif()
endif() option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT})
option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT}) if(DOWNLOAD_VORO)
if(DOWNLOAD_VORO) message(STATUS "Voro++ download requested - we will build our own")
if(CMAKE_GENERATOR STREQUAL "Ninja") include(ExternalProject)
message(FATAL_ERROR "Cannot build downloaded Voro++ library with Ninja build tool")
endif() if(BUILD_SHARED_LIBS)
message(STATUS "Voro++ download requested - we will build our own") set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
include(ExternalProject) else()
set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
if(BUILD_SHARED_LIBS) endif()
set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") if(APPLE)
else() get_filename_component(VORO_CXX ${CMAKE_CXX_COMPILER} NAME_WE)
set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") set(VORO_BUILD_OPTIONS CXX=${VORO_CXX} CFLAGS=${VORO_BUILD_CFLAGS})
endif() else()
if(APPLE) set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS})
get_filename_component(VORO_CXX ${CMAKE_CXX_COMPILER} NAME_WE) endif()
set(VORO_BUILD_OPTIONS CXX=${VORO_CXX} CFLAGS=${VORO_BUILD_CFLAGS})
else() ExternalProject_Add(voro_build
set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS}) URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
endif() URL_MD5 2338b824c3b7b25590e18e8df5d68af9
CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND ""
ExternalProject_Add(voro_build BUILD_BYPRODUCTS <SOURCE_DIR>/src/libvoro++.a
URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz )
URL_MD5 2338b824c3b7b25590e18e8df5d68af9 ExternalProject_get_property(voro_build SOURCE_DIR)
CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND "" file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
) add_library(LAMMPS::VORO UNKNOWN IMPORTED)
ExternalProject_get_property(voro_build SOURCE_DIR) set_target_properties(LAMMPS::VORO PROPERTIES
set(VORO_LIBRARIES ${SOURCE_DIR}/src/libvoro++.a) IMPORTED_LOCATION "${SOURCE_DIR}/src/libvoro++.a"
set(VORO_INCLUDE_DIRS ${SOURCE_DIR}/src) INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src")
list(APPEND LAMMPS_DEPS voro_build) target_link_libraries(lammps PRIVATE LAMMPS::VORO)
else() add_dependencies(LAMMPS::VORO voro_build)
find_package(VORO) if(NOT BUILD_SHARED_LIBS)
if(NOT VORO_FOUND) install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it") endif()
endif() else()
endif() find_package(VORO)
include_directories(${VORO_INCLUDE_DIRS}) if(NOT VORO_FOUND)
list(APPEND LAMMPS_LINK_LIBS ${VORO_LIBRARIES}) message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
endif()
target_link_libraries(lammps PRIVATE VORO::VORO)
endif() endif()

View File

@ -2,7 +2,7 @@
# Testing # Testing
############################################################################### ###############################################################################
option(ENABLE_TESTING "Enable testing" OFF) option(ENABLE_TESTING "Enable testing" OFF)
if(ENABLE_TESTING AND BUILD_EXE) if(ENABLE_TESTING)
enable_testing() enable_testing()
option(LAMMPS_TESTING_SOURCE_DIR "Location of lammps-testing source directory" "") option(LAMMPS_TESTING_SOURCE_DIR "Location of lammps-testing source directory" "")
option(LAMMPS_TESTING_GIT_TAG "Git tag of lammps-testing" "master") option(LAMMPS_TESTING_GIT_TAG "Git tag of lammps-testing" "master")
@ -28,7 +28,7 @@ if(ENABLE_TESTING AND BUILD_EXE)
"https://github.com/lammps/lammps-testing in LAMMPS_TESTING_SOURCE_DIR") "https://github.com/lammps/lammps-testing in LAMMPS_TESTING_SOURCE_DIR")
endif() endif()
add_test(ShowHelp ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -help) add_test(NAME ShowHelp COMMAND $<TARGET_FILE:lmp> -help)
if(EXISTS ${LAMMPS_TESTING_SOURCE_DIR}) if(EXISTS ${LAMMPS_TESTING_SOURCE_DIR})
message(STATUS "Running test discovery...") message(STATUS "Running test discovery...")
@ -42,8 +42,7 @@ if(ENABLE_TESTING AND BUILD_EXE)
string(REPLACE "-" "_" TEST_NAME ${TEST_NAME}) string(REPLACE "-" "_" TEST_NAME ${TEST_NAME})
string(REPLACE "+" "_" TEST_NAME ${TEST_NAME}) string(REPLACE "+" "_" TEST_NAME ${TEST_NAME})
set(TEST_NAME "test_core_${TEST_NAME}_serial") set(TEST_NAME "test_core_${TEST_NAME}_serial")
add_test(${TEST_NAME} ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -in ${SCRIPT_NAME}) add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:lmp> -in ${SCRIPT_NAME} WORKING_DIRECTORY ${PARENT_DIR})
set_tests_properties(${TEST_NAME} PROPERTIES WORKING_DIRECTORY ${PARENT_DIR})
endforeach() endforeach()
list(LENGTH TEST_SCRIPTS NUM_TESTS) list(LENGTH TEST_SCRIPTS NUM_TESTS)

File diff suppressed because it is too large Load Diff

View File

@ -18,12 +18,6 @@
# myapp_CFLAGS = $(LAMMPS_CFLAGS) # myapp_CFLAGS = $(LAMMPS_CFLAGS)
# myapp_LDADD = $(LAMMPS_LIBS) # myapp_LDADD = $(LAMMPS_LIBS)
# Use this in CMake:
# CMakeLists.txt:
# find_package(PkgConfig)
# pkg_check_modules(LAMMPS IMPORTED_TARGET lammps)
# target_link_libraries(<lib> PkgConfig::LAMMPS)
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
@ -31,8 +25,8 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: liblammps@LAMMPS_MACHINE@ Name: liblammps@LAMMPS_MACHINE@
Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library
URL: http://lammps.sandia.gov URL: http://lammps.sandia.gov
Version: @LAMMPS_VERSION@ Version: @PROJECT_VERSION@
Requires: Requires:
Libs: -L${libdir} -llammps@LAMMPS_LIB_SUFFIX@ Libs: -L${libdir} -llammps@LAMMPS_MACHINE@
Libs.private: -lm Libs.private: -lm
Cflags: -I${includedir} @LAMMPS_API_DEFINES@ Cflags: -I${includedir} @LAMMPS_API_DEFINES@

View File

@ -7,11 +7,11 @@ set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU
SRD VORONOI SRD VORONOI
USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK
USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP
USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP
USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP
USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ
USER-TALLY USER-UEF USER-VTK USER-YAFF) USER-SPH USER-TALLY USER-UEF USER-VTK USER-YAFF)
foreach(PKG ${ALL_PACKAGES}) foreach(PKG ${ALL_PACKAGES})
set(PKG_${PKG} OFF CACHE BOOL "" FORCE) set(PKG_${PKG} OFF CACHE BOOL "" FORCE)

View File

@ -9,11 +9,11 @@ set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU
SRD VORONOI SRD VORONOI
USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK
USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP
USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP
USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP
USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ
USER-TALLY USER-UEF USER-VTK USER-YAFF) USER-SPH USER-TALLY USER-UEF USER-VTK USER-YAFF)
foreach(PKG ${ALL_PACKAGES}) foreach(PKG ${ALL_PACKAGES})
set(PKG_${PKG} ON CACHE BOOL "" FORCE) set(PKG_${PKG} ON CACHE BOOL "" FORCE)

View File

@ -2,7 +2,7 @@
set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBG" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(MPI_CXX "clang++" CACHE STRING "" FORCE) set(MPI_CXX "clang++" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE) unset(HAVE_OMP_H_INCLUDE CACHE)
@ -13,5 +13,5 @@ set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_CXX "clang++" CACHE STRING "" FORCE) set(OpenMP_CXX "clang++" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE) set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "/usr/lib64/libomp.so" CACHE PATH "" FORCE) set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE)

12
cmake/presets/hip.cmake Normal file
View File

@ -0,0 +1,12 @@
# preset that will enable hipcc plus gcc with support for MPI and OpenMP (on Linux boxes)
set(CMAKE_CXX_COMPILER "hipcc" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "gcc" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_CXX "hipcc" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE)

16
cmake/presets/intel.cmake Normal file
View File

@ -0,0 +1,16 @@
# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes)
set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE)
set(MPI_CXX "icpc" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
set(OpenMP_C "icc" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_CXX "icpc" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE)

View File

@ -0,0 +1,11 @@
# preset that enables KOKKOS and selects CUDA compilation with OpenMP
# enabled as well. This preselects CC 5.0 as default GPU arch, since
# that is compatible with all higher CC, but not the default CC 3.5
set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE)
set(Kokkos_ARCH_MAXWELL50 on CACHE BOOL "" FORCE)
set(BUILD_OMP ON CACHE BOOL "" FORCE)
get_filename_component(NVCC_WRAPPER_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../lib/kokkos/bin/nvcc_wrapper ABSOLUTE)
set(CMAKE_CXX_COMPILER ${NVCC_WRAPPER_CMD} CACHE FILEPATH "" FORCE)

View File

@ -0,0 +1,6 @@
# preset that enables KOKKOS and selects OpenMP (only) compilation
set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "" FORCE)
set(BUILD_OMP ON CACHE BOOL "" FORCE)

View File

@ -0,0 +1,5 @@
# preset that enables KOKKOS and selects serial compilation only
set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_OPENMP OFF CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "" FORCE)

View File

@ -1,17 +1,29 @@
set(WIN_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU set(WIN_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU
GRANULAR KSPACE MANYBODY MC MISC MOLECULE OPT PERI POEMS QEQ GRANULAR KSPACE LATTE MANYBODY MC MISC MOLECULE OPT PERI
REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI USER-ATC USER-AWPMD POEMS QEQ REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI
USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK
USER-DPD USER-DRUDE USER-EFF USER-FEP USER-INTEL USER-MANIFOLD USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF
USER-MEAMC USER-MESO USER-MISC USER-MGPT USER-MOFFF USER-MOLFILE USER-FEP USER-INTEL USER-MANIFOLD USER-MEAMC USER-MESODPD
USER-OMP USER-PHONON USER-PTM USER-QTB USER-REAXC USER-SDPD USER-MISC USER-MGPT USER-MOFFF USER-MOLFILE USER-OMP
USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-YAFF) USER-PHONON USER-PTM USER-QTB USER-REACTION USER-REAXC
USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF
USER-YAFF)
foreach(PKG ${WIN_PACKAGES}) foreach(PKG ${WIN_PACKAGES})
set(PKG_${PKG} ON CACHE BOOL "" FORCE) set(PKG_${PKG} ON CACHE BOOL "" FORCE)
endforeach() endforeach()
# these two packages require a full MPI implementation
if(BUILD_MPI)
set(PKG_MPIIO ON CACHE BOOL "" FORCE)
set(PKG_USER-LB ON CACHE BOOL "" FORCE)
endif()
set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE) set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE)
set(DOWNLOAD_EIGEN3 ON CACHE BOOL "" FORCE) set(DOWNLOAD_EIGEN3 ON CACHE BOOL "" FORCE)
set(LAMMPS_MEMALIGN "0" CACHE STRING "" FORCE) set(LAMMPS_MEMALIGN "0" CACHE STRING "" FORCE)
set(CMAKE_TUNE_FLAGS "-Wno-missing-include-dirs" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-stdcall-fixup" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-stdcall-fixup" CACHE STRING "" FORCE)
set(BUILD_TOOLS ON CACHE BOOL "" FORCE)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lammps-installer") set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lammps-installer")

View File

@ -2,14 +2,16 @@
# external libraries. Compared to all_on.cmake some more unusual packages # external libraries. Compared to all_on.cmake some more unusual packages
# are removed. The resulting binary should be able to run most inputs. # are removed. The resulting binary should be able to run most inputs.
set(ALL_PACKAGES ASPHERE CLASS2 COLLOID CORESHELL DIPOLE set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL
GRANULAR KSPACE MANYBODY MC MISC MOLECULE OPT PERI DIPOLE GRANULAR KSPACE MANYBODY MC MISC MOLECULE OPT PERI
PYTHON QEQ REPLICA RIGID SHOCK SNAP SRD VORONOI POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI
USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION
USER-DRUDE USER-FEP USER-MEAMC USER-MESO USER-DPD USER-DRUDE USER-FEP USER-MEAMC USER-MESODPD
USER-MISC USER-MOFFF USER-OMP USER-PHONON USER-REAXC USER-MISC USER-MOFFF USER-OMP USER-PHONON USER-REACTION
USER-SPH USER-SMD USER-UEF USER-YAFF) USER-REAXC USER-SPH USER-SMD USER-UEF USER-YAFF)
foreach(PKG ${ALL_PACKAGES}) foreach(PKG ${ALL_PACKAGES})
set(PKG_${PKG} ON CACHE BOOL "" FORCE) set(PKG_${PKG} ON CACHE BOOL "" FORCE)
endforeach() endforeach()
set(BUILD_TOOLS ON CACHE BOOL "" FORCE)

2
doc/.gitignore vendored
View File

@ -1,6 +1,8 @@
/old /old
/html /html
/html-offline
/latex /latex
/mathjax
/spelling /spelling
/LAMMPS.epub /LAMMPS.epub
/LAMMPS.mobi /LAMMPS.mobi

View File

@ -3,8 +3,8 @@
SHELL = /bin/bash SHELL = /bin/bash
BUILDDIR = ${CURDIR} BUILDDIR = ${CURDIR}
RSTDIR = $(BUILDDIR)/src RSTDIR = $(BUILDDIR)/src
TXTDIR = $(BUILDDIR)/txt
VENV = $(BUILDDIR)/docenv VENV = $(BUILDDIR)/docenv
MATHJAX = $(BUILDDIR)/mathjax
TXT2RST = $(VENV)/bin/txt2rst TXT2RST = $(VENV)/bin/txt2rst
ANCHORCHECK = $(VENV)/bin/rst_anchor_check ANCHORCHECK = $(VENV)/bin/rst_anchor_check
@ -12,6 +12,7 @@ PYTHON = $(shell which python3)
VIRTUALENV = virtualenv VIRTUALENV = virtualenv
HAS_PYTHON3 = NO HAS_PYTHON3 = NO
HAS_VIRTUALENV = NO HAS_VIRTUALENV = NO
HAS_PDFLATEX = NO
ifeq ($(shell which python3 >/dev/null 2>&1; echo $$?), 0) ifeq ($(shell which python3 >/dev/null 2>&1; echo $$?), 0)
HAS_PYTHON3 = YES HAS_PYTHON3 = YES
@ -27,74 +28,77 @@ VIRTUALENV = virtualenv
HAS_VIRTUALENV = YES HAS_VIRTUALENV = YES
endif endif
SPHINXEXTRA = -j $(shell $(PYTHON) -c 'import multiprocessing;print(multiprocessing.cpu_count())') ifeq ($(shell which pdflatex >/dev/null 2>&1; echo $$?), 0)
SOURCES=$(filter-out $(wildcard $(TXTDIR)/lammps_commands*.txt) $(TXTDIR)/lammps_support.txt $(TXTDIR)/lammps_tutorials.txt,$(wildcard $(TXTDIR)/*.txt)) HAS_PDFLATEX = YES
OBJECTS=$(SOURCES:$(TXTDIR)/%.txt=$(RSTDIR)/%.rst) endif
.PHONY: help clean-all clean epub mobi rst html pdf venv spelling anchor_check
SPHINXEXTRA = -j $(shell $(PYTHON) -c 'import multiprocessing;print(multiprocessing.cpu_count())')
.PHONY: help clean-all clean clean-spelling epub mobi rst html pdf spelling anchor_check style_check
# ------------------------------------------ # ------------------------------------------
help: help:
@echo "Please use \`make <target>' where <target> is one of" @echo "Please use \`make <target>' where <target> is one of"
@echo " html create HTML doc pages in html dir" @echo " html create HTML doc pages in html dir"
@echo " pdf create Developer.pdf and Manual.pdf in this dir" @echo " pdf create Developer.pdf and Manual.pdf in this dir"
@echo " fetch fetch HTML and PDF files from LAMMPS web site" @echo " fetch fetch HTML and PDF files from LAMMPS web site"
@echo " epub create ePUB format manual for e-book readers" @echo " epub create ePUB format manual for e-book readers"
@echo " mobi convert ePUB to MOBI format manual for e-book readers (e.g. Kindle)" @echo " mobi convert ePUB to MOBI format manual for e-book readers (e.g. Kindle)"
@echo " (requires ebook-convert tool from calibre)" @echo " (requires ebook-convert tool from calibre)"
@echo " clean remove all intermediate RST files" @echo " clean remove all intermediate RST files"
@echo " clean-all reset the entire build environment" @echo " clean-all reset the entire build environment"
@echo " anchor_check scan for duplicate anchor labels" @echo " anchor_check scan for duplicate anchor labels"
@echo " spelling spell-check the manual" @echo " style_check check for complete and consistent style lists"
@echo " package_check check for complete and consistent package lists"
@echo " spelling spell-check the manual"
# ------------------------------------------ # ------------------------------------------
clean-all: clean clean-all: clean
rm -rf $(BUILDDIR)/docenv $(BUILDDIR)/doctrees rm -rf $(BUILDDIR)/docenv $(BUILDDIR)/doctrees $(BUILDDIR)/mathjax Manual.pdf Developer.pdf
clean: clean: clean-spelling
rm -rf html epub latex rm -rf html epub latex
rm -rf spelling
clean-spelling: clean-spelling:
rm -rf spelling rm -rf spelling
rst: clean $(OBJECTS) $(ANCHORCHECK) html: $(ANCHORCHECK) $(MATHJAX)
html: $(OBJECTS) $(ANCHORCHECK)
@(\ @(\
. $(VENV)/bin/activate ;\ . $(VENV)/bin/activate ;\
sphinx-build $(SPHINXEXTRA) -b html -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) html ;\ sphinx-build $(SPHINXEXTRA) -b html -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) html ;\
echo "############################################" ;\ echo "############################################" ;\
rst_anchor_check src/*.rst ;\ rst_anchor_check src/*.rst ;\
python utils/check-packages.py -s ../src -d src ;\
env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\
python utils/check-styles.py -s ../src -d src ;\
echo "############################################" ;\ echo "############################################" ;\
deactivate ;\ deactivate ;\
) )
-rm html/searchindex.js
@rm -rf html/_sources @rm -rf html/_sources
@rm -rf html/PDF @rm -rf html/PDF
@rm -rf html/USER @rm -rf html/USER
@rm -rf html/JPG
@cp -r src/PDF html/PDF @cp -r src/PDF html/PDF
@cp -r src/USER html/USER @mkdir -p html/JPG
@cp `grep -A2 '\.\. .*\(image\|figure\)::' src/*.rst | grep ':target:' | sed -e 's,.*:target: JPG/,src/JPG/,' | sort | uniq` html/JPG/
@rm -rf html/PDF/.[sg]* @rm -rf html/PDF/.[sg]*
@rm -rf html/USER/.[sg]* @mkdir -p html/_static/mathjax
@rm -rf html/USER/*/.[sg]* @cp -r $(MATHJAX)/es5 html/_static/mathjax/
@rm -rf html/USER/*/*.[sg]*
@echo "Build finished. The HTML pages are in doc/html." @echo "Build finished. The HTML pages are in doc/html."
spelling: $(OBJECTS) utils/sphinx-config/false_positives.txt spelling: $(VENV) utils/sphinx-config/false_positives.txt
@(\ @(\
. $(VENV)/bin/activate ;\ . $(VENV)/bin/activate ;\
pip install sphinxcontrib-spelling ;\ cp utils/sphinx-config/false_positives.txt $(RSTDIR)/ ; env PYTHONWARNINGS= \
cp utils/sphinx-config/false_positives.txt $(RSTDIR)/ ;\
sphinx-build -b spelling -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) spelling ;\ sphinx-build -b spelling -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) spelling ;\
deactivate ;\ deactivate ;\
) )
@echo "Spell check finished." @echo "Spell check finished."
epub: $(OBJECTS) epub: $(VENV)
@mkdir -p epub/JPG @mkdir -p epub/JPG
@rm -f LAMMPS.epub @rm -f LAMMPS.epub
@cp src/JPG/lammps-logo.png epub/ @cp src/JPG/lammps-logo.png epub/
@ -113,7 +117,8 @@ mobi: epub
@ebook-convert LAMMPS.epub LAMMPS.mobi @ebook-convert LAMMPS.epub LAMMPS.mobi
@echo "Conversion finished. The MOBI manual file is created." @echo "Conversion finished. The MOBI manual file is created."
pdf: $(OBJECTS) $(ANCHORCHECK) pdf: $(ANCHORCHECK)
@if [ "$(HAS_PDFLATEX)" == "NO" ] ; then echo "PDFLaTeX was not found! Please check README.md for further instructions" 1>&2; exit 1; fi
@(\ @(\
cd src/Developer; \ cd src/Developer; \
pdflatex developer; \ pdflatex developer; \
@ -122,33 +127,33 @@ pdf: $(OBJECTS) $(ANCHORCHECK)
cd ../../; \ cd ../../; \
) )
@(\ @(\
. $(VENV)/bin/activate ;\ . $(VENV)/bin/activate ;\
sphinx-build $(SPHINXEXTRA) -b latex -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) latex ;\ sphinx-build $(SPHINXEXTRA) -b latex -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) latex ;\
echo "############################################" ;\ echo "############################################" ;\
rst_anchor_check src/*.rst ;\ rst_anchor_check src/*.rst ;\
echo "############################################" ;\ python utils/check-packages.py -s ../src -d src ;\
deactivate ;\ env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\
python utils/check-styles.py -s ../src -d src ;\
echo "############################################" ;\
deactivate ;\
) )
@cd latex && \ @cd latex && \
sed 's/latexmk -pdf -dvi- -ps-/pdflatex/g' Makefile > temp && \ sed 's/latexmk -pdf -dvi- -ps-/pdflatex/g' Makefile > temp && \
mv temp Makefile && \ mv temp Makefile && \
sed 's/\\begin{equation}//g' LAMMPS.tex > tmp.tex && \ sed 's/\\begin{equation}//g' LAMMPS.tex > tmp.tex && \
mv tmp.tex LAMMPS.tex && \ mv tmp.tex LAMMPS.tex && \
sed 's/\\end{equation}//g' LAMMPS.tex > tmp.tex && \ sed 's/\\end{equation}//g' LAMMPS.tex > tmp.tex && \
mv tmp.tex LAMMPS.tex && \ mv tmp.tex LAMMPS.tex && \
make && \ make && \
make && \ make && \
mv LAMMPS.pdf ../Manual.pdf && \ make && \
cd ../; mv LAMMPS.pdf ../Manual.pdf && \
cd ../;
@rm -rf latex/_sources @rm -rf latex/_sources
@rm -rf latex/PDF @rm -rf latex/PDF
@rm -rf latex/USER @rm -rf latex/USER
@cp -r src/PDF latex/PDF @cp -r src/PDF latex/PDF
@cp -r src/USER latex/USER
@rm -rf latex/PDF/.[sg]* @rm -rf latex/PDF/.[sg]*
@rm -rf latex/USER/.[sg]*
@rm -rf latex/USER/*/.[sg]*
@rm -rf latex/USER/*/*.[sg]*
@echo "Build finished. Manual.pdf and Developer.pdf are in this directory." @echo "Build finished. Manual.pdf and Developer.pdf are in this directory."
fetch: fetch:
@ -162,30 +167,42 @@ fetch:
anchor_check : $(ANCHORCHECK) anchor_check : $(ANCHORCHECK)
@(\ @(\
. $(VENV)/bin/activate ;\ . $(VENV)/bin/activate ;\
rst_anchor_check src/*.txt ;\ rst_anchor_check src/*.rst ;\
deactivate ;\
)
style_check : $(VENV)
@(\
. $(VENV)/bin/activate ;\
python utils/check-styles.py -s ../src -d src ;\
deactivate ;\
)
package_check : $(VENV)
@(\
. $(VENV)/bin/activate ;\
python utils/check-packages.py -s ../src -d src ;\
deactivate ;\ deactivate ;\
) )
# ------------------------------------------ # ------------------------------------------
$(RSTDIR)/%.rst : $(TXTDIR)/%.txt $(TXT2RST)
@(\
mkdir -p $(RSTDIR) ; \
. $(VENV)/bin/activate ;\
txt2rst -v $< > $@ ;\
deactivate ;\
)
$(VENV): $(VENV):
@if [ "$(HAS_PYTHON3)" == "NO" ] ; then echo "Python3 was not found! Please check README.md for further instructions" 1>&2; exit 1; fi @if [ "$(HAS_PYTHON3)" == "NO" ] ; then echo "Python3 was not found! Please check README.md for further instructions" 1>&2; exit 1; fi
@if [ "$(HAS_VIRTUALENV)" == "NO" ] ; then echo "virtualenv was not found! Please check README.md for further instructions" 1>&2; exit 1; fi @if [ "$(HAS_VIRTUALENV)" == "NO" ] ; then echo "virtualenv was not found! Please check README.md for further instructions" 1>&2; exit 1; fi
@( \ @( \
$(VIRTUALENV) -p $(PYTHON) $(VENV); \ $(VIRTUALENV) -p $(PYTHON) $(VENV); \
. $(VENV)/bin/activate; \ . $(VENV)/bin/activate; \
pip install --upgrade pip; \
pip install Sphinx; \ pip install Sphinx; \
pip install sphinxcontrib-spelling ;\
pip install breathe; \
deactivate;\ deactivate;\
) )
$(MATHJAX):
@git clone --depth 1 https://github.com/mathjax/MathJax.git mathjax
$(TXT2RST) $(ANCHORCHECK): $(VENV) $(TXT2RST) $(ANCHORCHECK): $(VENV)
@( \ @( \
. $(VENV)/bin/activate; \ . $(VENV)/bin/activate; \

View File

@ -93,12 +93,18 @@ support for PDFLaTeX. Also the following LaTeX packages need
to be installed (e.g. from texlive): to be installed (e.g. from texlive):
- amsmath - amsmath
- babel - babel
- capt-of
- cmap - cmap
- fncychap - fncychap
- framed
- geometry - geometry
- hyperref - hyperref
- hypcap - hypcap
- needspace
- times - times
- tabulary
- upquote
- wrapfig
---------------- ----------------
Installing prerequisites for epub build Installing prerequisites for epub build

View File

@ -104,14 +104,17 @@ Here are some items to check:
* every new command or style should have documentation. The names of * every new command or style should have documentation. The names of
source files (c++ and manual) should follow the name of the style. source files (c++ and manual) should follow the name of the style.
(example: `src/fix_nve.cpp`, `src/fix_nve.h` for `fix nve` command, (example: `src/fix_nve.cpp`, `src/fix_nve.h` for `fix nve` command,
implementing the class `FixNVE`, documented in `doc/src/fix_nve.txt`) implementing the class `FixNVE`, documented in `doc/src/fix_nve.rst`)
* all new style names should be lower case, the must be no dashes, * all new style names should be lower case, the must be no dashes,
blanks, or underscores separating words, only forward slashes. blanks, or underscores separating words, only forward slashes.
* new style docs should be added to the "overview" files in * new style docs should be added to the "overview" files in
`doc/src/Commands_*.txt`, `doc/src/{fixes,computes,pairs,bonds,...}.txt` `doc/src/Commands_*.rst`, `doc/src/{fixes,computes,pairs,bonds,...}.rst`
and `doc/src/lammps.book`
* check whether manual cleanly translates with `make html` and `make pdf` * check whether manual cleanly translates with `make html` and `make pdf`
* if documentation is (still) provided as a .txt file, convert to .rst
and remove the .txt file. For files in doc/txt the conversion is automatic.
* remove all .txt files in `doc/txt` that are out of sync with their .rst counterparts in `doc/src`
* check spelling of manual with `make spelling` in doc folder * check spelling of manual with `make spelling` in doc folder
* check style tables and command lists with `make style_check`
* new source files in packages should be added to `src/.gitignore` * new source files in packages should be added to `src/.gitignore`
* removed or renamed files in packages should be added to `src/Purge.list` * removed or renamed files in packages should be added to `src/Purge.list`
* C++ source files should use C++ style include files for accessing * C++ source files should use C++ style include files for accessing
@ -136,7 +139,7 @@ Here are some items to check:
* Code should follow the C++-98 standard. C++-11 is only accepted * Code should follow the C++-98 standard. C++-11 is only accepted
in individual special purpose packages in individual special purpose packages
* indentation is 2 spaces per level * indentation is 2 spaces per level
* there should be NO tabs and no trailing whitespace * there should be NO tabs and no trailing whitespace (review the "checkstyle" test on pull requests)
* header files, especially of new styles, should not include any * header files, especially of new styles, should not include any
other headers, except the header with the base class or cstdio. other headers, except the header with the base class or cstdio.
Forward declarations should be used instead when possible. Forward declarations should be used instead when possible.

View File

@ -49,22 +49,15 @@ include files provided with LAMMPS are included with double quotes
For headers declaring functions of the C-library, the corresponding For headers declaring functions of the C-library, the corresponding
C++ versions should be included (examples: `#include <cstdlib>` or C++ versions should be included (examples: `#include <cstdlib>` or
`#include <cctypes>`). However, these includes are limited to those defined `#include <cctypes>` instead of `#include <stdlib.h>` or
in the C++98 standard. Some files thus must use the older style until `#include<ctypes.h>` ).
the minimum C++ standard requirement of LAMMPS is lifted to C++11 or
even beyond (examples: `#include <stdint.h>` versus `#include <cstdint>`
or `#include <inttypes.h>` versus `#include <cinttypes>`).
### C++ Standard Compliance ### C++ Standard Compliance
LAMMPS core files currently correspond to the C++98 standard. Files LAMMPS core files use standard conforming C++ compatible with the
requiring C++11 or later are only permitted in (optional) packages C++11 standard, unless explicitly noted. Also, LAMMPS uses the C-style
and particularly packages that are not part of the list of commonly stdio library for I/O instead of iostreams. Since using both at the
used packages such as MOLECULE, KSPACE, MANYBODY, or RIGID. same time can cause problems, iostreams should be avoided where possible.
Also, LAMMPS uses the C-style stdio library for I/O instead of iostreams.
Since using both at the same time can cause problems, iostreams should
be avoided where possible.
### Lean Header Files ### Lean Header Files

View File

@ -1,4 +1,4 @@
.TH LAMMPS "20 November 2019" "2019-11-20" .TH LAMMPS "15 April 2020" "2020-04-15"
.SH NAME .SH NAME
.B LAMMPS .B LAMMPS
\- Molecular Dynamics Simulator. \- Molecular Dynamics Simulator.
@ -11,13 +11,18 @@ or
mpirun \-np 2 mpirun \-np 2
.B lmp .B lmp
<input file> [OPTIONS] ... \-in <input file> [OPTIONS] ...
or or
.B lmp .B lmp
\-r2data file.restart file.data \-r2data file.restart file.data
or
.B lmp
\-h
.SH DESCRIPTION .SH DESCRIPTION
.B LAMMPS .B LAMMPS
is a classical molecular dynamics code, and an acronym for \fBL\fRarge-scale is a classical molecular dynamics code, and an acronym for \fBL\fRarge-scale
@ -249,7 +254,7 @@ the chapter on errors in the
manual gives some additional information about error messages, if possible. manual gives some additional information about error messages, if possible.
.SH COPYRIGHT .SH COPYRIGHT
© 2003--2019 Sandia Corporation © 2003--2020 Sandia Corporation
This package is free software; you can redistribute it and/or modify This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as it under the terms of the GNU General Public License version 2 as

View File

@ -31,7 +31,7 @@ of benzene, you have to provide the files 'benzene.car' and 'benzene.mdf'
in the current working directory. in the current working directory.
.B msi2lmp .B msi2lmp
will then read and process those files according to its remaining settings. will then read and process those files according to its remaining settings.
All other settins are optional and have defaults as listed. All other settings are optional and have defaults as listed.
.TP .TP
\fB\-c <I,1,II,2,O,0>\fR, \fB\-class <I,1,II,2,O,0>\fR \fB\-c <I,1,II,2,O,0>\fR, \fB\-class <I,1,II,2,O,0>\fR
The \-c or \-class option selects the force field class, i.e which pair The \-c or \-class option selects the force field class, i.e which pair

3
doc/src/.gitignore vendored
View File

@ -1,2 +1 @@
Eqs /false_positives.txt
JPG

View File

@ -10,7 +10,7 @@ LAMMPS</H2>
LAMMPS = Large-scale Atomic/Molecular Massively Parallel Simulator</P> LAMMPS = Large-scale Atomic/Molecular Massively Parallel Simulator</P>
<P> <P>
This is the documentation for the LAMMPS 2001 version, written in F90, This is the documentation for the LAMMPS 2001 version, written in F90,
which has been superceded by more current versions. See the <A which has been superseded by more current versions. See the <A
HREF="http://www.cs.sandia.gov/~sjplimp/lammps.html">LAMMPS WWW HREF="http://www.cs.sandia.gov/~sjplimp/lammps.html">LAMMPS WWW
Site</A> for more information. Site</A> for more information.
<P> <P>

View File

@ -47,7 +47,7 @@ directories: </P>
<P> <P>
The src directory contains the F90 and C source files for LAMMPS as The src directory contains the F90 and C source files for LAMMPS as
well as several sample Makefiles for different machines. To make LAMMPS well as several sample Makefiles for different machines. To make LAMMPS
for a specfic machine, you simply type</P> for a specific machine, you simply type</P>
<P> <P>
make machine</P> make machine</P>
<P> <P>

View File

@ -1079,7 +1079,7 @@ for style aveforce, average force on the group of fixed atoms is computed,
to new total value -> has effect of applying same force to entire group to new total value -> has effect of applying same force to entire group
of atoms of atoms
thermostatting constraints (rescale, hoover/drag, langevin) cannot be used in thermostatting constraints (rescale, hoover/drag, langevin) cannot be used in
conjuction with global &quot;temp control&quot;, since they conflict and will conjunction with global &quot;temp control&quot;, since they conflict and will
cause atom velocities to be reset twice cause atom velocities to be reset twice
thermostatting constraints (rescale, hoover/drag, langevin) cannot be used thermostatting constraints (rescale, hoover/drag, langevin) cannot be used
when performing a minimization when performing a minimization
@ -1089,7 +1089,7 @@ meaning of rescale and Langevin thermostatting coefficients is same as in
&quot;temp control&quot; command &quot;temp control&quot; command
for rescale style, it can be used as a coarse temperature rescaler, for rescale style, it can be used as a coarse temperature rescaler,
for example &quot;rescale 200.0 300.0 100 10.0 1.0&quot; will ramp the temperature for example &quot;rescale 200.0 300.0 100 10.0 1.0&quot; will ramp the temperature
up during the simulation, resetting it to the target temperatue as needed up during the simulation, resetting it to the target temperature as needed
for rescale style, it can be used to create an instantaneous for rescale style, it can be used to create an instantaneous
drag force that slowly rescales the temperature without oscillation, drag force that slowly rescales the temperature without oscillation,
for example &quot;rescale 300.0 300.0 1 0.0 0.0001&quot; will force (or keep) for example &quot;rescale 300.0 300.0 1 0.0 0.0001&quot; will force (or keep)
@ -1952,7 +1952,7 @@ for rescale style, the amount of rescaling is contfolled by the fractional
to halfway between the current and target temperature to halfway between the current and target temperature
for rescale style, it can be used as a coarse temperature rescaler, for rescale style, it can be used as a coarse temperature rescaler,
for example "rescale 200.0 300.0 100 10.0 1.0" will ramp the temperature for example "rescale 200.0 300.0 100 10.0 1.0" will ramp the temperature
up during the simulation, resetting it to the target temperatue as needed up during the simulation, resetting it to the target temperature as needed
for rescale style, it can be used to create an instantaneous for rescale style, it can be used to create an instantaneous
drag force that slowly rescales the temperature without oscillation, drag force that slowly rescales the temperature without oscillation,
for example "rescale 300.0 300.0 1 0.0 0.0001" will force (or keep) for example "rescale 300.0 300.0 1 0.0 0.0001" will force (or keep)

View File

@ -10,7 +10,7 @@ LAMMPS</H2>
LAMMPS = Large-scale Atomic/Molecular Massively Parallel Simulator</P> LAMMPS = Large-scale Atomic/Molecular Massively Parallel Simulator</P>
<P> <P>
This is the documentation for the LAMMPS 99 version, written in F77, This is the documentation for the LAMMPS 99 version, written in F77,
which has been superceded by more current versions. See the <A which has been superseded by more current versions. See the <A
HREF="http://www.cs.sandia.gov/~sjplimp/lammps.html">LAMMPS WWW HREF="http://www.cs.sandia.gov/~sjplimp/lammps.html">LAMMPS WWW
Site</A> for more information. Site</A> for more information.
<P> <P>

View File

@ -45,7 +45,7 @@ directories: </P>
<P> <P>
The src directory contains the F77 and C source files for LAMMPS as The src directory contains the F77 and C source files for LAMMPS as
well as several sample Makefiles for different machines. To make LAMMPS well as several sample Makefiles for different machines. To make LAMMPS
for a specfic machine, you simply type</P> for a specific machine, you simply type</P>
<P> <P>
make machine</P> make machine</P>
<P> <P>

View File

@ -430,7 +430,7 @@ accuracy criterion effectively determines how many k-space vectors are used
for PPPM, accuracy criterion determines mesh spacing (see &quot;particle mesh&quot; for PPPM, accuracy criterion determines mesh spacing (see &quot;particle mesh&quot;
command) command)
for PPPM, must be running on power-of-2 number of processors for FFTs for PPPM, must be running on power-of-2 number of processors for FFTs
must use periodic boundary conditions in conjuction with Ewald and PPPM must use periodic boundary conditions in conjunction with Ewald and PPPM
cannot use any styles other than none with nonbond style = lj/shift or cannot use any styles other than none with nonbond style = lj/shift or
nonbond style = soft nonbond style = soft
Coulomb style = smooth should be used with nonbond style = lj/switch, Coulomb style = smooth should be used with nonbond style = lj/switch,
@ -772,7 +772,7 @@ for style aveforce, average force on the group of fixed atoms is computed,
to new total value -&gt; has effect of applying same force to entire group to new total value -&gt; has effect of applying same force to entire group
of atoms of atoms
thermostatting constraints (rescale, langevin, nose/hoover) cannot be used in thermostatting constraints (rescale, langevin, nose/hoover) cannot be used in
conjuction with global &quot;temp control&quot;, since they conflict and will conjunction with global &quot;temp control&quot;, since they conflict and will
cause atom velocities to be reset twice cause atom velocities to be reset twice
if multiple Langevin constraints are specified the Marsaglia RNG will if multiple Langevin constraints are specified the Marsaglia RNG will
only use the last RNG seed specified for initialization only use the last RNG seed specified for initialization

View File

@ -1,13 +1,14 @@
Build LAMMPS Build LAMMPS
************ ************
LAMMPS can be built as an executable or library from source code via LAMMPS is built as a library and an executable from source code using
either traditional makefiles (which may require manual editing) either traditional makefiles for use with GNU make (which may require
for use with GNU make or gmake, or a build environment generated by CMake manual editing), or using a build environment generated by CMake (Unix
(Unix Makefiles, Xcode, Visual Studio, KDevelop or more). As an Makefiles, Ninja, Xcode, Visual Studio, KDevelop, CodeBlocks and more).
alternative you can download a package with pre-built executables
as described on the :doc:`Install <Install>` doc page.
As an alternative you can download a package with pre-built executables
or automated build trees as described on the :doc:`Install <Install>`
doc page.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
@ -21,8 +22,3 @@ as described on the :doc:`Install <Install>` doc page.
Build_extras Build_extras
Build_windows Build_windows
Build_development Build_development
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -6,159 +6,203 @@ CMake and make:
* :ref:`Serial vs parallel build <serial>` * :ref:`Serial vs parallel build <serial>`
* :ref:`Choice of compiler and compile/link options <compile>` * :ref:`Choice of compiler and compile/link options <compile>`
* :ref:`Build LAMMPS as an executable or a library <exe>` * :ref:`Build the LAMMPS executable and library <exe>`
* :ref:`Including and removing debug support <debug>`
* :ref:`Build the LAMMPS documentation <doc>` * :ref:`Build the LAMMPS documentation <doc>`
* :ref:`Install LAMMPS after a build <install>` * :ref:`Install LAMMPS after a build <install>`
---------- ----------
.. _serial: .. _serial:
Serial vs parallel build Serial vs parallel build
------------------------------------- ------------------------
LAMMPS can be built to run in parallel using the ubiquitous `MPI (message-passing interface) <https://en.wikipedia.org/wiki/Message_Passing_Interface>`_ LAMMPS is written to use the ubiquitous `MPI (Message Passing Interface)
library. Or it can built to run on a single processor (serial) <https://en.wikipedia.org/wiki/Message_Passing_Interface>`_ library API
without MPI. It can also be built with support for OpenMP threading for distributed memory parallel computation. You need to have such a
(see more discussion below). library installed for building and running LAMMPS in parallel using a
domain decomposition parallelization. It is compatible with the MPI
standard version 2.x and later. LAMMPS can also be built into a
"serial" executable for use with a single processor using the bundled
MPI STUBS library.
**CMake variables**\ : Independent of the distributed memory MPI parallelization, parts of
LAMMPS are also written with support for shared memory parallelization
using the `OpenMP <https://en.wikipedia.org/wiki/OpenMP>`_ threading
standard. A more detailed discussion of that is below.
**CMake build**\ :
.. parsed-literal:: .. code-block:: bash
-D BUILD_MPI=value # yes or no, default is yes if CMake finds MPI, else no -D BUILD_MPI=value # yes or no, default is yes if CMake finds MPI, else no
-D BUILD_OMP=value # yes or no (default) -D BUILD_OMP=value # yes or no, default is yes if a compatible compiler is detected
-D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc -D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc
# no default value # no default value
The executable created by CMake (after running make) is lmp\_name. If The executable created by CMake (after running make) is named ``lmp`` unless
the LAMMPS\_MACHINE variable is not specified, the executable is just the ``LAMMPS_MACHINE`` option is set. When setting ``LAMMPS_MACHINE=name``
lmp. Using BUILD\_MPI=no will produce a serial executable. the executable will be called ``lmp_name``. Using ``BUILD_MPI=no`` will
enforce building a serial executable using the MPI STUBS library.
**Traditional make**\ : **Traditional make**\ :
The build with traditional makefiles has to be done inside the source folder ``src``.
.. parsed-literal:: .. code-block:: bash
cd lammps/src
make mpi # parallel build, produces lmp_mpi using Makefile.mpi make mpi # parallel build, produces lmp_mpi using Makefile.mpi
make serial # serial build, produces lmp_serial using Makefile/serial make serial # serial build, produces lmp_serial using Makefile/serial
make mybox # uses Makefile.mybox to produce lmp_mybox make mybox # uses Makefile.mybox to produce lmp_mybox
Serial build (see src/MAKE/Makefile.serial): Any ``make machine`` command will look up the make settings from a file
``Makefile.machine`` in the folder ``src/MAKE`` or one of its
sub-directories ``MINE``, ``MACHINES``, or ``OPTIONS``, create a folder
``Obj_machine`` with all objects and generated files and an executable
called ``lmp_machine``\ . The standard parallel build with ``make mpi``
assumes a standard MPI installation with MPI compiler wrappers where all
necessary compiler and linker flags to get access and link with the
suitable MPI headers and libraries are set by the wrapper programs. For
other cases or the serial build, you have to adjust the make file
variables ``MPI_INC``, ``MPI_PATH``, ``MPI_LIB`` as well as ``CC`` and
``LINK``\ . To enable OpenMP threading usually a compiler specific flag
needs to be added to the compile and link commands. For the GNU
compilers, this is ``-fopenmp``\ , which can be added to the ``CC`` and
``LINK`` makefile variables.
For the serial build the following make variables are set (see src/MAKE/Makefile.serial):
.. parsed-literal:: .. code-block:: make
CC = g++
LINK = g++
MPI_INC = -I../STUBS MPI_INC = -I../STUBS
MPI_PATH = -L../STUBS MPI_PATH = -L../STUBS
MPI_LIB = -lmpi_stubs MPI_LIB = -lmpi_stubs
For a parallel build, if MPI is installed on your system in the usual You also need to build the STUBS library for your platform before making
place (e.g. under /usr/local), you do not need to specify the 3 LAMMPS itself. A ``make serial`` build does this for you automatically,
variables MPI\_INC, MPI\_PATH, MPI\_LIB. The MPI wrapper on the compiler otherwise, type ``make mpi-stubs`` from the src directory, or ``make``
(e.g. mpicxx, mpiCC) knows where to find the needed include and from the ``src/STUBS`` dir. If the build fails, you may need to edit
library files. Failing this, these 3 variables can be used to specify the ``STUBS/Makefile`` for your platform. The stubs library does not
where the mpi.h file (MPI\_INC), and the MPI library files (MPI\_PATH) provide MPI/IO functions required by some LAMMPS packages,
are found, and the name of the library files (MPI\_LIB). e.g. ``MPIIO`` or ``USER-LB``, and thus is not compatible with those
packages.
For a serial build, you need to specify the 3 variables, as shown .. note::
above.
For a serial LAMMPS build, use the dummy MPI library provided in The file ``src/STUBS/mpi.c`` provides a CPU timer function called
src/STUBS. You also need to build the STUBS library for your platform ``MPI_Wtime()`` that calls ``gettimeofday()``. If your operating system
before making LAMMPS itself. A "make serial" build does this for. does not support ``gettimeofday()``, you will need to insert code to
Otherwise, type "make mpi-stubs" from the src directory, or "make" call another timer. Note that the ANSI-standard function ``clock()``
from the src/STUBS dir. If the build fails, you will need to edit the rolls over after an hour or so, and is therefore insufficient for
STUBS/Makefile for your platform. timing long LAMMPS simulations.
The file STUBS/mpi.c provides a CPU timer function called MPI\_Wtime() **MPI and OpenMP support info**\ :
that calls gettimeofday() . If your system doesn't support
gettimeofday() , you'll need to insert code to call another timer.
Note that the ANSI-standard function clock() rolls over after an hour
or so, and is therefore insufficient for timing long LAMMPS
simulations.
**CMake and make info**\ : If you are installing MPI yourself to build a parallel LAMMPS
executable, we recommend either MPICH or OpenMPI which are regularly
used and tested with LAMMPS by the LAMMPS developers. MPICH can be
downloaded from the `MPICH home page <https://www.mpich.org>`_ and
OpenMPI can be downloaded correspondingly from the `OpenMPI home page
<https://www.open-mpi.org>`_. Other MPI packages should also work. No
specific vendor provided and standard compliant MPI library is currently
known to be incompatible with LAMMPS. If you are running on a large
parallel machine, your system admins or the vendor should have already
installed a version of MPI, which is likely to be faster than a
self-installed MPICH or OpenMPI, so you should study the provided
documentation to find out how to build and link with it.
If you are installing MPI yourself, we recommend MPICH2 from Argonne The majority of OpenMP (threading) support in LAMMPS is provided by the
National Laboratory or OpenMPI. MPICH can be downloaded from the ``USER-OMP`` package; see the :doc:`Speed omp <Speed_omp>` doc page for
`Argonne MPI site <http://www.mcs.anl.gov/research/projects/mpich2/>`_. details. The ``USER-INTEL`` package also includes OpenMP threading (it
OpenMPI can be downloaded from the `OpenMPI site <http://www.open-mpi.org>`_. Other MPI packages should also work. is compatible with ``USER-OMP`` and will usually fall back on styles
If you are running on a large parallel machine, your system admins or from that package, if a ``USER-INTEL`` does not exist) and adds
the vendor should have already installed a version of MPI, which is vectorization support when compiled with compatible compilers, in
likely to be faster than a self-installed MPICH or OpenMPI, so find particular the Intel compilers on top of OpenMP. Also, the ``KOKKOS``
out how to build and link with it. package can be compiled to include OpenMP threading.
The majority of OpenMP (threading) support in LAMMPS is provided by In addition, there are a few commands in LAMMPS that have native OpenMP
the USER-OMP package; see the :doc:`Speed omp <Speed_omp>` doc page for support included as well. These are commands in the ``MPIIO``,
details. The USER-INTEL package also provides OpenMP support (it is ``SNAP``, ``USER-DIFFRACTION``, and ``USER-DPD`` packages. In addition
compatible with USER-OMP) and adds vectorization support when compiled some packages support OpenMP threading indirectly through the libraries
with the Intel compilers on top of that. Also, the KOKKOS package can they interface to: e.g. ``LATTE``, ``KSPACE``, and ``USER-COLVARS``.
be compiled for using OpenMP threading. See the :doc:`Packages details <Packages_details>` doc page for more
info on these packages and the doc pages for their respective commands
for OpenMP threading info.
However, there are a few commands in LAMMPS that have native OpenMP For CMake, if you use ``BUILD_OMP=yes``, you can use these packages
support. These are commands in the MPIIO, SNAP, USER-DIFFRACTION, and and turn on their native OpenMP support and turn on their native OpenMP
USER-DPD packages. In addition some packages support OpenMP threading support at run time, by setting the ``OMP_NUM_THREADS`` environment
indirectly through the libraries they interface to: e.g. LATTE and
USER-COLVARS. See the :doc:`Packages details <Packages_details>` doc
page for more info on these packages and the doc pages for their
respective commands for OpenMP threading info.
For CMake, if you use BUILD\_OMP=yes, you can use these packages and
turn on their native OpenMP support and turn on their native OpenMP
support at run time, by setting the OMP\_NUM\_THREADS environment
variable before you launch LAMMPS. variable before you launch LAMMPS.
For building via conventional make, the CCFLAGS and LINKFLAGS For building via conventional make, the ``CCFLAGS`` and ``LINKFLAGS``
variables in Makefile.machine need to include the compiler flag that variables in Makefile.machine need to include the compiler flag that
enables OpenMP. For GNU compilers it is -fopenmp. For (recent) Intel enables OpenMP. For GNU compilers it is ``-fopenmp``\ . For (recent) Intel
compilers it is -qopenmp. If you are using a different compiler, compilers it is ``-qopenmp``\ . If you are using a different compiler,
please refer to its documentation. please refer to its documentation.
.. _default-none-issues: .. _default-none-issues:
**OpenMP Compiler compatibility info**\ : **OpenMP Compiler compatibility info**\ :
Some compilers do not fully support the 'default(none)' directive
and others (e.g. GCC version 9 and beyond) may implement OpenMP 4.0
semantics, which are incompatible with the OpenMP 3.1 directives used
in LAMMPS (for maximal compatibility with compiler versions in use).
In those case, all 'default(none)' directives (which aid in detecting
incorrect and unwanted sharing) can be replaced with 'default(shared)'
while dropping all 'shared()' directives. The script
'src/USER-OMP/hack\_openmp\_for\_pgi\_gcc9.sh' can be used to automate
this conversion.
Some compilers do not fully support the ``default(none)`` directive
and others (e.g. GCC version 9 and beyond, Clang version 10 and later)
may implement strict OpenMP 4.0 and later semantics, which are incompatible
with the OpenMP 3.1 semantics used in LAMMPS for maximal compatibility
with compiler versions in use. If compilation with OpenMP enabled fails
because of your compiler requiring strict OpenMP 4.0 semantic, you can
change the behavior by adding ``-D LAMMPS_OMP_COMPAT=4`` to the ``LMP_INC``
variable in your makefile, or add it to the command line while configuring
with CMake. CMake will detect the suitable setting for the GNU, Clang,
and Intel compilers.
---------- ----------
.. _compile: .. _compile:
Choice of compiler and compile/link options Choice of compiler and compile/link options
--------------------------------------------------------- ---------------------------------------------------------
The choice of compiler and compiler flags can be important for The choice of compiler and compiler flags can be important for maximum
performance. Vendor compilers can produce faster code than performance. Vendor provided compilers for a specific hardware can
open-source compilers like GNU. On boxes with Intel CPUs, we suggest produce faster code than open-source compilers like the GNU compilers.
trying the `Intel C++ compiler <intel_>`_. On the most common x86 hardware most popular C++ compilers are quite
similar in performance of C/C++ code at high optimization levels. When
using the ``USER-INTEL`` package, there is a distinct advantage in using
the `Intel C++ compiler <intel_>`_ due to much improved vectorization
through SSE and AVX instructions on compatible hardware as the source
code includes changes and Intel compiler specific directives to enable
high degrees of vectorization. This may change over time as equivalent
vectorization directives are included into OpenMP standard revisions and
other compilers adopt them.
.. _intel: https://software.intel.com/en-us/intel-compilers .. _intel: https://software.intel.com/en-us/intel-compilers
On parallel clusters or supercomputers which use "environment modules"
for their compile/link environments, you can often access different
compilers by simply loading the appropriate module before building
LAMMPS.
**CMake build**\ :
On parallel clusters or supercomputers which use "modules" for their By default CMake will use a compiler it finds according to internal
compile/link environments, you can often access different compilers by preferences and it will add optimization flags appropriate to that
simply loading the appropriate module before building LAMMPS. compiler and any :doc:`accelerator packages <Speed_packages>` you have
included in the build.
**CMake variables**\ : You can tell CMake to look for a specific compiler with setting CMake
variable during configuration. For a few common choices, there are also
presets in the ``cmake/presets`` folder. For convenience, there is a
``CMAKE_TUNE_FLAGS`` variable that can be set to apply global compiler
options. More on that below, but you can also specify the corresponding
``CMAKE_*_FLAGS`` variables individually if you want to experiment with
alternate optimization flags. You should specify all 3 compilers, so
that the (few) LAMMPS source files written in C or Fortran are built
with a compiler consistent with the one used for the C++ files:
.. code-block:: bash
.. parsed-literal::
-D CMAKE_CXX_COMPILER=name # name of C++ compiler -D CMAKE_CXX_COMPILER=name # name of C++ compiler
-D CMAKE_C_COMPILER=name # name of C compiler -D CMAKE_C_COMPILER=name # name of C compiler
@ -168,77 +212,96 @@ simply loading the appropriate module before building LAMMPS.
-D CMAKE_C_FLAGS=string # flags to use with C compiler -D CMAKE_C_FLAGS=string # flags to use with C compiler
-D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler -D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler
By default CMake will use a compiler it finds and it will add A few example command lines are:
optimization flags appropriate to that compiler and any :doc:`accelerator packages <Speed_packages>` you have included in the build.
You can tell CMake to look for a specific compiler with these variable .. code-block:: bash
settings. Likewise you can specify the FLAGS variables if you want to
experiment with alternate optimization flags. You should specify all
3 compilers, so that the small number of LAMMPS source files written
in C or Fortran are built with a compiler consistent with the one used
for all the C++ files:
# Building with GNU Compilers:
.. parsed-literal::
Building with GNU Compilers:
cmake ../cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_Fortran_COMPILER=gfortran cmake ../cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_Fortran_COMPILER=gfortran
Building with Intel Compilers: # Building with Intel Compilers:
cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort
Building with LLVM/Clang Compilers: # Building with LLVM/Clang Compilers:
cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_Fortran_COMPILER=flang cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_Fortran_COMPILER=flang
For compiling with the Clang/LLVM compilers a CMake preset is provided that
can be loaded with `-C ../cmake/presets/clang.cmake`. Similarly,
`-C ../cmake/presets/intel.cmake` should switch the
In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add
compiler flags to tune for optimal performance on given hosts. By
default these are initialized to some compiler specific flags, to
optimize the LAMMPS executable with optimizations and instructions
available on the host where LAMMPS is compiled. For example, for Intel
compilers this would be ``-xHost`` and for GNU compilers this would be
``-march=native``. To turn these flags off, do ``-D CMAKE_TUNE_FLAGS=``.
.. note:: .. note::
When the cmake command completes, it prints info to the screen When the cmake command completes, it prints a summary to the screen
as to which compilers it is using, and what flags will be used in the which compilers it is using and what flags and settings will be used
compilation. Note that if the top-level compiler is mpicxx, it is for the compilation. Note that if the top-level compiler is mpicxx,
simply a wrapper on a real compiler. The underlying compiler info is it is simply a wrapper on a real compiler. The underlying compiler
what will be listed in the CMake output. You should check to insure info is what CMake will try to determine and report. You should check
you are using the compiler and optimization flags are the ones you to confirm you are using the compiler and optimization flags you want.
want.
**Makefile.machine settings**\ : **Makefile.machine settings for traditional make**\ :
Parallel build (see src/MAKE/Makefile.mpi): The "compiler/linker settings" section of a Makefile.machine lists
compiler and linker settings for your C++ compiler, including
optimization flags. For a parallel build it is recommended to use
``mpicxx`` or ``mpiCC``, since these compiler wrappers will include a
variety of settings appropriate for your MPI installation and thus
avoiding the guesswork of finding the right flags.
Parallel build (see ``src/MAKE/Makefile.mpi``):
.. parsed-literal:: .. code-block:: bash
CC = mpicxx CC = mpicxx
CCFLAGS = -g -O3 CCFLAGS = -g -O3
LINK = mpicxx LINK = mpicxx
LINKFLAGS = -g -O LINKFLAGS = -g -O
Serial build (see src/MAKE/Makefile.serial): Serial build with GNU gcc (see ``src/MAKE/Makefile.serial``):
.. code-block:: make
.. parsed-literal::
CC = g++ CC = g++
CCFLAGS = -g -O3 CCFLAGS = -g -O3
LINK = g++ LINK = g++
LINKFLAGS = -g -O LINKFLAGS = -g -O
The "compiler/linker settings" section of a Makefile.machine lists
compiler and linker settings for your C++ compiler, including
optimization flags. You should always use mpicxx or mpiCC for
a parallel build, since these compiler wrappers will include
a variety of settings appropriate for your MPI installation.
.. note:: .. note::
If you build LAMMPS with any :doc:`accelerator packages <Speed_packages>` included, they have specific If compilation stops with a message like the following:
optimization flags that are either required or recommended for optimal
performance. You need to include these in the CCFLAGS and LINKFLAGS
settings above. For details, see the individual package doc pages
listed on the :doc:`Speed packages <Speed_packages>` doc page. Or
examine these files in the src/MAKE/OPTIONS directory. They
correspond to each of the 5 accelerator packages and their hardware
variants:
.. code-block::
.. parsed-literal:: g++ -g -O3 -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -I../STUBS -c ../main.cpp
In file included from ../pointers.h:24:0,
from ../input.h:17,
from ../main.cpp:16:
../lmptype.h:34:2: error: #error LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.
then you have either an unsupported (old) compiler or you have to
turn on C++11 mode. The latter applies to GCC 4.8.x shipped with
RHEL 7.x and CentOS 7.x. For those compilers, you need to add the
``-std=c++11`` flag. Otherwise, you would have to install a newer
compiler that supports C++11; either as a binary package or through
compiling from source.
If you build LAMMPS with any :doc:`accelerator packages
<Speed_packages>` included, there may be specific optimization flags
that are either required or recommended to enable required features and
to achieve optimal performance. You need to include these in the
CCFLAGS and LINKFLAGS settings above. For details, see the individual
package doc pages listed on the :doc:`Speed packages <Speed_packages>`
doc page. Or examine these files in the src/MAKE/OPTIONS directory.
They correspond to each of the 5 accelerator packages and their hardware
variants:
.. code-block:: bash
Makefile.opt # OPT package Makefile.opt # OPT package
Makefile.omp # USER-OMP package Makefile.omp # USER-OMP package
@ -249,129 +312,198 @@ a variety of settings appropriate for your MPI installation.
Makefile.kokkos_omp # KOKKOS package for CPUs (OpenMP) Makefile.kokkos_omp # KOKKOS package for CPUs (OpenMP)
Makefile.kokkos_phi # KOKKOS package for KNLs (OpenMP) Makefile.kokkos_phi # KOKKOS package for KNLs (OpenMP)
---------- ----------
.. _exe: .. _exe:
Build LAMMPS as an executable or a library Build the LAMMPS executable and library
---------------------------------------------------- ---------------------------------------
LAMMPS can be built as either an executable or as a static or shared LAMMPS is always built as a library of C++ classes plus an executable.
library. The LAMMPS library can be called from another application or The executable is a simple ``main()`` function that sets up MPI and then
a scripting language. See the :doc:`Howto couple <Howto_couple>` doc creates a LAMMPS class instance from the LAMMPS library, which
will then process commands provided via a file or from the console
input. The LAMMPS library can also be called from another application
or a scripting language. See the :doc:`Howto couple <Howto_couple>` doc
page for more info on coupling LAMMPS to other codes. See the page for more info on coupling LAMMPS to other codes. See the
:doc:`Python <Python_head>` doc page for more info on wrapping and :doc:`Python <Python_head>` doc page for more info on wrapping and
running LAMMPS from Python via its library interface. running LAMMPS from Python via its library interface.
**CMake variables**\ : **CMake build**\ :
For CMake builds, you can select through setting CMake variables between
building a shared or a static LAMMPS library and what kind of suffix is
added to them (in case you want to concurrently install multiple variants
of binaries with different settings). If none are set, defaults are applied.
.. parsed-literal:: .. code-block:: bash
-D BUILD_EXE=value # yes (default) or no
-D BUILD_LIB=value # yes or no (default)
-D BUILD_SHARED_LIBS=value # yes or no (default) -D BUILD_SHARED_LIBS=value # yes or no (default)
-D LAMMPS_LIB_SUFFIX=name # name = mpi, serial, mybox, titan, laptop, etc -D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc
# no default value # no default value
Setting BUILD\_EXE=no will not produce an executable. Setting The compilation will always produce a LAMMPS library and an executable
BUILD\_LIB=yes will produce a static library named liblammps.a. linked to it. By default this will be a static library named
Setting both BUILD\_LIB=yes and BUILD\_SHARED\_LIBS=yes will produce a ``liblammps.a`` and an executable named ``lmp`` Setting
shared library named liblammps.so. If LAMMPS\_LIB\_SUFFIX is set the generated ``BUILD_SHARED_LIBS=yes`` will instead produce a shared library called
libraries will be named liblammps\_name.a or liblammps\_name.so instead. ``liblammps.so`` (or ``liblammps.dylib`` or ``liblammps.dll`` depending
on the platform) If ``LAMMPS_MACHINE=name`` is set in addition, the name
of the generated libraries will be changed to either
``liblammps_name.a`` or ``liblammps_name.so``\ , respectively and the
executable will be called ``lmp_name``.
**Traditional make**\ : **Traditional make**\ :
With the traditional makefile based build process, the choice of
the generated executable or library depends on the "mode" setting.
Several options are available and ``mode=static`` is the default.
.. parsed-literal:: .. code-block:: bash
cd lammps/src
make machine # build LAMMPS executable lmp_machine make machine # build LAMMPS executable lmp_machine
make mode=lib machine # build LAMMPS static lib liblammps_machine.a make mode=static machine # same as "make machine"
make mode=shlib machine # build LAMMPS shared lib liblammps_machine.so make mode=shared machine # build LAMMPS shared lib liblammps_machine.so instead
The two library builds also create generic soft links, named The "static" build will generate a static library called
liblammps.a and liblammps.so, which point to the liblammps\_machine ``liblammps_machine.a`` and an executable named ``lmp_machine``\ , while
files. the "shared" build will generate a shared library
``liblammps_machine.so`` instead and ``lmp_machine`` will be linked to
it. The build step will also create generic soft links, named
``liblammps.a`` and ``liblammps.so``\ , which point to the specific
``liblammps_machine.a/so`` files.
**CMake and make info**\ : **CMake and make info**\ :
Note that for a shared library to be usable by a calling program, all Note that for creating a shared library, all the libraries it depends on
the auxiliary libraries it depends on must also exist as shared must be compiled to be compatible with shared libraries. This should be
libraries. This will be the case for libraries included with LAMMPS, the case for libraries included with LAMMPS, such as the dummy MPI
such as the dummy MPI library in src/STUBS or any package libraries in library in ``src/STUBS`` or any package libraries in the ``lib``
the lib/packages directory, since they are always built as shared directory, since they are always built in a shared library compatible
libraries using the -fPIC switch. However, if a library like MPI or way using the ``-fPIC`` compiler switch. However, if an auxiliary
FFTW does not exist as a shared library, the shared library build will library (like MPI or FFTW) does not exist as a compatible format, the
generate an error. This means you will need to install a shared shared library linking step may generate an error. This means you will
library version of the auxiliary library. The build instructions for need to install a compatible version of the auxiliary library. The
the library should tell you how to do this. build instructions for that library should tell you how to do this.
As an example, here is how to build and install the `MPICH library <mpich_>`_, a popular open-source version of MPI, distributed by As an example, here is how to build and install the `MPICH library
Argonne National Lab, as a shared library in the default <mpich_>`_, a popular open-source version of MPI, as a shared library
/usr/local/lib location: in the default /usr/local/lib location:
.. _mpich: http://www-unix.mcs.anl.gov/mpi .. _mpich: https://www.mpich.org
.. code-block:: bash
.. parsed-literal::
./configure --enable-shared ./configure --enable-shared
make make
make install make install
You may need to use "sudo make install" in place of the last line if You may need to use ``sudo make install`` in place of the last line if
you do not have write privileges for /usr/local/lib. The end result you do not have write privileges for ``/usr/local/lib`` or use the
should be the file /usr/local/lib/libmpich.so. ``--prefix`` configuration option to select an installation folder,
where you do have write access. The end result should be the file
``/usr/local/lib/libmpich.so``. On many Linux installations the folder
``${HOME}/.local`` is an alternative to using ``/usr/local`` and does
not require superuser or sudo access. In that case the configuration
step becomes:
.. code-block:: bash
./configure --enable-shared --prefix=${HOME}/.local
Avoiding to use "sudo" for custom software installation (i.e. from source
and not through a package manager tool provided by the OS) is generally
recommended to ensure the integrity of the system software installation.
---------- ----------
.. _debug:
Excluding or removing debug support
-----------------------------------
By default the compilation settings will include the *-g* flag which
instructs the compiler to include debug information (e.g. which line of
source code a particular instruction correspond to). This can be
extremely useful in case LAMMPS crashes and can help to provide crucial
information in :doc:`tracking down the origin of a crash <Errors_debug>`
and help the LAMMPS developers fix bugs in the source code. However,
this increases the storage requirements for object files, libraries, and
the executable 3-5 fold.
If this is a concern, you can change the compilation settings or remove
the debug information from the LAMMPS executable:
- **Traditional make**: edit your ``Makefile.<machine>`` to remove the
*-g* flag from the ``CCFLAGS`` and ``LINKFLAGS`` definitions
- **CMake**: use ``-D CMAKE_BUILD_TYPE=Release`` or explicitly reset
the applicable compiler flags (best done using the text mode or
graphical user interface).
- **Remove debug info**: If you are only concerned about the executable
being too large, you can use the ``strip`` tool (e.g. ``strip
lmp_serial``) to remove the debug information from the executable file.
Do not strip libraries or object files, as that will render them unusable.
----------
.. _doc: .. _doc:
Build the LAMMPS documentation Build the LAMMPS documentation
---------------------------------------- ----------------------------------------
**CMake variable**\ : The LAMMPS manual is written in `reStructuredText <rst_>`_ format which
can be translated to different output format using the `Sphinx <sphinx_>`_
document generator tool. Currently the translation to HTML and PDF (via
LaTeX) are supported. For that to work a Python 3 interpreter and
internet access is required. For the documentation build a python
based virtual environment is set up in the folder doc/docenv and various
python packages are installed into that virtual environment via the pip
tool. The actual translation is then done via make commands.
.. _rst: https://docutils.readthedocs.io/en/sphinx-docs/user/rst/quickstart.html
.. _sphinx: https://sphinx-doc.org
.. parsed-literal:: **Documentation make option**\ :
-D BUILD_DOC=value # yes or no (default) The following make commands can be issued in the doc folder of the
LAMMPS source distribution.
This will create the HTML doc pages within the CMake build directory. .. code-block:: bash
The reason to do this is if you want to "install" LAMMPS on a system
after the CMake build via "make install", and include the doc pages in
the install.
**Traditional make**\ : make html # create HTML doc pages in html directory
make pdf # create Developer.pdf and Manual.pdf in this directory
make fetch # fetch HTML and PDF files from LAMMPS web site
make clean # remove all intermediate files
make clean-all # reset the entire doc build environment
make anchor_check # scan for duplicate anchor labels
make style_check # check for complete and consistent style lists
make package_check # check for complete and consistent package lists
make spelling # spell-check the manual
Thus "make html" will create a "doc/html" directory with the HTML format
.. parsed-literal:: manual pages so that you can browse them with a web browser locally on
your system.
cd lammps/doc
make html # html doc pages
make pdf # single Manual.pdf file
This will create a lammps/doc/html dir with the HTML doc pages so that
you can browse them locally on your system. Type "make" from the
lammps/doc dir to see other options.
.. note:: .. note::
You can also download a tarball of the documentation for the You can also download a tarball of the documentation for the
current LAMMPS version (HTML and PDF files), from the website current LAMMPS version (HTML and PDF files), from the website
`download page <http://lammps.sandia.gov/download.html>`_. `download page <https://lammps.sandia.gov/download.html>`_.
**CMake build option**\ :
It is also possible to create the HTML version of the manual within
the :doc:`CMake build directory <Build_cmake>`. The reason for this
option is to include the installation of the HTML manual pages into
the "install" step when installing LAMMPS after the CMake build via
``make install``. The documentation build is included in the default
build target, but can also be requested independently with ``make doc``.
.. code-block:: bash
-D BUILD_DOC=value # yes or no (default)
---------- ----------
.. _tools: .. _tools:
Build LAMMPS tools Build LAMMPS tools
@ -380,19 +512,18 @@ Build LAMMPS tools
Some tools described in :doc:`Auxiliary tools <Tools>` can be built directly Some tools described in :doc:`Auxiliary tools <Tools>` can be built directly
using CMake or Make. using CMake or Make.
**CMake variable**\ : **CMake build3**\ :
.. code-block:: bash
.. parsed-literal::
-D BUILD_TOOLS=value # yes or no (default) -D BUILD_TOOLS=value # yes or no (default)
The generated binaries will also become part of the LAMMPS installation (see below) The generated binaries will also become part of the LAMMPS installation
(see below).
**Traditional make**\ : **Traditional make**\ :
.. code-block:: bash
.. parsed-literal::
cd lammps/tools cd lammps/tools
make all # build all binaries of tools make all # build all binaries of tools
@ -401,10 +532,8 @@ The generated binaries will also become part of the LAMMPS installation (see bel
make micelle2d # build only micelle2d tool make micelle2d # build only micelle2d tool
make thermo_extract # build only thermo_extract tool make thermo_extract # build only thermo_extract tool
---------- ----------
.. _install: .. _install:
Install LAMMPS after a build Install LAMMPS after a build
@ -416,10 +545,9 @@ a globally visible place on your system, for others to access. Note
that you may need super-user privileges (e.g. sudo) if the directory that you may need super-user privileges (e.g. sudo) if the directory
you want to copy files to is protected. you want to copy files to is protected.
**CMake variable**\ : **CMake build**\ :
.. code-block:: bash
.. parsed-literal::
cmake -D CMAKE_INSTALL_PREFIX=path [options ...] ../cmake cmake -D CMAKE_INSTALL_PREFIX=path [options ...] ../cmake
make # perform make after CMake command make # perform make after CMake command
@ -427,11 +555,6 @@ you want to copy files to is protected.
**Traditional make**\ : **Traditional make**\ :
There is no "install" option in the src/Makefile for LAMMPS. If you There is no "install" option in the ``src/Makefile`` for LAMMPS. If
wish to do this you will need to first build LAMMPS, then manually you wish to do this you will need to first build LAMMPS, then manually
copy the desired LAMMPS files to the appropriate system directories. copy the desired LAMMPS files to the appropriate system directories.
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -1,222 +1,162 @@
Build LAMMPS with CMake Build LAMMPS with CMake
======================= =======================
This page is a short summary of how to use CMake to build LAMMPS. This page describes how to use `CMake <https://cmake.org>`_ in general
Details on CMake variables that enable specific LAMMPS build options to build LAMMPS. Details for specific compile time settings and options
are given on the pages linked to from the :doc:`Build <Build>` doc page. to enable and configure add-on packages are discussed with those
packages. Links to those pages on the :doc:`Build overview <Build>`
page.
Richard Berger (Temple U) has also written a `more comprehensive guide <https://github.com/lammps/lammps/blob/master/cmake/README.md>`_ The following text assumes some familiarity with CMake and focuses on
for how to use CMake to build LAMMPS. If you are new to CMake it is a using the command line tool ``cmake`` and what settings are supported
good place to start. for building LAMMPS. A more detailed tutorial on how to use ``cmake``
itself, the text mode or graphical user interface, change the generated
output files for different build tools and development environments is
on a :doc:`separate page <Howto_cmake>`.
.. note::
LAMMPS currently requires that CMake version 3.10 or later is available;
version 3.12 or later is preferred.
.. warning::
You must not mix the :doc:`traditional make based <Build_make>`
LAMMPS build procedure with using CMake. Thus no packages may be
installed or a build been previously attempted in the LAMMPS source
directory by using ``make <machine>``. CMake will detect if this is
the case and generate an error. To remove conflicting files from the
``src`` you can use the command ``make no-all purge`` which will
un-install all packages and delete all auto-generated files.
---------- Advantages of using CMake
^^^^^^^^^^^^^^^^^^^^^^^^^
CMake is an alternative to compiling LAMMPS in the traditional way
through :doc:`(manually customized) makefiles <Build_make>` and a recent
addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL)
and Richard Berger (Temple U). Using CMake has multiple advantages that
are specifically helpful for people with limited experience in compiling
software or for people that want to modify or extend LAMMPS.
- CMake can detect available hardware, tools, features, and libraries
and adapt the LAMMPS default build configuration accordingly.
- CMake can generate files for different build tools and integrated
development environments (IDE).
- CMake supports customization of settings with a text mode or graphical
user interface. No knowledge of file formats or and complex command
line syntax required.
- All enabled components are compiled in a single build operation.
- Automated dependency tracking for all files and configuration options.
- Support for true out-of-source compilation. Multiple configurations
and settings with different choices of LAMMPS packages, settings, or
compilers can be configured and built concurrently from the same
source tree.
- Simplified packaging of LAMMPS for Linux distributions, environment
modules, or automated build tools like `Homebrew <https://brew.sh/>`_.
- Integration of automated regression testing (the LAMMPS side for that
is still under development).
.. _cmake_build:
Getting started
^^^^^^^^^^^^^^^
Building LAMMPS with CMake is a two-step process. First you use CMake Building LAMMPS with CMake is a two-step process. First you use CMake
to create a build environment in a new directory. On Linux systems, to generate a build environment in a new directory. For that purpose
this will be based on makefiles for use with make. Then you use the you can use either the command-line utility ``cmake`` (or ``cmake3``),
make command to build LAMMPS, which uses the created the text-mode UI utility ``ccmake`` (or ``ccmake3``) or the graphical
Makefile(s). Example: utility ``cmake-gui``, or use them interchangeably. The second step is
then the compilation and linking of all objects, libraries, and
executables. Here is a minimal example using the command line version of
CMake to build LAMMPS with no add-on packages enabled and no
customization:
.. code-block:: bash
.. parsed-literal:: cd lammps # change to the LAMMPS distribution directory
mkdir build; cd build # create and use a build directory
cmake ../cmake # configuration reading CMake scripts from ../cmake
cmake --build . # compilation (or type "make")
cd lammps # change to the LAMMPS distribution directory This will create and change into a folder called ``build``, then run the
mkdir build; cd build # create a new directory (folder) for build configuration step to generate build files for the default build command
cmake [options ...] ../cmake # configuration with (command-line) cmake and then launch that build command to compile LAMMPS. During the
make # compilation configuration step CMake will try to detect whether support for MPI,
OpenMP, FFTW, gzip, JPEG, PNG, and ffmpeg are available and enable the
corresponding configuration settings. The progress of this
configuration can be followed on the screen and a summary of selected
options and settings will be printed at the end. The ``cmake --build
.`` command will launch the compilation, which, if successful, will
ultimately produce a library ``liblammps.a`` and the LAMMPS executable
``lmp`` inside the ``build`` folder.
The cmake command will detect available features, enable selected Compilation can take a long time, since LAMMPS is a large project with
packages and options, and will generate the build environment. By default many features. If your machine has multiple CPU cores (most do these
this build environment will be created for "Unix Makefiles" on most days), you can speed this up by compiling sources in parallel with
platforms and particularly on Linux. However, alternate build tools ``make -j N`` (with N being the maximum number of concurrently executed
(e.g. Ninja) and support files for Integrated Development Environments tasks). Also installation of the `ccache <https://ccache.dev/>`_ (=
(IDE) like Eclipse, CodeBlocks, or Kate can be generated, too. This is Compiler Cache) software may speed up repeated compilation even more,
selected via the "-G" command line flag. For the rest of the documentation e.g. during code development.
we will assume that the build environment is generated for makefiles
and thus the make command will be used to compile and link LAMMPS as
indicated above, producing (by default) an executable called "lmp" and
a library called "liblammps.a" in the "build" folder. When generating
a build environment for the "Ninja" build tool, the build command would
be "ninja" instead of "make".
If your machine has multiple CPU cores (most do these days), using a After the initial build, whenever you edit LAMMPS source files, enable
command like "make -jN" (with N being the number of available local or disable packages, change compiler flags or build options, you must
CPU cores) can be much faster. If you plan to do development on re-compile and relink the LAMMPS executable with ``cmake --build .`` (or
LAMMPS or need to re-compile LAMMPS repeatedly, installation of the ``make``). If the compilation fails for some reason, try running
ccache (= Compiler Cache) software may speed up repeated compilation ``cmake .`` and then compile again. The included dependency tracking
even more. should make certain that only the necessary subset of files are
re-compiled. You can also delete compiled objects, libraries and
executables with ``cmake --build . clean`` (or ``make clean``).
After compilation, you may optionally install the LAMMPS executable into After compilation, you may optionally install the LAMMPS executable into
your system with: your system with:
.. code-block:: bash
.. parsed-literal:: make install # optional, copy compiled files into installation location
make install # optional, copy LAMMPS executable & library elsewhere This will install the LAMMPS executable and library, some tools (if
configured) and additional files like LAMMPS API headers, manpages,
potential and force field files. The location of the installation tree
defaults to ``${HOME}/.local``.
This will install the lammps executable and library (if requested), some .. _cmake_options:
tools (if configured) and additional files like library API headers,
manpages, potential and force field files. The location of the installation Configuration and build options
tree is set by the CMake variable "CMAKE\_INSTALL\_PREFIX" which defaults ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
to ${HOME}/.local
The CMake commands have one mandatory argument: a folder containing a
file called ``CMakeLists.txt`` (for LAMMPS it is located in the
``cmake`` folder) or a build folder containing a file called
``CMakeCache.txt``, which is generated at the end of the CMake
configuration step. The cache file contains all current CMake settings.
To modify settings, enable or disable features, you need to set *variables*
with either the *-D* command line flag (``-D VARIABLE1_NAME=value``) or
change them in the text mode of graphical user interface. The *-D* flag
can be used several times in one command.
For your convenience we provide :ref:`CMake presets <cmake_presets>`
that combine multiple settings to enable optional LAMMPS packages or use
a different compiler tool chain. Those are loaded with the *-C* flag
(``-C ../cmake/presets/minimal.cmake``). This step would only be needed
once, as the settings from the preset files are stored in the
``CMakeCache.txt`` file. It is also possible to customize the build
by adding one or more *-D* flags to the CMake command line.
Generating files for alternate build tools (e.g. Ninja) and project files
for IDEs like Eclipse, CodeBlocks, or Kate can be selected using the *-G*
command line flag. A list of available generator settings for your
specific CMake version is given when running ``cmake --help``.
---------- Installing CMake
^^^^^^^^^^^^^^^^
There are 3 variants of CMake: a command-line version (cmake), a text mode
UI version (ccmake), and a graphical GUI version (cmake-GUI). You can use
any of them interchangeably to configure and create the LAMMPS build
environment. On Linux all the versions produce a Makefile as their
output. See more details on each below.
You can specify a variety of options with any of the 3 versions, which
affect how the build is performed and what is included in the LAMMPS
executable. Links to pages explaining all the options are listed on
the :doc:`Build <Build>` doc page.
You must perform the CMake build system generation and compilation in
a new directory you create. It can be anywhere on your local machine.
In these Build pages we assume that you are building in a directory
called "lammps/build". You can perform separate builds independently
with different options, so long as you perform each of them in a
separate directory you create. All the auxiliary files created by one
build process (executable, object files, log files, etc) are stored in
this directory or sub-directories within it that CMake creates.
.. note::
To perform a CMake build, no packages can be installed or a
build been previously attempted in the LAMMPS src directory by using
"make" commands to :doc:`perform a conventional LAMMPS build <Build_make>`. CMake detects if this is the case and
generates an error, telling you to type "make no-all purge" in the src
directory to un-install all packages. The purge removes all the \*.h
files auto-generated by make.
You must have CMake version 2.8 or later on your system to build
LAMMPS. A handful of LAMMPS packages (KOKKOS, LATTE, MSCG) require a
later version. CMake will print a message telling you if a later
version is required. Installation instructions for CMake are below.
After the initial build, if you edit LAMMPS source files, or add your
own new files to the source directory, you can just re-type make from
your build directory and it will re-compile only the files that have
changed. If you want to change CMake options you can run cmake (or
ccmake or cmake-gui) again from the same build directory and alter
various options; see details below. Or you can remove the entire build
folder, recreate the directory and start over.
----------
**Command-line version of CMake**\ :
.. parsed-literal::
cmake [options ...] /path/to/lammps/cmake # build from any dir
cmake [options ...] ../cmake # build from lammps/build
The cmake command takes one required argument, which is the LAMMPS
cmake directory which contains the CMakeLists.txt file.
The argument can be preceeded or followed by various CMake
command-line options. Several useful ones are:
.. parsed-literal::
-D CMAKE_INSTALL_PREFIX=path # where to install LAMMPS executable/lib if desired
-D CMAKE_BUILD_TYPE=type # type = RelWithDebInfo (default), Release, MinSizeRel, or Debug
-G output # style of output CMake generates
-DVARIABLE=value # setting for a LAMMPS feature to enable
-D VARIABLE=value # ditto, but cannot come after CMakeLists.txt dir
-C path/to/preset/file # load some CMake settings before configuring
All the LAMMPS-specific -D variables that a LAMMPS build supports are
described on the pages linked to from the :doc:`Build <Build>` doc page.
All of these variable names are upper-case and their values are
lower-case, e.g. -D LAMMPS\_SIZES=smallbig. For boolean values, any of
these forms can be used: yes/no, on/off, 1/0.
On Unix/Linux machines, CMake generates a Makefile by default to
perform the LAMMPS build. Alternate forms of build info can be
generated via the -G switch, e.g. Visual Studio on a Windows machine,
Xcode on MacOS, or KDevelop on Linux. Type "cmake --help" to see the
"Generator" styles of output your system supports.
.. note::
When CMake runs, it prints configuration info to the screen.
You should review this to verify all the features you requested were
enabled, including packages. You can also see what compilers and
compile options will be used for the build. Any errors in CMake
variable syntax will also be flagged, e.g. mis-typed variable names or
variable values.
CMake creates a CMakeCache.txt file when it runs. This stores all the
settings, so that when running CMake again you can use the current
folder '.' instead of the path to the LAMMPS cmake folder as the
required argument to the CMake command. Either way the existing
settings will be inherited unless the CMakeCache.txt file is removed.
If you later want to change a setting you can rerun cmake in the build
directory with different setting. Please note that some automatically
detected variables will not change their value when you rerun cmake.
In these cases it is usually better to first remove all the
files/directories in the build directory, or start with a fresh build
directory.
----------
**Curses version (terminal-style menu) of CMake**\ :
.. parsed-literal::
ccmake ../cmake
You initiate the configuration and build environment generation steps
separately. For the first you have to type **c**\ , for the second you
have to type **g**\ . You may need to type **c** multiple times, and may be
required to edit some of the entries of CMake configuration variables
in between. Please see the `ccmake manual <https://cmake.org/cmake/help/latest/manual/ccmake.1.html>`_ for
more information.
----------
**GUI version of CMake**\ :
.. parsed-literal::
cmake-gui ../cmake
You initiate the configuration and build environment generation steps
separately. For the first you have to click on the **Configure** button,
for the second you have to click on the **Generate** button. You may
need to click on **Configure** multiple times, and may be required to
edit some of the entries of CMake configuration variables in between.
Please see the `cmake-gui manual <https://cmake.org/cmake/help/latest/manual/cmake-gui.1.html>`_
for more information.
----------
**Installing CMake**
Check if your machine already has CMake installed: Check if your machine already has CMake installed:
.. code-block:: bash
.. parsed-literal::
which cmake # do you have it? which cmake # do you have it?
which cmake3 # version 3 may have this name which cmake3 # version 3 may have this name
@ -225,21 +165,16 @@ Check if your machine already has CMake installed:
On clusters or supercomputers which use environment modules to manage On clusters or supercomputers which use environment modules to manage
software packages, do this: software packages, do this:
.. code-block:: bash
.. parsed-literal:: module list # is a module for cmake already loaded?
module avail # is a module for cmake available?
module load cmake # load cmake module with appropriate name
module list # is a cmake module already loaded? Most Linux distributions offer pre-compiled cmake packages through their
module avail # is a cmake module available? package management system. If you do not have CMake or a recent enough
module load cmake3 # load cmake module with appropriate name version (Note: for CentOS 7.x you need to enable the EPEL repository),
you can download the latest version from `https://cmake.org/download/
Most Linux distributions offer pre-compiled cmake packages through <https://cmake.org/download/>`_. Instructions on how to install it on
their package management system. If you do not have CMake or a new various platforms can be found `on this page
enough version, you can download the latest version at <https://cmake.org/install/>`_.
`https://cmake.org/download/ <https://cmake.org/download/>`_.
Instructions on how to install it on various platforms can be found
`on this page <https://cmake.org/install/>`_.
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -1,63 +1,60 @@
Development build options (CMake only) Development build options (CMake only)
====================================== ======================================
The CMake build of LAMMPS has a few extra options which are useful during The CMake build procedure of LAMMPS offers a few extra options which are
development, testing or debugging. useful during development, testing or debugging.
---------- ----------
.. _compilation: .. _compilation:
Verify compilation flags Verify compilation flags
------------------------------------------ ------------------------
Sometimes it is necessary to verify the complete sequence of compilation flags Sometimes it is necessary to verify the complete sequence of compilation flags
generated by the CMake build. To enable a more verbose output during generated by the CMake build. To enable a more verbose output during
compilation you can use the following option. compilation you can use the following option.
.. code-block:: bash
.. parsed-literal::
-D CMAKE_VERBOSE_MAKEFILE=value # value = no (default) or yes -D CMAKE_VERBOSE_MAKEFILE=value # value = no (default) or yes
Another way of doing this without reconfiguration is calling make with variable VERBOSE set to 1: Another way of doing this without reconfiguration is calling make with variable VERBOSE set to 1:
.. code-block:: bash
.. parsed-literal::
make VERBOSE=1 make VERBOSE=1
---------- ----------
.. _sanitizer: .. _sanitizer:
Address, Undefined Behavior, and Thread Sanitizer Support Address, Undefined Behavior, and Thread Sanitizer Support
------------------------------------------------------------------------- ---------------------------------------------------------
Compilers such as GCC and Clang support generating binaries which use different Compilers such as GCC and Clang support generating instrumented binaries
sanitizers to detect problems in code during run-time. They can detect `memory leaks <https://clang.llvm.org/docs/AddressSanitizer.html>`_, which use different sanitizer libraries to detect problems in code
code that runs into `undefined behavior <https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html>`_ of the during run-time. They can detect issues like:
language and `data races <https://clang.llvm.org/docs/ThreadSanitizer.html>`_ in threaded code.
The following settings allow you enable these features if your compiler supports - `memory leaks <https://clang.llvm.org/docs/AddressSanitizer.html>`_
it. Please note that they come with a performance hit. However, they are - `undefined behavior <https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html>`_
usually faster than using tools like Valgrind. - `data races <https://clang.llvm.org/docs/ThreadSanitizer.html>`_
Please note that this kind of instrumentation usually comes with a small
performance hit (much less than using tools like `Valgrind
<https://valgrind.org>`_). The to enable these features additional
compiler flags need to be added to the compilation and linking stages.
This is most easily done through setting the ``CMAKE_TUNE_FLAGS``
variable during configuration. Examples:
.. parsed-literal:: .. code-block:: bash
-D ENABLE_SANITIZE_ADDRESS=value # enable Address Sanitizer, value = no (default) or yes
-D ENABLE_SANITIZE_UNDEFINED=value # enable Undefined Behaviour Sanitizer, value = no (default) or yes
-D ENABLE_SANITIZE_THREAD=value # enable Thread Sanitizer, value = no (default) or yes
-D CMAKE_TUNE_FLAGS=-fsanitize=address # enable address sanitizer / memory leak checker
-D CMAKE_TUNE_FLAGS=-fsanitize=undefined # enable undefined behavior sanitizer
-D CMAKE_TUNE_FLAGS=-fsanitize=thread # enable thread sanitizer
---------- ----------
.. _testing: .. _testing:
Code Coverage and Testing Code Coverage and Testing
@ -71,50 +68,42 @@ developers can run the tests directly on their workstation.
this is incomplete and only represents a small subset of tests that we run this is incomplete and only represents a small subset of tests that we run
.. code-block:: bash
.. parsed-literal::
-D ENABLE_TESTING=value # enable simple run tests of LAMMPS, value = no (default) or yes -D ENABLE_TESTING=value # enable simple run tests of LAMMPS, value = no (default) or yes
-D LAMMPS_TESTING_SOURCE_DIR=path # path to lammps-testing repository (option if in custom location) -D LAMMPS_TESTING_SOURCE_DIR=path # path to lammps-testing repository (option if in custom location)
-D LAMMPS_TESTING_GIT_TAG=value # version of lammps-testing repository that should be used, value = master (default) or custom git commit or tag -D LAMMPS_TESTING_GIT_TAG=value # version of lammps-testing repository that should be used, value = master (default) or custom git commit or tag
If you enable testing in the CMake build it will create an additional target called "test". You can run them with: If you enable testing in the CMake build it will create an additional
target called "test". You can run them with:
.. code-block:: bash
.. parsed-literal:: cmake --build . test
make test
The test cases used come from the lammps-testing repository. They are The test cases used come from the lammps-testing repository. They are
derivatives of the examples folder with some modifications to make the run derivatives of the examples folder with some modifications to make the
faster. run faster.
You can also collect code coverage metrics while running the tests by enabling You can also collect code coverage metrics while running the tests by
coverage support during building. enabling coverage support during building.
.. code-block:: bash
.. parsed-literal::
-D ENABLE_COVERAGE=value # enable coverage measurements, value = no (default) or yes -D ENABLE_COVERAGE=value # enable coverage measurements, value = no (default) or yes
This will also add the following targets to generate coverage reports after running the LAMMPS executable: This will also add the following targets to generate coverage reports
after running the LAMMPS executable:
.. code-block:: bash
.. parsed-literal::
make test # run tests first! make test # run tests first!
make gen_coverage_html # generate coverage report in HTML format make gen_coverage_html # generate coverage report in HTML format
make gen_coverage_xml # generate coverage report in XML format make gen_coverage_xml # generate coverage report in XML format
These reports require GCOVR to be installed. The easiest way to do this to install it via pip: These reports require GCOVR to be installed. The easiest way to do this
to install it via pip:
.. code-block:: bash
.. parsed-literal::
pip install git+https://github.com/gcovr/gcovr.git pip install git+https://github.com/gcovr/gcovr.git
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

File diff suppressed because it is too large Load Diff

View File

@ -1,91 +1,259 @@
Link LAMMPS as a library to another code Link LAMMPS as a library to another code
======================================== ========================================
LAMMPS can be used as a library by another application, including LAMMPS is designed as a library of C++ objects and can thus be
Python scripts. The files src/library.cpp and library.h define the integrated into other applications including Python scripts.
C-style API for using LAMMPS as a library. See the :doc:`Howto library <Howto_library>` doc page for a description of the The files ``src/library.cpp`` and ``src/library.h`` define a
interface and how to extend it for your needs. C-style API for using LAMMPS as a library. See the :doc:`Howto
library <Howto_library>` doc page for a description of the interface
and how to extend it for your needs.
The :doc:`Build basics <Build_basics>` doc page explains how to build The :doc:`Build basics <Build_basics>` doc page explains how to build
LAMMPS as either a shared or static library. This results in one of LAMMPS as either a shared or static library. This results in a file
these 2 files: in the compilation folder called ``liblammps.a`` or ``liblammps_<name>.a``
in case of building a static library. In case of a shared library
the name is the same only that the suffix is going to be either ``.so``
or ``.dylib`` or ``.dll`` instead of ``.a`` depending on the OS.
In some cases the ``.so`` file may be a symbolic link to a file with
the suffix ``.so.0`` (or some other number).
liblammps.so # shared library .. note::
liblammps.a # static library
Care should be taken to use the same MPI library for the calling code
and the LAMMPS library. The ``library.h`` file includes ``mpi.h``
and uses definitions from it so those need to be available and
consistent. When LAMMPS is compiled with the included STUBS MPI
library, then its ``mpi.h`` file needs to be included. While it is
technically possible to use a full MPI library in the calling code
and link to a serial LAMMPS library compiled with MPI STUBS, it is
recommended to use the *same* MPI library for both, and then use
``MPI_Comm_split()`` in the calling code to pass a suitable
communicator with a subset of MPI ranks to the function creating the
LAMMPS instance.
---------- ----------
**Link with LAMMPS as a static library**\ : **Link with LAMMPS as a static library**\ :
The calling application can link to LAMMPS as a static library with a The calling application can link to LAMMPS as a static library with
link command like this: compilation and link commands as in the examples shown below. These
are examples for a code written in C in the file *caller.c*.
The benefit of linking to a static library is, that the resulting
executable is independent of that library since all required
executable code from the library is copied into the calling executable.
g++ caller.o -L/home/sjplimp/lammps/src -llammps -o caller *CMake build*\ :
The -L argument is the path to where the liblammps.a file is. The This assumes that LAMMPS has been configured without setting a
-llammps argument is shorthand for the file liblammps.a. ``LAMMPS_MACHINE`` name, installed with "make install", and the
``PKG_CONFIG_PATH`` environment variable has been updated to include the
``liblammps.pc`` file installed into the configured destination folder.
The commands to compile and link a coupled executable are then:
.. code-block:: bash
mpicc -c -O $(pkgconf liblammps --cflags) caller.c
mpicxx -o caller caller.o -$(pkgconf liblammps --libs)
*Traditional make*\ :
This assumes that LAMMPS has been compiled in the folder
``${HOME}/lammps/src`` with "make mpi". The commands to compile and link
a coupled executable are then:
.. code-block:: bash
mpicc -c -O -I${HOME}/lammps/src caller.c
mpicxx -o caller caller.o -L${HOME}/lammps/src -llammps_mpi
The *-I* argument is the path to the location of the ``library.h``
header file containing the interface to the LAMMPS C-style library
interface. The *-L* argument is the path to where the ``liblammps_mpi.a``
file is located. The *-llammps_mpi* argument is shorthand for telling the
compiler to link the file ``liblammps_mpi.a``. If LAMMPS has been
built as a shared library, then the linker will use ``liblammps_mpi.so``
instead. If both files are available, the linker will usually prefer
the shared library. In case of a shared library, you may need to update
the ``LD_LIBRARY_PATH`` environment variable or running the ``caller``
executable will fail since it cannot find the shared library at runtime.
However, it is only as simple as shown above for the case of a plain
LAMMPS library without any optional packages that depend on libraries
(bundled or external) or when using a shared library. Otherwise, you
need to include all flags, libraries, and paths for the coupled
executable, that are also required to link the LAMMPS executable.
*CMake build*\ :
When using CMake, additional libraries with sources in the lib folder
are built, but not included in ``liblammps.a`` and (currently) not
installed with "make install" and not included in the *pkgconfig*
configuration file. They can be found in the top level build folder,
but you have to determine the necessary link flags manually. It is
therefore recommended to either use the traditional make procedure to
build and link with a static library or build and link with a shared
library instead.
.. TODO: this needs to be updated to reflect that latest CMake changes after they are complete.
*Traditional make*\ :
After you have compiled a static LAMMPS library using the conventional
build system for example with "make mode=static serial". And you also
have installed the ``POEMS`` package after building its bundled library
in ``lib/poems``. Then the commands to build and link the coupled executable
change to:
.. code-block:: bash
gcc -c -O -I${HOME}/lammps/src/STUBS -I${HOME}/lammps/src -caller.c
g++ -o caller caller.o -L${HOME}/lammps/lib/poems \
-L${HOME}/lammps/src/STUBS -L${HOME}/lammps/src -llammps_serial -lpoems -lmpi_stubs
Note, that you need to link with "g++" instead of "gcc", since the
LAMMPS library is C++ code. You can display the currently applied
settings for building LAMMPS for the "serial" machine target by using
the command:
.. code-block:: bash
make mode=print serial
Which should output something like:
.. code-block:: bash
# Compiler:
CXX=g++
# Linker:
LD=g++
# Compilation:
CXXFLAGS=-g -O3 -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -I${HOME}/compile/lammps/lib/poems -I${HOME}/compile/lammps/src/STUBS
# Linking:
LDFLAGS=-g -O
# Libraries:
LDLIBS=-L${HOME}/compile/lammps/src -llammps_serial -L${HOME}/compile/lammps/lib/poems -L${HOME}/compile/lammps/src/STUBS -lpoems -lmpi_stubs
From this you can gather the necessary paths and flags. With
makefiles for other *machine* configurations you need to do the
equivalent and replace "serial" with the corresponding *machine* name
of the makefile.
---------- ----------
**Link with LAMMPS as a shared library**\ : **Link with LAMMPS as a shared library**\ :
If you wish to link to liblammps.so, the operating system finds shared When linking to LAMMPS built as a shared library, the situation becomes
libraries to load at run-time using the environment variable much simpler, as all dependent libraries and objects are either included
LD\_LIBRARY\_PATH. To enable this you can do one of two things: in the shared library or registered as a dependent library in the shared
library file. Thus those libraries need not to be specified when
linking the calling executable. Only the *-I* flags are needed. So the
example case from above of the serial version static LAMMPS library with
the POEMS package installed becomes:
(1) Copy the liblammps.so file to a location the system can find it, *CMake build*\ :
such as /usr/local/lib. I.e. a directory already listed in your
LD\_LIBRARY\_PATH variable. You can type
The commands with a shared LAMMPS library compiled with the CMake
build process are the same as for the static library.
.. parsed-literal:: .. code-block:: bash
mpicc -c -O $(pkgconf liblammps --cflags) caller.c
mpicxx -o caller caller.o -$(pkgconf --libs)
*Traditional make*\ :
The commands with a shared LAMMPS library compiled with the
traditional make build using "make mode=shared serial" becomes:
.. code-block:: bash
gcc -c -O -I${HOME}/lammps/src/STUBS -I${HOME}/lammps/src -caller.c
g++ -o caller caller.o -L${HOME}/lammps/src -llammps_serial
*Locating liblammps.so at runtime*\ :
However, now the ``liblammps.so`` file is required at runtime and needs
to be in a folder, where the shared linker program of the operating
system can find it. This would be either a folder like ``/usr/local/lib64``
or ``${HOME}/.local/lib64`` or a folder pointed to by the ``LD_LIBRARY_PATH``
environment variable. You can type
.. code-block:: bash
printenv LD_LIBRARY_PATH printenv LD_LIBRARY_PATH
to see what directories are in that list. to see what directories are in that list.
(2) Add the LAMMPS src directory (or the directory you perform CMake Or you can add the LAMMPS src directory (or the directory you performed
build in) to your LD\_LIBRARY\_PATH, so that the current version of the a CMake style build in) to your ``LD_LIBRARY_PATH``, so that the current
shared library is always available to programs that use it. version of the shared library is always available to programs that use it.
For the csh or tcsh shells, you would add something like this to your For the Bourne or Korn shells (/bin/sh, /bin/ksh, /bin/bash etc.), you
~/.cshrc file: would add something like this to your ``${HOME}/.profile`` file:
.. code-block:: bash
.. parsed-literal:: LD_LIBRARY_PATH ${LD_LIBRARY_PATH-/usr/lib64}:${HOME}/lammps/src
export LD_LIBRARY_PATH
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src For the csh or tcsh shells, you would equivalently add something like this
to your ``${HOME}/.cshrc`` file:
.. code-block:: csh
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${HOME}/lammps/src
You can verify whether all required shared libraries are found with the
``ldd`` tool. Example:
.. code-block:: bash
$ LD_LIBRARY_PATH=/home/user/lammps/src ldd caller
linux-vdso.so.1 (0x00007ffe729e0000)
liblammps.so => /home/user/lammps/src/liblammps.so (0x00007fc91bb9e000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fc91b984000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc91b83e000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc91b824000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc91b65b000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc91c094000)
If a required library is missing, you would get a 'not found' entry:
.. code-block:: bash
$ ldd caller
linux-vdso.so.1 (0x00007ffd672fe000)
liblammps.so => not found
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fb7c7e86000)
libm.so.6 => /usr/lib64/libm.so.6 (0x00007fb7c7d40000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007fb7c7d26000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007fb7c7b5d000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb7c80a2000)
---------- ----------
**Calling the LAMMPS library**\ : **Calling the LAMMPS library**\ :
Either flavor of library (static or shared) allows one or more LAMMPS Either flavor of library (static or shared) allows one or more LAMMPS
objects to be instantiated from the calling program. objects to be instantiated from the calling program. When used from a
C++ program, most of the symbols and functions in LAMMPS are wrapped
in a ``LAMMPS_NS`` namespace; you can safely use any of its classes and
methods from within the calling code, as needed, and you will not incur
conflicts with functions and variables in your code that share the name.
This, however, does not extend to all additional libraries bundled with
LAMMPS in the lib folder and some of the low-level code of some packages.
When used from a C++ program, all of LAMMPS is wrapped in a LAMMPS\_NS To be compatible with C, Fortran, Python programs, the library has a simple
namespace; you can safely use any of its classes and methods from C-style interface, provided in ``src/library.cpp`` and ``src/library.h``.
within the calling code, as needed.
When used from a C or Fortran program, the library has a simple
C-style interface, provided in src/library.cpp and src/library.h.
See the :doc:`Python library <Python_library>` doc page for a See the :doc:`Python library <Python_library>` doc page for a
description of the Python interface to LAMMPS, which wraps the C-style description of the Python interface to LAMMPS, which wraps the C-style
interface. interface from a shared library through the `ctypes python module <ctypes_>`_.
See the sample codes in examples/COUPLE/simple for examples of C++ and See the sample codes in ``examples/COUPLE/simple`` for examples of C++ and
C and Fortran codes that invoke LAMMPS through its library interface. C and Fortran codes that invoke LAMMPS through its library interface.
Other examples in the COUPLE directory use coupling ideas discussed on Other examples in the COUPLE directory use coupling ideas discussed on
the :doc:`Howto couple <Howto_couple>` doc page. the :doc:`Howto couple <Howto_couple>` doc page.
.. _ctypes: https://docs.python.org/3/library/ctypes.html
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -2,71 +2,109 @@ Build LAMMPS with make
====================== ======================
Building LAMMPS with traditional makefiles requires that you have a Building LAMMPS with traditional makefiles requires that you have a
Makefile."machine" file appropriate for your system in the src/MAKE, ``Makefile.<machine>`` file appropriate for your system in either the
src/MAKE/MACHINES, src/MAKE/OPTIONS, or src/MAKE/MINE directory (see ``src/MAKE``, ``src/MAKE/MACHINES``, ``src/MAKE/OPTIONS``, or
below). It can include various options for customizing your LAMMPS ``src/MAKE/MINE`` directory (see below). It can include various options
build with a number of global compilation options and features. for customizing your LAMMPS build with a number of global compilation
options and features.
To include LAMMPS packages (i.e. optional commands and styles) you Requirements
must install them first, as discussed on the :doc:`Build package <Build_package>` doc page. If the packages require ^^^^^^^^^^^^
provided or external libraries, you must build those libraries before
building LAMMPS. Building :doc:`LAMMPS with CMake <Build_cmake>` can
automate all of this for many types of machines, especially
workstations, desktops and laptops, so we suggest you try it first.
These commands perform a default LAMMPS build, producing the LAMMPS Those makefiles are written for and tested with GNU make and may not
executable lmp\_serial or lmp\_mpi in lammps/src: be compatible with other make programs. In most cases, if the "make"
program is not GNU make, then there will be a GNU make program
available under the name "gmake". If GNU make or a compatible make is
not available, you may have to first install it or switch to building
with :doc:`CMake <Build_cmake>`. The makefiles of the traditional
make based build process and the scripts they are calling expect a few
additional tools to be available and functioning.
* a working C/C++ compiler toolchain supporting the C++11 standard; on
Linux these are often the GNU compilers. Some older compilers
require adding flags like ``-std=c++11`` to enable the C++11 mode.
* a Bourne shell compatible "Unix" shell program (often this is ``bash``)
* a few shell utilities: ``ls``, ``mv``, ``ln``, ``rm``, ``grep``, ``sed``, ``tr``, ``cat``, ``touch``, ``diff``, ``dirname``
* python (optional, required for ``make lib-<pkg>`` in the src folder).
python scripts are currently tested with python 2.7 and 3.6. The procedure
for :doc:`building the documentation <Manual_build>` requires python 3.
.. parsed-literal:: Getting started
^^^^^^^^^^^^^^^
cd lammps/src To include LAMMPS packages (i.e. optional commands and styles) you must
make serial # build a serial LAMMPS executable enable (or "install") them first, as discussed on the :doc:`Build
package <Build_package>` doc page. If a packages requires (provided or
external) libraries, you must configure and build those libraries
**before** building LAMMPS itself and especially **before** enabling
such a package with ``make yes-<package>``. Building :doc:`LAMMPS with
CMake <Build_cmake>` can automate much of this for many types of
machines, especially workstations, desktops, and laptops, so we suggest
you try it first when building LAMMPS in those cases.
The commands below perform a default LAMMPS build, producing the LAMMPS
executable ``lmp_serial`` and ``lmp_mpi`` in ``lammps/src``:
.. code-block:: bash
cd lammps/src # change to main LAMMPS source folder
make serial # build a serial LAMMPS executable using GNU g++
make mpi # build a parallel LAMMPS executable with MPI make mpi # build a parallel LAMMPS executable with MPI
make # see a variety of make options make # see a variety of make options
This initial compilation can take a long time, since LAMMPS is a large Compilation can take a long time, since LAMMPS is a large project with
project with many features. If your machine has multiple CPU cores many features. If your machine has multiple CPU cores (most do these
(most do these days), using a command like "make -jN mpi" (with N = days), you can speed this up by compiling sources in parallel with
the number of available CPU cores) can be much faster. If you plan to ``make -j N`` (with N being the maximum number of concurrently executed
do development on LAMMPS or need to re-compile LAMMPS repeatedly, the tasks). Also installation of the `ccache <https://ccache.dev/>`_ (=
installation of the ccache (= Compiler Cache) software may speed up Compiler Cache) software may speed up repeated compilation even more,
compilation even more. e.g. during code development.
After the initial build, whenever you edit LAMMPS source files, or add After the initial build, whenever you edit LAMMPS source files, or add
or remove new files to the source directory (e.g. by installing or or remove new files to the source directory (e.g. by installing or
uninstalling packages), you must re-compile and relink the LAMMPS uninstalling packages), you must re-compile and relink the LAMMPS
executable with the same "make" command. This makefiles dependencies executable with the same ``make <machine>`` command. The makefile's
should insure that only the subset of files that need to be are dependency tracking should insure that only the necessary subset of
re-compiled. files are re-compiled. If you change settings in the makefile, you have
to recompile *everything*. To delete all objects you can use ``make
clean-<machine>``.
.. note:: .. note::
When you build LAMMPS for the first time, a long list of \*.d Before the actual compilation starts, LAMMPS will perform several
files will be printed out rapidly. This is not an error; it is the steps to collect information from the configuration and setup that
Makefile doing its normal creation of dependencies. is then embedded into the executable. When you build LAMMPS for
the first time, it will also compile a tool to quickly assemble
a list of dependencies, that are required for the make program to
correctly detect which parts need to be recompiled after changes
were made to the sources.
Customized builds and alternate makefiles
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---------- The ``src/MAKE`` directory tree contains the ``Makefile.<machine>``
files included in the LAMMPS distribution. Typing ``make example`` uses
``Makefile.example`` from one of those folders, if available. Thus the
``make serial`` and ``make mpi`` lines above use
``src/MAKE/Makefile.serial`` and ``src/MAKE/Makefile.mpi``,
respectively. Other makefiles are in these directories:
.. code-block:: bash
The lammps/src/MAKE tree contains all the Makefile.machine files
included in the LAMMPS distribution. Typing "make machine" uses
Makefile.machine. Thus the "make serial" or "make mpi" lines above
use Makefile.serial and Makefile.mpi. Others are in these dirs:
.. parsed-literal::
OPTIONS # Makefiles which enable specific options OPTIONS # Makefiles which enable specific options
MACHINES # Makefiles for specific machines MACHINES # Makefiles for specific machines
MINE # customized Makefiles you create (you may need to create this folder) MINE # customized Makefiles you create (you may need to create this folder)
Typing "make" lists all the available Makefile.machine files. A file Simply typing ``make`` lists all the available ``Makefile.<machine>``
with the same name can appear in multiple folders (not a good idea). files with a single line description toward the end of the output. A
The order the dirs are searched is as follows: src/MAKE/MINE, file with the same name can appear in multiple folders (not a good
src/MAKE, src/MAKE/OPTIONS, src/MAKE/MACHINES. This gives preference idea). The order the directories are searched is as follows:
to a customized file you put in src/MAKE/MINE. ``src/MAKE/MINE``, ``src/MAKE``, ``src/MAKE/OPTIONS``,
``src/MAKE/MACHINES``. This gives preference to a customized file you
put in ``src/MAKE/MINE``. If you create your own custom makefile under
a new name, please edit the first line with the description and machine
name, so you will not confuse yourself, when looking at the machine
summary.
Makefiles you may wish to try include these (some require a package Makefiles you may wish to try include these (some require a package
first be installed). Many of these include specific compiler flags first be installed). Many of these include specific compiler flags
@ -75,8 +113,7 @@ customized machine Makefile are contributed by users. Since both
compilers, OS configurations, and LAMMPS itself keep changing, their compilers, OS configurations, and LAMMPS itself keep changing, their
settings may become outdated: settings may become outdated:
.. code-block:: bash
.. parsed-literal::
make mac # build serial LAMMPS on a Mac make mac # build serial LAMMPS on a Mac
make mac_mpi # build parallel LAMMPS on a Mac make mac_mpi # build parallel LAMMPS on a Mac
@ -87,8 +124,3 @@ settings may become outdated:
make kokkos_omp # build with the KOKKOS package for OpenMP make kokkos_omp # build with the KOKKOS package for OpenMP
make kokkos_cuda_mpi # build with the KOKKOS package for GPUs make kokkos_cuda_mpi # build with the KOKKOS package for GPUs
make kokkos_phi # build with the KOKKOS package for KNLs make kokkos_phi # build with the KOKKOS package for KNLs
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -14,10 +14,13 @@ package. In general there is no need to include a package if you
never plan to use its features. never plan to use its features.
If you get a run-time error that a LAMMPS command or style is If you get a run-time error that a LAMMPS command or style is
"Unknown", it is often because the command is contained in a package, "unknown", it is often because the command is contained in a package,
and your build did not include that package. Running LAMMPS with the and your build did not include that package. If the command or style
:doc:`-h command-line switch <Run_options>` will print all the included *is* available in a package included in the LAMMPS distribution,
packages and commands for that executable. the error message will indicate which package would be needed.
Running LAMMPS with the :doc:`-h command-line switch <Run_options>`
will print *all* optional commands and packages that were enabled
when building that executable.
For the majority of packages, if you follow the single step below to For the majority of packages, if you follow the single step below to
include it, you can then build LAMMPS exactly the same as you would include it, you can then build LAMMPS exactly the same as you would
@ -42,17 +45,15 @@ packages:
The mechanism for including packages is simple but different for CMake The mechanism for including packages is simple but different for CMake
versus make. versus make.
**CMake variables**\ : **CMake build**\ :
.. code-block:: csh
.. parsed-literal::
-D PKG_NAME=value # yes or no (default) -D PKG_NAME=value # yes or no (default)
Examples: Examples:
.. code-block:: csh
.. parsed-literal::
-D PKG_MANYBODY=yes -D PKG_MANYBODY=yes
-D PKG_USER-INTEL=yes -D PKG_USER-INTEL=yes
@ -73,8 +74,7 @@ once with CMake.
**Traditional make**\ : **Traditional make**\ :
.. code-block:: bash
.. parsed-literal::
cd lammps/src cd lammps/src
make ps # check which packages are currently installed make ps # check which packages are currently installed
@ -84,8 +84,7 @@ once with CMake.
Examples: Examples:
.. code-block:: bash
.. parsed-literal::
make no-rigid make no-rigid
make yes-user-intel make yes-user-intel
@ -119,7 +118,7 @@ are already included. Likewise, if a package is excluded, other files
dependent on that package are also excluded. dependent on that package are also excluded.
When you download a LAMMPS tarball or download LAMMPS source files When you download a LAMMPS tarball or download LAMMPS source files
from the Git or SVN repositories, no packages are pre-installed in the from the git repository, no packages are pre-installed in the
src directory. src directory.
.. note:: .. note::
@ -129,16 +128,17 @@ src directory.
That is no longer the case, so that CMake will build as-is without the That is no longer the case, so that CMake will build as-is without the
need to un-install those packages. need to un-install those packages.
---------- ----------
.. _cmake_presets:
**CMake shortcuts for installing many packages**\ : **CMake shortcuts for installing many packages**\ :
Instead of specifying all the CMake options via the command-line, Instead of specifying all the CMake options via the command-line,
CMake allows initializing the variable cache using script files. These CMake allows initializing its settings cache using script files.
are regular CMake files which can manipulate and set variables, and These are regular CMake files which can manipulate and set CMake
can also contain control flow constructs. variables (which represent selected options), and can also contain
control flow constructs for more complex operations.
LAMMPS includes several of these files to define configuration LAMMPS includes several of these files to define configuration
"presets", similar to the options that exist for the Make based "presets", similar to the options that exist for the Make based
@ -146,33 +146,27 @@ system. Using these files you can enable/disable portions of the
available packages in LAMMPS. If you need a custom preset you can take available packages in LAMMPS. If you need a custom preset you can take
one of them as a starting point and customize it to your needs. one of them as a starting point and customize it to your needs.
+-------------------------------------------------------------+-----------------------------------------------------------+ .. code-block:: bash
| cmake -C ../cmake/presets/all\_on.cmake [OPTIONS] ../cmake | enable all packages |
+-------------------------------------------------------------+-----------------------------------------------------------+ cmake -C ../cmake/presets/minimal.cmake [OPTIONS] ../cmake # enable just a few core packages
| cmake -C ../cmake/presets/all\_off.cmake [OPTIONS] ../cmake | disable all packages | cmake -C ../cmake/presets/most.cmake [OPTIONS] ../cmake # enable most packages
+-------------------------------------------------------------+-----------------------------------------------------------+ cmake -C ../cmake/presets/nolib.cmake [OPTIONS] ../cmake # disable packages that do require extra libraries or tools
| cmake -C ../cmake/presets/minimal.cmake [OPTIONS] ../cmake | enable just a few core packages | cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake # change settings to use the Clang compilers by default
+-------------------------------------------------------------+-----------------------------------------------------------+ cmake -C ../cmake/presets/intel.cmake [OPTIONS] ../cmake # change settings to use the Intel compilers by default
| cmake -C ../cmake/presets/most.cmake [OPTIONS] ../cmake | enable most common packages | cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages
+-------------------------------------------------------------+-----------------------------------------------------------+ cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages
| cmake -C ../cmake/presets/nolib.cmake [OPTIONS] ../cmake | disable packages that do require extra libraries or tools | mingw64-cmake -C ../cmake/presets/mingw-cross.cmake [OPTIONS] ../cmake # compile with MinGW cross compilers
+-------------------------------------------------------------+-----------------------------------------------------------+
| cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake | change settings to use the Clang compilers by default |
+-------------------------------------------------------------+-----------------------------------------------------------+
| cmake -C ../cmake/presets/mingw.cmake [OPTIONS] ../cmake | enable all packages compatible with MinGW compilers |
+-------------------------------------------------------------+-----------------------------------------------------------+
.. note:: .. note::
Running cmake this way manipulates the variable cache in your Running cmake this way manipulates the CMake settings cache in your
current build directory. You can combine multiple presets and options current build directory. You can combine multiple presets and options
in a single cmake run, or change settings incrementally by running in a single cmake run, or change settings incrementally by running
cmake with new flags. cmake with new flags.
**Example:** **Example:**
.. code-block:: bash
.. parsed-literal::
# build LAMMPS with most commonly used packages, but then remove # build LAMMPS with most commonly used packages, but then remove
# those requiring additional library or tools, but still enable # those requiring additional library or tools, but still enable
@ -188,49 +182,40 @@ one of them as a starting point and customize it to your needs.
# but leaving all other settings untouched. You can run: # but leaving all other settings untouched. You can run:
cmake -C ../cmake/presets/no_all.cmake . cmake -C ../cmake/presets/no_all.cmake .
---------- ----------
**Make shortcuts for installing many packages**\ : **Make shortcuts for installing many packages**\ :
The following commands are useful for managing package source files The following commands are useful for managing package source files
and their installation when building LAMMPS via traditional make. and their installation when building LAMMPS via traditional make.
Just type "make" in lammps/src to see a one-line summary. Just type ``make`` in lammps/src to see a one-line summary.
These commands install/un-install sets of packages: These commands install/un-install sets of packages:
+-----------------------------------+-----------------------------------------------------+ .. code-block:: bash
| make yes-all | install all packages |
+-----------------------------------+-----------------------------------------------------+
| make no-all | un-install all packages |
+-----------------------------------+-----------------------------------------------------+
| make yes-standard or make yes-std | install standard packages |
+-----------------------------------+-----------------------------------------------------+
| make no-standard or make no-std | un-install standard packages |
+-----------------------------------+-----------------------------------------------------+
| make yes-user | install user packages |
+-----------------------------------+-----------------------------------------------------+
| make no-user | un-install user packages |
+-----------------------------------+-----------------------------------------------------+
| make yes-lib | install packages that require extra libraries |
+-----------------------------------+-----------------------------------------------------+
| make no-lib | un-install packages that require extra libraries |
+-----------------------------------+-----------------------------------------------------+
| make yes-ext | install packages that require external libraries |
+-----------------------------------+-----------------------------------------------------+
| make no-ext | un-install packages that require external libraries |
+-----------------------------------+-----------------------------------------------------+
which install/un-install various sets of packages. Typing "make make yes-all # install all packages
package" will list all the these commands. make no-all # uninstall all packages
make yes-standard or make yes-std # install standard packages
make no-standard or make no-std # uninstall standard packages
make yes-user # install user packages
make no-user # uninstall user packages
make yes-lib # install packages that require extra libraries
make no-lib # uninstall packages that require extra libraries
make yes-ext # install packages that require external libraries
make no-ext # uninstall packages that require external libraries
which install/un-install various sets of packages. Typing ``make
package`` will list all the these commands.
.. note:: .. note::
Installing or un-installing a package works by simply copying Installing or un-installing a package for the make based build process
files back and forth between the main src directory and works by simply copying files back and forth between the main source
sub-directories with the package name (e.g. src/KSPACE, src/USER-ATC), directory src and the sub-directories with the package name (e.g.
so that the files are included or excluded when LAMMPS is built. src/KSPACE, src/USER-ATC), so that the files are included or excluded
when LAMMPS is built. Only source files in the src folder will be
compiled.
The following make commands help manage files that exist in both the The following make commands help manage files that exist in both the
src directory and in package sub-directories. You do not normally src directory and in package sub-directories. You do not normally
@ -238,28 +223,23 @@ need to use these commands unless you are editing LAMMPS files or are
:doc:`installing a patch <Install_patch>` downloaded from the LAMMPS web :doc:`installing a patch <Install_patch>` downloaded from the LAMMPS web
site. site.
Type "make package-status" or "make ps" to show which packages are Type ``make package-status`` or ``make ps`` to show which packages are
currently installed. For those that are installed, it will list any currently installed. For those that are installed, it will list any
files that are different in the src directory and package files that are different in the src directory and package
sub-directory. sub-directory.
Type "make package-installed" or "make pi" to show which packages are Type ``make package-installed`` or ``make pi`` to show which packages are
currently installed, without listing the status of packages that are currently installed, without listing the status of packages that are
not installed. not installed.
Type "make package-update" or "make pu" to overwrite src files with Type ``make package-update`` or ``make pu`` to overwrite src files with
files from the package sub-directories if the package is installed. files from the package sub-directories if the package is installed.
It should be used after a :doc:`patch has been applied <Install_patch>`, It should be used after a :doc:`patch has been applied <Install_patch>`,
since patches only update the files in the package sub-directory, but since patches only update the files in the package sub-directory, but
not the src files. not the src files.
Type "make package-overwrite" to overwrite files in the package Type ``make package-overwrite`` to overwrite files in the package
sub-directories with src files. sub-directories with src files.
Type "make package-diff" to list all differences between pairs of Type ``make package-diff`` to list all differences between pairs of
files in both the src dir and a package dir. files in both the source directory and the package directory.
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -4,77 +4,49 @@ Optional build settings
LAMMPS can be built with several optional settings. Each sub-section LAMMPS can be built with several optional settings. Each sub-section
explain how to do this for building both with CMake and make. explain how to do this for building both with CMake and make.
| :ref:`C++11 standard compliance test <cxx11>` when building all of LAMMPS * :ref:`C++11 standard compliance <cxx11>` when building all of LAMMPS
| :ref:`FFT library <fft>` for use with the :doc:`kspace\_style pppm <kspace_style>` command * :ref:`FFT library <fft>` for use with the :doc:`kspace_style pppm <kspace_style>` command
| :ref:`Size of LAMMPS data types <size>` * :ref:`Size of LAMMPS data types <size>`
| :ref:`Read or write compressed files <gzip>` * :ref:`Read or write compressed files <gzip>`
| :ref:`Output of JPG and PNG files <graphics>` via the :doc:`dump image <dump_image>` command * :ref:`Output of JPG and PNG files <graphics>` via the :doc:`dump image <dump_image>` command
| :ref:`Output of movie files <graphics>` via the :doc:`dump\_movie <dump_image>` command * :ref:`Output of movie files <graphics>` via the :doc:`dump_movie <dump_image>` command
| :ref:`Memory allocation alignment <align>` * :ref:`Memory allocation alignment <align>`
| :ref:`Workaround for long long integers <longlong>` * :ref:`Workaround for long long integers <longlong>`
| :ref:`Error handling exceptions <exceptions>` when using LAMMPS as a library * :ref:`Error handling exceptions <exceptions>` when using LAMMPS as a library
|
---------- ----------
.. _cxx11: .. _cxx11:
C++11 standard compliance test C++11 standard compliance
------------------------------------------ ------------------------------------------
The LAMMPS developers plan to transition to make the C++11 standard the A C++11 standard compatible compiler is a requirement for compiling LAMMPS.
minimum requirement for compiling LAMMPS. Currently this only applies to LAMMPS version 3 March 2020 is the last version compatible with the previous
some packages like KOKKOS while the rest aims to be compatible with the C++98 C++98 standard for the core code and most packages. Most currently used
standard. Most currently used compilers are compatible with C++11; some need C++ compilers are compatible with C++11, but some older ones may need extra
to set extra flags to switch. To determine the impact of requiring C++11, flags to enable C++11 compliance. Example for GNU c++ 4.8.x:
we have added a simple compliance test to the source code, that will cause
the compilation to abort, if C++11 compliance is not available or enabled.
To bypass this check, you need to change a setting in the makefile or
when calling CMake.
**CMake variable**\ : .. code-block:: make
.. parsed-literal::
-D DISABLE_CXX11_REQUIREMENT=yes
You can set additional C++ compiler flags (beyond those selected by CMake)
through the CMAKE\_CXX\_FLAGS variable. Example for CentOS 7:
.. parsed-literal::
-D CMAKE_CXX_FLAGS="-O3 -g -fopenmp -DNDEBUG -std=c++11"
**Makefile.machine setting**\ :
.. parsed-literal::
LMP_INC = -DLAMMPS_CXX98
CCFLAGS = -g -O3 -std=c++11
---------- ----------
.. _fft: .. _fft:
FFT library FFT library
--------------------- ---------------------
When the KSPACE package is included in a LAMMPS build, the When the KSPACE package is included in a LAMMPS build, the
:doc:`kspace\_style pppm <kspace_style>` command performs 3d FFTs which :doc:`kspace_style pppm <kspace_style>` command performs 3d FFTs which
require use of an FFT library to compute 1d FFTs. The KISS FFT require use of an FFT library to compute 1d FFTs. The KISS FFT
library is included with LAMMPS but other libraries can be faster. library is included with LAMMPS but other libraries can be faster.
LAMMPS can use them if they are available on your system. LAMMPS can use them if they are available on your system.
**CMake variables**\ : **CMake variables**\ :
.. code-block:: bash
.. parsed-literal::
-D FFT=value # FFTW3 or MKL or KISS, default is FFTW3 if found, else KISS -D FFT=value # FFTW3 or MKL or KISS, default is FFTW3 if found, else KISS
-D FFT_SINGLE=value # yes or no (default), no = double precision -D FFT_SINGLE=value # yes or no (default), no = double precision
@ -86,70 +58,83 @@ LAMMPS can use them if they are available on your system.
an exception to the rule that all CMake variables can be specified an exception to the rule that all CMake variables can be specified
with lower-case values. with lower-case values.
Usually these settings are all that is needed. If CMake cannot find Usually these settings are all that is needed. If FFTW3 is selected,
the FFT library, you can set these variables: then CMake will try to detect, if threaded FFTW libraries are available
and enable them by default. This setting is independent of whether
OpenMP threads are enabled and a packages like KOKKOS or USER-OMP is
used. If CMake cannot detect the FFT library, you can set these variables
to assist:
.. code-block:: bash
.. parsed-literal::
-D FFTW3_INCLUDE_DIRS=path # path to FFTW3 include files -D FFTW3_INCLUDE_DIRS=path # path to FFTW3 include files
-D FFTW3_LIBRARIES=path # path to FFTW3 libraries -D FFTW3_LIBRARIES=path # path to FFTW3 libraries
-D FFT_FFTW_THREADS=on # enable using threaded FFTW3 libraries
-D MKL_INCLUDE_DIRS=path # ditto for Intel MKL library -D MKL_INCLUDE_DIRS=path # ditto for Intel MKL library
-D FFT_MKL_THREADS=on # enable using threaded FFTs with MKL libraries
-D MKL_LIBRARIES=path -D MKL_LIBRARIES=path
**Makefile.machine settings**\ : **Makefile.machine settings**\ :
.. code-block:: make
.. parsed-literal::
FFT_INC = -DFFT_FFTW3 # -DFFT_FFTW3, -DFFT_FFTW (same as -DFFT_FFTW3), -DFFT_MKL, or -DFFT_KISS FFT_INC = -DFFT_FFTW3 # -DFFT_FFTW3, -DFFT_FFTW (same as -DFFT_FFTW3), -DFFT_MKL, or -DFFT_KISS
# default is KISS if not specified # default is KISS if not specified
FFT_INC = -DFFT_SINGLE # do not specify for double precision FFT_INC = -DFFT_SINGLE # do not specify for double precision
FFT_INC = -DFFT_FFTW_THREADS # enable using threaded FFTW3 libraries
FFT_INC = -DFFT_MKL_THREADS # enable using threaded FFTs with MKL libraries
FFT_INC = -DFFT_PACK_ARRAY # or -DFFT_PACK_POINTER or -DFFT_PACK_MEMCPY FFT_INC = -DFFT_PACK_ARRAY # or -DFFT_PACK_POINTER or -DFFT_PACK_MEMCPY
# default is FFT\_PACK\_ARRAY if not specified # default is FFT_PACK_ARRAY if not specified
.. code-block:: make
.. parsed-literal::
FFT_INC = -I/usr/local/include FFT_INC = -I/usr/local/include
FFT_PATH = -L/usr/local/lib FFT_PATH = -L/usr/local/lib
FFT_LIB = -lfftw3 # FFTW3 double precision FFT_LIB = -lfftw3 # FFTW3 double precision
FFT_LIB = -lfftw3 -lfftw3_omp # FFTW3 double precision with threads (needs -DFFT_FFTW_THREADS)
FFT_LIB = -lfftw3 -lfftw3f # FFTW3 single precision FFT_LIB = -lfftw3 -lfftw3f # FFTW3 single precision
FFT_LIB = -lmkl_intel_lp64 -lmkl_sequential -lmkl_core # MKL with Intel compiler FFT_LIB = -lmkl_intel_lp64 -lmkl_sequential -lmkl_core # MKL with Intel compiler, serial interface
FFT_LIB = -lmkl_gf_lp64 -lmkl_sequential -lmkl_core # MKL with GNU compier FFT_LIB = -lmkl_gf_lp64 -lmkl_sequential -lmkl_core # MKL with GNU compiler, serial interface
FFT_LIB = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core # MKL with Intel compiler, threaded interface
FFT_LIB = -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core # MKL with GNU compiler, threaded interface
FFT_LIB = -lmkl_rt # MKL with automatic runtime selection of interface libs
As with CMake, you do not need to set paths in FFT\_INC or FFT\_PATH, if As with CMake, you do not need to set paths in ``FFT_INC`` or ``FFT_PATH``, if
make can find the FFT header and library files. You must specify the compiler can find the FFT header and library files in its default search path.
FFT\_LIB with the appropriate FFT libraries to include in the link. You must specify ``FFT_LIB`` with the appropriate FFT libraries to include in the link.
**CMake and make info**\ : **CMake and make info**\ :
The `KISS FFT library <http://kissfft.sf.net>`_ is included in the LAMMPS The `KISS FFT library <http://kissfft.sf.net>`_ is included in the LAMMPS
distribution. It is portable across all platforms. Depending on the distribution. It is portable across all platforms. Depending on the size
size of the FFTs and the number of processors used, the other of the FFTs and the number of processors used, the other libraries listed
libraries listed here can be faster. here can be faster.
However, note that long-range Coulombics are only a portion of the However, note that long-range Coulombics are only a portion of the
per-timestep CPU cost, FFTs are only a portion of long-range per-timestep CPU cost, FFTs are only a portion of long-range
Coulombics, and 1d FFTs are only a portion of the FFT cost (parallel Coulombics, and 1d FFTs are only a portion of the FFT cost (parallel
communication can be costly). A breakdown of these timings is printed communication can be costly). A breakdown of these timings is printed
to the screen at the end of a run using the :doc:`kspace\_style pppm <kspace_style>` command. The :doc:`Run output <Run_output>` to the screen at the end of a run when using the
doc page gives more details. :doc:`kspace_style pppm <kspace_style>` command. The :doc:`Run output <Run_output>`
doc page gives more details. A more detailed (and time consuming)
report of the FFT performance is generated with the
:doc:`kspace_modify fftbench yes <kspace_modify>` command.
FFTW is a fast, portable FFT library that should also work on any FFTW is a fast, portable FFT library that should also work on any
platform and can be faster than the KISS FFT library. You can platform and can be faster than the KISS FFT library. You can
download it from `www.fftw.org <http://www.fftw.org>`_. LAMMPS requires download it from `www.fftw.org <http://www.fftw.org>`_. LAMMPS requires
version 3.X; the legacy version 2.1.X is no longer supported. version 3.X; the legacy version 2.1.X is no longer supported.
Building FFTW for your box should be as simple as ./configure; make; Building FFTW for your box should be as simple as ``./configure; make;
make install. The install command typically requires root privileges make install``\ . The install command typically requires root privileges
(e.g. invoke it via sudo), unless you specify a local directory with (e.g. invoke it via sudo), unless you specify a local directory with
the "--prefix" option of configure. Type "./configure --help" to see the "--prefix" option of configure. Type ``./configure --help`` to see
various options. various options.
The Intel MKL math library is part of the Intel compiler suite. It The Intel MKL math library is part of the Intel compiler suite. It
can be used with the Intel or GNU compiler (see FFT\_LIB setting above). can be used with the Intel or GNU compiler (see the ``FFT_LIB`` setting
above).
Performing 3d FFTs in parallel can be time consuming due to data Performing 3d FFTs in parallel can be time consuming due to data
access and required communication. This cost can be reduced by access and required communication. This cost can be reduced by
@ -158,33 +143,30 @@ precision means the real and imaginary parts of a complex datum are
4-byte floats. Double precision means they are 8-byte doubles. Note 4-byte floats. Double precision means they are 8-byte doubles. Note
that Fourier transform and related PPPM operations are somewhat less that Fourier transform and related PPPM operations are somewhat less
sensitive to floating point truncation errors and thus the resulting sensitive to floating point truncation errors and thus the resulting
error is less than the difference in precision. Using the -DFFT\_SINGLE error is less than the difference in precision. Using the ``-DFFT_SINGLE``
setting trades off a little accuracy for reduced memory use and setting trades off a little accuracy for reduced memory use and
parallel communication costs for transposing 3d FFT data. parallel communication costs for transposing 3d FFT data.
When using -DFFT\_SINGLE with FFTW3 you may need to build the FFTW When using ``-DFFT_SINGLE`` with FFTW3 you may need to build the FFTW
library a second time with support for single-precision. library a second time with support for single-precision.
For FFTW3, do the following, which should produce the additional For FFTW3, do the following, which should produce the additional
library libfftw3f.a library ``libfftw3f.a`` or ``libfftw3f.so``\ .
.. code-block:: bash
.. parsed-literal::
make clean make clean
./configure --enable-single; make; make install ./configure --enable-single; make; make install
Performing 3d FFTs requires communication to transpose the 3d FFT Performing 3d FFTs requires communication to transpose the 3d FFT
grid. The data packing/unpacking for this can be done in one of 3 grid. The data packing/unpacking for this can be done in one of 3
modes (ARRAY, POINTER, MEMCPY) as set by the FFT\_PACK syntax above. modes (ARRAY, POINTER, MEMCPY) as set by the FFT_PACK syntax above.
Depending on the machine, the size of the FFT grid, the number of Depending on the machine, the size of the FFT grid, the number of
processors used, one option may be slightly faster. The default is processors used, one option may be slightly faster. The default is
ARRAY mode. ARRAY mode.
---------- ----------
.. _size: .. _size:
Size of LAMMPS data types Size of LAMMPS data types
@ -196,19 +178,18 @@ adequate.
**CMake variable**\ : **CMake variable**\ :
.. code-block:: bash
.. parsed-literal::
-D LAMMPS_SIZES=value # smallbig (default) or bigbig or smallsmall -D LAMMPS_SIZES=value # smallbig (default) or bigbig or smallsmall
**Makefile.machine setting**\ : **Makefile.machine setting**\ :
.. code-block:: make
.. parsed-literal::
LMP_INC = -DLAMMPS_SMALLBIG # or -DLAMMPS_BIGBIG or -DLAMMPS_SMALLSMALL LMP_INC = -DLAMMPS_SMALLBIG # or -DLAMMPS_BIGBIG or -DLAMMPS_SMALLSMALL
# default is LAMMPS\_SMALLBIG if not specified The default setting is ``-DLAMMPS_SMALLBIG`` if nothing is specified
**CMake and make info**\ : **CMake and make info**\ :
The default "smallbig" setting allows for simulations with: The default "smallbig" setting allows for simulations with:
@ -235,7 +216,7 @@ support 8-byte integers. It allows for:
Atom IDs are not required for atomic systems which do not store bond Atom IDs are not required for atomic systems which do not store bond
topology information, though IDs are enabled by default. The topology information, though IDs are enabled by default. The
:doc:`atom\_modify id no <atom_modify>` command will turn them off. Atom :doc:`atom_modify id no <atom_modify>` command will turn them off. Atom
IDs are required for molecular systems with bond topology (bonds, IDs are required for molecular systems with bond topology (bonds,
angles, dihedrals, etc). Thus if you model a molecular system with angles, dihedrals, etc). Thus if you model a molecular system with
more than 2 billion atoms, you need the "bigbig" setting. more than 2 billion atoms, you need the "bigbig" setting.
@ -256,12 +237,10 @@ than crashing randomly or corrupting data.
Also note that the GPU package requires its lib/gpu library to be Also note that the GPU package requires its lib/gpu library to be
compiled with the same size setting, or the link will fail. A CMake compiled with the same size setting, or the link will fail. A CMake
build does this automatically. When building with make, the setting build does this automatically. When building with make, the setting
in whichever lib/gpu/Makefile is used must be the same as above. in whichever ``lib/gpu/Makefile`` is used must be the same as above.
---------- ----------
.. _graphics: .. _graphics:
Output of JPG, PNG, and movie files Output of JPG, PNG, and movie files
@ -274,22 +253,20 @@ following settings:
**CMake variables**\ : **CMake variables**\ :
.. code-block:: bash
.. parsed-literal::
-D WITH_JPEG=value # yes or no -D WITH_JPEG=value # yes or no
# default = yes if CMake finds JPEG files, else no # default = yes if CMake finds JPEG files, else no
-D WITH_PNG=value # yes or no -D WITH_PNG=value # yes or no
# default = yes if CMake finds PNG and ZLIB files, else no # default = yes if CMake finds PNG and ZLIB files, else no
-D WITH_FFMPEG=value # yes or no -D WITH_FFMPEG=value # yes or no
# default = yes if CMake can find ffmpeg, else no # default = yes if CMake can find ffmpeg, else no
Usually these settings are all that is needed. If CMake cannot find Usually these settings are all that is needed. If CMake cannot find
the graphics header, library, executable files, you can set these the graphics header, library, executable files, you can set these
variables: variables:
.. code-block:: bash
.. parsed-literal::
-D JPEG_INCLUDE_DIR=path # path to jpeglib.h header file -D JPEG_INCLUDE_DIR=path # path to jpeglib.h header file
-D JPEG_LIBRARIES=path # path to libjpeg.a (.so) file -D JPEG_LIBRARIES=path # path to libjpeg.a (.so) file
@ -301,8 +278,7 @@ variables:
**Makefile.machine settings**\ : **Makefile.machine settings**\ :
.. code-block:: make
.. parsed-literal::
LMP_INC = -DLAMMPS_JPEG LMP_INC = -DLAMMPS_JPEG
LMP_INC = -DLAMMPS_PNG LMP_INC = -DLAMMPS_PNG
@ -312,28 +288,27 @@ variables:
JPG_PATH = -L/usr/lib # paths to libjpeg.a, libpng.a, libz.a (.so) files if make cannot find them JPG_PATH = -L/usr/lib # paths to libjpeg.a, libpng.a, libz.a (.so) files if make cannot find them
JPG_LIB = -ljpeg -lpng -lz # library names JPG_LIB = -ljpeg -lpng -lz # library names
As with CMake, you do not need to set JPG\_INC or JPG\_PATH, if make can As with CMake, you do not need to set ``JPG_INC`` or ``JPG_PATH``,
find the graphics header and library files. You must specify JPG\_LIB if make can find the graphics header and library files. You must
specify ``JPG_LIB``
with a list of graphics libraries to include in the link. You must with a list of graphics libraries to include in the link. You must
insure ffmpeg is in a directory where LAMMPS can find it at runtime, insure ffmpeg is in a directory where LAMMPS can find it at runtime,
i.e. a dir in your PATH environment variable. that is a directory in your PATH environment variable.
**CMake and make info**\ : **CMake and make info**\ :
Using ffmpeg to output movie files requires that your machine Using ``ffmpeg`` to output movie files requires that your machine
supports the "popen" function in the standard runtime library. supports the "popen" function in the standard runtime library.
.. note:: .. note::
On some clusters with high-speed networks, using the fork() On some clusters with high-speed networks, using the fork()
library calls (required by popen()) can interfere with the fast library call (required by popen()) can interfere with the fast
communication library and lead to simulations using ffmpeg to hang or communication library and lead to simulations using ffmpeg to hang or
crash. crash.
---------- ----------
.. _gzip: .. _gzip:
Read or write compressed files Read or write compressed files
@ -341,12 +316,11 @@ Read or write compressed files
If this option is enabled, large files can be read or written with If this option is enabled, large files can be read or written with
gzip compression by several LAMMPS commands, including gzip compression by several LAMMPS commands, including
:doc:`read\_data <read_data>`, :doc:`rerun <rerun>`, and :doc:`dump <dump>`. :doc:`read_data <read_data>`, :doc:`rerun <rerun>`, and :doc:`dump <dump>`.
**CMake variables**\ : **CMake variables**\ :
.. code-block:: bash
.. parsed-literal::
-D WITH_GZIP=value # yes or no -D WITH_GZIP=value # yes or no
# default is yes if CMake can find gzip, else no # default is yes if CMake can find gzip, else no
@ -354,8 +328,7 @@ gzip compression by several LAMMPS commands, including
**Makefile.machine setting**\ : **Makefile.machine setting**\ :
.. code-block:: make
.. parsed-literal::
LMP_INC = -DLAMMPS_GZIP LMP_INC = -DLAMMPS_GZIP
@ -368,22 +341,20 @@ found by LAMMPS during a run.
.. note:: .. note::
On some clusters with high-speed networks, using the fork() On some clusters with high-speed networks, using the fork()
library calls (required by popen()) can interfere with the fast library call (required by popen()) can interfere with the fast
communication library and lead to simulations using compressed output communication library and lead to simulations using compressed output
or input to hang or crash. For selected operations, compressed file or input to hang or crash. For selected operations, compressed file
I/O is also available using a compression library instead, which is I/O is also available using a compression library instead, which is
what the :ref:`COMPRESS package <PKG-COMPRESS>` enables. what the :ref:`COMPRESS package <PKG-COMPRESS>` enables.
---------- ----------
.. _align: .. _align:
Memory allocation alignment Memory allocation alignment
--------------------------------------- ---------------------------------------
This setting enables the use of the posix\_memalign() call instead of This setting enables the use of the posix_memalign() call instead of
malloc() when LAMMPS allocates large chunks or memory. This can make malloc() when LAMMPS allocates large chunks or memory. This can make
vector instructions on CPUs more efficient, if dynamically allocated vector instructions on CPUs more efficient, if dynamically allocated
memory is aligned on larger-than-default byte boundaries. memory is aligned on larger-than-default byte boundaries.
@ -394,33 +365,29 @@ aligned on 64-byte boundaries.
**CMake variable**\ : **CMake variable**\ :
.. code-block:: bash
.. parsed-literal::
-D LAMMPS_MEMALIGN=value # 0, 8, 16, 32, 64 (default) -D LAMMPS_MEMALIGN=value # 0, 8, 16, 32, 64 (default)
Use a LAMMPS\_MEMALIGN value of 0 to disable using posix\_memalign() Use a ``LAMMPS_MEMALIGN`` value of 0 to disable using posix_memalign()
and revert to using the malloc() C-library function instead. When and revert to using the malloc() C-library function instead. When
compiling LAMMPS for Windows systems, malloc() will always be used compiling LAMMPS for Windows systems, malloc() will always be used
and this setting ignored. and this setting ignored.
**Makefile.machine setting**\ : **Makefile.machine setting**\ :
.. code-block:: make
.. parsed-literal::
LMP_INC = -DLAMMPS_MEMALIGN=value # 8, 16, 32, 64 LMP_INC = -DLAMMPS_MEMALIGN=value # 8, 16, 32, 64
Do not set -DLAMMPS\_MEMALIGN, if you want to have memory allocated Do not set ``-DLAMMPS_MEMALIGN``, if you want to have memory allocated
with the malloc() function call instead. -DLAMMPS\_MEMALIGN **cannot** with the malloc() function call instead. ``-DLAMMPS_MEMALIGN`` **cannot**
be used on Windows, as it does use different function calls for be used on Windows, as it does use different function calls for
allocating aligned memory, that are not compatible with how LAMMPS allocating aligned memory, that are not compatible with how LAMMPS
manages its dynamical memory. manages its dynamical memory.
---------- ----------
.. _longlong: .. _longlong:
Workaround for long long integers Workaround for long long integers
@ -433,47 +400,37 @@ those systems:
**CMake variable**\ : **CMake variable**\ :
.. code-block:: bash
.. parsed-literal::
-D LAMMPS_LONGLONG_TO_LONG=value # yes or no (default) -D LAMMPS_LONGLONG_TO_LONG=value # yes or no (default)
**Makefile.machine setting**\ : **Makefile.machine setting**\ :
.. code-block:: make
.. parsed-literal::
LMP_INC = -DLAMMPS_LONGLONG_TO_LONG LMP_INC = -DLAMMPS_LONGLONG_TO_LONG
---------- ----------
.. _exceptions: .. _exceptions:
Exception handling when using LAMMPS as a library Exception handling when using LAMMPS as a library
------------------------------------------------------------------ ------------------------------------------------------------------
This setting is useful when external codes drive LAMMPS as a library. This setting is useful when external codes drive LAMMPS as a library.
With this option enabled LAMMPS errors do not kill the caller. With this option enabled, LAMMPS errors do not kill the calling code.
Instead, the call stack is unwound and control returns to the caller, Instead, the call stack is unwound and control returns to the caller,
e.g. to Python. e.g. to Python. Of course the calling code has to be set up to
*catch* exceptions from within LAMMPS.
**CMake variable**\ : **CMake variable**\ :
.. code-block:: bash
.. parsed-literal::
-D LAMMPS_EXCEPTIONS=value # yes or no (default) -D LAMMPS_EXCEPTIONS=value # yes or no (default)
**Makefile.machine setting**\ : **Makefile.machine setting**\ :
.. code-block:: make
.. parsed-literal::
LMP_INC = -DLAMMPS_EXCEPTIONS LMP_INC = -DLAMMPS_EXCEPTIONS
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -6,10 +6,8 @@ Notes for building LAMMPS on Windows
* :ref:`Using GNU GCC ported to Windows <gnu>` * :ref:`Using GNU GCC ported to Windows <gnu>`
* :ref:`Using a cross-compiler <cross>` * :ref:`Using a cross-compiler <cross>`
---------- ----------
.. _generic: .. _generic:
General remarks General remarks
@ -17,9 +15,9 @@ General remarks
LAMMPS is developed and tested primarily on Linux machines. The vast LAMMPS is developed and tested primarily on Linux machines. The vast
majority of HPC clusters and supercomputers today runs on Linux as well. majority of HPC clusters and supercomputers today runs on Linux as well.
Thus portability to other platforms is desired, but not always achieved. While portability to other platforms is desired, it is not always achieved.
The LAMMPS developers strongly rely on LAMMPS users giving feedback and The LAMMPS developers strongly rely on LAMMPS users giving feedback and
providing assistance in resolving portability issues. This particularly providing assistance in resolving portability issues. This is particularly
true for compiling LAMMPS on Windows, since this platform has significant true for compiling LAMMPS on Windows, since this platform has significant
differences with some low-level functionality. differences with some low-level functionality.
@ -31,18 +29,20 @@ Running Linux on Windows
So before trying to build LAMMPS on Windows, please consider if using So before trying to build LAMMPS on Windows, please consider if using
the pre-compiled Windows binary packages are sufficient for your needs the pre-compiled Windows binary packages are sufficient for your needs
(as an aside, those packages themselves are build on a Linux machine (as an aside, those packages themselves are build on a Linux machine
using cross-compilers). If it is necessary for your to compile LAMMPS using cross-compilers). If it is necessary for you to compile LAMMPS
on a Windows machine (e.g. because it is your main desktop), please also on a Windows machine (e.g. because it is your main desktop), please also
consider using a virtual machine software and run a Linux virtual machine, consider using a virtual machine software and compile and run LAMMPS in
or - if have a recently updated Windows 10 installation - consider using a Linux virtual machine, or - if you have a recently updated Windows 10
the Windows subsystem for Linux, which allows to run a bash shell from installation - consider using the Windows subsystem for Linux. This
Ubuntu and from there on, you can pretty much use that shell like you optional Windows feature allows you to run the bash shell from Ubuntu
are running on an Ubuntu Linux machine (e.g. installing software via from within Windows and from there on, you can pretty much use that
apt-get). For more details on that, please see :doc:`this tutorial <Howto_bash>` shell like you are running on an Ubuntu Linux machine (e.g. installing
software via apt-get and more). For more details on that, please
see :doc:`this tutorial <Howto_bash>`
.. _gnu: .. _gnu:
Using GNU GCC ported to Windows Using a GNU GCC ported to Windows
----------------------------------------- -----------------------------------------
One option for compiling LAMMPS on Windows natively, that has been known One option for compiling LAMMPS on Windows natively, that has been known
@ -55,8 +55,8 @@ and the corresponding new code. A machine makefile for using cygwin for
the old build system is provided. Using CMake for this mode of compilation the old build system is provided. Using CMake for this mode of compilation
is untested and not likely to work. is untested and not likely to work.
When compiling for Windows do **not** set the -DLAMMPS\_MEMALIGN define When compiling for Windows do **not** set the -DLAMMPS_MEMALIGN define
in the LMP\_INC makefile variable and add -lwsock32 -lpsapi to the linker in the LMP_INC makefile variable and add -lwsock32 -lpsapi to the linker
flags in LIB makefile variable. Try adding -static-libgcc or -static or flags in LIB makefile variable. Try adding -static-libgcc or -static or
both to the linker flags when your resulting LAMMPS Windows executable both to the linker flags when your resulting LAMMPS Windows executable
complains about missing .dll files. The CMake configuration should set complains about missing .dll files. The CMake configuration should set
@ -83,13 +83,19 @@ traditional build system, but CMake has also been successfully tested
using the mingw32-cmake and mingw64-cmake wrappers that are bundled using the mingw32-cmake and mingw64-cmake wrappers that are bundled
with the cross-compiler environment on Fedora machines. A CMake preset with the cross-compiler environment on Fedora machines. A CMake preset
selecting all packages compatible with this cross-compilation build selecting all packages compatible with this cross-compilation build
is provided. You likely need to disable the GPU package unless you is provided. The GPU package can only be compiled with OpenCL support
download and install the contents of the pre-compiled `OpenCL ICD loader library <https://download.lammps.org/thirdparty/opencl-win-devel.tar.gz>`_ and you need to download and install the pre-compiled
into your MinGW64 cross-compiler environment. The cross-compilation `OpenCL ICD loader library <https://download.lammps.org/thirdparty/opencl-win-devel.tar.gz>`_
currently will only produce non-MPI serial binaries. into your MinGW64 cross-compiler environment. With CMake this will be
done transparently. To compile with MPI support, a pre-compiled
library and the corresponding header files are required. There is
`one package for 32-bit Windows <https://download.lammps.org/thirdparty/mpich2-win32-devel.tar.gz>`_
and `a second package for 64-bit Windows <https://download.lammps.org/thirdparty/mpich2-win64-devel.tar.gz>`_.
When building with CMake, the matching package will be downloaded
automatically, but MPI support has to be explicitly enabled with ``-DBUILD_MPI=on``.
Please keep in mind, though, that this only applies to compiling LAMMPS. Please keep in mind, though, that this only applies to **compiling** LAMMPS.
Whether the resulting binaries do work correctly is no tested by the Whether the resulting binaries do work correctly is not tested by the
LAMMPS developers. We instead rely on the feedback of the users LAMMPS developers. We instead rely on the feedback of the users
of these pre-compiled LAMMPS packages for Windows. We will try to resolve of these pre-compiled LAMMPS packages for Windows. We will try to resolve
issues to the best of our abilities if we become aware of them. However issues to the best of our abilities if we become aware of them. However
@ -104,8 +110,3 @@ Support for the Visual C++ compilers is currently not available. The
CMake build system is capable of creating suitable a Visual Studio CMake build system is capable of creating suitable a Visual Studio
style build environment, but the LAMMPS code itself is not fully ported style build environment, but the LAMMPS code itself is not fully ported
to support Visual C++. Volunteers to take on this task are welcome. to support Visual C++. Volunteers to take on this task are welcome.
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -4,7 +4,6 @@ Commands
These pages describe how a LAMMPS input script is formatted and the These pages describe how a LAMMPS input script is formatted and the
commands in it are used to define a LAMMPS simulation. commands in it are used to define a LAMMPS simulation.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
@ -27,8 +26,3 @@ commands in it are used to define a LAMMPS simulation.
:maxdepth: 1 :maxdepth: 1
Commands_removed Commands_removed
.. _lws: http://lammps.sandia.gov
.. _ld: Manual.html
.. _lc: Commands_all.html

View File

@ -1,59 +1,139 @@
+----------------------------------------+------------------------------------+------------------------------------------+ .. table_from_list::
| :doc:`General commands <Commands_all>` | :doc:`Fix styles <Commands_fix>` | :doc:`Compute styles <Commands_compute>` | :columns: 3
+----------------------------------------+------------------------------------+------------------------------------------+
| :doc:`Pair styles <Commands_pair>` | :doc:`Bond styles <Commands_bond>` | :ref:`Angle styles <angle>` | * :doc:`General commands <Commands_all>`
+----------------------------------------+------------------------------------+------------------------------------------+ * :doc:`Fix styles <Commands_fix>`
| :ref:`Dihedral styles <dihedral>` | :ref:`Improper styles <improper>` | :doc:`KSpace styles <Commands_kspace>` | * :doc:`Compute styles <Commands_compute>`
+----------------------------------------+------------------------------------+------------------------------------------+ * :doc:`Pair styles <Commands_pair>`
* :ref:`Bond styles <bond>`
* :ref:`Angle styles <angle>`
* :ref:`Dihedral styles <dihedral>`
* :ref:`Improper styles <improper>`
* :doc:`KSpace styles <Commands_kspace>`
General commands General commands
================ ================
An alphabetic list of all general LAMMPS commands. An alphabetic list of all general LAMMPS commands.
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+ .. table_from_list::
| :doc:`angle\_coeff <angle_coeff>` | :doc:`angle\_style <angle_style>` | :doc:`atom\_modify <atom_modify>` | :doc:`atom\_style <atom_style>` | :doc:`balance <balance>` | :doc:`bond\_coeff <bond_coeff>` | :columns: 5
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`bond\_style <bond_style>` | :doc:`bond\_write <bond_write>` | :doc:`boundary <boundary>` | :doc:`box <box>` | :doc:`change\_box <change_box>` | :doc:`clear <clear>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`comm\_modify <comm_modify>` | :doc:`comm\_style <comm_style>` | :doc:`compute <compute>` | :doc:`compute\_modify <compute_modify>` | :doc:`create\_atoms <create_atoms>` | :doc:`create\_bonds <create_bonds>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`create\_box <create_box>` | :doc:`delete\_atoms <delete_atoms>` | :doc:`delete\_bonds <delete_bonds>` | :doc:`dielectric <dielectric>` | :doc:`dihedral\_coeff <dihedral_coeff>` | :doc:`dihedral\_style <dihedral_style>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`dimension <dimension>` | :doc:`displace\_atoms <displace_atoms>` | :doc:`dump <dump>` | :doc:`dump adios <dump_adios>` | :doc:`dump image <dump_image>` | :doc:`dump movie <dump_image>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`dump netcdf <dump_netcdf>` | :doc:`dump netcdf/mpiio <dump_netcdf>` | :doc:`dump vtk <dump_vtk>` | :doc:`dump\_modify <dump_modify>` | :doc:`dynamical\_matrix <dynamical_matrix>` | :doc:`echo <echo>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`fix <fix>` | :doc:`fix\_modify <fix_modify>` | :doc:`group <group>` | :doc:`group2ndx <group2ndx>` | :doc:`hyper <hyper>` | :doc:`if <if>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`info <info>` | :doc:`improper\_coeff <improper_coeff>` | :doc:`improper\_style <improper_style>` | :doc:`include <include>` | :doc:`jump <jump>` | :doc:`kim\_init <kim_commands>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`kim\_interactions <kim_commands>` | :doc:`kim\_query <kim_commands>` | :doc:`kspace\_modify <kspace_modify>` | :doc:`kspace\_style <kspace_style>` | :doc:`label <label>` | :doc:`lattice <lattice>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`log <log>` | :doc:`mass <mass>` | :doc:`message <message>` | :doc:`minimize <minimize>` | :doc:`min\_modify <min_modify>` | :doc:`min\_style <min_style>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`min\_style spin <min_spin>` | :doc:`molecule <molecule>` | :doc:`ndx2group <group2ndx>` | :doc:`neb <neb>` | :doc:`neb/spin <neb_spin>` | :doc:`neigh\_modify <neigh_modify>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`neighbor <neighbor>` | :doc:`newton <newton>` | :doc:`next <next>` | :doc:`package <package>` | :doc:`pair\_coeff <pair_coeff>` | :doc:`pair\_modify <pair_modify>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`pair\_style <pair_style>` | :doc:`pair\_write <pair_write>` | :doc:`partition <partition>` | :doc:`prd <prd>` | :doc:`print <print>` | :doc:`processors <processors>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`python <python>` | :doc:`quit <quit>` | :doc:`read\_data <read_data>` | :doc:`read\_dump <read_dump>` | :doc:`read\_restart <read_restart>` | :doc:`region <region>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`replicate <replicate>` | :doc:`rerun <rerun>` | :doc:`reset\_ids <reset_ids>` | :doc:`reset\_timestep <reset_timestep>` | :doc:`restart <restart>` | :doc:`run <run>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`run\_style <run_style>` | :doc:`server <server>` | :doc:`set <set>` | :doc:`shell <shell>` | :doc:`special\_bonds <special_bonds>` | :doc:`suffix <suffix>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`tad <tad>` | :doc:`temper <temper>` | :doc:`temper/grem <temper_grem>` | :doc:`temper/npt <temper_npt>` | :doc:`thermo <thermo>` | :doc:`thermo\_modify <thermo_modify>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`thermo\_style <thermo_style>` | :doc:`third\_order <third_order>` | :doc:`timer <timer>` | :doc:`timestep <timestep>` | :doc:`uncompute <uncompute>` | :doc:`undump <undump>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`unfix <unfix>` | :doc:`units <units>` | :doc:`variable <variable>` | :doc:`velocity <velocity>` | :doc:`write\_coeff <write_coeff>` | :doc:`write\_data <write_data>` |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
| :doc:`write\_dump <write_dump>` | :doc:`write\_restart <write_restart>` | | | | |
+-----------------------------------------+-----------------------------------------+-----------------------------------------+-----------------------------------------+---------------------------------------------+-----------------------------------------+
* :doc:`angle_coeff <angle_coeff>`
.. _lws: http://lammps.sandia.gov * :doc:`angle_style <angle_style>`
.. _ld: Manual.html * :doc:`atom_modify <atom_modify>`
.. _lc: Commands_all.html * :doc:`atom_style <atom_style>`
* :doc:`balance <balance>`
* :doc:`bond_coeff <bond_coeff>`
* :doc:`bond_style <bond_style>`
* :doc:`bond_write <bond_write>`
* :doc:`boundary <boundary>`
* :doc:`box <box>`
* :doc:`change_box <change_box>`
* :doc:`clear <clear>`
* :doc:`comm_modify <comm_modify>`
* :doc:`comm_style <comm_style>`
* :doc:`compute <compute>`
* :doc:`compute_modify <compute_modify>`
* :doc:`create_atoms <create_atoms>`
* :doc:`create_bonds <create_bonds>`
* :doc:`create_box <create_box>`
* :doc:`delete_atoms <delete_atoms>`
* :doc:`delete_bonds <delete_bonds>`
* :doc:`dielectric <dielectric>`
* :doc:`dihedral_coeff <dihedral_coeff>`
* :doc:`dihedral_style <dihedral_style>`
* :doc:`dimension <dimension>`
* :doc:`displace_atoms <displace_atoms>`
* :doc:`dump <dump>`
* :doc:`dump atom/adios <dump_adios>`
* :doc:`dump custom/adios <dump_adios>`
* :doc:`dump image <dump_image>`
* :doc:`dump movie <dump_image>`
* :doc:`dump netcdf <dump_netcdf>`
* :doc:`dump netcdf/mpiio <dump_netcdf>`
* :doc:`dump vtk <dump_vtk>`
* :doc:`dump_modify <dump_modify>`
* :doc:`dynamical_matrix <dynamical_matrix>`
* :doc:`echo <echo>`
* :doc:`fix <fix>`
* :doc:`fix_modify <fix_modify>`
* :doc:`group <group>`
* :doc:`group2ndx <group2ndx>`
* :doc:`hyper <hyper>`
* :doc:`if <if>`
* :doc:`improper_coeff <improper_coeff>`
* :doc:`improper_style <improper_style>`
* :doc:`include <include>`
* :doc:`info <info>`
* :doc:`jump <jump>`
* :doc:`kim_init <kim_commands>`
* :doc:`kim_interactions <kim_commands>`
* :doc:`kim_param <kim_commands>`
* :doc:`kim_property <kim_commands>`
* :doc:`kim_query <kim_commands>`
* :doc:`kspace_modify <kspace_modify>`
* :doc:`kspace_style <kspace_style>`
* :doc:`label <label>`
* :doc:`lattice <lattice>`
* :doc:`log <log>`
* :doc:`mass <mass>`
* :doc:`message <message>`
* :doc:`minimize <minimize>`
* :doc:`min_modify <min_modify>`
* :doc:`min_style <min_style>`
* :doc:`min_style spin <min_spin>`
* :doc:`molecule <molecule>`
* :doc:`ndx2group <group2ndx>`
* :doc:`neb <neb>`
* :doc:`neb/spin <neb_spin>`
* :doc:`neigh_modify <neigh_modify>`
* :doc:`neighbor <neighbor>`
* :doc:`newton <newton>`
* :doc:`next <next>`
* :doc:`package <package>`
* :doc:`pair_coeff <pair_coeff>`
* :doc:`pair_modify <pair_modify>`
* :doc:`pair_write <pair_write>`
* :doc:`partition <partition>`
* :doc:`prd <prd>`
* :doc:`print <print>`
* :doc:`processors <processors>`
* :doc:`python <python>`
* :doc:`quit <quit>`
* :doc:`read_data <read_data>`
* :doc:`read_dump <read_dump>`
* :doc:`read_restart <read_restart>`
* :doc:`region <region>`
* :doc:`replicate <replicate>`
* :doc:`rerun <rerun>`
* :doc:`reset_ids <reset_ids>`
* :doc:`reset_timestep <reset_timestep>`
* :doc:`restart <restart>`
* :doc:`run <run>`
* :doc:`run_style <run_style>`
* :doc:`server <server>`
* :doc:`set <set>`
* :doc:`shell <shell>`
* :doc:`special_bonds <special_bonds>`
* :doc:`suffix <suffix>`
* :doc:`tad <tad>`
* :doc:`temper <temper>`
* :doc:`temper/grem <temper_grem>`
* :doc:`temper/npt <temper_npt>`
* :doc:`thermo <thermo>`
* :doc:`thermo_modify <thermo_modify>`
* :doc:`thermo_style <thermo_style>`
* :doc:`third_order <third_order>`
* :doc:`timer <timer>`
* :doc:`timestep <timestep>`
* :doc:`uncompute <uncompute>`
* :doc:`undump <undump>`
* :doc:`unfix <unfix>`
* :doc:`units <units>`
* :doc:`variable <variable>`
* :doc:`velocity <velocity>`
* :doc:`write_coeff <write_coeff>`
* :doc:`write_data <write_data>`
* :doc:`write_dump <write_dump>`
* :doc:`write_restart <write_restart>`

View File

@ -1,112 +1,159 @@
.. table_from_list::
:columns: 3
* :doc:`General commands <Commands_all>`
* :doc:`Fix styles <Commands_fix>`
* :doc:`Compute styles <Commands_compute>`
* :doc:`Pair styles <Commands_pair>`
* :ref:`Bond styles <bond>`
* :ref:`Angle styles <angle>`
* :ref:`Dihedral styles <dihedral>`
* :ref:`Improper styles <improper>`
* :doc:`KSpace styles <Commands_kspace>`
.. _bond: .. _bond:
Bond\_style potentials Bond_style potentials
================================= =====================
All LAMMPS :doc:`bond\_style <bond_style>` commands. Some styles have All LAMMPS :doc:`bond_style <bond_style>` commands. Some styles have
accelerated versions. This is indicated by additional letters in accelerated versions. This is indicated by additional letters in
parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t = parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t =
OPT. OPT.
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+ .. table_from_list::
| :doc:`none <bond_none>` | :doc:`zero <bond_zero>` | :doc:`hybrid <bond_hybrid>` | | :columns: 4
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+
| | | | |
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+
| :doc:`class2 (ko) <bond_class2>` | :doc:`fene (iko) <bond_fene>` | :doc:`fene/expand (o) <bond_fene_expand>` | :doc:`gromos (o) <bond_gromos>` |
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+
| :doc:`harmonic (iko) <bond_harmonic>` | :doc:`harmonic/shift (o) <bond_harmonic_shift>` | :doc:`harmonic/shift/cut (o) <bond_harmonic_shift_cut>` | :doc:`mm3 <bond_mm3>` |
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+
| :doc:`morse (o) <bond_morse>` | :doc:`nonlinear (o) <bond_nonlinear>` | :doc:`oxdna/fene <bond_oxdna>` | :doc:`oxdna2/fene <bond_oxdna>` |
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+
| :doc:`quartic (o) <bond_quartic>` | :doc:`table (o) <bond_table>` | | |
+---------------------------------------+-------------------------------------------------+---------------------------------------------------------+---------------------------------+
----------
* :doc:`none <bond_none>`
* :doc:`zero <bond_zero>`
* :doc:`hybrid <bond_hybrid>`
*
*
*
*
*
* :doc:`class2 (ko) <bond_class2>`
* :doc:`fene (iko) <bond_fene>`
* :doc:`fene/expand (o) <bond_fene_expand>`
* :doc:`gromos (o) <bond_gromos>`
* :doc:`harmonic (iko) <bond_harmonic>`
* :doc:`harmonic/shift (o) <bond_harmonic_shift>`
* :doc:`harmonic/shift/cut (o) <bond_harmonic_shift_cut>`
* :doc:`mm3 <bond_mm3>`
* :doc:`morse (o) <bond_morse>`
* :doc:`nonlinear (o) <bond_nonlinear>`
* :doc:`oxdna/fene <bond_oxdna>`
* :doc:`oxdna2/fene <bond_oxdna>`
* :doc:`oxrna2/fene <bond_oxdna>`
* :doc:`quartic (o) <bond_quartic>`
* :doc:`table (o) <bond_table>`
.. _angle: .. _angle:
Angle\_style potentials Angle_style potentials
=================================== ======================
All LAMMPS :doc:`angle\_style <angle_style>` commands. Some styles have All LAMMPS :doc:`angle_style <angle_style>` commands. Some styles have
accelerated versions. This is indicated by additional letters in accelerated versions. This is indicated by additional letters in
parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t = parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t =
OPT. OPT.
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+ .. table_from_list::
| :doc:`none <angle_none>` | :doc:`zero <angle_zero>` | :doc:`hybrid <angle_hybrid>` | | :columns: 4
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
| | | | |
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
| :doc:`charmm (iko) <angle_charmm>` | :doc:`class2 (ko) <angle_class2>` | :doc:`class2/p6 <angle_class2>` | :doc:`cosine (ko) <angle_cosine>` |
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
| :doc:`cosine/buck6d <angle_cosine_buck6d>` | :doc:`cosine/delta (o) <angle_cosine_delta>` | :doc:`cosine/periodic (o) <angle_cosine_periodic>` | :doc:`cosine/shift (o) <angle_cosine_shift>` |
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
| :doc:`cosine/shift/exp (o) <angle_cosine_shift_exp>` | :doc:`cosine/squared (o) <angle_cosine_squared>` | :doc:`cross <angle_cross>` | :doc:`dipole (o) <angle_dipole>` |
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
| :doc:`fourier (o) <angle_fourier>` | :doc:`fourier/simple (o) <angle_fourier_simple>` | :doc:`harmonic (iko) <angle_harmonic>` | :doc:`mm3 <angle_mm3>` |
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
| :doc:`quartic (o) <angle_quartic>` | :doc:`sdk (o) <angle_sdk>` | :doc:`table (o) <angle_table>` | |
+------------------------------------------------------+--------------------------------------------------+----------------------------------------------------+----------------------------------------------+
----------
* :doc:`none <angle_none>`
* :doc:`zero <angle_zero>`
* :doc:`hybrid <angle_hybrid>`
*
*
*
*
*
* :doc:`charmm (iko) <angle_charmm>`
* :doc:`class2 (ko) <angle_class2>`
* :doc:`class2/p6 <angle_class2>`
* :doc:`cosine (ko) <angle_cosine>`
* :doc:`cosine/buck6d <angle_cosine_buck6d>`
* :doc:`cosine/delta (o) <angle_cosine_delta>`
* :doc:`cosine/periodic (o) <angle_cosine_periodic>`
* :doc:`cosine/shift (o) <angle_cosine_shift>`
* :doc:`cosine/shift/exp (o) <angle_cosine_shift_exp>`
* :doc:`cosine/squared (o) <angle_cosine_squared>`
* :doc:`cross <angle_cross>`
* :doc:`dipole (o) <angle_dipole>`
* :doc:`fourier (o) <angle_fourier>`
* :doc:`fourier/simple (o) <angle_fourier_simple>`
* :doc:`harmonic (iko) <angle_harmonic>`
* :doc:`mm3 <angle_mm3>`
* :doc:`quartic (o) <angle_quartic>`
* :doc:`sdk (o) <angle_sdk>`
* :doc:`table (o) <angle_table>`
.. _dihedral: .. _dihedral:
Dihedral\_style potentials Dihedral_style potentials
========================================= =========================
All LAMMPS :doc:`dihedral\_style <dihedral_style>` commands. Some styles All LAMMPS :doc:`dihedral_style <dihedral_style>` commands. Some styles
have accelerated versions. This is indicated by additional letters in have accelerated versions. This is indicated by additional letters in
parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t = parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t =
OPT. OPT.
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+ .. table_from_list::
| :doc:`none <dihedral_none>` | :doc:`zero <dihedral_zero>` | :doc:`hybrid <dihedral_hybrid>` | | :columns: 4
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+
| | | | |
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`charmm (iko) <dihedral_charmm>` | :doc:`charmmfsw <dihedral_charmm>` | :doc:`class2 (ko) <dihedral_class2>` | :doc:`cosine/shift/exp (o) <dihedral_cosine_shift_exp>` |
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`fourier (io) <dihedral_fourier>` | :doc:`harmonic (iko) <dihedral_harmonic>` | :doc:`helix (o) <dihedral_helix>` | :doc:`multi/harmonic (o) <dihedral_multi_harmonic>` |
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`nharmonic (o) <dihedral_nharmonic>` | :doc:`opls (iko) <dihedral_opls>` | :doc:`quadratic (o) <dihedral_quadratic>` | :doc:`spherical <dihedral_spherical>` |
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`table (o) <dihedral_table>` | :doc:`table/cut <dihedral_table_cut>` | | |
+-------------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------------------+
----------
* :doc:`none <dihedral_none>`
* :doc:`zero <dihedral_zero>`
* :doc:`hybrid <dihedral_hybrid>`
*
*
*
*
*
* :doc:`charmm (iko) <dihedral_charmm>`
* :doc:`charmmfsw <dihedral_charmm>`
* :doc:`class2 (ko) <dihedral_class2>`
* :doc:`cosine/shift/exp (o) <dihedral_cosine_shift_exp>`
* :doc:`fourier (io) <dihedral_fourier>`
* :doc:`harmonic (iko) <dihedral_harmonic>`
* :doc:`helix (o) <dihedral_helix>`
* :doc:`multi/harmonic (o) <dihedral_multi_harmonic>`
* :doc:`nharmonic (o) <dihedral_nharmonic>`
* :doc:`opls (iko) <dihedral_opls>`
* :doc:`quadratic (o) <dihedral_quadratic>`
* :doc:`spherical <dihedral_spherical>`
* :doc:`table (o) <dihedral_table>`
* :doc:`table/cut <dihedral_table_cut>`
.. _improper: .. _improper:
Improper\_style potentials Improper_style potentials
========================================= =========================
All LAMMPS :doc:`improper\_style <improper_style>` commands. Some styles All LAMMPS :doc:`improper_style <improper_style>` commands. Some styles
have accelerated versions. This is indicated by additional letters in have accelerated versions. This is indicated by additional letters in
parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t = parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t =
OPT. OPT.
+--------------------------------------+-----------------------------------------+-------------------------------------------+---------------------------------------------------------+ .. table_from_list::
| :doc:`none <improper_none>` | :doc:`zero <improper_zero>` | :doc:`hybrid <improper_hybrid>` | | :columns: 4
+--------------------------------------+-----------------------------------------+-------------------------------------------+---------------------------------------------------------+
| | | | |
+--------------------------------------+-----------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`class2 (ko) <improper_class2>` | :doc:`cossq (o) <improper_cossq>` | :doc:`cvff (io) <improper_cvff>` | :doc:`distance <improper_distance>` |
+--------------------------------------+-----------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`distharm <improper_distharm>` | :doc:`fourier (o) <improper_fourier>` | :doc:`harmonic (iko) <improper_harmonic>` | :doc:`inversion/harmonic <improper_inversion_harmonic>` |
+--------------------------------------+-----------------------------------------+-------------------------------------------+---------------------------------------------------------+
| :doc:`ring (o) <improper_ring>` | :doc:`sqdistharm <improper_sqdistharm>` | :doc:`umbrella (o) <improper_umbrella>` | |
+--------------------------------------+-----------------------------------------+-------------------------------------------+---------------------------------------------------------+
* :doc:`none <improper_none>`
.. _lws: http://lammps.sandia.gov * :doc:`zero <improper_zero>`
.. _ld: Manual.html * :doc:`hybrid <improper_hybrid>`
.. _lc: Commands_all.html *
*
*
*
*
* :doc:`class2 (ko) <improper_class2>`
* :doc:`cossq (o) <improper_cossq>`
* :doc:`cvff (io) <improper_cvff>`
* :doc:`distance <improper_distance>`
* :doc:`distharm <improper_distharm>`
* :doc:`fourier (o) <improper_fourier>`
* :doc:`harmonic (iko) <improper_harmonic>`
* :doc:`inversion/harmonic <improper_inversion_harmonic>`
* :doc:`ring (o) <improper_ring>`
* :doc:`sqdistharm <improper_sqdistharm>`
* :doc:`umbrella (o) <improper_umbrella>`

Some files were not shown because too many files have changed in this diff Show More