Skip to content
Snippets Groups Projects
Commit 3ade06c1 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Remove unused procedures and programs

Remove unused procedures and programs `inside_4`,
`max_speed_contour_ssh`, `test_inside_4`,
`test_max_speed_contour_ssh`. Unused since commit 99e2e1b1.
parent 9373acb8
No related branches found
No related tags found
No related merge requests found
add_subdirectory(Tests)
target_sources(test_get_1_outerm PRIVATE derived_types.f90 get_slice_dir.f90
spher_polyline_area.f90 shpc_close.f90)
target_sources(test_max_speed_contour_ssh PRIVATE derived_types.f90)
target_sources(test_nearby_extr PRIVATE derived_types.f90
read_field_indices.f90 shpc_open.f90 shpc_close.f90
get_slice_dir.f90)
......
# inst_eddies:
add_executable(inst_eddies inst_eddies.f90 local_extrema.f90 set_max_speed.f90
get_1_outerm.f90 max_speed_contour_ssh.f90 good_contour.f90 mean_speed.f90
inside_4.f90 set_all_contours.f90 nearby_extr.f90 get_var.f90 config.f90
input_ssh.f90 shpc_create.f90 write_snapshot.f90 ccw_orient.f90
write_eddy.f90 set_all_extr.f90 complete_ssh.f90)
get_1_outerm.f90 good_contour.f90 mean_speed.f90 set_all_contours.f90
nearby_extr.f90 get_var.f90 config.f90 input_ssh.f90 shpc_create.f90
write_snapshot.f90 ccw_orient.f90 write_eddy.f90 set_all_extr.f90
complete_ssh.f90)
target_link_libraries(inst_eddies PRIVATE Contour_531::contour_531
Geometry::geometry NetCDF95::netcdf95 Shapelib_03::shapelib_03
Numer_Rec_95::numer_rec_95 Jumble::jumble NetCDF_Fortran::netcdff)
......@@ -22,14 +22,11 @@ target_sources(test_get_1_outerm PRIVATE get_1_outerm.f90 good_contour.f90
config.f90 input_ssh.f90 get_var.f90 shpc_create.f90 write_eddy.f90
ccw_orient.f90)
target_sources(test_good_contour PRIVATE good_contour.f90)
target_sources(test_inside_4 PRIVATE inside_4.f90)
target_sources(test_mean_speed PRIVATE mean_speed.f90)
target_sources(test_max_speed_contour_ssh PRIVATE max_speed_contour_ssh.f90
get_var.f90)
target_sources(test_nearby_extr PRIVATE nearby_extr.f90)
target_sources(test_local_extrema PRIVATE local_extrema.f90)
target_sources(test_set_max_speed PRIVATE set_max_speed.f90 good_contour.f90
max_speed_contour_ssh.f90 mean_speed.f90 inside_4.f90 get_var.f90 config.f90
input_ssh.f90 shpc_create.f90 ccw_orient.f90 write_eddy.f90 complete_ssh.f90)
mean_speed.f90 get_var.f90 config.f90 input_ssh.f90 shpc_create.f90
ccw_orient.f90 write_eddy.f90 complete_ssh.f90)
target_sources(test_write_null PRIVATE shpc_create.f90)
target_sources(test_complete_ssh PRIVATE complete_ssh.f90)
......@@ -10,24 +10,12 @@ target_link_libraries(test_good_contour PRIVATE Geometry::geometry
NetCDF95::netcdf95 Shapelib_03::shapelib_03 Contour_531::contour_531
Jumble::jumble NetCDF_Fortran::netcdff)
# test_inside_4
add_executable(test_inside_4 test_inside_4.f90)
target_link_libraries(test_inside_4 PRIVATE Geometry::geometry
Shapelib_03::shapelib_03 Jumble::jumble)
# test_mean_speed
add_executable(test_mean_speed test_mean_speed.f90)
target_link_libraries(test_mean_speed PRIVATE Numer_Rec_95::numer_rec_95
NetCDF95::netcdf95 Shapelib_03::shapelib_03 Contour_531::contour_531
NetCDF_Fortran::netcdff gpc_f Jumble::jumble)
# test_max_speed_contour_ssh
add_executable(test_max_speed_contour_ssh
test_max_speed_contour_ssh.f90)
target_link_libraries(test_max_speed_contour_ssh PRIVATE
fortrangis::fortranGIS NetCDF95::netcdf95 Contour_531::contour_531
Jumble::jumble NetCDF_Fortran::netcdff)
# test_nearby_extr
add_executable(test_nearby_extr test_nearby_extr.f90
${PROJECT_SOURCE_DIR}/Overlap/read_grid.F90
......@@ -54,9 +42,8 @@ target_link_libraries(test_set_max_speed PRIVATE Geometry::geometry
add_executable(test_complete_ssh test_complete_ssh.f90)
target_link_libraries(test_complete_ssh PRIVATE Jumble::jumble)
foreach(my_target IN ITEMS test_get_1_outerm test_good_contour test_inside_4
test_mean_speed test_max_speed_contour_ssh test_nearby_extr
test_local_extrema test_set_max_speed test_complete_ssh)
foreach(my_target IN ITEMS test_get_1_outerm test_good_contour test_mean_speed
test_nearby_extr test_local_extrema test_set_max_speed test_complete_ssh)
set_target_properties(${my_target} PROPERTIES Fortran_MODULE_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/${my_target}_modules)
target_include_directories(${my_target} PRIVATE
......
......@@ -114,20 +114,6 @@
],
"stdin_filename": "$src_dir/Inst_eddies/Tests/Input/no_good_contour.txt"
},
"Inside_4_true": {
"stdin_filename": "$src_dir/Inst_eddies/Tests/Input/inside_4_true_nml.txt",
"command": [
"$build_dir/Inst_eddies/Tests/test_inside_4",
"$src_dir/Inst_eddies/Tests/Input/outermost_eddy_5"
]
},
"Inside_4_false": {
"stdin_filename": "$src_dir/Inst_eddies/Tests/Input/inside_4_false_nml.txt",
"command": [
"$build_dir/Inst_eddies/Tests/test_inside_4",
"$src_dir/Inst_eddies/Tests/Input/outermost_eddy_5"
]
},
"Local_extrema": {
"input": "f",
"command": [
......@@ -167,32 +153,6 @@
"$src_dir/Inst_eddies/Tests/Input/h_2006_01_01_coarse.nc"
]
},
"Max_speed_contour_ssh": {
"input": "&main_nml /\n",
"command": [
"$build_dir/Inst_eddies/Tests/test_max_speed_contour_ssh",
"$src_dir/Inst_eddies/Tests/Input/Region_1/huv_region_1_2006_01_01.nc",
"$src_dir/Inst_eddies/Tests/Input/Region_1/huv_region_1_2006_01_01.nc"
]
},
"Max_speed_contour_ssh_north": {
"description": "direction = 2",
"input": "&main_nml IND_EXTR= 4,14/\n",
"command": [
"$build_dir/Inst_eddies/Tests/test_max_speed_contour_ssh",
"$src_dir/Inst_eddies/Tests/Input/Region_1/huv_region_1_2006_01_01.nc",
"$src_dir/Inst_eddies/Tests/Input/Region_1/huv_region_1_2006_01_01.nc"
]
},
"Max_speed_contour_ssh_missing": {
"description": "Missing value in speed.",
"input": "&main_nml IND_EXTR= 3, 4/\n",
"command": [
"$build_dir/Inst_eddies/Tests/test_max_speed_contour_ssh",
"$src_dir/Inst_eddies/Tests/Input/huv_2015_11_29.nc",
"$src_dir/Inst_eddies/Tests/Input/huv_2015_11_29.nc"
]
},
"Mean_speed": {
"input": "&main_nml /\n",
"symlink": [
......
program test_inside_4
use inside_4_m, only: inside_4
use jumble, only: get_command_arg_dyn
use shapelib, only: shpfileobject, shpclose, shpobject
use shapelib_03, only: shp_open_03, shp_read_object_03
implicit none
character(len = :), allocatable:: filename
real:: distance(2) = [1., 1.], center(2) = [0., 0.]
TYPE(shpfileobject) hshp
TYPE(shpobject) psobject
real, allocatable:: v(:, :) ! (2, :)
namelist /main_nml/ distance, center
!-----------------------------------------------------------------------
call get_command_arg_dyn(1, filename)
print *, "Reading from ", filename, "..."
call shp_open_03(hshp, filename, "rb")
call shp_read_object_03(hshp, 0, psobject)
CALL shpclose(hshp)
write(unit = *, nml = main_nml)
print *, "Enter namelist main_nml."
read(unit = *, nml = main_nml)
write(unit = *, nml = main_nml)
allocate(v(2, psobject%nvertices))
v(1, :) = psobject%padfx
v(2, :) = psobject%padfy
print *, "inside_4: ", inside_4(distance, center, v)
end program test_inside_4
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_gw_var
use jumble, only: assert
use get_var_m, only: get_var
use max_speed_contour_ssh_m, only: max_speed_contour_ssh
implicit none
integer nlon, nlat
character(len = :), allocatable:: adt_file, velocity_file
integer ncid, varid
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
integer:: radius = 3
namelist /main_nml/ ind_extr, radius
!----------------------------------------------------------------
call assert(COMMAND_ARGUMENT_COUNT() == 2, &
"Required arguments: ADT-file velocity-file")
call get_command_arg_dyn(1, adt_file)
call get_command_arg_dyn(2, velocity_file)
write(unit = error_unit, nml = main_nml)
write(unit = error_unit, fmt = *) "Enter namelist main_nml."
read(unit = *, nml = main_nml)
write(unit = *, nml = main_nml)
print *, "Reading from ", adt_file, "..."
call nf95_open(adt_file, nf90_nowrite, ncid)
call nf95_inq_varid(ncid, "adt", varid)
call nf95_gw_var(ncid, varid, ssh)
call nf95_close(ncid)
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 get_var(periodic = .false., max_rad_lon = 0, values = u, ncid = ncid, &
nlon = nlon, name = "ugos", &
new_fill_value = ieee_value(0., IEEE_QUIET_NAN))
call get_var(periodic = .false., max_rad_lon = 0, values = v, ncid = ncid, &
nlon = nlon, name = "vgos", &
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, &
radius)
end program test_max_speed_contour_ssh
module inside_4_m
implicit none
contains
logical function inside_4(distance, center, v)
! This procedure returns true if the four points center \pm
! (distance(1), 0) and center \pm (0, distance(2)) are inside
! the polygon v.
use geometry, only: polygon_contains_point
real, intent(in):: distance(:) ! (2)
real, intent(in):: center(:) ! (2) coordinates of the center point
real, intent(in):: v(:, :) ! (2, :) vertices of the polygon
! The last vertex should repeat the first vertex.
!-------------------------------------------------------------
! On the eastern way:
inside_4 = polygon_contains_point(v, [center(1) + distance(1), center(2)])
if (inside_4) then
! On the northern way:
inside_4 = polygon_contains_point(v, &
[center(1), center(2) + distance(2)])
if (inside_4) then
! On the western way:
inside_4 = polygon_contains_point(v, &
[center(1) - distance(1), center(2)])
if (inside_4) then
! On the southern way:
inside_4 = polygon_contains_point(v, &
[center(1), center(2) - distance(2)])
end if
end if
end if
end function inside_4
end module inside_4_m
module max_speed_contour_ssh_m
implicit none
contains
pure real function max_speed_contour_ssh(ssh, u, v, ind_extr, radius)
! Choose an SSH level by examining the values of velocities inside
! radius.
use, intrinsic:: IEEE_ARITHMETIC, only: IEEE_IS_NAN
use derived_types, only: missing_ssh
real, intent(in):: ssh(:, :), u(:, :), v(:, :)
integer, intent(in):: ind_extr(:) ! (2) indices of the extremum in ssh
integer, intent(in):: radius
! ind_extr + radius - 1 in all four directions is inside outermost
! contour, ind_extr + radius may be outside. radius should be >=
! 2.
! Local:
real v_azim(4, radius - 1)
! azimuthal velocity
! First dimension: direction, index 1 for east, 2 for north, etc.
! Second dimension: grid index, starting one point away from the extremum
integer l, direction
integer, parameter:: east = 1, north = 2, west = 3, south = 4
!----------------------------------------------------------------------
! Assuming that ascending indices in u and v correspond to
! ascending longitude and latitude:
v_azim(east, :) = v(ind_extr(1) + 1:ind_extr(1) + radius - 1, &
ind_extr(2))
v_azim(north, :) = - u(ind_extr(1), ind_extr(2) + 1:ind_extr(2) &
+ radius - 1)
v_azim(west, :) = - v(ind_extr(1) - 1:ind_extr(1) - radius + 1:- 1, &
ind_extr(2))
v_azim(south, :) = u(ind_extr(1), ind_extr(2) - 1:ind_extr(2) - radius &
+ 1:- 1)
if (any(ieee_is_nan(v_azim))) then
! This is strange, we are inside an outermost contour, and yet
! there is a missing value. Well, we will go on with the
! outermost contour as max-speed contour.
max_speed_contour_ssh = missing_ssh
else
if (radius >= 3) then
l = maxloc(abs(sum(v_azim, dim = 1) / 4.), dim = 1)
else
l = 1
end if
direction = maxloc(abs(v_azim(:, l)), dim = 1)
select case (direction)
case(east)
max_speed_contour_ssh = ssh(ind_extr(1) + l, ind_extr(2))
case(north)
max_speed_contour_ssh = ssh(ind_extr(1), ind_extr(2) + l)
case(west)
max_speed_contour_ssh = ssh(ind_extr(1) - l, ind_extr(2))
case(south)
max_speed_contour_ssh = ssh(ind_extr(1), ind_extr(2) - l)
end select
end if
end function max_speed_contour_ssh
end module max_speed_contour_ssh_m
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment