Filedes.cc 12 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
4
/*
  This file is part of CDO. CDO is a collection of Operators to
  manipulate and analyse Climate model Data.

Uwe Schulzweida's avatar
Uwe Schulzweida committed
5
  Copyright (C) 2003-2017 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
6
7
8
9
10
11
12
13
14
15
16
17
  See COPYING file for copying and redistribution conditions.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
*/

18
19
20
/*
   This module contains the following operators:

21
      Filedes    codetab         Parameter code table
22
23
24
25
      Filedes    griddes         Grid description
      Filedes    vct             Vertical coordinate table
*/

Ralf Mueller's avatar
Ralf Mueller committed
26
#include <cdi.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
27
28
29
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
30
#include "grid.h"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
32


33
void cdo_print_zaxis(int zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
34

35
void cdo_print_attributes(FILE *fp, int cdiID, int varID, int nblanks)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
36
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
37
#define MAXATT 8192
38
  int natts;
39
  char attname[CDI_MAX_NAME];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
40
41
42
43
  int atttype, attlen;
  char atttxt[MAXATT];
  int attint[MAXATT];
  double attflt[MAXATT];
44
  char fltstr[128];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
45

46
  cdiInqNatts(cdiID, varID, &natts);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
47

48
  for ( int ia = 0; ia < natts; ++ia )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
49
    {
50
51
52
53
54
55
      cdiInqAtt(cdiID, varID, ia, attname, &atttype, &attlen);

      if ( atttype == CDI_DATATYPE_INT8  || atttype == CDI_DATATYPE_UINT8  ||
           atttype == CDI_DATATYPE_INT16 || atttype == CDI_DATATYPE_UINT16 ||
           atttype == CDI_DATATYPE_INT32 || atttype == CDI_DATATYPE_UINT32 )
        {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
56
	  if ( attlen > MAXATT ) attlen = MAXATT;
57
58
59
60
	  cdiInqAttInt(cdiID, varID, attname, attlen, attint);
          fprintf(fp, "%*s", nblanks, "");
	  fprintf(fp, "%s = ", attname);
	  for ( int i = 0; i < attlen; ++i )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
61
	    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
62
63
	      if ( i > 0 ) fprintf(fp, ", ");
	      fprintf(fp, "%d", attint[i]);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
64
	    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
65
	  fprintf(fp, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
66
	}
67
      else if ( atttype == CDI_DATATYPE_FLT32 || atttype == CDI_DATATYPE_FLT64 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
68
	{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
69
	  if ( attlen > MAXATT ) attlen = MAXATT;
70
71
72
73
	  cdiInqAttFlt(cdiID, varID, attname, MAXATT, attflt);
          fprintf(fp, "%*s", nblanks, "");
	  fprintf(fp, "%s = ", attname);
	  for ( int i = 0; i < attlen; ++i )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
74
	    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
	      if ( i > 0 ) fprintf(fp, ", ");
76
77
78
79
              if ( atttype == CDI_DATATYPE_FLT32 )
                fprintf(fp, "%sf", double_to_attstr(CDO_flt_digits, fltstr, sizeof(fltstr), attflt[i]));
              else
                fprintf(fp, "%s", double_to_attstr(CDO_dbl_digits, fltstr, sizeof(fltstr), attflt[i]));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
80
	    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
81
	  fprintf(fp, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
82
	}
83
      else if ( atttype == CDI_DATATYPE_TXT )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
84
	{
85
	  cdiInqAttTxt(cdiID, varID, attname, sizeof(atttxt), atttxt);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
86
	  atttxt[attlen] = 0;
87
88
          fprintf(fp, "%*s", nblanks, "");
	  fprintf(fp, "%s = \"%s\"\n", attname, atttxt);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
89
90
91
92
93
	}
    }
}

static
94
void printHistory(FILE *fp, int streamID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
95
{
96
97
98
99
100
101
102
  int fileID = pstreamFileID(streamID);
  size_t historysize = (size_t) streamInqHistorySize(fileID);
  if ( historysize > 0 )
    {
      char *history = (char*) Malloc(historysize+1);
      history[historysize] = 0;
      streamInqHistoryString(fileID, history);
103
      fprintf(fp, "  history = %s\n", history);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
104
      Free(history);
105
106
107
108
109
110
111
112
    }
}

static
void printSource(FILE *fp, int vlistID, int varID)
{
  /* institute info */
  const char *instptr = institutInqLongnamePtr(vlistInqVarInstitut(vlistID, varID));
113
  if ( instptr ) fprintf(fp, "  institution = %s\n", instptr);
114
115
116

  /* source info */
  const char *modelptr = modelInqNamePtr(vlistInqVarModel(vlistID, varID));
117
  if ( modelptr ) fprintf(fp, "  source = %s\n", modelptr);
118
119
120
121
122
}

static
void partab(FILE *fp, int streamID, int option)
{
123
  int vlistID = pstreamInqVlist(streamID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
124
  int varID, datatype = -1;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
  char pstr[32];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
126
  char paramstr[32];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
127
128
  char varname[CDI_MAX_NAME], varlongname[CDI_MAX_NAME], varstdname[CDI_MAX_NAME], varunits[CDI_MAX_NAME];
      
129
  int nvars = vlistNvars(vlistID);
130
  bool linebreak = ( option == 4 ) ? false : true;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
131
132
133

  if ( option == 2 )
    {
134
      int natts;
135
      cdiInqNatts(vlistID, CDI_GLOBAL, &natts);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
136
137
      if ( natts > 0 )
	{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
138
	  fprintf(fp, "&parameter\n");
139
	  fprintf(fp, "  name = _GLOBAL_\n");
140
141
          printHistory(fp, streamID);
          printSource(fp, vlistID, 0);
142
	  cdo_print_attributes(fp, vlistID, CDI_GLOBAL, 2);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
	  fprintf(fp, "/\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
144
145
	}
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
146

Uwe Schulzweida's avatar
Uwe Schulzweida committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  if ( nvars > 1 )
    {
      datatype = vlistInqVarDatatype(vlistID, 0);
      for ( varID = 1; varID < nvars; varID++ )
	{
	  if ( datatype != vlistInqVarDatatype(vlistID, varID) )
	    {
	      datatype = -1;
	      break;
	    }
	}

      if ( datatype != -1 )
	{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
161
162
	  fprintf(fp, "&parameter");
	  if ( linebreak ) fprintf(fp, "\n");
163
	  fprintf(fp, "  name = _default_");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
164
	  if ( linebreak ) fprintf(fp, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
165
	  if ( datatype2str(datatype, pstr) == 0 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
166
	    {
167
	      fprintf(fp, "  datatype = %s", pstr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
168
169
	      if ( linebreak ) fprintf(fp, "\n");
	    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
170
171
172
173
	  fprintf(fp, "/\n");
	}
    }

Uwe Schulzweida's avatar
Uwe Schulzweida committed
174
175
  for ( varID = 0; varID < nvars; varID++ )
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
176
177
      fprintf(fp, "&parameter");
      if ( linebreak ) fprintf(fp, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
178
179
180
181
      
      varname[0]     = 0;
      varlongname[0] = 0;
      varunits[0]    = 0;
182
183
      int param = vlistInqVarParam(vlistID, varID);
      double missval = vlistInqVarMissval(vlistID, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
184
185
186
187
      vlistInqVarName(vlistID, varID, varname);
      vlistInqVarStdname(vlistID, varID, varstdname);
      vlistInqVarLongname(vlistID, varID, varlongname);
      vlistInqVarUnits(vlistID, varID, varunits);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
188
            
189
      fprintf(fp, "  name = %s", varname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
190
      if ( linebreak ) fprintf(fp, "\n");
191
192
      // if ( code   > 0 ) fprintf(fp, "  code=%d\n", code);
      // if ( tabnum > 0 ) fprintf(fp, "  table=%d\n", tabnum);
193
      if ( param >= 0 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
194
195
	{
	  cdiParamToString(param, paramstr, sizeof(paramstr));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
196
197
	  fprintf(fp, "  param=%s", paramstr);
	  if ( linebreak ) fprintf(fp, "\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
198
	}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
199
      if ( strlen(varstdname) )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
200
	{
201
	  fprintf(fp, "  standard_name = %s", varstdname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
202
203
	  if ( linebreak ) fprintf(fp, "\n");
	}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
204
      if ( strlen(varlongname) )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
205
	{
206
	  fprintf(fp, "  long_name = \"%s\"", varlongname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
207
208
	  if ( linebreak ) fprintf(fp, "\n");
	}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
209
      if ( strlen(varunits) )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
210
	{
211
	  fprintf(fp, "  units = \"%s\"", varunits);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
212
213
214
	  if ( linebreak ) fprintf(fp, "\n");
	}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
215
216
      if ( datatype == -1 )
	if ( datatype2str(vlistInqVarDatatype(vlistID, varID), pstr) == 0 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
217
	  {
218
	    fprintf(fp, "  datatype = %s", pstr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
219
220
	    if ( linebreak ) fprintf(fp, "\n");
	  }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
221

222
      int chunktype = vlistInqVarChunkType(vlistID, varID);
223
      if ( chunktype == CDI_CHUNK_AUTO )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
224
	{
225
	  fprintf(fp, "  chunktype = auto");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
226
227
	  if ( linebreak ) fprintf(fp, "\n");
	}
228
      else if ( chunktype == CDI_CHUNK_GRID )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
229
	{
230
	  fprintf(fp, "  chunktype = grid");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
231
232
	  if ( linebreak ) fprintf(fp, "\n");
	}
233
      if ( chunktype == CDI_CHUNK_LINES )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
234
	{
235
	  fprintf(fp, "  chunktype = lines");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
236
237
	  if ( linebreak ) fprintf(fp, "\n");
	}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
238
      
239
      if ( option == 2 ) cdo_print_attributes(fp, vlistID, varID, 2);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
240
      if ( option == 2 ) 
241
	fprintf(fp, "  missing_value = %g\n", missval);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
242
      
Uwe Schulzweida's avatar
Uwe Schulzweida committed
243
      if ( !linebreak ) fprintf(fp, "  ");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
244
245
246
247
248
249
250
251
      fprintf(fp, "/\n");
    }   
}

static
void filedes(int streamID)
{
  printf("\n");
252
  int filetype = pstreamInqFiletype(streamID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
253
254
  switch ( filetype )
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
    case CDI_FILETYPE_GRB:  printf("  GRIB data\n"); break;
    case CDI_FILETYPE_GRB2: printf("  GRIB2 data\n"); break;
    case CDI_FILETYPE_NC:   printf("  NetCDF data\n"); break;
    case CDI_FILETYPE_NC2:  printf("  NetCDF2 data\n"); break;
    case CDI_FILETYPE_NC4:  printf("  NetCDF4 data\n"); break;
    case CDI_FILETYPE_NC4C: printf("  NetCDF4 classic data\n"); break;
    case CDI_FILETYPE_SRV:  printf("  SERVICE data\n"); break;
    case CDI_FILETYPE_EXT:  printf("  EXTRA data\n"); break;
    case CDI_FILETYPE_IEG:  printf("  IEG data\n"); break;
    default: printf("  unsupported filetype %d\n" , filetype);
    }

  switch ( filetype )
    {
269
270
271
    case CDI_FILETYPE_SRV:
    case CDI_FILETYPE_EXT:
    case CDI_FILETYPE_IEG:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
272
      {
273
274
        int byteorder = pstreamInqByteorder(streamID);
        switch ( byteorder )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
275
276
277
          {
          case CDI_BIGENDIAN:    printf("  byteorder is BIGENDIAN\n"); break;
          case CDI_LITTLEENDIAN: printf("  byteorder is LITTLEENDIAN\n"); break;
278
          default:  printf("  byteorder %d undefined\n", byteorder); break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
279
280
281
          }
       }
    }  
Uwe Schulzweida's avatar
Uwe Schulzweida committed
282
283
  
  printf("\n");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
284
285
286
}


Uwe Schulzweida's avatar
Uwe Schulzweida committed
287
288
289
290
void *Filedes(void *argument)
{
  cdoInitialize(argument);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
291
  // clang-format off
292
293
294
295
296
297
298
299
300
301
302
  int GRIDDES  = cdoOperatorAdd("griddes",   0, 0, NULL);
  int GRIDDES2 = cdoOperatorAdd("griddes2",  0, 0, NULL);
  int ZAXISDES = cdoOperatorAdd("zaxisdes",  0, 0, NULL);
  int VCT      = cdoOperatorAdd("vct",       0, 0, NULL);
  int VCT2     = cdoOperatorAdd("vct2",      0, 0, NULL);
  int CODETAB  = cdoOperatorAdd("codetab",   0, 0, NULL);
  int FILEDES  = cdoOperatorAdd("filedes",   0, 0, NULL);
  int VLIST    = cdoOperatorAdd("vlist",     0, 0, NULL);
  int SPARTAB  = cdoOperatorAdd("spartab",   0, 0, NULL);
  int PARTAB   = cdoOperatorAdd("partab",    0, 0, NULL);
  int PARTAB2  = cdoOperatorAdd("partab2",   0, 0, NULL);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
303
  // clang-format on
Uwe Schulzweida's avatar
Uwe Schulzweida committed
304

305
  int operatorID = cdoOperatorID();
Uwe Schulzweida's avatar
Uwe Schulzweida committed
306

307
  int streamID = pstreamOpenRead(cdoStreamName(0));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
308

309
  int vlistID = pstreamInqVlist(streamID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
310

311
312
313
  int nvars  = vlistNvars(vlistID);
  int ngrids = vlistNgrids(vlistID);
  int nzaxis = vlistNzaxis(vlistID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
314

315
  if ( operatorID == GRIDDES || operatorID == GRIDDES2 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
316
    {
317
      int opt = (operatorID == GRIDDES) ? 1 : 0;
318
      for ( int index = 0; index < ngrids; index++ )
319
320
        {
          printf("#\n" "# gridID %d\n" "#\n", index+1);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
321
          cdo_print_grid(vlistGrid(vlistID, index), opt);
322
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
323
324
325
    }
  else if ( operatorID == ZAXISDES )
    {
326
      for ( int index = 0; index < nzaxis; index++ )
327
328
        {
          printf("#\n" "# zaxisID %d\n" "#\n", index+1);
329
          cdo_print_zaxis(vlistZaxis(vlistID, index));
330
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
331
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
332
  else if ( operatorID == VCT || operatorID == VCT2 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
333
    {
334
      for ( int index = 0; index < nzaxis; index++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
335
	{
336
337
	  int zaxisID = vlistZaxis(vlistID, index);
	  int type = zaxisInqType(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
338
	  if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
339
	    {
340
	      int vctsize = zaxisInqVctSize(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
341
	      const double *vct = zaxisInqVctPtr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
342
		
343
	      if ( vctsize%2 == 0 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
344
345
346
		{
		  if ( operatorID == VCT )
		    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
347
		      fprintf(stdout, "#   k         vct_a(k) [Pa]             vct_b(k) []\n");
348
		      for ( int i = 0; i < vctsize/2; i++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
349
350
351
352
353
			fprintf(stdout, "%5d %25.17f %25.17f\n", i, vct[i], vct[vctsize/2+i]);
		    }
		  else
		    {
		      fprintf(stdout, "vctsize   = %d\n", vctsize);
354
355
356
		      int nbyte0 = fprintf(stdout, "vct       = ");
		      int nbyte = nbyte0;
		      for ( int i = 0; i < vctsize; i++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
357
358
359
360
361
362
363
364
365
366
367
			{
			  if ( nbyte > 70 || i == vctsize/2 )
			    {
			      fprintf(stdout, "\n%*s", nbyte0, "");
			      nbyte = nbyte0;
			    }
			  nbyte += fprintf(stdout, "%.9g ", vct[i]);
			}
		      fprintf(stdout, "\n");
		    }
		}
368
	      else
369
		for ( int i = 0; i < vctsize; i++ )
370
		  fprintf(stdout, "%5d %25.17f\n", i, vct[i]);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
371
372

	      break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
373
374
375
376
377
378
379
	    }
	}
    }
  else if ( operatorID == VLIST )
    {
      vlistPrint(vlistID);
    }
380
  else if ( operatorID == CODETAB )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
381
    {
382
      char varname[CDI_MAX_NAME], varlongname[CDI_MAX_NAME], varunits[CDI_MAX_NAME];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
383

384
      for ( int varID = 0; varID < nvars; varID++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
385
386
387
388
	{
	  varname[0]     = 0;
	  varlongname[0] = 0;
	  varunits[0]    = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
389
	  int code = vlistInqVarCode(vlistID, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
390
391
392
393
	  vlistInqVarName(vlistID, varID, varname);
	  vlistInqVarLongname(vlistID, varID, varlongname);
	  vlistInqVarUnits(vlistID, varID, varunits);
	  fprintf(stdout, "%4d  %-12s", code, varname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
394
	  if ( varlongname[0] )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
395
396
	    {
	      fprintf(stdout, "  %s", varlongname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
397
	      if ( varunits[0] )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
398
399
400
401
402
		fprintf(stdout, " [%s]", varunits);
	    }
	  fprintf(stdout, "\n");
	}   
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
403
  else if ( operatorID == PARTAB || operatorID == SPARTAB || operatorID == PARTAB2 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
404
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
405
      int option = 1;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
406
      if ( operatorID == SPARTAB ) option = 4;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
407
408
      if ( operatorID == PARTAB2 ) option = 2;
      
409
      partab(stdout, streamID, option);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
410
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
411
412
  else if ( operatorID == FILEDES )
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
413
      filedes(streamID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
414
415
    }

416
  pstreamClose(streamID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
417
418
419

  cdoFinish();

Uwe Schulzweida's avatar
Uwe Schulzweida committed
420
  return 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
421
}