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.
- 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, andfeature/wg-releasebranches. 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. - 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.
- 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.
- 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.
- 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 theb2input.xmlfile, lines should begin with tabs, as these are used by the Python script that buildsb2cdci.Fandb2cdcn.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. - In addition, changes to the default values of switches need to be explicitly mentioned in the commit message.
- 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. - 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 runMakefile(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. - 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!).
- If a new module is introduced, its location must be added to the
src/modules/.new_modulesfile, for compilation purposes, within the same commit, so that theMakefileis aware of the need to rebuild thedependenciesfile. - 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. - 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
dbversioninb2mds.Fmust be incremented and a description of the change given in the comments above the setting ofdbversion. The MDSplus tree file descriptions in$SOLPSTOP/doc/solps/MDSPLUSmay also need to be updated. - 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 theb2cdcr.Ffile, within the same commit. In general, the name of any new routine and its subroutine statement must be on the same line, so that thetagsapplication inemacswill 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.calland the name of the subroutine being called should be kept together. - If a new main variable is added, its description and use shall be included in the
b2cdcv.Ffile, within the same commit. - If a new script is added, it shall be listed and described in the SOLPS-ITER manual, within the same commit.
- If a new b2plot function is added, it must be added to the list in
b2mod_b2plot_help.Fand described in the SOLPS-ITER manual, within the same pull request. - When adding a
use modulestatement, and if the module is to be obtained from an outside library, an! IGNOREcomment must be added at the end of the line so it is not included when building thedependenciesfiles. - 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
-DLEGACYCOMPpre-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. - 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.
- Double-precision real numerical values inside B2.5 and Carre should be written as
0.0_R8, NOT0.,0.0,0.0e0, or0.0d0. In Eirene, they should be written as0.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. - Do not use hash characters (
#) as continuation characters in Fortran 77 files, as these are misinterpreted by the pre-processor. - If the real result of a ratio of two integers is needed, use the
rratio(m,n)function provided within the B2.5 code. - 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. - 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
IFstatements should be kept consistent within the same file to maintain good code readability. - Within modules, individual subroutines and functions must be terminated with either an
END SUBROUTINEorEND FUNCTIONstatement, respectively. Some compilers will fail if onlyENDis 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. - The use of
ENTRYstatements must be avoided. Instead, it is recommended to create a module that contains the entries as separate subroutines. - The use of
GOTOstatements should be avoided and substituted bySELECT CASEorIFstatements whenever possible. - Statement functions should be avoided and substituted by external or contained functions.
- The use of
stopstatements within B2.5 or Eirene is not MPI-compliant and therefore not allowed. Within B2.5, use thexerraborxertstfunctions to cause the code to stop upon some error. In Eirene, the relevant routine to call isEIRENE_EXIT_OWN. - 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.
- 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.
- 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_inputandfix_logical_inputcalls respectively. - 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.
- When adding or modifying a variable in the
fort.44orfort.46output files from Eirene, a conversion or transcription rule must be provided inb2yt_ngreadorb2yt_ntread, respectively, in the same pull request, as well as a description of the changed or added variable in the SOLPS-ITER manual. - In comments and printed statements, avoid the use of apostrophes, as they can be mis-interpreted as unbalanced quote characters by certain compilers.
- When using a mathematical or physical constant, always apply the value provided by the
b2mod_constantsmodule. - 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.F90routine.