From 86f22a35d4fb9f5e09a6063b5102e7ff7ca3aa5b Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Tue, 3 Oct 2017 16:47:21 +0200
Subject: [PATCH] Philippe 03/10/2017: set IP and NPROC in INIT_NMNH_COMM_WORLD
 + removed superfluous MPI initialisation in PREP_NEST_PGD

---
 src/LIB/SURCOUCHE/src/mode_init_ll.f90       |  4 ----
 src/LIB/SURCOUCHE/src/mode_mnh_world.f90     |  7 +++++--
 src/LIB/SURCOUCHE/src/mode_splittingz_ll.f90 |  5 -----
 src/MNH/prep_nest_pgd.f90                    | 10 ----------
 4 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/src/LIB/SURCOUCHE/src/mode_init_ll.f90 b/src/LIB/SURCOUCHE/src/mode_init_ll.f90
index 21ce3980f..1cc488308 100644
--- a/src/LIB/SURCOUCHE/src/mode_init_ll.f90
+++ b/src/LIB/SURCOUCHE/src/mode_init_ll.f90
@@ -556,10 +556,6 @@
            CALL INIT_NMNH_COMM_WORLD(KINFO_ll)
         END IF
         !
-        CALL MPI_COMM_RANK(NMNH_COMM_WORLD, IP, KINFO_ll)
-        !
-        CALL MPI_COMM_SIZE(NMNH_COMM_WORLD, NPROC, KINFO_ll)
-        !
         CALL MPI_COMM_DUP(NMNH_COMM_WORLD, NHALO_COM, KINFO_ll)
         !
         CALL MPI_COMM_DUP(NMNH_COMM_WORLD, NHALO2_COM, KINFO_ll)
diff --git a/src/LIB/SURCOUCHE/src/mode_mnh_world.f90 b/src/LIB/SURCOUCHE/src/mode_mnh_world.f90
index 5614c9799..11da8603c 100644
--- a/src/LIB/SURCOUCHE/src/mode_mnh_world.f90
+++ b/src/LIB/SURCOUCHE/src/mode_mnh_world.f90
@@ -22,7 +22,7 @@ CONTAINS
 #ifdef MNH_GA
     USE MODD_MPIF  , ONLY :  MPI_THREAD_MULTIPLE
 #endif
-    USE MODD_VAR_ll, ONLY : NMNH_COMM_WORLD
+    USE MODD_VAR_ll, ONLY : IP, NPROC, NMNH_COMM_WORLD
     !JUANZ
     IMPLICIT NONE
 
@@ -107,7 +107,10 @@ CONTAINS
        !
        !JUANZ create new/remapped communicator 
        !
-
+       CALL MPI_COMM_RANK(NMNH_COMM_WORLD, IP, KINFO_ll)
+       IP = IP + 1
+       !
+       CALL MPI_COMM_SIZE(NMNH_COMM_WORLD, NPROC, KINFO_ll)
        !
     END IF
 
diff --git a/src/LIB/SURCOUCHE/src/mode_splittingz_ll.f90 b/src/LIB/SURCOUCHE/src/mode_splittingz_ll.f90
index d01789808..c09b6fd31 100644
--- a/src/LIB/SURCOUCHE/src/mode_splittingz_ll.f90
+++ b/src/LIB/SURCOUCHE/src/mode_splittingz_ll.f90
@@ -180,9 +180,6 @@ CONTAINS
        CALL INIT_NMNH_COMM_WORLD(KINFO_ll)
     END IF
     !
-    CALL MPI_COMM_RANK(NMNH_COMM_WORLD, IP, KINFO_ll)
-    !
-    CALL MPI_COMM_SIZE(NMNH_COMM_WORLD, NPROC, KINFO_ll)
     !
     CALL MPI_COMM_DUP(NMNH_COMM_WORLD, NHALO_COM, KINFO_ll)
     !
@@ -192,8 +189,6 @@ CONTAINS
     !
     CALL MPI_COMM_DUP(NMNH_COMM_WORLD, NGRID_COM, KINFO_ll)
     !
-    IP = IP + 1
-    !
     MPI_PRECISION  = MNH_MPI_REAL
     MPI_2PRECISION = MNH_MPI_2REAL
     !
diff --git a/src/MNH/prep_nest_pgd.f90 b/src/MNH/prep_nest_pgd.f90
index 0db388877..523f7a555 100644
--- a/src/MNH/prep_nest_pgd.f90
+++ b/src/MNH/prep_nest_pgd.f90
@@ -203,16 +203,6 @@ CALL READ_ALL_NAMELISTS(YSURF_CUR,'MESONH','PRE',.FALSE.)
 !*       3.    READING OF THE GRIDS
 !              --------------------
 !
-! INITIALIZE MPI :
-IINFO_ll = 0
-CALL MPI_INITIALIZED(GISINIT, IINFO_ll)
-IF (.NOT. GISINIT) THEN
-  CALL INIT_NMNH_COMM_WORLD(IINFO_ll)
-END IF
-CALL MPI_COMM_RANK(NMNH_COMM_WORLD, IP, IINFO_ll)
-IP = IP+1
-CALL MPI_COMM_SIZE(NMNH_COMM_WORLD, NPROC, IINFO_ll)
-!
 CALL SET_DAD0_ll()
 DO JPGD=1,NMODEL
   ! read and set dimensions and ratios of model JPGD
-- 
GitLab