Index: branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90
===================================================================
--- branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 5845)
+++ branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 6004)
@@ -9,6 +9,6 @@
 
    !!----------------------------------------------------------------------
-   !!   dyn_spg     : update the dynamics trend with the lateral diffusion
-   !!   dyn_spg_ctl : initialization, namelist read, and parameters control
+   !!   dyn_spg     : update the dynamics trend with surface pressure gradient 
+   !!   dyn_spg_init: initialization, namelist read, and parameters control
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers variables
@@ -18,12 +18,8 @@
    USE sbc_oce        ! surface boundary condition: ocean
    USE sbcapr         ! surface boundary condition: atmospheric pressure
-   USE dynspg_oce     ! surface pressure gradient variables
    USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
    USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
-   USE dynspg_flt     ! surface pressure gradient     (dyn_spg_flt routine)
-   USE dynadv         ! dynamics: vector invariant versus flux form
-   USE dynhpg, ONLY: ln_dynhpg_imp
-   USE sbctide
-   USE updtide
+   USE sbctide        ! 
+   USE updtide        ! 
    USE trd_oce        ! trends: ocean variables
    USE trddyn         ! trend manager: dynamics
@@ -32,9 +28,7 @@
    USE in_out_manager ! I/O manager
    USE lib_mpp        ! MPP library
-   USE solver         ! solver initialization
    USE wrk_nemo       ! Memory Allocation
    USE timing         ! Timing
 
-
    IMPLICIT NONE
    PRIVATE
@@ -44,4 +38,9 @@
 
    INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_... 
+
+   !                       ! Parameter to control the surface pressure gradient scheme
+   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
+   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
+   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
 
    !! * Substitutions
@@ -54,19 +53,14 @@
 CONTAINS
 
-   SUBROUTINE dyn_spg( kt, kindic )
+   SUBROUTINE dyn_spg( kt )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE dyn_spg  ***
       !!
-      !! ** Purpose :   achieve the momentum time stepping by computing the
-      !!              last trend, the surface pressure gradient including the 
-      !!              atmospheric pressure forcing (ln_apr_dyn=T), and performing
-      !!              the Leap-Frog integration.
-      !!gm              In the current version only the filtered solution provide
-      !!gm            the after velocity, in the 2 other (ua,va) are still the trends
+      !! ** Purpose :   compute surface pressure gradient including the 
+      !!              atmospheric pressure forcing (ln_apr_dyn=T).
       !!
-      !! ** Method  :   Three schemes:
-      !!              - explicit computation      : the spg is evaluated at now
-      !!              - filtered computation      : the Roulet & madec (2000) technique is used
-      !!              - split-explicit computation: a time splitting technique is used
+      !! ** Method  :   Two schemes:
+      !!              - explicit       : the spg is evaluated at now
+      !!              - split-explicit : a time splitting technique is used
       !!
       !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied 
@@ -78,5 +72,4 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER, INTENT(  out) ::   kindic   ! solver flag
       !
       INTEGER  ::   ji, jj, jk                             ! dummy loop indices
@@ -88,10 +81,4 @@
       IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
       !
-
-!!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that 
-!!gm             they return the after velocity, not the trends (as in trazdf_imp...)
-!!gm             In this case, change/simplify dynnxt
-
-
       IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
          CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
@@ -99,7 +86,7 @@
          ztrdv(:,:,:) = va(:,:,:)
       ENDIF
-
+      !
       IF(      ln_apr_dyn                                                &   ! atmos. pressure
-         .OR.  ( .NOT.lk_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
+         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
          .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
          !
@@ -111,5 +98,5 @@
          END DO         
          !
-         IF( ln_apr_dyn .AND. (.NOT. lk_dynspg_ts) ) THEN                    !==  Atmospheric pressure gradient (added later in time-split case) ==!
+         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
             zg_2 = grav * 0.5
             DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
@@ -124,5 +111,5 @@
          !
          !                                    !==  tide potential forcing term  ==!
-         IF( .NOT.lk_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
+         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
             !
             CALL upd_tide( kt )                      ! update tide potential
@@ -152,5 +139,5 @@
          ENDIF
          !
-         DO jk = 1, jpkm1                     !== Add all terms to the general trend
+         DO jk = 1, jpkm1                    !== Add all terms to the general trend
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -160,33 +147,21 @@
             END DO
          END DO    
-         
+         !
 !!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
-              
-      ENDIF
-
-      SELECT CASE ( nspg )                       ! compute surf. pressure gradient trend and add it to the general trend
-      !                                                     
-      CASE (  0 )   ;   CALL dyn_spg_exp( kt )              ! explicit
-      CASE (  1 )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
-      CASE (  2 )   ;   CALL dyn_spg_flt( kt, kindic )      ! filtered
-      !                                                    
+         !    
+      ENDIF
+      !
+      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
+      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
+      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
       END SELECT
       !                    
-      IF( l_trddyn )   THEN                      ! save the surface pressure gradient trends for further diagnostics
-         SELECT CASE ( nspg )
-         CASE ( 0, 1 )
-            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
-            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-         CASE( 2 )
-            z2dt = 2. * rdt
-            IF( neuler == 0 .AND. kt == nit000 )   z2dt = rdt
-            ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:)
-            ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:)
-         END SELECT
+      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
          CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
-         !
          CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
       ENDIF
-      !                                          ! print mean trends (used for debugging)
+      !                                      ! print mean trends (used for debugging)
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
@@ -201,57 +176,54 @@
       !!                  ***  ROUTINE dyn_spg_init  ***
       !!                
-      !! ** Purpose :   Control the consistency between cpp options for 
+      !! ** Purpose :   Control the consistency between namelist options for 
       !!              surface pressure gradient schemes
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio
+      INTEGER ::   ioptio, ios   ! local integers
+      !
+      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
+      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
+      &                    nn_baro , rn_bt_cmax, nn_bt_flt
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
       !
-      IF(lwp) THEN             ! Control print
+      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
+      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
+      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namdyn_spg )
+      !
+      IF(lwp) THEN             ! Namelist print
          WRITE(numout,*)
          WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
          WRITE(numout,*) '~~~~~~~~~~~'
-         WRITE(numout,*) '     Explicit free surface                  lk_dynspg_exp = ', lk_dynspg_exp
-         WRITE(numout,*) '     Free surface with time splitting       lk_dynspg_ts  = ', lk_dynspg_ts
-         WRITE(numout,*) '     Filtered free surface cst volume       lk_dynspg_flt = ', lk_dynspg_flt
-      ENDIF
-
-      IF( lk_dynspg_ts ) CALL dyn_spg_ts_init( nit000 )
-      ! (do it now, to set nn_baro, used to allocate some arrays later on)
-      !                        ! allocate dyn_spg arrays
-      IF( lk_dynspg_ts ) THEN
-         IF( dynspg_oce_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays')
-         IF( dyn_spg_ts_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays')
-         IF ((neuler/=0).AND.(ln_bt_fw)) CALL ts_rst( nit000, 'READ' )
-      ENDIF
-
-      !                        ! Control of surface pressure gradient scheme options
-      ioptio = 0
-      IF(lk_dynspg_exp)   ioptio = ioptio + 1
-      IF(lk_dynspg_ts )   ioptio = ioptio + 1
-      IF(lk_dynspg_flt)   ioptio = ioptio + 1
-      !
-      IF(  ioptio > 1  .OR. ( ioptio == 0 .AND. .NOT. lk_c1d ) )   &
-           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' )
-      IF( ( lk_dynspg_ts .OR. lk_dynspg_exp ) .AND. ln_isfcav )   &
-           &   CALL ctl_stop( ' dynspg_ts and dynspg_exp not tested with ice shelf cavity ' )
-      !
-      IF( lk_dynspg_exp)   nspg =  0
-      IF( lk_dynspg_ts )   nspg =  1
-      IF( lk_dynspg_flt)   nspg =  2
+         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
+         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
+      ENDIF
+      !                          ! Control of surface pressure gradient scheme options
+      ;                              nspg =  np_NO    ;   ioptio = 0
+      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
+      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
+      !
+      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
+      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
+      !
+      IF( ln_dynspg_ts .AND. ln_isfcav )   CALL ctl_stop( ' dynspg_ts not tested with ice shelf cavity ' )
       !
       IF(lwp) THEN
          WRITE(numout,*)
-         IF( nspg ==  0 )   WRITE(numout,*) '     explicit free surface'
-         IF( nspg ==  1 )   WRITE(numout,*) '     free surface with time splitting scheme'
-         IF( nspg ==  2 )   WRITE(numout,*) '     filtered free surface'
-      ENDIF
-
-#if defined key_dynspg_flt
-      CALL solver_init( nit000 )   ! Elliptic solver initialisation
-#endif
-      !			       ! Control of hydrostatic pressure choice
-      IF( lk_dynspg_ts .AND. ln_dynhpg_imp )   CALL ctl_stop( 'Semi-implicit hpg not compatible with time splitting' )
+         IF( nspg == np_EXP )   WRITE(numout,*) '     explicit free surface'
+         IF( nspg == np_TS  )   WRITE(numout,*) '     free surface with time splitting scheme'
+         IF( nspg == np_NO  )   WRITE(numout,*) '     No surface surface pressure gradient trend in momentum Eqs.'
+      ENDIF
+      !
+      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
+         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
+         IF( dyn_spg_ts_alloc() /= 0  )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays' )
+         IF( neuler/=0 .AND. ln_bt_fw )   CALL ts_rst( nit000, 'READ' )
+      ENDIF
       !
       IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
