From e02bd168166c666ceb0854ff0a33f39188d92162 Mon Sep 17 00:00:00 2001
From: Antoine <antoine.hoffmann@epfl.ch>
Date: Fri, 11 Aug 2023 10:12:19 +0200
Subject: [PATCH] write MPI procs dist. in the output file

---
 src/diagnose.F90     |  2 ++
 src/parallel_mod.F90 | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/diagnose.F90 b/src/diagnose.F90
index 1f77b3e2..327ad696 100644
--- a/src/diagnose.F90
+++ b/src/diagnose.F90
@@ -47,6 +47,7 @@ SUBROUTINE init_outfile(comm,file0,file,fid)
   USE collision,       ONLY: coll_outputinputs
   USE initial_par,     ONLY: initial_outputinputs
   USE time_integration,ONLY: time_integration_outputinputs
+  USE parallel,        ONLY: parallel_outputinputs
   USE futils,          ONLY: creatf, creatg, creatd, attach, putfile
   IMPLICIT NONE
   !input
@@ -89,6 +90,7 @@ SUBROUTINE init_outfile(comm,file0,file,fid)
   CALL             coll_outputinputs(fid)
   CALL          initial_outputinputs(fid)
   CALL time_integration_outputinputs(fid)
+  CALL         parallel_outputinputs(fid)
   !  Save STDIN (input file) of this run
   IF(jobnum .LE. 99) THEN
      WRITE(str,'(a,i2.2)') "/files/STDIN.",jobnum
diff --git a/src/parallel_mod.F90 b/src/parallel_mod.F90
index 2d409441..5f7e921d 100644
--- a/src/parallel_mod.F90
+++ b/src/parallel_mod.F90
@@ -37,7 +37,8 @@ MODULE parallel
   INTEGER, DIMENSION(:), ALLOCATABLE :: rcv_zyp, dsp_zyp
 
   PUBLIC :: ppinit, manual_0D_bcast, manual_3D_bcast, init_parallel_var, &
-            gather_xyz, gather_xyz_real, gather_pjz, gather_pjxyz, exchange_ghosts_1D
+            gather_xyz, gather_xyz_real, gather_pjz, gather_pjxyz, exchange_ghosts_1D, &
+            parallel_outputinputs
 
 CONTAINS
 
@@ -463,4 +464,19 @@ CONTAINS
     ENDDO
   END SUBROUTINE exchange_ghosts_1D
 
+
+  SUBROUTINE parallel_outputinputs(fid)
+    ! Write the input parameters to the results_xx.h5 file
+    USE futils, ONLY: attach, creatd
+    IMPLICIT NONE
+    INTEGER, INTENT(in) :: fid
+    CHARACTER(len=256)  :: str
+    WRITE(str,'(a)') '/data/input/parallel'
+    CALL creatd(fid, 0,(/0/),TRIM(str),'MPI parallelization')
+    CALL attach(fid, TRIM(str),    "num_procs",    num_procs)
+    CALL attach(fid, TRIM(str),  "num_procs_p",  num_procs_p)
+    CALL attach(fid, TRIM(str), "num_procs_ky", num_procs_ky)
+    CALL attach(fid, TRIM(str),  "num_procs_z",  num_procs_z)
+  END SUBROUTINE parallel_outputinputs
+
 END MODULE parallel
-- 
GitLab