6. Use by the developer#

In programming, we avoid using very low level macros.

For example, in C, we never use ASTER_INT_SIZE (the number of bytes used for an integer) but the associated type. And for this type, we don’t use ASTERC_FORTRAN_INT but the « internal » name: INTEGER.

Likewise in Fortran, you don’t use ASTER_INT_SIZE directly, but the values defined in aster_types.h.

6.1. Types to use in C#

We include the aster.h general header file (which includes aster_depend.h). We then have access to the types mentioned above: INTEGER, INTEGER4,,, DOUBLE, REAL4, STRING_SIZE.

6.2. Types to use in Fortran#

We include the aster_types.h header file which defines:

  • aster_int_kind

  • aster_int

as well as to_aster_int conversion functions.

Similar conversion types and functions are defined: med_int, mpi_int, mumps_int, blas_int and therefore to_mpi_int, etc.

Care is taken to use these types in functions that exchange data with external libraries.

6.3. Error and exception handling in C#

In Fortran, we have the macro ASSERT which checks a condition and stops in error when it is not verified by indicating the location in the source.

To emit an error message in C, we use the macro MYABORT, which allows you to raise an exception to properly stop the calculation.

The exception mechanism is emulated in C code by relying on the setjmp and longjmp system functions.

Writing is simplified by using macros: try, except, exceptAll, endTry. As well as RaiseException and RaiseExceptionString to raise an exception.

See the aster_exceptions.c module for an example.

6.4. Fortran utility macros#

  • ASSERT (condition): emits an error message if the condition is not met by indicating the name of the file and the line of code where the check was done.

  • TO_STRING (code): replace code with a character string, usable in other macros (example in ASSERT).