diff --git a/GNUmakefile b/GNUmakefile index 0d3d75ac6fa56e5322098915b3f3eaec4c0669b3..425e7f469de8d98c645b14dd9b54ce11377ffb97 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -17,7 +17,7 @@ src_test_set_all_outerm = test_set_all_outerm.f derived_types.f set_all_outerm.f src_test_weight = test_weight.f weight.f derived_types.f -sources := $(sort ${src_test_local_extrema} ${src_test_get_1_outerm} ${src_test_set_max_speed} ${src_test_get_snapshot} ${src_test_set_all_outerm} ${src_test_weight}) test_good_contour.f test_inside_4.f test_max_speed_contour_ssh.f test_mean_speed.f +sources := $(sort ${src_test_local_extrema} ${src_test_get_1_outerm} ${src_test_set_max_speed} ${src_test_get_snapshot} ${src_test_set_all_outerm} ${src_test_weight}) test_good_contour.f test_inside_4.f test_max_speed_contour_ssh.f test_mean_speed.f test_spherical_polyline_area.f lib_list = contour_531 numer_rec_95 shapelib_03 netcdf95 geometry jumble netcdff fortrangis shp fortranc nr_util @@ -31,7 +31,7 @@ obj_test_set_all_outerm := $(src_test_set_all_outerm:.f=.o) obj_test_weight := $(src_test_weight:.f=.o) objects := $(sources:.f=.o) -execut = test_good_contour test_inside_4 test_get_1_outerm test_local_extrema test_max_speed_contour_ssh test_mean_speed test_set_max_speed test_get_snapshot test_set_all_outerm test_weight +execut = test_good_contour test_inside_4 test_get_1_outerm test_local_extrema test_max_speed_contour_ssh test_mean_speed test_set_max_speed test_get_snapshot test_set_all_outerm test_weight test_spherical_polyline_area # 3. Compiler-dependent part @@ -70,6 +70,7 @@ test_mean_speed: mean_speed.o test_get_snapshot: ${obj_test_get_snapshot} test_set_all_outerm: ${obj_test_set_all_outerm} test_weight: ${obj_test_weight} +test_spherical_polyline_area: spherical_polyline_area.o depend ${makefile_dir}/depend.mk: makedepf90 -free -Wmissing -Wconfused $(addprefix -I, ${VPATH}) -nosrc $(addprefix -u , ${lib_list} shapelib netcdf intrinsic) ${sources} >${makefile_dir}/depend.mk diff --git a/Tests/test_spherical_polyline_area.f b/Tests/test_spherical_polyline_area.f new file mode 100644 index 0000000000000000000000000000000000000000..b77e28eb36fa8776e0ff5515adb10e185b49537c --- /dev/null +++ b/Tests/test_spherical_polyline_area.f @@ -0,0 +1,22 @@ +program test_spherical_polyline_area + + use contour_531, only: polyline + use nr_util, only: pi + use spherical_polyline_area_m, only: spherical_polyline_area + + implicit none + + real points(2, 4) + real, parameter:: deg2rad = pi / 180. + + !------------------------------------------------------------------------- + + points(:, 1) = [0., 0.] + points(:, 2) = [30. * deg2rad, 0.] + points(:, 3) = [0., 30. * deg2rad] + points(:, 4) = points(:, 1) + + print *, "Area = ", spherical_polyline_area(polyline(n_points = 4, & + closed = .true., points = points)) / 1e6, "km2" + +end program test_spherical_polyline_area diff --git a/Tests/tests.json b/Tests/tests.json index 84ac3d1a6a275b8ab3ea14c16cfba71c6f735cf4..8de24f86895d43e63d6163069aba0718d284d75f 100644 --- a/Tests/tests.json +++ b/Tests/tests.json @@ -187,5 +187,9 @@ "input": "1e-3\n", "description": "Same as Get_snapshot_region_4 with larger domain." }, - {"args": "$compil_prod_dir/test_weight", "title": "Weight"} + {"args": "$compil_prod_dir/test_weight", "title": "Weight"}, + { + "args": "$compil_prod_dir/test_spherical_polyline_area", + "title": "Spherical_polyline_area" + } ] diff --git a/depend.mk b/depend.mk index f0d4f7268e3a3a0518ab9b26baea2247f661afff..54428c2a0b807f71e73f0f6ec0668a6072a27295 100644 --- a/depend.mk +++ b/depend.mk @@ -17,3 +17,4 @@ test_good_contour.o : good_contour.o test_inside_4.o : inside_4.o test_max_speed_contour_ssh.o : max_speed_contour_ssh.o test_mean_speed.o : mean_speed.o +test_spherical_polyline_area.o : spherical_polyline_area.o diff --git a/spherical_polyline_area.f b/spherical_polyline_area.f index 1c05d6ddc931d6622c0484725c3c5edd1b9d491f..59b96370dd6d9142a011ee1b97074017a4678b0c 100644 --- a/spherical_polyline_area.f +++ b/spherical_polyline_area.f @@ -6,8 +6,8 @@ contains pure real function spherical_polyline_area(p) - ! Assuming p is a polyline in longitude, latitude, in - ! rad. Computing the area of a polyline in longitude, sin(latitude) + ! Assuming p is a polyline in longitude, latitude, in rad, compute + ! the area (positive) of a polyline in longitude, sin(latitude) ! with the same vertices. Result in m2. use contour_531, only: polyline