Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 9321)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 10269)
@@ -46,4 +46,5 @@
    USE eosbn2
    USE sbcrnf   , ONLY : l_rnfcpl
+   USE cpl_rnf_1d, ONLY: nn_cpl_river, cpl_rnf_1d_init, cpl_rnf_1d_to_2d   ! Variables used in 1D river outflow
 #if defined key_cpl_carbon_cycle
    USE p4zflx, ONLY : oce_co2
@@ -111,5 +112,6 @@
    INTEGER, PARAMETER ::   jpr_atm_pco2 = 46          ! Incoming atm CO2 flux
    INTEGER, PARAMETER ::   jpr_atm_dust = 47          ! Incoming atm aggregate dust 
-   INTEGER, PARAMETER ::   jprcv      = 47            ! total number of fields received
+   INTEGER, PARAMETER ::   jpr_rnf_1d = 48            ! 1D river runoff
+   INTEGER, PARAMETER ::   jprcv      = 48            ! total number of fields received
 
    INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction sent to the atmosphere
@@ -175,4 +177,5 @@
    LOGICAL     ::   ln_usecplmask          !  use a coupling mask file to merge data received from several models
                                            !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
+
    TYPE ::   DYNARR     
       REAL(wp), POINTER, DIMENSION(:,:,:)    ::   z3   
@@ -253,4 +256,5 @@
       NAMELIST/namsbc_cpl/  sn_snd_bio_co2, sn_snd_bio_dms, sn_snd_bio_chloro,                        &
          &                  sn_rcv_atm_pco2, sn_rcv_atm_dust
+
 
       !!---------------------------------------------------------------------
@@ -324,4 +328,5 @@
          WRITE(numout,*)'  rn_antarctica_calving_fraction      = ', rn_antarctica_calving_fraction
          WRITE(numout,*)'  rn_iceshelf_fluxes_tolerance        = ', rn_iceshelf_fluxes_tolerance
+
       ENDIF
 
@@ -339,5 +344,9 @@
 
       ! default definitions of srcv
-      srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1.   ;   srcv(:)%nct = 1
+      srcv(:)%laction = .FALSE.
+      srcv(:)%clgrid = 'T'
+      srcv(:)%nsgn = 1.
+      srcv(:)%nct = 1
+      srcv(:)%dimensions = 2
 
       !                                                      ! ------------------------- !
@@ -460,6 +469,11 @@
       !                                                      ! ------------------------- !
       srcv(jpr_rnf   )%clname = 'O_Runoff'
-      IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) THEN
-         srcv(jpr_rnf)%laction = .TRUE.
+      srcv(jpr_rnf_1d   )%clname = 'ORunff1D'
+      IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' .OR. TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) THEN 
+         IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) srcv(jpr_rnf)%laction = .TRUE.
+         IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) THEN
+            srcv(jpr_rnf_1d)%laction = .TRUE.
+            srcv(jpr_rnf_1d)%dimensions = 1 ! 1D field passed through coupler
+         END IF
          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
@@ -468,7 +482,15 @@
       ENDIF
       !
