From 502d4b90b6b05aa596d58ba4e515a8b9fd4c4fba Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Thu, 1 Jul 2021 21:11:40 +0200
Subject: [PATCH] Write file `node_id_param.json`

Write file `node_id_param.json` from programs `test_overlap` and `eddy_graph`.
---
 Overlap/Tests/test_overlap.f90 | 5 +++++
 Overlap/eddy_graph.f90         | 8 ++++++++
 Overlap/eddy_graph_in.sh       | 3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90
index 0b58a13c..9108a494 100644
--- a/Overlap/Tests/test_overlap.f90
+++ b/Overlap/Tests/test_overlap.f90
@@ -82,6 +82,11 @@ program test_overlap
   e_overestim = maxval([ishape_last(1) + 1, ediff1d(ishape_last)])
   call shpc_open(hshp, trim(shpc_dir), rank = 0)
   call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0)
+  open(unit, file = "node_id_param.json", status = "replace", &
+       action = "write")
+  write(unit, fmt = *) '{"e_overestim": ', e_overestim, ', "d_init": ', &
+       d_init, '}'
+  close(unit)
   call read_snapshot(flow(1), hshp, nlon, nlat, d_init, k_test_1, corner, &
        step, copy, ishape_last)
   call read_snapshot(flow(max_delta + 1), hshp, nlon, nlat, d_init, k_test_2, &
diff --git a/Overlap/eddy_graph.f90 b/Overlap/eddy_graph.f90
index 4992b86e..7199c09a 100644
--- a/Overlap/eddy_graph.f90
+++ b/Overlap/eddy_graph.f90
@@ -121,6 +121,14 @@ program eddy_graph
        hshp%extr_date, ishape = 0)
   call ezmpi_bcast(d_init, root = 0)
 
+  if (rank == 0) then
+     open(unit, file = "node_id_param.json", status = "replace", &
+          action = "write")
+     write(unit, fmt = *) '{"e_overestim": ', e_overestim, ', "d_init": ', &
+          d_init, '}'
+     close(unit)
+  end if
+
   ! Open output files:
   
   call new_unit(unit_isolated)
diff --git a/Overlap/eddy_graph_in.sh b/Overlap/eddy_graph_in.sh
index 29bc2072..2ef3ec50 100755
--- a/Overlap/eddy_graph_in.sh
+++ b/Overlap/eddy_graph_in.sh
@@ -33,4 +33,5 @@ $(sort --key=1 --numeric-sort edgelist_no_header.csv)
 EOF
 rm edgelist_no_header.csv 
 
-echo "Created files \"edgelist.csv\" and \"isolated_nodes.txt\"."
+echo "Created files \"edgelist.csv\", \"isolated_nodes.txt\" and " \
+     "\"node_id_param.json\"."
-- 
GitLab