Index: /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/ICB/icbclv.F90
===================================================================
--- /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/ICB/icbclv.F90	(revision 12674)
+++ /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/ICB/icbclv.F90	(revision 12675)
@@ -53,5 +53,6 @@
       !
       REAL(wp)      ::   zcalving_used, zdist, zfact
-      REAL(wp)      ::   zgreenland_calving_sum, zantarctica_calving_sum 
+      REAL(wp), DIMENSION(1)      ::   zgreenland_calving_sum, zantarctica_calving_sum 
+      LOGICAL       ::   ll_write
       INTEGER       ::   jn, ji, jj                    ! loop counters
       INTEGER       ::   imx                           ! temporary integer for max berg class
@@ -77,27 +78,27 @@
           ! to preserve total freshwater conservation in coupled models without an active ice sheet model.
 
-           zgreenland_calving_sum = SUM( berg_grid%calving(:,:) * greenland_icesheet_mask(:,:) )
-           IF( lk_mpp ) CALL mpp_sum( zgreenland_calving_sum )
+           zgreenland_calving_sum(1) = SUM( berg_grid%calving(:,:) * greenland_icesheet_mask(:,:) )
+           IF( lk_mpp ) CALL mpp_sum( 'icbclv', zgreenland_calving_sum )
            WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                                 &
           &    berg_grid%calving(:,:) = berg_grid%calving(:,:) * greenland_icesheet_mass_rate_of_change * rn_greenland_calving_fraction &
-          &                                     / ( zgreenland_calving_sum + 1.0e-10_wp )
+          &                                     / ( zgreenland_calving_sum(1) + 1.0e-10_wp )
 
            ! check
-           IF(ll_write) WRITE(numout, *) 'Greenland iceberg calving climatology (kg/s) : ',zgreenland_calving_sum
-           zgreenland_calving_sum = SUM( berg_grid%calving(:,:) * greenland_icesheet_mask(:,:) )
-           IF( lk_mpp ) CALL mpp_sum( zgreenland_calving_sum )
-           IF(ll_write) WRITE(numout, *) 'Greenland iceberg calving adjusted value (kg/s) : ',zgreenland_calving_sum
-
-           zantarctica_calving_sum = SUM( berg_grid%calving(:,:) * antarctica_icesheet_mask(:,:) )
-           IF( lk_mpp ) CALL mpp_sum( zantarctica_calving_sum )
+           IF(ll_write) WRITE(numout, *) 'Greenland iceberg calving climatology (kg/s) : ',zgreenland_calving_sum(1)
+           zgreenland_calving_sum(1) = SUM( berg_grid%calving(:,:) * greenland_icesheet_mask(:,:) )
+           IF( lk_mpp ) CALL mpp_sum( 'icbclv', zgreenland_calving_sum )
+           IF(ll_write) WRITE(numout, *) 'Greenland iceberg calving adjusted value (kg/s) : ',zgreenland_calving_sum(1)
+
+           zantarctica_calving_sum(1) = SUM( berg_grid%calving(:,:) * antarctica_icesheet_mask(:,:) )
+           IF( lk_mpp ) CALL mpp_sum( 'icbclv', zantarctica_calving_sum )
            WHERE( antarctica_icesheet_mask(:,:) == 1.0 )                                                                              &
            berg_grid%calving(:,:) = berg_grid%calving(:,:) * antarctica_icesheet_mass_rate_of_change * rn_antarctica_calving_fraction &
-          &                           / ( zantarctica_calving_sum + 1.0e-10_wp )
+          &                           / ( zantarctica_calving_sum(1) + 1.0e-10_wp )
 
            ! check
