Skip to content

Latest commit

 

History

History
43 lines (40 loc) · 13.9 KB

CONTRIBUTING.md

File metadata and controls

43 lines (40 loc) · 13.9 KB

The SOLPS-ITER code suite is a complex package with many cross-relations within its separate components and this needs to be kept in mind when developers are involved in any coding improvements. The list below provides a non-exhaustive set of coding requirements that are requested of developers, in order to maintain the integrity of the code package and a consistent coding style, as well as facilitate further development by others and code usage by the community. One must always stay mindful that the code is meant to be used on a wide variety of OS platforms, compilers, and physics use cases, so any change that would compromise the portability of the code is absolutely to be avoided, unless it has been specifically authorized by the ITER code Responsible Officer (RO) and presented to the user community for comment before incorporation into the main code branches. Of course, usual coding recommendations about including clear comments, explicit variable and routine names, and respecting indentations also apply throughout.

All code change suggestions should be made through GIT pull requests (PR) to the appropriate main distributions branches (currently develop, release/3.1.2, and feature/wg-release for the 3.0.10, 3.1.2, and 3.2.0 versions respectively). If a code change may apply to more than one version, then the pull request need only be done for one of the branches, but structured in such a way that cherry-picking it to add to the other branches can be easily achieved, and including in the PR description for which other branches it is meant. The cherry-picking will then be the responsibility of the ITER RO. The proposed side branch to be pulled in should already be positioned at the top of its destination branch, since only fast-forward merges are allowed. If a pull request involves branches in the main SOLPS-ITER repository and one or more of its submodules, the pull request at the SOLPS-ITER top level need not include the changes in the pointers to the updated submodules. These are the responsibility of the ITER RO, as the requester may be unaware of other developments in the submodules that would change the actual pointers to be included.

