dbcsr
dbcsr copied to clipboard
Use a centralized DEBUG flag
Drop all
LOGICAL, PARAMETER :: debug_mod = .FALSE.
LOGICAL, PARAMETER :: careful_mod = .FALSE.
....
IF (debug_mod) THEN
...
ENDIF
IF (careful_mod) THEN
...
ENDIF
@pseewald The problem is that we cannot control the parameters at the compiling time, therefore the code becomes pretty soon untested (have you ever tried to make any of those flags .TRUE.? Believe me, most of the time you will get troubles...)
My proposal is to make them always .TRUE. if NDEBUG is not set by using a centralized parameter
#ifdef NDEBUG
LOGICAL, PARAMETER :: debug = .FALSE.
#else
LOGICAL, PARAMETER :: debug = .TRUE.
#endif
Locally, for each module, you can have
LOGICAL, PARAMETER :: debug_mod = .FALSE. .OR. debug
In this way, we can overwrite the module debug and test the code. The rest of the code will remain as it is, but at least we can test it...
BTW, some of these debugs are messages, for example
IF (debug_mod) WRITE (*, '(1X,A)') routineN//" waiting for right"
I would propose to introduce a new macro (WRITE_DBG) and drop the IF...