Commit 437252d6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

app/cdi: added verbose option to printTimesteps()

parent adddc8f9
...@@ -285,7 +285,7 @@ const char * tunit2str(int tunits) ...@@ -285,7 +285,7 @@ const char * tunit2str(int tunits)
} }
const char * calendar2str(int calendar) const char* calendar2str(int calendar)
{ {
if ( calendar == CALENDAR_STANDARD ) return ("standard"); if ( calendar == CALENDAR_STANDARD ) return ("standard");
else if ( calendar == CALENDAR_PROLEPTIC ) return ("proleptic_gregorian"); else if ( calendar == CALENDAR_PROLEPTIC ) return ("proleptic_gregorian");
...@@ -295,6 +295,22 @@ const char * calendar2str(int calendar) ...@@ -295,6 +295,22 @@ const char * calendar2str(int calendar)
else return ("unknown"); else return ("unknown");
} }
static
void limit_string_length(char* string)
{
size_t len = strlen(string);
if ( len > 10 )
{
for ( size_t i = 3; i < len; ++i )
if ( string[i] == ' ' )
{
string[i] = 0;
break;
}
}
}
static static
void printShortinfo(int streamID, int vlistID, int vardis) void printShortinfo(int streamID, int vlistID, int vardis)
{ {
...@@ -305,6 +321,7 @@ void printShortinfo(int streamID, int vlistID, int vardis) ...@@ -305,6 +321,7 @@ void printShortinfo(int streamID, int vlistID, int vardis)
int nvars, ntsteps; int nvars, ntsteps;
int levelsize; int levelsize;
int tsteptype, taxisID; int tsteptype, taxisID;
char tmpname[CDI_MAX_NAME];
char varname[CDI_MAX_NAME]; char varname[CDI_MAX_NAME];
char *modelptr, *instptr; char *modelptr, *instptr;
int datatype; int datatype;
...@@ -335,17 +352,17 @@ void printShortinfo(int streamID, int vlistID, int vardis) ...@@ -335,17 +352,17 @@ void printShortinfo(int streamID, int vlistID, int vardis)
/* institute info */ /* institute info */
instptr = institutInqNamePtr(vlistInqVarInstitut(vlistID, varID)); instptr = institutInqNamePtr(vlistInqVarInstitut(vlistID, varID));
if ( instptr ) strcpy(tmpname, "unknown");
fprintf(stdout, "%-8s ", instptr); if ( instptr ) strcpy(tmpname, instptr);
else limit_string_length(tmpname);
fprintf(stdout, "unknown "); fprintf(stdout, "%-8s ", tmpname);
/* source info */ /* source info */
modelptr = modelInqNamePtr(vlistInqVarModel(vlistID, varID)); modelptr = modelInqNamePtr(vlistInqVarModel(vlistID, varID));
if ( modelptr ) strcpy(tmpname, "unknown");
fprintf(stdout, "%-8s ", modelptr); if ( modelptr ) strcpy(tmpname, modelptr);
else limit_string_length(tmpname);
fprintf(stdout, "unknown "); fprintf(stdout, "%-8s ", tmpname);
/* tsteptype */ /* tsteptype */
tsteptype = vlistInqVarTsteptype(vlistID, varID); tsteptype = vlistInqVarTsteptype(vlistID, varID);
...@@ -456,7 +473,7 @@ void printShortinfo(int streamID, int vlistID, int vardis) ...@@ -456,7 +473,7 @@ void printShortinfo(int streamID, int vlistID, int vardis)
fprintf(stdout, " YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss\n"); fprintf(stdout, " YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss\n");
printTimesteps(streamID, taxisID); printTimesteps(streamID, taxisID, 0);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
......
...@@ -538,7 +538,7 @@ int printDot(int ndotout, int *nfact, int *ncout) ...@@ -538,7 +538,7 @@ int printDot(int ndotout, int *nfact, int *ncout)
} }
static static
void printTimesteps(int streamID, int taxisID) void printTimesteps(int streamID, int taxisID, int verbose)
{ {
int nrecs; int nrecs;
int vdate, vtime; int vdate, vtime;
...@@ -559,12 +559,13 @@ void printTimesteps(int streamID, int taxisID) ...@@ -559,12 +559,13 @@ void printTimesteps(int streamID, int taxisID)
int ncout = 0; int ncout = 0;
int nfact = 1; int nfact = 1;
int tsID = 0; int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID, tsID)) ) while ( (nrecs = streamInqTimestep(streamID, tsID)) )
{ {
vdate = taxisInqVdate(taxisID); vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID); vtime = taxisInqVtime(taxisID);
if ( tsID < NUM_TIMESTEP ) if ( verbose || tsID < NUM_TIMESTEP )
{ {
ntimeout = printDateTime(ntimeout, vdate, vtime); ntimeout = printDateTime(ntimeout, vdate, vtime);
} }
......
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