Commit 164abdce authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add transfer of variable lists.

* This implementation is very incomplete.
parent 6985d0b6
......@@ -261,6 +261,7 @@ src/vlist.c -text
src/vlist.h -text
src/vlist_att.c -text
src/vlist_var.c -text
src/vlist_var.h -text
src/zaxis.c -text
tables/cosmo002 -text
tables/cosmo201 -text
......
......@@ -8,6 +8,7 @@
#include "cdi.h"
#include "institution.h"
#include "model.h"
#include "vlist.h"
MPI_Comm commGlob;
int sizeGlob;
......@@ -242,6 +243,7 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
unpackStream ( unpackBuffer, unpackBufferSize, &unpackBufferPos, comm );
break;
case VLIST:
vlistUnpack(unpackBuffer, unpackBufferSize, &unpackBufferPos, comm);
break;
default:
xabort ( "no valid datatype" );
......
......@@ -10,6 +10,7 @@
#include "namespace.h"
#include "pio_util.h"
#include "resource_handle.h"
#include "vlist_var.h"
#include "pio_rpc.h"
static int VLIST_Debug = 0;
......@@ -129,7 +130,6 @@ void vlist_initialize(void)
env = getenv("VLIST_DEBUG");
if ( env ) VLIST_Debug = atoi(env);
}
static
......@@ -1518,17 +1518,55 @@ vlistTxCode(void *vlistptr)
static
int vlistGetSizeP ( void * vlistptr, MPI_Comm comm )
{
int txsize, varID;
xdebug ();
return 0;
xmpi(MPI_Pack_size(vlist_nints, MPI_INT, comm, &txsize));
for ( varID = 0; varID < ((vlist_t *)vlistptr)->nvars; varID++ )
{
txsize += vlistVarGetSize(((vlist_t *)vlistptr)->vars + varID, comm);
}
return txsize;
}
static
void vlistPackP ( void * vlistptr, void * buff, int size, int *position,
void vlistPackP ( void * vlistptr, void * buf, int size, int *position,
MPI_Comm comm )
{
int varID, tempbuf[vlist_nints];
vlist_t *p = vlistptr;
xdebug ();
tempbuf[0] = p->self;
tempbuf[1] = p->nvars;
tempbuf[2] = p->ntsteps;
tempbuf[3] = p->taxisID;
tempbuf[4] = p->tableID;
tempbuf[5] = p->instID;
tempbuf[6] = p->modelID;
xmpi(MPI_Pack(tempbuf, vlist_nints, MPI_INT, buf, size, position, comm));
for ( varID = 0; varID < p->nvars; varID++ )
{
vlistVarPack(p->vars + varID, buf, size, position, comm);
}
}
void vlistUnpack(char * buf, int size, int *position, MPI_Comm comm)
{
int newvlist;
int varID, tempbuf[vlist_nints];
xmpi(MPI_Unpack(buf, size, position, tempbuf, vlist_nints, MPI_INT, comm));
newvlist = vlistCreate();
/* assert(newvlist == tempbuf[0]); */
vlistDefTaxis(newvlist, tempbuf[3]);
vlistDefTable(newvlist, tempbuf[4]);
vlistDefInstitut(newvlist, tempbuf[5]);
vlistDefModel(newvlist, tempbuf[6]);
for ( varID = 0; varID < tempbuf[1]; varID++ )
{
vlistVarUnpack(newvlist, buf, size, position, comm);
}
}
#endif
#ifndef _VLIST_H
#define _VLIST_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stddef.h> /* size_t */
#ifdef USE_MPI
#include <mpi.h>
#endif
#ifndef _CDI_LIMITS_H
# include "cdi_limits.h"
#endif
......@@ -116,4 +124,8 @@ int vlistHasTime(int vlistID);
int vlistDelAtts(int vlistID, int varID);
int vlistCopyVarAtts(int vlistID1, int varID_1, int vlistID2, int varID_2);
#ifdef USE_MPI
void vlistUnpack(char * buffer, int bufferSize, int * pos, MPI_Comm comm);
#endif
#endif /* _VLIST_H */
......@@ -3,13 +3,16 @@
#endif
#include <limits.h>
#ifdef USE_MPI
#include <mpi.h>
#include "pio_util.h"
#endif
#include "dmemory.h"
#include "cdi.h"
#include "stream_int.h"
#include "vlist.h"
static
void vlistvarInitEntry(int vlistID, int varID)
{
......@@ -1521,3 +1524,42 @@ int vlistInqVarZlevel(int vlistID, int varID)
return (vlistptr->vars[varID].zlevel);
}
#ifdef USE_MPI
enum {
vlistvar_nints = 4,
};
int vlistVarGetSize(var_t *var, MPI_Comm comm)
{
int varsize;
xmpi(MPI_Pack_size(vlistvar_nints, MPI_INT, comm, &varsize));
return varsize;
}
void vlistVarPack(var_t *var, char * buf, int size, int *position,
MPI_Comm comm)
{
int tempbuf[vlistvar_nints];
tempbuf[0] = var->flag;
tempbuf[1] = var->gridID;
tempbuf[2] = var->zaxisID;
tempbuf[3] = var->timeID;
xmpi(MPI_Pack(tempbuf, vlistvar_nints, MPI_INT,
buf, size, position, comm));
}
void vlistVarUnpack(int vlistID,
char * buf, int size, int *position, MPI_Comm comm)
{
int tempbuf[vlistvar_nints];
int newvar;
xmpi(MPI_Unpack(buf, size, position,
tempbuf, vlistvar_nints, MPI_INT, comm));
newvar = vlistDefVar(vlistID, tempbuf[1], tempbuf[2], tempbuf[3]);
}
#endif
#ifndef VLIST_VAR_H
#define VLIST_VAR_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef USE_MPI
#include <mpi.h>
#endif
#include "vlist.h"
#ifdef USE_MPI
int vlistVarGetSize(var_t *var, MPI_Comm comm);
void vlistVarPack(var_t *var, char * buffer, int bufferSize, int * pos,
MPI_Comm comm);
void vlistVarUnpack(int vlistID,
char * buf, int size, int *position, MPI_Comm comm);
#endif
#endif
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