Commit 66844e26 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Move serial netCDF library owner rank to table internal to pio_server.

parent 781cefd8
...@@ -254,8 +254,6 @@ typedef struct { ...@@ -254,8 +254,6 @@ typedef struct {
#else #else
void *gribContainers; void *gribContainers;
#endif #endif
/* only used by MPI-parallelized version of library */
int ownerRank; // MPI rank of owner process
void *gh; // grib handle void *gh; // grib handle
} }
......
...@@ -51,6 +51,9 @@ static struct ...@@ -51,6 +51,9 @@ static struct
{ {
MPI_Win getWin; MPI_Win getWin;
struct clientBuf *clientBuf; struct clientBuf *clientBuf;
#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
int ownerRank;
#endif
} *rxWin; } *rxWin;
static struct idList openStreams; static struct idList openStreams;
...@@ -442,11 +445,13 @@ writeNetCDFStream(size_t streamIdx, ...@@ -442,11 +445,13 @@ writeNetCDFStream(size_t streamIdx,
/* cdiOpenFileMap(fileID) gives the writer process */ /* cdiOpenFileMap(fileID) gives the writer process */
static int cdiPioSerialOpenFileMap(int streamID) static int cdiPioSerialOpenFileMap(int streamID)
{ {
return stream_to_pointer(streamID)->ownerRank; size_t streamIdx = indexOfID(&openStreams, streamID);
xassert(streamIdx < SIZE_MAX);
return rxWin[streamIdx].ownerRank;
} }
/* for load-balancing purposes, count number of files per process */ /* for load-balancing purposes, count number of files per process */
/* cdiOpenFileCounts[rank] gives number of open files rank has to himself */ /* cdiOpenFileCounts[rank] gives number of open files rank has to himself */
static int *cdiSerialOpenFileCount = NULL; static int *cdiSerialOpenFileCount;
static int static int
cdiPioNextOpenRank() cdiPioNextOpenRank()
...@@ -807,14 +812,16 @@ cdiPioServerStreamOpen(const char *filename, char filemode, ...@@ -807,14 +812,16 @@ cdiPioServerStreamOpen(const char *filename, char filemode,
int recordBufIsToBeCreated) int recordBufIsToBeCreated)
{ {
int fileID; int fileID;
#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
/* Only needs initialization to shut up gcc */
int rank = -1;
#endif
switch (filetype) switch (filetype)
{ {
#if defined (HAVE_LIBNETCDF) && ! defined (HAVE_PARALLEL_NC4) #if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
case FILETYPE_NC4: case FILETYPE_NC4:
case FILETYPE_NC4C: case FILETYPE_NC4C:
{ {
/* Only needs initialization to shut up gcc */
int rank = -1;
int ioMode = commInqIOMode(); int ioMode = commInqIOMode();
if (ioMode == PIO_NONE if (ioMode == PIO_NONE
|| commInqRankColl() == (rank = cdiPioNextOpenRank())) || commInqRankColl() == (rank = cdiPioNextOpenRank()))
...@@ -825,7 +832,6 @@ cdiPioServerStreamOpen(const char *filename, char filemode, ...@@ -825,7 +832,6 @@ cdiPioServerStreamOpen(const char *filename, char filemode,
streamptr->filetype = filetype; streamptr->filetype = filetype;
if (ioMode != PIO_NONE) if (ioMode != PIO_NONE)
xmpi(MPI_Bcast(&fileID, 1, MPI_INT, rank, commInqCommColl())); xmpi(MPI_Bcast(&fileID, 1, MPI_INT, rank, commInqCommColl()));
streamptr->ownerRank = rank;
cdiPioOpenFileOnRank(rank); cdiPioOpenFileOnRank(rank);
} }
break; break;
...@@ -851,6 +857,9 @@ cdiPioServerStreamOpen(const char *filename, char filemode, ...@@ -851,6 +857,9 @@ cdiPioServerStreamOpen(const char *filename, char filemode,
for (size_t i = oldNumStreams; i < numStreams; ++i) for (size_t i = oldNumStreams; i < numStreams; ++i)
rxWin[i].clientBuf = newClientBufs + i * (size_t)numClients_; rxWin[i].clientBuf = newClientBufs + i * (size_t)numClients_;
rxWin[streamIdx].getWin = MPI_WIN_NULL; rxWin[streamIdx].getWin = MPI_WIN_NULL;
#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
rxWin[streamIdx].ownerRank = rank;
#endif
} }
return fileID; return fileID;
} }
......
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