parflow / parflow

Parflow is an open-source parallel watershed flow model.
http://parflow.org
Other
163 stars 98 forks source link

Cleanup #ifdef usage #333

Open smithsg84 opened 3 years ago

smithsg84 commented 3 years ago

Would improve code if we replaced

ifdef DEPENDENCY

dependency

endif

Kinds of logic if we created functions or function pointers and put specific logic there.

To hide the some of the CUDA, KOKKOS, OMP, SAMRAI specializations.

for example in main.c for init/finalize kinds of logic. Would make main much less cluttered.

alanquits commented 2 years ago

I agree that the #ifdef usage clutters main a little bit, but it's not so bad. Adding initialize and finalize functions would move a lot of it and still be an intuitive layout, but I suspect enough variables would need to be passed around that a clean refactor would take some work.

On a related note, I've always wondered if the CLM #ifdefs could be removed by just making CLM a part of ParFlow that is always compiled. It requires a fortran compiler, but there does not seem to be any licensing restrictions and it's such a big part of ParFlow that I suspect most users would want it.