From c6f9247d83630ef54e0e90b24b51da1814aefc98 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 7 Jun 2023 09:20:29 +0200
Subject: [PATCH] Write to `speed.csv` instead of standard output

---
 Inst_eddies/set_max_speed.F90 | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/Inst_eddies/set_max_speed.F90 b/Inst_eddies/set_max_speed.F90
index eecb124a..5923c154 100644
--- a/Inst_eddies/set_max_speed.F90
+++ b/Inst_eddies/set_max_speed.F90
@@ -18,6 +18,9 @@ contains
     use, intrinsic:: IEEE_ARITHMETIC, only: IEEE_IS_NAN, ieee_value, &
          IEEE_QUIET_NAN
 
+    ! Libraries:
+    use jumble, only: new_unit
+
     use ccw_orient_m, only: ccw_orient
     use complete_ssh_m, only: complete_ssh
     use derived_types, only: eddy, null_ssh_contour, ssh_contour, missing_speed
@@ -63,7 +66,7 @@ contains
     ! Local:
 
     real, allocatable:: speed(:) ! (n_cont) speed on the contour
-    integer i, i_outer
+    integer i, i_outer, unit
 
     integer sort_ssh(size(cont_list)) ! (n_max_cont)
     ! Sorts cont_list%ssh in ascending order. Defined only for
@@ -95,9 +98,15 @@ contains
     end do
 
 #ifdef DEBUG
-    print *, "set_max_speed: speed(sort_ssh) = ", speed(sort_ssh(:n_cont))
-    print *, "set_max_speed: cont_list%ssh(sort_ssh) = ", &
-         cont_list(sort_ssh(:n_cont))%ssh
+    call new_unit(unit)
+    open(unit, file = "speed.csv", status = "replace", action = "write")
+    write(unit, fmt = *) "speed(sort_ssh) cont_list%ssh(sort_ssh)"
+
+    do i = 1, n_cont
+       write(unit, fmt = *) speed(sort_ssh(i)), cont_list(sort_ssh(i))%ssh
+    end do
+
+    close(unit)
 #endif
 
     i = maxloc(abs(speed), dim = 1, mask = .not. IEEE_IS_NAN(speed))
-- 
GitLab