Index: LMDZ6/trunk/libf/dyn3dmem/abort_gcm.F
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/abort_gcm.F	(revision 4593)
+++ LMDZ6/trunk/libf/dyn3dmem/abort_gcm.F	(revision 4600)
@@ -47,11 +47,13 @@
       else
         write(lunout,*) 'Houston, we have a problem, ierr = ', ierr
-#ifdef CPP_MPI
+
+        if (using_mpi) THEN
 C$OMP CRITICAL (MPI_ABORT_GCM)
-        call MPI_ABORT(COMM_LMDZ, 1, ierror_mpi)
+          call MPI_ABORT(COMM_LMDZ, 1, ierror_mpi)
 C$OMP END CRITICAL (MPI_ABORT_GCM)
-#else
-        stop 1
-#endif          
+        else
+         stop 1
+        endif          
+      
       endif
       END
Index: LMDZ6/trunk/libf/dyn3dmem/mod_const_mpi.F90
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/mod_const_mpi.F90	(revision 4593)
+++ LMDZ6/trunk/libf/dyn3dmem/mod_const_mpi.F90	(revision 4600)
@@ -11,4 +11,6 @@
 
   SUBROUTINE Init_const_mpi
+    USE lmdz_mpi
+
 #ifdef CPP_IOIPSL
     USE IOIPSL, ONLY: getin
@@ -25,7 +27,4 @@
 #endif
     IMPLICIT NONE
-#ifdef CPP_MPI
-    INCLUDE 'mpif.h'
-#endif
 
     INTEGER             :: ierr
@@ -52,7 +51,5 @@
 !$OMP END MASTER
 #endif
-#ifdef CPP_MPI
       MPI_REAL_LMDZ=MPI_REAL8
-#endif
     ELSE
       CALL init_mpi
@@ -62,16 +59,14 @@
   
   SUBROUTINE Init_mpi
+    USE lmdz_mpi
+
 #ifdef CPP_XIOS
     USE wxios, only: wxios_init
 #endif
   IMPLICIT NONE
-#ifdef CPP_MPI
-     INCLUDE 'mpif.h'
-#endif
     INTEGER             :: ierr
     INTEGER             :: thread_required
     INTEGER             :: thread_provided
 
-#ifdef CPP_MPI
 !$OMP MASTER
       thread_required=MPI_THREAD_SERIALIZED
@@ -92,13 +87,6 @@
 #endif
 !$OMP END MASTER
-#else
-#ifdef CPP_XIOS
-!$OMP MASTER
-      CALL wxios_init("LMDZ")
-!$OMP END MASTER
-#endif
-#endif
 
-   END SUBROUTINE Init_mpi
+END SUBROUTINE Init_mpi
     
 END MODULE mod_const_mpi
Index: LMDZ6/trunk/libf/dyn3dmem/mod_hallo.F90
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/mod_hallo.F90	(revision 4593)
+++ LMDZ6/trunk/libf/dyn3dmem/mod_hallo.F90	(revision 4600)
@@ -106,15 +106,9 @@
   
   SUBROUTINE create_global_mpi_buffer
+  USE lmdz_mpi
   IMPLICIT NONE
-#ifdef CPP_MPI
-  INCLUDE 'mpif.h'
-#endif  
     POINTER (Pbuffer,MPI_Buffer(MaxBufferSize))
     REAL :: MPI_Buffer
-#ifdef CPP_MPI
     INTEGER(KIND=MPI_ADDRESS_KIND) :: BS 
-#else
-    INTEGER(KIND=8) :: BS
-#endif
     INTEGER :: i,ierr
 
@@ -122,7 +116,5 @@
       Bs=8*MaxBufferSize
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
       CALL MPI_ALLOC_MEM(BS,MPI_INFO_NULL,Pbuffer,ierr)
-#endif
 !$OMP END CRITICAL (MPI)
       DO i=1,MaxBufferSize
@@ -1157,9 +1149,7 @@
   subroutine Register_Hallo(Field,ij,ll,RUp,Rdown,SUp,SDown,a_request)
   USE dimensions_mod
+  USE lmdz_mpi
       implicit none
 
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ij,ll
       REAL, dimension(ij,ll) :: Field
@@ -1224,8 +1214,6 @@
   subroutine Register_Hallo_u(Field,ll,RUp,Rdown,SUp,SDown,a_request)
   USE dimensions_mod
+  USE lmdz_mpi
       implicit none
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ll
       REAL, dimension(ijb_u:ije_u,ll) :: Field
@@ -1289,8 +1277,6 @@
   subroutine Register_Hallo_v(Field,ll,RUp,Rdown,SUp,SDown,a_request)
   USE dimensions_mod
+  USE lmdz_mpi
       implicit none
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ll
       REAL, dimension(ijb_v:ije_v,ll) :: Field
@@ -1354,9 +1340,6 @@
     subroutine SendRequest(a_Request)
     USE dimensions_mod
+    USE lmdz_mpi
       implicit none
-
-#ifdef CPP_MPI
-      include 'mpif.h'
-#endif
 
       type(request),target :: a_request
@@ -1410,8 +1393,6 @@
 !$OMP CRITICAL (MPI)
          
-#ifdef CPP_MPI
          call MPI_ISEND(Buffer(req%Pos),SizeBuffer,MPI_REAL_LMDZ,rank,a_request%tag+1000*omp_rank,     &
                          COMM_LMDZ,Req%MSG_Request,ierr)
-#endif
          IF (.NOT.using_mpi) THEN
            PRINT *,'Erreur, echange MPI en mode sequentiel !!!'
@@ -1453,8 +1434,7 @@
 !$OMP CRITICAL (MPI)
 
-#ifdef CPP_MPI
              call MPI_IRECV(Buffer(Req%Pos),SizeBuffer,MPI_REAL_LMDZ,rank,a_request%tag+1000*omp_rank,     &
                            COMM_LMDZ,Req%MSG_Request,ierr)
-#endif             
+
              IF (.NOT.using_mpi) THEN
                PRINT *,'Erreur, echange MPI en mode sequentiel !!!'
@@ -1478,9 +1458,6 @@
    subroutine WaitRequest(a_Request)
    USE dimensions_mod
+   USE lmdz_mpi
    implicit none
-   
-#ifdef CPP_MPI
-      include 'mpif.h'   
-#endif
       
       type(request),target :: a_request
@@ -1488,9 +1465,5 @@
       type(Hallo),pointer :: PtrHallo
       integer, dimension(2*mpi_size) :: TabRequest
-#ifdef CPP_MPI
       integer, dimension(MPI_STATUS_SIZE,2*mpi_size) :: TabStatus
-#else
-      integer, dimension(1,2*mpi_size) :: TabStatus
-#endif
       integer :: NbRequest
       integer :: i,rank,pos,ij,l,ierr
@@ -1521,7 +1494,5 @@
 !        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"en attente"
 !        PRINT *,"No des requetes :",TabRequest(1:NbRequest)
-#ifdef CPP_MPI
         call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
-#endif
 !        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"complete"
 !        PRINT *,"-------------------------------------------------------------------"
@@ -1571,19 +1542,13 @@
      
    subroutine WaitSendRequest(a_Request)
+   USE lmdz_mpi
    USE dimensions_mod
    implicit none
    
-#ifdef CPP_MPI
-      include 'mpif.h'   
-#endif      
       type(request),target :: a_request
       type(request_SR),pointer :: Req
       type(Hallo),pointer :: PtrHallo
       integer, dimension(mpi_size) :: TabRequest
-#ifdef CPP_MPI
       integer, dimension(MPI_STATUS_SIZE,mpi_size) :: TabStatus
-#else
-      integer, dimension(1,mpi_size) :: TabStatus
-#endif
       integer :: NbRequest
       integer :: i,rank,pos,ij,l,ierr
@@ -1606,7 +1571,5 @@
 !        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"en attente"
 !        PRINT *,"No des requetes :",TabRequest(1:NbRequest)
-#ifdef CPP_MPI
-        call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
-#endif
+         call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
 !        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"complete"
 !        PRINT *,"-------------------------------------------------------------------"
@@ -1628,19 +1591,11 @@
    subroutine WaitRecvRequest(a_Request)
    USE dimensions_mod
+   USE lmdz_mpi
    implicit none
-   
-#ifdef CPP_MPI
-      include 'mpif.h'   
-#endif
-      
       type(request),target :: a_request
       type(request_SR),pointer :: Req
       type(Hallo),pointer :: PtrHallo
       integer, dimension(mpi_size) :: TabRequest
-#ifdef CPP_MPI
       integer, dimension(MPI_STATUS_SIZE,mpi_size) :: TabStatus
-#else
-      integer, dimension(1,mpi_size) :: TabStatus
-#endif
       integer :: NbRequest
       integer :: i,rank,pos,ij,l,ierr
@@ -1664,7 +1619,5 @@
 !        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"en attente"
 !        PRINT *,"No des requetes :",TabRequest(1:NbRequest)
-#ifdef CPP_MPI
-        call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
-#endif
+         call MPI_WAITALL(NbRequest,TabRequest,TabStatus,ierr)
 !        PRINT *,"Process de rang",mpi_rank,"Task : ",omp_rank,"--->",NbRequest,"complete"
 !        PRINT *,"-------------------------------------------------------------------"
Index: LMDZ6/trunk/libf/dyn3dmem/parallel_lmdz.F90
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/parallel_lmdz.F90	(revision 4593)
+++ LMDZ6/trunk/libf/dyn3dmem/parallel_lmdz.F90	(revision 4600)
@@ -4,4 +4,5 @@
   MODULE parallel_lmdz
   USE mod_const_mpi
+  USE lmdz_mpi, ONLY : using_mpi
 #ifdef CPP_IOIPSL
       use IOIPSL
@@ -12,5 +13,4 @@
     INTEGER,PARAMETER :: halo_max=3
     
-    LOGICAL,SAVE :: using_mpi ! .true. if using MPI
     LOGICAL,SAVE :: using_omp ! .true. if using OpenMP
     LOGICAL,SAVE :: is_master ! .true. if the core is both MPI & OpenMP master
@@ -88,8 +88,6 @@
     subroutine init_parallel
     USE vampir
+    USE lmdz_mpi
     implicit none
-#ifdef CPP_MPI
-      include 'mpif.h'
-#endif
       INCLUDE "dimensions.h"
       INCLUDE "paramet.h"
@@ -111,11 +109,4 @@
 #endif  
 
-#ifdef CPP_MPI
-       using_mpi=.TRUE.
-#else
-       using_mpi=.FALSE.
-#endif
-      
-
 #ifdef CPP_OMP
        using_OMP=.TRUE.
@@ -127,8 +118,6 @@
       
       IF (using_mpi) THEN
-#ifdef CPP_MPI
         call MPI_COMM_SIZE(COMM_LMDZ,mpi_size,ierr)
         call MPI_COMM_RANK(COMM_LMDZ,mpi_rank,ierr)
-#endif
       ELSE
         mpi_size=1
@@ -161,7 +150,6 @@
          write(lunout,*)" ---> diminuez le nombre de CPU ou augmentez la taille en lattitude"
           
-#ifdef CPP_MPI
           IF (using_mpi) call MPI_ABORT(COMM_LMDZ,-1, ierr)
-#endif          
+
         endif
         
@@ -395,4 +383,5 @@
     
     subroutine Finalize_parallel
+    USE lmdz_mpi
 #ifdef CPP_XIOS
     ! ug Pour les sorties XIOS
@@ -418,7 +407,4 @@
       include "dimensions.h"
       include "paramet.h"
