foresight_contour
foresight_contour, gnuplot's contour lines of a surface grid.
A port of gnuplot 6.0's contour.c: each cell of the grid split into two triangles (edges in gnuplot's list order), the edges crossing a level traced through the triangles, from the boundary first (open lines) then inside (closed ones); each line in linear segments, a cubic spline through its points or a B-spline approximation of them; lines cut into chunks of at most 99 points, the last one starting the next; the list built last first, as gnuplot's (its table and drawing order). The levels: auto N (gnuplot's quantize_normal_tics of the z extent, guide 2 (N + 1)), discrete z1, z2, ..., incremental start, step[, end].
Source: src/lib/foresight_contour.F90
Dependencies
Contents
- contour_object
- tracer
- contour_levels
- contour_lines
- new_triangle
- link
- trace
- edge_point
- put_line
- add_point
- end_chunk
- put_cubic
- cubic_points
- put_bspline
- cubic_spline
- cholesky
- cholesky_solve
- bspline_point
- quantize
- new_edge
- same_point
- knot_value
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
CONTOUR_LINEAR | integer(kind=I4P) | parameter | set cntrparam linear. |
CONTOUR_CUBIC | integer(kind=I4P) | parameter | cubicspline. |
CONTOUR_BSPLINE | integer(kind=I4P) | parameter | bspline. |
LEVELS_AUTO | integer(kind=I4P) | parameter | levels auto N. |
LEVELS_DISCRETE | integer(kind=I4P) | parameter | levels discrete z1, z2, .... |
LEVELS_INCREMENTAL | integer(kind=I4P) | parameter | levels incremental start, step[, end]. |
MAX_POINTS | integer(kind=I4P) | parameter | gnuplot's MAX_POINTS_PER_CNTR: chunks of 99 points. |
EPS | real(kind=R8P) | parameter | gnuplot's EPSILON: two points are the same. |
BOUNDARY | integer(kind=I4P) | parameter | An edge of one triangle. |
DIAGONAL | integer(kind=I4P) | parameter | The diagonal of a cell. |
Derived Types
contour_object
Contour settings of a panel (gnuplot set contour, set cntrparam, set cntrlabel).
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
on | logical | Contours drawn (set contour). | |
place | character(len=7) | base, surface or both. | |
kind | integer(kind=I4P) | Interpolation. | |
levels_kind | integer(kind=I4P) | Levels kind. | |
levels | integer(kind=I4P) | Levels of auto (about), or of incremental with an end. | |
list | real(kind=R8P) | allocatable | discrete levels, or incremental start and step. |
order | integer(kind=I4P) | B-spline order, 2 to 10. | |
npoints | integer(kind=I4P) | Points per interval of the splines. | |
firstlinetype | integer(kind=I4P) | Linetype of the first level, else the surface's + 1. | |
sorted | logical | Levels sorted high to low. | |
format | character(len=64) | Label format (set cntrlabel format). | |
onecolor | logical | All levels in the surface's color, one key entry (onecolor). | |
label_start | integer(kind=I4P) | First labelled point of with labels (start). | |
label_interval | integer(kind=I4P) | Points between labels (interval). |
tracer
The triangulation of a grid and the lines traced on it (gnuplot's contour.c state).
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
settings | type(contour_object) | Settings. | |
nx | integer(kind=I4P) | Points per row. | |
vx | real(kind=R8P) | allocatable | Vertices, (row - 1) nx + point. |
vy | real(kind=R8P) | allocatable | Vertices, (row - 1) nx + point. |
vz | real(kind=R8P) | allocatable | Vertices, (row - 1) nx + point. |
vin | logical | allocatable | Vertex in range, defined. |
vdef | logical | allocatable | Vertex in range, defined. |
unit_x | real(kind=R8P) | Grid extent along x. | |
unit_y | real(kind=R8P) | Grid extent along y. | |
ev | integer(kind=I4P) | allocatable | Edge vertices (2, edge). |
ep | integer(kind=I4P) | allocatable | Edge triangles (2, edge), 0 for none. |
epos | integer(kind=I4P) | allocatable | Edge position: 1 inner, BOUNDARY, DIAGONAL. |
active | logical | allocatable | Edge crossing the current level. |
pe | integer(kind=I4P) | allocatable | Triangle edges (3, triangle). |
hprev | integer(kind=I4P) | allocatable | Horizontal edges of the previous and current rows. |
hrow | integer(kind=I4P) | allocatable | Horizontal edges of the previous and current rows. |
htri | integer(kind=I4P) | allocatable | Triangle of each upper edge of the current row. |
ne | integer(kind=I4P) | Edges. | |
np | integer(kind=I4P) | Triangles. | |
nactive | integer(kind=I4P) | Active edges. | |
px | real(kind=R8P) | allocatable | Points of the line being traced. |
py | real(kind=R8P) | allocatable | Points of the line being traced. |
npt | integer(kind=I4P) | Its points. | |
cur | real(kind=R8P) | gnuplot's crnt_cntr. | |
ncur | integer(kind=I4P) | Its points. | |
kx | real(kind=R8P) | allocatable | Chunks made (in making order), NaN separated, their level. |
ky | real(kind=R8P) | allocatable | Chunks made (in making order), NaN separated, their level. |
kz | real(kind=R8P) | allocatable | Chunks made (in making order), NaN separated, their level. |
nk | integer(kind=I4P) | Rows made. | |
kfirst | integer(kind=I4P) | allocatable | First and last row of each chunk. |
klast | integer(kind=I4P) | allocatable | First and last row of each chunk. |
knew | logical | allocatable | Chunk flagged new level. |
nchunks | integer(kind=I4P) | Chunks made. |
Subroutines
contour_levels
The levels of the contours of a surface of heights zmin to zmax (its defined points), as gnuplot's contour(): auto levels at the multiples of a round step within the extent, incremental from start by step (a factor on a log z axis, zlog), discrete as given; sorted high to low with sorted.
Attributes: pure
subroutine contour_levels(settings, zmin, zmax, zlog, levels)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
settings | type(contour_object) | in | Settings. | |
zmin | real(kind=R8P) | in | Lowest height. | |
zmax | real(kind=R8P) | in | Highest height. | |
zlog | logical | in | A log z axis. | |
levels | real(kind=R8P) | out | allocatable | Levels. |
Call graph
contour_lines
The contour lines of a grid of size(gx, 1) points per row and size(gx, 2) rows (gnuplot's iso-curves in their list order), as gnuplot's contour(): the grid triangulated over its points in range (inrange), its extent over the defined ones, the levels of contour_levels; the chunks of the lines in gnuplot's order (the last made first), as rows cx, cy (a NaN row after each chunk), cz their level; chunk_level the level of each chunk, new_level true on the first chunk of each level (its key entry, its table header).
subroutine contour_lines(gx, gy, gz, inrange, defined, settings, zlog, cx, cy, cz, chunk_level, new_level)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gx | real(kind=R8P) | in | Abscissae (point, row). | |
gy | real(kind=R8P) | in | Ordinates. | |
gz | real(kind=R8P) | in | Heights. | |
inrange | logical | in | Points in range (gnuplot's INRANGE). | |
defined | logical | in | Points defined. | |
settings | type(contour_object) | in | Settings. | |
zlog | logical | in | A log z axis. | |
cx | real(kind=R8P) | out | allocatable | Line abscissae, NaN after each chunk. |
cy | real(kind=R8P) | out | allocatable | Line ordinates. |
cz | real(kind=R8P) | out | allocatable | Their level. |
chunk_level | real(kind=R8P) | out | allocatable | Level of each chunk. |
new_level | logical | out | allocatable | First chunk of its level. |
Call graph
new_triangle
gnuplot's add_poly: a triangle of the edges a, b, c if all three exist (an upper edge numbered later, -1); each numbered edge told the triangle.
subroutine new_triangle(st, a, b, c)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Triangulation. | |
a | integer(kind=I4P) | in | First edge. | |
b | integer(kind=I4P) | in | Second edge. | |
c | integer(kind=I4P) | in | Third edge. |
Call graph
link
Edge e told of the newest triangle.
subroutine link(st, e)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Triangulation. | |
e | integer(kind=I4P) | in | Edge. |
trace
gnuplot's trace_contour: the line from edge e_start through the triangles to a boundary edge or back to it, its points (px, py, npt) on the non-diagonal edges, nearby ones merged; none on a dead end.
subroutine trace(st, e_start, z, isclosed)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Triangulation and line. | |
e_start | integer(kind=I4P) | in | First edge. | |
z | real(kind=R8P) | in | Level. | |
isclosed | logical | in | Looking for closed lines. |
Call graph
edge_point
gnuplot's update_cntr_pt: where edge e crosses level z, linearly.
Attributes: pure
subroutine edge_point(st, e, z, qx, qy)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | in | Triangulation. | |
e | integer(kind=I4P) | in | Edge. | |
z | real(kind=R8P) | in | Level. | |
qx | real(kind=R8P) | out | Abscissa. | |
qy | real(kind=R8P) | out | Ordinate. |
Call graph
put_line
gnuplot's put_contour: the traced line as it is, through a cubic spline, or approximated by a B-spline.
subroutine put_line(st, z, isclosed)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Line and chunks. | |
z | real(kind=R8P) | in | Level. | |
isclosed | logical | in | A closed line. |
Call graph
add_point
gnuplot's add_cntr_point: a point of the current chunk, a full chunk ended and its last point the next's first.
subroutine add_point(st, x, y, z)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Chunks. | |
x | real(kind=R8P) | in | Abscissa. | |
y | real(kind=R8P) | in | Ordinate. | |
z | real(kind=R8P) | in | Level. |
Call graph
end_chunk
gnuplot's end_crnt_cntr: the current chunk kept, a NaN row after it.
subroutine end_chunk(st, z)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Chunks. | |
z | real(kind=R8P) | in | Level. |
Call graph
put_cubic
gnuplot's put_contour_cubic: a cubic spline through the points, parameter the length of the stroke in grid units, npoints points per interval.
subroutine put_cubic(st, z, isclosed)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Line and chunks. | |
z | real(kind=R8P) | in | Level. | |
isclosed | logical | in | A closed line. |
Call graph
cubic_points
gnuplot's intp_cubic_spline: n_intpol points of the spline, evenly in its parameter.
subroutine cubic_points(st, n, qx, qy, d2x, d2y, dt, n_intpol, z)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Chunks. | |
n | integer(kind=I4P) | in | Points. | |
qx | real(kind=R8P) | in | Points. | |
qy | real(kind=R8P) | in | Points. | |
d2x | real(kind=R8P) | in | Second derivatives, interval lengths. | |
d2y | real(kind=R8P) | in | Second derivatives, interval lengths. | |
dt | real(kind=R8P) | in | Second derivatives, interval lengths. | |
n_intpol | integer(kind=I4P) | in | Points made. | |
z | real(kind=R8P) | in | Level. |
Call graph
put_bspline
gnuplot's put_contour_bspline and gen_bspline_approx: the B-spline of order order (less than the points) through the points as control points, open or (closed) float knots, npoints points per section.
subroutine put_bspline(st, z, isclosed)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Line and chunks. | |
z | real(kind=R8P) | in | Level. | |
isclosed | logical | in | A closed line. |
Call graph
cubic_spline
gnuplot's gen_cubic_spline: the second derivatives d2x, d2y at the points and the interval lengths dt of the cubic spline through them (parameter the stroke length in grid units), right sides cut at cusps beyond 90 degrees; ok false if the system has no solution.
Attributes: pure
subroutine cubic_spline(n, qx, qy, d2x, d2y, dt, isclosed, unit_x, unit_y, ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
n | integer(kind=I4P) | in | Points (at least 3). | |
qx | real(kind=R8P) | in | Points. | |
qy | real(kind=R8P) | in | Points. | |
d2x | real(kind=R8P) | inout | Second derivatives, interval lengths (n + 1). | |
d2y | real(kind=R8P) | inout | Second derivatives, interval lengths (n + 1). | |
dt | real(kind=R8P) | inout | Second derivatives, interval lengths (n + 1). | |
isclosed | logical | in | A closed line (first point = last). | |
unit_x | real(kind=R8P) | in | Grid extent. | |
unit_y | real(kind=R8P) | in | Grid extent. | |
ok | logical | out | Solved. |
Call graph
cholesky
gnuplot's solve_cubic_1: the Cholesky decomposition of the cyclic tridiagonal matrix m (n >= 1).
Attributes: pure
subroutine cholesky(m, n, ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
m | real(kind=R8P) | inout | Matrix (3, row), decomposed. | |
n | integer(kind=I4P) | in | Size. | |
ok | logical | out | Positive definite. |
Call graph
cholesky_solve
gnuplot's solve_cubic_2: x overwritten by the solution of the decomposed system with right side x.
Attributes: pure
subroutine cholesky_solve(m, x, n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
m | real(kind=R8P) | in | Decomposed matrix. | |
x | real(kind=R8P) | inout | Right side, solution. | |
n | integer(kind=I4P) | in | Size. |
Call graph
bspline_point
gnuplot's eval_bspline (de Boor): the point at t of the B-spline blending the control points from first, knot index j.
Attributes: pure
subroutine bspline_point(t, qx, qy, first, n, order, j, isclosed, x, y)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
t | real(kind=R8P) | in | Parameter. | |
qx | real(kind=R8P) | in | Control points. | |
qy | real(kind=R8P) | in | Control points. | |
first | integer(kind=I4P) | in | First control point to blend. | |
n | integer(kind=I4P) | in | Control points. | |
order | integer(kind=I4P) | in | Order. | |
j | integer(kind=I4P) | in | Knot index. | |
isclosed | logical | in | Float knots. | |
x | real(kind=R8P) | out | Abscissa. | |
y | real(kind=R8P) | out | Ordinate. |
Call graph
Functions
quantize
gnuplot's quantize_normal_tics: a step about arg / guide (a round number).
Attributes: pure
Returns: real(kind=R8P)
function quantize(arg, guide) result(step)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
arg | real(kind=R8P) | in | Extent. | |
guide | integer(kind=I4P) | in | Steps wanted. |
Call graph
new_edge
gnuplot's add_edge to the main list: an edge of the vertices a, b if both are in range, else 0.
Returns: integer(kind=I4P)
function new_edge(st, a, b) result(e)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | inout | Triangulation. | |
a | integer(kind=I4P) | in | First vertex. | |
b | integer(kind=I4P) | in | Second vertex. |
Call graph
same_point
gnuplot's fuzzy_equal: two points within EPS of the grid extent.
Attributes: pure
Returns: logical
function same_point(st, ax, ay, bx, by) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
st | type(tracer) | in | Grid extent. | |
ax | real(kind=R8P) | in | The points. | |
ay | real(kind=R8P) | in | The points. | |
bx | real(kind=R8P) | in | The points. | |
by | real(kind=R8P) | in | The points. |
Call graph
knot_value
gnuplot's fetch_knot: knot i (from 0) of the uniform knot vector, open (the first and last order equal) or float (closed lines).
Attributes: pure
Returns: real(kind=R8P)
function knot_value(isclosed, n, order, i) result(t)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
isclosed | logical | in | Float knots. | |
n | integer(kind=I4P) | in | Control points. | |
order | integer(kind=I4P) | in | Order. | |
i | integer(kind=I4P) | in | Knot. |
Call graph