Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
Introduction
Expand |
---|
Radioss is mostly written using Fortran language, Fortran77 and Fortran90 https://fortran-lang.org A few low level routines are written in C Thanks to architecture convergence, x86-64 under Linux and Windows, Radioss compilation relies on Intel compilers ifort and icc The aim of this document is not to paraphrase the Fortran documentation but to give clear recommendations and advices about developing Radioss code OpenRadioss contributors should read and understand this documentation and apply the rules defined hereafter Radioss development should be focused towards performance and efficiency of the code written. Recommendations to help write efficient code are widely explained throughout these pages |
Programming Languages
Expand | ||
---|---|---|
Fortran LanguageFortran90 is the programming language used for Radioss development, including memory management (since the Altair commercial Radioss release v51) The documentation of this compiler is given here: https://software.intel.com/en-us/intel-fortran-compiler-17.0-user-and-reference-guide
C LanguageC routines deal with low level I/O, system calls, library interface (CUDA) only Reference manual: https://software.intel.com/en-us/intel-cplusplus-compiler-17.0-user-and-reference-guide |
Precompiler Directives
Expand |
---|
Fortran files are of type foo.F. Fortran precompiler is automatically called Therefore, it is forbidden to name a file .f or .f90 In particular the below directives are in use: Examples:
|
IMPLICIT NONE
Expand |
---|
For historical reasons, (in the past it was not supported everywhere) IMPLICIT NONE is automatically added to the source via a specific include implicit_f.inc. Its usage forces the programmer to declare every variable Every Radioss Fortran routine needs to include implicit_f.inc |
Fixed Format
Expand |
---|
To keep coherency between original code and new code, only fixed format is allowed, extended to 132 columns Comments need to begin with They can be placed anywhere ( Several instructions per line are allowed using |
Fortran95, Fortran2003, Fortran2008 Extensions
Expand |
---|
Intrinsic functions are allowed, especially Other Fortran95 extensions are refused Fortran2003 and Fortran2008 extensions are refused |
Fortran 90 Restrictions
Expand |
---|
Object oriented features like operator overloading are forbidden as they can highly penalize performance Array manipulation, and especially non-contiguous section as subroutine argument is forbidden (assumed-shape-array) Array reduction and special functions like |
Fortran 77 Extensions
Expand |
---|
Fortran77 extensions which are not Fortran90 standard are refused |
Obsolete Fortran 77 coding
Expand |
---|
EQUIVALENCE
Use There is an ongoing effort to clean out the remaining instances in the code COMMON
For new development, Current/existing SAVE
Multiple RETURNMultiple GOTOThe use of DO loop with label
|
Data Types
Expand | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
IntegerAll integers are by default 32-bit integers ( Where it is required 64-bit integer ( Use of RealReals can be either 32-bit simple precision or 64-bit double precision reals Real variables need to be declared as my_real.inc is automatically included together with implicit_f.inc to define The pre-compiler automatically replaces
Example:
For some exceptions, it is sometimes needed to explicitly use Such exceptions are limited in the source code Logical
In particular, it is forbidden to use “ Derived data typeDerived data type is one of the main improvements of Fortran90 standard The use of derived data types is strongly encouraged (see OpenRadioss Coding Recommendations ). Derived data type allows to define new structured types The name of a new type should use suffix Example:
Intrinsic functionsProgrammers are only allowed to use generic functions compatible with both single and double precision: Explicitly typed functions are prohibited: Numerical constantsAll real constant variables are declared inside constant.inc common and initialized using Examples: Forbidden:
Allowed:
Zero & infinite valuesTo avoid division by zero, it is advised to test against To avoid infinite value test against These values are generally a good compromise for both double and single precision It is always possible to check version precision using flag
Bitwise logical operationsSemantic of bitwise logical operators like Note: |
Interfacing Fortran and C
Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Calling conventionThere is no standard calling convention between Fortran and C Here is described the way it is handled in Radioss by defining every potential calling convention Notice that the importance of this specific point is decreasing with the number of architectures and compilers supported Fortran 90 calling routine:
C callee routine:
Argument variable correspondence
Examples of type definition under Linux and Windows
|
Specific code management
Expand |
---|
For some reason, some code may depend on a specific architecture or compiler. In this case, such code is gathered into a unique directory (one for Starter and one for Engine) called spe and spe_inc for include files The rest of the code needs to be machine independent. This facilitates porting to new machine or compiler The specific part of the code is managed by the precompiler using The different supported architectures are defined under hardware.inc A clean up of the supported architecture must be scheduled |