- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a program I am debugging in which I have some data written to an output file. However when I am testing to code I don't really need those extra files slowing me down. I would like to not execute those write commands when I compile in RELEASE mode, but I often forget to comment out those lines before I compile. I've seen in some C programs I work with techniques to execute certain lines of code depending on the compiler options selected.
Does any one know a way to specify a line of code so that it is only compiled when the compiler is in DEBUG mode, but it does not compile in RELEASE mode?
Does any one know a way to specify a line of code so that it is only compiled when the compiler is in DEBUG mode, but it does not compile in RELEASE mode?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your debugproject settings Fortran->Preprocessor->Preprocessor Definitions put DEBUG
Then in your code put :
!DEC$ IF DEFINED (DEBUG)
code to execute indebug mode only
!DEC$ ELSE
!DEC$ ENDIF
Les
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your debugproject settings Fortran->Preprocessor->Preprocessor Definitions put DEBUG
Then in your code put :
!DEC$ IF DEFINED (DEBUG)
code to execute indebug mode only
!DEC$ ELSE
!DEC$ ENDIF
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is also a project properties setting, fortran / language / compile lines with "D" in column 1 / boolean
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In addition to the compiler directives to control active code, we also use an integer or logical flag to control debugging and log file output. I like an integer variable so that levels or amounts of debugging output can be controlled as needed. Depending on how you are running the program, you can control the integer output flag from a command line input, a value from an input file, or even a slider bar in a GUI. Since we often have a GUI written in another language like Visual Basic, it is convenient to get debugging output from the release version by using our log file. Perhaps this approach would also be helpful for you.
Regards,
Greg
In addition to the compiler directives to control active code, we also use an integer or logical flag to control debugging and log file output. I like an integer variable so that levels or amounts of debugging output can be controlled as needed. Depending on how you are running the program, you can control the integer output flag from a command line input, a value from an input file, or even a slider bar in a GUI. Since we often have a GUI written in another language like Visual Basic, it is convenient to get debugging output from the release version by using our log file. Perhaps this approach would also be helpful for you.
Regards,
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The "D Lines" feature is for fixed-form source only. I do not recommend its use. The conditional compilation directives are the best choice.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page