Commit 4eba98f3 authored by Deike Kleberg's avatar Deike Kleberg
Browse files

Introduce new function xassert.

parent 49c47aa5
......@@ -11,11 +11,11 @@
#include "pio_util.h"
enum {
nProcsIO = 3,
//IOMode = PIO_NONE,
nProcsIO = 1,
IOMode = PIO_NONE,
//IOMode = PIO_MPI_NONB,
//IOMode = PIO_POSIX_FPGUARD_SENDRECV,
IOMode = PIO_POSIX_ASYNCH,
//IOMode = PIO_POSIX_ASYNCH,
//IOMode = PIO_POSIX_NONB,
filetype = FILETYPE_GRB,
ntfiles = 2,
......@@ -56,7 +56,7 @@ void modelRun ()
zaxisID[i] = zaxisCreate ( ZAXIS_PRESSURE, nlev[i] );
zaxisDefLevels ( zaxisID[i], levs );
}
vlistID = vlistCreate ();
vlistID = vlistCreate ();
for ( i = 0; i < nVars; i++ )
varID[i] = vlistDefVar ( vlistID, gridID, zaxisID[i], TIME_VARIABLE );
......
......@@ -2,6 +2,7 @@
# include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
......@@ -191,7 +192,7 @@ static filePtrToIdx *_fileAvail = NULL;
static
void file_list_new(void)
{
xassert(_fileList == NULL);
assert(_fileList == NULL);
_fileList = (filePtrToIdx *) malloc(_file_max*sizeof(filePtrToIdx));
}
......
......@@ -184,6 +184,8 @@ void backendCleanup ( void )
int IOMode = commInqIOMode ();
switch ( IOMode )
{
case PIO_NONE:
break;
case PIO_MPI_NONB:
finalizeMPINONB ();
break;
......
......@@ -34,7 +34,7 @@ void streamUnpack ( char * unpackBuffer, int unpackBufferSize,
intBuffer, streamNint, MPI_INT, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_INT, streamNint, intBuffer ) != d ) xabort ("");
xassert ( xchecksum ( DATATYPE_INT, streamNint, intBuffer ) == d );
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&cdiDefaultMissval, 1, MPI_DOUBLE, comm ));
......@@ -42,16 +42,15 @@ void streamUnpack ( char * unpackBuffer, int unpackBufferSize,
&filename, intBuffer[2], MPI_CHAR, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( d != xchecksum ( DATATYPE_TXT, intBuffer[2], filename )) xabort ("");
xassert ( d == xchecksum ( DATATYPE_TXT, intBuffer[2], filename ));
streamID = streamOpenWrite ( filename, intBuffer[1] );
if ( streamID < 0 ) xabort ( "can not open output file" );
if ( namespaceAdaptKey ( intBuffer[0], nspTarget ) != streamID )
xabort ("");
xassert ( streamID >= 0 &&
namespaceAdaptKey ( intBuffer[0], nspTarget ) == streamID );
streamDefVlist ( streamID, namespaceAdaptKey ( intBuffer[4], nspTarget ));
if ( streamInqVlist ( streamID ) != namespaceAdaptKey ( intBuffer[3], nspTarget ))
xabort ("");
xassert ( streamInqVlist ( streamID ) ==
namespaceAdaptKey ( intBuffer[3], nspTarget ));
streamDefByteorder ( streamID, intBuffer[5] );
streamDefCompType ( streamID, intBuffer[6] );
......@@ -114,17 +113,12 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
nspTarget, comm);
break;
default:
xabort ( "no valid datatype" );
xabort ( "TOKEN MAPS NO VALID DATATYPE" );
}
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, &unpackBufferPos,
&token2, 1, MPI_INT, comm ));
if ( token2 != SEPARATOR )
{
sprintf ( text, "problems unpacking type %d", token1);
xabort ( text);
}
xassert ( token2 == SEPARATOR );
}
}
......
......@@ -1335,15 +1335,14 @@ void taxisUnpack ( char * unpackBuffer, int unpackBufferSize,
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_INT, taxisNint, intBuffer ) != d ) xabort ("");
xassert ( xchecksum ( DATATYPE_INT, taxisNint, intBuffer ) == d );
taxisInit ();
taxisP = taxisNewEntry();
if ( ! taxisP ) Error("No memory");
if ( namespaceAdaptKey ( intBuffer[0], nspTarget ) != taxisP->self )
xabort ("");
xassert ( namespaceAdaptKey ( intBuffer[0], nspTarget ) == taxisP->self );
taxisP->used = intBuffer[1];
taxisP->type = intBuffer[2];
......
......@@ -488,6 +488,7 @@ vlistAttGetSize(vlist_t *vlistptr, int varID, int attnum, MPI_Comm comm)
int txsize = 0, txinc;
cdi_atts_t *attsp;
cdi_att_t *attp;
char text[1024];
xassert(attsp = get_attsp(vlistptr, varID));
xassert(attnum >= 0 && attnum < (int)attsp->nelems);
......@@ -507,9 +508,9 @@ vlistAttGetSize(vlist_t *vlistptr, int varID, int attnum, MPI_Comm comm)
xmpi(MPI_Pack_size((int)attp->nelems, MPI_CHAR, comm, &txinc));
break;
default:
fprintf(stderr, "Unknown datatype encountered in attribute %s: %d\n",
sprintf( text, "Unknown datatype encountered in attribute %s: %d\n",
attp->name, attp->indtype);
xabort("");
xabort ( text );
}
txsize += txinc;
return txsize;
......@@ -538,6 +539,7 @@ vlistAttPack(vlist_t *vlistptr, int varID, int attnum,
cdi_att_t *attp;
int tempbuf[vlist_att_nints];
MPI_Datatype attVMPIDt;
char text[1024];
xassert(attsp = get_attsp(vlistptr, varID));
xassert(attnum >= 0 && attnum < (int)attsp->nelems);
......@@ -560,9 +562,9 @@ vlistAttPack(vlist_t *vlistptr, int varID, int attnum,
attVMPIDt = MPI_CHAR;
break;
default:
fprintf(stderr, "Unknown datatype encountered in attribute %s: %d\n",
attp->name, attp->indtype);
xabort("");
sprintf( text, "Unknown datatype encountered in attribute %s: %d\n",
attp->name, attp->indtype);
xabort ( text );
}
xmpi(MPI_Pack(attp->xvalue, (int)attp->nelems, attVMPIDt,
buf, size, position, comm));
......@@ -591,7 +593,8 @@ vlistAttUnpack(int vlistID, int varID,
MPI_Datatype attVMPIDt;
int elemSize;
void *attData;
char text[1024];
xmpi(MPI_Unpack(buf, size, position,
tempbuf, vlist_att_nints, MPI_INT, comm));
attName = xmalloc(tempbuf[0] + 1);
......@@ -612,9 +615,9 @@ vlistAttUnpack(int vlistID, int varID,
elemSize = 1;
break;
default:
fprintf(stderr, "Unknown datatype encountered in attribute %s: %d\n",
sprintf ( text, "Unknown datatype encountered in attribute %s: %d\n",
attName, tempbuf[2]);
xabort("");
xabort ( text );
}
attData = xmalloc(elemSize * tempbuf[3]);
xmpi(MPI_Unpack(buf, size, position, attData, tempbuf[3], attVMPIDt, comm));
......
......@@ -1399,7 +1399,7 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
if ( z1->vals )
{
if ( !z1->size ) xabort ("");
xassert ( z1->size );
if ( !z2->vals ) return differ;
......@@ -1411,7 +1411,7 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
if ( z1->lbounds )
{
if ( !z1->size ) xabort ("");
xassert ( z1->size );
if ( !z2->lbounds ) return differ;
......@@ -1423,7 +1423,7 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
if ( z1->ubounds )
{
if ( !z1->size ) xabort ("");
xassert ( z1->size );
if ( !z2->ubounds ) return differ;
......@@ -1435,7 +1435,7 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
if ( z1->weights )
{
if ( !z1->size ) xabort ("");
xassert ( z1->size );
if ( !z2->weights ) return differ;
......@@ -1447,7 +1447,7 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
if ( z1->vct )
{
if ( !z1->vctsize ) xabort ("");
xassert ( z1->vctsize );
if ( !z2->vct ) return differ;
......@@ -1518,7 +1518,7 @@ int zaxisGetPackSize ( void * voidP, MPI_Comm comm )
if ( zaxisP->vals )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack_size ( zaxisP->size, MPI_DOUBLE, comm, &size ));
packBufferSize += size;
......@@ -1528,7 +1528,7 @@ int zaxisGetPackSize ( void * voidP, MPI_Comm comm )
if ( zaxisP->lbounds )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack_size ( zaxisP->size, MPI_DOUBLE, comm, &size ));
packBufferSize += size;
......@@ -1538,7 +1538,7 @@ int zaxisGetPackSize ( void * voidP, MPI_Comm comm )
if ( zaxisP->ubounds )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack_size ( zaxisP->size, MPI_DOUBLE, comm, &size ));
packBufferSize += size;
......@@ -1548,7 +1548,7 @@ int zaxisGetPackSize ( void * voidP, MPI_Comm comm )
if ( zaxisP->weights )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack_size ( zaxisP->size, MPI_DOUBLE, comm, &size ));
packBufferSize += size;
......@@ -1558,7 +1558,7 @@ int zaxisGetPackSize ( void * voidP, MPI_Comm comm )
if ( zaxisP->vct )
{
if ( ! zaxisP->vctsize ) xabort ("");
xassert ( zaxisP->vctsize );
xmpi ( MPI_Pack_size ( zaxisP->vctsize, MPI_DOUBLE, comm, &size ));
packBufferSize += size;
......@@ -1590,15 +1590,14 @@ void zaxisUnpack ( char * unpackBuffer, int unpackBufferSize,
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_INT, zaxisNint + 1, intBuffer ) != d ) xabort ("");
xassert ( xchecksum ( DATATYPE_INT, zaxisNint + 1, intBuffer ) == d );
zaxisInit ();
zaxisP = zaxisNewEntry();
if ( ! zaxisP ) Error("No memory");
if ( namespaceAdaptKey ( intBuffer[0], nspTarget ) != zaxisP->self )
xabort ("");
xassert ( namespaceAdaptKey ( intBuffer[0], nspTarget ) == zaxisP->self );
zaxisP->prec = intBuffer[1];
zaxisP->type = intBuffer[2];
......@@ -1610,67 +1609,62 @@ void zaxisUnpack ( char * unpackBuffer, int unpackBufferSize,
if ( memberMask & vals )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
zaxisP->vals = xmalloc ( zaxisP->size * sizeof ( double ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
zaxisP->vals, zaxisP->size, MPI_DOUBLE, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->vals ) != d )
xabort ("");
xassert ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->vals ) == d );
}
if ( memberMask & lbounds )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
zaxisP->lbounds = xmalloc ( zaxisP->size * sizeof ( double ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
zaxisP->lbounds, zaxisP->size, MPI_DOUBLE, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->lbounds ) != d )
xabort ("");
xassert ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->lbounds ) == d );
}
if ( memberMask & ubounds )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
zaxisP->ubounds = xmalloc ( zaxisP->size * sizeof ( double ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
zaxisP->ubounds, zaxisP->size, MPI_DOUBLE, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->ubounds ) != d )
xabort ("");
xassert ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->ubounds ) == d );
}
if ( memberMask & weights )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
zaxisP->weights = xmalloc ( zaxisP->size * sizeof ( double ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
zaxisP->weights, zaxisP->size, MPI_DOUBLE, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->weights ) != d )
xabort ("");
xassert ( xchecksum ( DATATYPE_FLT, zaxisP->size, zaxisP->weights ) == d );
}
if ( memberMask & vct )
{
if ( ! zaxisP->vctsize ) xabort ("");
xassert ( zaxisP->vctsize );
zaxisP->vct = xmalloc ( zaxisP->vctsize * sizeof ( double ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
zaxisP->vct, zaxisP->vctsize, MPI_DOUBLE, comm ));
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( xchecksum ( DATATYPE_FLT, zaxisP->vctsize, zaxisP->vct ) != d )
xabort ("");
xassert ( xchecksum ( DATATYPE_FLT, zaxisP->vctsize, zaxisP->vct ) == d );
}
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
......@@ -1678,7 +1672,7 @@ void zaxisUnpack ( char * unpackBuffer, int unpackBufferSize,
xmpi ( MPI_Unpack ( unpackBuffer, unpackBufferSize, unpackBufferPos,
&d, 1, MPI_DOUBLE, comm ));
if ( d != xchecksum ( DATATYPE_TXT, zaxisNstrings * CDI_MAX_NAME, charBuffer )) xabort ("");
xassert ( d == xchecksum ( DATATYPE_TXT, zaxisNstrings * CDI_MAX_NAME, charBuffer ));
memcpy ( zaxisP->name, &charBuffer[CDI_MAX_NAME * 0], CDI_MAX_NAME );
memcpy ( zaxisP->longname, &charBuffer[CDI_MAX_NAME * 1], CDI_MAX_NAME );
......@@ -1716,7 +1710,7 @@ void zaxisPack ( void * voidP, void * packBuffer, int packBufferSize,
if ( zaxisP->vals )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack ( zaxisP->vals, zaxisP->size, MPI_DOUBLE,
packBuffer, packBufferSize, packBufferPos, comm ));
......@@ -1727,7 +1721,7 @@ void zaxisPack ( void * voidP, void * packBuffer, int packBufferSize,
if ( zaxisP->lbounds )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack ( zaxisP->lbounds, zaxisP->size, MPI_DOUBLE,
packBuffer, packBufferSize, packBufferPos, comm ));
......@@ -1738,7 +1732,7 @@ void zaxisPack ( void * voidP, void * packBuffer, int packBufferSize,
if ( zaxisP->ubounds )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack ( zaxisP->ubounds, zaxisP->size, MPI_DOUBLE,
packBuffer, packBufferSize, packBufferPos, comm ));
......@@ -1749,7 +1743,7 @@ void zaxisPack ( void * voidP, void * packBuffer, int packBufferSize,
if ( zaxisP->weights )
{
if ( ! zaxisP->size ) xabort ("");
xassert ( zaxisP->size );
xmpi ( MPI_Pack ( zaxisP->weights, zaxisP->size, MPI_DOUBLE,
packBuffer, packBufferSize, packBufferPos, comm ));
......@@ -1760,7 +1754,7 @@ void zaxisPack ( void * voidP, void * packBuffer, int packBufferSize,
if ( zaxisP->vct )
{
if ( ! zaxisP->vctsize ) xabort ("");
xassert ( zaxisP->vctsize );
xmpi ( MPI_Pack ( zaxisP->vct, zaxisP->vctsize, MPI_DOUBLE,
packBuffer, packBufferSize, packBufferPos, comm ));
......
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