diff --git a/Tests/test_get_1_outerm.f b/Tests/test_get_1_outerm.f index 2e4fa17bd24a2f3a8ab263e3b2d1c64a047b1cba..5e07f5a245aa19a1d8686941ad56532fc3b4de13 100644 --- a/Tests/test_get_1_outerm.f +++ b/Tests/test_get_1_outerm.f @@ -3,8 +3,7 @@ program test_get_1_outerm use, intrinsic:: ISO_FORTRAN_ENV ! Libraries: - use contour_531, only: convert_to_reg_coord - use jumble, only: argwhere + use jumble, only: new_unit, count_lines use netcdf, only: nf90_nowrite use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, nf95_get_var, & nf95_gw_var @@ -18,12 +17,11 @@ program test_get_1_outerm implicit none - integer ncid, varid + integer ncid, varid, unit, n, l real longitude(2) ! in rad real latitude(2) ! in rad real step(2) ! in rad - real, allocatable:: ssh(:, :) ! sea-surface height, in m - integer, allocatable:: extr_map(:, :) ! map of extrema + real, allocatable:: ssh(:, :, :) ! (:, :, 1) sea-surface height, in m integer:: ind_targ_extr(2) = [19, 11] ! indices in the two dimensions of target extremum @@ -47,16 +45,6 @@ program test_get_1_outerm read(unit = *, nml = main_nml) write(unit = *, nml = main_nml) - ! No problem of degenerate time coordinate with "extr_map.nc" so - ! read it first: - print *, 'Reading from "extr_map.nc"...' - call nf95_open("extr_map.nc", nf90_nowrite, ncid) - - call nf95_inq_varid(ncid, "extr_map", varid) - call nf95_gw_var(ncid, varid, extr_map) - - call nf95_close(ncid) - print *, 'Reading from "h.nc"...' call nf95_open("h.nc", nf90_nowrite, ncid) @@ -69,21 +57,33 @@ program test_get_1_outerm latitude = latitude * deg_to_rad call nf95_inq_varid(ncid, "adt", varid) - ! Do not use nf95_gw_var so that the program also works with a - ! degenerate time coordinate: - allocate(ssh(size(extr_map, 1), size(extr_map, 2))) - call nf95_get_var(ncid, varid, ssh) - + call nf95_gw_var(ncid, varid, ssh) call nf95_close(ncid) step = [longitude(2) - longitude(1), latitude(2) - latitude(1)] - nearby_extr = convert_to_reg_coord(argwhere(extr_map > 0 .and. extr_map & - /= extr_map(ind_targ_extr(1), ind_targ_extr(2))), corner & - = [longitude(1), latitude(1)], step = step) + + print *, "Reading from nearby_extr.csv..." + call new_unit(unit) + open(unit, file = "nearby_extr.csv", status = "old", action = "read", & + position = "rewind") + call count_lines(unit, n) + n = n - 2 ! 2 title lines + allocate(nearby_extr(2, n)) + rewind(unit) + read(unit, fmt = *) + read(unit, fmt = *) + + do l = 1, n + read(unit, fmt = *) nearby_extr(:, l) + end do + + nearby_extr = nearby_extr * deg_to_rad + close(unit) + outermost_contour = get_1_outerm(cyclone, & coord_extr = [longitude(1), latitude(1)] + (ind_targ_extr - 1) * step, & innermost_level = innermost_level, nearby_extr = nearby_extr, & - ssh = ssh, corner = [longitude(1), latitude(1)], step = step) + ssh = ssh(:, :, 1), corner = [longitude(1), latitude(1)], step = step) if (outermost_contour%closed) then print *, "Radius of disk of equal area: ", & diff --git a/Tests/test_set_max_speed.f b/Tests/test_set_max_speed.f index 69f890bd16a08613e7a9b7baebcc97016089c6fd..951ef61ece9c8ea553d5e8745c1e02926aa5d4d9 100644 --- a/Tests/test_set_max_speed.f +++ b/Tests/test_set_max_speed.f @@ -8,7 +8,7 @@ program test_set_max_speed use netcdf, only: nf90_nowrite use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, nf95_get_var, & find_coord, nf95_inquire_dimension - use nr_util, only: pi + use nr_util, only: deg_to_rad, rad_to_deg use shapelib, only: shpt_polygon, shpfileobject, ftdouble, shpclose, & shpobject, dbfreadattribute use shapelib_03, only: shp_open_03, shp_create_03, dbf_add_field_03, & @@ -29,8 +29,6 @@ program test_set_max_speed ! indices of the target extremum, relative to corner real corner(2) - real, parameter:: deg_over_rad = pi / 180. - real, parameter:: rad_over_deg = 180. / pi TYPE(shpfileobject) hshp TYPE(shpobject) psobject integer ifield, ishape @@ -90,12 +88,12 @@ program test_set_max_speed e%out_cont%ssh = outermost_contour_ssh e%cyclone = cyclone e%ssh_extr = ssh_extremum - e%coord_extr = coord_extr * deg_over_rad + e%coord_extr = coord_extr * deg_to_rad e%out_cont%n_points = psobject%nvertices e%out_cont%closed = .true. allocate(e%out_cont%points(2, e%out_cont%n_points)) - e%out_cont%points(1, :) = psobject%padfx * deg_over_rad - e%out_cont%points(2, :) = psobject%padfy * deg_over_rad + e%out_cont%points(1, :) = psobject%padfx * deg_to_rad + e%out_cont%points(2, :) = psobject%padfy * deg_to_rad print *, "Reading from nearby_extr.csv..." call new_unit(unit) @@ -111,10 +109,12 @@ program test_set_max_speed do l = 1, n read(unit, fmt = *) nearby_extr(:, l) end do - + + nearby_extr = nearby_extr * deg_to_rad close(unit) + call set_max_speed(e, ind_targ_extr, nearby_extr, ssh, u, v, & - corner * deg_over_rad, step = [0.25, 0.25] * deg_over_rad) + corner * deg_to_rad, step = [0.25, 0.25] * deg_to_rad) call shp_create_03("test_set_max_speed", shpt_polygon, hshp) call dbf_add_field_03(ifield, hshp, 'ssh', ftdouble, nwidth = 13, & @@ -125,7 +125,7 @@ program test_set_max_speed ndecimals = 6) call shp_append_object_03(ishape, hshp, shpt_polygon, & - e%speed_cont%points * rad_over_deg) + e%speed_cont%points * rad_to_deg) call dbf_write_attribute_03(hshp, ishape, 0, e%speed_cont%ssh) call dbf_write_attribute_03(hshp, ishape, 1, e%speed_cont%area) call dbf_write_attribute_03(hshp, ishape, 2, e%max_speed) diff --git a/Tests/tests.json b/Tests/tests.json index 4fed17096d3f2b24d44f47237bcb395434c98e9a..9c6647da4cb676562db2658f756adb9dad7842e1 100644 --- a/Tests/tests.json +++ b/Tests/tests.json @@ -34,27 +34,38 @@ }, { "args" : "$compil_prod_dir/test_get_1_outerm", - "required": [["$input_dir/2006_01/h_region_1.nc", "h.nc"], - ["$tests_old_dir/Local_extrema/test_local_extrema.nc", "extr_map.nc"]], + "required": + [ + ["$input_dir/2006_01/h_region_1.nc", "h.nc"], + ["$input_dir/nearby_extr_get_1_outerm.csv", "nearby_extr.csv"] + ], "title" : "Get_1_outerm", "input" : "&main_nml /\n" }, { "args" : "$compil_prod_dir/test_get_1_outerm", - "required": [["$input_dir/2006_01/h_region_1.nc", "h.nc"], - ["$input_dir/extr_map_negative_2_8.nc", "extr_map.nc"]], + "required": + [ + ["$input_dir/2006_01/h_region_1.nc", "h.nc"], + "$input_dir/nearby_extr.csv" + ], "title" : "Get_1_outerm_noise_2_8", "input" : "&main_nml /\n", -"description": "Negative values for extrema 2 and 8." + "description": "Negative values for extrema 2 and 8." }, { "args" : "$compil_prod_dir/test_get_1_outerm", - "required": [["$input_dir/2006_01/h_region_1.nc", "h.nc"], - ["$input_dir/extr_map_negative_2.nc", "extr_map.nc"]], + "required": [ + ["$input_dir/2006_01/h_region_1.nc", "h.nc"], + [ + "$input_dir/nearby_extr_get_1_outerm_noise_2.csv", + "nearby_extr.csv" + ] + ], "title" : "Get_1_outerm_noise_2", "input" : "&main_nml /\n", - "description": "Negative value for extremum 2." - }, + "description": "Negative value for extremum 2." + }, { "args" : ["$compil_prod_dir/test_max_speed_contour_ssh", "$input_dir/2006_01/h_2006_01_01.nc", "$input_dir/2006_01/uv_2006_01_01.nc"],