From b947127c1d91e8b596d74b25f67bb618d3cf3be5 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 12 Apr 2018 13:49:00 +0200 Subject: [PATCH] Add test for procedure spherical_polyline_area. --- GNUmakefile | 5 +++-- Tests/test_spherical_polyline_area.f | 22 ++++++++++++++++++++++ Tests/tests.json | 6 +++++- depend.mk | 1 + spherical_polyline_area.f | 4 ++-- 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 Tests/test_spherical_polyline_area.f diff --git a/GNUmakefile b/GNUmakefile index 0d3d75ac..425e7f46 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 00000000..b77e28eb --- /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 84ac3d1a..8de24f86 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 f0d4f726..54428c2a 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 1c05d6dd..59b96370 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 -- GitLab