Index: /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6009)
+++ /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6010)
@@ -145,11 +145,4 @@
       ENDIF
 
-      IF(ln_diurnal) THEN
-         CALL iom_put( "sst_wl"   , x_dsst               )    ! warm layer
-         CALL iom_put( "sst_cs"   , x_csdsst             )    ! cool skin
-      ENDIF
-       
-      IF( ln_diurnal_only ) RETURN 
-      
       IF( .NOT.lk_vvl ) THEN
          CALL iom_put( "e3t" , fse3t_n(:,:,:) )
Index: /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/cool_skin.F90
===================================================================
--- /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/cool_skin.F90	(revision 6009)
+++ /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/cool_skin.F90	(revision 6010)
@@ -94,5 +94,10 @@
      
       INTEGER :: ji,jj
-      
+     
+      IF ( .NOT. ln_blk_core ) THEN
+         CALL ctl_stop("cool_skin.f90: diurnal flux processing only implemented"//&
+         &             " for core bulk forcing")
+      ENDIF
+ 
       DO jj = 1,jpj
          DO ji = 1,jpi
Index: /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/diurnal_bulk.F90
===================================================================
--- /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/diurnal_bulk.F90	(revision 6009)
+++ /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/diurnal_bulk.F90	(revision 6010)
@@ -81,6 +81,6 @@
    END SUBROUTINE diurnal_sst_bulk_init
    
-   SUBROUTINE diurnal_sst_takaya_step(psolflux, pqflux, ptauflux, prho, p_rdt,&
-            &                  pla, pthick, pcoolthick, pmu, ld_calcfrac, &
+   SUBROUTINE diurnal_sst_takaya_step(kt, psolflux, pqflux, ptauflux, prho, p_rdt,&
+            &                  pla, pthick, pcoolthick, pmu, &
             &                  p_fvel_bkginc, p_hflux_bkginc)
       !!----------------------------------------------------------------------
@@ -123,8 +123,4 @@
       REAL(wp), INTENT(IN) :: p_rdt                         ! time-step
       
-      LOGICAL, OPTIONAL, &
-      &     INTENT(IN)  :: ld_calcfrac   ! Set TRUE to recalculate the 
-                                         ! solar fraction
-      
       ! Local variables 
       REAL(wp), DIMENSION(jpi,jpj) :: z_fvel              ! friction velocity     
@@ -136,4 +132,5 @@
       
       INTEGER :: ji,jj
+      INTEGER, INTENT(IN) :: kt                           ! time step
 
       ! Set optional arguments to their defaults
@@ -158,12 +155,7 @@
          zla(:,:) = pla(:,:)
       ENDIF
-      IF ( .NOT. PRESENT(ld_calcfrac) ) THEN
-         ll_calcfrac = .FALSE.
-      ELSE
-         ll_calcfrac = ld_calcfrac
-      ENDIF     
       
       ! If not done already, calculate the solar fraction
-      IF (ll_calcfrac ) THEN
+      IF ( kt==nit000 ) THEN
          DO jj = 1,jpj
             DO ji = 1, jpi
Index: /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/step_diu.F90
===================================================================
--- /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/step_diu.F90	(revision 6010)
+++ /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/DIU/step_diu.F90	(revision 6010)
@@ -0,0 +1,87 @@
+MODULE stp_diu
+   !!======================================================================
+   !!                       ***  MODULE stp_diu  ***
+   !! Time-stepping of diurnal cycle models
+   !!======================================================================
+   !! History :  3.7  ! 2015-11  (J. While)  Original code
+
+   USE step_oce         ! time stepping definition modules
+   USE iom
+
+   PUBLIC   stp_diurnal   ! called by nemogcm.F90 or step.F90
+
+   IMPLICIT NONE
+   PRIVATE
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id:$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   CONTAINS
+
+   SUBROUTINE stp_diurnal( kstp ) 
+      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index 
+      !!---------------------------------------------------------------------- 
+      !!                     ***  ROUTINE stp_diurnal  *** 
+      !!                       
+      !! ** Purpose : - Time stepping of diurnal SST model only 
+      !!   
+      !! ** Method  : -1- Update forcings and data   
+      !!              -2- Update ocean physics   
+      !!              -3- Compute the t and s trends   
+      !!              -4- Update t and s   
+      !!              -5- Compute the momentum trends 
+      !!              -6- Update the horizontal velocity 
+      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w) 
+      !!              -8- Outputs and diagnostics 
+      !!---------------------------------------------------------------------- 
+      INTEGER ::   jk       ! dummy loop indices
+      INTEGER ::   indic    ! error indicator if < 0 
+      REAL(wp), DIMENSION(jpi,jpj) :: z_fvel_bkginc, z_hflux_bkginc     
+      !! --------------------------------------------------------------------- 
+      
+      IF(ln_diurnal_only) THEN
+         indic = 0                                 ! reset to no error condition 
+         IF( kstp /= nit000 )   CALL day( kstp )   ! Calendar (day was already called at nit000 in day_init) 
+ 
+         CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! tell iom we are at time step kstp
+         IF( ln_crs ) THEN
+            CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" ) ! tell iom we are at time step kstp
+         ENDIF
+       
+            CALL sbc    ( kstp )                      ! Sea Boundary Conditions 
+      ENDIF
+     
+      ! Cool skin
+      IF ( .NOT.ln_diurnal ) CALL ctl_stop(  "stp_diurnal: ln_diurnal not set"  )
+         
+      IF ( .NOT. ln_blk_core ) THEN
+         CALL ctl_stop("step.f90: diurnal flux processing only implemented"//&
+         &             " for core forcing") 
+      ENDIF
+
+      CALL diurnal_sst_coolskin_step( qns, taum, rhop(:,:,1), rdt)
+
+      CALL iom_put( "sst_wl"   , x_dsst               )    ! warm layer (write out before update below).
+      CALL iom_put( "sst_cs"   , x_csdsst             )    ! cool skin
+
+      ! Diurnal warm layer model       
+      CALL diurnal_sst_takaya_step( kstp, & 
+      &    qsr, qns, taum, rhop(:,:,1), rdt) 
+
+      IF(ln_diurnal_only) THEN
+         IF( ln_diaobs )         CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
+     
+         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
+         ! Control and restarts 
+         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
+         IF( kstp == nit000   )   CALL iom_close( numror )     ! close input  ocean restart file 
+         IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
+     
+         IF( nn_timing == 1 .AND.  kstp == nit000  )   CALL timing_reset 
+      ENDIF
+       
+   END SUBROUTINE stp_diurnal  
+   
+END MODULE stp_diu
Index: /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 6009)
+++ /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 6010)
@@ -80,4 +80,5 @@
    USE lib_mpp         ! distributed memory computing
    USE diurnal_bulk    ! diurnal bulk SST 
+   USE stp_diu         ! diurnal bulk SST timestepping if run offline
 #if defined key_iomput
    USE xios            ! xIOserver
Index: /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6009)
+++ /branches/2015/dev_MetOffice_merge_2015/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6010)
@@ -234,12 +234,5 @@
       ! cool skin
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<      
-      IF ( ln_diurnal ) THEN 
-         IF ( .NOT. ln_blk_core ) THEN
-            CALL ctl_stop("step.f90: diurnal flux processing not implemented"//&
-            &             " for direct forcing")
-         ENDIF
-         CALL diurnal_sst_coolskin_step( & 
-                    qns, taum, rhop(:,:,1), rdt)
-      ENDIF
+      IF ( ln_diurnal )  CALL stp_diurnal( kstp )
       
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -256,19 +249,4 @@
       !
       IF( ln_crs     )   CALL crs_fld       ( kstp )  ! ocean model: online field coarsening & output
-      
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! diurnal warm layer
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF ( ln_diurnal ) THEN 
-         IF( kstp == nit000 )THEN 
-            CALL diurnal_sst_takaya_step( & 
-            &    qsr, qns, taum, rhop(:,:,1), &
-            &    rdt, ld_calcfrac = .TRUE.) 
-         ELSE 
-            CALL diurnal_sst_takaya_step( & 
-            &    qsr, qns, taum, rhop(:,:,1), rdt ) 
-         ENDIF
-      ENDIF     
-      
       
 #if defined key_top
@@ -382,71 +360,3 @@
    END SUBROUTINE stp
    
-   SUBROUTINE stp_diurnal( kstp ) 
-      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index 
-      !!---------------------------------------------------------------------- 
-      !!                     ***  ROUTINE stp  *** 
-      !!                       
-      !! ** Purpose : - Time stepping of diurnal SST model only 
-      !!   
-      !! ** Method  : -1- Update forcings and data   
-      !!              -2- Update ocean physics   
-      !!              -3- Compute the t and s trends   
-      !!              -4- Update t and s   
-      !!              -5- Compute the momentum trends 
-      !!              -6- Update the horizontal velocity 
-      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w) 
-      !!              -8- Outputs and diagnostics 
-      !!---------------------------------------------------------------------- 
-      INTEGER ::   jk       ! dummy loop indices
-      INTEGER ::   indic    ! error indicator if < 0 
-      REAL(wp), DIMENSION(jpi,jpj) :: z_fvel_bkginc, z_hflux_bkginc     
-      !! --------------------------------------------------------------------- 
- 
-      indic = 1                                 ! reset to no error condition 
- 
-      IF( kstp /= nit000 )   CALL day( kstp )   ! Calendar (day was already called at nit000 in day_init) 
- 
-      CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! tell iom we are at time step kstp
-      IF( ln_crs ) THEN
-         CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" ) ! tell iom we are at time step kstp
-      ENDIF
-       
-      CALL sbc    ( kstp )                      ! Sea Boundary Conditions 
-     
-      ! Cool skin
-      IF ( .NOT.ln_diurnal ) CALL ctl_stop(  "stp_diurnal: ln_diurnal not set"  )
-         
-      IF ( .NOT. ln_blk_core ) THEN
-         CALL ctl_stop("step.f90: diurnal flux processing not implemented"//&
-         &             " for direct forcing") 
-      ENDIF
-
-      CALL diurnal_sst_coolskin_step( qns, taum, rhop(:,:,1), rdt)
-
-      CALL dia_wri( kstp )                            ! ocean model: outputs 
-       
-      ! Diurnal warm layer model       
-           
-      IF( kstp == nit000 )THEN 
-         CALL diurnal_sst_takaya_step( & 
-         &    qsr, qns, taum, rhop(:,:,1), &
-         &    rdt, ld_calcfrac = .TRUE.) 
-      ELSE 
-         CALL diurnal_sst_takaya_step( & 
-         &    qsr, qns, taum, rhop(:,:,1), rdt ) 
-      ENDIF
-
-      IF( ln_diaobs  )         CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
-     
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
-      ! Control and restarts 
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
-      IF( kstp == nit000   )   CALL iom_close( numror )     ! close input  ocean restart file 
-      IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
-     
-      IF( nn_timing == 1 .AND.  kstp == nit000  )   CALL timing_reset 
-       
-   END SUBROUTINE stp_diurnal  
-   
-   !!======================================================================
 END MODULE step
