Commit 497bf0e2 authored by Uwe Schulzweida's avatar Uwe Schulzweida

git push

Merge branch 'develop'
parents 34644e5d 9bf03a51
......@@ -3,6 +3,10 @@
* Using CDI library version 1.8.0
* Version 1.8.0 release
2017-02-07 Uwe Schulzweida
* New operator setattribute: set attributes
2017-02-03 Uwe Schulzweida
* using CDI library version 1.8.0rc7
......
......@@ -10,11 +10,10 @@ Version 1.8.0 (26 October 2016):
* setpartabn: added support for user defined attributes
* Reverse: adjust date/time by -1 second (introduced in last revision)
New operators:
* timcumsum: Cumulative sum over time.
* setattribute: Set attributes
* cmorlite: Apply variable_entry of cmor tables
* timcumsum: Cumulative sum over time.
* shiftx/shifty: Shift fields on rectilinear/curvilinear grids in x/y direction
Changed operators:
* Tim<STAT> (e.g. monmean):
Fixed bugs:
* Cond: bug fix for ntsteps1 == 1 && ntsteps2 != 1
* ml2pl: interpolation failed for data on hybrid half levels [Bug #7225]
......
......@@ -121,6 +121,7 @@ Operator catalog:
-------------------------------------------------------------
Modification
-------------------------------------------------------------
Setattributes setattribute Set attributes
Setpartab setpartabp Set parameter table
Setpartab setpartabn Set parameter table
Set setcodetab Set parameter code table
......@@ -153,8 +154,6 @@ Operator catalog:
Setgrid setgridarea Set grid cell area
Setzaxis setzaxis Set z-axis
Setzaxis genlevelbounds Generate level bounds
Setgatt setgatt Set global attribute
Setgatt setgatts Set global attributes
Invert invertlat Invert latitudes
Invertlev invertlev Invert levels
Shiftxy shiftx Shift x
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for cdo 1.8.0rc7.
# Generated by GNU Autoconf 2.68 for cdo 1.8.0.
#
# Report bugs to <http://mpimet.mpg.de/cdo>.
#
......@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdo'
PACKAGE_TARNAME='cdo'
PACKAGE_VERSION='1.8.0rc7'
PACKAGE_STRING='cdo 1.8.0rc7'
PACKAGE_VERSION='1.8.0'
PACKAGE_STRING='cdo 1.8.0'
PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdo'
PACKAGE_URL=''
......@@ -1395,7 +1395,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdo 1.8.0rc7 to adapt to many kinds of systems.
\`configure' configures cdo 1.8.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1465,7 +1465,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdo 1.8.0rc7:";;
short | recursive ) echo "Configuration of cdo 1.8.0:";;
esac
cat <<\_ACEOF
......@@ -1613,7 +1613,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdo configure 1.8.0rc7
cdo configure 1.8.0
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
......@@ -2206,7 +2206,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdo $as_me 1.8.0rc7, which was
It was created by cdo $as_me 1.8.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
......@@ -3155,7 +3155,7 @@ fi
# Define the identity of the package.
PACKAGE='cdo'
VERSION='1.8.0rc7'
VERSION='1.8.0'
cat >>confdefs.h <<_ACEOF
......@@ -21662,7 +21662,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdo $as_me 1.8.0rc7, which was
This file was extended by cdo $as_me 1.8.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -21728,7 +21728,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
cdo config.status 1.8.0rc7
cdo config.status 1.8.0
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
......
......@@ -4,7 +4,7 @@
# autoconf 2.68
# libtool 2.4.2
AC_INIT([cdo], [1.8.0rc7], [http://mpimet.mpg.de/cdo])
AC_INIT([cdo], [1.8.0], [http://mpimet.mpg.de/cdo])
AC_DEFINE_UNQUOTED(CDO, ["$PACKAGE_VERSION"], [CDO version])
......
......@@ -24,13 +24,13 @@ Condc Conditional selection
MapReduce Conditional selection
Comp Comparison
Compc Comparison
Setattributes Modification
Setpartab Modification
Set Modification
Settime Modification
Change Modification
Setgrid Modification
Setzaxis Modification
Setgatt Modification
Invert Modification
Invertlev Modification
Shiftxy Modification
......
@BeginModule
@NewPage
@Name = Setattribute
@Title = Set attributes
@Section = Modification
@Class = Modification
@Arguments = infile outfile
@Operators = setattribute
@BeginDescription
This operator sets attributes of a dataset. Each attribute has the following structure:
[@bold{var_nm}@]@bold{att_nm}=@bold{att_val}
@IfMan
var_nm Variable name (optional). Example: pressure
att_nm Attribute name. Example: units
att_val Comma separated list of attribute values. Example: pascal
@EndifMan
@IfDoc
\begin{defalist}{\textbf{var_nm}}
\item[\ \ \ \textbf{var_nm}\ \ \hfill] Variable name (optional). Example: pressure
\item[\ \ \ \textbf{att_nm}\ \ \hfill] Attribute name. Example: units
\item[\ \ \ \textbf{att_val}\ \ \hfill] Comma separated list of attribute values. Example: pascal
\end{defalist}
@EndifDoc
The value of @bold{var_nm} is the name of the variable containing the attribute (named @bold{att_nm}) that
you want to set. Use wildcards to set the attribute @bold{att_nm} to more than one variable.
A value of @bold{var_nm} of '@bold{*}' will set the attribute @bold{att_nm} to all data variables.
If @bold{var_nm} is missing then @bold{att_nm} refers to a global attribute.
The value of @bold{att_nm} is the name of the attribute you want to set.
The value of @bold{att_val} is the contents of the attribute @bold{att_nm}. @bold{att_val} may be a single value
or one-dimensional array of elements. The type of the attribute value will be detected
automaticly from the contents of the value.
A special meaning has the attribute name @bold{FILE}. If this is the 1st attribute then all attributes
are read from a file specified in the value of @bold{att_val}.
@EndDescription
@EndModule
@BeginOperator_setattribute
@Title = Set attributes
@Parameter = attributes
@EndOperator
@BeginParameter
@Item = attributes
STRING Comma separated list of attributes.
@EndParameter
@BeginExample
To set the units of the variable pressure to pascal use:
@BeginVerbatim
cdo setattribute,pressure@units=pascal infile outfile
@EndVerbatim
To set the global text attribute "my_att" to "my contents", use:
@BeginVerbatim
cdo setattribute,my_att="my contents" infile outfile
@EndVerbatim
Result of '\texttt{ncdump -h outfile}':
@BeginListing
netcdf outfile {
dimensions: ...
variables: ...
// global attributes:
:my_att = "my contents" ;
}
@EndListing
@EndExample
......@@ -37,6 +37,7 @@ The following parameter table entries are supported:
convert & INTEGER & Set to 1 to convert the unit if necessary
@EndTable
Unsupported parameter table entries are stored as variable attributes.
The search key for the variable depends on the operator. Use @oper{setpartabn} to search variables by the name.
This is typically used for NetCDF datasets. The operator @oper{setpartabp} searches variables by the parameter ID.
@EndDescription
......
libcdi @ 14440b7b
Subproject commit d80fbb45efcae7f218eb8933d23f3a00ee5be517
Subproject commit 14440b7b3b844cc0d31141b6fcd9e74b3a64b9e6
......@@ -22,7 +22,6 @@
Adisit adipot compute potential from insitu temperature
*/
#include <ctype.h>
#include <cdi.h>
#include "cdo.h"
......
......@@ -4,7 +4,6 @@
#include "pstream.h"
#if defined(HAVE_LIBCMOR)
#include <ctype.h>
#include <unistd.h>
#include "uthash.h"
#include "cmor.h"
......
......@@ -15,7 +15,6 @@
GNU General Public License for more details.
*/
#include <ctype.h>
#include <cdi.h>
#include "cdo.h"
......
......@@ -15,7 +15,6 @@
GNU General Public License for more details.
*/
#include <ctype.h>
#include <cdi.h>
#include "cdo.h"
......@@ -87,8 +86,6 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
bool lregular = false;
bool lcurvilinear = false;
int gridID2 = -1;
int idx;
int ny, ix, iy, i, j, ij, offset;
double *xvals2 = NULL, *yvals2 = NULL;
int nx = -1;
......@@ -108,7 +105,7 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
for ( int fileID = 0; fileID < nfiles; fileID++ )
{
gridID = vlistGrid(ef[fileID].vlistID, igrid);
gridtype = gridInqType(gridID);
int gridtype = gridInqType(gridID);
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN )
lregular = true;
else if ( gridtype == GRID_CURVILINEAR )
......@@ -199,13 +196,13 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
if ( nx <= 0 ) nx = nfiles;
}
ny = nfiles/nx;
int ny = nfiles/nx;
if ( nx*ny != nfiles ) cdoAbort("Number of input files (%d) and number of blocks (%dx%d) differ!", nfiles, nx, ny);
int xsize2 = 0;
for ( i = 0; i < nx; ++i ) xsize2 += xsize[xyinfo[i].id];
for ( int i = 0; i < nx; ++i ) xsize2 += xsize[xyinfo[i].id];
int ysize2 = 0;
for ( j = 0; j < ny; ++j ) ysize2 += ysize[xyinfo[j*nx].id];
for ( int j = 0; j < ny; ++j ) ysize2 += ysize[xyinfo[j*nx].id];
if ( cdoVerbose ) cdoPrint("xsize2 %d ysize2 %d", xsize2, ysize2);
if ( lregular )
......@@ -223,17 +220,17 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
int *yoff = (int*) Malloc((ny+1)*sizeof(int));
xoff[0] = 0;
for ( i = 0; i < nx; ++i )
for ( int i = 0; i < nx; ++i )
{
idx = xyinfo[i].id;
int idx = xyinfo[i].id;
if ( lregular ) memcpy(xvals2+xoff[i], xvals[idx], xsize[idx]*sizeof(double));
xoff[i+1] = xoff[i] + xsize[idx];
}
yoff[0] = 0;
for ( j = 0; j < ny; ++j )
for ( int j = 0; j < ny; ++j )
{
idx = xyinfo[j*nx].id;
int idx = xyinfo[j*nx].id;
if ( lregular ) memcpy(yvals2+yoff[j], yvals[idx], ysize[idx]*sizeof(double));
yoff[j+1] = yoff[j] + ysize[idx];
}
......@@ -242,18 +239,18 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
{
for ( int fileID = 0; fileID < nfiles; fileID++ )
{
idx = xyinfo[fileID].id;
iy = fileID/nx;
ix = fileID - iy*nx;
int idx = xyinfo[fileID].id;
int iy = fileID/nx;
int ix = fileID - iy*nx;
offset = yoff[iy]*xsize2 + xoff[ix];
int offset = yoff[iy]*xsize2 + xoff[ix];
/*
printf("fileID %d %d, iy %d, ix %d, offset %d\n",
fileID, xyinfo[fileID].id, iy, ix, offset);
*/
ij = 0;
for ( j = 0; j < ysize[idx]; ++j )
for ( i = 0; i < xsize[idx]; ++i )
int ij = 0;
for ( int j = 0; j < ysize[idx]; ++j )
for ( int i = 0; i < xsize[idx]; ++i )
{
if ( lcurvilinear )
{
......@@ -294,6 +291,8 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
grid_copy_attributes(gridID, gridID2);
if ( gridtype == GRID_PROJECTION ) grid_copy_mapping(gridID, gridID2);
return gridID2;
}
......
......@@ -19,7 +19,6 @@
This module contains the following operators:
*/
#include <ctype.h> /* isspace */
#include <cdi.h>
#include "cdo.h"
......
......@@ -15,7 +15,6 @@
GNU General Public License for more details.
*/
#include <ctype.h>
#include <cdi.h>
#include "cdo.h"
......
......@@ -20,7 +20,6 @@
Derivepar gheight geopotential height
*/
#include <ctype.h>
#include <cdi.h>
#include "cdo.h"
......
......@@ -18,6 +18,7 @@
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
#include "grid.h"
#include "pstream.h"
#define MAX_BLOCKS 65536
......@@ -26,26 +27,21 @@ static
void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, int nyblocks,
int **gridindex, int *ogridsize, int nsplit)
{
int gridID2;
int gridsize2;
int i, j, ix, iy, offset;
double *xpvals = NULL, *ypvals = NULL;
int gridtype = gridInqType(gridID1);
int lregular = TRUE;
bool lregular = true;
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_GENERIC )
lregular = TRUE;
lregular = true;
else if ( gridtype == GRID_CURVILINEAR )
lregular = FALSE;
lregular = false;
else
cdoAbort("Unsupported grid type: %s!", gridNamePtr(gridtype));
int nx = gridInqXsize(gridID1);
int ny = gridInqYsize(gridID1);
bool lxcoord = true;
bool lycoord = true;
if ( gridInqXvals(gridID1, NULL) == 0 ) lxcoord = false;
if ( gridInqYvals(gridID1, NULL) == 0 ) lycoord = false;
bool lxcoord = gridInqXvals(gridID1, NULL) > 0;
bool lycoord = gridInqYvals(gridID1, NULL) > 0;
double *xvals = NULL, *yvals = NULL;
double *xvals2 = NULL, *yvals2 = NULL;
......@@ -83,44 +79,49 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
int *xlsize = (int*) Malloc(nxblocks*sizeof(int));
int *ylsize = (int*) Malloc(nyblocks*sizeof(int));
for ( ix = 0; ix < nxblocks; ++ix ) xlsize[ix] = nxvals;
for ( int ix = 0; ix < nxblocks; ++ix ) xlsize[ix] = nxvals;
if ( nx%nxblocks != 0 ) xlsize[nxblocks-1] = nx - (nxblocks-1)*nxvals;
if ( cdoVerbose ) for ( ix = 0; ix < nxblocks; ++ix ) cdoPrint("xblock %d: %d", ix, xlsize[ix]);
if ( cdoVerbose ) for ( int ix = 0; ix < nxblocks; ++ix ) cdoPrint("xblock %d: %d", ix, xlsize[ix]);
for ( iy = 0; iy < nyblocks; ++iy ) ylsize[iy] = nyvals;
for ( int iy = 0; iy < nyblocks; ++iy ) ylsize[iy] = nyvals;
if ( ny%nyblocks != 0 ) ylsize[nyblocks-1] = ny - (nyblocks-1)*nyvals;
if ( cdoVerbose ) for ( iy = 0; iy < nyblocks; ++iy ) cdoPrint("yblock %d: %d", iy, ylsize[iy]);
if ( cdoVerbose ) for ( int iy = 0; iy < nyblocks; ++iy ) cdoPrint("yblock %d: %d", iy, ylsize[iy]);
int index = 0;
for ( iy = 0; iy < nyblocks; ++iy )
for ( ix = 0; ix < nxblocks; ++ix )
for ( int iy = 0; iy < nyblocks; ++iy )
for ( int ix = 0; ix < nxblocks; ++ix )
{
offset = iy*nyvals*nx + ix*nxvals;
int offset = iy*nyvals*nx + ix*nxvals;
gridsize2 = xlsize[ix]*ylsize[iy];
int gridsize2 = xlsize[ix]*ylsize[iy];
gridindex[index] = (int*) Malloc(gridsize2*sizeof(int));
gridsize2 = 0;
// printf("iy %d, ix %d offset %d\n", iy, ix, offset);
for ( j = 0; j < ylsize[iy]; ++j )
{
for ( i = 0; i < xlsize[ix]; ++i )
{
// printf(">> %d %d %d\n", j, i, offset + j*nx + i);
if ( !lregular )
{
if ( lxcoord ) xvals2[gridsize2] = xvals[offset + j*nx + i];
if ( lycoord ) yvals2[gridsize2] = yvals[offset + j*nx + i];
}
gridindex[index][gridsize2++] = offset + j*nx + i;
}
}
for ( int j = 0; j < ylsize[iy]; ++j )
for ( int i = 0; i < xlsize[ix]; ++i )
{
// printf(">> %d %d %d\n", j, i, offset + j*nx + i);
if ( !lregular )
{
if ( lxcoord ) xvals2[gridsize2] = xvals[offset + j*nx + i];
if ( lycoord ) yvals2[gridsize2] = yvals[offset + j*nx + i];
}
gridindex[index][gridsize2++] = offset + j*nx + i;
}
// printf("gridsize2 %d\n", gridsize2);
gridID2 = gridCreate(gridtype, gridsize2);
int gridID2 = gridCreate(gridtype, gridsize2);
gridDefXsize(gridID2, xlsize[ix]);
gridDefYsize(gridID2, ylsize[iy]);
gridDefNP(gridID2, gridInqNP(gridID1));
gridDefPrec(gridID2, gridInqPrec(gridID1));
grid_copy_attributes(gridID1, gridID2);
if ( gridtype == GRID_PROJECTION ) grid_copy_mapping(gridID1, gridID2);
if ( lregular )
{
if ( lxcoord ) gridDefXvals(gridID2, xvals+ix*nxvals);
......@@ -131,7 +132,41 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
if ( lxcoord ) gridDefXvals(gridID2, xvals2);
if ( lycoord ) gridDefYvals(gridID2, yvals2);
}
int projID1 = gridInqProj(gridID1);
if ( projID1 != CDI_UNDEFID && gridInqType(projID1) == GRID_PROJECTION )
{
int projID2 = gridCreate(GRID_PROJECTION, gridsize2);
gridDefXsize(projID2, xlsize[ix]);
gridDefYsize(projID2, ylsize[iy]);
grid_copy_attributes(projID1, projID2);
grid_copy_mapping(projID1, projID2);
bool lxpcoord = gridInqXvals(projID1, NULL) > 0;
if ( lxpcoord )
{
if ( !xpvals )
{
xpvals = (double*) Malloc(nx*sizeof(double));
gridInqXvals(projID1, xpvals);
}
gridDefXvals(projID2, xpvals+ix*nxvals);
}
bool lypcoord = gridInqYvals(projID1, NULL) > 0;
if ( lypcoord )
{
if ( !ypvals )
{
ypvals = (double*) Malloc(ny*sizeof(double));
gridInqYvals(projID1, ypvals);
}
gridDefYvals(projID2, ypvals+iy*nyvals);
}
gridDefProj(gridID2, projID2);
}
gridIDs[index] = gridID2;
ogridsize[index] = gridsize2;
......@@ -142,10 +177,12 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
if ( xvals2 ) Free(xvals2);
if ( yvals2 ) Free(yvals2);
Free(xvals);
Free(yvals);
Free(xlsize);
Free(ylsize);
if ( xvals ) Free(xvals);
if ( yvals ) Free(yvals);
if ( xpvals ) Free(xpvals);
if ( ypvals ) Free(ypvals);
if ( xlsize ) Free(xlsize);
if ( ylsize ) Free(ylsize);
}
static
......@@ -171,12 +208,10 @@ void *Distgrid(void *argument)
int nrecs;
char filesuffix[32];
char filename[8192];
const char *refname;
int index;
int gridtype = -1;
int nmiss;
int i;
double missval;
cdoInitialize(argument);
......@@ -212,7 +247,7 @@ void *Distgrid(void *argument)
int gridsize = gridInqSize(gridID1);
int nx = gridInqXsize(gridID1);
int ny = gridInqYsize(gridID1);
for ( i = 1; i < ngrids; i++ )
for ( int i = 1; i < ngrids; i++ )
{
gridID1 = vlistGrid(vlistID1, i);
if ( gridsize != gridInqSize(gridID1) )
......@@ -245,36 +280,36 @@ void *Distgrid(void *argument)
int *streamIDs = (int*) Malloc(nsplit*sizeof(int));
sgrid_t *grids = (sgrid_t*) Malloc(ngrids*sizeof(sgrid_t));
for ( i = 0; i < ngrids; i++ )
for ( int i = 0; i < ngrids; i++ )
{
grids[i].gridID = vlistGrid(vlistID1, i);
grids[i].gridIDs = (int*) Malloc(nsplit*sizeof(int));
grids[i].gridsize = (int*) Malloc(nsplit*sizeof(int));
grids[i].gridindex = (int**) Malloc(nsplit*sizeof(int*));
for ( index = 0; index < nsplit; index++ ) grids[i].gridindex[index] = NULL;
for ( int index = 0; index < nsplit; index++ ) grids[i].gridindex[index] = NULL;
}
for ( index = 0; index < nsplit; index++ )
for ( int index = 0; index < nsplit; index++ )
vlistIDs[index] = vlistDuplicate(vlistID1);
if ( cdoVerbose ) cdoPrint("ngrids=%d nsplit=%d", ngrids, nsplit);
for ( i = 0; i < ngrids; i++ )
for ( int i = 0; i < ngrids; i++ )
{
gridID1 = vlistGrid(vlistID1, i);
genGrids(gridID1, grids[i].gridIDs, xinc, yinc, nxblocks, nyblocks, grids[i].gridindex, grids[i].gridsize, nsplit);
/*
if ( cdoVerbose )
for ( index = 0; index < nsplit; index++ )