1 | MODULE dynspg |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE dynspg *** |
---|
4 | !! Ocean dynamics: surface pressure gradient control |
---|
5 | !!====================================================================== |
---|
6 | !! History : 1.0 ! 2005-12 (C. Talandier, G. Madec, V. Garnier) Original code |
---|
7 | !! 3.2 ! 2009-07 (R. Benshila) Suppression of rigid-lid option |
---|
8 | !!---------------------------------------------------------------------- |
---|
9 | |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | !! dyn_spg : update the dynamics trend with the lateral diffusion |
---|
12 | !! dyn_spg_ctl : initialization, namelist read, and parameters control |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | USE oce ! ocean dynamics and tracers variables |
---|
15 | USE dom_oce ! ocean space and time domain variables |
---|
16 | USE phycst ! physical constants |
---|
17 | USE obc_oce ! ocean open boundary conditions |
---|
18 | USE sbc_oce ! surface boundary condition: ocean |
---|
19 | USE sbcapr ! surface boundary condition: atmospheric pressure |
---|
20 | USE dynspg_oce ! surface pressure gradient variables |
---|
21 | USE dynspg_exp ! surface pressure gradient (dyn_spg_exp routine) |
---|
22 | USE dynspg_ts ! surface pressure gradient (dyn_spg_ts routine) |
---|
23 | USE dynspg_flt ! surface pressure gradient (dyn_spg_flt routine) |
---|
24 | USE dynadv ! dynamics: vector invariant versus flux form |
---|
25 | USE trdmod ! ocean dynamics trends |
---|
26 | USE trdmod_oce ! ocean variables trends |
---|
27 | USE prtctl ! Print control (prt_ctl routine) |
---|
28 | USE in_out_manager ! I/O manager |
---|
29 | USE lib_mpp ! MPP library |
---|
30 | USE solver ! solver initialization |
---|
31 | |
---|
32 | IMPLICIT NONE |
---|
33 | PRIVATE |
---|
34 | |
---|
35 | PUBLIC dyn_spg ! routine called by step module |
---|
36 | PUBLIC dyn_spg_init ! routine called by opa module |
---|
37 | |
---|
38 | INTEGER :: nspg = 0 ! type of surface pressure gradient scheme defined from lk_dynspg_... |
---|
39 | |
---|
40 | !! * Substitutions |
---|
41 | # include "domzgr_substitute.h90" |
---|
42 | # include "vectopt_loop_substitute.h90" |
---|
43 | !!---------------------------------------------------------------------- |
---|
44 | !! NEMO/OPA 3.2 , LODYC-IPSL (2009) |
---|
45 | !! $Id$ |
---|
46 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
47 | !!---------------------------------------------------------------------- |
---|
48 | CONTAINS |
---|
49 | |
---|
50 | SUBROUTINE dyn_spg( kt, kindic ) |
---|
51 | !!---------------------------------------------------------------------- |
---|
52 | !! *** ROUTINE dyn_spg *** |
---|
53 | !! |
---|
54 | !! ** Purpose : achieve the momentum time stepping by computing the |
---|
55 | !! last trend, the surface pressure gradient including the |
---|
56 | !! atmospheric pressure forcing (ln_apr_dyn=T), and performing |
---|
57 | !! the Leap-Frog integration. |
---|
58 | !!gm In the current version only the filtered solution provide |
---|
59 | !!gm the after velocity, in the 2 other (ua,va) are still the trends |
---|
60 | !! |
---|
61 | !! ** Method : Three schemes: |
---|
62 | !! - explicit computation : the spg is evaluated at now |
---|
63 | !! - filtered computation : the Roulet & madec (2000) technique is used |
---|
64 | !! - split-explicit computation: a time splitting technique is used |
---|
65 | !! |
---|
66 | !! ln_apr_dyn=T : the atmospheric pressure forcing is applied |
---|
67 | !! as the gradient of the inverse barometer ssh: |
---|
68 | !! apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb] |
---|
69 | !! apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb] |
---|
70 | !! Note that as all external forcing a time averaging over a two rdt |
---|
71 | !! period is used to prevent the divergence of odd and even time step. |
---|
72 | !! |
---|
73 | !! N.B. : When key_esopa is used all the scheme are tested, regardless |
---|
74 | !! of the physical meaning of the results. |
---|
75 | !!---------------------------------------------------------------------- |
---|
76 | USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released |
---|
77 | USE wrk_nemo, ONLY: ztrdu => wrk_3d_4 , ztrdv => wrk_3d_5 ! 3D workspace |
---|
78 | ! |
---|
79 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
80 | INTEGER, INTENT( out) :: kindic ! solver flag |
---|
81 | ! |
---|
82 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
83 | REAL(wp) :: z2dt, zg_2 ! temporary scalar |
---|
84 | !!---------------------------------------------------------------------- |
---|
85 | |
---|
86 | IF( wrk_in_use(3, 4,5) ) THEN |
---|
87 | CALL ctl_stop('dyn_spg: requested workspace arrays unavailable') ; RETURN |
---|
88 | ENDIF |
---|
89 | |
---|
90 | !!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that |
---|
91 | !!gm they return the after velocity, not the trends (as in trazdf_imp...) |
---|
92 | !!gm In this case, change/simplify dynnxt |
---|
93 | |
---|
94 | |
---|
95 | IF( l_trddyn ) THEN ! temporary save of ta and sa trends |
---|
96 | ztrdu(:,:,:) = ua(:,:,:) |
---|
97 | ztrdv(:,:,:) = va(:,:,:) |
---|
98 | ENDIF |
---|
99 | |
---|
100 | IF( ln_apr_dyn ) THEN !== Atmospheric pressure gradient ==! |
---|
101 | zg_2 = grav * 0.5 |
---|
102 | DO jj = 2, jpjm1 ! gradient of Patm using inverse barometer ssh |
---|
103 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
104 | spgu(ji,jj) = zg_2 * ( ssh_ib (ji+1,jj) - ssh_ib (ji,jj) & |
---|
105 | & + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj) ) /e1u(ji,jj) |
---|
106 | spgv(ji,jj) = zg_2 * ( ssh_ib (ji,jj+1) - ssh_ib (ji,jj) & |
---|
107 | & + ssh_ibb(ji,jj+1) - ssh_ib (ji,jj) ) /e2v(ji,jj) |
---|
108 | END DO |
---|
109 | END DO |
---|
110 | DO jk = 1, jpkm1 ! Add the apg to the general trend |
---|
111 | DO jj = 2, jpjm1 |
---|
112 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
113 | ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj) |
---|
114 | va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj) |
---|
115 | END DO |
---|
116 | END DO |
---|
117 | END DO |
---|
118 | ENDIF |
---|
119 | |
---|
120 | |
---|
121 | SELECT CASE ( nspg ) ! compute surf. pressure gradient trend and add it to the general trend |
---|
122 | ! |
---|
123 | CASE ( 0 ) ; CALL dyn_spg_exp( kt ) ! explicit |
---|
124 | CASE ( 1 ) ; CALL dyn_spg_ts ( kt ) ! time-splitting |
---|
125 | CASE ( 2 ) ; CALL dyn_spg_flt( kt, kindic ) ! filtered |
---|
126 | ! |
---|
127 | CASE ( -1 ) ! esopa: test all possibility with control print |
---|
128 | CALL dyn_spg_exp( kt ) |
---|
129 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg0 - Ua: ', mask1=umask, & |
---|
130 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
131 | CALL dyn_spg_ts ( kt ) |
---|
132 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg1 - Ua: ', mask1=umask, & |
---|
133 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
134 | CALL dyn_spg_flt( kt, kindic ) |
---|
135 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg2 - Ua: ', mask1=umask, & |
---|
136 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
137 | END SELECT |
---|
138 | ! |
---|
139 | IF( l_trddyn ) THEN ! save the surface pressure gradient trends for further diagnostics |
---|
140 | SELECT CASE ( nspg ) |
---|
141 | CASE ( 0, 1 ) |
---|
142 | ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:) |
---|
143 | ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:) |
---|
144 | CASE( 2 ) |
---|
145 | z2dt = 2. * rdt |
---|
146 | IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt |
---|
147 | ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:) |
---|
148 | ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:) |
---|
149 | END SELECT |
---|
150 | CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_spg, 'DYN', kt ) |
---|
151 | ENDIF |
---|
152 | ! ! print mean trends (used for debugging) |
---|
153 | IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' spg - Ua: ', mask1=umask, & |
---|
154 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
155 | ! |
---|
156 | IF( wrk_not_released(3, 4,5) ) CALL ctl_stop('dyn_spg: failed to release workspace arrays') |
---|
157 | ! |
---|
158 | END SUBROUTINE dyn_spg |
---|
159 | |
---|
160 | |
---|
161 | SUBROUTINE dyn_spg_init |
---|
162 | !!--------------------------------------------------------------------- |
---|
163 | !! *** ROUTINE dyn_spg_init *** |
---|
164 | !! |
---|
165 | !! ** Purpose : Control the consistency between cpp options for |
---|
166 | !! surface pressure gradient schemes |
---|
167 | !!---------------------------------------------------------------------- |
---|
168 | INTEGER :: ioptio |
---|
169 | !!---------------------------------------------------------------------- |
---|
170 | |
---|
171 | IF(lwp) THEN ! Control print |
---|
172 | WRITE(numout,*) |
---|
173 | WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme' |
---|
174 | WRITE(numout,*) '~~~~~~~~~~~' |
---|
175 | WRITE(numout,*) ' Explicit free surface lk_dynspg_exp = ', lk_dynspg_exp |
---|
176 | WRITE(numout,*) ' Free surface with time splitting lk_dynspg_ts = ', lk_dynspg_ts |
---|
177 | WRITE(numout,*) ' Filtered free surface cst volume lk_dynspg_flt = ', lk_dynspg_flt |
---|
178 | ENDIF |
---|
179 | |
---|
180 | ! ! allocate dyn_spg arrays |
---|
181 | IF( lk_dynspg_ts ) THEN |
---|
182 | IF( dynspg_oce_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays') |
---|
183 | IF( dyn_spg_ts_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts arrays') |
---|
184 | ENDIF |
---|
185 | |
---|
186 | ! ! Control of surface pressure gradient scheme options |
---|
187 | ioptio = 0 |
---|
188 | IF(lk_dynspg_exp) ioptio = ioptio + 1 |
---|
189 | IF(lk_dynspg_ts ) ioptio = ioptio + 1 |
---|
190 | IF(lk_dynspg_flt) ioptio = ioptio + 1 |
---|
191 | ! |
---|
192 | IF( ( ioptio > 1 .AND. .NOT. lk_esopa ) .OR. ioptio == 0 ) & |
---|
193 | & CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' ) |
---|
194 | ! |
---|
195 | IF( lk_esopa ) nspg = -1 |
---|
196 | IF( lk_dynspg_exp) nspg = 0 |
---|
197 | IF( lk_dynspg_ts ) nspg = 1 |
---|
198 | IF( lk_dynspg_flt) nspg = 2 |
---|
199 | ! |
---|
200 | IF( lk_esopa ) nspg = -1 |
---|
201 | ! |
---|
202 | IF(lwp) THEN |
---|
203 | WRITE(numout,*) |
---|
204 | IF( nspg == -1 ) WRITE(numout,*) ' ESOPA test All scheme used' |
---|
205 | IF( nspg == 0 ) WRITE(numout,*) ' explicit free surface' |
---|
206 | IF( nspg == 1 ) WRITE(numout,*) ' free surface with time splitting scheme' |
---|
207 | IF( nspg == 2 ) WRITE(numout,*) ' filtered free surface' |
---|
208 | ENDIF |
---|
209 | |
---|
210 | #if defined key_dynspg_flt || defined key_esopa |
---|
211 | CALL solver_init( nit000 ) ! Elliptic solver initialisation |
---|
212 | #endif |
---|
213 | |
---|
214 | ! ! Control of timestep choice |
---|
215 | IF( lk_dynspg_ts .OR. lk_dynspg_exp ) THEN |
---|
216 | IF( nn_cla == 1 ) CALL ctl_stop( 'Crossland advection not implemented for this free surface formulation' ) |
---|
217 | ENDIF |
---|
218 | |
---|
219 | ! ! Control of momentum formulation |
---|
220 | IF( lk_dynspg_ts .AND. lk_vvl ) THEN |
---|
221 | IF( .NOT.ln_dynadv_vec ) CALL ctl_stop( 'Flux form not implemented for this free surface formulation' ) |
---|
222 | ENDIF |
---|
223 | |
---|
224 | #if defined key_obc |
---|
225 | ! ! Conservation of ocean volume (key_dynspg_flt) |
---|
226 | IF( lk_dynspg_flt ) ln_vol_cst = .true. |
---|
227 | |
---|
228 | ! ! Application of Flather's algorithm at open boundaries |
---|
229 | IF( lk_dynspg_flt ) ln_obc_fla = .false. |
---|
230 | IF( lk_dynspg_exp ) ln_obc_fla = .true. |
---|
231 | IF( lk_dynspg_ts ) ln_obc_fla = .true. |
---|
232 | #endif |
---|
233 | ! |
---|
234 | END SUBROUTINE dyn_spg_init |
---|
235 | |
---|
236 | !!====================================================================== |
---|
237 | END MODULE dynspg |
---|