Commit 65342830 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

move streamWriteRecord to stream_write.c

parent c99f1ef7
......@@ -384,6 +384,7 @@ void streamInqRecord(int streamID, int *varID, int *levelID);
void streamWriteRecord(int streamID, const double data[], int nmiss);
void streamWriteRecordF(int streamID, const float data[], int nmiss);
void streamReadRecord(int streamID, double data[], int *nmiss);
void streamReadRecordF(int streamID, float data[], int *nmiss);
void streamCopyRecord(int streamIDdest, int streamIDsrc);
void streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignum);
......
......@@ -259,6 +259,7 @@ module mo_cdi
public :: streamWriteRecord
public :: streamWriteRecordF
public :: streamReadRecord
public :: streamReadRecordF
public :: streamCopyRecord
public :: cdiIterator_new
public :: cdiIterator_clone
......@@ -964,6 +965,14 @@ module mo_cdi
integer(c_int), intent(inout) :: nmiss_dummy
end subroutine streamReadRecord
subroutine streamReadRecordF(streamID_dummy, data_dummy, nmiss_dummy)&
& bind(c, name = 'streamReadRecordF')
import c_float, c_int
integer(c_int), value :: streamID_dummy
real(c_float), intent(inout) :: data_dummy(*)
integer(c_int), intent(inout) :: nmiss_dummy
end subroutine streamReadRecordF
subroutine streamCopyRecord(streamIDdest_dummy, streamIDsrc_dummy) bind(c,&
& name = 'streamCopyRecord')
import c_int
......
......@@ -269,83 +269,6 @@ void streamReadRecord(int streamID, double *data, int *nmiss)
}
}
static void
stream_write_record(int streamID, int memtype, const void *data, int nmiss)
{
check_parg(data);
stream_t *streamptr = stream_to_pointer(streamID);
stream_check_ptr(__func__, streamptr);
switch (streamptr->filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
grb_write_record(streamptr, memtype, data, nmiss);
break;
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteRecord not implemented for memtype float!");
srvWriteRecord(streamptr, (const double *)data);
break;
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteRecord not implemented for memtype float!");
extWriteRecord(streamptr, (const double *)data);
break;
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteRecord not implemented for memtype float!");
iegWriteRecord(streamptr, (const double *)data);
break;
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
{
cdf_write_record(streamptr, memtype, data, nmiss);
break;
}
#endif
default:
{
Error("%s support not compiled in!", strfiletype(streamptr->filetype));
break;
}
}
}
/*
@Function streamWriteRecord
@Title Write a horizontal slice of a variable
@Prototype void streamWriteRecord(int streamID, const double *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@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 streamWriteRecord writes the values of a horizontal slice (record) of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
@EndFunction
*/
void streamWriteRecord(int streamID, const double *data, int nmiss)
{
stream_write_record(streamID, MEMTYPE_DOUBLE, (const void *) data, nmiss);
}
void streamWriteRecordF(int streamID, const float *data, int nmiss)
{
stream_write_record(streamID, MEMTYPE_FLOAT, (const void *) data, nmiss);
}
void streamCopyRecord(int streamID2, int streamID1)
{
......
......@@ -311,3 +311,81 @@ cdiStreamWriteVarChunk_(int streamID, int varID, int memtype,
break;
}
}
static
void stream_write_record(int streamID, int memtype, const void *data, int nmiss)
{
check_parg(data);
stream_t *streamptr = stream_to_pointer(streamID);
stream_check_ptr(__func__, streamptr);
switch (streamptr->filetype)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
grb_write_record(streamptr, memtype, data, nmiss);
break;
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteRecord not implemented for memtype float!");
srvWriteRecord(streamptr, (const double *)data);
break;
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteRecord not implemented for memtype float!");
extWriteRecord(streamptr, (const double *)data);
break;
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteRecord not implemented for memtype float!");
iegWriteRecord(streamptr, (const double *)data);
break;
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
{
cdf_write_record(streamptr, memtype, data, nmiss);
break;
}
#endif
default:
{
Error("%s support not compiled in!", strfiletype(streamptr->filetype));
break;
}
}
}
/*
@Function streamWriteRecord
@Title Write a horizontal slice of a variable
@Prototype void streamWriteRecord(int streamID, const double *data, int nmiss)
@Parameter
@Item streamID Stream ID, from a previous call to @fref{streamOpenWrite}.
@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 streamWriteRecord writes the values of a horizontal slice (record) of a variable to an open dataset.
The values are converted to the external data type of the variable, if necessary.
@EndFunction
*/
void streamWriteRecord(int streamID, const double *data, int nmiss)
{
stream_write_record(streamID, MEMTYPE_DOUBLE, (const void *) data, nmiss);
}
void streamWriteRecordF(int streamID, const float *data, int nmiss)
{
stream_write_record(streamID, MEMTYPE_FLOAT, (const void *) data, nmiss);
}
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