Commit 30c9bac5 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

moved streamWriteVar functions to stream_write.c

parent 1d65d88a
......@@ -341,6 +341,7 @@ src/stream_record.c -text
src/stream_srv.c -text
src/stream_srv.h -text
src/stream_var.c -text
src/stream_write.c -text
src/subtype.c -text
src/subtype.h -text
src/swap.c -text
......
......@@ -116,7 +116,8 @@ libcdi_la_SOURCES = \
zaxis.c \
zaxis.h \
stream.c \
swap.c \
stream_write.c \
swap.c \
iterator.c \
iterator.h \
iterator_fallback.c \
......
......@@ -187,7 +187,7 @@ am__libcdi_la_SOURCES_DIST = basetime.c basetime.h binary.c binary.h \
tablepar.h taxis.c taxis.h timebase.c timebase.h tsteps.c \
util.c varscan.c varscan.h version.c vlist.c vlist.h \
vlist_att.c vlist_att.h vlist_var.c vlist_var.h zaxis.c \
zaxis.h stream.c swap.c iterator.c iterator.h \
zaxis.h stream.c stream_write.c swap.c iterator.c iterator.h \
iterator_fallback.c iterator_fallback.h iterator_grib.c \
iterator_grib.h cfortran.h cdiFortran.c gribapi_utilities.c
am__objects_1 = cdiFortran.lo
......@@ -205,9 +205,9 @@ am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
stream_fcommon.lo cdi_int.lo stream_record.lo stream_srv.lo \
stream_var.lo subtype.lo table.lo taxis.lo timebase.lo \
tsteps.lo util.lo varscan.lo version.lo vlist.lo vlist_att.lo \
vlist_var.lo zaxis.lo stream.lo swap.lo iterator.lo \
iterator_fallback.lo iterator_grib.lo $(am__objects_2) \
$(am__objects_4)
vlist_var.lo zaxis.lo stream.lo stream_write.lo swap.lo \
iterator.lo iterator_fallback.lo iterator_grib.lo \
$(am__objects_2) $(am__objects_4)
libcdi_la_OBJECTS = $(am_libcdi_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
......@@ -531,10 +531,10 @@ libcdi_la_SOURCES = basetime.c basetime.h binary.c binary.h calendar.c \
subtype.c subtype.h swap.h table.c table.h tablepar.h taxis.c \
taxis.h timebase.c timebase.h tsteps.c util.c varscan.c \
varscan.h version.c vlist.c vlist.h vlist_att.c vlist_att.h \
vlist_var.c vlist_var.h zaxis.c zaxis.h stream.c swap.c \
iterator.c iterator.h iterator_fallback.c iterator_fallback.h \
iterator_grib.c iterator_grib.h $(am__append_2) \
$(am__append_3)
vlist_var.c vlist_var.h zaxis.c zaxis.h stream.c \
stream_write.c swap.c iterator.c iterator.h \
iterator_fallback.c iterator_fallback.h iterator_grib.c \
iterator_grib.h $(am__append_2) $(am__append_3)
# cfortran.h is an optional part of libcdi
libcdi_la_USE_FC_extra_sources = \
......@@ -755,6 +755,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_record.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_srv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_var.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_write.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subtype.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table.Plo@am__quote@
......
......@@ -121,6 +121,7 @@ files="basetime.c \
serialize.c \
servicelib.c \
stream.c \
stream_write.c \
stream_cdf.c \
stream_cgribex.c \
stream_ext.c \
......
......@@ -1449,127 +1449,6 @@ void streamReadVarF(int streamID, int varID, float *data, int *nmiss)
cdiStreamReadVar(streamID, varID, MEMTYPE_FLOAT, data, nmiss);
}
/* the single image implementation */
void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data, int nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
check_parg(data);
stream_t *streamptr = stream_to_pointer(streamID);
if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
Error("Writing of non-trivial subtypes not yet implemented!");
stream_check_ptr(__func__, streamptr);
// check taxis
if ( streamptr->curTsID == CDI_UNDEFID ) streamDefTimestep(streamID, 0);
int filetype = streamptr->filetype;
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
{
grb_write_var(streamptr, varID, memtype, data, nmiss);
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
{
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVar not implemented for memtype float!");
srvWriteVarDP(streamptr, varID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
{
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVar not implemented for memtype float!");
extWriteVarDP(streamptr, varID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
{
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVar not implemented for memtype float!");
iegWriteVarDP(streamptr, varID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
{
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
cdf_write_var(streamptr, varID, memtype, (double *)data, nmiss);
break;
}
#endif
default:
{
Error("%s support not compiled in!", strfiletype(filetype));
break;
}
}
}
/*
@Function streamWriteVar
@Title Write a variable
@Prototype void streamWriteVar(int streamID, int varID, const double *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item data Pointer to a block of double precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVar writes the values of one time step of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
@EndFunction
*/
void streamWriteVar(int streamID, int varID, const double *data, int nmiss)
{
void (*myCdiStreamWriteVar_)(int streamID, int varID, int memtype,
const void *data, int nmiss)
= (void (*)(int, int, int, const void *, int))
namespaceSwitchGet(NSSWITCH_STREAM_WRITE_VAR_).func;
myCdiStreamWriteVar_(streamID, varID, MEMTYPE_DOUBLE, data, nmiss);
}
/*
@Function streamWriteVarF
@Title Write a variable
@Prototype void streamWriteVarF(int streamID, int varID, const float *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item data Pointer to a block of single precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVarF writes the values of one time step of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
Only support for netCDF was implemented in this function.
@EndFunction
*/
void streamWriteVarF(int streamID, int varID, const float *data, int nmiss)
{
void (*myCdiStreamWriteVar_)(int streamID, int varID, int memtype,
const void *data, int nmiss)
= (void (*)(int, int, int, const void *, int))
namespaceSwitchGet(NSSWITCH_STREAM_WRITE_VAR_).func;
myCdiStreamWriteVar_(streamID, varID, MEMTYPE_FLOAT, data, nmiss);
}
static
int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, void *data, int *nmiss)
......@@ -1710,184 +1589,6 @@ void streamReadVarSliceF(int streamID, int varID, int levelID, float *data, int
}
}
static
void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, const void *data, int nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
check_parg(data);
stream_t *streamptr = stream_to_pointer(streamID);
if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
Error("Writing of non-trivial subtypes not yet implemented!");
stream_check_ptr(__func__, streamptr);
// check taxis
if ( streamptr->curTsID == CDI_UNDEFID ) streamDefTimestep(streamID, 0);
int filetype = streamptr->filetype;
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
{
grb_write_var_slice(streamptr, varID, levelID, memtype, data, nmiss);
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
{
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVarSlice not implemented for memtype float!");
srvWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
{
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVarSlice not implemented for memtype float!");
extWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
{
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVarSlice not implemented for memtype float!");
iegWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
cdf_write_var_slice(streamptr, varID, levelID, memtype, data, nmiss);
break;
#endif
default:
{
Error("%s support not compiled in!", strfiletype(filetype));
break;
}
}
}
/*
@Function streamWriteVarSlice
@Title Write a horizontal slice of a variable
@Prototype void streamWriteVarSlice(int streamID, int varID, int levelID, const double *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item levelID Level identifier.
@Item data Pointer to a block of double precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVarSlice writes the values of a horizontal slice of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
@EndFunction
*/
void streamWriteVarSlice(int streamID, int varID, int levelID, const double *data, int nmiss)
{
cdiStreamWriteVarSlice(streamID, varID, levelID, MEMTYPE_DOUBLE, data, nmiss);
}
/*
@Function streamWriteVarSliceF
@Title Write a horizontal slice of a variable
@Prototype void streamWriteVarSliceF(int streamID, int varID, int levelID, const float *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item levelID Level identifier.
@Item data Pointer to a block of single precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVarSliceF writes the values of a horizontal slice of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
Only support for netCDF was implemented in this function.
@EndFunction
*/
void streamWriteVarSliceF(int streamID, int varID, int levelID, const float *data, int nmiss)
{
cdiStreamWriteVarSlice(streamID, varID, levelID, MEMTYPE_FLOAT, data, nmiss);
}
void
streamWriteVarChunk(int streamID, int varID,
const int rect[][2], const double *data, int nmiss)
{
void (*myCdiStreamWriteVarChunk_)(int streamID, int varID, int memtype,
const int rect[][2], const void *data,
int nmiss)
= (void (*)(int, int, int, const int [][2], const void *, int))
namespaceSwitchGet(NSSWITCH_STREAM_WRITE_VAR_CHUNK_).func;
myCdiStreamWriteVarChunk_(streamID, varID, MEMTYPE_DOUBLE, rect, data, nmiss);
}
/* single image implementation */
void
cdiStreamWriteVarChunk_(int streamID, int varID, int memtype,
const int rect[][2], const void *data, int nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
stream_t *streamptr = stream_to_pointer(streamID);
stream_check_ptr(__func__, streamptr);
// streamDefineTaxis(streamID);
int filetype = streamptr->filetype;
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
#endif
#if defined (HAVE_LIBGRIB) || defined (HAVE_LIBSERVICE) \
|| defined (HAVE_LIBEXTRA) || defined (HAVE_LIBIEG)
xabort("streamWriteVarChunk not implemented for filetype %s!",
strfiletype(filetype));
break;
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
cdf_write_var_chunk(streamptr, varID, memtype, rect, data, nmiss);
break;
#endif
default:
Error("%s support not compiled in!", strfiletype(filetype));
break;
}
}
#if 0
void streamWriteContents(int streamID, char *cname)
{
......
#if defined (HAVE_CONFIG_H)
# include "config.h"
#endif
#include "cdi.h"
#include "cdi_int.h"
#include "stream_grb.h"
#include "stream_cdf.h"
#include "stream_srv.h"
#include "stream_ext.h"
#include "stream_ieg.h"
#include "namespace.h"
/* the single image implementation */
void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data, int nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
check_parg(data);
stream_t *streamptr = stream_to_pointer(streamID);
if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
Error("Writing of non-trivial subtypes not yet implemented!");
stream_check_ptr(__func__, streamptr);
// check taxis
if ( streamptr->curTsID == CDI_UNDEFID ) streamDefTimestep(streamID, 0);
int filetype = streamptr->filetype;
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
{
grb_write_var(streamptr, varID, memtype, data, nmiss);
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
{
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVar not implemented for memtype float!");
srvWriteVarDP(streamptr, varID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
{
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVar not implemented for memtype float!");
extWriteVarDP(streamptr, varID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
{
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVar not implemented for memtype float!");
iegWriteVarDP(streamptr, varID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
{
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
cdf_write_var(streamptr, varID, memtype, (double *)data, nmiss);
break;
}
#endif
default:
{
Error("%s support not compiled in!", strfiletype(filetype));
break;
}
}
}
/*
@Function streamWriteVar
@Title Write a variable
@Prototype void streamWriteVar(int streamID, int varID, const double *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item data Pointer to a block of double precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVar writes the values of one time step of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
@EndFunction
*/
void streamWriteVar(int streamID, int varID, const double *data, int nmiss)
{
void (*myCdiStreamWriteVar_)(int streamID, int varID, int memtype,
const void *data, int nmiss)
= (void (*)(int, int, int, const void *, int))
namespaceSwitchGet(NSSWITCH_STREAM_WRITE_VAR_).func;
myCdiStreamWriteVar_(streamID, varID, MEMTYPE_DOUBLE, data, nmiss);
}
/*
@Function streamWriteVarF
@Title Write a variable
@Prototype void streamWriteVarF(int streamID, int varID, const float *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item data Pointer to a block of single precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVarF writes the values of one time step of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
Only support for netCDF was implemented in this function.
@EndFunction
*/
void streamWriteVarF(int streamID, int varID, const float *data, int nmiss)
{
void (*myCdiStreamWriteVar_)(int streamID, int varID, int memtype,
const void *data, int nmiss)
= (void (*)(int, int, int, const void *, int))
namespaceSwitchGet(NSSWITCH_STREAM_WRITE_VAR_).func;
myCdiStreamWriteVar_(streamID, varID, MEMTYPE_FLOAT, data, nmiss);
}
static
void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, const void *data, int nmiss)
{
if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
check_parg(data);
stream_t *streamptr = stream_to_pointer(streamID);
if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
Error("Writing of non-trivial subtypes not yet implemented!");
stream_check_ptr(__func__, streamptr);
// check taxis
if ( streamptr->curTsID == CDI_UNDEFID ) streamDefTimestep(streamID, 0);
int filetype = streamptr->filetype;
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
{
grb_write_var_slice(streamptr, varID, levelID, memtype, data, nmiss);
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
{
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVarSlice not implemented for memtype float!");
srvWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
{
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVarSlice not implemented for memtype float!");
extWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
{
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVarSlice not implemented for memtype float!");
iegWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
cdf_write_var_slice(streamptr, varID, levelID, memtype, data, nmiss);
break;
#endif
default:
{
Error("%s support not compiled in!", strfiletype(filetype));
break;
}
}
}
/*
@Function streamWriteVarSlice
@Title Write a horizontal slice of a variable
@Prototype void streamWriteVarSlice(int streamID, int varID, int levelID, const double *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item levelID Level identifier.
@Item data Pointer to a block of double precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVarSlice writes the values of a horizontal slice of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
@EndFunction
*/
void streamWriteVarSlice(int streamID, int varID, int levelID, const double *data, int nmiss)
{
cdiStreamWriteVarSlice(streamID, varID, levelID, MEMTYPE_DOUBLE, data, nmiss);
}
/*
@Function streamWriteVarSliceF
@Title Write a horizontal slice of a variable
@Prototype void streamWriteVarSliceF(int streamID, int varID, int levelID, const float *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@Item varID Variable identifier.
@Item levelID Level identifier.
@Item data Pointer to a block of single precision floating point data values to be written.
@Item nmiss Number of missing values.
@Description
The function streamWriteVarSliceF writes the values of a horizontal slice of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.