-      srcv(jpr_cal   )%clname = 'OCalving'   ;   IF( TRIM( sn_rcv_cal%cldes ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.
-      srcv(jpr_grnm  )%clname = 'OGrnmass'   ;   IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled' )   srcv(jpr_grnm)%laction = .TRUE.
-      srcv(jpr_antm  )%clname = 'OAntmass'   ;   IF( TRIM( sn_rcv_antm%cldes ) == 'coupled' )   srcv(jpr_antm)%laction = .TRUE.
+      srcv(jpr_cal   )%clname = 'OCalving'   
+      IF( TRIM( sn_rcv_cal%cldes ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.     
+
+      srcv(jpr_grnm  )%clname = 'OGrnmass' 
+      IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled' .OR. TRIM( sn_rcv_grnm%cldes ) == 'coupled0d' ) srcv(jpr_grnm)%laction = .TRUE.        
+      IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled0d' ) srcv(jpr_grnm  )%dimensions = 0 ! Scalar field
+      
+      srcv(jpr_antm  )%clname = 'OAntmass'
+      IF( TRIM( sn_rcv_antm%cldes ) == 'coupled' .OR. TRIM( sn_rcv_antm%cldes ) == 'coupled0d' )  srcv(jpr_antm)%laction = .TRUE.
+      IF( TRIM( sn_rcv_antm%cldes ) == 'coupled0d' ) srcv(jpr_antm  )%dimensions = 0 ! Scalar field   
+      
 
 
@@ -657,23 +679,4 @@
          ENDIF
       ENDIF
-      
-      ! =================================================== !
-      ! Allocate all parts of frcv used for received fields !
-      ! =================================================== !
-      DO jn = 1, jprcv
-         IF ( srcv(jn)%laction ) ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
-      END DO
-      ! Allocate taum part of frcv which is used even when not received as coupling field
-      IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) )
-      ! Allocate w10m part of frcv which is used even when not received as coupling field
-      IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
-      ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
-      IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
-      IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
-      ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
-      IF( k_ice /= 0 ) THEN
-         IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) )
-         IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) )
-      END IF
 
       ! ================================ !
@@ -683,8 +686,12 @@
       !                 define send or not from the namelist parameters (ssnd(:)%laction)
       !                 define the north fold type of lbc               (ssnd(:)%nsgn)
-      
+
       ! default definitions of nsnd
-      ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1.  ; ssnd(:)%nct = 1
-         
+      ssnd(:)%laction = .FALSE.
+      ssnd(:)%clgrid = 'T'
+      ssnd(:)%nsgn = 1.
+      ssnd(:)%nct = 1
+      ssnd(:)%dimensions = 2
+
       !                                                      ! ------------------------- !
       !                                                      !    Surface temperature    !
@@ -942,4 +949,42 @@
          ENDIF
       ENDIF
+      
+      ! Initialise 1D river outflow scheme 
+      nn_cpl_river = 1 
+      IF ( TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) CALL cpl_rnf_1d_init   ! Coupled runoff using 1D array
+
+      ! =================================================== !
+      ! Allocate all parts of frcv used for received fields !
+      ! =================================================== !
+      DO jn = 1, jprcv
+
+         IF ( srcv(jn)%laction ) THEN 
+            SELECT CASE( srcv(jn)%dimensions )
+            !
+            CASE( 0 )   ! Scalar field
+               ALLOCATE( frcv(jn)%z3(1,1,1) )
+               
+            CASE( 1 )   ! 1D field
+               ALLOCATE( frcv(jn)%z3(nn_cpl_river,1,1) )
+               
+            CASE DEFAULT  ! 2D (or pseudo 3D) field.
+               ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
+               
+            END SELECT
+         END IF
+
+      END DO
+      ! Allocate taum part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) )
+      ! Allocate w10m part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
+      ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
+      IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
+      ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
+      IF( k_ice /= 0 ) THEN
+         IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) )
+         IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) )
+      END IF
 
       !
@@ -1073,7 +1118,14 @@
       isec = ( kt - nit000 ) * NINT( rdttra(1) )                ! date of exchanges
       DO jn = 1, jprcv                                          ! received fields sent by the atmosphere
-         IF( srcv(jn)%laction )   CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) )
+         IF( srcv(jn)%laction ) THEN 
+
+            IF ( srcv(jn)%dimensions <= 1 ) THEN
+               CALL cpl_rcv_1d( jn, isec, frcv(jn)%z3, SIZE(frcv(jn)%z3), nrcvinfo(jn) )
+            ELSE
+               CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) )
+            END IF
+
+         END IF
       END DO
-
       !                                                      ! ========================= !
       IF( srcv(jpr_otx1)%laction ) THEN                      !  ocean stress components  !
