Commit 043bbd05 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

add module Filter

parent 4dabc9a8
......@@ -228,6 +228,7 @@ src/Ensstat.c -text
src/Exprf.c -text
src/Filedes.c -text
src/Fillmiss.c -text
src/Filter.c -text
src/Fldrms.c -text
src/Fldstat.c -text
src/Gengrid.c -text
......
......@@ -49,7 +49,7 @@ case "${HOSTNAME}" in
# x86_64-suse-linux
tornado1)
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/sles9-x64 \
--with-netcdf=/sw/sles9-x64/netcdf-3.6.1 \
--with-netcdf=/sw/sles9-x64/netcdf-3.6.2 \
--with-szlib=$HOME/local/sles9-x64 \
CC=gcc CFLAGS="-g -D_REENTRANT -O2 -Wall"
;;
......@@ -57,13 +57,13 @@ case "${HOSTNAME}" in
squall1)
if [ "$SGE_MODE" = "off" ] ; then
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/etch-x64 \
--with-netcdf=/sw/etch-x64/netcdf-3.6.1 \
--with-netcdf=/sw/etch-x64/netcdf-3.6.2 \
--with-szlib=/sw/etch-x64/szip-2.1 \
--with-proj=$HOME/local/etch-x64/proj-4.6.1 \
CC=gcc CFLAGS="-g -D_REENTRANT -O2 -Wall"
else
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/etch-x64 \
--with-netcdf=/sw/etch-x64/netcdf-3.6.1 \
--with-netcdf=/sw/etch-x64/netcdf-3.6.2 \
--with-szlib=/sw/etch-x64/szip-2.1 \
CPPFLAGS="-DHAVE_LIBDRMAA -I/opt/gridware/sge/include -DHAVE_LIBCURL -I/usr/include" \
LIBS="-L/opt/gridware/sge/lib/lx24-amd64 -ldrmaa -ldl -L/usr/lib -lcurl" \
......@@ -81,7 +81,7 @@ case "${HOSTNAME}" in
etch-ia32 | gata | baba)
if [ "$SGE_MODE" = "off" ] ; then
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/etch-ia32 \
--with-netcdf=/sw/etch-ia32/netcdf-3.6.1 \
--with-netcdf=/sw/etch-ia32/netcdf-3.6.2 \
--with-hdf5=/sw/etch-ia32/hdf5-1.8.0 \
--with-szlib=$HOME/local/etch-ia32 \
--with-proj=/sw/etch-ia32/proj-4.6.0 \
......@@ -89,7 +89,7 @@ case "${HOSTNAME}" in
else
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/etch-ia32 \
--program-suffix=_${SGE_SUFFIX} \
--with-netcdf=/sw/etch-ia32/netcdf-3.6.1 \
--with-netcdf=/sw/etch-ia32/netcdf-3.6.2 \
--with-szlib=$HOME/local/etch-ia32 \
CPPFLAGS="-DHAVE_LIBDRMAA -I/opt/gridware/sge/include -DHAVE_LIBCURL -I/usr/include" \
LIBS="-L/opt/gridware/sge/lib/lx24-x86 -ldrmaa -ldl -L/usr/lib -lcurl" \
......@@ -129,7 +129,7 @@ case "${HOSTNAME}" in
# sparc-sun-solaris2.10
xxf)
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris10 \
--with-netcdf=/sw/solaris10/netcdf-3.6.1 \
--with-netcdf=/sw/solaris10/netcdf-3.6.2 \
CC=cc CFLAGS="-g -mt -xO3 -m64"
;;
# sparc-sun-solaris2.9 changed to
......@@ -137,13 +137,13 @@ case "${HOSTNAME}" in
executor | yang | yin)
if [ "$SGE_MODE" = "off" ] ; then
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris10 \
--with-netcdf=/sw/solaris10/netcdf-3.6.1 \
--with-netcdf=/sw/solaris10/netcdf-3.6.2 \
--with-szlib=$HOME/local/solaris10 \
CC=cc CFLAGS="-g -mt -xO3 -m64"
else
${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/solaris10 \
--program-suffix=_${SGE_SUFFIX} \
--with-netcdf=/sw/solaris10/netcdf-3.6.1 \
--with-netcdf=/sw/solaris10/netcdf-3.6.2 \
--with-szlib=$HOME/local/solaris10 \
CPPFLAGS="-DHAVE_LIBDRMAA -I/opt/gridware/sge/include -DHAVE_LIBCURL -I/usr/local/include" \
LIBS="-L/opt/gridware/sge/lib/sol-sparc64 -ldrmaa -ldl -L/sw/solaris10/curl-7.16.4-cc/lib -lcurl" \
......
......@@ -31,6 +31,7 @@
#define NALLOC_INC 1000
static
void detrend(int nts, double missval1, double *array1, double *array2)
{
int j;
......
/*
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2008 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.
*/
/*
This module contains the following operators:
*/
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
#define NALLOC_INC 1000
static
void detrend(int nts, double missval1, double *array1, double *array2)
{
int j;
int n;
double sumj, sumjj;
double sumx, sumjx;
double work1, work2;
double missval2 = missval1;
sumx = sumjx = 0;
sumj = sumjj = n = 0;
for ( j = 0; j < nts; j++ )
if ( !DBL_IS_EQUAL(array1[j], missval1) )
{
sumx += array1[j];
sumjx += j * array1[j];
sumj += j;
sumjj += j * j;
n++;
}
work1 = DIV(SUB(sumjx, DIV(MUL(sumx, sumj), n) ),
SUB(sumjj, DIV(MUL(sumj, sumj), n)) );
work2 = SUB(DIV(sumx, n), MUL(work1, DIV(sumj, n)));
for ( j = 0; j < nts; j++ )
array2[j] = SUB(array1[j], ADD(work2, MUL(j, work1)));
}
void *Filter(void *argument)
{
static char func[] = "Filter";
int gridsize;
int nrecs;
int gridID, varID, levelID, recID;
int tsID;
int i;
int nts;
int nalloc = 0;
int streamID1, streamID2;
int vlistID1, vlistID2, taxisID1, taxisID2;
int nmiss;
int nvars, nlevel;
int *vdate = NULL, *vtime = NULL;
double missval;
double *array1, *array2;
FIELD ***vars = NULL;
cdoInitialize(argument);
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 ***) realloc(vars, nalloc*sizeof(FIELD **));
}
vdate[tsID] = taxisInqVdate(taxisID1);
vtime[tsID] = taxisInqVtime(taxisID1);
vars[tsID] = (FIELD **) malloc(nvars*sizeof(FIELD *));
for ( varID = 0; varID < nvars; varID++ )
{
gridID = vlistInqVarGrid(vlistID1, varID);
missval = vlistInqVarMissval(vlistID1, varID);
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
vars[tsID][varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
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;
array1 = (double *) malloc(nts*sizeof(double));
array2 = (double *) malloc(nts*sizeof(double));
for ( varID = 0; varID < nvars; varID++ )
{
gridID = vlistInqVarGrid(vlistID1, varID);
missval = vlistInqVarMissval(vlistID1, varID);
gridsize = gridInqSize(gridID);
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
for ( i = 0; i < gridsize; i++ )
{
for ( tsID = 0; tsID < nts; tsID++ )
array1[tsID] = vars[tsID][varID][levelID].ptr[i];
detrend(nts, missval, array1, array2);
for ( tsID = 0; tsID < nts; tsID++ )
vars[tsID][varID][levelID].ptr[i] = array2[tsID];
}
}
}
if ( array1 ) free(array1);
if ( array2 ) free(array2);
for ( tsID = 0; tsID < nts; tsID++ )
{
taxisDefVdate(taxisID2, vdate[tsID]);
taxisDefVtime(taxisID2, vtime[tsID]);
streamDefTimestep(streamID2, 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);
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);
}
......@@ -27,6 +27,7 @@ cdo_SOURCES = Arith.c \
Exprf.c \
Filedes.c \
Fillmiss.c \
Filter.c \
Fldrms.c \
Fldstat.c \
Gengrid.c \
......
......@@ -55,62 +55,62 @@ am_cdo_OBJECTS = Arith.$(OBJEXT) Arithc.$(OBJEXT) Arithdays.$(OBJEXT) \
Del29feb.$(OBJEXT) Detrend.$(OBJEXT) Diff.$(OBJEXT) \
Echam5ini.$(OBJEXT) Enlarge.$(OBJEXT) Enlargegrid.$(OBJEXT) \
Ensstat.$(OBJEXT) Exprf.$(OBJEXT) Filedes.$(OBJEXT) \
Fillmiss.$(OBJEXT) Fldrms.$(OBJEXT) Fldstat.$(OBJEXT) \
Gengrid.$(OBJEXT) Gradsdes.$(OBJEXT) Gridboxstat.$(OBJEXT) \
Gridcell.$(OBJEXT) Harmonic.$(OBJEXT) Histogram.$(OBJEXT) \
Importamsr.$(OBJEXT) Importcmsaf.$(OBJEXT) Info.$(OBJEXT) \
Input.$(OBJEXT) Intgrid.$(OBJEXT) Intgridtraj.$(OBJEXT) \
Intlevel.$(OBJEXT) Inttime.$(OBJEXT) Intntime.$(OBJEXT) \
Intyear.$(OBJEXT) Invert.$(OBJEXT) Invertlev.$(OBJEXT) \
Log.$(OBJEXT) Maskbox.$(OBJEXT) Mastrfu.$(OBJEXT) \
Math.$(OBJEXT) Merge.$(OBJEXT) Mergegrid.$(OBJEXT) \
Mergetime.$(OBJEXT) Merstat.$(OBJEXT) Monarith.$(OBJEXT) \
Mrotuv.$(OBJEXT) Mrotuvb.$(OBJEXT) Ninfo.$(OBJEXT) \
Nmltest.$(OBJEXT) Output.$(OBJEXT) Outputgmt.$(OBJEXT) \
Pinfo.$(OBJEXT) Pressure.$(OBJEXT) Regres.$(OBJEXT) \
Remap.$(OBJEXT) Remapeta.$(OBJEXT) Replace.$(OBJEXT) \
Rotuv.$(OBJEXT) Runpctl.$(OBJEXT) Runstat.$(OBJEXT) \
Seascount.$(OBJEXT) Seaspctl.$(OBJEXT) Seasstat.$(OBJEXT) \
Selbox.$(OBJEXT) Select.$(OBJEXT) Seloperator.$(OBJEXT) \
Selrec.$(OBJEXT) Seltime.$(OBJEXT) Set.$(OBJEXT) \
Setbox.$(OBJEXT) Setgatt.$(OBJEXT) Setgrid.$(OBJEXT) \
Sethalo.$(OBJEXT) Setmiss.$(OBJEXT) Setrange.$(OBJEXT) \
Setrcaname.$(OBJEXT) Settime.$(OBJEXT) Setzaxis.$(OBJEXT) \
Showinfo.$(OBJEXT) Sinfo.$(OBJEXT) Smooth9.$(OBJEXT) \
Sort.$(OBJEXT) Specinfo.$(OBJEXT) Spectral.$(OBJEXT) \
Spectrum.$(OBJEXT) Split.$(OBJEXT) Splitrec.$(OBJEXT) \
Splitsel.$(OBJEXT) Splittime.$(OBJEXT) Splityear.$(OBJEXT) \
Subtrend.$(OBJEXT) Templates.$(OBJEXT) Test.$(OBJEXT) \
Tests.$(OBJEXT) Timcount.$(OBJEXT) Timpctl.$(OBJEXT) \
Timsort.$(OBJEXT) Timselpctl.$(OBJEXT) Timselstat.$(OBJEXT) \
Timstat.$(OBJEXT) Timstat2.$(OBJEXT) Timstat3.$(OBJEXT) \
Tinfo.$(OBJEXT) Trend.$(OBJEXT) Trms.$(OBJEXT) \
Vardup.$(OBJEXT) Vargen.$(OBJEXT) Varrms.$(OBJEXT) \
Vertint.$(OBJEXT) Vertstat.$(OBJEXT) Vertwind.$(OBJEXT) \
Wind.$(OBJEXT) Writegrid.$(OBJEXT) Writerandom.$(OBJEXT) \
Yhourstat.$(OBJEXT) Ydaypctl.$(OBJEXT) Ydaystat.$(OBJEXT) \
Ydrunpctl.$(OBJEXT) Ydrunstat.$(OBJEXT) Ymonarith.$(OBJEXT) \
Ymonpctl.$(OBJEXT) Ymonstat.$(OBJEXT) Yseaspctl.$(OBJEXT) \
Yseasstat.$(OBJEXT) Zonstat.$(OBJEXT) cdilib.$(OBJEXT) \
commandline.$(OBJEXT) exception.$(OBJEXT) expr_yacc.$(OBJEXT) \
expr_lex.$(OBJEXT) expr.$(OBJEXT) cdo.$(OBJEXT) \
cdo_pthread.$(OBJEXT) cdo_vlist.$(OBJEXT) field.$(OBJEXT) \
fieldc.$(OBJEXT) field2.$(OBJEXT) fieldmer.$(OBJEXT) \
fieldzon.$(OBJEXT) grid.$(OBJEXT) grid_gme.$(OBJEXT) \
grid_lcc.$(OBJEXT) grid_rot.$(OBJEXT) griddes.$(OBJEXT) \
griddes_nc.$(OBJEXT) griddes_h5.$(OBJEXT) hetaeta.$(OBJEXT) \
history.$(OBJEXT) institution.$(OBJEXT) interpol.$(OBJEXT) \
job.$(OBJEXT) modules.$(OBJEXT) namelist.$(OBJEXT) \
normal.$(OBJEXT) pipe.$(OBJEXT) process.$(OBJEXT) \
remaplib.$(OBJEXT) timer.$(OBJEXT) realtime.$(OBJEXT) \
pstream.$(OBJEXT) table.$(OBJEXT) userlog.$(OBJEXT) \
util.$(OBJEXT) legendre.$(OBJEXT) fourier.$(OBJEXT) \
specspace.$(OBJEXT) readline.$(OBJEXT) julian.$(OBJEXT) \
vinterp.$(OBJEXT) zaxis.$(OBJEXT) pthread_debug.$(OBJEXT) \
color.$(OBJEXT) list.$(OBJEXT) percentiles.$(OBJEXT) \
nth_element.$(OBJEXT) ecacore.$(OBJEXT) ecautil.$(OBJEXT) \
EcaIndices.$(OBJEXT) Hi.$(OBJEXT) Wct.$(OBJEXT) \
statistic.$(OBJEXT)
Fillmiss.$(OBJEXT) Filter.$(OBJEXT) Fldrms.$(OBJEXT) \
Fldstat.$(OBJEXT) Gengrid.$(OBJEXT) Gradsdes.$(OBJEXT) \
Gridboxstat.$(OBJEXT) Gridcell.$(OBJEXT) Harmonic.$(OBJEXT) \
Histogram.$(OBJEXT) Importamsr.$(OBJEXT) Importcmsaf.$(OBJEXT) \
Info.$(OBJEXT) Input.$(OBJEXT) Intgrid.$(OBJEXT) \
Intgridtraj.$(OBJEXT) Intlevel.$(OBJEXT) Inttime.$(OBJEXT) \
Intntime.$(OBJEXT) Intyear.$(OBJEXT) Invert.$(OBJEXT) \
Invertlev.$(OBJEXT) Log.$(OBJEXT) Maskbox.$(OBJEXT) \
Mastrfu.$(OBJEXT) Math.$(OBJEXT) Merge.$(OBJEXT) \
Mergegrid.$(OBJEXT) Mergetime.$(OBJEXT) Merstat.$(OBJEXT) \
Monarith.$(OBJEXT) Mrotuv.$(OBJEXT) Mrotuvb.$(OBJEXT) \
Ninfo.$(OBJEXT) Nmltest.$(OBJEXT) Output.$(OBJEXT) \
Outputgmt.$(OBJEXT) Pinfo.$(OBJEXT) Pressure.$(OBJEXT) \
Regres.$(OBJEXT) Remap.$(OBJEXT) Remapeta.$(OBJEXT) \
Replace.$(OBJEXT) Rotuv.$(OBJEXT) Runpctl.$(OBJEXT) \
Runstat.$(OBJEXT) Seascount.$(OBJEXT) Seaspctl.$(OBJEXT) \
Seasstat.$(OBJEXT) Selbox.$(OBJEXT) Select.$(OBJEXT) \
Seloperator.$(OBJEXT) Selrec.$(OBJEXT) Seltime.$(OBJEXT) \
Set.$(OBJEXT) Setbox.$(OBJEXT) Setgatt.$(OBJEXT) \
Setgrid.$(OBJEXT) Sethalo.$(OBJEXT) Setmiss.$(OBJEXT) \
Setrange.$(OBJEXT) Setrcaname.$(OBJEXT) Settime.$(OBJEXT) \
Setzaxis.$(OBJEXT) Showinfo.$(OBJEXT) Sinfo.$(OBJEXT) \
Smooth9.$(OBJEXT) Sort.$(OBJEXT) Specinfo.$(OBJEXT) \
Spectral.$(OBJEXT) Spectrum.$(OBJEXT) Split.$(OBJEXT) \
Splitrec.$(OBJEXT) Splitsel.$(OBJEXT) Splittime.$(OBJEXT) \
Splityear.$(OBJEXT) Subtrend.$(OBJEXT) Templates.$(OBJEXT) \
Test.$(OBJEXT) Tests.$(OBJEXT) Timcount.$(OBJEXT) \
Timpctl.$(OBJEXT) Timsort.$(OBJEXT) Timselpctl.$(OBJEXT) \
Timselstat.$(OBJEXT) Timstat.$(OBJEXT) Timstat2.$(OBJEXT) \
Timstat3.$(OBJEXT) Tinfo.$(OBJEXT) Trend.$(OBJEXT) \
Trms.$(OBJEXT) Vardup.$(OBJEXT) Vargen.$(OBJEXT) \
Varrms.$(OBJEXT) Vertint.$(OBJEXT) Vertstat.$(OBJEXT) \
Vertwind.$(OBJEXT) Wind.$(OBJEXT) Writegrid.$(OBJEXT) \
Writerandom.$(OBJEXT) Yhourstat.$(OBJEXT) Ydaypctl.$(OBJEXT) \
Ydaystat.$(OBJEXT) Ydrunpctl.$(OBJEXT) Ydrunstat.$(OBJEXT) \
Ymonarith.$(OBJEXT) Ymonpctl.$(OBJEXT) Ymonstat.$(OBJEXT) \
Yseaspctl.$(OBJEXT) Yseasstat.$(OBJEXT) Zonstat.$(OBJEXT) \
cdilib.$(OBJEXT) commandline.$(OBJEXT) exception.$(OBJEXT) \
expr_yacc.$(OBJEXT) expr_lex.$(OBJEXT) expr.$(OBJEXT) \
cdo.$(OBJEXT) cdo_pthread.$(OBJEXT) cdo_vlist.$(OBJEXT) \
field.$(OBJEXT) fieldc.$(OBJEXT) field2.$(OBJEXT) \
fieldmer.$(OBJEXT) fieldzon.$(OBJEXT) grid.$(OBJEXT) \
grid_gme.$(OBJEXT) grid_lcc.$(OBJEXT) grid_rot.$(OBJEXT) \
griddes.$(OBJEXT) griddes_nc.$(OBJEXT) griddes_h5.$(OBJEXT) \
hetaeta.$(OBJEXT) history.$(OBJEXT) institution.$(OBJEXT) \
interpol.$(OBJEXT) job.$(OBJEXT) modules.$(OBJEXT) \
namelist.$(OBJEXT) normal.$(OBJEXT) pipe.$(OBJEXT) \
process.$(OBJEXT) remaplib.$(OBJEXT) timer.$(OBJEXT) \
realtime.$(OBJEXT) pstream.$(OBJEXT) table.$(OBJEXT) \
userlog.$(OBJEXT) util.$(OBJEXT) legendre.$(OBJEXT) \
fourier.$(OBJEXT) specspace.$(OBJEXT) readline.$(OBJEXT) \
julian.$(OBJEXT) vinterp.$(OBJEXT) zaxis.$(OBJEXT) \
pthread_debug.$(OBJEXT) color.$(OBJEXT) list.$(OBJEXT) \
percentiles.$(OBJEXT) nth_element.$(OBJEXT) ecacore.$(OBJEXT) \
ecautil.$(OBJEXT) EcaIndices.$(OBJEXT) Hi.$(OBJEXT) \
Wct.$(OBJEXT) statistic.$(OBJEXT)
cdo_OBJECTS = $(am_cdo_OBJECTS)
cdo_LDADD = $(LDADD)
am_cdotest_OBJECTS = cdilib.$(OBJEXT) cdotest.$(OBJEXT)
......@@ -251,6 +251,7 @@ cdo_SOURCES = Arith.c \
Exprf.c \
Filedes.c \
Fillmiss.c \
Filter.c \
Fldrms.c \
Fldstat.c \
Gengrid.c \
......@@ -577,6 +578,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exprf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filedes.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Fillmiss.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Fldrms.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Fldstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Gengrid.Po@am__quote@
......
......@@ -374,6 +374,10 @@ int gridFromH5file(const char *gridfile)
if ( lon_id >= 0 && lat_id >= 0 )
{
hid_t type_id;
hid_t native_type;
int ftype = 0;
dataspace = H5Dget_space(lon_id); /* dataspace handle */
rank = H5Sget_simple_extent_ndims(dataspace);
status = H5Sget_simple_extent_dims(dataspace, dims_out, NULL);
......@@ -388,6 +392,24 @@ int gridFromH5file(const char *gridfile)
(unsigned long)(dims_out[1]), (unsigned long)(dims_out[0]));
*/
type_id = H5Dget_type(lon_id); /* get datatype*/
native_type = H5Tget_native_type(type_id, H5T_DIR_ASCEND);
if ( H5Tequal(native_type, H5T_NATIVE_SCHAR) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_UCHAR) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_SHORT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_USHORT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_INT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_UINT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_FLOAT) > 0 ) {ftype=1;}
else if ( H5Tequal(native_type, H5T_NATIVE_DOUBLE) > 0 ) {ftype=1;}
else
{
cdoWarning("Grid has unsupported native datatype!");
goto RETURN;
}
H5Tclose(native_type);
grid.xsize = (int)dims_out[1];
grid.ysize = (int)dims_out[0];
grid.size = grid.xsize*grid.ysize;
......@@ -395,8 +417,21 @@ int gridFromH5file(const char *gridfile)
grid.xvals = (double *) malloc(grid.size*sizeof(double));
grid.yvals = (double *) malloc(grid.size*sizeof(double));
status = H5Dread(lon_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.xvals);
status = H5Dread(lat_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.yvals);
if ( ftype )
{
status = H5Dread(lon_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.xvals);
status = H5Dread(lat_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.yvals);
}
else
{
int *iarray, i;
iarray = (int *) malloc(grid.size*sizeof(int));
status = H5Dread(lon_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
for ( i = 0; i < grid.size; ++i ) grid.xvals[i] = iarray[i];
status = H5Dread(lat_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
for ( i = 0; i < grid.size; ++i ) grid.yvals[i] = iarray[i];
free(iarray);
}
status = H5Sclose(dataspace);
......
......@@ -59,6 +59,7 @@ void *Ensstat(void *argument);
void *Expr(void *argument);
void *Filedes(void *argument);
void *Fillmiss(void *argument);
void *Filter(void *argument);
void *Fldrms(void *argument);
void *Fldstat(void *argument);
void *Gengrid(void *argument);
......@@ -258,6 +259,7 @@ void *Wct(void *argument);
#define ExprOperators {"expr", "exprf", "aexpr", "aexprf"}
#define FiledesOperators {"filedes", "griddes", "griddes2", "zaxisdes", "vct", "pardes", "taxisdes", "vlist", "partab", "partab2"}
#define FillmissOperators {"fillmiss"}
#define FilterOperators {"bandpass", "highpass", "lowpass"}
#define FldrmsOperators {"fldrms"}
#define FldstatOperators {"fldmin", "fldmax", "fldsum", "fldmean", "fldavg", "fldvar", "fldstd", "fldpctl"}
#define GengridOperators {"gengrid"}
......@@ -490,11 +492,12 @@ static MODULES Modules[] =
{ Expr, ExprHelp, ExprOperators, 1, 1 },
{ Filedes, FiledesHelp, FiledesOperators, 1, 0 },
{ Fillmiss, NULL, FillmissOperators, 1, 1 },
{ Filter, NULL, FilterOperators, 1, 1 },
{ Fldrms, NULL, FldrmsOperators, 2, 1 },
{ Fldstat, FldstatHelp, FldstatOperators, 1, 1 },
{ Gengrid, NULL, GengridOperators, 2, 1 },
{ Gradsdes, GradsdesHelp, GradsdesOperators, 1, 0 },
{ Gridboxstat, NULL, GridboxstatOperators, 1, 1 },
{ Gridboxstat, NULL, GridboxstatOperators, 1, 1 },
{ Gridcell, GridcellHelp, GridcellOperators, 1, 1 },
{ Harmonic, NULL, HarmonicOperators, 1, 1 },
{ Histogram, HistogramHelp, HistogramOperators, 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