Commit 39119658 authored by miller86's avatar miller86
Browse files

changing log file behavior, minor fixes to NASTRAN, Claw

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3652 18c085ea-50e0-402c-830e-de6fd14e8384
parent 6611bb7b
......@@ -95,12 +95,13 @@ bool avtDatabase::onlyServeUpMetaData = false;
// ****************************************************************************
// The following methods are convenience methods to help database plugins
// do dynamic domain decomposion for rectilinear grids...
// do dynamic domain decomposion for rectilinear grids. There are four
// methods...
//
// DetermineRectilinearDecomposition: Used to compute domain a decomposition
// ComputeDomainLogicalCoords: Used to compute the logical indices of a domain
// ComputeDomainBounds: Used to compute spatial bounds of a domain
// RectilinearDecompCost: Used *internally* to help compute domain decomp.
// 1 DetermineRectilinearDecomposition: Used to compute a domain decomposition
// 2 ComputeDomainLogicalCoords: Used to compute the logical indices of a domain
// 3 ComputeDomainBounds: Used to compute spatial bounds of a domain
// 4 RectilinearDecompCost: Used *internally* to help compute domain decomp.
//
// DetermineRectilinearDecomposition determines the number of domains in
// each dimension to decompose the mesh into. For example, for a mesh that
......@@ -128,7 +129,7 @@ bool avtDatabase::onlyServeUpMetaData = false;
// domain in the Y axis would go from 0 to 49 while slot 1 would go from
// 50 to 99.
//
// This routines could be improved to support simple ghosting.
// These routines could be improved to support simple ghosting.
//
// ****************************************************************************
......
......@@ -299,6 +299,9 @@ $0 = shift @ARGV;
# Unset DYLD_LIBRARY_PATH on Darwin so that we can't be hit by anything the
# user might have set.
#
# Mark C. Miller, Thu Apr 3 14:54:42 PDT 2008
# Added comments regarding -debug_<compname> and -vtk-debug arguments.
#
###############################################################################
use POSIX qw(ceil);
......@@ -630,7 +633,17 @@ $fullusage = "$usage
Note: Debugging options may degrade performance
---------------------------------------------------------------------------
-debug <level> Run with <level> levels of output logging.
<level> must be between 1 and 5.
<level> must be between 1 and 5. This will generate
debug logs for ALL components.
-debug_<compname> <level> Run specified component with <level> of output
logging. For example, '-debug_mdserver 4' will run
the mdserver with level 4 debugging. Multiple
'-debug_<compname> <level>' args are allowed.
-clobber_vlogs By default, each invokation or restart of a VisIt
component will write its debug logs to new files.
This flag causes VisIt to overwrite existing debug
logs rather than creating new ones.
-vtk-debug Turn on debugging of vtk objects used in pipelines.
-pid Append process ids to the names of log files.
-timing Save timing data to files.
-withhold-timing-output
......
......@@ -41,6 +41,8 @@
#if defined(_WIN32)
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include <signal.h>
......@@ -483,12 +485,43 @@ DebugStream::~DebugStream()
// Change the DebugStreamBuf member to be a pointered value instead of a
// referenced value so that it works with the MIPSpro compiler.
//
// Mark C. Miller, Thu Apr 3 13:39:55 PDT 2008
// Change the extension from '.log' to '.vlog'. Made it loop to find
// a unique filename.
//
// ****************************************************************************
void
DebugStream::open(const char *progname)
DebugStream::open(const char *progname, bool clobber)
{
char filename[256];
sprintf(filename, "%s.%d.log", progname, level);
sprintf(filename, "%s.%d.vlog", progname, level);
// only search for a unique name if we don't have pids
bool findUnique = !clobber && strspn(filename, ".0123456789") == 0;
// loop until we create a name for which stat returns 0
int n = 1;
while (findUnique)
{
// We don't use VisItStat() here to avoid lib interdependence. Also,
// we don't really need to worry about the 32/64 bit file size issue
// for log files.
#if defined(_WIN32)
struct _stat stbuf;
if (_stat(filename, &stbuf) != 0)
break;
#else
struct stat stbuf;
if (stat(filename, &stbuf) != 0)
break;
#endif
sprintf(filename, "%s.%d.%d.vlog", progname, level, n);
n++;
}
// ok, open the stream
buf->open(filename);
enabled = true;
}
......@@ -564,19 +597,20 @@ DebugStream::close()
// ****************************************************************************
void
DebugStream::Initialize(const char *progname, int debuglevel, bool sigs)
DebugStream::Initialize(const char *progname, int debuglevel, bool sigs,
bool clobber)
{
switch (debuglevel)
{
case 5: debug5_real.open(progname);
case 5: debug5_real.open(progname, clobber);
/* FALLTHRU */
case 4: debug4_real.open(progname);
case 4: debug4_real.open(progname, clobber);
/* FALLTHRU */
case 3: debug3_real.open(progname);
case 3: debug3_real.open(progname, clobber);
/* FALLTHRU */
case 2: debug2_real.open(progname);
case 2: debug2_real.open(progname, clobber);
/* FALLTHRU */
case 1: debug1_real.open(progname);
case 1: debug1_real.open(progname, clobber);
break;
default:
break;
......
......@@ -94,9 +94,9 @@ class MISC_API DebugStream : public ostream
~DebugStream();
operator bool() {return enabled;};
void open(const char *progname);
void open(const char *progname, bool);
void close();
static void Initialize(const char *, int, bool=true);
static void Initialize(const char *, int, bool=true, bool=false);
private:
class DebugStreamBuf : public streambuf
{
......
......@@ -208,36 +208,45 @@ Init::Initialize(int &argc, char *argv[], int r, int n, bool strip, bool sigs)
#else
bool usePid = false;
#endif
bool clobberVlogs = false;
bool vtk_debug = false;
bool enableTimings = false;
for (i=1; i<argc; i++)
{
if (strcmp("-debug",argv[i]) == 0)
if (strncmp("-debug",argv[i],6) == 0)
{
debuglevel = 1;
if (i+1 < argc && isdigit(*(argv[i+1])))
debuglevel = atoi(argv[i+1]);
else
cerr << "Warning: debug level not specified, assuming 1\n";
if (debuglevel > 5)
{
cerr << "Warning: clamping debug level to 5\n";
debuglevel = 5;
}
if (debuglevel < 0)
{
cerr << "Warning: clamping debug level to 0\n";
debuglevel = 0;
}
if(strip)
{
striparg(i,2, argc,argv);
--i;
}
else
{
++i;
}
if ((strlen(argv[i]) > 7 && IsComponent(&argv[i][7])) ||
strlen(argv[i]) == 6)
{
debuglevel = 1;
if (i+1 < argc && isdigit(*(argv[i+1])))
debuglevel = atoi(argv[i+1]);
else
cerr << "Warning: debug level not specified, assuming 1\n";
if (debuglevel > 5)
{
cerr << "Warning: clamping debug level to 5\n";
debuglevel = 5;
}
if (debuglevel < 0)
{
cerr << "Warning: clamping debug level to 0\n";
debuglevel = 0;
}
if(strip)
{
striparg(i,2, argc,argv);
--i;
}
else
{
++i;
}
}
}
else if (strcmp("-clobber_vlogs", argv[i]) == 0)
{
clobberVlogs = true;
}
else if (strcmp("-pid", argv[i]) == 0)
{
......@@ -308,7 +317,7 @@ Init::Initialize(int &argc, char *argv[], int r, int n, bool strip, bool sigs)
// Initialize the debug streams and also add the command line arguments
// to the debug logs.
DebugStream::Initialize(progname, debuglevel, sigs);
DebugStream::Initialize(progname, debuglevel, sigs, clobberVlogs);
for(i = 0; i < argc; ++i)
debug1 << argv[i] << " ";
debug1 << endl;
......
......@@ -310,7 +310,7 @@ SortFilenames(vector<string> &fnames, string cycleRegex)
// Added support for 'ndims' header info
//
// ****************************************************************************
static bool
static void
ReadTimeStepHeader(string rootDir, string fileName, TimeHeader_t *hdr)
{
char buf[2048];
......@@ -399,7 +399,7 @@ DataSegmentLengthInChars(const GridHeader_t *ghdr, int ndims)
// Mark C. Miller, Tue Sep 18 11:08:52 PDT 2007
// Changed naux to ndims
// ****************************************************************************
static bool
static void
ReadGridHeader(int fd, int offset, const TimeHeader_t* thdr, GridHeader_t *ghdr, int *nextoff)
{
char buf[2048];
......@@ -492,7 +492,7 @@ ReadGridHeader(int fd, int offset, const TimeHeader_t* thdr, GridHeader_t *ghdr,
// Creation: September 13, 2007
//
// ****************************************************************************
static int
static void
ReadGridHeaders(string rootDir, string fileName, const TimeHeader_t *thdr,
vector<GridHeader_t> &gridHeaders, map<int, GridHeader_t> &gridHeaderMap)
{
......
......@@ -50,6 +50,7 @@
#include <vtkFloatArray.h>
#include <vtkUnstructuredGrid.h>
#include <avtCallback.h>
#include <avtDatabaseMetaData.h>
#include <InvalidVariableException.h>
......@@ -58,6 +59,7 @@
#include <TimingsManager.h>
#include <DebugStream.h>
#include <Utility.h>
#include <snprintf.h>
//
// NASTRAN models have a node id associated with each vertex and that nodeid
......@@ -171,6 +173,60 @@ avtNASTRANFileFormat::ActivateTimestep()
#endif
}
// ****************************************************************************
// Function: Getf
//
// Purpose: Robust way of reading string for float value
//
// Programmer: Mark C. Miller, Thu Apr 3 16:27:01 PDT 2008
// ****************************************************************************
static float Getf(const char *s)
{
char *ends;
errno = 0;
double val = strtod(s, &ends);
if (errno != 0)
{
char msg[512];
SNPRINTF(msg, sizeof(msg),
"Error \"%s\" at word \"% 32s\"\n", strerror(errno), s);
if (!avtCallback::IssueWarning(msg))
cerr << msg << endl;
return 0.0;
}
return (float) val;
}
// ****************************************************************************
// Function: Geti
//
// Purpose: Robust way of reading string for integer value
//
// Programmer: Mark C. Miller, Thu Apr 3 16:27:01 PDT 2008
// ****************************************************************************
static int Geti(const char *s)
{
char *ends;
errno = 0;
long val = strtol(s, &ends, 10);
if (errno != 0)
{
char msg[512];
SNPRINTF(msg, sizeof(msg),
"Error \"%s\" at word \"% 32s\"\n", strerror(errno), s);
if (!avtCallback::IssueWarning(msg))
cerr << msg << endl;
return 0;
}
return (int) val;
}
// ****************************************************************************
// Method: avtNASTRANFileFormat::ReadFile
//
......@@ -262,24 +318,24 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
ifile.getline(line + 72, 1024-72);
#define LONG_FIELD_WIDTH 16
char *valstart = line + 81;
pt[2] = atof(valstart);
char *valstart = line + 81 - 1;
pt[2] = Getf(valstart);
valstart = line + 72 - LONG_FIELD_WIDTH+1;
valstart = line + 72 - LONG_FIELD_WIDTH+1 - 1;
char *valend = line + 72;
*valend = '\0';
pt[1] = atof(valstart);
pt[1] = Getf(valstart);
valstart -= LONG_FIELD_WIDTH;
valend -= LONG_FIELD_WIDTH;
*valend = '\0';
pt[0] = atof(valstart);
pt[0] = Getf(valstart);
#ifdef USE_POINT_INDICES_TO_INSERT
valstart -= (2 * LONG_FIELD_WIDTH);
valend -= (2 * LONG_FIELD_WIDTH);
*valend = '\0';
int psi = atoi(valstart)-1;
int psi = Geti(valstart)-1;
if(psi < nPoints)
pts->SetPoint(psi, pt);
......@@ -311,17 +367,17 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
char *valend = line + 48;
*valend = '\0';
pt[2] = atof(valstart);
pt[2] = Getf(valstart);
valstart -= SHORT_FIELD_WIDTH;
valend -= SHORT_FIELD_WIDTH;
*valend = '\0';
pt[1] = atof(valstart);
pt[1] = Getf(valstart);
valstart -= SHORT_FIELD_WIDTH;
valend -= SHORT_FIELD_WIDTH;
*valend = '\0';
pt[0] = atof(valstart);
pt[0] = Getf(valstart);
#if 0
debug4 << pt[0] << ", " << pt[1] << ", " << pt[2] << endl;
......@@ -330,7 +386,7 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
valstart -= (2 * SHORT_FIELD_WIDTH);
valend -= (2 * SHORT_FIELD_WIDTH);
*valend = '\0';
int psi = atoi(valstart)-1;
int psi = Geti(valstart)-1;
if(psi < nPoints)
pts->SetPoint(psi, pt);
......@@ -361,11 +417,11 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
char *valstart = line + 88;
char *valend = valstart;
verts[7] = atoi(valstart)-1;
verts[7] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[6] = atoi(valstart)-1;
verts[6] = Geti(valstart)-1;
// Skip the blank
valstart -= INDEX_FIELD_WIDTH;
......@@ -374,32 +430,32 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[5] = atoi(valstart)-1;
verts[5] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[4] = atoi(valstart)-1;
verts[4] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[3] = atoi(valstart)-1;
verts[3] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[2] = atoi(valstart)-1;
verts[2] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
ugrid->InsertNextCell(VTK_HEXAHEDRON, 8, verts);
......@@ -419,21 +475,21 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
{
char *valstart = line + 48;
char *valend = valstart;
verts[3] = atoi(valstart)-1;
verts[3] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[2] = atoi(valstart)-1;
verts[2] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
#if 0
debug4 << verts[0]
......@@ -449,26 +505,26 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
{
char *valstart = line + 56;
char *valend = valstart;
verts[4] = atoi(valstart)-1;
verts[4] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[3] = atoi(valstart)-1;
verts[3] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[2] = atoi(valstart)-1;
verts[2] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
#if 0
debug4 << verts[0]
......@@ -485,31 +541,31 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
{
char *valstart = line + 64;
char *valend = valstart;
verts[5] = atoi(valstart)-1;
verts[5] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[4] = atoi(valstart)-1;
verts[4] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[3] = atoi(valstart)-1;
verts[3] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[2] = atoi(valstart)-1;
verts[2] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
#if 0
debug4 << verts[0]
<< ", " << verts[1]
......@@ -525,21 +581,21 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
{
char *valstart = line + 48;
char *valend = valstart;
verts[3] = atoi(valstart)-1;
verts[3] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[2] = atoi(valstart)-1;
verts[2] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
#if 0
debug4 << verts[0]
......@@ -556,16 +612,16 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
{
char *valstart = line + 40;
char *valend = valstart;
verts[2] = atoi(valstart)-1;
verts[2] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
valend -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
#if 0
debug4 << verts[0]
<< ", " << verts[1]
......@@ -579,11 +635,11 @@ avtNASTRANFileFormat::ReadFile(const char *name, int nLines)
{
char *valstart = line + 32;
char *valend = valstart;
verts[1] = atoi(valstart)-1;
verts[1] = Geti(valstart)-1;
valstart -= INDEX_FIELD_WIDTH;
*valend = '\0';
verts[0] = atoi(valstart)-1;
verts[0] = Geti(valstart)-1;
#if 0
debug4 << verts[0]
......
......@@ -324,6 +324,8 @@ Engine *Engine::Instance()
// Removed a lingering cerr message showing the MPI rank of the engine
// process.
//
// Mark C. Miller, Thu Apr 3 14:36:48 PDT 2008
// Moved setting of component name to before Initialize
// ****************************************************************************
void
Engine::Initialize(int *argc, char **argv[], bool sigs)
......@@ -346,12 +348,12 @@ Engine::Initialize(int *argc, char **argv[], bool sigs)
//
// Initialize error logging