danieljprice / phantom

Phantom Smoothed Particle Hydrodynamics and Magnetohydrodynamics code
https://phantomsph.github.io
Other
108 stars 238 forks source link

remove #ifdefs from phantom #55

Open danieljprice opened 4 years ago

danieljprice commented 4 years ago

ifdefs look horrible in the code, and make testing all possible compile-time combinations very difficult. We should avoid introducing any new #ifdefs, preferencing use of the logical flags from the config module where possible, e.g. if (mhd), if (radiation) etc.

Many of these could also be made into runtime options, since they are mainly there to determine whether memory is allocated for certain arrays. This would need a bit more thought.

For now, we should try to keep as many files as .f90 as possible, rather than .F90, to disallow the use of ugly and unnecessary #ifdef statements. The only allowed use case for #ifdefs should be for linking with external libraries, e.g. MPI, or when the performance really matters (e.g. use of #ifdef PERIODIC in dens, force or kdtree)

danieljprice commented 6 months ago

Current status:

Number of source files (.f90, .F90):      442
Number of .f90 files               :      380
Number of .F90 files               :       62
Number of unique #ifdef statements :       48
Number of total  #ifdef statements :      526