Commit 39a2a0fc authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Change logic for netCDF file setup.

parent 4c108660
......@@ -22,9 +22,6 @@
#include "serialize.h"
#include "resource_handle.h"
#include "resource_unpack.h"
#ifdef USE_MPI
#include "pio_comm.h"
#endif
#if defined (HAVE_LIBCGRIBEX)
#include "cgribex.h"
......@@ -680,22 +677,17 @@ cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
vlistInqVarMissval(vlistID, varID));
}
if (namespaceHasLocalFile(namespaceGetActive())
&& streamptr->filemode == 'w' )
if (streamptr->filemode == 'w' )
{
if ( streamptr->filetype == FILETYPE_NC ||
streamptr->filetype == FILETYPE_NC2 ||
streamptr->filetype == FILETYPE_NC4 ||
streamptr->filetype == FILETYPE_NC4C )
{
#if USE_MPI && defined (HAVE_LIBNETCDF) && ! defined (HAVE_PARALLEL_NC4)
int rank, rankOpen;
if (commInqIOMode() == PIO_NONE
|| ((rank = commInqRankColl())
== (rankOpen = cdiPioSerialOpenFileMap(streamptr->self))))
#endif
#ifdef HAVE_LIBNETCDF
cdfDefVars(streamptr);
void (*myCdfDefVars)(stream_t *streamptr)
= namespaceSwitchGet(NSSWITCH_CDF_STREAM_SETUP);
myCdfDefVars(streamptr);
#endif
}
else if ( streamptr->filetype == FILETYPE_GRB ||
......
......@@ -16,7 +16,8 @@ static int nNamespaces = 1;
static int activeNamespace = 0;
#ifdef HAVE_LIBNETCDF
#define CDI_NETCDF_SWITCHES nc__create,cdf_def_var_serial,cdfDefTimestep,
#define CDI_NETCDF_SWITCHES nc__create,cdf_def_var_serial,cdfDefTimestep,\
cdfDefVars
#else
#define CDI_NETCDF_SWITCHES
#endif
......
......@@ -37,6 +37,7 @@ enum namespaceSwitch
NSSWITCH_NC__CREATE,
NSSWITCH_CDF_DEF_VAR,
NSSWITCH_CDF_DEF_TIMESTEP,
NSSWITCH_CDF_STREAM_SETUP,
#endif
NUM_NAMESPACE_SWITCH,
};
......
......@@ -98,6 +98,11 @@ static void
cdiPioCdfDefTimestepNOP(stream_t *streamptr, int tsID)
{
}
static void
cdiPioClientCdfDefVarsNOP(stream_t *streamptr)
{
}
#endif
static void
......@@ -136,6 +141,7 @@ cdiPioClientSetup(int *pioNamespace_, int *pioNamespace)
namespaceSwitchSet(NSSWITCH_STREAM_CLOSE_BACKEND, cdiPioClientStreamClose);
#ifdef HAVE_LIBNETCDF
namespaceSwitchSet(NSSWITCH_CDF_DEF_TIMESTEP, cdiPioCdfDefTimestepNOP);
namespaceSwitchSet(NSSWITCH_CDF_STREAM_SETUP, cdiPioClientCdfDefVarsNOP);
#endif
pioNamespaceSetActive(callerCDINamespace);
}
......
......@@ -426,6 +426,16 @@ void cdiPioCloseFileOnRank(int rank)
--(cdiSerialOpenFileCount[rank]);
}
static void
cdiPioServerCdfDefVars(stream_t *streamptr)
{
int rank, rankOpen;
if (commInqIOMode() == PIO_NONE
|| ((rank = commInqRankColl())
== (rankOpen = cdiPioSerialOpenFileMap(streamptr->self))))
cdfDefVars(streamptr);
}
#endif
static
......@@ -927,6 +937,7 @@ void IOServer ()
namespaceSwitchSet(NSSWITCH_STREAM_OPEN_BACKEND, cdiPioStreamCDFOpenWrap);
namespaceSwitchSet(NSSWITCH_STREAM_CLOSE_BACKEND, cdiPioStreamCDFCloseWrap);
namespaceSwitchSet(NSSWITCH_CDF_DEF_TIMESTEP, cdiPioCdfDefTimestep);
namespaceSwitchSet(NSSWITCH_CDF_STREAM_SETUP, cdiPioServerCdfDefVars);
#endif
namespaceSwitchSet(NSSWITCH_FILE_WRITE, cdiPioFileWrite);
......
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