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.
2021WP/KNL-02_Jerome_RK3_stage1_tsplit – NEMO
wiki:2021WP/KNL-02_Jerome_RK3_stage1_tsplit

Version 8 (modified by jchanut, 3 years ago) (diff)

--

Name and subject of the action

Last edition: Wikinfo(changed_ts)? by Wikinfo(changed_by)?

The PI is responsible to closely follow the progress of the action, and especially to contact NEMO project manager if the delay on preview (or review) are longer than the 2 weeks expected.

  1. Summary
  2. Preview
  3. Tests
  4. Review

Summary

Action RK3_stage1_tsplit
PI(S) Jérôme Chanut
Digest Refactorize time splitting scheme for RK3 (and MLF). Make is compliant with a possible coupling at barotropic level with AGRiF
Dependencies
Branch source:/NEMO/branches/2021/dev_r14318_RK3_stage1_tsplit/
Previewer(s) G. Madec & S. Téchené
Reviewer(s) G. Madec & S. Téchené
Ticket #2634

Description

1) Simplify/clean the actual split-explicit procedure

2) Refactorize dynspg_ts module: (and anticipate possible exchange at barotropic time step with AGRIF) ...

Implementation

1) Simplify/clean the actual split-explicit procedure:

  • Remove " centred integration" of barotropic mode (ln_bt_fw=F), which is only relevant with LF-RA and not compatible with AGRIF (This nevertheless precludes from ever implementing a coherent treatment in baroclinic and barotropic modes of implicit bottom stress with Leapfrog.
  • Set initialization of filtering weights at initialization step (maybe not relevant to do so if any adaptive time stepping procedure is ever implemented - one would like to change the number of barotropic iterations online).
  • Add time indexes (4 levels) to barotropic instantaneous arrays (AB3-AM4 time stepping) to match baroclinic mode syntax
  • We agreed (with Gurvan) to keep the barotropic filtering option (ln_bt_ave=T) even if it complicates a bit the integration. It will be useful for comparison with Demange's diffusive time stepping approach.

2) Refactorize dynspg_ts module:

  • Extract a single external step into a stp_2D routine. Such a routine could be the basis of an "autonomous" barotropic model within NEMO.
  • Same for barotropic to baroclinic forcing term: prep_stp_2D
  • I would have tend to think that a kind of post-processing of stp_2D, i.e. a kind of finalize_stp_2D would have been nice so that stp_2D does not have to do specific operations at the end of the cycle (write restart, compute advective velocities, etc...).

At the end, call to dynspg_ts could be replaced in the main stp routine by:

   ! Set barotropic forcing (incl. 3d to 2d forcing and drag): Ue_rhs, Ve_rhs, sshe_rhs, CdU_u , CdU_v
   !  and initialize instantaneous barotropic arrays: uu_e, vv_e, hu_e, hv_e, ssh_e
   CALL prep_stp_2D( kstp, Nbb, Nbb, Naa, Nrhs )
   !
   DO kit = 1, icycle
      ! iterate external mode: update uu_e, vv_e, hu_e, hv_e, ssh_e
      ! increment and provide time averaged and final barotropic arrays at kit=icycle, e.g. N+1: 
      !           ssh (:,:,Naa), uu_b(:,:,Naa), vv_b(:,:,Naa) => barotropic arrays at N+1 baroclinic step (eventually filtered)
      !           un_adv(:,:), vn_adv(:,:) => advective fluxes over N->N+1 (RK3) or N-1 -> N+1 (LF)
      !           ub2_b(:,:), vb2_b(:,:), un_bf(:,:), vn_bf(:,:) => Leapfrog backward fluxes over N-1 -> N
      !           ub2_i_b(:,:), ub2_i_b(:,:) => AGRIF time integrated fluxes over N child grid baroclinic steps
      !
      CALL stp_2D(kstp, kit, ll_init, Nbbb_e, Nbb_e, Nnn_e, uu_e, vv_e, hu_e, hv_e, ssh_e, Naa_e)
      !
      ! Swap external mode arrays:
      Nbbb_e =  Nbb_e
      Nbb_e  =  Nnn_e
      Nnn_e  =  Naa_e
   END DO

I'm in trouble to see which arrays should be passed by argument to stp_2D, e.g. output baroclinic arrays and input forcing terms also ? That's a lot of arrays ! Advice needed.

As an alternative, we can have time averages outside the external loop and move all the rest elsewhere (I prefer this one).

   ! Set barotropic forcing (incl. 3d to 2d forcing and drag): Ue_rhs, Ve_rhs, sshe_rhs, CdU_u , CdU_v
   !  and initialize instantaneous barotropic arrays: uu_e, vv_e, hu_e, hv_e, ssh_e
   CALL prep_stp_2D( kstp, Nbb, Nbb, Naa, Nrhs )
   !
   ! Reset arrays to be averaged later on:
   un_adv(:,:) = 0._wp ; vn_adv(:,:) = 0._wp
   uu_b(:,:,Naa) = 0._wp ; vv_b(:,:,Naa) = 0._wp ; ssh(:,:,Naa) = 0._wp
   !
   DO kit = 1, icycle
      ! iterate external mode: update uu_e, vv_e, hu_e, hv_e, ssh_e AND fluxes uf_e, vf_e
      !
      CALL stp_2D(kstp, kit, ll_init, Nbbb_e, Nbb_e, Nnn_e, uu_e, vv_e, hu_e, hv_e, ssh_e, uf_e, vf_e, Naa_e)
      !
      ! Average external mode arrays
      za1 = wgtbtp1(kit) ;  za2 = wgtbtp2(kit)
      uu_b(:,:,Naa) = uu_b  (:,:,Naa) + za1 * uu_e  (:,:,Naa_e) * hu_e (:,:)
      vv_b(:,:,Naa) = vv_b  (:,:,Naa) + za1 * vv_e  (:,:,Naa_e) * hv_e (:,:)
      ssh(:,:,Naa) = ssh(:,:,Naa) + za1 * ssh_e(:,:,Naa_e)
      !
      un_adv(:,:) = un_adv(:,:) + za2 * uf_e(:,:)
      vn_adv(:,:) = vn_adv(:,:) + za2 * vf_e(:,:)
      !
      ! Swap external mode arrays:
      Nbbb_e =  Nbb_e
      Nbb_e  =  Nnn_e
      Nnn_e  =  Naa_e
   END DO

This part should ease a possible transition to the coupling at each barotropic time step. The philosophy behind this is to be able to insert the external loop within the main time stepping routine and possibly cycle the stp routine over nstep x icycle steps, i.e. the total number of sub-steps. The integration of agrif should then be trivial, swapping grids at each parent sub cycle.

Even if this task won't go up the AGRIF implementation itself, the idea is to have the following flowchart at the end:

DO WHILE( istp <= nitend  )
   DO iit = 1, icycle
      CALL stp   
           | 
           kstp = nit000 + MOD(Agrif_Nb_Step(), icycle)                   ! internal mode time step
           kit = Agrif_Nb_Step() - icycle * MOD(Agrif_Nb_Step(), icycle)  ! external mode time step
           |
           do_bef_stp2D = (kit == 1)
           do_aft_stp2D = (kit == icycle)                
           |
           IF ( do_bef_stp2D ) THEN
              ! ... do stuff
              ! Set barotropic forcing (incl. 3d to 2d forcing)
              !  and initialize instantaneous barotropic arrays
              CALL prep_stp_2D( kstp, Nbb, Nbb, Naa, Nrhs )
           END IF
           |
           CALL stp_2D(kstp, kit, ll_init, Nbbb_e, Nbb_e, Nnn_e, uu_e, vv_e, hu_e, hv_e, ssh_e, Naa_e)
           ! Swap external mode arrays:
           Nbbb_e =  Nbb_e
           Nbb_e  =  Nnn_e
           Nnn_e  =  Naa_e
           |
           IF ( do_aft_stp2D ) THEN
              ! ... do stuff
           END IF 
           |
           CALL Agrif_Integrate_ChildGrids( stp ) 
           |
   END DO
   istp = istp + 1
END DO

...

Documentation updates

Split explicit documentation part should be updated:

  • Removal of "centred" integration option
  • Introduce Demange's time dissipation factor

...

Preview

Error: Failed to load processor box
No macro or processor named 'box' found

...

Tests

Error: Failed to load processor box
No macro or processor named 'box' found

...

Review

Error: Failed to load processor box
No macro or processor named 'box' found

...