Commit 5e4fb1ad authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added vlistNsubtypes(), vlistSubtype() and vlistSubtypeIndex()

parent b4abb379
......@@ -314,7 +314,7 @@ void printShortinfo(int streamID, int vlistID, int vardis)
int gridsize = 0;
int gridID, zaxisID, param;
int vdate, vtime;
int nvars, ntsteps;
int ntsteps;
int levelsize;
int tsteptype, taxisID;
char tmpname[CDI_MAX_NAME];
......@@ -329,14 +329,19 @@ void printShortinfo(int streamID, int vlistID, int vardis)
fprintf(stdout, " : ");
printFiletype(streamID, vlistID);
if ( vardis )
fprintf(stdout,
" Var : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter name\n");
//vlistPrint(vlistID);
int nvars = vlistNvars(vlistID);
int nsubtypes = vlistNsubtypes(vlistID);
if ( nsubtypes > 0 )
fprintf(stdout, " Var : Institut Source Ttype Subtypes Num Levels Num Gridsize Num Dtype : ");
else
fprintf(stdout,
" Var : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter ID\n");
fprintf(stdout, " Var : Institut Source Ttype Levels Num Gridsize Num Dtype : ");
nvars = vlistNvars(vlistID);
if ( vardis )
fprintf(stdout, "Parameter name\n");
else
fprintf(stdout, "Parameter ID\n");
for ( varID = 0; varID < nvars; varID++ )
{
......@@ -374,6 +379,14 @@ void printShortinfo(int streamID, int vlistID, int vardis)
else if ( tsteptype == TSTEP_DIFF ) fprintf(stdout, "%-8s ", "diff");
else fprintf(stdout, "%-8s ", "unknown");
if ( nsubtypes > 0 )
{
int subtypeID = vlistInqVarSubtype(vlistID, varID);
int subtypesize = subtypeInqSize(subtypeID);
fprintf(stdout, " %6d ", subtypesize);
fprintf(stdout, "%3d ", vlistSubtypeIndex(vlistID, subtypeID) + 1);
}
/* layer info */
levelsize = zaxisInqSize(zaxisID);
fprintf(stdout, "%6d ", levelsize);
......@@ -433,6 +446,14 @@ void printShortinfo(int streamID, int vlistID, int vardis)
printZaxisInfo(vlistID);
if ( nsubtypes > 0 )
{
fprintf(stdout, " Subtypes");
fprintf(stdout, " :\n");
printSubtypeInfo(vlistID);
}
taxisID = vlistInqTaxis(vlistID);
ntsteps = vlistNtsteps(vlistID);
......
......@@ -407,14 +407,13 @@ void printGridInfo(int vlistID)
static
void printZaxisInfo(int vlistID)
{
int nzaxis, index;
int zaxisID, zaxistype, levelsize, levelID;
int ltype;
double *levels = NULL;
char zaxisname[CDI_MAX_NAME], zname[CDI_MAX_NAME], zunits[CDI_MAX_NAME];
nzaxis = vlistNzaxis(vlistID);
for ( index = 0; index < nzaxis; index++)
int nzaxis = vlistNzaxis(vlistID);
for ( int index = 0; index < nzaxis; index++)
{
double zfirst = 0, zlast = 0, zinc = 0;
zaxisID = vlistZaxis(vlistID, index);
......@@ -509,6 +508,21 @@ void printZaxisInfo(int vlistID)
}
}
static
void printSubtypeInfo(int vlistID)
{
int nsubtypes = vlistNsubtypes(vlistID);
for ( int index = 0; index < nsubtypes; index++)
{
int subtypeID = vlistSubtype(vlistID, index);
int subtypesize = subtypeInqSize(subtypeID);
// subtypePrint(subtypeID);
fprintf(stdout, " %4d : %-24s :", vlistSubtypeIndex(vlistID, subtypeID)+1, "tiles");
fprintf(stdout, " ntiles=%d", subtypesize);
fprintf(stdout, "\n");
}
}
static
int printDateTime(int ntimeout, int vdate, int vtime)
......
......@@ -487,6 +487,9 @@ int vlistNgrids(int vlistID);
/* vlistNzaxis: Number of zaxis in a variable list */
int vlistNzaxis(int vlistID);
/* vlistNsubtypes: Number of subtypes in a variable list */
int vlistNsubtypes(int vlistID);
void vlistDefNtsteps(int vlistID, int nts);
int vlistNtsteps(int vlistID);
int vlistGridsizeMax(int vlistID);
......@@ -499,6 +502,8 @@ int vlistZaxisIndex(int vlistID, int zaxisID);
void vlistChangeZaxisIndex(int vlistID, int index, int zaxisID);
void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2);
int vlistNrecs(int vlistID);
int vlistSubtype(int vlistID, int index);
int vlistSubtypeIndex(int vlistID, int subtypeID);
/* vlistDefTaxis: Define the time axis of a variable list */
void vlistDefTaxis(int vlistID, int taxisID);
......
......@@ -307,6 +307,7 @@ module mo_cdi
public vlistNvars
public vlistNgrids
public vlistNzaxis
public vlistNsubtypes
public vlistDefNtsteps
public vlistNtsteps
public vlistGridsizeMax
......@@ -319,6 +320,8 @@ module mo_cdi
public vlistChangeZaxisIndex
public vlistChangeZaxis
public vlistNrecs
public vlistSubtype
public vlistSubtypeIndex
public vlistDefTaxis
public vlistInqTaxis
public vlistDefTable
......@@ -2583,6 +2586,18 @@ contains
result = lib_vlistNzaxis(vlistID_dummy)
end function vlistNzaxis
function vlistNsubtypes(vlistID_dummy) result(result)
integer(c_int) :: result
integer(c_int), value :: vlistID_dummy
interface
integer(c_int) function lib_vlistNsubtypes(vlistID_dummy) bind(c, name = 'vlistNsubtypes')
import c_int
integer(c_int), value :: vlistID_dummy
end function lib_vlistNsubtypes
end interface
result = lib_vlistNsubtypes(vlistID_dummy)
end function vlistNsubtypes
subroutine vlistDefNtsteps(vlistID_dummy, nts_dummy)
integer(c_int), value :: vlistID_dummy
integer(c_int), value :: nts_dummy
......@@ -2748,6 +2763,34 @@ contains
result = lib_vlistNrecs(vlistID_dummy)
end function vlistNrecs
function vlistSubtype(vlistID_dummy, index_dummy) result(result)
integer(c_int) :: result
integer(c_int), value :: vlistID_dummy
integer(c_int), value :: index_dummy
interface
integer(c_int) function lib_vlistSubtype(vlistID_dummy, index_dummy) bind(c, name = 'vlistSubtype')
import c_int
integer(c_int), value :: vlistID_dummy
integer(c_int), value :: index_dummy
end function lib_vlistSubtype
end interface
result = lib_vlistSubtype(vlistID_dummy, index_dummy)
end function vlistSubtype
function vlistSubtypeIndex(vlistID_dummy, subtypeID_dummy) result(result)
integer(c_int) :: result
integer(c_int), value :: vlistID_dummy
integer(c_int), value :: subtypeID_dummy
interface
integer(c_int) function lib_vlistSubtypeIndex(vlistID_dummy, subtypeID_dummy) bind(c, name = 'vlistSubtypeIndex')
import c_int
integer(c_int), value :: vlistID_dummy
integer(c_int), value :: subtypeID_dummy
end function lib_vlistSubtypeIndex
end interface
result = lib_vlistSubtypeIndex(vlistID_dummy, subtypeID_dummy)
end function vlistSubtypeIndex
subroutine vlistDefTaxis(vlistID_dummy, taxisID_dummy)
integer(c_int), value :: vlistID_dummy
integer(c_int), value :: taxisID_dummy
......
......@@ -1318,6 +1318,7 @@ int vlistZaxis(int vlistID, int index)
return (zaxisID);
}
int vlistZaxisIndex(int vlistID, int zaxisID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
......@@ -1396,6 +1397,32 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
}
int vlistSubtype(int vlistID, int index)
{
int subtypeID = CDI_UNDEFID;
vlist_t *vlistptr = vlist_to_pointer(vlistID);
if ( index < vlistptr->nsubtypes && index >= 0 )
subtypeID = vlistptr->subtypeIDs[index];
return subtypeID;
}
int vlistSubtypeIndex(int vlistID, int subtypeID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
int index;
for ( index = 0 ; index < vlistptr->nsubtypes ; index++ )
if ( subtypeID == vlistptr->subtypeIDs[index] ) break;
if ( index == vlistptr->nsubtypes ) index = -1;
return (index);
}
int vlistHasTime(int vlistID)
{
int hastime = FALSE;
......
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