Index: NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/LBC/lib_mpp.F90	(revision 13310)
+++ NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/LBC/lib_mpp.F90	(revision 13311)
@@ -686,5 +686,13 @@
       ! leave other components deadlocked.
 
-      CALL oasis_abort(nproc,"mppstop","NEMO initiated abort")
+! RSRH No! 
+      IF(ll_abort) THEN
+         !CALL mpi_abort( MPI_COMM_WORLD )
+         CALL oasis_abort(nproc,"mppstop","NEMO initiated abort")
+      ELSE
+         CALL mppsync
+         CALL mpi_finalize( info )
+      ENDIF
+      IF( ll_abort ) STOP 123
 
 
Index: NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/SBC/cpl_oasis3.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/SBC/cpl_oasis3.F90	(revision 13310)
+++ NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/SBC/cpl_oasis3.F90	(revision 13311)
@@ -95,5 +95,6 @@
 CONTAINS
 
-   SUBROUTINE cpl_init( cd_modname, kl_comm )
+   SUBROUTINE cpl_init( cd_modname, kl_comm ) 
+
       !!-------------------------------------------------------------------
       !!             ***  ROUTINE cpl_init  ***
@@ -104,4 +105,5 @@
       !! ** Method  :   OASIS3 MPI communication 
       !!--------------------------------------------------------------------
+      USE sbc_oce , ONLY :   ln_cpl
       CHARACTER(len = *), INTENT(in   ) ::   cd_modname   ! model name as set in namcouple file
       INTEGER           , INTENT(  out) ::   kl_comm      ! local communicator of the model
@@ -114,5 +116,5 @@
       ! 1st Initialize the OASIS system for the application
       !------------------------------------------------------------------
-      CALL oasis_init_comp ( ncomp_id, TRIM(cd_modname), nerror )
+      CALL oasis_init_comp ( ncomp_id, TRIM(cd_modname), nerror, ln_cpl )
       IF ( nerror /= OASIS_Ok ) &
          CALL oasis_abort (ncomp_id, 'cpl_init', 'Failure in oasis_init_comp')
@@ -530,5 +532,6 @@
       !!----------------------------------------------------------------------
       !
-      DEALLOCATE( exfld )
+      IF (ALLOCATED(exfld)) DEALLOCATE( exfld )
+
       IF (nstop == 0) THEN
          CALL oasis_terminate( nerror )         
@@ -545,5 +548,5 @@
    !!----------------------------------------------------------------------
 
-   SUBROUTINE oasis_init_comp(k1,cd1,k2)
+   SUBROUTINE oasis_init_comp(k1,cd1,k2,l1)
       CHARACTER(*), INTENT(in   ) ::  cd1
       INTEGER     , INTENT(  out) ::  k1,k2
@@ -554,5 +557,6 @@
    SUBROUTINE oasis_abort(k1,cd1,cd2)
       INTEGER     , INTENT(in   ) ::  k1
-      CHARACTER(*), INTENT(in   ) ::  cd1,cd2
+      CHARACTER(*), INTENT(in   ) ::  cd1,cd2     
+      LOGICAL     , OPTIONAL,  INTENT(in   ) ::  l1
       WRITE(numout,*) 'oasis_abort: Error you sould not be there...', cd1, cd2
    END SUBROUTINE oasis_abort
Index: NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/SBC/sbccpl.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/SBC/sbccpl.F90	(revision 13310)
+++ NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/SBC/sbccpl.F90	(revision 13311)
@@ -466,11 +466,13 @@
       !                                                      ! ------------------------- !
       srcv(jpr_rnf   )%clname = 'O_Runoff'
