Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Is there any document that describes in detail what the debug mode is doing ?

Status
Not open for further replies.

Xueli Huo

Member
Hi,

I have a question about building CLM with debug mode on.

About debug mode, I know this from the tutorial http://www.cgd.ucar.edu/events/2019/ctsm/files/practical3-sacks.pdf
1) Debug will turn on additional error checking for issues such as division by zero and trying to access array elements outside the bounds of the array;
2) Debug is much more expensive;
3) The values of variables generated in debug mode are different from values generated in normal compiled mode.

I want to know more about what CLM debug does. Is there any document that describes in detail what debug mode really does to the source code ?

Sincerely,

Xueli
 

erik

Erik Kluzek
CSEG and Liaisons
Staff member
We don't seem to explicitly state it in the document you reference above -- but DEBUG primarily changes how the code is compiled. What it does is turn on flags that are specific to the compiler being used that turn on extra things that help to debug the code. Almost all compilers support both checking that the indices for arrays are within bounds, and turn on floating point error trapping. The best way to see what flags are turned on and what they do -- is to look at the Make.macros file in your case, find which compiler you are using and see what flags are turned on when DEBUG is activated. Then look at the documentation for your compiler on those specific flags.

How much more expensive it is in DEBUG mode will depend on the specifics of the compiler and the case. But, yes normally you only use it to actively find problems. The values are usually technically different, but should only be different to roundoff level (1.e-15 level for double-precision), so it shouldn't change the climate in a discernible way.

The other thing DEBUG mode does is it turns on some additional checks that developers have added with SHR_ASSERT calls. These checks are only turned on when DEBUG is on.
 

erik

Erik Kluzek
CSEG and Liaisons
Staff member
It checks to ensure that the value of something is what it's expected to be. And it will fail with an error if it's not.

Here's an example...


In this case it's checking that the array size for the pointer are what they are expected to be. These can be used
for lot's of different things, but a developer has to add it by hand.
 
Status
Not open for further replies.
Top