From 2dab0f9760f362b0e08af0dcc26681a2637cadfa Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Mon, 20 Jun 2022 18:33:21 +0200
Subject: [PATCH] cdfDefTimestep(): call cdfEndDef() if streamptr->accessmode
 == 0.

---
 src/stream_cdf_o.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/stream_cdf_o.c b/src/stream_cdf_o.c
index 20b024a46..d99b57b90 100644
--- a/src/stream_cdf_o.c
+++ b/src/stream_cdf_o.c
@@ -57,6 +57,11 @@ cdfDefTimestep(stream_t *streamptr, int tsID)
       streamptr->ncmode = 2;
     }
 
+  if (streamptr->accessmode == 0)
+    {
+      cdfEndDef(streamptr);
+    }
+
   double timevalue = cdi_encode_timeval(taxis->vdatetime, &streamptr->tsteps[0].taxis);
   if (CDI_Debug) Message("tsID = %d  timevalue = %f", tsID, timevalue);
 
-- 
GitLab