Next: Program structure.
Up: CalculiX CrunchiX USER'S MANUAL
Previous: Network element
Contents
CalculiX CrunchiX is a mixture of FORTRAN77 (with elements from FORTRAN90) and
C. C is primarily used for automatic allocation and reallocation
purposes. FORTRAN is the first language I learned and I must admit that I'm
still a FORTRAN addict. I use C where necessary, I avoid it where
possible. Roughly
speaking, the main routine and some of the routines called by main are in C,
the others are in FORTRAN. This means that no C routine is called by a FORTRAN
routine, a FORTRAN routine
may be called by a C routine or a FORTRAN routine. There are NO commons in the
code. All data transfer is through arguments of subroutine calls. All
arguments are transferred by address, not value (there may be one or two
exceptions on this rule in the code).
In summary, the following programming rules apply:
- C calls C or FORTRAN, FORTRAN only calls FORTRAN
- Data transfer to subroutines is ALWAYS by address (not value). This
applies to the C-to-C data transfer and the C-to-FORTRAN transfer. The
reason for this rule is that FORTRAN always transfers by address.
- Subroutines should be written in lower case. Upper case variables or
mixed variables should not be used
- All FORTRAN routines are started with ``implicit none''. For choosing
names of variables, however, you should stick to the ``implicit
real(a-h,o-z)'' rule, i.e. integers start by the letters i up to n, reals by
the letters a up to h and o up to z. Characters and logicals can start by
any character. This applies to C and FORTRAN.
- In C-routines only one-dimensional arrays or scalar should be defined
and used. More-dimensional arrays should not be used in C. This is because C
and FORTRAN store more-dimensional arrays in different ways. Therefore, I
prefer to limit the use of more-dimensional arrays to the FORTRAN routines.
- In FORTRAN, common statements should not be used.
- Avoid the transfer of logical variables from C to FORTRAN.
- For sections of the code which are parallellized (multithreading):
- avoid logical variables
- avoid internal read and write statements (use the ichar function instead)
- avoid external read and write statements
This set of rules grew out of my long-year experience with C and
FORTRAN. These are personal preferences, and some of them are really useful in
order to avoid different-to-trace programming errors. If you want to
contribute to CalculiX, I expect you to adhere to these rules.
Starting with version 2.8 the environment variable
CCX_LOG_ALLOC has been introduced. If set to 1 (default is zero) one gets
detailed information on all allocated, reallocated and deallocated fields
during the executation of CalculiX. This may be particularly important during
debugging of segmentation faults.
Next: Program structure.
Up: CalculiX CrunchiX USER'S MANUAL
Previous: Network element
Contents
guido dhondt
2018-12-15