Commit 24a52a40 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge branch 'gridsize' into develop

parents a8cb47fe 3256ff69
......@@ -184,10 +184,10 @@ void usage(void)
static
void printInfo(int vdate, int vtime, char *varname, double level,
int datasize, int number, int nmiss, double missval, const double *data, int vardis)
size_t datasize, int number, size_t nmiss, double missval, const double *data, int vardis)
{
static int rec = 0;
int i, ivals = 0, imiss = 0;
size_t ivals = 0, imiss = 0;
double arrmean, arrmin, arrmax;
char vdatestr[32], vtimestr[32];
......@@ -208,9 +208,9 @@ void printInfo(int vdate, int vtime, char *varname, double level,
fprintf(stdout, "%6d :%s %s %7g ", ++rec, vdatestr, vtimestr, level);
fprintf(stdout, "%8d ", datasize);
fprintf(stdout, "%8zu ", datasize);
fprintf(stdout, "%7d :", nmiss);
fprintf(stdout, "%7zu :", nmiss);
if ( number == CDI_REAL )
{
......@@ -219,7 +219,7 @@ void printInfo(int vdate, int vtime, char *varname, double level,
arrmean = 0;
arrmin = 1.e300;
arrmax = -1.e300;
for ( i = 0; i < datasize; i++ )
for ( size_t i = 0; i < datasize; i++ )
{
if ( !DBL_IS_EQUAL(data[i], missval) )
{
......@@ -237,7 +237,7 @@ void printInfo(int vdate, int vtime, char *varname, double level,
arrmean = data[0];
arrmin = data[0];
arrmax = data[0];
for ( i = 1; i < datasize; i++ )
for ( size_t i = 1; i < datasize; i++ )
{
if ( data[i] < arrmin ) arrmin = data[i];
if ( data[i] > arrmax ) arrmax = data[i];
......@@ -251,10 +251,10 @@ void printInfo(int vdate, int vtime, char *varname, double level,
}
else
{
int nvals_r = 0, nvals_i = 0;
size_t nvals_r = 0, nvals_i = 0;
double arrsum_r = 0, arrsum_i = 0, arrmean_r = 0, arrmean_i = 0;
for ( i = 0; i < datasize; i++ )
for ( size_t i = 0; i < datasize; i++ )
{
if ( !DBL_IS_EQUAL(data[i*2], missval) )
{
......@@ -278,7 +278,7 @@ void printInfo(int vdate, int vtime, char *varname, double level,
fprintf(stdout, " : %-14s\n", varname);
if ( imiss != nmiss && nmiss > 0 )
fprintf(stdout, "Found %d of %d missing values!\n", imiss, nmiss);
fprintf(stdout, "Found %zu of %zu missing values!\n", imiss, nmiss);
}
static const char *tunit2str(int tunits)
......@@ -406,8 +406,8 @@ void printShortinfo(int streamID, int vlistID, int vardis)
fprintf(stdout, "%3d ", vlistZaxisIndex(vlistID, zaxisID) + 1);
/* grid info */
int gridsize = gridInqSize(gridID);
fprintf(stdout, "%9d ", gridsize);
size_t gridsize = gridInqSize(gridID);
fprintf(stdout, "%9zu ", gridsize);
fprintf(stdout, "%3d ", vlistGridIndex(vlistID, gridID) + 1);
/* datatype */
......@@ -836,9 +836,9 @@ int main(int argc, char *argv[])
if ( fname1 )
{
int nmiss;
size_t nmiss;
int number;
int datasize = 0;
size_t datasize = 0;
int streamID2 = CDI_UNDEFID;
int filetype;
int gridID, zaxisID;
......@@ -846,7 +846,7 @@ int main(int argc, char *argv[])
int nrecs;
int levelID, levelsize;
int nts = 0;
int gridsize = 0;
size_t gridsize = 0;
int recID;
int taxisID2 = CDI_UNDEFID;
int vlistID2 = CDI_UNDEFID;
......@@ -911,7 +911,7 @@ int main(int argc, char *argv[])
}
if ( vlistNumber(vlistID1) != CDI_REAL ) datasize *= 2;
double *data = (double *) malloc((size_t)datasize * sizeof (double));
double *data = (double *) malloc(datasize * sizeof (double));
/*
nts = cdiInqTimeSize(streamID1);
......@@ -925,6 +925,7 @@ int main(int argc, char *argv[])
printShortinfo(streamID1, vlistID1, Vardis);
}
size_t idum;
int tsID = 0;
if ( Info || fname2 )
while ( (nrecs = streamInqTimestep(streamID1, tsID)) > 0 )
......@@ -945,7 +946,8 @@ int main(int argc, char *argv[])
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamReadRecord(streamID1, data, &nmiss);
streamReadRecord(streamID1, data, &idum);
nmiss = idum;
number = vlistInqVarNumber(vlistID1, varID);
gridID = vlistInqVarGrid(vlistID1, varID);
......@@ -973,7 +975,7 @@ int main(int argc, char *argv[])
if ( Move )
streamCopyRecord(streamID2, streamID1);
else
streamWriteRecord(streamID2, data, nmiss);
streamWriteRecord(streamID2, data, idum);
}
}
}
......@@ -1004,7 +1006,8 @@ int main(int argc, char *argv[])
for ( levelID = 0; levelID < levelsize; levelID++ )
{
double level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levelID) : levelID+1;
streamReadVarSlice(streamID1, varID, levelID, data, &nmiss);
streamReadVarSlice(streamID1, varID, levelID, data, &idum);
nmiss = idum;
if ( Info )
printInfo(vdate, vtime, varname, level, gridsize, number, nmiss, missval, data, Vardis);
......
......@@ -102,7 +102,7 @@ Get number of attributes assigned to this variable.
\section*{\tt \htmlref{gridCreate}{gridCreate}}
\begin{verbatim}
int gridCreate (int gridtype, int size);
int gridCreate (int gridtype, size_t size);
\end{verbatim}
Create a horizontal Grid.
......@@ -210,7 +210,7 @@ Define the name of a X-axis.
\section*{\tt \htmlref{gridDefXsize}{gridDefXsize}}
\begin{verbatim}
void gridDefXsize (int gridID, int xsize);
void gridDefXsize (int gridID, size_t xsize);
\end{verbatim}
Define the size of a X-axis.
......@@ -264,7 +264,7 @@ Define the name of a Y-axis.
\section*{\tt \htmlref{gridDefYsize}{gridDefYsize}}
\begin{verbatim}
void gridDefYsize (int gridID, int ysize);
void gridDefYsize (int gridID, size_t ysize);
\end{verbatim}
Define the size of a Y-axis.
......@@ -381,7 +381,7 @@ Get the reference URI to an unstructured grid.
\section*{\tt \htmlref{gridInqSize}{gridInqSize}}
\begin{verbatim}
int gridInqSize (int gridID);
size_t gridInqSize (int gridID);
\end{verbatim}
Get the size of a Grid.
......@@ -417,7 +417,7 @@ Find out whether X-coordinate is of type CHAR.
\section*{\tt \htmlref{gridInqXbounds}{gridInqXbounds}}
\begin{verbatim}
int gridInqXbounds (int gridID, double xbounds[]);
size_t gridInqXbounds (int gridID, double xbounds[]);
\end{verbatim}
Get the bounds of a X-axis.
......@@ -444,7 +444,7 @@ Get the name of a X-axis.
\section*{\tt \htmlref{gridInqXsize}{gridInqXsize}}
\begin{verbatim}
int gridInqXsize (int gridID);
size_t gridInqXsize (int gridID);
\end{verbatim}
Get the size of a X-axis.
......@@ -471,7 +471,7 @@ Get the units of a X-axis.
\section*{\tt \htmlref{gridInqXval}{gridInqXval}}
\begin{verbatim}
double gridInqXval (int gridID, int index);
double gridInqXval (int gridID, size_t index);
\end{verbatim}
Get one value of a X-axis.
......@@ -480,7 +480,7 @@ Get one value of a X-axis.
\section*{\tt \htmlref{gridInqXvals}{gridInqXvals}}
\begin{verbatim}
int gridInqXvals (int gridID, double xvals[]);
size_t gridInqXvals (int gridID, double xvals[]);
\end{verbatim}
Get all values of a X-axis.
......@@ -498,7 +498,7 @@ Find out whether Y-coordinate is of type CHAR.
\section*{\tt \htmlref{gridInqYbounds}{gridInqYbounds}}
\begin{verbatim}
int gridInqYbounds (int gridID, double ybounds[]);
size_t gridInqYbounds (int gridID, double ybounds[]);
\end{verbatim}
Get the bounds of a Y-axis.
......@@ -525,7 +525,7 @@ Get the name of a Y-axis.
\section*{\tt \htmlref{gridInqYsize}{gridInqYsize}}
\begin{verbatim}
int gridInqYsize (int gridID);
size_t gridInqYsize (int gridID);
\end{verbatim}
Get the size of a Y-axis.
......@@ -552,7 +552,7 @@ Get the units of a Y-axis.
\section*{\tt \htmlref{gridInqYval}{gridInqYval}}
\begin{verbatim}
double gridInqYval (int gridID, int index);
double gridInqYval (int gridID, size_t index);
\end{verbatim}
Get one value of a Y-axis.
......@@ -561,7 +561,7 @@ Get one value of a Y-axis.
\section*{\tt \htmlref{gridInqYvals}{gridInqYvals}}
\begin{verbatim}
int gridInqYvals (int gridID, double yvals[]);
size_t gridInqYvals (int gridID, double yvals[]);
\end{verbatim}
Get all values of a Y-axis.
......@@ -696,7 +696,7 @@ Create a new dataset.
\section*{\tt \htmlref{streamReadVar}{streamReadVar}}
\begin{verbatim}
void streamReadVar (int streamID, int varID, double data[], int *nmiss);
void streamReadVar (int streamID, int varID, double data[], size_t *nmiss);
\end{verbatim}
Read a variable.
......@@ -706,7 +706,7 @@ Read a variable.
\begin{verbatim}
void streamReadVarSlice (int streamID, int varID, int levelID, double data[],
int *nmiss);
size_t *nmiss);
\end{verbatim}
Read a horizontal slice of a variable.
......@@ -724,7 +724,7 @@ Synchronize an Open Dataset to Disk.
\section*{\tt \htmlref{streamWriteVar}{streamWriteVar}}
\begin{verbatim}
void streamWriteVar (int streamID, int varID, const double data[], int nmiss);
void streamWriteVar (int streamID, int varID, const double data[], size_t nmiss);
\end{verbatim}
Write a variable.
......@@ -734,7 +734,7 @@ Write a variable.
\begin{verbatim}
void streamWriteVarSlice (int streamID, int varID, int levelID,
const double data[], int nmiss);
const double data[], size_t nmiss);
\end{verbatim}
Write a horizontal slice of a variable.
......
......@@ -7,7 +7,7 @@ int main(void)
const int nlat = 6; // Number of latitudes
const int nlev = 5; // Number of levels
const int nts = 3; // Number of time steps
int nmiss;
size_t nmiss;
double var1[nlon*nlat];
double var2[nlon*nlat*nlev];
......
......@@ -12,7 +12,8 @@
INTEGER gridID, zaxisID1, zaxisID2, tsID
INTEGER vlistID1, vlistID2, varID1, varID2, streamID1, streamID2
INTEGER i, nmiss, status
INTEGER i, status
INTEGER nmiss
REAL*8 var1(nlon*nlat), var2(nlon*nlat*nlev)
! Open the input dataset
......
......@@ -10,8 +10,9 @@
int main(int argc, char *argv[])
{
int linfo = 0;
int vlistID1, vlistID2, varID, streamID1, streamID2, tsID;
int nmiss, nvars, status, gridsize;
int vlistID1, vlistID2, varID, streamID1, streamID2;
size_t nmiss;
int nvars, status;
double *vardata = NULL;
const char *ifile, *ofile;
......@@ -35,7 +36,7 @@ int main(int argc, char *argv[])
/* Get the variable list of the dataset */
vlistID1 = streamInqVlist(streamID1);
nvars = vlistNvars(vlistID1);
gridsize = vlistGridsizeMax(vlistID1);
size_t gridsize = vlistGridsizeMax(vlistID1);
vardata = (double *) malloc(gridsize*MAX_LEVEL*sizeof(double));
......@@ -52,7 +53,7 @@ int main(int argc, char *argv[])
streamDefVlist(streamID2, vlistID2);
/* Loop over all time steps */
tsID = 0;
int tsID = 0;
while ( (status = streamInqTimestep(streamID1, tsID)) )
{
/* Define the output time step */
......
......@@ -7,7 +7,7 @@ int main(void)
const int nlat = 6; // Number of latitudes
const int nlev = 5; // Number of levels
const int nts = 3; // Number of time steps
int nmiss, vdate, vtime;
size_t nmiss;
double var1[nlon*nlat];
double var2[nlon*nlat*nlev];
......@@ -37,8 +37,8 @@ int main(void)
streamInqTimestep(streamID, tsID);
// Get the verification date and time
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
int vdate = taxisInqVdate(taxisID);
int vtime = taxisInqVtime(taxisID);
printf("read timestep %d: date=%d time=%d\n", tsID+1, vdate, vtime);
// Read var1 and var2
......
......@@ -8,8 +8,8 @@ int nts = 3; // Number of time steps
int main(void)
{
int taxisID, vlistID, varID1, varID2, streamID, tsID;
int nmiss, vdate, vtime;
int taxisID, vlistID, varID1, varID2, streamID;
size_t nmiss;
double var1[nlon*nlat];
double var2[nlon*nlat*nlev];
......@@ -53,14 +53,14 @@ int main(void)
taxisID = vlistInqTaxis(vlistID);
// Loop over the number of time steps
for ( tsID = 0; tsID < nts; tsID++ )
for ( int tsID = 0; tsID < nts; tsID++ )
{
// Inquire the time step
streamInqTimestep(streamID, tsID);
// Get the verification date and time
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
int vdate = taxisInqVdate(taxisID);
int vtime = taxisInqVtime(taxisID);
// Read var1 and var2
streamReadVar(streamID, varID1, var1, &nmiss);
......
......@@ -17,7 +17,8 @@
INTEGER inst
INTEGER gridID, zaxisID1, zaxisID2, taxisID
INTEGER vlistID, varID1, varID2, streamID, tsID
INTEGER nmiss, status, vdate, vtime
INTEGER status, vdate, vtime
INTEGER nmiss
REAL*8 var1(nlon*nlat), var2(nlon*nlat*nlev)
! Open the dataset
......
......@@ -5,9 +5,10 @@ PROGRAM CDIREAD
INCLUDE 'cdi.inc'
INTEGER :: gsize, nlevel, nvars, code
INTEGER :: vdate, vtime, nmiss, status, ilev
INTEGER :: vdate, vtime, status, ilev
INTEGER :: streamID, varID, levelID, gridID, zaxisID
INTEGER :: tsID, vlistID, taxisID
INTEGER :: nmiss
REAL*8, ALLOCATABLE :: field(:,:)
CHARACTER(len=256) :: name, longname, units
......
......@@ -4,7 +4,8 @@
INCLUDE 'cdi.inc'
INTEGER nlon, nlat, nlev, nts
INTEGER nlon, nlat
INTEGER nlev, nts
PARAMETER (nlon = 12) ! Number of longitudes
PARAMETER (nlat = 6) ! Number of latitudes
PARAMETER (nlev = 5) ! Number of levels
......@@ -12,7 +13,8 @@
INTEGER gridID, zaxisID1, zaxisID2, taxisID
INTEGER vlistID, varID1, varID2, streamID, tsID
INTEGER nmiss, status, vdate, vtime
INTEGER status, vdate, vtime
INTEGER nmiss
REAL*8 var1(nlon*nlat), var2(nlon*nlat*nlev)
! Open the dataset
......
......@@ -4,8 +4,9 @@ PROGRAM CDIREADF2003
IMPLICIT NONE
INTEGER :: gsize, nlevel, nvars, code
INTEGER :: vdate, vtime, nmiss, status, ilev
INTEGER(c_size_t) :: gsize, nmiss
INTEGER :: nlevel, nvars, code
INTEGER :: vdate, vtime, status, ilev
INTEGER :: streamID, varID, gridID, zaxisID
INTEGER :: tsID, vlistID, taxisID
DOUBLE PRECISION, ALLOCATABLE :: field(:,:)
......
......@@ -8,8 +8,8 @@ int nts = 3; // Number of time steps
int main(void)
{
int taxisID, vlistID, varID1, varID2, streamID, tsID;
int nmiss, vdate, vtime;
int taxisID, vlistID, varID1, varID2, streamID;
size_t nmiss;
float var1[nlon*nlat];
float var2[nlon*nlat*nlev];
......@@ -33,14 +33,14 @@ int main(void)
taxisID = vlistInqTaxis(vlistID);
// Loop over the number of time steps
for ( tsID = 0; tsID < nts; tsID++ )
for ( int tsID = 0; tsID < nts; tsID++ )
{
// Inquire the time step
streamInqTimestep(streamID, tsID);
// Get the verification date and time
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
int vdate = taxisInqVdate(taxisID);
int vtime = taxisInqVtime(taxisID);
// Read var1 and var2
streamReadVarF(streamID, varID1, var1, &nmiss);
......
......@@ -15,14 +15,16 @@
typedef struct {
int streamID;
int *varID, *levelID, *nmiss;
int *varID, *levelID;
size_t *nmiss;
double *array;
}
read_arg_t;
typedef struct {
int varID, levelID, nmiss;
int varID, levelID;
size_t nmiss;
double *array;
int array_size;
int recID, nrecs;
......@@ -39,7 +41,8 @@ typedef struct work_st{
typedef struct {
int varID, levelID, nmiss;
int varID, levelID;
size_t nmiss;
double *array;
int array_size;
int recID, nrecs;
......@@ -60,7 +63,8 @@ void readRecord(void *arg)
{
read_arg_t *read_arg = (read_arg_t *) arg;
int streamID;
int *varID, *levelID, *nmiss;
int *varID, *levelID;
size_t *nmiss;
double *array;
streamID = read_arg->streamID;
......@@ -249,7 +253,7 @@ void destroy_iothread(void *p)
#endif
void stream_read_record_par(int streamID, int *varID, int *levelID, double *array, int *nmiss, par_io_t *parIO)
void stream_read_record_par(int streamID, int *varID, int *levelID, double *array, size_t *nmiss, par_io_t *parIO)
{
int lpario = 0;
int recID = 0, nrecs = 0;
......@@ -311,7 +315,7 @@ void stream_read_record_par(int streamID, int *varID, int *levelID, double *arra
}
void stream_read_record(int streamID, int *varID, int *levelID, double *data, int *nmiss)
void stream_read_record(int streamID, int *varID, int *levelID, double *data, size_t *nmiss)
{
streamInqRecord(streamID, varID, levelID);
streamReadRecord(streamID, data, nmiss);
......@@ -321,7 +325,8 @@ void stream_read_record(int streamID, int *varID, int *levelID, double *data, in
int main(int argc, char *argv[])
{
int taxisID, vlistID, varID, levelID, streamID, tsID;
int nmiss, vdate, vtime;
size_t nmiss;
int vdate, vtime;
int nrecs, recID, code;
int gridsize, i;
double *data;
......
......@@ -13,7 +13,8 @@
INTEGER inst
INTEGER gridID, zaxisID1, zaxisID2, taxisID
INTEGER vlistID, varID1, varID2, streamID, tsID
INTEGER nmiss, status, vdate, vtime
INTEGER status, vdate, vtime
INTEGER nmiss
REAL*8 var1(nlon*nlat), var2(nlon*nlat*nlev)
! Open the dataset
......
......@@ -9,7 +9,8 @@
INTEGER gridID, taxisID
INTEGER vlistID, varID1, streamID, tsID
INTEGER nmiss, status, vdate, vtime
INTEGER status, vdate, vtime
INTEGER nmiss
REAL*8 sst(nvals)
! CALL cdiDebug(1)
......
......@@ -7,7 +7,7 @@ int main(void)
const int nlat = 6; // Number of latitudes
const int nlev = 5; // Number of levels
const int nts = 20; // Number of time steps
int nmiss, vdate, vtime;
size_t nmiss;
double var1[nlon*nlat];
double var2[nlon*nlat*nlev];
......@@ -37,8 +37,8 @@ int main(void)
streamInqTimestep(streamID, tsID);
// Get the verification date and time
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
int vdate = taxisInqVdate(taxisID);
int vtime = taxisInqVtime(taxisID);
printf("read timestep %d: date=%d time=%d\n", tsID+1, vdate, vtime);
// Read var1 and var2
......
......@@ -7,7 +7,7 @@ int main(void)
const int nlat = 6; // Number of latitudes
const int nlev = 5; // Number of levels
const int nts = 3; // Number of time steps
int nmiss = 0;
size_t nmiss = 0;
double lons[] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
double lats[] = {-75, -45, -15, 15, 45, 75};
double levs[] = {101300, 92500, 85000, 50000, 20000};
......@@ -68,8 +68,8 @@ int main(void)
streamDefTimestep(streamID, tsID);
// Init var1 and var2
for ( int i = 0; i < nlon*nlat; i++ ) var1[i] = 1.1;
for ( int i = 0; i < nlon*nlat*nlev; i++ ) var2[i] = 2.2;
for ( size_t i = 0; i < nlon*nlat; i++ ) var1[i] = 1.1;
for ( size_t i = 0; i < nlon*nlat*nlev; i++ ) var2[i] = 2.2;
// Write var1 and var2
streamWriteVar(streamID, varID1, var1, nmiss);
......
......@@ -9,7 +9,7 @@ int main(void)
{
int gridID, zaxisID1, zaxisID2;
int vlistID, varID1, varID2, streamID;
int i, nmiss = 0;
size_t i, nmiss = 0;
double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
double lats[nlat] = {-75, -45, -15, 15, 45, 75};
double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
......
......@@ -10,7 +10,7 @@ int main(void)
{
int gridID, zaxisID1, zaxisID2, taxisID;
int vlistID, varID1, varID2, streamID, tsID;
int i, nmiss = 0;
size_t i, nmiss = 0;
double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
double lats[nlat] = {-75, -45, -15, 15, 45, 75};
double levs[nlev] = {5, 10, 50, 100, 500};
......
......@@ -18,7 +18,7 @@ int main(void)