Index: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 2224)
+++ branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 2228)
@@ -177,7 +177,5 @@
       ENDIF
 
-                       CALL fld_read( kt, nn_fsbc, sf )        ! input fields provided at the current time-step
-
-      IF( ln_dm2dc )   CALL sbc_dcy ( kt , sf(jp_qsr)%fnow )   ! modify now Qsr to include the diurnal cycle
+      CALL fld_read( kt, nn_fsbc, sf )        ! input fields provided at the current time-step
 
 #if defined key_lim3
@@ -264,7 +262,9 @@
       ! ----------------------------------------------------------------------------- !
     
+      IF( ln_dm2dc ) THEN   ;   qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) )   ! modify now Qsr to include the diurnal cycle
+      ELSE                  ;   qsr(:,:) =          sf(jp_qsr)%fnow(:,:,1)
+      ENDIF
       ! ocean albedo assumed to be 0.066
-!CDIR COLLAPSE
-      qsr (:,:) = ( 1. - 0.066 ) * sf(jp_qsr)%fnow(:,:,1) * tmask(:,:,1)                                     ! Short Wave
+      qsr (:,:) = ( 1. - 0.066 ) * qsr(:,:) * tmask(:,:,1)                                                 ! Short Wave
 !CDIR COLLAPSE
       zqlw(:,:) = (  sf(jp_qlw)%fnow(:,:,1) - Stef * zst(:,:)*zst(:,:)*zst(:,:)*zst(:,:)  ) * tmask(:,:,1)   ! Long  Wave
Index: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 2224)
+++ branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 2228)
@@ -23,4 +23,5 @@
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
+   USE sbcdcy          ! surface boundary condition: diurnal cycle
    USE phycst          ! physical constants
 #if defined key_lim3
@@ -728,4 +729,5 @@
          IF( srcv(jpr_qsroce)%laction )   qsr(:,:) = frcv(:,:,jpr_qsroce) 
          IF( srcv(jpr_qsrmix)%laction )   qsr(:,:) = frcv(:,:,jpr_qsrmix)
+         IF( ln_dm2dc )   qsr(:,:) = sbc_dcy( qsr )                           ! modify qsr to include the diurnal cycle
          !
          !                                                       ! total freshwater fluxes over the ocean (emp, emps)
@@ -1159,4 +1161,8 @@
             &                     + palbi         (:,:,1) * zicefr(:,:,1) ) )
       END SELECT
+      IF( ln_dm2dc ) THEN   ! modify qsr to include the diurnal cycle
+         pqsr_tot(:,:  ) = sbc_dcy( pqsr_tot(:,:  ) )
+         pqsr_ice(:,:,1) = sbc_dcy( pqsr_ice(:,:,1) )
+      ENDIF
 
       SELECT CASE( TRIM( cn_rcv_dqnsdt ) )
Index: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcdcy.F90
===================================================================
--- branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 2224)
+++ branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 2228)
@@ -16,12 +16,12 @@
    USE phycst           ! ocean physics
    USE dom_oce          ! ocean space and time domain
+   USE sbc_oce          ! Surface boundary condition: ocean fields
    USE in_out_manager   ! I/O manager
 
    IMPLICIT NONE
    PRIVATE
-   INTEGER                      ::   nday_qsr                    ! day when parameters were computed
+   INTEGER, PUBLIC              ::   nday_qsr                    ! day when parameters were computed
    REAL(wp), DIMENSION(jpi,jpj) ::   raa , rbb  , rcc  , rab     ! parameters used to compute the diurnal cycle
    REAL(wp), DIMENSION(jpi,jpj) ::   rtmd, rdawn, rdusk, rscal   !     -       -         -           -      -
-   REAL(wp), DIMENSION(jpi,jpj) ::   qsr_daily                   ! to hold daily mean QSR
   
    PUBLIC   sbc_dcy     ! routine called by sbc
@@ -34,5 +34,5 @@
 CONTAINS
 
-      SUBROUTINE sbc_dcy( kt, pqsr )
+      FUNCTION sbc_dcy( pqsrin ) RESULT( zqsrout )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE sbc_dcy  ***
@@ -48,14 +48,14 @@
       !!              Part 1: a diurnally forced OGCM. Climate Dynamics 29:6, 575-590.
       !!----------------------------------------------------------------------
-      INTEGER,                        INTENT(in   ) ::   kt     ! ocean time-step index
-      REAL(wp), DIMENSION(jpi,jpj,1), INTENT(inout) ::   pqsr   ! QSR flux with diurnal cycle
-      !!
-      INTEGER  ::   ji, jj                                      ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pqsrin    ! input daily QSR flux 
+      !!
+      INTEGER  ::   ji, jj                                       ! dummy loop indices
       REAL(wp) ::   ztwopi, zinvtwopi, zconvrad 
       REAL(wp) ::   zlo, zup, zlousd, zupusd
-      REAL(wp) ::   zdsws, zdecrad, ztx
+      REAL(wp) ::   zdsws, zdecrad, ztx, zsin, zcos
       REAL(wp) ::   ztmp, ztmp1, ztmp2, ztest
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqsrout                  ! output QSR flux with diurnal cycle
       !---------------------------statement functions------------------------
-      REAL(wp) ::   fintegral, pt1, pt2, paaa, pbbb, pccc       ! dummy statement function arguments
+      REAL(wp) ::   fintegral, pt1, pt2, paaa, pbbb, pccc        ! dummy statement function arguments
       fintegral( pt1, pt2, paaa, pbbb, pccc ) =                         &
          &   paaa * pt2 + zinvtwopi * pbbb * SIN(pccc + ztwopi * pt2)   &
@@ -70,9 +70,9 @@
 
       ! When are we during the day (from 0 to 1)
-      zlo = MOD( rdt / rday * REAL( kt-nit000, wp ), 1.)
-      zup = zlo + rdt / rday
+      zlo = ( REAL(nsec_day, wp) - 0.5   * rdttra(1) ) / rday
+      zup = zlo + ( REAL(nn_fsbc, wp) * rdttra(1) ) / rday
 
       !                                          
-      IF( kt == nit000 ) THEN       ! first time step only               
+      IF( nday_qsr == -1 ) THEN       ! first time step only               
          IF(lwp) THEN
             WRITE(numout,*)
@@ -81,5 +81,4 @@
             WRITE(numout,*)
          ENDIF
-         nday_qsr = 0
          ! Compute rcc needed to compute the time integral of the diurnal cycle
          rcc(:,:) = zconvrad * glamt(:,:) - rpi
@@ -99,16 +98,15 @@
          nday_qsr = nday 
          ! number of days since the previous winter solstice (supposed to be always 21 December)         
-         zdsws = 11 + nday_year
+         zdsws = REAL(11 + nday_year, wp)
          ! declination of the earths orbit
          zdecrad = (-23.5 * zconvrad) * COS( zdsws * ztwopi / REAL(nyear_len(1),wp) )
-         ! save the daily QSR for nest hours of the day
-         qsr_daily(:,:) = pqsr(:,:,1)
          ! Compute A and B needed to compute the time integral of the diurnal cycle
         
+         zsin = SIN( zdecrad )   ;   zcos = COS( zdecrad )
          DO jj = 1, jpj
             DO ji = 1, jpi
                ztmp = zconvrad * gphit(ji,jj)
-               raa(ji,jj) = SIN( ztmp ) * SIN( zdecrad )
-               rbb(ji,jj) = COS( ztmp ) * COS( zdecrad )
+               raa(ji,jj) = SIN( ztmp ) * zsin
+               rbb(ji,jj) = COS( ztmp ) * zcos
             END DO  
          END DO  
@@ -140,5 +138,4 @@
          rdawn(:,:) = MOD((rdawn(:,:) + 1.), 1.)
          rdusk(:,:) = MOD((rdusk(:,:) + 1.), 1.)
-
 
          !     2.2 Compute the scalling function:
@@ -166,5 +163,5 @@
          END DO  
          !
-         ztmp = rday / rdt
+         ztmp = rday / ( rdttra(1) * REAL(nn_fsbc, wp) )
          rscal(:,:) = rscal(:,:) * ztmp
 
@@ -184,5 +181,5 @@
                   zupusd = MAX(zupusd, zlo)
                   ztmp = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
-                  pqsr(ji,jj,1) = qsr_daily(ji,jj) * ztmp * rscal(ji,jj)
+                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
                   !
                ELSE                                         ! day time in two parts
@@ -194,14 +191,14 @@
                   ztmp2 = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
                   ztmp = ztmp1 + ztmp2
-                  pqsr(ji,jj,1) = qsr_daily(ji,jj) * ztmp * rscal(ji,jj)
+                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
                ENDIF
             ELSE                                   ! 24h light or 24h night
                !
-               IF( raa(ji,jj) > rbb(ji,jj) ) THEN         ! 24h day
+               IF( raa(ji,jj) > rbb(ji,jj) ) THEN           ! 24h day
                   ztmp = fintegral(zlo, zup, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
-                  pqsr(ji,jj,1) = qsr_daily(ji,jj) * ztmp * rscal(ji,jj)
+                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
                   !
                ELSE                                         ! No day
-                  pqsr(ji,jj,1) = 0.e0
+                  zqsrout(ji,jj) = 0.e0
                ENDIF
             ENDIF
@@ -209,5 +206,5 @@
       END DO  
       !
-   END SUBROUTINE sbc_dcy
+   END FUNCTION sbc_dcy
 
    !!======================================================================
Index: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcflx.F90
===================================================================
--- branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 2224)
+++ branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 2228)
@@ -123,9 +123,11 @@
       ENDIF
 
-                       CALL fld_read( kt, nn_fsbc, sf )       ! input fields provided at the current time-step
-      
-      IF( ln_dm2dc )   CALL sbc_dcy( kt , sf(jp_qsr)%fnow )   ! modify now Qsr to include the diurnal cycle
+      CALL fld_read( kt, nn_fsbc, sf )                            ! input fields provided at the current time-step
+     
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN                        ! update ocean fluxes at each SBC frequency
 
-      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN                    ! update ocean fluxes at each SBC frequency
+         IF( ln_dm2dc ) THEN   ;   qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) )   ! modify now Qsr to include the diurnal cycle
+         ELSE                  ;   qsr(:,:) =          sf(jp_qsr)%fnow(:,:,1)
+         ENDIF
 !CDIR COLLAPSE
          DO jj = 1, jpj                                           ! set the ocean fluxes from read fields
@@ -134,5 +136,4 @@
                vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj,1)
                qns (ji,jj) = sf(jp_qtot)%fnow(ji,jj,1) - sf(jp_qsr)%fnow(ji,jj,1)
-               qsr (ji,jj) = sf(jp_qsr )%fnow(ji,jj,1)
                emp (ji,jj) = sf(jp_emp )%fnow(ji,jj,1)
             END DO
Index: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 2224)
+++ branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 2228)
@@ -19,4 +19,5 @@
    USE sbc_oce          ! Surface boundary condition: ocean fields
    USE sbc_ice          ! Surface boundary condition: ice fields
+   USE sbcdcy           ! surface boundary condition: diurnal cycle
    USE sbcssm           ! surface boundary condition: sea-surface mean variables
    USE sbcana           ! surface boundary condition: analytical formulation
@@ -134,4 +135,6 @@
          &   CALL ctl_stop( 'sea-ice model requires a bulk formulation or coupled configuration' )
       
+      IF( ln_dm2dc )   nday_qsr = -1   ! initialisation flag
+
       IF( ln_dm2dc .AND. .NOT.( ln_flx .OR. ln_blk_core ) )   &
          &   CALL ctl_stop( 'diurnal cycle into qsr field from daily values requires a flux or core-bulk formulation' )
