Skip to content
Snippets Groups Projects
Commit efecbd02 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cat: destroy vlist and taxis if streamMode is StreamMode::CREATE.

parent 3f6f4ca7
No related branches found
No related tags found
No related merge requests found
Pipeline #13887 passed
......@@ -23,7 +23,13 @@
void *
Cat(void *process)
{
bool lconstvars = true;
enum class StreamMode
{
APPEND,
CREATE
};
auto streamMode = StreamMode::APPEND;
auto hasConstVars = true;
int tsID2 = 0, varID, levelID;
CdoStreamID streamID2;
int vlistID2 = CDI_UNDEFID;
......@@ -82,12 +88,13 @@ Cat(void *process)
tsID2 = vlistNtsteps(vlistID2);
if (tsID2 == 0) tsID2 = 1; // bug fix for time constant data only
if (ntsteps == 0) lconstvars = false;
if (ntsteps == 0) hasConstVars = false;
}
else
{
if (Options::cdoVerbose) cdo_print("Output file doesn't exist, creating: %s", cdo_get_stream_name(nfiles));
streamMode = StreamMode::CREATE;
streamID2 = cdo_open_write(nfiles);
vlistID2 = vlistDuplicate(vlistID1);
......@@ -96,7 +103,7 @@ Cat(void *process)
if (ntsteps == 0 && nfiles > 1)
{
lconstvars = false;
hasConstVars = false;
for (varID = 0; varID < nvars; ++varID) vlistDefVarTimetype(vlistID2, varID, TIME_VARYING);
}
......@@ -126,7 +133,7 @@ Cat(void *process)
{
cdo_inq_record(streamID1, &varID, &levelID);
if (lconstvars && tsID2 > 0 && tsID1 == 0)
if (hasConstVars && tsID2 > 0 && tsID1 == 0)
if (varList1[varID].timetype == TIME_CONSTANT) continue;
cdo_def_record(streamID2, varID, levelID);
......@@ -155,6 +162,12 @@ Cat(void *process)
cdo_stream_close(streamID2);
if (streamMode == StreamMode::CREATE)
{
vlistDestroy(vlistID2);
taxisDestroy(taxisID2);
}
if (Options::Timer) timer_stop(timer_cat);
cdo_finish();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment