Commit f79f5c08 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Add module CDItest

parent 7060d0e0
......@@ -207,6 +207,7 @@ src/Arith.c -text
src/Arithc.c -text
src/Arithdays.c -text
src/Arithlat.c -text
src/CDItest.c -text
src/Cat.c -text
src/Change.c -text
src/Comp.c -text
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for cdo 1.2.1beta8.
# Generated by GNU Autoconf 2.61 for cdo 1.2.1beta9.
#
# Report bugs to <Uwe.Schulzweida@zmaw.de>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cdo'
PACKAGE_TARNAME='cdo'
PACKAGE_VERSION='1.2.1beta8'
PACKAGE_STRING='cdo 1.2.1beta8'
PACKAGE_VERSION='1.2.1beta9'
PACKAGE_STRING='cdo 1.2.1beta9'
PACKAGE_BUGREPORT='Uwe.Schulzweida@zmaw.de'
# Factoring default headers for most tests.
......@@ -1222,7 +1222,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.2.1beta8 to adapt to many kinds of systems.
\`configure' configures cdo 1.2.1beta9 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1293,7 +1293,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdo 1.2.1beta8:";;
short | recursive ) echo "Configuration of cdo 1.2.1beta9:";;
esac
cat <<\_ACEOF
......@@ -1398,7 +1398,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdo configure 1.2.1beta8
cdo configure 1.2.1beta9
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1412,7 +1412,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.2.1beta8, which was
It was created by cdo $as_me 1.2.1beta9, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2236,7 +2236,7 @@ fi
# Define the identity of the package.
PACKAGE='cdo'
VERSION='1.2.1beta8'
VERSION='1.2.1beta9'
cat >>confdefs.h <<_ACEOF
......@@ -7481,7 +7481,7 @@ exec 6>&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.2.1beta8, which was
This file was extended by cdo $as_me 1.2.1beta9, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -7534,7 +7534,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
cdo config.status 1.2.1beta8
cdo config.status 1.2.1beta9
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT(cdo, 1.2.1beta8, Uwe.Schulzweida@zmaw.de)
AC_INIT(cdo, 1.2.1beta9, Uwe.Schulzweida@zmaw.de)
CONFIG_ABORT=yes
......
/*
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 <string.h>
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
void *CDItest(void *argument)
{
static char func[] = "CDItest";
int NCOPY;
int operatorID;
int streamID1, streamID2;
int n;
int nrecs;
int tsID1, tsID2, recID, varID, levelID;
int lcopy = FALSE;
int gridsize;
int vlistID1, vlistID2 = -1;
int nmiss;
int taxisID1, taxisID2 = CDI_UNDEFID;
double *array = NULL;
double s_utime, s_stime;
double e_utime, e_stime;
double c_cputime = 0, c_usertime = 0, c_systime = 0;
cdoInitialize(argument);
NCOPY = cdoOperatorAdd("ncopy", 0, 0, NULL);
if ( UNCHANGED_RECORD ) lcopy = TRUE;
operatorID = cdoOperatorID();
processStartTime(&s_utime, &s_stime);
n = 0;
while ( TRUE )
{
streamID1 = streamOpenRead(cdoStreamName(0));
if ( streamID1 < 0 ) cdiError(streamID1, "Open failed on %s", cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
taxisID1 = vlistInqTaxis(vlistID1);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
if ( streamID2 < 0 ) cdiError(streamID2, "Open failed on %s", cdoStreamName(1));
vlistID2 = vlistDuplicate(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamDefVlist(streamID2, vlistID2);
gridsize = vlistGridsizeMax(vlistID1);
array = (double *) malloc(gridsize*sizeof(double));
tsID1 = 0;
tsID2 = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
{
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);
}
}
tsID1++;
tsID2++;
}
streamClose(streamID1);
streamClose(streamID2);
vlistDestroy(vlistID2);
taxisDestroy(taxisID2);
if ( array ) free(array);
n++;
cdoProcessTime(&e_utime, &e_stime);
c_usertime = e_utime - s_utime;
c_systime = e_stime - s_stime;
c_cputime = c_usertime + c_systime;
s_utime = e_utime;
s_stime = e_stime;
cdoPrint("Copy number %d: %.2fs %.2fs %.2fs", n, c_usertime, c_systime, c_cputime);
if ( n == 3 ) break;
}
cdoFinish();
return (0);
}
......@@ -9,6 +9,7 @@ cdo_SOURCES = Arith.c \
Arithdays.c \
Arithlat.c \
Cat.c \
CDItest.c \
Change.c \
Comp.c \
Compc.c \
......
......@@ -49,66 +49,66 @@ am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
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) 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) 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) \
gridnc.$(OBJEXT) gridh5.$(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)
Arithlat.$(OBJEXT) Cat.$(OBJEXT) CDItest.$(OBJEXT) \
Change.$(OBJEXT) Comp.$(OBJEXT) Compc.$(OBJEXT) Cond.$(OBJEXT) \
Cond2.$(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) \
Gengrid.$(OBJEXT) Gradsdes.$(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) gridnc.$(OBJEXT) gridh5.$(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)
......@@ -232,6 +232,7 @@ cdo_SOURCES = Arith.c \
Arithdays.c \
Arithlat.c \
Cat.c \
CDItest.c \
Change.c \
Comp.c \
Compc.c \
......@@ -549,6 +550,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Arithc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Arithdays.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Arithlat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CDItest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Change.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Comp.Po@am__quote@
......
......@@ -52,6 +52,7 @@ void *Remap(void *argument)
int streamID1, streamID2 = -1;
int nrecs, ngrids;
int nzaxis, zaxisID, zaxissize;
int nvars;
int index;
int tsID, recID, varID, levelID;
int gridsize, gridsize2;
......@@ -238,6 +239,9 @@ void *Remap(void *argument)
if ( zaxissize > max_remaps ) max_remaps = zaxissize;
}
nvars = vlistNvars(vlistID1);
if ( nvars > max_remaps ) max_remaps = nvars;
max_remaps++;
if ( cdoVerbose )
......
......@@ -41,6 +41,7 @@ void *Arithc(void *argument);
void *Arithdays(void *argument);
void *Arithlat(void *argument);
void *Cat(void *argument);
void *CDItest(void *argument);
void *Change(void *argument);
void *Comp(void *argument);
void *Compc(void *argument);
......@@ -237,6 +238,7 @@ void *Wct(void *argument);
#define ArithdaysOperators {"muldpm", "divdpm", "muldpy", "divdpy"}
#define ArithlatOperators {"mulcoslat", "divcoslat"}
#define CatOperators {"cat"}
#define CDItestOperators {"ncopy"}
#define ChangeOperators {"chcode", "chname", "chlevel", "chlevelc", "chlevelv", "chltype"}
#define CompOperators {"eq", "ne", "le", "lt", "ge", "gt"}
#define CompcOperators {"eqc", "nec", "lec", "ltc", "gec", "gtc"}
......@@ -467,6 +469,7 @@ static MODULES Modules[] =
{ Arithdays, ArithdaysHelp, ArithdaysOperators, 1, 1 },
{ Arithlat, NULL, ArithlatOperators, 1, 1 },
{ Cat, CopyHelp, CatOperators, -1, 1 },
{ CDItest, NULL, CDItestOperators, 1, 1 },
{ Change, ChangeHelp, ChangeOperators, 1, 1 },
{ Comp, CompHelp, CompOperators, 2, 1 },
{ Compc, CompcHelp, CompcOperators, 1, 1 },
......
......@@ -44,6 +44,7 @@
*/
/* #define REMAPTEST 1 */
/* #define REMAPDEBUG 1 */
#if defined (HAVE_CONFIG_H)
# include "config.h"
......@@ -739,6 +740,39 @@ void remapGridInit(int map_type, int gridID1, int gridID2, REMAPGRID *rg)
if ( rg->grid1_corner_lon[i] > PI2 ) rg->grid1_corner_lon[i] -= PI2;
if ( rg->grid1_corner_lon[i] < ZERO ) rg->grid1_corner_lon[i] += PI2;
}
#ifdef REMAPDEBUG
for ( i = 0; i < rg->grid2_size; ++i )
{
if ( i == 269 )
{
printf("grid2 %d ", i);
for ( j = 0; j < 4; ++j )
printf("%g ", RAD2DEG*rg->grid2_corner_lon[i*4+j]);
for ( j = 0; j < 4; ++j )
printf("%g ", RAD2DEG*rg->grid2_corner_lat[i*4+j]);
printf("%g ", RAD2DEG*rg->grid2_center_lon[i]);
printf("%g ", RAD2DEG*rg->grid2_center_lat[i]);
printf("\n");
}
}
for ( i = 0; i < rg->grid1_size; ++i )
{
if ( i == 25498 || i == 28378 )
{
printf("grid1 %d ", i);
for ( j = 0; j < 4; ++j )
printf("%g ", RAD2DEG*rg->grid1_corner_lon[i*4+j]);
for ( j = 0; j < 4; ++j )
printf("%g ", RAD2DEG*rg->grid1_corner_lat[i*4+j]);
for ( j = 0; j < 4; ++j )
if ( rg->grid1_corner_lat[i*4+j] >= PIH )
rg->grid1_corner_lat[i*4+j] = /*89.998*/ 90*DEG2RAD;
printf("%g ", RAD2DEG*rg->grid1_center_lon[i]);
printf("%g ", RAD2DEG*rg->grid1_center_lat[i]);
printf("\n");
}
}
#endif
if ( rg->grid2_corners )
for ( i = 0; i < rg->grid2_corners*rg->grid2_size; i++ )
......@@ -3662,7 +3696,7 @@ void intersection(int *location, double *intrsct_lat, double *intrsct_lon, int *
static
void line_integral(double *weights, int num_wts,
double in_phi1, double in_phi2, double theta1, double theta2,
double grid1_lon, double grid2_lon)
double grid1_lon, double grid2_lon, int grid1_add, int grid2_add)
{
/*
Intent(in):
......@@ -3670,7 +3704,7 @@ void line_integral(double *weights, int num_wts,
double in_phi1, in_phi2, ! Longitude endpoints for the segment
double theta1, theta2, ! Latitude endpoints for the segment
double grid1_lon, ! Reference coordinates for each
double grid2_lon ! Grid (to ensure correct 0,2pi interv.
double grid2_lon ! Grid (to ensure correct 0,2pi interv.)
Intent(out):
double weights[2*num_wts] ! Line integral contribution to weights
......@@ -3699,11 +3733,15 @@ void line_integral(double *weights, int num_wts,
The first weight is the area overlap integral. The second and
fourth are second-order latitude gradient weights.
*/
weights[ 0] = dphi*(sinth1 + sinth2);
weights[num_wts+0] = dphi*(sinth1 + sinth2);
weights[ 1] = dphi*(costh1 + costh2 + (theta1*sinth1 + theta2*sinth2));
weights[num_wts+1] = dphi*(costh1 + costh2 + (theta1*sinth1 + theta2*sinth2));
weights[0] = dphi*(sinth1 + sinth2);
weights[1] = dphi*(costh1 + costh2 + (theta1*sinth1 + theta2*sinth2));
weights[num_wts+0] = weights[0];
weights[num_wts+1] = weights[1];
#ifdef REMAPDEBUG
if ( (grid1_add == 25498 || grid1_add == 28378 || grid1_add == 25499 ) && grid2_add == 269 )
printf("in li: %g %g %g %g %g %g %g %g %g %g\n",
RAD2DEG*in_phi1, RAD2DEG*in_phi2, RAD2DEG*theta1, RAD2DEG*theta2, RAD2DEG*grid1_lon, RAD2DEG*grid2_lon, RAD2DEG*dphi, sinth1, sinth2, weights[0]);
#endif
/*
The third and fifth weights are for the second-order phi gradient
component. Must be careful of longitude range.
......@@ -4159,12 +4197,12 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
line_integral(weights, rv->num_wts,
beglon, intrsct_lon, beglat, intrsct_lat,
rg->grid1_center_lon[grid1_add],
rg->grid2_center_lon[grid2_add]);
rg->grid2_center_lon[grid2_add], grid1_add, grid2_add);
else
line_integral(weights, rv->num_wts,
beglon, intrsct_lon, beglat, intrsct_lat,
rg->grid1_center_lon[grid1_add],
rg->grid1_center_lon[grid1_add]);
rg->grid1_center_lon[grid1_add], grid1_add, grid2_add);
/* If integrating in reverse order, change sign of weights */
......@@ -4177,6 +4215,10 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
if ( grid2_add != -1 )
if ( rg->grid1_mask[grid1_add] )
{
#ifdef REMAPDEBUG
if ( (grid1_add == 25498 || grid1_add == 28378) && grid2_add == 269 )
printf("grid1: %d %d\n", grid1_add, grid2_add);
#endif
store_link_cnsrv(rv, grid1_add, grid2_add, weights, link_add1, link_add2);
rg->grid1_frac[grid1_add] += weights[0];
......@@ -4364,16 +4406,22 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
/* Compute line integral for this subsegment. */
#ifdef REMAPDEBUG
if ( (grid1_add == 25498 || grid1_add == 28378 || grid1_add == 25499 ) && grid2_add == 269 )
printf("li: %d %d %g %g %g %g %g %g\n", grid1_add, grid2_add, RAD2DEG*beglon, RAD2DEG*intrsct_lon, RAD2DEG*beglat, RAD2DEG*intrsct_lat,
RAD2DEG*rg->grid1_center_lon[grid1_add],
RAD2DEG*rg->grid2_center_lon[grid2_add]);
#endif
if ( grid1_add != -1 )
line_integral(weights, rv->num_wts,
beglon, intrsct_lon, beglat, intrsct_lat,
rg->grid1_center_lon[grid1_add],
rg->grid2_center_lon[grid2_add]);
rg->grid2_center_lon[grid2_add], grid1_add, grid2_add);
else
line_integral(weights, rv->num_wts,
beglon, intrsct_lon, beglat, intrsct_lat,
rg->grid2_center_lon[grid2_add],
rg->grid2_center_lon[grid2_add]);
rg->grid2_center_lon[grid2_add], grid1_add, grid2_add);
/* If integrating in reverse order, change sign of weights */
......@@ -4389,10 +4437,26 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
if ( ! lcoinc && grid1_add != -1 )
if ( rg->grid1_mask[grid1_add] )
{
#ifdef REMAPDEBUG
if ( (grid1_add == 25498 || grid1_add == 28378 || grid1_add == 25499 ) && grid2_add == 269 )
{
printf("grid2: %d %d\n", grid1_add, grid2_add);
printf("grid2: %g %g %g %g %g %g %g %g\n", weights[0], weights[1], weights[2], weights[3], weights[4], weights[5], rg->grid1_frac[grid1_add], rg->grid2_frac[grid2_add]);
}
#endif
store_link_cnsrv(rv, grid1_add, grid2_add, weights, link_add1, link_add2);
#ifdef REMAPDEBUG
if ( grid2_add == 269 )
printf("link: %d %g %g %g\n",
rv->num_links-1, rv->wts[0][rv->num_links-1], weights[rv->num_wts],
rv->wts[0][rv->num_links-1]/weights[rv->num_wts]);
#endif
rg->grid1_frac[grid1_add] += weights[0];
rg->grid2_frac[grid2_add] += weights[rv->num_wts];
#ifdef REMAPDEBUG
if ( grid2_add == 269 )
printf(">>> %d %g %g %g %g\n", grid1_add, weights[0], weights[rv->num_wts], rg->grid1_frac[grid1_add], rg->grid2_frac[grid2_add]);
#endif
}
rg->grid2_area[grid2_add] += weights[rv->num_wts+0];
......@@ -4583,6 +4647,10 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
else
norm_factor = ZERO;
#ifdef REMAPDEBUG
if ( (grid1_add == 25498 || grid1_add == 28378 || grid1_add == 25499 ) && grid2_add == 269 )
printf("wts: %d %d %g %g %g\n", grid1_add, grid2_add, weights[0],norm_factor, weights[0]*norm_factor);
#endif
rv->wts[0][n] = weights[0]*norm_factor;
rv->wts[1][n] = (weights[1] - weights[0]*grid1_centroid_lat[grid1_add])*norm_factor;
rv->wts[2][n] = (weights[2] - weights[0]*grid1_centroid_lon[grid1_add])*norm_factor;
......
......@@ -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-2006 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
......
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