1 | MODULE step |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE step *** |
---|
4 | !! Time-stepping : manager of the ocean, tracer and ice time stepping |
---|
5 | !!====================================================================== |
---|
6 | !! History : OPA ! 1991-03 (G. Madec) Original code |
---|
7 | !! - ! 1991-11 (G. Madec) |
---|
8 | !! - ! 1992-06 (M. Imbard) add a first output record |
---|
9 | !! - ! 1996-04 (G. Madec) introduction of dynspg |
---|
10 | !! - ! 1996-04 (M.A. Foujols) introduction of passive tracer |
---|
11 | !! 8.0 ! 1997-06 (G. Madec) new architecture of call |
---|
12 | !! 8.2 ! 1997-06 (G. Madec, M. Imbard, G. Roullet) free surface |
---|
13 | !! - ! 1999-02 (G. Madec, N. Grima) hpg implicit |
---|
14 | !! - ! 2000-07 (J-M Molines, M. Imbard) Open Bondary Conditions |
---|
15 | !! NEMO 1.0 ! 2002-06 (G. Madec) free form, suppress macro-tasking |
---|
16 | !! - ! 2004-08 (C. Talandier) New trends organization |
---|
17 | !! - ! 2005-01 (C. Ethe) Add the KPP closure scheme |
---|
18 | !! - ! 2005-11 (G. Madec) Reorganisation of tra and dyn calls |
---|
19 | !! - ! 2006-01 (L. Debreu, C. Mazauric) Agrif implementation |
---|
20 | !! - ! 2006-07 (S. Masson) restart using iom |
---|
21 | !! 3.2 ! 2009-02 (G. Madec, R. Benshila) reintroduicing z*-coordinate |
---|
22 | !! - ! 2009-06 (S. Masson, G. Madec) TKE restart compatible with key_cpl |
---|
23 | !! 3.3 ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA |
---|
24 | !!---------------------------------------------------------------------- |
---|
25 | |
---|
26 | !!---------------------------------------------------------------------- |
---|
27 | !! stp : OPA system time-stepping |
---|
28 | !!---------------------------------------------------------------------- |
---|
29 | USE step_oce ! time stepping definition modules |
---|
30 | #if defined key_top |
---|
31 | USE trcstp ! passive tracer time-stepping (trc_stp routine) |
---|
32 | #endif |
---|
33 | |
---|
34 | IMPLICIT NONE |
---|
35 | PRIVATE |
---|
36 | |
---|
37 | PUBLIC stp ! called by opa.F90 |
---|
38 | |
---|
39 | !! * Substitutions |
---|
40 | # include "domzgr_substitute.h90" |
---|
41 | # include "zdfddm_substitute.h90" |
---|
42 | !!---------------------------------------------------------------------- |
---|
43 | !! NEMO/OPA 3.3 , LOCEAN-IPSL (2010) |
---|
44 | !! $Id$ |
---|
45 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
46 | !!---------------------------------------------------------------------- |
---|
47 | |
---|
48 | CONTAINS |
---|
49 | |
---|
50 | #if defined key_agrif |
---|
51 | SUBROUTINE stp( ) |
---|
52 | INTEGER :: kstp ! ocean time-step index |
---|
53 | #else |
---|
54 | SUBROUTINE stp( kstp ) |
---|
55 | INTEGER, INTENT(in) :: kstp ! ocean time-step index |
---|
56 | #endif |
---|
57 | !!---------------------------------------------------------------------- |
---|
58 | !! *** ROUTINE stp *** |
---|
59 | !! |
---|
60 | !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.) |
---|
61 | !! - Time stepping of LIM (dynamic and thermodynamic eqs.) |
---|
62 | !! - Tme stepping of TRC (passive tracer eqs.) |
---|
63 | !! |
---|
64 | !! ** Method : -1- Update forcings and data |
---|
65 | !! -2- Update ocean physics |
---|
66 | !! -3- Compute the t and s trends |
---|
67 | !! -4- Update t and s |
---|
68 | !! -5- Compute the momentum trends |
---|
69 | !! -6- Update the horizontal velocity |
---|
70 | !! -7- Compute the diagnostics variables (rd,N2, div,cur,w) |
---|
71 | !! -8- Outputs and diagnostics |
---|
72 | !!---------------------------------------------------------------------- |
---|
73 | INTEGER :: jk ! dummy loop indice |
---|
74 | INTEGER :: indic ! error indicator if < 0 |
---|
75 | !! --------------------------------------------------------------------- |
---|
76 | |
---|
77 | #if defined key_agrif |
---|
78 | kstp = nit000 + Agrif_Nb_Step() |
---|
79 | # if defined key_iomput |
---|
80 | IF( Agrif_Nbstepint() == 0 ) CALL iom_swap |
---|
81 | # endif |
---|
82 | #endif |
---|
83 | indic = 0 ! reset to no error condition |
---|
84 | IF( kstp /= nit000 ) CALL day ( kstp ) ! Calendar (day was already called at nit000 in day_init) |
---|
85 | CALL iom_setkt( kstp ) ! say to iom that we are at time step kstp |
---|
86 | CALL rst_opn ( kstp ) ! Open the restart file |
---|
87 | |
---|
88 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
89 | ! Update data, open boundaries, surface boundary condition (including sea-ice) |
---|
90 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
91 | IF( lk_dtatem ) CALL dta_tem( kstp ) ! update 3D temperature data |
---|
92 | IF( lk_dtasal ) CALL dta_sal( kstp ) ! update 3D salinity data |
---|
93 | CALL sbc ( kstp ) ! Sea Boundary Condition (including sea-ice) |
---|
94 | IF( lk_obc ) CALL obc_dta( kstp ) ! update dynamic and tracer data at open boundaries |
---|
95 | IF( lk_obc ) CALL obc_rad( kstp ) ! compute phase velocities at open boundaries |
---|
96 | IF( lk_bdy ) CALL bdy_dta( kstp ) ! update dynamic and tracer data at unstructured open boundary |
---|
97 | |
---|
98 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
99 | ! Ocean dynamics : ssh, wn, hdiv, rot ! |
---|
100 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
101 | CALL ssh_wzv( kstp ) ! after ssh & vertical velocity |
---|
102 | |
---|
103 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
104 | ! Ocean physics update (ua, va, ta, sa used as workspace) |
---|
105 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
106 | CALL bn2( tsb, rn2b ) ! before Brunt-Vaisala frequency |
---|
107 | CALL bn2( tsn, rn2 ) ! now Brunt-Vaisala frequency |
---|
108 | ! |
---|
109 | ! VERTICAL PHYSICS |
---|
110 | CALL zdf_bfr( kstp ) ! bottom friction |
---|
111 | ! ! Vertical eddy viscosity and diffusivity coefficients |
---|
112 | IF( lk_zdfric ) CALL zdf_ric ( kstp ) ! Richardson number dependent Kz |
---|
113 | IF( lk_zdftke_old ) CALL zdf_tke_old( kstp ) ! TKE closure scheme for Kz (old scheme) |
---|
114 | IF( lk_zdftke ) CALL zdf_tke ( kstp ) ! TKE closure scheme for Kz |
---|
115 | IF( lk_zdfkpp ) CALL zdf_kpp ( kstp ) ! KPP closure scheme for Kz |
---|
116 | IF( lk_zdfcst ) THEN ! Constant Kz (reset avt, avm[uv] to the background value) |
---|
117 | avt (:,:,:) = rn_avt0 * tmask(:,:,:) |
---|
118 | avmu(:,:,:) = rn_avm0 * umask(:,:,:) |
---|
119 | avmv(:,:,:) = rn_avm0 * vmask(:,:,:) |
---|
120 | ENDIF |
---|
121 | IF( ln_rnf_mouth ) THEN ! increase diffusivity at rivers mouths |
---|
122 | DO jk = 2, nkrnf ; avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk) ; END DO |
---|
123 | ENDIF |
---|
124 | IF( ln_zdfevd ) CALL zdf_evd( kstp ) ! enhanced vertical eddy diffusivity |
---|
125 | |
---|
126 | IF( lk_zdftmx ) CALL zdf_tmx( kstp ) ! tidal vertical mixing |
---|
127 | |
---|
128 | IF( lk_zdfddm .AND. .NOT. lk_zdfkpp ) & |
---|
129 | & CALL zdf_ddm( kstp ) ! double diffusive mixing |
---|
130 | CALL zdf_mxl( kstp ) ! mixed layer depth |
---|
131 | |
---|
132 | ! write tke information in the restart file |
---|
133 | IF( lrst_oce .AND. lk_zdftke ) CALL tke_rst( kstp, 'WRITE' ) |
---|
134 | ! |
---|
135 | ! LATERAL PHYSICS |
---|
136 | ! |
---|
137 | IF( lk_ldfslp ) THEN ! slope of lateral mixing |
---|
138 | CALL eos( tsb, rhd ) ! before in situ density |
---|
139 | IF( ln_zps ) CALL zps_hde( kstp, jpts, tsb, gtsu, gtsv, & ! Partial steps: before horizontal gradient |
---|
140 | & rhd, gru , grv ) ! of t, s, rd at the last ocean level |
---|
141 | CALL ldf_slp( kstp, rhd, rn2b ) ! before slope of the lateral mixing |
---|
142 | ENDIF |
---|
143 | #if defined key_traldf_c2d |
---|
144 | IF( lk_traldf_eiv ) CALL ldf_eiv( kstp ) ! eddy induced velocity coefficient |
---|
145 | # endif |
---|
146 | |
---|
147 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
148 | ! diagnostics and outputs (ua, va, ta, sa used as workspace) |
---|
149 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
150 | IF( lk_floats ) CALL flo_stp( kstp ) ! drifting Floats |
---|
151 | IF( lk_diahth ) CALL dia_hth( kstp ) ! Thermocline depth (20 degres isotherm depth) |
---|
152 | IF( lk_diagap ) CALL dia_gap( kstp ) ! basin averaged diagnostics |
---|
153 | IF( lk_diahdy ) CALL dia_hdy( kstp ) ! dynamical heigh diagnostics |
---|
154 | IF( lk_diafwb ) CALL dia_fwb( kstp ) ! Fresh water budget diagnostics |
---|
155 | IF( ln_diaptr ) CALL dia_ptr( kstp ) ! Poleward TRansports diagnostics |
---|
156 | IF( lk_diaar5 ) CALL dia_ar5( kstp ) ! ar5 diag |
---|
157 | CALL dia_wri( kstp ) ! ocean model: outputs |
---|
158 | |
---|
159 | #if defined key_top |
---|
160 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
161 | ! Passive Tracer Model |
---|
162 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
163 | CALL trc_stp( kstp ) ! time-stepping |
---|
164 | #endif |
---|
165 | |
---|
166 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
167 | ! Active tracers (ua, va used as workspace) |
---|
168 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
169 | tsa(:,:,:,:) = 0.e0 ! set tracer trends to zero |
---|
170 | |
---|
171 | CALL tra_sbc ( kstp ) ! surface boundary condition |
---|
172 | IF( ln_traqsr ) CALL tra_qsr ( kstp ) ! penetrative solar radiation qsr |
---|
173 | IF( lk_trabbc ) CALL tra_bbc ( kstp ) ! bottom heat flux |
---|
174 | IF( lk_trabbl ) CALL tra_bbl ( kstp ) ! advective (and/or diffusive) bottom boundary layer scheme |
---|
175 | IF( lk_tradmp ) CALL tra_dmp ( kstp ) ! internal damping trends |
---|
176 | CALL tra_adv ( kstp ) ! horizontal & vertical advection |
---|
177 | IF( n_cla == 1 ) CALL tra_cla ( kstp ) ! Cross Land Advection (Update Hor. advection) |
---|
178 | IF( lk_zdfkpp ) CALL tra_kpp ( kstp ) ! KPP non-local tracer fluxes |
---|
179 | CALL tra_ldf ( kstp ) ! lateral mixing |
---|
180 | #if defined key_agrif |
---|
181 | CALL tra_unswap |
---|
182 | IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra ! tracers sponge |
---|
183 | CALL tra_swap |
---|
184 | #endif |
---|
185 | CALL tra_zdf ( kstp ) ! vertical mixing and after tracer fields |
---|
186 | |
---|
187 | IF( ln_dynhpg_imp ) THEN ! semi-implicit hpg (time stepping then eos) |
---|
188 | IF( ln_zdfnpc ) CALL tra_npc ( kstp ) ! update after fields by non-penetrative convection |
---|
189 | CALL tra_nxt ( kstp ) ! tracer fields at next time step |
---|
190 | CALL eos( tsa, rhd, rhop ) ! Time-filtered in situ density for hpg computation |
---|
191 | IF( ln_zps ) CALL zps_hde( kstp, jpts, tsa, gtsu, gtsv, & ! zps: time filtered hor. derivative |
---|
192 | & rhd, gru , grv ) ! of t, s, rd at the last ocean level |
---|
193 | |
---|
194 | ELSE ! centered hpg (eos then time stepping) |
---|
195 | CALL eos( tsn, rhd, rhop ) ! now in situ density for hpg computation |
---|
196 | IF( ln_zps ) CALL zps_hde( kstp, jpts, tsn, gtsu, gtsv, & ! zps: now hor. derivative |
---|
197 | & rhd, gru , grv ) ! of t, s, rd at the last ocean level |
---|
198 | IF( ln_zdfnpc ) CALL tra_npc ( kstp ) ! update after fields by non-penetrative convection |
---|
199 | CALL tra_nxt ( kstp ) ! tracer fields at next time step |
---|
200 | ENDIF |
---|
201 | CALL tra_unswap |
---|
202 | |
---|
203 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
204 | ! Dynamics (ta, sa used as workspace) |
---|
205 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
206 | ua(:,:,:) = 0.e0 ! set dynamics trends to zero |
---|
207 | va(:,:,:) = 0.e0 |
---|
208 | |
---|
209 | CALL dyn_adv( kstp ) ! advection (vector or flux form) |
---|
210 | CALL dyn_vor( kstp ) ! vorticity term including Coriolis |
---|
211 | CALL dyn_ldf( kstp ) ! lateral mixing |
---|
212 | #if defined key_agrif |
---|
213 | IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn ! momemtum sponge |
---|
214 | #endif |
---|
215 | CALL dyn_hpg( kstp ) ! horizontal gradient of Hydrostatic pressure |
---|
216 | CALL dyn_bfr( kstp ) ! bottom friction |
---|
217 | CALL dyn_zdf( kstp ) ! vertical diffusion |
---|
218 | CALL dyn_spg( kstp, indic ) ! surface pressure gradient |
---|
219 | CALL dyn_nxt( kstp ) ! lateral velocity at next time step |
---|
220 | |
---|
221 | CALL ssh_nxt( kstp ) ! sea surface height at next time step |
---|
222 | |
---|
223 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
224 | ! Control and restarts |
---|
225 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
226 | CALL stp_ctl( kstp, indic ) |
---|
227 | IF( indic < 0 ) THEN |
---|
228 | CALL ctl_stop( 'step: indic < 0' ) |
---|
229 | CALL dia_wri_state( 'output.abort', kstp ) |
---|
230 | ENDIF |
---|
231 | IF( kstp == nit000 ) CALL iom_close( numror ) ! close input ocean restart file |
---|
232 | IF( lrst_oce ) CALL rst_write ( kstp ) ! write output ocean restart file |
---|
233 | IF( lk_obc ) CALL obc_rst_write( kstp ) ! write open boundary restart file |
---|
234 | |
---|
235 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
236 | ! Trends (ua, va, ta, sa used as workspace) |
---|
237 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
238 | IF( nstop == 0 ) THEN |
---|
239 | IF( lk_trddyn ) CALL trd_dwr( kstp ) ! trends: dynamics |
---|
240 | IF( lk_trdtra ) CALL trd_twr( kstp ) ! trends: active tracers |
---|
241 | IF( lk_trdmld ) CALL trd_mld( kstp ) ! trends: Mixed-layer |
---|
242 | IF( lk_trdvor ) CALL trd_vor( kstp ) ! trends: vorticity budget |
---|
243 | ENDIF |
---|
244 | |
---|
245 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
246 | ! Coupled mode |
---|
247 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
---|
248 | IF( lk_cpl ) CALL sbc_cpl_snd( kstp ) ! coupled mode : field exchanges |
---|
249 | ! |
---|
250 | ! |
---|
251 | END SUBROUTINE stp |
---|
252 | |
---|
253 | !!====================================================================== |
---|
254 | END MODULE step |
---|