[358] | 1 | MODULE dynspg |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE dynspg *** |
---|
| 4 | !! Ocean dynamics: surface pressure gradient control |
---|
| 5 | !!====================================================================== |
---|
[1566] | 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 |
---|
[503] | 8 | !!---------------------------------------------------------------------- |
---|
[358] | 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 |
---|
[2715] | 16 | USE phycst ! physical constants |
---|
[2528] | 17 | USE sbc_oce ! surface boundary condition: ocean |
---|
| 18 | USE sbcapr ! surface boundary condition: atmospheric pressure |
---|
[367] | 19 | USE dynspg_oce ! surface pressure gradient variables |
---|
[358] | 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) |
---|
[2528] | 23 | USE dynadv ! dynamics: vector invariant versus flux form |
---|
[358] | 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 |
---|
[2715] | 28 | USE lib_mpp ! MPP library |
---|
| 29 | USE solver ! solver initialization |
---|
[3294] | 30 | USE wrk_nemo ! Memory Allocation |
---|
| 31 | USE timing ! Timing |
---|
[358] | 32 | |
---|
[3294] | 33 | |
---|
[358] | 34 | IMPLICIT NONE |
---|
| 35 | PRIVATE |
---|
| 36 | |
---|
[2528] | 37 | PUBLIC dyn_spg ! routine called by step module |
---|
| 38 | PUBLIC dyn_spg_init ! routine called by opa module |
---|
[358] | 39 | |
---|
[503] | 40 | INTEGER :: nspg = 0 ! type of surface pressure gradient scheme defined from lk_dynspg_... |
---|
[358] | 41 | |
---|
| 42 | !! * Substitutions |
---|
| 43 | # include "domzgr_substitute.h90" |
---|
| 44 | # include "vectopt_loop_substitute.h90" |
---|
| 45 | !!---------------------------------------------------------------------- |
---|
[1566] | 46 | !! NEMO/OPA 3.2 , LODYC-IPSL (2009) |
---|
[1152] | 47 | !! $Id$ |
---|
[2715] | 48 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[358] | 49 | !!---------------------------------------------------------------------- |
---|
| 50 | CONTAINS |
---|
| 51 | |
---|
| 52 | SUBROUTINE dyn_spg( kt, kindic ) |
---|
| 53 | !!---------------------------------------------------------------------- |
---|
| 54 | !! *** ROUTINE dyn_spg *** |
---|
| 55 | !! |
---|
[1566] | 56 | !! ** Purpose : achieve the momentum time stepping by computing the |
---|
[2528] | 57 | !! last trend, the surface pressure gradient including the |
---|
| 58 | !! atmospheric pressure forcing (ln_apr_dyn=T), and performing |
---|
[1566] | 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 | !! |
---|
[2528] | 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 | !! |
---|
[1566] | 75 | !! N.B. : When key_esopa is used all the scheme are tested, regardless |
---|
| 76 | !! of the physical meaning of the results. |
---|
[358] | 77 | !!---------------------------------------------------------------------- |
---|
[2715] | 78 | ! |
---|
[1566] | 79 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
| 80 | INTEGER, INTENT( out) :: kindic ! solver flag |
---|
[2715] | 81 | ! |
---|
[2528] | 82 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
[3625] | 83 | REAL(wp) :: z2dt, zg_2, zintp, zgrau0r ! temporary scalar |
---|
[3294] | 84 | REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdu, ztrdv |
---|
[3625] | 85 | REAL(wp), POINTER, DIMENSION(:,:) :: zpice |
---|
[358] | 86 | !!---------------------------------------------------------------------- |
---|
[3294] | 87 | ! |
---|
| 88 | IF( nn_timing == 1 ) CALL timing_start('dyn_spg') |
---|
| 89 | ! |
---|
[358] | 90 | |
---|
[1566] | 91 | !!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that |
---|
| 92 | !!gm they return the after velocity, not the trends (as in trazdf_imp...) |
---|
| 93 | !!gm In this case, change/simplify dynnxt |
---|
| 94 | |
---|
| 95 | |
---|
[358] | 96 | IF( l_trddyn ) THEN ! temporary save of ta and sa trends |
---|
[3294] | 97 | CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv ) |
---|
[358] | 98 | ztrdu(:,:,:) = ua(:,:,:) |
---|
| 99 | ztrdv(:,:,:) = va(:,:,:) |
---|
| 100 | ENDIF |
---|
| 101 | |
---|
[2528] | 102 | IF( ln_apr_dyn ) THEN !== Atmospheric pressure gradient ==! |
---|
| 103 | zg_2 = grav * 0.5 |
---|
| 104 | DO jj = 2, jpjm1 ! gradient of Patm using inverse barometer ssh |
---|
| 105 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 106 | spgu(ji,jj) = zg_2 * ( ssh_ib (ji+1,jj) - ssh_ib (ji,jj) & |
---|
| 107 | & + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj) ) /e1u(ji,jj) |
---|
| 108 | spgv(ji,jj) = zg_2 * ( ssh_ib (ji,jj+1) - ssh_ib (ji,jj) & |
---|
[3322] | 109 | & + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj) ) /e2v(ji,jj) |
---|
[2528] | 110 | END DO |
---|
| 111 | END DO |
---|
| 112 | DO jk = 1, jpkm1 ! Add the apg to the general trend |
---|
| 113 | DO jj = 2, jpjm1 |
---|
| 114 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 115 | ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj) |
---|
| 116 | va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj) |
---|
| 117 | END DO |
---|
| 118 | END DO |
---|
| 119 | END DO |
---|
| 120 | ENDIF |
---|
| 121 | |
---|
[3625] | 122 | IF( nn_ice_embd == 2 ) THEN !== embedded sea ice: Pressure gradient due to snow-ice mass ==! |
---|
| 123 | CALL wrk_alloc( jpi, jpj, zpice ) |
---|
| 124 | ! |
---|
| 125 | zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc ) |
---|
| 126 | zgrau0r = - grav * r1_rau0 |
---|
| 127 | zpice(:,:) = ( zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:) ) * zgrau0r |
---|
| 128 | DO jj = 2, jpjm1 |
---|
| 129 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 130 | spgu(ji,jj) = ( zpice(ji+1,jj) - zpice(ji,jj) ) / e1u(ji,jj) |
---|
| 131 | spgv(ji,jj) = ( zpice(ji,jj+1) - zpice(ji,jj) ) / e2v(ji,jj) |
---|
| 132 | END DO |
---|
| 133 | END DO |
---|
| 134 | DO jk = 1, jpkm1 ! Add the surface pressure trend to the general trend |
---|
| 135 | DO jj = 2, jpjm1 |
---|
| 136 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 137 | ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj) |
---|
| 138 | va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj) |
---|
| 139 | END DO |
---|
| 140 | END DO |
---|
| 141 | END DO |
---|
| 142 | ! |
---|
| 143 | CALL wrk_dealloc( jpi, jpj, zpice ) |
---|
| 144 | ENDIF |
---|
[2528] | 145 | |
---|
[3625] | 146 | |
---|
[358] | 147 | SELECT CASE ( nspg ) ! compute surf. pressure gradient trend and add it to the general trend |
---|
[789] | 148 | ! |
---|
[1566] | 149 | CASE ( 0 ) ; CALL dyn_spg_exp( kt ) ! explicit |
---|
| 150 | CASE ( 1 ) ; CALL dyn_spg_ts ( kt ) ! time-splitting |
---|
| 151 | CASE ( 2 ) ; CALL dyn_spg_flt( kt, kindic ) ! filtered |
---|
[789] | 152 | ! |
---|
[1566] | 153 | CASE ( -1 ) ! esopa: test all possibility with control print |
---|
| 154 | CALL dyn_spg_exp( kt ) |
---|
| 155 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg0 - Ua: ', mask1=umask, & |
---|
| 156 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
| 157 | CALL dyn_spg_ts ( kt ) |
---|
| 158 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg1 - Ua: ', mask1=umask, & |
---|
| 159 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
| 160 | CALL dyn_spg_flt( kt, kindic ) |
---|
| 161 | CALL prt_ctl( tab3d_1=ua, clinfo1=' spg2 - Ua: ', mask1=umask, & |
---|
| 162 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
[358] | 163 | END SELECT |
---|
[503] | 164 | ! |
---|
[1566] | 165 | IF( l_trddyn ) THEN ! save the surface pressure gradient trends for further diagnostics |
---|
[358] | 166 | SELECT CASE ( nspg ) |
---|
[1528] | 167 | CASE ( 0, 1 ) |
---|
[358] | 168 | ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:) |
---|
| 169 | ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:) |
---|
[1528] | 170 | CASE( 2 ) |
---|
[358] | 171 | z2dt = 2. * rdt |
---|
| 172 | IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt |
---|
| 173 | ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:) |
---|
| 174 | ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:) |
---|
| 175 | END SELECT |
---|
[503] | 176 | CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_spg, 'DYN', kt ) |
---|
[3294] | 177 | ! |
---|
| 178 | CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) |
---|
[358] | 179 | ENDIF |
---|
| 180 | ! ! print mean trends (used for debugging) |
---|
| 181 | IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' spg - Ua: ', mask1=umask, & |
---|
| 182 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
[503] | 183 | ! |
---|
[3294] | 184 | IF( nn_timing == 1 ) CALL timing_stop('dyn_spg') |
---|
[2715] | 185 | ! |
---|
[358] | 186 | END SUBROUTINE dyn_spg |
---|
| 187 | |
---|
| 188 | |
---|
[2528] | 189 | SUBROUTINE dyn_spg_init |
---|
[358] | 190 | !!--------------------------------------------------------------------- |
---|
[2528] | 191 | !! *** ROUTINE dyn_spg_init *** |
---|
[358] | 192 | !! |
---|
| 193 | !! ** Purpose : Control the consistency between cpp options for |
---|
[1566] | 194 | !! surface pressure gradient schemes |
---|
[358] | 195 | !!---------------------------------------------------------------------- |
---|
| 196 | INTEGER :: ioptio |
---|
| 197 | !!---------------------------------------------------------------------- |
---|
[3294] | 198 | ! |
---|
| 199 | IF( nn_timing == 1 ) CALL timing_start('dyn_spg_init') |
---|
| 200 | ! |
---|
[1566] | 201 | IF(lwp) THEN ! Control print |
---|
[358] | 202 | WRITE(numout,*) |
---|
[2528] | 203 | WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme' |
---|
[358] | 204 | WRITE(numout,*) '~~~~~~~~~~~' |
---|
| 205 | WRITE(numout,*) ' Explicit free surface lk_dynspg_exp = ', lk_dynspg_exp |
---|
| 206 | WRITE(numout,*) ' Free surface with time splitting lk_dynspg_ts = ', lk_dynspg_ts |
---|
| 207 | WRITE(numout,*) ' Filtered free surface cst volume lk_dynspg_flt = ', lk_dynspg_flt |
---|
| 208 | ENDIF |
---|
| 209 | |
---|
[2715] | 210 | ! ! allocate dyn_spg arrays |
---|
| 211 | IF( lk_dynspg_ts ) THEN |
---|
| 212 | IF( dynspg_oce_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays') |
---|
| 213 | IF( dyn_spg_ts_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts arrays') |
---|
| 214 | ENDIF |
---|
| 215 | |
---|
[1566] | 216 | ! ! Control of surface pressure gradient scheme options |
---|
[358] | 217 | ioptio = 0 |
---|
| 218 | IF(lk_dynspg_exp) ioptio = ioptio + 1 |
---|
| 219 | IF(lk_dynspg_ts ) ioptio = ioptio + 1 |
---|
| 220 | IF(lk_dynspg_flt) ioptio = ioptio + 1 |
---|
[1566] | 221 | ! |
---|
[474] | 222 | IF( ( ioptio > 1 .AND. .NOT. lk_esopa ) .OR. ioptio == 0 ) & |
---|
| 223 | & CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' ) |
---|
[1566] | 224 | ! |
---|
[358] | 225 | IF( lk_esopa ) nspg = -1 |
---|
| 226 | IF( lk_dynspg_exp) nspg = 0 |
---|
| 227 | IF( lk_dynspg_ts ) nspg = 1 |
---|
| 228 | IF( lk_dynspg_flt) nspg = 2 |
---|
[1566] | 229 | ! |
---|
[372] | 230 | IF( lk_esopa ) nspg = -1 |
---|
[1566] | 231 | ! |
---|
| 232 | IF(lwp) THEN |
---|
[358] | 233 | WRITE(numout,*) |
---|
[1528] | 234 | IF( nspg == -1 ) WRITE(numout,*) ' ESOPA test All scheme used' |
---|
[372] | 235 | IF( nspg == 0 ) WRITE(numout,*) ' explicit free surface' |
---|
| 236 | IF( nspg == 1 ) WRITE(numout,*) ' free surface with time splitting scheme' |
---|
| 237 | IF( nspg == 2 ) WRITE(numout,*) ' filtered free surface' |
---|
[358] | 238 | ENDIF |
---|
| 239 | |
---|
[2715] | 240 | #if defined key_dynspg_flt || defined key_esopa |
---|
| 241 | CALL solver_init( nit000 ) ! Elliptic solver initialisation |
---|
| 242 | #endif |
---|
| 243 | |
---|
[1566] | 244 | ! ! Control of timestep choice |
---|
[1241] | 245 | IF( lk_dynspg_ts .OR. lk_dynspg_exp ) THEN |
---|
[2528] | 246 | IF( nn_cla == 1 ) CALL ctl_stop( 'Crossland advection not implemented for this free surface formulation' ) |
---|
[358] | 247 | ENDIF |
---|
| 248 | |
---|
[2528] | 249 | ! ! Control of momentum formulation |
---|
| 250 | IF( lk_dynspg_ts .AND. lk_vvl ) THEN |
---|
| 251 | IF( .NOT.ln_dynadv_vec ) CALL ctl_stop( 'Flux form not implemented for this free surface formulation' ) |
---|
| 252 | ENDIF |
---|
[1566] | 253 | ! |
---|
[3294] | 254 | IF( nn_timing == 1 ) CALL timing_stop('dyn_spg_init') |
---|
| 255 | ! |
---|
[2528] | 256 | END SUBROUTINE dyn_spg_init |
---|
[358] | 257 | |
---|
| 258 | !!====================================================================== |
---|
| 259 | END MODULE dynspg |
---|