From 17842ecbf7b5b6a061c394da8b458ea4bf0bffcb Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Fri, 9 Jun 2023 15:22:09 +0200 Subject: [PATCH] Use `cont_list_m` It is a little simpler to use `cont_list_m` and we then have the speed in `cont_list.dbf`. The pre-existing `cont_list` shapefile is now open for read access only. --- Inst_eddies/Tests/test_set_max_speed.f90 | 28 +++++++++--------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/Inst_eddies/Tests/test_set_max_speed.f90 b/Inst_eddies/Tests/test_set_max_speed.f90 index 38d9fc02..ab8ee7d5 100644 --- a/Inst_eddies/Tests/test_set_max_speed.f90 +++ b/Inst_eddies/Tests/test_set_max_speed.f90 @@ -3,12 +3,12 @@ program test_set_max_speed ! Libraries: use contour_531, only: convert_to_ind, null_polyline use gpc_f, only: shp_read_pol, polygon - use jumble, only: get_command_arg_dyn, assert, deg_to_rad, rad_to_deg - use shapelib, only: shpfileobject, shpclose, shpt_polygon - use shapelib_03, only: shp_open_03, shp_get_info_03, dbf_read_attribute_03, & - dbf_write_attribute_03, shp_append_object_03 + use jumble, only: get_command_arg_dyn, assert, deg_to_rad + use shapelib, only: shpfileobject, shpclose + use shapelib_03, only: shp_open_03, shp_get_info_03, dbf_read_attribute_03 use config_m, only: config + use cont_list_m, only: create_cont_list, close_cont_list use derived_types, only: eddy, shpc_slice_handler, ssh_contour use input_ssh_m, only: input_ssh use read_eddy_m, only: read_eddy @@ -22,7 +22,7 @@ program test_set_max_speed logical cyclone logical periodic ! grid is periodic in longitude - integer nlon, nlat, d, eddy_index, n_cont, i, ishape, i_outer + integer nlon, nlat, d, eddy_index, n_cont, i, ishape real, allocatable:: ssh(:, :) ! (nlon, nlat) sea-surface height, in m real, allocatable:: u(:, :), v(:, :) ! (nlon, nlat) wind, in m s-1 type(eddy) e @@ -79,7 +79,7 @@ program test_set_max_speed ! Define cont_list: - call shp_open_03(hshp, "cont_list", "rb+") + call shp_open_03(hshp, "cont_list", "rb") call shp_get_info_03(hshp, n_cont) call assert(1 <= n_cont, n_cont <= n_max_cont - 1, & "test_set_max_speed n_cont") @@ -100,27 +100,19 @@ program test_set_max_speed ishape = ishape) end do - i_outer = n_cont - + call shpclose(hshp) + call create_cont_list call set_max_speed(e%speed_cont, e%max_speed, cont_list, n_cont, & e%extr%coord, ssh(llc(1):urc(1), llc(2):urc(2)), & u(llc(1):urc(1), llc(2):urc(2)), v(llc(1):urc(1), llc(2):urc(2)), & corner_window, step) - - do i = i_outer + 1, n_cont - call shp_append_object_03(ishape, hshp, shpt_polygon, & - cont_list(i)%points * rad_to_deg) - call dbf_write_attribute_03(hshp, ishape, ifield = 0, & - fieldvalue = cont_list(i)%ssh) - end do - - call shpclose(hshp) + call close_cont_list call shpc_create(hshpc, shpc_dir = "SHPC", cyclone = cyclone, slice = 0, & grid_lon_lat = .true.) call write_eddy(e, hshpc, d, eddy_index) write(hshpc%unit, fmt = *) 0 CALL shpc_close(hshpc) - print *, 'test_set_max_speed: Created "SHPC", modified "cont_list".' + print *, 'test_set_max_speed: Created "SHPC" and "cont_list".' else print *, "No outermost contour found." end if -- GitLab