Use submodules
Description
Currently not fortran module is compiled using submodules. This makes the code unnecessarily harder to read and creates unnecessary rebuilds:
- Code is harder to read because there is little separation between interface and implementation
- Unnecessary rebuilds can occur as described in the commit message of 9c1e1be7
- Ideally there would be more separation of the interface and implementations, e.g. add an
include
folder where all the interface module are built, and all the submodules and "non-public" modules would be insrc
. Similar to C headers - This would also help create an interface for octopus so that it can be called by other libraries and languages
Standards
- module interface files are named with a suffix
_h
e.g.module_h.F90
- submodule names are named as
module_oct_m_impl
for the main submodule, and freely named for subsequent ones - in the interface module, add the
module
keyword beforesubroutine
orfunction
, and afterpure
,return_type
,recursive
, etc.
Proposal
- Moving forward, all new code will create separate
module
andsubmodule
files with the previously mentioned standards: - On new PRs, wen editing a module file that is not split, split the file before merging. Link to this PR for example on how to do so and what standards to follow
To discuss
-
Naming convention of the submodules. - Some candidates:
module_oct_m_impl
,module_oct_sm
,module_oct
,module
. All are valid as they are namespaces bymodule_oct_m
. - Invalid:
module_oct_m
. Sometimes the compiler will complain about ambiguity
- Some candidates:
-
Further separation into include
andsrc
subfolders -
Alternatives to using _inc.F90
in the module files- If we want other languages to use the interface module F90 files as headers, they should be as close to standard fortran as possible
- Of course, the current
#include
should still work for fortran projects, but it is not guaranteed it will work for creating links to other languages
News snippet
Add here a one line description to be included in the Changes page. You can delete this section if the changes are trivial and of no consequence for the users.
Checklist
-
I have checked that my code follows the Octopus coding standards -
I have added tests for all the new features added in this request.
Edited by Cristian Le