-           IF(ll_write) WRITE(numout, *) 'Antarctica iceberg calving climatology (kg/s) : ',zantarctica_calving_sum
-           zantarctica_calving_sum = SUM( berg_grid%calving(:,:) * antarctica_icesheet_mask(:,:) )
-           IF( lk_mpp ) CALL mpp_sum( zantarctica_calving_sum )
-           IF(ll_write) WRITE(numout, *) 'Antarctica iceberg calving adjusted value (kg/s) : ',zantarctica_calving_sum
+           IF(ll_write) WRITE(numout, *) 'Antarctica iceberg calving climatology (kg/s) : ',zantarctica_calving_sum(1)
+           zantarctica_calving_sum(1) = SUM( berg_grid%calving(:,:) * antarctica_icesheet_mask(:,:) )
+           IF( lk_mpp ) CALL mpp_sum( 'icbclv', zantarctica_calving_sum )
+           IF(ll_write) WRITE(numout, *) 'Antarctica iceberg calving adjusted value (kg/s) : ',zantarctica_calving_sum(1)
 
         ENDIF
Index: /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/cpl_oasis3.F90
===================================================================
--- /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/cpl_oasis3.F90	(revision 12674)
+++ /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/cpl_oasis3.F90	(revision 12675)
@@ -33,4 +33,5 @@
    USE in_out_manager               ! I/O manager
    USE lbclnk                       ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp
 
    IMPLICIT NONE
@@ -52,4 +53,9 @@
    PUBLIC   cpl_finalize
 
+#if defined key_mpp_mpi
+   INCLUDE 'mpif.h'
+#endif
+
+   INTEGER, PARAMETER         ::   localRoot  = 0
    INTEGER, PUBLIC            ::   OASIS_Rcv  = 1    !: return code if received field
    INTEGER, PUBLIC            ::   OASIS_idle = 0    !: return code if nothing done by oasis
@@ -115,4 +121,5 @@
       CHARACTER(len = *), INTENT(in   ) ::   cd_modname   ! model name as set in namcouple file
       INTEGER           , INTENT(  out) ::   kl_comm      ! local communicator of the model
+      INTEGER                           ::   error
       !!--------------------------------------------------------------------
 
@@ -627,5 +634,4 @@
                      WRITE(numout,*) '     - Start of data is ', pdata(1:number_to_print)
                      WRITE(numout,*) '****************'
-                     IF(lflush) CALL flush(numout)
                   ENDIF
                   
@@ -635,5 +641,6 @@
             
        ENDDO
-       
+
+#if defined key_mpp_mpi
        ! Set the precision that we want to broadcast using MPI_BCAST
        SELECT CASE( wp )
@@ -651,5 +658,8 @@
        ! to deal with that w/o NEMO adopting a UM-style test mechanism
        ! to determine active put/get timesteps. 
-       CALL mpi_bcast( pdata, nitems, MPI_WORKING_PRECISION, localRoot, mpi_comm_opa, ierr )
+       CALL mpi_bcast( pdata, nitems, MPI_WORKING_PRECISION, localRoot, mpi_comm_oce, ierr )
+#else
+       CALL oasis_abort( ncomp_id, "cpl_rcv_1d", "Unable to use mpi_bcast without key_mpp_mpi present. Please add key_mpp_mpi to your list of NEMO keys." )
+#endif
 
       !
Index: /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/cpl_rnf_1d.F90
===================================================================
--- /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/cpl_rnf_1d.F90	(revision 12674)
+++ /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/cpl_rnf_1d.F90	(revision 12675)
@@ -19,5 +19,4 @@
    USE lib_mpp         ! MPP library
    USE iom
-   USE wrk_nemo        ! Memory allocation
    USE dom_oce         ! Domain sizes (for grid box area e1e2t)
    USE sbc_oce         ! Surface boundary condition: ocean fields
@@ -31,7 +30,7 @@
    
    TYPE, PUBLIC ::   RIVERS_DATA     !: Storage for river outflow data
-      INTEGER, POINTER, DIMENSION(:,:)    ::   river_number       !: River outflow number
-      REAL(wp), POINTER, DIMENSION(:)     ::   river_area         ! 1D array listing areas of each river outflow (m2)
-      COMPLEX(wp), POINTER, DIMENSION(:)  ::   river_area_c       ! Comlex version of river_area for use in bit reproducible sums (m2)
+      INTEGER, ALLOCATABLE, DIMENSION(:,:)    ::   river_number       !: River outflow number
+      REAL(wp), ALLOCATABLE, DIMENSION(:)     ::   river_area         ! 1D array listing areas of each river outflow (m2)
+      COMPLEX(wp), ALLOCATABLE, DIMENSION(:)  ::   river_area_c       ! Comlex version of river_area for use in bit reproducible sums (m2)
    END TYPE RIVERS_DATA
    
