I have a main program and a module. I want the main program to use certain parts of the module under normal circumstances, but to use some added elements if compiled with a "DEBUG" cpp macro. This is the way I have found to make this work:
program myprogram
use comp_module, only: data1, routine1 &
#idef DEBUG
, debug_data, debug routine
#endif
;
....
If I don't put that semicolon in at the end, the compiler thinks it's an error when not compiled for debugging. So, this works.
It's just that it looks sort of inelegant with a leading comma in the debug line and a useless semicolon following. And I can just see some developer coming along later, not getting what's going on, and re-introducing a compiler error.
What is a better way?
In this case you can just use two separate use
declarations
use comp_module, only: data1, routine1
#idef DEBUG
use comp_module, only: debug_data, debug routine
#endif