I usually use a preprocessor for this task:
#ifdef DEBUG subroutine test(...) #else pure subroutine(...) #endif ! ... #ifdef DEBUG write(*,*) 'Debug output' #endif ! ... end subroutine
You can then compile your code with gfortran -DDEBUG for verbose output. (In fact, I personally do not set this flag globally, but through #define DEBUG at the beginning of the file I want to debug).
I also have MACRO, which simplifies the use of debugging write statements:
#ifdef DEBUG #define dwrite write #else #define dwrite ! write #endif
In doing so, the code above comes down to:
#ifdef DEBUG subroutine test(...) #else pure subroutine(...) #endif ! ... dwrite (*,*) 'Debug output' ! ... end subroutine
You can enable the pre-processor with -cpp for -fpp and -fpp for ifort . Of course, when using .F90 or .F preprocessor is enabled by default.
source share