-#ifdef CPP_MPI
-      include 'mpif.h'
-#endif      
 
       integer :: ierr
@@ -446,7 +432,5 @@
       CALL wxios_close()
 #endif
-#ifdef CPP_MPI
-         IF (using_mpi) call MPI_FINALIZE(ierr)
-#endif
+      IF (using_mpi) call MPI_FINALIZE(ierr)
       end if
       
@@ -502,14 +486,10 @@
     
     SUBROUTINE barrier
+    USE lmdz_mpi
     IMPLICIT NONE
-#ifdef CPP_MPI
-    INCLUDE 'mpif.h'
-#endif
     INTEGER :: ierr
     
 !$OMP CRITICAL (MPI)      
-#ifdef CPP_MPI
       IF (using_mpi) CALL MPI_Barrier(COMM_LMDZ,ierr)
-#endif
 !$OMP END CRITICAL (MPI)
     
@@ -518,11 +498,9 @@
       
     subroutine exchange_hallo(Field,ij,ll,up,down)
+    USE lmdz_mpi
     USE Vampir
     implicit none
       INCLUDE "dimensions.h"
       INCLUDE "paramet.h"    
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ij,ll
       REAL, dimension(ij,ll) :: Field
@@ -533,9 +511,6 @@
       LOGICAL :: RecvUp,RecvDown
       INTEGER, DIMENSION(4) :: Request
-#ifdef CPP_MPI
       INTEGER, DIMENSION(MPI_STATUS_SIZE,4) :: Status
-#else
-      INTEGER, DIMENSION(1,4) :: Status
-#endif
+
       INTEGER :: NbRequest
       REAL, dimension(:),allocatable :: Buffer_Send_up,Buffer_Send_down
@@ -582,8 +557,6 @@
           call PACK_Data(Field(ij_begin,1),ij,ll,down,Buffer_Send_up)
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
           call MPI_ISEND(Buffer_send_up,Buffer_Size,MPI_REAL8,MPI_Rank-1,1,     &
                           COMM_LMDZ,Request(NbRequest),ierr)
-#endif
 !$OMP END CRITICAL (MPI)
         ENDIF
@@ -597,8 +570,6 @@
         
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
           call MPI_ISEND(Buffer_send_down,Buffer_Size,MPI_REAL8,MPI_Rank+1,1,     &
                           COMM_LMDZ,Request(NbRequest),ierr)
-#endif
 !$OMP END CRITICAL (MPI)
         ENDIF
@@ -611,8 +582,6 @@
               
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
           call MPI_IRECV(Buffer_recv_up,Buffer_size,MPI_REAL8,MPI_Rank-1,1,  &
                           COMM_LMDZ,Request(NbRequest),ierr)
-#endif
 !$OMP END CRITICAL (MPI)
      
@@ -626,15 +595,11 @@
         
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
           call MPI_IRECV(Buffer_recv_down,Buffer_size,MPI_REAL8,MPI_Rank+1,1,     &
                           COMM_LMDZ,Request(NbRequest),ierr)
-#endif
 !$OMP END CRITICAL (MPI)
         
         ENDIF
   
-#ifdef CPP_MPI
         if (NbRequest > 0) call MPI_WAITALL(NbRequest,Request,Status,ierr)
-#endif
         IF (RecvUp)  call Unpack_Data(Field(ij_begin-up*iip1,1),ij,ll,up,Buffer_Recv_up)
         IF (RecvDown) call Unpack_Data(Field(ij_end+1,1),ij,ll,down,Buffer_Recv_down)  
@@ -651,11 +616,9 @@
 
     subroutine Gather_Field(Field,ij,ll,rank)
+    USE lmdz_mpi
     implicit none
     INCLUDE "dimensions.h"
     INCLUDE "paramet.h" 
     INCLUDE "iniprint.h"
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ij,ll,rank
       REAL, dimension(ij,ll) :: Field
