diff --git a/ChangeLog b/ChangeLog index 8d490ca33b4cf1c30589dbc4210c4c9c636886b0..fe99ea0668cc0996f702bfc3e7a3a4e43a7e2ba4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ 2021-06-12 Uwe Schulzweida * splitsel: output sequence number starts at 0 (bug fix) + * cdo_append_history: check if the history for vlist has already been defined 2021-06-09 Uwe Schulzweida diff --git a/src/cdo_history.cc b/src/cdo_history.cc index 88e71a6687c08d3bea15bda877174959e2de1c91..e751450ccb90a2e5e08142f9aef46680ac60c80c 100644 --- a/src/cdo_history.cc +++ b/src/cdo_history.cc @@ -25,6 +25,10 @@ #include "cdo_options.h" #include "cdi_uuid.h" +static int numVlist; +static constexpr int maxVlist = 256; +static int vlistHistory[maxVlist]; + static char strtime[32]; static char datetimestr[32]; @@ -51,6 +55,11 @@ get_strtimeptr() void cdo_append_history(int vlistID, const char *histstring) { + for (int i = 0; i < numVlist; ++i) + if (vlistHistory[i] == vlistID) return; + + if (numVlist < maxVlist) vlistHistory[numVlist++] = vlistID; + static const char *historyAttrName = "history"; if (Options::CDO_Reset_History) cdiDelAtt(vlistID, CDI_GLOBAL, historyAttrName);