Commit 393dfedb authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

move grid_lcc, grid_gme, grid_rot code to CDO

parent 905a0f6a
......@@ -112,9 +112,6 @@ src/grib.h -text
src/griblib.c -text
src/grid.c -text
src/grid.h -text
src/grid_gme.c -text
src/grid_lcc.c -text
src/grid_rot.c -text
src/ieg.h -text
src/ieglib.c -text
src/institution.c -text
......
......@@ -2,7 +2,10 @@
* add support for GRID type SINUSOIDAL
* add support of GRIB level type MEANSEA
* move grid_lcc, grid_gme, grid_rot code to CDO
* move gridToCurvilinear and gridToCell code to CDO
* cdf_inq_contents: check zaxis type "depth_blow_sea/land" (bug fix)
* Version 1.3.0 released
2008-11-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for cdi 1.2.2.
# Generated by GNU Autoconf 2.61 for cdi 1.3.0.
#
# Report bugs to <Uwe.Schulzweida@zmaw.de>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.2.2'
PACKAGE_STRING='cdi 1.2.2'
PACKAGE_VERSION='1.3.0'
PACKAGE_STRING='cdi 1.3.0'
PACKAGE_BUGREPORT='Uwe.Schulzweida@zmaw.de'
# Factoring default headers for most tests.
......@@ -1229,7 +1229,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 cdi 1.2.2 to adapt to many kinds of systems.
\`configure' configures cdi 1.3.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1300,7 +1300,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.2.2:";;
short | recursive ) echo "Configuration of cdi 1.3.0:";;
esac
cat <<\_ACEOF
......@@ -1405,7 +1405,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.2.2
cdi configure 1.3.0
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1419,7 +1419,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 cdi $as_me 1.2.2, which was
It was created by cdi $as_me 1.3.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2244,7 +2244,7 @@ fi
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.2.2'
VERSION='1.3.0'
cat >>confdefs.h <<_ACEOF
......@@ -6919,7 +6919,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 cdi $as_me 1.2.2, which was
This file was extended by cdi $as_me 1.3.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -6972,7 +6972,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
cdi config.status 1.2.2
cdi config.status 1.3.0
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(cdi, 1.2.2, Uwe.Schulzweida@zmaw.de)
AC_INIT(cdi, 1.3.0, Uwe.Schulzweida@zmaw.de)
CONFIG_ABORT=yes
......
......@@ -29,9 +29,6 @@ libcdi_a_SOURCES = \
stream_ext.c \
stream_ieg.c \
grid.c \
grid_rot.c \
grid_gme.c \
grid_lcc.c \
zaxis.c \
stream.c \
stream_var.c \
......
......@@ -65,8 +65,7 @@ am_libcdi_a_OBJECTS = cdiFortran.$(OBJEXT) cdi_error.$(OBJEXT) \
vlist_var.$(OBJEXT) vlist_att.$(OBJEXT) basetime.$(OBJEXT) \
stream_history.$(OBJEXT) stream_grb.$(OBJEXT) \
stream_cdf.$(OBJEXT) stream_srv.$(OBJEXT) stream_ext.$(OBJEXT) \
stream_ieg.$(OBJEXT) grid.$(OBJEXT) grid_rot.$(OBJEXT) \
grid_gme.$(OBJEXT) grid_lcc.$(OBJEXT) zaxis.$(OBJEXT) \
stream_ieg.$(OBJEXT) grid.$(OBJEXT) zaxis.$(OBJEXT) \
stream.$(OBJEXT) stream_var.$(OBJEXT) stream_record.$(OBJEXT) \
tsteps.$(OBJEXT) stream_int.$(OBJEXT) servicelib.$(OBJEXT) \
extralib.$(OBJEXT) ieglib.$(OBJEXT) cdf.$(OBJEXT) \
......@@ -221,9 +220,6 @@ libcdi_a_SOURCES = \
stream_ext.c \
stream_ieg.c \
grid.c \
grid_rot.c \
grid_gme.c \
grid_lcc.c \
zaxis.c \
stream.c \
stream_var.c \
......@@ -378,9 +374,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/griblib.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_gme.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_lcc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_rot.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieglib.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/institution.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model.Po@am__quote@
......
......@@ -573,10 +573,6 @@ int gridInqYbounds(int gridID, double *ybounds);
void gridDefRowlon(int gridID, int nrowlon, int *rowlon);
void gridInqRowlon(int gridID, int *rowlon);
void gridChangeType(int gridID, int gridtype);
int gridToZonal(int gridID);
int gridToMeridional(int gridID);
int gridToCell(int gridID);
int gridToCurvilinear(int gridID);
/* ZAXIS routines */
......
......@@ -4,7 +4,7 @@
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, October 2008
! Uwe Schulzweida, MPI-MET, Hamburg, November 2008
!
INTEGER CDI_UNDEFID
......@@ -188,6 +188,8 @@
PARAMETER (GRID_LCC = 11)
INTEGER GRID_LAEA
PARAMETER (GRID_LAEA = 12)
INTEGER GRID_SINUSOIDAL
PARAMETER (GRID_SINUSOIDAL = 13)
!
! ZAXIS types
!
......@@ -215,6 +217,8 @@
PARAMETER (ZAXIS_ALTITUDE = 10)
INTEGER ZAXIS_SIGMA
PARAMETER (ZAXIS_SIGMA = 11)
INTEGER ZAXIS_MEANSEA
PARAMETER (ZAXIS_MEANSEA = 12)
!
! TAXIS types
!
......@@ -1306,22 +1310,6 @@
! INTEGER gridtype)
EXTERNAL gridChangeType
INTEGER gridToZonal
! (INTEGER gridID)
EXTERNAL gridToZonal
INTEGER gridToMeridional
! (INTEGER gridID)
EXTERNAL gridToMeridional
INTEGER gridToCell
! (INTEGER gridID)
EXTERNAL gridToCell
INTEGER gridToCurvilinear
! (INTEGER gridID)
EXTERNAL gridToCurvilinear
!
! ZAXIS routines
!
......
......@@ -275,10 +275,6 @@ FCALLSCFUN2 (INT, gridInqYbounds, GRIDINQYBOUNDS, gridinqybounds, INT, PDOUBLE)
FCALLSCSUB3 (gridDefRowlon, GRIDDEFROWLON, griddefrowlon, INT, INT, PINT)
FCALLSCSUB2 (gridInqRowlon, GRIDINQROWLON, gridinqrowlon, INT, PINT)
FCALLSCSUB2 (gridChangeType, GRIDCHANGETYPE, gridchangetype, INT, INT)
FCALLSCFUN1 (INT, gridToZonal, GRIDTOZONAL, gridtozonal, INT)
FCALLSCFUN1 (INT, gridToMeridional, GRIDTOMERIDIONAL, gridtomeridional, INT)
FCALLSCFUN1 (INT, gridToCell, GRIDTOCELL, gridtocell, INT)
FCALLSCFUN1 (INT, gridToCurvilinear, GRIDTOCURVILINEAR, gridtocurvilinear, INT)
/* ZAXIS routines */
......
......@@ -3241,630 +3241,6 @@ void gridPrint(int gridID, int opt)
}
int gridToZonal(int gridID1)
{
static char func[] = "gridToZonal";
int gridID2;
int gridtype, gridsize;
double xval = 0;
double *yvals;
gridtype = gridInqType(gridID1);
gridsize = gridInqYsize(gridID1);
gridID2 = gridCreate(gridtype, gridsize);
if ( gridtype != GRID_LONLAT &&
gridtype != GRID_GAUSSIAN &&
(gridtype == GRID_GENERIC && gridsize <= 1) )
{
Error(func, "Gridtype %s unsupported!", gridNamePtr(gridtype));
}
else
{
gridDefXsize(gridID2, 1);
gridDefYsize(gridID2, gridsize);
gridDefXvals(gridID2, &xval);
if ( gridInqYvals(gridID1, NULL) )
{
yvals = (double *) malloc(gridsize*sizeof(double));
gridInqYvals(gridID1, yvals);
gridDefYvals(gridID2, yvals);
free(yvals);
}
}
return (gridID2);
}
int gridToMeridional(int gridID1)
{
static char func[] = "gridToMeridional";
int gridID2;
int gridtype, gridsize;
double *xvals;
double yval = 0;
gridtype = gridInqType(gridID1);
gridsize = gridInqXsize(gridID1);
gridID2 = gridCreate(gridtype, gridsize);
switch (gridtype)
{
case GRID_LONLAT:
case GRID_GAUSSIAN:
{
gridDefXsize(gridID2, gridsize);
gridDefYsize(gridID2, 1);
xvals = (double *) malloc(gridsize*sizeof(double));
gridInqXvals(gridID1, xvals);
gridDefXvals(gridID2, xvals);
gridDefYvals(gridID2, &yval);
free(xvals);
break;
}
default:
{
Error(func, "Gridtype %s unsupported!", gridNamePtr(gridtype));
break;
}
}
return (gridID2);
}
void gridGenXbounds(int nx, double *xvals, double *xbounds)
{
int i;
for ( i = 0; i < nx-1; i++ )
{
xbounds[2*i+1] = 0.5*(xvals[i] + xvals[i+1]);
xbounds[2*(i+1)] = 0.5*(xvals[i] + xvals[i+1]);
}
xbounds[0] = 2*xvals[0] - xbounds[1];
xbounds[2*nx-1] = 2*xvals[nx-1] - xbounds[2*(nx-1)];
}
void gridGenYbounds(int ny, double *yvals, double *ybounds)
{
int i;
for ( i = 0; i < ny-1; i++ )
{
ybounds[2*i+1] = 0.5*(yvals[i] + yvals[i+1]);
ybounds[2*(i+1)] = 0.5*(yvals[i] + yvals[i+1]);
}
ybounds[0] = 2*yvals[0] - ybounds[1];
ybounds[2*ny-1] = 2*yvals[ny-1] - ybounds[2*(ny-1)];
if ( yvals[0] > yvals[ny-1] )
{
if ( ybounds[0] > 88 ) ybounds[0] = 90;
if ( ybounds[2*ny-1] < -88 ) ybounds[2*ny-1] = -90;
}
else
{
if ( ybounds[0] < -88 ) ybounds[0] = -90;
if ( ybounds[2*ny-1] > 88 ) ybounds[2*ny-1] = 90;
}
}
void gridGenRotBounds(int gridID, int nx, int ny,
double *xbounds, double *ybounds, double *xbounds2D, double *ybounds2D)
{
int i, j, index;
double minlon, maxlon;
double minlat, maxlat;
double xpole, ypole;
xpole = gridInqXpole(gridID);
ypole = gridInqYpole(gridID);
for ( j = 0; j < ny; j++ )
{
if ( ybounds[0] > ybounds[1] )
{
maxlat = ybounds[2*j];
minlat = ybounds[2*j+1];
}
else
{
maxlat = ybounds[2*j+1];
minlat = ybounds[2*j];
}
for ( i = 0; i < nx; i++ )
{
minlon = xbounds[2*i];
maxlon = xbounds[2*i+1];
index = j*4*nx + 4*i;
xbounds2D[index+0] = rls_to_rl(minlat, minlon, ypole, xpole);
xbounds2D[index+1] = rls_to_rl(minlat, maxlon, ypole, xpole);
xbounds2D[index+2] = rls_to_rl(maxlat, maxlon, ypole, xpole);
xbounds2D[index+3] = rls_to_rl(maxlat, minlon, ypole, xpole);
ybounds2D[index+0] = phs_to_ph(minlat, minlon, ypole);
ybounds2D[index+1] = phs_to_ph(minlat, maxlon, ypole);
ybounds2D[index+2] = phs_to_ph(maxlat, maxlon, ypole);
ybounds2D[index+3] = phs_to_ph(maxlat, minlon, ypole);
}
}
}
void gridGenXbounds2D(int nx, int ny, double *xbounds, double *xbounds2D)
{
int i, j, index;
double minlon, maxlon;
for ( i = 0; i < nx; i++ )
{
minlon = xbounds[2*i];
maxlon = xbounds[2*i+1];
for ( j = 0; j < ny; j++ )
{
index = j*4*nx + 4*i;
xbounds2D[index+0] = minlon;
xbounds2D[index+1] = maxlon;
xbounds2D[index+2] = maxlon;
xbounds2D[index+3] = minlon;
}
}
}
void gridGenYbounds2D(int nx, int ny, double *ybounds, double *ybounds2D)
{
int i, j, index;
double minlat, maxlat;
for ( j = 0; j < ny; j++ )
{
if ( ybounds[0] > ybounds[1] )
{
maxlat = ybounds[2*j];
minlat = ybounds[2*j+1];
}
else
{
maxlat = ybounds[2*j+1];
minlat = ybounds[2*j];
}
for ( i = 0; i < nx; i++ )
{
index = j*4*nx + 4*i;
ybounds2D[index+0] = minlat;
ybounds2D[index+1] = minlat;
ybounds2D[index+2] = maxlat;
ybounds2D[index+3] = maxlat;
}
}
}
int gridToCurvilinear(int gridID1)
{
static char func[] = "gridToCurvilinear";
int gridID2;
int gridtype, gridsize;
gridtype = gridInqType(gridID1);
gridsize = gridInqSize(gridID1);
gridID2 = gridCreate(GRID_CURVILINEAR, gridsize);
switch (gridtype)
{
case GRID_LONLAT:
case GRID_GAUSSIAN:
case GRID_LCC:
{
int i, j, nx, ny;
double *xvals = NULL, *yvals = NULL;
double *xvals2D, *yvals2D;
double *xbounds = NULL, *ybounds = NULL;
double *xbounds2D, *ybounds2D;
nx = gridInqXsize(gridID1);
ny = gridInqYsize(gridID1);
gridDefXsize(gridID2, nx);
gridDefYsize(gridID2, ny);
xvals2D = (double *) malloc(gridsize*sizeof(double));
yvals2D = (double *) malloc(gridsize*sizeof(double));
if ( gridtype == GRID_LCC )
{
double xi, xj;
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
double zlat, zlon;
int projflag, scanflag;
int status;
gridInqLCC(gridID1, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
/*
while ( originLon < 0 ) originLon += 360;
while ( lonParY < 0 ) lonParY += 360;
*/
if ( ! DBL_IS_EQUAL(xincm, yincm) )
Warning(func, "X and Y increment must be equal on Lambert Conformal grid (Xinc = %g, Yinc = %g)\n",
xincm, yincm);
if ( ! DBL_IS_EQUAL(lat1, lat2) )
Warning(func, "Lat1 and Lat2 must be equal on Lambert Conformal grid (Lat1 = %g, Lat2 = %g)\n",
lat1, lat2);
for ( j = 0; j < ny; j++ )
for ( i = 0; i < nx; i++ )
{
xi = i+1;
xj = j+1;
status = W3FB12(xi, xj, originLat, originLon, xincm, lonParY, lat1, &zlat, &zlon);
xvals2D[j*nx+i] = zlon;
yvals2D[j*nx+i] = zlat;
}
}
else
{
if ( ! (gridInqXvals(gridID1, NULL) && gridInqYvals(gridID1, NULL)) )
Error(func, "Grid has no values");
xvals = (double *) malloc(nx*sizeof(double));
yvals = (double *) malloc(ny*sizeof(double));
gridInqXvals(gridID1, xvals);
gridInqYvals(gridID1, yvals);
if ( gridIsRotated(gridID1) )
{
double xpole, ypole;
xpole = gridInqXpole(gridID1);
ypole = gridInqYpole(gridID1);
for ( j = 0; j < ny; j++ )
for ( i = 0; i < nx; i++ )
{
xvals2D[j*nx+i] = rls_to_rl(yvals[j], xvals[i], ypole, xpole);
yvals2D[j*nx+i] = phs_to_ph(yvals[j], xvals[i], ypole);
}
}
else
{
for ( j = 0; j < ny; j++ )
for ( i = 0; i < nx; i++ )
{
xvals2D[j*nx+i] = xvals[i];
yvals2D[j*nx+i] = yvals[j];
}
}
}
gridDefXvals(gridID2, xvals2D);
gridDefYvals(gridID2, yvals2D);
free(xvals2D);
free(yvals2D);
if ( gridtype == GRID_LCC )
{
double xi, xj;
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
double zlat, zlon;
int projflag, scanflag;
int status;
int index;
gridInqLCC(gridID1, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
xbounds2D = (double *) malloc(4*gridsize*sizeof(double));
ybounds2D = (double *) malloc(4*gridsize*sizeof(double));
for ( j = 0; j < ny; j++ )
for ( i = 0; i < nx; i++ )
{
index = j*4*nx + 4*i;
xi = i+1.5;
xj = j+1.5;
status = W3FB12(xi, xj, originLat, originLon, xincm, lonParY, lat1, &zlat,&zlon);
xbounds2D[index+0] = zlon;
ybounds2D[index+0] = zlat;
xi = i+0.5;
xj = j+1.5;
status = W3FB12(xi, xj, originLat, originLon, xincm, lonParY, lat1, &zlat,&zlon);
xbounds2D[index+1] = zlon;
ybounds2D[index+1] = zlat;
xi = i+0.5;
xj = j+0.5;
status = W3FB12(xi, xj, originLat, originLon, xincm, lonParY, lat1, &zlat,&zlon);
xbounds2D[index+2] = zlon;
ybounds2D[index+2] = zlat;
xi = i+1.5;
xj = j+0.5;
status = W3FB12(xi, xj, originLat, originLon, xincm, lonParY, lat1, &zlat,&zlon);
xbounds2D[index+3] = zlon;
ybounds2D[index+3] = zlat;
}
gridDefXbounds(gridID2, xbounds2D);
gridDefYbounds(gridID2, ybounds2D);
free(xbounds2D);
free(ybounds2D);
}
else
{
if ( gridInqXboundsPtr(gridID1) )
{
xbounds = (double *) malloc(2*nx*sizeof(double));
gridInqXbounds(gridID1, xbounds);
}
else if ( nx > 1 )
{
xbounds = (double *) malloc(2*nx*sizeof(double));
gridGenXbounds(nx, xvals, xbounds);
}
if ( gridInqYboundsPtr(gridID1) )
{
ybounds = (double *) malloc(2*ny*sizeof(double));
gridInqYbounds(gridID1, ybounds);
}
else if ( ny > <