Commit b0b18f72 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add routine to elicit type code for transmission.

parent 80e52896
......@@ -15,6 +15,7 @@
#include "gaussgrid.h"
#include "pio_util.h"
#include "resource_handle.h"
#include "pio_rpc.h"
#ifndef RAD2DEG
#define RAD2DEG (180./M_PI) /* conversion for rad to deg */
......@@ -52,11 +53,12 @@ static void gridPrintP ( void * gridptr );
static int gridGetSizeP ( void * gridptr, MPI_Comm comm );
static void gridPackP ( void * gridptr, void * buff, int size,
int *position, MPI_Comm comm );
static int gridTxCode ( void * gridptr );
#endif
resOps gridOps = { gridCompareP, gridDestroyP, gridPrintP
#ifdef USE_MPI
, gridGetSizeP, gridPackP
, gridGetSizeP, gridPackP, gridTxCode
#endif
};
......@@ -3674,6 +3676,12 @@ void gridGetIndexArray ( int ngrids, int * gridIndexArray )
#ifdef USE_MPI
static int
gridTxCode( void * gridptr )
{
return GRID;
}
static
int gridGetSizeP ( void * gridptr, MPI_Comm comm )
{
......
......@@ -8,6 +8,7 @@
#include "resource_handle.h"
#include "pio_util.h"
#include "resource_handle.h"
#include "pio_rpc.h"
#undef UNDEFID
#define UNDEFID -1
......@@ -35,11 +36,12 @@ static void institutePrintP ( void * instituteptr );
static int instituteGetSizeP ( void * instituteptr, MPI_Comm comm );
static void institutePackP ( void * instituteptr, void *buf, int size,
int *position, MPI_Comm comm );
static int instituteTxCode ( void * instituteptr );
#endif
resOps instituteOps = { instituteCompareP, instituteDestroyP, institutePrintP
#ifdef USE_MPI
,instituteGetSizeP, institutePackP
,instituteGetSizeP, institutePackP, instituteTxCode
#endif
};
......@@ -325,6 +327,12 @@ void institutePrintP ( void * instituteptr )
#ifdef USE_MPI
static int
instituteTxCode(void *vlistptr)
{
return INSTITUTE;
}
static
int instituteGetSizeP ( void * instituteptr, MPI_Comm comm )
{
......
......@@ -7,6 +7,7 @@
#include "stream_int.h"
#include "pio_util.h"
#include "resource_handle.h"
#include "pio_rpc.h"
#undef UNDEFID
#define UNDEFID -1
......@@ -38,11 +39,12 @@ static void modelPrintP ( void * modelptr );
static int modelGetSizeP ( void * modelptr, MPI_Comm comm );
static void modelPackP ( void * modelptr, void * buff, int size,
int *position, MPI_Comm comm);
static int modelTxCode ( void * modelptr );
#endif
resOps modelOps = { modelCompareP, modelDestroyP, modelPrintP
#ifdef USE_MPI
, modelGetSizeP, modelPackP
, modelGetSizeP, modelPackP, modelTxCode
#endif
};
......@@ -262,6 +264,13 @@ void modelPrintP ( void * modelptr )
#ifdef USE_MPI
static int
modelTxCode(void *modelptr)
{
return MODEL;
}
static
int modelGetSizeP ( void * modelptr, MPI_Comm comm )
{
......
......@@ -9,8 +9,6 @@
#include "error.h"
#include "pio_rpc.h"
extern resOps gridOps;
enum { MIN_ARRAY_SIZE = 128, MIN_BUFF_SIZE = 4096 };
static int *arraySizeAllocated;
......@@ -338,11 +336,14 @@ static
int getPackBufferSize ( MPI_Comm comm )
{
int nsp, i;
int packBufferSize = 0, size;
int packBufferSize = 0;
int intpacksize;
node * curr;
nsp = namespaceGetActive ();
xmpi(MPI_Pack_size(1, MPI_INT, comm, &intpacksize));
for ( i = 0; i < arraySizeAllocated[nsp]; i++ )
if ( arrayResources[nsp][i].ptr )
if ( ! arrayResources[nsp][i].sent )
......@@ -350,16 +351,13 @@ int getPackBufferSize ( MPI_Comm comm )
curr = arrayResources[nsp] + i;
assert ( curr->ops );
if ( curr->ops != &gridOps )
continue;
MPI_Pack_size ( 2, MPI_INT, comm, &size );
packBufferSize += curr->ops->valGetSize ( curr->ptr, comm ) + size;
/* message plus frame of 2 ints */
packBufferSize += curr->ops->valGetSize ( curr->ptr, comm )
+ 2 * intpacksize;
}
MPI_Pack_size ( 1, MPI_INT, comm, &size );
packBufferSize += size;
/* end marker */
packBufferSize += intpacksize;
return packBufferSize;
}
......@@ -378,7 +376,7 @@ void reshPackBufferDestroy ( char ** buffer )
void reshPackBufferCreate ( char ** packBuffer, int * packBufferSize, MPI_Comm comm )
{
int i, nsp, packBufferPos = 0;
int end = END, sep = SEPARATOR, type = GRID;
int end = END, sep = SEPARATOR, type;
node * curr;
xdebug ();
......@@ -399,11 +397,14 @@ void reshPackBufferCreate ( char ** packBuffer, int * packBufferSize, MPI_Comm c
curr = arrayResources[nsp] + i;
assert ( curr->ops );
if ( curr->ops != &gridOps )
type = curr->ops->txCode(curr->ptr);
if ( ! type )
continue;
MPI_Pack ( &type, 1, MPI_INT,
* packBuffer, * packBufferSize, &packBufferPos, comm );
xmpi(MPI_Pack ( &type, 1, MPI_INT,
* packBuffer, * packBufferSize, &packBufferPos,
comm ));
curr->ops->valPack ( curr->ptr,
* packBuffer ,
......@@ -411,8 +412,8 @@ void reshPackBufferCreate ( char ** packBuffer, int * packBufferSize, MPI_Comm c
&packBufferPos,
comm );
MPI_Pack ( &sep, 1, MPI_INT, * packBuffer,
* packBufferSize, &packBufferPos, comm );
xmpi(MPI_Pack ( &sep, 1, MPI_INT, * packBuffer,
* packBufferSize, &packBufferPos, comm ));
xdebug ( "#### packed one resource with type and separator" );
......@@ -421,8 +422,8 @@ void reshPackBufferCreate ( char ** packBuffer, int * packBufferSize, MPI_Comm c
ARRAY_UNLOCK();
MPI_Pack ( &end, 1, MPI_INT,
* packBuffer, * packBufferSize, &packBufferPos, comm );
xmpi(MPI_Pack ( &end, 1, MPI_INT,
* packBuffer, * packBufferSize, &packBufferPos, comm ));
xdebug ( "#### packed END token" );
}
......
......@@ -30,6 +30,7 @@ typedef void ( * valPrintFunc )( void * );
typedef int ( * valGetSizeFunc )( void *, MPI_Comm comm );
typedef void ( * valPackFunc )( void *, void *buf, int size, int *pos,
MPI_Comm comm );
typedef int ( * txCodeFunc )( void * );
#endif
typedef struct {
......@@ -39,6 +40,7 @@ typedef struct {
#ifdef USE_MPI
valGetSizeFunc valGetSize;
valPackFunc valPack;
txCodeFunc txCode;
#endif
}resOps;
......
......@@ -16,6 +16,7 @@
#include "pio_util.h"
#include "namespace.h"
#include "resource_handle.h"
#include "pio_rpc.h"
#if defined (HAVE_LIBCGRIBEX)
#include "cgribex.h"
......@@ -72,12 +73,14 @@ static void streamPrintP ( void * streamptr );
static int streamGetSizeP ( void * streamptr, MPI_Comm comm );
static void streamPackP ( void * streamptr, void * buff, int size,
int * position, MPI_Comm comm );
static int streamTxCode ( void * streamptr );
#endif
resOps streamOps = { streamCompareP, streamDestroyP, streamPrintP,
#ifdef USE_MPI
streamGetSizeP,
streamPackP
streamPackP,
streamTxCode,
#endif
};
......@@ -572,6 +575,12 @@ void streamPrintP ( void * streamptr )
#ifdef USE_MPI
static int
streamTxCode ( void * streamptr )
{
return STREAM;
}
static
int streamGetSizeP ( void * streamptr, MPI_Comm comm )
{
......
......@@ -10,11 +10,13 @@
#include "dmemory.h"
#include "cdi.h"
#include "taxis.h"
#include "stream_int.h"
#include "calendar.h"
#include "pio_util.h"
#include "namespace.h"
#include "resource_handle.h"
#include "pio_rpc.h"
extern int cdiDefaultCalendar;
......@@ -44,11 +46,12 @@ static void taxisPrintP ( void * taxisptr );
static int taxisGetSizeP ( void * taxisptr, MPI_Comm comm );
static void taxisPackP ( void * taxisptr, void *buf, int size,
int *position, MPI_Comm comm );
static int taxisTxCode ( void * taxisptr );
#endif
resOps taxisOps = { taxisCompareP, taxisDestroyP, taxisPrintP
#ifdef USE_MPI
, taxisGetSizeP, taxisPackP
, taxisGetSizeP, taxisPackP, taxisTxCode
#endif
};
......@@ -1274,7 +1277,13 @@ int taxisCompareP ( void * taxisptr1, void * taxisptr2 )
#ifdef USE_MPI
static
static int
taxisTxCode ( void * taxisptr )
{
return TAXIS;
}
static
int taxisGetSizeP ( void * taxisptr, MPI_Comm comm )
{
xdebug ();
......
......@@ -10,6 +10,7 @@
#include "namespace.h"
#include "pio_util.h"
#include "resource_handle.h"
#include "pio_rpc.h"
static int VLIST_Debug = 0;
......@@ -51,6 +52,7 @@ vlistPrintKernel(vlist_t *vlistptr);
static int vlistGetSizeP ( void * vlistptr, MPI_Comm comm );
static void vlistPackP ( void * vlistptr, void * buff, int size,
int *position, MPI_Comm comm );
static int vlistTxCode(void *vlistptr);
#endif
resOps vlist_ops = {
......@@ -59,7 +61,8 @@ resOps vlist_ops = {
(valPrintFunc)vlistPrintKernel
#ifdef USE_MPI
, vlistGetSizeP,
vlistPackP
vlistPackP,
vlistTxCode
#endif
};
......@@ -1501,6 +1504,17 @@ int vlistHasTime(int vlistID)
#ifdef USE_MPI
enum {
vlist_nints=7,
};
static int
vlistTxCode(void *vlistptr)
{
return VLIST;
}
static
int vlistGetSizeP ( void * vlistptr, MPI_Comm comm )
{
......
......@@ -12,6 +12,7 @@
#include "stream_int.h"
#include "pio_util.h"
#include "resource_handle.h"
#include "pio_rpc.h"
#include "varscan.h"
......@@ -68,11 +69,12 @@ static void zaxisPrintP ( void * zaxisptr );
static int zaxisGetSizeP ( void * zaxisptr, MPI_Comm comm );
static void zaxisPackP ( void * zaxisptr, void * buffer, int size,
int *pos, MPI_Comm comm);
static int zaxisTxCode ( void * zaxisptr );
#endif
resOps zaxisOps = { zaxisCompareP, zaxisDestroyP, zaxisPrintP
#ifdef USE_MPI
, zaxisGetSizeP, zaxisPackP
, zaxisGetSizeP, zaxisPackP, zaxisTxCode
#endif
};
......@@ -1197,6 +1199,12 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
#ifdef USE_MPI
static int
zaxisTxCode ( void * zaxisptr )
{
return ZAXIS;
}
static
int zaxisGetSizeP ( void * zaxisptr, MPI_Comm comm )
{
......
Markdown is supported
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