From f34b3ed9faf67fe95eefd9aa940a57757d44417d Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Tue, 13 Jul 2021 16:00:49 +0200
Subject: [PATCH] Remove MPI from program `test_overlap`

Than ks to commit 5ff9e1d, we are reverting in part commits e1aa5bc and
fda1e6c.
---
 Overlap/Tests/CMakeLists.txt   |  2 +-
 Overlap/Tests/short_tests.json | 47 +---------------------------------
 Overlap/Tests/test_overlap.f90 | 14 +---------
 3 files changed, 3 insertions(+), 60 deletions(-)

diff --git a/Overlap/Tests/CMakeLists.txt b/Overlap/Tests/CMakeLists.txt
index fce83707..1429684c 100644
--- a/Overlap/Tests/CMakeLists.txt
+++ b/Overlap/Tests/CMakeLists.txt
@@ -12,7 +12,7 @@ add_executable(test_overlap
   ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90 unit_edge_m.f90)
 
 target_link_libraries(test_overlap shapelib_03 geometry contour_531
-  gpc_f ezmpi nr_util jumble MPI::MPI_Fortran)
+  gpc_f nr_util jumble)
 
 target_include_directories(test_overlap PRIVATE ${fortrangis_INCLUDE_DIR})
 
diff --git a/Overlap/Tests/short_tests.json b/Overlap/Tests/short_tests.json
index 7fa846c3..4fb6fba7 100644
--- a/Overlap/Tests/short_tests.json
+++ b/Overlap/Tests/short_tests.json
@@ -63,10 +63,9 @@
 	"$src_dir/Overlap/Tests/Input/successive_overlap_in.txt",
         "description": "Overlap of a snapshot with itself.",
         "title": "Successive_overlap",
-        "stdout": "test_overlap_stdout.txt",
         "command":
         [
-          "$mpiexec", "-n", "1", "$build_dir/Overlap/test_overlap",
+          "$build_dir/Overlap/test_overlap",
           "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti_all_dates"
         ]
     },
@@ -75,12 +74,8 @@
 	"$src_dir/Overlap/Tests/Input/successive_overlap_in.txt",
         "description": "Same as Successive_overlap, but with larger domain: region 5 instead of region 4.",
         "title": "Successive_overlap_region_5_one_date",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$PWD/Inst_eddies_4_anti"
             ]
@@ -89,12 +84,8 @@
         "stdin_filename": "$src_dir/Overlap/Tests/Input/successive_overlap_periodic_in.txt",
         "description": "Overlap of a snapshot with itself. Global coarse grid.",
         "title": "Successive_overlap_periodic",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$tests_old_dir/Extraction_eddies_periodic/SHPC_cyclo"
             ]
@@ -104,12 +95,8 @@
 	"$src_dir/Overlap/Tests/Input/global_successive_overlap_in.txt",
         "description": "Overlap of different snapshots.",
         "title": "Successive_overlap_different_snapshots",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti_all_dates"
             ]
@@ -120,12 +107,8 @@
         "description":
 	"Overlap of different snapshots. Same as Successive_overlap_different_snapshots, but with a larger region. The identifying numbers of the connected eddies are not the same for all edges.",
         "title": "Successive_overlap_region_2",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti_all_dates"
             ]
@@ -135,12 +118,8 @@
 	"$src_dir/Overlap/Tests/Input/global_successive_overlap_in.txt",
         "description": "Same as Successive_overlap_region_2, but with a larger region. We get some merging and splitting.",
         "title": "Successive_overlap_region_5",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$PWD/Inst_eddies_4_anti"
             ]
@@ -150,12 +129,8 @@
 	"$src_dir/Overlap/Tests/Input/global_successive_overlap_in.txt",
         "description": "Global grid, normal 0.25° resolution.",
         "title": "Successive_overlap_global",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$PWD/Inst_eddies_5_anti"
             ]
@@ -164,12 +139,8 @@
         "stdin_filename": "$src_dir/Overlap/Tests/Input/non_successive_overlap_in.txt",
         "description": "Overlap of a snapshot with itself. Same as Successive_overlap, except for max_delta.",
         "title": "Non_successive_overlap",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti_all_dates"
             ]
@@ -179,12 +150,8 @@
         "description":
 	"Overlap of different snapshots. Same as Successive_overlap_different_snapshots, except for max_delta.",
         "title": "NSO_different_snapshots",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti_all_dates"
             ]
@@ -194,12 +161,8 @@
         "description":
 	"Same as Successive_overlap_region_5, except for max_delta.",
         "title": "NSO_region_5",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$PWD/Inst_eddies_4_anti"
             ]
@@ -209,12 +172,8 @@
         "description":
 	"Same as Successive_overlap_global, except for max_delta.",
         "title": "NSO_global",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$PWD/Inst_eddies_5_anti"
             ]
@@ -223,12 +182,8 @@
         "stdin_filename": "$src_dir/Overlap/Tests/Input/NSO_delta_in.txt",
         "description": "Test the logic of delta_in and delta_out. See documentation, figure 10 and comments on overlap.",
         "title": "NSO_delta",
-        "stdout": "test_overlap_stdout.txt",
         "command":
             [
-                "$mpiexec",
-                "-n",
-                "1",
                 "$build_dir/Overlap/test_overlap",
                 "$tests_old_dir/Region_6/SHPC_anti_all_dates"
             ]
diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90
index 960274cb..f20be0e6 100644
--- a/Overlap/Tests/test_overlap.f90
+++ b/Overlap/Tests/test_overlap.f90
@@ -4,8 +4,6 @@ program test_overlap
 
   ! Libraries:
   use jumble, only: get_command_arg_dyn, read_column, new_unit, ediff1d
-  use mpi_f08, only: mpi_init, mpi_finalize, MPI_Comm_rank, MPI_Comm_world, &
-       MPI_Comm_size, mpi_abort
   use nr_util, only: deg_to_rad, assert
   use shapelib_03, only: dbf_read_attribute_03
 
@@ -21,7 +19,7 @@ program test_overlap
   character(len = :), allocatable:: shpc_dir
   integer d_init
   integer:: k_test_1 = 0, k_test_2 = 1
-  integer unit, i, copy, rank, n_proc, n_dates
+  integer unit, i, copy, n_dates
   integer, allocatable:: ishape_last(:)
   type(snapshot), allocatable:: flow(:) ! (max_delta + 1)
   TYPE(shpc) hshp
@@ -46,15 +44,6 @@ program test_overlap
 
   !-------------------------------------------------------------------------
 
-  call mpi_init
-  call MPI_Comm_rank(MPI_Comm_world, rank)
-  call mpi_comm_size(mpi_comm_world, n_proc)
-
-  if (n_proc /= 1) then
-     if (rank == 0) print *, "test_overlap: 1 process only"
-     call mpi_abort(MPI_Comm_world, errorcode = 1)
-  end if
-
   call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory")
   call new_unit(unit)
   open(unit, file = shpc_dir // "/grid_nml.txt", status = "old", &
@@ -125,6 +114,5 @@ program test_overlap
   end do
 
   print *
-  call mpi_finalize
 
 end program test_overlap
-- 
GitLab