Skip to content
Snippets Groups Projects
Commit e45f0016 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel: Committed by Sergey Kosukhin
Browse files

Do not unnecessarily switch NetCDF files to data mode.

parent 444d35e9
No related branches found
No related tags found
2 merge requests!34Version 2.2.0,!13Consolidation with CDI-PIO (develop)
......@@ -236,7 +236,13 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridIndex, const struct cd
{
int dimNcID = streamptr->basetime.ncvarid;
const int fileID = streamptr->fileID;
if (streamptr->ncmode == 2) cdf_redef(fileID);
bool switch2Data = false;
if (streamptr->ncmode == 2)
{
cdf_redef(fileID);
switch2Data = true;
streamptr->ncmode = 1;
}
char axisname[CDI_MAX_NAME];
const int axistype = (inqs->axisSym == 'X') ? CDI_XAXIS : CDI_YAXIS;
......@@ -244,8 +250,11 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridIndex, const struct cd
cdiInqKeyString(gridID, axistype, CDI_KEY_NAME, axisname, &length);
cdf_def_var(fileID, axisname, xtype, 1, &dimNcID, &ncvarid);
cdfPutGridStdAtts(fileID, ncvarid, gridID, inqs->axisSym);
cdf_enddef(fileID);
streamptr->ncmode = 2;
if (switch2Data)
{
cdf_enddef(fileID);
streamptr->ncmode = 2;
}
}
ncgrid[gridIndex].gridID = gridID;
......
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