Skip to content
Snippets Groups Projects
Commit 9eb1c01d authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

In program test_spherical_polygon_area, read a shapefile instead of

specifying polygon in source code.
parent 36b0c18c
No related branches found
No related tags found
No related merge requests found
program test_spherical_polygon_area
use contour_531, only: polyline
use gpc_f, only: polygon
use nr_util, only: pi
use gpc_f, only: polygon, shpobj2pol
use jumble, only: get_command_arg_dyn
use nr_util, only: pi, assert
use shapelib, only: shpfileobject, shpobject, shpclose, shpdestroyobject
use shapelib_03, only: shp_open_03, shp_read_object_03
use spherical_polygon_area_m, only: spherical_polygon_area
implicit none
real points(2, 4)
character(len = :), allocatable:: filename
TYPE(shpfileobject) hshp
TYPE(shpobject) psobject
type(POLYGON) p
real, parameter:: deg2rad = pi / 180.
integer i
!---------------------------------------------------------------------
points(:, 1) = [0., 0.]
points(:, 2) = [30. * deg2rad, 0.]
points(:, 3) = [0., 30. * deg2rad]
points(:, 4) = points(:, 1)
call get_command_arg_dyn(1, filename, "Required argument: shapefile")
call shp_open_03(filename, "rb", hshp)
call shp_read_object_03(hshp, 0, psobject)
call shpclose(hshp)
call assert(psobject%nparts >= 1, "psobject%nparts >= 1")
call assert(psobject%panpartstart(1) == 0, "psobject%panpartstart(1)")
p = shpobj2pol(psobject)
call shpdestroyobject(psobject)
print *, "Area = ", spherical_polygon_area(polygon(nparts = 1, &
part = [polyline(n_points = 4, closed = .true., points = points)], &
hole = [.false.])) / 1e6, "km2"
forall (i = 1:p%nparts) p%part(i)%points = p%part(i)%points * deg2rad
print *, "Area = ", spherical_polygon_area(p) / 1e6, "km2"
end program test_spherical_polygon_area
......@@ -146,12 +146,14 @@
"input": "1e-3\n"
},
{
"args": ["$compil_prod_dir/test_inside_4", "$input_dir/outermost_eddy_5"],
"args": ["$compil_prod_dir/test_inside_4",
"$input_dir/outermost_eddy_5"],
"title": "Inside_4_true",
"stdin": "$stdin_dir/inside_4_true_nml.txt"
},
{
"args": ["$compil_prod_dir/test_inside_4", "$input_dir/outermost_eddy_5"],
"args": ["$compil_prod_dir/test_inside_4",
"$input_dir/outermost_eddy_5"],
"title": "Inside_4_false",
"stdin": "$stdin_dir/inside_4_false_nml.txt"
},
......@@ -193,7 +195,8 @@
"title": "Spherical_polyline_area"
},
{
"args": "$compil_prod_dir/test_spherical_polygon_area",
"args": ["$compil_prod_dir/test_spherical_polygon_area",
"$input_dir/triangle"],
"title": "Spherical_polygon_area"
}
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment