Skip to content

Draft: Complete Removal of CNST Macro

Alex Buccheri requested to merge refactor/remove_cnst into main

Exploratory attempt at removing all instances of the CNST macro from the electrons folder.

Find/replace done with sed (on Mac), using:

# Pure numerical matches
for file in electrons/*.F90; do sed -i '' -E 's/CNST\(\s*([+-]?[0-9]+(\.[0-9]+)?)\s*\)/\1d0/g' "$file"; done

# For CNST with exponents
for file in electrons/*.F90; do sed -i '' -E 's/CNST\(\s*([0-9.e+-]+)\s*\)/\1/g' "$file"; done

which I shamelessly generated with GPT.

Questions

  • Do the replacements look reasonable?
  • Am I missing any fringe cases.
  • Should we roll the changes to all subfolders in a single MR, or multiple MRs?

My suggestion would be to remove all instances of CNST, then kill the macro in global.h, then migrate to the precision defined by the iso standard (at which point we could also kill or replace FLOAT).

Also tagging @sohlmann just in case he currently checks e-mails/wants to throw in an opinion.

Edited by Alex Buccheri

Merge request reports