@@ -1378,10 +1430,20 @@
 
       IF( srcv(jpr_grnm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN
-         greenland_icesheet_mass_array(:,:) = frcv(jpr_grnm)%z3(:,:,1)
-         ! take average over ocean points of input array to avoid cumulative error over time
-         ! The following must be bit reproducible over different PE decompositions
-         zgreenland_icesheet_mass_in = glob_sum( greenland_icesheet_mass_array(:,:) * tmask(:,:,1) )
-
-         zgreenland_icesheet_mass_in = zgreenland_icesheet_mass_in / zmask_sum
+         
+         IF( srcv(jpr_grnm)%dimensions == 0 ) THEN
+      
+           ! This is a zero dimensional, single value field. 
+           zgreenland_icesheet_mass_in =  frcv(jpr_grnm)%z3(1,1,1)
+           
+         ELSE
+         
+           greenland_icesheet_mass_array(:,:) = frcv(jpr_grnm)%z3(:,:,1) 
+           ! take average over ocean points of input array to avoid cumulative error over time 
+           ! The following must be bit reproducible over different PE decompositions 
+           zgreenland_icesheet_mass_in = glob_sum( greenland_icesheet_mass_array(:,:) * tmask(:,:,1) )  
+           zgreenland_icesheet_mass_in = zgreenland_icesheet_mass_in / zmask_sum 
+           
+         END IF
+
          greenland_icesheet_timelapsed = greenland_icesheet_timelapsed + rdt         
 
@@ -1415,10 +1477,20 @@
       !                                                        ! land ice masses : Antarctica
       IF( srcv(jpr_antm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN
-         antarctica_icesheet_mass_array(:,:) = frcv(jpr_antm)%z3(:,:,1)
-         ! take average over ocean points of input array to avoid cumulative error from rounding errors over time
-         ! The following must be bit reproducible over different PE decompositions
-         zantarctica_icesheet_mass_in = glob_sum( antarctica_icesheet_mass_array(:,:) * tmask(:,:,1) )
-
-         zantarctica_icesheet_mass_in = zantarctica_icesheet_mass_in / zmask_sum
+      
+         IF( srcv(jpr_antm)%dimensions == 0 ) THEN
+         
+           ! This is a zero dimensional, single value field. 
+           zantarctica_icesheet_mass_in = frcv(jpr_antm)%z3(1,1,1)
+           
+         ELSE
+         
+           antarctica_icesheet_mass_array(:,:) = frcv(jpr_antm)%z3(:,:,1) 
+           ! take average over ocean points of input array to avoid cumulative error from rounding errors over time 
+           ! The following must be bit reproducible over different PE decompositions 
+           zantarctica_icesheet_mass_in = glob_sum( antarctica_icesheet_mass_array(:,:) * tmask(:,:,1) )  
+           zantarctica_icesheet_mass_in = zantarctica_icesheet_mass_in / zmask_sum 
+           
+         END IF
+
          antarctica_icesheet_timelapsed = antarctica_icesheet_timelapsed + rdt         
 
@@ -1821,4 +1893,5 @@
       ! --- runoffs (included in emp later on) --- !
       IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+      IF( srcv(jpr_rnf_1d)%laction )   CALL cpl_rnf_1d_to_2d(frcv(jpr_rnf_1d)%z3(:,:,:))
 
       ! --- calving (put in emp_tot and emp_oce) --- !
@@ -1858,4 +1931,5 @@
       ! runoffs and calving (put in emp_tot)
       IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+      IF( srcv(jpr_rnf_1d)%laction )   CALL cpl_rnf_1d_to_2d(frcv(jpr_rnf_1d)%z3(:,:,:))
       IF( iom_use('hflx_rnf_cea') )   &
          CALL iom_put( 'hflx_rnf_cea' , rnf(:,:) * zcptn(:,:) )
