Commit 33401a96 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

merged branches/cdi-tiles to trunk

parents d703640f 8774586b
......@@ -320,6 +320,8 @@ src/stream_record.c -text
src/stream_srv.c -text
src/stream_srv.h -text
src/stream_var.c -text
src/subtype.c -text
src/subtype.h -text
src/swap.c -text
src/swap.h -text
src/table.c -text
......
......@@ -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)
......
......@@ -22,6 +22,15 @@ Clear the list of additional GRIB keys..
Register an additional GRIB key which is read when file is opened..
\section*{\tt \htmlref{cdiGetStringError}{cdiGetStringError}}
\begin{verbatim}
void cdiGetStringError (int vlistID, char *name);
\end{verbatim}
Get CDI error String.
\section*{\tt \htmlref{gridCreate}{gridCreate}}
\begin{verbatim}
......@@ -618,6 +627,51 @@ Write a variable.
Write a horizontal slice of a variable.
\section*{\tt \htmlref{subtypeCreate}{subtypeCreate}}
\begin{verbatim}
int subtypeCreate (int subtype);
\end{verbatim}
Create a variable subtype.
\section*{\tt \htmlref{subtypeDefActiveIndex}{subtypeDefActiveIndex}}
\begin{verbatim}
void subtypeDefActiveIndex (int subtypeID, int index);
\end{verbatim}
Set the currently active index of a subtype (e.g. current tile index)..
\section*{\tt \htmlref{subtypeInqActiveIndex}{subtypeInqActiveIndex}}
\begin{verbatim}
int subtypeInqActiveIndex (int subtypeID);
\end{verbatim}
Get the currently active index of a subtype (e.g. current tile index)..
\section*{\tt \htmlref{subtypeInqSize}{subtypeInqSize}}
\begin{verbatim}
int subtypeInqSize (int subtypeID);
\end{verbatim}
Get the size of a subtype (e.g. no. of tiles)..
\section*{\tt \htmlref{subtypeInqTile}{subtypeInqTile}}
\begin{verbatim}
int subtypeInqTile (int subtypeID, int tileindex, int attribute);
\end{verbatim}
Specialized version of subtypeInqSubEntry looking for tile/attribute pair..
\section*{\tt \htmlref{taxisCreate}{taxisCreate}}
\begin{verbatim}
......@@ -843,7 +897,7 @@ Define the time axis of a variable list.
int vlistDefVar (int vlistID, int gridID, int zaxisID, int tsteptype);
\end{verbatim}
Create a new Variable.
Create a new variable.
\section*{\tt \htmlref{vlistDefVarCode}{vlistDefVarCode}}
......@@ -1120,6 +1174,15 @@ Get the parameter number of a Variable.
Get the standard name of a Variable.
\section*{\tt \htmlref{vlistInqVarSubtype}{vlistInqVarSubtype}}
\begin{verbatim}
int vlistInqVarSubtype (int vlistID, int varID);
\end{verbatim}
Return subtype ID for a given variable..
\section*{\tt \htmlref{vlistInqVarUnits}{vlistInqVarUnits}}
\begin{verbatim}
......
......@@ -22,6 +22,15 @@ Clear the list of additional GRIB keys..
Register an additional GRIB key which is read when file is opened..
\section*{\tt \htmlref{cdiGetStringError}{cdiGetStringError}}
\begin{verbatim}
SUBROUTINE cdiGetStringError (INTEGER vlistID, CHARACTER*(*) name)
\end{verbatim}
Get CDI error String.
\section*{\tt \htmlref{gridCreate}{gridCreate}}
\begin{verbatim}
......@@ -620,6 +629,52 @@ Write a variable.
Write a horizontal slice of a variable.
\section*{\tt \htmlref{subtypeCreate}{subtypeCreate}}
\begin{verbatim}
INTEGER FUNCTION subtypeCreate (INTEGER subtype)
\end{verbatim}
Create a variable subtype.
\section*{\tt \htmlref{subtypeDefActiveIndex}{subtypeDefActiveIndex}}
\begin{verbatim}
SUBROUTINE subtypeDefActiveIndex (INTEGER subtypeID, INTEGER index)
\end{verbatim}
Set the currently active index of a subtype (e.g. current tile index)..
\section*{\tt \htmlref{subtypeInqActiveIndex}{subtypeInqActiveIndex}}
\begin{verbatim}
INTEGER FUNCTION subtypeInqActiveIndex (INTEGER subtypeID)
\end{verbatim}
Get the currently active index of a subtype (e.g. current tile index)..
\section*{\tt \htmlref{subtypeInqSize}{subtypeInqSize}}
\begin{verbatim}
INTEGER FUNCTION subtypeInqSize (INTEGER subtypeID)
\end{verbatim}
Get the size of a subtype (e.g. no. of tiles)..
\section*{\tt \htmlref{subtypeInqTile}{subtypeInqTile}}
\begin{verbatim}
INTEGER FUNCTION subtypeInqTile (INTEGER subtypeID, INTEGER tileindex,
INTEGER attribute)
\end{verbatim}
Specialized version of subtypeInqSubEntry looking for tile/attribute pair..
\section*{\tt \htmlref{taxisCreate}{taxisCreate}}
\begin{verbatim}
......@@ -849,7 +904,7 @@ Define the time axis of a variable list.
INTEGER tsteptype)
\end{verbatim}
Create a new Variable.
Create a new variable.
\section*{\tt \htmlref{vlistDefVarCode}{vlistDefVarCode}}
......@@ -1139,6 +1194,15 @@ Get the parameter number of a Variable.
Get the standard name of a Variable.
\section*{\tt \htmlref{vlistInqVarSubtype}{vlistInqVarSubtype}}
\begin{verbatim}
INTEGER FUNCTION vlistInqVarSubtype (INTEGER vlistID, INTEGER varID)
\end{verbatim}
Return subtype ID for a given variable..
\section*{\tt \htmlref{vlistInqVarUnits}{vlistInqVarUnits}}
\begin{verbatim}
......
......@@ -79,7 +79,7 @@ static void modelRun(MPI_Comm commModel)
#endif
for ( i = 0; i < nVars; i++ )
{
varID[i] = vlistDefVar ( vlistID, gridID, zaxisID[i], TIME_VARIABLE );
varID[i] = vlistDefVar ( vlistID, gridID, zaxisID[i], TIME_VARIABLE);
#ifdef USE_MPI
{
int start = uniform_partition_start((int [2]){ 0, (int)varSize[i] - 1 },
......
......@@ -104,7 +104,7 @@ static void modelRun(MPI_Comm commModel)
for ( j = 0; j < nVars; j++ )
{
varID[i][j] = vlistDefVar(vlistID[i], gridID, zaxisID[i][j],
TIME_VARIABLE );
TIME_VARIABLE);
varSize[i][j] = nlon * nlat * (size_t)nlev[i][j];
#ifdef USE_MPI
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -92,6 +92,8 @@ libcdi_la_SOURCES = \
stream_srv.c \
stream_srv.h \
stream_var.c \
subtype.c \
subtype.h \
swap.h \
table.c \
table.h \
......
......@@ -177,13 +177,13 @@ am__libcdi_la_SOURCES_DIST = basetime.c basetime.h binary.c binary.h \
stream_grb.c stream_grb.h stream_gribapi.c stream_gribapi.h \
stream_history.c stream_ieg.c stream_ieg.h stream_fcommon.c \
stream_fcommon.h cdi_int.c cdi_int.h stream_record.c \
stream_srv.c stream_srv.h stream_var.c swap.h table.c table.h \
tablepar.h taxis.c taxis.h timebase.c timebase.h tsteps.c \
util.c varscan.c varscan.h version.c vlist.c vlist.h \
vlist_att.c vlist_att.h vlist_var.c vlist_var.h zaxis.c \
zaxis.h stream.c swap.c iterator.c iterator.h \
iterator_fallback.c iterator_fallback.h iterator_grib.c \
iterator_grib.h cfortran.h cdiFortran.c
stream_srv.c stream_srv.h stream_var.c subtype.c subtype.h \
swap.h table.c table.h tablepar.h taxis.c taxis.h timebase.c \
timebase.h tsteps.c util.c varscan.c varscan.h version.c \
vlist.c vlist.h vlist_att.c vlist_att.h vlist_var.c \
vlist_var.h zaxis.c zaxis.h stream.c swap.c iterator.c \
iterator.h iterator_fallback.c iterator_fallback.h \
iterator_grib.c iterator_grib.h cfortran.h cdiFortran.c
am__objects_1 = cdiFortran.lo
@USE_FC_TRUE@am__objects_2 = $(am__objects_1)
am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
......@@ -195,10 +195,11 @@ am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
servicelib.lo stream_cdf.lo stream_cgribex.lo stream_ext.lo \
stream_grb.lo stream_gribapi.lo stream_history.lo \
stream_ieg.lo stream_fcommon.lo cdi_int.lo stream_record.lo \
stream_srv.lo stream_var.lo table.lo taxis.lo timebase.lo \
tsteps.lo util.lo varscan.lo version.lo vlist.lo vlist_att.lo \
vlist_var.lo zaxis.lo stream.lo swap.lo iterator.lo \
iterator_fallback.lo iterator_grib.lo $(am__objects_2)
stream_srv.lo stream_var.lo subtype.lo table.lo taxis.lo \
timebase.lo tsteps.lo util.lo varscan.lo version.lo vlist.lo \
vlist_att.lo vlist_var.lo zaxis.lo stream.lo swap.lo \
iterator.lo iterator_fallback.lo iterator_grib.lo \
$(am__objects_2)
libcdi_la_OBJECTS = $(am_libcdi_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
......@@ -503,12 +504,13 @@ libcdi_la_SOURCES = basetime.c basetime.h binary.c binary.h calendar.c \
stream_gribapi.c stream_gribapi.h stream_history.c \
stream_ieg.c stream_ieg.h stream_fcommon.c stream_fcommon.h \
cdi_int.c cdi_int.h stream_record.c stream_srv.c stream_srv.h \
stream_var.c swap.h table.c table.h tablepar.h taxis.c taxis.h \
timebase.c timebase.h tsteps.c util.c varscan.c varscan.h \
version.c vlist.c vlist.h vlist_att.c vlist_att.h vlist_var.c \
vlist_var.h zaxis.c zaxis.h stream.c swap.c iterator.c \
iterator.h iterator_fallback.c iterator_fallback.h \
iterator_grib.c iterator_grib.h $(am__append_2)
stream_var.c subtype.c subtype.h swap.h table.c table.h \
tablepar.h taxis.c taxis.h timebase.c timebase.h tsteps.c \
util.c varscan.c varscan.h version.c vlist.c vlist.h \
vlist_att.c vlist_att.h vlist_var.c vlist_var.h zaxis.c \
zaxis.h stream.c swap.c iterator.c iterator.h \
iterator_fallback.c iterator_fallback.h iterator_grib.c \
iterator_grib.h $(am__append_2)
# cfortran.h is an optional part of libcdi
libcdi_la_USE_FC_extra_sources = \
......@@ -736,6 +738,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_record.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_srv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_var.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subtype.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/taxis.Plo@am__quote@
......
......@@ -169,6 +169,26 @@ extern "C" {
#define ZAXIS_MIX_LAYER 24 /* Mixing Layer */
#define ZAXIS_REFERENCE 25 /* zaxis reference number */
/* SUBTYPE types */
enum {
SUBTYPE_TILES = 0 /* Tiles variable */
};
#define MAX_KV_PAIRS_MATCH 10
/* Data structure defining a key-value search, possibly with multiple
key-value pairs in combination.
Currently, only multiple pairs combined by AND are supported.
*/
typedef struct {
int nAND; /* no. of key-value pairs that have to match */
int key_value_pairs[2][MAX_KV_PAIRS_MATCH]; /* key-value pairs */
} subtype_query_t;
/* TIME types */
#define TIME_CONSTANT 0 /* obsolate, use TSTEP_CONSTANT */
......@@ -238,6 +258,11 @@ void cdiReset(void);
const char *cdiStringError(int cdiErrno);
/* cdiGetStringError: Get CDI error String */
/* Wrapper for cdiStringError, since direct use of */
/* cdiStringError results in SEGFAULT with Cray compiler */
void cdiGetStringError(int vlistID, char *name);
void cdiDebug(int debug);
const char *cdiLibraryVersion(void);
......@@ -462,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);
......@@ -474,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);
......@@ -491,7 +521,10 @@ int vlistInqModel(int vlistID);
/* VLIST VAR routines */
/* vlistDefVar: Create a new Variable */
/* vlistDefVar: Create a new tile-based variable */
int vlistDefVarTiles(int vlistID, int gridID, int zaxisID, int tsteptype, int tilesetID);
/* vlistDefVar: Create a new variable */
int vlistDefVar(int vlistID, int gridID, int zaxisID, int tsteptype);
void vlistChangeVarGrid(int vlistID, int varID, int gridID);
......@@ -1098,9 +1131,47 @@ void streamDefHistory(int streamID, int size, const char *history);
int streamInqHistorySize(int streamID);
void streamInqHistoryString(int streamID, char *history);
/* Subtype routines */
/* subtypeCreate: Create a variable subtype */
int subtypeCreate(int subtype);
/* Gives a textual summary of the variable subtype */
void subtypePrint(int subtypeID);
/* Compares two subtype data structures. */
int subtypeCompare(int subtypeID1, int subtypeID2);
/* subtypeInqSize: Get the size of a subtype (e.g. no. of tiles). */
int subtypeInqSize(int subtypeID);
/* subtypeInqActiveIndex: Get the currently active index of a subtype (e.g. current tile index). */
int subtypeInqActiveIndex(int subtypeID);
/* subtypeDefActiveIndex: Set the currently active index of a subtype (e.g. current tile index). */
void subtypeDefActiveIndex(int subtypeID, int index);
/* Generate a "query object" out of a key-value pair. */
subtype_query_t keyValuePair(const char* key, int value);
/* Generate an AND-combined "query object" out of two previous
query objects. */
subtype_query_t matchAND(subtype_query_t q1, subtype_query_t q2);
/* subtypeInqSubEntry: Returns subtype entry ID for a given criterion. */
int subtypeInqSubEntry(int subtypeID, subtype_query_t criterion);
/* subtypeInqTile: Specialized version of subtypeInqSubEntry looking for tile/attribute pair. */
int subtypeInqTile(int subtypeID, int tileindex, int attribute);
/* vlistInqVarSubtype: Return subtype ID for a given variable. */
int vlistInqVarSubtype(int vlistID, int varID);
void gribapiLibraryVersion(int *major_version, int *minor_version, int *revision_version);
/*
#if defined (__cplusplus)
}
......
......@@ -287,6 +287,17 @@
INTEGER ZAXIS_REFERENCE
PARAMETER (ZAXIS_REFERENCE = 25)
!
! SUBTYPE types
!
INTEGER MAX_KV_PAIRS_MATCH
PARAMETER (MAX_KV_PAIRS_MATCH = 10)
!
! Data structure defining a key-value search, possibly with multiple
! key-value pairs in combination.
!
! Currently, only multiple pairs combined by AND are supported.
!
!
! TIME types
!
INTEGER TIME_CONSTANT
......@@ -394,6 +405,17 @@
! (INTEGER cdiErrno)
EXTERNAL cdiStringError
!
! Wrapper for cdiStringError, since direct use of
!
!
! cdiStringError results in SEGFAULT with Cray compiler
!
! cdiGetStringError
! (INTEGER vlistID,
! CHARACTER*(*) name)
EXTERNAL cdiGetStringError
! cdiDebug
! (INTEGER debug)
EXTERNAL cdiDebug
......@@ -852,6 +874,14 @@
!
! VLIST VAR routines
!
INTEGER vlistDefVarTiles
! (INTEGER vlistID,
! INTEGER gridID,
! INTEGER zaxisID,
! INTEGER tsteptype,
! INTEGER tilesetID)
EXTERNAL vlistDefVarTiles
INTEGER vlistDefVar
! (INTEGER vlistID,
! INTEGER gridID,
......@@ -2347,6 +2377,59 @@
! CHARACTER*(*) history)
EXTERNAL streamInqHistoryString
!
! Subtype routines
!
INTEGER subtypeCreate
! (INTEGER subtype)
EXTERNAL subtypeCreate
!
! Gives a textual summary of the variable subtype
!
! subtypePrint
! (INTEGER subtypeID)
EXTERNAL subtypePrint
!
! Compares two subtype data structures.
!
INTEGER subtypeCompare
! (INTEGER subtypeID1,
! INTEGER subtypeID2)
EXTERNAL subtypeCompare
INTEGER subtypeInqSize
! (INTEGER subtypeID)
EXTERNAL subtypeInqSize
INTEGER subtypeInqActiveIndex
! (INTEGER subtypeID)
EXTERNAL subtypeInqActiveIndex
! subtypeDefActiveIndex
! (INTEGER subtypeID,
! INTEGER index)
EXTERNAL subtypeDefActiveIndex
!
! Generate a "query object" out of a key-value pair.
!
!
! Generate an AND-combined "query object" out of two previous
! query objects.
!
INTEGER subtypeInqTile
! (INTEGER subtypeID,
! INTEGER tileindex,
! INTEGER attribute)
EXTERNAL subtypeInqTile
INTEGER vlistInqVarSubtype
! (INTEGER vlistID,
! INTEGER varID)
EXTERNAL vlistInqVarSubtype
! gribapiLibraryVersion
! (INTEGER major_version,
! INTEGER minor_version,
......
......@@ -42,6 +42,15 @@
/* ZAXIS types */
/* SUBTYPE types */
/* Data structure defining a key-value search, possibly with multiple
key-value pairs in combination.
Currently, only multiple pairs combined by AND are supported. */
/* TIME types */