diff --git a/.gitattributes b/.gitattributes index 02b13c8ee5..660c85d619 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ .gitattributes export-ignore .gitignore export-ignore .github export-ignore +.lgtm.yml export-ignore +SECURITY.md export-ignore diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8457af3af9..ba702784f4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,43 +13,51 @@ lib/kim/* @ellio167 lib/mesont/* @iafoss # whole packages -src/COMPRESS/* @akohlmey +src/COMPRESS/* @rbberger src/GPU/* @ndtrung81 src/KOKKOS/* @stanmoore1 src/KIM/* @ellio167 src/LATTE/* @cnegre src/MESSAGE/* @sjplimp +src/MLIAP/* @athomps +src/SNAP/* @athomps src/SPIN/* @julient31 -src/USER-CGDNA/* @ohenrich -src/USER-CGSDK/* @akohlmey -src/USER-COLVARS/* @giacomofiorin -src/USER-INTEL/* @wmbrownintel -src/USER-MANIFOLD/* @Pakketeretet2 -src/USER-MEAMC/* @martok -src/USER-MESONT/* @iafoss -src/USER-MOFFF/* @hheenen -src/USER-MOLFILE/* @akohlmey -src/USER-NETCDF/* @pastewka -src/USER-PLUMED/* @gtribello -src/USER-PHONON/* @lingtikong -src/USER-PTM/* @pmla -src/USER-OMP/* @akohlmey -src/USER-QMMM/* @akohlmey -src/USER-REAXC/* @hasanmetin -src/USER-SCAFACOS/* @rhalver -src/USER-TALLY/* @akohlmey -src/USER-UEF/* @danicholson -src/USER-VTK/* @rbberger - +src/BROWNIAN/* @samueljmcameron +src/CG-DNA/* @ohenrich +src/CG-SDK/* @akohlmey +src/COLVARS/* @giacomofiorin +src/DIELECTRIC/* @ndtrung81 +src/FEP/* @agiliopadua +src/ML-HDNNP/* @singraber +src/INTEL/* @wmbrownintel +src/MANIFOLD/* @Pakketeretet2 +src/MDI/* @taylor-a-barnes +src/MEAM/* @martok +src/MESONT/* @iafoss +src/MOFFF/* @hheenen +src/MOLFILE/* @akohlmey +src/NETCDF/* @pastewka +src/ML-PACE/* @yury-lysogorskiy +src/PLUMED/* @gtribello +src/PHONON/* @lingtikong +src/PTM/* @pmla +src/OPENMP/* @akohlmey +src/QMMM/* @akohlmey +src/REAXFF/* @hasanmetin @stanmoore1 +src/REACTION/* @jrgissing +src/SCAFACOS/* @rhalver +src/TALLY/* @akohlmey +src/UEF/* @danicholson +src/VTK/* @rbberger # individual files in packages src/GPU/pair_vashishta_gpu.* @andeplane src/KOKKOS/pair_vashishta_kokkos.* @andeplane src/MANYBODY/pair_vashishta_table.* @andeplane src/MANYBODY/pair_atm.* @sergeylishchuk -src/USER-REACTION/fix_bond_react.* @jrgissing -src/USER-MISC/*_grem.* @dstelter92 -src/USER-MISC/compute_stress_mop*.* @RomainVermorel +src/REPLICA/*_grem.* @dstelter92 +src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel +src/MISC/*_tracker.* @jtclemm # core LAMMPS classes src/lammps.* @sjplimp @@ -73,8 +81,9 @@ src/kspace.* @sjplimp src/lmptyp.h @sjplimp src/library.* @sjplimp src/main.cpp @sjplimp +src/min_*.* @sjplimp src/memory.* @sjplimp -src/modify.* @sjplimp +src/modify.* @sjplimp @stanmoore1 src/molecule.* @sjplimp src/my_page.h @sjplimp src/my_pool_chunk.h @sjplimp @@ -101,7 +110,6 @@ src/thermo.* @sjplimp src/universe.* @sjplimp src/update.* @sjplimp src/variable.* @sjplimp -src/verlet.* @sjplimp src/velocity.* @sjplimp src/write_data.* @sjplimp src/write_restart.* @sjplimp @@ -114,23 +122,26 @@ src/info.* @akohlmey @rbberger src/timer.* @akohlmey src/min* @sjplimp @stanmoore1 src/utils.* @akohlmey @rbberger +src/verlet.* @sjplimp @stanmoore1 src/math_eigen_impl.h @jewettaij # tools tools/msi2lmp/* @akohlmey tools/emacs/* @HaoZeke tools/singularity/* @akohlmey @rbberger -tools/code_standard/* @rbberger +tools/coding_standard/* @rbberger tools/valgrind/* @akohlmey +tools/swig/* @akohlmey +tools/offline/* @rbberger # tests unittest/* @akohlmey @rbberger # cmake cmake/* @junghans @rbberger -cmake/Modules/Packages/USER-COLVARS.cmake @junghans @rbberger @giacomofiorin +cmake/Modules/Packages/COLVARS.cmake @junghans @rbberger @giacomofiorin cmake/Modules/Packages/KIM.cmake @junghans @rbberger @ellio167 -cmake/presets/*.cmake @junghans @rbberger @akohlmey +cmake/presets/*.cmake @akohlmey # python python/* @rbberger @@ -142,6 +153,7 @@ fortran/* @akohlmey doc/utils/*/* @rbberger doc/Makefile @rbberger doc/README @rbberger +examples/plugin/* @akohlmey # for releases src/version.h @sjplimp diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 31b9becc0c..182dd302b6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -5,8 +5,9 @@ Thank your for considering to contribute to the LAMMPS software project. The following is a set of guidelines as well as explanations of policies and work flows for contributing to the LAMMPS molecular dynamics software project. These guidelines focus on submitting issues or pull requests on the LAMMPS GitHub project. Thus please also have a look at: -* [The Section on submitting new features for inclusion in LAMMPS of the Manual](https://lammps.sandia.gov/doc/Modify_contribute.html) -* [The LAMMPS GitHub Tutorial in the Manual](http://lammps.sandia.gov/doc/Howto_github.html) +* [The guide for submitting new features in the LAMMPS manual](https://lammps.sandia.gov/doc/Modify_contribute.html) +* [The guide on programming style and requirement in the LAMMPS manual](https://lammps.sandia.gov/doc/Modify_contribute.html) +* [The GitHub tutorial in the LAMMPS manual](http://lammps.sandia.gov/doc/Howto_github.html) ## Table of Contents @@ -26,11 +27,11 @@ __ ## I don't want to read this whole thing I just have a question! -> **Note:** Please do not file an issue to ask a general question about LAMMPS, its features, how to use specific commands, or how perform simulations or analysis in LAMMPS. Instead post your question to either the ['lammps-users' mailing list](https://lammps.sandia.gov/mail.html) or the [LAMMPS Material Science Discourse forum](https://matsci.org/lammps). You do not need to be subscribed to post to the list (but a mailing list subscription avoids having your post delayed until it is approved by a mailing list moderator). Most posts to the mailing list receive a response within less than 24 hours. Before posting to the mailing list, please read the [mailing list guidelines](https://lammps.sandia.gov/guidelines.html). Following those guidelines will help greatly to get a helpful response. Always mention which LAMMPS version you are using. The LAMMPS forum was recently created as part of a larger effort to build a materials science community and have discussions not just about using LAMMPS. Thus the forum may be also used for discussions that would be off-topic for the mailing list. Those will just have to be moved to a more general category. +> **Note:** Please do not file an issue to ask a general question about LAMMPS, its features, how to use specific commands, or how perform simulations or analysis in LAMMPS. Instead post your question to either the ['lammps-users' mailing list](https://lammps.sandia.gov/mail.html) or the [LAMMPS Material Science Discourse forum](https://matsci.org/lammps). You do not need to be subscribed to post to the list (but a mailing list subscription avoids having your post delayed until it is approved by a mailing list moderator). Most posts to the mailing list receive a response within less than 24 hours. Before posting to the mailing list, please read the [mailing list guidelines](https://lammps.sandia.gov/guidelines.html). Following those guidelines will help greatly to get a helpful response. Always mention which LAMMPS version you are using. The LAMMPS forum was recently created as part of a larger effort to build a materials science community and have discussions not just about using LAMMPS. Thus the forum may be also used for discussions that would be off-topic for the mailing list. Those will just have to be posted to a more general category. ## How Can I Contribute? -There are several ways how you can actively contribute to the LAMMPS project: you can discuss compiling and using LAMMPS, and solving LAMMPS related problems with other LAMMPS users on the lammps-users mailing list, you can report bugs or suggest enhancements by creating issues on GitHub (or posting them to the lammps-users mailing list or posting in the LAMMPS Materials Science Discourse forum), and you can contribute by submitting pull requests on GitHub or e-mail your code +There are several ways how you can actively contribute to the LAMMPS project: you can discuss compiling and using LAMMPS, and solving LAMMPS related problems with other LAMMPS users on the lammps-users mailing list or the forum, you can report bugs or suggest enhancements by creating issues on GitHub (or posting them to the lammps-users mailing list or posting in the LAMMPS Materials Science Discourse forum), and you can contribute by submitting pull requests on GitHub or e-mail your code to one of the [LAMMPS core developers](https://lammps.sandia.gov/authors.html). As you may see from the aforementioned developer page, the LAMMPS software package includes the efforts of a very large number of contributors beyond the principal authors and maintainers. ### Discussing How To Use LAMMPS @@ -62,37 +63,12 @@ To be able to submit an issue on GitHub, you have to register for an account (fo ### Contributing Code -We encourage users to submit new features or modifications for LAMMPS to the core developers so they can be added to the LAMMPS distribution. The preferred way to manage and coordinate this is by submitting a pull request at the LAMMPS project on GitHub. For any larger modifications or programming project, you are encouraged to contact the LAMMPS developers ahead of time, in order to discuss implementation strategies and coding guidelines, that will make it easier to integrate your contribution and result in less work for everybody involved. You are also encouraged to search through the list of open issues on GitHub and submit a new issue for a planned feature, so you would not duplicate the work of others (and possibly get scooped by them) or have your work duplicated by others. +We encourage users to submit new features or modifications for LAMMPS. Instructions, guidelines, requirements, +and recommendations are in the following sections of the LAMMPS manual: +* [The guide for submitting new features in the LAMMPS manual](https://lammps.sandia.gov/doc/Modify_contribute.html) +* [The guide on programming style and requirement in the LAMMPS manual](https://lammps.sandia.gov/doc/Modify_contribute.html) +* [The GitHub tutorial in the LAMMPS manual](http://lammps.sandia.gov/doc/Howto_github.html) -How quickly your contribution will be integrated depends largely on how much effort it will cause to integrate and test it, how much it requires changes to the core code base, and of how much interest it is to the larger LAMMPS community. Please see below for a checklist of typical requirements. Once you have prepared everything, see [this tutorial](https://lammps.sandia.gov/doc/Howto_github.html) - for instructions on how to submit your changes or new files through a GitHub pull request - -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. - -* C++ source code must be compatible with the C++-11 standard. Packages may require a later standard, if justified. -* 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 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 (.cpp) system includes should be placed in angular brackets (<>) and for c-library functions the C++ style header files should be included ( instead of , or instead of ). 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.rst'. -* If you want your contribution to be added as a user-contributed feature, and it is a single file (actually a `.cpp` and `.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. -* 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 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 `.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 new utility functions or class (i.e. anything that does not depend on a LAMMPS object), new unit tests should be added to the unittest tree. -* When adding a new LAMMPS style, a .yaml file with a test configuration and reference data should be added for the styles where a suitable tester program already exists (e.g. pair styles, bond styles, etc.). -* 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. - -Finally, as a general rule-of-thumb, the more clear and self-explanatory you make your documentation and README files, and the easier you make it for people to get started, e.g. by providing example scripts, the more likely it is that users will try out your new feature. - -If the new features/files are broadly useful we may add them as core files to LAMMPS or as part of a standard package. Else we will add them as a user-contributed file or package. Examples of user packages are in src sub-directories that start with USER. The USER-MISC package is simply a collection of (mostly) unrelated single files, which is the simplest way to have your contribution quickly added to the LAMMPS distribution. You can see a list of the both standard and user packages by typing "make package" in the LAMMPS src directory. - -Note that by providing us files to release, you are agreeing to make them open-source, i.e. we can release them under the terms of the GPL, used as a license for the rest of LAMMPS. See Section 1.4 for details. - -With user packages and files, all we are really providing (aside from the fame and fortune that accompanies having your name in the source code and on the Authors page of the LAMMPS WWW site), is a means for you to distribute your work to the LAMMPS user community, and a mechanism for others to easily try out your new feature. This may help you find bugs or make contact with new collaborators. Note that you are also implicitly agreeing to support your code which means answer questions, fix bugs, and maintain it if LAMMPS changes in some way that breaks it (an unusual event). - -To be able to submit an issue on GitHub, you have to register for an account (for GitHub in general). If you do not want to do that, or have other reservations or difficulties to submit a pull request, you can - as an alternative - contact one or more of the core LAMMPS developers and ask if one of them would be interested in manually merging your code into LAMMPS and send them your source code. Since the effort to merge a pull request is a small fraction of the effort of integrating source code manually (which would usually be done by converting the contribution into a pull request), your chances to have your new code included quickly are the best with a pull request. - -If you prefer to submit patches or full files, you should first make certain, that your code works correctly with the latest patch-level version of LAMMPS and contains all bug fixes from it. Then create a gzipped tar file of all changed or added files or a corresponding patch file using 'diff -u' or 'diff -c' and compress it with gzip. Please only use gzip compression, as this works well on all platforms. ## GitHub Workflows @@ -102,17 +78,17 @@ This section briefly summarizes the steps that will happen **after** you have su After submitting an issue, one or more of the LAMMPS developers will review it and categorize it by assigning labels. Confirmed bug reports will be labeled `bug`; if the bug report also contains a suggestion for how to fix it, it will be labeled `bugfix`; if the issue is a feature request, it will be labeled `enhancement`. Other labels may be attached as well, depending on which parts of the LAMMPS code are affected. If the assessment is, that the issue does not warrant any changes, the `wontfix` label will be applied and if the submission is incorrect or something that should not be submitted as an issue, the `invalid` label will be applied. In both of the last two cases, the issue will then be closed without further action. -For feature requests, what happens next is that developers may comment on the viability or relevance of the request, discuss and make suggestions for how to implement it. If a LAMMPS developer or user is planning to implement the feature, the issue will be assigned to that developer. For developers, that are not yet listed as LAMMPS project collaborators, they will receive an invitation to be added to the LAMMPS project as a collaborator so they can get assigned. If the requested feature or enhancement is implemented, it will usually be submitted as a pull request, which will contain a reference to the issue number. And once the pull request is reviewed and accepted for inclusion into LAMMPS, the issue will be closed. For details on how pull requests are processed, please see below. +For feature requests, what happens next is that developers may comment on the viability or relevance of the request, discuss and make suggestions for how to implement it. If a LAMMPS developer or user is planning to implement the feature, the issue will be assigned to that developer. For developers, that are not yet listed as LAMMPS project collaborators, they will receive an invitation to be added to the LAMMPS project as a collaborator so they can get assigned. If the requested feature or enhancement is implemented, it will be submitted as a pull request, which will contain a reference to the issue number. And once the pull request is reviewed and accepted for inclusion into LAMMPS, the issue will be closed. For details on how pull requests are processed, please see below. Feature requests may be labeled with `volunteer_needed` if none of the LAMMPS developers has the time and the required knowledge implement the feature. -For bug reports, the next step is that one of the core LAMMPS developers will self-assign to the issue and try to confirm the bug. If confirmed, the `bug` label and potentially other labels are added to classify the issue and its impact to LAMMPS. Before confirming, further questions may be asked or requests for providing additional input files or details about the steps required to reproduce the issue. Any bugfix is likely to be submitted as a pull request (more about that below) and since most bugs require only local changes, the bugfix may be included in a pull request specifically set up to collect such local bugfixes or small enhancements. Once the bugfix is included in the master branch, the issue will be closed. +For bug reports, the next step is that one of the core LAMMPS developers will self-assign to the issue and try to confirm the bug. If confirmed, the `bug` label and potentially other labels are added to classify the issue and its impact to LAMMPS. Otherwise the `unconfirmed` label will be applied and some comment about what was tried to confirm the bug added. Before confirming, further questions may be asked or requests for providing additional input files or details about the steps required to reproduce the issue. Any bugfix will be submitted as a pull request (more about that below) and since most bugs require only local changes, the bugfix may be included in a pull request specifically set up to collect such local bugfixes or small enhancements. Once the bugfix is included in the master branch, the issue will be closed. ### Pull Requests -For submitting pull requests, there is a [detailed tutorial](https://lammps.sandia.gov/doc/Howto_github.html) in the LAMMPS manual. Thus only a brief breakdown of the steps is presented here. Please note, that the LAMMPS developers are still reviewing and trying to improve the process. If you are unsure about something, do not hesitate to post a question on the lammps-users mailing list or contact one fo the core LAMMPS developers. -Immediately after the submission, the LAMMPS continuing integration server at ci.lammps.org will download your submitted branch and perform a simple compilation test, i.e. will test whether your submitted code can be compiled under various conditions. It will also do a check on whether your included documentation translates cleanly. Whether these tests are successful or fail will be recorded. If a test fails, please inspect the corresponding output on the CI server and take the necessary steps, if needed, so that the code can compile cleanly again. The test will be re-run each the pull request is updated with a push to the remote branch on GitHub. -Next a LAMMPS core developer will self-assign and do an overall technical assessment of the submission. If you are not yet registered as a LAMMPS collaborator, you will receive an invitation for that. As part of the assessment, the pull request will be categorized with labels. There are two special labels: `needs_work` (indicates that work from the submitter of the pull request is needed) and `work_in_progress` (indicates, that the assigned LAMMPS developer will make changes, if not done by the contributor who made the submit). +Pull requests are the **only** way that changes get made to the LAMMPS distribution. So also the LAMMPS core developers will submit pull requests for their own changes and discuss them on GitHub. Thus if you submit a pull request it will be treated in a similar fashion. When you submit a pull request you may opt to submit a "Draft" pull request. That means your changes are visible and will be subject to testing, but reviewers will not be (auto-)assigned and comments will take into account that this is not complete. On the other hand, this is a perfect way to ask the LAMMPS developers for comments on non-obvious changes and get feedback and possible suggestions for improvements or recommendations about what to avoid. +Immediately after the submission, the LAMMPS continuing integration server at ci.lammps.org will download your submitted branch and perform a number of tests: it will tests whether it compiles cleanly under various conditions, it will also do a check on whether your included documentation translates cleanly and run some unit tests and other checks. Whether these tests are successful or fail will be recorded. If a test fails, please inspect the corresponding output on the CI server and take the necessary steps, if needed, so that the code can compile cleanly again. The test will be re-run each time the pull request is updated with a push to the remote branch on GitHub. If you are unsure about what you need to change, ask a question in the discussion area of the pull request. +Next a LAMMPS core developer will self-assign and do an overall technical assessment of the submission. If you submitted a draft pull request, this will not happen unless you mark it "ready for review". If you are not yet invited as a LAMMPS collaborator, and your contribution seems significant, you may also receive an invitation for collaboration on the LAMMPS repository. As part of the assessment, the pull request will be categorized with labels. There are two special labels: `needs_work` (indicates that work from the submitter of the pull request is needed) and `work_in_progress` (indicates, that the assigned LAMMPS developer will make changes, if not done by the contributor who made the submit). You may also receive comments and suggestions on the overall submission or specific details and on occasion specific requests for changes as part of the review. If permitted, also additional changes may be pushed into your pull request branch or a pull request may be filed in your LAMMPS fork on GitHub to include those changes. The LAMMPS developer may then decide to assign the pull request to another developer (e.g. when that developer is more knowledgeable about the submitted feature or enhancement or has written the modified code). It may also happen, that additional developers are requested to provide a review and approve the changes. For submissions, that may change the general behavior of LAMMPS, or where a possibility of unwanted side effects exists, additional tests may be requested by the assigned developer. -If the assigned developer is satisfied and considers the submission ready for inclusion into LAMMPS, the pull request will receive approvals and be merged into the master branch by one of the core LAMMPS developers. After the pull request is merged, you may delete the feature branch used for the pull request in your personal LAMMPS fork. -Since the learning curve for git is quite steep for efficiently managing remote repositories, local and remote branches, pull requests and more, do not hesitate to ask questions, if you are not sure about how to do certain steps that are asked of you. Even if the changes asked of you do not make sense to you, they may be important for the LAMMPS developers. Please also note, that these all are guidelines and nothing set in stone. So depending on the nature of the contribution, the workflow may be adjusted. +If the assigned developer is satisfied and considers the submission ready for inclusion into LAMMPS, the pull request will receive approvals and be merged into the master branch by one of the core LAMMPS developers. After the pull request is merged, you may delete the feature branch used for the pull request in your personal LAMMPS fork. The minimum requirement to merge a pull request is that all automated tests have to pass and at least one LAMMPS developer has approved integrating the submitted code. Since the approver will not be the person merging a pull request, you will have at least two LAMMPS developers that looked at your contribution. +Since the learning curve for git is quite steep for efficiently managing remote repositories, local and remote branches, pull requests and more, do not hesitate to ask questions, if you are not sure about how to do certain steps that are asked of you. Even if the changes asked of you do not make sense to you, they may be important for the LAMMPS developers. Please also note, that these all are guidelines and nothing set in stone. So depending on the nature of the contribution, the work flow may be adjusted. diff --git a/.github/codeql/cpp.yml b/.github/codeql/cpp.yml new file mode 100644 index 0000000000..6244ba707d --- /dev/null +++ b/.github/codeql/cpp.yml @@ -0,0 +1,4 @@ +paths: + - src + - lib + - tools diff --git a/.github/codeql/python.yml b/.github/codeql/python.yml new file mode 100644 index 0000000000..c02a54e3ea --- /dev/null +++ b/.github/codeql/python.yml @@ -0,0 +1,5 @@ +paths: + - python/lammps + +queries: + - uses: security-and-quality diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 827306c9aa..f9503e0e1f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -3,7 +3,7 @@ name: "CodeQL Code Analysis" on: push: - branches: [master] + branches: [develop] jobs: analyze: @@ -31,16 +31,18 @@ jobs: uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} + config-file: ./.github/codeql/${{ matrix.language }}.yml - name: Create Build Environment - run: cmake -E make_directory ${{github.workspace}}/build + if: ${{ matrix.language == 'cpp' }} + run: mkdir build - name: Building LAMMPS via CMake if: ${{ matrix.language == 'cpp' }} shell: bash - working-directory: ${{github.workspace}}/build + working-directory: build run: | - cmake -C $GITHUB_WORKSPACE/cmake/presets/most.cmake $GITHUB_WORKSPACE/cmake + cmake -C ../cmake/presets/most.cmake ../cmake cmake --build . --parallel 2 - name: Perform CodeQL Analysis diff --git a/.github/workflows/compile-msvc.yml b/.github/workflows/compile-msvc.yml new file mode 100644 index 0000000000..e8cfcd4788 --- /dev/null +++ b/.github/workflows/compile-msvc.yml @@ -0,0 +1,33 @@ +# GitHub action to build LAMMPS on Windows with Visual C++ +name: "Native Windows Compilation" + +on: + push: + branches: [develop] + +jobs: + build: + name: Windows Compilation Test + if: ${{ github.repository == 'lammps/lammps' }} + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Building LAMMPS via CMake + shell: bash + run: | + cmake -C cmake/presets/windows.cmake \ + -S cmake -B build \ + -D BUILD_SHARED_LIBS=on \ + -D LAMMPS_EXCEPTIONS=on + cmake --build build --config Release + + - name: Run LAMMPS executable + shell: bash + run: | + ./build/Release/lmp.exe -h + ./build/Release/lmp.exe -in bench/in.lj diff --git a/.github/workflows/unittest-macos.yml b/.github/workflows/unittest-macos.yml index f62b3046c9..6e2f9bd800 100644 --- a/.github/workflows/unittest-macos.yml +++ b/.github/workflows/unittest-macos.yml @@ -3,13 +3,15 @@ name: "Unittest for MacOS" on: push: - branches: [master] + branches: [develop] jobs: build: name: MacOS Unit Test if: ${{ github.repository == 'lammps/lammps' }} runs-on: macos-latest + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache steps: - name: Checkout repository @@ -17,20 +19,36 @@ jobs: with: fetch-depth: 2 + - name: Install ccache + run: brew install ccache + - name: Create Build Environment - run: cmake -E make_directory ${{github.workspace}}/build + run: mkdir build + + - name: Set up ccache + uses: actions/cache@v2 + with: + path: ${{ env.CCACHE_DIR }} + key: macos-ccache-${{ github.sha }} + restore-keys: macos-ccache- - name: Building LAMMPS via CMake shell: bash - working-directory: ${{github.workspace}}/build + working-directory: build run: | - cmake -C $GITHUB_WORKSPACE/cmake/presets/clang.cmake \ - -C $GITHUB_WORKSPACE/cmake/presets/most.cmake \ - $GITHUB_WORKSPACE/cmake \ - -DENABLE_TESTING=ON -DBUILD_SHARED_LIBS=ON -DLAMMPS_EXCEPTIONS=ON + ccache -z + cmake -C ../cmake/presets/clang.cmake \ + -C ../cmake/presets/most.cmake \ + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ + -D ENABLE_TESTING=on \ + -D BUILD_SHARED_LIBS=on \ + -D LAMMPS_EXCEPTIONS=on \ + ../cmake cmake --build . --parallel 2 + ccache -s - name: Run Tests - working-directory: ${{github.workspace}}/build + working-directory: build shell: bash run: ctest -V diff --git a/.gitignore b/.gitignore index 0f1b01775d..3fb3af0d13 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *.sif *.dll *.pyc +a.out __pycache__ Obj_* @@ -36,13 +37,20 @@ vgcore.* .Trashes ehthumbs.db Thumbs.db -.clang-format .lammps_history +.vs #cmake /build* /CMakeCache.txt /CMakeFiles/ +/Testing /Makefile +/Testing /cmake_install.cmake /lmp +out/Debug +out/RelWithDebInfo +out/Release +out/x86 +out/x64 diff --git a/.lgtm.yml b/.lgtm.yml new file mode 100644 index 0000000000..e5a62fd04b --- /dev/null +++ b/.lgtm.yml @@ -0,0 +1,14 @@ +extraction: + cpp: + configure: + command: + - "mkdir build" + - "cd build" + - "cmake -G Ninja -C ../cmake/presets/most.cmake ../cmake" + index: + build_command: + - "cd build" + - "ninja" + python: + python_setup: + version: 3 diff --git a/README b/README index 5b832790f3..bb0f335848 100644 --- a/README +++ b/README @@ -14,10 +14,10 @@ LAMMPS is a classical molecular dynamics simulation code designed to run efficiently on parallel computers. It was developed at Sandia National Laboratories, a US Department of Energy facility, with funding from the DOE. It is an open-source code, distributed freely -under the terms of the GNU Public License (GPL). +under the terms of the GNU Public License (GPL) version 2. The primary author of the code is Steve Plimpton, who can be emailed -at sjplimp@sandia.gov. The LAMMPS WWW Site at lammps.sandia.gov has +at sjplimp@sandia.gov. The LAMMPS WWW Site at www.lammps.org has more information about the code and its uses. The LAMMPS distribution includes the following files and directories: @@ -37,14 +37,14 @@ tools pre- and post-processing tools Point your browser at any of these files to get started: -https://lammps.sandia.gov/doc/Manual.html LAMMPS manual -https://lammps.sandia.gov/doc/Intro.html hi-level introduction -https://lammps.sandia.gov/doc/Build.html how to build LAMMPS -https://lammps.sandia.gov/doc/Run_head.html how to run LAMMPS -https://lammps.sandia.gov/doc/Commands_all.html Table of available commands -https://lammps.sandia.gov/doc/Library.html LAMMPS library interfaces -https://lammps.sandia.gov/doc/Modify.html how to modify and extend LAMMPS -https://lammps.sandia.gov/doc/Developer.html LAMMPS developer info +https://docs.lammps.org/Manual.html LAMMPS manual +https://docs.lammps.org/Intro.html hi-level introduction +https://docs.lammps.org/Build.html how to build LAMMPS +https://docs.lammps.org/Run_head.html how to run LAMMPS +https://docs.lammps.org/Commands_all.html Table of available commands +https://docs.lammps.org/Library.html LAMMPS library interfaces +https://docs.lammps.org/Modify.html how to modify and extend LAMMPS +https://docs.lammps.org/Developer.html LAMMPS developer info You can also create these doc pages locally: diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..9f65e2f88e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,35 @@ +# Security Policy + +LAMMPS is designed as a user-level application to conduct computer +simulations for research using classical mechanics. As such LAMMPS +depends to some degrees on users providing correctly formatted input and +LAMMPS needs to read and write files based on uncontrolled user input. +As a parallel application for use in high-performance computing +environments, performance critical steps are also done without checking +data. + +LAMMPS also is interfaced to a number of external libraries, including +libraries with experimental research software, that are not validated +and tested by the LAMMPS developers, so it is easy to import bad +behavior from calling functions in one of those libraries. + +Thus is is quite easy to crash LAMMPS through malicious input and do all +kinds of filesystem manipulations. And because of that LAMMPS should +**NEVER** be compiled or **run** as superuser, either from a "root" or +"administrator" account directly or indirectly via "sudo" or "su". + +Therefore what could be seen as a security vulnerability is usually +either a user mistake or a bug in the code. Bugs can be reported in +the LAMMPS project +[issue tracker on GitHub](https://github.com/lammps/lammps/issues). + + +# Version Updates + +LAMMPS follows continuous release development model. We aim to keep all +release versions (stable or patch) fully functional and employ a variety +of automatic testing procedures to detect failures of existing +functionality from adding new features before releases are made. Thus +bugfixes and updates are only integrated into the current development +branch and thus the next (patch) release and users are recommended to +update regularly. diff --git a/bench/POTENTIALS/README b/bench/POTENTIALS/README index d42726c184..a9e319a6c4 100644 --- a/bench/POTENTIALS/README +++ b/bench/POTENTIALS/README @@ -1,7 +1,7 @@ These are input scripts used to run benchmark tests for many of the interatomic potentials in LAMMPS. The results of running these scripts on different machines are shown on the Potentials section of -the Benchmark page of the LAMMPS WWW site (lammps.sandia.gov/bench). +the Benchmark page of the LAMMPS WWW site (https://www.lammps.org/bench.html). Examples are shown below of how to run these scripts. Log files for running them on 1 and 4 processors of a Linux box are included in the diff --git a/bench/POTENTIALS/in.meamc b/bench/POTENTIALS/in.meam similarity index 94% rename from bench/POTENTIALS/in.meamc rename to bench/POTENTIALS/in.meam index 0739b49411..9c6e06cd4d 100644 --- a/bench/POTENTIALS/in.meamc +++ b/bench/POTENTIALS/in.meam @@ -8,7 +8,7 @@ region box block 0 20 0 20 0 20 create_box 1 box create_atoms 1 box -pair_style meam/c +pair_style meam pair_coeff * * library.meam Ni4 Ni.meam Ni4 velocity all create 1600.0 376847 loop geom diff --git a/bench/POTENTIALS/log.9Oct20.meamc.1 b/bench/POTENTIALS/log.9Oct20.meam.1 similarity index 96% rename from bench/POTENTIALS/log.9Oct20.meamc.1 rename to bench/POTENTIALS/log.9Oct20.meam.1 index d6bebcd664..03e027674f 100644 --- a/bench/POTENTIALS/log.9Oct20.meamc.1 +++ b/bench/POTENTIALS/log.9Oct20.meam.1 @@ -15,7 +15,7 @@ create_atoms 1 box Created 32000 atoms create_atoms CPU = 0.002 seconds -pair_style meam/c +pair_style meam pair_coeff * * library.meam Ni4 Ni.meam Ni4 Reading potential file library.meam with DATE: 2012-06-29 Reading potential file Ni.meam with DATE: 2007-06-11 @@ -38,12 +38,12 @@ Neighbor list info ... ghost atom cutoff = 5 binsize = 2.5, bins = 29 29 29 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair meam/c, perpetual + (1) pair meam, perpetual attributes: full, newton on pair build: full/bin/atomonly stencil: full/bin/3d bin: standard - (2) pair meam/c, perpetual, half/full from (1) + (2) pair meam, perpetual, half/full from (1) attributes: half, newton on pair build: halffull/newton stencil: none diff --git a/bench/POTENTIALS/log.9Oct20.meamc.4 b/bench/POTENTIALS/log.9Oct20.meam.4 similarity index 96% rename from bench/POTENTIALS/log.9Oct20.meamc.4 rename to bench/POTENTIALS/log.9Oct20.meam.4 index 4ccae5ddce..fa343e33b5 100644 --- a/bench/POTENTIALS/log.9Oct20.meamc.4 +++ b/bench/POTENTIALS/log.9Oct20.meam.4 @@ -15,7 +15,7 @@ create_atoms 1 box Created 32000 atoms create_atoms CPU = 0.001 seconds -pair_style meam/c +pair_style meam pair_coeff * * library.meam Ni4 Ni.meam Ni4 Reading potential file library.meam with DATE: 2012-06-29 Reading potential file Ni.meam with DATE: 2007-06-11 @@ -38,12 +38,12 @@ Neighbor list info ... ghost atom cutoff = 5 binsize = 2.5, bins = 29 29 29 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair meam/c, perpetual + (1) pair meam, perpetual attributes: full, newton on pair build: full/bin/atomonly stencil: full/bin/3d bin: standard - (2) pair meam/c, perpetual, half/full from (1) + (2) pair meam, perpetual, half/full from (1) attributes: half, newton on pair build: halffull/newton stencil: none diff --git a/bench/POTENTIALS/log.9Oct20.reaxc.1 b/bench/POTENTIALS/log.9Oct20.reaxc.1 index fc89a32c85..86e35aa664 100644 --- a/bench/POTENTIALS/log.9Oct20.reaxc.1 +++ b/bench/POTENTIALS/log.9Oct20.reaxc.1 @@ -24,7 +24,7 @@ velocity all create 300.0 9999 pair_style reax/c NULL pair_coeff * * ffield.reax C H O N -WARNING: Changed valency_val to valency_boc for X (src/USER-REAXC/reaxc_ffield.cpp:315) +WARNING: Changed valency_val to valency_boc for X (src/REAXFF/reaxc_ffield.cpp:315) timestep 0.1 fix 1 all nve diff --git a/bench/POTENTIALS/log.9Oct20.reaxc.4 b/bench/POTENTIALS/log.9Oct20.reaxc.4 index c72cc9185d..f83ad2a05a 100644 --- a/bench/POTENTIALS/log.9Oct20.reaxc.4 +++ b/bench/POTENTIALS/log.9Oct20.reaxc.4 @@ -24,7 +24,7 @@ velocity all create 300.0 9999 pair_style reax/c NULL pair_coeff * * ffield.reax C H O N -WARNING: Changed valency_val to valency_boc for X (src/USER-REAXC/reaxc_ffield.cpp:315) +WARNING: Changed valency_val to valency_boc for X (src/REAXFF/reaxc_ffield.cpp:315) timestep 0.1 fix 1 all nve diff --git a/bench/README b/bench/README index 0806fcded6..7d5aced119 100644 --- a/bench/README +++ b/bench/README @@ -2,7 +2,7 @@ LAMMPS benchmark problems This directory contains 5 benchmark problems which are discussed in the Benchmark section of the LAMMPS documentation, and on the -Benchmark page of the LAMMPS WWW site (lammps.sandia.gov/bench). +Benchmark page of the LAMMPS WWW site (https://www.lammps.org/bench.html). This directory also has several sub-directories: @@ -11,7 +11,7 @@ KEPLER benchmark scripts for GPU cluster with Kepler GPUs POTENTIALS benchmarks scripts for various potentials in LAMMPS The results for all of these benchmarks are displayed and discussed on -the Benchmark page of the LAMMPS WWW site: lammps.sandia.gov/bench. +the Benchmark page of the LAMMPS WWW site: https://www.lammps.org/bench.html The remainder of this file refers to the 5 problems in the top-level of this directory and how to run them on CPUs, either in serial or diff --git a/cmake/.coveragerc.in b/cmake/.coveragerc.in new file mode 100644 index 0000000000..3dc467d4d0 --- /dev/null +++ b/cmake/.coveragerc.in @@ -0,0 +1,10 @@ +[run] +source = @LAMMPS_PYTHON_DIR@ +parallel=True +branch=True +omit=*/install.py + */setup.py + +[paths] +sources = python + @LAMMPS_PYTHON_DIR@ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index dd4c3bcaba..00a254197d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -7,6 +7,11 @@ cmake_minimum_required(VERSION 3.10) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() +# set policy to silence warnings about missing executable permissions in +# pythonx.y-config when cross-compiling. review occasionally if it may be set to NEW +if(POLICY CMP0109) + cmake_policy(SET CMP0109 OLD) +endif() ######################################## project(lammps CXX) @@ -31,7 +36,11 @@ find_package(Git) # by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Default install path" FORCE) + if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND (NOT CMAKE_CROSSCOMPILING)) + set(CMAKE_INSTALL_PREFIX "$ENV{USERPROFILE}/LAMMPS" CACHE PATH "Default install path" FORCE) + else() + set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Default install path" FORCE) + endif() endif() # If enabled, no need to use LD_LIBRARY_PATH / DYLD_LIBRARY_PATH when installed @@ -72,19 +81,46 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR}) include(CheckIncludeFileCXX) # set required compiler flags and compiler/CPU arch specific optimizations -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") - 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") +if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qrestrict") + endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4) + set(CMAKE_TUNE_DEFAULT "/QxCOMMON-AVX512") + else() + set(CMAKE_TUNE_DEFAULT "/QxHost") + endif() else() - set(CMAKE_TUNE_DEFAULT "-xHost") + 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() -# we require C++11 without extensions +# we require C++11 without extensions. Kokkos requires at least C++14 (currently) set(CMAKE_CXX_STANDARD 11) +if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14)) + set(CMAKE_CXX_STANDARD 14) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions") +# ugly hacks for MSVC which by default always reports an old C++ standard in the __cplusplus macro +# and prints lots of pointless warnings about "unsafe" functions +if(MSVC) + add_compile_options(/Zc:__cplusplus) + add_compile_options(/wd4244) + add_compile_options(/wd4267) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + +# export all symbols when building a .dll file on windows +if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() ######################################################################## # User input options # @@ -104,11 +140,23 @@ endif() option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF) +# allow enabling clang-tidy for C++ files +set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Include clang-tidy processing when compiling") +if(ENABLE_CLANG_TIDY) + set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*-header-filter=.*" CACHE STRING "") +endif() + include(GNUInstallDirs) file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp) list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES}) add_library(lammps ${ALL_SOURCES}) + +# tell CMake to export all symbols to a .dll on Windows with MinGW cross-compilers +if(BUILD_SHARED_LIBS AND (CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING) + set_target_properties(lammps PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols") +endif() + add_executable(lmp ${MAIN_SOURCES}) target_link_libraries(lmp PRIVATE lammps) set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY}) @@ -116,17 +164,92 @@ install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR}) option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) -set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE - GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE PERI POEMS - PLUGIN QEQ REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI - USER-ADIOS 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-MANIFOLD USER-MEAMC USER-MESONT USER-MGPT USER-MISC USER-MOFFF - USER-MOLFILE USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB - USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH - USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-PACE) +set(STANDARD_PACKAGES + ADIOS + ASPHERE + ATC + AWPMD + BOCS + BODY + BROWNIAN + CG-DNA + CG-SDK + CLASS2 + COLLOID + COLVARS + COMPRESS + DIELECTRIC + DIFFRACTION + DIPOLE + DPD-BASIC + DPD-MESO + DPD-REACT + DPD-SMOOTH + DRUDE + EFF + EXTRA-COMPUTE + EXTRA-DUMP + EXTRA-FIX + EXTRA-MOLECULE + EXTRA-PAIR + FEP + GRANULAR + H5MD + INTERLAYER + KIM + KSPACE + LATBOLTZ + LATTE + MACHDYN + MANIFOLD + MANYBODY + MC + MDI + MEAM + MESONT + MESSAGE + MGPT + MISC + ML-HDNNP + ML-IAP + ML-PACE + ML-QUIP + ML-RANN + ML-SNAP + MOFFF + MOLECULE + MOLFILE + MPIIO + MSCG + NETCDF + ORIENT + PERI + PHONON + PLUGIN + PLUMED + POEMS + PTM + PYTHON + QEQ + QMMM + QTB + REACTION + REAXFF + REPLICA + RIGID + SCAFACOS + SHOCK + SMTBQ + SPH + SPIN + SRD + TALLY + UEF + VORONOI + VTK + YAFF) -set(SUFFIX_PACKAGES CORESHELL GPU KOKKOS OPT USER-INTEL USER-OMP) +set(SUFFIX_PACKAGES CORESHELL GPU KOKKOS OPT INTEL OPENMP) foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) option(PKG_${PKG} "Build ${PKG} Package" OFF) @@ -137,7 +260,7 @@ endforeach() ###################################################### target_include_directories(lammps PUBLIC $) -if(PKG_USER-ADIOS) +if(PKG_ADIOS) # The search for ADIOS2 must come before MPI because # it includes its own MPI search with the latest FindMPI.cmake # script that defines the MPI::MPI_C target @@ -147,7 +270,6 @@ if(PKG_USER-ADIOS) endif() if(NOT CMAKE_CROSSCOMPILING) - set(MPI_CXX_SKIP_MPICXX TRUE) find_package(MPI QUIET) option(BUILD_MPI "Build MPI version" ${MPI_FOUND}) else() @@ -155,8 +277,11 @@ else() endif() if(BUILD_MPI) + # do not include the (obsolete) MPI C++ bindings which makes + # for leaner object files and avoids namespace conflicts + set(MPI_CXX_SKIP_MPICXX TRUE) # We use a non-standard procedure to cross-compile with MPI on Windows - if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING) + if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING) include(MPI4WIN) target_link_libraries(lammps PUBLIC MPI::MPI_CXX) else() @@ -174,6 +299,11 @@ else() target_include_directories(mpi_stubs PUBLIC $) if(BUILD_SHARED_LIBS) target_link_libraries(lammps PRIVATE mpi_stubs) + if(MSVC) + target_link_libraries(lmp PRIVATE mpi_stubs) + target_include_directories(lmp INTERFACE $) + target_compile_definitions(lmp INTERFACE $) + endif(MSVC) target_include_directories(lammps INTERFACE $) target_compile_definitions(lammps INTERFACE $) else() @@ -190,7 +320,7 @@ string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES) target_compile_definitions(lammps PUBLIC -DLAMMPS_${LAMMPS_SIZES}) # posix_memalign is not available on Windows -if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(LAMMPS_MEMALIGN "0" CACHE STRING "posix_memalign() is not available on Windows" FORCE) 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") @@ -206,12 +336,16 @@ endif() # "hard" dependencies between packages resulting # in an error instead of skipping over files -pkg_depends(MLIAP SNAP) +pkg_depends(ML-IAP ML-SNAP) pkg_depends(MPIIO MPI) -pkg_depends(USER-ATC MANYBODY) -pkg_depends(USER-LB MPI) -pkg_depends(USER-PHONON KSPACE) -pkg_depends(USER-SCAFACOS MPI) +pkg_depends(ATC MANYBODY) +pkg_depends(LATBOLTZ MPI) +pkg_depends(PHONON KSPACE) +pkg_depends(SCAFACOS MPI) +pkg_depends(DIELECTRIC KSPACE) +pkg_depends(DIELECTRIC EXTRA-PAIR) +pkg_depends(CG-DNA MOLECULE) +pkg_depends(CG-DNA ASPHERE) # detect if we may enable OpenMP support by default set(BUILD_OMP_DEFAULT OFF) @@ -232,8 +366,10 @@ if(BUILD_OMP) message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support") endif() - if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR - (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR + if(((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") OR + (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") OR (CMAKE_CXX_COMPILER_ID STREQUAL "XLClang") OR + ((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0))) # GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts. @@ -245,7 +381,7 @@ if(BUILD_OMP) target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) endif() -if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) +if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_LATTE) enable_language(C) find_package(LAPACK) find_package(BLAS) @@ -265,6 +401,8 @@ if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) endif() endif() +# tweak jpeg library names to avoid linker errors with MinGW cross-compilation +set(JPEG_NAMES libjpeg libjpeg-62) find_package(JPEG QUIET) option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) if(WITH_JPEG) @@ -296,7 +434,7 @@ find_program(GZIP_EXECUTABLE gzip) find_package_handle_standard_args(GZIP REQUIRED_VARS GZIP_EXECUTABLE) option(WITH_GZIP "Enable GZIP support" ${GZIP_FOUND}) if(WITH_GZIP) - if(GZIP_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)) + if(GZIP_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING)) target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP) else() message(FATAL_ERROR "gzip executable not found") @@ -307,7 +445,7 @@ find_program(FFMPEG_EXECUTABLE ffmpeg) find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_EXECUTABLE) option(WITH_FFMPEG "Enable FFMPEG support" ${FFMPEG_FOUND}) if(WITH_FFMPEG) - if(FFMPEG_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)) + if(FFMPEG_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING)) target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG) else() message(FATAL_ERROR "ffmpeg executable not found") @@ -324,10 +462,10 @@ else() set(CUDA_REQUEST_PIC) endif() -foreach(PKG_WITH_INCL KSPACE PYTHON MLIAP VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM - USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS USER-PACE) +foreach(PKG_WITH_INCL KSPACE PYTHON ML-IAP VORONOI COLVARS ML-HDNNP MDI MOLFILE NETCDF + PLUMED QMMM ML-QUIP SCAFACOS MACHDYN VTK KIM LATTE MESSAGE MSCG COMPRESS ML-PACE) if(PKG_${PKG_WITH_INCL}) - include(Packages/${PKG_WITH_INCL}) + include(Packages/${PKG_WITH_INCL}) endif() endforeach() @@ -353,9 +491,12 @@ foreach(HEADER cmath) endif(NOT FOUND_${HEADER}) endforeach(HEADER) -set(MATH_LIBRARIES "m" CACHE STRING "math library") -mark_as_advanced( MATH_LIBRARIES ) -target_link_libraries(lammps PRIVATE ${MATH_LIBRARIES}) +# make the standard math library overrideable and autodetected (for systems that don't have it) +find_library(STANDARD_MATH_LIB m DOC "Standard Math library") +mark_as_advanced(STANDARD_MATH_LIB) +if(STANDARD_MATH_LIB) + target_link_libraries(lammps PRIVATE ${STANDARD_MATH_LIB}) +endif() ###################################### # Generate Basic Style files @@ -418,11 +559,10 @@ endforeach() ############################################## # add lib sources of (simple) enabled packages ############################################ -foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-MESONT) - if(PKG_${SIMPLE_LIB}) - string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}") +foreach(PKG_LIB POEMS ATC AWPMD H5MD MESONT) + if(PKG_${PKG_LIB}) string(TOLOWER "${PKG_LIB}" PKG_LIB) - if(PKG_LIB STREQUAL mesont) + if(PKG_LIB STREQUAL "mesont") enable_language(Fortran) file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.f90) @@ -434,9 +574,9 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-MESONT) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) 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) - elseif(PKG_LIB STREQUAL h5md) + elseif(PKG_LIB STREQUAL "h5md") target_include_directories(h5md PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/h5md/include ${HDF5_INCLUDE_DIRS}) else() target_include_directories(${PKG_LIB} PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) @@ -444,13 +584,13 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-MESONT) endif() endforeach() -if(PKG_USER-AWPMD) +if(PKG_AWPMD) target_link_libraries(awpmd PRIVATE ${LAPACK_LIBRARIES}) endif() -if(PKG_USER-ATC) - if(LAMMPS_SIZES STREQUAL BIGBIG) - message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG") +if(PKG_ATC) + if(LAMMPS_SIZES STREQUAL "BIGBIG") + message(FATAL_ERROR "The ATC Package is not compatible with -DLAMMPS_BIGBIG") endif() target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES}) if(BUILD_MPI) @@ -462,30 +602,27 @@ if(PKG_USER-ATC) target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES}) endif() -if(PKG_USER-H5MD) - include(Packages/USER-H5MD) +if(PKG_H5MD) + include(Packages/H5MD) endif() ###################################################################### # packages which selectively include variants based on enabled styles # e.g. accelerator packages ###################################################################### -foreach(PKG_WITH_INCL CORESHELL QEQ USER-OMP USER-SDPD KOKKOS OPT USER-INTEL GPU) +foreach(PKG_WITH_INCL CORESHELL QEQ OPENMP DPD-SMOOTH KOKKOS OPT INTEL GPU) if(PKG_${PKG_WITH_INCL}) include(Packages/${PKG_WITH_INCL}) endif() endforeach() if(PKG_PLUGIN) - if(BUILD_SHARED_LIBS) - target_compile_definitions(lammps PRIVATE -DLMP_PLUGIN) - else() - message(WARNING "Plugin loading will not work unless BUILD_SHARED_LIBS is enabled") - endif() - # link with -ldl or equivalent for plugin loading; except on Windows - if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - target_link_libraries(lammps PRIVATE ${CMAKE_DL_LIBS}) - endif() + target_compile_definitions(lammps PRIVATE -DLMP_PLUGIN) +endif() + +# link with -ldl or equivalent for plugin loading; except on Windows +if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(lammps PRIVATE ${CMAKE_DL_LIBS}) endif() ###################################################################### @@ -493,8 +630,8 @@ endif() # 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) +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_link_libraries(lammps PRIVATE "wsock32;psapi") endif() ###################################################### @@ -542,8 +679,8 @@ add_dependencies(lammps gitversion) # Actually add executable and lib to build ############################################ get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) -list (FIND LANGUAGES "Fortran" _index) -if(${_index} GREATER -1) +list(FIND LANGUAGES "Fortran" _index) +if(_index GREATER -1) target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() 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 @@ -621,7 +758,7 @@ if(BUILD_SHARED_LIBS) else() find_package(Python COMPONENTS Interpreter) endif() - if (Python_EXECUTABLE) + if(Python_EXECUTABLE) add_custom_target( install-python ${CMAKE_COMMAND} -E remove_directory build COMMAND ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h @@ -654,7 +791,7 @@ if(BUILD_SHARED_LIBS OR PKG_PYTHON) else() find_package(Python COMPONENTS Interpreter) endif() - if (Python_EXECUTABLE) + if(Python_EXECUTABLE) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python) install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})") endif() @@ -663,6 +800,13 @@ endif() include(Testing) include(CodeCoverage) include(CodingStandard) +find_package(ClangFormat 8.0) + +if(ClangFormat_FOUND) + add_custom_target(format-src + COMMAND ${ClangFormat_EXECUTABLE} --verbose -i -style=file *.cpp *.h */*.cpp */*.h + WORKING_DIRECTORY ${LAMMPS_SOURCE_DIR}) +endif() get_target_property(DEFINES lammps COMPILE_DEFINITIONS) include(FeatureSummary) @@ -699,15 +843,15 @@ if(OPTIONS) message(" Options: ${OPTIONS}") endif() get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) -list (FIND LANGUAGES "Fortran" _index) -if(${_index} GREATER -1) +list(FIND LANGUAGES "Fortran" _index) +if(_index GREATER -1) message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER} Type: ${CMAKE_Fortran_COMPILER_ID} Version: ${CMAKE_Fortran_COMPILER_VERSION} Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") endif() -list (FIND LANGUAGES "C" _index) -if(${_index} GREATER -1) +list(FIND LANGUAGES "C" _index) +if(_index GREATER -1) message(STATUS "C compiler: ${CMAKE_C_COMPILER} Type: ${CMAKE_C_COMPILER_ID} Version: ${CMAKE_C_COMPILER_VERSION} @@ -772,7 +916,7 @@ if(PKG_KSPACE) endif() if(PKG_KOKKOS) if(Kokkos_ENABLE_CUDA) - if (${FFT} STREQUAL "KISS") + if(FFT STREQUAL "KISS") message(STATUS "Kokkos FFT: KISS") else() message(STATUS "Kokkos FFT: cuFFT") diff --git a/cmake/CMakeSettings.json b/cmake/CMakeSettings.json new file mode 100644 index 0000000000..dada2f6752 --- /dev/null +++ b/cmake/CMakeSettings.json @@ -0,0 +1,55 @@ +{ + "configurations": [ + { + "name": "x64-Debug-MSVC", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${workspaceRoot}\\build\\${name}", + "installRoot": "${workspaceRoot}\\install\\${name}", + "cmakeCommandArgs": "-S ${workspaceRoot}\\cmake -C ${workspaceRoot}\\cmake\\presets\\windows.cmake", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "BUILD_SHARED_LIBS", + "value": "True", + "type": "BOOL" + }, + { + "name": "BUILD_TOOLS", + "value": "True", + "type": "BOOL" + }, + { + "name": "LAMMPS_EXCEPTIONS", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "x64-Debug-Clang", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${workspaceRoot}\\build\\${name}", + "installRoot": "${workspaceRoot}\\install\\${name}", + "cmakeCommandArgs": "-S ${workspaceRoot}\\cmake -C ${workspaceRoot}\\cmake\\presets\\windows.cmake", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "clang_cl_x64" ], + "variables": [ + { + "name": "BUILD_TOOLS", + "value": "True", + "type": "BOOL" + }, + { + "name": "LAMMPS_EXCEPTIONS", + "value": "True", + "type": "BOOL" + } + ] + } + ] +} \ No newline at end of file diff --git a/cmake/Modules/CodeCoverage.cmake b/cmake/Modules/CodeCoverage.cmake index 054e08fc1a..21a651e519 100644 --- a/cmake/Modules/CodeCoverage.cmake +++ b/cmake/Modules/CodeCoverage.cmake @@ -54,6 +54,8 @@ if(ENABLE_COVERAGE) if(COVERAGE_FOUND) set(PYTHON_COVERAGE_HTML_DIR ${CMAKE_BINARY_DIR}/python_coverage_html) + configure_file(.coveragerc.in ${CMAKE_BINARY_DIR}/.coveragerc @ONLY) + add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/unittest/python/.coverage COMMAND ${COVERAGE_BINARY} combine @@ -63,16 +65,16 @@ if(ENABLE_COVERAGE) add_custom_target( gen_python_coverage_html - COMMAND ${COVERAGE_BINARY} html -d ${PYTHON_COVERAGE_HTML_DIR} - DEPENDS ${CMAKE_BINARY_DIR}/unittest/python/.coverage + COMMAND ${COVERAGE_BINARY} html --rcfile=${CMAKE_BINARY_DIR}/.coveragerc -d ${PYTHON_COVERAGE_HTML_DIR} + DEPENDS ${CMAKE_BINARY_DIR}/unittest/python/.coverage ${CMAKE_BINARY_DIR}/.coveragerc WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/unittest/python COMMENT "Generating HTML Python coverage report..." ) add_custom_target( gen_python_coverage_xml - COMMAND ${COVERAGE_BINARY} xml -o ${CMAKE_BINARY_DIR}/python_coverage.xml - DEPENDS ${CMAKE_BINARY_DIR}/unittest/python/.coverage + COMMAND ${COVERAGE_BINARY} xml --rcfile=${CMAKE_BINARY_DIR}/.coveragerc -o ${CMAKE_BINARY_DIR}/python_coverage.xml + DEPENDS ${CMAKE_BINARY_DIR}/unittest/python/.coverage ${CMAKE_BINARY_DIR}/.coveragerc WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/unittest/python COMMENT "Generating XML Python coverage report..." ) diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 646bdcdd4a..6bb607be12 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -15,6 +15,11 @@ if(Python3_EXECUTABLE) ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/whitespace.py . WORKING_DIRECTORY ${LAMMPS_DIR} COMMENT "Check for whitespace errors") + add_custom_target( + check-homepage + ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/homepage.py . + WORKING_DIRECTORY ${LAMMPS_DIR} + COMMENT "Check for homepage URL errors") add_custom_target( check-permissions ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/permissions.py . @@ -25,6 +30,11 @@ if(Python3_EXECUTABLE) ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/whitespace.py -f . WORKING_DIRECTORY ${LAMMPS_DIR} COMMENT "Fix whitespace errors") + add_custom_target( + fix-homepage + ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/homepage.py -f . + WORKING_DIRECTORY ${LAMMPS_DIR} + COMMENT "Fix homepage URL errors") add_custom_target( fix-permissions ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/permissions.py -f . diff --git a/cmake/Modules/FindFFTW3.cmake b/cmake/Modules/FindFFTW3.cmake index 708ec49509..6a34c21e10 100644 --- a/cmake/Modules/FindFFTW3.cmake +++ b/cmake/Modules/FindFFTW3.cmake @@ -38,7 +38,7 @@ if(FFTW3_FOUND) add_library(FFTW3::FFTW3_OMP UNKNOWN IMPORTED) set_target_properties(FFTW3::FFTW3_OMP PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${FFTW3_OMP_LIBRARY}" + IMPORTED_LOCATION "${FFTW3_OMP_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}") endif() endif() diff --git a/cmake/Modules/FindFFTW3F.cmake b/cmake/Modules/FindFFTW3F.cmake index 3dbcdaa04e..86355e04cd 100644 --- a/cmake/Modules/FindFFTW3F.cmake +++ b/cmake/Modules/FindFFTW3F.cmake @@ -37,7 +37,7 @@ if(FFTW3F_FOUND) add_library(FFTW3F::FFTW3F_OMP UNKNOWN IMPORTED) set_target_properties(FFTW3F::FFTW3F_OMP PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${FFTW3F_OMP_LIBRARY}" + IMPORTED_LOCATION "${FFTW3F_OMP_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}") endif() endif() diff --git a/cmake/Modules/FindN2P2.cmake b/cmake/Modules/FindN2P2.cmake new file mode 100644 index 0000000000..597e3e4609 --- /dev/null +++ b/cmake/Modules/FindN2P2.cmake @@ -0,0 +1,61 @@ +include(FindPackageHandleStandardArgs) + +# Check if N2P2_DIR is set manually. +if (DEFINED ENV{N2P2_DIR}) + set(N2P2_DIR "${N2P2_DIR}") +# If not, try if directory "lib/hdnnp/n2p2" exists. +else() + get_filename_component(_fullpath "${LAMMPS_LIB_SOURCE_DIR}/hdnnp/n2p2" REALPATH) + if (EXISTS ${_fullpath}) + set(N2P2_DIR "${_fullpath}") + endif() +endif() + +# Set path to include directory. +find_path(N2P2_INCLUDE_DIR InterfaceLammps.h HINTS "${N2P2_DIR}/include") +# Two libraries need to be linked: libnnp and libnnpif. +find_library(N2P2_LIBNNP NAMES nnp HINTS "${N2P2_DIR}/lib") +find_library(N2P2_LIBNNPIF NAMES nnpif HINTS "${N2P2_DIR}/lib") +# Users could compile n2p2 with extra flags which are then also required for +# pair_hdnnp.cpp compilation. To forward them to the LAMMPS build process n2p2 +# writes a file with cmake commands, e.g. +# +# target_compile_definitions(lammps PRIVATE -DN2P2_NO_SF_GROUPS) +# +# to "lib/lammps-extra.cmake" which is then included by ML-HDNNP.cmake. +find_file(N2P2_CMAKE_EXTRA NAMES lammps-extra.cmake HINTS "${N2P2_DIR}/lib") + +find_package_handle_standard_args(N2P2 DEFAULT_MSG + N2P2_DIR + N2P2_INCLUDE_DIR + N2P2_LIBNNP + N2P2_LIBNNPIF + N2P2_CMAKE_EXTRA) + +if(N2P2_FOUND) + if (NOT TARGET N2P2::N2P2) + # n2p2 core library "libnnp" + add_library(N2P2::LIBNNP UNKNOWN IMPORTED) + set_target_properties(N2P2::LIBNNP PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${N2P2_INCLUDE_DIR} + IMPORTED_LOCATION ${N2P2_LIBNNP}) + # n2p2 interface library "libnnpif" + add_library(N2P2::LIBNNPIF UNKNOWN IMPORTED) + set_target_properties(N2P2::LIBNNPIF PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${N2P2_INCLUDE_DIR} + IMPORTED_LOCATION ${N2P2_LIBNNPIF}) + # Put libnnp, libnnpif and include directory together. + add_library(N2P2::N2P2 INTERFACE IMPORTED) + set_property(TARGET N2P2::N2P2 PROPERTY + INTERFACE_LINK_LIBRARIES N2P2::LIBNNPIF N2P2::LIBNNP) + set(N2P2_CMAKE_EXTRAS ${N2P2_CMAKE_EXTRA}) + endif() +endif() + +mark_as_advanced( + N2P2_DIR + N2P2_INCLUDE_DIR + N2P2_LIBNNP + N2P2_LIBNNPIF + N2P2_CMAKE_EXTRA +) diff --git a/cmake/Modules/GTest.cmake b/cmake/Modules/GTest.cmake index 677ed5f4af..e012e61ea9 100644 --- a/cmake/Modules/GTest.cmake +++ b/cmake/Modules/GTest.cmake @@ -1,14 +1,14 @@ message(STATUS "Downloading and building Google Test library") -if(CMAKE_BUILD_TYPE STREQUAL Debug) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(GTEST_LIB_POSTFIX d) else() set(GTEST_LIB_POSTFIX) endif() include(ExternalProject) -set(GTEST_URL "https://github.com/google/googletest/archive/release-1.10.0.tar.gz" CACHE STRING "URL for GTest tarball") -set(GTEST_MD5 "ecd1fa65e7de707cd5c00bdac56022cd" CACHE STRING "MD5 checksum of GTest tarball") +set(GTEST_URL "https://github.com/google/googletest/archive/release-1.11.0.tar.gz" CACHE STRING "URL of googletest source") +set(GTEST_MD5 "e8a8df240b6938bb6384155d4c37d937" CACHE STRING "MD5 sum for googletest source") mark_as_advanced(GTEST_URL) mark_as_advanced(GTEST_MD5) ExternalProject_Add(googletest diff --git a/cmake/Modules/GenerateOpenCLHeader.cmake b/cmake/Modules/GenerateOpenCLHeader.cmake new file mode 100644 index 0000000000..18dfac1604 --- /dev/null +++ b/cmake/Modules/GenerateOpenCLHeader.cmake @@ -0,0 +1,3 @@ +# utility script to call WriteOpenCLHeader function +include(${SOURCE_DIR}/Modules/OpenCLUtils.cmake) +WriteOpenCLHeader(${VARNAME} ${HEADER_FILE} ${SOURCE_FILES}) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 41dcfc5b2f..28ad99fa31 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -67,7 +67,7 @@ endfunction() macro(pkg_depends PKG1 PKG2) if(PKG_${PKG1} AND NOT (PKG_${PKG2} OR BUILD_${PKG2})) - message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}") + message(FATAL_ERROR "The ${PKG1} package needs LAMMPS to be build with the ${PKG2} package") endif() endmacro() @@ -85,7 +85,7 @@ endfunction(GenerateBinaryHeader) # fetch missing potential files function(FetchPotentials pkgfolder potfolder) - if (EXISTS "${pkgfolder}/potentials.txt") + if(EXISTS "${pkgfolder}/potentials.txt") file(STRINGS "${pkgfolder}/potentials.txt" linelist REGEX "^[^#].") foreach(line ${linelist}) string(FIND ${line} " " blank) @@ -106,7 +106,7 @@ function(FetchPotentials pkgfolder potfolder) endfunction(FetchPotentials) # set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux -if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (EXISTS /etc/os-release)) +if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (EXISTS /etc/os-release)) file(STRINGS /etc/os-release distro REGEX "^NAME=") string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}") file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=") diff --git a/cmake/Modules/OpenCLLoader.cmake b/cmake/Modules/OpenCLLoader.cmake index 54eaab4795..3a8e63b213 100644 --- a/cmake/Modules/OpenCLLoader.cmake +++ b/cmake/Modules/OpenCLLoader.cmake @@ -1,6 +1,6 @@ message(STATUS "Downloading and building OpenCL loader library") -set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2020.12.18.tar.gz" CACHE STRING "URL for OpenCL loader tarball") -set(OPENCL_LOADER_MD5 "011cdcbd41030be94f3fced6d763a52a" CACHE STRING "MD5 checksum of OpenCL loader tarball") +set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2021.09.18.tar.gz" CACHE STRING "URL for OpenCL loader tarball") +set(OPENCL_LOADER_MD5 "3b3882627964bd02e5c3b02065daac3c" CACHE STRING "MD5 checksum of OpenCL loader tarball") mark_as_advanced(OPENCL_LOADER_URL) mark_as_advanced(OPENCL_LOADER_MD5) diff --git a/cmake/Modules/OpenCLUtils.cmake b/cmake/Modules/OpenCLUtils.cmake index a9441ce518..eb17da0b3d 100644 --- a/cmake/Modules/OpenCLUtils.cmake +++ b/cmake/Modules/OpenCLUtils.cmake @@ -1,10 +1,8 @@ -function(GenerateOpenCLHeader varname outfile files) - message("Creating ${outfile}...") +function(WriteOpenCLHeader varname outfile files) file(WRITE ${outfile} "const char * ${varname} = \n") - math(EXPR ARG_END "${ARGC}-1") + separate_arguments(files) - foreach(IDX RANGE 2 ${ARG_END}) - list(GET ARGV ${IDX} filename) + foreach(filename ${files}) file(READ ${filename} content) string(REGEX REPLACE "\\s*//[^\n]*\n" "\n" content "${content}") string(REGEX REPLACE "\\\\" "\\\\\\\\" content "${content}") @@ -15,4 +13,16 @@ function(GenerateOpenCLHeader varname outfile files) endforeach() file(APPEND ${outfile} ";\n") +endfunction(WriteOpenCLHeader) + +function(GenerateOpenCLHeader varname outfile files) + list(REMOVE_AT ARGV 0 1) + add_custom_command(OUTPUT ${outfile} + COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} + -D VARNAME=${varname} + -D HEADER_FILE=${outfile} + -D SOURCE_FILES="${ARGV}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/GenerateOpenCLHeader.cmake + DEPENDS ${ARGV} + COMMENT "Generating ${outfile}...") endfunction(GenerateOpenCLHeader) diff --git a/cmake/Modules/Packages/USER-COLVARS.cmake b/cmake/Modules/Packages/COLVARS.cmake similarity index 100% rename from cmake/Modules/Packages/USER-COLVARS.cmake rename to cmake/Modules/Packages/COLVARS.cmake diff --git a/cmake/Modules/Packages/USER-SDPD.cmake b/cmake/Modules/Packages/DPD-SMOOTH.cmake similarity index 50% rename from cmake/Modules/Packages/USER-SDPD.cmake rename to cmake/Modules/Packages/DPD-SMOOTH.cmake index c9f419d918..c5271d9091 100644 --- a/cmake/Modules/Packages/USER-SDPD.cmake +++ b/cmake/Modules/Packages/DPD-SMOOTH.cmake @@ -1,13 +1,13 @@ # Fix rigid/meso requires RIGID to be installed -set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD) +set(DPD-SMOOTH_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/DPD-SMOOTH) get_property(hlist GLOBAL PROPERTY FIX) if(NOT PKG_RIGID) - list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h) + list(REMOVE_ITEM hlist ${DPD-SMOOTH_SOURCES_DIR}/fix_rigid_meso.h) get_target_property(LAMMPS_SOURCES lammps SOURCES) - list(REMOVE_ITEM LAMMPS_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp) + list(REMOVE_ITEM LAMMPS_SOURCES ${DPD-SMOOTH_SOURCES_DIR}/fix_rigid_meso.cpp) set_property(TARGET lammps PROPERTY SOURCES ${LAMMPS_SOURCES}) endif() set_property(GLOBAL PROPERTY FIX "${hlist}") -target_include_directories(lammps PRIVATE ${USER-SDPD_SOURCES_DIR}) +target_include_directories(lammps PRIVATE ${DPD-SMOOTH_SOURCES_DIR}) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index fa1a493330..a57715d294 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -48,7 +48,7 @@ if(GPU_API STREQUAL "CUDA") # ensure that no *cubin.h files exist from a compile in the lib/gpu folder file(GLOB GPU_LIB_OLD_CUBIN_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) - if (GPU_LIB_OLD_CUBIN_HEADERS) + if(GPU_LIB_OLD_CUBIN_HEADERS) message(FATAL_ERROR "########################################################################\n" "Found file(s) generated by the make-based build system in lib/gpu\n" "Please run\n" @@ -71,44 +71,47 @@ if(GPU_API STREQUAL "CUDA") # 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_EQUAL "3.2") 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.0) is supported by CUDA 5 to CUDA 10.2 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") - endif() - # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) - string(APPEND GPU_CUDA_GENCODE " -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_EQUAL "6.0") - 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_EQUAL "8.0") - 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_EQUAL "9.0") - 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_EQUAL "10.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") - endif() - # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") - endif() - # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") - endif() + + # apply the following to build "fat" CUDA binaries only for known CUDA toolkits if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") - message(WARNING "Unsupported CUDA version. Use at your own risk.") + message(WARNING "Untested CUDA Toolkit version. Use at your own risk") + else() + # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0 + if((CUDA_VERSION VERSION_GREATER_EQUAL "3.2") 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.0) is supported by CUDA 5 to CUDA 10.2 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") + endif() + # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) + string(APPEND GPU_CUDA_GENCODE " -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_EQUAL "6.0") + 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_EQUAL "8.0") + 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_EQUAL "9.0") + 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_EQUAL "10.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") + endif() + # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") + endif() + # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") + endif() endif() cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS ${CUDA_REQUEST_PIC} @@ -145,9 +148,16 @@ if(GPU_API STREQUAL "CUDA") target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) elseif(GPU_API STREQUAL "OPENCL") - option(USE_STATIC_OPENCL_LOADER "Download and include a static OpenCL ICD loader" ON) + # the static OpenCL loader doesn't seem to work on macOS. use the system provided + # version by default instead (for as long as it will be available) + if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + set(_opencl_static_default OFF) + else() + set(_opencl_static_default ON) + endif() + option(USE_STATIC_OPENCL_LOADER "Download and include a static OpenCL ICD loader" ${_opencl_static_default}) mark_as_advanced(USE_STATIC_OPENCL_LOADER) - if (USE_STATIC_OPENCL_LOADER) + if(USE_STATIC_OPENCL_LOADER) include(OpenCLLoader) else() find_package(OpenCL REQUIRED) @@ -207,13 +217,20 @@ elseif(GPU_API STREQUAL "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") + set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to HIP installation") else() - set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed") + set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to HIP installation") endif() endif() - set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) - find_package(HIP REQUIRED) + if(NOT DEFINED ROCM_PATH) + if(NOT DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to ROCm installation") + else() + set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to ROCm installation") + endif() + endif() + list(APPEND CMAKE_PREFIX_PATH ${HIP_PATH} ${ROCM_PATH}) + find_package(hip REQUIRED) option(HIP_USE_DEVICE_SORT "Use GPU sorting" ON) if(NOT DEFINED HIP_PLATFORM) @@ -315,10 +332,11 @@ elseif(GPU_API STREQUAL "HIP") 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}) + 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) + target_link_libraries(gpu PRIVATE hip::host) if(HIP_USE_DEVICE_SORT) # add hipCUB @@ -367,8 +385,9 @@ elseif(GPU_API STREQUAL "HIP") endif() endif() - hip_add_executable(hip_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) + add_executable(hip_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) target_compile_definitions(hip_get_devices PRIVATE -DUCL_HIP) + target_link_libraries(hip_get_devices hip::host) if(HIP_PLATFORM STREQUAL "nvcc") target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_NVCC__) diff --git a/cmake/Modules/Packages/USER-H5MD.cmake b/cmake/Modules/Packages/H5MD.cmake similarity index 100% rename from cmake/Modules/Packages/USER-H5MD.cmake rename to cmake/Modules/Packages/H5MD.cmake diff --git a/cmake/Modules/Packages/USER-INTEL.cmake b/cmake/Modules/Packages/INTEL.cmake similarity index 61% rename from cmake/Modules/Packages/USER-INTEL.cmake rename to cmake/Modules/Packages/INTEL.cmake index 90ab6167a3..af08249090 100644 --- a/cmake/Modules/Packages/USER-INTEL.cmake +++ b/cmake/Modules/Packages/INTEL.cmake @@ -3,9 +3,9 @@ if(NOT FOUND_IMMINTRIN) message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it") endif() -target_compile_definitions(lammps PRIVATE -DLMP_USER_INTEL) +target_compile_definitions(lammps PRIVATE -DLMP_INTEL) -set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)") +set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by 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) @@ -40,10 +40,10 @@ 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}") + message(FATAL_ERROR "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") + message(WARNING "INTEL gives best performance with Intel compilers") endif() find_package(TBB_MALLOC QUIET) @@ -52,7 +52,7 @@ if(TBB_MALLOC_FOUND) 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") + message(WARNING "INTEL with Intel compilers should use TBB malloc libraries") endif() endif() @@ -65,12 +65,12 @@ else() 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") + message(FATAL_ERROR "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") + message(FATAL_ERROR "Must use Intel compiler with 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\\\"\"") @@ -79,9 +79,11 @@ if(INTEL_ARCH STREQUAL "KNL") 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}) + foreach(_FLAG -O2 "-fp-model fast=2" -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict) + string(REGEX REPLACE "[ =\"]" "" _FLAGX ${_FLAG}) + check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAGX}) + if(COMPILER_SUPPORTS${_FLAGX}) + separate_arguments(_FLAG UNIX_COMMAND "${_FLAG}") target_compile_options(lammps PRIVATE ${_FLAG}) endif() endforeach() @@ -89,26 +91,26 @@ else() 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(INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/INTEL) +set(INTEL_SOURCES ${INTEL_SOURCES_DIR}/fix_intel.cpp + ${INTEL_SOURCES_DIR}/fix_nh_intel.cpp + ${INTEL_SOURCES_DIR}/intel_buffers.cpp + ${INTEL_SOURCES_DIR}/nbin_intel.cpp + ${INTEL_SOURCES_DIR}/npair_intel.cpp) -set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}") +set_property(GLOBAL PROPERTY "INTEL_SOURCES" "${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) +# detect styles which have a INTEL version +RegisterStylesExt(${INTEL_SOURCES_DIR} intel INTEL_SOURCES) +RegisterNBinStyle(${INTEL_SOURCES_DIR}/nbin_intel.h) +RegisterNPairStyle(${INTEL_SOURCES_DIR}/npair_intel.h) +RegisterFixStyle(${INTEL_SOURCES_DIR}/fix_intel.h) -get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES) +get_property(INTEL_SOURCES GLOBAL PROPERTY 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) + list(APPEND INTEL_SOURCES ${INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp) + RegisterIntegrateStyle(${INTEL_SOURCES_DIR}/verlet_lrt_intel.h) endif() -target_sources(lammps PRIVATE ${USER-INTEL_SOURCES}) -target_include_directories(lammps PRIVATE ${USER-INTEL_SOURCES_DIR}) +target_sources(lammps PRIVATE ${INTEL_SOURCES}) +target_include_directories(lammps PRIVATE ${INTEL_SOURCES_DIR}) diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 1f00516e08..fe6c17801e 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -1,6 +1,8 @@ ######################################################################## # As of version 3.3.0 Kokkos requires C++14 -set(CMAKE_CXX_STANDARD 14) +if(CMAKE_CXX_STANDARD LESS 14) + message(FATAL_ERROR "The KOKKOS package requires the C++ standard to be set to at least C++14") +endif() ######################################################################## # consistency checks and Kokkos options/settings required by LAMMPS if(Kokkos_ENABLE_CUDA) @@ -37,8 +39,8 @@ if(DOWNLOAD_KOKKOS) 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) - set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/3.3.01.tar.gz" CACHE STRING "URL for KOKKOS tarball") - set(KOKKOS_MD5 "08201d1c7cf5bc458ce0f5b44a629d5a" CACHE STRING "MD5 checksum of KOKKOS tarball") + set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/3.4.01.tar.gz" CACHE STRING "URL for KOKKOS tarball") + set(KOKKOS_MD5 "4c84698917c93a18985b311bb6caf84f" CACHE STRING "MD5 checksum of KOKKOS tarball") mark_as_advanced(KOKKOS_URL) mark_as_advanced(KOKKOS_MD5) ExternalProject_Add(kokkos_build @@ -58,7 +60,7 @@ if(DOWNLOAD_KOKKOS) target_link_libraries(lmp PRIVATE LAMMPS::KOKKOS) add_dependencies(LAMMPS::KOKKOS kokkos_build) elseif(EXTERNAL_KOKKOS) - find_package(Kokkos 3.3.01 REQUIRED CONFIG) + find_package(Kokkos 3.4.01 REQUIRED CONFIG) target_link_libraries(lammps PRIVATE Kokkos::kokkos) target_link_libraries(lmp PRIVATE Kokkos::kokkos) else() @@ -74,11 +76,12 @@ else() target_link_libraries(lammps PRIVATE kokkos) target_link_libraries(lmp PRIVATE kokkos) endif() -target_compile_definitions(lammps PRIVATE -DLMP_KOKKOS) +target_compile_definitions(lammps PUBLIC $) 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_map_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 @@ -99,7 +102,7 @@ if(PKG_KSPACE) ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp ${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp) if(Kokkos_ENABLE_CUDA) - if(NOT ${FFT} STREQUAL "KISS") + if(NOT (FFT STREQUAL "KISS")) target_compile_definitions(lammps PRIVATE -DFFT_CUFFT) target_link_libraries(lammps PRIVATE cufft) endif() @@ -116,7 +119,7 @@ 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) +if(PKG_DPD-REACT) 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) @@ -126,4 +129,4 @@ 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}) +target_include_directories(lammps PUBLIC $) diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake index ddf31a68ed..a96e850f7e 100644 --- a/cmake/Modules/Packages/LATTE.cmake +++ b/cmake/Modules/Packages/LATTE.cmake @@ -19,6 +19,14 @@ if(DOWNLOAD_LATTE) set(LATTE_MD5 "820e73a457ced178c08c71389a385de7" CACHE STRING "MD5 checksum of LATTE tarball") mark_as_advanced(LATTE_URL) mark_as_advanced(LATTE_MD5) + + # CMake cannot pass BLAS or LAPACK library variable to external project if they are a list + list(LENGTH BLAS_LIBRARIES} NUM_BLAS) + list(LENGTH LAPACK_LIBRARIES NUM_LAPACK) + if((NUM_BLAS GREATER 1) OR (NUM_LAPACK GREATER 1)) + message(FATAL_ERROR "Cannot compile downloaded LATTE library due to a technical limitation") + endif() + include(ExternalProject) ExternalProject_Add(latte_build URL ${LATTE_URL} diff --git a/cmake/Modules/Packages/USER-SMD.cmake b/cmake/Modules/Packages/MACHDYN.cmake similarity index 74% rename from cmake/Modules/Packages/USER-SMD.cmake rename to cmake/Modules/Packages/MACHDYN.cmake index 6d941f9798..d90ca8146c 100644 --- a/cmake/Modules/Packages/USER-SMD.cmake +++ b/cmake/Modules/Packages/MACHDYN.cmake @@ -7,8 +7,9 @@ endif() option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT}) if(DOWNLOAD_EIGEN3) message(STATUS "Eigen3 download requested - we will build our own") - set(EIGEN3_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz" CACHE STRING "URL for Eigen3 tarball") - set(EIGEN3_MD5 "9e30f67e8531477de4117506fe44669b" CACHE STRING "MD5 checksum of Eigen3 tarball") + + set(EIGEN3_URL "${LAMMPS_THIRDPARTY_URL}/eigen-3.4.0.tar.gz" CACHE STRING "URL for Eigen3 tarball") + set(EIGEN3_MD5 "4c527a9171d71a72a9d4186e65bea559" CACHE STRING "MD5 checksum of Eigen3 tarball") mark_as_advanced(EIGEN3_URL) mark_as_advanced(EIGEN3_MD5) include(ExternalProject) @@ -30,3 +31,8 @@ else() endif() target_link_libraries(lammps PRIVATE Eigen3::Eigen) endif() + +# PGI/Nvidia compiler internals collide with vector intrinsics support in Eigen3 +if((CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")) + target_compile_definitions(lammps PRIVATE -DEIGEN_DONT_VECTORIZE) +endif() diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake new file mode 100644 index 0000000000..047c30c603 --- /dev/null +++ b/cmake/Modules/Packages/MDI.cmake @@ -0,0 +1,118 @@ +find_package(mdi QUIET) +if(${mdi_FOUND}) + set(DOWNLOAD_MDI_DEFAULT OFF) +else() + set(DOWNLOAD_MDI_DEFAULT ON) +endif() +option(DOWNLOAD_MDI "Download and compile the MDI library instead of using an already installed one" ${DOWNLOAD_MDI_DEFAULT}) + +if(DOWNLOAD_MDI) + message(STATUS "MDI download requested - we will build our own") + set(MDI_URL "https://github.com/MolSSI-MDI/MDI_Library/archive/v1.2.9.tar.gz" CACHE STRING "URL for MDI tarball") + set(MDI_MD5 "ddfa46d6ee15b4e59cfd527ec7212184" CACHE STRING "MD5 checksum for MDI tarball") + mark_as_advanced(MDI_URL) + mark_as_advanced(MDI_MD5) + enable_language(C) + + # only ON/OFF are allowed for "mpi" flag when building MDI library + # so translate boolean value of BUILD_MPI + # always disable MPI when cross-compiling to Windows. + if((BUILD_MPI) AND NOT((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING)) + set(MDI_USE_MPI ON) + else() + set(MDI_USE_MPI OFF) + endif() + + # detect if we have python development support and thus can enable python plugins + set(MDI_USE_PYTHON_PLUGINS OFF) + if(CMAKE_VERSION VERSION_LESS 3.12) + find_package(PythonLibs QUIET) # Deprecated since version 3.12 + if(PYTHONLIBS_FOUND) + set(MDI_USE_PYTHON_PLUGINS ON) + endif() + else() + find_package(Python QUIET COMPONENTS Development) + if(Python_Development_FOUND) + set(MDI_USE_PYTHON_PLUGINS ON) + endif() + endif() + + # download/ build MDI library + # always build static library with -fpic + # support cross-compilation and ninja-build + include(ExternalProject) + ExternalProject_Add(mdi_build + URL ${MDI_URL} + URL_MD5 ${MDI_MD5} + CMAKE_ARGS ${CMAKE_REQUEST_PIC} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -Dlanguage=C + -Dlibtype=STATIC + -Dmpi=${MDI_USE_MPI} + -Dpython_plugins=${MDI_USE_PYTHON_PLUGINS} + UPDATE_COMMAND "" + INSTALL_COMMAND "" + BUILD_BYPRODUCTS "/MDI_Library/libmdi.a" + ) + + # where is the compiled library? + ExternalProject_get_property(mdi_build BINARY_DIR) + set(MDI_BINARY_DIR "${BINARY_DIR}/MDI_Library") + # workaround for older CMake versions + file(MAKE_DIRECTORY ${MDI_BINARY_DIR}) + + # create imported target for the MDI library + add_library(LAMMPS::MDI UNKNOWN IMPORTED) + add_dependencies(LAMMPS::MDI mdi_build) + set_target_properties(LAMMPS::MDI PROPERTIES + IMPORTED_LOCATION "${MDI_BINARY_DIR}/libmdi.a" + INTERFACE_INCLUDE_DIRECTORIES ${MDI_BINARY_DIR} + ) + + set(MDI_DEP_LIBS "") + # if compiling with python plugins we need + # to add python libraries as dependency. + if(MDI_USE_PYTHON_PLUGINS) + if(CMAKE_VERSION VERSION_LESS 3.12) + list(APPEND MDI_DEP_LIBS ${PYTHON_LIBRARIES}) + else() + list(APPEND MDI_DEP_LIBS Python::Python) + endif() + + endif() + # need to add support for dlopen/dlsym, except when compiling for Windows. + if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) + list(APPEND MDI_DEP_LIBS "${CMAKE_DL_LIBS}") + endif() + if(MDI_DEP_LIBS) + set_target_properties(LAMMPS::MDI PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES "${MDI_DEP_LIBS}") + endif() + + target_link_libraries(lammps PRIVATE LAMMPS::MDI) + target_link_libraries(lmp PRIVATE LAMMPS::MDI) + +else() + + find_package(mdi) + if(NOT mdi_FOUND) + message(FATAL_ERROR "MDI library not found. Help CMake to find it " + "by setting mdi_LIBRARY and mdi_INCLUDE_DIR, or set DOWNLOAD_MDI=ON " + "to download and compile it") + endif() + + # Link the lammps library against MDI + target_include_directories(lammps PRIVATE ${mdi_INCLUDE_DIR}) + target_link_libraries(lammps PRIVATE ${mdi_LIBRARY}) + + # Link the lammps executable against MDI + target_include_directories(lmp PRIVATE ${mdi_INCLUDE_DIR}) + target_link_libraries(lmp PRIVATE ${mdi_LIBRARY}) +endif() + +target_compile_definitions(lammps PRIVATE -DLMP_MDI) +target_compile_definitions(lmp PRIVATE -DLMP_MDI) diff --git a/cmake/Modules/Packages/MESSAGE.cmake b/cmake/Modules/Packages/MESSAGE.cmake index 6ff4e322aa..b5a61a1607 100644 --- a/cmake/Modules/Packages/MESSAGE.cmake +++ b/cmake/Modules/Packages/MESSAGE.cmake @@ -1,4 +1,4 @@ -if(LAMMPS_SIZES STREQUAL BIGBIG) +if(LAMMPS_SIZES STREQUAL "BIGBIG") message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG") endif() option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF) diff --git a/cmake/Modules/Packages/ML-HDNNP.cmake b/cmake/Modules/Packages/ML-HDNNP.cmake new file mode 100644 index 0000000000..e27b3a1410 --- /dev/null +++ b/cmake/Modules/Packages/ML-HDNNP.cmake @@ -0,0 +1,133 @@ +find_package(N2P2 QUIET) +if(N2P2_FOUND) + set(DOWNLOAD_N2P2_DEFAULT OFF) +else() + set(DOWNLOAD_N2P2_DEFAULT ON) +endif() +option(DOWNLOAD_N2P2 "Download n2p2 library instead of using an already installed one)" ${DOWNLOAD_N2P2_DEFAULT}) +if(DOWNLOAD_N2P2) + set(N2P2_URL "https://github.com/CompPhysVienna/n2p2/archive/v2.1.4.tar.gz" CACHE STRING "URL for n2p2 tarball") + set(N2P2_MD5 "9595b066636cd6b90b0fef93398297a5" CACHE STRING "MD5 checksum of N2P2 tarball") + mark_as_advanced(N2P2_URL) + mark_as_advanced(N2P2_MD5) + + # adjust settings from detected compiler to compiler platform in n2p2 library + # set compiler specific flag to turn on C++11 syntax (required on macOS and CentOS 7) + if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")) + set(N2P2_COMP llvm) + set(N2P2_CXX_STD "-std=c++11") + elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") OR (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")) + set(N2P2_COMP intel) + set(N2P2_CXX_STD "-std=c++11") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(N2P2_COMP gnu) + set(N2P2_CXX_STD "-std=gnu++11") + elseif((CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")) + set(N2P2_COMP gnu) + set(N2P2_CXX_STD "--c++11") + else() # default + set(N2P2_COMP "") + endif() + + # pass on archive creator command. prefer compiler specific version, if set. + # important when using cross compiler. + if(CMAKE_CXX_COMPILER_AR) + set(N2P2_AR ${CMAKE_CXX_COMPILER_AR}) + else() + set(N2P2_AR ${CMAKE_AR}) + endif() + + # adjust compilation of n2p2 library to whether MPI is requested in LAMMPS or not + # need special care for compiling for MPICH2 with Linux-to-Windows cross compiler. + if(NOT BUILD_MPI) + set(N2P2_PROJECT_OPTIONS "-DN2P2_NO_MPI") + else() + # get path to MPI include directory when cross-compiling to windows + if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING) + get_target_property(N2P2_MPI_INCLUDE MPI::MPI_CXX INTERFACE_INCLUDE_DIRECTORIES) + set(N2P2_PROJECT_OPTIONS "-I${N2P2_MPI_INCLUDE}") + set(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER}) + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + get_target_property(N2P2_MPI_INCLUDE MPI::MPI_CXX INTERFACE_INCLUDE_DIRECTORIES) + set(N2P2_PROJECT_OPTIONS "-I${N2P2_MPI_INCLUDE}") + set(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER}) + endif() + endif() + + # prefer GNU make, if available. N2P2 lib seems to need it. + find_program(N2P2_MAKE NAMES gmake make) + + # override compiler (optimization) flags in n2p2 library to flags used for LAMMPS + # specifically -march=native can result in problems when compiling on HPC clusters or with a cross compiler + # this convoluted way gets correct quoting/escaping when configuring the external project + string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) + set(N2P2_BUILD_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}} ${N2P2_CXX_STD}") + set(N2P2_BUILD_OPTIONS INTERFACES=LAMMPS COMP=${N2P2_COMP} "PROJECT_OPTIONS=${N2P2_PROJECT_OPTIONS}" "PROJECT_DEBUG=" + "PROJECT_CC=${CMAKE_CXX_COMPILER}" "PROJECT_MPICC=${MPI_CXX_COMPILER}" "PROJECT_CFLAGS=${N2P2_BUILD_FLAGS}" + "PROJECT_AR=${N2P2_AR}") + # echo final flag for debugging + message(STATUS "N2P2 BUILD OPTIONS: ${N2P2_BUILD_OPTIONS}") + + # must have "sed" command to compile n2p2 library (for now) + find_program(HAVE_SED sed) + if(NOT HAVE_SED) + message(FATAL_ERROR "Must have 'sed' program installed to compile 'n2p2' library for ML-HDNNP package") + endif() + + # download compile n2p2 library. much patch MPI calls in LAMMPS interface to accommodate MPI-2 (e.g. for cross-compiling) + include(ExternalProject) + ExternalProject_Add(n2p2_build + URL ${N2P2_URL} + URL_MD5 ${N2P2_MD5} + UPDATE_COMMAND "" + CONFIGURE_COMMAND "" + PATCH_COMMAND sed -i -e "s/\\(MPI_\\(P\\|Unp\\)ack(\\)/\\1(void *) /" src/libnnpif/LAMMPS/InterfaceLammps.cpp + BUILD_COMMAND ${N2P2_MAKE} -f makefile libnnpif ${N2P2_BUILD_OPTIONS} + BUILD_ALWAYS YES + INSTALL_COMMAND "" + BUILD_IN_SOURCE 1 + LOG_BUILD ON + SOURCE_SUBDIR src/ + BUILD_BYPRODUCTS /lib/libnnp.a /lib/libnnpif.a + ) + + # create imported target LAMMPS::N2P2 from two libraries nnp and nnpif + ExternalProject_get_property(n2p2_build SOURCE_DIR) + # n2p2 core library "libnnp" + add_library(LAMMPS::N2P2::LIBNNP UNKNOWN IMPORTED) + set_target_properties(LAMMPS::N2P2::LIBNNP PROPERTIES + IMPORTED_LOCATION "${SOURCE_DIR}/lib/libnnp.a" + INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include") + # n2p2 interface library "libnnpif" + add_library(LAMMPS::N2P2::LIBNNPIF UNKNOWN IMPORTED) + set_target_properties(LAMMPS::N2P2::LIBNNPIF PROPERTIES + IMPORTED_LOCATION "${SOURCE_DIR}/lib/libnnpif.a" + INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include") + # nnpif library has MPI calls if MPI is enabled, so we must link with MPI libs + if(BUILD_MPI) + set_target_properties(LAMMPS::N2P2::LIBNNPIF PROPERTIES + INTERFACE_LINK_LIBRARIES MPI::MPI_CXX) + if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING) + add_dependencies(LAMMPS::N2P2::LIBNNPIF MPI::MPI_CXX) + endif() + endif() + + # final step to define imported target + add_library(LAMMPS::N2P2 INTERFACE IMPORTED) + set_property(TARGET LAMMPS::N2P2 PROPERTY + INTERFACE_LINK_LIBRARIES LAMMPS::N2P2::LIBNNPIF LAMMPS::N2P2::LIBNNP) + target_link_libraries(lammps PRIVATE LAMMPS::N2P2) + + add_dependencies(LAMMPS::N2P2 n2p2_build) + # work around issues with older CMake versions + file(MAKE_DIRECTORY "${SOURCE_DIR}/include") + file(MAKE_DIRECTORY "${SOURCE_DIR}/lib") +else() + find_package(N2P2) + if(NOT N2P2_FOUND) + message(FATAL_ERROR "n2p2 not found, help CMake to find it by setting N2P2_DIR, or set DOWNLOAD_N2P2=ON to download it") + endif() + target_link_libraries(lammps PRIVATE N2P2::N2P2) + include(${N2P2_CMAKE_EXTRAS}) +endif() diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake similarity index 78% rename from cmake/Modules/Packages/MLIAP.cmake rename to cmake/Modules/Packages/ML-IAP.cmake index 81bb10cb8f..63f91ba8d3 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -1,4 +1,4 @@ -# if PYTHON package is included we may also include Python support in MLIAP +# if PYTHON package is included we may also include Python support in ML-IAP set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) if(PKG_PYTHON) find_package(Cythonize QUIET) @@ -7,25 +7,25 @@ if(PKG_PYTHON) endif() endif() -option(MLIAP_ENABLE_PYTHON "Build MLIAP package with Python support" ${MLIAP_ENABLE_PYTHON_DEFAULT}) +option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_ENABLE_PYTHON_DEFAULT}) if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) if(NOT PKG_PYTHON) - message(FATAL_ERROR "Must enable PYTHON package for including Python support in MLIAP") + message(FATAL_ERROR "Must enable PYTHON package for including Python support in ML-IAP") endif() if(CMAKE_VERSION VERSION_LESS 3.12) if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in MLIAP requires Python 3.6 or later") + message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() else() if(Python_VERSION VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in MLIAP requires Python 3.6 or later") + message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) - set(MLIAP_CYTHON_SRC ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx) + set(MLIAP_CYTHON_SRC ${LAMMPS_SOURCE_DIR}/ML-IAP/mliap_model_python_couple.pyx) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_SRC} NAME_WE) file(MAKE_DIRECTORY ${MLIAP_BINARY_DIR}) add_custom_command(OUTPUT ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.h diff --git a/cmake/Modules/Packages/USER-PACE.cmake b/cmake/Modules/Packages/ML-PACE.cmake similarity index 51% rename from cmake/Modules/Packages/USER-PACE.cmake rename to cmake/Modules/Packages/ML-PACE.cmake index 2d88d3a313..d46197114d 100644 --- a/cmake/Modules/Packages/USER-PACE.cmake +++ b/cmake/Modules/Packages/ML-PACE.cmake @@ -1,11 +1,11 @@ +set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.10.25.tar.gz" CACHE STRING "URL for PACE evaluator library sources") -set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.4.9.tar.gz" CACHE STRING "URL for PACE evaluator library sources") -set(PACELIB_MD5 "4db54962fbd6adcf8c18d46e1798ceb5" CACHE STRING "MD5 checksum of PACE evaluator library tarball") +set(PACELIB_MD5 "a2ac3315c41a1a4a5c912bcb1bc9c5cc" CACHE STRING "MD5 checksum of PACE evaluator library tarball") mark_as_advanced(PACELIB_URL) mark_as_advanced(PACELIB_MD5) # download library sources to build folder -file(DOWNLOAD ${PACELIB_URL} ${CMAKE_BINARY_DIR}/libpace.tar.gz SHOW_PROGRESS EXPECTED_HASH MD5=${PACELIB_MD5}) +file(DOWNLOAD ${PACELIB_URL} ${CMAKE_BINARY_DIR}/libpace.tar.gz EXPECTED_HASH MD5=${PACELIB_MD5}) #SHOW_PROGRESS # uncompress downloaded sources execute_process( @@ -14,13 +14,19 @@ execute_process( WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) +file(GLOB lib-pace ${CMAKE_BINARY_DIR}/lammps-user-pace-*) +add_subdirectory(${lib-pace}/yaml-cpp build-yaml-cpp) +set(YAML_CPP_INCLUDE_DIR ${lib-pace}/yaml-cpp/include) -file(GLOB PACE_EVALUATOR_INCLUDE_DIR ${CMAKE_BINARY_DIR}/lammps-user-pace-*/USER-PACE) -file(GLOB PACE_EVALUATOR_SOURCES ${CMAKE_BINARY_DIR}/lammps-user-pace-*/USER-PACE/*.cpp) +file(GLOB PACE_EVALUATOR_INCLUDE_DIR ${lib-pace}/ML-PACE) +file(GLOB PACE_EVALUATOR_SOURCES ${lib-pace}/ML-PACE/*.cpp) list(FILTER PACE_EVALUATOR_SOURCES EXCLUDE REGEX pair_pace.cpp) add_library(pace STATIC ${PACE_EVALUATOR_SOURCES}) -set_target_properties(pace PROPERTIES OUTPUT_NAME lammps_pace${LAMMPS_MACHINE}) -target_include_directories(pace PUBLIC ${PACE_EVALUATOR_INCLUDE_DIR}) -target_link_libraries(lammps PRIVATE pace) +set_target_properties(pace PROPERTIES CXX_EXTENSIONS ON OUTPUT_NAME lammps_pace${LAMMPS_MACHINE}) +target_include_directories(pace PUBLIC ${PACE_EVALUATOR_INCLUDE_DIR} ${YAML_CPP_INCLUDE_DIR}) + +target_link_libraries(pace PRIVATE yaml-cpp-pace) + +target_link_libraries(lammps PRIVATE pace) diff --git a/cmake/Modules/Packages/ML-QUIP.cmake b/cmake/Modules/Packages/ML-QUIP.cmake new file mode 100644 index 0000000000..92418e8939 --- /dev/null +++ b/cmake/Modules/Packages/ML-QUIP.cmake @@ -0,0 +1,70 @@ +enable_language(Fortran) +find_package(QUIP QUIET) + +if(QUIP_FOUND) + set(DOWNLOAD_QUIP_DEFAULT OFF) +else() + set(DOWNLOAD_QUIP_DEFAULT ON) +endif() +option(DOWNLOAD_QUIP "Download the QUIP library instead of using an already installed one" ${DOWNLOAD_QUIP_DEFAULT}) +if(DOWNLOAD_QUIP) + string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) + set(temp "F77 = ${CMAKE_Fortran_COMPILER}\nF90 = ${CMAKE_Fortran_COMPILER}\nF95 = ${CMAKE_Fortran_COMPILER}\n") + set(temp "${temp}CC=${CMAKE_C_COMPILER}\nCPLUSPLUS=${CMAKE_CXX_COMPILER}\nLINKER=${CMAKE_Fortran_COMPILER}\n") + if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) + set(temp "${temp}FPP=${CMAKE_Fortran_COMPILER} -E\nOPTIM=${CMAKE_Fortran_FLAGS_${BTYPE}}\n") + set(temp "${temp}DEFINES += -DGETARG_F2003 -DFORTRAN_UNDERSCORE\n") + set(temp "${temp}F95FLAGS += -fpp -free -fPIC\n") + set(temp "${temp}F77FLAGS += -fpp -fixed -fPIC\n") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) + set(temp "${temp}FPP=${CMAKE_Fortran_COMPILER} -E -x f95-cpp-input\nOPTIM=${CMAKE_Fortran_FLAGS_${BTYPE}}\n") + set(temp "${temp}DEFINES += -DGETARG_F2003 -DGETENV_F2003 -DGFORTRAN -DFORTRAN_UNDERSCORE\n") + set(temp "${temp}F95FLAGS += -x f95-cpp-input -ffree-line-length-none -ffree-form -fno-second-underscore -fPIC\n") + set(temp "${temp}F77FLAGS += -x f77-cpp-input -fno-second-underscore -fPIC\n") + else() + message(FATAL_ERROR "The ${CMAKE_Fortran_COMPILER_ID} Fortran compiler is not (yet) supported for building QUIP") + endif() + set(temp "${temp}CFLAGS += -fPIC \nCPLUSPLUSFLAGS += -fPIC\nAR_ADD=src\n") + set(temp "${temp}MATH_LINKOPTS=") + foreach(flag ${BLAS_LIBRARIES}) + set(temp "${temp} ${flag}") + endforeach() + foreach(flag ${LAPACK_LIBRARIES}) + set(temp "${temp} ${flag}") + endforeach() + set(temp "${temp}\n") + set(temp "${temp}PYTHON=python\nPIP=pip\nEXTRA_LINKOPTS=\n") + set(temp "${temp}HAVE_CP2K=0\nHAVE_VASP=0\nHAVE_TB=0\nHAVE_PRECON=1\nHAVE_LOTF=0\nHAVE_ONIOM=0\n") + set(temp "${temp}HAVE_LOCAL_E_MIX=0\nHAVE_QC=0\nHAVE_GAP=1\nHAVE_DESCRIPTORS_NONCOMMERCIAL=1\n") + set(temp "${temp}HAVE_TURBOGAP=0\nHAVE_QR=1\nHAVE_THIRDPARTY=0\nHAVE_FX=0\nHAVE_SCME=0\nHAVE_MTP=0\n") + set(temp "${temp}HAVE_MBD=0\nHAVE_TTM_NF=0\nHAVE_CH4=0\nHAVE_NETCDF4=0\nHAVE_MDCORE=0\nHAVE_ASAP=0\n") + set(temp "${temp}HAVE_CGAL=0\nHAVE_METIS=0\nHAVE_LMTO_TBE=0\nHAVE_SCALAPACK=0\n") + file(WRITE ${CMAKE_BINARY_DIR}/quip.config "${temp}") + + message(STATUS "QUIP download via git requested - we will build our own") + # QUIP has no releases (except for a tag marking the end of Python 2 support). We use the current "public" branch + # The LAMMPS interface wrapper has a compatibility constant that is being checked at runtime. + include(ExternalProject) + ExternalProject_Add(quip_build + GIT_REPOSITORY "https://github.com/libAtoms/QUIP/" + GIT_TAG origin/public + GIT_SHALLOW YES + GIT_PROGRESS YES + PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/quip.config /arch/Makefile.lammps + CONFIGURE_COMMAND env QUIP_ARCH=lammps make config + BUILD_COMMAND env QUIP_ARCH=lammps make libquip + INSTALL_COMMAND "" + BUILD_IN_SOURCE YES + BUILD_BYPRODUCTS /build/lammps/libquip.a + ) + ExternalProject_get_property(quip_build SOURCE_DIR) + add_library(LAMMPS::QUIP UNKNOWN IMPORTED) + set_target_properties(LAMMPS::QUIP PROPERTIES + IMPORTED_LOCATION "${SOURCE_DIR}/build/lammps/libquip.a" + INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}") + target_link_libraries(lammps PRIVATE LAMMPS::QUIP) + add_dependencies(LAMMPS::QUIP quip_build) +else() + find_package(QUIP REQUIRED) + target_link_libraries(lammps PRIVATE QUIP::QUIP ${LAPACK_LIBRARIES}) +endif() diff --git a/cmake/Modules/Packages/USER-MOLFILE.cmake b/cmake/Modules/Packages/MOLFILE.cmake similarity index 67% rename from cmake/Modules/Packages/USER-MOLFILE.cmake rename to cmake/Modules/Packages/MOLFILE.cmake index 427f0ed6fa..add4c640e7 100644 --- a/cmake/Modules/Packages/USER-MOLFILE.cmake +++ b/cmake/Modules/Packages/MOLFILE.cmake @@ -1,5 +1,7 @@ set(MOLFILE_INCLUDE_DIR "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers") -set(MOLFILE_INCLUDE_DIRS "${MOLFILE_INCLUDE_DIR}") add_library(molfile INTERFACE) -target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS}) +target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIR}) +if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) + target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS}) +endif() target_link_libraries(lammps PRIVATE molfile) diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake index 6ac62cb012..cf3d506c82 100644 --- a/cmake/Modules/Packages/MSCG.cmake +++ b/cmake/Modules/Packages/MSCG.cmake @@ -12,6 +12,13 @@ if(DOWNLOAD_MSCG) mark_as_advanced(MSCG_URL) mark_as_advanced(MSCG_MD5) + # CMake cannot pass BLAS or LAPACK library variable to external project if they are a list + list(LENGTH BLAS_LIBRARIES} NUM_BLAS) + list(LENGTH LAPACK_LIBRARIES NUM_LAPACK) + if((NUM_BLAS GREATER 1) OR (NUM_LAPACK GREATER 1)) + message(FATAL_ERROR "Cannot compile downloaded MSCG library due to a technical limitation") + endif() + include(ExternalProject) ExternalProject_Add(mscg_build URL ${MSCG_URL} diff --git a/cmake/Modules/Packages/USER-NETCDF.cmake b/cmake/Modules/Packages/NETCDF.cmake similarity index 89% rename from cmake/Modules/Packages/USER-NETCDF.cmake rename to cmake/Modules/Packages/NETCDF.cmake index d63e9773c3..2e521b81b0 100644 --- a/cmake/Modules/Packages/USER-NETCDF.cmake +++ b/cmake/Modules/Packages/NETCDF.cmake @@ -1,4 +1,4 @@ -# USER-NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary. +# NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary. # NetCDF library enables dump style "netcdf", while PNetCDF enables dump style "netcdf/mpiio" # may use NetCDF or PNetCDF with MPI, but must have NetCDF without diff --git a/cmake/Modules/Packages/OPENMP.cmake b/cmake/Modules/Packages/OPENMP.cmake new file mode 100644 index 0000000000..a69a81acec --- /dev/null +++ b/cmake/Modules/Packages/OPENMP.cmake @@ -0,0 +1,40 @@ + set(OPENMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPENMP) + set(OPENMP_SOURCES ${OPENMP_SOURCES_DIR}/thr_data.cpp + ${OPENMP_SOURCES_DIR}/thr_omp.cpp + ${OPENMP_SOURCES_DIR}/fix_omp.cpp + ${OPENMP_SOURCES_DIR}/fix_nh_omp.cpp + ${OPENMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp + ${OPENMP_SOURCES_DIR}/domain_omp.cpp) + target_compile_definitions(lammps PRIVATE -DLMP_OPENMP) + set_property(GLOBAL PROPERTY "OMP_SOURCES" "${OPENMP_SOURCES}") + + # detects styles which have OPENMP version + RegisterStylesExt(${OPENMP_SOURCES_DIR} omp OMP_SOURCES) + RegisterFixStyle(${OPENMP_SOURCES_DIR}/fix_omp.h) + + get_property(OPENMP_SOURCES GLOBAL PROPERTY OMP_SOURCES) + + # manually add package dependent source files from OPENMP that do not provide styles + + if(PKG_ASPHERE) + list(APPEND OPENMP_SOURCES ${OPENMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp) + endif() + + if(PKG_RIGID) + list(APPEND OPENMP_SOURCES ${OPENMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp) + endif() + + if(PKG_REAXFF) + list(APPEND OPENMP_SOURCES ${OPENMP_SOURCES_DIR}/reaxff_bond_orders_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_hydrogen_bonds_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_nonbonded_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_bonds_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_init_md_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_torsion_angles_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_forces_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_multi_body_omp.cpp + ${OPENMP_SOURCES_DIR}/reaxff_valence_angles_omp.cpp) + endif() + + target_sources(lammps PRIVATE ${OPENMP_SOURCES}) + target_include_directories(lammps PRIVATE ${OPENMP_SOURCES_DIR}) diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/PLUMED.cmake similarity index 97% rename from cmake/Modules/Packages/USER-PLUMED.cmake rename to cmake/Modules/Packages/PLUMED.cmake index e71542cfc5..0f063f3e14 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/PLUMED.cmake @@ -54,8 +54,8 @@ if(DOWNLOAD_PLUMED) set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumedWrapper.a") endif() - set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.1/plumed-src-2.7.1.tgz" CACHE STRING "URL for PLUMED tarball") - set(PLUMED_MD5 "4eac6a462ec84dfe0cec96c82421b8e8" CACHE STRING "MD5 checksum of PLUMED tarball") + set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.2/plumed-src-2.7.2.tgz" CACHE STRING "URL for PLUMED tarball") + set(PLUMED_MD5 "cfa0b4dd90a81c25d3302e8d97bfeaea" CACHE STRING "MD5 checksum of PLUMED tarball") mark_as_advanced(PLUMED_URL) mark_as_advanced(PLUMED_MD5) diff --git a/cmake/Modules/Packages/QEQ.cmake b/cmake/Modules/Packages/QEQ.cmake index 1bdaa02f43..041d34cf9d 100644 --- a/cmake/Modules/Packages/QEQ.cmake +++ b/cmake/Modules/Packages/QEQ.cmake @@ -1,18 +1,13 @@ # Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ) -file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h) -file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp) +get_property(hlist GLOBAL PROPERTY FIX) if(NOT PKG_MANYBODY) - 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 hlist ${QEQ_SOURCES_DIR}/fix_qeq_fire.h) + get_target_property(LAMMPS_SOURCES lammps SOURCES) + list(REMOVE_ITEM LAMMPS_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp) + set_property(TARGET lammps PROPERTY SOURCES ${LAMMPS_SOURCES}) endif() -set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}") +set_property(GLOBAL PROPERTY FIX "${hlist}") -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}) diff --git a/cmake/Modules/Packages/USER-QMMM.cmake b/cmake/Modules/Packages/QMMM.cmake similarity index 100% rename from cmake/Modules/Packages/USER-QMMM.cmake rename to cmake/Modules/Packages/QMMM.cmake diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/SCAFACOS.cmake similarity index 96% rename from cmake/Modules/Packages/USER-SCAFACOS.cmake rename to cmake/Modules/Packages/SCAFACOS.cmake index fd355420c3..de611a1edb 100644 --- a/cmake/Modules/Packages/USER-SCAFACOS.cmake +++ b/cmake/Modules/Packages/SCAFACOS.cmake @@ -23,6 +23,11 @@ if(DOWNLOAD_SCAFACOS) file(DOWNLOAD ${LAMMPS_THIRDPARTY_URL}/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff EXPECTED_HASH MD5=4baa1333bb28fcce102d505e1992d032) + find_program(HAVE_PATCH patch) + if(NOT HAVE_PATCH) + message(FATAL_ERROR "The 'patch' program is required to build the ScaFaCoS library") + endif() + include(ExternalProject) ExternalProject_Add(scafacos_build URL ${SCAFACOS_URL} diff --git a/cmake/Modules/Packages/USER-OMP.cmake b/cmake/Modules/Packages/USER-OMP.cmake deleted file mode 100644 index a1053ad355..0000000000 --- a/cmake/Modules/Packages/USER-OMP.cmake +++ /dev/null @@ -1,40 +0,0 @@ - set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP) - set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp - ${USER-OMP_SOURCES_DIR}/thr_omp.cpp - ${USER-OMP_SOURCES_DIR}/fix_omp.cpp - ${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp - ${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp - ${USER-OMP_SOURCES_DIR}/domain_omp.cpp) - target_compile_definitions(lammps PRIVATE -DLMP_USER_OMP) - set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}") - - # detects styles which have USER-OMP version - RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES) - RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h) - - get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES) - - # manually add package dependent source files from USER-OMP that do not provide styles - - if(PKG_ASPHERE) - list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp) - endif() - - if(PKG_RIGID) - list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp) - endif() - - if(PKG_USER-REAXC) - 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_nonbonded_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_bonds_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_forces_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp - ${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp) - endif() - - target_sources(lammps PRIVATE ${USER-OMP_SOURCES}) - target_include_directories(lammps PRIVATE ${USER-OMP_SOURCES_DIR}) diff --git a/cmake/Modules/Packages/USER-QUIP.cmake b/cmake/Modules/Packages/USER-QUIP.cmake deleted file mode 100644 index 790f27def7..0000000000 --- a/cmake/Modules/Packages/USER-QUIP.cmake +++ /dev/null @@ -1,3 +0,0 @@ -enable_language(Fortran) -find_package(QUIP REQUIRED) -target_link_libraries(lammps PRIVATE QUIP::QUIP ${LAPACK_LIBRARIES}) diff --git a/cmake/Modules/Packages/VORONOI.cmake b/cmake/Modules/Packages/VORONOI.cmake index 7feea4c52e..c010469677 100644 --- a/cmake/Modules/Packages/VORONOI.cmake +++ b/cmake/Modules/Packages/VORONOI.cmake @@ -26,6 +26,11 @@ if(DOWNLOAD_VORO) set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS}) endif() + find_program(HAVE_PATCH patch) + if(NOT HAVE_PATCH) + message(FATAL_ERROR "The 'patch' program is required to build the voro++ library") + endif() + ExternalProject_Add(voro_build URL ${VORO_URL} URL_MD5 ${VORO_MD5} diff --git a/cmake/Modules/Packages/USER-VTK.cmake b/cmake/Modules/Packages/VTK.cmake similarity index 100% rename from cmake/Modules/Packages/USER-VTK.cmake rename to cmake/Modules/Packages/VTK.cmake diff --git a/cmake/Modules/PreventInSourceBuilds.cmake b/cmake/Modules/PreventInSourceBuilds.cmake index 31f2376aa1..f9b8fc3368 100644 --- a/cmake/Modules/PreventInSourceBuilds.cmake +++ b/cmake/Modules/PreventInSourceBuilds.cmake @@ -9,7 +9,7 @@ function(prevent_in_source_builds) get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) # disallow in-source builds - if("${srcdir}" STREQUAL "${bindir}" OR "${srcdir2}" STREQUAL "${bindir}" OR "${srcdir3}" STREQUAL "${bindir}") + if(("${srcdir}" STREQUAL "${bindir}") OR ("${srcdir2}" STREQUAL "${bindir}") OR ("${srcdir3}" STREQUAL "${bindir}")) message(FATAL_ERROR "\ CMake must not to be run in the source directory. \ diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index d1fa97a7a8..2bb9c4757b 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -19,11 +19,11 @@ if(ENABLE_TESTING) # we need to build and link a LOT of tester executables, so it is worth checking if # a faster linker is available. requires GNU or Clang compiler, newer CMake. # also only verified with Fedora Linux > 30 and Ubuntu <= 18.04 (Ubuntu 20.04 fails) - if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - AND ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))) - if (((CMAKE_LINUX_DISTRO STREQUAL Ubuntu) AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04)) - OR ((CMAKE_LINUX_DISTRO STREQUAL Fedora) AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30))) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) + if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04)) + OR ((CMAKE_LINUX_DISTRO STREQUAL "Fedora") AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30))) include(CheckCXXCompilerFlag) set(CMAKE_CUSTOM_LINKER_DEFAULT default) check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG) @@ -58,7 +58,7 @@ if(ENABLE_TESTING) endif() # Compiler specific features for testing -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) @@ -83,7 +83,7 @@ mark_as_advanced(ENABLE_IWYU) if(ENABLE_IWYU) # enforce these settings set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable reporting compilation commands to compile_commands.json" FORCE) - if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))) + if(NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))) message(FATAL_ERROR "IWYU is only supported with Clang or GNU compilers") endif() # detect the "native" header folder so we can include them first @@ -91,7 +91,7 @@ if(ENABLE_IWYU) string(REGEX REPLACE ".*libraries: *=([^:]+):.*" "\\1/include" IWYU_EXTRA_INCLUDE_DIR ${IWYU_SEARCH_PATHS}) find_program(IWYU_EXE NAMES include-what-you-use iwyu) find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py) - if (IWYU_EXE AND IWYU_TOOL) + if(IWYU_EXE AND IWYU_TOOL) add_custom_target( iwyu ${IWYU_TOOL} -o clang -p ${CMAKE_CURRENT_BINARY_DIR} -- -I${IWYU_EXTRA_INCLUDE_DIR} -Xiwyu --mapping_file=${CMAKE_CURRENT_SOURCE_DIR}/iwyu/iwyu-extra-map.imp diff --git a/cmake/Modules/Tools.cmake b/cmake/Modules/Tools.cmake index 078b4ebcf4..c3b0a0771d 100644 --- a/cmake/Modules/Tools.cmake +++ b/cmake/Modules/Tools.cmake @@ -9,21 +9,25 @@ if(BUILD_TOOLS) check_language(Fortran) if(CMAKE_Fortran_COMPILER) enable_language(Fortran) - add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f) + add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f90) target_link_libraries(chain.x PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) - install(TARGETS chain.x DESTINATION ${CMAKE_INSTALL_BINDIR}) + add_executable(micelle2d.x ${LAMMPS_TOOLS_DIR}/micelle2d.f90) + target_link_libraries(micelle2d.x PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) + install(TARGETS chain.x micelle2d.x DESTINATION ${CMAKE_INSTALL_BINDIR}) else() - message(WARNING "No suitable Fortran compiler found, skipping build of 'chain.x'") + message(WARNING "No suitable Fortran compiler found, skipping build of 'chain.x' and 'micelle2d.x'") endif() else() - message(WARNING "CMake build doesn't support fortran, skipping build of 'chain.x'") + message(WARNING "CMake build doesn't support Fortran, skipping build of 'chain.x' and 'micelle2d.x'") endif() enable_language(C) get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE) file(GLOB MSI2LMP_SOURCES ${MSI2LMP_SOURCE_DIR}/[^.]*.c) add_executable(msi2lmp ${MSI2LMP_SOURCES}) - target_link_libraries(msi2lmp PRIVATE ${MATH_LIBRARIES}) + if(STANDARD_MATH_LIB) + target_link_libraries(msi2lmp PRIVATE ${STANDARD_MATH_LIB}) + endif() install(TARGETS msi2lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endif() @@ -45,7 +49,7 @@ if(BUILD_LAMMPS_SHELL) target_include_directories(lammps-shell PRIVATE ${LAMMPS_TOOLS_DIR}/lammps-shell) # workaround for broken readline pkg-config file on FreeBSD - if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") target_include_directories(lammps-shell PRIVATE /usr/local/include) endif() target_link_libraries(lammps-shell PRIVATE lammps PkgConfig::READLINE) diff --git a/cmake/Modules/YAML.cmake b/cmake/Modules/YAML.cmake index c50773568c..77ee804111 100644 --- a/cmake/Modules/YAML.cmake +++ b/cmake/Modules/YAML.cmake @@ -6,15 +6,27 @@ set(YAML_MD5 "bb15429d8fb787e7d3f1c83ae129a999" CACHE STRING "MD5 checksum of li mark_as_advanced(YAML_URL) mark_as_advanced(YAML_MD5) +# support cross-compilation to windows +if(CMAKE_CROSSCOMPILING AND (CMAKE_SYSTEM_NAME STREQUAL "Windows")) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86") + set(YAML_CROSS_HOST --host=i686-mingw64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(YAML_CROSS_HOST --host=x86_64-mingw64) + else() + message(FATAL_ERROR "Unsupported cross-compilation " + " for ${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}" + " on ${CMAKE_HOST_SYSTEM}/${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() +endif() + ExternalProject_Add(libyaml URL ${YAML_URL} URL_MD5 ${YAML_MD5} SOURCE_DIR "${CMAKE_BINARY_DIR}/yaml-src" BINARY_DIR "${CMAKE_BINARY_DIR}/yaml-build" CONFIGURE_COMMAND /configure ${CONFIGURE_REQUEST_PIC} - CXX=${CMAKE_CXX_COMPILER} - CC=${CMAKE_C_COMPILER} - --prefix= --disable-shared + CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER} + --prefix= --disable-shared ${YAML_CROSS_HOST} BUILD_BYPRODUCTS /lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX} TEST_COMMAND "") diff --git a/cmake/iwyu/iwyu-extra-map.imp b/cmake/iwyu/iwyu-extra-map.imp index 4fadea73fb..8eae74cbfa 100644 --- a/cmake/iwyu/iwyu-extra-map.imp +++ b/cmake/iwyu/iwyu-extra-map.imp @@ -1,7 +1,28 @@ [ - { include: [ "", private, "", public ] }, - { include: [ "", public, "", public ] }, { include: [ "@", private, "", public ] }, { include: [ "@", private, "\"gtest/gtest.h\"", public ] }, { include: [ "@", private, "\"gmock/gmock.h\"", public ] }, + { include: [ "@", private, "\"gmock/gmock.h\"", public ] }, + { include: [ "@<(cell|c_loops|container).hh>", private, "", public ] }, + { include: [ "@\"atom_vec_.*.h\"", public, "\"style_atom.h\"", public ] }, + { include: [ "@\"body_.*.h\"", public, "\"style_body.h\"", public ] }, + { include: [ "@\"compute_.*.h\"", public, "\"style_compute.h\"", public ] }, + { include: [ "@\"fix_.*.h\"", public, "\"style_fix.h\"", public ] }, + { include: [ "@\"dump_.*.h\"", public, "\"style_dump.h\"", public ] }, + { include: [ "@\"min_.*.h\"", public, "\"style_minimize.h\"", public ] }, + { include: [ "@\"reader_.*.h\"", public, "\"style_reader.h\"", public ] }, + { include: [ "@\"region_.*.h\"", public, "\"style_region.h\"", public ] }, + { include: [ "@\"pair_.*.h\"", public, "\"style_pair.h\"", public ] }, + { include: [ "@\"angle_.*.h\"", public, "\"style_angle.h\"", public ] }, + { include: [ "@\"bond_.*.h\"", public, "\"style_bond.h\"", public ] }, + { include: [ "@\"dihedral_.*.h\"", public, "\"style_dihedral.h\"", public ] }, + { include: [ "@\"improper_.*.h\"", public, "\"style_improper.h\"", public ] }, + { include: [ "@\"kspace_.*.h\"", public, "\"style_kspace.h\"", public ] }, + { include: [ "@\"nbin_.*.h\"", public, "\"style_nbin.h\"", public ] }, + { include: [ "@\"npair_.*.h\"", public, "\"style_npair.h\"", public ] }, + { include: [ "@\"nstenci_.*.h\"", public, "\"style_nstencil.h\"", public ] }, + { include: [ "@\"ntopo_.*.h\"", public, "\"style_ntopo.h\"", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", private, "", public ] }, ] diff --git a/cmake/pkgconfig/liblammps.pc.in b/cmake/pkgconfig/liblammps.pc.in index ca2c6191b7..42c8fddadd 100644 --- a/cmake/pkgconfig/liblammps.pc.in +++ b/cmake/pkgconfig/liblammps.pc.in @@ -24,7 +24,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: liblammps@LAMMPS_MACHINE@ Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library -URL: http://lammps.sandia.gov +URL: https://www.lammps.org Version: @PROJECT_VERSION@ Requires: Libs: -L${libdir} -llammps@LAMMPS_MACHINE@ diff --git a/cmake/presets/all_off.cmake b/cmake/presets/all_off.cmake index 9be6cfe54b..2893bbab6b 100644 --- a/cmake/presets/all_off.cmake +++ b/cmake/presets/all_off.cmake @@ -1,17 +1,96 @@ -# preset that turns on all existing packages off. can be used to reset +# Preset that turns on all existing packages off. Can be used to reset # an existing package selection without losing any other settings -set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE - MPIIO MSCG OPT PERI PLUGIN POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN - SRD VORONOI - 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-H5MD USER-INTEL - USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD USER-MESONT USER-MGPT - USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-PACE USER-PHONON - USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-REACTION USER-REAXC - USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF - USER-VTK USER-YAFF) +set(ALL_PACKAGES + ADIOS + ASPHERE + ATC + AWPMD + BOCS + BODY + BROWNIAN + CG-DNA + CG-SDK + CLASS2 + COLLOID + COLVARS + COMPRESS + CORESHELL + DIELECTRIC + DIFFRACTION + DIPOLE + DPD-BASIC + DPD-MESO + DPD-REACT + DPD-SMOOTH + DRUDE + EFF + EXTRA-COMPUTE + EXTRA-DUMP + EXTRA-FIX + EXTRA-MOLECULE + EXTRA-PAIR + FEP + GPU + GRANULAR + H5MD + INTEL + INTERLAYER + KIM + KOKKOS + KSPACE + LATBOLTZ + LATTE + MACHDYN + MANIFOLD + MANYBODY + MC + MDI + MEAM + MESONT + MESSAGE + MGPT + MISC + ML-HDNNP + ML-IAP + ML-PACE + ML-QUIP + ML-RANN + ML-SNAP + MOFFF + MOLECULE + MOLFILE + MPIIO + MSCG + NETCDF + OPENMP + OPT + ORIENT + PERI + PHONON + PLUGIN + PLUMED + POEMS + PTM + PYTHON + QEQ + QMMM + QTB + REACTION + REAXFF + REPLICA + RIGID + SCAFACOS + SHOCK + SMTBQ + SPH + SPIN + SRD + TALLY + UEF + VORONOI + VTK + YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/all_on.cmake b/cmake/presets/all_on.cmake index 411fb09d6b..9f38f1e1e4 100644 --- a/cmake/presets/all_on.cmake +++ b/cmake/presets/all_on.cmake @@ -1,19 +1,98 @@ -# preset that turns on all existing packages. using the combination -# this preset followed by the nolib.cmake preset should configure a -# LAMMPS binary, with as many packages included, that can be compiled +# Preset that turns on all existing packages. Using the combination +# of this preset followed by the nolib.cmake preset should configure +# a LAMMPS binary, with as many packages included, that can be compiled # with just a working C++ compiler and an MPI library. -set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE - MPIIO MSCG OPT PERI PLUGIN POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN - SRD VORONOI - 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-H5MD USER-INTEL - USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD USER-MESONT USER-MGPT - USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-PACE USER-PHONON - USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-REACTION USER-REAXC - USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF - USER-VTK USER-YAFF) +set(ALL_PACKAGES + ADIOS + ASPHERE + ATC + AWPMD + BOCS + BODY + BROWNIAN + CG-DNA + CG-SDK + CLASS2 + COLLOID + COLVARS + COMPRESS + CORESHELL + DIELECTRIC + DIFFRACTION + DIPOLE + DPD-BASIC + DPD-MESO + DPD-REACT + DPD-SMOOTH + DRUDE + EFF + EXTRA-COMPUTE + EXTRA-DUMP + EXTRA-FIX + EXTRA-MOLECULE + EXTRA-PAIR + FEP + GPU + GRANULAR + H5MD + INTEL + INTERLAYER + KIM + KOKKOS + KSPACE + LATBOLTZ + LATTE + MACHDYN + MANIFOLD + MANYBODY + MC + MDI + MEAM + MESONT + MESSAGE + MGPT + MISC + ML-HDNNP + ML-IAP + ML-PACE + ML-QUIP + ML-RANN + ML-SNAP + MOFFF + MOLECULE + MOLFILE + MPIIO + MSCG + NETCDF + OPENMP + OPT + ORIENT + PERI + PHONON + PLUGIN + PLUMED + POEMS + PTM + PYTHON + QEQ + QMMM + QTB + REACTION + REAXFF + REPLICA + RIGID + SCAFACOS + SHOCK + SMTBQ + SPH + SPIN + SRD + TALLY + UEF + VORONOI + VTK + YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/minimal.cmake b/cmake/presets/basic.cmake similarity index 100% rename from cmake/presets/minimal.cmake rename to cmake/presets/basic.cmake diff --git a/cmake/presets/clang.cmake b/cmake/presets/clang.cmake index 47df6dcc6f..a0d654ad35 100644 --- a/cmake/presets/clang.cmake +++ b/cmake/presets/clang.cmake @@ -1,13 +1,26 @@ # preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes) +# prefer flang over gfortran, if available +find_program(CLANG_FORTRAN NAMES flang gfortran f95) +set(ENV{OMPI_FC} ${CLANG_FORTRAN}) + set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER ${CLANG_FORTRAN} CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) + set(MPI_CXX "clang++" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) -unset(HAVE_OMP_H_INCLUDE CACHE) +unset(HAVE_OMP_H_INCLUDE CACHE) set(OpenMP_C "clang" CACHE STRING "" FORCE) set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) diff --git a/cmake/presets/download.cmake b/cmake/presets/download.cmake index 84629ce785..2030a97dbb 100644 --- a/cmake/presets/download.cmake +++ b/cmake/presets/download.cmake @@ -1,7 +1,7 @@ -# preset that turns on packages with automatic downloads of sources of potentials -# compilation of libraries like Plumed or ScaFaCoS can take a considerable amount of time. +# Preset that turns on packages with automatic downloads of sources or potentials. +# Compilation of libraries like Plumed or ScaFaCoS can take a considerable amount of time. -set(ALL_PACKAGES KIM LATTE MSCG VORONOI USER-PLUMED USER-SCAFACOS USER-SMD USER-MESONT) +set(ALL_PACKAGES KIM LATTE MSCG VORONOI PLUMED SCAFACOS MACHDYN MESONT MDI ML-PACE) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) @@ -9,9 +9,11 @@ endforeach() set(DOWNLOAD_KIM ON CACHE BOOL "" FORCE) set(DOWNLOAD_LATTE ON CACHE BOOL "" FORCE) +set(DOWNLOAD_MDI ON CACHE BOOL "" FORCE) set(DOWNLOAD_MSCG ON CACHE BOOL "" FORCE) set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE) set(DOWNLOAD_EIGEN3 ON CACHE BOOL "" FORCE) +set(DOWNLOAD_PACE ON CACHE BOOL "" FORCE) set(DOWNLOAD_PLUMED ON CACHE BOOL "" FORCE) set(DOWNLOAD_SCAFACOS ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/gcc.cmake b/cmake/presets/gcc.cmake index 51003c75fb..c2dbacf674 100644 --- a/cmake/presets/gcc.cmake +++ b/cmake/presets/gcc.cmake @@ -1,11 +1,23 @@ -# preset that will restore gcc/g++ with support for MPI and OpenMP (on Linux boxes) +# preset that will explicitly request gcc/g++ compilers with support for MPI and OpenMP set(CMAKE_CXX_COMPILER "g++" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "gcc" CACHE STRING "" FORCE) -set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) set(MPI_CXX "g++" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) +set(MPI_C "gcc" CACHE STRING "" FORCE) +set(MPI_C_COMPILER "mpicc" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(MPI_Fortran "gfortran" CACHE STRING "" FORCE) +set(MPI_Fortran_COMPILER "mpifort" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -g -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) unset(HAVE_OMP_H_INCLUDE CACHE) set(OpenMP_C "gcc" CACHE STRING "" FORCE) diff --git a/cmake/presets/hip.cmake b/cmake/presets/hip.cmake index 44f1fc093f..64f825134c 100644 --- a/cmake/presets/hip.cmake +++ b/cmake/presets/hip.cmake @@ -1,12 +1,26 @@ -# preset that will enable hipcc plus gcc with support for MPI and OpenMP (on Linux boxes) +# preset that will enable hipcc plus gcc/gfortran 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_Fortran_COMPILER gfortran CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) -unset(HAVE_OMP_H_INCLUDE CACHE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) -set(OpenMP_CXX "hipcc" CACHE STRING "" FORCE) +set(MPI_CXX "hipcc" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) + +unset(HAVE_OMP_H_INCLUDE CACHE) +set(OpenMP_C "gcc" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "gomp" CACHE STRING "" FORCE) set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_CXX "hipcc" CACHE STRING "" FORCE) set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE) diff --git a/cmake/presets/hip_amd.cmake b/cmake/presets/hip_amd.cmake new file mode 100644 index 0000000000..4b8945e0c7 --- /dev/null +++ b/cmake/presets/hip_amd.cmake @@ -0,0 +1,30 @@ +# preset that will enable hip (clang/clang++) with support for MPI and OpenMP (on Linux boxes) + +# prefer flang over gfortran, if available +find_program(CLANG_FORTRAN NAMES flang gfortran f95) +set(ENV{OMPI_FC} ${CLANG_FORTRAN}) + +set(CMAKE_CXX_COMPILER "hipcc" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "hipcc" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER ${CLANG_FORTRAN} CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -std=f2003" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) + +set(MPI_CXX "hipcc" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) + +unset(HAVE_OMP_H_INCLUDE CACHE) +set(OpenMP_C "hipcc" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) +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) diff --git a/cmake/presets/intel.cmake b/cmake/presets/intel.cmake index d101a0f699..9baf873608 100644 --- a/cmake/presets/intel.cmake +++ b/cmake/presets/intel.cmake @@ -3,10 +3,20 @@ set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE) set(CMAKE_Fortran_COMPILER "ifort" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) + set(MPI_CXX "icpc" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) -unset(HAVE_OMP_H_INCLUDE CACHE) +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) diff --git a/cmake/presets/mingw-cross.cmake b/cmake/presets/mingw-cross.cmake index 32b17d43c2..fe828a6d9a 100644 --- a/cmake/presets/mingw-cross.cmake +++ b/cmake/presets/mingw-cross.cmake @@ -1,13 +1,76 @@ -set(WIN_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KSPACE LATTE MANYBODY MC MISC MLIAP MOLECULE OPT - PERI POEMS QEQ REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI - USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK - USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF - USER-FEP USER-INTEL USER-MANIFOLD USER-MEAMC USER-MESODPD - USER-MESONT USER-MISC USER-MGPT USER-MOFFF USER-MOLFILE USER-OMP - USER-PHONON USER-PTM USER-QTB USER-REACTION USER-REAXC - USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF - USER-YAFF) +set(WIN_PACKAGES + ASPHERE + ATC + AWPMD + BOCS + BODY + BROWNIAN + CG-DNA + CG-SDK + CLASS2 + COLLOID + COLVARS + COMPRESS + CORESHELL + DIELECTRIC + DIFFRACTION + DIPOLE + DPD-BASIC + DPD-MESO + DPD-REACT + DPD-SMOOTH + DRUDE + EFF + EXTRA-COMPUTE + EXTRA-DUMP + EXTRA-FIX + EXTRA-MOLECULE + EXTRA-PAIR + FEP + GPU + GRANULAR + INTEL + INTERLAYER + KSPACE + LATTE + MACHDYN + MANIFOLD + MANYBODY + MC + MDI + MEAM + MESONT + MGPT + MISC + ML-HDNNP + ML-IAP + ML-SNAP + ML-RANN + MOFFF + MOLECULE + MOLFILE + OPENMP + OPT + ORIENT + PERI + PHONON + POEMS + PTM + QEQ + QTB + REACTION + REAXFF + REPLICA + RIGID + SHOCK + SMTBQ + SPH + SPIN + SRD + TALLY + UEF + VORONOI + YAFF) foreach(PKG ${WIN_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) @@ -16,7 +79,7 @@ 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) + set(PKG_LATBOLTZ ON CACHE BOOL "" FORCE) endif() set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index 5dc58b735b..eb26b38928 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -2,13 +2,66 @@ # external libraries. Compared to all_on.cmake some more unusual packages # are removed. The resulting binary should be able to run most inputs. -set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE - GRANULAR KSPACE MANYBODY MC MISC MLIAP MOLECULE OPT PERI - PLUGIN POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI - USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION - USER-DPD USER-DRUDE USER-EFF USER-FEP USER-MEAMC USER-MESODPD - USER-MISC USER-MOFFF USER-OMP USER-PHONON USER-REACTION - USER-REAXC USER-SDPD USER-SPH USER-SMD USER-UEF USER-YAFF) +set(ALL_PACKAGES + ASPHERE + BOCS + BODY + BROWNIAN + CG-DNA + CG-SDK + CLASS2 + COLLOID + COLVARS + COMPRESS + CORESHELL + DIELECTRIC + DIFFRACTION + DIPOLE + DPD-BASIC + DPD-MESO + DPD-REACT + DPD-SMOOTH + DRUDE + EFF + EXTRA-COMPUTE + EXTRA-DUMP + EXTRA-FIX + EXTRA-MOLECULE + EXTRA-PAIR + FEP + GRANULAR + INTERLAYER + KSPACE + MACHDYN + MANYBODY + MC + MEAM + MISC + ML-IAP + ML-SNAP + MOFFF + MOLECULE + OPENMP + OPT + ORIENT + PERI + PHONON + PLUGIN + POEMS + PYTHON + QEQ + REACTION + REAXFF + REPLICA + RIGID + SHOCK + SPH + SPIN + SRD + TALLY + UEF + VORONOI + YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/nolib.cmake b/cmake/presets/nolib.cmake index c9abb00a15..fd9c2ed1ac 100644 --- a/cmake/presets/nolib.cmake +++ b/cmake/presets/nolib.cmake @@ -1,11 +1,34 @@ # preset that turns off all packages that require some form of external # library or special compiler (fortran or cuda) or equivalent. -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MESSAGE MPIIO MSCG - PYTHON VORONOI - USER-ADIOS USER-ATC USER-AWPMD USER-H5MD USER-LB USER-MOLFILE USER-MESONT - USER-NETCDF USER-PACE USER-PLUMED USER-QMMM USER-QUIP USER-SCAFACOS - USER-SMD USER-VTK) +set(PACKAGES_WITH_LIB + ADIOS + ATC + AWPMD + COMPRESS + GPU + H5MD + KIM + KOKKOS + LATBOLTZ + LATTE + MACHDYN + MDI + MESONT + MESSAGE + ML-HDNNP + ML-PACE + ML-QUIP + MOLFILE + MPIIO + MSCG + NETCDF + PLUMED + PYTHON + QMMM + SCAFACOS + VORONOI + VTK) foreach(PKG ${PACKAGES_WITH_LIB}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/oneapi.cmake b/cmake/presets/oneapi.cmake index ef04167305..403494c409 100644 --- a/cmake/presets/oneapi.cmake +++ b/cmake/presets/oneapi.cmake @@ -1,12 +1,22 @@ -# preset that will enable the LLVM based Intel compilers with support for MPI and OpenMP (on Linux boxes) +# preset that will enable the LLVM based Intel compilers with support for MPI and OpenMP and Fortran (on Linux boxes) set(CMAKE_CXX_COMPILER "icpx" CACHE STRING "" FORCE) set(CMAKE_C_COMPILER "icx" CACHE STRING "" FORCE) set(CMAKE_Fortran_COMPILER "ifx" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) + set(MPI_CXX "icpx" CACHE STRING "" FORCE) set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) -unset(HAVE_OMP_H_INCLUDE CACHE) +unset(HAVE_OMP_H_INCLUDE CACHE) set(OpenMP_C "icx" CACHE STRING "" FORCE) set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) diff --git a/cmake/presets/pedantic.cmake b/cmake/presets/pedantic.cmake new file mode 100644 index 0000000000..11c74dbaa4 --- /dev/null +++ b/cmake/presets/pedantic.cmake @@ -0,0 +1,26 @@ +# preset that will restore gcc/g++ with support for MPI and OpenMP (on Linux boxes) + +set(CMAKE_CXX_COMPILER "g++" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "gcc" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -Werror=vla -Wno-maybe-uninitialized -g" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -Werror=vla -Wno-maybe-uninitialized -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O3 -DNDEBUG" CACHE STRING "" FORCE) +set(MPI_CXX "g++" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) +set(MPI_C "gcc" CACHE STRING "" FORCE) +set(MPI_C_COMPILER "mpicc" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -Wno-maybe-uninitialized -g" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Wall -Wextra -Wno-maybe-uninitialized -g -O2 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-Wall -O3 -DNDEBUG" CACHE STRING "" FORCE) +set(MPI_Fortran "gfortran" CACHE STRING "" FORCE) +set(MPI_Fortran_COMPILER "mpifort" CACHE STRING "" FORCE) +unset(HAVE_OMP_H_INCLUDE CACHE) + +set(OpenMP_C "gcc" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "gomp" CACHE STRING "" FORCE) +set(OpenMP_CXX "g++" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE) +set(OpenMP_CXX_LIB_NAMES "gomp" CACHE STRING "" FORCE) +set(OpenMP_omp_LIBRARY "libgomp.so" CACHE PATH "" FORCE) diff --git a/cmake/presets/windows.cmake b/cmake/presets/windows.cmake new file mode 100644 index 0000000000..d4e69c5fca --- /dev/null +++ b/cmake/presets/windows.cmake @@ -0,0 +1,64 @@ +set(WIN_PACKAGES + ASPHERE + BOCS + BODY + BROWNIAN + CG-DNA + CG-SDK + CLASS2 + COLLOID + COLVARS + CORESHELL + DIELECTRIC + DIFFRACTION + DIPOLE + DPD-BASIC + DPD-MESO + DPD-REACT + DPD-SMOOTH + DRUDE + EFF + EXTRA-COMPUTE + EXTRA-DUMP + EXTRA-FIX + EXTRA-MOLECULE + EXTRA-PAIR + FEP + GRANULAR + INTERLAYER + KSPACE + MANIFOLD + MANYBODY + MC + MEAM + MISC + ML-IAP + ML-SNAP + MOFFF + MOLECULE + MOLFILE + OPENMP + ORIENT + PERI + PHONON + POEMS + PTM + QEQ + QTB + REACTION + REAXFF + REPLICA + RIGID + SHOCK + SMTBQ + SPH + SPIN + SRD + TALLY + UEF + YAFF) + +foreach(PKG ${WIN_PACKAGES}) + set(PKG_${PKG} ON CACHE BOOL "" FORCE) +endforeach() + diff --git a/doc/Makefile b/doc/Makefile index e49d42ca77..d61f844a1b 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -10,7 +10,6 @@ endif BUILDDIR = ${CURDIR} RSTDIR = $(BUILDDIR)/src VENV = $(BUILDDIR)/docenv -TXT2RST = $(VENV)/bin/txt2rst ANCHORCHECK = $(VENV)/bin/rst_anchor_check SPHINXCONFIG = $(BUILDDIR)/utils/sphinx-config MATHJAX = $(SPHINXCONFIG)/_static/mathjax @@ -59,7 +58,7 @@ SPHINXEXTRA = -E -j $(shell $(PYTHON) -c 'import multiprocessing;print(multiproc # we only want to use explicitly listed files. DOXYFILES = $(shell sed -n -e 's/\#.*$$//' -e '/^ *INPUT \+=/,/^[A-Z_]\+ \+=/p' doxygen/Doxyfile.in | sed -e 's/@LAMMPS_SOURCE_DIR@/..\/src/g' -e 's/\\//g' -e 's/ \+/ /' -e 's/[A-Z_]\+ \+= *\(YES\|NO\|\)//') -.PHONY: help clean-all clean clean-spelling epub mobi rst html pdf spelling anchor_check style_check xmlgen +.PHONY: help clean-all clean clean-spelling epub mobi rst html pdf spelling anchor_check style_check char_check xmlgen # ------------------------------------------ @@ -68,7 +67,6 @@ help: @echo "Please use \`make ' where is one of" @echo " html create HTML pages in html dir" @echo " pdf create Manual.pdf in this dir" - @echo " fetch fetch HTML and PDF files from LAMMPS web site" @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 " (requires ebook-convert tool from calibre)" @@ -185,13 +183,6 @@ pdf: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) @rm -rf latex/PDF/.[sg]* @echo "Build finished. Manual.pdf is in this directory." -fetch: - @rm -rf html_www Manual_www.pdf - @curl -s -o Manual_www.pdf http://lammps.sandia.gov/doc/Manual.pdf - @curl -s -o lammps-doc.tar.gz http://lammps.sandia.gov/tars/lammps-doc.tar.gz - @tar xzf lammps-doc.tar.gz - @rm -f lammps-doc.tar.gz - anchor_check : $(ANCHORCHECK) @(\ . $(VENV)/bin/activate ;\ @@ -213,6 +204,9 @@ package_check : $(VENV) deactivate ;\ ) +char_check : + @( env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst && exit 1 || : ) + xmlgen : doxygen/xml/index.xml doxygen/Doxyfile: doxygen/Doxyfile.in @@ -236,9 +230,9 @@ $(VENV): ) $(MATHJAX): - @git clone -b 3.1.4 -c advice.detachedHead=0 --depth 1 git://github.com/mathjax/MathJax.git $@ + @git clone -b 3.2.0 -c advice.detachedHead=0 --depth 1 git://github.com/mathjax/MathJax.git $@ -$(TXT2RST) $(ANCHORCHECK): $(VENV) +$(ANCHORCHECK): $(VENV) @( \ . $(VENV)/bin/activate; \ (cd utils/converters;\ diff --git a/doc/README b/doc/README index 8af4021a60..fed2e515b3 100644 --- a/doc/README +++ b/doc/README @@ -25,16 +25,11 @@ github-development-workflow.md notes on the LAMMPS development workflow include-file-conventions.md notes on LAMMPS' include file conventions documentation_conventions.md notes on writing documentation for LAMMPS -If you downloaded a LAMMPS tarball from lammps.sandia.gov, then the html +If you downloaded a LAMMPS tarball from www.lammps.org, then the html folder and the PDF manual should be included. If you downloaded LAMMPS -from GitHub then you either need to download them or build them. +from GitHub then you either need to build them. -(a) You can "fetch" the current HTML and PDF files from the LAMMPS web -site. Just type "make fetch". This should create a html_www directory -and Manual_www.pdf file. These will always represent the latest published -patch/development version of LAMMPS. - -(b) You can build the HTML and PDF files yourself, by typing "make html" +You can build the HTML and PDF files yourself, by typing "make html" or by "make pdf", respectively. This requires various tools and files. Some of them have to be installed (more on that below). For the rest the build process will attempt to download and install into a python virtual @@ -78,4 +73,4 @@ the tool 'ebook-convert' from the 'calibre' e-book management software ---------------- More details this can be found in the manual itself. The online -version is at: https://lammps.sandia.gov/doc/Manual_build.html +version is at: https://docs.lammps.org/Build_manual.html diff --git a/doc/doxygen/Doxyfile.in b/doc/doxygen/Doxyfile.in index 49a271355f..d454898f4e 100644 --- a/doc/doxygen/Doxyfile.in +++ b/doc/doxygen/Doxyfile.in @@ -435,6 +435,8 @@ INPUT = @LAMMPS_SOURCE_DIR@/utils.cpp \ @LAMMPS_SOURCE_DIR@/my_pool_chunk.cpp \ @LAMMPS_SOURCE_DIR@/my_pool_chunk.h \ @LAMMPS_SOURCE_DIR@/math_eigen.h \ + @LAMMPS_SOURCE_DIR@/platform.h \ + @LAMMPS_SOURCE_DIR@/platform.cpp \ # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/doc/github-development-workflow.md b/doc/github-development-workflow.md index c34a67dfcf..1c0eddedcf 100644 --- a/doc/github-development-workflow.md +++ b/doc/github-development-workflow.md @@ -6,7 +6,7 @@ choices the LAMMPS developers have agreed on. Git and GitHub provide the tools, but do not set policies, so it is up to the developers to come to an agreement as to how to define and interpret policies. This document is likely to change as our experiences and needs change and we try to -adapt accordingly. Last change 2018-12-19. +adapt accordingly. Last change 2021-09-02. ## Table of Contents @@ -23,19 +23,19 @@ adapt accordingly. Last change 2018-12-19. In the interest of consistency, ONLY ONE of the core LAMMPS developers should doing the merging itself. This is currently -[@akohlmey](https://github.com/akohlmey) (Axel Kohlmeyer). -If this assignment needs to be changed, it shall be done right after a -stable release. If the currently assigned developer cannot merge outstanding pull -requests in a timely manner, or in other extenuating circumstances, +[@akohlmey](https://github.com/akohlmey) (Axel Kohlmeyer). If this +assignment needs to be changed, it shall be done right after a stable +release. If the currently assigned developer cannot merge outstanding +pull requests in a timely manner, or in other extenuating circumstances, other core LAMMPS developers with merge rights can merge pull requests, when necessary. ## Pull Requests ALL changes to the LAMMPS code and documentation, however trivial, MUST -be submitted as a pull request to GitHub. All changes to the "master" +be submitted as a pull request to GitHub. All changes to the "develop" branch must be made exclusively through merging pull requests. The -"unstable" and "stable" branches, respectively are only to be updated +"release" and "stable" branches, respectively are only to be updated upon patch or stable releases with fast-forward merges based on the associated tags. Pull requests may also be submitted to (long-running) feature branches created by LAMMPS developers inside the LAMMPS project, @@ -55,13 +55,14 @@ the required changes or ask the submitter of the pull request to implement them. Even though, all LAMMPS developers may have write access to pull requests (if enabled by the submitter, which is the default), only the submitter or the assignee of a pull request may do so. During this -period the `work_in_progress` label shall be applied to the pull +period the `work_in_progress` label may be applied to the pull request. The assignee gets to decide what happens to the pull request next, e.g. whether it should be assigned to a different developer for additional checks and changes, or is recommended to be merged. Removing the `work_in_progress` label and assigning the pull request to the developer tasked with merging signals that a pull request is ready to be -merged. +merged. In addition, a `ready_for_merge` label may also be assigned +to signal urgency to merge this pull request quickly. ### Pull Request Reviews @@ -97,108 +98,50 @@ rationale behind choices made. Exceptions to this policy are technical discussions, that are centered on tools or policies themselves (git, GitHub, c++) rather than on the content of the pull request. -### Checklist for Pull Requests - -Here are some items to check: - * source and text files should not have CR/LF line endings (use dos2unix to remove) - * every new command or style should have documentation. The names of - 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, - implementing the class `FixNVE`, documented in `doc/src/fix_nve.rst`) - * all new style names should be lower case, the must be no dashes, - blanks, or underscores separating words, only forward slashes. - * new style docs should be added to the "overview" files in - `doc/src/Commands_*.rst`, `doc/src/{fixes,computes,pairs,bonds,...}.rst` - * 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 style tables and command lists with `make style_check` - * new source files in packages should be added to `src/.gitignore` - * 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-library APIs, e.g. `#include ` instead of `#include `. - And they should use angular brackets instead of double quotes. Full list: - * assert.h -> cassert - * ctype.h -> cctype - * errno.h -> cerrno - * float.h -> cfloat - * limits.h -> climits - * math.h -> cmath - * complex.h -> complex - * setjmp.h -> csetjmp - * signal.h -> csignal - * stddef.h -> cstddef - * stdint.h -> cstdint - * stdio.h -> cstdio - * stdlib.h -> cstdlib - * string.h -> cstring - * time.h -> ctime - * Do NOT replace (as they are C++-11): `inttypes.h` and `stdint.h`. - * Code must follow the C++-11 standard. C++98-only is no longer accepted - * Code should use `nullptr` instead of `NULL` where applicable. - in individual special purpose packages - * indentation is 2 spaces per level - * 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 - other headers, except the header with the base class or cstdio. - Forward declarations should be used instead when possible. - * iostreams should be avoided. LAMMPS uses stdio from the C-library. - * use of STL in headers and class definitions should be avoided. - exception is , but it won't need to be explicitly included - since pointers.h already includes it. so std::string can be used directly. - * there MUST NOT be any "using namespace XXX;" statements in headers. - * static class members should be avoided at all cost. - * anything storing atom IDs should be using `tagint` and not `int`. - This can be flagged by the compiler only for pointers and only when - compiling LAMMPS with `-DLAMMPS_BIGBIG`. - * when including both `lmptype.h` (and using defines or macros from it) - and `mpi.h`, `lmptype.h` must be included first. - * see https://github.com/lammps/lammps/blob/master/doc/include-file-conventions.md - for general include file conventions and best practices - * when pair styles are added, check if settings for flags like - `single_enable`, `writedata`, `reinitflag`, `manybody_flag` - and others are correctly set and supported. - ## GitHub Issues The GitHub issue tracker is the location where the LAMMPS developers and other contributors or LAMMPS users can report issues or bugs with -the LAMMPS code or request new features to be added. Feature requests -are usually indicated by a `[Feature Request]` marker in the subject. -Issues are assigned to a person, if this person is working on this -feature or working to resolve an issue. Issues that have nobody working -on them at the moment, have the label `volunteer needed` attached. +the LAMMPS code or request new features to be added. Bug reports have +a `[Bug]` marker in the subject line; suggestions for changes or +adding new functionality are indicated by a `[Feature Request]` +marker in the subject. This is automatically done when using the +corresponding template for submitting an issue. Issues may be assigned +to one or more developers, if they are working on this feature or +working to resolve an issue. Issues that have nobody working +on them at the moment or in the near future, have the label +`volunteer needed` attached. When an issue, say `#125` is resolved by a specific pull request, the comment for the pull request shall contain the text `closes #125` or `fixes #125`, so that the issue is automatically deleted when -the pull request is merged. +the pull request is merged. The template for pull requests includes +a header where connections between pull requests and issues can be listed +and thus were this comment should be placed. ## Milestones and Release Planning LAMMPS uses a continuous release development model with incremental changes, i.e. significant effort is made - including automated pre-merge -testing - that the code in the branch "master" does not get broken. -More extensive testing (including regression testing) is performed after -code is merged to the "master" branch. There are patch releases of -LAMMPS every 1-3 weeks at a point, when the LAMMPS developers feel, that -a sufficient amount of changes have happened, and the post-merge testing -has been successful. These patch releases are marked with a -`patch_` tag and the "unstable" branch follows only these -versions (and thus is always supposed to be of production quality, -unlike "master", which may be temporary broken, in the case of larger -change sets or unexpected incompatibilities or side effects. +testing - that the code in the branch "develop" does not get easily +broken. These tests are run after every update to a pull request. More +extensive and time consuming tests (including regression testing) are +performed after code is merged to the "develop" branch. There are patch +releases of LAMMPS every 3-5 weeks at a point, when the LAMMPS +developers feel, that a sufficient amount of changes have happened, and +the post-merge testing has been successful. These patch releases are +marked with a `patch_` tag and the "release" branch +follows only these versions (and thus is always supposed to be of +production quality, unlike "develop", which may be temporary broken, in +the case of larger change sets or unexpected incompatibilities or side +effects. -About 3-4 times each year, there are going to be "stable" releases -of LAMMPS. These have seen additional, manual testing and review of +About 1-2 times each year, there are going to be "stable" releases of +LAMMPS. These have seen additional, manual testing and review of results from testing with instrumented code and static code analysis. -Also, in the last 2-3 patch releases before a stable release are -"release candidate" versions which only contain bugfixes and -documentation updates. For release planning and the information of -code contributors, issues and pull requests being actively worked on -are assigned a "milestone", which corresponds to the next stable -release or the stable release after that, with a tentative release -date. - +Also, the last 1-3 patch releases before a stable release are "release +candidate" versions which only contain bugfixes and documentation +updates. For release planning and the information of code contributors, +issues and pull requests being actively worked on are assigned a +"milestone", which corresponds to the next stable release or the stable +release after that, with a tentative release date. diff --git a/doc/include-file-conventions.md b/doc/include-file-conventions.md deleted file mode 100644 index 87b9eba8df..0000000000 --- a/doc/include-file-conventions.md +++ /dev/null @@ -1,128 +0,0 @@ -# Outline of include file conventions in LAMMPS - -This purpose of this document is to provide a point of reference -for LAMMPS developers and contributors as to what include files -and definitions to put where into LAMMPS source. -Last change 2020-08-31 - -## Table of Contents - - * [Motivation](#motivation) - * [Rules](#rules) - * [Tools](#tools) - * [Legacy Code](#legacy-code) - -## Motivation - -The conventions outlined in this document are supposed to help make -maintenance of the LAMMPS software easier. By trying to achieve -consistency across files contributed by different developers, it will -become easier for the code maintainers to modify and adjust files and, -overall, the chance for errors or portability issues will be reduced. -The rules employed are supposed to minimize naming conflicts and -simplify dependencies between files and thus speed up compilation. They -may, as well, make otherwise hidden dependencies visible. - -## Rules - -Below are the various rules that are applied. Not all are enforced -strictly and automatically. If there are no significant side effects, -exceptions may be possible for cases where a full compliance to the -rules may require a large effort compared to the benefit. - -### Core Files Versus Package Files - -All rules listed below are most strictly observed for core LAMMPS files, -which are the files that are not part of a package, and the files of the -packages MOLECULE, MANYBODY, KSPACE, and RIGID. On the other end of -the spectrum are USER packages and legacy packages that predate these -rules and thus may not be fully compliant. Also, new contributions -will be checked more closely, while existing code will be incrementally -adapted to the rules as time and required effort permits. - -### System Versus Local Header Files - -All system- or library-provided include files are included with angular -brackets (examples: `#include ` or `#include `) while -include files provided with LAMMPS are included with double quotes -(examples: `#include "pointers.h"` or `#include "compute_temp.h"`). - -For headers declaring functions of the C-library, the corresponding -C++ versions should be included (examples: `#include ` or -`#include ` instead of `#include ` or -`#include` ). - -### C++ Standard Compliance - -LAMMPS core files use standard conforming C++ compatible with the -C++11 standard, unless explicitly noted. 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 - -Header files will typically contain the definition of a (single) class. -These header files should have as few include statements as possible. -This is particularly important for classes that implement a "style" and -thus use a macro of the kind `SomeStyle(some/name,SomeName)`. These will -all be included in the auto-generated `"some_style.h"` files which -results in a high potential for direct or indirect symbol name clashes. - -In the ideal case, the header would only include one file defining the -parent class. That would typically be either `#include "pointers.h"` for -the `Pointers` class, or a header of a class derived from it like -`#include "pair.h"` for the `Pair` class and so on. References to other -classes inside the class should be make through pointers, for which forward -declarations (inside the `LAMMPS_NS` or the new class' namespace) can -be employed. The full definition will then be included into the corresponding -implementation file. In the given example from above, the header file -would be called `some_name.h` and the implementation `some_name.cpp` (all -lower case with underscores, while the class itself would be in camel case -and no underscores `SomeName`, and the style name with lower case names separated by -a forward slash). - -### Implementation Files - -In the implementation files (typically, those would have the same base name -as the corresponding header with a .cpp extension instead of .h) include -statements should follow the "include what you use" principle. - -### Order of Include Statements - -Include files should be included in this order: -* the header matching the implementation (`some_class.h` for file `some_class.cpp`) -* mpi.h (only if needed) -* LAMMPS local headers (preferably in alphabetical order) -* system and library headers (anything that is using angular brackets; preferably in alphabetical order) -* conditional include statements (i.e. anything bracketed with ifdefs) - -### Special Cases and Exceptions - -#### pointers.h - -The `pointer.h` header file also includes (in this order) `lmptype.h`, -`mpi.h`, `cstddef`, `cstdio`, `string`, `utils.h`, and `fmt/format.h` -and through `lmptype.h` indirectly also `climits`, `cstdlib`, `cinttypes`. -This means any header including `pointers.h` can assume that `FILE`, -`NULL`, `INT_MAX` are defined, and the may freely use the std::string -for arguments. Corresponding implementation files do not need to include -those headers. - -## Tools - -The [Include What You Use tool](https://include-what-you-use.org/) -can be used to provide supporting information about compliance with -the rules listed here. Through setting `-DENABLE_IWYU=on` when running -CMake, a custom build target is added that will enable recording -the compilation commands and then run the `iwyu_tool` using the -recorded compilation commands information when typing `make iwyu`. - -## Legacy Code - -A lot of code predates the application of the rules in this document -and the rules themselves are a moving target. So there are going to be -significant chunks of code that do not fully comply. This applies -for example to the USER-REAXC, or the USER-ATC package. The LAMMPS -developers are dedicated to make an effort to improve the compliance -and welcome volunteers wanting to help with the process. - diff --git a/doc/lammps.1 b/doc/lammps.1 index c10950643d..78b6c9fd67 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "8 April 2021" "2021-04-08" +.TH LAMMPS "1" "27 October 2021" "2021-10-27" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. @@ -34,7 +34,7 @@ semiconductors) and coarse-grained or mesoscopic systems. It can be used to model atoms or, more generically, as a parallel particle simulator at the atomic, meso, or continuum scale. -See https://lammps.sandia.gov/ for more information and documentation. +See https://www.lammps.org/ for more information and documentation. .SH EXECUTABLE NAME The @@ -54,7 +54,7 @@ using this parameter can be chosen arbitrarily at configuration time, but more common is to just use .B lmp -without a suffix. In this manpage we will use +without a suffix. In this man page we will use .B lmp to represent any of those names. @@ -94,7 +94,7 @@ Enable or disable general KOKKOS support, as provided by the KOKKOS package. Even if LAMMPS is built with this package, this switch must be set to \fBon\fR to enable running with KOKKOS-enabled styles. More details on this switch and its optional keyword value pairs are discussed -at: https://lammps.sandia.gov/doc/Run_options.html +at: https://docs.lammps.org/Run_options.html .TP \fB\-l \fR or \fB\-log \fR Specify a log file for LAMMPS to write status information to. @@ -122,6 +122,38 @@ to perform client/server messaging with another application. .B LAMMPS can act as either a client or server (or both). .TP +\fB\-mdi ''\fR +This flag is only recognized and used when +.B LAMMPS +has support for the MolSSI +Driver Interface (MDI) included as part of the MDI package. This flag is +specific to the MDI library and controls how +.B LAMMPS +interacts with MDI. There are usually multiple flags that have to follow it +and those have to be placed in quotation marks. For more information about +how to launch LAMMPS in MDI client/server mode please refer to the +MDI How-to at https://docs.lammps.org/Howto_mdi.html +.TP +\fB\-c\fR or \fB\-cite