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.
step.F90 in branches/dev_1784_PATM/NEMO/OPA_SRC – NEMO

source: branches/dev_1784_PATM/NEMO/OPA_SRC/step.F90 @ 2141

Last change on this file since 2141 was 2141, checked in by cbricaud, 14 years ago

add module to read atmospheric pressure and module to compute surface pressure gradient

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 20.5 KB
Line 
1MODULE 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   !!----------------------------------------------------------------------
24
25   !!----------------------------------------------------------------------
26   !!   stp            : OPA system time-stepping
27   !!----------------------------------------------------------------------
28   USE oce             ! ocean dynamics and tracers variables
29   USE dom_oce         ! ocean space and time domain variables
30   USE sbc_oce         ! surface boundary condition
31   USE zdf_oce         ! ocean vertical physics variables
32   USE ldftra_oce      ! ocean tracer   - trends
33   USE ldfdyn_oce      ! ocean dynamics - trends
34   USE in_out_manager  ! I/O manager
35   USE iom             !
36   USE lbclnk
37
38   USE daymod          ! calendar                         (day     routine)
39
40   USE dtatem          ! ocean temperature data           (dta_tem routine)
41   USE dtasal          ! ocean salinity    data           (dta_sal routine)
42   USE sbcmod          ! surface boundary condition       (sbc     routine)
43   USE sbcrnf          ! surface boundary condition: runoff variables
44   USE sbccpl          ! surface boundary condition: coupled formulation (call send at end of step)
45   USE sbcpatm         ! Atmospheric pressure forcing
46   USE cpl_oasis3, ONLY : lk_cpl
47
48#if defined key_top
49   USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
50#endif
51
52   USE traqsr          ! solar radiation penetration      (tra_qsr routine)
53   USE trasbc          ! surface boundary condition       (tra_sbc routine)
54   USE trabbc          ! bottom boundary condition        (tra_bbc routine)
55   USE trabbl          ! bottom boundary layer            (tra_bbl routine)
56   USE tradmp          ! internal damping                 (tra_dmp routine)
57   USE traadv          ! advection scheme control     (tra_adv_ctl routine)
58   USE traldf          ! lateral mixing                   (tra_ldf routine)
59   USE cla             ! cross land advection             (tra_cla routine)
60   !   zdfkpp          ! KPP non-local tracer fluxes      (tra_kpp routine)
61   USE trazdf          ! vertical mixing                  (tra_zdf routine)
62   USE tranxt          ! time-stepping                    (tra_nxt routine)
63   USE tranpc          ! non-penetrative convection       (tra_npc routine)
64
65   USE eosbn2          ! equation of state                (eos_bn2 routine)
66
67   USE dynadv          ! advection                        (dyn_adv routine)
68   USE dynbfr          ! Bottom friction terms            (dyn_bfr routine)
69   USE dynvor          ! vorticity term                   (dyn_vor routine)
70   USE dynhpg          ! hydrostatic pressure grad.       (dyn_hpg routine)
71   USE dynldf          ! lateral momentum diffusion       (dyn_ldf routine)
72   USE dynzdf          ! vertical diffusion               (dyn_zdf routine)
73   USE dynspg_oce      ! surface pressure gradient        (dyn_spg routine)
74   USE dynapg          ! atmospheric pressure forcing     (dyn_apg routine)
75   USE dynspg          ! surface pressure gradient        (dyn_spg routine)
76   USE dynnxt          ! time-stepping                    (dyn_nxt routine)
77
78   USE obc_par         ! open boundary condition variables
79   USE obcdta          ! open boundary condition data     (obc_dta routine)
80   USE obcrst          ! open boundary cond. restart      (obc_rst routine)
81   USE obcrad          ! open boundary cond. radiation    (obc_rad routine)
82
83   USE bdy_par         ! unstructured open boundary data variables
84   USE bdydta          ! unstructured open boundary data  (bdy_dta routine)
85
86   USE sshwzv          ! vertical velocity and ssh        (ssh_wzv routine)
87
88   USE ldfslp          ! iso-neutral slopes               (ldf_slp routine)
89   USE ldfeiv          ! eddy induced velocity coef.      (ldf_eiv routine)
90
91   USE zdftmx          ! tide-induced vertical mixing     (zdf_tmx routine)
92   USE zdfbfr          ! bottom friction                  (zdf_bfr routine)
93   USE zdftke_old      ! old TKE vertical mixing      (zdf_tke_old routine)
94   USE zdftke          ! TKE vertical mixing              (zdf_tke routine)
95   USE zdfkpp          ! KPP vertical mixing              (zdf_kpp routine)
96   USE zdfddm          ! double diffusion mixing          (zdf_ddm routine)
97   USE zdfevd          ! enhanced vertical diffusion      (zdf_evd routine)
98   USE zdfric          ! Richardson vertical mixing       (zdf_ric routine)
99   USE zdfmxl          ! Mixed-layer depth                (zdf_mxl routine)
100
101   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
102
103   USE diawri          ! Standard run outputs             (dia_wri routine)
104   USE trdicp          ! Ocean momentum/tracers trends    (trd_wri routine)
105   USE trdmld          ! mixed-layer trends               (trd_mld routine)
106   USE trdmld_rst      ! restart for mixed-layer trends
107   USE trdmod_oce      ! ocean momentum/tracers trends
108   USE trdvor          ! vorticity budget                 (trd_vor routine)
109   USE diagap          ! hor. mean model-data gap         (dia_gap routine)
110   USE diahdy          ! dynamic height                   (dia_hdy routine)
111   USE diaptr          ! poleward transports              (dia_ptr routine)
112   USE diaar5          ! AR5 diagnosics                   (dia_ar5 routine)
113   USE diahth          ! thermocline depth                (dia_hth routine)
114   USE diafwb          ! freshwater budget                (dia_fwb routine)
115   USE flo_oce         ! floats variables
116   USE floats          ! floats computation               (flo_stp routine)
117
118   USE stpctl          ! time stepping control            (stp_ctl routine)
119   USE restart         ! ocean restart                    (rst_wri routine)
120   USE prtctl          ! Print control                    (prt_ctl routine)
121
122#if defined key_agrif
123   USE agrif_opa_sponge ! Momemtum and tracers sponges
124#endif
125
126   IMPLICIT NONE
127   PRIVATE
128
129   PUBLIC   stp        ! called by opa.F90
130
131   !! * Substitutions
132#  include "domzgr_substitute.h90"
133#  include "zdfddm_substitute.h90"
134   !!----------------------------------------------------------------------
135   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
136   !! $Id$
137   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
138   !!----------------------------------------------------------------------
139
140CONTAINS
141
142#if defined key_agrif
143   SUBROUTINE stp( )
144      INTEGER             ::   kstp   ! ocean time-step index
145#else
146   SUBROUTINE stp( kstp )
147      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
148#endif
149      !!----------------------------------------------------------------------
150      !!                     ***  ROUTINE stp  ***
151      !!                     
152      !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
153      !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
154      !!              - Tme stepping  of TRC (passive tracer eqs.)
155      !!
156      !! ** Method  : -1- Update forcings and data 
157      !!              -2- Update ocean physics
158      !!              -3- Compute the t and s trends
159      !!              -4- Update t and s
160      !!              -5- Compute the momentum trends
161      !!              -6- Update the horizontal velocity
162      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
163      !!              -8- Outputs and diagnostics
164      !!----------------------------------------------------------------------
165      INTEGER ::   jk       ! dummy loop indice
166      INTEGER ::   indic    ! error indicator if < 0
167      !! ---------------------------------------------------------------------
168
169#if defined key_agrif
170      kstp = nit000 + Agrif_Nb_Step()
171!      IF ( Agrif_Root() .and. lwp) Write(*,*) '---'
172!      IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp
173#endif
174      indic = 1                                       ! reset to no error condition
175
176      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
177
178      CALL iom_setkt( kstp )                          ! say to iom that we are at time step kstp
179     
180      CALL rst_opn( kstp )                            ! Open the restart file
181
182      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
183      ! Update data, open boundaries, surface boundary condition (including sea-ice)
184      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
185      IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
186      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
187                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
188      IF( lk_obc     )   CALL obc_dta( kstp )         ! update dynamic and tracer data at open boundaries
189      IF( lk_obc     )   CALL obc_rad( kstp )         ! compute phase velocities at open boundaries
190      IF( lk_bdy     )   CALL bdy_dta( kstp )         ! update dynamic and tracer data at unstructured open boundary
191
192      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
193      !  Ocean dynamics : ssh, wn, hdiv, rot                                 !
194      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
195                         CALL ssh_wzv( kstp )         ! after ssh & vertical velocity
196
197      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
198      ! Ocean physics update                (ua, va, ta, sa used as workspace)
199      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
200                         CALL bn2( tb, sb, rn2b )     ! before Brunt-Vaisala frequency
201                         CALL bn2( tn, sn, rn2  )     ! now    Brunt-Vaisala frequency
202      !
203      !  VERTICAL PHYSICS   
204                         CALL zdf_bfr( kstp )         ! bottom friction
205      !                                               ! Vertical eddy viscosity and diffusivity coefficients
206      IF( lk_zdfric     )   CALL zdf_ric    ( kstp )  ! Richardson number dependent Kz
207      IF( lk_zdftke_old )   CALL zdf_tke_old( kstp )  ! TKE closure scheme for Kz (old scheme)
208      IF( lk_zdftke     )   CALL zdf_tke    ( kstp )  ! TKE closure scheme for Kz
209      IF( lk_zdfkpp     )   CALL zdf_kpp    ( kstp )  ! KPP closure scheme for Kz
210      IF( lk_zdfcst     )   THEN                      ! Constant Kz (reset avt, avm[uv] to the background value)
211         avt (:,:,:) = rn_avt0 * tmask(:,:,:)
212         avmu(:,:,:) = rn_avm0 * umask(:,:,:)
213         avmv(:,:,:) = rn_avm0 * vmask(:,:,:)
214      ENDIF
215      IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths
216         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO
217      ENDIF
218      IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
219
220      IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
221
222      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
223         &               CALL zdf_ddm( kstp )         ! double diffusive mixing
224                         CALL zdf_mxl( kstp )         ! mixed layer depth
225
226                                                      ! write tke information in the restart file
227      IF( lrst_oce .AND. lk_zdftke )   CALL tke_rst( kstp, 'WRITE' )
228      !
229      !  LATERAL  PHYSICS
230      !
231      IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
232                         CALL eos( tb, sb, rhd )                ! before in situ density
233         IF( ln_zps )    CALL zps_hde( kstp, tb, sb, rhd,  &    ! Partial steps: before horizontal gradient
234            &                              gtu, gsu, gru,  &    ! of t, s, rd at the last ocean level
235            &                              gtv, gsv, grv )
236                         CALL ldf_slp( kstp, rhd, rn2b )        ! before slope of the lateral mixing
237      ENDIF
238#if defined key_traldf_c2d
239      IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )      ! eddy induced velocity coefficient
240#  endif
241
242      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
243      ! diagnostics and outputs             (ua, va, ta, sa used as workspace)
244      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
245      IF( lk_floats  )   CALL flo_stp( kstp )         ! drifting Floats
246      IF( lk_diahth  )   CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth)
247      IF( lk_diagap  )   CALL dia_gap( kstp )         ! basin averaged diagnostics
248      IF( lk_diahdy  )   CALL dia_hdy( kstp )         ! dynamical heigh diagnostics
249      IF( lk_diafwb  )   CALL dia_fwb( kstp )         ! Fresh water budget diagnostics
250      IF( ln_diaptr  )   CALL dia_ptr( kstp )         ! Poleward TRansports diagnostics
251      IF( lk_diaar5  )   CALL dia_ar5( kstp )         ! ar5 diag
252                         CALL dia_wri( kstp )         ! ocean model: outputs
253
254#if defined key_top
255      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
256      ! Passive Tracer Model
257      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
258                         CALL trc_stp( kstp )         ! time-stepping
259#endif
260
261      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
262      ! Active tracers                              (ua, va used as workspace)
263      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
264                             ta(:,:,:) = 0.e0               ! set tracer trends to zero
265                             sa(:,:,:) = 0.e0
266
267                             CALL tra_sbc    ( kstp )       ! surface boundary condition
268      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
269      IF( lk_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
270      IF( lk_trabbl_dif  )   CALL tra_bbl_dif( kstp )       ! diffusive bottom boundary layer scheme
271      IF( lk_trabbl_adv  )   CALL tra_bbl_adv( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
272      IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
273                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection
274      IF( n_cla == 1     )   CALL tra_cla    ( kstp )       ! Cross Land Advection (Update Hor. advection)
275      IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
276                             CALL tra_ldf    ( kstp )       ! lateral mixing
277#if defined key_agrif
278      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge
279#endif
280                             CALL tra_zdf    ( kstp )       ! vertical mixing and after tracer fields
281
282      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg (time stepping then eos)
283         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )            ! update after fields by non-penetrative convection
284                             CALL tra_nxt    ( kstp )            ! tracer fields at next time step
285                             CALL eos( ta, sa, rhd, rhop )       ! Time-filtered in situ density for hpg computation
286         IF( ln_zps      )   CALL zps_hde( kstp, ta, sa, rhd,   &   ! Partial steps: time filtered hor. derivative
287            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
288            &                                   gtv, gsv, grv )
289         
290      ELSE                                                  ! centered hpg  (eos then time stepping)
291                             CALL eos( tn, sn, rhd, rhop )       ! now in situ density for hpg computation
292         IF( ln_zps      )   CALL zps_hde( kstp, tn, sn, rhd,   &   ! Partial steps: now horizontal derivative
293            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
294            &                                   gtv, gsv, grv )
295         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )       ! update after fields by non-penetrative convection
296                             CALL tra_nxt    ( kstp )       ! tracer fields at next time step
297      ENDIF 
298
299      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
300      ! Dynamics                                    (ta, sa used as workspace)
301      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
302                               ua(:,:,:) = 0.e0             ! set dynamics trends to zero
303                               va(:,:,:) = 0.e0
304
305                               CALL dyn_adv( kstp )         ! advection (vector or flux form)
306                               CALL dyn_vor( kstp )         ! vorticity term including Coriolis
307                               CALL dyn_ldf( kstp )         ! lateral mixing
308#if defined key_agrif
309      IF(.NOT. Agrif_Root())   CALL Agrif_Sponge_dyn        ! momemtum sponge
310#endif
311                               CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
312                               CALL dyn_bfr( kstp )           ! bottom friction   
313                               CALL dyn_zdf( kstp )         ! vertical diffusion
314                               indic=0
315        IF( ln_patm_apg  )     CALL dyn_apg( kstp )         ! Atmospheric pressure forcing
316                               CALL dyn_spg( kstp, indic )  ! surface pressure gradient
317                               CALL dyn_nxt( kstp )         ! lateral velocity at next time step
318
319                               CALL ssh_nxt( kstp )         ! sea surface height at next time step
320
321      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
322      ! Control and restarts
323      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
324                               CALL stp_ctl( kstp, indic )
325      IF( indic < 0        )   THEN
326                               CALL ctl_stop( 'step: indic < 0' )
327                               CALL dia_wri_state( 'output.abort', kstp )
328      ENDIF
329      IF( kstp == nit000   )   CALL iom_close( numror )     ! close input  ocean restart file
330      IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
331      IF( lk_obc           )   CALL obc_rst_write( kstp )   ! write open boundary restart file
332
333      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
334      ! Trends                              (ua, va, ta, sa used as workspace)
335      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
336      IF( nstop == 0 ) THEN                         
337         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics
338         IF( lk_trdtra     )   CALL trd_twr( kstp )         ! trends: active tracers
339         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer
340         IF( lk_trdvor     )   CALL trd_vor( kstp )         ! trends: vorticity budget
341      ENDIF
342
343      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
344      ! Coupled mode
345      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
346      IF( lk_cpl           )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
347      !
348      !
349   END SUBROUTINE stp
350
351   !!======================================================================
352END MODULE step
Note: See TracBrowser for help on using the repository browser.