Commit 254aeb5c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

New operator: del29feb to delete the 29. February

parent 621c31a2
......@@ -214,6 +214,7 @@ src/Cond.c -text
src/Cond2.c -text
src/Condc.c -text
src/Copy.c -text
src/Del29feb.c -text
src/Detrend.c -text
src/Diff.c -text
src/EcaIndices.c -text
......
2008-04-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CDI library version 1.1.1
* New operator: del29feb to delete the 29. February [request: Etienne Tourigny]
* Exprf: using MT safe version of bison and flex (bug fix) [report: Claas Teichmann]
* Seltime: changed value of NOPERATORS (bug fix)
* Version 1.1.1 released
2008-01-24 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
/*
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.
*/
#include <string.h>
#include <ctype.h>
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h" /* processSelf */
#include "pstream.h"
#include "error.h"
#include "util.h"
#include "functs.h"
#include "list.h"
void *Del29feb(void *argument)
{
const char func[] = "Del29feb";
int streamID1, streamID2;
int tsID, tsID2, nrecs;
int recID, varID, levelID;
int vlistID1 = -1, vlistID2 = -1;
int taxisID1, taxisID2;
int vdate, vtime;
int copytimestep;
int lcopy = FALSE;
int gridsize;
int nmiss;
int year, month, day;
double *array = NULL;
cdoInitialize(argument);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
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);
taxisDefCalendar(taxisID2, CALENDAR_365DAYS);
vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
if ( streamID2 < 0 ) cdiError(streamID2, "Open failed on %s", cdoStreamName(1));
streamDefVlist(streamID2, vlistID2);
if ( ! lcopy )
{
gridsize = vlistGridsizeMax(vlistID1);
array = (double *) malloc(gridsize*sizeof(double));
}
tsID = 0;
tsID2 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
decode_date(vdate, &year, &month, &day);
if ( month == 2 && day == 29 )
{
copytimestep = FALSE;
if ( cdoVerbose )
cdoPrint("Delete %4.4d-%2.2d-%2.2d at timestep %d", year, month, day, tsID+1);
}
else
copytimestep = TRUE;
if ( copytimestep )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID2++);
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamDefRecord(streamID2, varID, levelID);
if ( lcopy )
{
streamCopyRecord(streamID2, streamID1);
}
else
{
streamReadRecord(streamID1, array, &nmiss);
streamWriteRecord(streamID2, array, nmiss);
}
}
}
tsID++;
}
streamClose(streamID2);
streamClose(streamID1);
if ( ! lcopy )
if ( array ) free(array);
vlistDestroy(vlistID2);
cdoFinish();
return (NULL);
}
......@@ -16,6 +16,7 @@ cdo_SOURCES = Arith.c \
Cond2.c \
Condc.c \
Copy.c \
Del29feb.c \
Detrend.c \
Diff.c \
Echam5ini.c \
......
......@@ -55,60 +55,60 @@ PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am_cdo_OBJECTS = Arith.$(OBJEXT) Arithc.$(OBJEXT) Arithdays.$(OBJEXT) \
Arithlat.$(OBJEXT) Cat.$(OBJEXT) Change.$(OBJEXT) \
Comp.$(OBJEXT) Compc.$(OBJEXT) Cond.$(OBJEXT) Cond2.$(OBJEXT) \
Condc.$(OBJEXT) Copy.$(OBJEXT) Detrend.$(OBJEXT) \
Diff.$(OBJEXT) Echam5ini.$(OBJEXT) Enlarge.$(OBJEXT) \
Enlargegrid.$(OBJEXT) Ensstat.$(OBJEXT) Exprf.$(OBJEXT) \
Filedes.$(OBJEXT) Fillmiss.$(OBJEXT) Fldrms.$(OBJEXT) \
Fldstat.$(OBJEXT) Gradsdes.$(OBJEXT) Harmonic.$(OBJEXT) \
Histogram.$(OBJEXT) Info.$(OBJEXT) Input.$(OBJEXT) \
Intgrid.$(OBJEXT) Intgridtraj.$(OBJEXT) Inttime.$(OBJEXT) \
Intntime.$(OBJEXT) Intyear.$(OBJEXT) Invert.$(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) 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) \
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) 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)
Condc.$(OBJEXT) Copy.$(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) Gradsdes.$(OBJEXT) \
Harmonic.$(OBJEXT) Histogram.$(OBJEXT) Info.$(OBJEXT) \
Input.$(OBJEXT) Intgrid.$(OBJEXT) Intgridtraj.$(OBJEXT) \
Inttime.$(OBJEXT) Intntime.$(OBJEXT) Intyear.$(OBJEXT) \
Invert.$(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) 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) 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) \
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)
am__DEPENDENCIES_1 =
cdo_DEPENDENCIES = $(am__DEPENDENCIES_1)
......@@ -124,48 +124,48 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@ ./$(DEPDIR)/Comp.Po ./$(DEPDIR)/Compc.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Cond.Po ./$(DEPDIR)/Cond2.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Condc.Po ./$(DEPDIR)/Copy.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Detrend.Po ./$(DEPDIR)/Diff.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/EcaIndices.Po ./$(DEPDIR)/Echam5ini.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Enlarge.Po ./$(DEPDIR)/Enlargegrid.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Ensstat.Po ./$(DEPDIR)/Exprf.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Filedes.Po ./$(DEPDIR)/Fillmiss.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Fldrms.Po ./$(DEPDIR)/Fldstat.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Gradsdes.Po ./$(DEPDIR)/Harmonic.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Hi.Po ./$(DEPDIR)/Histogram.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Info.Po ./$(DEPDIR)/Input.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Intgrid.Po ./$(DEPDIR)/Intgridtraj.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Intntime.Po ./$(DEPDIR)/Inttime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Intyear.Po ./$(DEPDIR)/Invert.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Log.Po ./$(DEPDIR)/Maskbox.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Mastrfu.Po ./$(DEPDIR)/Math.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Merge.Po ./$(DEPDIR)/Mergegrid.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Mergetime.Po ./$(DEPDIR)/Merstat.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Monarith.Po ./$(DEPDIR)/Mrotuv.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Mrotuvb.Po ./$(DEPDIR)/Ninfo.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Nmltest.Po ./$(DEPDIR)/Output.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Outputgmt.Po ./$(DEPDIR)/Pinfo.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Remap.Po ./$(DEPDIR)/Remapeta.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Replace.Po ./$(DEPDIR)/Rotuv.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Runpctl.Po ./$(DEPDIR)/Runstat.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Seascount.Po ./$(DEPDIR)/Seaspctl.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Seasstat.Po ./$(DEPDIR)/Selbox.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Select.Po ./$(DEPDIR)/Seloperator.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Selrec.Po ./$(DEPDIR)/Seltime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Set.Po ./$(DEPDIR)/Setbox.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setgatt.Po ./$(DEPDIR)/Setgrid.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Sethalo.Po ./$(DEPDIR)/Setmiss.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setrange.Po ./$(DEPDIR)/Setrcaname.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Settime.Po ./$(DEPDIR)/Setzaxis.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Showinfo.Po ./$(DEPDIR)/Sinfo.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Smooth9.Po ./$(DEPDIR)/Sort.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Specinfo.Po ./$(DEPDIR)/Spectral.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Spectrum.Po ./$(DEPDIR)/Split.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Splitrec.Po ./$(DEPDIR)/Splitsel.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Splittime.Po ./$(DEPDIR)/Splityear.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Subtrend.Po ./$(DEPDIR)/Templates.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Test.Po ./$(DEPDIR)/Tests.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Timcount.Po ./$(DEPDIR)/Timpctl.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Timselpctl.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Del29feb.Po ./$(DEPDIR)/Detrend.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Diff.Po ./$(DEPDIR)/EcaIndices.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Echam5ini.Po ./$(DEPDIR)/Enlarge.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Enlargegrid.Po ./$(DEPDIR)/Ensstat.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Exprf.Po ./$(DEPDIR)/Filedes.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Fillmiss.Po ./$(DEPDIR)/Fldrms.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Fldstat.Po ./$(DEPDIR)/Gradsdes.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Harmonic.Po ./$(DEPDIR)/Hi.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Histogram.Po ./$(DEPDIR)/Info.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Input.Po ./$(DEPDIR)/Intgrid.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Intgridtraj.Po ./$(DEPDIR)/Intntime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Inttime.Po ./$(DEPDIR)/Intyear.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Invert.Po ./$(DEPDIR)/Log.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Maskbox.Po ./$(DEPDIR)/Mastrfu.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Math.Po ./$(DEPDIR)/Merge.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Mergegrid.Po ./$(DEPDIR)/Mergetime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Merstat.Po ./$(DEPDIR)/Monarith.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Mrotuv.Po ./$(DEPDIR)/Mrotuvb.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Ninfo.Po ./$(DEPDIR)/Nmltest.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Output.Po ./$(DEPDIR)/Outputgmt.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Pinfo.Po ./$(DEPDIR)/Remap.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Remapeta.Po ./$(DEPDIR)/Replace.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Rotuv.Po ./$(DEPDIR)/Runpctl.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Runstat.Po ./$(DEPDIR)/Seascount.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Seaspctl.Po ./$(DEPDIR)/Seasstat.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Selbox.Po ./$(DEPDIR)/Select.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Seloperator.Po ./$(DEPDIR)/Selrec.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Seltime.Po ./$(DEPDIR)/Set.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setbox.Po ./$(DEPDIR)/Setgatt.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setgrid.Po ./$(DEPDIR)/Sethalo.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setmiss.Po ./$(DEPDIR)/Setrange.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setrcaname.Po ./$(DEPDIR)/Settime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Setzaxis.Po ./$(DEPDIR)/Showinfo.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Sinfo.Po ./$(DEPDIR)/Smooth9.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Sort.Po ./$(DEPDIR)/Specinfo.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Spectral.Po ./$(DEPDIR)/Spectrum.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Split.Po ./$(DEPDIR)/Splitrec.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Splitsel.Po ./$(DEPDIR)/Splittime.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Splityear.Po ./$(DEPDIR)/Subtrend.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Templates.Po ./$(DEPDIR)/Test.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Tests.Po ./$(DEPDIR)/Timcount.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Timpctl.Po ./$(DEPDIR)/Timselpctl.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Timselstat.Po ./$(DEPDIR)/Timsort.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Timstat.Po ./$(DEPDIR)/Timstat2.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/Timstat3.Po ./$(DEPDIR)/Tinfo.Po \
......@@ -319,6 +319,7 @@ cdo_SOURCES = Arith.c \
Cond2.c \
Condc.c \
Copy.c \
Del29feb.c \
Detrend.c \
Diff.c \
Echam5ini.c \
......@@ -624,6 +625,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cond2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Condc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Copy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Del29feb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Detrend.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Diff.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EcaIndices.Po@am__quote@
......
......@@ -2,7 +2,7 @@
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2007 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
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
......@@ -43,14 +43,103 @@
#include "color.h"
int pnpoly(int npol, double *xp, double *yp, double x, double y)
{
int i, j, c = 0;
for (i = 0, j = npol-1; i < npol; j = i++) {
if ((((yp[i]<=y) && (y<yp[j])) ||
((yp[j]<=y) && (y<yp[i]))) &&
(x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
c = !c;
}
return c;
}
void verify_grid(int gridtype, int gridsize, int xsize, int ysize, int ncorner,
double *grid_center_lon, double *grid_center_lat,
double *grid_corner_lon, double *grid_corner_lat)
{
int i, k;
int nout = 0;
int isinside;
double lon, lat;
double lon_bounds[9], lat_bounds[9];
/* check that all centers are inside the bounds */
for ( i = 0; i < gridsize; ++i )
{
lon = grid_center_lon[i];
lat = grid_center_lat[i];
for ( k = 0; k < ncorner; ++k )
{
lon_bounds[k] = grid_corner_lon[i*ncorner+k];
lat_bounds[k] = grid_corner_lat[i*ncorner+k];
}
for ( k = 0; k < ncorner; ++k )
{
if ( (grid_center_lon[i] - lon_bounds[k]) > 270 ) lon_bounds[k] += 360;
if ( (lon_bounds[k] - grid_center_lon[i]) > 270 ) lon_bounds[k] -= 360;
}
lon_bounds[ncorner] = lon_bounds[0];
lat_bounds[ncorner] = lat_bounds[0];
isinside = pnpoly(ncorner+1, lon_bounds, lat_bounds, lon, lat);
if ( !isinside ) nout++;
if ( !isinside && cdoVerbose )
printf("%d %d %g %g %g %g %g %g %g %g %g %g\n", nout, i, lon, lat, lon_bounds[0], lat_bounds[0],
lon_bounds[1], lat_bounds[1], lon_bounds[2], lat_bounds[2], lon_bounds[3], lat_bounds[3]);
}
if ( nout > 0 )
cdoWarning("%d of %d points out of bounds!\n", nout, gridsize);
}
void make_cyclic(double *array1, double *array2, int nlon, int nlat)
{
int i, j;
int ij1, ij2;
for ( j = 0; j < nlat; ++j )
{
for ( i = 0; i < nlon; ++i )
{
ij1 = j*nlon+i;
ij2 = j*(nlon+1)+i;
array2[ij2] = array1[ij1];
}
}
for ( j = 0; j < nlat; ++j )
{
ij2 = j*(nlon+1);
array2[ij2+nlon] = array2[ij2];
}
}
void *Outputgmt(void *argument)
{
static char func[] = "Outputgmt";
int OUTPUTCENTER, OUTPUTCENTERCPT, OUTPUTBOUNDS, OUTPUTBOUNDSCPT, OUTPUTVECTOR;
int GRIDVERIFY, OUTPUTCENTER, OUTPUTCENTER2, OUTPUTCENTERCPT, OUTPUTBOUNDS;
int OUTPUTBOUNDSCPT, OUTPUTVECTOR, OUTPUTTRI;
int operatorID;
int process_data = TRUE;
int i, j;
int varID0, varID, recID;
int nvals;
int gridsize = 0;
int gridsize2 = 0;
int gridID, code;
int nrecs;
int levelID;
......@@ -71,20 +160,28 @@ void *Outputgmt(void *argument)
double level;
double missval;
double *array = NULL;
double *array2 = NULL;
double *parray;
double *uf = NULL, *vf = NULL, *alpha = NULL, *auv = NULL;
double *grid_center_lat = NULL, *grid_center_lon = NULL;
double *grid_center_lat2 = NULL, *grid_center_lon2 = NULL;
double *grid_corner_lat = NULL, *grid_corner_lon = NULL;
double *plat, *plon;
double *zaxis_center_lev, *zaxis_lower_lev, *zaxis_upper_lev;
FILE *cpt_fp;
CPT cpt;
int grid_is_circular;
cdoInitialize(argument);
GRIDVERIFY = cdoOperatorAdd("gridverify", 0, 0, NULL);
OUTPUTCENTER = cdoOperatorAdd("outputcenter", 0, 0, NULL);
OUTPUTCENTER2 = cdoOperatorAdd("outputcenter2", 0, 0, NULL);
OUTPUTCENTERCPT = cdoOperatorAdd("outputcentercpt", 0, 0, NULL);
OUTPUTBOUNDS = cdoOperatorAdd("outputbounds", 0, 0, NULL);
OUTPUTBOUNDSCPT = cdoOperatorAdd("outputboundscpt", 0, 0, NULL);
OUTPUTVECTOR = cdoOperatorAdd("outputvector", 0, 0, NULL);
OUTPUTTRI = cdoOperatorAdd("outputtri", 0, 0, NULL);
operatorID = cdoOperatorID();
......@@ -96,6 +193,12 @@ void *Outputgmt(void *argument)
if ( ninc < 1 ) cdoAbort("Increment must be greater than 0!");
}
if ( operatorID == GRIDVERIFY )
{
process_data = FALSE;
luse_grid_corner = TRUE;
}
if ( operatorID == OUTPUTBOUNDS || operatorID == OUTPUTBOUNDSCPT )
luse_grid_corner = TRUE;
......@@ -185,12 +288,41 @@ void *Outputgmt(void *argument)
else
gridcorners = 4;
grid_center_lat = (double *) realloc(grid_center_lat, gridsize*sizeof(double));
grid_center_lon = (double *) realloc(grid_center_lon, gridsize*sizeof(double));
grid_is_circular = gridIsCircular(gridID);
grid_center_lat = (double *) malloc(gridsize*sizeof(double));
grid_center_lon = (double *) malloc(gridsize*sizeof(double));
gridInqYvals(gridID, grid_center_lat);
gridInqXvals(gridID, grid_center_lon);
nvals = gridsize;
plon = grid_center_lon;
plat = grid_center_lat;
if ( operatorID == OUTPUTCENTER2 && grid_is_circular )
{
int ij2;
gridsize2 = nlat*(nlon+1);
grid_center_lat2 = (double *) malloc(gridsize2*sizeof(double));
grid_center_lon2 = (double *) malloc(gridsize2*sizeof(double));
make_cyclic(grid_center_lat, grid_center_lat2, nlon, nlat);
make_cyclic(grid_center_lon, grid_center_lon2, nlon, nlat);
for ( j = 0; j < nlat; ++j )
{
ij2 = j*(nlon+1);
grid_center_lon2[ij2+nlon] += 360;
}
nvals = gridsize2;
plon = grid_center_lon2;
plat = grid_center_lat2;
}
zaxis_center_lev = (double *) malloc(nlev*sizeof(double));
zaxis_lower_lev = (double *) malloc(nlev*sizeof(double));
zaxis_upper_lev = (double *) malloc(nlev*sizeof(double));
......@@ -244,6 +376,14 @@ void *Outputgmt(void *argument)
}
array = (double *) malloc(gridsize*sizeof(double));
parray = array;
if ( operatorID == OUTPUTCENTER2 && grid_is_circular )
{
array2 = (double *) malloc(nlat*(nlon+1)*sizeof(double));
parray = array2;
}
if ( operatorID == OUTPUTVECTOR )
{
uf = (double *) malloc(gridsize*sizeof(double));
......@@ -252,7 +392,13 @@ void *Outputgmt(void *argument)
auv = (double *) malloc(gridsize*sizeof(double));
}
if ( operatorID == GRIDVERIFY )
verify_grid(gridInqType(gridID), gridsize, nlon, nlat, gridcorners,
grid_center_lon, grid_center_lat,
grid_corner_lon, grid_corner_lat);
tsID = 0;
if ( process_data )
while ( (nrecs = streamInqTimestep(streamID, tsID)) )
{
vdate = taxisInqVdate(taxisID);
......@@ -261,7 +407,7 @@ void *Outputgmt(void *argument)
decode_date(vdate, &year, &month, &day);
decode_time(vtime, &hour, &minute);
if ( tsID == 0 )
if ( tsID == 0 && operatorID != OUTPUTTRI )
{
#if defined (VERSION)
fprintf(stdout, "# Generated by CDO version %s\n", VERSION);
......@@ -294,18 +440,21 @@ void *Outputgmt(void *argument)
streamReadRecord(streamID, array, &nmiss);