Commit 1fb9b62c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

clipping update

parent 861ee383
......@@ -325,7 +325,7 @@ void *Vertint(void *argument)
half_press = malloc(ngp*nhlevh*sizeof(double));
}
else
cdoWarning("No data on hybrid model level found!");
cdoWarning("No data on hybrid sigma pressure levels found!");
if ( operfunc == func_hl )
{
......
......@@ -405,13 +405,21 @@ void cell_clipping(unsigned N,
if (intersect != -1) {
// if both edges are on an identical great circle
if (intersect & (1 << 4))
if (intersect & (1 << 4)) {
print_grid_cell(stderr, target_cell, "target cell");
print_grid_cell(stderr, source_cell[n], "source cell");
abort_message("ERROR: edges on identical circle, this case should"
" have been handled somewhere else\n", __FILE__, __LINE__);
}
// if there are two intersection points with the source edge
if ((intersect & ((1 << 0) | (1 << 1))) == ((1 << 0) | (1 << 1))) {
print_grid_cell(stderr, target_cell, "target cell");
print_grid_cell(stderr, source_cell[n], "source cell");
abort_message("ERROR: more than one intersections with the "
"source edges", __FILE__, __LINE__);
......@@ -438,17 +446,8 @@ void cell_clipping(unsigned N,
} else {
for (int i = 0; i < source_cell[n].num_corners; ++i) {
fprintf(stderr, "src: %d, %lf, %lf\n", i,
source_cell[n].coordinates_x[i],
source_cell[n].coordinates_y[i]);
}
for (int i = 0; i < target_cell.num_corners; ++i) {
fprintf(stderr, "tgt: %d, %lf, %lf\n", i,
target_cell.coordinates_x[i],
target_cell.coordinates_y[i]);
}
print_grid_cell(stderr, target_cell, "target cell");
print_grid_cell(stderr, source_cell[n], "source cell");
abort_message("ERROR: no intersection with source edge was found\n",
__FILE__, __LINE__);
......@@ -481,9 +480,14 @@ void cell_clipping(unsigned N,
if (intersect != -1) {
// if both edges are on an identical great circle
if (intersect & (1 << 4))
if (intersect & (1 << 4)) {
print_grid_cell(stderr, target_cell, "target cell");
print_grid_cell(stderr, source_cell[n], "source cell");
abort_message("ERROR: edges on identical circle, this case should"
" have been handled somewhere else\n", __FILE__, __LINE__);
}
// if there are two intersection points with the source edge
if ((intersect & ((1 << 0) | (1 << 1))) == ((1 << 0) | (1 << 1))) {
......
......@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "grid_cell.h"
#include "utils.h"
......@@ -157,3 +158,41 @@ void unpack_grid_cell(struct grid_cell * cell, double * dble_buf,
cell->coordinates_xyz + 3*i);
}
}
void print_grid_cell(FILE * stream, struct grid_cell cell, char * name) {
char * out = NULL;
unsigned out_array_size = 0;
unsigned out_size = 0;
if (name != NULL) {
out_size = strlen(name) + 1 + 1 + 1;
ENSURE_ARRAY_SIZE(out, out_array_size, out_size);
strcpy(out, name);
strcat(out, ":\n");
}
for (unsigned i = 0; i < cell.num_corners; ++i) {
char buffer[1024];
sprintf(buffer, "%d x %.16f y %.16f %s\n", i, cell.coordinates_x[i],
cell.coordinates_y[i],
(cell.edge_type[i] == LAT_CIRCLE)?("LAT_CIRCLE"):
((cell.edge_type[i] == LON_CIRCLE)?("LON_CIRCLE"):
("GREAT_CIRCLE")));
out_size += strlen(buffer);
ENSURE_ARRAY_SIZE(out, out_array_size, out_size);
strcat(out, buffer);
}
if (out != NULL)
fputs(out, stream);
free(out);
}
......@@ -31,6 +31,8 @@
* along with YAC. If not, see <http://www.gnu.org/licenses/gpl.txt>.
*/
#include <stdio.h>
#ifndef GRID_CELL_H
#define GRID_CELL_H
......@@ -84,4 +86,6 @@ void unpack_grid_cell(struct grid_cell * cell, double * dble_buf,
unsigned * dble_buf_data_size, unsigned * uint_buf,
unsigned * uint_buf_data_size);
void print_grid_cell(FILE * stream, struct grid_cell cell, char * name);
#endif // GRID_CELL_H
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