diff --git a/GNUmakefile b/GNUmakefile index 1281706f821c7ad1b11cc4e39035a4e23dd2a1df..2695582252829cd160ad43152ee5a818fcf81883 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -29,7 +29,9 @@ src_test_successive_overlap = test_successive_overlap.f derived_types.f successi src_test_nearby_extr = test_nearby_extr.f nearby_extr.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} ${src_test_spherical_polygon_area} ${src_test_read_eddy} ${src_test_read_snapshot} ${src_test_successive_overlap} ${src_test_nearby_extr}) test_good_contour.f test_inside_4.f test_max_speed_contour_ssh.f test_mean_speed.f test_spherical_polyline_area.f +src_test_max_speed_contour_ssh = test_max_speed_contour_ssh.f max_speed_contour_ssh.f get_var.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} ${src_test_spherical_polygon_area} ${src_test_read_eddy} ${src_test_read_snapshot} ${src_test_successive_overlap} ${src_test_nearby_extr} ${src_test_max_speed_contour_ssh}) test_good_contour.f test_inside_4.f test_mean_speed.f test_spherical_polyline_area.f lib_list = GPC_F contour_531 numer_rec_95 GPC shapelib_03 netcdf95 geometry jumble netcdff fortrangis shp fortranc nr_util @@ -46,6 +48,7 @@ obj_test_read_eddy := $(src_test_read_eddy:.f=.o) obj_test_read_snapshot := $(src_test_read_snapshot:.f=.o) obj_test_successive_overlap := $(src_test_successive_overlap:.f=.o) obj_test_nearby_extr := $(src_test_nearby_extr:.f=.o) +obj_test_max_speed_contour_ssh := $(src_test_max_speed_contour_ssh:.f=.o) objects := $(sources:.f=.o) @@ -63,7 +66,7 @@ endif all: ${execut} log test_get_1_outerm: ${obj_test_get_1_outerm} test_set_max_speed: ${obj_test_set_max_speed} -test_max_speed_contour_ssh: max_speed_contour_ssh.o +test_max_speed_contour_ssh: ${obj_test_max_speed_contour_ssh} test_good_contour: good_contour.o test_inside_4: inside_4.o test_local_extrema: ${obj_test_local_extrema} diff --git a/Tests/test_max_speed_contour_ssh.f b/Tests/test_max_speed_contour_ssh.f index 1192b0707d90c789e34c2d35b37a3fbfe6342afe..08ade81c94a5775a36182569ca8f398ea3d86662 100644 --- a/Tests/test_max_speed_contour_ssh.f +++ b/Tests/test_max_speed_contour_ssh.f @@ -1,24 +1,25 @@ program test_max_speed_contour_ssh + use, intrinsic:: ieee_arithmetic, only: ieee_value, IEEE_QUIET_NAN use, intrinsic:: ISO_FORTRAN_ENV ! Libraries: use jumble, only: get_command_arg_dyn use netcdf, only: nf90_nowrite - use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, nf95_get_var, & - nf95_gw_var + use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, nf95_gw_var use nr_util, only: assert + use get_var_m, only: get_var use max_speed_contour_ssh_m, only: max_speed_contour_ssh implicit none - integer n_lon, n_lat + integer nlon, nlat character(len = :), allocatable:: adt_file, velocity_file integer ncid, varid - real, allocatable:: ssh(:, :, :) ! (n_lon, n_lat, 1) sea-surface height, in m - real, allocatable:: u(:, :), v(:, :) ! (n_lon, n_lat) wind, in m s-1 + real, allocatable:: ssh(:, :, :) ! (nlon, nlat, 1) sea-surface height, in m + real, allocatable:: u(:, :), v(:, :) ! (nlon, nlat) wind, in m s-1 integer:: ind_extr(2) = [19, 11] ! indices in the two dimensions of the extremum @@ -46,19 +47,18 @@ program test_max_speed_contour_ssh call nf95_gw_var(ncid, varid, ssh) call nf95_close(ncid) - n_lon = size(ssh, 1) - n_lat = size(ssh, 2) - allocate(u(n_lon, n_lat), v(n_lon, n_lat)) + nlon = size(ssh, 1) + nlat = size(ssh, 2) + allocate(u(nlon, nlat), v(nlon, nlat)) print *, "Reading from ", velocity_file, "..." call nf95_open(velocity_file, nf90_nowrite, ncid) - - call nf95_inq_varid(ncid, "u", varid) - call nf95_get_var(ncid, varid, u) - - call nf95_inq_varid(ncid, "v", varid) - call nf95_get_var(ncid, varid, v) - + call get_var(periodic = .false., max_rad_lon = 0, values = u, ncid = ncid, & + nlon = nlon, k = 1, name = "u", & + new_fill_value = ieee_value(0., IEEE_QUIET_NAN)) + call get_var(periodic = .false., max_rad_lon = 0, values = v, ncid = ncid, & + nlon = nlon, k = 1, name = "v", & + new_fill_value = ieee_value(0., IEEE_QUIET_NAN)) call nf95_close(ncid) print *, "level = ", max_speed_contour_ssh(ssh(:, :, 1), u, v, ind_extr, & diff --git a/depend.mk b/depend.mk index f8a9e17951d32e48e03ec1e589d9d0f8d1a6b385..7f2e4508751dd67b48279793d091a1472081a3e9 100644 --- a/depend.mk +++ b/depend.mk @@ -13,6 +13,7 @@ successive_overlap.o : weight.o spherical_polyline_area.o spherical_polygon_area test_get_1_outerm.o : get_1_outerm.o derived_types.o test_get_snapshot.o : init_shapefiles.o get_snapshot.o dispatch_snapshot.o derived_types.o test_local_extrema.o : local_extrema.o +test_max_speed_contour_ssh.o : max_speed_contour_ssh.o get_var.o test_nearby_extr.o : nearby_extr.o derived_types.o test_read_eddy.o : write_eddy.o read_field_indices.o read_eddy.o init_shapefiles.o derived_types.o test_read_snapshot.o : read_snapshot.o init_shapefiles.o dispatch_snapshot.o derived_types.o @@ -25,6 +26,5 @@ weight.o : derived_types.o write_eddy.o : init_shapefiles.o derived_types.o 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/get_var.f b/get_var.f index 9b578ddd77ca86d34e824a11be29371890f855cb..67fe23823ca0dc1e2791eb137206a5c38eea08b5 100644 --- a/get_var.f +++ b/get_var.f @@ -19,8 +19,10 @@ contains ! longitude, in number of grid points, used only if periodic real, intent(out):: values(1 - merge(max_rad_lon, 0, periodic):, :) - ! (1 - merge(max_rad_lon, 0, periodic):nlon + merge(max_rad_lon, 0, - ! periodic), nlat) ssh, u or v + ! (1 - merge(max_rad_lon, 0, periodic):nlon + merge(max_rad_lon, + ! 0, periodic), nlat) ssh, u or v. We cannot place this argument + ! first because the declaration references max_rad_lon and + ! periodic. integer, intent(in):: ncid, nlon integer, intent(in):: k ! date index diff --git a/max_speed_contour_ssh.f b/max_speed_contour_ssh.f index 6e7f6ee89eb0e396c3310b0e7cdf136e8a82fb29..5ca6241c4b1f2537069a520c6c30b324f5b8fc61 100644 --- a/max_speed_contour_ssh.f +++ b/max_speed_contour_ssh.f @@ -11,6 +11,7 @@ contains use, intrinsic:: IEEE_ARITHMETIC, only: IEEE_IS_NAN + ! Library: use nr_util, only: assert real, intent(in):: ssh(:, :), u(:, :), v(:, :)