-      IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) THEN
-         srcv(jpr_rnf)%laction = .TRUE.
-         l_rnfcpl              = .TRUE.                      ! -> no need to read runoffs in sbcrnf
-         ln_rnf                = nn_components /= jp_iam_sas ! -> force to go through sbcrnf if not sas
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '   runoffs received from oasis -> force ln_rnf = ', ln_rnf
-      ENDIF
+      IF (ln_cpl) THEN ! Don't perform this code if coupling is not active!
+         IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) THEN
+            srcv(jpr_rnf)%laction = .TRUE.
+            l_rnfcpl              = .TRUE.                      ! -> no need to read runoffs in sbcrnf
+            ln_rnf                = nn_components /= jp_iam_sas ! -> force to go through sbcrnf if not sas
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '   runoffs received from oasis -> force ln_rnf = ', ln_rnf
+         ENDIF
+      ENDIF 
       !
       srcv(jpr_cal)%clname = 'OCalving'   ;  IF( TRIM( sn_rcv_cal%cldes) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.
@@ -543,10 +545,12 @@
       !                                                      ! ------------------------- !
       srcv(jpr_co2 )%clname = 'O_AtmCO2'   
-      IF( TRIM(sn_rcv_co2%cldes   ) == 'coupled' )  THEN
-         srcv(jpr_co2 )%laction = .TRUE.
-         l_co2cpl = .TRUE.
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '   Atmospheric pco2 received from oasis '
-         IF(lwp) WRITE(numout,*)
+      IF (ln_cpl) THEN ! Not needed if we're not coupling
+         IF( TRIM(sn_rcv_co2%cldes   ) == 'coupled' )  THEN
+            srcv(jpr_co2 )%laction = .TRUE.
+            l_co2cpl = .TRUE.
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '   Atmospheric pco2 received from oasis '
+            IF(lwp) WRITE(numout,*)
+         ENDIF
       ENDIF
       !
@@ -1032,5 +1036,6 @@
       ! ================================ !
 
-      CALL cpl_define(jprcv, jpsnd, nn_cplmodel)
+      ! If ln_cpl is false, clearly we don't want to call cpl_dfine!
+      if (ln_cpl) CALL cpl_define(jprcv, jpsnd, nn_cplmodel)
       
       IF (ln_usecplmask) THEN 
Index: NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/nemogcm.F90	(revision 13310)
+++ NEMO/branches/UKMO/NEMO_4.0.1_NGMS_couple_pkg/src/OCE/nemogcm.F90	(revision 13311)
@@ -41,4 +41,5 @@
    !!   nemo_alloc    : dynamical allocation
    !!----------------------------------------------------------------------
+   USE mod_oasis ! RSRH temp
    USE step_oce       ! module used in the ocean time stepping module (step.F90)
    USE phycst         ! physical constant                  (par_cst routine)
@@ -130,5 +131,5 @@
       !!              Madec, 2008, internal report, IPSL.
       !!----------------------------------------------------------------------
-      INTEGER ::   istp   ! time step index
+      INTEGER ::   istp, nerror   ! time step index
       REAL(wp)::   zstptiming   ! elapsed time for 1 time step
       !!----------------------------------------------------------------------
@@ -200,7 +201,8 @@
             ENDIF
             
-            IF (lk_oasis) THEN
-               CALL sbc_cpl_snd( istp )  ! Coupling to atmos
-            ENDIF
+            ! RSRH. You can compile with OASIS but not want to do any
+            ! coupling. We need to cater for that properly!
+            IF (ln_cpl) CALL sbc_cpl_snd( istp )  ! Coupling to atmos
+
             CALL stp        ( istp ) 
             istp = istp + 1
@@ -239,18 +241,27 @@
       IF( ln_timing )   CALL timing_finalize
       !
+      write(numout,*) "RSRH calling nemo_closefile " , lk_oasis; flush(numout)
       CALL nemo_closefile
+      write(numout,*) "RSRH done closefiles " , lk_oasis; flush(numout)
       !
 #if defined key_iomput
-                                    CALL xios_finalize  ! end mpp communications with xios
-      IF( lk_oasis     )            CALL cpl_finalize   ! end coupling and mpp communications with OASIS
+      CALL xios_finalize()  ! end mpp communications with xios
+
+      IF (lk_oasis)  CALL oasis_terminate(nerror)
+      CALL mppstop ! RSRH temp for development
+      !IF( lk_oasis     )            CALL cpl_finalize()   ! end coupling and mpp communications with OASIS
 #else
-      IF    ( lk_oasis ) THEN   ;   CALL cpl_finalize   ! end coupling and mpp communications with OASIS
-      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop      ! end mpp communications
+      IF    ( lk_oasis ) THEN   
+          CALL cpl_finalize()   ! end coupling and mpp communications with OASIS
+      ELSEIF( lk_mpp   ) THEN 
+          CALL mppstop      ! end mpp communications
       ENDIF
 #endif
       !
       IF(lwm) THEN
-         IF( nstop == 0 ) THEN   ;   STOP 0
-         ELSE                    ;   STOP 123
+         IF( nstop == 0 ) THEN   
+                STOP 0
+         ELSE        
+                STOP 123
          ENDIF
       ENDIF
@@ -265,5 +276,5 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER ::   ios, ilocal_comm   ! local integers
+      INTEGER ::   ios, ilocal_comm, nerror, ncomp_id, llmpi_init, ierr  ! local integers
       !!
       NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
@@ -281,11 +292,19 @@
       !
 #if defined key_iomput
-      IF( Agrif_Root() ) THEN
-         IF( lk_oasis ) THEN
-            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
-            CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
-         ENDIF
+!      IF( Agrif_Root() ) THEN
+!         IF( lk_oasis ) THEN
+!            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
+!            CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
+!         ENDIF
+!      ENDIF
+! RSRH simplify initialisaton for test
+      IF( lk_oasis ) THEN
+          CALL mpi_init(nerror)
+          CALL oasis_init_comp ( ncomp_id, "toyoce", nerror, .FALSE. )
+!          CALL cpl_init( "toyoce", ilocal_comm ) 
+          CALL oasis_get_localcomm ( ilocal_comm , nerror )
+          CALL xios_initialize( "toyoce", local_comm =ilocal_comm )
       ENDIF
       CALL mpp_start( ilocal_comm )
@@ -330,4 +349,6 @@
       lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
       !
+WRITE(numout,*) "RSRH NEMO start local com=",ilocal_comm ; flush(numout) 
+WRITE(numout,*) "RSRH NEMO my rank=",mpprank ; flush(numout) 
       IF(lwp) THEN                      ! open listing units
          !
@@ -335,4 +356,8 @@
             &            CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
          !
+
+WRITE(numout,*) "RSRH NEMO start local com=",ilocal_comm ; flush(numout) 
+WRITE(numout,*) "RSRH NEMO my rank=",mpprank ; flush(numout) 
+
          WRITE(numout,*)
          WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
@@ -625,4 +650,6 @@
       !
       CALL iom_close                                 ! close all input/output files managed by iom_*
+
+write(numout,*) "RSRH after iom_close";flush(numout)
       !
       IF( numstp          /= -1 )   CLOSE( numstp          )   ! time-step file
@@ -640,5 +667,5 @@
       IF( numdct_salt     /= -1 )   CLOSE( numdct_salt     )   ! salt transports
       !
-      numout = 6                                     ! redefine numout in case it is used after this point...
+!      numout = 6                                     ! redefine numout in case it is used after this point...
       !
    END SUBROUTINE nemo_closefile
