Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 5222)
@@ -264,5 +264,12 @@
 
       !   daily mean qsr when diurnal cycle is applied on physics - for BGC models
-      IF( l_trcdm2dc ) qsr_mean(:,:) =  pfrld(:,:) * qsr_mean(:,:) + ( 1. - pfrld(:,:) ) * fstric_mean(:,:)
+      IF( l_trcdm2dc ) THEN qsr_mean(:,:) =  pfrld(:,:) * qsr_mean(:,:) + ( 1. - pfrld(:,:) ) * fstric_mean(:,:)
+         !   computation the solar flux at ocean surface
+         IF( lk_cpl ) THEN
+            qsr_mean(:,:) = qsr_mean(:,:) + ( fstric_mean(:,:) - qsr_ice_mean(:,:,1) ) * ( 1.0 - pfrld(:,:) )  ! qsr_mean = qsr_tot
+         ELSE
+            qsr_mean(:,:) =  pfrld(:,:) * qsr_mean(:,:) + ( 1. - pfrld(:,:) ) * fstric_mean(:,:)
+         ENDIF
+      ENDIF
 
 
Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 5222)
@@ -219,15 +219,41 @@
 
 
+      IF( lk_cpl ) THEN 
+         !!! LIM2 version zqsr = qsr_tot(ji,jj) + ( fstric(ji,jj) - qsr_ice(ji,jj,1) ) * ( 1.0 - pfrld(ji,jj) )
+          zfcm1 = qsr_tot(ji,jj)
+          DO jl = 1, jpl
+             zfcm1 = zfcm1 + ( ftr_ice(ji,jj,jl) - qsr_ice(ji,jj,jl) ) * a_i_b(ji,jj,jl)
+          END DO
+      ELSE
+          !!! LIM2 version zqsr = pfrld(ji,jj) * qsr(ji,jj)  + ( 1.  - pfrld(ji,jj) ) * fstric(ji,jj)
+          zfcm1   = pfrld(ji,jj) * qsr(ji,jj)
+          DO jl = 1, jpl
+             zfcm1   = zfcm1 + a_i_b(ji,jj,jl) * ftr_ice(ji,jj,jl)
+          END DO
+      ENDIF
+
       !   daily mean qsr when diurnal cycle is applied on physics - for BGC models
       IF( l_trcdm2dc ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zfcm1 = pfrld(ji,jj) * qsr_mean(ji,jj)
-               DO jl = 1, jpl
-                  zfcm1 = zfcm1 + ftr_ice_mean(ji,jj,jl)
-               END DO
-               qsr_mean(ji,jj) = zfcm1                                      
+         IF( lk_cpl ) THEN 
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zfcm1 = qsr_mean(ji,jj)
+                  DO jl = 1, jpl
+                    zfcm1 = zfcm1 + ftr_ice_mean(ji,jj,jl) - qsr_ice_mean(ji,jj,jl) * a_i_b(ji,jj,jl)
+                 END DO
+                 qsr_mean(ji,jj) = zfcm1                                      
+               ENDDO
             ENDDO
-         ENDDO
+         ELSE
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zfcm1 = pfrld(ji,jj) * qsr_mean(ji,jj)
+                  DO jl = 1, jpl
+                     zfcm1 = zfcm1 + ftr_ice_mean(ji,jj,jl)
+                  END DO
+                  qsr_mean(ji,jj) = zfcm1                                      
+               ENDDO
+            ENDDO
+         ENDIF
       ENDIF
 
Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 5222)
@@ -81,5 +81,6 @@
    !!              Ocean Surface Boundary Condition fields
    !!----------------------------------------------------------------------
-   LOGICAL , PUBLIC ::   l_trcdm2dc               !: In case of Diurnal Cycle short wave, compute a Daily Mean short waves flux
+   LOGICAL , PUBLIC ::  l_trcdm2dc               !: In case of Diurnal Cycle short wave, compute a Daily Mean short waves flux
+   INTEGER , PUBLIC ::  n_cpl_qsr                !: qsr coupling frequency per days
    !
    LOGICAL , PUBLIC ::   lhftau = .FALSE.        !: HF tau used in TKE: mean(stress module) - module(mean stress)
@@ -137,5 +138,5 @@
       !!                  ***  FUNCTION sbc_oce_alloc  ***
       !!---------------------------------------------------------------------
-      INTEGER :: ierr(6)
+      INTEGER :: ierr(5)
       !!---------------------------------------------------------------------
       ierr(:) = 0