Contributors to the SOLPS-ITER code base are expected to follow ALL the rules below. Failure to abide by them will lead to their pull requests being delayed and/or summarily declined.

  1. When working on a new code feature or bug fix, it is important to work in a branch forked from a development branch from the official distribution. These are the develop, release/3.1.1, and feature/wg-release branches. It is necessary to keep that forked branch abreast of any changes occurring in the reference branch, either by rebasing, merging, or cherry-picking the appropriate commits, before submitting any pull requests. Doing so regularly decreases the amount of work required to inspect the pull request and ensures all relevant code updates can be introduced with minimal risk of errors.
  2. Code that only works for a particular set of cases, and is not general, should be avoided whenever possible and must always be identified as such. The code should then include safeties and/or error/warning messages to prevent its unintentional use by an unsuspecting user.
  3. If modifying the code equations or introducing a new physics term, this shall be reflected in the physics model description chapter of the SOLPS-ITER manual, within the same commit or pull request.
  4. Any pull request introducing changes to the physics results of the code that would affect some of the provided reference examples must contain pointers to newly converged occurrences of these affected examples.
  5. When introducing a new switch or extending its functionality, a description of this switch must be added to the documentation files, within the same commit or pull request. For the B2.5 code, the list of input file switches is given in the XML file $SOLPSTOP/modules/B2.5/src/documentation/b2input.xml. When editing the b2input.xml file, lines should begin with tabs, as these are used by the Python script that builds b2cdci.F and b2cdcn.F. The latter two files are not to be changed, since they will be automatically regenerated. If the value of the switch depends on the numbering/ordering/bundling of species or grid size, a conversion rule must also be provided within the b2yt program.
  6. In addition, changes to the default values of switches need to be explicitly mentioned in the commit message.
  7. Same when introducing or extending a namelist variable, the new variable and/or functionality must be added in b2input.xml, as well as in the relevant section of the SOLPS-ITER manual ($SOLPSTOP/doc/solps/solps.tex). Depending on the namelist involved and the type of variable (array depending on the numbering of species or grid size, in particular), conversion rules must also be provided within the b2yt and b2sxdr programs, as appropriate. It may also be necessary to provide a recommended default setting within Uinp or b2us. Again, all of this within the same commit or pull request as the new variable or functionality being introduced.
  8. If a new input/output file is introduced, the Makefile, run submission, and relevant file manipulation scripts must be adapted to its presence. If the file is optional, the relevant run Makefile(s) must operate without any errors (no matter how mild) whether the file is present or not. A description of the new file and its usage must also be added in the documentation. Again, all of this within the same commit or pull request where the new file is introduced.
  9. Importantly, code changes that imply a change of the physics result when code defaults are being used must be identified as such in the commit message. Such commit messages should then start with “Changes default behaviour” (ALL CAPS allowed if it is a big/important change!).
  10. If a new module is introduced, its location must be added to the src/modules/.new_modules file, for compilation purposes, within the same commit, so that the Makefile is aware of the need to rebuild the dependencies file.
  11. If the contents of one of the standard SOLPS-ITER I/O files is changed, it may be necessary to change the "version number" of that file, to ensure full backward compatibility. This backward compatibility will then need to be checked. If a version number change for a B2.5 file is necessary, it must be included and described in b2mod_version.F, within the same commit. Any relevant conversion rules must also be added to the b2yt, b2us, and b2sxdr programs, as appropriate. Such changes cannot occur without explicit consultation and approval by the ITER RO.
  12. If a new variable is added to the MDSplus tree database, or the definition of an existing variable is changed, the value of the variable dbversion in b2mds.F must be incremented and a description of the change given in the comments above the setting of dbversion. The MDSplus tree file descriptions in $SOLPSTOP/doc/solps/MDSPLUS may also need to be updated.
  13. If a new B2.5 routine is added, and the routine name is b2*, then a short description of the routine must be added to the b2cdcr.F file, within the same commit. In general, the name of any new routine and its subroutine statement must be on the same line, so that the tags application in emacs will be able to find the routine when requested. In the same vein, to facilitate searches through the code base, please keep calling statements on the same line, i.e. call and the name of the subroutine being called should be kept together.
  14. If a new main variable is added, its description and use shall be included in the b2cdcv.F file, within the same commit.
  15. If a new script is added, it shall be listed and described in the SOLPS-ITER manual, within the same commit.
  16. If a new b2plot function is added, it must be added to the list in b2mod_b2plot_help.F and described in the SOLPS-ITER manual, within the same pull request.
  17. When adding a use module statement, and if the module is to be obtained from an outside library, an ! IGNORE comment must be added at the end of the line so it is not included when building the dependencies files.
  18. A commit should not be made unless it has been verified that, at least, the code compiles with the new changes included. Creating a pull request will trigger a series of Continuous Integration (CI) tests, and these must also be passed for the pull request to be merged in, unless specifically authorized by the ITER RO. If the changes involve some pre-processor switches, the compilation test must be done with the pre-processor switches both on and off. The compilation should result in no warnings and no errors, for all tested compilers. Compilation should be tested, ideally, on more than one compiler. For general distribution, SOLPS-ITER is to be made to compile on the Intel, GNU, Portland Group (NVIDIA), NAG, and Cray compilers. Only Fortran standard should be used, as not all extensions are supported by all compilers, or alternative code must be provided with appropriate pre-processor bracketing. The -DLEGACYCOMP pre-processor pragma is available to allow for legacy Fortran compilers that do not support the 2003 standard extensions. Other compiler-specific pragmas include -DGFORTRAN, -DPGF90, -DNAGFOR, or -DCRAY. A full list of the currently used pre-processor bracketing variables is available in the SOLPS-ITER manual, and should be updated, within the same pull request, whenever a pragma is being used within a source code file.
  19. To avoid memory leaks, which may become problematic when using SOLPS-ITER as a recurring actor in an IMAS workflow, every array allocation statement shall be twinned with a corresponding array deallocation, preferably within the same subroutine or module.
  20. Double-precision real numerical values inside B2.5 and Carre should be written as 0.0_R8, NOT 0., 0.0, 0.0e0, or 0.0d0. In Eirene, they should be written as 0.0_DP. Single precision reals use the _R4 (in B2.5 and Carre) and _SP (in Eirene) extensions. Quadruple precision variables use _R16. Long integers use _I8.
  21. Do not use hash characters (#) as continuation characters in Fortran 77 files, as these are misinterpreted by the pre-processor.
  22. If the real result of a ratio of two integers is needed, use the rratio(m,n) function provided within the B2.5 code.
  23. Care must be taken NOT to import special DOS carriage return control characters (^M) before committing files. The GIT repository is configured to automatically convert such files. Files must also be checked to have proper read/write/execute permissions.
  24. In source code, trailing whitespace characters and indentation by means of “tab” characters are to be avoided. Tagging individual lines with comments indicating author and date is not mandatory, since proper use of the version control tools is sufficient to keep traceability of the code source. Progressive indentation into loops and IF statements should be kept consistent within the same file to maintain good code readability.
  25. Within modules, individual subroutines and functions must be terminated with either an END SUBROUTINE or END FUNCTION statement, respectively. Some compilers will fail if only END is used. Preferably, also include the name of the ending subroutine or function in that statement, and apply the same rule also to individual subroutine files.
  26. The use of ENTRY statements must be avoided. Instead, it is recommended to create a module that contains the entries as separate subroutines.
  27. The use of GOTO statements should be avoided and substituted by SELECT CASE or IF statements whenever possible.
  28. Statement functions should be avoided and substituted by external or contained functions.
  29. The use of stop statements within B2.5 or Eirene is not MPI-compliant and therefore not allowed. Within B2.5, use the xerrab or xertst functions to cause the code to stop upon some error. In Eirene, the relevant routine to call is EIRENE_EXIT_OWN.
  30. Avoid special characters (accents, Greek letters, etc...) in the GIT commit messages as the GIT log is appended to the manual and the LaTeX builders may not be able to digest such entries.
  31. When introducing a new variable in Eirene, and if its use is not confined to the SOLPS-ITER interface and user routines, the code must be modified in such a way that ALL interfaces will still function, so that the new Eirene code can still pass all the CI tests managed on the Eirene JuGit repository maintained by FZJ. This may mean providing a default value for the new variable and a way to recover old behaviour when running Eirene coupled to other codes or in stand-alone mode.
  32. When adding a new integer or logical variable to the Eirene input file, if it is added to an existing input line, this must be done in a backward-compatible and compiler-safe fashion through the use of fix_integer_input and fix_logical_input calls respectively.
  33. When modifying the format of the Eirene input file, the converter program b2yt and input file builder program Uinp must also be modified to reflect this change, within the same pull request.
  34. When adding or modifying a variable in the fort.44 or fort.46 output files from Eirene, a conversion or transcription rule must be provided in b2yt_ngread or b2yt_ntread, respectively, in the same pull request, as well as a description of the changed or added variable in the SOLPS-ITER manual.
  35. In comments and printed statements, avoid the use of apostrophes, as they can be mis-interpreted as unbalanced quote characters by certain compilers.
  36. When using a mathematical or physical constant, always apply the value provided by the b2mod_constants module.
  37. When adding an input or output file to the run workflow, the run submission scripts must be adapted accordingly, as well as the list of filenames for the SimDB manifest in the b2mod_ual.F90 routine.