Index: trunk/NEMO/OPA_SRC/step.F90
===================================================================
--- trunk/NEMO/OPA_SRC/step.F90	(revision 699)
+++ trunk/NEMO/OPA_SRC/step.F90	(revision 703)
@@ -4,6 +4,5 @@
    !! Time-stepping    : manager of the ocean, tracer and ice time stepping
    !!======================================================================
-   !! History :        !  91-03  ()  Original code
-   !!                  !  91-11  (G. Madec)
+   !! History :        !  91-03  (G. Madec)  Original code
    !!                  !  92-06  (M. Imbard)  add a first output record
    !!                  !  96-04  (G. Madec)  introduction of dynspg
@@ -20,4 +19,7 @@
    !!             " "  !  06-01  (L. Debreu, C. Mazauric)  Agrif implementation
    !!             " "  !  06-07  (S. Masson)  restart using iom
+   !!             " "  !  06-08  (G. Madec)  surface module 
+   !!----------------------------------------------------------------------
+
    !!----------------------------------------------------------------------
    !!   stp            : OPA system time-stepping
@@ -30,5 +32,5 @@
    USE cpl_oce         ! coupled ocean-atmosphere variables
    USE in_out_manager  ! I/O manager
-   USE iom
+   USE iom             !
    USE lbclnk
 
@@ -37,12 +39,6 @@
    USE dtatem          ! ocean temperature data           (dta_tem routine)
    USE dtasal          ! ocean salinity    data           (dta_sal routine)
-   USE dtasst          ! ocean sea surface temperature    (dta_sst routine)
-   USE dtasss          ! ocean sea surface salinity       (dta_sss routine)
-   USE taumod          ! surface stress                   (tau     routine)
-   USE flxmod          ! thermohaline fluxes              (flx     routine)
-   USE ocesbc          ! thermohaline fluxes              (oce_sbc routine)
-   USE flxrnf          ! runoffs                          (flx_rnf routine)
-   USE flxfwb          ! freshwater budget correction     (flx_fwb routine)
-   USE closea          ! closed sea freshwater budget     (flx_clo routine)
+   USE sbcmod          ! surface boundary condition       (sbc     routine)
+   USE sbcrnf          ! surface boundary condition: runoff variables
    USE ocfzpt          ! surface ocean freezing point    (oc_fz_pt routine)
 
@@ -161,12 +157,10 @@
       !!              -8- Outputs and diagnostics
       !!----------------------------------------------------------------------
-      !! * Arguments
 #if defined key_agrif   
-      INTEGER               :: kstp   ! ocean time-step index
+      INTEGER             ::   kstp   ! ocean time-step index
 #else
-      INTEGER, INTENT( in ) :: kstp   ! ocean time-step index
+      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
 #endif      
-
-      !! * local declarations
+      INTEGER ::   jk       ! dummy loop indice
       INTEGER ::   indic    ! error indicator if < 0
       !! ---------------------------------------------------------------------
@@ -179,5 +173,7 @@
       indic = 1                    ! reset to no error condition
 
+!!gm: attention n'est plus ds le step de gm
       adatrj = adatrj + rdt/86400._wp
+!!gm: attention n'est plus ds le step de gm
 
       CALL day( kstp )             ! Calendar
@@ -186,50 +182,18 @@
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! Update data, open boundaries and Forcings
+      ! Update data, open boundaries, surface boundary condition (including sea-ice)
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
       IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
-
-      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! Salinity data
-
-      IF( lk_dtasst  )   CALL dta_sst( kstp )         ! Sea Surface Temperature data
-
-      IF( lk_dtasss  )   CALL dta_sss( kstp )         ! Sea Surface Salinity data
+      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
+
+                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
 
       IF( lk_obc     )   CALL obc_dta( kstp )         ! update dynamic and tracer data at open boundaries
-
       IF( lk_obc     )   CALL obc_rad( kstp )         ! compute phase velocities at open boundaries
 
