New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 5901 for branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/step.F90 – NEMO

Ignore:
Timestamp:
2015-11-20T09:39:06+01:00 (8 years ago)
Author:
jamesharle
Message:

merging branch with head of the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/step.F90

    r5620 r5901  
    2424   !!             -   !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA 
    2525   !!            3.4  !  2011-04  (G. Madec, C. Ethe) Merge of dtatem and dtasal 
    26    !!                 !  2012-07  (J. Simeon, G. Madec, C. Ethe) Online coarsening of outputs 
    27    !!            3.7  !  2014-04  (F. Roquet, G. Madec) New equations of state 
     26   !!            3.6  !  2012-07  (J. Simeon, G. Madec. C. Ethe)  Online coarsening of outputs 
     27   !!            3.6  !  2014-04  (F. Roquet, G. Madec) New equations of state 
     28   !!            3.7  !  2014-10  (G. Madec)  LDF simplication  
     29   !!             -   !  2014-12  (G. Madec) remove KPP scheme 
    2830   !!---------------------------------------------------------------------- 
    2931 
     
    3739   PRIVATE 
    3840 
    39    PUBLIC   stp   ! called by opa.F90 
     41   PUBLIC   stp   ! called by nemogcm.F90 
    4042 
    4143   !! * Substitutions 
     
    4345!!gm   #  include "zdfddm_substitute.h90" 
    4446   !!---------------------------------------------------------------------- 
    45    !! NEMO/OPA 3.7 , NEMO Consortium (2014) 
     47   !! NEMO/OPA 3.7 , NEMO Consortium (2015) 
    4648   !! $Id$ 
    4749   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     
    5052 
    5153#if defined key_agrif 
    52    SUBROUTINE stp( ) 
     54   RECURSIVE SUBROUTINE stp( ) 
    5355      INTEGER             ::   kstp   ! ocean time-step index 
    5456#else 
     
    6971      !!              -5- Compute the momentum trends 
    7072      !!              -6- Update the horizontal velocity 
    71       !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w) 
     73      !!              -7- Compute the diagnostics variables (rd,N2, hdiv,w) 
    7274      !!              -8- Outputs and diagnostics 
    7375      !!---------------------------------------------------------------------- 
     
    7678      INTEGER ::   kcall    ! optional integer argument (dom_vvl_sf_nxt) 
    7779      !! --------------------------------------------------------------------- 
    78  
    7980#if defined key_agrif 
    8081      kstp = nit000 + Agrif_Nb_Step() 
    81 !      IF ( Agrif_Root() .and. lwp) Write(*,*) '---' 
    82 !      IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp 
    83       IF ( kstp == (nit000 + 1) ) lk_agrif_fstep = .FALSE. 
     82      IF( lk_agrif_debug ) THEN 
     83         IF( Agrif_Root() .and. lwp)   WRITE(*,*) '---' 
     84         IF(lwp)   WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint() 
     85      ENDIF 
     86      IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE. 
    8487# if defined key_iomput 
    8588      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context ) 
    8689# endif 
    8790#endif 
    88                              indic = 0           ! reset to no error condition 
    89       IF( kstp == nit000 ) THEN 
    90          ! must be done after nemo_init for AGRIF+XIOS+OASIS 
    91                       CALL iom_init(      cxios_context          )  ! iom_put initialization 
    92          IF( ln_crs ) CALL iom_init( TRIM(cxios_context)//"_crs" )  ! initialize context for coarse grid 
    93       ENDIF 
    94  
     91      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
     92      ! update I/O and calendar  
     93      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     94                             indic = 0                ! reset to no error condition 
     95                              
     96      IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS) 
     97                             CALL iom_init(      cxios_context          )  ! for model grid (including passible AGRIF zoom) 
     98         IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid 
     99      ENDIF 
    95100      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init) 
    96                              CALL iom_setkt( kstp - nit000 + 1,      cxios_context          )   ! tell iom we are at time step kstp 
    97       IF( ln_crs     )       CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" )   ! tell iom we are at time step kstp 
    98  
    99       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    100       ! Update data, open boundaries, surface boundary condition (including sea-ice) 
    101       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    102       IF( lk_tide    )   CALL sbc_tide( kstp ) 
    103       IF( lk_bdy     )  THEN 
    104          IF( ln_apr_dyn) CALL sbc_apr( kstp )   ! bdy_dta needs ssh_ib  
    105                          CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries 
    106       ENDIF 
    107                          CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice) 
    108                                                       ! clem: moved here for bdy ice purpose 
     101                             CALL iom_setkt( kstp - nit000 + 1,      cxios_context          )   ! tell IOM we are at time step kstp 
     102      IF( ln_crs         )   CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" )   ! tell IOM we are at time step kstp 
     103 
     104      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
     105      ! Update external forcing (tides, open boundaries, and surface boundary condition (including sea-ice) 
     106      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     107      IF( lk_tide    )   CALL sbc_tide( kstp )                   ! update tide potential 
     108      IF( ln_apr_dyn )   CALL sbc_apr ( kstp )                   ! atmospheric pressure (NB: call before bdy_dta which needs ssh_ib)  
     109      IF( lk_bdy     )   CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries 
     110                         CALL sbc     ( kstp )                   ! Sea Boundary Condition (including sea-ice) 
     111 
    109112      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    110113      ! Update stochastic parameters and random T/S fluctuations 
    111114      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    112                         CALL sto_par( kstp )          ! Stochastic parameters 
     115                         CALL sto_par( kstp )          ! Stochastic parameters 
    113116 
    114117      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
     
    120123                         CALL bn2    ( tsb, rab_b, rn2b ) ! before Brunt-Vaisala frequency 
    121124                         CALL bn2    ( tsn, rab_n, rn2  ) ! now    Brunt-Vaisala frequency 
     125 
    122126      ! 
    123127      !  VERTICAL PHYSICS 
     
    127131      IF( lk_zdftke  )   CALL zdf_tke( kstp )            ! TKE closure scheme for Kz 
    128132      IF( lk_zdfgls  )   CALL zdf_gls( kstp )            ! GLS closure scheme for Kz 
    129       IF( lk_zdfkpp  )   CALL zdf_kpp( kstp )            ! KPP closure scheme for Kz 
    130133      IF( lk_zdfcst  ) THEN                              ! Constant Kz (reset avt, avm[uv] to the background value) 
    131134         avt (:,:,:) = rn_avt0 * wmask (:,:,:) 
     
    133136         avmv(:,:,:) = rn_avm0 * wvmask(:,:,:) 
    134137      ENDIF 
     138 
    135139      IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths 
    136          DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO 
     140         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2._wp * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO 
    137141      ENDIF 
    138142      IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity 
     
    140144      IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing 
    141145 
    142       IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   & 
    143          &               CALL zdf_ddm( kstp )         ! double diffusive mixing 
     146      IF( lk_zdfddm  )   CALL zdf_ddm( kstp )         ! double diffusive mixing 
    144147 
    145148                         CALL zdf_mxl( kstp )         ! mixed layer depth 
     
    151154      !  LATERAL  PHYSICS 
    152155      ! 
    153       IF( lk_ldfslp ) THEN                            ! slope of lateral mixing 
     156      IF( l_ldfslp ) THEN                             ! slope of lateral mixing 
     157!!gm : why this here ???? 
    154158         IF(ln_sto_eos ) CALL sto_pts( tsn )          ! Random T/S fluctuations 
     159!!gm 
    155160                         CALL eos( tsb, rhd, gdept_0(:,:,:) )               ! before in situ density 
     161 
    156162         IF( ln_zps .AND. .NOT. ln_isfcav)                               & 
    157163            &            CALL zps_hde    ( kstp, jpts, tsb, gtsu, gtsv,  &  ! Partial steps: before horizontal gradient 
    158164            &                                          rhd, gru , grv    )  ! of t, s, rd at the last ocean level 
     165 
    159166         IF( ln_zps .AND.       ln_isfcav)                               & 
    160             &            CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv, &    ! Partial steps for top cell (ISF) 
     167            &            CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv, gtui, gtvi,  &    ! Partial steps for top cell (ISF) 
    161168            &                                          rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   & 
    162             &                                   gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the first ocean level 
    163          IF( ln_traldf_grif ) THEN                           ! before slope for Griffies operator 
    164                          CALL ldf_slp_grif( kstp ) 
    165          ELSE 
    166                          CALL ldf_slp( kstp, rhd, rn2b )     ! before slope for Madec operator 
     169            &                                   grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the first ocean level 
     170 
     171         IF( ln_traldf_triad ) THEN  
     172                         CALL ldf_slp_triad( kstp )                       ! before slope for triad operator 
     173         ELSE      
     174                         CALL ldf_slp     ( kstp, rhd, rn2b )             ! before slope for standard operator 
    167175         ENDIF 
    168176      ENDIF 
    169 #if defined key_traldf_c2d 
    170       IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )      ! eddy induced velocity coefficient 
    171 #endif 
    172 #if defined key_traldf_c3d && defined key_traldf_smag 
    173                           CALL ldf_tra_smag( kstp )      ! eddy induced velocity coefficient 
    174 #  endif 
    175 #if defined key_dynldf_c3d && defined key_dynldf_smag 
    176                           CALL ldf_dyn_smag( kstp )      ! eddy induced velocity coefficient 
    177 #  endif 
    178  
    179       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    180       !  Ocean dynamics : hdiv, rot, ssh, e3, wn 
    181       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    182                          CALL ssh_nxt       ( kstp )  ! after ssh (includes call to div_cur) 
     177      !                                               ! eddy diffusivity coeff. and/or eiv coeff. 
     178      IF( l_ldftra_time .OR. l_ldfeiv_time )   CALL ldf_tra( kstp )  
     179 
     180      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
     181      !  Ocean dynamics : hdiv, ssh, e3, wn 
     182      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     183                         CALL ssh_nxt       ( kstp )  ! after ssh (includes call to div_hor) 
    183184      IF( lk_vvl     )   CALL dom_vvl_sf_nxt( kstp )  ! after vertical scale factors  
    184185                         CALL wzv           ( kstp )  ! now cross-level velocity  
     
    188189          ! Note that the computation of vertical velocity above, hence "after" sea level 
    189190          ! is necessary to compute momentum advection for the rhs of barotropic loop: 
     191!!gm : why also here ???? 
    190192            IF(ln_sto_eos ) CALL sto_pts( tsn )                             ! Random T/S fluctuations 
     193!!gm 
    191194                            CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation 
    192             IF( ln_zps .AND. .NOT. ln_isfcav)                               & 
    193                &            CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient 
    194                &                                          rhd, gru , grv    )  ! of t, s, rd at the last ocean level 
    195             IF( ln_zps .AND.       ln_isfcav)                               & 
    196                &            CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps for top cell (ISF) 
     195                             
     196            IF( ln_zps .AND. .NOT. ln_isfcav)   &                           ! Partial steps: bottom before horizontal gradient 
     197               &            CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &  ! of t, s, rd at the last ocean level 
     198               &                                          rhd, gru , grv    ) 
     199            IF( ln_zps .AND.       ln_isfcav)   &                           ! Partial steps: top & bottom before horizontal gradient 
     200               &            CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, gtui, gtvi,   &  
    197201               &                                          rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   & 
    198                &                                   gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level 
    199  
    200                                   ua(:,:,:) = 0.e0             ! set dynamics trends to zero 
    201                                   va(:,:,:) = 0.e0 
    202           IF(  ln_asmiau .AND. & 
     202               &                                               grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) 
     203 
     204                                  ua(:,:,:) = 0._wp            ! set dynamics trends to zero 
     205                                  va(:,:,:) = 0._wp 
     206          IF(  lk_asminc .AND. ln_asmiau .AND. & 
    203207             & ln_dyninc       )  CALL dyn_asm_inc  ( kstp )   ! apply dynamics assimilation increment 
    204           IF( ln_neptsimp )       CALL dyn_nept_cor ( kstp )   ! subtract Neptune velocities (simplified) 
    205208          IF( lk_bdy           )  CALL bdy_dyn3d_dmp( kstp )   ! bdy damping trends 
    206209                                  CALL dyn_adv      ( kstp )   ! advection (vector or flux form) 
    207210                                  CALL dyn_vor      ( kstp )   ! vorticity term including Coriolis 
    208211                                  CALL dyn_ldf      ( kstp )   ! lateral mixing 
    209           IF( ln_neptsimp )       CALL dyn_nept_cor ( kstp )   ! add Neptune velocities (simplified) 
    210212#if defined key_agrif 
    211213          IF(.NOT. Agrif_Root())  CALL Agrif_Sponge_dyn        ! momentum sponge 
     
    217219                                  va_sv(:,:,:) = va(:,:,:) 
    218220 
    219                                   CALL div_cur( kstp )         ! Horizontal divergence & Relative vorticity (2nd call in time-split case) 
     221                                  CALL div_hor( kstp )         ! Horizontal divergence (2nd call in time-split case) 
    220222          IF( lk_vvl     )        CALL dom_vvl_sf_nxt( kstp, kcall=2 )  ! after vertical scale factors (update depth average component) 
    221223                                  CALL wzv           ( kstp )  ! now cross-level velocity  
     
    225227      ! diagnostics and outputs             (ua, va, tsa used as workspace) 
    226228      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    227       IF( lk_floats  )      CALL flo_stp( kstp )         ! drifting Floats 
    228       IF( lk_diahth  )      CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth) 
    229       IF( .NOT. ln_cpl )    CALL dia_fwb( kstp )         ! Fresh water budget diagnostics 
    230       IF( lk_diadct  )      CALL dia_dct( kstp )         ! Transports 
    231       IF( lk_diaar5  )      CALL dia_ar5( kstp )         ! ar5 diag 
    232       IF( lk_diaharm )      CALL dia_harm( kstp )        ! Tidal harmonic analysis 
    233                             CALL dia_wri( kstp )         ! ocean model: outputs 
    234       ! 
    235       IF( ln_crs     )      CALL crs_fld( kstp )         ! ocean model: online field coarsening & output 
     229      IF( lk_floats  )   CALL flo_stp( kstp )         ! drifting Floats 
     230      IF( lk_diahth  )   CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth) 
     231      IF(.NOT.ln_cpl )   CALL dia_fwb( kstp )         ! Fresh water budget diagnostics 
     232      IF( lk_diadct  )   CALL dia_dct( kstp )         ! Transports 
     233      IF( lk_diaar5  )   CALL dia_ar5( kstp )         ! ar5 diag 
     234      IF( lk_diaharm )   CALL dia_harm( kstp )        ! Tidal harmonic analysis 
     235                         CALL dia_wri( kstp )         ! ocean model: outputs 
     236      ! 
     237      IF( ln_crs     )   CALL crs_fld( kstp )         ! ocean model: online field coarsening & output 
    236238 
    237239#if defined key_top 
     
    242244#endif 
    243245 
    244  
    245246      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    246247      ! Active tracers                              (ua, va used as workspace) 
    247248      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    248                              tsa(:,:,:,:) = 0.e0            ! set tracer trends to zero 
    249  
    250       IF(  ln_asmiau .AND. & 
     249                             tsa(:,:,:,:) = 0._wp           ! set tracer trends to zero 
     250 
     251      IF(  lk_asminc .AND. ln_asmiau .AND. & 
    251252         & ln_trainc     )   CALL tra_asm_inc( kstp )       ! apply tracer assimilation increment 
    252253                             CALL tra_sbc    ( kstp )       ! surface boundary condition 
     
    257258      IF( lk_bdy         )   CALL bdy_tra_dmp( kstp )       ! bdy damping trends 
    258259                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection 
    259       IF( lk_zdfkpp      )   CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes 
    260260                             CALL tra_ldf    ( kstp )       ! lateral mixing 
    261261 
     262!!gm : why CALL to dia_ptr has been moved here??? (use trends info?) 
    262263      IF( ln_diaptr      )   CALL dia_ptr                   ! Poleward adv/ldf TRansports diagnostics 
     264!!gm 
    263265 
    264266#if defined key_agrif 
     
    270272         IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection 
    271273                             CALL tra_nxt( kstp )                ! tracer fields at next time step 
     274!!gm : why again a call to sto_pts ??? 
    272275            IF( ln_sto_eos ) CALL sto_pts( tsn )                 ! Random T/S fluctuations 
     276!!gm 
    273277                             CALL eos    ( tsa, rhd, rhop, fsdept_n(:,:,:) )  ! Time-filtered in situ density for hpg computation 
    274278            IF( ln_zps .AND. .NOT. ln_isfcav)                                & 
     
    276280               &                                           rhd, gru , grv    )  ! of t, s, rd at the last ocean level 
    277281            IF( ln_zps .AND.       ln_isfcav)                                & 
    278                &             CALL zps_hde_isf( kstp, jpts, tsa, gtsu, gtsv,  &    ! Partial steps for top cell (ISF) 
     282               &             CALL zps_hde_isf( kstp, jpts, tsa, gtsu, gtsv, gtui, gtvi,  &    ! Partial steps for top/bottom cells 
    279283               &                                           rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   & 
    280                &                                    gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level 
     284               &                                                grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) 
    281285      ELSE                                                  ! centered hpg  (eos then time stepping) 
    282286         IF ( .NOT. lk_dynspg_ts ) THEN                     ! eos already called in time-split case 
     287!!gm : why again a call to sto_pts ??? 
    283288            IF( ln_sto_eos ) CALL sto_pts( tsn )    ! Random T/S fluctuations 
     289!!gm 
    284290                             CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )  ! now in situ density for hpg computation 
    285291         IF( ln_zps .AND. .NOT. ln_isfcav)                                   & 
    286                &             CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient 
    287                &                                           rhd, gru , grv    )  ! of t, s, rd at the last ocean level 
     292               &             CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps: bottom before horizontal gradient 
     293               &                                           rhd, gru , grv    )    ! of t, s, rd at the last ocean level 
    288294         IF( ln_zps .AND.       ln_isfcav)                                   &  
    289                &             CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps for top cell (ISF) 
     295               &             CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, gtui, gtvi,   &    ! Partial steps for top/bottom cells 
    290296               &                                           rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   & 
    291                &                                    gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level 
     297               &                                    grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level 
    292298         ENDIF 
    293299         IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection 
     
    303309                               ua(:,:,:) = ua_sv(:,:,:) 
    304310                               va(:,:,:) = va_sv(:,:,:) 
    305                                                              ! Revert now divergence and rotational to previously computed ones  
    306                                                              !(needed because of the time swap in div_cur, at the beginning of each time step) 
    307                                hdivn(:,:,:) = hdivb(:,:,:) 
    308                                rotn(:,:,:)  = rotb(:,:,:)  
    309311 
    310312                               CALL dyn_bfr( kstp )         ! bottom friction 
    311313                               CALL dyn_zdf( kstp )         ! vertical diffusion 
    312314      ELSE 
    313                                ua(:,:,:) = 0.e0             ! set dynamics trends to zero 
    314                                va(:,:,:) = 0.e0 
    315  
    316         IF(  ln_asmiau .AND. & 
     315                               ua(:,:,:) = 0._wp            ! set dynamics trends to zero 
     316                               va(:,:,:) = 0._wp 
     317 
     318        IF(  lk_asminc .AND. ln_asmiau .AND. & 
    317319           & ln_dyninc      )  CALL dyn_asm_inc( kstp )     ! apply dynamics assimilation increment 
    318320        IF( ln_bkgwri )        CALL asm_bkg_wri( kstp )     ! output background fields 
    319         IF( ln_neptsimp )      CALL dyn_nept_cor( kstp )    ! subtract Neptune velocities (simplified) 
    320321        IF( lk_bdy          )  CALL bdy_dyn3d_dmp(kstp )    ! bdy damping trends 
    321322                               CALL dyn_adv( kstp )         ! advection (vector or flux form) 
    322323                               CALL dyn_vor( kstp )         ! vorticity term including Coriolis 
    323324                               CALL dyn_ldf( kstp )         ! lateral mixing 
    324         IF( ln_neptsimp )      CALL dyn_nept_cor( kstp )    ! add Neptune velocities (simplified) 
    325325#if defined key_agrif 
    326326        IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn        ! momemtum sponge 
     
    335335                               CALL ssh_swp( kstp )         ! swap of sea surface height 
    336336      IF( lk_vvl           )   CALL dom_vvl_sf_swp( kstp )  ! swap of vertical scale factors 
    337  
     337      ! 
     338 
     339!!gm : This does not only concern the dynamics ==>>> add a new title 
     340!!gm2: why ouput restart before AGRIF update? 
     341      IF( lrst_oce         )   CALL rst_write( kstp )       ! write output ocean restart file 
     342 
     343#if defined key_agrif 
     344      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
     345      ! AGRIF 
     346      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<       
     347                               CALL Agrif_Integrate_ChildGrids( stp )   
     348 
     349      IF ( Agrif_NbStepint().EQ.0 ) THEN 
     350                               CALL Agrif_Update_Tra()      ! Update active tracers 
     351                               CALL Agrif_Update_Dyn()      ! Update momentum 
     352      ENDIF 
     353#endif 
    338354      IF( ln_diahsb        )   CALL dia_hsb( kstp )         ! - ML - global conservation diagnostics 
    339355      IF( lk_diaobs  )         CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update) 
    340356 
    341357      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    342       ! Control and restarts 
     358      ! Control 
    343359      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    344360                               CALL stp_ctl( kstp, indic ) 
     
    350366                 CALL iom_close( numror )     ! close input  ocean restart file 
    351367         IF(lwm) CALL FLUSH    ( numond )     ! flush output namelist oce 
    352          IF( lwm.AND.numoni /= -1 ) CALL FLUSH    ( numoni )     ! flush output namelist ice 
    353       ENDIF 
    354       IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file 
     368         IF(lwm.AND.numoni /= -1 )   & 
     369            &    CALL FLUSH    ( numoni )     ! flush output namelist ice (if exist) 
     370      ENDIF 
    355371 
    356372      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    357373      ! Coupled mode 
    358374      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     375!!gm why lk_oasis and not lk_cpl ???? 
    359376      IF( lk_oasis         )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges 
    360377      ! 
Note: See TracChangeset for help on using the changeset viewer.