[cig-commits] r14239 - long/3D/SNAC/trunk/StGermain/Base/IO/src
echoi at geodynamics.org
echoi at geodynamics.org
Fri Mar 6 08:53:19 PST 2009
Author: echoi
Date: 2009-03-06 08:53:19 -0800 (Fri, 06 Mar 2009)
New Revision: 14239
Modified:
long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.c
long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.h
Log:
* Created Journal_OptFirewall()
to catsh nan or inf in the computed values
even in the optimised mode.
Modified: long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.c
===================================================================
--- long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.c 2009-03-06 00:49:00 UTC (rev 14238)
+++ long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.c 2009-03-06 16:53:19 UTC (rev 14239)
@@ -587,11 +587,11 @@
{
va_start( ap, fmt );
/*
- Journal_Printf( stream, "Expression: %s\n", expressionText );
- Journal_Printf( stream, "From File: %s\n", file );
- Journal_Printf( stream, " Function: %s\n", func );
- Journal_Printf( stream, " Line: %d\n", line );
-*/
+ Journal_Printf( stream, "Expression: %s\n", expressionText );
+ Journal_Printf( stream, "From File: %s\n", file );
+ Journal_Printf( stream, " Function: %s\n", func );
+ Journal_Printf( stream, " Line: %d\n", line );
+*/
result = Stream_Printf( stream, fmt, ap );
Stream_Flush( stream );
@@ -621,6 +621,62 @@
return result;
}
+int Journal_OptFirewall( int expression, void* _stream, const char* file, const char* func, int line, char* fmt, ... )
+{
+ int result = 0;
+ Stream* stream = (Stream*)_stream;
+ int nProc = 0;
+
+ va_list ap;
+
+ MPI_Comm_size( MPI_COMM_WORLD, &nProc );
+
+ if ( expression )
+ {
+ /* Every thing is OK! Back to work as normal */
+ return 0;
+ }
+
+ Stream_Enable( stream, True ); /* Enforce enabling of stream because we really do want to see this */
+
+ if ( stJournal->enable && Stream_IsEnable( stream ) )
+ {
+ va_start( ap, fmt );
+
+ result = Stream_Printf( stream, fmt, ap );
+ Stream_Flush( stream );
+
+ va_end(ap);
+ }
+
+ if ( stJournal->firewallProducesAssert == True ) {
+/* Journal_Printf( stream, "Expression: %s\n", expressionText ); */
+ Journal_Printf( stream, "From File: %s\n", file );
+ Journal_Printf( stream, " Function: %s\n", func );
+ Journal_Printf( stream, " Line: %d\n", line );
+ __assert_fail("expression hidden", file, line, func);
+/* assert( expression ); */
+ }
+ else {
+ /* TODO: Don't use FAILURE until Pat beef's up the test scripts to do .error checks
+ exit( EXIT_FAILURE );
+ */
+
+ // SGI MPI on the ess does not always print out everything before it exits
+ // To ensure all output is displayed before the program quits on firewall, sleep for one second
+ // Alan & Kath 20061006
+ sleep( 1 );
+ if ( nProc == 1 ) {
+ exit(EXIT_SUCCESS);
+ }
+ else {
+ MPI_Abort( MPI_COMM_WORLD, EXIT_SUCCESS );
+ }
+ }
+
+ return result;
+}
+
SizeT Journal_Write( void* _stream, void* data, SizeT elem_size, SizeT num_elems )
{
Stream* stream = (Stream*)_stream;
Modified: long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.h
===================================================================
--- long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.h 2009-03-06 00:49:00 UTC (rev 14238)
+++ long/3D/SNAC/trunk/StGermain/Base/IO/src/Journal.h 2009-03-06 16:53:19 UTC (rev 14239)
@@ -224,6 +224,7 @@
/* Temporary revert back to old protoype to avoid compilation issues. Need to fix. */
int Journal_Firewall( int expression, void* stream, char* fmt, ... );
+ int Journal_OptFirewall( int expression, void* stream, const char* FILE, const char* func, int LINE, char* fmt, ... );
#ifdef DEBUG
/** Performs a Journal_Firewall() only if DEBUG is defined. */
@@ -233,6 +234,7 @@
* Compilers won't compile if (0) code even without optimisation options
*/
#define Journal_DFirewall if (0) Journal_Firewall
+ #define Journal_OFirewall Journal_OptFirewall
#endif
/** Performs a write() to the given stream.
More information about the CIG-COMMITS
mailing list