@@ -145,5 +146,5 @@
          !
       ALLOCATE( qns_tot(jpi,jpj) , qns  (jpi,jpj) , qns_b(jpi,jpj),        &
-         &      qsr_tot(jpi,jpj) , qsr  (jpi,jpj) ,                        &
+         &      qsr_tot(jpi,jpj) , qsr  (jpi,jpj) , qsr_mean(jpi,jpj),     &
          &      emp    (jpi,jpj) , emp_b(jpi,jpj) ,                        &
          &      sfx    (jpi,jpj) , sfx_b(jpi,jpj) , emp_tot(jpi,jpj), fmmflx(jpi,jpj), STAT=ierr(2) )
@@ -159,8 +160,6 @@
          &      ssv_m  (jpi,jpj) , sss_m  (jpi,jpj), ssh_m(jpi,jpj) , STAT=ierr(4) )
          !
-         IF( l_trcdm2dc )   ALLOCATE( qsr_mean(jpi,jpj) , STAT=ierr(5) )
-         !
 #if defined key_vvl
-      ALLOCATE( e3t_m(jpi,jpj) , STAT=ierr(6) )
+      ALLOCATE( e3t_m(jpi,jpj) , STAT=ierr(5) )
 #endif
          !
Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 5222)
@@ -135,4 +135,7 @@
 
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   albedo_oce_mix     ! ocean albedo sent to atmosphere (mix clear/overcast sky)
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   :: qsr_tot_tmp     ! arrays containing consecutives qsr in a day
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: qsr_ice_tmp     !  ===                        === 
 
    INTEGER , ALLOCATABLE, SAVE, DIMENSION(    :) ::   nrcvinfo           ! OASIS info argument
@@ -583,7 +586,11 @@
       ENDIF
       !
-      IF( ln_dm2dc .AND. ( cpl_freq( jpr_qsroce ) + cpl_freq( jpr_qsrmix ) /= 86400 ) )   &
+      n_cpl_qsr = INT( 86400 / ( cpl_freq( jpr_qsroce ) + cpl_freq( jpr_qsrmix ) )  ! qsr coupling frequency per day
+      !
+      IF( ln_dm2dc .AND. n_cpl_qsr /= 1 )   &
          &   CALL ctl_stop( 'sbc_cpl_init: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
 
+      !
+      !
       CALL wrk_dealloc( jpi,jpj, zacs, zaos )
       !
@@ -1056,5 +1063,5 @@
    
 
-   SUBROUTINE sbc_cpl_ice_flx( p_frld  , palbi   , psst    , pist    )
+   SUBROUTINE sbc_cpl_ice_flx( p_frld  , kt, palbi   , psst    , pist    )
       !!----------------------------------------------------------------------
       !!             ***  ROUTINE sbc_cpl_ice_flx  ***
@@ -1096,4 +1103,5 @@
       !!                   sprecip             solid precipitation over the ocean  
       !!----------------------------------------------------------------------
+      INTEGER,  INTENT(in   ), OPTIONAL         ::   kt     !  time-step
       REAL(wp), INTENT(in   ), DIMENSION(:,:)   ::   p_frld     ! lead fraction                [0 to 1]
       ! optional arguments, used only in 'mixed oce-ice' case
@@ -1102,5 +1110,5 @@
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   pist    ! ice surface temperature     [Kelvin]
       !
-      INTEGER ::   jl   ! dummy loop index
+      INTEGER ::   it, jl   ! dummy loop index
       REAL(wp), POINTER, DIMENSION(:,:) ::   zcptn, ztmp, zicefr
       !!----------------------------------------------------------------------
@@ -1109,4 +1117,6 @@
       !
       CALL wrk_alloc( jpi,jpj, zcptn, ztmp, zicefr )
+
+      IF( PRESENT( kt ) ) it = kt
 
       zicefr(:,:) = 1.- p_frld(:,:)
@@ -1272,4 +1282,5 @@
             &                     + palbi         (:,:,1) * zicefr(:,:) ) )
       END SELECT
+      !
       IF( ln_dm2dc ) THEN   ! modify qsr to include the diurnal cycle
          qsr_tot(:,:  ) = sbc_dcy( qsr_tot(:,:  ) )
@@ -1278,4 +1289,6 @@
          ENDDO
       ENDIF
+      !
+      IF( l_trcdm2dc )  CALL sbc_cpl_qsr_mean( it )    ! computation of daily mean qsr for biogeochemical model if needed
 
       !                                                      ! ========================= !
@@ -1313,4 +1326,39 @@
       !
    END SUBROUTINE sbc_cpl_ice_flx