@@ -60,15 +59,15 @@
       INTEGER                                   ::   ii, jj, rr          !: Loop indices
       INTEGER                                   ::   max_river
-      REAL(wp), POINTER, DIMENSION(:,:)         ::   river_number        ! 2D array containing the river outflow numbers
+      REAL(wp), DIMENSION(jpi,jpj)              ::   river_number        ! 2D array containing the river outflow numbers
       
       NAMELIST/nam_cpl_rnf_1d/file_riv_number, nn_cpl_river, ln_print_river_info
       !!----------------------------------------------------------------------
 
-      IF( nn_timing == 1 ) CALL timing_start('cpl_rnf_1d_init')
+      IF( ln_timing ) CALL timing_start('cpl_rnf_1d_init')
       
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'cpl_rnf_1d_init : initialization of river runoff coupling'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-      IF(lwp .AND. lflush) CALL flush(numout)
+      IF(lwp) CALL flush(numout)
       
       REWIND(numnam_cfg)
@@ -76,7 +75,7 @@
       ! Read the namelist
       READ  ( numnam_ref, nam_cpl_rnf_1d, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in reference namelist' )
       READ  ( numnam_cfg, nam_cpl_rnf_1d, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in configuration namelist', lwp )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in configuration namelist' )
       IF(lwm .AND. nprint > 2) WRITE ( numond, nam_cpl_rnf_1d )
 
@@ -88,9 +87,8 @@
       IF(lwp) WRITE(numout,*) '             Print river information = ',ln_print_river_info
       IF(lwp) WRITE(numout,*) ' '
-      IF(lwp .AND. lflush) CALL flush(numout)
-      
+      IF(lwp) CALL flush(numout)
+
       ! Assign space for river numbers
       ALLOCATE( rivers%river_number( jpi, jpj ) )
-      CALL wrk_alloc( jpi, jpj, river_number )
       
       ! Read the river numbers from netcdf file
@@ -113,5 +111,5 @@
       IF ( ln_print_river_info .AND. lwp) THEN
          WRITE(numout,*) 'Maximum river number in input file = ',max_river
-         IF(lflush) CALL flush(numout)
+         CALL flush(numout)
       END IF
       
@@ -132,5 +130,5 @@
       
       ! Use mpp_sum to add together river areas on other processors
-      CALL mpp_sum( rivers%river_area_c, nn_cpl_river )
+      CALL mpp_sum( 'cpl_rnf_1d', rivers%river_area_c )
       
       ! Convert from complex number to real
@@ -142,5 +140,5 @@
       IF ( ln_print_river_info .AND. lwp) THEN
         WRITE(numout,*) 'Area of rivers 1 to 10 are ',rivers%river_area(1:10)
-        IF(lflush) CALL flush(numout)
+        CALL flush(numout)
       END IF
       
Index: /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/sbccpl.F90
===================================================================
--- /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/sbccpl.F90	(revision 12674)
+++ /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/sbccpl.F90	(revision 12675)
@@ -262,5 +262,5 @@
          &                  sn_rcv_icb   , sn_rcv_isf   , sn_rcv_wfreq , sn_rcv_tauw, nn_cats_cpl  ,   &
          &                  sn_rcv_ts_ice, sn_rcv_grnm  , sn_rcv_antm  ,                               &
-         &                  nn_coupled_iceshelf_fluxes  , ln_iceshelf_init_atmos                       &
+         &                  nn_coupled_iceshelf_fluxes  , ln_iceshelf_init_atmos ,                     &
          &                  rn_greenland_total_fw_flux  , rn_greenland_calving_fraction  ,             &
          &                  rn_antarctica_total_fw_flux , rn_antarctica_calving_fraction ,             &
@@ -1185,14 +1185,17 @@
       INTEGER  ::   ji, jj, jn             ! dummy loop indices
       INTEGER  ::   isec                   ! number of seconds since nit000 (assuming rdt did not change since nit000)
-      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars  
+      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars     
+      REAL(wp) ::   zcoef                  ! temporary scalar
+      LOGICAL  ::   ll_wrtstp              ! write diagnostics?
+      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient
       REAL(wp) ::   zgreenland_icesheet_mass_in, zantarctica_icesheet_mass_in 
       REAL(wp) ::   zgreenland_icesheet_mass_b, zantarctica_icesheet_mass_b 
       REAL(wp) ::   zmask_sum, zepsilon    
-      REAL(wp) ::   zcoef                  ! temporary scalar
-      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3
-      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient
       REAL(wp) ::   zzx, zzy               ! temporary variables
       REAL(wp), DIMENSION(jpi,jpj) ::   ztx, zty, zmsk, zemp, zqns, zqsr
       !!----------------------------------------------------------------------
+      !
+      ll_wrtstp  = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
       !
       IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
@@ -1574,5 +1577,4 @@
             WRITE(numout,*) 'Greenland icesheet mass rate of change (kg/s) is ', greenland_icesheet_mass_rate_of_change
             WRITE(numout,*) 'Greenland icesheet seconds lapsed since last change is ', greenland_icesheet_timelapsed
-            IF(lflush) CALL flush(numout)
          ENDIF
       ELSE IF ( nn_coupled_iceshelf_fluxes == 2 ) THEN
@@ -1612,5 +1614,4 @@
             WRITE(numout,*) 'Antarctica icesheet mass rate of change (kg/s) is ', antarctica_icesheet_mass_rate_of_change
             WRITE(numout,*) 'Antarctica icesheet seconds lapsed since last change is ', antarctica_icesheet_timelapsed
-            IF(lflush) CALL flush(numout)
          ENDIF
       ELSE IF ( nn_coupled_iceshelf_fluxes == 2 ) THEN
Index: /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/sbcisf.F90
===================================================================
--- /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/sbcisf.F90	(revision 12674)
+++ /NEMO/branches/UKMO/NEMO_4.0.1_icesheet_and_river_coupling/src/OCE/SBC/sbcisf.F90	(revision 12675)
@@ -96,6 +96,8 @@
       REAL(wp), DIMENSION(:,:)  , ALLOCATABLE ::   zqhcisf2d
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   zfwfisf3d, zqhcisf3d, zqlatisf3d
+      LOGICAL :: ll_wrtstp
       !!---------------------------------------------------------------------
       !
+      ll_wrtstp  = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
       IF( MOD( kt-1, nn_fsbc) == 0 ) THEN    ! compute salt and heat flux
          !
@@ -138,5 +140,5 @@
 
                 ! All related global sums must be done bit reproducibly
-                 zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
+                 zgreenland_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
 
                  ! use ABS function because we need to preserve the sign of fwfisf
@@ -148,9 +150,9 @@
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum
 
-                 zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
+                 zgreenland_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
 
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum
 
-                 zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
+                 zantarctica_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
 
                  ! use ABS function because we need to preserve the sign of fwfisf
@@ -162,5 +164,5 @@
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum
 
-                 zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
+                 zantarctica_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
 
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum
@@ -189,5 +191,5 @@
 
                 ! All related global sums must be done bit reproducibly
-                 zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
+                 zgreenland_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
 
                  ! use ABS function because we need to preserve the sign of fwfisf
@@ -199,9 +201,9 @@
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum
 
-                 zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
+                 zgreenland_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) )
 
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum
 
-                 zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
+                 zantarctica_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
 
                  ! use ABS function because we need to preserve the sign of fwfisf
@@ -213,5 +215,5 @@
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum
 
-                 zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
+                 zantarctica_fwfisf_sum = glob_sum( 'sbcisf', fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) )
 
                  IF(lwp .AND. ll_wrtstp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum
