Commit 64037f88 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added operator duplicate

parent dfd14eb7
......@@ -270,6 +270,7 @@ src/Copy.c -text
src/Deltime.c -text
src/Detrend.c -text
src/Diff.c -text
src/Duplicate.c -text
src/EOFs.c -text
src/EcaIndices.c -text
src/Echam5ini.c -text
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.66 for cdo 1.4.8rc1.
# Generated by GNU Autoconf 2.66 for cdo 1.4.8rc2.
#
# Report bugs to <http://code.zmaw.de/projects/cdo>.
#
......@@ -562,8 +562,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdo'
PACKAGE_TARNAME='cdo'
PACKAGE_VERSION='1.4.8rc1'
PACKAGE_STRING='cdo 1.4.8rc1'
PACKAGE_VERSION='1.4.8rc2'
PACKAGE_STRING='cdo 1.4.8rc2'
PACKAGE_BUGREPORT='http://code.zmaw.de/projects/cdo'
PACKAGE_URL=''
 
......@@ -1339,7 +1339,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.4.8rc1 to adapt to many kinds of systems.
\`configure' configures cdo 1.4.8rc2 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
......@@ -1409,7 +1409,7 @@ fi
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdo 1.4.8rc1:";;
short | recursive ) echo "Configuration of cdo 1.4.8rc2:";;
esac
cat <<\_ACEOF
 
......@@ -1545,7 +1545,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdo configure 1.4.8rc1
cdo configure 1.4.8rc2
generated by GNU Autoconf 2.66
 
Copyright (C) 2010 Free Software Foundation, Inc.
......@@ -2092,7 +2092,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.4.8rc1, which was
It was created by cdo $as_me 1.4.8rc2, which was
generated by GNU Autoconf 2.66. Invocation command line was
 
$ $0 $@
......@@ -2987,7 +2987,7 @@ fi
 
# Define the identity of the package.
PACKAGE='cdo'
VERSION='1.4.8rc1'
VERSION='1.4.8rc2'
 
 
cat >>confdefs.h <<_ACEOF
......@@ -18562,7 +18562,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.4.8rc1, which was
This file was extended by cdo $as_me 1.4.8rc2, which was
generated by GNU Autoconf 2.66. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
......@@ -18628,7 +18628,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.4.8rc1
cdo config.status 1.4.8rc2
configured by $0, generated by GNU Autoconf 2.66,
with options \\"\$ac_cs_config\\"
 
......
# Process this file with autoconf to produce a configure script.
AC_INIT([cdo], [1.4.8rc1], [http://code.zmaw.de/projects/cdo])
AC_INIT([cdo], [1.4.8rc2], [http://code.zmaw.de/projects/cdo])
CONFIG_ABORT=yes
AC_CONFIG_AUX_DIR(config)
......
/*
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2011 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
#define NALLOC_INC 1024
void *Duplicate(void *argument)
{
int gridsize;
int nrecs;
int gridID, varID, levelID, recID;
int tsID;
int nts;
int nalloc = 0;
int streamID1, streamID2;
int vlistID1, vlistID2, taxisID1, taxisID2;
int nmiss;
int nvars, nlevel;
int *vdate = NULL, *vtime = NULL;
int idup, ndup = 1;
double missval;
field_t ***vars = NULL;
cdoInitialize(argument);
if ( operatorArgc() > 1 ) cdoAbort("Too many arguments!");
else if ( operatorArgc() == 1 ) ndup = atoi(operatorArgv()[0]);
if ( cdoVerbose ) cdoPrint("ndup = %d\n", ndup);
streamID1 = streamOpenRead(cdoStreamName(0));
if ( streamID1 < 0 ) cdiError(streamID1, "Open failed on %s", cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
if ( streamID2 < 0 ) cdiError(streamID2, "Open failed on %s", cdoStreamName(1));
streamDefVlist(streamID2, vlistID2);
nvars = vlistNvars(vlistID1);
tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
if ( tsID >= nalloc )
{
nalloc += NALLOC_INC;
vdate = (int *) realloc(vdate, nalloc*sizeof(int));
vtime = (int *) realloc(vtime, nalloc*sizeof(int));
vars = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
}
vdate[tsID] = taxisInqVdate(taxisID1);
vtime[tsID] = taxisInqVtime(taxisID1);
vars[tsID] = (field_t **) malloc(nvars*sizeof(field_t *));
for ( varID = 0; varID < nvars; varID++ )
{
gridID = vlistInqVarGrid(vlistID1, varID);
missval = vlistInqVarMissval(vlistID1, varID);
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
vars[tsID][varID] = (field_t *) malloc(nlevel*sizeof(field_t));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
vars[tsID][varID][levelID].grid = gridID;
vars[tsID][varID][levelID].missval = missval;
vars[tsID][varID][levelID].ptr = NULL;
}
}
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
gridID = vlistInqVarGrid(vlistID1, varID);
gridsize = gridInqSize(gridID);
vars[tsID][varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double));
streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
vars[tsID][varID][levelID].nmiss = nmiss;
}
tsID++;
}
nts = tsID;
for ( idup = 0; idup < ndup; idup++ )
{
for ( tsID = 0; tsID < nts; tsID++ )
{
taxisDefVdate(taxisID2, vdate[tsID]);
taxisDefVtime(taxisID2, vtime[tsID]);
streamDefTimestep(streamID2, idup*nts+tsID);
for ( varID = 0; varID < nvars; varID++ )
{
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( vars[tsID][varID][levelID].ptr )
{
nmiss = vars[tsID][varID][levelID].nmiss;
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
}
}
}
}
}
for ( tsID = 0; tsID < nts; tsID++ )
{
for ( varID = 0; varID < nvars; varID++ )
{
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevel; levelID++ )
if ( vars[tsID][varID][levelID].ptr )
free(vars[tsID][varID][levelID].ptr);
free(vars[tsID][varID]);
}
free(vars[tsID]);
}
if ( vars ) free(vars);
if ( vdate ) free(vdate);
if ( vtime ) free(vtime);
streamClose(streamID2);
streamClose(streamID1);
cdoFinish();
return (0);
}
......@@ -24,6 +24,7 @@ cdo_SOURCES += Arith.c \
Deltime.c \
Detrend.c \
Diff.c \
Duplicate.c \
EOFs.c \
Eof3d.c \
EcaIndices.c \
......
......@@ -65,7 +65,7 @@ am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Arith.$(OBJEXT) \
cdo-Cond2.$(OBJEXT) cdo-Condc.$(OBJEXT) \
cdo-Consecstat.$(OBJEXT) cdo-Copy.$(OBJEXT) \
cdo-Deltime.$(OBJEXT) cdo-Detrend.$(OBJEXT) cdo-Diff.$(OBJEXT) \
cdo-EOFs.$(OBJEXT) cdo-Eof3d.$(OBJEXT) \
cdo-Duplicate.$(OBJEXT) cdo-EOFs.$(OBJEXT) cdo-Eof3d.$(OBJEXT) \
cdo-EcaIndices.$(OBJEXT) cdo-Echam5ini.$(OBJEXT) \
cdo-Enlarge.$(OBJEXT) cdo-Enlargegrid.$(OBJEXT) \
cdo-Ensstat.$(OBJEXT) cdo-Ensstat3.$(OBJEXT) \
......@@ -335,18 +335,18 @@ top_srcdir = @top_srcdir@
cdo_SOURCES = cdo.c Arith.c Arithc.c Arithdays.c Arithlat.c CDItest.c \
Cat.c Change.c Change_e5slm.c Cloudlayer.c Command.c Comp.c \
Compc.c Complextorect.c Cond.c Cond2.c Condc.c Consecstat.c \
Copy.c Deltime.c Detrend.c Diff.c EOFs.c Eof3d.c EcaIndices.c \
Echam5ini.c Enlarge.c Enlargegrid.c Ensstat.c Ensstat3.c \
Eofcoeff.c Eofcoeff3d.c Exprf.c Filedes.c Fillmiss.c Filter.c \
Fldrms.c Fldstat.c Fldstat2.c Fourier.c Gather.c Gengrid.c \
Gradsdes.c Gridboxstat.c Gridcell.c Harmonic.c Hi.c \
Histogram.c IFS2ICON.c Importamsr.c Importbinary.c \
Importcmsaf.c Importobs.c Info.c Input.c Intgrid.c \
Intgridtraj.c Intlevel.c Intntime.c Inttime.c Intyear.c \
Invert.c Invertlev.c Log.c Maskbox.c Mastrfu.c Math.c Merge.c \
Mergegrid.c Mergetime.c Merstat.c Monarith.c Mrotuv.c \
Mrotuvb.c Ninfo.c Nmltest.c Output.c Outputgmt.c Pinfo.c \
Pressure.c Regres.c Remap.c Remapeta.c Replace.c \
Copy.c Deltime.c Detrend.c Diff.c Duplicate.c EOFs.c Eof3d.c \
EcaIndices.c Echam5ini.c Enlarge.c Enlargegrid.c Ensstat.c \
Ensstat3.c Eofcoeff.c Eofcoeff3d.c Exprf.c Filedes.c \
Fillmiss.c Filter.c Fldrms.c Fldstat.c Fldstat2.c Fourier.c \
Gather.c Gengrid.c Gradsdes.c Gridboxstat.c Gridcell.c \
Harmonic.c Hi.c Histogram.c IFS2ICON.c Importamsr.c \
Importbinary.c Importcmsaf.c Importobs.c Info.c Input.c \
Intgrid.c Intgridtraj.c Intlevel.c Intntime.c Inttime.c \
Intyear.c Invert.c Invertlev.c Log.c Maskbox.c Mastrfu.c \
Math.c Merge.c Mergegrid.c Mergetime.c Merstat.c Monarith.c \
Mrotuv.c Mrotuvb.c Ninfo.c Nmltest.c Output.c Outputgmt.c \
Pinfo.c Pressure.c Regres.c Remap.c Remapeta.c Replace.c \
Replacevalues.c Rotuv.c Runpctl.c Runstat.c Scatter.c \
Seascount.c Seaspctl.c Seasstat.c Selbox.c Select.c \
Seloperator.c Selrec.c Seltime.c Selvar.c Set.c Setbox.c \
......@@ -529,6 +529,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Deltime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Detrend.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Diff.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Duplicate.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-EOFs.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-EcaIndices.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Echam5ini.Po@am__quote@
......@@ -1054,6 +1055,20 @@ cdo-Diff.obj: Diff.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Diff.obj `if test -f 'Diff.c'; then $(CYGPATH_W) 'Diff.c'; else $(CYGPATH_W) '$(srcdir)/Diff.c'; fi`
cdo-Duplicate.o: Duplicate.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Duplicate.o -MD -MP -MF $(DEPDIR)/cdo-Duplicate.Tpo -c -o cdo-Duplicate.o `test -f 'Duplicate.c' || echo '$(srcdir)/'`Duplicate.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cdo-Duplicate.Tpo $(DEPDIR)/cdo-Duplicate.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='Duplicate.c' object='cdo-Duplicate.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Duplicate.o `test -f 'Duplicate.c' || echo '$(srcdir)/'`Duplicate.c
cdo-Duplicate.obj: Duplicate.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Duplicate.obj -MD -MP -MF $(DEPDIR)/cdo-Duplicate.Tpo -c -o cdo-Duplicate.obj `if test -f 'Duplicate.c'; then $(CYGPATH_W) 'Duplicate.c'; else $(CYGPATH_W) '$(srcdir)/Duplicate.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cdo-Duplicate.Tpo $(DEPDIR)/cdo-Duplicate.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='Duplicate.c' object='cdo-Duplicate.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Duplicate.obj `if test -f 'Duplicate.c'; then $(CYGPATH_W) 'Duplicate.c'; else $(CYGPATH_W) '$(srcdir)/Duplicate.c'; fi`
cdo-EOFs.o: EOFs.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-EOFs.o -MD -MP -MF $(DEPDIR)/cdo-EOFs.Tpo -c -o cdo-EOFs.o `test -f 'EOFs.c' || echo '$(srcdir)/'`EOFs.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cdo-EOFs.Tpo $(DEPDIR)/cdo-EOFs.Po
......
......@@ -59,6 +59,7 @@ void *Copy(void *argument);
void *Deltime(void *argument);
void *Detrend(void *argument);
void *Diff(void *argument);
void *Duplicate(void *argument);
void *Echam5ini(void *argument);
void *Enlarge(void *argument);
void *Enlargegrid(void *argument);
......@@ -264,6 +265,7 @@ void *Wct(void *argument);
#define DeltimeOperators {"delday", "del29feb"}
#define DetrendOperators {"detrend"}
#define DiffOperators {"diff", "diffp", "diffv", "sdiff"}
#define DuplicateOperators {"duplicate"}
#define Echam5iniOperators {"import_e5ml", "import_e5res", \
"export_e5ml", "export_e5res"}
#define EnlargeOperators {"enlarge"}
......@@ -507,6 +509,7 @@ static modules_t Modules[] =
{ Deltime, NULL, DeltimeOperators, CDI_REAL, 1, 1 },
{ Detrend, DetrendHelp, DetrendOperators, CDI_REAL, 1, 1 },
{ Diff, DiffHelp, DiffOperators, CDI_REAL, 2, 0 },
{ Duplicate, NULL, DuplicateOperators, CDI_REAL, 1, 1 },
{ Echam5ini, NULL, Echam5iniOperators, CDI_REAL, 1, 1 },
{ Enlarge, EnlargeHelp, EnlargeOperators, CDI_REAL, 1, 1 },
{ Enlargegrid, NULL, EnlargegridOperators, CDI_REAL, 1, 1 },
......
Supports Markdown
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