Commit 8edf7d91 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

printinfo.c: removed ifdef CDO.

parent d8bfdd6c
// This file is used in CDI and CDO !!!
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../src/config.h" #include "../src/config.h"
#endif #endif
...@@ -12,37 +10,10 @@ ...@@ -12,37 +10,10 @@
#include <cdi.h> #include <cdi.h>
#include "cdi_uuid.h" #include "cdi_uuid.h"
#ifdef CDO
#include "text.h"
#include "datetime.h"
#include "compare.h"
#include "util.h"
#include "pstream_int.h"
#include "process_int.h" //TODO: this include must not be here.
//refactoring needed (11.9.2018);
#define streamInqFiletype pstreamInqFiletype
#define streamInqByteorder pstreamInqByteorder
#define streamInqTimestep cdoStreamInqTimestep
#else
#include "cdi_int.h" #include "cdi_int.h"
#endif
#include "printinfo.h" #include "printinfo.h"
static void
my_reset_text_color(FILE *fp)
{
(void) fp;
#ifdef CDO
reset_text_color(fp);
#endif
}
void void
datetime2str(int64_t date, int time, char *datetimestr, int maxlen) datetime2str(int64_t date, int time, char *datetimestr, int maxlen)
{ {
...@@ -126,11 +97,7 @@ printFiletype(int streamID, int vlistID) ...@@ -126,11 +97,7 @@ printFiletype(int streamID, int vlistID)
const int comptype = vlistInqVarCompType(vlistID, varID); const int comptype = vlistInqVarCompType(vlistID, varID);
if (comptype == comps[k]) if (comptype == comps[k])
{ {
if (kk++ == 0) printf("%c%s", (kk++ == 0) ? ' ' : '/', comp_name(comptype));
printf(" ");
else
printf("/");
printf("%s", comp_name(comptype));
break; break;
} }
} }
...@@ -303,7 +270,6 @@ printGridNp(int gridtype, int gridID, size_t gridsize, size_t xsize, size_t ysiz ...@@ -303,7 +270,6 @@ printGridNp(int gridtype, int gridID, size_t gridsize, size_t xsize, size_t ysiz
fprintf(stdout, " (%zux%zu)", xsize, ysize); fprintf(stdout, " (%zux%zu)", xsize, ysize);
if (gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED) fprintf(stdout, " np=%d", gridInqNP(gridID)); if (gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED) fprintf(stdout, " np=%d", gridInqNP(gridID));
my_reset_text_color(stdout);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
...@@ -324,19 +290,11 @@ printGridInfoKernel(int gridID, int index, bool lproj) ...@@ -324,19 +290,11 @@ printGridInfoKernel(int gridID, int index, bool lproj)
// int prec = gridInqDatatype(gridID); // int prec = gridInqDatatype(gridID);
// int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7; // int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7;
int dig = 7; int dig = 7;
#ifdef CDO
extern int CDO_flt_digits;
dig = CDO_flt_digits;
#endif
if (!lproj) if (!lproj)
{ {
fprintf(stdout, " %4d : ", index + 1); fprintf(stdout, " %4d : ", index + 1);
#ifdef CDO
set_text_color(stdout, RESET, BLUE);
#endif
fprintf(stdout, "%-24s", gridNamePtr(gridtype)); fprintf(stdout, "%-24s", gridNamePtr(gridtype));
my_reset_text_color(stdout);
fprintf(stdout, " : "); fprintf(stdout, " : ");
} }
...@@ -344,11 +302,7 @@ printGridInfoKernel(int gridID, int index, bool lproj) ...@@ -344,11 +302,7 @@ printGridInfoKernel(int gridID, int index, bool lproj)
|| gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED) || gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED)
{ {
if (!lproj) if (!lproj)
{ {
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
printGridNp(gridtype, gridID, gridsize, xsize, ysize); printGridNp(gridtype, gridID, gridsize, xsize, ysize);
} }
...@@ -358,17 +312,9 @@ printGridInfoKernel(int gridID, int index, bool lproj) ...@@ -358,17 +312,9 @@ printGridInfoKernel(int gridID, int index, bool lproj)
if (gridtype == GRID_PROJECTION || name[0]) if (gridtype == GRID_PROJECTION || name[0])
{ {
if (name[0] == 0) strcpy(name, "undefined"); if (name[0] == 0) strcpy(name, "undefined");
#ifdef CDO
set_text_color(stdout, RESET, BLUE);
#endif
fprintf(stdout, " %24s", "mapping"); fprintf(stdout, " %24s", "mapping");
my_reset_text_color(stdout);
fprintf(stdout, " : "); fprintf(stdout, " : ");
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
fprintf(stdout, "%s\n", name); fprintf(stdout, "%s\n", name);
my_reset_text_color(stdout);
} }
print_xvals(gridID, dig); print_xvals(gridID, dig);
...@@ -385,44 +331,28 @@ printGridInfoKernel(int gridID, int index, bool lproj) ...@@ -385,44 +331,28 @@ printGridInfoKernel(int gridID, int index, bool lproj)
} }
else if (gridtype == GRID_SPECTRAL) else if (gridtype == GRID_SPECTRAL)
{ {
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
fprintf(stdout, "points=%zu nsp=%zu truncation=%d", gridsize, gridsize / 2, trunc); fprintf(stdout, "points=%zu nsp=%zu truncation=%d", gridsize, gridsize / 2, trunc);
if (gridInqComplexPacking(gridID)) fprintf(stdout, " complexPacking"); if (gridInqComplexPacking(gridID)) fprintf(stdout, " complexPacking");
my_reset_text_color(stdout);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
else if (gridtype == GRID_FOURIER) else if (gridtype == GRID_FOURIER)
{ {
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
fprintf(stdout, "points=%zu nfc=%zu truncation=%d\n", gridsize, gridsize / 2, trunc); fprintf(stdout, "points=%zu nfc=%zu truncation=%d\n", gridsize, gridsize / 2, trunc);
my_reset_text_color(stdout);
} }
else if (gridtype == GRID_GME) else if (gridtype == GRID_GME)
{ {
int nd, ni, ni2, ni3; int nd, ni, ni2, ni3;
gridInqParamGME(gridID, &nd, &ni, &ni2, &ni3); gridInqParamGME(gridID, &nd, &ni, &ni2, &ni3);
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
fprintf(stdout, "points=%zu nd=%d ni=%d\n", gridsize, nd, ni); fprintf(stdout, "points=%zu nd=%d ni=%d\n", gridsize, nd, ni);
my_reset_text_color(stdout);
} }
else if (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED) else if (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED)
{ {
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
if (gridtype == GRID_CURVILINEAR) if (gridtype == GRID_CURVILINEAR)
fprintf(stdout, "points=%zu (%zux%zu)", gridsize, xsize, ysize); fprintf(stdout, "points=%zu (%zux%zu)", gridsize, xsize, ysize);
else else
fprintf(stdout, "points=%zu", gridsize); fprintf(stdout, "points=%zu", gridsize);
if (gridtype == GRID_UNSTRUCTURED && gridInqNvertex(gridID) > 0) fprintf(stdout, " nvertex=%d", gridInqNvertex(gridID)); if (gridtype == GRID_UNSTRUCTURED && gridInqNvertex(gridID) > 0) fprintf(stdout, " nvertex=%d", gridInqNvertex(gridID));
my_reset_text_color(stdout);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
...@@ -444,14 +374,10 @@ printGridInfoKernel(int gridID, int index, bool lproj) ...@@ -444,14 +374,10 @@ printGridInfoKernel(int gridID, int index, bool lproj)
} }
else /* if ( gridtype == GRID_GENERIC ) */ else /* if ( gridtype == GRID_GENERIC ) */
{ {
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
if (ysize == 0) if (ysize == 0)
fprintf(stdout, "points=%zu\n", gridsize); fprintf(stdout, "points=%zu\n", gridsize);
else else
fprintf(stdout, "points=%zu (%zux%zu)\n", gridsize, xsize, ysize); fprintf(stdout, "points=%zu (%zux%zu)\n", gridsize, xsize, ysize);
my_reset_text_color(stdout);
} }
if (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED) if (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED)
...@@ -607,10 +533,6 @@ printZaxisInfo(int vlistID) ...@@ -607,10 +533,6 @@ printZaxisInfo(int vlistID)
for (int index = 0; index < nzaxis; index++) for (int index = 0; index < nzaxis; index++)
{ {
int dig = 7; int dig = 7;
#ifdef CDO
extern int CDO_flt_digits;
dig = CDO_flt_digits;
#endif
//______________________________________________________-- //______________________________________________________--
double zinc = 0; double zinc = 0;
const int zaxisID = vlistZaxis(vlistID, index); const int zaxisID = vlistZaxis(vlistID, index);
...@@ -626,22 +548,14 @@ printZaxisInfo(int vlistID) ...@@ -626,22 +548,14 @@ printZaxisInfo(int vlistID)
zunits[12] = 0; zunits[12] = 0;
fprintf(stdout, " %4d : ", vlistZaxisIndex(vlistID, zaxisID) + 1); fprintf(stdout, " %4d : ", vlistZaxisIndex(vlistID, zaxisID) + 1);
#ifdef CDO
set_text_color(stdout, RESET, BLUE);
#endif
printZaxisGenericInfo(ltype, zaxistype, zaxisname);
my_reset_text_color(stdout); printZaxisGenericInfo(ltype, zaxistype, zaxisname);
fprintf(stdout, " :"); fprintf(stdout, " :");
#ifdef CDO
set_text_color(stdout, RESET, GREEN);
#endif
fprintf(stdout, " levels=%d", levelsize); fprintf(stdout, " levels=%d", levelsize);
const bool zscalar = (levelsize == 1) ? zaxisInqScalar(zaxisID) : false; const bool zscalar = (levelsize == 1) ? zaxisInqScalar(zaxisID) : false;
if (zscalar) fprintf(stdout, " scalar"); if (zscalar) fprintf(stdout, " scalar");
my_reset_text_color(stdout);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
if (zaxisInqLevels(zaxisID, NULL)) if (zaxisInqLevels(zaxisID, NULL))
...@@ -744,19 +658,10 @@ printTimesteps(int streamID, int taxisID, int verbose) ...@@ -744,19 +658,10 @@ printTimesteps(int streamID, int taxisID, int verbose)
int nfact = 1; int nfact = 1;
int tsID = 0; int tsID = 0;
#ifdef CDO
DateTimeList dtlist;
#endif
while ((nrecs = streamInqTimestep(streamID, tsID))) while ((nrecs = streamInqTimestep(streamID, tsID)))
{ {
#ifdef CDO
dtlist.taxisInqTimestep(taxisID, 0);
const int64_t vdate = dtlist.getVdate(0);
const int vtime = dtlist.getVtime(0);
#else
const int64_t vdate = taxisInqVdate(taxisID); const int64_t vdate = taxisInqVdate(taxisID);
const int vtime = taxisInqVtime(taxisID); const int vtime = taxisInqVtime(taxisID);
#endif
if (verbose || tsID < NUM_TIMESTEP) if (verbose || tsID < NUM_TIMESTEP)
{ {
......
// This file is used in CDI and CDO !!!
#ifndef PRINTINFO_H #ifndef PRINTINFO_H
#define PRINTINFO_H #define PRINTINFO_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment