Commit 28db0834 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added module Tocomplex

parent 9e1d39d0
......@@ -343,6 +343,7 @@ src/Timstat.c -text
src/Timstat2.c -text
src/Timstat3.c -text
src/Tinfo.c -text
src/Tocomplex.c -text
src/Transpose.c -text
src/Trend.c -text
src/Trms.c -text
......
......@@ -16,17 +16,10 @@
*/
#include <string.h>
#include <ctype.h>
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
#include "error.h"
#include "util.h"
#include "functs.h"
#include "list.h"
void *Del29feb(void *argument)
......@@ -35,7 +28,7 @@ void *Del29feb(void *argument)
int streamID1, streamID2;
int tsID, tsID2, nrecs;
int recID, varID, levelID;
int vlistID1 = -1, vlistID2 = -1;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int vdate, vtime;
int copytimestep;
......
......@@ -122,6 +122,7 @@ cdo_SOURCES = Arith.c \
Timstat2.c \
Timstat3.c \
Tinfo.c \
Tocomplex.c \
Transpose.c \
Trend.c \
Trms.c \
......
......@@ -87,34 +87,34 @@ am_cdo_OBJECTS = Arith.$(OBJEXT) Arithc.$(OBJEXT) Arithdays.$(OBJEXT) \
Timcount.$(OBJEXT) Timeof.$(OBJEXT) Timpctl.$(OBJEXT) \
Timsort.$(OBJEXT) Timselpctl.$(OBJEXT) Timselstat.$(OBJEXT) \
Timstat.$(OBJEXT) Timstat2.$(OBJEXT) Timstat3.$(OBJEXT) \
Tinfo.$(OBJEXT) Transpose.$(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) gradsdeslib.$(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) juldate.$(OBJEXT) vinterp.$(OBJEXT) \
zaxis.$(OBJEXT) par_io.$(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)
Tinfo.$(OBJEXT) Tocomplex.$(OBJEXT) Transpose.$(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) \
gradsdeslib.$(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) juldate.$(OBJEXT) \
vinterp.$(OBJEXT) zaxis.$(OBJEXT) par_io.$(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)
......@@ -349,6 +349,7 @@ cdo_SOURCES = Arith.c \
Timstat2.c \
Timstat3.c \
Tinfo.c \
Tocomplex.c \
Transpose.c \
Trend.c \
Trms.c \
......@@ -690,6 +691,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Timstat2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Timstat3.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tinfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tocomplex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Transpose.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Trend.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Trms.Po@am__quote@
......
/*
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2009 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"
void *Tocomplex(void *argument)
{
const char func[] = "Tocomplex";
int RETOCOMPLEX, IMTOCOMPLEX;
int operatorID;
int streamID1, streamID2;
int tsID, tsID2, nrecs;
int recID, varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int i, gridsize;
int nmiss, nvars;
double *array1 = NULL, *array2 = NULL;
cdoInitialize(argument);
RETOCOMPLEX = cdoOperatorAdd("retocomplex", 0, 0, NULL);
IMTOCOMPLEX = cdoOperatorAdd("imtocomplex", 0, 0, NULL);
operatorID = cdoOperatorID();
streamID1 = streamOpenRead(cdoStreamName(0));
if ( streamID1 < 0 ) cdiError(streamID1, "Open failed on %s", cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
vlistID2 = vlistDuplicate(vlistID1);
nvars = vlistNvars(vlistID2);
for ( varID = 0; varID < nvars; ++varID )
vlistDefVarNumber(vlistID2, varID, CDI_COMP);
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);
gridsize = vlistGridsizeMax(vlistID1);
array1 = (double *) malloc(gridsize*sizeof(double));
array2 = (double *) malloc(2*gridsize*sizeof(double));
tsID = 0;
tsID2 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID2++);
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
streamDefRecord(streamID2, varID, levelID);
gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
streamReadRecord(streamID1, array1, &nmiss);
if ( operatorID == RETOCOMPLEX )
{
for ( i = 0; i < gridsize; ++i )
{
array2[2*i] = array1[i];
array2[2*i+1] = 0;
}
}
else if ( operatorID == IMTOCOMPLEX )
{
for ( i = 0; i < gridsize; ++i )
{
array2[2*i] = 0;
array2[2*i+1] = array1[i];
}
}
streamWriteRecord(streamID2, array2, nmiss);
}
tsID++;
}
streamClose(streamID2);
streamClose(streamID1);
if ( array1 ) free(array1);
if ( array2 ) free(array2);
vlistDestroy(vlistID2);
cdoFinish();
return (NULL);
}
......@@ -159,6 +159,7 @@ void *Timstat(void *argument);
void *Timstat2(void *argument);
void *Timstat3(void *argument);
void *Tinfo(void *argument);
void *Tocomplex(void *argument);
void *Transpose(void *argument);
void *Trend(void *argument);
void *Trms(void *argument);
......@@ -377,6 +378,7 @@ void *Wct(void *argument);
#define Timstat2Operators {"timcor"}
#define Timstat3Operators {"meandiff2test", "varquot2test"}
#define TinfoOperators {"tinfo"}
#define TocomplexOperators {"retocomplex", "imtocomplex"}
#define TransposeOperators {"transxy"}
#define TrendOperators {"trend"}
#define TrmsOperators {"trms"}
......@@ -592,6 +594,7 @@ static modules_t Modules[] =
{ Timstat2, NULL, Timstat2Operators, CDI_REAL, 2, 1 },
{ Timstat3, NULL, Timstat3Operators, CDI_REAL, 2, 1 },
{ Tinfo, NULL, TinfoOperators, CDI_REAL, 1, 0 },
{ Tocomplex, NULL, TocomplexOperators, CDI_REAL, 1, 1 },
{ Transpose, NULL, TransposeOperators, CDI_REAL, 1, 1 },
{ Trend, TrendHelp, TrendOperators, CDI_REAL, 1, 2 },
{ Trms, NULL, TrmsOperators, CDI_REAL, 2, 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