Commit ee566da9 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Change cdfCopyRecord to not propagate errors.

Fail early instead.
parent e1ea901c
......@@ -606,39 +606,30 @@ void defineAttributes(int vlistID, int varID, int fileID, int ncvarID)
}
#endif
int cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
void cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
{
double *data;
int datasize;
int tsID1, recID1;
int ivarID, gridID;
int nmiss;
int ierr = 0;
int memtype = MEMTYPE_DOUBLE;
int vlistID1;
vlistID1 = streamptr1->vlistID;
int vlistID1 = streamptr1->vlistID;
tsID1 = streamptr1->curTsID;
int tsID1 = streamptr1->curTsID;
recID1 = streamptr1->tsteps[tsID1].curRecID;
int recID1 = streamptr1->tsteps[tsID1].curRecID;
ivarID = streamptr1->tsteps[tsID1].records[recID1].varID;
int ivarID = streamptr1->tsteps[tsID1].records[recID1].varID;
gridID = vlistInqVarGrid(vlistID1, ivarID);
int gridID = vlistInqVarGrid(vlistID1, ivarID);
datasize = gridInqSize(gridID);
int datasize = gridInqSize(gridID);
/* bug fix for constant netCDF fields */
if ( datasize < 1048576 ) datasize = 1048576;
data = (double *) malloc(datasize*sizeof(double));
double *data = xmalloc(datasize*sizeof(double));
int nmiss;
cdfReadRecord(streamptr1, data, &nmiss);
cdf_write_record(streamptr2, memtype, data, nmiss);
free(data);
return (ierr);
}
/* not used
......
......@@ -12,7 +12,7 @@ void cdfInqHistoryString(stream_t *streamptr, char *history);
void cdfEndDef(stream_t * streamptr);
void cdfDefRecord(stream_t * streamptr);
int cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
void cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
void cdfReadRecord(stream_t *streamptr, double *data, int *nmiss);
void cdf_write_record(stream_t *streamptr, int memtype, const void *data, int nmiss);
......
......@@ -398,7 +398,6 @@ void streamWriteRecordF(int streamID, const float *data, int nmiss)
void streamCopyRecord(int streamID2, int streamID1)
{
int status = 0;
int filetype = FILETYPE_UNDEF, filetype1, filetype2;
stream_t *streamptr1;
stream_t *streamptr2;
......@@ -466,11 +465,8 @@ void streamCopyRecord(int streamID2, int streamID1)
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
{
/* FIXME: return value not inspected */
status = cdfCopyRecord(streamptr2, streamptr1);
break;
}
cdfCopyRecord(streamptr2, streamptr1);
break;
#endif
default:
{
......
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