Commit 87d784e2 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Virtualize fileWrite.

parent cb3252e9
......@@ -27,6 +27,7 @@ static int activeNamespace = 0;
serializePackInCore, \
serializeUnpackInCore, \
fileOpen_serial, \
fileWrite, \
fileClose_serial, \
cdiStreamOpenDefaultDelegate, \
cdiStreamDefVlist_, \
......
......@@ -26,6 +26,7 @@ enum namespaceSwitch
NSSWITCH_SERIALIZE_PACK,
NSSWITCH_SERIALIZE_UNPACK,
NSSWITCH_FILE_OPEN,
NSSWITCH_FILE_WRITE,
NSSWITCH_FILE_CLOSE,
NSSWITCH_STREAM_OPEN_BACKEND,
NSSWITCH_STREAM_DEF_VLIST_,
......
......@@ -64,7 +64,8 @@ struct fileOpTag decodeFileOpTag(int tag)
/***************************************************************/
size_t pioFileWrite ( int fileID, int tsID, const void *buffer, size_t len )
size_t
cdiPioFileWrite(int fileID, const void *restrict buffer, size_t len, int tsID)
{
size_t iret = CDI_UNDEFID;
......
......@@ -16,7 +16,8 @@ void backendInit ( void );
void backendFinalize ( void );
int pioFileOpen(const char *filename, const char *mode);
int pioFileClose ( int );
size_t pioFileWrite ( int, int, const void*, size_t );
size_t cdiPioFileWrite(int fileID, const void *restrict buffer, size_t len,
int tsID);
int cdiPioStreamOpen(const char *filename, const char *filemode,
int filetype, stream_t *streamptr,
int recordBufIsToBeCreated);
......
......@@ -920,7 +920,8 @@ void IOServer ()
namespaceSwitchSet(NSSWITCH_STREAM_CLOSE_BACKEND, cdiPioStreamCDFCloseWrap);
namespaceSwitchSet(NSSWITCH_CDF_DEF_TIMESTEP, cdiPioCdfDefTimestep);
#endif
namespaceSwitchSet(NSSWITCH_FILE_WRITE, cdiPioFileWrite);
for ( ;; )
{
xmpi ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, commCalc, &status ));
......
......@@ -13,11 +13,7 @@
#include "file.h"
#include "cgribex.h" /* gribZip gribGetZip gribGinfo */
#include "gribapi.h"
#ifdef USE_MPI
#include "pio.h"
#include "pio_comm.h"
#endif
#include "namespace.h"
int grib1ltypeToZaxisType(int grib_ltype)
......@@ -558,14 +554,12 @@ int grb_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtype
if ( streamptr->comptype == COMPRESS_SZIP )
nbytes = grbSzip(filetype, gribbuffer, nbytes);
/* begin deike */
#ifdef USE_MPI
if ( commInqIOMode () != PIO_NONE )
nwrite = pioFileWrite ( fileID, tsID, gribbuffer, nbytes );
else
#endif
/* end deike */
nwrite = fileWrite(fileID, gribbuffer, nbytes);
{
size_t (*myFileWrite)(int fileID, const void *restrict buffer,
size_t len, int tsID)
= namespaceSwitchGet(NSSWITCH_FILE_WRITE);
nwrite = myFileWrite(fileID, gribbuffer, nbytes, tsID);
}
if ( nwrite != nbytes ) perror(__func__);
......
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