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

gridToCurvilinear: optional computation of grid bounds

parent c2df4dd5
......@@ -3,6 +3,8 @@ CDO NEWS
Version 1.5.4 (?? January 2012):
New features:
* setgridtype: added parameter lonlat to convert curvilinear to regular lon/lat grids
New operators:
* timcovar: covariance over time
* fldcovar: covariance in grid space
......
......@@ -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-2011 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2012 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
......@@ -96,7 +96,7 @@ void *Arithlat(void *argument)
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_LCC )
{
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 1);
}
else if ( gridtype == GRID_CURVILINEAR ||
gridtype == GRID_UNSTRUCTURED )
......
......@@ -750,7 +750,7 @@ void *Gradsdes(void *argument)
fprintf(gdp, "PDEF %d %d lcc %g %g 1 1 %g %g %g %g %g\n",
xsize, ysize, originLat, originLon, lat1, lat2, lonParY, xincm, yincm);
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 0);
xvals = (double *) malloc(xsize*ysize*sizeof(double));
yvals = (double *) malloc(xsize*ysize*sizeof(double));
gridInqXvals(gridID, xvals);
......
......@@ -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-2011 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2012 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
......@@ -209,7 +209,7 @@ void *Gridcell(void *argument)
char units[CDI_MAX_NAME];
if ( gridtype != GRID_CURVILINEAR )
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 1);
gridsize = gridInqSize(gridID);
xsize = gridInqXsize(gridID);
......
......@@ -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-2011 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2012 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
......@@ -254,7 +254,7 @@ void *Mrotuv(void *argument)
cdoAbort("Grid %s unsupported!", gridNamePtr(gridInqType(gridID1)));
if ( gridInqType(gridID1) != GRID_CURVILINEAR )
gridID1 = gridToCurvilinear(gridID1);
gridID1 = gridToCurvilinear(gridID1, 0);
if ( gridsize != gridInqSize(gridID1) ) cdoAbort("Internal problem: gridsize changed!");
......
......@@ -305,12 +305,12 @@ void *Mrotuvb(void *argument)
cdoAbort("Grid %s unsupported!", gridNamePtr(gridInqType(gridID1)));
if ( gridInqType(gridID1) != GRID_CURVILINEAR )
gridID1 = gridToCurvilinear(gridID1);
gridID1 = gridToCurvilinear(gridID1, 1);
if ( gridsize != gridInqSize(gridID1) ) cdoAbort("Internal problem: gridsize changed!");
if ( gridInqType(gridID2) != GRID_CURVILINEAR )
gridID2 = gridToCurvilinear(gridID2);
gridID2 = gridToCurvilinear(gridID2, 1);
if ( gridsize != gridInqSize(gridID2) ) cdoAbort("Internal problem: gridsize changed!");
......
......@@ -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-2011 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2012 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
......@@ -158,7 +158,7 @@ void *Output(void *argument)
if ( gridInqType(gridID) == GRID_GME ) gridID = gridToUnstructured(gridID);
if ( gridInqType(gridID) != GRID_UNSTRUCTURED && gridInqType(gridID) != GRID_CURVILINEAR )
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 0);
gridtype = gridInqType(gridID);
......
......@@ -660,7 +660,7 @@ void *Outputgmt(void *argument)
if ( gridInqType(gridID) != GRID_UNSTRUCTURED && gridInqType(gridID) != GRID_CURVILINEAR )
{
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 1);
lgrid_gen_bounds = TRUE;
}
......
......@@ -239,7 +239,7 @@ void *Setgrid(void *argument)
{
if ( gridtype == GRID_CURVILINEAR )
{
gridID2 = gridToCurvilinear(gridID1);
gridID2 = gridToCurvilinear(gridID1, 1);
}
else if ( gridtype == GRID_UNSTRUCTURED )
{
......
......@@ -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-2011 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2012 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
......@@ -50,7 +50,7 @@ void *Writegrid(void *argument)
if ( gridtype == GRID_GME ) gridID = gridToUnstructured(gridID);
if ( gridtype != GRID_CURVILINEAR && gridtype != GRID_UNSTRUCTURED )
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 1);
if ( gridInqXbounds(gridID, NULL) == 0 || gridInqYbounds(gridID, NULL) == 0 )
cdoAbort("Grid corner missing!");
......
......@@ -1052,7 +1052,7 @@ void eca4(const ECA_REQUEST_4 *request)
if ( gridtype == GRID_GME )
gridID = gridToUnstructured(gridID);
else
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 1);
}
gridsize = gridInqSize(gridID);
/* for later check on northern\southern hemisphere */
......
......@@ -579,7 +579,7 @@ int check_range(long n, double *vals, double valid_min, double valid_max)
}
int gridToCurvilinear(int gridID1)
int gridToCurvilinear(int gridID1, int lbounds)
{
int gridID2;
int gridtype, gridsize;
......@@ -688,6 +688,8 @@ int gridToCurvilinear(int gridID1)
if ( xvals2D ) free(xvals2D);
if ( yvals2D ) free(yvals2D);
if ( !lbounds ) goto NO_BOUNDS;
if ( gridtype == GRID_LCC )
{
xbounds2D = (double *) malloc(4*gridsize*sizeof(double));
......@@ -762,9 +764,6 @@ int gridToCurvilinear(int gridID1)
gridGenYbounds(ny, yvals, ybounds);
}
if ( xvals ) free(xvals);
if ( yvals ) free(yvals);
if ( xbounds && ybounds )
{
xbounds2D = (double *) malloc(4*gridsize*sizeof(double));
......@@ -834,6 +833,11 @@ int gridToCurvilinear(int gridID1)
}
}
NO_BOUNDS:
if ( xvals ) free(xvals);
if ( yvals ) free(yvals);
gridCopyMask(gridID1, gridID2, gridsize);
break;
......@@ -1399,7 +1403,7 @@ int gridGenArea(int gridID, double *area)
else
{
lgriddestroy = TRUE;
gridID = gridToCurvilinear(gridID);
gridID = gridToCurvilinear(gridID, 1);
lgrid_gen_bounds = TRUE;
}
}
......
......@@ -10,7 +10,7 @@ void gridToDegree(const char *units, const char *string, int gridsize, double *a
int gridToZonal(int gridID);
int gridToMeridional(int gridID);
int gridToUnstructured(int gridID);
int gridToCurvilinear(int gridID);
int gridToCurvilinear(int gridID, int lbounds);
int gridCurvilinearToRegular(int gridID);
int gridToRegular(int gridID);
void field2regular(int gridID1, int gridID2, double missval, double *array, int nmiss);
......
......@@ -280,7 +280,7 @@ void intgrid(field_t *field1, field_t *field2)
double *lon2, *lat2;
if ( gridInqType(gridID2) != GRID_UNSTRUCTURED && gridInqType(gridID2) != GRID_CURVILINEAR )
gridID2 = gridToCurvilinear(gridID2);
gridID2 = gridToCurvilinear(gridID2, 0);
if ( ! (gridInqXvals(gridID2, NULL) && gridInqYvals(gridID2, NULL)) )
cdoAbort("Target grid has no values");
......
......@@ -1005,7 +1005,7 @@ void remapGridInit(int map_type, int lextrapolate, int gridID1, int gridID2, rem
gridInqType(rg->gridID1) == GRID_LAEA ||
gridInqType(rg->gridID1) == GRID_SINUSOIDAL) )
{
rg->gridID1 = gridID1 = gridToCurvilinear(rg->gridID1);
rg->gridID1 = gridID1 = gridToCurvilinear(rg->gridID1, 1);
}
if ( !rg->lextrapolate && gridInqSize(rg->gridID1) > 1 &&
......@@ -1042,7 +1042,7 @@ void remapGridInit(int map_type, int lextrapolate, int gridID1, int gridID2, rem
else
{
lgrid1_destroy = TRUE;
gridID1 = gridToCurvilinear(rg->gridID1);
gridID1 = gridToCurvilinear(rg->gridID1, 1);
lgrid1_gen_bounds = TRUE;
}
}
......@@ -1060,7 +1060,7 @@ void remapGridInit(int map_type, int lextrapolate, int gridID1, int gridID2, rem
else
{
lgrid2_destroy = TRUE;
gridID2 = gridToCurvilinear(rg->gridID2);
gridID2 = gridToCurvilinear(rg->gridID2, 1);
lgrid2_gen_bounds = TRUE;
}
}
......
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