+
+   SUBROUTINE sbc_cpl_qsr_mean( kt )
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_mean  ***
+      !!
+      !! ** Purpose :   Compute daily mean qsr for biogeochmeical model in case of diurnal cycle
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt
+      INTEGER  :: jn
+
+      IF( kt == nit000 ) THEN
+         ALLOCATE( qsr_tot_tmp(jpi,jpj,n_cpl_qsr), qsr_ice_tmp(jpi,jpj,jpl,n_cpl_qsr) ) 
+         DO jn = 1, n_cpl_qsr
+            qsr_tot_tmp(:,:  ,jn) = qsr_tot(:,:  )
+            qsr_ice_tmp(:,:,:,jn) = qsr_ice(:,:,:)
+         ENDDO
+         qsr_mean    (:,:  ) = qsr_tot(:,:  ) 
+         qsr_ice_mean(:,:,:) = qsr_ice(:,:,:)
+      ENDIF
+      !
+      IF( kt /= nit000 .AND.  nrcvinfo(jpr_qsroce) == OASIS_Rcv ) THEN !  => need to be done only when we receive the field
+         DO jn = 1, n_cpl_qsr - 1
+            qsr_tot_tmp(:,:  ,jn) = qsr_tot_tmp(:,:  ,jn+1)
+            qsr_ice_tmp(:,:,:,jn) = qsr_ice_tmp(:,:,:,jn+1)
+         ENDDO
+         qsr_tot_tmp(:,:  ,n_cpl_qsr ) = qsr_tot(:,:  )
+         qsr_ice_tmp(:,:,:,n_cpl_qsr ) = qsr_ice(:,:,:)
+         !
+         qsr_mean    (:,:) = SUM( qsr_tot_tmp(:,:,:), 3 ) / n_cpl_qsr 
+         qsr_ice_mean(:,:) = SUM( qsr_ice_tmp(:,:,:), 4 ) / n_cpl_qsr 
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_cpl_qsr_mean
    
    
Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 5222)
@@ -224,5 +224,5 @@
          SELECT CASE( kblk )
          CASE ( jp_cpl )
-            CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=zalb_ice, psst=sst_m, pist=t_su    )
+            CALL sbc_cpl_ice_flx( p_frld=pfrld, kt=kt, palbi=zalb_ice, psst=sst_m, pist=t_su    )
             IF( nn_limflx == 2 )   CALL ice_lim_flx( t_su, zalb_ice, qns_ice, qsr_ice ,   &
                &                                           dqns_ice, qla_ice, dqla_ice, nn_limflx )
Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 5222)
@@ -233,5 +233,5 @@
             CALL sbc_cpl_ice_flx( frld,                                              &
             !                                optional arguments, used only in 'mixed oce-ice' case
-            &                                             palbi = zalb_ice, psst = sst_m, pist = zsist )
+            &                                             kt=kt, palbi=zalb_ice, psst=sst_m, pist=zsist )
             sprecip(:,:) = - emp_ice(:,:)   ! Ugly patch, WARNING, in coupled mode, sublimation included in snow (parsub = 0.)
          ENDIF
Index: /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 5221)
+++ /branches/2015/dev_r5204_CNRS_PISCES_dcy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 5222)
@@ -152,14 +152,4 @@
       END SELECT
       !
-      IF( ln_dm2dc .AND. lk_top  )  THEN   
-         l_trcdm2dc = .TRUE.
-         IF( lwp ) THEN
-            WRITE(numout,*) "In case of diurnal cycle coupled with passive tracers"
-            WRITE(numout,*) "Computation of a daily mean shortwave for some biogeochemical models"
-         ENDIF
-      ELSE             
-         l_trcdm2dc = .FALSE.
-      ENDIF
-
       !                              ! allocate sbc arrays
       IF( sbc_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_oce arrays' )
@@ -276,4 +266,11 @@
       !
       IF( nsbc   == jp_cpl )   CALL sbc_cpl_init (nn_ice)      ! OASIS initialisation. must be done before first time step
+      
+      l_trcdm2dc == lk_top .AND. ( ln_dm2dc .OR. ( lk_cpl .AND. n_cpl_qsr /= 1 ) )  
+      IF( l_trcdm2dc .AND. lwp ) THEN
+            WRITE(numout,*) "Coupling with passive tracers and used of diurnal cycle !!!!! "
+            WRITE(numout,*) "Computation of a daily mean shortwave for some biogeochemical models"
+         ENDIF
+      ENDIF
 
    END SUBROUTINE sbc_init
