-
Notifications
You must be signed in to change notification settings - Fork 392
Debugging Tips
The Microsoft Visual Studio C++ compiler has a way to stop on a NAN (usually shown as a -1.#IND) no matter where or when it is generated. I would expect other compilers do also. To cause it to stop on NAN the /fp:strict should be used as shown at:
http://stackoverflow.com/questions/4454582/visual-studio-c-2008-2010-break-on-float-nan
Right click on energyplus in Solution Explorer, click properties, under C/C++ -> Code Generation -> Floating Point Model set to "Strict (/fp:strict)". Repeat this for energypluslib in the Solution explorer.
I could not get it to work by just putting it into the Visual Studio GUI and instead put it on the
CMAKE_CXX_FLAGS CMAKE_C_FLAGS
variables in CMake.
In addition, I had add the fp_control_state to main.cc:
int
main( int argc, const char * argv[] )
{
unsigned int fp_control_state = _controlfp( _EM_INEXACT, _MCW_EM );
ProcessArgs( argc, argv );
EnergyPlusPgm();
}
The line that sets fp_control_state is commented out in the code base -- remove the comments to build with fp:strict to catch NANs.
The library used as as part of converting EnergyPlus from Fortran to C++ is called Objexx and uses arrays that are difficult to understand during debugging in Microsoft Visual Studio. To overcome this issue copy the file from the repository at:
- third_party/ObjexxFCL/visualizer/Array.natvis
Into the local directory on your computer:
- My documents\Visual Studio 2013\Visualizers
- My documents\Visual Studio 2015\Visualizers
This should show the values of these Objexx array the next time you debug EnergyPlus in Microsoft Visual Studio.