Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mpim-sw
cdo
Commits
d14c47bb
Commit
d14c47bb
authored
Jan 12, 2021
by
Uwe Schulzweida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_no_unique_center_points(): simplify if statement.
parent
28d6cf00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
48 deletions
+33
-48
src/Verifygrid.cc
src/Verifygrid.cc
+33
-48
No files found.
src/Verifygrid.cc
View file @
d14c47bb
...
...
@@ -339,31 +339,25 @@ print_header(int gridtype, size_t gridsize, size_t nx, int gridno, int ngrids)
}
static
size_t
get_no_unique_center_points
(
size_t
gridsize
,
size_t
nx
,
const
Varray
<
double
>
&
center_point
_array
)
get_no_unique_center_points
(
size_t
gridsize
,
size_t
nx
,
const
Varray
<
double
>
&
center_point
)
{
size_t
no_unique_center_points
=
1
;
for
(
size_t
cell_no
=
0
;
cell_no
<
gridsize
-
1
;
cell_no
++
)
{
if
(
std
::
fabs
(
center_point_array
[
cell_no
*
2
+
0
]
-
center_point_array
[(
cell_no
+
1
)
*
2
+
0
])
<
eps
)
if
(
std
::
fabs
(
center_point
[
cell_no
*
2
+
0
]
-
center_point
[(
cell_no
+
1
)
*
2
+
0
])
<
eps
&&
std
::
fabs
(
center_point
[
cell_no
*
2
+
1
]
-
center_point
[(
cell_no
+
1
)
*
2
+
1
])
<
eps
)
{
if
(
std
::
fabs
(
center_point_array
[
cell_no
*
2
+
1
]
-
center_point_array
[(
cell_no
+
1
)
*
2
+
1
])
<
eps
)
if
(
Options
::
cdoVerbose
)
{
if
(
Options
::
cdoVerbose
)
{
fprintf
(
stdout
,
"Duplicate point [lon=%.5g lat=%.5g] was found in cell no %zu"
,
center_point_array
[
cell_no
*
2
+
0
],
center_point_array
[
cell_no
*
2
+
1
],
cell_no
+
1
);
if
(
nx
)
printIndex2D
(
cell_no
,
nx
);
fprintf
(
stdout
,
"
\n
"
);
}
continue
;
fprintf
(
stdout
,
"Duplicate point [lon=%.5g lat=%.5g] was found in cell no %zu"
,
center_point
[
cell_no
*
2
+
0
],
center_point
[
cell_no
*
2
+
1
],
cell_no
+
1
);
if
(
nx
)
printIndex2D
(
cell_no
,
nx
);
fprintf
(
stdout
,
"
\n
"
);
}
else
no_unique_center_points
+=
1
;
}
else
{
no_unique_center_points
+=
1
;
no_unique_center_points
++
;
}
}
...
...
@@ -373,15 +367,15 @@ get_no_unique_center_points(size_t gridsize, size_t nx, const Varray<double> &ce
void
set_cell_corners_xyz
(
int
ncorner
,
const
double
*
cell_corners_lon
,
const
double
*
cell_corners_lat
,
Varray
<
Point3D
>
&
cell_corners_xyz
)
{
double
corner_coordinates
[
3
];
for
(
int
corner_no
=
0
;
corner_no
<
ncorner
;
corner_no
++
)
for
(
int
k
=
0
;
k
<
ncorner
;
k
++
)
{
// Conversion of corner spherical coordinates to Cartesian coordinates.
gcLLtoXYZ
(
cell_corners_lon
[
corner_no
],
cell_corners_lat
[
corner_no
],
corner_coordinates
);
gcLLtoXYZ
(
cell_corners_lon
[
k
],
cell_corners_lat
[
k
],
corner_coordinates
);
// The components of the result vector are appended to the list of cell corner coordinates.
cell_corners_xyz
[
corner_no
].
X
=
corner_coordinates
[
0
];
cell_corners_xyz
[
corner_no
].
Y
=
corner_coordinates
[
1
];
cell_corners_xyz
[
corner_no
].
Z
=
corner_coordinates
[
2
];
cell_corners_xyz
[
k
].
X
=
corner_coordinates
[
0
];
cell_corners_xyz
[
k
].
Y
=
corner_coordinates
[
1
];
cell_corners_xyz
[
k
].
Z
=
corner_coordinates
[
2
];
}
}
...
...
@@ -398,27 +392,18 @@ void set_center_point_plane_projection(int coordinate_to_ignore, const Point3D &
}
void
set_cell_corners_plane_projection
(
int
coordinate_to_ignore
,
int
ncorner
,
const
Varray
<
Point3D
>
&
cell_corners_xyz
,
Varray
<
Point
>
&
cell_corners_plane
_projection
)
Varray
<
Point
>
&
cell_corners_plane
)
{
switch
(
coordinate_to_ignore
)
{
case
1
:
for
(
int
corner_no
=
0
;
corner_no
<=
ncorner
;
corner_no
++
)
{
cell_corners_plane_projection
[
corner_no
]
=
Point
{
cell_corners_xyz
[
corner_no
].
Y
,
cell_corners_xyz
[
corner_no
].
Z
};
}
for
(
int
k
=
0
;
k
<=
ncorner
;
k
++
)
cell_corners_plane
[
k
]
=
Point
{
cell_corners_xyz
[
k
].
Y
,
cell_corners_xyz
[
k
].
Z
};
break
;
case
2
:
for
(
int
corner_no
=
0
;
corner_no
<=
ncorner
;
corner_no
++
)
{
cell_corners_plane_projection
[
corner_no
]
=
Point
{
cell_corners_xyz
[
corner_no
].
Z
,
cell_corners_xyz
[
corner_no
].
X
};
}
for
(
int
k
=
0
;
k
<=
ncorner
;
k
++
)
cell_corners_plane
[
k
]
=
Point
{
cell_corners_xyz
[
k
].
Z
,
cell_corners_xyz
[
k
].
X
};
break
;
case
3
:
for
(
int
corner_no
=
0
;
corner_no
<=
ncorner
;
corner_no
++
)
{
cell_corners_plane_projection
[
corner_no
]
=
Point
{
cell_corners_xyz
[
corner_no
].
X
,
cell_corners_xyz
[
corner_no
].
Y
};
}
for
(
int
k
=
0
;
k
<=
ncorner
;
k
++
)
cell_corners_plane
[
k
]
=
Point
{
cell_corners_xyz
[
k
].
X
,
cell_corners_xyz
[
k
].
Y
};
break
;
}
}
...
...
@@ -427,11 +412,11 @@ int get_actual_number_of_corners(int ncorner, const Varray<Point3D> &cell_corner
{
auto
actual_number_of_corners
=
ncorner
;
for
(
int
corner_no
=
ncorner
-
1
;
corner_no
>
0
;
corner_no
--
)
for
(
int
k
=
ncorner
-
1
;
k
>
0
;
k
--
)
{
if
(
IS_EQUAL
(
cell_corners_xyz_open_cell
[
corner_no
].
X
,
cell_corners_xyz_open_cell
[
corner_no
-
1
].
X
)
&&
IS_EQUAL
(
cell_corners_xyz_open_cell
[
corner_no
].
Y
,
cell_corners_xyz_open_cell
[
corner_no
-
1
].
Y
)
&&
IS_EQUAL
(
cell_corners_xyz_open_cell
[
corner_no
].
Z
,
cell_corners_xyz_open_cell
[
corner_no
-
1
].
Z
))
if
(
IS_EQUAL
(
cell_corners_xyz_open_cell
[
k
].
X
,
cell_corners_xyz_open_cell
[
k
-
1
].
X
)
&&
IS_EQUAL
(
cell_corners_xyz_open_cell
[
k
].
Y
,
cell_corners_xyz_open_cell
[
k
-
1
].
Y
)
&&
IS_EQUAL
(
cell_corners_xyz_open_cell
[
k
].
Z
,
cell_corners_xyz_open_cell
[
k
-
1
].
Z
))
actual_number_of_corners
--
;
else
break
;
...
...
@@ -452,7 +437,7 @@ int get_no_duplicates(int actual_number_of_corners, const Varray<Point3D> &cell_
&&
std
::
fabs
(
cell_corners_xyz_open_cell
[
i
].
Y
-
cell_corners_xyz_open_cell
[
j
].
Y
)
<
eps
&&
std
::
fabs
(
cell_corners_xyz_open_cell
[
i
].
Z
-
cell_corners_xyz_open_cell
[
j
].
Z
)
<
eps
)
{
no_duplicates
+=
1
;
no_duplicates
++
;
marked_duplicate_indices
[
j
]
=
true
;
}
...
...
@@ -464,11 +449,11 @@ void copy_unique_corners(int actual_number_of_corners, const Varray<Point3D> &ce
{
int
unique_corner_number
=
0
;
for
(
int
corner_no
=
0
;
corner_no
<
actual_number_of_corners
;
corner_no
++
)
for
(
int
k
=
0
;
k
<
actual_number_of_corners
;
k
++
)
{
if
(
marked_duplicate_indices
[
corner_no
]
==
false
)
if
(
marked_duplicate_indices
[
k
]
==
false
)
{
cell_corners_xyz_without_duplicates
[
unique_corner_number
]
=
cell_corners_xyz_open_cell
[
corner_no
];
cell_corners_xyz_without_duplicates
[
unique_corner_number
]
=
cell_corners_xyz_open_cell
[
k
];
unique_corner_number
++
;
}
}
...
...
@@ -541,16 +526,16 @@ verify_grid(size_t gridsize, size_t nx, int ncorner,
center_point_xyz
.
Z
=
center_coordinates
[
2
];
double
corner_coordinates
[
3
];
for
(
int
corner_no
=
0
;
corner_no
<
ncorner
;
corner_no
++
)
for
(
int
k
=
0
;
k
<
ncorner
;
k
++
)
{
// Conversion of corner spherical coordinates to Cartesian coordinates.
gcLLtoXYZdeg
(
grid_corner_lon
[
cell_no
*
ncorner
+
corner_no
],
grid_corner_lat
[
cell_no
*
ncorner
+
corner_no
],
gcLLtoXYZdeg
(
grid_corner_lon
[
cell_no
*
ncorner
+
k
],
grid_corner_lat
[
cell_no
*
ncorner
+
k
],
corner_coordinates
);
// The components of the result vector are appended to the list of cell corner coordinates.
cell_corners_xyz_open_cell
[
corner_no
].
X
=
corner_coordinates
[
0
];
cell_corners_xyz_open_cell
[
corner_no
].
Y
=
corner_coordinates
[
1
];
cell_corners_xyz_open_cell
[
corner_no
].
Z
=
corner_coordinates
[
2
];
cell_corners_xyz_open_cell
[
k
].
X
=
corner_coordinates
[
0
];
cell_corners_xyz_open_cell
[
k
].
Y
=
corner_coordinates
[
1
];
cell_corners_xyz_open_cell
[
k
].
Z
=
corner_coordinates
[
2
];
}
/*
...
...
@@ -692,8 +677,8 @@ verify_grid(size_t gridsize, size_t nx, int ncorner,
if
(
Options
::
cdoVerbose
&&
winding_number
==
0
)
{
fprintf
(
stdout
,
"Center point [lon=%.5g lat=%.5g] outside bounds ["
,
grid_center_lon
[
cell_no
],
grid_center_lat
[
cell_no
]);
for
(
int
corner_no
=
0
;
corner_no
<
ncorner
;
corner_no
++
)
fprintf
(
stdout
,
" %.5g/%.5g"
,
grid_corner_lon
[
cell_no
*
ncorner
+
corner_no
],
grid_corner_lat
[
cell_no
*
ncorner
+
corner_no
]);
for
(
int
k
=
0
;
k
<
ncorner
;
k
++
)
fprintf
(
stdout
,
" %.5g/%.5g"
,
grid_corner_lon
[
cell_no
*
ncorner
+
k
],
grid_corner_lat
[
cell_no
*
ncorner
+
k
]);
fprintf
(
stdout
,
"] in cell no %zu"
,
cell_no
+
1
);
if
(
nx
)
printIndex2D
(
cell_no
,
nx
);
fprintf
(
stdout
,
"
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment