Skip to content

Macros: CNST removal

Alex Buccheri requested to merge macros/cnst_removal into main

Following the discussion in MR !2152 (closed) @AlexBuccheri is implementing the removal of the CNST macro by removing all instances of CNST. This MR will touch all source in src/, with a Git commit per refactored folder.

Conventions are set according to the discussion in MR !2152 (closed) and issue #773. As #773 has not yet reached a consensus amongst all developers on custom precision names vs fortran standard, I'm using the fortran standard, and accessing via the kind module. If we wish to use r8 instead of real64, this should only require a single find/replace.

Conventions Used:

CNST(0.01) -> 0.01_real64

CNST(1.d-19) -> 1.d-19_real64

CNST(1.e-19) -> 1.e-19_real64

The MR will come out of DRAFT once all source folders/files have been updated, however feel free to comment on it at any point.

Point for @micael.oliveira, global.F90 contains the private keyword (since 2005) so there's no implicit use of kinds via it. As such, I'll add use kind_oct_m in all the required modules. Ultimately, this is then trivial to either use our own definitions of precision, or globally replace kind_oct_m for the fortran standard precision.

TODOs

  • All exponents appear to be defined with e, not d. Do a second pass through the code for any CNST(1.d)
  • Do a second pass to replace all instances of .d0
  • Replace all instances of r8 with real64
  • Replace all instances of r4 with real32
  • Replace all instances of i4 and i8

In global.h:

  • Remove CNST from global.h

TODOS to Bump to a Separate MR:

- [ ] Replace CMPLX complex(8) with CMPLX complex(real64)

- [ ] Replace #define REAL_PRECISION 8 with #define REAL_PRECISION real64

- [ ] Consider redefining MPI_FLOAT, MPI_2FLOAT and MPI_CMPLX to be consistent

By extension, this means every explicit interface that contains FLOAT or CMPLX will need updating, and as Micael points out, some may require precision fro the c bindings. So this needs to be done on a case by case basis.

This MR closes !2152 (closed)

Edited by Alex Buccheri

Merge request reports