printinfo.h 22.8 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
// This file is used in CDI and CDO !!!

Uwe Schulzweida's avatar
Uwe Schulzweida committed
3
#ifdef HAVE_CONFIG_H
Uwe Schulzweida's avatar
Uwe Schulzweida committed
4
#include "../src/config.h"
5
6
7
8
#endif

#include <stdio.h>

Uwe Schulzweida's avatar
Uwe Schulzweida committed
9
#ifdef CDO
Uwe Schulzweida's avatar
Uwe Schulzweida committed
10
11
12
13
14
#include "text.h"
#include "datetime.h"
#define streamInqFiletype pstreamInqFiletype
#define streamInqByteorder pstreamInqByteorder
#define streamInqTimestep cdoStreamInqTimestep
Uwe Schulzweida's avatar
Uwe Schulzweida committed
15
16
#endif

17
18
19
#define DATE_FORMAT "%5.4d-%2.2d-%2.2d"
#define TIME_FORMAT "%2.2d:%2.2d:%2.2d"

Uwe Schulzweida's avatar
Uwe Schulzweida committed
20
21
void
my_reset_text_color(FILE *fp)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
22
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
23
  (void) fp;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
24
25
26
27
28
#ifdef CDO
  reset_text_color(fp);
#endif
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
29
void
30
datetime2str(int64_t date, int time, char *datetimestr, int maxlen)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
32
33
34
35
36
37
{
  int year, month, day;
  cdiDecodeDate(date, &year, &month, &day);
  int hour, minute, second;
  cdiDecodeTime(time, &hour, &minute, &second);

  int len = sprintf(datetimestr, DATE_FORMAT "T" TIME_FORMAT, year, month, day, hour, minute, second);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
38
  if (len > (maxlen - 1)) fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
39
40
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
41
void
42
date2str(int64_t date, char *datestr, int maxlen)
43
44
45
46
{
  int year, month, day;
  cdiDecodeDate(date, &year, &month, &day);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
47
  int len = sprintf(datestr, DATE_FORMAT, year, month, day);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
48
  if (len > (maxlen - 1)) fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
49
50
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
51
52
void
time2str(int time, char *timestr, int maxlen)
53
54
55
56
{
  int hour, minute, second;
  cdiDecodeTime(time, &hour, &minute, &second);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
57
  int len = sprintf(timestr, TIME_FORMAT, hour, minute, second);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
58
  if (len > (maxlen - 1)) fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
59
60
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
61
62
63
64
65
66
67
68
69
const char *
comp_name(int comptype)
{
  if (comptype == CDI_COMPRESS_SZIP) return "szip";
  if (comptype == CDI_COMPRESS_ZIP) return "zip";
  if (comptype == CDI_COMPRESS_JPEG) return "jpeg";
  if (comptype == CDI_COMPRESS_AEC) return "aec";
  return " ";
}
70

Uwe Schulzweida's avatar
Uwe Schulzweida committed
71
72
void
printFiletype(int streamID, int vlistID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
73
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
74
  int filetype = streamInqFiletype(streamID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75

Uwe Schulzweida's avatar
Uwe Schulzweida committed
76
  // clang-format off
Uwe Schulzweida's avatar
Uwe Schulzweida committed
77
78
  switch ( filetype )
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
80
81
82
83
84
85
86
87
88
89
    case CDI_FILETYPE_GRB:  printf("GRIB");  break;
    case CDI_FILETYPE_GRB2: printf("GRIB2");  break;
    case CDI_FILETYPE_NC:   printf("NetCDF");  break;
    case CDI_FILETYPE_NC2:  printf("NetCDF2");  break;
    case CDI_FILETYPE_NC4:  printf("NetCDF4");  break;
    case CDI_FILETYPE_NC4C: printf("NetCDF4 classic");  break;
    case CDI_FILETYPE_NC5:  printf("NetCDF5");  break;
    case CDI_FILETYPE_SRV:  printf("SERVICE");  break;
    case CDI_FILETYPE_EXT:  printf("EXTRA");  break;
    case CDI_FILETYPE_IEG:  printf("IEG");  break;
    default: printf("  File format: unsupported filetype %d" , filetype);  break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
90
91
    }

92
  if ( filetype == CDI_FILETYPE_SRV || filetype == CDI_FILETYPE_EXT || filetype == CDI_FILETYPE_IEG )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
93
94
95
    {
      switch ( streamInqByteorder(streamID) )
	{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
96
97
98
	case CDI_BIGENDIAN:    printf("  BIGENDIAN");  break;
	case CDI_LITTLEENDIAN: printf("  LITTLEENDIAN");  break;
	default: printf("  byteorder: %d undefined", streamInqByteorder(streamID));  break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
99
100
	}
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
101
  // clang-format on
Uwe Schulzweida's avatar
Uwe Schulzweida committed
102

Uwe Schulzweida's avatar
Uwe Schulzweida committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  int nvars = vlistNvars(vlistID);
  int comps[] = { CDI_COMPRESS_ZIP, CDI_COMPRESS_JPEG, CDI_COMPRESS_SZIP, CDI_COMPRESS_AEC };
  unsigned kk = 0;
  for (unsigned k = 0; k < sizeof(comps) / sizeof(int); ++k)
    for (int varID = 0; varID < nvars; varID++)
      {
        int comptype = vlistInqVarCompType(vlistID, varID);
        if (comptype == comps[k])
          {
            if (kk++ == 0)
              printf(" ");
            else
              printf("/");
            printf("%s", comp_name(comptype));
            break;
          }
      }
120

Uwe Schulzweida's avatar
Uwe Schulzweida committed
121
122
123
  printf("\n");
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
124
125
static void
print_xvals(int gridID, int dig)
126
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
127
128
  size_t xsize = gridInqXsize(gridID);
  if (xsize > 0 && gridInqXvals(gridID, NULL))
129
130
131
132
133
134
    {
      char xname[CDI_MAX_NAME], xunits[CDI_MAX_NAME];
      gridInqXname(gridID, xname);
      gridInqXunits(gridID, xunits);

      double xfirst = gridInqXval(gridID, 0);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
135
136
      double xlast = gridInqXval(gridID, xsize - 1);
      double xinc = gridInqXinc(gridID);
137
      fprintf(stdout, "%33s : %.*g", xname, dig, xfirst);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
138
      if (xsize > 1)
139
140
        {
          fprintf(stdout, " to %.*g", dig, xlast);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
141
          if (IS_NOT_EQUAL(xinc, 0)) fprintf(stdout, " by %.*g", dig, xinc);
142
143
        }
      fprintf(stdout, " %s", xunits);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
144
      if (gridIsCircular(gridID)) fprintf(stdout, "  circular");
145
146
147
148
      fprintf(stdout, "\n");
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
149
150
static void
print_yvals(int gridID, int dig)
151
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
152
153
  size_t ysize = gridInqYsize(gridID);
  if (ysize > 0 && gridInqYvals(gridID, NULL))
154
155
156
157
158
159
    {
      char yname[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
      gridInqYname(gridID, yname);
      gridInqYunits(gridID, yunits);

      double yfirst = gridInqYval(gridID, 0);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
160
161
      double ylast = gridInqYval(gridID, ysize - 1);
      double yinc = gridInqYinc(gridID);
162
      fprintf(stdout, "%33s : %.*g", yname, dig, yfirst);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
163
      if (ysize > 1)
164
165
166
        {
          int gridtype = gridInqType(gridID);
          fprintf(stdout, " to %.*g", dig, ylast);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
167
          if (IS_NOT_EQUAL(yinc, 0) && gridtype != GRID_GAUSSIAN && gridtype != GRID_GAUSSIAN_REDUCED)
168
169
170
171
172
173
174
            fprintf(stdout, " by %.*g", dig, yinc);
        }
      fprintf(stdout, " %s", yunits);
      fprintf(stdout, "\n");
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
175
176
static void
print_xyvals2D(int gridID, int dig)
177
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
178
  if (gridInqXvals(gridID, NULL) && gridInqYvals(gridID, NULL))
179
180
181
182
183
184
185
    {
      char xname[CDI_MAX_NAME], yname[CDI_MAX_NAME], xunits[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
      gridInqXname(gridID, xname);
      gridInqYname(gridID, yname);
      gridInqXunits(gridID, xunits);
      gridInqYunits(gridID, yunits);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
186
      size_t gridsize = gridInqSize(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
187
188
      double *xvals2D = (double *) malloc(gridsize * sizeof(double));
      double *yvals2D = (double *) malloc(gridsize * sizeof(double));
189
190
191
192
193

      gridInqXvals(gridID, xvals2D);
      gridInqYvals(gridID, yvals2D);

      double xfirst = xvals2D[0];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
194
      double xlast = xvals2D[0];
195
      double yfirst = yvals2D[0];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
196
197
      double ylast = yvals2D[0];
      for (size_t i = 1; i < gridsize; i++)
198
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
199
200
201
202
          if (xvals2D[i] < xfirst) xfirst = xvals2D[i];
          if (xvals2D[i] > xlast) xlast = xvals2D[i];
          if (yvals2D[i] < yfirst) yfirst = yvals2D[i];
          if (yvals2D[i] > ylast) ylast = yvals2D[i];
203
204
205
206
207
        }

      double xinc = 0;
      double yinc = 0;
      int gridtype = gridInqType(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
208
      if (gridtype == GRID_CURVILINEAR)
209
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
210
211
212
          size_t xsize = gridInqXsize(gridID);
          size_t ysize = gridInqYsize(gridID);
          if (xsize > 1)
213
            {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
214
215
216
217
218
219
220
221
222
              double *xvals = (double *) malloc((size_t) xsize * sizeof(double));
              for (size_t i = 0; i < xsize; ++i) xvals[i] = xvals2D[i];
              xinc = fabs(xvals[xsize - 1] - xvals[0]) / (xsize - 1);
              for (size_t i = 1; i < xsize; i++)
                if (fabs(fabs(xvals[i - 1] - xvals[i]) - xinc) > 0.01 * xinc)
                  {
                    xinc = 0;
                    break;
                  }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
223
              free(xvals);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
224
225
226
227
228
229
230
231
232
233
              if (IS_NOT_EQUAL(xinc, 0))
                {
                  for (size_t i = 1; i < ysize; i++)
                    if (IS_NOT_EQUAL(xvals2D[i * xsize], xvals2D[0])
                        || IS_NOT_EQUAL(xvals2D[(i + 1) * xsize - 1], xvals2D[xsize - 1]))
                      {
                        xinc = 0;
                        break;
                      }
                }
234
            }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
235
          if (ysize > 1)
236
            {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
237
238
239
240
241
242
243
244
245
              double *yvals = (double *) malloc((size_t) ysize * sizeof(double));
              for (size_t i = 0; i < ysize; ++i) yvals[i] = yvals2D[i * xsize];
              yinc = fabs(yvals[ysize - 1] - yvals[0]) / (ysize - 1);
              for (size_t i = 1; i < ysize; i++)
                if (fabs(fabs(yvals[i - 1] - yvals[i]) - yinc) > 0.01 * yinc)
                  {
                    yinc = 0;
                    break;
                  }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
246
              free(yvals);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
247
248
249
250
251
252
253
254
255
256
              if (IS_NOT_EQUAL(yinc, 0))
                {
                  for (size_t i = 1; i < xsize; i++)
                    if (IS_NOT_EQUAL(yvals2D[i], yvals2D[0])
                        || IS_NOT_EQUAL(yvals2D[(ysize - 1) * xsize + i], yvals2D[(ysize - 1) * xsize]))
                      {
                        yinc = 0;
                        break;
                      }
                }
257
258
259
            }
        }

Uwe Schulzweida's avatar
Uwe Schulzweida committed
260
      fprintf(stdout, "%33s : %.*g", xname, dig, xfirst);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
261
262
      if (gridsize > 1) fprintf(stdout, " to %.*g", dig, xlast);
      if (IS_NOT_EQUAL(xinc, 0)) fprintf(stdout, " by %.*g", dig, xinc);
263
      fprintf(stdout, " %s", xunits);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
264
      if (gridIsCircular(gridID)) fprintf(stdout, "  circular");
265
      fprintf(stdout, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
266
      fprintf(stdout, "%33s : %.*g", yname, dig, yfirst);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
267
268
      if (gridsize > 1) fprintf(stdout, " to %.*g", dig, ylast);
      if (IS_NOT_EQUAL(yinc, 0)) fprintf(stdout, " by %.*g", dig, yinc);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
269
      fprintf(stdout, " %s", yunits);
270
271
272
273
274
275
276
      fprintf(stdout, "\n");

      free(xvals2D);
      free(yvals2D);
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
277
278
static void
printGridInfoKernel(int gridID, int index, bool lproj)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
279
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
280
281
  int gridtype = gridInqType(gridID);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
282
  if (lproj && gridtype != GRID_PROJECTION)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
283
284
    fprintf(stderr, "Internal problem (%s): sub grid not equal GRID_PROJECTION!\n", __func__);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
285
  int trunc = gridInqTrunc(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
286
  size_t gridsize = gridInqSize(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
287
288
289
  size_t xsize = gridInqXsize(gridID);
  size_t ysize = gridInqYsize(gridID);
  size_t xysize = xsize * ysize;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
290

Uwe Schulzweida's avatar
Uwe Schulzweida committed
291
  // int prec     = gridInqDatatype(gridID);
292
  // int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
293
  int dig = 7;
294
295
296
297
#ifdef CDO
  extern int CDO_flt_digits;
  dig = CDO_flt_digits;
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
298

Uwe Schulzweida's avatar
Uwe Schulzweida committed
299
  if (!lproj)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
300
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
301
      fprintf(stdout, "  %4d : ", index + 1);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
302
303
304
#ifdef CDO
      set_text_color(stdout, RESET, BLUE);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
305
306
307
308
      fprintf(stdout, "%-24s", gridNamePtr(gridtype));
      my_reset_text_color(stdout);
      fprintf(stdout, " : ");
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
309

Uwe Schulzweida's avatar
Uwe Schulzweida committed
310
311
  if (gridtype == GRID_LONLAT || gridtype == GRID_PROJECTION || gridtype == GRID_GENERIC || gridtype == GRID_CHARXY
      || gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
312
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
313
      if (!lproj)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
314
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
315
316
317
#ifdef CDO
          set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
318
          fprintf(stdout, "points=%zu", gridsize);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
319
          if (gridtype == GRID_GAUSSIAN_REDUCED)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
320
            fprintf(stdout, "  nlat=%zu", ysize);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
321
          else if (xysize)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
322
            fprintf(stdout, " (%zux%zu)", xsize, ysize);
323

Uwe Schulzweida's avatar
Uwe Schulzweida committed
324
          if (gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED) fprintf(stdout, "  np=%d", gridInqNP(gridID));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
325
          my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
326

Uwe Schulzweida's avatar
Uwe Schulzweida committed
327
328
329
          fprintf(stdout, "\n");
        }

Uwe Schulzweida's avatar
Uwe Schulzweida committed
330
331
      char name[CDI_MAX_NAME];
      name[0] = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
332
      cdiGridInqKeyStr(gridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, name);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
333
      if (gridtype == GRID_PROJECTION || name[0])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
334
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
335
          if (name[0] == 0) strcpy(name, "undefined");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
336
337
338
#ifdef CDO
          set_text_color(stdout, RESET, BLUE);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
339
          fprintf(stdout, "         %24s", "mapping");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
340
341
          my_reset_text_color(stdout);
          fprintf(stdout, " : ");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
342
343
344
#ifdef CDO
          set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
345
346
          fprintf(stdout, "%s\n", name);
          my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
347
        }
348

Uwe Schulzweida's avatar
Uwe Schulzweida committed
349
350
      print_xvals(gridID, dig);
      print_yvals(gridID, dig);
351

Uwe Schulzweida's avatar
Uwe Schulzweida committed
352
      if (gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
353
354
        {
          fprintf(stdout, "%33s :", "available");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
355
356
357
          if (gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL)) fprintf(stdout, " cellbounds");
          if (gridHasArea(gridID)) fprintf(stdout, " area");
          if (gridInqMask(gridID, NULL)) fprintf(stdout, " mask");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
358
359
360
          fprintf(stdout, "\n");
        }
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
361
  else if (gridtype == GRID_SPECTRAL)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
362
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
363
364
365
#ifdef CDO
      set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
366
367
      fprintf(stdout, "points=%zu  nsp=%zu  truncation=%d", gridsize, gridsize / 2, trunc);
      if (gridInqComplexPacking(gridID)) fprintf(stdout, "  complexPacking");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
368
      my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
369
370
      fprintf(stdout, "\n");
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
371
  else if (gridtype == GRID_FOURIER)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
372
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
373
374
375
#ifdef CDO
      set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
376
      fprintf(stdout, "points=%zu  nfc=%zu  truncation=%d\n", gridsize, gridsize / 2, trunc);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
377
      my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
378
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
379
  else if (gridtype == GRID_GME)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
380
    {
381
382
      int nd, ni, ni2, ni3;
      gridInqParamGME(gridID, &nd, &ni, &ni2, &ni3);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
383
384
385
#ifdef CDO
      set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
386
      fprintf(stdout, "points=%zu  nd=%d  ni=%d\n", gridsize, nd, ni);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
387
      my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
388
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
389
  else if (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
390
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
391
392
393
#ifdef CDO
      set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
394
      if (gridtype == GRID_CURVILINEAR)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
395
        fprintf(stdout, "points=%zu (%zux%zu)", gridsize, xsize, ysize);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
396
      else
Uwe Schulzweida's avatar
Uwe Schulzweida committed
397
        fprintf(stdout, "points=%zu", gridsize);
398

Uwe Schulzweida's avatar
Uwe Schulzweida committed
399
      if (gridtype == GRID_UNSTRUCTURED && gridInqNvertex(gridID) > 0) fprintf(stdout, "  nvertex=%d", gridInqNvertex(gridID));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
400
      my_reset_text_color(stdout);
401

Uwe Schulzweida's avatar
Uwe Schulzweida committed
402
      fprintf(stdout, "\n");
403

Uwe Schulzweida's avatar
Uwe Schulzweida committed
404
      if (gridtype == GRID_UNSTRUCTURED)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
405
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
406
          int number = gridInqNumber(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
407
          int position = gridInqPosition(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
408
          if (number > 0) fprintf(stdout, "%33s : number=%d  position=%d\n", "grid", number, position);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
409

Uwe Schulzweida's avatar
Uwe Schulzweida committed
410
          if (gridInqReference(gridID, NULL))
411
            {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
412
413
414
              char reference_link[8192];
              gridInqReference(gridID, reference_link);
              fprintf(stdout, "%33s : %s\n", "uri", reference_link);
415
            }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
416
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
417

Uwe Schulzweida's avatar
Uwe Schulzweida committed
418
419
420
421
      print_xyvals2D(gridID, dig);
    }
  else /* if ( gridtype == GRID_GENERIC ) */
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
422
423
424
#ifdef CDO
      set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
425
      if (ysize == 0)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
426
        fprintf(stdout, "points=%zu\n", gridsize);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
427
      else
Uwe Schulzweida's avatar
Uwe Schulzweida committed
428
        fprintf(stdout, "points=%zu (%zux%zu)\n", gridsize, xsize, ysize);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
429
      my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
430
    }
431

Uwe Schulzweida's avatar
Uwe Schulzweida committed
432
  if (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
433
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
434
      if (gridHasArea(gridID) || gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL))
435
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
436
          fprintf(stdout, "%33s :", "available");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
437
438
439
          if (gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL)) fprintf(stdout, " cellbounds");
          if (gridHasArea(gridID)) fprintf(stdout, " area");
          if (gridInqMask(gridID, NULL)) fprintf(stdout, " mask");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
440
441
442
443
444
445
          fprintf(stdout, "\n");
        }
    }

  unsigned char uuidOfHGrid[CDI_UUID_SIZE];
  gridInqUUID(gridID, uuidOfHGrid);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
446
  if (!cdiUUIDIsNull(uuidOfHGrid))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
447
448
449
    {
      char uuidOfHGridStr[37];
      cdiUUID2Str(uuidOfHGrid, uuidOfHGridStr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
450
      if (uuidOfHGridStr[0] != 0 && strlen(uuidOfHGridStr) == 36)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
451
452
        {
          fprintf(stdout, "%33s : %s\n", "uuid", uuidOfHGridStr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
453
454
455
456
        }
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
457
458
static void
printGridInfo(int vlistID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
459
460
{
  int ngrids = vlistNgrids(vlistID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
461
  for (int index = 0; index < ngrids; index++)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
462
463
464
465
    {
      int gridID = vlistGrid(vlistID, index);
      printGridInfoKernel(gridID, index, false);
      int projID = gridInqProj(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
466
      if (projID != CDI_UNDEFID) printGridInfoKernel(projID, index, true);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
467
468
469
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
470
471
static void
printZaxisInfo(int vlistID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
472
473
474
{
  char zaxisname[CDI_MAX_NAME], zname[CDI_MAX_NAME], zunits[CDI_MAX_NAME];

475
  int nzaxis = vlistNzaxis(vlistID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
476
  for (int index = 0; index < nzaxis; index++)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
477
    {
478
      double zinc = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
479
      int zaxisID = vlistZaxis(vlistID, index);
480
      int zaxistype = zaxisInqType(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
481
      int ltype = zaxisInqLtype(zaxisID);
482
      int levelsize = zaxisInqSize(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
483
      // int prec      = zaxisInqDatatype(zaxisID);
484
      // int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
485
      int dig = 7;
486
487
488
489
#ifdef CDO
      extern int CDO_flt_digits;
      dig = CDO_flt_digits;
#endif
490

Uwe Schulzweida's avatar
Uwe Schulzweida committed
491
492
493
494
495
      zaxisName(zaxistype, zaxisname);
      zaxisInqName(zaxisID, zname);
      zaxisInqUnits(zaxisID, zunits);
      zunits[12] = 0;

Uwe Schulzweida's avatar
Uwe Schulzweida committed
496
      fprintf(stdout, "  %4d : ", vlistZaxisIndex(vlistID, zaxisID) + 1);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
497
498
499
#ifdef CDO
      set_text_color(stdout, RESET, BLUE);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
500
      if (zaxistype == ZAXIS_GENERIC && ltype != 0)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
501
        fprintf(stdout, "%-12s (ltype=%3d)", zaxisname, ltype);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
502
      else
Uwe Schulzweida's avatar
Uwe Schulzweida committed
503
504
505
506
        fprintf(stdout, "%-24s", zaxisname);
      my_reset_text_color(stdout);

      fprintf(stdout, " :");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
507

Uwe Schulzweida's avatar
Uwe Schulzweida committed
508
509
510
#ifdef CDO
      set_text_color(stdout, RESET, GREEN);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
511
      fprintf(stdout, " levels=%d", levelsize);
512
      bool zscalar = (levelsize == 1) ? zaxisInqScalar(zaxisID) : false;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
513
      if (zscalar) fprintf(stdout, "  scalar");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
514
      my_reset_text_color(stdout);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
515
516
      fprintf(stdout, "\n");

Uwe Schulzweida's avatar
Uwe Schulzweida committed
517
      if (zaxisInqLevels(zaxisID, NULL))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
518
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
519
          double *levels = (double *) malloc((size_t) levelsize * sizeof(double));
520
          zaxisInqLevels(zaxisID, levels);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
521

Uwe Schulzweida's avatar
Uwe Schulzweida committed
522
          if (!(zaxistype == ZAXIS_SURFACE && levelsize == 1 && !(fabs(levels[0]) > 0)))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
523
            {
524
              double zfirst = levels[0];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
525
526
              double zlast = levels[levelsize - 1];
              if (levelsize > 2)
527
                {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
528
529
530
                  zinc = (levels[levelsize - 1] - levels[0]) / (levelsize - 1);
                  for (int levelID = 2; levelID < levelsize; ++levelID)
                    if (fabs(fabs(levels[levelID] - levels[levelID - 1]) - zinc) > 0.001 * zinc)
531
532
533
534
535
536
537
                      {
                        zinc = 0;
                        break;
                      }
                }

              fprintf(stdout, "%33s : %.*g", zname, dig, zfirst);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
538
              if (levelsize > 1)
539
540
                {
                  fprintf(stdout, " to %.*g", dig, zlast);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
541
                  if (IS_NOT_EQUAL(zinc, 0)) fprintf(stdout, " by %.*g", dig, zinc);
542
543
544
                }
              fprintf(stdout, " %s", zunits);
              fprintf(stdout, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
545
546
            }

547
548
          free(levels);
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
549

Uwe Schulzweida's avatar
Uwe Schulzweida committed
550
      if (zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
551
552
553
554
555
556
        {
          double level1, level2;
          fprintf(stdout, "%33s : ", "bounds");

          level1 = zaxisInqLbound(zaxisID, 0);
          level2 = zaxisInqUbound(zaxisID, 0);
557
          fprintf(stdout, "%.*g-%.*g", dig, level1, dig, level2);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
558
          if (levelsize > 1)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
559
            {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
560
561
              level1 = zaxisInqLbound(zaxisID, levelsize - 1);
              level2 = zaxisInqUbound(zaxisID, levelsize - 1);
562
              fprintf(stdout, " to %.*g-%.*g", dig, level1, dig, level2);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
563
              if (IS_NOT_EQUAL(zinc, 0)) fprintf(stdout, " by %.*g", dig, zinc);
564
            }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
565
566
          fprintf(stdout, " %s", zunits);
          fprintf(stdout, "\n");
567
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
568

Uwe Schulzweida's avatar
Uwe Schulzweida committed
569
      if (zaxistype == ZAXIS_HYBRID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
570
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
571
572
          char psname[CDI_MAX_NAME];
          psname[0] = 0;
573
          cdiZaxisInqKeyStr(zaxisID, CDI_KEY_PSNAME, CDI_MAX_NAME, psname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
574
          int vctsize = zaxisInqVctSize(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
575
          if (vctsize || psname[0])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
576
            {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
577
578
579
              fprintf(stdout, "%33s :", "available");
              if (vctsize) fprintf(stdout, " vct");
              if (psname[0]) fprintf(stdout, "  ps: %s", psname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
580
581
582
583
              fprintf(stdout, "\n");
            }
        }

Uwe Schulzweida's avatar
Uwe Schulzweida committed
584
      if (zaxistype == ZAXIS_REFERENCE)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
585
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
586
          int number = zaxisInqNumber(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
587

Uwe Schulzweida's avatar
Uwe Schulzweida committed
588
          if (number > 0)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
589
590
            {
              fprintf(stdout, "%33s : ", "zaxis");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
591
              fprintf(stdout, "number=%d\n", number);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
592
593
            }

594
          unsigned char uuidOfVGrid[CDI_UUID_SIZE];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
595
          zaxisInqUUID(zaxisID, uuidOfVGrid);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
596
          if (!cdiUUIDIsNull(uuidOfVGrid))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
597
598
            {
              char uuidOfVGridStr[37];
599
              cdiUUID2Str(uuidOfVGrid, uuidOfVGridStr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
600
              if (uuidOfVGridStr[0] != 0 && strlen(uuidOfVGridStr) == 36)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
601
602
603
604
605
606
607
608
609
                {
                  fprintf(stdout, "%33s : ", "uuid");
                  fprintf(stdout, "%s\n", uuidOfVGridStr);
                }
            }
        }
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
610
611
static void
printSubtypeInfo(int vlistID)
612
613
{
  int nsubtypes = vlistNsubtypes(vlistID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
614
  for (int index = 0; index < nsubtypes; index++)
615
616
617
618
    {
      int subtypeID = vlistSubtype(vlistID, index);
      int subtypesize = subtypeInqSize(subtypeID);
      // subtypePrint(subtypeID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
619
      fprintf(stdout, "  %4d : %-24s :", vlistSubtypeIndex(vlistID, subtypeID) + 1, "tiles");
620
621
622
623
      fprintf(stdout, " ntiles=%d", subtypesize);
      fprintf(stdout, "\n");
    }
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
624

Uwe Schulzweida's avatar
Uwe Schulzweida committed
625
static int
626
printDateTime(int ntimeout, int64_t vdate, int vtime)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
627
628
629
{
  char vdatestr[32], vtimestr[32];

Uwe Schulzweida's avatar
Uwe Schulzweida committed
630
  if (ntimeout == 4)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
631
632
633
634
635
636
637
638
639
640
    {
      ntimeout = 0;
      fprintf(stdout, "\n");
    }

  date2str(vdate, vdatestr, sizeof(vdatestr));
  time2str(vtime, vtimestr, sizeof(vtimestr));

  fprintf(stdout, " %s %s", vdatestr, vtimestr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
641
  return ++ntimeout;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
642
643
644
}

#define NUM_TIMESTEP 60
Uwe Schulzweida's avatar
Uwe Schulzweida committed
645
#define MAX_DOTS 80
Uwe Schulzweida's avatar
Uwe Schulzweida committed
646

Uwe Schulzweida's avatar
Uwe Schulzweida committed
647
648
static int
printDot(int ndotout, int *nfact, int *ncout)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
649
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
650
651
  // printf("ncout %d %d %d\n",*ncout, (*ncout)%(*nfact), *nfact);
  if ((*ncout) % (*nfact) == 0)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
652
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
653
654
655
656
657
658
659
      if (ndotout == MAX_DOTS)
        {
          *ncout = 0;
          ndotout = 0;
          fprintf(stdout, "\n   ");
          (*nfact) *= 10;
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
660
661
662
663
664
665
666
667

      fprintf(stdout, ".");
      fflush(stdout);
      ndotout++;
    }

  (*ncout)++;

Uwe Schulzweida's avatar
Uwe Schulzweida committed
668
  return ndotout;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
669
670
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
671
672
static void
printTimesteps(int streamID, int taxisID, int verbose)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
673
674
{
  int nrecs;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
675
676
  struct datetime
  {
677
    int64_t vdate;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
678
679
680
681
682
683
    int vtime;
    struct datetime *next;
  };
  struct datetime vdatetime[NUM_TIMESTEP];
  struct datetime *next_vdatetime = vdatetime;

Uwe Schulzweida's avatar
Uwe Schulzweida committed
684
685
  for (int i = 0; i < NUM_TIMESTEP - 1; ++i) vdatetime[i].next = &vdatetime[i + 1];
  vdatetime[NUM_TIMESTEP - 1].next = &vdatetime[0];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
686
687
688
689
690
691
692

  int ntimeout = 0;
  int ndotout = 0;
  int nvdatetime = 0;
  int ncout = 0;
  int nfact = 1;
  int tsID = 0;
693

694
#ifdef CDO
Uwe Schulzweida's avatar
Uwe Schulzweida committed
695
  DateTimeList dtlist;
696
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
697
  while ((nrecs = streamInqTimestep(streamID, tsID)))
Uwe Schulzweida's avatar
Uwe Schulzweida committed
698
    {
699
#ifdef CDO
Uwe Schulzweida's avatar
Uwe Schulzweida committed
700
701
702
      dtlist.taxisInqTimestep(taxisID, 0);
      int64_t vdate = dtlist.getVdate(0);
      int vtime = dtlist.getVtime(0);
703
#else
704
      int64_t vdate = taxisInqVdate(taxisID);
705
706
      int vtime = taxisInqVtime(taxisID);
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
707

Uwe Schulzweida's avatar
Uwe Schulzweida committed
708
709
710
711
      if (verbose || tsID < NUM_TIMESTEP)
        {
          ntimeout = printDateTime(ntimeout, vdate, vtime);
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
712
      else
Uwe Schulzweida's avatar
Uwe Schulzweida committed
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
        {
          if (tsID == 2 * NUM_TIMESTEP) fprintf(stdout, "\n   ");
          if (tsID >= 2 * NUM_TIMESTEP) ndotout = printDot(ndotout, &nfact, &ncout);

          if (nvdatetime < NUM_TIMESTEP)
            {
              vdatetime[nvdatetime].vdate = vdate;
              vdatetime[nvdatetime].vtime = vtime;
              nvdatetime++;
            }
          else
            {
              next_vdatetime->vdate = vdate;
              next_vdatetime->vtime = vtime;
              next_vdatetime = next_vdatetime->next;
            }
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
730
731
732
733

      tsID++;
    }

Uwe Schulzweida's avatar
Uwe Schulzweida committed
734
  if (nvdatetime)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
735
736
737
738
    {
      fprintf(stdout, "\n");

      ntimeout = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
739
      int toff = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
740
      if (tsID > 2 * NUM_TIMESTEP)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
741
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
742
743
744
745
746
747
          toff = tsID % 4;
          if (toff > 0) toff = 4 - toff;
          for (int i = 0; i < toff; ++i) next_vdatetime = next_vdatetime->next;
        }
      for (int i = toff; i < nvdatetime; ++i)
        {
748
          int64_t vdate = next_vdatetime->vdate;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
749
750
751
          int vtime = next_vdatetime->vtime;
          ntimeout = printDateTime(ntimeout, vdate, vtime);
          next_vdatetime = next_vdatetime->next;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
752
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
753
754
    }
}
755
756
757
758
759
760
761
762
763
/*
 * Local Variables:
 * c-file-style: "Java"
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */