Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diadimg.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diadimg.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diadimg.F90	(revision 6558)
@@ -124,6 +124,7 @@
 
     CASE DEFAULT
-       IF(lwp) WRITE(numout,*) ' E R R O R : bad cd_type in dia_wri_dimg '
-       STOP 'dia_wri_dimg'
+    
+       WRITE(numout,*) 'dia_wri_dimg : 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/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6558)
@@ -1062,4 +1062,8 @@
       ENDIF
 #endif
+
+      IF (cdfile_name == "output.abort") THEN
+         CALL ctl_stop('STOP', 'NEMO abort from dia_wri_state')
+      END IF
        
 !     IF( nn_timing == 1 )   CALL timing_stop('dia_wri_state') ! not sure this works for routines not called in first timestep
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diawri_dimg.h90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 6558)
@@ -112,5 +112,5 @@
     IF( inbsel >  jpk ) THEN
        IF(lwp) WRITE(numout,*)  ' STOP inbsel =',inbsel,' is larger than jpk=',jpk
-       STOP
+       CALL ctl_stop('STOP', 'NEMO aborted from dia_wri')
     ENDIF
 
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 6558)
@@ -526,5 +526,5 @@
       IF(lwp) WRITE(numout,*) 'dom_msk_nsa : noslip accurate boundary condition'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   using Schchepetkin and O Brian scheme'
-      IF( lk_mpp )   CALL ctl_stop( ' mpp version is not yet implemented' )
+      IF( lk_mpp )   CALL ctl_stop('STOP', ' mpp version is not yet implemented' )
 
       ! mask for second order calculation of vorticity
@@ -548,5 +548,5 @@
          WRITE(numout,*) ' symetric boundary conditions need special'
          WRITE(numout,*) ' treatment not implemented. we stop.'
-         STOP
+         CALL ctl_stop('STOP', 'NEMO abort from dom_msk_nsa')
       ENDIF
       
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 6558)
@@ -465,7 +465,9 @@
             END DO
          ELSE
-            IF(lwp)WRITE(numout,*) ' ldfguv: kahm= 1 or 2, here =', kahm
-            IF(lwp)WRITE(numout,*) '         We stop'
-            STOP 'ldfguv'
+            
+            WRITE(numout,*) ' ldfguv: kahm= 1 or 2, here =', kahm
+            WRITE(numout,*) '         We stop'
+            CALL ctl_stop('STOP', 'ldfguv: Unexpected kahm value')
+
          ENDIF
          !                                             ! ===============
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 6558)
@@ -62,4 +62,5 @@
    USE lbcnfd         ! north fold treatment
    USE in_out_manager ! I/O manager
+   USE mod_oasis      ! coupling routines
 
    IMPLICIT NONE
@@ -2006,4 +2007,6 @@
 
    SUBROUTINE mppstop
+   
+
       !!----------------------------------------------------------------------
       !!                  ***  routine mppstop  ***
@@ -2015,6 +2018,19 @@
       !!----------------------------------------------------------------------
       !
+      
+#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
@@ -3784,5 +3800,5 @@
             WRITE(kout,*)
          ENDIF
-         STOP 'ctl_opn bad opening'
+         CALL ctl_stop ('STOP', 'NEMO abort ctl_opn bad opening')
       ENDIF
 
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 6558)
@@ -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
@@ -31,4 +31,9 @@
    USE in_out_manager               ! I/O manager
    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
@@ -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,5 +98,7 @@
 
    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   exfld   ! Temporary buffer for receiving
-
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   tbuf  ! Temporary buffer for sending / receiving 
+   INTEGER, PUBLIC :: localComm 
+      
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
@@ -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
@@ -148,4 +167,11 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
       IF(lwp) WRITE(numout,*)
+      
+      commRank = .false.
+      IF ( rootexchg ) THEN
+         IF ( nproc == localRoot ) commRank = .true.
+      ELSE
+         commRank = .true.
+      ENDIF
 
       ncplmodel = kcplmodel
@@ -172,14 +198,18 @@
       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
       !
       ! -----------------------------------------------------------------
       ! ... Define the partition 
       ! -----------------------------------------------------------------
+      
+      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
@@ -196,5 +226,22 @@
       ENDIF
       
-      CALL oasis_def_partition ( id_part, paral, nerror )
+      ENDIF
+      IF ( commRank )  CALL oasis_def_partition ( id_part, paral, nerror, jpiglo*jpjglo )
+     
+      ! ... 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. 
@@ -241,5 +288,5 @@
             END DO
          ENDIF
-      END DO
+      END DO      
       !
       ! ... Announce received variables. 
@@ -288,4 +335,6 @@
          ENDIF
       END DO
+      !
+      ENDIF  ! commRank=true 
       
       !------------------------------------------------------------------
@@ -293,6 +342,9 @@
       !------------------------------------------------------------------
       
-      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 +363,5 @@
       REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdata
       !!
-      INTEGER                                   ::   jc,jm     ! local loop index
+      INTEGER                                   ::   jn,jc,jm     ! local loop index
       !!--------------------------------------------------------------------
       !
@@ -320,5 +372,28 @@
         
             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 +433,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 +447,11 @@
 
             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 +464,28 @@
                   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 +565,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 +588,5 @@
       !
       DEALLOCATE( exfld )
+      IF ( rootexchg ) DEALLOCATE ( tbuf )
       IF (nstop == 0) THEN
          CALL oasis_terminate( nerror )         
@@ -489,5 +597,5 @@
    END SUBROUTINE cpl_finalize
 
-#if ! defined key_oasis3
+#if ! defined key_oasis3 && ! defined key_oasis3mct
 
    !!----------------------------------------------------------------------
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 6558)
@@ -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/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 6558)
@@ -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/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 6558)
@@ -330,7 +330,7 @@
                END DO
             ELSE
-               IF(lwp) WRITE(numout,*) ' ldfght: kaht= 1 or 2, here =', kaht
-               IF(lwp) WRITE(numout,*) '         We stop'
-               STOP 'ldfght'
+               WRITE(numout,*) ' ldfght: kaht= 1 or 2, here =', kaht
+               WRITE(numout,*) '         We stop'
+               CALL ctl_stop( 'STOP', 'ldfght : unexpected kaht value')
             ENDIF
             !                                             ! ===============
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 6558)
@@ -277,5 +277,5 @@
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
-            CALL cpl_init( "oceanx", ilocal_comm )                     ! nemo local communicator given by oasis
+            CALL cpl_init( "toyoce", ilocal_comm )                     ! nemo local communicator given by oasis
             CALL xios_initialize( "not used",local_comm=ilocal_comm )    ! send nemo communicator to xios
          ELSE
@@ -288,5 +288,5 @@
       IF( lk_oasis ) THEN
          IF( Agrif_Root() ) THEN
-            CALL cpl_init( "oceanx", ilocal_comm )                      ! nemo local communicator given by oasis
+            CALL cpl_init( "toyoce", ilocal_comm )                      ! nemo local communicator given by oasis
          ENDIF
          ! Nodes selection (control print return in cltxt)
@@ -461,4 +461,9 @@
       IF( lk_asminc     )   CALL asm_inc_init   ! Initialize assimilation increments
       IF(lwp) WRITE(numout,*) 'Euler time step switch is ', neuler
+      
+      IF (nstop > 0) THEN
+        CALL CTL_STOP('STOP','Critical errors in NEMO initialisation')
+      END IF
+
       !
    END SUBROUTINE nemo_init
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6558)
@@ -346,4 +346,5 @@
                                CALL ctl_stop( 'step: indic < 0' )
                                CALL dia_wri_state( 'output.abort', kstp )
+                               CALL ctl_stop('STOP','NEMO failure in stp')
       ENDIF
       IF( kstp == nit000   )   THEN
Index: branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/wrk_nemo.F90
===================================================================
--- branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/wrk_nemo.F90	(revision 6557)
+++ branches/UKMO/dev_r5518_hadgem3_mct/NEMOGCM/NEMO/OPA_SRC/wrk_nemo.F90	(revision 6558)
@@ -72,4 +72,5 @@
    !!----------------------------------------------------------------------
    USE par_oce        ! ocean parameters
+   USE lib_mpp
 
    IMPLICIT NONE
@@ -483,5 +484,6 @@
          &      .AND. SUM( tree(ii)%ishape ) /= 0 )
          ii = ii + 1
-         IF (ii > jparray) STOP   ! increase the value of jparray (should not be needed as already very big!)
+         IF (ii > jparray) CALL ctl_stop('STOP', 'NEMO aborted wrk_allocbase')
+                           ! increase the value of jparray (should not be needed as already very big!)
       END DO
       
