1 | MODULE stpmlf |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE stpMLF *** |
---|
4 | !! Time-stepping : manager of the ocean, tracer and ice time stepping |
---|
5 | !! using Modified Leap Frog for OCE |
---|
6 | !! TSUNAMI version: call only dynspg_ts |
---|
7 | !!====================================================================== |
---|
8 | !! History : OPA ! 1991-03 (G. Madec) Original code |
---|
9 | !! - ! 1991-11 (G. Madec) |
---|
10 | !! - ! 1992-06 (M. Imbard) add a first output record |
---|
11 | !! - ! 1996-04 (G. Madec) introduction of dynspg |
---|
12 | !! - ! 1996-04 (M.A. Foujols) introduction of passive tracer |
---|
13 | !! 8.0 ! 1997-06 (G. Madec) new architecture of call |
---|
14 | !! 8.2 ! 1997-06 (G. Madec, M. Imbard, G. Roullet) free surface |
---|
15 | !! - ! 1999-02 (G. Madec, N. Grima) hpg implicit |
---|
16 | !! - ! 2000-07 (J-M Molines, M. Imbard) Open Bondary Conditions |
---|
17 | !! NEMO 1.0 ! 2002-06 (G. Madec) free form, suppress macro-tasking |
---|
18 | !! - ! 2004-08 (C. Talandier) New trends organization |
---|
19 | !! - ! 2005-01 (C. Ethe) Add the KPP closure scheme |
---|
20 | !! - ! 2005-11 (G. Madec) Reorganisation of tra and dyn calls |
---|
21 | !! - ! 2006-01 (L. Debreu, C. Mazauric) Agrif implementation |
---|
22 | !! - ! 2006-07 (S. Masson) restart using iom |
---|
23 | !! 3.2 ! 2009-02 (G. Madec, R. Benshila) reintroduicing z*-coordinate |
---|
24 | !! - ! 2009-06 (S. Masson, G. Madec) TKE restart compatible with key_cpl |
---|
25 | !! 3.3 ! 2010-05 (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface |
---|
26 | !! - ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA |
---|
27 | !! 3.4 ! 2011-04 (G. Madec, C. Ethe) Merge of dtatem and dtasal |
---|
28 | !! 3.6 ! 2012-07 (J. Simeon, G. Madec. C. Ethe) Online coarsening of outputs |
---|
29 | !! 3.6 ! 2014-04 (F. Roquet, G. Madec) New equations of state |
---|
30 | !! 3.6 ! 2014-10 (E. Clementi, P. Oddo) Add Qiao vertical mixing in case of waves |
---|
31 | !! 3.7 ! 2014-10 (G. Madec) LDF simplication |
---|
32 | !! - ! 2014-12 (G. Madec) remove KPP scheme |
---|
33 | !! - ! 2015-11 (J. Chanut) free surface simplification (remove filtered free surface) |
---|
34 | !! 4.0 ! 2017-05 (G. Madec) introduction of the vertical physics manager (zdfphy) |
---|
35 | !! 4.1 ! 2019-08 (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme |
---|
36 | !! 4.x ! 2020-08 (S. Techene, G. Madec) quasi eulerian coordinate time stepping |
---|
37 | !!---------------------------------------------------------------------- |
---|
38 | #if defined key_qco || defined key_linssh |
---|
39 | !!---------------------------------------------------------------------- |
---|
40 | !! 'key_qco' Quasi-Eulerian vertical coordinate |
---|
41 | !! OR |
---|
42 | !! 'key_linssh Fixed in time vertical coordinate |
---|
43 | !!---------------------------------------------------------------------- |
---|
44 | !! |
---|
45 | !!---------------------------------------------------------------------- |
---|
46 | !! stp_MLF : NEMO modified Leap Frog time-stepping with qco or linssh |
---|
47 | !!---------------------------------------------------------------------- |
---|
48 | USE step_oce ! time stepping definition modules |
---|
49 | ! |
---|
50 | USE domqco ! quasi-eulerian coordinate |
---|
51 | USE traatf_qco ! time filtering (tra_atf_qco routine) |
---|
52 | USE dynatf_qco ! time filtering (dyn_atf_qco routine) |
---|
53 | |
---|
54 | USE bdydyn ! ocean open boundary conditions (define bdy_dyn) |
---|
55 | |
---|
56 | #if defined key_agrif |
---|
57 | USE agrif_oce_interp |
---|
58 | #endif |
---|
59 | |
---|
60 | IMPLICIT NONE |
---|
61 | PRIVATE |
---|
62 | |
---|
63 | PUBLIC stp_MLF ! called by nemogcm.F90 |
---|
64 | |
---|
65 | ! !** time level indices **! |
---|
66 | INTEGER, PUBLIC :: Nbb, Nnn, Naa, Nrhs !: used by nemo_init |
---|
67 | |
---|
68 | !! * Substitutions |
---|
69 | # include "domzgr_substitute.h90" |
---|
70 | !!---------------------------------------------------------------------- |
---|
71 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
72 | !! $Id: step.F90 12377 2020-02-12 14:39:06Z acc $ |
---|
73 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
74 | !!---------------------------------------------------------------------- |
---|
75 | CONTAINS |
---|
76 | |
---|
77 | #if defined key_agrif |
---|
78 | RECURSIVE SUBROUTINE stp_MLF( ) |
---|
79 | INTEGER :: kstp ! ocean time-step index |
---|
80 | #else |
---|
81 | SUBROUTINE stp_MLF( kstp ) |
---|
82 | INTEGER, INTENT(in) :: kstp ! ocean time-step index |
---|
83 | #endif |
---|
84 | !!---------------------------------------------------------------------- |
---|
85 | !! *** ROUTINE stp_MLF *** |
---|
86 | !! |
---|
87 | !! ** Purpose : - Time stepping of OCE (momentum and active tracer eqs.) |
---|
88 | !! |
---|
89 | !! ** Method : - call dynspg_ts |
---|
90 | !!---------------------------------------------------------------------- |
---|
91 | #if defined key_agrif |
---|
92 | IF( nstop > 0 ) RETURN ! avoid to go further if an error was detected during previous time step (child grid) |
---|
93 | kstp = nit000 + Agrif_Nb_Step() |
---|
94 | Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices |
---|
95 | IF( lk_agrif_debug ) THEN |
---|
96 | IF( Agrif_Root() .and. lwp) WRITE(*,*) '---' |
---|
97 | IF(lwp) WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint() |
---|
98 | ENDIF |
---|
99 | IF( kstp == nit000 + 1 ) lk_agrif_fstep = .FALSE. |
---|
100 | # if defined key_iomput |
---|
101 | IF( Agrif_Nbstepint() == 0 ) CALL iom_swap( cxios_context ) |
---|
102 | # endif |
---|
103 | #endif |
---|
104 | ! |
---|
105 | IF( ln_timing ) CALL timing_start('stp_MLF') |
---|
106 | ! |
---|
107 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
108 | ! model timestep |
---|
109 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
110 | ! |
---|
111 | IF( l_1st_euler ) THEN ! start or restart with Euler 1st time-step |
---|
112 | rDt = rn_Dt |
---|
113 | r1_Dt = 1._wp / rDt |
---|
114 | ENDIF |
---|
115 | ! |
---|
116 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
117 | ! update I/O and calendar |
---|
118 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
119 | ! |
---|
120 | IF( kstp == nit000 ) THEN ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS) |
---|
121 | CALL iom_init( cxios_context, ld_closedef=.FALSE. ) ! for model grid (including possible AGRIF zoom) |
---|
122 | CALL iom_init_closedef |
---|
123 | ts (:,:,:,:,Naa) = ts (:,:,:,:,Nnn) ! needed for stpctl |
---|
124 | ELSE |
---|
125 | CALL day( kstp ) ! Calendar (day was already called at nit000 in day_init) |
---|
126 | ENDIF |
---|
127 | CALL iom_setkt( kstp - nit000 + 1, cxios_context ) ! tell IOM we are at time step kstp |
---|
128 | |
---|
129 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
130 | ! Update external forcing (tides, open boundaries, ice shelf interaction and surface boundary condition (including sea-ice) |
---|
131 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
132 | CALL sbc ( kstp, Nbb, Nnn ) ! Sea Boundary Condition (including sea-ice) |
---|
133 | |
---|
134 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
135 | ! Ocean dynamics : hdiv, ssh, e3, u, v, w |
---|
136 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
137 | IF( .NOT.lk_linssh ) THEN |
---|
138 | CALL dom_qco_r3c( ssh(:,:,Naa), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa) ) ! "after" ssh/h_0 ratio at t,u,v pts |
---|
139 | IF( ln_dynspg_exp ) & |
---|
140 | & CALL dom_qco_r3c( ssh(:,:,Nnn), r3t(:,:,Nnn), r3u(:,:,Nnn), r3v(:,:,Nnn), r3f(:,:) ) ! spg_exp : needed only for "now" ssh/h_0 ratio at f point |
---|
141 | ENDIF |
---|
142 | uu(:,:,:,Nrhs) = 0._wp ! set dynamics trends to zero |
---|
143 | vv(:,:,:,Nrhs) = 0._wp |
---|
144 | CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa, 1 ) ! surface pressure gradient |
---|
145 | CALL iom_put( "ssh" , ssh(:,:,Nnn) ) ! sea surface height |
---|
146 | ! Swap time levels |
---|
147 | Nrhs = Nbb |
---|
148 | Nbb = Nnn |
---|
149 | Nnn = Naa |
---|
150 | Naa = Nrhs |
---|
151 | |
---|
152 | #if defined key_agrif |
---|
153 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
154 | ! AGRIF recursive integration |
---|
155 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
156 | Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices |
---|
157 | CALL Agrif_Integrate_ChildGrids( stp_MLF ) ! allows to finish all the Child Grids before updating |
---|
158 | |
---|
159 | #endif |
---|
160 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
161 | ! Control |
---|
162 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
163 | CALL stp_ctl ( kstp, Nnn ) |
---|
164 | |
---|
165 | #if defined key_agrif |
---|
166 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
167 | ! AGRIF update |
---|
168 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
169 | IF( Agrif_NbStepint() == 0 .AND. nstop == 0 ) & |
---|
170 | & CALL Agrif_update_all( ) ! Update all components |
---|
171 | ENDIF |
---|
172 | |
---|
173 | #endif |
---|
174 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
175 | ! File manipulation at the end of the first time step |
---|
176 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
177 | IF( kstp == nit000 ) THEN ! 1st time step only |
---|
178 | CALL iom_close( numror ) ! close input ocean restart file |
---|
179 | IF(lwm) CALL FLUSH ( numond ) ! flush output namelist oce |
---|
180 | IF(lwm .AND. numoni /= -1 ) CALL FLUSH ( numoni ) ! flush output namelist ice (if exist) |
---|
181 | ENDIF |
---|
182 | |
---|
183 | #if defined key_iomput |
---|
184 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
185 | ! Finalize contextes if end of simulation or error detected |
---|
186 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
187 | IF( kstp == nitend .OR. nstop > 0 ) THEN |
---|
188 | CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF |
---|
189 | ENDIF |
---|
190 | #endif |
---|
191 | ! |
---|
192 | IF( l_1st_euler ) THEN ! recover Leap-frog timestep |
---|
193 | rDt = 2._wp * rn_Dt |
---|
194 | r1_Dt = 1._wp / rDt |
---|
195 | l_1st_euler = .FALSE. |
---|
196 | ENDIF |
---|
197 | ! |
---|
198 | IF( ln_timing ) CALL timing_stop('stp_MLF') |
---|
199 | ! |
---|
200 | END SUBROUTINE stp_MLF |
---|
201 | |
---|
202 | #else |
---|
203 | !!---------------------------------------------------------------------- |
---|
204 | !! default option EMPTY MODULE qco not activated |
---|
205 | !!---------------------------------------------------------------------- |
---|
206 | #endif |
---|
207 | |
---|
208 | !!====================================================================== |
---|
209 | END MODULE stpmlf |
---|