diff --git a/Inst_eddies/Tests/CMakeLists.txt b/Inst_eddies/Tests/CMakeLists.txt
index 734af5e1911bcf3003a83a1cfcba2fe3aa90a434..1f29807ab145dad8b766b3f0518062c964da817d 100644
--- a/Inst_eddies/Tests/CMakeLists.txt
+++ b/Inst_eddies/Tests/CMakeLists.txt
@@ -32,7 +32,7 @@ target_link_libraries(test_local_extrema PRIVATE NetCDF95::netcdf95
 
 # test_set_max_speed
 add_executable(test_set_max_speed test_set_max_speed.f90
-  ${PROJECT_SOURCE_DIR}/Overlap/read_eddy.f90)
+  ${PROJECT_SOURCE_DIR}/Overlap/read_eddy.f90 cont_list.f90)
 target_link_libraries(test_set_max_speed PRIVATE Geometry::geometry
   Numer_Rec_95::numer_rec_95 NetCDF95::netcdf95
   Shapelib_03::shapelib_03 Contour_531::contour_531 Jumble::jumble
diff --git a/Inst_eddies/set_contours.f90 b/Inst_eddies/set_contours.f90
index 1b59ab3e3e7776b05ee0bb479493a7cc2c701fca..9151936c8ec26f2b691d3eda267d140b0bacd7f3 100644
--- a/Inst_eddies/set_contours.f90
+++ b/Inst_eddies/set_contours.f90
@@ -11,12 +11,8 @@ contains
 
     ! Libraries:
     use contour_531, only: convert_to_ind
-    use jumble, only: rad_to_deg
-    use shapelib, only: shpt_polygon
-    use shapelib_03, only: shp_append_object_03, dbf_write_attribute_03
 
     use config_m, only: min_amp
-    use cont_list_m, only: write_cont_list, hshp_cont_list
     use derived_types, only: extremum, ssh_contour
     use get_1_outerm_m, only: get_1_outerm
     use set_max_speed_m, only: set_max_speed
@@ -80,8 +76,6 @@ contains
     ! number of good contours found and stored in cont_list, 0 <=
     ! n_cont <= n_max_cont
 
-    integer i, ishape
-
     !--------------------------------------------------------------
 
     ! Only look for good contours with amplitudes >= min_amp:
@@ -115,15 +109,6 @@ contains
             v(llc(1):urc(1), llc(2):urc(2)), corner_window, step)
     end if
 
-    if (write_cont_list) then
-       do i = 1, n_cont
-          call shp_append_object_03(ishape, hshp_cont_list, shpt_polygon, &
-               cont_list(i)%points * rad_to_deg)
-          call dbf_write_attribute_03(hshp_cont_list, ishape, ifield = 0, &
-               fieldvalue = cont_list(i)%ssh)
-       end do
-    end if
-
   end subroutine set_contours
 
 end module set_contours_m
diff --git a/Inst_eddies/set_max_speed.F90 b/Inst_eddies/set_max_speed.F90
index 5923c1541c656fd015235e37375eda9ffbff10f4..53afe9f3e0e3d4f06e6ae5a96cdee99d3309a3ce 100644
--- a/Inst_eddies/set_max_speed.F90
+++ b/Inst_eddies/set_max_speed.F90
@@ -19,7 +19,9 @@ contains
          IEEE_QUIET_NAN
 
     ! Libraries:
-    use jumble, only: new_unit
+    use jumble, only: new_unit, rad_to_deg
+    use shapelib, only: shpt_polygon
+    use shapelib_03, only: shp_append_object_03, dbf_write_attribute_03
 
     use ccw_orient_m, only: ccw_orient
     use complete_ssh_m, only: complete_ssh
@@ -27,6 +29,7 @@ contains
     use good_contour_m, only: good_contour
     use mean_speed_m, only: mean_speed
     use spher_polyline_area_m, only: spher_polyline_area
+    use cont_list_m, only: write_cont_list, hshp_cont_list
 
     type(ssh_contour), intent(out):: speed_cont
 
@@ -66,7 +69,7 @@ contains
     ! Local:
 
     real, allocatable:: speed(:) ! (n_cont) speed on the contour
-    integer i, i_outer, unit
+    integer i, i_outer, unit, ishape
 
     integer sort_ssh(size(cont_list)) ! (n_max_cont)
     ! Sorts cont_list%ssh in ascending order. Defined only for
@@ -107,6 +110,15 @@ contains
     end do
 
     close(unit)
+
+    if (write_cont_list) then
+       do i = 1, n_cont
+          call shp_append_object_03(ishape, hshp_cont_list, shpt_polygon, &
+               cont_list(i)%points * rad_to_deg)
+          call dbf_write_attribute_03(hshp_cont_list, ishape, ifield = 0, &
+               fieldvalue = cont_list(i)%ssh)
+       end do
+    end if
 #endif
 
     i = maxloc(abs(speed), dim = 1, mask = .not. IEEE_IS_NAN(speed))