-      IF( .NOT. lk_core )    CALL tau( kstp )         ! wind stress
-
-                         CALL flx_rnf( kstp )         ! runoff data
-
-                         CALL flx( kstp )             ! heat and freshwater fluxes
-
-      IF( lk_ice_lim )   CALL ice_stp( kstp )         ! sea-ice model (Update stress & fluxes)
-
-                         CALL oce_sbc( kstp )         ! ocean surface boudaries
-
-      IF( ln_fwb     )   CALL flx_fwb( kstp )         ! freshwater budget
-
-      IF( nclosea == 1 ) CALL flx_clo( kstp )         ! closed sea in the domain (update freshwater fluxes)
-
-      IF( kstp == nit000 ) THEN 
-         IF( ninist == 1 ) THEN                       ! Output the initial state and forcings
-            CALL dia_wri_state( 'output.init' )
-         ENDIF
-      ENDIF
-
-      IF(ln_ctl) THEN         ! print mean trends (used for debugging)
-         CALL prt_ctl(tab2d_1=emp    , clinfo1=' emp  -   : ', mask1=tmask, ovlap=1)
-         CALL prt_ctl(tab2d_1=emps   , clinfo1=' emps -   : ', mask1=tmask, ovlap=1)
-         CALL prt_ctl(tab2d_1=qt     , clinfo1=' qt   -   : ', mask1=tmask, ovlap=1)
-         CALL prt_ctl(tab2d_1=qsr    , clinfo1=' qsr  -   : ', mask1=tmask, ovlap=1)
-         CALL prt_ctl(tab2d_1=runoff , clinfo1=' runoff   : ', mask1=tmask, ovlap=1)
-         CALL prt_ctl(tab3d_1=tmask  , clinfo1=' tmask    : ', mask1=tmask, ovlap=1, kdim=jpk)
-         CALL prt_ctl(tab3d_1=tn     , clinfo1=' sst  -   : ', mask1=tmask, ovlap=1, kdim=1)
-         CALL prt_ctl(tab3d_1=sn     , clinfo1=' sss  -   : ', mask1=tmask, ovlap=1, kdim=1)
-         CALL prt_ctl(tab2d_1=taux   , clinfo1=' tau  - x : ', mask1=umask, &
-            &         tab2d_2=tauy   , clinfo2='      - y : ', mask2=vmask,ovlap=1)
+      IF( ninist == 1 ) THEN                       ! Output the initial state and forcings
+                        CALL dia_wri_state( 'output.init' )
+                        ninist = 0
       ENDIF
 
@@ -244,5 +208,5 @@
       !-----------------------------------------------------------------------
 
-                       CALL bn2( tb, sb, rn2 )              ! before Brunt-Vaisala frequency
+                        CALL bn2( tb, sb, rn2 )              ! before Brunt-Vaisala frequency
       
       !                                                     ! Vertical eddy viscosity and diffusivity coefficients
@@ -261,16 +225,11 @@
       ENDIF
 
-      IF( cp_cfg == "orca" ) THEN                           ! ORCA: Reduce vertical mixing in some specific areas
-         SELECT CASE ( jp_cfg )
-            CASE ( 05 )                         ! ORCA R2 configuration
-               avt  (:,:,2) = avt  (:,:,2) + 1.e-3 * upsrnfh(:,:)   ! increase diffusivity of rivers mouths
-            CASE ( 025 )                         ! ORCA R025 configuration
-               avt  (:,:,2) = avt  (:,:,2) + 2.e-3 * upsrnfh(:,:)   ! increase diffusivity of rivers mouths
-         END SELECT
+      IF( nn_runoff /=0 ) THEN                              ! increase diffusivity at rivers mouths
+         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + rn_avt_rnf * rnfmsk(:,:)   ;   END DO
       ENDIF
 
       IF( ln_zdfevd )   CALL zdf_evd( kstp )                 ! enhanced vertical eddy diffusivity
 
-      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp)   &
+      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
          &              CALL zdf_ddm( kstp )                 ! double diffusive mixing
 
@@ -285,12 +244,9 @@
       ! N.B. ua, va, ta, sa arrays are used as workspace in this section
       !-----------------------------------------------------------------------
-
       IF( lk_ldfslp     )   CALL ldf_slp( kstp, rhd, rn2 )       ! before slope of the lateral mixing
-
 #if defined key_traldf_c2d
       IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )                 ! eddy induced velocity coefficient
 #endif
 
-
 #if defined key_passivetrc
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -299,9 +255,6 @@
       ! N.B. ua, va, ta, sa arrays are used as workspace in this section
       !-----------------------------------------------------------------------
-
                              CALL trc_stp( kstp, indic )            ! time-stepping
-
-#endif
-
+#endif
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -310,25 +263,16 @@
       ! N.B. ua, va arrays are used as workspace in this section
       !-----------------------------------------------------------------------
-
                              ta(:,:,:) = 0.e0               ! set tracer trends to zero
                              sa(:,:,:) = 0.e0
 
                              CALL tra_sbc    ( kstp )       ! surface boundary condition
-
       IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
-
       IF( lk_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
-
       IF( lk_trabbl_dif  )   CALL tra_bbl_dif( kstp )       ! diffusive bottom boundary layer scheme
       IF( lk_trabbl_adv  )   CALL tra_bbl_adv( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
-
       IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
-
                              CALL tra_adv    ( kstp )       ! horizontal & vertical advection
-
       IF( n_cla == 1     )   CALL tra_cla    ( kstp )       ! Cross Land Advection (Update Hor. advection)
-
       IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
-
                              CALL tra_ldf    ( kstp )       ! lateral mixing
 #if defined key_agrif
@@ -336,7 +280,5 @@
 #endif
                              CALL tra_zdf    ( kstp )       ! vertical mixing
-
                              CALL tra_nxt( kstp )           ! tracer fields at next time step
-
       IF( ln_zdfnpc      )   CALL tra_npc( kstp )           ! update the new (t,s) fields by non
       !                                                     ! penetrative convective adjustment
@@ -359,13 +301,9 @@
       ! N.B. ta, sa arrays are used as workspace in this section 
       !-----------------------------------------------------------------------
-
-
                                ua(:,:,:) = 0.e0               ! set dynamics trends to zero
                                va(:,:,:) = 0.e0
 
                                CALL dyn_adv( kstp )           ! advection (vector or flux form)
-
                                CALL dyn_vor( kstp )           ! vorticity term including Coriolis
-
                                CALL dyn_ldf( kstp )           ! lateral mixing
 #if defined key_agrif
@@ -373,18 +311,11 @@
 #endif
                                CALL dyn_hpg( kstp )           ! horizontal gradient of Hydrostatic pressure
-
                                CALL dyn_zdf( kstp )           ! vertical diffusion
-
       IF( lk_dynspg_rl ) THEN
          IF( lk_obc    )       CALL obc_spg( kstp )           ! surface pressure gradient at open boundaries
       ENDIF
-                       indic=0
-!i bug lbc sur emp
-      CALL lbc_lnk( emp, 'T', 1. )
-!i
+                               indic=0
                                CALL dyn_spg( kstp, indic )    ! surface pressure gradient
-
                                CALL dyn_nxt( kstp )           ! lateral velocity at next time step
-
       IF( lk_vvl )             CALL dom_vvl                   ! vertical mesh at next time step
 
@@ -395,24 +326,14 @@
       ! N.B. ua, va, ta, sa arrays are used as workspace in this section
       !-----------------------------------------------------------------------
-
                        CALL oc_fz_pt                        ! ocean surface freezing temperature
-
                        CALL div_cur( kstp )                 ! Horizontal divergence & Relative vorticity
-
       IF( n_cla == 1 ) CALL div_cla( kstp )                 ! Cross Land Advection (Update Hor. divergence)
-
                        CALL wzv( kstp )                     ! Vertical velocity
 
-
-
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! Control, and restarts
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
-      !-----------------------------------------------------------------------
-      !                                                     ! Time loop: control and print
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Control and restarts
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                  CALL stp_ctl( kstp, indic )
       IF( indic < 0          )   CALL ctl_stop( 'step: indic < 0' )
-
       IF( kstp == nit000     )   CALL iom_close( numror )             ! close input  ocean restart file
       IF( lrst_oce           )   CALL rst_write  ( kstp )             ! write output ocean restart file
@@ -425,5 +346,5 @@
       !-----------------------------------------------------------------------
 
-      IF ( nstop == 0 ) THEN                                ! Diagnostics
+      IF( nstop == 0 ) THEN                                 ! Diagnostics:
          IF( lk_floats  )   CALL flo_stp( kstp )                 ! drifting Floats
          IF( lk_trddyn  )   CALL trd_dwr( kstp )                 ! trends: dynamics 
@@ -437,7 +358,6 @@
          IF( lk_diafwb  )   CALL dia_fwb( kstp )                 ! Fresh water budget diagnostics
          IF( ln_diaptr  )   CALL dia_ptr( kstp )                 ! Poleward TRansports diagnostics
-
-         !                                                 ! Outputs
-                            CALL dia_wri    ( kstp, indic )      ! ocean model: outputs
+         !                                                 ! outputs
+                            CALL dia_wri( kstp, indic )          ! ocean model: outputs
       ENDIF
 
