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)
}
const char * calendar2str(int calendar)
const char* calendar2str(int calendar)
{
if ( calendar == CALENDAR_STANDARD ) return ("standard");
else if ( calendar == CALENDAR_PROLEPTIC ) return ("proleptic_gregorian");
......@@ -295,6 +295,22 @@ const char * calendar2str(int calendar)
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
void printShortinfo(int streamID, int vlistID, int vardis)
{
......@@ -305,6 +321,7 @@ void printShortinfo(int streamID, int vlistID, int vardis)
int nvars, ntsteps;
int levelsize;
int tsteptype, taxisID;
char tmpname[CDI_MAX_NAME];
char varname[CDI_MAX_NAME];
char *modelptr, *instptr;
int datatype;
......@@ -335,17 +352,17 @@ void printShortinfo(int streamID, int vlistID, int vardis)
/* institute info */
instptr = institutInqNamePtr(vlistInqVarInstitut(vlistID, varID));
if ( instptr )
fprintf(stdout, "%-8s ", instptr);
else
fprintf(stdout, "unknown ");
strcpy(tmpname, "unknown");
if ( instptr ) strcpy(tmpname, instptr);
limit_string_length(tmpname);
fprintf(stdout, "%-8s ", tmpname);
/* source info */
modelptr = modelInqNamePtr(vlistInqVarModel(vlistID, varID));
if ( modelptr )
fprintf(stdout, "%-8s ", modelptr);
else
fprintf(stdout, "unknown ");
strcpy(tmpname, "unknown");
if ( modelptr ) strcpy(tmpname, modelptr);
limit_string_length(tmpname);
fprintf(stdout, "%-8s ", tmpname);
/* tsteptype */
tsteptype = vlistInqVarTsteptype(vlistID, varID);
......@@ -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");
printTimesteps(streamID, taxisID);
printTimesteps(streamID, taxisID, 0);
fprintf(stdout, "\n");
}
......
......@@ -538,7 +538,7 @@ int printDot(int ndotout, int *nfact, int *ncout)
}
static
void printTimesteps(int streamID, int taxisID)
void printTimesteps(int streamID, int taxisID, int verbose)
{
int nrecs;
int vdate, vtime;
......@@ -559,12 +559,13 @@ void printTimesteps(int streamID, int taxisID)
int ncout = 0;
int nfact = 1;
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID, tsID)) )
{
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
if ( tsID < NUM_TIMESTEP )
if ( verbose || tsID < NUM_TIMESTEP )
{
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