@@ -709,8 +672,6 @@
   
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
         call MPI_GATHERV(Buffer_send,(min(ij_end,ij)-ij_begin+1)*ll,MPI_REAL8,   &
                           Buffer_Recv,Recv_count,displ,MPI_REAL8,rank,COMM_LMDZ,ierr)
-#endif
 !$OMP END CRITICAL (MPI)
       
@@ -735,10 +696,8 @@
 
     subroutine AllGather_Field(Field,ij,ll)
+    USE lmdz_mpi
     implicit none
     INCLUDE "dimensions.h"
     INCLUDE "paramet.h"    
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ij,ll
       REAL, dimension(ij,ll) :: Field
@@ -748,7 +707,5 @@
         call Gather_Field(Field,ij,ll,0)
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
       call MPI_BCAST(Field,ij*ll,MPI_REAL8,0,COMM_LMDZ,ierr)
-#endif
 !$OMP END CRITICAL (MPI)
       ENDIF
@@ -757,10 +714,8 @@
     
    subroutine Broadcast_Field(Field,ij,ll,rank)
+    USE lmdz_mpi
     implicit none
     INCLUDE "dimensions.h"
     INCLUDE "paramet.h"    
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif    
       INTEGER :: ij,ll
       REAL, dimension(ij,ll) :: Field
@@ -771,7 +726,5 @@
       
 !$OMP CRITICAL (MPI)
-#ifdef CPP_MPI
       call MPI_BCAST(Field,ij*ll,MPI_REAL8,rank,COMM_LMDZ,ierr)
-#endif
 !$OMP END CRITICAL (MPI)
       
@@ -781,8 +734,8 @@
    
 !  Subroutine verif_hallo(Field,ij,ll,up,down)
+!    USE lmdz_mpi
 !    implicit none
 !      INCLUDE "dimensions.h"
 !      INCLUDE "paramet.h"    
-!    include 'mpif.h'
 !    
 !      INTEGER :: ij,ll
Index: LMDZ6/trunk/libf/dyn3dmem/times.F90
===================================================================
--- LMDZ6/trunk/libf/dyn3dmem/times.F90	(revision 4593)
+++ LMDZ6/trunk/libf/dyn3dmem/times.F90	(revision 4600)
@@ -137,8 +137,7 @@
   subroutine allgather_timer
     USE parallel_lmdz
-    implicit none
-#ifdef CPP_MPI    
-    include 'mpif.h'
-#endif
+    USE lmdz_mpi
+    implicit none
+
     integer :: ierr
     integer :: data_size
@@ -155,11 +154,7 @@
     
       tmp_table(:,:)=timer_table(:,:,mpi_rank)
-#ifdef CPP_MPI 
       call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_table(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
-#endif
       tmp_table(:,:)=timer_table_sqr(:,:,mpi_rank)
-#ifdef CPP_MPI
       call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_table_sqr(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
-#endif    
       deallocate(tmp_table)
     
@@ -172,8 +167,6 @@
   subroutine allgather_timer_average
     USE parallel_lmdz
-    implicit none
-#ifdef CPP_MPI
-    include 'mpif.h'
-#endif
+    USE lmdz_mpi
+    implicit none
     integer :: ierr
     integer :: data_size
@@ -192,15 +185,9 @@
 
       tmp_table(:,:)=timer_average(:,:,mpi_rank)
-#ifdef CPP_MPI
       call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_average(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
-#endif
       tmp_table(:,:)=timer_delta(:,:,mpi_rank)
-#ifdef CPP_MPI
       call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_delta(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
-#endif
       tmp_iter(:,:)=timer_iteration(:,:,mpi_rank)
-#ifdef CPP_MPI
       call mpi_allgather(tmp_iter(1,1),data_size,MPI_INTEGER,timer_iteration(1,1,0),data_size,MPI_INTEGER,COMM_LMDZ,ierr)
-#endif    
       deallocate(tmp_table)
     
