Commit 23f45aa0 authored by Deike Kleberg's avatar Deike Kleberg
Browse files

Bugfix in readGetBuffers(), replaced abort() with exit.

parent 771be69e
......@@ -104,8 +104,8 @@ int main (int argc, char *argv[])
{
enum {
nProcsIO = 1,
IOMode = PIO_NONE,
//IOMode = PIO_MPI,
//IOMode = PIO_NONE,
IOMode = PIO_MPI,
//IOMode = PIO_FPGUARD,
//IOMode = PIO_ASYNCH,
//IOMode = PIO_WRITER,
......
......@@ -10,7 +10,7 @@
#include "pio_c_temp.h"
#include "pio_util.h"
extern int reshArrayCompare ( int, int );
extern int reshListCompare ( int, int );
extern void reshPackBufferCreate ( char **, int *, MPI_Comm );
extern void reshPackBufferDestroy ( char ** );
extern void rpcUnpackResources ( char *, int, MPI_Comm );
......
......@@ -24,8 +24,8 @@ size_t getpagesize(void);
#include "namespace.h"
#include "pio.h"
#include "pio_comm.h"
#include "pio_util.h"
#endif
#include "pio_util.h"
#if ! defined(O_BINARY)
#define O_BINARY 0
......@@ -1145,7 +1145,6 @@ int fileOpen(const char *filename, const char *mode)
if ( FILE_Debug )
Message("File %s opened with ID %d", filename, fileID);
}
return (fileID);
}
......
......@@ -4258,7 +4258,7 @@ int gridGetPackSize ( void * voidP, MPI_Comm comm )
count = gridP->size;
else
count = gridP->ysize;
if ( !count ) abort ();
xassert ( count );
xmpi ( MPI_Pack_size ( count, MPI_DOUBLE, comm, &size ));
packBuffSize += size;
......
......@@ -107,8 +107,7 @@ int namespaceGetNumber ()
void pioNamespaceSetActive ( int nId )
{
#ifdef USE_MPI
if ( nId >= nNamespaces || nId < 0 )
abort ();
xassert ( nId < nNamespaces && nId >= 0 );
activeNamespace = nId;
#endif
......@@ -123,8 +122,7 @@ int namespaceGetActive ()
int namespaceHasLocalFile ( int nId )
{
if ( nId >= nNamespaces || nId < 0 )
abort ();
xassert ( nId < nNamespaces && nId >= 0 );
return hasLocalFiles ? hasLocalFiles[nId] : 0;
}
......
......@@ -209,7 +209,7 @@ void backendFinalize ( void )
{
commDestroy ();
MPI_Finalize ();
exit ( 0 );
exit ( EXIT_SUCCESS );
}
#endif
/*
......
......@@ -503,6 +503,8 @@ void commEvalPhysNodes ( void )
if ( nodeInfo[IOID].isProcColl ) info->nProcsColl++;
}
xdebug ( "info->nProcsColl=%d", info->nProcsColl );
xassert ( info->nProcsColl <= info->nProcsModel );
// define nodeSizes
......
......@@ -256,6 +256,8 @@ void varsMapNDeco ( int nNodes, int * nodeSizes )
int nProcsColl = commInqNProcsColl ();
char text[1024];
xdebug ( "START, nProcsColl=%d", nProcsColl );
nStreams = streamSize ();
resHs = xmalloc ( nStreams * sizeof ( resHs[0] ));
......@@ -263,8 +265,6 @@ void varsMapNDeco ( int nNodes, int * nodeSizes )
collectsData = xmalloc ( nProcsColl * sizeof ( collectsData[0] ));
streamGetIndexList ( nStreams, resHs );
xprintArray ( "Echam streams", resHs, nStreams, DATATYPE_INT );
for ( i = 0; i < nStreams; i++ )
streamSizes[i] = streamInqNvars ( * ( resHs + i ));
......@@ -272,8 +272,6 @@ void varsMapNDeco ( int nNodes, int * nodeSizes )
varSizes = xmalloc ( nVars * sizeof ( varSizes[0] ));
varMapping = xmalloc ( nVars * sizeof ( varMapping[0] ));
reshListPrint ( "reshListModelEcham" );
for ( i = 0; i < nStreams; i++ )
for ( j = 0; j < * ( streamSizes + i ); j++ )
varSizes[k++] += vlistInqVarSize ( streamInqVlist ( * ( resHs + i )), j );
......@@ -312,6 +310,8 @@ void varsMapNDeco ( int nNodes, int * nodeSizes )
if ( collectsData ) free ( collectsData );
if ( streamSizes ) free ( streamSizes );
if ( resHs ) free ( resHs );
xdebug ( "RETURN" );
}
/************************************************************************/
......@@ -321,6 +321,7 @@ void modelWinCleanup ( void )
{
int collID;
xdebug ( "START" );
if ( winPostSet != NULL &&
win != NULL &&
winBuffer != NULL &&
......@@ -342,7 +343,7 @@ void modelWinCleanup ( void )
if ( winBuffer ) free ( winBuffer );
if ( winBufferSize ) free ( winBufferSize );
xdebug ( "cleaned up mpi_win's" );
xdebug ( "RETURN. CLEANED UP MPI_WIN'S" );
}
/************************************************************************/
......@@ -357,6 +358,7 @@ static
int rankModel = commInqRankModel ();
int root = commInqRootGlob ();
xdebug ( "START" );
xassert ( winBufferSize != NULL );
nstreams = reshCountType ( &streamOps );
......@@ -395,6 +397,7 @@ static
xdebug ("sumWinBufferSize=%d, MAXWINBUFFERSIZE=%d", sumWinBufferSize, MAXWINBUFFERSIZE );
xassert ( sumWinBufferSize <= MAXWINBUFFERSIZE );
xprintArray ( "winBufferSize", winBufferSize, nProcsColl, DATATYPE_INT );
xdebug ( "RETURN" );
}
......@@ -430,6 +433,7 @@ void modelWinCreate ( void )
int collID, ranks[1];
int nProcsColl = commInqNProcsColl ();
xdebug ( "START" );
winBufferSize = xmalloc ( nProcsColl * sizeof ( winBufferSize[0] ));
winBuffer = xmalloc ( nProcsColl * sizeof ( winBuffer[0] ));
winBufferHead = xmalloc ( nProcsColl * sizeof ( winBufferHead[0] ));
......@@ -457,7 +461,7 @@ void modelWinCreate ( void )
xmpi ( MPI_Group_incl ( groupsIONetto[collID], 1, ranks,
&groupsIONetto[collID] ));
}
xdebug ( "created mpi_win's" );
xdebug ( "RETURN, CREATED MPI_WIN'S" );
}
/************************************************************************/
......@@ -558,6 +562,8 @@ void pioBufferFuncCall ( const char * func, int argc, ... )
size_t size = 0;
int funcID = func2Int ( func );
xdebug ( "START" );
if ( rankGlob != root ) return;
xassert ( func != NULL &&
......@@ -695,6 +701,8 @@ void pioBufferFuncCall ( const char * func, int argc, ... )
}
va_end ( ap );
xdebug ( "RETURN" );
}
#endif
......@@ -771,8 +779,8 @@ MPI_Comm pioInit_c ( MPI_Comm commGlob, int nProcsIO, int IOMode,
// JUST FOR TEST CASES WITH ONLY ONE MPI TASK
if ( commInqSizeGlob () == 1 )
{
namespaceInit ( nNamespaces, hasLocalFile );
{
namespaceInit ( nNamespaces, hasLocalFile );
return commInqCommGlob ();
}
......@@ -784,7 +792,7 @@ MPI_Comm pioInit_c ( MPI_Comm commGlob, int nProcsIO, int IOMode,
IOServer ();
commDestroy ();
MPI_Finalize ();
exit ( 0 );
exit ( EXIT_SUCCESS );
}
else
{
......@@ -793,7 +801,7 @@ MPI_Comm pioInit_c ( MPI_Comm commGlob, int nProcsIO, int IOMode,
namespaceInit ( nNamespaces, hasLocalFile );
}
xdebug ( "nProcsGlob=%d, return from pioInit()", sizeGlob );
xdebug ( "nProcsGlob=%d, RETURN", sizeGlob );
return commInqCommModel ();
}
#endif
......@@ -803,8 +811,7 @@ MPI_Comm pioInit_c ( MPI_Comm commGlob, int nProcsIO, int IOMode,
int pioInit ( int commGlobArg, int nProcsIO, int IOMode, int nNamespaces,
int * hasLocalFile )
{
xdebug( "%s, nProcsIO=%d, IOMode=%d, nNamespaces=%d",
xdebug( "START: %s, nProcsIO=%d, IOMode=%d, nNamespaces=%d",
#ifdef USE_MPI
"cdi parallel",
#else
......@@ -822,6 +829,8 @@ int pioInit ( int commGlobArg, int nProcsIO, int IOMode, int nNamespaces,
return MPI_Comm_c2f ( pioInit_c ( commGlob, nProcsIO, IOMode, nNamespaces,
hasLocalFile ));
#endif
xdebug ( "RETURN" );
return 0;
}
......@@ -834,9 +843,11 @@ void pioEndDef ( void )
int bufferSize;
int rankGlob = commInqRankGlob ();
xdebug ( "START" );
varsMapNDeco ( commInqNNodes (), commInqNodeSizes ());
reshListPrint ( "reshListModelEcham" );
reshListPrint ( "reshListModel" );
if ( rankGlob < commInqNProcsColl ())
{
......@@ -850,11 +861,9 @@ void pioEndDef ( void )
reshPackBufferDestroy ( &buffer );
}
xdebug();
modelWinCreate ();
xdebug();
namespaceDefResStatus ( STAGE_TIMELOOP );
xdebug ( "RETURN" );
#endif
}
......@@ -863,7 +872,9 @@ void pioEndDef ( void )
void pioEndTimestepping ( void )
{
#ifdef USE_MPI
xdebug ( "START" );
namespaceDefResStatus ( STAGE_CLEANUP );
xdebug ( "RETURN" );
#endif
}
......@@ -884,6 +895,7 @@ void pioFinalize ( void )
{
#ifdef USE_MPI
int collID, ibuffer = 1111;
xdebug ( "START" );
namespaceCleanup ();
for ( collID = 0; collID < commInqNProcsColl (); collID++ )
{
......@@ -893,6 +905,7 @@ void pioFinalize ( void )
}
modelWinCleanup ();
commDestroy ();
xdebug ( "RETURN" );
#endif
}
......@@ -932,10 +945,23 @@ void pioWriteTimestep ( int tsID, int vdate, int vtime )
winPostSet[collID] = 0;
modelWinFlushBuffer ( collID );
}
modelWinBufferPutAtEnd ( __func__, collID, &tokenEnd, sizeof ( tokenEnd ));
modelWinBufferPutAtEnd ( __func__, collID, &tokenEnd,
sizeof ( tokenEnd ));
xmpi ( MPI_Win_post ( groupsIONetto[collID], iAssert, win[collID] ));
winPostSet[collID] = 1;
}
xdebug ( "RETURN. messages sent, windows posted: tsID=%d, vdate=%d, vtime=%d",
tsID, vdate, vtime );
#endif
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
......@@ -43,10 +43,14 @@ void streamUnpack ( char * unpackBuffer, int unpackBufferSize,
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
xassert ( d == xchecksum ( DATATYPE_TXT, intBuffer[2], filename ));
streamID = streamOpenWrite ( filename, intBuffer[1] );
xdebug ("streamID=%d, intBuffer[0]=%d, nspTarget=%d,"
" namespaceAdaptKey(a,b)=%d",
streamID, intBuffer[0], nspTarget,
namespaceAdaptKey ( intBuffer[0], nspTarget ));
xassert ( streamID >= 0 &&
namespaceAdaptKey ( intBuffer[0], nspTarget ) == streamID );
xdebug ("streamID=%d, vlistID=%d", streamID, namespaceAdaptKey ( intBuffer[4], nspTarget ));
streamDefVlist ( streamID, namespaceAdaptKey ( intBuffer[4], nspTarget ));
xassert ( streamInqVlist ( streamID ) ==
......@@ -56,7 +60,7 @@ void streamUnpack ( char * unpackBuffer, int unpackBufferSize,
streamDefCompType ( streamID, intBuffer[6] );
streamDefCompLevel ( streamID, intBuffer[7] );
cdiDefGlobal ( "REGULARGRID", intBuffer[8] );
cdiDefGlobal ( "SORTNAME", intBuffer[9] );
cdiDefGlobal ( "SORTNAME", intBuffer[9] );
cdiDefGlobal ( "HAVE_MISSVAL", intBuffer[10] );
}
......@@ -71,7 +75,7 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
int unpackBufferPos = 0;
char text[4096];
xdebug ();
xdebug ( "START" );
while ( unpackBufferPos < unpackBufferSize )
{
......@@ -122,7 +126,7 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
&token2, 1, MPI_INT, comm ));
xassert ( token2 == SEPARATOR );
}
xdebug ();
xdebug ( "RETURN" );
}
#endif
......
......@@ -255,7 +255,8 @@ void readGetBuffers ( int tsID, int vdate, int vtime )
char text[1024];
int nProcsModel = commInqNProcsModel ();
int root = commInqRootGlob ();
xdebug ( "START" );
getBufferGetFromEnd ( __func__, __LINE__,
root, &tokenID, sizeof ( tokenID ));
......@@ -272,7 +273,7 @@ void readGetBuffers ( int tsID, int vdate, int vtime )
streamID = streamIDNew;
vlistID = streamInqVlist ( streamID );
taxisID = vlistInqTaxis ( vlistID );
taxisDefVdate ( taxisID, vdate + tsID );
taxisDefVdate ( taxisID, vdate );
taxisDefVtime ( taxisID, vtime );
streamDefTimestep ( streamID, tsID );
}
......@@ -326,7 +327,7 @@ void readGetBuffers ( int tsID, int vdate, int vtime )
getBufferGetFromEnd ( __func__, __LINE__,
root, &tokenID, sizeof ( tokenID ));
}
xdebug ( "RETURN" );
}
/************************************************************************/
......@@ -360,14 +361,17 @@ void getData ( int tsID, int vdate, int vtime )
char text[1024];
int nProcsModel = commInqNProcsModel ();
xdebug ( "START" );
// todo put in correct lbs and ubs
xassert ( tsID >= 0 && vdate >= 0 && vtime >= 0 );
xmpi ( MPI_Win_start ( groupModel, iAssert, getWin ));
for ( modelID = 0; modelID < nProcsModel; modelID++ )
{
getFlushBuffer ( modelID );
xdebug ( "modelID=%d, nProcsModel=%d, getBufferSize[%d]=%d, getWin=%p, sizeof(int)=%d",
modelID, nProcsModel, modelID, getBufferSize[modelID], getWin,
sizeof ( int ));
xmpi ( MPI_Get ( &getBuffer[modelID][0], getBufferSize[modelID],
MPI_UNSIGNED_CHAR, modelID, 0,
getBufferSize[modelID], MPI_UNSIGNED_CHAR, getWin ));
......@@ -385,7 +389,7 @@ void getData ( int tsID, int vdate, int vtime )
}
readGetBuffers ( tsID, vdate, vtime );
xdebug ( "RETURN" );
}
/************************************************************************/
......
......@@ -31,7 +31,7 @@ void pcdiAssert ( bool assumption, const char * filename,
fprintf ( stderr, "ERROR, FALSE ASSUMPTION, %s, %s, line %d\n",
functionname, filename, line );
fflush ( stderr );
abort();
exit ( EXIT_FAILURE );
#endif
}
}
......@@ -51,7 +51,7 @@ void pcdiAbort ( char * errorString, const char * filename,
#else
fprintf ( stderr, "ERROR, %s, %s, line %d, errorString: \"%s\"\n",
functionname, filename, line, errorString );
abort();
exit ( EXIT_FAILURE );
#endif
}
......
......@@ -617,7 +617,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
if ( ! filename || ! filemode || filetype < 0 ) return (CDI_EINVAL);
xdebug( "filename = %s, filemode = %s, filetype = %d, "
xdebug( "START, filename = %s, filemode = %s, filetype = %d, "
"namespaceHasLocalFile(%d)=%s",
filename, filemode, filetype, namespaceGetActive(),
namespaceHasLocalFile ( namespaceGetActive ()) ? "true":"false");
......@@ -631,6 +631,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
case FILETYPE_GRB2:
{
fileID = gribOpen(filename, filemode);
xdebug ( "%s OPENED, fileID=%d", filename, fileID );
record = (Record *) malloc(sizeof(Record));
record->buffer = NULL;
break;
......@@ -711,7 +712,6 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
}
#endif
if ( fileID < 0 && hasLocalFile )
{
streamID = fileID;
......@@ -1153,7 +1153,7 @@ void streamClose(int streamID)
if ( namespaceHasLocalFile ( namespaceGetActive ()))
{
if ( fileID == CDI_UNDEFID )
Warning("File %s not open!", streamptr->filename);
Warning("File %s not open!", streamptr->filename);
else
switch (filetype)
{
......@@ -1299,6 +1299,8 @@ void streamSync(int streamID)
int nvars;
stream_t *streamptr;
if ( !namespaceHasLocalFile ( namespaceGetActive ())) return;
streamptr = stream_to_pointer(streamID);
stream_check_ptr(__func__, streamptr);
......@@ -2075,7 +2077,6 @@ void streamDefVlist(int streamID, int vlistID)
streamptr = stream_to_pointer(streamID);
stream_check_ptr(__func__, streamptr);
#ifdef USE_MPI
{
statusCode nspStatus = namespaceInqResStatus ();
......@@ -2107,7 +2108,8 @@ void streamDefVlist(int streamID, int vlistID)
zaxisID = vlistInqVarZaxis(vlistID, varID);
streamNewVar(streamID, gridID, zaxisID);
if ( streamptr->have_missval )
vlistDefVarMissval(streamptr->vlistID, varID, vlistInqVarMissval(vlistID, varID));
vlistDefVarMissval(streamptr->vlistID, varID,
vlistInqVarMissval(vlistID, varID));
}
if ( streamptr->filemode == 'w' )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment