Index: branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diadimg.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diadimg.F90	(revision 10385)
+++ branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diadimg.F90	(revision 10392)
@@ -124,7 +124,6 @@
 
     CASE DEFAULT
-       IF(lwp) WRITE(numout,*) ' E R R O R : bad cd_type in dia_wri_dimg '
-       STOP 'dia_wri_dimg'
-
+       WRITE(numout,*) ' E R R O R : bad cd_type in dia_wri_dimg' 
+       CALL ctl_stop( 'STOP', 'dia_wri_dimg :bad cd_type in dia_wri_dimg ' ) 
     END SELECT
 
Index: branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 10385)
+++ branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 10392)
@@ -62,4 +62,5 @@
    USE lbcnfd         ! north fold treatment
    USE in_out_manager ! I/O manager
+   USE mod_oasis      ! coupling routines
 
    IMPLICIT NONE
@@ -2023,6 +2024,13 @@
       !!----------------------------------------------------------------------
       !
+#if defined key_oasis3 || defined key_oasis3mct   
+      ! If we're trying to shut down cleanly then we need to consider the fact   
+      ! that this could be part of an MPMD configuration - we don't want to   
+      ! leave other components deadlocked.   
+      CALL oasis_abort(nproc,"mppstop","NEMO initiated abort")   
+#else   
       CALL mppsync
       CALL mpi_finalize( info )
+#endif 
       !
    END SUBROUTINE mppstop
Index: branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 10385)
+++ branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 10392)
@@ -24,5 +24,5 @@
    !!   cpl_finalize : finalize the coupled mode communication
    !!----------------------------------------------------------------------
-#if defined key_oasis3
+#if defined key_oasis3 || defined key_oasis3mct
    USE mod_oasis                    ! OASIS3-MCT module
 #endif
@@ -32,4 +32,9 @@
    USE lbclnk                       ! ocean lateral boundary conditions (or mpp link)
 
+#if defined key_cpl_rootexchg   
+   USE lib_mpp, only : mppsync   
+   USE lib_mpp, only : mppscatter,mppgather   
+#endif    
+
    IMPLICIT NONE
    PRIVATE
@@ -41,4 +46,15 @@
    PUBLIC   cpl_freq
    PUBLIC   cpl_finalize
+#if defined key_mpp_mpi   
+   INCLUDE 'mpif.h'   
+#endif   
+      
+   INTEGER, PARAMETER         :: localRoot  = 0   
+   LOGICAL                    :: commRank            ! true for ranks doing OASIS communication   
+#if defined key_cpl_rootexchg   
+   LOGICAL                    :: rootexchg =.true.   ! logical switch    
+#else   
+   LOGICAL                    :: rootexchg =.false.  ! logical switch    
+#endif    
 
    INTEGER, PUBLIC            ::   OASIS_Rcv  = 1    !: return code if received field
@@ -46,5 +62,5 @@
    INTEGER                    ::   ncomp_id          ! id returned by oasis_init_comp
    INTEGER                    ::   nerror            ! return error code
-#if ! defined key_oasis3
+#if ! defined key_oasis3 && ! defined key_oasis3mct
    ! OASIS Variables not used. defined only for compilation purpose
    INTEGER                    ::   OASIS_Out         = -1
@@ -82,4 +98,6 @@
 
    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   exfld   ! Temporary buffer for receiving
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   tbuf  ! Temporary buffer for sending / receiving    
+   INTEGER, PUBLIC :: localComm    
 
    !!----------------------------------------------------------------------
@@ -120,4 +138,5 @@
       IF ( nerror /= OASIS_Ok ) &
          CALL oasis_abort (ncomp_id, 'cpl_init','Failure in oasis_get_localcomm' )
+      localComm = kl_comm
       !
    END SUBROUTINE cpl_init
@@ -149,4 +168,11 @@
       IF(lwp) WRITE(numout,*)
 
+      commRank = .false.   
+      IF ( rootexchg ) THEN   
+         IF ( nproc == localRoot ) commRank = .true.   
+      ELSE   
+         commRank = .true.   
+      ENDIF   
+
       ncplmodel = kcplmodel
       IF( kcplmodel > nmaxcpl ) THEN
@@ -172,10 +198,4 @@
       ishape(:,2) = (/ 1, nlej-nldj+1 /)
       !
-      ! ... Allocate memory for data exchange
-      !
-      ALLOCATE(exfld(nlei-nldi+1, nlej-nldj+1), stat = nerror)
-      IF( nerror > 0 ) THEN
-         CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating exfld')   ;   RETURN
-      ENDIF
       !
       ! -----------------------------------------------------------------
@@ -183,4 +203,13 @@
       ! -----------------------------------------------------------------
       
+      IF ( rootexchg ) THEN   
+       
+         paral(1) = 2              ! box partitioning   
+         paral(2) = 0              ! NEMO lower left corner global offset        
+         paral(3) = jpiglo         ! local extent in i    
+         paral(4) = jpjglo         ! local extent in j   
+         paral(5) = jpiglo         ! global extent in x   
+       
+      ELSE    
       paral(1) = 2                                              ! box partitioning
       paral(2) = jpiglo * (nldj-1+njmpp-1) + (nldi-1+nimpp-1)   ! NEMO lower left corner global offset    
@@ -196,5 +225,22 @@
       ENDIF
       
-      CALL oasis_def_partition ( id_part, paral, nerror )
+      ENDIF 
+      IF ( commRank )  CALL oasis_def_partition ( id_part, paral, nerror )   
+       
+      ! ... Allocate memory for data exchange   
+      !   
+      ALLOCATE(exfld(paral(3), paral(4)), stat = nerror)   
+      IF( nerror > 0 ) THEN   
+         CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating exfld')   ;   RETURN   
+      ENDIF   
+      IF ( rootexchg ) THEN   
+         ! Should possibly use one of the work arrays for tbuf really   
+         ALLOCATE(tbuf(jpi, jpj, jpnij), stat = nerror)   
+         IF( nerror > 0 ) THEN   
+            CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating tbuf') ; RETURN   
+         ENDIF   
+      ENDIF                
+      !   
+      IF (commRank ) THEN 
       !
       ! ... Announce send variables. 
@@ -288,4 +334,6 @@
          ENDIF
       END DO
+      !  
+      ENDIF  ! commRank=true  
       
       !------------------------------------------------------------------
@@ -293,6 +341,8 @@
       !------------------------------------------------------------------
       
-      CALL oasis_enddef(nerror)
-      IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')
+      IF ( commRank ) THEN        
+         CALL oasis_enddef(nerror)   
+         IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')   
+      ENDIF   
       !
    END SUBROUTINE cpl_define
@@ -311,5 +361,5 @@
       REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdata
       !!
-      INTEGER                                   ::   jc,jm     ! local loop index
+      INTEGER                                   ::   jn,jc,jm  ! local loop index
       !!--------------------------------------------------------------------
       !
@@ -320,5 +370,23 @@
         
             IF( ssnd(kid)%nid(jc,jm) /= -1 ) THEN
-               CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(nldi:nlei, nldj:nlej,jc), kinfo )
+               IF ( rootexchg ) THEN   
+                  !   
+                  ! collect data on the local root process   
+                  !   
+                  CALL mppgather (pdata(:,:,jc),localRoot,tbuf)    
+                  CALL mppsync    
+                         
+                  IF ( nproc == localRoot ) THEN   
+                     DO jn = 1, jpnij   
+                        exfld(nimppt(jn)-1+nldit(jn):nimppt(jn)+nleit(jn)-1,njmppt(jn)-1+nldjt(jn):njmppt(jn)+nlejt(jn)-1)= &   
+                          tbuf(nldit(jn):nleit(jn),nldjt(jn):nlejt(jn),jn)   
+                     ENDDO   
+                     ! snd data to OASIS3   
+                     CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, exfld, kinfo )   
+                  ENDIF   
+               ELSE   
+                  ! snd data to OASIS3   
+                  CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(nldi:nlei, nldj:nlej,jc), kinfo )   
+               ENDIF   
                
                IF ( ln_ctl ) THEN        
@@ -358,5 +426,5 @@
       INTEGER                   , INTENT(  out) ::   kinfo     ! OASIS3 info argument
       !!
-      INTEGER                                   ::   jc,jm     ! local loop index
+      INTEGER                                   ::   jn,jc,jm  ! local loop index
       LOGICAL                                   ::   llaction, llfisrt
       !!--------------------------------------------------------------------
@@ -372,6 +440,9 @@
 
             IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN
-
-               CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )         
+               !   
+               ! receive data from OASIS3   
+               !   
+               IF ( commRank )   CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo )   
+               IF ( rootexchg )  CALL MPI_BCAST ( kinfo, 1, MPI_INTEGER, localRoot, localComm, nerror ) 
                
                llaction =  kinfo == OASIS_Recvd   .OR. kinfo == OASIS_FromRest .OR.   &
@@ -384,5 +455,19 @@
                   kinfo = OASIS_Rcv
                   IF( llfisrt ) THEN 
-                     pdata(nldi:nlei,nldj:nlej,jc) =                                 exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)
+                     IF ( rootexchg ) THEN   
+                        ! distribute data to processes   
+                        !   
+                        IF ( nproc == localRoot ) THEN   
+                           DO jn = 1, jpnij   
+                              tbuf(nldit(jn):nleit(jn),nldjt(jn):nlejt(jn),jn)=          &   
+                              exfld(nimppt(jn)-1+nldit(jn):nimppt(jn)+nleit(jn)-1,njmppt(jn)-1+nldjt(jn):njmppt(jn)+nlejt(jn)-1)   
+                              ! NOTE: we are missing combining this with pmask (see else below)   
+                           ENDDO   
+                        ENDIF   
+                        CALL mppscatter(tbuf,localRoot,pdata(:,:,jc))    
+                        CALL mppsync   
+                     ELSE   
+                        pdata(nldi:nlei, nldj:nlej, jc) = exfld(:,:) * pmask(nldi:nlei,nldj:nlej,jm)   
+                     ENDIF   
                      llfisrt = .FALSE.
                   ELSE
@@ -462,8 +547,12 @@
 #if defined key_oa3mct_v3
          CALL oasis_get_freqs(id, mop, 1, itmp, info)
-#else
+#endif
+#if defined key_oasis3
          CALL oasis_get_freqs(id,      1, itmp, info)
 #endif
          cpl_freq = itmp(1)
+#if defined key_oasis3mct  
+         cpl_freq = namflddti( id )  
+#endif 
       ENDIF
       !
@@ -481,4 +570,5 @@
       !
       DEALLOCATE( exfld )
+      IF ( rootexchg ) DEALLOCATE ( tbuf )
       IF (nstop == 0) THEN
          CALL oasis_terminate( nerror )         
@@ -489,5 +579,5 @@
    END SUBROUTINE cpl_finalize
 
-#if ! defined key_oasis3
+#if ! defined key_oasis3 && ! defined key_oasis3mct
 
    !!----------------------------------------------------------------------
Index: branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 10385)
+++ branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 10392)
@@ -35,5 +35,5 @@
    LOGICAL , PUBLIC ::   ln_blk_core    !: CORE bulk formulation
    LOGICAL , PUBLIC ::   ln_blk_mfs     !: MFS  bulk formulation
-#if defined key_oasis3
+#if defined key_oasis3 || defined key_oasis3mct
    LOGICAL , PUBLIC ::   lk_oasis = .TRUE.  !: OASIS used
 #else
Index: branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 10385)
+++ branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 10392)
@@ -41,4 +41,7 @@
    USE timing          ! Timing
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+#if defined key_oasis3 || defined key_oasis3mct   
+   USE mod_oasis                    ! OASIS3-MCT module   
+#endif  
    USE eosbn2
    USE sbcrnf   , ONLY : l_rnfcpl
Index: branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 10385)
+++ branches/UKMO/AMM15_v3_6_STABLE_package_collate_coupling/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 10392)
@@ -397,4 +397,5 @@
                                CALL ctl_stop( 'step: indic < 0' )
                                CALL dia_wri_state( 'output.abort', kstp )
+                               CALL ctl_stop('STOP','NEMO failure in stp')
       ENDIF
       IF( ln_harm_ana_store   )   CALL harm_ana( kstp )        ! Harmonic analysis of tides 
