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 sbc_oce ! surface boundary condition: ocean |
---|
18 | USE sbcapr ! surface boundary condition: atmospheric pressure |
---|
19 | USE dynspg_oce ! surface pressure gradient variables |
---|
20 | USE dynspg_exp ! surface pressure gradient (dyn_spg_exp routine) |
---|
21 | USE dynspg_ts ! surface pressure gradient (dyn_spg_ts routine) |
---|
22 | USE dynspg_flt ! surface pressure gradient (dyn_spg_flt routine) |
---|
23 | USE dynadv ! dynamics: vector invariant versus flux form |
---|
24 | USE trdmod ! ocean dynamics trends |
---|
25 | USE trdmod_oce ! ocean variables trends |
---|
26 | USE prtctl ! Print control (prt_ctl routine) |
---|
27 | USE in_out_manager ! I/O manager |
---|
28 | USE lib_mpp ! MPP library |
---|
29 | USE solver ! solver initialization |
---|
30 | USE wrk_nemo ! Memory Allocation |
---|
31 | USE timing ! Timing |
---|
32 | |
---|
33 | |
---|
34 | IMPLICIT NONE |
---|
35 | PRIVATE |
---|
36 | |
---|
37 | PUBLIC dyn_spg ! routine called by step module |
---|
38 | PUBLIC dyn_spg_init ! routine called by opa module |
---|
39 | |
---|
40 | INTEGER :: nspg = 0 ! type of surface pressure gradient scheme defined from lk_dynspg_... |
---|
41 | |
---|
42 | !! * Substitutions |
---|
43 | # include "domzgr_substitute.h90" |
---|
44 | # include "vectopt_loop_substitute.h90" |
---|
45 | !!---------------------------------------------------------------------- |
---|
46 | !! NEMO/OPA 3.2 , LODYC-IPSL (2009) |
---|
47 | !! $Id: dynspg.F90 3322 2012-03-06 16:44:02Z rfurner $ |
---|
48 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
49 | !!---------------------------------------------------------------------- |
---|
50 | CONTAINS |
---|
51 | |
---|
52 | SUBROUTINE dyn_spg( kt, kindic ) |
---|
53 | !!---------------------------------------------------------------------- |
---|
54 | !! *** ROUTINE dyn_spg *** |
---|
55 | !! |
---|
56 | !! ** Purpose : achieve the momentum time stepping by computing the |
---|
57 | !! last trend, the surface pressure gradient including the |
---|
58 | !! atmospheric pressure forcing (ln_apr_dyn=T), and performing |
---|
59 | !! the Leap-Frog integration. |
---|
60 | !!gm In the current version only the filtered solution provide |
---|
61 | !!gm the after velocity, in the 2 other (ua,va) are still the trends |
---|
62 | !! |
---|
63 | !! ** Method : Three schemes: |
---|
64 | !! - explicit computation : the spg is evaluated at now |
---|
65 | !! - filtered computation : the Roulet & madec (2000) technique is used |
---|
66 | !! - split-explicit computation: a time splitting technique is used |
---|
67 | !! |
---|
68 | !! ln_apr_dyn=T : the atmospheric pressure forcing is applied |
---|
69 | !! as the gradient of the inverse barometer ssh: |
---|
70 | !! apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb] |
---|
71 | !! apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb] |
---|
72 | !! Note that as all external forcing a time averaging over a two rdt |
---|
73 | !! period is used to prevent the divergence of odd and even time step. |
---|
74 | !! |
---|
75 | !! N.B. : When key_esopa is used all the scheme are tested, regardless |
---|
76 | !! of the physical meaning of the results. |
---|
77 | !!---------------------------------------------------------------------- |
---|
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 | REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdu, ztrdv |
---|
85 | !!---------------------------------------------------------------------- |
---|
86 | ! |
---|
87 | IF( nn_timing == 1 ) CALL timing_start('dyn_spg') |
---|
88 | ! |
---|
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 | CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv ) |
---|
97 | ztrdu(:,:,:) = ua(:,:,:) |
---|
98 | ztrdv(:,:,:) = va(:,:,:) |
---|
99 | ENDIF |
---|
100 | |
---|
101 | IF( ln_apr_dyn ) THEN !== Atmospheric pressure gradient ==! |
---|
102 | zg_2 = grav * 0.5 |
---|
103 | DO jj = 2, jpjm1 ! gradient of Patm using inverse barometer ssh |
---|
104 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
105 | spgu(ji,jj) = zg_2 * ( ssh_ib (ji+1,jj) - ssh_ib (ji,jj) & |
---|
106 | & + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj) ) /e1u(ji,jj) |
---|
107 | spgv(ji,jj) = zg_2 * ( ssh_ib (ji,jj+1) - ssh_ib (ji,jj) & |
---|
108 | & + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj) ) /e2v(ji,jj) |
---|
109 | END DO |
---|
110 | END DO |
---|
111 | DO jk = 1, jpkm1 ! Add the apg to the general trend |
---|
112 | DO jj = 2, jpjm1 |
---|
113 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
114 | ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj) |
---|
115 | va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj) |
---|
116 | END DO |
---|
117 | END DO |
---|
118 | END DO |
---|
119 | ENDIF |
---|
120 | |
---|
121 | |
---|
122 | SELECT CASE ( nspg ) ! compute surf. pressure gradient trend and add it to the general trend |
---|
123 | ! |
---|
124 | CASE ( 0 ) ; CALL dyn_spg_exp( kt ) ! explicit |
---|
125 | CASE ( 1 ) ; CALL dyn_spg_ts ( kt ) ! time-splitting |
---|
126 | CASE ( 2 ) ; CALL dyn_spg_flt( kt, kindic ) ! filtered |
---|
127 | ! |
---|
128 | CASE ( -1 ) ! esopa: test all possibility with control print |
---|
129 | CALL dyn_spg_exp( kt ) |
---|
130 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg0 - Ua: ', mask1=umask, & |
---|
131 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
132 | CALL dyn_spg_ts ( kt ) |
---|
133 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg1 - Ua: ', mask1=umask, & |
---|
134 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
135 | CALL dyn_spg_flt( kt, kindic ) |
---|
136 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg2 - Ua: ', mask1=umask, & |
---|
137 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
138 | END SELECT |
---|
139 | ! |
---|
140 | IF( l_trddyn ) THEN ! save the surface pressure gradient trends for further diagnostics |
---|
141 | SELECT CASE ( nspg ) |
---|
142 | CASE ( 0, 1 ) |
---|
143 | ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:) |
---|
144 | ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:) |
---|
145 | CASE( 2 ) |
---|
146 | z2dt = 2. * rdt |
---|
147 | IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt |
---|
148 | ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:) |
---|
149 | ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:) |
---|
150 | END SELECT |
---|
151 | CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_spg, 'DYN', kt ) |
---|
152 | ! |
---|
153 | CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) |
---|
154 | ENDIF |
---|
155 | ! ! print mean trends (used for debugging) |
---|
156 | IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' spg - Ua: ', mask1=umask, & |
---|
157 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
158 | ! |
---|
159 | IF( nn_timing == 1 ) CALL timing_stop('dyn_spg') |
---|
160 | ! |
---|
161 | END SUBROUTINE dyn_spg |
---|
162 | |
---|
163 | |
---|
164 | SUBROUTINE dyn_spg_init |
---|
165 | !!--------------------------------------------------------------------- |
---|
166 | !! *** ROUTINE dyn_spg_init *** |
---|
167 | !! |
---|
168 | !! ** Purpose : Control the consistency between cpp options for |
---|
169 | !! surface pressure gradient schemes |
---|
170 | !!---------------------------------------------------------------------- |
---|
171 | INTEGER :: ioptio |
---|
172 | !!---------------------------------------------------------------------- |
---|
173 | ! |
---|
174 | IF( nn_timing == 1 ) CALL timing_start('dyn_spg_init') |
---|
175 | ! |
---|
176 | IF(lwp) THEN ! Control print |
---|
177 | WRITE(numout,*) |
---|
178 | WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme' |
---|
179 | WRITE(numout,*) '~~~~~~~~~~~' |
---|
180 | WRITE(numout,*) ' Explicit free surface lk_dynspg_exp = ', lk_dynspg_exp |
---|
181 | WRITE(numout,*) ' Free surface with time splitting lk_dynspg_ts = ', lk_dynspg_ts |
---|
182 | WRITE(numout,*) ' Filtered free surface cst volume lk_dynspg_flt = ', lk_dynspg_flt |
---|
183 | ENDIF |
---|
184 | |
---|
185 | ! ! allocate dyn_spg arrays |
---|
186 | IF( lk_dynspg_ts ) THEN |
---|
187 | IF( dynspg_oce_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays') |
---|
188 | IF( dyn_spg_ts_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts arrays') |
---|
189 | ENDIF |
---|
190 | |
---|
191 | ! ! Control of surface pressure gradient scheme options |
---|
192 | ioptio = 0 |
---|
193 | IF(lk_dynspg_exp) ioptio = ioptio + 1 |
---|
194 | IF(lk_dynspg_ts ) ioptio = ioptio + 1 |
---|
195 | IF(lk_dynspg_flt) ioptio = ioptio + 1 |
---|
196 | ! |
---|
197 | IF( ( ioptio > 1 .AND. .NOT. lk_esopa ) .OR. ioptio == 0 ) & |
---|
198 | & CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' ) |
---|
199 | ! |
---|
200 | IF( lk_esopa ) nspg = -1 |
---|
201 | IF( lk_dynspg_exp) nspg = 0 |
---|
202 | IF( lk_dynspg_ts ) nspg = 1 |
---|
203 | IF( lk_dynspg_flt) nspg = 2 |
---|
204 | ! |
---|
205 | IF( lk_esopa ) nspg = -1 |
---|
206 | ! |
---|
207 | IF(lwp) THEN |
---|
208 | WRITE(numout,*) |
---|
209 | IF( nspg == -1 ) WRITE(numout,*) ' ESOPA test All scheme used' |
---|
210 | IF( nspg == 0 ) WRITE(numout,*) ' explicit free surface' |
---|
211 | IF( nspg == 1 ) WRITE(numout,*) ' free surface with time splitting scheme' |
---|
212 | IF( nspg == 2 ) WRITE(numout,*) ' filtered free surface' |
---|
213 | ENDIF |
---|
214 | |
---|
215 | #if defined key_dynspg_flt || defined key_esopa |
---|
216 | CALL solver_init( nit000 ) ! Elliptic solver initialisation |
---|
217 | #endif |
---|
218 | |
---|
219 | ! ! Control of timestep choice |
---|
220 | IF( lk_dynspg_ts .OR. lk_dynspg_exp ) THEN |
---|
221 | IF( nn_cla == 1 ) CALL ctl_stop( 'Crossland advection not implemented for this free surface formulation' ) |
---|
222 | ENDIF |
---|
223 | |
---|
224 | ! ! Control of momentum formulation |
---|
225 | IF( lk_dynspg_ts .AND. lk_vvl ) THEN |
---|
226 | IF( .NOT.ln_dynadv_vec ) CALL ctl_stop( 'Flux form not implemented for this free surface formulation' ) |
---|
227 | ENDIF |
---|
228 | ! |
---|
229 | IF( nn_timing == 1 ) CALL timing_stop('dyn_spg_init') |
---|
230 | ! |
---|
231 | END SUBROUTINE dyn_spg_init |
---|
232 | |
---|
233 | !!====================================================================== |
---|
234 | END MODULE dynspg |
---|