Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
Coding Style
Expand | |||||
---|---|---|---|---|---|
Use uppercase for all Fortran instructions, variable names Use lowercase for pre-compiler directives Comments should be written in English only (uppercase & lowercase accepted) Tabulations are forbidden (to be replaced by spaces at the beginning of line) Use meaningful names for variables, in English, keep the same name throughout the code Systematically indent your blocks ( In case of long
|
Routine & file organisation
Expand |
---|
By default, one file contains only one subroutine or function, except when the understanding of the code is facilitated by grouping few procedures The same rule applies for modules: one module per file, same name For module several subroutines can be defined under the |
Header definition
Expand | ||
---|---|---|
Each source file should have the copyright notice Each procedure needs to have a conforming header, containing by order of appearance:
|
Comments
Expand | |||||
---|---|---|---|---|---|
It is important to comment algorithms, especially when non straightforward coding is used Comments are written in English Comments respect Fortran90 standard. The use of " Except for preprocessor directives, the following characters Example:
|
Modules
Expand | |||||
---|---|---|---|---|---|
Module FormatGeneric format of a Fortran90 module is as follows:
Naming ConventionModule name is defined as follows: With module file name: modulename_mod.F Module file is placed at the same location as other files used by the option Restart VariablesAll the variables communicated between Starter and Engine are declared in module Interface definitionFortran90 interface allows the compiler to do additional checks like coherency between argument types, attributes and number between calling and callee routines. It is required in some cases like when a procedure has a dummy argument with attribute In practice, it was introduced in few places of the code for routines which were called at several different places Such coherency is automatically tested by QA static analysis tools (Forcheck). And for pointer, good practice is to use derived data types instead of pointer directly Therefore, the remaining use of interface is regarding routine with optional arguments This feature should be spread in the code instead of adding additional “dummy” arguments |
Memory Allocation
Expand | ||||||
---|---|---|---|---|---|---|
Dynamic memory allocation mechanismLarge arrays should be allocatable arrays: Avoid using pointer when possible, and do not use automatic arrays. Arrays should be explicitly deallocated as soon as possible Developers are required to check the success of the allocation For large arrays it is preferred to print a specific message, with some advice for the user, or at least the option concerned by this failure Nevertheless, there are macros that will check and print a generic error message
See my_allocate.inc in GitHub for the definitions Global MemoryMemory allocation of global data structures, arrays and derived data types, should be done at the highest level, in It is advised to use derived data type with structure of arrays. This way it is possible to declare the variable at the upper level, gather the allocation of array members in a dedicated subroutine, then use the variable in procedures called at lower level without losing traceability Local MemoryIn a procedure, local variable allocation method depends on its size:
It is allowed to use In case of multiple calls to Shared Memory Programming (SMP) and memory allocationFor OpenRadioss Engine, OpenMP programming model is used for second level parallelization By default any memory allocation done outside of a parallel section is shared between threads Most of the parallel sections are started from The same way, any variable defined in a common or module is shared by default For pointer, notice that a single thread needs to allocate and deallocate it. Synchronization may be needed after the allocation and before the deallocation The Array Aliasing
Example:
|
\uD83D\uDCCB Related articles
OpenRadioss HMPP Development InsightsOpenRadioss Coding Standards
OpenRadioss Performance Aspects: Vectorization and Optimization
OpenRadioss Performance Aspects: Parallelism
OpenRadioss Coding: Additional Considerations
OpenRadioss Reader (Radioss Block Format)